From: Shashank Balaji <shashank.mahadasyam@sony.com>
To: Sohil Mehta <sohil.mehta@intel.com>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Long Li <longli@microsoft.com>,
Ajay Kaher <ajay.kaher@broadcom.com>,
Alexey Makhalov <alexey.makhalov@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Juergen Gross <jgross@suse.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org,
virtualization@lists.linux.dev, jailhouse-dev@googlegroups.com,
kvm@vger.kernel.org, xen-devel@lists.xenproject.org,
Rahul Bukte <rahul.bukte@sony.com>,
Daniel Palmer <daniel.palmer@sony.com>,
Tim Bird <tim.bird@sony.com>
Subject: Re: [PATCH 3/3] x86/virt: rename x2apic_available to x2apic_without_ir_available
Date: Fri, 6 Feb 2026 18:23:53 +0900 [thread overview]
Message-ID: <aYWzKQQTyTZpMAme@JPC00244420> (raw)
In-Reply-To: <ab7f5935-fd5e-4ba5-a97d-5433f241a089@intel.com>
On Thu, Feb 05, 2026 at 04:10:37PM -0800, Sohil Mehta wrote:
> On 2/2/2026 1:51 AM, Shashank Balaji wrote:
> > No functional change.
> >
> > x86_init.hyper.x2apic_available is used only in try_to_enable_x2apic to check if
> > x2apic needs to be disabled if interrupt remapping support isn't present. But
> > the name x2apic_available doesn't reflect that usage.
> >
>
> I don't understand the premise of this patch. Shouldn't the variable
> name reflect what is stored rather than how it is used?
Sorry about the confusion, I should have used '()'.
x86_init.hyper.x2apic_available() is called only in
try_to_enable_x2apic(). Here's the relevant snippet:
static __init void try_to_enable_x2apic(int remap_mode)
{
if (x2apic_state == X2APIC_DISABLED)
return;
if (remap_mode != IRQ_REMAP_X2APIC_MODE) {
u32 apic_limit = 255;
/*
* Using X2APIC without IR is not architecturally supported
* on bare metal but may be supported in guests.
*/
if (!x86_init.hyper.x2apic_available()) {
pr_info("x2apic: IRQ remapping doesn't support X2APIC mode\n");
x2apic_disable();
return;
}
So the question being asked is, "can x2apic be used without IR?", but
the name "x2apic_available" signals "is x2apic available?". I found this
confusing while going through the source.
Most hypervisors set their x2apic_available() implementation to
essentially return if the CPU supports x2apic or not, which is valid
given the name "x2apic_available", but x2apic availability is not what's in
question at the callsite.
> > This is what x2apic_available is set to for various hypervisors:
> >
> > acrn boot_cpu_has(X86_FEATURE_X2APIC)
> > mshyperv boot_cpu_has(X86_FEATURE_X2APIC)
> > xen boot_cpu_has(X86_FEATURE_X2APIC) or false
> > vmware vmware_legacy_x2apic_available
> > kvm kvm_cpuid_base() != 0
> > jailhouse x2apic_enabled()
> > bhyve true
> > default false
> >
>
> If both interrupt remapping and x2apic are enabled, what would the name
> x2apic_without_ir_available signify?
If IR is enabled, then the branch to call x2apic_available() wouldn't be taken :)
So the meaning of x2apic_without_ir_available wouldn't be relevant
anymore.
> A value of "true" would mean x2apic is available without IR. But that
> would be inaccurate for most hypervisors. A value of "false" could be
> interpreted as x2apic is not available, which is also inaccurate.
>
> To me, x2apic_available makes more sense than
> x2apic_without_ir_available based on the values being set by the
> hypervisors.
I agree with you, and I think therein lies the problem. Most hypervisors
are answering the broader question "is x2apic available?", so the name
"x2apic_available" makes sense.
I think further work is required to check if various implementations of
x2apic_available() also need to be changed to reflect the "x2apic
without IR?" semantic, but I don't know enough to do that myself. Maybe
I should have added TODOs above the implementations.
I would like the feedback of the virt folks too on all this, maybe I'm
misinterpreting what's going on here.
> > Bare metal and vmware correctly check if x2apic is available without interrupt
> > remapping. The rest of them check if x2apic is enabled/supported, and kvm just
> > checks if the kernel is running on kvm. The other hypervisors may have to have
> > their checks audited.
> >
> AFAIU, the value on bare metal is set to false because this is a
> hypervisor specific variable. Perhaps I have misunderstood something?
next prev parent reply other threads:[~2026-02-06 9:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 9:51 [PATCH 0/3] x86/x2apic: Fix hang-up of defconfig kernel on resume from s2ram Shashank Balaji
2026-02-02 9:51 ` [PATCH 1/3] x86/x2apic: disable x2apic on resume if the kernel expects so Shashank Balaji
2026-02-02 15:02 ` kernel test robot
2026-02-02 22:31 ` kernel test robot
2026-02-03 0:24 ` Shashank Balaji
2026-02-03 21:08 ` Sohil Mehta
2026-02-04 9:17 ` Shashank Balaji
2026-02-04 18:53 ` Sohil Mehta
2026-02-05 6:07 ` Shashank Balaji
2026-02-05 23:18 ` Sohil Mehta
2026-02-06 3:44 ` Shashank Balaji
2026-02-06 8:57 ` Shashank Balaji
2026-02-07 0:37 ` Sohil Mehta
2026-02-02 9:51 ` [PATCH 2/3] x86/defconfig: add CONFIG_IRQ_REMAP Shashank Balaji
2026-02-02 11:35 ` Andrew Cooper
2026-02-02 11:54 ` Jan Kiszka
2026-02-02 12:12 ` Andrew Cooper
2026-02-02 13:50 ` Jan Kiszka
2026-02-02 9:51 ` [PATCH 3/3] x86/virt: rename x2apic_available to x2apic_without_ir_available Shashank Balaji
2026-02-06 0:10 ` Sohil Mehta
2026-02-06 9:23 ` Shashank Balaji [this message]
2026-02-13 7:39 ` Shashank Balaji
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=aYWzKQQTyTZpMAme@JPC00244420 \
--to=shashank.mahadasyam@sony.com \
--cc=ajay.kaher@broadcom.com \
--cc=alexey.makhalov@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=daniel.palmer@sony.com \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=jailhouse-dev@googlegroups.com \
--cc=jan.kiszka@siemens.com \
--cc=jgross@suse.com \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rahul.bukte@sony.com \
--cc=sohil.mehta@intel.com \
--cc=tglx@kernel.org \
--cc=tim.bird@sony.com \
--cc=virtualization@lists.linux.dev \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
--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.