From patchwork Sun Jan 30 03:15:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 517121 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 p0U5oJNN013186 for ; Sun, 30 Jan 2011 05:51:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752694Ab1A3DQG (ORCPT ); Sat, 29 Jan 2011 22:16:06 -0500 Received: from mga02.intel.com ([134.134.136.20]:22257 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752352Ab1A3DP7 (ORCPT ); Sat, 29 Jan 2011 22:15:59 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 29 Jan 2011 19:15:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,398,1291622400"; d="scan'208";a="597720043" Received: from yhuang-dev.sh.intel.com ([10.239.13.101]) by orsmga002.jf.intel.com with ESMTP; 29 Jan 2011 19:15:55 -0800 From: Huang Ying To: Avi Kivity , Marcelo Tosatti Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Andi Kleen , ying.huang@intel.com, Tony Luck , Dean Nelson , Andrew Morton Subject: [PATCH -v2 2/3] mm, Make __get_user_pages return -EHWPOISON for HWPOISON page optionally Date: Sun, 30 Jan 2011 11:15:48 +0800 Message-Id: <1296357349-18022-3-git-send-email-ying.huang@intel.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1296357349-18022-1-git-send-email-ying.huang@intel.com> References: <1296357349-18022-1-git-send-email-ying.huang@intel.com> 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]); Sun, 30 Jan 2011 05:51:05 +0000 (UTC) --- a/include/asm-generic/errno.h +++ b/include/asm-generic/errno.h @@ -108,4 +108,6 @@ #define ERFKILL 132 /* Operation not possible due to RF-kill */ +#define EHWPOISON 133 /* Memory page has hardware error */ + #endif --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1534,6 +1534,7 @@ struct page *follow_page(struct vm_area_ #define FOLL_FORCE 0x10 /* get_user_pages read/write w/o permission */ #define FOLL_MLOCK 0x40 /* mark page as mlocked */ #define FOLL_SPLIT 0x80 /* don't return transhuge pages, split them */ +#define FOLL_HWPOISON 0x100 /* check page is hwpoisoned */ typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr, void *data); --- a/mm/memory.c +++ b/mm/memory.c @@ -1576,9 +1576,16 @@ int __get_user_pages(struct task_struct if (ret & VM_FAULT_ERROR) { if (ret & VM_FAULT_OOM) return i ? i : -ENOMEM; - if (ret & - (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE| - VM_FAULT_SIGBUS)) + if (ret & (VM_FAULT_HWPOISON | + VM_FAULT_HWPOISON_LARGE)) { + if (i) + return i; + else if (gup_flags & FOLL_HWPOISON) + return -EHWPOISON; + else + return -EFAULT; + } + if (ret & VM_FAULT_SIGBUS) return i ? i : -EFAULT; BUG(); }