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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5E27C19F2D for ; Thu, 4 Aug 2022 12:11:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234379AbiHDML2 (ORCPT ); Thu, 4 Aug 2022 08:11:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232031AbiHDML1 (ORCPT ); Thu, 4 Aug 2022 08:11:27 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CD4125E98; Thu, 4 Aug 2022 05:11:26 -0700 (PDT) Received: from zn.tnic (p200300ea970f4fa7329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:970f:4fa7:329c:23ff:fea6:a903]) (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 A09BE1EC056A; Thu, 4 Aug 2022 14:11:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1659615080; 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=dnIT6BfnSCaKhEYKVBp/iA/Xm7t6NZGreWnaebbwv6k=; b=W0AeNaoVM6CH3GtewEuI+fIELWnyUWnbtPopu0teCfDVXAA+IY0af/WCp/fUXMNVQlR+TK T7iY6EHSMJ5d5w6FvIBUxFmeoZ0H7X7gmQt0AFqnck6ptA9thEH0t2Ga6yTQM2/CzR8WOk nJnFZXaVIpDqFzGDdrWHxjYY2fcrKx4= Date: Thu, 4 Aug 2022 14:11:16 +0200 From: Borislav Petkov To: "Kalra, Ashish" 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" , "tglx@linutronix.de" , "mingo@redhat.com" , "jroedel@suse.de" , "Lendacky, Thomas" , "hpa@zytor.com" , "ardb@kernel.org" , "pbonzini@redhat.com" , "seanjc@google.com" , "vkuznets@redhat.com" , "jmattson@google.com" , "luto@kernel.org" , "dave.hansen@linux.intel.com" , "slp@redhat.com" , "pgonda@google.com" , "peterz@infradead.org" , "srinivas.pandruvada@linux.intel.com" , "rientjes@google.com" , "dovmurik@linux.ibm.com" , "tobin@ibm.com" , "Roth, Michael" , "vbabka@suse.cz" , "kirill@shutemov.name" , "ak@linux.intel.com" , "tony.luck@intel.com" , "marcorr@google.com" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "alpergun@google.com" , "dgilbert@redhat.com" , "jarkko@kernel.org" Subject: Re: [PATCH Part2 v6 07/49] x86/sev: Invalid pages from direct map when adding it to RMP table Message-ID: References: <243778c282cd55a554af9c11d2ecd3ff9ea6820f.1655761627.git.ashish.kalra@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Aug 01, 2022 at 11:57:09PM +0000, Kalra, Ashish wrote: > You mean set_memory_present() ? Right, that. We have set_memory_np() but set_memory_present(). Talk about consistence... ;-\ > But again, calling set_direct_map_invalid_noflush() is easier to > understand from the calling function's point of view as it correlates > to the functionality of invalidating the page from kernel direct map ? You mean, we prefer easy to understand to performance? set_direct_map_invalid_noflush() means crap to me. I have to go look it up - set memory P or NP is much clearer. The patch which added those things you consider easier to understand is: commit d253ca0c3865a8d9a8c01143cf20425e0be4d0ce Author: Rick Edgecombe Date: Thu Apr 25 17:11:34 2019 -0700 x86/mm/cpa: Add set_direct_map_*() functions Add two new functions set_direct_map_default_noflush() and set_direct_map_invalid_noflush() for setting the direct map alias for the page to its default valid permissions and to an invalid state that cannot be cached in a TLB, respectively. These functions do not flush the TLB. I don't see how this fits with your use case... Also, your helpers are called restore_direct_map and invalidate_direct_map. That's already explaining what this is supposed to do. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette