Commit Graph
49764 Commits
Author SHA1 Message Date
Oleksii Kurochko 40e5a4ee55 xen/riscv: add p2m context switch handling for VSATP and HGATP
Introduce helpers to manage VS-stage and G-stage translation state during
vCPU context switches.

As VSATP and HGATP cannot be updated atomically, clear VSATP on context
switch-out to prevent speculative VS-stage translations from being associated
with an incorrect VMID. On context switch-in, restore HGATP and VSATP in the
required order.

Add p2m_handle_vmenter() to perform VMID management and issue TLB flushes
only when required (e.g. on VMID reuse or generation change).

This provides the necessary infrastructure for correct p2m context switching
on RISC-V.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-24 10:30:01 +01:00
Jan Beulich fcd373dc72 x86/shadow: adjust monitor table prealloc amount
While 670d6b908f ('x86 shadow: Move the shadow linear mapping for
n-on-3-on-4 shadows so') bumped the amount by one too little for the
32-on-64 case (which luckily was dead code, and hence a bump wasn't
necessary in the first place), 0b841314da ('x86/shadow:
sh_{make,destroy}_monitor_table() are "even more" HVM-only'), dropping
the dead code, then didn't adjust the amount back. Yet even the original
amount was too high in certain cases. Switch to pre-allocating just as
much as is going to be needed.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-24 10:29:58 +01:00
Jan Beulich 88f7ce5f57 x86/shadow: vCPU-s never have "no mode"
With an initial mode installed by shadow_vcpu_init(), there's no need
for sh_update_paging_modes() to deal with the "mode is still unset"
case. Leave an assertion, though.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-24 10:29:56 +01:00
Jan Beulich 06dfcb7f61 x86/shadow: make monitor table create/destroy more consistent
While benign at present, it is still a little fragile to operate on a
wrong "old_mode" value in sh_update_paging_modes(). This can happen when
no monitor table was present initially - we'd create one for the new
mode without updating old_mode. Correct this in two ways, each of which
would be sufficient on its own: Once by adding "else" to the second of
the involved if()s in the function, and then by setting the correct
initial mode for HVM domains in shadow_vcpu_init().

Further use the same predicate (paging_mode_external()) consistently
when dealing with shadow mode init/update/cleanup, rather than a mix of
is_hvm_vcpu() (init), is_hvm_domain() (update), and
paging_mode_external() (cleanup).

Finally drop a redundant is_hvm_domain() from inside the bigger if()
(which is being converted to paging_mode_external()) in
sh_update_paging_modes().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-24 10:29:55 +01:00
Jan Beulich 227b86fee0 x86/shadow: drop is_hvm_...() where easily possible
These emulation related functions are involved in HVM handling only, and
in some cases they even invoke such checks after having already done
things which are valid for HVM domains only. OOS active also implies HVM.
In sh_remove_all_mappings() one of the two checks is redundant with an
earlier paging_mode_external() one (the other, however, needs to stay).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-24 10:29:47 +01:00
Jan Beulich 259dc9c485 x86/shadow: sh_rm_write_access_from_sl1p() is HVM-only
The function is used from (HVM-only) OOS code only - replace the
respective #ifdef inside the function to make this more obvious. (Note
that SHOPT_OUT_OF_SYNC won't be set when !HVM, so the #ifdef surrounding
the function is already sufficient.)

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew cooper <andrew.cooper3@citrix.com>
2026-02-24 10:29:47 +01:00
Stewart Hildebrand de963f81ef vpci/msix: fix typo
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
2026-02-24 09:34:29 +01:00
Roger Pau Monne ac607edc2e x86/p2m: clarify foreign map handling in p2m_entry_modify()
Introduce an extra check and comment to ensure the outer caller has
possibly taken an extra reference on the foreign page that's about to be
removed from the p2m.  Otherwise the put_page() in p2m_entry_modify() won't
be safe to do ahead of the entry being removed form the p2m and any cached
states purged.

While there also replace the error codes for unreachable paths to use
EILSEQ.

No functional change intended.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-02-24 09:34:29 +01:00
Jan Beulich 5eb84d6c99 x86/bitops: drop redundant casts from find_next{,_zero}_bit()
It's not clear why they were put in place - a__ is of the very type
already.

No change in generated code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-23 08:43:46 +01:00
Jan Beulich 0e6f9fbb8a x86/bitops: adjust partial first word handling in __find_next{,_zero}_bit()
There's no need to subtract "bit" in what is passed to __scanbit(), as the
other bits are zero anyway after the shift (in __find_next_bit()) or can
be made so (in __find_next_zero_bit()) by flipping negation and shift. (We
actually leverage the same facts in find_next{,_zero}_bit() as well.) This
way in __scanbit() the TZCNT alternative can be engaged.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-23 08:43:29 +01:00
Daniel P. Smith 0c79dde780 common/domctl: xsm update for get_domain_state access
When using XSM Flask, passing DOMID_INVALID will result in a NULL pointer
reference from the passing of NULL as the target domain to
xsm_get_domain_state(). Simply not invoking xsm_get_domain_state() when the
target domain is NULL opens the opportunity to circumvent the XSM
get_domain_state access check. This is due to the fact that the call to
xsm_domctl() for get_domain_state op is a no-op check, deferring to
xsm_get_domain_state().

Modify the helper get_domain_state() to ensure the requesting domain has
get_domain_state access for the target domain, whether the target domain is
explicitly set or implicitly determined with a domain state search. In the case
of access not being allowed for a domain found during an implicit search, the
search will continue to the next domain whose state has changed.

Fixes: 3ad3df1bd0 ("xen: add new domctl get_domain_state")
Reported-by: Chris Rogers <rogersc@ainfosec.com>
Reported-by: Dmytro Firsov <dmytro_firsov@epam.com>
Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-02-23 08:42:15 +01:00
Abdelkareem Abdelsaamad 0294292b4c x86/svm: Add Enumerations for the SVM virtual NMI
Introduce the cpuid bit for the SVM vNMI feature support for the x86\AMD
platforms. The feature support is indicated by the CPUID
Fn8000_000A_EDX[25] = 1.

Add defines for the three SVM's Virtual NMI (vNMI) managements bits in the
VMCB structure's vintr_t:

vintr_t(11) - Virtual NMI is pending.
vintr_t(12) - Virtual NMI is masked.
vintr_t(26) - Enable NMI virtualization.

Signed-off-by: Abdelkareem Abdelsaamad <abdelkareem.abdelsaamad@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-23 08:41:32 +01:00
Jan Beulich e2d4157fb5 x86/shadow: don't use #if in macro invocations
As per the standard this is UB, i.e. we're building on a defacto extension
in the compilers we use. Misra C:2012 rule 20.6 disallows this altogether,
though. Use helper always-inline functions instead.

In sh_audit_l1_table(), along with reducing the scope of "gfn", which now
isn't used anymore by the if() side of the conditional, also reduce the
scope of two other adjacent variables.

For audit_magic() note that both which parameters are needed and what
their types are is attributed to AUDIT_FAIL() accessing variables which
aren't passed as arguments to it.

No functional change intended. Of course codegen does change with this,
first and foremost in register allocation.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
2026-02-23 08:41:07 +01:00
Jan Beulich a94c5fd829 x86/MCE: restore CPU vendor reporting to the outside world
The records reported used to contain Linux enumerators. We first broke
that connection when purging unused ones, and then again when switching to
the bit mask forms.

Fixes: 4084130511 ("x86/cpu: Drop unused X86_VENDOR_* values")
Fixes: 0cd074144c ("x86/cpu: Renumber X86_VENDOR_* to form a bitmap")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
2026-02-23 08:39:58 +01:00
Jan Beulich 20f7edd97c x86/shadow: use lighter-weight mode checks
shadow_mode_...(), with the exception of shadow_mode_enabled(), are
shorthands for shadow_mode_enabled() && paging_mode_...(). While
potentially useful outside of shadow-internal functions, when we already
know that we're dealing with a domain in shadow mode, the "paging"
checks are sufficient and cheaper. While the "shadow" ones commonly
translate to a MOV/AND/CMP/Jcc sequence, the "paging" ones typically
resolve to just TEST+Jcc.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-23 08:38:48 +01:00
Jan Beulich cbfed8361b x86/shadow: don't generate bogus "domain dying" trace entry from sh_page_fault()
When in 3-level guest mode we help a guest to stay alive, we also
shouldn't emit a trace entry to the contrary. Move the invocation up
into the respective #ifdef, noting that while this moves it into the
locked region, emitting trace records with the paging lock held is okay
(as done elsewhere as well), just needlessly increasing lock holding
time a little.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-23 08:38:07 +01:00
Jan Beulich 5d45c8202d x86/shadow: call sh_update_cr3() directly from sh_page_fault()
There's no need for an indirect call here, as the mode is invariant
throughout the entire paging-locked region. All it takes to avoid it is
to have a forward declaration of sh_update_cr3() in place.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-23 08:37:49 +01:00
Jan Beulich ff78502db0 x86/shadow: reduce explicit log-dirty recording for HVM
validate_guest_pt_write(), by calling sh_validate_guest_entry(), already
guarantees the needed update of log-dirty information. Move the
operation into the sole code path needing it (when SHOPT_SKIP_VERIFY is
enabled), making clear that only one such call is needed.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-23 08:37:13 +01:00
Sohil Mehta 0acaba1257 x86/cpu/intel: Limit the non-architectural constant_tsc model checks
X86_FEATURE_CONSTANT_TSC is a Linux-defined, synthesized feature flag.
It is used across several vendors. Intel CPUs will set the feature when
the architectural CPUID.80000007.EDX[1] bit is set. There are also some
Intel CPUs that have the X86_FEATURE_CONSTANT_TSC behavior but don't
enumerate it with the architectural bit.  Those currently have a model
range check.

Today, virtually all of the CPUs that have the CPUID bit *also* match
the "model >= 0x0e" check. This is confusing. Instead of an open-ended
check, pick some models (INTEL_IVYBRIDGE and P4_WILLAMETTE) as the end
of goofy CPUs that should enumerate the bit but don't.  These models are
relatively arbitrary but conservative pick for this.

This makes it obvious that later CPUs (like Family 18+) no longer need
to synthesize X86_FEATURE_CONSTANT_TSC.

Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250219184133.816753-14-sohil.mehta@intel.com
Link: https://git.kernel.org/tip/fadb6f569b10bf668677add876ed50586931b8f3
[Port to Xen]
Signed-off-by: Kevin Lampis <kevin.lampis@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-20 10:37:42 +00:00
Andrew Cooper 52e801093b CI: Extend eclair-*-allcode to enable as much as possible
On x86, this is basically everything.

For ARM, CONFIG_MPU and CONFIG_MMU are mutually exclusive (with
CONFIG_STATIC_MEMORY in the mix), as well as CONFIG_NEW_VGIC being mutually
exclusive with the other VGIC infrastructure.

No functional change, but a lot of new Eclair reports (non-blocking).

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Bertrand Marquis <bertrand.marquis@arm.com>
2026-02-18 16:12:43 +00:00
Jan Beulich bada585003 domain: skip more stuff for idle's vCPU-s in vcpu_create()
Nothing hypercall-related needs setting up there. Nor do we need to
check whether the idle domain is shutting down - it never will.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
2026-02-18 10:18:53 +01:00
Jan Beulich af6fc34e20 Arm: tighten translate_get_page()
Permitting writes when the P2M type says "read-only" can't be correct.

Fixes: 1661158723 ("xen/arm: Extend copy_to_guest to support copying from/to guest physical address")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2026-02-18 10:17:39 +01:00
Oleksii Kurochko 8ca1a1d5e6 xen/riscv: build setup code as .init
At the moment, all code and data in setup.c are marked with __init or
__initdata, which is intended to remain this way. Leverage this by using
setup.init.o instead of setup.o in Makefile.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-18 10:17:06 +01:00
Oleksii Kurochko ad535118f0 xen/riscv: implement arch_vcpu_{create,destroy}()
Introduce architecture-specific functions to create and destroy VCPUs.
Note that arch_vcpu_create() currently returns -EOPNOTSUPP, as the virtual
timer and interrupt controller are not yet implemented.

Add callee-saved registers to struct arch_vcpu which are  used to preserve
Xen’s own execution context when switching between vCPU stacks.
It is going to be used in the following way (pseudocode):
  context_switch(prev_vcpu, next_vcpu):
    ...

    /* Switch from previous stack to the next stack. */
    __context_switch(prev_vcpu, next_vcpu);

    ...
    schedule_tail(prev_vcpu):
        Save and restore vCPU's CSRs.
The Xen-saved context allows __context_switch() to switch execution
from the previous vCPU’s stack to the next vCPU’s stack and later resume
execution on the original stack when switching back.

During vCPU creation, the Xen-saved context is going to be initialized
with:
  - SP pointing to the newly allocated vCPU stack.
  - RA pointing to a helper that performs final vCPU setup before
    transferring control to the guest.

As part of this change, add continue_new_vcpu(), which will be used after
the first context_switch() of a new vCPU. Since this functionality is not
yet implemented, continue_new_vcpu() is currently provided as a stub.
The prev argument is going to be set by RISC-V ABI (prev will be stored in
a0) when __context_swtich() will be introduced and called from
context_switch().

Update the STACK_SIZE definition.

Introduce struct cpu_info to store per-vCPU state that lives at the top
of the vCPU's stack.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-18 10:16:34 +01:00
Juergen Gross ebf99a1627 tools/xenstored: fix live update
Commit e5b0a94055 ("tools/xenstored: Auto-introduce domains") broke
xenstored live update, as init_domains() will be skipped when live
update is detected to have happened. This will leave priv_domid and
store_domid set as invalid.

Fix that by calling init_domains() in live update case, too. In case
of live update skip introducing any found domains, as this will be done
when reading the live update state.

Fixes: e5b0a94055 ("tools/xenstored: Auto-introduce domains")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
2026-02-17 11:46:29 +01:00
Jan Beulich 9f4d363241 symbols: don't over-align data
Arrays of .byte or .short don't really need aligning better than 1 or 2
bytes respectively. Arrays of .long also don't need aligning to 8 bytes
(which would have happened when BITS_PER_LONG is 64 and SYMBOLS_ORIGIN is
not defined).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2026-02-17 11:45:22 +01:00
Marek Marczykowski-Górecki d41501fcf6 VT-d: fix off-by-one when handling extra RMRR ranges
add_one_user_rmrr() operates on inclusive [start,end] range, which means
the end page needs to be calculated as (start + page_count - 1).
This off-by-one error resulted in one extra pages being mapped in IOMMU
context, but not marked as reserved in the memory map. This in turns
confused PVH dom0 code, resulting in the following crash:

    (XEN) [    3.934848] d0: GFN 0x5475c (0x5475c,5,3) -> (0x46a0f4,0,7) not permitted (0x20)
    (XEN) [    3.969657] domain_crash called from arch/x86/mm/p2m.c:695
    (XEN) [    3.972568] Domain 0 reported crashed by domain 32767 on cpu#0:
    (XEN) [    3.975527] Hardware Dom0 crashed: rebooting machine in 5 seconds.
    (XEN) [    8.986353] Resetting with ACPI MEMORY or I/O RESET_REG.

I checked other parts of this API and it was the only error like this.
Other places:
 - iommu_get_extra_reserved_device_memory() -> reserve_e820_ram() - this
   function expects exclusive range, so the code is correct
 - add_one_extra_ivmd() - this operates on start address and memory
   length

Fixes: 2d9b369913 ("IOMMU/VT-d: wire common device reserved memory API")
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2026-02-17 08:59:34 +01:00
Jason Andryuk b8f7b62e02 xen: Put wait.c behind CONFIG_VM_EVENT
wait.c is only used by vm_event.c, so build it when CONFIG_VM_EVENT is
selected.

Provide stubs of functions called from common code.  entry.S needs an
ifdef to hide the symbol from the assembly.

Also conditionalize .waitqueue_vcpu in struct vcpu to save space.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-14 01:01:33 +00:00
Andrew Cooper 3ff1030ea7 x86/fsgsbase: Make SHADOW_GS accesses safe under FRED
Under FRED, the SWAPGS instruction is disallowed.  Therefore we must use the
MSR path instead.

read_registers() is in the show_registers() path, so this change allows Xen to
render it's current state without suffering #UD (and recursing until the stack
guard page is hit).

All hardware with FRED is expected to have some kind of non-serialising access
to these registers.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-02-14 01:01:33 +00:00
Andrew Cooper 40fbf97177 x86/traps: Alter switch_stack_and_jump() for FRED mode
FRED and IDT differ by a Supervisor Token on the base of the shadow stack.
This means that switch_stack_and_jump() needs to discard one extra word when
FRED is active.

Fix a typo in the parameter name, which should be shstk_base.

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>
2026-02-14 01:01:33 +00:00
Denis Mukhin f7173bff9d xtf: fix argo test parameters
The mac-permissive= option is currently ignored because Argo configuration
parameters are comma-separated.

Fix the missing comma in the XTF test arguments.

Fixes: 150c6ef459 ("CI: add argo x86 XTF test")
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2026-02-14 01:01:33 +00:00
Andrew Cooper 9ad2c65726 xen/bitmap: Drop unused headers
Nothing in bitmap.h uses lib.h.  Reduce to just macros.h and string.h.  Drop
types.h while at it, as it comes in through bitops.h

cpumask.h and nodemask.h only include kernel.h to get container_of().  Move it
into macros.h where it belongs, cleaning it up as it goes.

acpi/numa.c was picking up printk() transitively through bitmap.h so include
lib.h directly.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Julien Grall <jgrall@amazon.com>
2026-02-14 01:01:33 +00:00
Andrew Cooper 2cc63f3b8b xen: Strip vcpu_switch_to_aarch64_mode() from PPC and RISC-V stubs
This is absolutely too much copy&paste from ARM.  All other stubs look
somewhat reasonable.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-02-14 01:01:33 +00:00
Roger Pau Monne 3dfd77003c xen: add non-executable stack note uniformly
Currently the -Wa,--noexecstack parameter is only passed to the compiler
when building assembly files, as the assembler doesn't add such note for
stack attributes.

However, the default addition of the .note.GNU-stack section is dependent
on the ELF target used.  Adjust the passing of -Wa,--noexecstack so it's
added to CFLAGS instead of AFLAGS, and hence such section is also added to
object files generated from .c sources.  This fixes the complains from the
linker about missing .note.GNU-stack section when building x86-64 Xen on
Darwin platforms.

Note we could instead pass `-z noexecstack` to the linker, but that however
would mask any possible errors or unintended mismatches from previous
steps.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-13 16:42:42 +01:00
Roger Pau Monne c13335b5c1 xen/x86: fix usage of [[:blank:]] with BSD grep
BSD grep only recognizes [[:blank:]] as a valid expression when using
extended (modern) regular expressions.  Pass -E to the grep call used in
efi-nr-fixups.

Additionally, the return from `wc -l` is space padded on BSD, and hence
the content of efi-nr-fixups is "       2", not plain "2".  Strip the
spaces in the Makefile using $(strip ...).

Fixes: 1be65ec4c8 ('x86/EFI: avoid use of GNU ld's --disable-reloc-section when possible')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-13 16:42:34 +01:00
Roger Pau Monne 1f4f85b64d cirrus-ci: add x86 XTF self-tests for macOS build
Like we do for the FreeBSD builds, introduce some basic smoke testing of
the built binary using the XTF selftest image.

Note this is only done for the x86 build, there's no ARM support in XTF
yet.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-12 19:22:54 +01:00
Roger Pau Monne 7ad6037fa1 cirrus-ci: add x86 and arm64 macOS hypervisor builds
Introduce two new build that run on macOS Cirrus-CI instances.  Those build
the hypervisor using the elf cross-toolchain from Homebrew for both x86 and
arm64.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-12 19:22:44 +01:00
Roger Pau Monne 57cf001b8c xen/tools: fix grep reporting 'illegal byte sequence' in check-endbr.sh
On macOS the default encoding is UTF-8.  The binary encoding used by the
grep matching pattern is not valid when processed as UTF-8.  Switch the
local to C just for the grep invocation to use the binary match pattern
correctly.

Suggested-by: Bertrand Marquis <bertrand.marquis@arm.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-12 19:22:38 +01:00
Roger Pau Monne 1348cb4f04 xen/tools: remove usages of stat -c in check-endbr.sh
The `-c` option to stat is not POSIX compatible, and hence prevents the
check-endbr.sh script from running reliably.

The first instance of `stat -c` can be removed by fetching the section size
from the output of objdump itself, which the script already parses to get
the VMA values.

The other two instances can be replaced by counting the lines in the
respective files.  Those files contain list of addresses, so the size in
bytes is not strictly needed, we can count the number of lines instead.

Suggested-by: Bertrand Marquis <bertrand.marquis@arm.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-12 19:22:11 +01:00
Roger Pau Monne 6ccdd6cb46 xen/x86: always consider '/' as a division in assembly
On x86 GNU assembler will consider '/' as the start of comment marker for
some ELF targets.  This is incorrect with Xen's usage, which does use '/'
in assembly files as a mathematical operator.

The behavior of the assembler can be altered by passing the --divide
option; unconditionally pass this option when available to force the
expected behavior.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-02-12 19:21:46 +01:00
Marek Marczykowski-Górecki 3ea44aa78c EFI: Fix relocating ESRT for dom0
Fix calculating the table size - it consists of a header + entries, not
just entries.
This bug caused the last entry to have garbage in its final fields,
including LowestSupportedFwVersion and CapsuleFlags, which (usually)
made fwupd able to detect firmware update availability, but refuse
actually installing it.

Fixes: dc7da0874b ("EFI: preserve the System Resource Table for dom0")
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
2026-02-12 11:35:05 +01:00
Alejandro Vallejo 5513bfd054 x86/domctl: Conditionalise x86 domctl using DCE rather than ifdef
Make them uniformly return EOPNOTSUPP when their dependent features
are absent. Otherwise the compiler loses context and they might return
ENOSYS instead.

debug_op, mem_sharing_op, p2m_audit and psr_alloc change behaviour and
return EOPNOTSUPP when compiled out, rather than ENOSYS.

While at it, remove the public headers from mem_sharing.h (forward
declarations are fine) and add a missing xen/sched.h include (for
complete struct domain definition).

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-02-12 11:34:44 +01:00
Oleksii Kurochko 8173a23dd6 xen/riscv: add support for local guest TLB flush using HFENCE.VVMA
Introduce flush_tlb_guest_local() to perform a local TLB flush of the guest's
address space for the current hart. This leverages the RISC-V HFENCE.VVMA
instruction, which is used to invalidate translations in the VS-stage of
address translation.

As for RISC-V binutils >= 2.39 is choosen, we can use hfence.vvma mnemonics
instead of defining hfence.vvma using .insn.

Although it would be possible to use sbi_remote_hfence_vvma() for this purpose,
it is unnecessary in this context since the flush is required only on the
local hart. Using the SBI call would introduce additional overhead without
benefit, resulting in unnecessary performance loss.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-12 11:33:46 +01:00
Jan Beulich c3f76328d5 sched: move vCPU exec state barriers
The barrier in vcpu_context_saved() is specifically about the clearing of
->is_running. It isn't needed when we don't clear the flag.

Furthermore, one side of the barrier being in common code, the other would
better be, too. This way, all architectures are covered (beyond any
specific needs they may have).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Julien Grall <julien@xen.org>
2026-02-12 11:32:00 +01:00
Jan Beulich d96694508a x86/PCI: avoid re-evaluation of extended config space accessibility
When, during boot, we have already correctly determined availability of
the MMCFG access method for a given bus range, there's then no need to
invoke pci_check_extcfg() again for every of the devices. This in
particular avoids ->ext_cfg to transiently indicate the wrong state.

Switch to using Xen style on lines being touched and immediately adjacent
ones.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
2026-02-11 09:21:35 +01:00
Oleksii Kurochko e1689365da xen/riscv: avoid reading hstateen0 when Smstateen is not implemented
If the Smstateen extension is not implemented, the hstateen0 CSR is
considered non-existent. Any attempt to access it will raise an
illegal-instruction exception.

Guard the hstateen0 dump with a runtime check for Smstateen support to
avoid triggering traps when dumping CSRs on systems that do not
implement this extension.

Fixes: 3babc8d2e5 ("xen/riscv: dump GPRs and CSRs on unexpected traps")
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-02-11 09:20:51 +01:00
Jan Beulich aa786d6e34 non-x86/symbols: check table sizes don't change between linking passes 2 and 3
Extend commit 1df11ccceb ("symbols: check table sizes don't change
between linking passes 2 and 3") to other ports as well.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-02-11 09:20:08 +01:00
Bertrand Marquis 2fa468919c xen: Add Darwin.mk
Xen does not provide a Darwin build configuration useable on Mac OS.
It is possible to build Xen Hypervisor (tools are not supported) with a
toolchain able to produce ELF binaries (GCC or others).

Add config/Darwin.mk to include StdGNU.mk and force
XEN_COMPILE_ARCH=unknown, ensuring Darwin builds always follow
the cross-compile path so compiling on Mac OS is always handled as a
cross compilation case.

Only compiling the hypervisor has been tested !

An example of how to build the hypervisor for arm64 on Mac OS
(tools cannot be build for now) using a compiler from brew:
- brew install aarch64-elf-gcc aarch64-elf-binutils
- make XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-elf- HOSTCC=clang -C xen

Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-10 10:24:18 +01:00
Alejandro Vallejo 15da92361b x86/kconfig: Reflow the SHADOW help message
Wasn't following the tab+2 spaces convention throughout the rest of the file.

Not a functional change.

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-02-10 10:23:10 +01:00
Bertrand Marquis f2a31b7d7c xen: Use MFLAGS for silent-mode detection
GNU make 4.4+ exposes variable overrides in MAKEFLAGS after "--" (e.g.
O=/path, FOO=bar). The silent-mode check searches for "s" and can match
an override value, forcing silent output even without -s.

Use MFLAGS for short options and filter out any long options before
searching for "s". This preserves -s detection while avoiding false
positives from overrides.

Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-02-10 10:22:53 +01:00