cputlb: tweak qemu_ram_addr_from_host_nofail reporting

This moves the helper function closer to where it is called and updates
the error message to report via error_report instead of the deprecated
fprintf.

Backports commit 857baec1d9e80947f0c1007c3a3d2331d62b4b53 from qemu
This commit is contained in:
Alex Bennée 2018-03-02 10:14:27 -05:00 committed by Lioncash
parent 454932263c
commit 157efaa8a9
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -272,6 +272,19 @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr,
prot, mmu_idx, size);
}
static ram_addr_t qemu_ram_addr_from_host_nofail(struct uc_struct *uc, void *ptr)
{
ram_addr_t ram_addr;
ram_addr = qemu_ram_addr_from_host(uc, ptr);
if (ram_addr == RAM_ADDR_INVALID) {
//error_report("Bad ram pointer %p", ptr);
return RAM_ADDR_INVALID;
}
return ram_addr;
}
/* NOTE: this function can trigger an exception */
/* NOTE2: the returned address is not exactly the physical address: it
* is actually a ram_addr_t (in system mode; the user mode emulation
@ -323,19 +336,6 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr)
}
}
static ram_addr_t qemu_ram_addr_from_host_nofail(struct uc_struct *uc, void *ptr)
{
ram_addr_t ram_addr;
ram_addr = qemu_ram_addr_from_host(uc, ptr);
if (ram_addr == RAM_ADDR_INVALID) {
// fprintf(stderr, "Bad ram pointer %p\n", ptr);
return RAM_ADDR_INVALID;
}
return ram_addr;
}
static void tlb_set_dirty1(CPUTLBEntry *tlb_entry, target_ulong vaddr)
{
if (tlb_entry->addr_write == (vaddr | TLB_NOTDIRTY)) {