[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/x86/hvm: Propagate emulated CR2 writes to the VMCB


  • To: Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxx>
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Wed, 21 Oct 2026 14:11:30 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eMKq2hosY3n2Jkdt8BIfiPZxBfY4uYcPjsGcQxNPe2A=; b=BFh6Zcrf8gC9+KURAnSVrhlV7ZMjjH8TQ6Le7x06G7nnV/vdt7cus1MzV+B16y480pGtMV1NEd+iKnnG8Qn+1Lz/P2zOXpcqTdSCtjP+t8ENo+yz8om92fEkZth5k44QG1RZoINZRcY5FQVetbryqtuAmJ+xr66Dixy5tCc3J+BAA2uRMXFTIht5K8+b094ST6HPuf36ZubpuQSGTKEL+tzUl9vkL+TWC9idDfFpA0DhKQLQtkOZGKw+SeQGqVd+QgfEnGdaNBr5H+SGxTU3EnkyfzvohVKxNT66RJJ0ne3/uu84RFcH3wyv0G4hGUIPNG4bEgGP6TA6skkBSLr36A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mRFVlnUd67sZs0tWj5BMttspFSYmAXUojQrN/wvgcbybpdA+djRUTusVrqblAnn7ajOwo8B9rWznzKYBrFY1yXNgxFIwXkK7psWoRW481rEmhE/zA0iGj7ephRWX6HmAm1ijdO1S1xDIu/N03AAQDnTy9daFfKqBlr2uT9J9YJzbJYYraiskDArKHAMBee1XZqiYu7Sr5Cdj6dgl9j14PEFmh2eP6P8dDu8TRAdJ6ih1LPgUQIO4tlMS1+pqIVfxGCX+VOYQZbIINKVVZQj+RflPlaGvFXy7T3UG+Syvmk0lpkLxN5kzqyPPu6UY6gnFf2Q7E6NKb8FDue5FSBzR6w==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, jbeulich@xxxxxxxx, andrew.cooper3@xxxxxxxxxx, jason.andryuk@xxxxxxx, teddy.astie@xxxxxxxxxx
  • Delivery-date: Wed, 21 Oct 2026 13:12:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 10/21/26 9:19 AM, Roger Pau Monné wrote:
On Tue, Oct 20, 2026 at 02:33:15PM -0700, Stefano Stabellini wrote:
hvmemul_write_cr() updates guest_cr[2] but, unlike every other writer of
it, doesn't call hvm_update_guest_cr(). On SVM, CR2 is loaded from
the VMCB, so the emulated write never reaches the guest, and the next
VMExit overwrites guest_cr[2] with the stale VMCB value.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>

Acked-by: Roger Pau Monné <roger@xxxxxxxxxxxxxx>

I wonder whether there's more missing here, see below.

---
  xen/arch/x86/hvm/emulate.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index c09ea002ec..cd2831d34b 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -2350,6 +2350,7 @@ static int cf_check hvmemul_write_cr(
case 2:
          curr->arch.hvm.guest_cr[2] = val;
+        hvm_update_guest_cr(curr, 2);

Looking at hvm_update_cr(), is this possibly also missing a call to
nestedhvm_set_cr()?

AFAIK the values set by nestedhvm_set_cr() are not used at all with nested SVM
and from a brief look may only be used for CR0 and CR4 for VVMX. So maybe it is
not needed, though for consistency I think it would make sense to replace both
lines with a single call to hvm_update_cr().

Ross



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.