Commit Graph
49579 Commits
Author SHA1 Message Date
Oleksii Kurochko ff14053983 xen/riscv: Implement p2m_pte_from_mfn() and support PBMT configuration
This patch adds the initial logic for constructing PTEs from MFNs in the RISC-V
p2m subsystem. It includes:
- Implementation of p2m_pte_from_mfn(): Generates a valid PTE using the
  given MFN, p2m_type_t, including permission encoding and PBMT attribute
  setup.
- New helper p2m_set_permission(): Encodes access rights (r, w, x) into the
  PTE based on both p2m type and access permissions.
- p2m_set_type(): Stores the p2m type in PTE's bits. The storage of types,
  which don't fit PTE bits, will be implemented separately later.
- Add detection of Svade extension to properly handle a possible page-fault
  if A and D bits aren't set.

PBMT type encoding support:
- Introduces an enum pbmt_type_t to represent the PBMT field values.
- Maps types like p2m_mmio_direct_dev to p2m_mmio_direct_io, others default
  to pbmt_pma.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 14:25:00 +01:00
Oleksii Kurochko 6f7881e331 xen/riscv: Implement p2m_free_subtree() and related helpers
This patch introduces a working implementation of p2m_free_subtree() for RISC-V
based on ARM's implementation of p2m_free_entry(), enabling proper cleanup
of page table entries in the P2M (physical-to-machine) mapping.

Only few things are changed:
- Introduce and use p2m_get_type() to get a type of p2m entry as
  RISC-V's PTE doesn't have enough space to store all necessary types so
  a type is stored outside PTE. But, at the moment, handle only types
  which fit into PTE's bits.

Key additions include:
- p2m_free_subtree(): Recursively frees page table entries at all levels. It
  handles both regular and superpage mappings and ensures that TLB entries
  are flushed before freeing intermediate tables.
- p2m_put_page() and helpers:
  - p2m_put_4k_page(): Clears GFN from xenheap pages if applicable.
  - p2m_put_2m_superpage(): Releases foreign page references in a 2MB
    superpage.
  - p2m_get_type(): Extracts the stored p2m_type from the PTE bits.
- p2m_free_page(): Returns a page to a domain's freelist.
- Introduce p2m_is_foreign() and connected to it things.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 14:24:45 +01:00
Oleksii Kurochko fcd6755606 xen/riscv: implement p2m_set_range()
This patch introduces p2m_set_range() and its core helper p2m_set_entry() for
RISC-V, based loosely on the Arm implementation, with several RISC-V-specific
modifications.

The main changes are:
- Simplification of Break-Before-Make (BBM) approach as according to RISC-V
  spec:
    It is permitted for multiple address-translation cache entries to co-exist
    for the same address. This represents the fact that in a conventional
    TLB hierarchy, it is possible for multiple entries to match a single
    address if, for example, a page is upgraded to a superpage without first
    clearing the original non-leaf PTE’s valid bit and executing an SFENCE.VMA
    with rs1=x0, or if multiple TLBs exist in parallel at a given level of the
    hierarchy. In this case, just as if an SFENCE.VMA is not executed between
    a write to the memory-management tables and subsequent implicit read of the
    same address: it is unpredictable whether the old non-leaf PTE or the new
    leaf PTE is used, but the behavior is otherwise well defined.
  In contrast to the Arm architecture, where BBM is mandatory and failing to
  use it in some cases can lead to CPU instability, RISC-V guarantees
  stability, and the behavior remains safe — though unpredictable in terms of
  which translation will be used.
- Unlike Arm, the valid bit is not repurposed for other uses in this
  implementation. Instead, entry validity is determined based solely on P2M
  PTE's valid bit.

The main functionality is in p2m_set_entry(), which handles mappings aligned
to page table block entries (e.g., 1GB, 2MB, or 4KB with 4KB granularity).

p2m_set_range() breaks a region down into block-aligned mappings and calls
p2m_set_entry() accordingly.

Stub implementations (to be completed later) include:
- p2m_free_subtree()
- p2m_next_level()
- p2m_pte_from_mfn()

Note: Support for shattering block entries is not implemented in this
patch and will be added separately.

Additionally, some straightforward helper functions are now implemented:
- p2m_write_pte()
- p2m_remove_pte()
- p2m_get_root_pointer()

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 14:24:32 +01:00
Oleksii Kurochko 96553849a3 xen/riscv: implement function to map memory in guest p2m
Implement map_regions_p2mt() to map a region in the guest p2m with
a specific p2m type. The memory attributes will be derived from the
p2m type. This function is used in dom0less common
code.

To implement it, introduce:
- p2m_write_(un)lock() to ensure safe concurrent updates to the P2M.
  As part of this change, introduce p2m_tlb_flush_sync() and
  p2m_force_tlb_flush_sync().
- A stub for p2m_set_range() to map a range of GFNs to MFNs.
- p2m_insert_mapping().
- p2m_is_write_locked().

Drop guest_physmap_add_entry() and call map_regions_p2mt() directly
from guest_physmap_add_page(), making guest_physmap_add_entry()
unnecessary.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 14:24:17 +01:00
Oleksii Kurochko 5bcbcc2565 xen/dom0less: abstract Arm-specific p2m type name for device MMIO mappings
Introduce arch_dt_passthrough_p2m_type() and use it instead of
`p2m_mmio_direct_dev` to avoid leaking Arm-specific naming into
common Xen code, such as dom0less passthrough property handling.

This helps reduce platform-specific terminology in shared logic and
improves clarity for future non-Arm ports (e.g. RISC-V or PowerPC).

No functional changes — the definition is preserved via a static inline
function for Arm.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2025-12-18 14:23:42 +01:00
Grygorii Strashko 7d2e057368 xen/x86: move d->arch.physaddr_bitsize field handling into pv32
The d->arch.physaddr_bitsize field is used only by PV32 code, so move
d->arch.physaddr_bitsize field under PV32 ifdef into struct pv_domain.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2025-12-18 10:07:08 +01:00
Grygorii Strashko c37bcb35f9 xen/x86: move domain_clamp_alloc_bitsize() into pv32 code
The d->arch.physaddr_bitsize field is used only by PV32 code so as the
domain_clamp_alloc_bitsize() function.

Hence move domain_clamp_alloc_bitsize() function into PV32 code and convert
it to macro.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 10:04:55 +01:00
Oleksii Kurochko c9f88ba993 xen/riscv: add new p2m types and helper macros for type classification
- Extended p2m_type_t with additional types: p2m_mmio_direct,
  p2m_ext_storage.
- Added macros to classify memory types: P2M_RAM_TYPES.
- Introduced helper predicates: p2m_is_ram(), p2m_is_any_ram().
- Introduce arch_dt_passthrough() to tell handle_passthrough_prop()
  from common code how to map device memory.
- Introduce p2m_first_external for detection for relational operations
  with p2m type which is stored outside P2M's PTE bits.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 10:00:07 +01:00
Oleksii Kurochko 3d197aad8a xen/riscv: introduce pte_{set,get}_mfn()
Introduce helpers pte_{set,get}_mfn() to simplify setting and getting
of mfn.

Also, introduce PTE_PPN_MASK and add BUILD_BUG_ON() to be sure that
PTE_PPN_MASK remains the same for all MMU modes except Sv32.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 09:59:53 +01:00
Oleksii Kurochko 824ec51384 xen/riscv: add root page table allocation
Introduce support for allocating and initializing the root page table
required for RISC-V stage-2 address translation.

To implement root page table allocation the following is introduced:
- p2m_get_clean_page() and p2m_alloc_root_table(), p2m_allocate_root()
  helpers to allocate and zero a 16 KiB root page table, as mandated
  by the RISC-V privileged specification for Sv32x4/Sv39x4/Sv48x4/Sv57x4
  modes.
- Update p2m_init() to inititialize p2m_root_order.
- Add maddr_to_page() and page_to_maddr() macros for easier address
  manipulation.
- Introduce paging_ret_to_domheap() to return some pages before
  allocate 16 KiB pages for root page table.
- Allocate root p2m table after p2m pool is initialized.
- Add construct_hgatp() to construct the hgatp register value based on
  p2m->root, p2m->hgatp_mode and VMID.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 09:59:40 +01:00
Oleksii Kurochko 3810f15521 xen/riscv: construct the P2M pages pool for guests
Implement p2m_set_allocation() to construct p2m pages pool for guests
based on required number of pages.

This is implemented by:
- Adding a `struct paging_domain` which contains a freelist, a
  counter variable and a spinlock to `struct arch_domain` to
  indicate the free p2m pages and the number of p2m total pages in
  the p2m pages pool.
- Adding a helper `p2m_set_allocation` to set the p2m pages pool
  size. This helper should be called before allocating memory for
  a guest and is called from domain_p2m_set_allocation(), the latter
  is a part of common dom0less code.
- Adding implementation of paging_freelist_adjust() and
  paging_domain_init().

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 09:59:29 +01:00
Oleksii Kurochko 45434df608 xen/riscv: introduce things necessary for p2m initialization
Introduce the following things:
- Update p2m_domain structure, which describe per p2m-table state, with:
  - lock to protect updates to p2m.
  - pool with pages used to construct p2m.
  - back pointer to domain structure.
- p2m_init() to initalize members introduced in p2m_domain structure.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 09:59:16 +01:00
Oleksii Kurochko bff3b9ea46 xen/riscv: introduce VMID allocation and manegement
Current implementation is based on x86's way to allocate VMIDs:
  VMIDs partition the physical TLB. In the current implementation VMIDs are
  introduced to reduce the number of TLB flushes. Each time a guest-physical
  address space changes, instead of flushing the TLB, a new VMID is
  assigned. This reduces the number of TLB flushes to at most 1/#VMIDs.
  The biggest advantage is that hot parts of the hypervisor's code and data
  retain in the TLB.

  VMIDs are a hart-local resource.  As preemption of VMIDs is not possible,
  VMIDs are assigned in a round-robin scheme. To minimize the overhead of
  VMID invalidation, at the time of a TLB flush, VMIDs are tagged with a
  64-bit generation. Only on a generation overflow the code needs to
  invalidate all VMID information stored at the VCPUs with are run on the
  specific physical processor. When this overflow appears VMID usage is
  disabled to retain correctness.

Only minor changes are made compared to the x86 implementation.
These include using RISC-V-specific terminology, adding a check to ensure
the type used for storing the VMID has enough bits to hold VMIDLEN,
and introducing a new function vmidlen_detect() to clarify the VMIDLEN
value, rename stuff connected to VMID enable/disable to "VMID use
enable/disable".

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 09:58:56 +01:00
Oleksii Kurochko 4112edae49 xen/riscv: detect and initialize G-stage mode
Introduce gstage_mode_detect() and guest_mm_init() to probe supported
G-stage paging modes at boot. The function iterates over possible
HGATP modes (Sv32x4 on RV32, Sv39x4/Sv48x4/Sv57x4 on RV64) and selects
the largest supported MMU translation address mode by programming
CSR_HGATP and reading it back.

The selected mode is stored in max_gstage_mode (marked __ro_after_init)
and reported via printk. If no supported mode is found, Xen panics
since Bare mode is not expected to be used.

Finally, CSR_HGATP is cleared and a local_hfence_gvma_all() is issued
to avoid any potential speculative pollution of the TLB, as required
by the RISC-V spec.

The following issue starts to occur:
 ./<riscv>/asm/flushtlb.h:37:55: error: 'struct page_info'  declared inside
   parameter list will not be visible outside of this definition or
   declaration [-Werror]
 37 | static inline void page_set_tlbflush_timestamp(struct page_info *page)
To resolve it, forward declaration of struct page_info is added to
<asm/flushtlb.h.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-18 09:58:32 +01:00
Jan Beulich 9cf4084f4e tools/fuzz: use vpath uniformly for access to hypervisor library code
It's not quite clear why for libelf and the emulator we use symlink-ing,
while elsewhere we use vpath. Do so for these two as well, thus also
eliminating the need for custom -iquote options and custom cleaning.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2025-12-18 09:57:42 +01:00
Andrew Cooper f34c965281 tools/tests: Memory Claims
Add some basic testing of the memory claims mechainsm.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2025-12-17 17:35:24 +00:00
Andrew Cooper 04ebc7b527 tools/tests: Sort Makefile
... and split the x86 group away from the common group.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2025-12-17 17:35:24 +00:00
Andrew Cooper 7672602df6 tools/libxc: Delete ENOSYS squashing in xc_domain_claim_pages()
It's not acceptable to hide this from the caller; the effect of doing so is to
break an atomicity expectation.

Only the caller can know what the appropriate safety action is in the case
that the claim hypercall isn't available.  Ignoring it might be the right
thing to do, but xc_domain_claim_pages() cannot make this decision on behalf
of all callers.

Fixes: fc67e9dc0c ("xc: use XENMEM_claim_pages hypercall during guest creation.")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2025-12-17 17:35:24 +00:00
Andrew Cooper 2379ca04fe xen/domain: Disallow XENMEM_claim_pages on dying domains
XENMEM_claim_pages can be issued on a domain in the later stages of
domain_kill().  In that case, the claimed memory is leaked, as there's no way
to subsequently release the claim.

Claims are intended for use during domain construction; to reserve sufficient
RAM to construct the domain fully.  There's no legitimate reason to be calling
it on a dying domain.

Fixes: 65c9792df6 ("mmu: Introduce XENMEM_claim_pages (subop of memory ops)")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2025-12-17 17:35:24 +00:00
Jan Beulich ebddf34aab x86: move {clear_,copy_,scrub-}page.S to arch-specific library
These are pretty similar to the standard library memset() / memcpy().

Switch to building scrub-page.S unconditionally; the linker will simply
not pick it up when not needed.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2025-12-17 09:04:01 +01:00
Jan Beulich 54ad9eb26a x86: move mem{cpy,set}.S to arch-specific library
If not these, what else are library functions.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2025-12-17 09:03:29 +01:00
Jan Beulich 7370966d1c x86: move / split usercopy.c to / into arch-specific library
The file wasn't correctly named for our purposes anyway. Split it into its
"guest" and "unsafe" parts, thus allowing the latter to not be linked in
at all (for presently having no caller). The building of the "guest" part
can then (later) become conditional upon PV=y.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Grygorii Strashko <grygorii_strashko@epam.com>
2025-12-17 09:02:37 +01:00
Nicola Vetrini c380923a52 misra: extend toolchain assumption about source character set
Similar to the ARM64 compiler, the same assumptions can be made about
the X86_64 toolchain.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-17 09:02:09 +01:00
Jason Andryuk 46f3ed0d53 xen/x86: Pass TPM ACPI table to PVH dom0
Pass the TPM2 ACPI table so that the device can be found by a PVH dom0.

Otherwise dom0 shows:
tpm_tis MSFT0101:00: [Firmware Bug]: failed to get TPM2 ACPI table
tpm_tis MSFT0101:00: probe with driver tpm_tis failed with error -22

TCPA is "Trusted Computing Platform Alliance table", but it is really
the table for a TPM 1.2.  Pass that as well.

While doing this, move ACPI_SIG_WPBT to alpabetize the entries.

This exposes TPM event log tables on PVH dom0, bring it in line with a
PV dom0.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2025-12-16 09:40:18 +01:00
Jan Beulich cc1166479b bump default SeaBIOS version to 1.17.0
It has been around for a while.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2025-12-16 09:32:26 +01:00
Jan Beulich 5d53a22c82 Arm: actually put library code in a library
Now that the build system supports it, build the $(ARCH)/lib/ directories
actually into libraries, thus permitting unreferenced objects to be
omitted.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2025-12-16 09:31:53 +01:00
Andrew Cooper fb01f69edb x86/svm: Merge vmcb.h into svm-types.h
While doing so, make some style fixes to comments/etc.

This removes the include/asm/hvm/svm/ subdirectory.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-15 11:24:26 +00:00
Andrew Cooper ada965a47a x86/svm: Merge nestedsvm.h into svm-types.h
While doing so, move the ns_gif field to beside ns_hap_enabled to remove 7
padding bytes, and make some style fixes to comments/etc.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-15 11:24:26 +00:00
Andrew Cooper a336c18037 x86/svm: Introduce svm-types.h
In order to reduce the header tangle around xen/sched.h, we need to split
types away from other declarations.

Introduce a new hvm/svm-types.h to do this, including it from hvm/domain.h and
hvm/vcpu.h, and dropping all other inclusions of svm/vmcb.h and
svm/nestedhvm.h

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-15 11:24:26 +00:00
Andrew Cooper f1e2c3f377 x86/svm: Move svm_intercept_msr() into svm.h
The single user of svm_intercept_msr() outside of the main svm logic is in
vpmu_amd.c.  Currently the declaration is picked up transitively through
xen/sched.h, so include asm/hvm/svm.h explicitly.

Sort the headers while doing so.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-15 11:24:26 +00:00
Andrew Cooper f28c2f8f7b x86/svm: Move asm/hvm/svm/svm.h up one directory
... in preparation to remove the svm/ directory entirely.

intr.c doesn't need to include svm.h at all.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-15 11:24:26 +00:00
Victor Lira 2a9dbe94e0 automation: edit pipeline to fix hardware jobs running by mistake
The selected jobs regex was assumed to be possibly empty in some places
and setting a default value for the regex caused the hardware jobs to
bypass some rules checks.

To fix this, adjust the rules to remove the check for empty and
instead just match the regex.

Fixes: 485ab1b5db
Signed-off-by: Victor Lira <victorm.lira@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-12 17:39:19 -08:00
Victor Lira 3490ca374a automation: edit pipeline to fix blocked status
The original yocto config had a hidden default of allow_failure: true for the
manual job while the hidden default for rules is false. This causes the
stages with manual jobs to show as blocked.

Set it explicitly to true to avoid the analyze and build stages being shown as
blocked.

Fixes: 485ab1b5db
Signed-off-by: Victor Lira <victorm.lira@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-12 17:39:08 -08:00
Victor Lira 485ab1b5db automation: edit pipeline to prevent running non-selected jobs
Filtering jobs using the selected jobs regex is missing for
qemu-export + yocto jobs when running regular pipelines and eclair jobs
when running scheduled pipelines.

First, set a default value for the selected jobs regex to remove the
need to always check if the variable is empty.

Then add the missing rules to filter out those jobs.

Signed-off-by: Victor Lira <victorm.lira@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-12 14:41:51 -08:00
Victor Lira 233f6be7fc automation: prevent eclair-ARM64-amd from running by mistake
It seems unintentional that this job references .eclair-analysis
instead of .eclair-analysis:triggered which does not apply the rules
from that template. One effect is that it runs always instead of
manually in my xen-project/people repo.

Signed-off-by: Victor Lira <victorm.lira@amd.com>
Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-12 14:41:46 -08:00
Volodymyr Babchuk e6836f213f xen/char: implement suspend/resume calls for SCIF driver
Implement suspend and resume callbacks for the SCIF UART driver,
enabled when CONFIG_SYSTEM_SUSPEND is set. This allows proper
handling of UART state across system suspend/resume cycles.

Tested on Renesas R-Car H3 Starter Kit.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
Acked-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
2025-12-12 09:48:57 +01:00
Andrew Cooper 4aa218acd4 xen/irq: Delete the pirq_cleanup_check() macro
MISRA Rule 5.5 objects to a macro aliasing a function, which is what
pirq_cleanup_check() does. The macro was originally intended to ensure the
condition 'if (!pirq->evtchn)' is always checked before invoking the function,
avoiding errors across call sites.

There are only a handful of users, so expand it inline to be plain regular
C. Doing this shows one path now needing braces, and one path in
'evtchn_bind_pirq()' where the expanded form simplifies back to no delta, as
it follows an unconditional clear of 'info->evtchn'.

While this complies with MISRA, it shifts the responsibility to developers to
check 'if (!pirq->evtchn)' at call sites.

No functional changes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-12 03:04:48 +00:00
Andrew Cooper 3161cfa40b CI/eclair: Rename the eclair-* jobs for clarity
All Eclair scanning is for safety purposes, and the *-safety jobs are AMD's
configuration specifically, and other configurations will likely be different.
Rename them to *-amd.

Give the un-suffixed job an *-allcode suffix to make it clearer that they're
looking at all code.

Give the un-suffixed scheduled jobs an *-allrules suffix.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-12 03:04:48 +00:00
Andrew Cooper 0c40d08f7c x86: Fix missing brackets in macros
With the wider testing, some more violations have been spotted.  This
addresses violations of Rule 20.7 which requires macro parameters to be
bracketed.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-12 03:04:48 +00:00
Andrew Cooper f1b1860226 x86: Fix missing breaks
With the wider testing, some more violations have been spotted.  This
addresses violations of Rule 16.3 which requires all case statements to be
terminated with a break or other unconditional control flow change.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
2025-12-12 03:04:48 +00:00
Andrew Cooper 7becd32d84 x86/ucode: Don't cast away const-ness in cmp_patch_id()
Fixes a volation of MISRA rule 11.8.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2025-12-12 03:04:48 +00:00
Andrew Cooper eb518632cd x86: Name parameters in function declarations
With the wider testing, some more violations have been spotted.  This
addresses violations of Rule 8.2 (parameters must be named).

livepatch_op() has a further problem.  The other declaration (the stub for
!LIVEPATCH builds) has a parameter named op, but the definition has the
parameter named livepatch.  Rename it to op which is more concise and better
in line with it's type name.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
2025-12-12 03:04:48 +00:00
Andrew Cooper b6f399b341 x86: Misra fixes for U/L suffixes
With the wider testing, some more violations have been spotted.  This
addresses violations of Rule 7.2 (suffixes required) and Rule 7.3 (L must be
uppercase).

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
2025-12-12 03:04:48 +00:00
Andrew Cooper cfa37c182c xen/libfdt: Fix comment following treewide __ASSEMBLY__ cleanup
This one comment didn't match the #ifdef symbol, and escaped conversion.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Michal Orzel <michal.orzel@amd.com>
2025-12-12 03:04:48 +00:00
Andrew Cooper 8efff5a69a tools/sd-notify.h: Include string.h too
Alpine Linux, when using --enable-systemd to get the init files, fails with:

  tools/include/xen-sd-notify.h:69:3: error: call to undeclared library
  function 'memcpy' with type 'void *(void *, const void *, unsigned long)';
  ISO C99 and later do not support implicit function declarations
  [-Wimplicit-function-declaration]
     69 |   memcpy(socket_addr.sun.sun_path, socket_path, path_length);
        |   ^

This will be down to using musl rather than glibc.  Include the appropriate
header.

Fixes: 78510f3a15 ("tools: Import stand-alone sd_notify() implementation from systemd")
Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
2025-12-12 03:04:48 +00:00
Andrew Cooper 6ccebacb53 x86/svm: Drop svmdebug.h
svmdebug.h now only contains the declaration for svm_sync_vmcb(), despite the
logic being local to svm.c.  Move the declaration into the local svm.h

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-12 03:04:48 +00:00
Andrew Cooper 0a55f32a2c x86/svm: Drop svmdebug.c
Everything here is really VMCB functionality, so merge it into vmcb.c.  Move
the declarations from the global svmdebug.h to the local vmcb.h.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-12 03:04:48 +00:00
Andrew Cooper f09b87a0ea x86/svm: Make vmcb_struct private to svm/
The rest of Xen has no buisness knowing this structure, and it is currently
included via xen/sched.h into most code.  Create a new private svm/vmcb.h.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-12-12 03:04:48 +00:00
Nicola Vetrini abac3b76d2 automation/eclair: Run *-testing jobs only in some branches
These jobs should not run in regular scans, but only in xen-project/people
repositories and branches to speed up pipeline execution.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2025-12-11 15:19:22 +00:00
Jan Beulich 98fccdf0ac x86/mm: update log-dirty bitmap when manipulating P2M
Just like for PV guests MMU_MACHPHYS_UPDATE implies marking of the
respective page as dirty, additions to a HVM guest's P2M should do so.

For HVM the opposite is also true: Pages being removed from the P2M are
no longer dirty at their prior GFN; there's no point in telling the tool
stack to try and copy that page, when this will fail anyway (until
perhaps a new page gets placed there). Introduce paging_mark_pfn_clean()
(intentionally without a paging_mark_clean() counterpart) to handle
this. Note that while there is an earlier call to set_gpfn_from_mfn() in
guest_physmap_add_entry(), but there's little reason to mark the page
clean there when later in the function it'll be marked dirty. This is
even more so given that at this point it's only the M2P that gets
updated, with the P2M still left unchanged.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2025-12-11 09:50:30 +01:00