Skip to contentSkip to conversation

qemu_{real_}host_page_[size|mask] change types to ram_addr_t

PATCH In review Dr. David Alan Gilbert (git) 3 participants 4 messages Dec 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu_{real_}host_page_[size|mask] change types to ram_addr_t

From: "Dr. David Alan Gilbert" <[email protected]>

Anthony reported that >4GB guests on Xen with 32bit QEMU broke after my 4ed023c (Round up RAMBlock sizes).

In that patch I mask sizes against qemu_host_page_size/mask which are uintptr_t, and thus 32bit on a 32bit QEMU, even though the ram space might be bigger than 4GB on Xen.

ram_addr_t is uintptr_t on KVM and uint64_t on Xen; so there should be no change on KVM, and on Xen we always get the larger size.

Remove the ~10 year old scary comment that the type of these variables is probably wrong.

Fixes 4ed023ce2a39ab5812d33cf4d819def168965a7f
---
 include/exec/cpu-all.h | 9 ++++-----
 translate-all.c        | 4 ++--
 translate-common.c     | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)
include/exec/cpu-all.h +4 -5
index f9998b9..e23b852 100644
@@ -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 uintptr_t qemu_host_page_size;
-extern uintptr_t qemu_host_page_mask;
+extern ram_addr_t qemu_real_host_page_size;
+extern ram_addr_t qemu_real_host_page_mask;
+extern ram_addr_t qemu_host_page_size;
+extern ram_addr_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 +2 -2
index a940bd2..317f251 100644
@@ -117,8 +117,8 @@ 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;
+ram_addr_t qemu_host_page_size;
+ram_addr_t qemu_host_page_mask;
 
 /* The bottom level has pointers to PageDesc */
 static void *l1_map[V_L1_SIZE];
translate-common.c +2 -2
index 619feb4..2fe2d1e 100644
@@ -20,8 +20,8 @@
 #include "qemu-common.h"
 #include "qom/cpu.h"
 
-uintptr_t qemu_real_host_page_size;
-uintptr_t qemu_real_host_page_mask;
+ram_addr_t qemu_real_host_page_size;
+ram_addr_t qemu_real_host_page_mask;
 
 #ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Anthony reported that >4GB guests on Xen with 32bit QEMU broke after my 4ed023c (Round up RAMBlock sizes).

In that patch I mask sizes against qemu_host_page_size/mask which are uintptr_t, and thus 32bit on a 32bit QEMU, even though the ram space might be bigger than 4GB on Xen.

ram_addr_t is uintptr_t on KVM and uint64_t on Xen; so there should be no change on KVM, and on Xen we always get the larger size.

Quoted 6 lines

Remove the ~10 year old scary comment that the type of these variables is probably wrong.

Fixes 4ed023ce2a39ab5812d33cf4d819def168965a7f

If nobody complains, I will sent this on next migration pull requset.

Paolo, I think that I preffer this that trusting the intptr_t sign extension, but I can be convinced either way. What do you think?

Quoted 58 lines
---
 include/exec/cpu-all.h | 9 ++++-----
 translate-all.c        | 4 ++--
 translate-common.c     | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)
include/exec/cpu-all.h +4 -5
index f9998b9..e23b852 100644
@@ -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 uintptr_t qemu_host_page_size;
-extern uintptr_t qemu_host_page_mask;
+extern ram_addr_t qemu_real_host_page_size;
+extern ram_addr_t qemu_real_host_page_mask;
+extern ram_addr_t qemu_host_page_size;
+extern ram_addr_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 +2 -2
index a940bd2..317f251 100644
@@ -117,8 +117,8 @@ 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;
+ram_addr_t qemu_host_page_size;
+ram_addr_t qemu_host_page_mask;
 
 /* The bottom level has pointers to PageDesc */
 static void *l1_map[V_L1_SIZE];
translate-common.c +2 -2
index 619feb4..2fe2d1e 100644
@@ -20,8 +20,8 @@
 #include "qemu-common.h"
 #include "qom/cpu.h"
 
-uintptr_t qemu_real_host_page_size;
-uintptr_t qemu_real_host_page_mask;
+ram_addr_t qemu_real_host_page_size;
+ram_addr_t qemu_real_host_page_mask;
 
 #ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
#2 lore raw
Quoted 6 lines · Juan Quintela

If nobody complains, I will sent this on next migration pull requset.

Paolo, I think that I preffer this that trusting the intptr_t sign extension, but I can be convinced either way. What do you think?

It's not trusting, it's the way C works, but I'm okay either way.

Paolo

#3 lore raw
In reply to Juan Quintela
Quoted 21 lines · * Juan Quintela ([email protected]) wrote:
Quoted 13 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Anthony reported that >4GB guests on Xen with 32bit QEMU broke after my 4ed023c (Round up RAMBlock sizes).

In that patch I mask sizes against qemu_host_page_size/mask which are uintptr_t, and thus 32bit on a 32bit QEMU, even though the ram space might be bigger than 4GB on Xen.

ram_addr_t is uintptr_t on KVM and uint64_t on Xen; so there should be no change on KVM, and on Xen we always get the larger size.

Quoted 6 lines

Remove the ~10 year old scary comment that the type of these variables is probably wrong.

Fixes 4ed023ce2a39ab5812d33cf4d819def168965a7f
Quoted 6 lines

If nobody complains, I will sent this on next migration pull requset.

Paolo, I think that I preffer this that trusting the intptr_t sign extension, but I can be convinced either way. What do you think?

Hang on, Juan just pointed out this breaks builds of a bunch of stuff; checking....

Dave

Quoted 52 lines
Quoted 52 lines
---
 include/exec/cpu-all.h | 9 ++++-----
 translate-all.c        | 4 ++--
 translate-common.c     | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)
include/exec/cpu-all.h +4 -5
index f9998b9..e23b852 100644
@@ -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 uintptr_t qemu_host_page_size;
-extern uintptr_t qemu_host_page_mask;
+extern ram_addr_t qemu_real_host_page_size;
+extern ram_addr_t qemu_real_host_page_mask;
+extern ram_addr_t qemu_host_page_size;
+extern ram_addr_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 +2 -2
index a940bd2..317f251 100644
@@ -117,8 +117,8 @@ 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;
+ram_addr_t qemu_host_page_size;
+ram_addr_t qemu_host_page_mask;
 
 /* The bottom level has pointers to PageDesc */
 static void *l1_map[V_L1_SIZE];
translate-common.c +0 -0
index 619feb4..2fe2d1e 100644
@@ -20,8 +20,8 @@
 #include "qemu-common.h"
 #include "qom/cpu.h"
 
Quoted 7 lines

translate-common.c line 27

Quoted 7 lines
translate-common.c +2 -2
-uintptr_t qemu_real_host_page_size;
-uintptr_t qemu_real_host_page_mask;
+ram_addr_t qemu_real_host_page_size;
+ram_addr_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