Fix usermode virtual address type

Usermode virtual addresses are abi_ulong, not target_ulong.

Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
Paul Brook 2010-03-12 23:23:29 +00:00
parent 4836a2b09a
commit b480d9b74d
5 changed files with 20 additions and 16 deletions

View File

@ -744,15 +744,17 @@ extern unsigned long qemu_host_page_mask;
#define PAGE_WRITE_ORG 0x0010 #define PAGE_WRITE_ORG 0x0010
#define PAGE_RESERVED 0x0020 #define PAGE_RESERVED 0x0020
#if defined(CONFIG_USER_ONLY)
void page_dump(FILE *f); void page_dump(FILE *f);
typedef int (*walk_memory_regions_fn)(void *, unsigned long, typedef int (*walk_memory_regions_fn)(void *, abi_ulong,
unsigned long, unsigned long); abi_ulong, unsigned long);
int walk_memory_regions(void *, walk_memory_regions_fn); int walk_memory_regions(void *, walk_memory_regions_fn);
int page_get_flags(target_ulong address); int page_get_flags(target_ulong address);
void page_set_flags(target_ulong start, target_ulong end, int flags); void page_set_flags(target_ulong start, target_ulong end, int flags);
int page_check_range(target_ulong start, target_ulong len, int flags); int page_check_range(target_ulong start, target_ulong len, int flags);
#endif
void cpu_exec_init_all(unsigned long tb_size); void cpu_exec_init_all(unsigned long tb_size);
CPUState *cpu_copy(CPUState *env); CPUState *cpu_copy(CPUState *env);

View File

@ -29,7 +29,7 @@
addresses in userspace mode. Define tb_page_addr_t to be an appropriate addresses in userspace mode. Define tb_page_addr_t to be an appropriate
type. */ type. */
#if defined(CONFIG_USER_ONLY) #if defined(CONFIG_USER_ONLY)
typedef target_ulong tb_page_addr_t; typedef abi_ulong tb_page_addr_t;
#else #else
typedef ram_addr_t tb_page_addr_t; typedef ram_addr_t tb_page_addr_t;
#endif #endif

22
exec.c
View File

@ -2217,7 +2217,7 @@ struct walk_memory_regions_data
}; };
static int walk_memory_regions_end(struct walk_memory_regions_data *data, static int walk_memory_regions_end(struct walk_memory_regions_data *data,
unsigned long end, int new_prot) abi_ulong end, int new_prot)
{ {
if (data->start != -1ul) { if (data->start != -1ul) {
int rc = data->fn(data->priv, data->start, end, data->prot); int rc = data->fn(data->priv, data->start, end, data->prot);
@ -2233,9 +2233,9 @@ static int walk_memory_regions_end(struct walk_memory_regions_data *data,
} }
static int walk_memory_regions_1(struct walk_memory_regions_data *data, static int walk_memory_regions_1(struct walk_memory_regions_data *data,
unsigned long base, int level, void **lp) abi_ulong base, int level, void **lp)
{ {
unsigned long pa; abi_ulong pa;
int i, rc; int i, rc;
if (*lp == NULL) { if (*lp == NULL) {
@ -2258,7 +2258,8 @@ static int walk_memory_regions_1(struct walk_memory_regions_data *data,
} else { } else {
void **pp = *lp; void **pp = *lp;
for (i = 0; i < L2_BITS; ++i) { for (i = 0; i < L2_BITS; ++i) {
pa = base | (i << (TARGET_PAGE_BITS + L2_BITS * level)); pa = base | ((abi_ulong)i <<
(TARGET_PAGE_BITS + L2_BITS * level));
rc = walk_memory_regions_1(data, pa, level - 1, pp + i); rc = walk_memory_regions_1(data, pa, level - 1, pp + i);
if (rc != 0) { if (rc != 0) {
return rc; return rc;
@ -2280,7 +2281,7 @@ int walk_memory_regions(void *priv, walk_memory_regions_fn fn)
data.prot = 0; data.prot = 0;
for (i = 0; i < V_L1_SIZE; i++) { for (i = 0; i < V_L1_SIZE; i++) {
int rc = walk_memory_regions_1(&data, i << V_L1_SHIFT, int rc = walk_memory_regions_1(&data, (abi_ulong)i << V_L1_SHIFT,
V_L1_SHIFT / L2_BITS - 1, l1_map + i); V_L1_SHIFT / L2_BITS - 1, l1_map + i);
if (rc != 0) { if (rc != 0) {
return rc; return rc;
@ -2290,12 +2291,13 @@ int walk_memory_regions(void *priv, walk_memory_regions_fn fn)
return walk_memory_regions_end(&data, 0, 0); return walk_memory_regions_end(&data, 0, 0);
} }
static int dump_region(void *priv, unsigned long start, static int dump_region(void *priv, abi_ulong start,
unsigned long end, unsigned long prot) abi_ulong end, unsigned long prot)
{ {
FILE *f = (FILE *)priv; FILE *f = (FILE *)priv;
(void) fprintf(f, "%08lx-%08lx %08lx %c%c%c\n", (void) fprintf(f, TARGET_ABI_FMT_lx"-"TARGET_ABI_FMT_lx
" "TARGET_ABI_FMT_lx" %c%c%c\n",
start, end, end - start, start, end, end - start,
((prot & PAGE_READ) ? 'r' : '-'), ((prot & PAGE_READ) ? 'r' : '-'),
((prot & PAGE_WRITE) ? 'w' : '-'), ((prot & PAGE_WRITE) ? 'w' : '-'),
@ -2332,8 +2334,8 @@ void page_set_flags(target_ulong start, target_ulong end, int flags)
/* This function should never be called with addresses outside the /* This function should never be called with addresses outside the
guest address space. If this assert fires, it probably indicates guest address space. If this assert fires, it probably indicates
a missing call to h2g_valid. */ a missing call to h2g_valid. */
#if HOST_LONG_BITS > L1_MAP_ADDR_SPACE_BITS #if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS
assert(end < (1ul << L1_MAP_ADDR_SPACE_BITS)); assert(end < ((abi_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
#endif #endif
assert(start < end); assert(start < end);

View File

@ -2020,7 +2020,7 @@ static int vma_get_mapping_count(const struct mm_struct *);
static struct vm_area_struct *vma_first(const struct mm_struct *); static struct vm_area_struct *vma_first(const struct mm_struct *);
static struct vm_area_struct *vma_next(struct vm_area_struct *); static struct vm_area_struct *vma_next(struct vm_area_struct *);
static abi_ulong vma_dump_size(const struct vm_area_struct *); static abi_ulong vma_dump_size(const struct vm_area_struct *);
static int vma_walker(void *priv, unsigned long start, unsigned long end, static int vma_walker(void *priv, abi_ulong start, abi_ulong end,
unsigned long flags); unsigned long flags);
static void fill_elf_header(struct elfhdr *, int, uint16_t, uint32_t); static void fill_elf_header(struct elfhdr *, int, uint16_t, uint32_t);
@ -2173,7 +2173,7 @@ static abi_ulong vma_dump_size(const struct vm_area_struct *vma)
return (vma->vma_end - vma->vma_start); return (vma->vma_end - vma->vma_start);
} }
static int vma_walker(void *priv, unsigned long start, unsigned long end, static int vma_walker(void *priv, abi_ulong start, abi_ulong end,
unsigned long flags) unsigned long flags)
{ {
struct mm_struct *mm = (struct mm_struct *)priv; struct mm_struct *mm = (struct mm_struct *)priv;

View File

@ -88,7 +88,7 @@ void *qemu_vmalloc(size_t size)
if (h2g_valid(p)) { if (h2g_valid(p)) {
/* Allocated region overlaps guest address space. This may recurse. */ /* Allocated region overlaps guest address space. This may recurse. */
unsigned long addr = h2g(p); abi_ulong addr = h2g(p);
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size), page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
PAGE_RESERVED); PAGE_RESERVED);
} }