* [PATCH 0/2] xen/x86: use extended destination mode if available
@ 2022-01-20 15:25 Roger Pau Monne
2022-01-20 15:25 ` [PATCH 1/2] xen/x2apic: enable x2apic mode when supported Roger Pau Monne
2022-01-20 15:25 ` [PATCH 2/2] xen/x86: detect support for extended destination ID Roger Pau Monne
0 siblings, 2 replies; 8+ messages in thread
From: Roger Pau Monne @ 2022-01-20 15:25 UTC (permalink / raw)
To: linux-kernel; +Cc: Roger Pau Monne
Hello,
Following two patches enable the usage of the extended destination ID if
supported by Xen. This is the same feature already supported by QEMU/KVM
and HyperV.
First patch can probably go in regardless of whether Xen ends up
implementing the extended destination ID, there's no reason to prevent a
VM from using x2APIC mode.
Thanks, Roger.
Roger Pau Monne (2):
xen/x2apic: enable x2apic mode when supported
xen/x86: detect support for extended destination ID
arch/x86/include/asm/xen/cpuid.h | 7 +++++++
arch/x86/xen/enlighten_hvm.c | 9 ++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] xen/x2apic: enable x2apic mode when supported
2022-01-20 15:25 [PATCH 0/2] xen/x86: use extended destination mode if available Roger Pau Monne
@ 2022-01-20 15:25 ` Roger Pau Monne
2022-01-21 1:01 ` Boris Ostrovsky
2022-01-20 15:25 ` [PATCH 2/2] xen/x86: detect support for extended destination ID Roger Pau Monne
1 sibling, 1 reply; 8+ messages in thread
From: Roger Pau Monne @ 2022-01-20 15:25 UTC (permalink / raw)
To: linux-kernel
Cc: Roger Pau Monne, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, xen-devel
There's no point in disabling x2APIC mode when running as a Xen HVM
guest, just enable it when available.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: xen-devel@lists.xenproject.org
---
arch/x86/xen/enlighten_hvm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index 42300941ec29..ab8171cbee23 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -9,6 +9,7 @@
#include <xen/events.h>
#include <xen/interface/memory.h>
+#include <asm/apic.h>
#include <asm/cpu.h>
#include <asm/smp.h>
#include <asm/io_apic.h>
@@ -248,7 +249,7 @@ bool __init xen_hvm_need_lapic(void)
return false;
if (!xen_hvm_domain())
return false;
- if (xen_feature(XENFEAT_hvm_pirqs) && xen_have_vector_callback)
+ if (!x2apic_supported())
return false;
return true;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] xen/x86: detect support for extended destination ID
2022-01-20 15:25 [PATCH 0/2] xen/x86: use extended destination mode if available Roger Pau Monne
2022-01-20 15:25 ` [PATCH 1/2] xen/x2apic: enable x2apic mode when supported Roger Pau Monne
@ 2022-01-20 15:25 ` Roger Pau Monne
2022-02-07 9:03 ` Juergen Gross
1 sibling, 1 reply; 8+ messages in thread
From: Roger Pau Monne @ 2022-01-20 15:25 UTC (permalink / raw)
To: linux-kernel
Cc: Roger Pau Monne, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, xen-devel
Xen allows the usage of some previously reserved bits in the IO-APIC
RTE and the MSI address fields in order to store high bits for the
target APIC ID. Such feature is already implemented by QEMU/KVM and
HyperV, so in order to enable it just add the handler that checks for
it's presence.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Must not be applied until the public headers are changed in Xen.
---
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: xen-devel@lists.xenproject.org
---
arch/x86/include/asm/xen/cpuid.h | 7 +++++++
arch/x86/xen/enlighten_hvm.c | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/arch/x86/include/asm/xen/cpuid.h b/arch/x86/include/asm/xen/cpuid.h
index a9630104f1c4..78e667a31d6c 100644
--- a/arch/x86/include/asm/xen/cpuid.h
+++ b/arch/x86/include/asm/xen/cpuid.h
@@ -100,6 +100,13 @@
/* Memory mapped from other domains has valid IOMMU entries */
#define XEN_HVM_CPUID_IOMMU_MAPPINGS (1u << 2)
#define XEN_HVM_CPUID_VCPU_ID_PRESENT (1u << 3) /* vcpu id is present in EBX */
+#define XEN_HVM_CPUID_DOMID_PRESENT (1u << 4) /* domid is present in ECX */
+/*
+ * Bits 55:49 from the IO-APIC RTE and bits 11:5 from the MSI address can be
+ * used to store high bits for the Destination ID. This expands the Destination
+ * ID field from 8 to 15 bits, allowing to target APIC IDs up 32768.
+ */
+#define XEN_HVM_CPUID_EXT_DEST_ID (1u << 5)
/*
* Leaf 6 (0x40000x05)
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index ab8171cbee23..0c5b0ee3a02a 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -254,6 +254,11 @@ bool __init xen_hvm_need_lapic(void)
return true;
}
+static bool __init msi_ext_dest_id(void)
+{
+ return cpuid_eax(xen_cpuid_base() + 4) & XEN_HVM_CPUID_EXT_DEST_ID;
+}
+
static __init void xen_hvm_guest_late_init(void)
{
#ifdef CONFIG_XEN_PVH
@@ -316,6 +321,7 @@ struct hypervisor_x86 x86_hyper_xen_hvm __initdata = {
.init.x2apic_available = xen_x2apic_para_available,
.init.init_mem_mapping = xen_hvm_init_mem_mapping,
.init.guest_late_init = xen_hvm_guest_late_init,
+ .init.msi_ext_dest_id = msi_ext_dest_id,
.runtime.pin_vcpu = xen_pin_vcpu,
.ignore_nopv = true,
};
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] xen/x2apic: enable x2apic mode when supported
2022-01-20 15:25 ` [PATCH 1/2] xen/x2apic: enable x2apic mode when supported Roger Pau Monne
@ 2022-01-21 1:01 ` Boris Ostrovsky
2022-01-21 9:01 ` [PATCH] xen/x2apic: enable x2apic mode when supported for HVM Roger Pau Monne
0 siblings, 1 reply; 8+ messages in thread
From: Boris Ostrovsky @ 2022-01-21 1:01 UTC (permalink / raw)
To: Roger Pau Monne, linux-kernel
Cc: Juergen Gross, Stefano Stabellini, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, xen-devel
On 1/20/22 10:25 AM, Roger Pau Monne wrote:
> There's no point in disabling x2APIC mode when running as a Xen HVM
> guest, just enable it when available.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: x86@kernel.org
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: xen-devel@lists.xenproject.org
> ---
> arch/x86/xen/enlighten_hvm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
> index 42300941ec29..ab8171cbee23 100644
> --- a/arch/x86/xen/enlighten_hvm.c
> +++ b/arch/x86/xen/enlighten_hvm.c
> @@ -9,6 +9,7 @@
> #include <xen/events.h>
> #include <xen/interface/memory.h>
>
> +#include <asm/apic.h>
> #include <asm/cpu.h>
> #include <asm/smp.h>
> #include <asm/io_apic.h>
> @@ -248,7 +249,7 @@ bool __init xen_hvm_need_lapic(void)
> return false;
> if (!xen_hvm_domain())
> return false;
> - if (xen_feature(XENFEAT_hvm_pirqs) && xen_have_vector_callback)
> + if (!x2apic_supported())
> return false;
> return true;
> }
Then it seems this whole routine can be reduced to just
return x2apic_supported();
and then dropped altogether and x2apic_supported() moved to xen_x2apic_para_available(). Domain type checks here are not really needed since this can only be called on HVM guests.
-boris
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] xen/x2apic: enable x2apic mode when supported for HVM
2022-01-21 1:01 ` Boris Ostrovsky
@ 2022-01-21 9:01 ` Roger Pau Monne
2022-01-21 20:30 ` Boris Ostrovsky
2022-02-03 6:50 ` Juergen Gross
0 siblings, 2 replies; 8+ messages in thread
From: Roger Pau Monne @ 2022-01-21 9:01 UTC (permalink / raw)
To: linux-kernel
Cc: Roger Pau Monne, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, xen-devel
There's no point in disabling x2APIC mode when running as a Xen HVM
guest, just enable it when available.
Remove some unneeded wrapping around the detection functions, and
simply provide a xen_x2apic_available helper that's a wrapper around
x2apic_supported.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
- Remove useless code around x2APIC detection for Xen.
---
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: xen-devel@lists.xenproject.org
---
arch/x86/include/asm/xen/hypervisor.h | 14 --------------
arch/x86/xen/enlighten_hvm.c | 13 ++++---------
2 files changed, 4 insertions(+), 23 deletions(-)
diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index 1bf2ad34188a..16f548a661cf 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -43,20 +43,6 @@ static inline uint32_t xen_cpuid_base(void)
return hypervisor_cpuid_base("XenVMMXenVMM", 2);
}
-#ifdef CONFIG_XEN
-extern bool __init xen_hvm_need_lapic(void);
-
-static inline bool __init xen_x2apic_para_available(void)
-{
- return xen_hvm_need_lapic();
-}
-#else
-static inline bool __init xen_x2apic_para_available(void)
-{
- return (xen_cpuid_base() != 0);
-}
-#endif
-
struct pci_dev;
#ifdef CONFIG_XEN_PV_DOM0
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index 42300941ec29..6448c5071117 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -9,6 +9,7 @@
#include <xen/events.h>
#include <xen/interface/memory.h>
+#include <asm/apic.h>
#include <asm/cpu.h>
#include <asm/smp.h>
#include <asm/io_apic.h>
@@ -242,15 +243,9 @@ static __init int xen_parse_no_vector_callback(char *arg)
}
early_param("xen_no_vector_callback", xen_parse_no_vector_callback);
-bool __init xen_hvm_need_lapic(void)
+static __init bool xen_x2apic_available(void)
{
- if (xen_pv_domain())
- return false;
- if (!xen_hvm_domain())
- return false;
- if (xen_feature(XENFEAT_hvm_pirqs) && xen_have_vector_callback)
- return false;
- return true;
+ return x2apic_supported();
}
static __init void xen_hvm_guest_late_init(void)
@@ -312,7 +307,7 @@ struct hypervisor_x86 x86_hyper_xen_hvm __initdata = {
.detect = xen_platform_hvm,
.type = X86_HYPER_XEN_HVM,
.init.init_platform = xen_hvm_guest_init,
- .init.x2apic_available = xen_x2apic_para_available,
+ .init.x2apic_available = xen_x2apic_available,
.init.init_mem_mapping = xen_hvm_init_mem_mapping,
.init.guest_late_init = xen_hvm_guest_late_init,
.runtime.pin_vcpu = xen_pin_vcpu,
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] xen/x2apic: enable x2apic mode when supported for HVM
2022-01-21 9:01 ` [PATCH] xen/x2apic: enable x2apic mode when supported for HVM Roger Pau Monne
@ 2022-01-21 20:30 ` Boris Ostrovsky
2022-02-03 6:50 ` Juergen Gross
1 sibling, 0 replies; 8+ messages in thread
From: Boris Ostrovsky @ 2022-01-21 20:30 UTC (permalink / raw)
To: Roger Pau Monne, linux-kernel
Cc: Juergen Gross, Stefano Stabellini, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, xen-devel
On 1/21/22 4:01 AM, Roger Pau Monne wrote:
> There's no point in disabling x2APIC mode when running as a Xen HVM
> guest, just enable it when available.
>
> Remove some unneeded wrapping around the detection functions, and
> simply provide a xen_x2apic_available helper that's a wrapper around
> x2apic_supported.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] xen/x2apic: enable x2apic mode when supported for HVM
2022-01-21 9:01 ` [PATCH] xen/x2apic: enable x2apic mode when supported for HVM Roger Pau Monne
2022-01-21 20:30 ` Boris Ostrovsky
@ 2022-02-03 6:50 ` Juergen Gross
1 sibling, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2022-02-03 6:50 UTC (permalink / raw)
To: Roger Pau Monne, linux-kernel
Cc: Boris Ostrovsky, Stefano Stabellini, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
xen-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 437 bytes --]
On 21.01.22 10:01, Roger Pau Monne wrote:
> There's no point in disabling x2APIC mode when running as a Xen HVM
> guest, just enable it when available.
>
> Remove some unneeded wrapping around the detection functions, and
> simply provide a xen_x2apic_available helper that's a wrapper around
> x2apic_supported.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Pushed to xen/tip.git for-linus-5.17a
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xen/x86: detect support for extended destination ID
2022-01-20 15:25 ` [PATCH 2/2] xen/x86: detect support for extended destination ID Roger Pau Monne
@ 2022-02-07 9:03 ` Juergen Gross
0 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2022-02-07 9:03 UTC (permalink / raw)
To: Roger Pau Monne, linux-kernel
Cc: Boris Ostrovsky, Stefano Stabellini, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
xen-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 470 bytes --]
On 20.01.22 16:25, Roger Pau Monne wrote:
> Xen allows the usage of some previously reserved bits in the IO-APIC
> RTE and the MSI address fields in order to store high bits for the
> target APIC ID. Such feature is already implemented by QEMU/KVM and
> HyperV, so in order to enable it just add the handler that checks for
> it's presence.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-02-07 9:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 15:25 [PATCH 0/2] xen/x86: use extended destination mode if available Roger Pau Monne
2022-01-20 15:25 ` [PATCH 1/2] xen/x2apic: enable x2apic mode when supported Roger Pau Monne
2022-01-21 1:01 ` Boris Ostrovsky
2022-01-21 9:01 ` [PATCH] xen/x2apic: enable x2apic mode when supported for HVM Roger Pau Monne
2022-01-21 20:30 ` Boris Ostrovsky
2022-02-03 6:50 ` Juergen Gross
2022-01-20 15:25 ` [PATCH 2/2] xen/x86: detect support for extended destination ID Roger Pau Monne
2022-02-07 9:03 ` Juergen Gross
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.