Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp723836pxb; Tue, 8 Feb 2022 00:38:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdigWv8j9zTefJ6t/M1TpzO/f1t094qTGr6diWdZNEnWYYELbH+TbQvJyh0Hsw6cXdguYI X-Received: by 2002:a63:8bc4:: with SMTP id j187mr2673894pge.536.1644309519383; Tue, 08 Feb 2022 00:38:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644309519; cv=none; d=google.com; s=arc-20160816; b=P/ciK2g7E7pV0N75D9Prq9R7qXAoxJemoncFLH6G/xykLEoeUvbWYRmM3OepTi466n +C7hQ+oKMHJGQYjMhdyUla9o46DDNWbzr9eGkoY7BaYeJPRrMeVzR9cZf1IUPqSA0tOH 77Cl/vi41U+wGXXqdBPML74gE24Ule5kSNNpJqAjuksoJNMdJsRXVcj6nUAyGq0iKMSE NX2hXT6YHjWlXXLm1w7MJ2MOEbOvLMm3+8TgrlZZGRCfaL7rGsq6PWZxPEH1XvFWDnFq UvQDB4kvCebbvxCcsO1bK0hXshZYW9eXSmC5FS3Ce8JMGZuFifFt7owVgF6b+/XmNmja J0eA== 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=V+wFfsqHNfZRL4X27c/FVRJb4slH/Iyz43L5rnSVKww=; b=Cw4jNF5p94/KyVAMSitxT9jxceVgXWNRGnAajJPbGW/AgIdbVz2qFY5XzqWwiwwiui Wqbfa7zJI5cPwmj0j3EaM1RJK/OwXz4ih61q+slLgQxhSgI8uT/d9Mb2gWpql08Jb2xG LA2djtu3M3G0RxYLaAS44OtUnbzy4lg0/Lbgx3ycWi4S7qbRJKWMm4idlsdY2+MGzi+1 mTXQ58AzYPaws6OINVPtuRy2wru+HA7ZxVc2gEGN2kijIrpdT2LfCjCUpJnYhn2YHMJJ 7V+eYjXsWHnYgwFGlJ5Qmnk6IG4BM/T9t/oWiAXjgg1ORZqz9xQFBHHhbQoBifX5VzH3 W3Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=X9yluiiE; 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 s1si12637375pgs.355.2022.02.08.00.38.26; Tue, 08 Feb 2022 00:38:39 -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=X9yluiiE; 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 S1389840AbiBGQau (ORCPT + 99 others); Mon, 7 Feb 2022 11:30:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388324AbiBGQ1d (ORCPT ); Mon, 7 Feb 2022 11:27:33 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5A0AC0401CE for ; Mon, 7 Feb 2022 08:27:30 -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 5079C1EC01A9; Mon, 7 Feb 2022 17:27:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1644251245; 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=V+wFfsqHNfZRL4X27c/FVRJb4slH/Iyz43L5rnSVKww=; b=X9yluiiEo6dUxb589S8A5/IYUIB2oE4PRH2xaGSR2m0NgweXp+TpqR5Su58q4dmnHaYj7a FCZD7OM0zodQtYSYpkwKPdSf+7QOLpRjFeARpFYmEDEAFT9PcxUR9BH0Q/G+g5hA0fHVuA ySgGSvdru5np43vV2veodivKtoSjK30= Date: Mon, 7 Feb 2022 17:27:20 +0100 From: Borislav Petkov To: "Kirill A. Shutemov" Cc: tglx@linutronix.de, mingo@redhat.com, dave.hansen@intel.com, luto@kernel.org, peterz@infradead.org, sathyanarayanan.kuppuswamy@linux.intel.com, aarcange@redhat.com, ak@linux.intel.com, dan.j.williams@intel.com, david@redhat.com, hpa@zytor.com, jgross@suse.com, jmattson@google.com, joro@8bytes.org, jpoimboe@redhat.com, knsathya@kernel.org, pbonzini@redhat.com, sdeep@vmware.com, seanjc@google.com, tony.luck@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 22/29] x86/tdx: Make pages shared in ioremap() Message-ID: References: <20220124150215.36893-1-kirill.shutemov@linux.intel.com> <20220124150215.36893-23-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220124150215.36893-23-kirill.shutemov@linux.intel.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 Mon, Jan 24, 2022 at 06:02:08PM +0300, Kirill A. Shutemov wrote: > -/* > - * Macros to add or remove encryption attribute > - */ > -#define pgprot_encrypted(prot) __pgprot(__sme_set(pgprot_val(prot))) > -#define pgprot_decrypted(prot) __pgprot(__sme_clr(pgprot_val(prot))) Why can't you simply define cc_set() and cc_clear() helpers which either call the __sme variants or __tdx variants, the latter you can define the same way, respectively, as the __sme ones. And then you do: #define pgprot_encrypted(prot) __pgprot(cc_set(pgprot_val(prot))) #define pgprot_decrypted(prot) __pgprot(cc_clear(pgprot_val(prot))) And just so that it works as early as possible, you can define a global tdx_shared_mask or so which gets initialized the moment you have td_info.gpa_width. And then you don't need to export anything or other ifdefferies - you just make sure you have that mask defined as early as needed. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette