constant truncation warning in hw/pc.c for 32bit targets
Hi,
for 32bit targets, the 0x100000000ULL start address of above-4G memory is truncated to zero. IMO the code for above-4G allocation could be #ifdef'ed only for 64 bit targets, as for 32bit it 1) miscompiles and
2) won't be used anyway:
pc.c (working copy) renamed from pc.c (revision 5338) +4 -0
@@ -747,7 +747,9 @@ BlockDriverState *fd[MAX_FD]; if (ram_size >= 0xe0000000 ) { +#if TARGET_PHYS_ADDR_BITS == 64 above_4g_mem_size = ram_size - 0xe0000000; +#endif below_4g_mem_size = 0xe0000000; } else { below_4g_mem_size = ram_size;
@@ -798,6 +800,7 @@ below_4g_mem_size - 0x100000, ram_addr); +#if TARGET_PHYS_ADDR_BITS == 64 /* above 4giga memory allocation */ if (above_4g_mem_size > 0) { ram_addr = qemu_ram_alloc(above_4g_mem_size);
@@ -805,6 +808,7 @@ above_4g_mem_size, ram_addr); } +#endif /* allocate VGA RAM */
Regards,
Signature · 1 line
Jindrich Makovicka
Quoted 6 lines · Jindrich Makovicka
Hi,
for 32bit targets, the
0x100000000ULLstart address of above-4G memory is truncated to zero. IMO the code for above-4G allocation could be #ifdef'ed only for 64 bit targets, as for 32bit it 1) miscompiles and
2) won't be used anyway:
There are i386 systems with more than 4G of memory, so your patch is incorrect.
Now, if the code miscompiles there could be a problem somewhere else.
Quoted 10 lines · On Sun, 28 Sep 2008 16:52:22 +0300 "Blue Swirl" <[email protected]> wrote:
Quoted 6 lines · Jindrich Makovicka
Hi,
for 32bit targets, the
0x100000000ULLstart address of above-4G
memory is truncated to zero. IMO the code for above-4G allocation could be #ifdef'ed only for 64 bit targets, as for 32bit it 1) miscompiles and 2) won't be used anyway:There are i386 systems with more than 4G of memory, so your patch is incorrect.
Yes, I know about PAE, but I assumed that when QEMU uses 32 bits for a physical address (32bit guest on 32bit host) it will not support more than 4 gigs.
Quoted 1 line
Now, if the code miscompiles there could be a problem somewhere else.
I meant that for a 32bit target, the physical address passed to cpu_register_physical_memory will be zero instead of 4 gig as one would expect because of the truncation.
I don't have a intimate knowledge of QEMU internals, but this warning just looked a bit fishy to me :)
Signature · 1 line
Jindrich Makovicka