mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 09:05:27 +00:00
translate-all: ensure host page mask is always extended with 1's
Anthony reported that >4GB guests on Xen with 32bit QEMU broke after commit 4ed023c ("Round up RAMBlock sizes to host page sizes", 2015-11-05). In that patch sizes are masked 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. Since ram_addr_t is not available on user-mode emulation targets, ensure that we get a sign extension when masking away the low bits of the address. Remove the ~10 year old scary comment that the type of these variables is probably wrong, with another equally scary comment. The new comment however does not have "???" in it, which is arguably an improvement. For completeness use the alignment macros in linux-user and bsd-user instead of manually doing an &. linux-user and bsd-user are not affected by the Xen issue, however. Backports commit 0c2d70c448b7853a91cfa63659aa3cc6630fb9be from qemu
This commit is contained in:
parent
86436964b5
commit
c8be425439
|
@ -119,9 +119,9 @@ typedef struct PageDesc {
|
||||||
#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)
|
#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)
|
||||||
|
|
||||||
static uintptr_t qemu_real_host_page_size;
|
static uintptr_t qemu_real_host_page_size;
|
||||||
|
static intptr_t qemu_real_host_page_mask;
|
||||||
static uintptr_t qemu_host_page_size;
|
static uintptr_t qemu_host_page_size;
|
||||||
static uintptr_t qemu_host_page_mask;
|
static intptr_t qemu_host_page_mask;
|
||||||
|
|
||||||
|
|
||||||
static void tb_link_page(struct uc_struct *uc, TranslationBlock *tb,
|
static void tb_link_page(struct uc_struct *uc, TranslationBlock *tb,
|
||||||
tb_page_addr_t phys_pc, tb_page_addr_t phys_page2);
|
tb_page_addr_t phys_pc, tb_page_addr_t phys_page2);
|
||||||
|
@ -317,13 +317,14 @@ static void page_size_init(void)
|
||||||
/* NOTE: we can always suppose that qemu_host_page_size >=
|
/* NOTE: we can always suppose that qemu_host_page_size >=
|
||||||
TARGET_PAGE_SIZE */
|
TARGET_PAGE_SIZE */
|
||||||
qemu_real_host_page_size = getpagesize();
|
qemu_real_host_page_size = getpagesize();
|
||||||
|
qemu_real_host_page_mask = -(intptr_t)qemu_real_host_page_size;
|
||||||
if (qemu_host_page_size == 0) {
|
if (qemu_host_page_size == 0) {
|
||||||
qemu_host_page_size = qemu_real_host_page_size;
|
qemu_host_page_size = qemu_real_host_page_size;
|
||||||
}
|
}
|
||||||
if (qemu_host_page_size < TARGET_PAGE_SIZE) {
|
if (qemu_host_page_size < TARGET_PAGE_SIZE) {
|
||||||
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)
|
static void page_init(void)
|
||||||
|
|
Loading…
Reference in a new issue