From patchwork Wed Jul 7 18:35:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 12363949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0F28C07E95 for ; Wed, 7 Jul 2021 19:11:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 88A8461A13 for ; Wed, 7 Jul 2021 19:11:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 88A8461A13 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 713326B005D; Wed, 7 Jul 2021 15:11:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EAC16B0071; Wed, 7 Jul 2021 15:11:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EEE16B0072; Wed, 7 Jul 2021 15:11:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 2DCE26B005D for ; Wed, 7 Jul 2021 15:11:50 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8FCB52439B for ; Wed, 7 Jul 2021 19:11:49 +0000 (UTC) X-FDA: 78336736338.07.E5F7E66 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2084.outbound.protection.outlook.com [40.107.93.84]) by imf11.hostedemail.com (Postfix) with ESMTP id 530E3F0000AC for ; Wed, 7 Jul 2021 19:11:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BdLcZ8d2I+2L57X3p6s6IcOvCzViNPVOcIJvQkRp7czep+96hHUAM6RM/RInpOuO7MZhXaMWnxApIqQSOpNHpUp2JhT2ZqApt65ksVjkvY4o0vOBZxp8QEr8GglnZMtT5yyA4eAy5vkMdGs3rOouvMSyrUldy6srOhuFLwLI2ARPYW1StMAhRcNV3H+ZEq3S9luiCAYp9q3Z3kFnMqJ3VOKXs4b0PGmShHy9+EwTLF0AC8l6YFph7pR5QWsuwX/QYuY8GyeuiywSPVbulQ8r8zwDnkKpRNWkUhJxpTijWghOvLTs665JlzsY08QfQYFp+PnG1oLOSlYk9v3zw6hjrQ== 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-SenderADCheck; bh=9IpMdpyuUJv/iUkp9gcvE2Lk8D0OpiJS+R9aTNr+fEg=; b=c/PVjFkLpjr2UmlXwMUsI5oDYix4Qrg6F8p9VuVmfVCDBW8xctjM5Z9vKh5z+fR6U/H1j6agbfunXi+LlERBQ8TqIO8VA1f/Ki0bt/fWGjPyIU1vxxSNpHztZJfuCoIiX0kM66nByVnat0Z6Uzx7TKYTOb9RuYcgK+maIBIIbUy4WMZ/GaDyLtRj+lit9YU1WUuj+ET3SwIMhBK23WEDc2gXJeMUZYMQvB6QsfLWMVcN/SiSxH4o/hqY12zGqAmdxnI+RKFeew3Z9HKGy1ZHrIb0JUwYujdIPid9SAMGpz+ogkNH4NJWc3R2DQbc/Vy0nt4h77LMSdxSmc85vbx/gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=9IpMdpyuUJv/iUkp9gcvE2Lk8D0OpiJS+R9aTNr+fEg=; b=BryJYEUoMaohkLrKPTCmBK1pNjznyuO5EfGqsnh0ocBL1OPLh7wT69J5+6FIm0F00nnEtFEUiERl4DVXZ9TXh3hY0hyTi/Bz6hS2QxbO/I98dlksudMUj4ALZhBrOVfBsTHJj4odYsVFZl2hJl7+n/pR4ZeP0Vp1We3DvdfJR/w= Received: from BYAPR12MB2711.namprd12.prod.outlook.com (2603:10b6:a03:63::10) by BYAPR12MB2808.namprd12.prod.outlook.com (2603:10b6:a03:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.26; Wed, 7 Jul 2021 18:37:15 +0000 Received: from BYAPR12MB2711.namprd12.prod.outlook.com ([fe80::40e3:aade:9549:4bed]) by BYAPR12MB2711.namprd12.prod.outlook.com ([fe80::40e3:aade:9549:4bed%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 18:37:15 +0000 From: Brijesh Singh To: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com, Brijesh Singh Subject: [PATCH Part2 RFC v4 08/40] x86/traps: Define RMP violation #PF error code Date: Wed, 7 Jul 2021 13:35:44 -0500 Message-Id: <20210707183616.5620-9-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707183616.5620-1-brijesh.singh@amd.com> References: <20210707183616.5620-1-brijesh.singh@amd.com> X-ClientProxiedBy: SN6PR04CA0078.namprd04.prod.outlook.com (2603:10b6:805:f2::19) To BYAPR12MB2711.namprd12.prod.outlook.com (2603:10b6:a03:63::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SN6PR04CA0078.namprd04.prod.outlook.com (2603:10b6:805:f2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20 via Frontend Transport; Wed, 7 Jul 2021 18:37:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8b16327-605e-4cba-bf02-08d941763dce X-MS-TrafficTypeDiagnostic: BYAPR12MB2808: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3TVCAW8mJFhixsEWZ7qip/8kalJp5NzmW11frHzru3B2Dp12qvXc6F+DISAhArwO4GaxhgcqsSlAibc0fVpnF3V8OdVfqKWRmGOPr6k+ZaKzFNYjRpiC4veKgNUBfTUYHPNq2gCtlgKZE59sWSWnvTd+S/qItqlbipYGOCxauWfV2i3mjNz7LQGT7epQZVb7mpDpL64jknoldphGWUUXEFyIYhz9OPYERjXPWv6ENA83T3ZIJBoB3MZWkW1mXisVdompo7qKIuoT3lerKSc+NIdzxvKNn6OjK2NwazmOotSWNvYknowILmad+hNO+Z9kp8/0P03uaQ6cJL7BVE9podwVdfQiQA8TA1EuR+0CZTs8Hsii+wKk0xqWj7YPdf9NQhXJfVK/pVmyMeNyGA8jsnZKAUDgyCLNRfvt56VWQNt3e2kozC/TasnnQGTAbAN22tALfyzeIoFn/GO461u5c/bSWHPZsJM2q9Q5w4DRXg+59HlWwVqLRlaydHOGxfETDVk9ulYuIFEMTpjLuy/7q69igUjCGOCG/spSA6YK0Bwsbx7cMgdse34CdM5MboMCdoL5NqZwIwaoMkBbVn8PNGQIS4kJ+AliSzX9mSEkgz7Qz7wzp7XdyeYFDZK/VRh+/uaL/2ZDbYsFjWLtUGIzz36ZD9bO9nZl2pWw42FRjjZWXwEaVbXR4oceooTqngEo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2711.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(39860400002)(366004)(376002)(7416002)(36756003)(83380400001)(66556008)(38100700002)(52116002)(2616005)(5660300002)(956004)(2906002)(86362001)(7406005)(4326008)(1076003)(44832011)(7696005)(66946007)(54906003)(316002)(8936002)(6486002)(8676002)(478600001)(6666004)(26005)(66476007)(186003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jdyh7sBb/cS1c4r44HyT/ONOzqq8PSKrETLgJhO4NbjtznvbZMTHRLhYvkwJhvXpFa5TGmV1E/Uv5OnkvrsVBPTH9vwosOqAwIKzN3YZULH8A8+EzpNR0fzcIpLxAO/AkK4QvNxvHW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44U5I3I9IOEsT5MaGoHvrug6LN6s97EO5Nbkh/RuuultAv5c2ypIIEVeK6QuTs5X5JXisvu6ERRE+gBQ0gaX+u8KKtf3ZSt+58UU4ZPL4SWmtOS9xa0SZA3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8b16327-605e-4cba-bf02-08d941763dce X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2711.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 18:37:15.0450 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jgRyfCiHafadZfOBrWI9lR3igvVDlpE4spvs2AEYxamcqBhsZ/XjmSt/4Tdm8p00EjZd4ruE9hfr/hcBvmp0wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2808 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=BryJYEUo; spf=pass (imf11.hostedemail.com: domain of brijesh.singh@amd.com designates 40.107.93.84 as permitted sender) smtp.mailfrom=brijesh.singh@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 530E3F0000AC X-Rspam-User: nil X-Stat-Signature: iyqr981mmg5s3r1i9w8ad1ipd1da7c9g X-HE-Tag: 1625685101-380887 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: Bit 31 in the page fault-error bit will be set when processor encounters an RMP violation. While at it, use the BIT() macro. Signed-off-by: Brijesh Singh --- arch/x86/include/asm/trap_pf.h | 18 +++++++++++------- arch/x86/mm/fault.c | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/trap_pf.h b/arch/x86/include/asm/trap_pf.h index 10b1de500ab1..29f678701753 100644 --- a/arch/x86/include/asm/trap_pf.h +++ b/arch/x86/include/asm/trap_pf.h @@ -2,6 +2,8 @@ #ifndef _ASM_X86_TRAP_PF_H #define _ASM_X86_TRAP_PF_H +#include /* BIT() macro */ + /* * Page fault error code bits: * @@ -12,15 +14,17 @@ * bit 4 == 1: fault was an instruction fetch * bit 5 == 1: protection keys block access * bit 15 == 1: SGX MMU page-fault + * bit 31 == 1: fault was an RMP violation */ enum x86_pf_error_code { - X86_PF_PROT = 1 << 0, - X86_PF_WRITE = 1 << 1, - X86_PF_USER = 1 << 2, - X86_PF_RSVD = 1 << 3, - X86_PF_INSTR = 1 << 4, - X86_PF_PK = 1 << 5, - X86_PF_SGX = 1 << 15, + X86_PF_PROT = BIT(0), + X86_PF_WRITE = BIT(1), + X86_PF_USER = BIT(2), + X86_PF_RSVD = BIT(3), + X86_PF_INSTR = BIT(4), + X86_PF_PK = BIT(5), + X86_PF_SGX = BIT(15), + X86_PF_RMP = BIT(31), }; #endif /* _ASM_X86_TRAP_PF_H */ diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 1c548ad00752..2715240c757e 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -545,6 +545,7 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad !(error_code & X86_PF_PROT) ? "not-present page" : (error_code & X86_PF_RSVD) ? "reserved bit violation" : (error_code & X86_PF_PK) ? "protection keys violation" : + (error_code & X86_PF_RMP) ? "rmp violation" : "permissions violation"); if (!(error_code & X86_PF_USER) && user_mode(regs)) {