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

Re: [PATCH for-4.17 2/2] hvm/apic: repurpose the reporting of the APIC assist options


  • To: Paul Durrant <xadimgnik@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 8 Nov 2022 11:03:09 +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=arcselector9901; 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=aooQ3uriuBZ1XS8ErDJpsLsMEgoeYZYtKG86JL2P+zg=; b=f2KzYAsxffCvgqgQKl9wH6WPu5frI4n5ZRg9XDgX42ZPhmxaZNtxr0LE8MTtdyNNyy37KVXU1ubguDfFOVMrkwYUzJ2M0vpbl0i0/NB96IuHHdjMG4zU1WG25R7RKxsljdoMfOln8g/v/up3ojbTjBJ/6OkKK8/Q4VqEYM7E1EkuLGa4i9S5zt8QaZp743g7cdnTZ7oa542+swnvKXwjtV4GEOIoltMX34nya5jhj1T1lvg9NjfMJUkvZWA2XR4YywWEF/QTSVibURGYcMYgcVgAIFSSvqzlxcnVyO50Rag2hakYIQ2mHBEjQpnTgFE4gcsKJmbFPQB46zxNcerLcg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L+pP1F7wfgbgpeZlQ1XMAlFNeWM/5tP0wO9iod/e8LmeqsMfJQFOOdNbg3casEq5wvZpoGcFE3L3Xji70Z89U2ZZvrTaOLR3ddGb84FkWDQcC/L6zUcEYg1WfJBlDi7qkTCOl29bgPtX/TSE/J34+OIctLvrs4I3Ulmy1N0HMVqGAt4tf3FmkOKUIjvmO63fAtSRUnGFBeJ6Acojvrimk/OpDY4mzdR9nKCQ62bxAYm5180kSHphieLfeCB5Kcb3Sv6Yf5UqcG6Htv7A7ElsI5EVSYtnn8e6DfTC0GunofLxQWofMWZpqAJpzIhHbb7Kn/ldKvuTgq+ABvHBUWmS2A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Henry.Wang@xxxxxxx, Wei Liu <wl@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Tue, 08 Nov 2022 10:03:32 +0000
  • Ironport-data: A9a23:xugPeKkYu08au3paY4IG/F7o5gx9J0RdPkR7XQ2eYbSJt1+Wr1Gzt xIZXDqPb6uIZGTze4slOt7j808P7JbVyYIxTAJt/n01FyMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6U6icf3grHmeIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE4p7aqaVA8w5ARkP6kS5A+GzhH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 dsSIWgcSy7bvuf18KChbPR1qv55Pta+aevzulk4pd3YJdAPZMmbBonvu5pf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVkVw3ieCwWDbWUoXiqcF9hEGXq 3iA523kKhobKMae2XyO9XfEaurnzX+gCdpDRO3QGvhCiQat4UVIVg8sDVKJj8S1rF+4YsMAA hlBksYphe1onKCxdfHtVhG5pXGCvx00VN9ZEul84waIooLE7gDcCmUaQzppbN09qNRwVTEsz kWOnd7iGXpoqrL9YVKQ8K2F6wy7Pyc9JHUHIyQDSGMt/N3LsIw1yBXVQb5LEqS4k9n0EjHY2 C2RoW41gLB7pcwW0eO99FPOgTOpr7DISBI44kPcWWfNxgB0eo+jIZCp4F7z7PBcIYLfRV6E1 EXogOCb5eEKSJ2IyiqERbxVGKnzvq7YdjrBnVRoAp8tsSy3/GKudpxR5zc4I1p1NsEDenniZ 0q7VR5t2aK/9UCCNcdfC79dwex2pUQ8PbwJjszpU+c=
  • Ironport-hdrordr: A9a23:pHBTOK5xvIMXMBbGhQPXwVqBI+orL9Y04lQ7vn2ZFiY5TiXIra qTdaogviMc6Ax/ZJjvo6HkBEClewKlyXcT2/hrAV7CZniehILMFu1fBOTZowEIdxeOldK1kJ 0QCZSWa+eAcmSS7/yKhzVQeuxIqLfnzEnrv5a5854Ed3AXV0gK1XYcNu/0KDwVeOEQbqBJaa Z0q/A37gZJPh8sH7eGL0hAe9KGi8zAlZrgbxJDLxk76DOWhTftzLLhCRCX0joXTjsKmN4ZgC P4uj28wp/mn+Cwyxfa2WOWx5NKmOH5wt8GIMCXkMAaJhjllw7tToV8XL+puiwzvYiUmR4Xue iJhy1lE9V46nvXcG3wiRzx2zP42DJr0HPmwU/wuwqWneXJABYBT+ZRj4NQdRXUr2A6ustn7a 5N12WF87JKEBLphk3Glpf1fiAvsnDxjWspkOYVgXAae5AZcqVtoYsW+14QOIscHRj99JssHI BVfY3hDc5tABKnhk3izylSKITGZAVxIv7GeDlOhiWt6UkZoJgjpHFohvD2nR87hecAotd/lq H5259T5cFzp/8tHNxA7dg6MLqK40z2MGXx2TGpUCLaPZBCHU7xgLjKx5hwzN2WWfUzvekPcd L6IRlliVI=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Nov 04, 2022 at 05:35:23PM +0000, Paul Durrant wrote:
> On 04/11/2022 16:10, Roger Pau Monné wrote:
> > On Fri, Nov 04, 2022 at 04:05:05PM +0000, Paul Durrant wrote:
> > > On 04/11/2022 16:01, Roger Pau Monné wrote:
> > > > On Fri, Nov 04, 2022 at 03:55:54PM +0000, Paul Durrant wrote:
> > > > > On 04/11/2022 14:22, Roger Pau Monne wrote:
> > > > > > The current reporting of the hardware assisted APIC options is done 
> > > > > > by
> > > > > > checking "virtualize APIC accesses" which is not very helpful, as 
> > > > > > that
> > > > > > feature doesn't avoid a vmexit, instead it does provide some help in
> > > > > > order to detect APIC MMIO accesses in vmexit processing.
> > > > > > 
> > > > > > Repurpose the current reporting of xAPIC assistance to instead 
> > > > > > report
> > > > > > such feature as present when there's support for "TPR shadow" and
> > > > > > "APIC register virtualization" because in that case some xAPIC MMIO
> > > > > > register accesses are handled directly by the hardware, without
> > > > > > requiring a vmexit.
> > > > > > 
> > > > > > For symetry also change assisted x2APIC reporting to require
> > > > > > "virtualize x2APIC mode" and "APIC register virtualization", 
> > > > > > dropping
> > > > > > the option to also be reported when "virtual interrupt delivery" is
> > > > > > available.  Presence of the "virtual interrupt delivery" feature 
> > > > > > will
> > > > > > be reported using a different option.
> > > > > > 
> > > > > > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > > > > > ---
> > > > > > I find the logic in vmx_vlapic_msr_changed() hard to follow, but I
> > > > > > don't want to rewrite the function logic at this point.
> > > > > > ---
> > > > > >     xen/arch/x86/hvm/viridian/viridian.c |  2 +-
> > > > > >     xen/arch/x86/hvm/vmx/vmcs.c          |  8 ++++----
> > > > > >     xen/arch/x86/hvm/vmx/vmx.c           | 25 
> > > > > > ++++++++++++++++++-------
> > > > > >     xen/arch/x86/traps.c                 |  4 +---
> > > > > >     4 files changed, 24 insertions(+), 15 deletions(-)
> > > > > > 
> > > > > > diff --git a/xen/arch/x86/hvm/viridian/viridian.c 
> > > > > > b/xen/arch/x86/hvm/viridian/viridian.c
> > > > > > index c4fa0a8b32..bafd8e90de 100644
> > > > > > --- a/xen/arch/x86/hvm/viridian/viridian.c
> > > > > > +++ b/xen/arch/x86/hvm/viridian/viridian.c
> > > > > > @@ -201,7 +201,7 @@ void cpuid_viridian_leaves(const struct vcpu 
> > > > > > *v, uint32_t leaf,
> > > > > >              * Suggest x2APIC mode by default, unless xAPIC 
> > > > > > registers are hardware
> > > > > >              * virtualized and x2APIC ones aren't.
> > > > > >              */
> > > > > > -        if ( !cpu_has_vmx_apic_reg_virt || 
> > > > > > cpu_has_vmx_virtualize_x2apic_mode )
> > > > > > +        if ( !has_assisted_xapic(d) || has_assisted_x2apic(d) )
> > > > > 
> > > > > So, not sure why this is separated from patch 1 but stated this way 
> > > > > it seems
> > > > > counterintuitive. We only want to use the viridian MSRs if they are 
> > > > > going to
> > > > > be more efficient.. which I think is only in the case where we have 
> > > > > neither
> > > > > an x2apic not an assisted xapic (hence we would trap for MMIO).
> > > > 
> > > > I've read the MS HTLFS and I guess I got confused, the section about
> > > > this CPUID bit states:
> > > > 
> > > > "Bit 3: Recommend using MSRs for accessing APIC registers EOI, ICR and
> > > > TPR rather than their memory-mapped"
> > > > 
> > > > So I've (wrongly) understood that MSRs for accessing APIC registers
> > > > was meant to be a recommendation to use x2APIC mode in order to access
> > > > those registers.  Didn't realize Viridian had a way to expose certain
> > > > APIC registers using MSRs when the APIC is in xAPIC mode.
> > > > 
> > > 
> > > Yeah, I think they predate the existence of x2apic.
> > > 
> > > > I withdraw patch 1 and adjust patch 2 accordingly then.
> > > > 
> > > Cool. Thanks,
> > 
> > How does Windows know whether to use xAPIC or x2APIC?
> > 
> 
> cpuid? TBH I'm not sure why this recommendation would ever trump x2apic
> anyway.

OK, so the recommendation is ignored when running in x2APIC mode,
which should be the default since Xen does always expose x2APIC by
default to guests.

Thanks, Roger.



 


Rackspace

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