]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Constrain PHYS_CODE() and REAL_CODE() to use i386 registers
authorMichael Brown <mcb30@ipxe.org>
Wed, 7 May 2025 21:57:40 +0000 (22:57 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 7 May 2025 22:03:02 +0000 (23:03 +0100)
Inline assembly using PHYS_CODE() or REAL_CODE() must use the "R"
constraint rather than the "r" constraint to ensure that the compiler
chooses registers that will be valid for the 32-bit or 16-bit assembly
code fragment.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/image/com32.c
src/arch/x86/image/comboot.c
src/arch/x86/interface/pcbios/bios_mp.c
src/arch/x86/interface/syslinux/comboot_call.c

index 0c47f95e45f5acefd7b302adaafce79f31fc6933..37fb2c3c0e453292f73509294bce3f055185f30e 100644 (file)
@@ -114,13 +114,13 @@ static int com32_exec_loop ( struct image *image ) {
                        /* Restore registers */
                        "popal\n\t" )
                        :
-                       : "r" ( avail_mem_top ),
-                         "r" ( virt_to_phys ( com32_cfarcall_wrapper ) ),
-                         "r" ( virt_to_phys ( com32_farcall_wrapper ) ),
-                         "r" ( get_fbms() * 1024 - ( COM32_BOUNCE_SEG << 4 ) ),
+                       : "R" ( avail_mem_top ),
+                         "R" ( virt_to_phys ( com32_cfarcall_wrapper ) ),
+                         "R" ( virt_to_phys ( com32_farcall_wrapper ) ),
+                         "R" ( get_fbms() * 1024 - ( COM32_BOUNCE_SEG << 4 ) ),
                          "i" ( COM32_BOUNCE_SEG << 4 ),
-                         "r" ( virt_to_phys ( com32_intcall_wrapper ) ),
-                         "r" ( virt_to_phys ( image->cmdline ?
+                         "R" ( virt_to_phys ( com32_intcall_wrapper ) ),
+                         "R" ( virt_to_phys ( image->cmdline ?
                                               image->cmdline : "" ) ),
                          "i" ( COM32_START_PHYS )
                        : "memory" );
index dcf9114b547cfe156840aa372bf19f94131a5bed..f717e1d32254acef0214a2da98d60785bce714cf 100644 (file)
@@ -171,7 +171,7 @@ static int comboot_exec_loop ( struct image *image ) {
                                    "xorw %%di, %%di\n\t"
                                    "xorw %%bp, %%bp\n\t"
                                    "lret\n\t" )
-                                        : : "r" ( COMBOOT_PSP_SEG ) : "eax" );
+                                        : : "R" ( COMBOOT_PSP_SEG ) : "eax" );
                DBGC ( image, "COMBOOT %p: returned\n", image );
                break;
 
index 9e1179ccdff4baebe1e9f0a5662f30b5e349f582..c903a81fc804e5aee1b46c5ac8001b4022f5a9ca 100644 (file)
@@ -92,9 +92,9 @@ static void bios_mp_exec_boot ( mp_func_t func, void *opaque ) {
                                           "pushl %k1\n\t"
                                           "call *%k0\n\t"
                                           "addl $8, %%esp\n\t" )
-                              : : "r" ( mp_address ( mp_call ) ),
-                                  "r" ( mp_address ( func ) ),
-                                  "r" ( mp_address ( opaque ) ) );
+                              : : "R" ( mp_address ( mp_call ) ),
+                                  "R" ( mp_address ( func ) ),
+                                  "R" ( mp_address ( opaque ) ) );
 }
 
 /**
index 714807f7a7cef97f1dbbe645dd52d217a610b167..f7cceb30f927c552c914f9b7add17a2af4426eda 100644 (file)
@@ -514,8 +514,8 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
                                "lret\n\t"
                        )
                        :
-                       : "r" ( ix86->segs.ds ),
-                         "r" ( ix86->regs.ebp ),
+                       : "R" ( ix86->segs.ds ),
+                         "R" ( ix86->regs.ebp ),
                          "d" ( ix86->regs.ebx ),
                          "S" ( ix86->regs.esi ) );