64 bit truncation in code_gen_buffer_size calculation
PATCH 1/1 64 bit truncation in code_gen_buffer_size calculation
Hi,
This one is pretty obvious, don't truncate the result of code_gen_buffer_size calculation to int when the target is an unsigned long. Gives funny results when trying to boot something with a lot of memory on a 64 bit system.
Cheers,
Jes
Don't truncate code_gen_buffer_size calculation to int, as it will give unpredicted results on 64 bit systems when booting large guests.
Signed-off-by Jes Sorensen <[email protected]>
--- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
exec.c +1 -1
@@ -410,7 +410,7 @@ static void code_gen_alloc(unsigned long code_gen_buffer_size =DEFAULT_CODE_GEN_BUFFER_SIZE ;#else /* XXX: needs ajustments */ - code_gen_buffer_size = (int )(phys_ram_size /4 ); + code_gen_buffer_size = (unsigned long )(phys_ram_size /4 );#endif }if (code_gen_buffer_size <MIN_CODE_GEN_BUFFER_SIZE )
Anthony Liguori
AppliedQuoted 6 lines · Jes Sorensen
Hi,
This one is pretty obvious, don't truncate the result of
code_gen_buffer_sizecalculation to int when the target is an unsigned long. Gives funny results when trying to boot something with a lot of memory on a 64 bit system.
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 5 lines
Cheers,
Jes