[build] Constrain PHYS_CODE() and REAL_CODE() to use i386 registers

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>
This commit is contained in:
Michael Brown
2025-05-07 22:57:40 +01:00
parent 12dee2dab2
commit e8a6c26571
4 changed files with 12 additions and 12 deletions

View 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" );

View 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;

View 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 ) ) );
}
/**

View 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 ) );