62 Commits
Author SHA1 Message Date
Frediano Ziglio 9ed72c697b x86: Fix typo in comment (indicies -> indices)
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2026-07-07 10:14:53 +02:00
Frediano Ziglio ac840e066f tools: Use posix_memalign instead of valloc for NetBSD
More similar to other implementation.
posix_memalign was adde in NetBSD 8.0, released on July 17, 2018
and went out of support on May 4, 2024.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
2026-07-06 09:40:17 +02:00
Frediano Ziglio f7091c0e1f xen/pci: prevent infinite loop for faulty SR-IOV cards
If a SR-IOV card presents an I/O space inside a BAR the
code will continue to loop on the same card.
This is due to the missing increment of the cycle variable.

Fixes: a1a6d59862 ("pci: split code to size BARs from pci_add_device")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-By: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2025-10-27 15:52:20 +01:00
Frediano Ziglio 50baf2d9f7 tools/libs/guest: Use superpages where possible on migrate/resume
Right now on migrate/resume, all guest memory is allocated with 4k
small pages.  This was an intended oversight in the original Migration
v2 implementation.

With some test memory program stressing TLB (many small random memory
accesses) superpages can show a 15% performance improvement.

On the first memory iteration the sender is currently sending memory
in 4MB aligned chunks of GFN space which allows the receiver to
allocate most pages as 2MB superpages instead of single 4KB pages.

This change does not handle 1GB superpages as this will require
changes to the migration protocol.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
2025-09-29 21:32:37 +02:00
Frediano Ziglio 375f0dd538 xen/efi: Fix crash with initial empty EFI options
EFI code path split options from EFI LoadOptions fields in 2
pieces, first EFI options, second Xen options.
"get_argv" function is called first to get the number of arguments
in the LoadOptions, second, after allocating enough space, to
fill some "argc"/"argv" variable. However the first parsing could
be different from second as second is able to detect "--" argument
separator. So it was possible that "argc" was bigger than the
initialized portion of "argv" array, leading to potential
uninitialized pointer dereference, in particular a string like
"-- a b c" would lead to crashes.
Using EFI shell is possible to pass any kind of string in
LoadOptions.

Fixes: bf6501a62e ("x86-64: EFI boot code")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-09-01 13:07:01 +02:00
Frediano Ziglio 2c0ca5956f x86/boot: Remove unused symbols from linker script
The symbols declared with DECLARE_IMPORT are meant to be
used by the 32 bit code.
The __base_relocs_{start,end} symbols were not used by the
code.
No functional changes.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2025-08-14 11:36:10 +02:00
Frediano Ziglio a492ec7b01 xen/efi: Reduce variable scope to avoid compiler warning
This change removes some piece of code working around with
some compiler warnings.
No functional change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-07-30 12:03:59 +02:00
Frediano Ziglio 710d1dd128 xen/rangeset: fix typo in comment
Fixes: fc41b5c1fd ("Extend the range abstraction"...)
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
2025-07-29 11:28:37 +02:00
Frediano Ziglio ac1d2e6caa xen/efi: Do not pass dummy pointer for empty property
There's no need to pass a buffer, the property is empty.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2025-07-23 09:52:15 +02:00
Frediano Ziglio 70b9bbe88c xen/efi: Fix indentation
Use 4 spaces instead of 3 spaces.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2025-07-23 09:52:15 +02:00
Frediano Ziglio 8025cb1c3d xen/efi: Reuse fdt_setprop_u32 and fdt_setprop_u64
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2025-07-23 09:52:15 +02:00
Frediano Ziglio 2dee23ad96 xen/efi: Remove PrintMessage function
The function is similar to PrintStr with an implicit newline
added to the string.
In Xen this is not a common pattern and this is used in EFI
ARM code only making it not much coherent with X86 code
so use PrintStr directly to make the code more coherent.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
2025-07-22 16:21:18 +02:00
Frediano Ziglio e5d6cc6f99 xen/efi: Update error flow for read_file function
Use more explicit goto statements to handle common error code
path instead of a lot of if/else.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-07-17 08:55:14 +02:00
Frediano Ziglio 196cdc097f xen/efi: Handle cases where file didn't come from ESP
A boot loader can load files from outside ESP.
In these cases device could be not provided or path could
be something not supported.
In these cases allows to boot anyway, all information
could be provided using UKI or using other boot loader
features.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-06-26 14:58:10 +02:00
Frediano Ziglio 136387f70f xen/efi: Drop stale #undef buffer
The "buffer" macro was removed when keyhandler_scratch was removed.

Fixes: 59e087bf6a ("xen/keyhandler: Drop keyhandler_scratch")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-06-24 14:56:58 +02:00
Frediano Ziglio e83364bc51 xen/efi: Show error message for EFI_INVALID_PARAMETER error
Show string message instead of code.
This happened trying some different ways to boot Xen, specifically
trying loading xen.efi using GRUB2 "linux" command.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-06-24 14:55:29 +02:00
Frediano Ziglio 623c365951 xen/efi: Do not check kernel signature if it was embedded
Using UKI it's possible to embed Linux kernel into xen.efi file.
In this case the signature for Secure Boot is applied to the
whole xen.efi, including the kernel.
So checking for specific signature for the kernel is not
needed.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-06-23 10:50:13 +02:00
Frediano Ziglio fd1a4550bf drivers/pci: Add minor comment for maximum capability constant
The comment is similar to extended capabilities in the function
below.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2025-06-16 10:13:48 +02:00
Frediano Ziglio a05598bd12 EFI: Avoid crash calling PrintErrMesg from efi_multiboot2
Although code is compiled with -fpic option data is not position
independent. This causes data pointer to become invalid if
code is not relocated properly which is what happens for
efi_multiboot2 which is called by multiboot entry code.

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

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

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

This partially rollback commit 00d5d5ce23.

Fixes: 9180f53655 ("x86: add multiboot2 protocol support for EFI platforms")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-04-17 09:59:41 +02:00
Frediano Ziglio 14694975cd docs: Add some details on XenServer PCI devices
Describe the usage of devices 5853:0002 and 5853:C000.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
2025-03-25 09:22:43 +01:00
Frediano Ziglio eaed0d185a EFI: Avoid crash calling PrintErrMesg() from efi_multiboot2()
Although code is compiled with -fpic option data is not position
independent. This causes data pointer to become invalid if
code is not relocated properly which is what happens for
efi_multiboot2 which is called by multiboot entry code.

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

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

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

This partially rollback commit 00d5d5ce23.

Fixes: 9180f53655 ("x86: add multiboot2 protocol support for EFI platforms")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2025-03-06 13:51:01 +01:00
Frediano Ziglio 7d5781d526 x86/boot: Setup correctly fs segment for bogus_real_magic
bogus_real_magic code uses fs segment so it should be initialised.

Fixes: d8c8fef090 ("Provide basic Xen PM infrastructure")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2024-11-11 15:25:39 +00:00
Frediano Ziglio c05ac8fe30 x86/boot: Explicitly list .{sym,shstr,str}tab in build32.lds.S
Currently, building with LLVM's LLD fails:

    ld -melf_i386_fbsd  --orphan-handling=error -N -T ...
    ld: error: <internal>:(.symtab) is being placed in '.symtab'
    ld: error: <internal>:(.shstrtab) is being placed in '.shstrtab'
    ld: error: <internal>:(.strtab) is being placed in '.strtab'
    gmake[11]: *** [arch/x86/boot/Makefile:69: arch/x86/boot/built-in-32.base.bin] Error 1

This is a consequence of --orphan-handling, and it appears that Binutils
doesn't diagnose some orphaned sections even explicitly asked to do so.

List the sections explicitly.

Fixes: aa9045e771 ('x86/boot: Rework how 32bit C is linked/included for early boot')
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-11-06 13:47:23 +00:00
Frediano Ziglio 1580813006 x86/boot: Uses nm command instead of map file to get symbols
combine_two_binaries.py only understands GNU LD's format, and does
not work with LLVM's LLD.

Use nm command instead to get list of symbols; specifically
BSD format as it does not truncate symbols names like sysv one.

Fixes: aa9045e771 ('x86/boot: Rework how 32bit C is linked/included for early boot')
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-11-06 13:47:23 +00:00
Frediano Ziglio e75b327c45 x86/boot: Fix intermediate file names to generate 32 bit code
The "base" and "offset" definition were inverted, "base" file should be the
files without offsets applied while "offset" should have the offsets applied.

Also update an old usage of "final" to "apply offset" to make more clear and
consistent (in former commit messages the "final" term was used instead of
"offset").

Fixes: aa9045e771 ('x86/boot: Rework how 32bit C is linked/included for early boot')
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-11-06 13:47:23 +00:00
Frediano Ziglio 3eb037fbbc MAINTAINERS: minor file line update
"xen/arch/arm/include/asm/tee" is a directory and should be terminated
by a slash ("/").

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Acked-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Acked-by: Bertrand Marquis <bertrand.marquis@arm.com>
2024-10-31 11:35:33 +00:00
Frediano Ziglio 9a2a50d5de x86/mm: Use standard C types for sized integers
The header is already using these types.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2024-10-30 17:34:32 +00:00
Frediano Ziglio aa4ad424f0 x86/setup: Make setup.h header self contained
The header uses rangeset structure pointer.
Forward declare the structure.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-10-30 17:34:32 +00:00
Frediano Ziglio 56bd76925e x86/boot: Use trampoline_phys variable directly from C code
No more need to pass from assembly code.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-10-29 15:10:17 +00:00
Frediano Ziglio d5a73cdc6b x86/boot: Use boot_vid_info variable directly from C code
No more need to pass from assembly code.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-10-29 15:10:17 +00:00
Frediano Ziglio db8acf31f9 x86/boot: Reuse code to relocate trampoline
Move code from efi-boot.h to a separate, new, reloc-trampoline.c file.
Reuse this new code, compiling it for 32bit as well, to replace assembly
code in head.S doing the same thing.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2024-10-29 15:10:17 +00:00
Frediano Ziglio aa9045e771 x86/boot: Rework how 32bit C is linked/included for early boot
Right now, the two functions which were really too complicated to write
in asm are compiled as 32bit PIC, linked to a blob and included
directly, using global asm() to arrange for them to have function semantics.

This is limiting and fragile; the use of data relocations will compile
fine but malfunction when used, creating hard-to-debug bugs.

Furthermore, we would like to increase the amount of C, to
deduplicate/unify Xen's boot logic, as well as making it easier to
follow.  Therefore, rework how the 32bit objects are included.

Link all 32bit objects together first.  This allows for sharing of logic
between translation units.  Use differential linking and explicit
imports/exports to confirm that we only have the expected relocations,
and write the object back out as an assembly file so it can be linked
again as if it were 64bit, to integrate with the rest of Xen.

This allows for the use of external references (e.g. access to global
variables) with reasonable assurance of doing so safely.

No functional change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-10-29 15:10:16 +00:00
Frediano Ziglio 0710b38921 Update deprecated SPDX license identifiers
As specified in LICENSES/GPL-2.0:
- GPL-2.0 -> GPL-2.0-only;
- GPL-2.0+ -> GPL-2.0-or-later.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> [RISC-V]
2024-10-18 23:34:11 +01:00
Frediano Ziglio 47990ecef2 x86/boot: Improve MBI2 structure check
Tag structure should contain at least the tag header.
Entire tag structure must be contained inside MBI2 data.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2024-10-15 18:22:07 +01:00
Frediano Ziglio f4c3300d88 x86/boot: Align mbi2.c stack to 16 bytes
Most of Xen is built with a stack alignment of 8 bytes, but the UEFI spec
mandates 16 and UEFI services will fault if the stack is misaligned.

While the caller of efi_multiboot2_prelude() takes care to align the stack,
mbi2.c accidentally got the Xen-wide default of 8, and has a 50% chance of
crashing depending on how many variables the compiler decided to spill to the
stack.

Compile mbi2.c with the appropriate alignment for UEFI functionality.

Also take the opportunity to make it a fully .init object.

Fixes: eb21ce14d7 ('x86/boot: Rewrite EFI/MBI2 code partly in C')
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
[rewrite the commit message]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-10-15 18:20:57 +01:00
Frediano Ziglio 93af5cc4df x86/boot: Prep work for 32bit object changes
Broken out of the subsequent patch for clarity.

 * Rename head-bin-objs to obj32
 * Use a .32.o suffix to distinguish these objects
 * Factor out $(LD32)

No functional change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2024-10-15 14:24:25 +02:00
Frediano Ziglio 439f3e6757 xen: Update header guards - ARGO
Updated header related to ARGO.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Christopher Clark <christopher.w.clark@gmail.com>
2024-10-10 10:53:15 +02:00
Frediano Ziglio b315293130 xen: Update header guards - RISC-V
Update headers related to RISC-V.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2024-10-09 09:53:49 +02:00
Frediano Ziglio 6bbcb97ba4 xen: Update header guards - I/O MMU
Update headers related to I/O MMU.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2024-10-09 09:53:25 +02:00
Frediano Ziglio 964c9568ea xen: Update header guards - Intel TXT
Update the header related to Intel trusted execution technology.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2024-10-09 09:53:05 +02:00
Frediano Ziglio 011814bd45 x86/boot: Rationalise .gitignore
Strip all related content out of the root .gitignore, and provide a
more local .gitignore's with up-to-date patterns.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-10-08 13:06:13 +01:00
Frediano Ziglio 9ab0496350 .gitignore: Remove not generated files
Both reloc.S and cmdline.S are not generated since commit
1ab7c128d9 ("x86/build: Don't convert boot/{cmdline,head}.bin back to .S")

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-10-08 13:06:13 +01:00
Frediano Ziglio 79ade905b9 x86: Use standard C types in multiboot2.h header
The header already uses standard types for many fields, extend
their usage.
No functional change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2024-10-08 11:15:08 +01:00
Frediano Ziglio eb21ce14d7 x86/boot: Rewrite EFI/MBI2 code partly in C
No need to have it coded in assembly.
Declare efi_multiboot2 in a new header to reuse between implementations
and caller.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2024-10-03 14:40:55 +01:00
Frediano Ziglio 94423b8f75 drivers/video: Convert source files to UTF-8
Most of the tools nowadays assume this encoding.
These files do not specify any encoding so convert them to the default.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-30 17:52:24 +01:00
Frediano Ziglio 0857c75e6f x86/boot: Refactor BIOS/PVH start
The 2 code paths were sharing quite some common code, reuse it instead
of having duplications.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-26 14:18:03 +01:00
Frediano Ziglio b083121c94 x86/boot: Initialise BSS sooner
Allows to call C code earlier.
In order to safely call C code we need to setup stack, selectors and BSS.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-25 16:47:51 +02:00
Frediano Ziglio b81ea162ef x86/defns: Fix typo in comment "Porection" -> "Protection"
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-25 12:12:35 +01:00
Frediano Ziglio 512ac41aa6 xen/efi: efibind: Fix typo in comment
expresion -> expression

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-25 12:12:31 +01:00
Frediano Ziglio be21da24c6 x86/boot: Add missing __XEN__ definition for 32 bit code
We are compiling Xen source code so we should define __XEN__ macro.
We don't want to import all definitions from XEN_CFLAGS (as done for
other options) because most of them are processor dependent and
do not apply to 32 bit.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-09 14:59:05 +01:00
Frediano Ziglio bbe4035e67 x86/boot: Optimise 32 bit C source code
The various filters are removing all optimisations.
No need to have all optimisations turned off.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-09 14:59:05 +01:00
Frediano Ziglio 71df923443 x86/boot: Avoid usage of global in reloc.c
All code and data from this file will go into a text section
which we want to not be writeable.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-09 13:42:38 +02:00
Frediano Ziglio e884903ec5 x86/boot: Use C99 types for integers
Just style update, no functional change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2024-09-02 11:42:32 +01:00
Frediano Ziglio e58a2858d5 x86/boot: Preserve the value clobbered by the load-base calculation
Right now, Xen clobbers the value at 0xffc when performing it's load-base
calculation.  We've got plenty of free registers at this point, so the value
can be preserved easily.

This fixes a real bug booting under Coreboot+SeaBIOS, where 0xffc happens to
be the cbmem pointer (e.g. Coreboot's dmesg ring, among other things).

However, there's also a better choice of memory location to use than 0xffc, as
all our supported boot protocols have a pointer to an info structure in %ebx.

Update the documentation to match.

Fixes: 1695e53851 ("x86/boot: Fix the boot time relocation calculations")
Fixes: d96bb172e8 ("x86/entry: Early PVH boot code")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2024-08-27 18:08:19 +01:00
Frediano Ziglio d9fe1d743f Constify some parameters
Make clear they are not changed in the functions.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com> # XSM
Acked-by: George Dunlap <george.dunlap@cloud.com> # sched
2024-02-22 11:51:19 +01:00
Frediano Ziglio c144b9e324 x86: Reduce assembly code size of entry points
On many entries we push 8-bytes zero and exception constants are
small so we can just write a single byte saving 3 bytes for
instruction.
With ENDBR64 this reduces the size of many entry points from 32 to
16 bytes (due to alignment).
The push and the mov are overlapping stores either way.  Swapping
between movl and movb will make no difference at all on performance.
Similar code is already used in autogen_stubs.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2024-02-19 12:46:21 +01:00
Frediano Ziglio 02c6ad4515 x86/entry: Reduce assembly instruction size
Use 32 bit versions in all cases, not only for registers till 8th.
This reduces the encoding from (example with r14):

     49 c7 c6 ff 7f 00 00    mov    $0x7fff,%r14

to

     41 be ff 7f 00 00       mov    $0x7fff,%r14d

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2024-02-06 11:57:05 +01:00
Frediano Ziglio 80b01e20d0 x86/paging: Use more specific constant
__HYPERVISOR_arch_1 and __HYPERVISOR_paging_domctl_cont for x86
have the same value but this function is handling
"paging_domctl_cont" hypercall so using the latter mnemonic in
the code is more clear.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2024-02-06 11:56:38 +01:00
Frediano Ziglio 1cb7949b37 xen/evtchn: Remove useless assignment in evtchn_alloc_unbound()
The variable 'rc' is assigned later, that value is never used.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2024-02-05 21:17:44 +00:00
Frediano Ziglio fbcec32d6d x86/mem_sharing: Release domain if we are not able to enable memory sharing
In case it's not possible to enable memory sharing (mem_sharing_control
fails) we just return the error code without releasing the domain
acquired some lines above by rcu_lock_live_remote_domain_by_id().

Fixes: 72f8d45d69 ("x86/mem_sharing: enable mem_sharing on first memop")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
2023-11-27 12:06:13 +00:00
Frediano Ziglio b9eeb19926 x86/mem_sharing: Fix typo in comment
ambigious -> ambiguous

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
2023-11-27 12:05:58 +00:00
Frediano Ziglio 3ea5918ead x86/ACPI: constify acpi_enter_sleep argument
Minor style change, structure is not changed.
No functional change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2023-11-23 10:05:01 +01:00