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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E9FCC433F5 for ; Fri, 1 Oct 2021 11:06:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AEB6D61A83 for ; Fri, 1 Oct 2021 11:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AEB6D61A83 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alien8.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id D8B3A9400FD; Fri, 1 Oct 2021 07:06:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D39649400E4; Fri, 1 Oct 2021 07:06:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD97B9400FD; Fri, 1 Oct 2021 07:06:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id AEFBF9400E4 for ; Fri, 1 Oct 2021 07:06:23 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 61E1E183459F1 for ; Fri, 1 Oct 2021 11:06:23 +0000 (UTC) X-FDA: 78647589846.10.84E2B2C Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by imf18.hostedemail.com (Postfix) with ESMTP id 644AD4001EAC for ; Fri, 1 Oct 2021 11:06:15 +0000 (UTC) Received: from zn.tnic (p200300ec2f0e8e0006425ffdb1062ac0.dip0.t-ipconnect.de [IPv6:2003:ec:2f0e:8e00:642:5ffd:b106:2ac0]) (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 7CBB61EC0419; Fri, 1 Oct 2021 13:06:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1633086372; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JCBAeXE9Fm2/4A8nfF4qlTElC4omNaQJNghTb8YDddM=; b=kTtfe1X/X1Cm8CiF7sqgmxJbnYSVBHwhUxmVIQWx22i7VqsRKC6EEWMxmDVCD+9RF7VzG5 QJBTrSVvQeE27As7XeJBpiyoxWoEGP1nFgkKyx5GnB9alDDmJT1lAjv2TqZFpTt2XpnmBK KSzCimg6oBTl41PghKnK15OZssLqRMo= Date: Fri, 1 Oct 2021 13:06:08 +0200 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, 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 , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH Part2 v5 06/45] x86/sev: Invalid pages from direct map when adding it to RMP table Message-ID: References: <20210820155918.7518-1-brijesh.singh@amd.com> <20210820155918.7518-7-brijesh.singh@amd.com> <60d6a70d-22ab-9e17-b243-7f5669b4b70d@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <60d6a70d-22ab-9e17-b243-7f5669b4b70d@amd.com> X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 644AD4001EAC X-Stat-Signature: snsethr81bhpxc6d6jauj1fa4wxe878e Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=alien8.de header.s=dkim header.b="kTtfe1X/"; dmarc=temperror reason="server fail" header.from=alien8.de (policy=temperror); spf=pass (imf18.hostedemail.com: domain of bp@alien8.de designates 5.9.137.197 as permitted sender) smtp.mailfrom=bp@alien8.de X-HE-Tag: 1633086375-260686 Content-Transfer-Encoding: quoted-printable 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 Thu, Sep 30, 2021 at 09:19:52AM -0700, Brijesh Singh wrote: > . The thought process is if in the future=C2=A0 > set_direct_map_default_noflush() is improved to restore the large > mapping then it will all work transparently. That's only scratching the surface of the *why* this is done so please explain why this dance is being done in a comment above the code so that it is clear. It is not really obvious why that hiding from the direct map is being done. Good reason from that memfd_secret mail are: "* Prevent cross-process secret userspace memory exposures. Once the secr= et memory is allocated, the user can't accidentally pass it into the kernel = to be transmitted somewhere. The secreremem pages cannot be accessed via the direct map and they are disallowed in GUP." and in general hiding RMP pages from the direct map is a nice additional protection. Thx. --=20 Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette