From patchwork Mon Feb 20 18:38:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13146864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1028C27C7C for ; Mon, 20 Feb 2023 18:47:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F3486B0071; Mon, 20 Feb 2023 13:47:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A3606B0072; Mon, 20 Feb 2023 13:47:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 644856B0073; Mon, 20 Feb 2023 13:47:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 56F1F6B0071 for ; Mon, 20 Feb 2023 13:47:08 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1C405160AA5 for ; Mon, 20 Feb 2023 18:47:08 +0000 (UTC) X-FDA: 80488552536.18.0DB6377 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2082.outbound.protection.outlook.com [40.107.237.82]) by imf26.hostedemail.com (Postfix) with ESMTP id 11DDD140008 for ; Mon, 20 Feb 2023 18:47:04 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=gp6doT3d; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf26.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.237.82 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676918825; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8hQgEt4zfuohLaU4xMAC3aVGdlY7+WMaFzYsllKiGIY=; b=USS6wJrFah2JgO2/VZTq5K7p/Zoy7Aj7ZwzspsFIRpKOuig1f0UrZk0F1mZRxjQ/wBb+IT cWW5yKBvkzMiNp2MAwp4xr+WYwpokLUXQX4WBgzx5b2ymuPpg2VTf1TWuJ0kL/x1sK3OKB 06IRlHCRGh6eThawORy1xU2ZFgsyZfE= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=gp6doT3d; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf26.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.237.82 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1676918825; a=rsa-sha256; cv=pass; b=XltFCljptqZEP8SIpoZ9A2lkrF+5FBbXSMmguKxA0T5nWmOV1I1AkqbtcF5WzTJ13IdXmq NU7h6Q4qRQIxWAIwtmdirfcw8ydMYVQMj1wWT0vjhVcbv3CmHaxVvwaXzoa1sNKajpK7uA FvjsxdhsgVxjX/R/NlsG8Zw4WpcwiW8= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T+JJla0olOxnhbHBPL9D0pNGBGWu1/JtPM5ULIJvnxosIgI+PsaY0sBfAECsQlOItmjckcQj/4J/RvLxcteje2yIRkm8ji51iCINmNDnvBrvTFstw5EmmthEhlF50z3LikmJj5fheDds56ktxFNfwffliO635E+EC6utPy7vvjOS4tnDOammBEdy3boVa0JKwXKqT99Lgr7EBnx2G3qbc0eXKlzfb3rI449bYrEdusa0hChjhbEGuI8PehWUyzLmK6XdLjpM9qLvoFnejypIKmOI2RtppazTBZgOY8b4bTq8qS7U+9hos4hqM3RvinOu4LMna/6uzVdRC1r798CJJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8hQgEt4zfuohLaU4xMAC3aVGdlY7+WMaFzYsllKiGIY=; b=iiILRzl3Ym+bS05JBKW/wnLSDUav0w5nogKzyyUdsbgvGyU8ZX48NOwBRBfo4PuUSPHjls6LkV3hdNr+tyTq7EnfyJp0AYSDut776EyfxymKyCfhMYsTdK2ARYZsBcF2X0IkYeDQ8haUNPa/sx4XbwzQx2pQhPiQxIS2/s7HS9e39L++l+6k/jFuclLgeqHm9P4MqwluH6r4HikaRppF8p/a8onSma48XSyHbWSXPEzLs1Pbnq7ZwMc0R8J8JBX1c7PcjwfaV1cg2BjNsQBu3nNyUBv4tyRrU0JXsxdSB12BlXJZAxu7CZzKB02xwcHBlKZJhtRfpeOhcuPYsHj4Iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8hQgEt4zfuohLaU4xMAC3aVGdlY7+WMaFzYsllKiGIY=; b=gp6doT3dHJYY8E9gGKjumXpv5LdwdRcCoDckGMKReqljFOVTP3JiwfebMQX3jO2NMN5BiDt3al+TESvoYWnNjDsOIaAlp1Fd8HH7zSL/oq+ORf20SGMSOpQD8b2V0KCd7dzQToUWz5ablhXhuCxKaD6JGTUSARyoDAqkGInk/ho= Received: from CY5P221CA0113.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:1f::6) by MN6PR12MB8513.namprd12.prod.outlook.com (2603:10b6:208:472::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 18:47:02 +0000 Received: from CY4PEPF0000C96A.namprd02.prod.outlook.com (2603:10b6:930:1f:cafe::20) by CY5P221CA0113.outlook.office365.com (2603:10b6:930:1f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20 via Frontend Transport; Mon, 20 Feb 2023 18:47:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000C96A.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6134.14 via Frontend Transport; Mon, 20 Feb 2023 18:47:02 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 20 Feb 2023 12:47:01 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH RFC v8 19/56] x86/fault: Return pfn from dump_pagetable() for SEV-specific fault handling. Date: Mon, 20 Feb 2023 12:38:10 -0600 Message-ID: <20230220183847.59159-20-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220183847.59159-1-michael.roth@amd.com> References: <20230220183847.59159-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000C96A:EE_|MN6PR12MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b2c1e85-2006-460b-f2d6-08db1372db01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sfiaFB4QrkAGuUpc9aYDo8hy7b2Tra5UUhwn+OhNIo53ij4AQLAHfrvoMTux2P8/TEa8mMsfxRPpaMAdDbhsmA2oY3zmSWPe7hoRDNc01R170JClPW8A9Vpueas1m5YaiIw4CLbIQ3TW8Gte5awLrk45nEoifCkvnB5kagH75Mufqoc282vTTg+B/co7YwTC1ndv/BYlMrqeH+ljhxR3/o1kvqfV4AiT3Ec+MDZleuIIEeACB7i/dN045+g3Y2FFkTNK89akTy17AiapDBaeh9D0e+6tcwe9B0MnDJQHM4ROMgBZt+nA5bNU/38u6mEd7uj6Jd/4LtdgSpE4LzwNUGQIQJsQ/W1S1o3m5wyxkfj6ddDT0eUyHjjK+TZ4S6pJ3xyP/7hoPmJwZjlYtFqLbl0fvylazK7KFMcY2cSHUES/9Zd3lu+Tq6lnKohZ3GNsekdMKH7Xzwl/7/Tr/FyLSp8IGD0lqfgOkHNp4NRlk5p5ZME/pn3eoTaKi5GZHWBO6oP/8tptiTd0Ai1c/Pe5ZCV/6ftdrUCPc7/QOwCWo3djpvf32B215zUnroMc3AV4Ym7e/0AZkUgf6fMeAryU3VGAiXQkbDIygQtQK1V9PPcS24nnXjwpyI9kfW++ZUlucZSFDzOevOrrB+bpa7+3iXkk5/Opds9GtI1cURI+V63FwX/YZdg7NXh1WlaSQahLWajjE1NSAOIlfH9dDh7KKC3JcoXYCsd6efT9Bd8c1LA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199018)(40470700004)(36840700001)(46966006)(6666004)(47076005)(478600001)(426003)(4326008)(6916009)(83380400001)(2616005)(336012)(70206006)(1076003)(16526019)(70586007)(8676002)(41300700001)(7416002)(5660300002)(7406005)(8936002)(36860700001)(44832011)(2906002)(82740400003)(81166007)(40480700001)(356005)(26005)(54906003)(316002)(186003)(36756003)(82310400005)(86362001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 18:47:02.3500 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b2c1e85-2006-460b-f2d6-08db1372db01 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000C96A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8513 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 11DDD140008 X-Stat-Signature: r7fe43dxq9abzw3r9z9zgy7z5szybgon X-Rspam-User: X-HE-Tag: 1676918824-489374 X-HE-Meta: U2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EPegeVt36eHovEyfFAKiDNUVzIJTLUnDHX9LFCs0N2/oJJ57sQp8DqgK6A+uW8oxz0vo7zMIVl2UWS9K1HoIGPu9MNVfw+BvCmEZSHjeduKchn+sEmkQzGsRTLPY9mHZ2Zl7EX6Rg9mlWBqOWuFYire/6APgozMvvRHUMg2nhXnrPF6V6vV+reNDCtlHJsIb0n+M4h+/Pg8ALMiQcVoST00tjYF3Bmj7+bq0GskwgkdCa85Hjv6/COHSjM1N8/ekiXTKiaVhCCqr9YKyRpspH8jtERL/0ak7Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Ashish Kalra Return pfn from dump_pagetable() to do SEV-specific fault handling. Used for handling SNP RMP page fault. Signed-off-by: Ashish Kalra Signed-off-by: Michael Roth --- arch/x86/mm/fault.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index afd4cde17001..f2b16dcfbd9a 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -311,7 +311,7 @@ static bool low_pfn(unsigned long pfn) return pfn < max_low_pfn; } -static void dump_pagetable(unsigned long address) +static unsigned long dump_pagetable(unsigned long address) { pgd_t *base = __va(read_cr3_pa()); pgd_t *pgd = &base[pgd_index(address)]; @@ -345,8 +345,10 @@ static void dump_pagetable(unsigned long address) pte = pte_offset_kernel(pmd, address); pr_cont("*pte = %0*Lx ", sizeof(*pte) * 2, (u64)pte_val(*pte)); + return 0; out: pr_cont("\n"); + return 0; } #else /* CONFIG_X86_64: */ @@ -367,10 +369,11 @@ static int bad_address(void *p) return get_kernel_nofault(dummy, (unsigned long *)p); } -static void dump_pagetable(unsigned long address) +static unsigned long dump_pagetable(unsigned long address) { pgd_t *base = __va(read_cr3_pa()); pgd_t *pgd = base + pgd_index(address); + unsigned long pfn; p4d_t *p4d; pud_t *pud; pmd_t *pmd; @@ -388,6 +391,7 @@ static void dump_pagetable(unsigned long address) if (bad_address(p4d)) goto bad; + pfn = p4d_pfn(*p4d); pr_cont("P4D %lx ", p4d_val(*p4d)); if (!p4d_present(*p4d) || p4d_large(*p4d)) goto out; @@ -396,6 +400,7 @@ static void dump_pagetable(unsigned long address) if (bad_address(pud)) goto bad; + pfn = pud_pfn(*pud); pr_cont("PUD %lx ", pud_val(*pud)); if (!pud_present(*pud) || pud_large(*pud)) goto out; @@ -404,6 +409,7 @@ static void dump_pagetable(unsigned long address) if (bad_address(pmd)) goto bad; + pfn = pmd_pfn(*pmd); pr_cont("PMD %lx ", pmd_val(*pmd)); if (!pmd_present(*pmd) || pmd_large(*pmd)) goto out; @@ -412,13 +418,14 @@ static void dump_pagetable(unsigned long address) if (bad_address(pte)) goto bad; + pfn = pte_pfn(*pte); pr_cont("PTE %lx", pte_val(*pte)); out: pr_cont("\n"); - - return; + return pfn; bad: pr_info("BAD\n"); + return -1; } #endif /* CONFIG_X86_64 */