[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: Fri, 4 Nov 2022 17:10:22 +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=asJu70y7I/TL9/w7H0BuAYOVE6i616taxm6hGN/k5d0=; b=nZYBysQmum2RbkwAjFcOkImaB5AG3ThwJfLWIxKqpqVJnEnUHZXw4gr5vxw0K49f/djA62WEMx3WU2li3Y/yZvvU2ElO4AEcS3BczYJXRJj3of8x6WB9edYKviN2d2Q3kFLDkTYSRlEoX9qSOn9E9Il8OJivRZpk3jTmkdnpAZmxa9EFHzpFMdkWZ3M/jW4z7K07yZjvYtsB6Hjj7OYHZcWoTiokLZ4w1dSQy00Eru24kOdiUeWj6gCJGSFJ6hC/5q6qcMSpavuxiIkgw3fAcXcJINbimoMh6DwK/eqaqrdAPJi1FZlk9TeEio8hGEcipSCa9ur9aEzuZ50rj9faiQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q8goVjkEEh/ARnzoHSVswX75anaWS5jpaD8VNLAPGr61UAhT6NepAOHXoa3/fBfaDEXichs5t3ksCc7yroonsNBy6QEePSbCvD8ZnFXQvXcX8Kq1moInCi8nWsZCHp4fHyVsiVBOsmnGg9a1/SSYSKon2b8ZCADt+YXPsMKPyuKrie4bTBFYrOothPeFUeA+752RAzUxuMZjnxNk2PbE31Cn2WzyrgqEguL5jmq0YGFhoh6rPI1kkvzISl/Zh51IpLEMYoVqK9HSgXRrMiMD8j9FAy+/DELG/3CaGGENeow1BZI5fIzsJeu0wT+irmNCCy2okf1cTuIkP8kdKT+Jew==
  • 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: Fri, 04 Nov 2022 16:10:56 +0000
  • Ironport-data: A9a23:6LEugqCVc09j4RVW/9Tiw5YqxClBgxIJ4kV8jS/XYbTApDhx3zFVx 2NKD22Bb/3bZGH9Lo0gYYWxpxlSuZ6EyIdnQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nNHuCnYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFtcpvlDs15K6o4WpA4gRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwq7tvQnhT5 +0jGQsIUEqFpsuk7u3lRbw57igjBJGD0II3nFhFlW2cIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTK/uxrvAA/zyQouFTpGMDSddGQA91cg26Tp 37c/nS/CRYfXDCa4WreqC332bSf9c/9cNxPH63p7+w0uVKK6WpUBwIxf1Spj+bs3yZSXPoac ST44BEGvaE+9UmkSNj+dxK9qX+A+BUbXrJ4A+A8rQ2A1KfQywKYHXQfCC5MbsQ8s807TiBs0 UWG9/vJCDp1ofuqQHSS3r6OqHW5Pi19BXAGTT8JS00C+daLiIM5gw/LT91jOLWoldCzEjb1q xiIsS54gbwQhMwK0qyT/FbbjjbqrZ/MJiY26xvWWCS57wp/TI+je4Gsr1Pc6J59wJ2xS1CAu D0InpaY5eVWUZWVznTRH6MKAa2j4OuDPHvEm1lzEpI99jOrvXm+YYRX5zI4L0BsWioZRQLUj IbokVs5zPdu0LGCN8ebv6rZ5xwW8JXd
  • Ironport-hdrordr: A9a23:29Aakqp/RkYMZ64xCfE2ft4aV5u5L9V00zEX/kB9WHVpm5Oj+v xGzc5w6farsl0ssREb9uxo9pPwJE800aQFmbX5Wo3SJzUO2VHYVb2KiLGP/9SOIU3DH4JmpM Rdmu1FeafN5DtB/LnHCWuDYrEdKbC8mcjH5Ns2jU0dKz2CA5sQkzuRYTzrdnGeKjM2Z6bQQ/ Gnl7d6TnebCD0qhoPRPAh3Y8Hz4/nw0L72ax8PABAqrCGIkDOT8bb/VzyVxA0XXT9jyaortT GtqX2z2oyT99WAjjPM3W7a6Jpb3PPn19t4HcSJzuwYMC/lhAqEbJloH5eCoDc2iuey70tCqq iFnz4Qe+BIr1/BdGC8phXgnyHmzTYV8nfnjWSVhHPyyPaJMA4SOo5kv8Z0YxHZ400vsJVXy6 RQxV+UsJJREFfpgDn9z8KgbWAkqmOE5V4Z1cIDhX1WVoUTLJVLq5YEwU9TGJAcWArn9YEcFv V0Bs203ocbTbqjVQGZgoBT+q3tYpxqdS32AXTq+/blngS+pUoJgXfxn6ck7zU9HJFUcegw2w 2LCNUsqFh0dL5nUUtMPpZ+fSKJMB29ffvtChPkHb21LtBwB1v977jK3Z4S2MaGPLQ18bpaou WybLofjx95R37T
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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?

I would assume CPUID4A_MSR_BASED_APIC only makes sense when in xAPIC
mode, as otherwise the registers are already accesses using MSRs.

Thanks, Roger.



 


Rackspace

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