[bios] Make uses of REAL_CODE() and PHYS_CODE() 64-bit clean
On a 64-bit CPU, any modification of a register by 32-bit or 16-bit code will destroy the invisible upper 32 bits of the corresponding 64-bit register. For example: a 32-bit "pushl %eax" followed by a "popl %eax" will zero the upper half of %rax. This differs from the treatment of upper halves of 32-bit registers by 16-bit code: a "pushw %ax" followed by a "popw %ax" will leave the upper 16 bits of %eax unmodified. Inline assembly generated using REAL_CODE() or PHYS_CODE() will therefore have to preserve the upper halves of all registers, to avoid clobbering registers that gcc expects to be preserved. Output operands from REAL_CODE() and PHYS_CODE() assembly may therefore contain undefined values in the upper 32 bits. Fix by using explicit variable widths (e.g. uint32_t) for non-discarded output operands, to ensure that undefined values in the upper 32 bits of 64-bit registers are ignored. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -208,8 +208,10 @@ int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
|
||||
void *params, size_t params_len ) {
|
||||
struct pxeparent_profiler *profiler = pxeparent_profiler ( function );
|
||||
PXENV_EXIT_t exit;
|
||||
unsigned long started;
|
||||
unsigned long stopped;
|
||||
uint32_t before;
|
||||
uint32_t started;
|
||||
uint32_t stopped;
|
||||
uint32_t after;
|
||||
int discard_D;
|
||||
int rc;
|
||||
|
||||
@@ -240,12 +242,14 @@ int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
|
||||
"D" ( __from_data16 ( &pxeparent_params ) )
|
||||
: "ecx", "esi" );
|
||||
profile_stop ( &profiler->total );
|
||||
profile_start_at ( &profiler->p2r, profile_started ( &profiler->total));
|
||||
before = profile_started ( &profiler->total );
|
||||
after = profile_stopped ( &profiler->total );
|
||||
profile_start_at ( &profiler->p2r, before );
|
||||
profile_stop_at ( &profiler->p2r, started );
|
||||
profile_start_at ( &profiler->ext, started );
|
||||
profile_stop_at ( &profiler->ext, stopped );
|
||||
profile_start_at ( &profiler->r2p, stopped );
|
||||
profile_stop_at ( &profiler->r2p, profile_stopped ( &profiler->total ));
|
||||
profile_stop_at ( &profiler->r2p, after );
|
||||
|
||||
/* Determine return status code based on PXENV_EXIT and
|
||||
* PXENV_STATUS
|
||||
|
||||
Reference in New Issue
Block a user