Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp605649pxj; Wed, 2 Jun 2021 07:08:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkrpz9xqF7UUKvzmUlzQYJ4MxtIk0roVqtqNu6C+TE/3kXgoy9sT7s0gb4RVcUl5TCMZa7 X-Received: by 2002:a05:6402:1d8e:: with SMTP id dk14mr39135319edb.385.1622642895256; Wed, 02 Jun 2021 07:08:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1622642895; cv=pass; d=google.com; s=arc-20160816; b=J3hPnAYQFRUJnQBYWrwcNeA5R6l5bXdnP3rzViBBTLGNCFNClvDzO3RIpZKMRVZg2K f7St1ec6B48MmnG3NhFIc1zlL2PKlBNlohuK0+MyuXb+6rRBG/sfZB0K6XeEhTQyTfIA 5drO7xWdkp1vEdKulIp3LmxMwlb4XymUvoRvi9hfdt5dXuJtjyvqrR1GHOrv5gPwZSxh A7bMoZLo2VdwvSmyEVyznPmr3coiwF8aZBd//WhyjePoLh8K/xFn/YpKMfWAVXnATwgn c+z294gB80HQ/yptImWQKnW6vCLlZdFBOP6FCLe6iAFf/WXno5kCjZ+t90bTllGinV52 HhMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9/JhxqSka73eZEhSsicofqkCL2gbRrNJ9DD4pCzki9Q=; b=XIHVsqcSJHp9x0MOxfGzvYmHJ6tqb1vl0/c+h81K4FiDy1QHL2iqDI7W5lFTnQKfrc oGY6WV7iBTDLRcfs7hguA3SgBbq2Q/Rk4UOlAd0RJCB/wys6KARG0tICQ7B3qO/5wej6 PjSULRJQv2GBhrBTocVqzp17Oq8V/Awaano24ZOGfEIAFLHskNF3zFbg3tkkqXUXa71i 78Nnxw4O5TZ5iLWmfOTHh/7J/kJprmlVMJbmu07TUZLUkAsrwQa09rtBUYLKap5C6COj qZmsPWEI6qfHeM8bUyu4s3M9uhfGEw0bFN7kCsozhSrT0VXPK2f1Cj38ueQdw0CY8gpa SJhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=nBEktVK3; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs19si6466935ejb.398.2021.06.02.07.07.50; Wed, 02 Jun 2021 07:08:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=nBEktVK3; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230523AbhFBOIM (ORCPT + 99 others); Wed, 2 Jun 2021 10:08:12 -0400 Received: from mail-mw2nam12on2072.outbound.protection.outlook.com ([40.107.244.72]:37216 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230093AbhFBOHU (ORCPT ); Wed, 2 Jun 2021 10:07:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R0LyKYs2hKNb0bNVUlV3mTHYJq4NCNG3DUnuvNEup5DBPFhzrNVfxX0gMqdz+ELVPmtBuiWkA4DYHsrrSQ24GHsbD4iaBCzeY4TK5lj+JgN5FxuEVBFDjf64MZ5bBHL1YU5LeSYgi0T6l6zYVPPgQpNnZ/vVwJXiwfu9LkCk9BnWwfeJ9D0QJhGuqFbJy4kVkPoXa5fs1j+N2vYTXUWOa2q07Xj5REmgvvsrhlLM8rUSWE0UOHBCWWK6FK6E0KYJpYa6qGPJv7fBjSc2Ir82l+KYWilBz6ZWCvzxORcdDEtZeFYhp65Fgen52SNJJiYLH6eZPZZSjU3KJq2ZZV1E/w== 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=9/JhxqSka73eZEhSsicofqkCL2gbRrNJ9DD4pCzki9Q=; b=ETaiQbEZ5oudP9HGADRP3iv5I00tdBddGq9uk7IvcN72qz2Eezl9rC0Nz6V2rMzzu7899RoXIoC/q5llcEFA9+d+7Mo0GzKil215S6ILRGl+DmuqN0sxe/yj+V3x26mbt4dyQbcLYzGqqpJp+RfxB7jSFnVJ8Lr4rxVv/iYved4GRbJr8+Rmchqrc2rw0YVAAglNWT41E7FxHCQSg8UTXCXQ0u/nYQ7q+FVpdOyuqKU7ljOYOVBMakKKJD2K/TXCS3kYXb85mDLxctRC7uSh+9RechAWyf+rThLJ9yRoKOAeH73gLamZGwQxPMFgZQGZjrL0u6kRtqnlpsXzrA/5dQ== 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=9/JhxqSka73eZEhSsicofqkCL2gbRrNJ9DD4pCzki9Q=; b=nBEktVK38UGaUxUOvo/TOdo/At6P+k6Ebr4EI2UPBKZ4WEpRkzVV23s0NmIzELkC71XbWE9PxnuQS7IoNVAN4LKifek0TpoYzBBEN/tpiLg9ROofMqdy29byi0k09umEvP2Xg3+F8RB27SyDBWbvBMfC1LxHLeHlXLkUZ18qfwI= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN6PR12MB2766.namprd12.prod.outlook.com (2603:10b6:805:78::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.22; Wed, 2 Jun 2021 14:04:59 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94%6]) with mapi id 15.20.4173.030; Wed, 2 Jun 2021 14:04:59 +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 , tony.luck@intel.com, npmccallum@redhat.com, Brijesh Singh Subject: [PATCH Part1 RFC v3 12/22] x86/kernel: Make the bss.decrypted section shared in RMP table Date: Wed, 2 Jun 2021 09:04:06 -0500 Message-Id: <20210602140416.23573-13-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210602140416.23573-1-brijesh.singh@amd.com> References: <20210602140416.23573-1-brijesh.singh@amd.com> Content-Type: text/plain X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN6PR05CA0010.namprd05.prod.outlook.com (2603:10b6:805:de::23) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SN6PR05CA0010.namprd05.prod.outlook.com (2603:10b6:805:de::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.9 via Frontend Transport; Wed, 2 Jun 2021 14:04:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 086a58ba-9ae5-4089-dccc-08d925cf6793 X-MS-TrafficTypeDiagnostic: SN6PR12MB2766: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n/qmT3VUUaHs/FG0ISKZANvVC4j+NE03guJ7pAe9gQ8BYj1r0h4Wfg4l0Sl9m+bTkH24xmvjpdHasq0Zrr1J1+u0+bo6IOtJR3f/h/L6oKdHyA27/DgpyQYMvKnvLOuQvgVldwAM/ewgpVJ59MvAiWNyTWug0IgkCxuPnvcqyYXXrAnBb3GRlCauFYgdYI1EkvNGpYAcy9A0HLt7hZuGIay6oIsE8AiwyUeENOYwzgj4+uBBT1WtJPfdprnH3pLRcO3W9GqtLDr0DvnGhVQOy14wEdn+d/pqqgcdi4WPSoPpUTGwHEkz+NvNzK9NosD5RjdimXiSd3GZOZy20aNtF5uLrjt1qj/jXbYX/CSWrAaPgd6kjAM+DKSphxtkTE2ux5usZ2+adisL8BPo+lnz88hk1Bv0vyex08ObuyloLRL2KrafYG3GKsOyJ9H8B5JTHX/pZoIIZuKxNV/tK7vJusumHtpdNY1A2eyRkPCiPL4iYyZwmUHV/ITNnJ3Z+hIVCN5Wu1GG05F73ipOcan6YTtxROA9YHuveJKtp6DJF64JMxzpGCvJu/xriqycbGmIN8wn575ZszP+Tc9UG04pUWOKUs7lET5L/b/3bU7t+zHUqcH+ZLz1Z3NgJOMHsr9Z3QA+/5pexl05zVBzFboIeA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(136003)(346002)(396003)(39860400002)(366004)(6486002)(38350700002)(86362001)(66946007)(38100700002)(44832011)(52116002)(36756003)(8676002)(83380400001)(7416002)(26005)(4326008)(2616005)(1076003)(186003)(956004)(16526019)(2906002)(316002)(54906003)(6666004)(66476007)(478600001)(5660300002)(7696005)(66556008)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?t/LfuCVb4vBYxe2e4KhvjRl6+HhUnbRDxLo8zu9TKLCrlLEn7v9CSilt+DEB?= =?us-ascii?Q?q82/Cek43bkRv8zXeMuRsdi2zc/KfYi6GlLP0twLmQL6GILD8lj1LpXiaWEx?= =?us-ascii?Q?Ezg2VKS9NqS03HreP45MUClYXJVKTRjswZscPgQ2pC1bIDtlezCMN1F4LZjT?= =?us-ascii?Q?LnVD0zKDm5LX5OpEoJpRtT47BYNOSQbfDHXW0FCgErjHWTJPJhyoOYq+ENwu?= =?us-ascii?Q?zgf1RXIZSsy3reEBUW2MH5vPBLX7larvabUD+1sJnyQHFjqwg2RdJOpQrVYM?= =?us-ascii?Q?zV3+IzMQujQ6AQqYAfeYF+DMypWrBRFhgV1ZgK0J9WeUTkBpF75r6kwpaiEw?= =?us-ascii?Q?2HmGd9ytFGSTuNLWMt++jI1sV5tYEzCUihraufc/mxMFXqFWvUeMHElHAkqc?= =?us-ascii?Q?4AzWJ2lb/l5FTa6T8HRgjL17Tn57IrJmIjqRoRqwde7fjFBwrfQUF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6?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 086a58ba-9ae5-4089-dccc-08d925cf6793 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 14:04:58.8170 (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: J5wic2EQO1WWU6+jTNCGsluTK7GyeVhiME3lEIlMHlQinTrsCP9vuTVqcds2BI423fcxHHueUZg/bKFEDkve7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2766 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The encryption attribute for the bss.decrypted region is cleared in the initial page table build. This is because the section contains the data that need to be shared between the guest and the hypervisor. When SEV-SNP is active, just clearing the encryption attribute in the page table is not enough. The page state need to be updated in the RMP table. Signed-off-by: Brijesh Singh --- arch/x86/kernel/head64.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index de01903c3735..f4c3e632345a 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -288,7 +288,14 @@ unsigned long __head __startup_64(unsigned long physaddr, if (mem_encrypt_active()) { vaddr = (unsigned long)__start_bss_decrypted; vaddr_end = (unsigned long)__end_bss_decrypted; + for (; vaddr < vaddr_end; vaddr += PMD_SIZE) { + /* + * When SEV-SNP is active then transition the page to shared in the RMP + * table so that it is consistent with the page table attribute change. + */ + early_snp_set_memory_shared(__pa(vaddr), __pa(vaddr), PTRS_PER_PMD); + i = pmd_index(vaddr); pmd[i] -= sme_get_me_mask(); } -- 2.17.1