mbox series

[v2,0/6] Reuse 32 bit C code more safely

Message ID 20241007141539.1899350-1-frediano.ziglio@cloud.com (mailing list archive)
Headers show
Series Reuse 32 bit C code more safely | expand

Message

Frediano Ziglio Oct. 7, 2024, 2:15 p.m. UTC
This series attempt to:
- use more C code, that is replace some assembly code with C;
- avoid some code duplication between C and assembly;
- prevent some issues having relocations in C code.

The idea is extending the current C to binary code conversion
done for 32 bit C code called from head.S making sure relocations
are safe and allowing external symbols usage from C code.

Note that, as an addition, scripts generating code check for no
data to allow code and data separation.

More details of the implementation are in commit message 3/6,
which is the largest patch.
Patch 4/6 reuses code to relocate the trampoline between 32 and 64 bit.
Patches 5/6 and 6/6 move some code from assembly to C.

Other RFC commits were excluded, I didn't manage to entangle the issues
sharing headers between 32 and 64 bits.
Since RFC code was more tested, also with CI and some incompatibility
were fixed. On that it's weird that we need Python 3.8 for Qemu but we
still use Python 2 for Xen. Shouldn't we bump requirement to Python 3
even for Xen?

Code boot successfully using:
- BIOS boot;
- EFI boot with Grub2 and ELF file;
- direct EFI boot without Grub.

Code is currently based on "master" branch, currently commit
6b20755c24ccd69d2482b45dfb9193940cdc346e.

Changes since v1:
- 2 preliminary commits for adjust .gitignore;
- last commit split (one variable at a time);
- lot of style and names changes;
- first commit, now 3/6 had some build changes, more details on
  commit message.

Frediano Ziglio (6):
  .gitignore: Remove not generated files
  x86/boot: Rationalise .gitignore
  x86/boot: create a C bundle for 32 bit boot code and use it
  x86/boot: Reuse code to relocate trampoline
  x86/boot: Use trampoline_phys variable directly from C code
  x86/boot: Use boot_vid_info variable directly from C code

 .gitignore                                    |   5 -
 xen/arch/x86/boot/.gitignore                  |   4 +
 xen/arch/x86/boot/Makefile                    |  62 ++++--
 .../x86/boot/{build32.lds => build32.lds.S}   |  49 ++++-
 xen/arch/x86/boot/cmdline.c                   |  12 --
 xen/arch/x86/boot/head.S                      |  49 +----
 xen/arch/x86/boot/reloc-trampoline.c          |  36 ++++
 xen/arch/x86/boot/reloc.c                     |  33 +--
 xen/arch/x86/efi/efi-boot.h                   |  15 +-
 xen/tools/combine_two_binaries                | 198 ++++++++++++++++++
 10 files changed, 344 insertions(+), 119 deletions(-)
 create mode 100644 xen/arch/x86/boot/.gitignore
 rename xen/arch/x86/boot/{build32.lds => build32.lds.S} (57%)
 create mode 100644 xen/arch/x86/boot/reloc-trampoline.c
 create mode 100755 xen/tools/combine_two_binaries

Comments

Andrew Cooper Oct. 8, 2024, 12:02 p.m. UTC | #1
On 07/10/2024 3:15 pm, Frediano Ziglio wrote:
> Frediano Ziglio (6):
>   .gitignore: Remove not generated files
>   x86/boot: Rationalise .gitignore

These two are trivial so I've taken them.

~Andrew