Commit Graph
100 Commits
Author SHA1 Message Date
Andrew Cooper c89185286c xen/gnttab: Prevent GNTTABOP_cache_flush from corrupting RO grants
Grants can be offered read-only by the owning domain.  While a domain mapping
a RO grant may have a need to invalidate the cache, it must not modify the
other-guests data while doing so.  Force-upgrade to a clean operation in this
case.

This is CVE-2026-102702, part of XSA-519.

Fixes: 18e8d22fe7 ("introduce GNTTABOP_cache_flush")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2026-10-13 13:32:17 +01:00
Andrew Cooper 1017562ac0 x86/vmx: Rework #DB intercept logic to fix VMEntry failure with BTF
The consistency checks in effect when Blocked-by-STI/MovSS are active includes
DEBUGCTL.BTF too.  Take this into account when editing PENDING_DBG.BS.

This ends up narrowing the cases where PENDING_DBG is modified.  Rework the
comment to be more precise.

This is XSA-518 / CVE-2026-79611.

Fixes: 1d3eb82598 ("x86/vtx: Work around SingleStep + STI/MovSS VMEntry failures")
Reported-by: Teddy Astie <teddy.astie@vates.tech>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-10-13 13:32:17 +01:00
Andrew Cooper 0c5ec39d91 x86/amd: Fix inverted condition in zenbleed_use_chickenbit()
The identified commit inverted the condition under which Xen chooses
to set the Zenbleed chickenbit.

Undo that, and leave a better comment explaining why.

Found by AI review of the referenced commit.

This is XSA-515 / CVE-2026-79608.

Fixes: d0c75dc4c0 ("x86/amd: Fix race editing DE_CFG")
Assisted-by: Sashiko + Opus 5.0
Reported-by: George Dunlap <dunlapg@umich.edu>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-10-13 13:32:17 +01:00
Andrew Cooper b7c0ac4467 x86/boot: Force error checking for reserve_e820_ram()
Failing to mark Xen as Reserved in the E820 is catastrophic; RAM regions get
handed to the physical memory allocator for general use.  Similarly, failure
to mark the boot modules as reserved is not going to result in a working
system.

Mark reserve_e820_ram() as __must_check, and panic() on failure.  To avoid
opencoding the range in every caller, print a general failure message in
reserve_e820_ram().

Reported-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-09-24 20:54:37 +01:00
Andrew Cooper a76479836d x86: Sort headers
... prior to making changes.

mtrr/main.c absolutely does not need to include asm/uaccess.h

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-09-24 20:54:37 +01:00
Andrew Cooper 384a4d98f8 x86/hvm: Use system descriptor type names in hvm_task_switch()
... rather than magic numbers.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-09-24 20:54:37 +01:00
Andrew Cooper 228c881efc x86/amd: Expand comment about NullSelectorClearsBase
Rework detect_zen2_null_seg_behaviour() to use the new MSR infrastructure.

Zen2 doesn't have WRMSRNS so don't bother relaxing the write.  All it will do
is insert a useless alternative.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-09-24 20:54:37 +01:00
Andrew Cooper 5838665ef1 x86/build: Remove leading space in xen.efi.S rule
It happens to be benign, but it causes emacs to ask:

  Suspicious line 194. Save anyway? (y or n)

whenever saving the file.

Fixes: da944a72fd ("x86: split xen-syms/xen.efi linking rules")
Acked-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-09-15 11:46:07 +02:00
Andrew Cooper 6bdb8d45b7 xen: Use __has_include() in xen/percpu.h
Only x86 has an asm/percpu.h.  Have the compiler only include it if it's
present, rather than symlinking an empty file.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2026-09-11 18:24:25 +01:00
Andrew Cooper 73df85da4f x86: Rename X86_ET_EXT_INTR to X86_ET_INTR and fix function names
The name X86_ET_EXT_INTR came from the VT-x code originally, but it's not
really correct.

The SDM doesn't give a concrete name, and only describes the fields as
"external interrupts".  The APM does give a concrete name of INTR, and both
Intel and AMD use the name INTR for related purposes elsewhere; the name
derives originally from #INTR which was a real pin on early processors.

Very importantly, this is distinct from ExtINT which is a type of maskable
interrupt which can be sent in an x86 system.

Therefore rename all {svm,vmx}_*_extint() to {svm,vmx}_*_intr(), as they
pertain to all maskable interrupts, not only to ExtINT interrupts.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-09-11 18:24:25 +01:00
Andrew Cooper 70cbd9a08d x86/ucode: Work around Granite Rapids erraturm GNR98
Block loads which are known to hang the system.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
Reviewed-by: Roger Pau Monné <roger@xenproject.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-09-09 18:07:32 +01:00
Andrew Cooper f3a525c259 x86/pci: Update pci_conf_write_intercept() to use pci_sbdf_t
... rather than splitting across two parameters.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-09-09 18:07:32 +01:00
Andrew Cooper 04670075bc x86/pci: Convert pci_mmcfg_{read,write}() to use pci_sbdf_t
All callers now have an sbdf.  Pass it down directly, rather than splitting
into three parameters.

In turn this shows that bus and devfn could never be out of bounds, so drop
those checks too.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-09-09 18:07:32 +01:00
Andrew Cooper e1ddc74203 x86/pv: Convert struct mmio_ro_emulate_ctxt to use pci_sbdf_t
This will be used to simplify some call chains.  Reposition the new field to
avoid creating a interior hole.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-09-09 18:07:32 +01:00
Andrew Cooper 1ff8c6e289 x86/cpu: Rewrite initialize_cpu_data() for clarity
Without passing opinion on the behaviour of this function, it is deceptive to
read (I've twice now mistaken it for resetting boot_cpu_data), and
inefficient.

Instead of having a 256 byte object on the stack and a double copy, copy
boot_cpu_data directly, then reset parts of cpu_data[cpu] in place.  Leave
some comments behind explaining what's happening.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-09-09 18:07:32 +01:00
Andrew Cooper 715f2c3c25 xen/arm: Rewrite arm_smccc_*() to return by value
Use statement expressions to return struct arm_smccc_res which makes the code
read a lot more normally, and avoids needing to pass in NULL in order to skip
return information.

More importantly, it removes the local implementation of __count_args() which
is off by two and deeply confusing to try and follow.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
2026-09-07 11:18:11 +01:00
Andrew Cooper 1b5ff89cc3 xen/arm: Rewrite arm_smccc_smc() for arm64
SMCCC v1.0 says that x4 through x17 may be clobbered.  SMCCC v1.1 says they
are strictly preserved, and SMCCC v1.2 permits them to contain extra return
values.

Xen deals with this by having __arm_smccc_1_0_smc() as an out-of-line
function, but this causes awful code generation in arm_smccc_smc().
cpus_have_const_cap() is opaque to the optimiser, so we end up with one basic
block doing the reasonably-ok arm_smccc_1_1_smc() code generation and a second
basic block setting up all 8 input registers even when they're not needed,
spilling or discarding x8 through x17, and calling an out-of-line function.

Remove __arm_smccc_1_0_smc() entirely, and rewrite arm_smccc_smc() to declare
x4 through x17 as clobbered.

This fully inlines the SMC, is a single basic block which instructs the
compiler to spill or discard the potentially clobbered registers, and only
sets up the necessary number of arguments for the call.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
2026-09-07 11:18:11 +01:00
Andrew Cooper 979251a377 xen/arm: Clean up 32bit arm_smccc_1_1_smc()
... before making a related copy of it.

 * Drop __constraints() so the output parameters are visible in the same block
   as they're defined.  Use PASTE() rather than opencoding it.
 * Adjust the indentation of trailing \'s for consistency.
 * Drop the newline at the end of the instruction.
 * Indent the if condition correctly.  ___res is always of type
   arm_smccc_res (declared in __declare_arg_0()), so drop the typeof().
 * Drop arm_smccc_1_0_smc() as it has no users.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
2026-09-07 11:18:11 +01:00
Andrew Cooper b128b74cf8 xen/arm: Introduce arm_smccc_guest_smc()
Both {get,set}_user_reg() are out-of-line functions, leading to awful code
generation.

Introduce arm_smccc_guest_smc() to operate directly on guest registers.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
2026-09-07 11:18:11 +01:00
Andrew Cooper 95302b3943 xen/arm: Fix evaluation of parameters for SMCCC calls
Contrary to what was claimed in commit 67bcf5eae7 ("xen/arm: Simplify type
handling for SMCCC declarations"), there is an important reason to retain the
intermediate variable.  It is unsafe to have any logic between the assignment
of the register variables and the asm() block they're used in.

This logically reverts commit 67bcf5eae7 ("xen/arm: Simplify type handling
for SMCCC declarations") while retaining the conversions from commit
7f15d5d132 ("xen/treewide: More typeof() -> auto conversions").

Adjust __declare_arg_0() to match.  It happens to be safe because it's the
first register expression once all macros are expanded, but it really should
be consistent with the others.

Leave a comment explaining why they must be written like this.

Fixes: 67bcf5eae7 ("xen/arm: Simplify type handling for SMCCC declarations")
Reported-by: Jan Setje-Eilers <Jan.SetjeEilers@oracle.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
2026-09-07 11:18:11 +01:00
Andrew Cooper b4a671acf1 x86/pci: Perform XSM checks on the correct device in pci_conf_write_intercept()
The requested PCI segment needs including in the call to
xsm_pci_config_permission().  Otherwise in a multi-segment system we can check
the perimssions on one device but operate on a different one.

This is only not a vulnerability because pci_conf_write_intercept() is only
reachable by the hardware domain.

Fixes: 300bb048ca ("x86/PCI: make all config space writes subject to XSM checking")
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-09-03 09:45:16 +01:00
Andrew Cooper cfad3bc123 x86/bitops: Remove ADDR
All this does is obfuscate the usage sites.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-09-02 21:44:30 +01:00
Andrew Cooper cdeace021b x86/bitops: Remove CONST_ADDR
All this does is obfuscate the usage sites.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-09-02 21:44:30 +01:00
Andrew Cooper 9b24af44e5 arm/bitops: Drop unused ADDR macros
These are unused and do not want to gain new users.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-09-02 21:44:30 +01:00
Andrew Cooper 5504b16eea xen/arm: Don't pad between function with x86 nops
This was copy&paste from x86.  It causes the padding between functions to be:

  a000026dd64:   90909090        adrp    x16, 9ff2147d000 <start-0xded83000>

rather than:

  a000026dd64:   00000000        udf     #0

No functional change.

Fixes: 5da0d3123c ("arm: entry.S and head.S")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2026-09-01 22:33:57 +01:00
Andrew Cooper 0345b835dc x86/pagewalk: Read guest PTEs with ACCESS_ONCE()
This has been a plain C read for as far back as I can trace in history.

Research into invented-loads has flagged it as a possible vulnerability.
After analysis, it is believed to be a bug only, not a security vulnerability.

The analysis suggests that we can read one value out of the guest, operate on
another, and that this could be an in-guest privliege escalation.  Any entity
in the guest able to modify the pagetables already has full privilege, so
while Xen can potentially malfunction, the effects don't cross a privilege
boundary.

The analysis also suggests that this is worse for shadow guests because we may
put the TOCTOU entry in the shadows, but this is inaccurate.  What we put in
the shadows is still translated under the P2M and refers to guest physical
address space.

Either way, the code fits the pattern for invented loads, and it is a risk;
harden the accesses.

Link: https://github.com/xoreaxeaxeax/schrodingers-toctou/blob/main/observer-effect/audits/audit-xen-ptwalk-RELEASE-4.21.1.md#86-per-candidate-finding
Fixes: 49f7c7364e ("Replace shadow pagetable code with shadow2.")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Roger Pau Monné <roger@xenproject.org>
2026-09-01 22:33:57 +01:00
Andrew Cooper a4049dd6ac xen/argo: Command line handling improvements
Treat "argo" on the command line as a positive boolean, rather than requiring
the user to pass "argo=1/on/enable/true".

Move both opt_argo* variables into __ro_after_init.  They're set during
command line parsing and never modified thereafter.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
2026-09-01 22:33:57 +01:00
Andrew Cooper 452ee45ee1 ARM/vgic: Clean up vgic_v{2,3}_setup_hw()
vgic_v{2,3}_setup_hw()'s callers are __init, so they should be too.
vgic_v{2,3}_hw and gic_v2_hw_data are written once during init and
unmodified thereafter, so make them __ro_after_init.  Reposition
'bool enabled' in these structures to fit in the tail padding, removing
8 bytes from their size when paddr_t is 8B.

While at it, drop dead vgic_v3_setup_hw() dummy implementation
from vgic/vgic.c. GICV3 depends on !NEW_VGIC.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Julien Grall <julien@xen.org>
2026-08-31 08:38:30 +02:00
Andrew Cooper 669f8c502a x86/nmi: Don't configure EvtSel repeatedly
In both setup_{k7,p6}_watchdog(), EvtSel0 is first zeroed, then written with
everything but the enable bit, then written with the enable bit.

setup_p4_watchdog() is slightly more complicated, owing to what
appears to be a bug introduced by commit 2a2bd8de16 ("Clean up NMI
watchdog handler."), which causes a second bit to be temporarily
different too.

The middle of the three writes is useless in all cases.  Drop it.

While doing this, rename the 'counter' parameter for
setup_p6_watchdog().  It is the event which is passed in; the counter
is always counter 0.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-18 12:51:59 +01:00
Andrew Cooper dfb428cb11 x86/nmi: Check MSR_MISC_ENABLE for all Intel platforms
Right now it's only checked in setup_p4_watchdog(), and not in
setup_p6_watchdog().

Perform the check in the common Intel path in setup_apic_nmi_watchdog(), and
pass misc_enable as a parameter into setup_p4_watchdog() to avoid reading it
twice.

Fixes: 0dfba864fb ("NMI watchdog support in Xen.")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-08-18 12:51:08 +01:00
Andrew Cooper a7a8c5a373 x86/nmi: Misc style fixes
* Drop trailing whitespace
 * Sort includes, dropping asm/mc146818rtc.h and asm/div64.h as unused
 * Brace position, and types

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-18 12:50:48 +01:00
Andrew Cooper 0555ad51db x86/nmi: Remove logic for pre-64bit Pentium 4 CPUs
Model 3 was the first 64bit-capable P4.  Xen won't be booting on anything
older, so remove the condition.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-18 12:50:29 +01:00
Andrew Cooper e1060c760d x86/emul: Drop the union in x86_event had have a single data field
FRED has formalised the event_data field.  It already has more uses than
given (e.g. the NMI Source Bitmap), and further uses are expected in the
future.

Collapse the union into a single field called 'data' as the struct has event
in it's name, as well as 'event' being the common name for the variable.
Refer to the FRED spec rather than keeping an out-of-date list of uses.

Adjust all users of the old names.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-18 12:50:11 +01:00
Andrew Cooper 72b05c267e x86/emul: Rename the x86_seg_* system segments
These refer to the segments themsevles, not to the registers, even if there is
a tight coupling between the two.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-08-18 12:50:11 +01:00
Andrew Cooper fddeb0fd64 x86/emul: Adjust comments in x86-types.h
x86_segment enumerates segments, not segment registers.  Adjust the comment to
make this clearer.

Fix a stray tab with the closing #endif.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-18 12:50:11 +01:00
Andrew Cooper ebc00c30c6 x86/nmi: Drop K7_NMI_EVENT
This name is misleading.

It's not possible to configure NMI or not from the event select register; that
comes from the APIC configuration for performance events.

This name is "the thing we want to count for the NMI watchdog", but that's
clearer to follow when it simply names the event.  Drop the indirection.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-17 18:46:08 +01:00
Andrew Cooper 74d16381e0 x86/nmi: Drop {reserve,release}_lapic_nmi()
With Oprofile support dropped, there are no more users of these.  Drop them.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-08-17 18:46:08 +01:00
Andrew Cooper dc5a77c6c4 x86/nmi: Fix mis-classification of watchdog NMIs
It used to be the case that cpu_data[] inherited the BSP's cpuid_level until
the AP had calculated it itself.  Following the rework, cpuid_level has a
placeholder 1 until it is calculated properly.

setup_apic_nmi_watchdog() happens to be called on the BSP after SMP bring-up,
meaning that the first call is on CPU1.  It is also positioned in the window
where cpu_data[] is wrong.

As a result, setup_p6_watchdog()'s one-time calculation of the performance
counter width falls back into Pentium compatibility mode assuming 32bit
counters.  This causes a watchdog NMI which is delayed a little (e.g. from an
SMI), to appear as if it hadn't overflowed, and therefore be considered as not
a watchdog NMI.  On systems where unknown NMIs are treated as fatal, this
results in a spurious crash.

Switch setup_p6_watchdog() to use boot_cpu_data.cpuid_level, which is how this
is checked almost everywhere else.

core2_vpmu_init() used the same pattern to look at leaf 0xa.  Despite being
init code and only running on the BSP, {boot,current}_cpu_data are different
objects, so switch it over to checking boot_cpu_data.cpuid_level too.

Fixes: 7126b7f806 ("x86/CPU: re-work populating of cpu_data[]")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-08-17 18:46:08 +01:00
Andrew Cooper 0dc67f3aab x86/alternatives: Introduce init_or_livepatch_ro_after_init
... and use it for ideal_nops and toolchain_nops_are_ideal; both of which are
invariant after arch_init_ideal_nops() has run.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-05 09:49:45 +01:00
Andrew Cooper ea20eafb46 x86/alternatives: Rework get_ideal_nops()
The {k8,p6}_nops[] arrays are both 80-byte structures indexing 45-byte
structures.  Furthermore, perhaps unusually for C, the source layout is an
obvious hint about the triangular nature of the structure.

Therefore, we can replace the pointer chase with some simple arithmetic.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-08-05 09:49:32 +01:00
Andrew Cooper 0d32eb2844 x86/alternatives: Factor out access to ideal_nops[]
... in order to rework the calculation.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-04 18:15:59 +01:00
Andrew Cooper 4ee301544e xen/livepatch: Move init_or_livepatch_* into xen/init.h
xen/livepatch.h is a fairly heavyweight header pulling in public/sysctl.h, and
a reasonable number of users care only for the init_or_livepatch_* tags.

They're arguably more init than livepatch anyway, and by moving them to
init.h, we can remove a number of includes.

The include in vsprintf was leftover from early versions of the work.  In the
version committed, d5ccf4482e ("x86, xsplice: Print payload's symbol name
and payload name in backtraces"), symbol_lookup() had been adjusted to handle
the livepatch symbol names properly.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2026-08-04 17:32:23 +01:00
Andrew Cooper 8efaec38d8 xen: Sort includes
Drop types.h when it's clearly not needed.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-08-04 17:32:23 +01:00
Andrew Cooper 2cb0ea59d2 xen/livepatch: Fix include hierarchy
xen/livepatch.h includes public/sysctl.h twice, which can be deduplicated.
xen/livepatch.h also includes asm/livepatch.h meaning that each livepatch.c
does not need to include both.

Comment the #else and #endif cases to aid legibility.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2026-08-04 17:32:23 +01:00
Andrew Cooper 7c77acd452 xen/elfstructs: Fix includes
elfstructs.h needs the stdint.h types.  Two headers arrange this manually, but
elf.h and livepatch.h do not, which breaks source files whose headers are
properly sorted.

elfstructs.h is used by tools too, so use stdint directly outside of Xen.

Clean up trailing whitespace.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2026-07-31 16:49:15 +01:00
Andrew Cooper d1aaf6358d CHANGELOG: Set release date for 4.22
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-07-29 19:13:38 +01:00
Andrew Cooper 365d2a5be3 tools/ocaml: Fix crash in Xenctrl.domain_getinfo{,list}() on ARM
The Store_field(result, 16, arch_config) sits inside an #ifdef x86, meaning
that on other architectures the pointer is not filled in.  Ocaml code then
falls over a NULL(ish) pointer (really the Val_unit used to initialise
'result') when the layout in the heap doesn't match the type system.

Rearrange alloc_domaininfo() to avoid this.  Similarly to
physinfo_arch_caps(), raise an exception if the architecture code hasn't
filled in an appropriate tag.  Move the setup of arch_domainconfig to be
common logic.

In order to simplify the addition of other architectures, remove the
arch_config variable (reusing tmp as it's touched exactly once), and rename
x86_arch_config to be arch_config so each architecture can fill in a suitable
one without needing more local variables.

Fixes: 9d683b5e37 ("tools/ocaml: Expose arch_config in domaininfo")
Fixes: 81838c9067 ("ocaml: fix arm build")
Reported-by: Julian Vetter <julian.vetter@vates.tech>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-07-29 13:38:22 +01:00
Andrew Cooper 334eea78a9 x86/vrtc: Use a real type for rtc_ioport_write()
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-07-29 13:38:22 +01:00
Andrew Cooper 50e7b8a32d x86/domctl: Reorder user_regs accesses for efficiency
The current order is derived from expanding XLAT_cpu_user_regs() which used
the x86_32 cpu_user_regs order.  This is correct for one the blocks, but not
the others.

In order to work with the prefetcher, rather than against it, loads want to be
in field order.  Make this so for the three paths reading an x86_64
cpu_user_regs.

No functional change.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-07-20 12:05:36 +01:00
Andrew Cooper bab8391805 x86/entry: Fix VERW offsets in restore_all_xen()
As explained in the comment partially in context, and contrary to what was
said in commit 8af337dfb8 ("x86/entry: Use POP_GPRS and remove
RESTORE_ALL"), the restore_all_xen() path cannot use default offsets for
SPEC_CTRL_COND_VERW.

Getting this wrong is surprisingly benign.  VERW doesn't fault for any limit
or descriptor reasons.

However, in SVM vCPU context LDTR is the guest's not Xen's.  When the segment
selector VERW uses happens to be an LDT selector, the CPU accesses the guest
LDTR in Xen context:

  (XEN) ----[ Xen-4.23.0  x86_64  debug=y  Not tainted ]----
  (XEN) CPU:    14
  (XEN) RIP:    e008:[<ffff82d0402007f2>] x86_64/entry.S#restore_all_xen+0x72/0x80
  (XEN) RFLAGS: 0000000000010002   CONTEXT: hypervisor (d3v1)
  ...
  (XEN) Xen code around <ffff82d0402007f2> (x86_64/entry.S#restore_all_xen+0x72/0x80):
  (XEN)  5f f6 44 24 7c 08 74 05 <0f> 00 6c 24 44 48 83 c4 08 48 cf 0f 1f 00 fc 0f
  ...
  (XEN) Xen call trace:
  (XEN)    [<ffff82d0402007f2>] R x86_64/entry.S#restore_all_xen+0x72/0x80
  (XEN)    [<ffff82d0402e79f6>] F nestedhap_fix_p2m+0x5f/0xc9
  (XEN)    [<ffff82d0402e7c8f>] F nestedhvm_hap_nested_page_fault+0x11e/0x22e
  (XEN)    [<ffff82d0402cd59d>] F hvm_hap_nested_page_fault+0x1b8/0x5d2
  (XEN)    [<ffff82d0402ad7de>] F svm_vmexit_handler+0xbe9/0x18b3
  (XEN)    [<ffff82d040202542>] F svm_asm_do_resume+0x162/0x172
  (XEN)
  (XEN) Pagetable walk from 000000000000fff8:
  (XEN)  L4[0x000] = 0000000000000000 ffffffffffffffff
  (XEN)
  (XEN) ****************************************
  (XEN) Panic on CPU 14:
  (XEN) FATAL PAGE FAULT
  (XEN) [error_code=0000]
  (XEN) Faulting linear address: 000000000000fff8
  (XEN) ****************************************

In this case, the guest's LDT obviously has a base of 0 and limit of 0xffff
for the segmentation checks to pass and a memory access to be attempted.

Fixes: 8af337dfb8 ("x86/entry: Use POP_GPRS and remove RESTORE_ALL")
Reported-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-07-15 16:41:00 +01:00
Andrew Cooper 1cc1f4d7a0 x86/pv: Only use the guest frame in pv_map_ldt_shadow_page()
pv_map_ldt_shadow_page() takes the whole guest PTE, adds _PAGE_RW to it, then
installs it into Xen's pagetables.  It has had this behaviour ever since LDT
support was added in 2003.

However, it allows the guest to control the software available bits and
cacheability.  This happens to be benign right now, but is bad form.

Use only the guest frame, and construct the mapping as regular RW frame, and
notably includes NX.  This is how the GDT logic already works.

Fixes: 005c272397 ("Finished virtualisation of x86 LDT")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-07-14 17:31:08 +01:00
Andrew Cooper 7ad6cfa66f arm/vgic-v3: Fix data abort in get_vcpu_from_rdist()
Just because vcpu_id is within d->max_vcpus doesn't mean d->vcpu[vcpu_id] is
non-NULL.  Use the proper accessor to look up a vcpu object.

Reported-by: Michal Orzel <michal.orzel@amd.com>
Fixes: acf65e5a25 ("xen/arm: vgic-v3: Emulate correctly the re-distributor")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Julien Grall <julien@xen.org>
2026-07-14 12:10:44 +01:00
Andrew Cooper 7d48ef45b6 x86/emul: Adjust handling of CR8_LEGACY
The APM description of the AltMovCR8 feature bit is:

  "LOCK MOV CR0 means MOV CR8"

Adjust the decode logic to behave like this.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-07-10 19:35:49 +01:00
Andrew Cooper 72927fc6f7 libs/guest: Allocate rec_pfns earlier in write_batch()
For reasons which escape me, rec_pfns are allocated separately to the rest of
the batch allocations.

Allocate them all together.  This will allow for future simplifications to be
performed in an incremental mannor.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
2026-07-08 15:35:45 +01:00
Andrew Cooper c4bf5bc5f0 x86/entry: Use PUSH_AND_CLEAR_GPRS and drop SAVE_ALL
PUSH_AND_CLEAR_GPRS is shorter than SAVE_ALL in terms of emitted code.

lstar_enter() and cstar_enter() do not need CLD.  The SYSCALL instruction
sanitises flags based on MSR_SYSCALL_MASK.  For all other cases, place the CLD
instruction next to STAC/CLAC so the flag handling is together.

Get rid of the compat=1 special case for PV32.  It's not obviously a win, and
PV32 is getting increasingly rare these days.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-07-07 17:19:38 +01:00
Andrew Cooper 8af337dfb8 x86/entry: Use POP_GPRS and remove RESTORE_ALL
POP_GPRS is shorter than RESTORE_ALL in terms of emitted code.

By separating the popping of entry_vector/error_code off the stack,
SPEC_CTRL_COND_VERW doesn't need custom displacements.

Get rid of the compat=1 special case for PV32.  It's not obviously a win, and
PV32 is getting increasingly rare these days.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-07-07 17:19:38 +01:00
Andrew Cooper 1557e03579 x86/hvm: Use PUSH_AND_CLEAR_GPRS in preference to SAVE_ALL
PUSH_AND_CLEAR_GPRS is shorter than SAVE_ALL in terms of emitted code.
SAVE_ALL hides a CLD instruction which is not needed anywhere here.

 * VMX VMExit always clears flags.  VMX VMentry failure never switched away
   from the host flags, so they're still good.
 * SVM VMRUN always saves and restores the host flags.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-07-07 17:19:38 +01:00
Andrew Cooper a41bba43a7 x86/pv: Adjust the save_segments() comment regarding MSR_GS_SHADOW
This is slightly stale mentioning SWAPGS and not LKGS.  However, take the
opportunity to make the comment more general and less likely to bitrot.

It would be a serious vulnerability for operating systems generally if CPL3
could modify GS_SHADOW at all.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
2026-07-07 17:19:38 +01:00
Andrew Cooper be22d975b0 x86/kexec: Drop compat_mode_gdt_desc
Given the need to calculate the base anyway, it's easier to do so entirely on
the stack.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-07-06 13:44:05 +01:00
Andrew Cooper f0161d2d89 tools/libfsimage: Remove the XEN_FSIMAGE_FSDIR environment variable
This was reported to the security team, demonstrating that code execution
could be achieved, but without a demonstration of a priviliege boundary being
bypassed.

Still, it's a high risk path with no obvious evidence of having been used even
for debugging, so remove the environment variable and use the build time
$(libdir)/xenfsimage path only.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-07-03 16:52:47 +02:00
Andrew Cooper e6b68789d4 xen/mm: Remove INVALID_{MFN,GFN}_INITIALIZER
These existed to work around a bug in older GCC when using struct-casting for
variable initialisation.  However, our baseline toolchain is new enough to not
suffer this bug.

Removing these resolves two MISRA Rule 9.2 violations which exist in release
builds of Xen only, where "= { ... }" is disallowed for simple scalar
initialisation.

The BUILD_BUG_ON() in xenmem_add_to_physmap() cannot stay as it is, because
INVALID_GFN is not an Integer Constant Expression.  Replace it BUILD_ERROR()
which is the nearest available alternative.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-30 16:46:42 +01:00
Andrew Cooper e0026fd5d1 x86/shadow: Drop SHADOW_AUDIT_ENABLE indirection
Simply define shadow_audit_enable to be false for the !SHADOW_AUDIT case.

Change the variable to be a bool, and __read_mostly as it's only enabled by
debugkey.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-06-30 16:46:42 +01:00
Andrew Cooper 505f2bda51 xen/kexec: Style fixes
Adjust kexec and kimage to more closely adhere to Xen style.

Sort the includes, dropping duplicates (kexec.h) and unused (ctype.h and
kernel.h).

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
2026-06-30 16:46:42 +01:00
Andrew Cooper 7702e782f3 xen/kexec: Drop the obsolete v1 hypercall implementation
The v1 interface was declared obsolete in Xen 4.4 (2013) when kexec in Xen was
overhauled.

The only known user of the v1 interface was the classic-xen fork of Linux.
Linux PVOps does not interact with Xen kexec directly, delegating it entirely
to userspace (i.e. kexec-tools).  Xen support in kexec-tools was part of this
work, and uses the "new" interface.

As such, there's no sensible way to test changes to the old interface any
more.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-30 16:46:42 +01:00
Andrew Cooper d635b5c04b CHANGELOG.md: Start a new 4.23 section
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-06-29 18:06:24 +01:00
Andrew Cooper a69ae04b8b Config.mk: Switch QEMU back to master
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-06-29 18:06:24 +01:00
Andrew Cooper 1383141821 Rerun ./autogen.sh for 4.23
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-06-29 18:06:24 +01:00
Andrew Cooper 982c56592a Update Xen to 4.23
Xen 4.22 has branched

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-06-29 18:06:23 +01:00
Andrew Cooper c8de9ae30a Update Xen version to 4.22.0-rc3
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-06-29 18:04:10 +01:00
Andrew Cooper 76fc776392 x86/fred: Send an EVENT_CHECK IPI on exit from NMI
Returning from an NMI which hits guest context needs special casing in FRED
mode just like it does in IDT mode.

Break nmi_exit_to_guest() out of handle_ist_exception(), and use it in
entry_FRED_R3() also.

Expand the comment a little, and invert the conditional jump to
compat_restore_all_guest() to avoid needing an #else clause for CONFIG_PV32.

Fixes: 87cfcbe9f0 ("x86/pv: Guest exception handling in FRED mode")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Relase-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-25 11:08:02 +01:00
Andrew Cooper 2c9829a261 x86/kexec: Check for a good per-cpu area before accessing IDTs
Prior to commit 9c20d3c591 ("x86/IDT: Make idt_tables[] be per_cpu(idt)"),
the global idt_tables[] was always safe to use for CPUs in any state.

However, not-yet-onlined CPUs (e.g. MADT with more entries than exist in
practice) or offlined CPUs (e.g. xen-hptool) have their per-cpu pointer
poisoned to detect incorrect uses.  machine_kexec() trips over the posion when
clobbering #MC entry paths.  Update the comment to discuss parked CPUs, and to
remove discussion which isn't particularly relevant to the actions at hand.

This fixes a fatal #GP (non-canonical memory reference) when trying to enter
the crash kernel.

Fixes: 9c20d3c591 ("x86/IDT: Make idt_tables[] be per_cpu(idt)")
Reported-by: Lin Liu <Lin.Liu01@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-23 19:15:51 +01:00
Andrew Cooper 4665d17967 x86/kexec: Disable FRED earlier in kexec_reloc()
With FRED just as with IDT, it's unsafe to run the exception handlers after
switching stack.

To remove this unsafe window, %cr4 needs clearing earlier.  In turn, we may
need to switch to PCID 0 earlier too in order to be able to clear CR4.PCIDE.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
2026-06-23 19:15:51 +01:00
Andrew Cooper c3974cbf20 x86/kexec: Invalidate the IDT earlier in kexec_reloc()
After switching stack, it is not safe to run any exception handlers, because
attempts to access the cpu_info block are out-of-bounds and will generate wild
accesses.

Invalidating the IDT in the common path means there's no need to do so again
in the 32bit path, so drop compat_mode_idt entirely.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-23 19:15:51 +01:00
Andrew Cooper 5cdae3c505 x86/kexec: Fix and expand comments for kexec_reloc()
The order of shutdown is delicate.  Explain things a little better.

Fix two comments about leaving Long Mode.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-23 19:15:51 +01:00
Andrew Cooper ad9c7d86c9 x86/kexec: Stop hooking NMIs with trap_nop()
When FRED is active, it is not possible to hook NMIs like this.

NMI hooking in the crash path has undergone several revisions since its
introduction.  Notably since commit e7f147bf4a ("x86/crash: Drop manual
hooking of exception_table[]") we use the regular nmi_callback()
infrastructure.

Instead of asserting that we don't enter do_nmi_crash() on the crashing CPU,
tolerate it and return early.  It's a marginally longer codepath but behaves
the same and is compatible with FRED.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-23 19:15:51 +01:00
Andrew Cooper 6ba5e9c7b8 x86/ucode: Exclude Zen6 from entrysign digest checking
There is a 3rd path which should have gained an is_zen6_uarch() check to
exclude Zen6 from entrysign mitigations.

Fixes: bd15fdedaf ("x86/ucode: Exclude Zen6 from entrysign mitigations")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
Acked-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-16 18:33:39 +01:00
Andrew Cooper 1cfceee62d Update Xen version to 4.22.0-rc2
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-06-15 20:16:58 +01:00
Andrew Cooper c109c7aa44 CI: Remove x86 microcode from arm32 jobs
All build containers are non-root now.  Complete the todo by dropping the
workaround.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-15 18:04:20 +01:00
Andrew Cooper 66f59e7657 CI: Fix inconsistent use of x86-{64,32} vs x86_{64,32}
The configuration uses a mix of dashes and underscores, which is irritating to
develop for.  Switch to using the underscore form consistently; it is the more
common form and it has the benefit that it allows splitting on dashes to work
sensibly.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-15 18:04:20 +01:00
Andrew Cooper cfaaf09a5e CI: Update the Alpine arm64 container to 3.24
Perform standard syntax cleanup and make it a non-root container.  Switch yajl
for json-c given the deprecation of the former.  Drop dev86 which is an
x86-only dependency, and QEMU dependencies as we don't build QEMU in this
environment any more.

When updating the job names, also rename some for consistency so the arm64
fragment comes before the compiler.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-15 18:04:20 +01:00
Andrew Cooper 694302cc84 CI: Update the Alpine x86_64 container to 3.24
Perform standard syntax cleanup and make it a non-root container.  Switch yajl
for json-c given the deprecation of the former.

Add an x86_64 suffix for naming consistency with everything else.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-15 18:04:20 +01:00
Andrew Cooper 4dff3f89c1 CI: Introduce new qubes-hw-runner.dockerfile
This container is tied to gitlab-runner environment in the RPis driving the
test systems, not a specific version of Alpine.  Intentionally give it a
generic name so it need not change in the future.

Switch to Alpine 3.24 right away, as it doesn't interact with the 3.18 builds
under test.

The container needs to remain a root container.  By no longer using the
arm64v8 build container for dual-purpose, we can finally make the build
containers be non-root.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-15 18:04:20 +01:00
Andrew Cooper be361c4285 Config.mk: Update QEMU to include pip-25.2 bugfix
Specifically:

  commit 6ad034e71232c2929ed546304c9d249312bb632f
  Author: Sv. Lockal <lockalsash@gmail.com>
  Date:   Mon Aug 11 20:01:59 2025

      mkvenv: Support pip 25.2

      Fix compilation with pip-25.2 due to missing distlib.version

      Bug: https://gitlab.com/qemu-project/qemu/-/issues/3062

from upstream QEMU.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-15 18:04:20 +01:00
Andrew Cooper 1a485996d9 tools/xenalyze: Fix -Werror=nonnull failure
GCC 15.2 with Alpine Linux 3.24 fails with -Werror=nonnull, complaining that
we're calling bzero(NULL, 128).

This is a legitimate diagnostic.  xenalyze has it's own error() function
shadowing the standard library one, and can in principle return when p is
NULL.

Extend the check in error() with ERR_MAX_TOLERABLE to short circuit the
variable tolerance check.

Suggested-by: Anthony PERARD <anthony.perard@vates.tech>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-15 18:04:20 +01:00
Andrew Cooper efcb4c5e2f CI: Use more specific Xilinx runner tags
In order to avoid serialising the testing on both boards, the runner
configuration is being adjusted.

Have the .xilinx-arm64 and .xilinx-x86_64 templates choose the board directly
using a more specific tag.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Victor Lira <victorm.lira@amd.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-15 12:42:55 +01:00
Andrew Cooper ffb9c3016b CI: Rename xenial-xilinx to xilinx-hw-runner
The container is tied to the runner, not a version of Ubuntu.  Intentionally
give it a generic name so it need not change in the future.

Apply standard cleanup to the dockerfile, except that it must continue to be a
root container to drive real hardware.  Explicitly install ca-certificates to
compensate for --no-install-recommends.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-12 15:00:38 +01:00
Andrew Cooper 3ddcb957b5 CI: Rework the archlinux container
Rename it to have an x86_64 suffix, updating the build job names and scheduled
rebuild task.

Apply standard cleanups.  Trim the package list down to what is actually
needed.  Archlinux's base-devel contains most libraries, but some of the
listed packages have never been dependenices for Xen, and a lot are QEMU
dependenices which aren't useful owing to the lack of the ninja package.

This shrinks the container from 533MB to 380MB.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-12 15:00:38 +01:00
Andrew Cooper 2a52894017 CI: Fixes to containerize
These were missed from prior changes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-12 15:00:38 +01:00
Andrew Cooper ccd8c65794 Revert recent ARGO changes
This reverts commit 3c4e804607.
This reverts commit 957f0f0b73.
This reverts commit 2bc9bc1978.
This reverts commit 03ebee6ed8.
This reverts commit a9720605b6.

These were committed without a maintainer ack, and therefore in contravention
of policy.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2026-06-08 23:03:22 +01:00
Andrew Cooper 37df17d2f9 CI: Update Opensuse 15.6 to 16.0
The default version of python is 3.13, so drop the 3.11 overrides.

Swap yajl for json-c, given the deprecation of the former.  Add lz4.

bin86/dev86 are no longer available.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 14:06:40 +01:00
Andrew Cooper 58eaf63b82 CI: Update Fedora to 43
Swap yajl for json-c, given the deprecation of the former.  Add lz4.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 14:06:40 +01:00
Andrew Cooper 58d797e1ac CI: Add Ubuntu 26.04
Swap yajl for json-c, given the deprecation of the former.  Add lz4.

Add 26.04 GCC/Clang debug/non-debug jobs.  Drop the 24.04 debug jobs to keep
the overall job count down.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 14:06:40 +01:00
Andrew Cooper def7f9ef58 CI: Drop Ubuntu 16.04
Ubuntu 16.04 is now fully out of support.

Introduce an 18.04 GCC Debug job in lieu of losing the 16.04 job.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 14:06:40 +01:00
Andrew Cooper fdcc559661 CI: Swap ocaml-nox for ocaml in newer Debian/Ubuntu
Ocaml 4.08 and earlier had the compiler package depend on graphics, and
therefore on X.  Ocaml 4.09 and later dropped this dependency.

Debian and Ubuntu versions with Ocaml 4.08 and earlier (which are Debian
Bullseye/11, and Ubuntu Focal/20.04 and earlier) had ocaml-nox packages with
this dependency stripped, which we use to keep the size of the containers
down.

In newer versions of Debian and Ubuntu, ocaml-nox is just a transitional
package referring back to ocaml.  Ubuntu Resolute/26.04 has finally removed
this transitional package.  For all versions where ocaml-nox is just a
transitional package, swap to the ocaml package.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 14:06:40 +01:00
Andrew Cooper e58d8aa171 CI: Drop test-artifacts/Makefile
This is unused since commit 3c0c177ff9 ("CI: Switch qemu-arm* jobs to using
the distro provided QEMU"), and wants never to return.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 14:06:40 +01:00
Andrew Cooper 38492dc098 tools/libs/guest: Use the system liblz4 in the bzimage loader
Right now lz4, unlike every other compression scheme, unconditionally uses
Xen's unsafe decompressor.  Make it consistent with all other compression
schemes by using liblz4.

The unsafe decompression is still required for the MiniOS build, so rename
xg_dom_decompress_lz4.c to xg_dom_decompress_unsafe_lz4.c and drop the
non-MiniOS content.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 14:06:40 +01:00
Andrew Cooper 924c0ff17f tools/configure: Detect the presence of liblz4
As with other compression libraries, group liblz4 into ZLIB_{CFLAGS,LIBS}.

Add the packages to the Debian Trixie build containers for coverage.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 14:06:40 +01:00
Andrew Cooper d2ddd2beff x86/hvm: Partially revert ("xen/mem_access: wrap memory access when VM_EVENT=n")
It is erroneous to check current like this; most commonly, introspection is
dom0 issuing hypercalls against domU.

The use of vm_event_is_enabled() is only for the IS_ENABLED(CONFIG_VM_EVENT)
short circut, so just use that directly.

Reported-by: Hady Azzam <hadyazzam@protonmail.com>
Fixes: b18e38e42d ("xen/mem_access: wrap memory access when VM_EVENT=n")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Tested-by: Hady Azzam <hadyazzam@protonmail.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-08 10:07:05 +01:00
Andrew Cooper 0d9d20bff0 MAINTAINERS: Update Ocaml maintainers
Christian has just left Citrix, and Dave almost a decade ago.

Andrii (a XAPI committer) has worked on oxenstored before and has agreed to
step up as a maintainer, and Guillaume wishes to get involved and learn too.
In practice I do a lot of the bindings work, so lets make things official.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Andrii Sultanov <andriy.sultanov@vates.tech>
Acked-by: Guillaume Thouvenin <guillaume.thouvenin@vates.tech>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-05 14:50:30 +01:00
Andrew Cooper 144dce88d5 CI: Remove .cirrus.yml now that CirrusCI has shut down
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2026-06-05 14:50:30 +01:00