Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4447418pxj; Tue, 8 Jun 2021 14:43:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0neEo8e5DZutRhP3pafKbHuNzhkedeuXk8L0fTdVhg//VjYxlT790QpyamDjljummgWa+ X-Received: by 2002:a17:906:33c8:: with SMTP id w8mr25810463eja.46.1623188609748; Tue, 08 Jun 2021 14:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623188609; cv=none; d=google.com; s=arc-20160816; b=f7BM0TmNMBhMG8X90R6e0RQoRUae+2QfBpMvZGqiVRNgRxroQ3sKcQkXmFoLV2a2mW ujbsjgN7CCbX6TK2x7jpSOvqFXqOg0NzOhE8FW73NkU/QK21TIhB0827ytkbSfyEBiR2 MR4cpcVNAsVddmbny5UIgysqJrDa+FK6d0FVDocpxPPnltw4UJkJBqtVFmGMvjGANHr5 NwkH5Y+2LYx2ybXrwh60f+Qao7IQHjOCEtiJAaSYtfT0g2c4+AfKISLxIzEWgeWFEojD pK1TpcY/lg2NZwPPDIajOh2wsVbvAeC+H+mcWtcAEpmIhAMACR18UBI2DYLuS2TOTrCF wETw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=7XDsMrXeVhmkqVpwkO4c4HWNqPotx6XPykSPXiU/TM0=; b=qHZTZlxw2vcrWMV8gbxgBFtVc1homczpjJvai4K2Y/BMQi7qUyuVUxSz4cHkOlknHT l54EBb98vPW+LiDmLZrqxv3bBF0QQ8xrQ8n6yeY/lcir4CkuAlpsj8fbpEIglwJTGa57 PEEJH2me4pZsq6QF4wHkxRifIcAlMLImKMUelkCNzlrk3tWuVGNiBiL1CvXgS6tE7g5t 47bumStsQt9Wbytg4NIj9jZ400Ur7L70j2ewMxXlEk85+y3mZ3GkywinATJ12iphi25I 41FVaKCgXZczJArKH1mTl6B0VHSKlZHe2Sv/KVTDB34G6OWBJyTHkcD4Egrp95RfBWyv lPnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si777355ejr.636.2021.06.08.14.43.06; Tue, 08 Jun 2021 14:43:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234552AbhFHVmt (ORCPT + 99 others); Tue, 8 Jun 2021 17:42:49 -0400 Received: from mga01.intel.com ([192.55.52.88]:45443 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234370AbhFHVmn (ORCPT ); Tue, 8 Jun 2021 17:42:43 -0400 IronPort-SDR: TtTxie9xQisHr/y7pCF0y7ZXqsREK3uSlHCNe77ZyUBv4ArBC7zUmPCDX3G0oUyL/YAOfkM7cC iB3eiiY9YPWA== X-IronPort-AV: E=McAfee;i="6200,9189,10009"; a="226309336" X-IronPort-AV: E=Sophos;i="5.83,259,1616482800"; d="scan'208";a="226309336" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2021 14:40:48 -0700 IronPort-SDR: rX10nWWudcUkwV+N31oSqMdZNruLG1K3urV94+n+wfV/INYwAL7+sqDgCQWmRniNq/C2gnI1xI LNpaIX+ozAjw== X-IronPort-AV: E=Sophos;i="5.83,259,1616482800"; d="scan'208";a="448057497" Received: from agluck-desk2.sc.intel.com ([10.3.52.146]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2021 14:40:48 -0700 From: Tony Luck To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Dave Hansen , Jarkko Sakkinen , Sean Christopherson , Tony Luck Subject: [RFC PATCH 3/4] x86/sgx: Hook sgx_memory_failure() into mainline code Date: Tue, 8 Jun 2021 14:40:37 -0700 Message-Id: <20210608214038.1026259-4-tony.luck@intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210608214038.1026259-1-tony.luck@intel.com> References: <20210608214038.1026259-1-tony.luck@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a call inside memory_failure() to check if the address is an SGX EPC page and handle it. Note the SGX EPC pages do not have a "struct page" entry, so the hook goes in at the same point as the device mapping hook. Signed-off-by: Tony Luck --- include/linux/mm.h | 9 +++++++++ mm/memory-failure.c | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index c274f75efcf9..8ad4c513d4cc 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3248,5 +3248,14 @@ static inline int seal_check_future_write(int seals, struct vm_area_struct *vma) return 0; } +#ifdef CONFIG_X86_SGX +int sgx_memory_failure(unsigned long pfn, int flags); +#else +static inline int sgx_memory_failure(unsigned long pfn, int flags) +{ + return -ENXIO; +} +#endif + #endif /* __KERNEL__ */ #endif /* _LINUX_MM_H */ diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 85ad98c00fd9..c2ade18fd8d5 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1413,6 +1413,10 @@ int memory_failure(unsigned long pfn, int flags) p = pfn_to_online_page(pfn); if (!p) { + res = sgx_memory_failure(pfn, flags); + if (res == 0) + return 0; + if (pfn_valid(pfn)) { pgmap = get_dev_pagemap(pfn, NULL); if (pgmap) -- 2.29.2