From: Denis Mukhin <dmukhin@ford.com>
Define an architecture-independent location for describing domain emulation
flags.
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Original code: https://lore.kernel.org/xen-devel/20250103-vuart-ns8250-v3-v1-6-c5d36b31d66c@ford.com/
---
xen/arch/x86/include/asm/domain.h | 23 ++++++++++++-----------
xen/include/xen/domain-emu.h | 30 ++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 11 deletions(-)
create mode 100644 xen/include/xen/domain-emu.h
diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h
index eafd5cfc903d..c6bc83b4abe0 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -3,6 +3,7 @@
#include <xen/mm.h>
#include <xen/radix-tree.h>
+#include <xen/domain-emu.h>
#include <asm/hvm/vcpu.h>
#include <asm/hvm/domain.h>
#include <asm/e820.h>
@@ -458,16 +459,16 @@ struct arch_domain
} __cacheline_aligned;
#ifdef CONFIG_HVM
-#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC
-#define X86_EMU_HPET XEN_X86_EMU_HPET
-#define X86_EMU_PM XEN_X86_EMU_PM
-#define X86_EMU_RTC XEN_X86_EMU_RTC
-#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC
-#define X86_EMU_PIC XEN_X86_EMU_PIC
-#define X86_EMU_VGA XEN_X86_EMU_VGA
-#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU
-#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ
-#define X86_EMU_VPCI XEN_X86_EMU_VPCI
+#define X86_EMU_LAPIC DOMAIN_EMU_LAPIC
+#define X86_EMU_HPET DOMAIN_EMU_HPET
+#define X86_EMU_PM DOMAIN_EMU_PM
+#define X86_EMU_RTC DOMAIN_EMU_RTC
+#define X86_EMU_IOAPIC DOMAIN_EMU_IOAPIC
+#define X86_EMU_PIC DOMAIN_EMU_PIC
+#define X86_EMU_VGA DOMAIN_EMU_VGA
+#define X86_EMU_IOMMU DOMAIN_EMU_IOMMU
+#define X86_EMU_USE_PIRQ DOMAIN_EMU_PIRQ
+#define X86_EMU_VPCI DOMAIN_EMU_PCI
#else
#define X86_EMU_LAPIC 0
#define X86_EMU_HPET 0
@@ -481,7 +482,7 @@ struct arch_domain
#define X86_EMU_VPCI 0
#endif
-#define X86_EMU_PIT XEN_X86_EMU_PIT
+#define X86_EMU_PIT DOMAIN_EMU_PIT
/* This must match XEN_X86_EMU_ALL in xen.h */
#define X86_EMU_ALL (X86_EMU_LAPIC | X86_EMU_HPET | \
diff --git a/xen/include/xen/domain-emu.h b/xen/include/xen/domain-emu.h
new file mode 100644
index 000000000000..410963ff480c
--- /dev/null
+++ b/xen/include/xen/domain-emu.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef XEN_DOMAIN_EMU_H
+#define XEN_DOMAIN_EMU_H
+
+/*
+ * Domain emulation flags.
+ */
+#define DOMAIN_EMU_LAPIC (1U << 0)
+#define DOMAIN_EMU_HPET (1U << 1)
+#define DOMAIN_EMU_PM (1U << 2)
+#define DOMAIN_EMU_RTC (1U << 3)
+#define DOMAIN_EMU_IOAPIC (1U << 4)
+#define DOMAIN_EMU_PIC (1U << 5)
+#define DOMAIN_EMU_VGA (1U << 6)
+#define DOMAIN_EMU_IOMMU (1U << 7)
+#define DOMAIN_EMU_PIT (1U << 8)
+#define DOMAIN_EMU_PIRQ (1U << 9)
+#define DOMAIN_EMU_PCI (1U << 10)
+
+#endif /* XEN_DOMAIN_EMU_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
2.34.1
On 24.06.2025 05:56, dmkhn@proton.me wrote: > @@ -458,16 +459,16 @@ struct arch_domain > } __cacheline_aligned; > > #ifdef CONFIG_HVM > -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC > -#define X86_EMU_HPET XEN_X86_EMU_HPET > -#define X86_EMU_PM XEN_X86_EMU_PM > -#define X86_EMU_RTC XEN_X86_EMU_RTC > -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC > -#define X86_EMU_PIC XEN_X86_EMU_PIC > -#define X86_EMU_VGA XEN_X86_EMU_VGA > -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU > -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ > -#define X86_EMU_VPCI XEN_X86_EMU_VPCI The old code deliberately used values from the public interface. > --- /dev/null > +++ b/xen/include/xen/domain-emu.h > @@ -0,0 +1,30 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +#ifndef XEN_DOMAIN_EMU_H > +#define XEN_DOMAIN_EMU_H > + > +/* > + * Domain emulation flags. > + */ > +#define DOMAIN_EMU_LAPIC (1U << 0) > +#define DOMAIN_EMU_HPET (1U << 1) > +#define DOMAIN_EMU_PM (1U << 2) > +#define DOMAIN_EMU_RTC (1U << 3) > +#define DOMAIN_EMU_IOAPIC (1U << 4) > +#define DOMAIN_EMU_PIC (1U << 5) > +#define DOMAIN_EMU_VGA (1U << 6) > +#define DOMAIN_EMU_IOMMU (1U << 7) > +#define DOMAIN_EMU_PIT (1U << 8) > +#define DOMAIN_EMU_PIRQ (1U << 9) > +#define DOMAIN_EMU_PCI (1U << 10) There's nothing in the new code making sure that the values won't go out of sync. Jan
Hi Jan, On Wed, Jul 09, 2025 at 04:57:44PM +0200, Jan Beulich wrote: > On 24.06.2025 05:56, dmkhn@proton.me wrote: > > @@ -458,16 +459,16 @@ struct arch_domain > > } __cacheline_aligned; > > > > #ifdef CONFIG_HVM > > -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC > > -#define X86_EMU_HPET XEN_X86_EMU_HPET > > -#define X86_EMU_PM XEN_X86_EMU_PM > > -#define X86_EMU_RTC XEN_X86_EMU_RTC > > -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC > > -#define X86_EMU_PIC XEN_X86_EMU_PIC > > -#define X86_EMU_VGA XEN_X86_EMU_VGA > > -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU > > -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ > > -#define X86_EMU_VPCI XEN_X86_EMU_VPCI > > The old code deliberately used values from the public interface. In next version I am building, I moved all of XEN_X86_EMU_XXX definitions as is to a new public header under include/public/xen-emu.h: https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942 That looks less invasive. Will that work? There should be a common header with emulation flags somewhere, since there will be SBSA and hwdom vUART definitions there. -- Denis
On 31.07.2025 22:55, dmkhn@proton.me wrote: > On Wed, Jul 09, 2025 at 04:57:44PM +0200, Jan Beulich wrote: >> On 24.06.2025 05:56, dmkhn@proton.me wrote: >>> @@ -458,16 +459,16 @@ struct arch_domain >>> } __cacheline_aligned; >>> >>> #ifdef CONFIG_HVM >>> -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC >>> -#define X86_EMU_HPET XEN_X86_EMU_HPET >>> -#define X86_EMU_PM XEN_X86_EMU_PM >>> -#define X86_EMU_RTC XEN_X86_EMU_RTC >>> -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC >>> -#define X86_EMU_PIC XEN_X86_EMU_PIC >>> -#define X86_EMU_VGA XEN_X86_EMU_VGA >>> -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU >>> -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ >>> -#define X86_EMU_VPCI XEN_X86_EMU_VPCI >> >> The old code deliberately used values from the public interface. > > In next version I am building, I moved all of XEN_X86_EMU_XXX definitions as > is to a new public header under include/public/xen-emu.h: > > https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942 > > That looks less invasive. > > Will that work? > > There should be a common header with emulation flags somewhere, since > there will be SBSA and hwdom vUART definitions there. Yet will there be a strict need for any constants to be identical (i.e. not only have the same name, but also the same value) across architectures? Jan
On Fri, Aug 01, 2025 at 08:02:56AM +0200, Jan Beulich wrote: > On 31.07.2025 22:55, dmkhn@proton.me wrote: > > On Wed, Jul 09, 2025 at 04:57:44PM +0200, Jan Beulich wrote: > >> On 24.06.2025 05:56, dmkhn@proton.me wrote: > >>> @@ -458,16 +459,16 @@ struct arch_domain > >>> } __cacheline_aligned; > >>> > >>> #ifdef CONFIG_HVM > >>> -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC > >>> -#define X86_EMU_HPET XEN_X86_EMU_HPET > >>> -#define X86_EMU_PM XEN_X86_EMU_PM > >>> -#define X86_EMU_RTC XEN_X86_EMU_RTC > >>> -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC > >>> -#define X86_EMU_PIC XEN_X86_EMU_PIC > >>> -#define X86_EMU_VGA XEN_X86_EMU_VGA > >>> -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU > >>> -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ > >>> -#define X86_EMU_VPCI XEN_X86_EMU_VPCI > >> > >> The old code deliberately used values from the public interface. > > > > In next version I am building, I moved all of XEN_X86_EMU_XXX definitions as > > is to a new public header under include/public/xen-emu.h: > > > > https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942 > > > > That looks less invasive. > > > > Will that work? > > > > There should be a common header with emulation flags somewhere, since > > there will be SBSA and hwdom vUART definitions there. > > Yet will there be a strict need for any constants to be identical (i.e. > not only have the same name, but also the same value) across architectures? I don't think there's strict need for identical values across achitectures. But some of the constants _may_ be reused for non-x86 arches, like VPCI bit and, perhaps, IOMMU, PIRQ and future NS16550 (after adding MMIO).
On 01.08.2025 21:30, dmkhn@proton.me wrote: > On Fri, Aug 01, 2025 at 08:02:56AM +0200, Jan Beulich wrote: >> On 31.07.2025 22:55, dmkhn@proton.me wrote: >>> On Wed, Jul 09, 2025 at 04:57:44PM +0200, Jan Beulich wrote: >>>> On 24.06.2025 05:56, dmkhn@proton.me wrote: >>>>> @@ -458,16 +459,16 @@ struct arch_domain >>>>> } __cacheline_aligned; >>>>> >>>>> #ifdef CONFIG_HVM >>>>> -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC >>>>> -#define X86_EMU_HPET XEN_X86_EMU_HPET >>>>> -#define X86_EMU_PM XEN_X86_EMU_PM >>>>> -#define X86_EMU_RTC XEN_X86_EMU_RTC >>>>> -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC >>>>> -#define X86_EMU_PIC XEN_X86_EMU_PIC >>>>> -#define X86_EMU_VGA XEN_X86_EMU_VGA >>>>> -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU >>>>> -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ >>>>> -#define X86_EMU_VPCI XEN_X86_EMU_VPCI >>>> >>>> The old code deliberately used values from the public interface. >>> >>> In next version I am building, I moved all of XEN_X86_EMU_XXX definitions as >>> is to a new public header under include/public/xen-emu.h: >>> >>> https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942 >>> >>> That looks less invasive. >>> >>> Will that work? >>> >>> There should be a common header with emulation flags somewhere, since >>> there will be SBSA and hwdom vUART definitions there. >> >> Yet will there be a strict need for any constants to be identical (i.e. >> not only have the same name, but also the same value) across architectures? > > I don't think there's strict need for identical values across achitectures. That's what I was expecting. > But some of the constants _may_ be reused for non-x86 arches, like VPCI bit > and, perhaps, IOMMU, PIRQ and future NS16550 (after adding MMIO). Right, but as you say - they want to use the same name, but they could easily have a different value there. I hope you understand that what I'm questioning is the introduction of a single header covering all architectures. Jan
On Mon, Aug 04, 2025 at 09:13:07AM +0200, Jan Beulich wrote: > On 01.08.2025 21:30, dmkhn@proton.me wrote: > > On Fri, Aug 01, 2025 at 08:02:56AM +0200, Jan Beulich wrote: > >> On 31.07.2025 22:55, dmkhn@proton.me wrote: > >>> On Wed, Jul 09, 2025 at 04:57:44PM +0200, Jan Beulich wrote: > >>>> On 24.06.2025 05:56, dmkhn@proton.me wrote: > >>>>> @@ -458,16 +459,16 @@ struct arch_domain > >>>>> } __cacheline_aligned; > >>>>> > >>>>> #ifdef CONFIG_HVM > >>>>> -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC > >>>>> -#define X86_EMU_HPET XEN_X86_EMU_HPET > >>>>> -#define X86_EMU_PM XEN_X86_EMU_PM > >>>>> -#define X86_EMU_RTC XEN_X86_EMU_RTC > >>>>> -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC > >>>>> -#define X86_EMU_PIC XEN_X86_EMU_PIC > >>>>> -#define X86_EMU_VGA XEN_X86_EMU_VGA > >>>>> -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU > >>>>> -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ > >>>>> -#define X86_EMU_VPCI XEN_X86_EMU_VPCI > >>>> > >>>> The old code deliberately used values from the public interface. > >>> > >>> In next version I am building, I moved all of XEN_X86_EMU_XXX definitions as > >>> is to a new public header under include/public/xen-emu.h: > >>> > >>> https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942 > >>> > >>> That looks less invasive. > >>> > >>> Will that work? > >>> > >>> There should be a common header with emulation flags somewhere, since > >>> there will be SBSA and hwdom vUART definitions there. > >> > >> Yet will there be a strict need for any constants to be identical (i.e. > >> not only have the same name, but also the same value) across architectures? > > > > I don't think there's strict need for identical values across achitectures. > > That's what I was expecting. > > > But some of the constants _may_ be reused for non-x86 arches, like VPCI bit > > and, perhaps, IOMMU, PIRQ and future NS16550 (after adding MMIO). > > Right, but as you say - they want to use the same name, but they could easily > have a different value there. I hope you understand that what I'm questioning > is the introduction of a single header covering all architectures. Yes, I understand your point wrt common header and identical values in emulation flags. I think I can add missing per-vUART fields to per-arch xen_arch_domainconfig, populate them by the toolstack and be done for now, i.e. I can drop that patch. -- Denis
© 2016 - 2026 Red Hat, Inc.