From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=46789 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdYP0-0002Cn-FD for qemu-devel@nongnu.org; Thu, 13 Jan 2011 20:24:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PdYOz-0007xv-Df for qemu-devel@nongnu.org; Thu, 13 Jan 2011 20:24:30 -0500 Received: from mga11.intel.com ([192.55.52.93]:4992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PdYOz-0007xY-7N for qemu-devel@nongnu.org; Thu, 13 Jan 2011 20:24:29 -0500 Subject: Re: [Qemu-devel] [PATCH uq/master 1/2] Add qemu_ram_remap From: Huang Ying In-Reply-To: References: <1294907684.4596.43.camel@yhuang-dev> Content-Type: text/plain; charset="UTF-8" Date: Fri, 14 Jan 2011 09:23:23 +0800 Message-ID: <1294968203.4596.60.camel@yhuang-dev> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: "kvm@vger.kernel.org" , Dean Nelson , Marcelo Tosatti , "qemu-devel@nongnu.org" , Anthony Liguori , Andi Kleen , Avi Kivity On Fri, 2011-01-14 at 05:14 +0800, Blue Swirl wrote: > On Thu, Jan 13, 2011 at 8:34 AM, Huang Ying wrote: > > qemu_ram_remap() unmaps the specified RAM pages, then re-maps these > > pages again. This is used by KVM HWPoison support to clear HWPoisoned > > page tables across guest rebooting, so that a new page may be > > allocated later to recover the memory error. > > > > Signed-off-by: Huang Ying > > --- > > cpu-all.h | 4 +++ > > cpu-common.h | 1 > > exec.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > > 3 files changed, 65 insertions(+), 1 deletion(-) > > > > --- a/cpu-all.h > > +++ b/cpu-all.h > > @@ -863,10 +863,14 @@ target_phys_addr_t cpu_get_phys_page_deb > > extern int phys_ram_fd; > > extern ram_addr_t ram_size; > > > > +/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ > > +#define RAM_PREALLOC_MASK (1 << 0) > > + > > typedef struct RAMBlock { > > uint8_t *host; > > ram_addr_t offset; > > ram_addr_t length; > > + uint32_t flags; > > char idstr[256]; > > QLIST_ENTRY(RAMBlock) next; > > #if defined(__linux__) && !defined(TARGET_S390X) > > --- a/exec.c > > +++ b/exec.c > > @@ -2830,6 +2830,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(Devic > > > > if (host) { > > new_block->host = host; > > + new_block->flags |= RAM_PREALLOC_MASK; > > } else { > > if (mem_path) { > > #if defined (__linux__) && !defined(TARGET_S390X) > > @@ -2883,7 +2884,9 @@ void qemu_ram_free(ram_addr_t addr) > > QLIST_FOREACH(block, &ram_list.blocks, next) { > > if (addr == block->offset) { > > QLIST_REMOVE(block, next); > > - if (mem_path) { > > + if (block->flags & RAM_PREALLOC_MASK) > > Missing braces. Sorry, forgot this one, will fix it. Best Regards, Huang Ying