From mboxrd@z Thu Jan 1 00:00:00 1970 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 E10B5C433EF for ; Thu, 10 Feb 2022 16:49:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 173DC6B0073; Thu, 10 Feb 2022 11:49:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 122B06B0074; Thu, 10 Feb 2022 11:49:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F05416B0075; Thu, 10 Feb 2022 11:49:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id E104F6B0073 for ; Thu, 10 Feb 2022 11:49:04 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7E1C1180AC35B for ; Thu, 10 Feb 2022 16:49:04 +0000 (UTC) X-FDA: 79127455008.08.A833383 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by imf30.hostedemail.com (Postfix) with ESMTP id C7CDC80006 for ; Thu, 10 Feb 2022 16:48:59 +0000 (UTC) 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-Rspamd-Queue-Id: C7CDC80006 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=alien8.de header.s=dkim header.b=arLbkOX2; spf=temperror (imf30.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de; dmarc=pass (policy=none) header.from=alien8.de X-Stat-Signature: z98tg1ebjjmbe9t3wdbxf6abihcjzq7t X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1644511739-834996 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: 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