Skip to contentSkip to conversation

x86/boot: Don't use INC to set defaults

PATCH In review Andrew Cooper 3 participants 4 messages Oct 3, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/boot: Don't use INC to set defaults

__efi64_mb2_start() makes some bold assumptions about the efi_platform and skip_realmode booleans. Set them to 1 explicitly, which is more robust.

Make the comment a little more consice.

No practical change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Frediano Ziglio <[email protected]>

---
 xen/arch/x86/boot/head.S | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
xen/arch/x86/boot/head.S +4 -6
index d1856d8012c9..af776c201a15 100644
@@ -279,14 +279,12 @@ __efi64_mb2_start:
         pop     %rbx
         pop     %rax
 
-        /* We are on EFI platform and EFI boot services are available. */
-        incb    efi_platform(%rip)
-
         /*
-         * Disable real mode and other legacy stuff which should not
-         * be run on EFI platforms.
+         * efi_multiboot2_prelude() is happy that we're on EFI platform.  Skip
+         * the BIOS initialisation path.
          */
-        incb    skip_realmode(%rip)
+        movb    $1, efi_platform(%rip)
+        movb    $1, skip_realmode(%rip)
 
         /* Jump to trampoline_setup after switching CPU to x86_32 mode. */
         lea     trampoline_setup(%rip),%r15

base-commit: eb21ce14d709ef0c0030d0625028a4868c81126f

Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 43 lines · Andrew Cooper

__efi64_mb2_start() makes some bold assumptions about the efi_platform and skip_realmode booleans. Set them to 1 explicitly, which is more robust.

Make the comment a little more consice.

No practical change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Frediano Ziglio <[email protected]>

---
 xen/arch/x86/boot/head.S | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
xen/arch/x86/boot/head.S +4 -6
index d1856d8012c9..af776c201a15 100644
@@ -279,14 +279,12 @@ __efi64_mb2_start:
         pop     %rbx
         pop     %rax
 
-        /* We are on EFI platform and EFI boot services are available. */
-        incb    efi_platform(%rip)
-
         /*
-         * Disable real mode and other legacy stuff which should not
-         * be run on EFI platforms.
+         * efi_multiboot2_prelude() is happy that we're on EFI platform.  Skip
+         * the BIOS initialisation path.
          */
-        incb    skip_realmode(%rip)
+        movb    $1, efi_platform(%rip)
+        movb    $1, skip_realmode(%rip)
 
         /* Jump to trampoline_setup after switching CPU to x86_32 mode. */
         lea     trampoline_setup(%rip),%r15
Quoted 1 line

base-commit: eb21ce14d709ef0c0030d0625028a4868c81126f

I like _Bool !

Frediano

#2 lore raw
Quoted 41 lines · Frediano Ziglio
Quoted 40 lines · Andrew Cooper

__efi64_mb2_start() makes some bold assumptions about the efi_platform and skip_realmode booleans. Set them to 1 explicitly, which is more robust.

Make the comment a little more consice.

No practical change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Frediano Ziglio <[email protected]>

---
 xen/arch/x86/boot/head.S | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
xen/arch/x86/boot/head.S +4 -6
index d1856d8012c9..af776c201a15 100644
@@ -279,14 +279,12 @@ __efi64_mb2_start:
         pop     %rbx
         pop     %rax
 
-        /* We are on EFI platform and EFI boot services are available. */
-        incb    efi_platform(%rip)
-
         /*
-         * Disable real mode and other legacy stuff which should not
-         * be run on EFI platforms.
+         * efi_multiboot2_prelude() is happy that we're on EFI platform.  Skip
+         * the BIOS initialisation path.
          */
-        incb    skip_realmode(%rip)
+        movb    $1, efi_platform(%rip)
+        movb    $1, skip_realmode(%rip)
 
Quoted 6 lines
Quoted 4 lines
xen/arch/x86/boot/head.S +0 -0
         /* Jump to trampoline_setup after switching CPU to x86_32 mode. */
         lea     trampoline_setup(%rip),%r15

base-commit: eb21ce14d709ef0c0030d0625028a4868c81126f

Thanks, Roger.

#3 lore raw
Quoted 41 lines · Roger Pau Monné
Quoted 40 lines · Frediano Ziglio
Quoted 39 lines · Andrew Cooper

__efi64_mb2_start() makes some bold assumptions about the efi_platform and skip_realmode booleans. Set them to 1 explicitly, which is more robust.

Make the comment a little more consice.

No practical change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Frediano Ziglio <[email protected]>

---
 xen/arch/x86/boot/head.S | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
xen/arch/x86/boot/head.S +4 -6
index d1856d8012c9..af776c201a15 100644
@@ -279,14 +279,12 @@ __efi64_mb2_start:
         pop     %rbx
         pop     %rax
 
-        /* We are on EFI platform and EFI boot services are available. */
-        incb    efi_platform(%rip)
-
         /*
-         * Disable real mode and other legacy stuff which should not
-         * be run on EFI platforms.
+         * efi_multiboot2_prelude() is happy that we're on EFI platform.  Skip
+         * the BIOS initialisation path.
          */
-        incb    skip_realmode(%rip)
+        movb    $1, efi_platform(%rip)
+        movb    $1, skip_realmode(%rip)
 
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
xen/arch/x86/boot/head.S +0 -0
         /* Jump to trampoline_setup after switching CPU to x86_32 mode. */
         lea     trampoline_setup(%rip),%r15

base-commit: eb21ce14d709ef0c0030d0625028a4868c81126f

Thanks both.

I further note that efi_platform is used exclusively to skip early cmdline parsing, and I'm sure there's probably a better way of doing this, but nothing obvious jumps out to me.

I suspect that getting rid of it will be easier when we've moved more logic to be in C.

~Andrew