From patchwork Wed Feb 9 03:00:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 542741 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1930fhQ002181 for ; Wed, 9 Feb 2011 03:00:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756187Ab1BIDAg (ORCPT ); Tue, 8 Feb 2011 22:00:36 -0500 Received: from mga11.intel.com ([192.55.52.93]:14815 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755500Ab1BIDAg (ORCPT ); Tue, 8 Feb 2011 22:00:36 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 08 Feb 2011 19:00:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,445,1291622400"; d="scan'208";a="885703242" Received: from yhuang-dev.sh.intel.com (HELO [10.239.13.107]) ([10.239.13.107]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2011 19:00:34 -0800 Subject: [PATCH uq/master -v2 2/2] KVM, MCE, unpoison memory address across reboot From: Huang Ying To: Avi Kivity , Marcelo Tosatti , Anthony Liguori Cc: "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" , Dean Nelson , Andi Kleen , Jan Kiszka Date: Wed, 09 Feb 2011 11:00:31 +0800 Message-ID: <1297220431.5180.15.camel@yhuang-dev> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 09 Feb 2011 03:00:41 +0000 (UTC) --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -508,6 +508,42 @@ static int kvm_get_supported_msrs(KVMSta return ret; } +struct HWPoisonPage; +typedef struct HWPoisonPage HWPoisonPage; +struct HWPoisonPage +{ + ram_addr_t ram_addr; + QLIST_ENTRY(HWPoisonPage) list; +}; + +static QLIST_HEAD(hwpoison_page_list, HWPoisonPage) hwpoison_page_list = + QLIST_HEAD_INITIALIZER(hwpoison_page_list); + +static void kvm_unpoison_all(void *param) +{ + HWPoisonPage *page, *next_page; + + QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) { + QLIST_REMOVE(page, list); + qemu_ram_remap(page->ram_addr, TARGET_PAGE_SIZE); + qemu_free(page); + } +} + +static void kvm_hwpoison_page_add(ram_addr_t ram_addr) +{ + HWPoisonPage *page; + + QLIST_FOREACH(page, &hwpoison_page_list, list) { + if (page->ram_addr == ram_addr) + return; + } + + page = qemu_malloc(sizeof(HWPoisonPage)); + page->ram_addr = ram_addr; + QLIST_INSERT_HEAD(&hwpoison_page_list, page, list); +} + int kvm_arch_init(KVMState *s) { uint64_t identity_base = 0xfffbc000; @@ -556,6 +592,7 @@ int kvm_arch_init(KVMState *s) fprintf(stderr, "e820_add_entry() table is full\n"); return ret; } + qemu_register_reset(kvm_unpoison_all, NULL); return 0; } @@ -1882,6 +1919,7 @@ int kvm_arch_on_sigbus_vcpu(CPUState *en hardware_memory_error(); } } + kvm_hwpoison_page_add(ram_addr); if (code == BUS_MCEERR_AR) { /* Fake an Intel architectural Data Load SRAR UCR */ @@ -1926,6 +1964,7 @@ int kvm_arch_on_sigbus(int code, void *a "QEMU itself instead of guest system!: %p\n", addr); return 0; } + kvm_hwpoison_page_add(ram_addr); kvm_mce_inj_srao_memscrub2(first_cpu, paddr); } else #endif