From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [patch uq/master 5/8] Export qemu_ram_addr_from_host Date: Tue, 05 Oct 2010 07:57:14 -0500 Message-ID: <4CAB20AA.7040801@codemonkey.ws> References: <20101004185447.891324545@redhat.com> <20101004185714.983252370@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, Huang Ying , Dean Nelson To: Marcelo Tosatti Return-path: Received: from mail-gx0-f174.google.com ([209.85.161.174]:52930 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728Ab0JEM53 (ORCPT ); Tue, 5 Oct 2010 08:57:29 -0400 Received: by gxk9 with SMTP id 9so1959551gxk.19 for ; Tue, 05 Oct 2010 05:57:29 -0700 (PDT) In-Reply-To: <20101004185714.983252370@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 10/04/2010 01:54 PM, Marcelo Tosatti wrote: > To be used by next patches. > > Signed-off-by: Marcelo Tosatti > > Index: qemu/cpu-common.h > =================================================================== > --- qemu.orig/cpu-common.h > +++ qemu/cpu-common.h > @@ -47,6 +47,7 @@ void qemu_ram_free(ram_addr_t addr); > /* This should only be used for ram local to a device. */ > void *qemu_get_ram_ptr(ram_addr_t addr); > /* This should not be used by devices. */ > +int do_qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr); > This is not a great name for a function. A better way to do this would be to make the existing qemu_ram_addr_from_host() -> qemu_ram_addr_from_host_nofail(). Regards, Anthony Liguori > ram_addr_t qemu_ram_addr_from_host(void *ptr); > > int cpu_register_io_memory(CPUReadMemoryFunc * const *mem_read, > Index: qemu/exec.c > =================================================================== > --- qemu.orig/exec.c > +++ qemu/exec.c > @@ -2938,23 +2938,31 @@ void *qemu_get_ram_ptr(ram_addr_t addr) > return NULL; > } > > -/* Some of the softmmu routines need to translate from a host pointer > - (typically a TLB entry) back to a ram offset. */ > -ram_addr_t qemu_ram_addr_from_host(void *ptr) > +int do_qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr) > { > RAMBlock *block; > uint8_t *host = ptr; > > QLIST_FOREACH(block,&ram_list.blocks, next) { > if (host - block->host< block->length) { > - return block->offset + (host - block->host); > + *ram_addr = block->offset + (host - block->host); > + return 0; > } > } > + return -1; > +} > > - fprintf(stderr, "Bad ram pointer %p\n", ptr); > - abort(); > +/* Some of the softmmu routines need to translate from a host pointer > + (typically a TLB entry) back to a ram offset. */ > +ram_addr_t qemu_ram_addr_from_host(void *ptr) > +{ > + ram_addr_t ram_addr; > > - return 0; > + if (do_qemu_ram_addr_from_host(ptr,&ram_addr)) { > + fprintf(stderr, "Bad ram pointer %p\n", ptr); > + abort(); > + } > + return ram_addr; > } > > static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr) > > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >