From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Paul Durrant <xadimgnik@gmail.com>
Cc: xen-devel@lists.xenproject.org, Henry.Wang@arm.com,
Wei Liu <wl@xen.org>, Jan Beulich <jbeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Kevin Tian <kevin.tian@intel.com>
Subject: Re: [PATCH for-4.17 2/2] hvm/apic: repurpose the reporting of the APIC assist options
Date: Fri, 4 Nov 2022 17:10:22 +0100 [thread overview]
Message-ID: <Y2U5bmp2rsUy2C93@Air-de-Roger> (raw)
In-Reply-To: <9a505567-57be-a7b4-7cab-d1d737172db0@xen.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@citrix.com>
> > > > ---
> > > > 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.
next prev parent reply other threads:[~2022-11-04 16:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 14:22 [PATCH for-4.17 0/2] vapic: followup from assisted APIC series Roger Pau Monne
2022-11-04 14:22 ` [PATCH for-4.17 1/2] viridian: suggest MSR APIC accesses if MSR accesses are accelerated Roger Pau Monne
2022-11-04 15:50 ` Paul Durrant
2022-11-04 14:22 ` [PATCH for-4.17 2/2] hvm/apic: repurpose the reporting of the APIC assist options Roger Pau Monne
2022-11-04 15:55 ` Paul Durrant
2022-11-04 16:01 ` Roger Pau Monné
2022-11-04 16:05 ` Paul Durrant
2022-11-04 16:10 ` Roger Pau Monné [this message]
2022-11-04 17:35 ` Paul Durrant
2022-11-08 10:03 ` Roger Pau Monné
2022-11-04 15:03 ` [PATCH for-4.17 0/2] vapic: followup from assisted APIC series Henry Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y2U5bmp2rsUy2C93@Air-de-Roger \
--to=roger.pau@citrix.com \
--cc=Henry.Wang@arm.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=wl@xen.org \
--cc=xadimgnik@gmail.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.