]> xenbits.xensource.com Git - xen.git/log
xen.git
7 hours agoxen/arm: check read handler behavior master staging
Stewart Hildebrand [Fri, 18 Apr 2025 18:58:36 +0000 (14:58 -0400)]
xen/arm: check read handler behavior

We expect mmio read handlers to leave the bits above the access size
zeroed. Add an ASSERT to check this aspect of read handler behavior.

Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
7 hours agoxen/common: dom0less: introduce common dom0less-build.c
Oleksii Kurochko [Mon, 5 May 2025 18:10:38 +0000 (20:10 +0200)]
xen/common: dom0less: introduce common dom0less-build.c

Part of Arm's dom0less-build.c could be common between architectures which are
using device tree files to create guest domains. Thereby move some parts of
Arm's dom0less-build.c to common code with minor changes.

As a part of theses changes the following changes are introduced:
- Introduce make_arch_nodes() to cover arch-specific nodes. For example, in
  case of Arm, it is PSCI and vpl011 nodes.
- Introduce set_domain_type() to abstract a way how setting of domain type
  happens. For example, RISC-V won't have this member of arch_domain structure
  as vCPUs will always have the same bitness as hypervisor. In case of Arm, it
  is possible that Arm64 could create 32-bit and 64-bit domains.
- Introduce init_vuart() to cover details of virtual uart initialization.
- Introduce init_intc_phandle() to cover some details of interrupt controller
  phandle initialization. As an example, RISC-V could have different name for
  interrupt controller node ( APLIC, PLIC, IMSIC, etc ) but the code in
  domain_handle_dtb_bootmodule() could handle only one interrupt controller
  node name.
- s/make_gic_domU_node/make_intc_domU_node as GIC is Arm specific naming and
  add prototype of make_intc_domU_node() to dom0less-build.h

The following functions are moved to xen/common/device-tree:
- Functions which are moved as is:
  - domain_p2m_pages().
  - handle_passthrough_prop().
  - handle_prop_pfdt().
  - scan_pfdt_node().
  - check_partial_fdt().
- Functions which are moved with some minor changes:
  - alloc_xenstore_evtchn():
    - ifdef-ing by CONFIG_HVM accesses to hvm.params.
  - prepare_dtb_domU():
    - ifdef-ing access to gnttab_{start,size} by CONFIG_GRANT_TABLE.
    - s/make_gic_domU_node/make_intc_domU_node.
    - Add call of make_arch_nodes().
- domain_handle_dtb_bootmodule():
  - hide details of interrupt controller phandle initialization by calling
    init_intc_phandle().
  - Update the comment above init_intc_phandle(): s/gic/interrupt controller.
- construct_domU():
  - ifdef-ing by CONFIG_HVM accesses to hvm.params.
  - Call init_vuart() to hide Arm's vpl011_init() details there.
  - Add call of set_domain_type() instead of setting kinfo->arch.type explicitly.

Some parts of dom0less-build.c are wraped by #ifdef CONFIG_STATIC_{SHMEM,MEMORY}
as not all archs support these configs.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
[stefano: fix code style]
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 hours agoxen/common: dom0less: introduce common domain-build.c
Oleksii Kurochko [Mon, 5 May 2025 18:10:37 +0000 (20:10 +0200)]
xen/common: dom0less: introduce common domain-build.c

Some functions of Arm's domain_build.c could be reused by dom0less or other
features connected to domain construction/build.

The following functions are moved to common:
- get_allocation_size().
- allocate_domheap_memory().
- guest_map_pages().
- allocate_bank_memory().
- add_hwdom_free_regions().
- find_unallocated_memory().
- allocate_memory().
- dtb_load().
- initrd_load().

Prototype of dtb_load() and initrd_load() is updated to recieve a pointer
to copy_to_guest_phys() as some archs require
copy_to_guest_phys_fluch_dcache().

Update arm/include/asm/Makefile to generate  domain-build.h for Arm as it is
used by domain-build.c.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 hours agoxen/common: dom0less: introduce common kernel.c
Oleksii Kurochko [Mon, 5 May 2025 18:10:36 +0000 (20:10 +0200)]
xen/common: dom0less: introduce common kernel.c

The following functions don't have arch specific things so it is moved to
common:
- kernel_prboe()
- kernel_load()
- output_length()

Functions necessary for dom0less are only moved.

The following changes are done:
- Swap __init and return type of kernel_decompress() function to be
  consistent with defintions of functions in other files. The same
  for output_length().
- Wrap by "ifdef CONFIG_ARM" the call of kernel_uimage_probe() in
  kernel_probe() as uImage isn't really used nowadays thereby leave
  kernel_uimage_probe() call here just for compatability with Arm code.
- Introduce kernel_zimage_probe() to cover the case that arch can have
  different zimage header.
- Add ASSERT() for kernel_load() to check that it argument isn't NULL.
- Make kernel_uimage_probe() non-static in Arm's code as it is used in
  common/kernel.c.

Introduce CONFIG_DOMAIN_BUILD_HELPERS to not provide stubs for archs
which don't provide enough functionality to enable it.
Select CONFIG_DOMAIN_BUILD_HELPERS for CONFIG_ARM as only Arm supports
it, at the moment.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 hours agoasm-generic: move some parts of Arm's domain_build.h to common
Oleksii Kurochko [Mon, 5 May 2025 18:10:35 +0000 (20:10 +0200)]
asm-generic: move some parts of Arm's domain_build.h to common

Nothing changed. Only some functions declaration are moved to xen/include/
headers as they are expected to be used by common code of domain builing
or dom0less.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 hours agoarm/static-shmem.h: drop inclusion of asm/setup.h
Oleksii Kurochko [Mon, 5 May 2025 18:10:34 +0000 (20:10 +0200)]
arm/static-shmem.h: drop inclusion of asm/setup.h

Nothing is dependent from asm/setup.h in asm/static-shmem.h so inclusion of
asm/setup.h is droped.

After this drop the following compilation error related to impicit declaration
of the following functions device_tree_get_reg and map_device_irqs_to_domain,
device_tree_get_u32 occur during compilation of dom0less-build.c ( as they are
declared in asm/setup.h ).

Add inclusion of <asm/setup.h> in dt-overlay.c as it is using handle_device()
declared in <asm/setup.h>.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 hours agoasm-generic: move parts of Arm's asm/kernel.h to common code
Oleksii Kurochko [Mon, 5 May 2025 18:10:33 +0000 (20:10 +0200)]
asm-generic: move parts of Arm's asm/kernel.h to common code

Move the following parts to common with the following changes:
- struct kernel_info:
  - Create arch_kernel_info for arch specific kernel information.
    At the moment, it contains domain_type for Arm.
  - s/phandle_gic/phandle_intc to have more generic name suitable for other
    archs.
  - Make text_offset of zimage structure available for RISCV_64.
- Wrap by `#ifdef KERNEL_INFO_SHM_MEM_INIT` definition of KERNEL_SHM_MEM_INIT
  and wrap by `#ifndef KERNEL_INFO_INIT` definition of KERNEL_INFO_INIT to have
  ability to override KERNEL_INFO_SHM_MEM_INIT for arch in case it doesn't
  want to use generic one.
- Move DOM0LESS_* macros to dom0less-build.h.
- Move all others parts of Arm's kernel.h to xen/fdt-kernel.h.

Because of the changes in struct kernel_info the correspondent parts of Arm's
code are updated.

As part of this patch the following clean up happens:
- Drop asm/setup.h from asm/kernel.h as nothing depends from it.
  Add inclusion of asm/setup.h for a code which uses device_tree_get_reg() to
  avoid compilation issues for CONFIG_STATIC_MEMORY and CONFIG_STATIC_SHM.
- Drop inclusion of asm/kernel.h everywhere except xen/fdt-kernel.h.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 hours agoxen/common: dom0less: make some parts of Arm's CONFIG_DOM0LESS common
Oleksii Kurochko [Mon, 5 May 2025 18:10:32 +0000 (20:10 +0200)]
xen/common: dom0less: make some parts of Arm's CONFIG_DOM0LESS common

Move some parts of Arm's Dom0Less code to be reused by other architectures.
At the moment, RISC-V is going to reuse these parts.

Move dom0less-build.h from the Arm-specific directory to asm-generic
as these header is expected to be the same across acrhictectures with
some updates: add the following declaration of construct_domU(),
and arch_create_domUs() as there are some parts which are still
architecture-specific.

Introduce HAS_DOM0LESS to provide ability to enable generic Dom0less
code for an architecture.

Relocate the CONFIG_DOM0LESS configuration to the common with adding
"depends on HAS_DOM0LESS" to not break builds for architectures which
don't support CONFIG_DOM0LESS config, especically it would be useful
to not provide stubs for  construct_domU(), arch_create_domUs()
in case of *-randconfig which may set CONFIG_DOM0LESS=y.

Move is_dom0less_mode() function to the common code, as it depends on
boot modules that are already part of the common code.

Move create_domUs() function to the common code with some updates:
- Add arch_create_domUs() to cover parsing of arch-specific features,
  for example, SVE (Scalar Vector Extension ) exists only in Arm.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
[stefano: fix arch_create_domUs to only modify flags]
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
9 hours agoxen/arm: drop declaration of handle_device_interrupts()
Oleksii Kurochko [Mon, 5 May 2025 18:10:31 +0000 (20:10 +0200)]
xen/arm: drop declaration of handle_device_interrupts()

There is no definition of handle_device_interrupts() thereby it
could be dropped.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
3 days agox86/mm: Improve bitops in vcpumask_to_pcpumask()
Andrew Cooper [Wed, 29 May 2024 13:58:57 +0000 (14:58 +0100)]
x86/mm: Improve bitops in vcpumask_to_pcpumask()

This loop is for_each_set_bit() in disguise.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
3 days agox86/vpic: Improve bitops usage
Andrew Cooper [Tue, 29 Apr 2025 13:52:08 +0000 (14:52 +0100)]
x86/vpic: Improve bitops usage

 * For vpic_get_priority(), introduce a common ror8() helper in plain C.  One
   thing that I can't persuade the compiler to realise is that a non-zero
   value rotated is still non-zero, so use __builtin_clz() to help the
   optimiser out.

 * vpic_ioport_write() can be simplified to just for_each_set_bit(), which
   avoids spilling pending to the stack each loop iteration.  Changing pending
   from unsigned int to uint8_t isn't even strictly necessary given the
   underlying types of vpic->isr and vpic->irr, but done so clarity.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
3 days agox86/vmx: Fix label name in vmwrite_safe()
Andrew Cooper [Mon, 28 Apr 2025 16:39:18 +0000 (17:39 +0100)]
x86/vmx: Fix label name in vmwrite_safe()

This condition is called VMFail(valid) in the SDM.

No functional change.

Fixes: fc3db01db6fb ("x86/vmx: Rework VMX wrappers using `asm goto()`")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
3 days agox86/thunk: Don't opencode TSX instructions in clear_bhb_tsx()
Andrew Cooper [Thu, 1 May 2025 18:05:53 +0000 (19:05 +0100)]
x86/thunk: Don't opencode TSX instructions in clear_bhb_tsx()

The new toolchain baseline understands the RTM instructions.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
3 days agox86/alternatives: allow replacement code snippets to be re-used
Jan Beulich [Fri, 2 May 2025 07:44:49 +0000 (09:44 +0200)]
x86/alternatives: allow replacement code snippets to be re-used

In a number of cases we use ALTERNATIVE_2 with both replacement insns /
insn sequences being identical. Avoid emitting the same code twice, and
instead alias the necessary helper labels to the existing ones.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 days agomm: move paddr_to_pdx()
Jan Beulich [Fri, 2 May 2025 07:44:03 +0000 (09:44 +0200)]
mm: move paddr_to_pdx()

There's nothing arch-specific about it.

While there, on x86 visually separate the vmap_to_*() macros from those
covered by the earlier comment.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Oleksii Kurochko<oleksii.kurochko@gmail.com>
3 days ago{hyper,multi}call: further limit arguments to just 5
Jan Beulich [Fri, 2 May 2025 07:43:23 +0000 (09:43 +0200)]
{hyper,multi}call: further limit arguments to just 5

Multicall compat translation and hypercall continuation handling can
also be shrunk to the processing of just (up to) 5 arguments.

Take the opportunity to
- make exceeding the limit noisy in hypercall_create_continuation(),
- use speculation-safe array access in hypercall_create_continuation(),
- avoid a Misra C:2012 Rule 19.1 violation in xlat_multicall_entry(),
- further tidy xlat_multicall_entry() and __trace_multicall_call()
  style-wise.

Amends: 2f531c122e95 ("x86: limit number of hypercall parameters to 5")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org> # arm
4 days agoxen/mm: Switch some APIs over to pte_attr_t
Shawn Anastasio [Fri, 25 Apr 2025 10:29:56 +0000 (11:29 +0100)]
xen/mm: Switch some APIs over to pte_attr_t

Several APIs take an architecture-dependent set of flags in an unsigned int,
but this needs to be a wider type to support PPC.

The new type pte_attr_t has been introduced for this purpose, so switch to it
in map_pages_to_xen(), __vmap() and modify_xen_mappings{,_lite}().

No functional change.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
4 days agoxen/mm: Introduce mm-types.h
Andrew Cooper [Fri, 25 Apr 2025 10:20:09 +0000 (11:20 +0100)]
xen/mm: Introduce mm-types.h

The type used for pagetable attributes/permissions is currently unsigned int,
but needs to become architecture dependent as PPC needs unsigned long.

Introduce mm-types.h to house pte_attr_t.

Given the new toolchain baseline, we can use __has_include() now to remove the
need for boilerplate on most architectures.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
4 days agoarm/alternative: Drop unused includes of asm/alternative.h
Andrew Cooper [Sat, 19 Apr 2025 21:22:52 +0000 (22:22 +0100)]
arm/alternative: Drop unused includes of asm/alternative.h

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
4 days agomisra: update list of GCC extensions used by Xen
Nicola Vetrini [Thu, 1 May 2025 19:24:24 +0000 (12:24 -0700)]
misra: update list of GCC extensions used by Xen

__inline and __inline__ are already handled by ECLAIR but
C-language-toolchain.rst doesn't reflect that. Update the doc.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
5 days agox86/intel: Move mcu_opt_ctrl_* into __ro_after_init
Andrew Cooper [Wed, 30 Apr 2025 15:18:13 +0000 (16:18 +0100)]
x86/intel: Move mcu_opt_ctrl_* into __ro_after_init

They're only modified by set_in_mcu_opt_ctrl() which is an __init function.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
5 days agocpufreq: don't leave stale statistics pointer
Jan Beulich [Wed, 30 Apr 2025 06:47:49 +0000 (08:47 +0200)]
cpufreq: don't leave stale statistics pointer

Error paths of cpufreq_statistic_init() correctly free the base
structure pointer, but the per-CPU variable would still hold it, mis-
guiding e.g. cpufreq_statistic_update(). Defer installing of the pointer
there until the structure was fully populated.

Fixes: 755af07edba1 ("x86/cpufreq: don't use static array for large per-CPU data structures")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
5 days agocpufreq: use existing local var in cpufreq_statistic_init()
Jan Beulich [Wed, 30 Apr 2025 06:47:15 +0000 (08:47 +0200)]
cpufreq: use existing local var in cpufreq_statistic_init()

..., which actually also helps readability (imo).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
5 days agox86: drop underscore-prefixed {maddr,virt} <=> page conversion macros
Jan Beulich [Wed, 30 Apr 2025 06:46:49 +0000 (08:46 +0200)]
x86: drop underscore-prefixed {maddr,virt} <=> page conversion macros

Unlike the ones converting to/from frame numbers, these don't have type-
safe overrides, and they also can't gain any within our present type
system. Unsurprisingly we also don't have any uses of the underscore-
prefixed variants.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
5 days agox86emul: avoid UB shifts in FLDENV/FRSTOR handling
Jan Beulich [Wed, 30 Apr 2025 06:46:21 +0000 (08:46 +0200)]
x86emul: avoid UB shifts in FLDENV/FRSTOR handling

16-bit quantities, no matter whether expressed as uint16_t or as
bitfield, will be promoted to plain int before doing any arithmetic on
them. Shifting such values by 16 will therefore shift into the sign bit,
which is UB if that bit becomes set. To account for all reads and all
writes accessing opposite members of the same union, introduce yet more
local variables to reduce the shift counts to 12.

Fixes: be55ed744ed8 ("x86emul: support FLDENV and FRSTOR")
Reported-by: Fabian Specht <f.specht@tum.de>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
6 days agox86/mm: move mmio_ro_emulated_write() to PV only file
Roger Pau Monne [Thu, 10 Apr 2025 09:48:03 +0000 (11:48 +0200)]
x86/mm: move mmio_ro_emulated_write() to PV only file

mmio_ro_emulated_write() is only used in pv/ro-page-fault.c, move the
function to that file and make it static.

No functional change intended.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
6 days agox86/hvm: only register the r/o subpage ops when needed
Roger Pau Monne [Fri, 11 Apr 2025 08:31:22 +0000 (10:31 +0200)]
x86/hvm: only register the r/o subpage ops when needed

MMIO operation handlers can be expensive to process, hence attempt to
register only those that will be needed by the domain.

Subpage r/o MMIO regions are added exclusively at boot, further limit their
addition to strictly before the initial domain gets created, so by the time
initial domain creation happens Xen knows whether subpage is required or
not.  This allows only registering the MMIO handler when there are
subpage regions to handle.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
6 days agox86/hvm: fix handling of accesses to partial r/o MMIO pages
Roger Pau Monne [Wed, 9 Apr 2025 16:53:00 +0000 (18:53 +0200)]
x86/hvm: fix handling of accesses to partial r/o MMIO pages

The current logic to handle accesses to MMIO pages partially read-only is
based on the (now removed) logic used to handle accesses to the r/o MMCFG
region(s) for PVH v1 dom0.  However that has issues when running on AMD
hardware, as in that case the guest linear address that triggered the fault
is not provided as part of the VM exit.  This caused
mmio_ro_emulated_write() to always fail before calling
subpage_mmio_write_emulate() when running on AMD and called from an HVM
context.

Take a different approach and convert the handling of partial read-only
MMIO page accesses into an HVM MMIO ops handler, as that's the more natural
way to handle this kind of emulation for HVM domains.

This allows getting rid of hvm_emulate_one_mmio() and it's single call site
in hvm_hap_nested_page_fault().  As part of the fix r/o MMIO accesses are
now handled by handle_mmio_with_translation(), re-using the same logic that
was used for other read-only types part of p2m_is_discard_write().  The
usage of emulation for faulting p2m_mmio_direct types is limited to
addresses in the r/o MMIO range. The page present check is dropped as type
p2m_mmio_direct must have the present bit set in the PTE.

Note a small adjustment is needed to the `pf-fixup` dom0 PVH logic: avoid
attempting to fixup faults resulting from write accesses to read-only MMIO
regions, as handling of those accesses is now done by handle_mmio().

Fixes: 33c19df9a5a0 ('x86/PCI: intercept accesses to RO MMIO from dom0s in HVM containers')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
6 days agoxen/io: provide helpers for multi size MMIO accesses
Roger Pau Monne [Thu, 10 Apr 2025 07:26:08 +0000 (09:26 +0200)]
xen/io: provide helpers for multi size MMIO accesses

Several handlers have the same necessity of reading or writing from or to
an MMIO region using 1, 2, 4 or 8 bytes accesses.  So far this has been
open-coded in the function itself.  Instead provide a new set of handlers
that encapsulate the accesses.

Since the added helpers are not architecture specific, introduce a new
generic io.h header.

No functional change intended.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 days agox86/vmx: Update DR7 type
Denis Mukhin [Sat, 26 Apr 2025 07:27:44 +0000 (07:27 +0000)]
x86/vmx: Update DR7 type

Use the new vmread() accessor and shrink dr7 to it's preferred size.

No functional change.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 days agox86/vmx: Introduce vmread()
Denis Mukhin [Sat, 26 Apr 2025 07:27:29 +0000 (07:27 +0000)]
x86/vmx: Introduce vmread()

The current implementation of __vmread() is void and returns the result via
pointer argument which leads to excess code in some places.

Introduce a new vmread() function, and implement __vmread() in terms of it.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 days agoxen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS
Andrew Cooper [Tue, 22 Apr 2025 11:30:19 +0000 (12:30 +0100)]
xen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS

Building Xen with Clang-17 yields the following warning:

  ld: warning: orphan section `.debug_str_offsets' from `prelink.o' being placed in section `.debug_str_offsets'
  ld: ./.xen.efi.0xffff82d040000000.0:/4: section below image base
  ld: ./.xen.efi.0xffff82d040000000.1:/4: section below image base
  ld: warning: orphan section `.debug_str_offsets' from `prelink.o' being placed in section `.debug_str_offsets'
  ld: xen.efi:/4: section below image base

Set the alignment to 4 as it holds 4-byte values, despite the fact that Clang
appears to only use 1.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 days agox86: constrain sub-page access length in mmio_ro_emulated_write()
Jan Beulich [Mon, 28 Apr 2025 07:48:14 +0000 (09:48 +0200)]
x86: constrain sub-page access length in mmio_ro_emulated_write()

Without doing so we could trigger the ASSERT_UNREACHABLE() in
subpage_mmio_write_emulate(). A comment there actually says this
validation would already have been done ...

Fixes: 8847d6e23f97 ("x86/mm: add API for marking only part of a MMIO page read only")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
7 days agostubdom: remove ancient stubdom-dm script
Juergen Gross [Mon, 28 Apr 2025 07:47:30 +0000 (09:47 +0200)]
stubdom: remove ancient stubdom-dm script

The stubdom-dm script is still using "xm" instead of "xl", so it is
probably unused since more than 10 years now.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
7 days agoSUPPORT.md: make Linux based stubdom fully supported
Juergen Gross [Mon, 28 Apr 2025 07:47:15 +0000 (09:47 +0200)]
SUPPORT.md: make Linux based stubdom fully supported

All patches needed for running with a Linux stubdom device model are
in the tree and QubesOS is using and testing Linux stubdoms nowadays.

Switch support from "Tech Preview" to "Supported, with caveats".

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-By: Oleksii Kurochko<oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
10 days agoxen/vpci: Fix msix existing mapping printk
Jason Andryuk [Thu, 24 Apr 2025 21:23:26 +0000 (17:23 -0400)]
xen/vpci: Fix msix existing mapping printk

The format string lacks a space, so mfn and type run together:
(XEN) d0v0 0000:06:00.7: existing mapping (mfn: 753037type: 0) at 0x1 clobbers MSIX MMIO area

Add a space.  Additionally, move the format string to a single long line
to improve grep-ability.

Fixes: 677053fac17a ("vpci/msix: carve p2m hole for MSIX MMIO regions")
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
10 days agox86/hvmloader: fix usage of NULL with cpuid_count()
Roger Pau Monne [Thu, 24 Apr 2025 11:39:45 +0000 (13:39 +0200)]
x86/hvmloader: fix usage of NULL with cpuid_count()

The commit that added support for retrieving the APIC IDs from the APs
introduced several usages of cpuid() with NULL parameters, which is not
handled by the underlying implementation.  For GCC I expect this results in
writes to the physical address at 0, however when using Clang 19.1.2 the
generated code in smp.o for the whole file is:

tools/firmware/hvmloader/smp.o: file format elf32-i386

Disassembly of section .text:

00000000 <smp_initialise>:
       0: 55                            pushl   %ebp
       1: 89 e5                         movl    %esp, %ebp
       3: 53                            pushl   %ebx
       4: 31 c0                         xorl    %eax, %eax
       6: 31 c9                         xorl    %ecx, %ecx
       8: 0f a2                         cpuid

Showing the usage of a NULL pointer results in undefined behavior, and
Clang refusing to generate further code after it.

Fix by using a temporary variable in cpuid_count() in place for any NULL
parameter.

Fixes: 9ad0db58c7e2 ('tools/hvmloader: Retrieve APIC IDs from the APs themselves')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 days agoxen: fix buffer over-read in bitmap_to_xenctl_bitmap()
Roger Pau Monne [Thu, 24 Apr 2025 10:23:14 +0000 (12:23 +0200)]
xen: fix buffer over-read in bitmap_to_xenctl_bitmap()

There's an off-by-one when calculating the last byte in the input array to
bitmap_to_xenctl_bitmap(), which leads to bitmaps with sizes multiple of 8
to over-read and incorrectly use a byte past the end of the array.

Fixes: 288c4641c80d ('xen: simplify bitmap_to_xenctl_bitmap for little endian')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 days agotools/xen-hptool: Replace hard tabs
Jason Andryuk [Wed, 23 Apr 2025 21:28:21 +0000 (17:28 -0400)]
tools/xen-hptool: Replace hard tabs

With a tab stop of 8, the alignment is off.  Replace the hard tabs with
spaces to match the file.

Fixes: 284d5633be37 ("Tools: add online/offline hotplug user interfaces")
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
10 days agotools/xen-hptool: Add missing newlines
Jason Andryuk [Wed, 23 Apr 2025 21:28:20 +0000 (17:28 -0400)]
tools/xen-hptool: Add missing newlines

Add some missing newlines to error messages.

Fixes: 284d5633be37 ("Tools: add online/offline hotplug user interfaces")
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
10 days agotools/libxl: Switch irq to unsigned int
Jason Andryuk [Fri, 18 Apr 2025 21:05:50 +0000 (17:05 -0400)]
tools/libxl: Switch irq to unsigned int

The PCI device irq is read with fscanf(%u).  Switch the irq variable to
unsigned int to match.

Linux driver/pci/pci-sysfs.c:irq_show() uses %u to print the value.

However, unsigned int irq doesn't compile because of:
error: pointer targets in passing argument 4 of 'xc_physdev_map_pirq' differ in signedness [-Werror=pointer-sign]

Add int pirq to provide the desired type instead of re-using irq.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
10 days agotools/libxl: Skip invalid IRQs
Jason Andryuk [Fri, 18 Apr 2025 21:05:49 +0000 (17:05 -0400)]
tools/libxl: Skip invalid IRQs

A PCI device's irq field is an 8-bit number.  A value of 0xff indicates
that the device IRQ is not connected.  Additionally, the Linux ACPI code
can convert these 0xff values to IRQ_NOTCONNECTED(0x80000000) because
"0x80000000 is guaranteed to be outside the available range of
interrupts and easy to distinguish from other possible incorrect
values."  When the hypercall to assign that IRQ fails, device
passthrough as a whole fails.

Add checking for a valid IRQ and skip the IRQ handling for PCI devices
outside that range.  This allows for passthrough of devices without
legacy IRQs.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
10 days agotools/tests: Fix newly introduced Makefile
Anthony PERARD [Mon, 14 Apr 2025 14:17:14 +0000 (16:17 +0200)]
tools/tests: Fix newly introduced Makefile

Fix few issue with this new directory:
- clean generated files
- and ignore those generated files
- include the dependency files generated by `gcc`.
- rework prerequisites:
  "test-rangeset.o" also needs the generated files "list.h" and
  "rangeset.h". Technically, both only needs "harness.h" which needs
  the generated headers, but that's a bit simpler and the previous
  point will add the dependency on "harness.h" automatically.

This last point fix an issue where `make` might decide to build
"test-rangeset.o" before the other files are ready.

Fixes: 7bf777b42cad ("tootls/tests: introduce unit tests for rangesets")
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
10 days agotools/libxl: search PATH for QEMU if `QEMU_XEN_PATH` is not absolute
Hongbo [Sun, 30 Mar 2025 16:03:04 +0000 (00:03 +0800)]
tools/libxl: search PATH for QEMU if `QEMU_XEN_PATH` is not absolute

`QEMU_XEN_PATH` will be configured as `qemu-system-i386` with no clue where, if
`--with-system-qemu` is set without giving a path (as matched in the case `yes`
but not `*`). However, the existence of the executable is checked by `access()`,
that will not look for anywhere in $PATH but the current directory. And since it
is possible for `qemu-system-i386` (or any other configured values) to be
executed from PATH later, we'd better find that in PATH and return the full path
for the caller to check against.

Signed-off-by: Hongbo <hehongbo@mail.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
[Initialise `saveptr` to NULL]
Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
10 days agoautomation: Avoid changing source files for randconfig tests
Anthony PERARD [Wed, 26 Mar 2025 14:28:25 +0000 (14:28 +0000)]
automation: Avoid changing source files for randconfig tests

We should avoid changing files from the source tree if we don't intend
to commit the result.

We don't really need to check if $EXTRA_FIXED_RANDCONFIG is empty so
add it to the temporary file in all cases.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
12 days agox86/alternatives: Simplify _apply_alternatives() now altcall is separate
Andrew Cooper [Sun, 20 Apr 2025 00:46:57 +0000 (01:46 +0100)]
x86/alternatives: Simplify _apply_alternatives() now altcall is separate

With altcall handled separately, the special case in _apply_alternatives() is
unused and can be dropped.  The force parameter (used to signify the seal
pass) can be removed too.

In turn, nmi_apply_alternatives() no longer needs to call
_apply_alternatives() on the second pass.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
12 days agox86/altcall: Switch to simpler scheme
Andrew Cooper [Sat, 19 Apr 2025 19:44:31 +0000 (20:44 +0100)]
x86/altcall: Switch to simpler scheme

With all the infrastructure in place, switch from using ALTERNATIVE() to
simply populating .alt_call_sites.

Before, _apply_alternatives() would devirtualise in two passes; the first
being opportunistic, and the second (signified by the force parameter) sealing
any call with a still-NULL function pointer.

Now, all devirtualising is performed together, at the point in time of the
second pass previously.  The call to seal_endbr64() needs delaying until after
apply_alt_calls() is complete, or we have a narrow window with real indirect
branches and no ENDBR64 instructions.

Under the hood, the following changes are happening:

  Section                Old size   New size   Change (%)
  .alt_call_sites               0    0x00730   +0x0730
  .altinstructions        0x1350a    0x11fe0   -0x152a (-7%)
  .altinstr_replacement   0x015f2    0x00e35   -0x07bd (-23%)

The changes aren't quite equal because inlining is affected by the smaller
asm() block.  Nevertheless, the metadata is held in 1/3 of the space, and
there are no CALL instructions held in the replacement section any more.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
12 days agoxen/livepatch: Support new altcall scheme
Andrew Cooper [Sun, 20 Apr 2025 01:32:26 +0000 (02:32 +0100)]
xen/livepatch: Support new altcall scheme

The new altcall scheme uses an .alt_call_sites section.  Wire this up in very
much the same way as the .altinstructions section, although there is less
sanity checking necessary.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
12 days agox86/altcall: Introduce new simpler scheme
Andrew Cooper [Sat, 19 Apr 2025 22:05:52 +0000 (23:05 +0100)]
x86/altcall: Introduce new simpler scheme

Encoding altcalls as regular alternatives leads to an unreasonable amount of
complexity in _apply_alternatives().

Introduce apply_alt_calls(), and an .alt_call_sites section which simply
tracks the source address (relative, to save on space).  That's literally all
that is needed in order to devirtualise the function pointers.

apply_alt_calls() is mostly as per _apply_alternatives(), except the size is
known to be 6 bytes.  Drop the logic for JMP *RIPREL, as there's no support
for tailcall optimisations, nor a feasbile plan on how to introduce support.
Pad with a redundant prefix to avoid needing a separate NOP on the end.

Wire it up in nmi_apply_alternatives(), although the section is empty at this
juncture so nothing happens in practice.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
12 days agox86/alternatives: Factor seal_endbr64() out of _apply_alternatives()
Andrew Cooper [Sun, 20 Apr 2025 00:19:47 +0000 (01:19 +0100)]
x86/alternatives: Factor seal_endbr64() out of _apply_alternatives()

We are going to need to reposition the call in a change with several moving
parts.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 days agox86/alternatives: Rework information passing into nmi_apply_alternatives()
Andrew Cooper [Sat, 19 Apr 2025 23:44:17 +0000 (00:44 +0100)]
x86/alternatives: Rework information passing into nmi_apply_alternatives()

nmi_apply_alternatives() is soon going to need to dispatch to multiple
functions, and a force parameter is not a good way of passing information.

Introduce ALT_INSNS and ALT_CALLS to pass in at the top level to select the
operation(s) desired.  They represent what will happen when we've separated
the altcalls out of the general alternative instructions infrastructure,
although in the short term we still need to synthesise the force parameter for
_apply_alternatives().

Move two externs to reduce their scope a little.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
12 days agox86/altcall: Rename alternative_branches() to boot_apply_alt_calls()
Andrew Cooper [Sat, 19 Apr 2025 21:38:23 +0000 (22:38 +0100)]
x86/altcall: Rename alternative_branches() to boot_apply_alt_calls()

The alternatives APIs are not great; rename alternative_branches() to be more
precise.  Centralise the declaration in xen/alternative-call.h, in the
expectation that x86 won't be the only user in the long term.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 days agox86/altcall: Split alternative-call.h out of alternative.h
Andrew Cooper [Sat, 19 Apr 2025 20:23:56 +0000 (21:23 +0100)]
x86/altcall: Split alternative-call.h out of alternative.h

... in preparation for changing how they're implemented.

Update the MISRA deviations with the new path.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 days agoxen: remove -N from the linker command line
Roger Pau Monne [Wed, 5 Mar 2025 10:53:20 +0000 (11:53 +0100)]
xen: remove -N from the linker command line

It's unclear why -N is being used in the first place.  It was added by
commit 4676bbf96dc8 back in 2002 without any justification.

When building a PE image it's actually detrimental to forcefully set the
.text section as writable.  The GNU LD man page contains the following
warning regarding the -N option:

> Note: Although a writable text section is allowed for PE-COFF targets, it
> does not conform to the format specification published by Microsoft.

Remove the usage of -N uniformly on all architectures, assuming that the
addition was simply done as a copy and paste of the original x86 linking
rune.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Julien Grall <jgrall@amazon.com>
12 days agox86/intel: workaround several MONITOR/MWAIT errata
Roger Pau Monne [Thu, 17 Apr 2025 10:35:28 +0000 (12:35 +0200)]
x86/intel: workaround several MONITOR/MWAIT errata

There are several errata on Intel regarding the usage of the MONITOR/MWAIT
instructions, all having in common that stores to the monitored region
might not wake up the CPU.

Fix them by forcing the sending of an IPI for the affected models.

The Ice Lake issue has been reproduced internally on XenServer hardware,
and the fix does seem to prevent it.  The symptom was APs getting stuck in
the idle loop immediately after bring up, which in turn prevented the BSP
from making progress.  This would happen before the watchdog was
initialized, and hence the whole system would get stuck.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
12 days agodrivers/pci: Get next capability without passing caps
Jiqian Chen [Wed, 23 Apr 2025 07:42:08 +0000 (09:42 +0200)]
drivers/pci: Get next capability without passing caps

Modify function pci_find_next_cap_ttl to support returning position
of next capability when size "n" is zero.

That can help caller to get next capability offset if caller just
has a information of current capability offset.

That will be used in a follow-on change.

Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 days agoxen/riscv: Increase XEN_VIRT_SIZE
Oleksii Kurochko [Wed, 23 Apr 2025 07:41:42 +0000 (09:41 +0200)]
xen/riscv: Increase XEN_VIRT_SIZE

A randconfig job failed with the following issue:
  riscv64-linux-gnu-ld: Xen too large for early-boot assumptions

The reason is that enabling the UBSAN config increased the size of
the Xen binary.

Increase XEN_VIRT_SIZE to reserve enough space, allowing both UBSAN
and GCOV to be enabled together, with some slack for future growth.

Additionally, add checks to verify that XEN_VIRT_START is 1GB-aligned
and XEN_VIRT_SIZE is 2MB-aligned to reduce the number of page tables
needed for the initial mapping. In the future, when 2MB mappings are
used for .text (rx), .rodata (r), and .data (rw), this will also help
reduce TLB pressure.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 days agox86/EFI: correct mkreloc header (field) reading
Jan Beulich [Wed, 23 Apr 2025 07:39:44 +0000 (09:39 +0200)]
x86/EFI: correct mkreloc header (field) reading

With us now reading the full combined optional and NT headers, the
subsequent reading of (and seeking to) NT header fields is wrong. Since
PE32 and PE32+ NT headers are different anyway (beyond the image base
oddity extending across both headers), switch to using a union. This
allows to fetch the image base more directly then.

Additionally add checking to map_section(), which would have caught at
least the wrong (zero) image size that we previously used.

Fixes: f7f42accbbbb ("x86/efi: Use generic PE/COFF structures")
Reported-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
13 days agoxen: debug: gcov: add condition coverage support
Volodymyr Babchuk [Tue, 22 Apr 2025 23:29:23 +0000 (16:29 -0700)]
xen: debug: gcov: add condition coverage support

Condition coverage, also known as MC/DC (modified condition/decision
coverage) is a coverage metric that tracks separate outcomes in
boolean expressions.

This patch adds CONFIG_CONDITION_COVERAGE option to enable MC/DC for
GCC. Clang is not supported right now because Xen can't emit version
10 of LLVM profile data, where MC/DC support was added.

Also, use the opportunity to convert COV_FLAGS to cov-cflags-y, which
reduces amount of ifeqs in Rules.mk. Otherwise this patch had to add
another nesting level with "ifeq ($(CONFIG_CONDITION_COVERAGE),y)".

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
13 days agoCI: switch arm64 XTF test runner to qemu-xtf.sh
Denis Mukhin [Tue, 22 Apr 2025 16:18:59 +0000 (16:18 +0000)]
CI: switch arm64 XTF test runner to qemu-xtf.sh

Hook arm64 QEMU configuration to qemu-xtf.sh and use new script in arm64 CI
jobs.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
13 days agoCI: switch x86 EFI smoke test runner to qemu-xtf.sh
Denis Mukhin [Tue, 22 Apr 2025 16:18:53 +0000 (16:18 +0000)]
CI: switch x86 EFI smoke test runner to qemu-xtf.sh

Use qemu-xtf.sh for qemu-smoke-x86-64-gcc-efi job.

Lead time is reduced a bit since not all XTF code base is built, just the
required test.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
13 days agoCI: unify x86 XTF test runner
Denis Mukhin [Tue, 22 Apr 2025 16:18:48 +0000 (16:18 +0000)]
CI: unify x86 XTF test runner

Add test runner script qemu-xtf.sh which is allows any XTF x86 test to be
easily executed. Test runner is invoked from the qemu-smoke* jobs with the
hardcoded parameters.

Each x86 XTF job lead time is reduced a bit since only the test-related code
is built, not the entire XTF project.

Add .gitignore to avoid committing test artifacts by mistake.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
13 days agox86/alternative: Clean up headers
Andrew Cooper [Mon, 21 Apr 2025 15:31:17 +0000 (16:31 +0100)]
x86/alternative: Clean up headers

alternative.h doesn't need lib.h now that macros.h exists.  Futhermore, STR()
is already the prevailing style, so convert the final __stringify() to drop
stringify.h too.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
13 days agox86/AMD: Convert rdmsr_amd_safe() to use asm goto()
Andrew Cooper [Mon, 7 Apr 2025 15:10:57 +0000 (16:10 +0100)]
x86/AMD: Convert rdmsr_amd_safe() to use asm goto()

Unlike the WRMSR side, we can't use asm goto() unconditionally, because our
toolchain baseline doesn't support asm goto with outputs.

However, the code generation improvements are substantial enough to warrant
the duplicate implementations.

Detect support, and use asm goto() when available.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
13 days agoxen: Drop CONFIG_CC_HAS_VISIBILITY_ATTRIBUTE
Andrew Cooper [Tue, 22 Apr 2025 11:36:01 +0000 (12:36 +0100)]
xen: Drop CONFIG_CC_HAS_VISIBILITY_ATTRIBUTE

All supported toolchains now have it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
13 days agoxen: Drop CONFIG_CC_HAS_UBSAN
Andrew Cooper [Tue, 22 Apr 2025 11:35:54 +0000 (12:35 +0100)]
xen: Drop CONFIG_CC_HAS_UBSAN

All supported toolchains now have it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
13 days agoxenstored: Remove setjmp.h
Jason Andryuk [Tue, 22 Apr 2025 09:25:48 +0000 (11:25 +0200)]
xenstored: Remove setjmp.h

Use of setjmp/longjmp as removed in 2006, but the include remained.
Remove it now.

Fixes: 1bac3b49cdd4 ("Import the current version of talloc from the Samba 3 source base")
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
13 days agocompat/memory: avoid UB shifts in XENMEM_exchange handling
Jan Beulich [Tue, 22 Apr 2025 09:25:23 +0000 (11:25 +0200)]
compat/memory: avoid UB shifts in XENMEM_exchange handling

Add an early basic check, yielding the same error code as the more
thorough one the main handler would produce.

Fixes: b8a7efe8528a ("Enable compatibility mode operation for HYPERVISOR_memory_op")
Reported-by: Manuel Andreas <manuel.andreas@tum.de>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
13 days agox86/boot: add cmdline to struct boot_domain
Daniel P. Smith [Tue, 22 Apr 2025 09:24:57 +0000 (11:24 +0200)]
x86/boot: add cmdline to struct boot_domain

Add a container for the "cooked" command line for a domain. This
provides for the backing memory to be directly associated with the
domain being constructed.  This is done in anticipation that the domain
construction path may need to be invoked multiple times, thus ensuring
each instance had a distinct memory allocation.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Signed-off-by: Alejandro Vallejo <agarciav@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
13 days agox86emul: also clip repetition count for STOS
Jan Beulich [Tue, 22 Apr 2025 09:24:20 +0000 (11:24 +0200)]
x86emul: also clip repetition count for STOS

Like MOVS, INS, and OUTS, STOS also has a special purpose hook, where
the hook function may legitimately have the same expectation as to the
request not straddling address space start/end.

Fixes: 5dfe4aa4eeb6 ("x86_emulate: Do not request emulation of REP instructions beyond the")
Reported-by: Fabian Specht <f.specht@tum.de>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
13 days agoArm: rename smp_clear_cpu_maps()
Jan Beulich [Tue, 22 Apr 2025 09:23:41 +0000 (11:23 +0200)]
Arm: rename smp_clear_cpu_maps()

The function has lost all clearing operations. Use the commonly
available name (declared in xen/smp.h), that x86 also uses. This then
also addresses a Misra C:2012 rule 8.6 violation (not really covered
by the deviation we have).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
13 days agovpci/msix: use host msix table address
Stewart Hildebrand [Tue, 22 Apr 2025 09:21:54 +0000 (11:21 +0200)]
vpci/msix: use host msix table address

Introduce vmsix_table_host_{addr,base} returning the host physical MSI-X
table address and base. Use them in update_entry() and get_table().

Remove stale comment.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2 weeks agoiommu/arm: Add iommu_dt_xlate()
Oleksandr Tyshchenko [Fri, 14 Mar 2025 13:34:50 +0000 (13:34 +0000)]
iommu/arm: Add iommu_dt_xlate()

Move code for processing DT IOMMU specifier to a separate helper.
This helper will be re-used for adding PCI devices by the subsequent
patches as we will need exact the same actions for processing
DT PCI-IOMMU specifier.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
2 weeks agoxen/arm: Add capabilities to dom0less
Jason Andryuk [Wed, 16 Apr 2025 21:29:11 +0000 (17:29 -0400)]
xen/arm: Add capabilities to dom0less

Add a capabilities property to dom0less to allow building a
disaggregated system.  Only a single hardware domain and single xenstore
domain can be specified.  Multiple control domains are possible.

Introduce bootfdt.h to contain these constants.

When using the hardware or xenstore capabilities, adjust the grant and
event channel limits similar to dom0.

For a hardware domain, disallow specifying "vpl011", "nr_spis",
"multiboot,device-tree" and "passthrough" nodes.  Also, require an IOMMU
when not direct-mapped,

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 weeks agoxen/arm: dom0less use has_dtb local variable
Jason Andryuk [Wed, 16 Apr 2025 21:29:10 +0000 (17:29 -0400)]
xen/arm: dom0less use has_dtb local variable

Store the result of finding a "multiboot,device-tree" node.  This will
simplity adding hardware domain checks.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 weeks agotools/init-dom0less: Only seed legacy xenstore grants
Jason Andryuk [Wed, 16 Apr 2025 21:29:09 +0000 (17:29 -0400)]
tools/init-dom0less: Only seed legacy xenstore grants

The hardware domain is unable to seed a control domain, but we want the
control domain to use xenstore.  Rely on the hypervisor to seed dom0less
grant table entries for Xenstore, so this seeding is unnecessary.

However, that only works for the new xenstore late init.  The legacy
protocol which uses init-dom0less to populate the page still needs to
seed the grant.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 weeks agoxen/arm: dom0less seed xenstore grant table entry
Jason Andryuk [Wed, 16 Apr 2025 21:29:08 +0000 (17:29 -0400)]
xen/arm: dom0less seed xenstore grant table entry

xenstored maps other domains' xenstore pages.  Currently this relies on
init-dom0less or xl to seed the grants from Dom0.  With split
hardware/control/xenstore domains, this is problematic since we don't
want the hardware domain to be able to map other domains' resources
without their permission.  Instead have the hypervisor seed the grant
table entry for every dom0less domain.  The grant is then accessible as
normal.

C xenstored uses grants, so it can map the xenstore pages from a
non-dom0 xenstore domain.  OCaml xenstored uses foreign mappings, so it
can only run from a privileged domain (dom0).

Add a define to indicate the late alloc xsentore PFN, to better indicate
what is being checked.  Use UINT64_MAX instead of ~0ULL as the HVM_PARAM
field is a uint64_t.  UINT64_MAX is not defined, so add it.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 weeks agoxen/arm: dom0less delay xenstore initialization
Jason Andryuk [Wed, 16 Apr 2025 21:29:07 +0000 (17:29 -0400)]
xen/arm: dom0less delay xenstore initialization

To allocate the xenstore event channel and initialize the grant table
entry, the xenstore domid is neeed.  A dom0 is created before the domUs,
so it is normally available through hardware_domain.  With capabilities
and dom0less, the xenstore domain may not be created first.

Keep the population of the page and HVM_PARAM_STORE_PFN in the normal
domain construction, but delay event channel creation and grant seeding
to after all domUs are created.  HVM_PARAM_STORE_PFN now serves as
indication to setup xenstore since the device tree is no longer
immediately available.  0 means no xenstore.  ~0ULL means legacy so only
the event channel needs setup, and any other value means to seed the
page.

dom0 needs to set xs_domid when it is serving as the xenstore domain.

The domain running xenstored needs to be the handler for VIRQ_DOM_EXC,
so set that as well - it otherwise defaults to hardware domain.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 weeks agoxen/arm: dom0less hwdom construction
Jason Andryuk [Wed, 16 Apr 2025 21:29:06 +0000 (17:29 -0400)]
xen/arm: dom0less hwdom construction

When creating a hardware domain, have the dom0less code call
construct_hwdom() which is shared with the dom0 code.  The hardware
domain requires building that best matches the dom0 build path.  Re-use
it to keep them in sync.

The device tree node of the dom0less config is now passed into
construct_hwdom().  dom0 uses /chosen for process_shm while a hwdom will
use the value from its dom0less device tree node.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 weeks agoxen: introduce hardware domain create flag
Daniel P. Smith [Wed, 16 Apr 2025 21:29:05 +0000 (17:29 -0400)]
xen: introduce hardware domain create flag

Add and use a new internal create domain flag to specify the hardware
domain.  This removes the hardcoding of domid 0 as the hardware domain.

This allows more flexibility with domain creation.

The assignment of d->cdf is moved later so CDF_hardware is added for the
late_hwdom case.  Also old_hwdom has the flag removed to reflect the
change.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2 weeks agovmx: Don't open-code vmresume/vmlaunch instructions
Teddy Astie [Thu, 17 Apr 2025 14:24:44 +0000 (14:24 +0000)]
vmx: Don't open-code vmresume/vmlaunch instructions

binutils 2.25 has support for assembling vmresume/vmlaunch
instructions, so we don't need to open-code the byte sequences
for these opcodes anymore.

Signed-off-by: Teddy Astie <teddy.astie@vates.tech>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 weeks agox86: Drop asm/byteorder.h
Andrew Cooper [Fri, 28 Mar 2025 11:19:23 +0000 (11:19 +0000)]
x86: Drop asm/byteorder.h

With the common code moved fully onto xen/byteorder.h, clean up the dregs.

It turns out that msi.h has not needed byteorder.h since the use of
__{BIG,LITTLE}_ENDIAN_BITFIELD was dropped in commit d58f3941ce3f ("x86/MSI:
use standard C types in structures/unions").

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2 weeks agoriscv: Remove asm/byteorder.h
Andrew Cooper [Fri, 28 Mar 2025 11:50:16 +0000 (11:50 +0000)]
riscv: Remove asm/byteorder.h

With the common code moved fully onto xen/byteorder.h, clean up the dregs.

The use of byteorder.h in io.h appears to have been copy&paste from ARM.  It's
not needed, but macros and types are.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2 weeks agoppc: Drop asm/byteorder.h
Andrew Cooper [Fri, 28 Mar 2025 13:10:58 +0000 (13:10 +0000)]
ppc: Drop asm/byteorder.h

With the common code moved fully onto xen/byteorder.h, clean up the dregs.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Shawn Anastasio <sanastasio@raptorengineering.com>
2 weeks agoarm: Remove asm/byteorder.h
Andrew Cooper [Fri, 28 Mar 2025 13:11:06 +0000 (13:11 +0000)]
arm: Remove asm/byteorder.h

With the common code moved fully onto xen/byteorder.h, clean up the dregs.

Sort includes in some files while swapping over to xen/byteorder.h.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2 weeks agoxen/common: Switch {asm -> xen}/byteorder.h
Andrew Cooper [Fri, 28 Mar 2025 13:06:42 +0000 (13:06 +0000)]
xen/common: Switch {asm -> xen}/byteorder.h

Sort the includes.  Drop useless includes of xen/types.h

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2 weeks agoxsm/flask: Switch {asm -> xen}/byteorder.h
Andrew Cooper [Fri, 28 Mar 2025 13:02:53 +0000 (13:02 +0000)]
xsm/flask: Switch {asm -> xen}/byteorder.h

Sort the includes while at it.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
2 weeks agocrypto/vmac: Switch to xen/byteswap.h
Lin Liu [Mon, 18 Oct 2021 10:32:39 +0000 (10:32 +0000)]
crypto/vmac: Switch to xen/byteswap.h

This file has its own implementation of swap bytes. Clean up
the code with xen/byteswap.h.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 weeks agoxen: Remove old byteorder infrastructure
Lin Liu [Thu, 21 Oct 2021 02:54:19 +0000 (02:54 +0000)]
xen: Remove old byteorder infrastructure

It is no longer used.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 weeks agoxen/decompressors: Use new byteorder infrastructure
Lin Liu [Fri, 5 Nov 2021 08:15:29 +0000 (04:15 -0400)]
xen/decompressors: Use new byteorder infrastructure

unaligned.h already includes byteorder.h, so most can simply be dropped.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2 weeks agoxen/arch: Switch to new byteorder infrastructure
Lin Liu [Mon, 9 May 2022 05:47:10 +0000 (06:47 +0100)]
xen/arch: Switch to new byteorder infrastructure

This needs to be done in several steps, because of common vs arch issues.
Start by using the new common infrastructure inside the arch infrastructure.

libelf-private.h is awkward, and the only thing in Xen using swab??()
directly.  It needs updating at the same time.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 weeks agoxen/decompressors: Remove use of *_to_cpup() helpers
Lin Liu [Thu, 21 Oct 2021 02:52:39 +0000 (02:52 +0000)]
xen/decompressors: Remove use of *_to_cpup() helpers

These wrappers simply hide a deference, which adds to the cognitive complexity
of reading the code.  As such, they're not going to be included in the new
byteswap infrastructure.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 weeks agoxen/device-tree: Remove use of *_to_cpup() helpers
Lin Liu [Thu, 21 Oct 2021 02:52:39 +0000 (03:52 +0100)]
xen/device-tree: Remove use of *_to_cpup() helpers

These wrappers simply hide a deference, which adds to the cognitive complexity
of reading the code.  As such, they're not going to be included in the new
byteswap infrastructure.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Bertrand Marquis <bertrand.marquis@arm.com>
2 weeks agoxen/lib: Switch to xen/byteorder.h
Lin Liu [Wed, 20 Oct 2021 04:29:46 +0000 (04:29 +0000)]
xen/lib: Switch to xen/byteorder.h

In divmod.c, additionally swap xen/lib.h for xen/macros.h as only ABS() is
needed.

In find-next-bit.c, ext2 has nothing to do with this logic.  It was a local
modification when the logic was imported from Linux, because Xen didn't have a
suitable helper at the time.

The new infrastructure does have a suitable primitive, so use it.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 weeks agodrivers/smmu-v3: Fix impending MISRA R20.6 violation
Andrew Cooper [Wed, 16 Apr 2025 10:54:04 +0000 (11:54 +0100)]
drivers/smmu-v3: Fix impending MISRA R20.6 violation

cpu_to_le64() is about to become a macro, at which point the #ifdef in the
middle of it becomes undefined behaviour.

Use a local variable to prepare strtab, where the #ifdef is fine to use.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
2 weeks agoxen: Implement common byte{order,swap}.h
Lin Liu [Mon, 9 May 2022 05:47:10 +0000 (01:47 -0400)]
xen: Implement common byte{order,swap}.h

The current swab??() infrastructure is unnecessarily complicated, and can be
replaced entirely with compiler builtins.

All supported compilers provide __BYTE_ORDER__ and __builtin_bswap??().

Nothing in Xen cares about the values of __{BIG,LITTLE}_ENDIAN; just that one
of them is defined.  Therefore, centralise their definitions in xen/config.h

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 weeks agoxen/percpu: NUMA-position the per-CPU area
Andrew Cooper [Thu, 17 Apr 2025 08:14:03 +0000 (09:14 +0100)]
xen/percpu: NUMA-position the per-CPU area

This seems to have been quite an oversight in Xen's NUMA support, albeit it
probably because NUMA was arch-specific at first.

This is unlikely to be useful for CONFIG_SEPARATE_XENHEAP builds, but that's
only ARM32 right now, and unlikely to be interested in NUMA.

Take the opportunity to sort the includes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 weeks agox86/HVM: update repeat count upon nested lin->phys failure
Jan Beulich [Thu, 17 Apr 2025 08:01:19 +0000 (10:01 +0200)]
x86/HVM: update repeat count upon nested lin->phys failure

For the X86EMUL_EXCEPTION case the repeat count must be correctly
propagated back. Since for the recursive invocation we use a local
helper variable, its value needs copying to the caller's one.

While there also correct the off-by-1 range in the comment ahead of the
function (strictly speaking for the "DF set" case we'd need to put
another, different range there as well).

Fixes: 53f87c03b4ea ("x86emul: generalize exception handling for rep_* hooks")
Reported-by: Manuel Andreas <manuel.andreas@tum.de>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 weeks agoArm: cpu_*_map adjustments
Jan Beulich [Thu, 17 Apr 2025 08:00:41 +0000 (10:00 +0200)]
Arm: cpu_*_map adjustments

First, they all start out zeroed. There's no point doing an initial
cpumask_clear() on them.

Next, only cpu_online_map may be altered post-boot, and even that only
rarely. Add respective placement attributes.

Finally, cpu_present_map really isn't anything more than an alias of
cpu_possible_map. Avoid the copying, and have the linker provide the
symbol (if needed in the first place; it is needed right now as
common code references the symbol).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2 weeks agoEFI: Avoid crash calling PrintErrMesg from efi_multiboot2
Frediano Ziglio [Thu, 17 Apr 2025 07:59:41 +0000 (09:59 +0200)]
EFI: Avoid crash calling PrintErrMesg from efi_multiboot2

Although code is compiled with -fpic option data is not position
independent. This causes data pointer to become invalid if
code is not relocated properly which is what happens for
efi_multiboot2 which is called by multiboot entry code.

Code tested adding
   PrintErrMesg(L"Test message", EFI_BUFFER_TOO_SMALL);
in efi_multiboot2 before calling efi_arch_edd (this function
can potentially call PrintErrMesg).

Before the patch (XenServer installation on Qemu, xen replaced
with vanilla xen.gz):
  Booting `XenServer (Serial)'Booting `XenServer (Serial)'
  Test message: !!!! X64 Exception Type - 0E(#PF - Page-Fault)  CPU Apic ID - 00000000 !!!!
  ExceptionData - 0000000000000000  I:0 R:0 U:0 W:0 P:0 PK:0 SS:0 SGX:0
  RIP  - 000000007EE21E9A, CS  - 0000000000000038, RFLAGS - 0000000000210246
  RAX  - 000000007FF0C1B5, RCX - 0000000000000050, RDX - 0000000000000010
  RBX  - 0000000000000000, RSP - 000000007FF0C180, RBP - 000000007FF0C210
  RSI  - FFFF82D040467CE8, RDI - 0000000000000000
  R8   - 000000007FF0C1C8, R9  - 000000007FF0C1C0, R10 - 0000000000000000
  R11  - 0000000000001020, R12 - FFFF82D040467CE8, R13 - 000000007FF0C1B8
  R14  - 000000007EA33328, R15 - 000000007EA332D8
  DS   - 0000000000000030, ES  - 0000000000000030, FS  - 0000000000000030
  GS   - 0000000000000030, SS  - 0000000000000030
  CR0  - 0000000080010033, CR2 - FFFF82D040467CE8, CR3 - 000000007FC01000
  CR4  - 0000000000000668, CR8 - 0000000000000000
  DR0  - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
  DR3  - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
  GDTR - 000000007F9DB000 0000000000000047, LDTR - 0000000000000000
  IDTR - 000000007F48E018 0000000000000FFF,   TR - 0000000000000000
  FXSAVE_STATE - 000000007FF0BDE0
  !!!! Find image based on IP(0x7EE21E9A) (No PDB)  (ImageBase=000000007EE20000, EntryPoint=000000007EE23935) !!!!

After the patch:
  Booting `XenServer (Serial)'Booting `XenServer (Serial)'
  Test message: Buffer too small
  BdsDxe: loading Boot0000 "UiApp" from Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(462CAA21-7614-4503-836E-8AB6F4662331)
  BdsDxe: starting Boot0000 "UiApp" from Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(462CAA21-7614-4503-836E-8AB6F4662331)

This partially rollback commit 00d5d5ce23e6.

Fixes: 9180f5365524 ("x86: add multiboot2 protocol support for EFI platforms")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>