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

Re: [PATCH v1 00/28] x86: initial SVM AVIC support


  • To: dmukhin@xxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 20 Nov 2026 15:47:15 +0000
  • 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=la+mP9ftGBKDpYTmR2zMy5E6U0eJ7d3p0TotaxhSGrE=; b=pSkURoimHOw+6ywlrfUhmXdIj7DFvG0lTQJCRUTT9C9xSkgEmZhIRlV+TjsKxica9sM56w2DXW/DyqNn3FPK46KKHsqY5rYHZ1i5BHELhp2qh1B8xjAzPvxW/uoaPsOsp0SiqYW9D3Qlu35Y3osKP9PEgvuzgSvcYpls5vPQJv46NSHP8QV8W3Jxp1whUeO/BS94m16Ee9ZFkBKMMn3ajc1I/H119rw6UsR/lbP7rDD0BdVp9ko+YdQgnYonEgI2Dj97tixD+IbB3F1bPuaKmtCQL24x4ewPxEexNXgn4kG24utuTgXSF+6loYjyy8RuCLx1Dy2A1JKSfUA4SmjqGw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q9eV3UgaxIpzWBAQOVb8j/0JKc58H27HiCaLJzvvC/k2nSJQ1c1HRS8A9OKTYr+KL92OPNI1Hhkh41puvyXDjoWxlQlij0DjxJ7OvvHFe0X9xXwTN7IFFxfsy7sFnb4eHVREaN5IJOqTt490P2Owq9mfABivGU8zNpUrDGa9cQZNi1l/tx3xYFzGK0KLD0U+iGziqhakisa8vPAbO9UJTghOtuSYnhqtV069U81TPJX0tu4lT5PqXyQA+12aH1RWoIkVOz0xYNWtz/q5jF2GIeWIFqZjdL/qtdB7zxkHMI/bk9YrviZnYUgigIt7LORxX8vYrS9BXPAiHsYjKauqsA==
  • 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;
  • Autocrypt: addr=andrew.cooper3@xxxxxxxxxx; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQ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klmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, jason.andryuk@xxxxxxx, jbeulich@xxxxxxxx, roger@xxxxxxxxxxxxxx, teddy.astie@xxxxxxxxxx, dmukhin@xxxxxxx
  • Delivery-date: Fri, 20 Nov 2026 15:47:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05/11/2026 1:33 am, dmukhin@xxxxxxxx wrote:
> Patch Series
> ============
>
> Basically the entire work is divided into three big series:
>  (A) Current series: initial SVM AVIC [5]
>  (B) XTF interrupt latency test [6]
>  (C) XTF infra in public CI [5]
>
> For this AVIC series:
>
>  Patches 1, 5, 6, 9, 11-16 introduce various cleanups and fixups.
>
>  Patch 20 changes XEN_DOMCTL_debug_op implementation to allow
>  more debug operations added (like enabling/disabling AVIC at
>  run-time - used by the XTF test).
>
>  Patches 2, 3, 4, 7, 8, 10, 17, 18-25 represent AVIC implementation
>  including performance counters and run-time controls via debug
>  hypercall.
>
>  Patches 26-28 cover various documentation updates.

Sorry this reply has taken longer to get to than I had intended.  I have
committed a couple of trivial patches, but I think the rest of the work
is going to take a bit more complicated rearranging.

First of all, I think there are two areas where we want to take other
pending work as prerequisite.

1) Moving the SVM/SEV leaves into CPU Policy.  (Series of mine needing
dusting off and re-posting.)

In patch 4, you introduce a new command line option.  I know Intel has
one, but it is part of a bigger anti-pattern we're trying to remove. 
Wit the SVM leaf in policy, `cpuid=no-avic` on the command line will
work to hide the feature from Xen, and without much effort we can make
`cpuid=avic` work as an opt-in until it's enabled by default.

Also my series removes the SVM_FEATURE_* constants (they'll be
auto-generated now), which simplifies your earlier patches.

2) Removing the vcpu_id <-> apic_id relation.  (Series of Alejandro's,
or at least the first part of it, needing dusting off and re-posting.)

In patch 7, you encode the guest's APIC_ID as it's vCPU ID * 2.  Yes
this is currently true, but we're desperately trying to break this bogus
relation.  It prohibits providing a sane topology to guests, and is one
of the hard limits on HVM_MAX_VCPUs being 128.

Alejandro did a series making topology selection work.  The first half
of it at least gets into a position where the toolstack chooses the
APIC_IDs and we've got a proper variable in Xen with which to derive
everything else from.  Getting at least this sorted will give you a
proper base to build the logical/physical table upon.

3) (Bonus).  We need to take a decision on whether we're going to block
writes to APIC_ID in xAPIC mode or not.  I sent an RFC patch.  If we do
decide to block writes to APIC_ID in xAPIC mode, then it means the
logical/physical table is static for the lifetime of the domain.


Now for some feedback in no specific order

a) Please have one single patch adding all the architectural enumeration
in one go (CPUID, VMCB, etc).  i.e. merge parts of patch 2, 3 and 7.  (I
have your patch 7 rebased over the VMCB cleanup which was merged after
posting).  I find this helpful when reviewing because it separates "what
is needed for the hardware" from "what is just internal book-keeping".

b) In patch 4 you have a single static avic_apic_access_page[].  That
was XSA-412 (3b5beaf49033cd).

It's actually worse on AMD.  On Intel, any writes targeting a
non-register part of the backing page are discarded.  On AMD, they're
deposited in the backing page.  So, this page *must* be allocated per
domain, and not global.

c) AMD has extensions to the APIC spec.  AVIC even accelerates some of
these, and you feed the accesses into the current vlapic
infrastructure.   For current CPUs, at a minimum that means reverting
changes to eLVTs, but I think more generally we should probably have a
CPU generation check during init and refuse to turn on AVIC until a
human has checked which new hardware features leak through.

d) One very fun bug with AVIC is that a misaligned xmm store can write
to two different registers at once (ymm can hit 3, and zmm can hit 5). 
The whole write gets deposited (contrary to Intel, which explicitly
discards outside of the first register hit), but only one VMExit
occurs.  This allows the guest to write reserved bits.  We need to
confirm that nothing in Xen is going to malfunction (e.g. check for
BUG_ON()'s/etc. which ought to be downgraded to domain_crash()/etc.)
because of finding non-architectural state.

e) You've got a number of fixes for interrupt-related things.  I think
we need to get those fixed first and with robust testing in place before
trying to add AVIC in on top.  I'll see about dusting off an XTF test I
have on the matter, but we really need to fix CR8 handling before
building further.

f) I'm not overly convinced with making use of debugop like that.  For
now, maybe defer it to the end of the series.  I have had several
occasions to need extra hypercalls to make testing happen nicely, so I
think there is room to make something, but I suspect it will want to be
a little different in nature.

I'm sure there's stuff I've missed, but I think this a long enough email
for now.

There's an outstanding question on patch 5.  If you can answer it, I can
commit.

Thanks,

~Andrew



 


Rackspace

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