Regression: Xen guest with 5G of RAM on 32bit fail to boot
Hi,
Under Xen, a guest with 5G of RAM, with a 32bit binary QEMU (well, with a 32bit dom0) does not boot anymore. QEMU abort() with "Bad ram offset efffd000".
This issue first appear in 4ed023ce2a39ab5812d33cf4d819def168965a7f (Round up RAMBlock sizes to host page sizes).
The problem is in qemu_ram_alloc_internal() where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been an uintptr_t in the HOST_PAGE_ALIGN macro.
ram_add_t is uint64_t when compiled with --enable-xen.
Regards,
Signature · 1 line
Anthony PERARD
Quoted 5 lines · * Anthony PERARD ([email protected]) wrote:
Hi,
Under Xen, a guest with 5G of RAM, with a 32bit binary QEMU (well, with a 32bit dom0) does not boot anymore. QEMU
abort()with "Bad ram offsetefffd000".
Quoted 8 lines
This issue first appear in
4ed023ce2a39ab5812d33cf4d819def168965a7f(Round up RAMBlock sizes to host page sizes).The problem is in
qemu_ram_alloc_internal()where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been anuintptr_tin theHOST_PAGE_ALIGNmacro.
ram_add_tisuint64_twhen compiled with --enable-xen.
Hmm, that's a fun problem.
Would changing qemu_host_page_[size|mask] to ram_addr_t work?
Dave
Quoted 5 lines
Regards,
Signature · 1 line
Anthony PERARD
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 5 lines · * Anthony PERARD ([email protected]) wrote:
Hi,
Under Xen, a guest with 5G of RAM, with a 32bit binary QEMU (well, with a 32bit dom0) does not boot anymore. QEMU
abort()with "Bad ram offsetefffd000".
Quoted 8 lines
This issue first appear in
4ed023ce2a39ab5812d33cf4d819def168965a7f(Round up RAMBlock sizes to host page sizes).The problem is in
qemu_ram_alloc_internal()where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been anuintptr_tin theHOST_PAGE_ALIGNmacro.
ram_add_tisuint64_twhen compiled with --enable-xen.
Hmm, that's a fun problem.
Would changing qemu_host_page_[size|mask] to ram_addr_t work?
Dave
Quoted 5 lines
Regards,
Signature · 1 line
Anthony PERARD
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Anthony PERARD ([email protected]) wrote:
Hi,
Under Xen, a guest with 5G of RAM, with a 32bit binary QEMU (well, with a 32bit dom0) does not boot anymore. QEMU
abort()with "Bad ram offsetefffd000".This issue first appear in
4ed023ce2a39ab5812d33cf4d819def168965a7f(Round up RAMBlock sizes to host page sizes).
Quoted 8 lines
Quoted 5 lines
The problem is in
qemu_ram_alloc_internal()where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been anuintptr_tin theHOST_PAGE_ALIGNmacro.
ram_add_tisuint64_twhen compiled with --enable-xen.Hmm, that's a fun problem.
Would changing qemu_host_page_[size|mask] toram_addr_twork?
Yes, well, I did change the type to uint64_t and I could boot a guest. With ram_addr_t, it works fine as well.
Signature · 1 line
Anthony PERARD
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Anthony PERARD ([email protected]) wrote:
Hi,
Under Xen, a guest with 5G of RAM, with a 32bit binary QEMU (well, with a 32bit dom0) does not boot anymore. QEMU
abort()with "Bad ram offsetefffd000".This issue first appear in
4ed023ce2a39ab5812d33cf4d819def168965a7f(Round up RAMBlock sizes to host page sizes).
Quoted 8 lines
Quoted 5 lines
The problem is in
qemu_ram_alloc_internal()where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been anuintptr_tin theHOST_PAGE_ALIGNmacro.
ram_add_tisuint64_twhen compiled with --enable-xen.Hmm, that's a fun problem.
Would changing qemu_host_page_[size|mask] toram_addr_twork?
Yes, well, I did change the type to uint64_t and I could boot a guest. With ram_addr_t, it works fine as well.
Signature · 1 line
Anthony PERARD
Quoted 3 lines · Anthony PERARD
The problem is in
qemu_ram_alloc_internal()where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been anuintptr_tin theHOST_PAGE_ALIGNmacro.
Isn't it qemu_host_page_mask that causes the problem?
This should also work, as it causes qemu_host_page_mask to sign-extend:
include/exec/cpu-all.h +2 -3
@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \
translate-all.c +3 -3
@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];
@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )
translate-common.c +1 -1
@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */
Quoted 3 lines · Anthony PERARD
The problem is in
qemu_ram_alloc_internal()where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been anuintptr_tin theHOST_PAGE_ALIGNmacro.
Isn't it qemu_host_page_mask that causes the problem?
This should also work, as it causes qemu_host_page_mask to sign-extend:
include/exec/cpu-all.h +2 -3
@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \
translate-all.c +3 -3
@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];
@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )
translate-common.c +1 -1
@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */
Quoted 10 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 3 lines · Anthony PERARD
The problem is in
qemu_ram_alloc_internal()where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been anuintptr_tin theHOST_PAGE_ALIGNmacro.Isn't it
qemu_host_page_maskthat causes the problem?This should also work, as it causes
qemu_host_page_maskto sign-extend:
I've just posted a set that just flips them to ram_addr_t (and removes the 10 year old warning that questions whether the type is right - which it obviously wasn't); see '[For 2.5?? PATCH 1/1] qemu_{real_}host_page_[size|mask] change types to
ram_addr_t'
Anthony: I'd appreciate if you could give it a Xen test.
Dave
Quoted 53 lines
include/exec/cpu-all.h +2
-3@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \translate-all.c +3
-3@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )translate-common.c +0
-0
translate-common.c line 27
Quoted 8 lines
translate-common.c +1
-1@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 10 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 3 lines · Anthony PERARD
The problem is in
qemu_ram_alloc_internal()where 'size' and 'maxsize' are now been truncate to 32bit, due to 'qemu_host_page_size' been anuintptr_tin theHOST_PAGE_ALIGNmacro.Isn't it
qemu_host_page_maskthat causes the problem?This should also work, as it causes
qemu_host_page_maskto sign-extend:
I've just posted a set that just flips them to ram_addr_t (and removes the 10 year old warning that questions whether the type is right - which it obviously wasn't); see '[For 2.5?? PATCH 1/1] qemu_{real_}host_page_[size|mask] change types to
ram_addr_t'
Anthony: I'd appreciate if you could give it a Xen test.
Dave
Quoted 53 lines
include/exec/cpu-all.h +2
-3@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \translate-all.c +3
-3@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )translate-common.c +0
-0
translate-common.c line 27
Quoted 8 lines
translate-common.c +1
-1@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 55 lines · Paolo Bonzini
include/exec/cpu-all.h +2
-3@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \translate-all.c +3
-3@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )translate-common.c +0
-0
translate-common.c line 27
Quoted 8 lines
translate-common.c +1
-1@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */
Ok, I tested this by adding
+ assert(HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll);
+ assert(REAL_HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll);
and doing a 32-bit x86_64-linux-user build. Since Dave's patch does not compile for user-mode emulation (ram_addr_t is a softmmu concept), I'm queuing my patch for 2.5.
Paolo
Quoted 55 lines · Paolo Bonzini
include/exec/cpu-all.h +2
-3@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \translate-all.c +3
-3@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )translate-common.c +0
-0
translate-common.c line 27
Quoted 8 lines
translate-common.c +1
-1@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */
Ok, I tested this by adding
+ assert(HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll);
+ assert(REAL_HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll);
and doing a 32-bit x86_64-linux-user build. Since Dave's patch does not compile for user-mode emulation (ram_addr_t is a softmmu concept), I'm queuing my patch for 2.5.
Paolo
Quoted 72 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 55 lines · Paolo Bonzini
include/exec/cpu-all.h +2
-3@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \translate-all.c +3
-3@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )translate-common.c +0
-0translate-common.c line 27
Quoted 8 lines
translate-common.c +1
-1@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */ Ok, I tested this by adding
(quoted diff) +2
-0+ assert(HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll); + assert(REAL_HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll);
Quoted 3 lines
and doing a 32-bit x86_64-linux-user build. Since Dave's patch does not compile for user-mode emulation (
ram_addr_tis a softmmu concept), I'm queuing my patch for 2.5.
Hmm yes OK; my alternate was just making ram_addr_t being always defined. I'm not sure we have any other type that's more suitable than ram_addr_t but I guess the intptr_t will work for the mask.
Dave
Quoted 2 lines
Paolo
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 72 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 55 lines · Paolo Bonzini
include/exec/cpu-all.h +2
-3@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \translate-all.c +3
-3@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )translate-common.c +0
-0translate-common.c line 27
Quoted 8 lines
translate-common.c +1
-1@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */ Ok, I tested this by adding
(quoted diff) +2
-0+ assert(HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll); + assert(REAL_HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll);
Quoted 3 lines
and doing a 32-bit x86_64-linux-user build. Since Dave's patch does not compile for user-mode emulation (
ram_addr_tis a softmmu concept), I'm queuing my patch for 2.5.
Hmm yes OK; my alternate was just making ram_addr_t being always defined. I'm not sure we have any other type that's more suitable than ram_addr_t but I guess the intptr_t will work for the mask.
Dave
Quoted 2 lines
Paolo
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Juan Quintela
Reviewed-byQuoted 70 lines · Paolo Bonzini
Quoted 55 lines · Paolo Bonzini
include/exec/cpu-all.h +2
-3@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \translate-all.c +3
-3@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )translate-common.c +0
-0translate-common.c line 27
Quoted 8 lines
translate-common.c +1
-1@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */ Ok, I tested this by adding
(quoted diff) +2
-0+ assert(HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll); + assert(REAL_HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll);
Quoted 5 lines
and doing a 32-bit x86_64-linux-user build. Since Dave's patch does not compile for user-mode emulation (
ram_addr_tis a softmmu concept), I'm queuing my patch for 2.5.Paolo
Dave patch massively broke linux-user. Going that route can make sense, but not so late on the cycle.
Juan Quintela
Reviewed-byQuoted 70 lines · Paolo Bonzini
Quoted 55 lines · Paolo Bonzini
include/exec/cpu-all.h +2
-3@@ -174,11 +174,10 @@ extern unsigned long reserved_va;#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)#define TARGET_PAGE_ALIGN (addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask;extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask;#define HOST_PAGE_ALIGN (addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)#define REAL_HOST_PAGE_ALIGN (addr) (((addr) + qemu_real_host_page_size - 1) & \translate-all.c +3
-3@@ -118,7 +118,7 @@ typedef struct PageDesc {#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask;/* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE ];@@ -326,14 +326,14 @@ void page_size_init(void)/* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size =getpagesize (); - qemu_real_host_page_mask = ~(qemu_real_host_page_size -1 ); + qemu_real_host_page_mask = -(intptr_t )qemu_real_host_page_size;if (qemu_host_page_size ==0 ) { qemu_host_page_size = qemu_real_host_page_size; }if (qemu_host_page_size <TARGET_PAGE_SIZE ) { qemu_host_page_size =TARGET_PAGE_SIZE ; } - qemu_host_page_mask = ~(qemu_host_page_size -1 ); + qemu_host_page_mask = -(intptr_t )qemu_host_page_size; }static void page_init (void )translate-common.c +0
-0translate-common.c line 27
Quoted 8 lines
translate-common.c +1
-1@@ -21,7 +21,7 @@#include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask;#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */ Ok, I tested this by adding
(quoted diff) +2
-0+ assert(HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll); + assert(REAL_HOST_PAGE_ALIGN(0x123456700ll) == 0x123457000ll);
Quoted 5 lines
and doing a 32-bit x86_64-linux-user build. Since Dave's patch does not compile for user-mode emulation (
ram_addr_tis a softmmu concept), I'm queuing my patch for 2.5.Paolo
Dave patch massively broke linux-user. Going that route can make sense, but not so late on the cycle.