Revision e890261f exec.c

b/exec.c
2085 2085
    if ((tlb_entry->addr_write & ~TARGET_PAGE_MASK) == IO_MEM_RAM) {
2086 2086
        p = (void *)(unsigned long)((tlb_entry->addr_write & TARGET_PAGE_MASK)
2087 2087
            + tlb_entry->addend);
2088
        ram_addr = qemu_ram_addr_from_host(p);
2088
        ram_addr = qemu_ram_addr_from_host_nofail(p);
2089 2089
        if (!cpu_physical_memory_is_dirty(ram_addr)) {
2090 2090
            tlb_entry->addr_write |= TLB_NOTDIRTY;
2091 2091
        }
......
2938 2938
    return NULL;
2939 2939
}
2940 2940

  
2941
/* Some of the softmmu routines need to translate from a host pointer
2942
   (typically a TLB entry) back to a ram offset.  */
2943
ram_addr_t qemu_ram_addr_from_host(void *ptr)
2941
int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)
2944 2942
{
2945 2943
    RAMBlock *block;
2946 2944
    uint8_t *host = ptr;
2947 2945

  
2948 2946
    QLIST_FOREACH(block, &ram_list.blocks, next) {
2949 2947
        if (host - block->host < block->length) {
2950
            return block->offset + (host - block->host);
2948
            *ram_addr = block->offset + (host - block->host);
2949
            return 0;
2951 2950
        }
2952 2951
    }
2952
    return -1;
2953
}
2953 2954

  
2954
    fprintf(stderr, "Bad ram pointer %p\n", ptr);
2955
    abort();
2955
/* Some of the softmmu routines need to translate from a host pointer
2956
   (typically a TLB entry) back to a ram offset.  */
2957
ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)
2958
{
2959
    ram_addr_t ram_addr;
2956 2960

  
2957
    return 0;
2961
    if (qemu_ram_addr_from_host(ptr, &ram_addr)) {
2962
        fprintf(stderr, "Bad ram pointer %p\n", ptr);
2963
        abort();
2964
    }
2965
    return ram_addr;
2958 2966
}
2959 2967

  
2960 2968
static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
......
3703 3711
{
3704 3712
    if (buffer != bounce.buffer) {
3705 3713
        if (is_write) {
3706
            ram_addr_t addr1 = qemu_ram_addr_from_host(buffer);
3714
            ram_addr_t addr1 = qemu_ram_addr_from_host_nofail(buffer);
3707 3715
            while (access_len) {
3708 3716
                unsigned l;
3709 3717
                l = TARGET_PAGE_SIZE;

Also available in: Unified diff