From patchwork Thu Jan 13 08:42:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 475431 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 p0D8Yq8M012454 for ; Thu, 13 Jan 2011 08:48:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756503Ab1AMIm5 (ORCPT ); Thu, 13 Jan 2011 03:42:57 -0500 Received: from mga14.intel.com ([143.182.124.37]:36310 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756343Ab1AMImy (ORCPT ); Thu, 13 Jan 2011 03:42:54 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 13 Jan 2011 00:42:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,317,1291622400"; d="scan'208";a="373946011" Received: from yhuang-dev.sh.intel.com (HELO [10.239.13.101]) ([10.239.13.101]) by azsmga001.ch.intel.com with ESMTP; 13 Jan 2011 00:42:51 -0800 Subject: [PATCH 2/2] KVM, Replace is_hwpoison_address with get_user_pages_hwpoison From: Huang Ying To: Avi Kivity , Marcelo Tosatti Cc: "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , Andi Kleen , Dean Nelson , Andrew Morton , Tony Luck Date: Thu, 13 Jan 2011 16:42:49 +0800 Message-ID: <1294908169.4596.59.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]); Thu, 13 Jan 2011 08:48:52 +0000 (UTC) --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1524,14 +1524,6 @@ extern int sysctl_memory_failure_recover extern void shake_page(struct page *p, int access); extern atomic_long_t mce_bad_pages; extern int soft_offline_page(struct page *page, int flags); -#ifdef CONFIG_MEMORY_FAILURE -int is_hwpoison_address(unsigned long addr); -#else -static inline int is_hwpoison_address(unsigned long addr) -{ - return 0; -} -#endif extern void dump_page(struct page *page); --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1433,35 +1433,3 @@ done: /* keep elevated page count for bad page */ return ret; } - -/* - * The caller must hold current->mm->mmap_sem in read mode. - */ -int is_hwpoison_address(unsigned long addr) -{ - pgd_t *pgdp; - pud_t pud, *pudp; - pmd_t pmd, *pmdp; - pte_t pte, *ptep; - swp_entry_t entry; - - pgdp = pgd_offset(current->mm, addr); - if (!pgd_present(*pgdp)) - return 0; - pudp = pud_offset(pgdp, addr); - pud = *pudp; - if (!pud_present(pud) || pud_large(pud)) - return 0; - pmdp = pmd_offset(pudp, addr); - pmd = *pmdp; - if (!pmd_present(pmd) || pmd_large(pmd)) - return 0; - ptep = pte_offset_map(pmdp, addr); - pte = *ptep; - pte_unmap(ptep); - if (!is_swap_pte(pte)) - return 0; - entry = pte_to_swp_entry(pte); - return is_hwpoison_entry(entry); -} -EXPORT_SYMBOL_GPL(is_hwpoison_address); --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -966,7 +966,9 @@ static pfn_t hva_to_pfn(struct kvm *kvm, goto return_fault_page; down_read(¤t->mm->mmap_sem); - if (is_hwpoison_address(addr)) { + npages = get_user_pages_hwpoison(current, current->mm, + addr, 1, 1, 0, page, NULL); + if (npages == -EHWPOISON) { up_read(¤t->mm->mmap_sem); get_page(hwpoison_page); return page_to_pfn(hwpoison_page);