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

Re: [PATCH] x86/svm: Adjust vNMI handling to update the cleanbit


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Mon, 2 Nov 2026 16:12:37 +0000
  • Accept-language: en-US
  • 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=8RoMvbCCA1f++QeWa/2B/0InoYavQTiFNIh2Id34LG8=; b=YCSCLqDoZvEJd0x3OaVNbOPe2uzKnR+gvmieuhtd/CexDCnkNgmylrUYwge0orOWpKzsnkuK9RvRWq1GOJzW9bd8oytyDmrsuWiFaGxSxyPQcJdl24o98JgiqrXyc8/Tpk6PaywFZdWzfD36Hm2kx7Lls41gH6AwqLacPBn06cwnpT0nLUsHNzOJ/kqaABhv05Hfk0NkMLnldByWv5wxWqcM54KZ5Am8axvKxZ8snfXPJQm9tHP7YZLH2KTTCebAIqW/wXEq7fHp9xreSIMFiYt3ePdELaHZFlzbJvbFlpiutG/nFbUeXm0c4lwp6eSGgk2M7keCFWuaXgIsedJmLA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DyC03YxT2nfalZVmhJAvWCJ0vxRoG0UwvLE5Y3zqRGEjinOYs9Twyd3i0xoxLxtmnt0zYOj8etwrBVrNUOJzloaK0eclRMg6hBnqYgK7CRMLB3E/o2QGZUfy99HFVn88Vzi5XrAvgTIGEwAGrq6JQw6n7Pev120fsD/BBQMeNhp6+vGxJtrR3EUJjdW+tisW4/4HNI/CoYXahQwko5Qbnm/NX9QXjw8NO/xZn4X3u4sPNvqcAthFYKDZnGVdMh7yhRwCI5cC3Js8lvUlJ75CYnA5mZDy7vA3FEZsji2juz75vK23G9E+9CpA0/UTcdgK81q64R0rltMWy6UA3k+smA==
  • 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: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>
  • Delivery-date: Mon, 02 Nov 2026 16:12:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHdatCVxv5aMy5E3UirptM0GAVt0LcazasAgAAmNnw=
  • Thread-topic: [PATCH] x86/svm: Adjust vNMI handling to update the cleanbit

> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> on behalf of Andrew 
> Cooper <andrew.cooper3@xxxxxxxxxx>
> Sent: Monday, November 02, 2026 13:54
> To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>; Jan Beulich 
> <jbeulich@xxxxxxxx>; Roger Pau Monné <roger@xxxxxxxxxxxxxx>; Teddy Astie 
> <teddy.astie@xxxxxxxxxx>; Jason Andryuk <jason.andryuk@xxxxxxx>
> Subject: Re: [PATCH] x86/svm: Adjust vNMI handling to update the cleanbit
>
>
> On 02/11/2026 1:46 pm, Andrew Cooper wrote:
> > Despite prior information to the contrary, APM Vol2 revision 3.46 October 
> > 2026
> > has been adjusted to state that the vNMI fields in vINTR are covered by the
> > TPR cleanbit.
> >
> > Adjust svm_inject_nmi() and svm_set_interrupt_shadow() to use 
> > vmcb_set_vintr()
> > rather than writing into the VMCB directly.
> >
> > In svm_inject_nmi(), fix an inefficiency from the introduction of vNMI.  
> > Move
> > the reading of vmcb_get_general1_intercepts() to the point at which it is
> > used; tt does not need reading on the case that vNMIs are enabled.
> >
> > Fixes: 86a203ab8d38 ("x86/svm: Support vNMI on capable hardware")
> > Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> > ---
> > CC: Jan Beulich <jbeulich@xxxxxxxx>
> > CC: Roger Pau Monné <roger@xxxxxxxxxxxxxx>
> > CC: Teddy Astie <teddy.astie@xxxxxxxxxx>
> > CC: Jason Andryuk <jason.andryuk@xxxxxxx>
>
> I forgot the extra comment.  This bug is hidden by:
>
>     /* The exit may have updated the TPR: reflect this in the hardware
> vtpr */
>     intr = vmcb_get_vintr(vmcb);
>     intr.fields.tpr =
>         (vlapic_get_reg(vlapic, APIC_TASKPRI) & 0xFF) >> 4;
>     vmcb_set_vintr(vmcb, intr);
> }
>
> at the very end of the vmexit handler which unconditionally writes vINTR
> and hits the cleanbit.
>
> This is an absurd codepath.  SVM has virtualised CR8 since the very
> beginning, and put in CR8_LEGACY for Windows to use even in 32bit mode,
> so the only path modifying TPR is a non-accelerated write to APIC_TPR. 
>  That path can be updated to modify vINTR, and this logic dropped.
>
> ~Andrew

The APM says "(Offset 60h–67h)" for this bit in the current and previous
versions. Perhaps that means that more or everything in that range may be
covered by this bit in future? In which case more extensive changes would be
needed to avoid future breakage.

On a related note, I see the APM says this:

> If any VMCB fields (excluding explicitly uncached fields) have been modified,
> all clean bits that are undefined (within the scope of the hypervisor) must be
> cleared to zero.

AFAICT Xen doesn't do this. Might that cause breakage in future?

Ross


 


Rackspace

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