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 9B059C433F5 for ; Thu, 23 Dec 2021 21:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350320AbhLWVJc (ORCPT ); Thu, 23 Dec 2021 16:09:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245175AbhLWVJb (ORCPT ); Thu, 23 Dec 2021 16:09:31 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F31BC061401 for ; Thu, 23 Dec 2021 13:09:31 -0800 (PST) Received: from zn.tnic (dslb-088-067-202-008.088.067.pools.vodafone-ip.de [88.67.202.8]) (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 98E671EC0518; Thu, 23 Dec 2021 22:09:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1640293765; 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=c3AfMlGm9ELJvSEyis1wt9Tb5x6tKoZk/NuzRyncwyU=; b=T30FPWOn+KiPJT9xuvaVSsOz6zxBIKLugQI0QXiQz0uvmCQ8FMxfEizLqvhAPHE/mSc60T F7ELqOMhIHyAXJKXdZiY7+yB8vgyb2v7oe6pK3qMhgOqAOEB7ETBV+MhaPrplNMk+tCeSc 3bwU1IQywvWppze1xEzYom7ApeJmL/Q= Date: Thu, 23 Dec 2021 22:09:26 +0100 From: Borislav Petkov To: "Kirill A. Shutemov" Cc: Dave Hansen , "Kirill A. Shutemov" , Tom Lendacky , tglx@linutronix.de, mingo@redhat.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: [PATCH 19/26] x86/tdx: Make pages shared in ioremap() Message-ID: References: <20211214150304.62613-1-kirill.shutemov@linux.intel.com> <20211214150304.62613-20-kirill.shutemov@linux.intel.com> <87c288d6-9bf8-5a94-a628-1e0aaa7de690@amd.com> <20211223171530.v73posbqizb5l3md@black.fi.intel.com> <20211223205604.g44kez5d7iedatfo@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211223205604.g44kez5d7iedatfo@box.shutemov.name> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 23, 2021 at 11:56:04PM +0300, Kirill A. Shutemov wrote: > Except CC_ATTR_MEM_ENCRYPT is true for TDX too, so it will also depend on > check order. It is fragile. So the query you wanna do is: if (memory encryption in use) use mask; and the mask you use depends on whether it is SEV or TDX. Right? If so, you can either do a cc_get_mask() function which gives you either the SEV or TDX mask or simply do: if (CC_ATTR_MEM_ENCRYPT) { if (CC_ATTR_GUEST_TDX) mask = tdx_shared_mask(); else if (sme_me_mask) mask = sme_me_mask; } Yeah, sme_me_mask has become synonymous with the kernel running as a AMD confidential guest. I need to think about how to make this cleaner... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette