Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3498847pxb; Fri, 11 Feb 2022 00:50:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5xMgeLnx5S4oC6rQH6BCFoNZuHpIjWwsMrKA+oKl/yqbiyJCba1WApRgSO6U6dPPGQ5k2 X-Received: by 2002:a17:906:a93:: with SMTP id y19mr443314ejf.719.1644569413807; Fri, 11 Feb 2022 00:50:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644569413; cv=none; d=google.com; s=arc-20160816; b=BgJZLCJ3cnAlBgR4lVIgzWrdWnsxZQcAT1oPHVnJfqPe9kOUawD/3g+BLxCOkPj7OP 22mjApKR+eQL6eRWFPDpmII+fim5sp6ihbpjTdXZ8/m0nAZPHuF2nHzi6W2B8zoYFKOC bHALt622PfTFFjUo9KmVj0Z10zkTROpqQPASNaFMWxVafLvUHpc4Y9OT9s9OIH6xyVeA zpiFfS/1V4U2B5lMbW1W2gRWXZW7b7gCD8Va5hF2WuDTwcu/dEUAKYu/VM8wrFweNcP5 lJ0HWMeyPvpBM0FuSrW7Zy+xSqaL9lOOrCsRXL6gOYAWzAL/HFiB5GqWeqBWm5AH5omG ejZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nkwdvv/kN4X+IUhmjyxPM+gWIWhdYINS6ChexlWbNOI=; b=Msd4fn+LLgQr32rFX6wFhpFrC/bdjIdIXZFT6BRjv9Y1Ot2gaMh2U9nW/2wYKuCbzF Cg9lV8B9BOiWCwQ9MLjXI5XlqS1nwi/H3gMCN/dENQcOGkhzRBczTKeT8kxlk1gYYnfU D5F26k9ro09j9XRNdMsWqrVaQwRX+ZMUvtRM+K0e3eEWNo1btyOhn2wqfU9FedHeGm17 FAU11c7odVP78LDRDTODTOHciww9RtJu55zmqW8tRFR29DWPHoXuV7nncucsOd90eV71 YYr4FczmIqTtXkkc1E/Tgs3hVfgAlyl97B3BQJTXdZQaxtqv3Fyd0IBVe5c9YzkpWVDr Z3ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=arLbkOX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1si16809856edd.507.2022.02.11.00.49.48; Fri, 11 Feb 2022 00:50:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=arLbkOX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244792AbiBJQtF (ORCPT + 99 others); Thu, 10 Feb 2022 11:49:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244818AbiBJQtB (ORCPT ); Thu, 10 Feb 2022 11:49:01 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40F95E87; Thu, 10 Feb 2022 08:48:59 -0800 (PST) Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 9FBA21EC05DD; Thu, 10 Feb 2022 17:48:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1644511733; h=from:from: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:in-reply-to:in-reply-to: references:references; bh=nkwdvv/kN4X+IUhmjyxPM+gWIWhdYINS6ChexlWbNOI=; b=arLbkOX2S7ry/YFU6kZeY6npGAVqVq1czzxbl6Wg3TeXcm/yLbTXBtO0kpBPLau3TR8IRL C1bHBb8f4K4p/UXHzOWeMiXb31DiA221T/eEqZ1tyzLSmbyajDlsAJaCg/NFezPoi0TNfR lSxt6sAQAeC+Yx4YlN0cZnq7X7/nx2o= Date: Thu, 10 Feb 2022 17:48:55 +0100 From: Borislav Petkov To: Brijesh Singh Cc: 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, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , "Dr . David Alan Gilbert" , brijesh.ksingh@gmail.com, tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH v10 21/45] x86/mm: Add support to validate memory when changing C-bit Message-ID: References: <20220209181039.1262882-1-brijesh.singh@amd.com> <20220209181039.1262882-22-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220209181039.1262882-22-brijesh.singh@amd.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 09, 2022 at 12:10:15PM -0600, Brijesh Singh wrote: > The set_memory_{encrypted,decrypted}() are used for changing the pages > from decrypted (shared) to encrypted (private) and vice versa. > When SEV-SNP is active, the page state transition needs to go through > additional steps done by the guest. > > If the page is transitioned from shared to private, then perform the > following after the encryption attribute is set in the page table: > > 1. Issue the page state change VMGEXIT to add the memory region in > the RMP table. > 2. Validate the memory region after the RMP entry is added. > > To maintain the security guarantees, if the page is transitioned from > private to shared, then perform the following before encryption attribute > is removed from the page table: > > 1. Invalidate the page. > 2. Issue the page state change VMGEXIT to remove the page from RMP table. > > To change the page state in the RMP table, use the Page State Change > VMGEXIT defined in the GHCB specification. > > The GHCB specification provides the flexibility to use either 4K or 2MB > page size in during the page state change (PSC) request. For now use the > 4K page size for all the PSC until RMP page size tracking is supported > in the kernel. This commit message sounds familiar because I've read it before - patch 18 - and it looks copied. So I've turned into a simple one which says it all: x86/mm: Validate memory when changing the C-bit Add the needed functionality to change pages state from shared to private and vice-versa using the Page State Change VMGEXIT as documented in the GHCB spec. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette