Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2939684rdb; Mon, 4 Dec 2023 11:37:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRfkUlJDjebm9Nr8y1gxRHvIjzXpY57YdCcRpQbA0gIij5L1q3bkyaRyP/YuZUMLKmxBfg X-Received: by 2002:a05:6a00:114b:b0:6ce:2731:79ef with SMTP id b11-20020a056a00114b00b006ce273179efmr68708pfm.37.1701718676553; Mon, 04 Dec 2023 11:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701718676; cv=none; d=google.com; s=arc-20160816; b=ph2ujgK8LU/mnJr3YVi1RQNMeC58C6LepZK5q7ILQrPpB7/YiHWwDH8fEvR7MsuDAS EO6lTQCHBcHmvma/OlCRV6nPSAUHCAVDCkm5iz7CHzuiX6JR1g0OoyirMlyQFBbkKADE xhlPMHzqZqQaGqzNc6Y1WE6yDlOdI7KryM7yXKkPNJsfDoOoXgUdcFQ09dkn+jWaY+QR WKYwtSyBkwlxTDhw8OMbIqA6np0e2hyUEdU5J0td6ebWAnD6F9R96qS5Y0il0Q/6ajml bK0jIdHf/RsRHUvRkvaT4h/mR56KFNh6TMCzmPbYeK/RkcrU4Xg2BS695nMXdjbFNlB6 fxLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=6OgqpPIDYAhEvqdnTA5+1k8rBb0kW/Ne8m6QL+eFWfI=; fh=TUzkTK21/UltQaSwblS2Zj3JNSnNRYOMz1OcqFsuKc0=; b=yALcXtY0kaEqrGyTT0eybKtQxlXI4q9V63ymwefQIjM7Xf11VnrAH3kjj3g43p7GVm dapb+PeuGea8VPnF8Mfd1styy6r7gxufVxovmkCuxf52RjIdWSi7sjBUhyVmm3iEy0RW dEtfsFWVc50V3UMueHP1taxH2zm8TAS0e7/BE7JJIYXAFXhMYksn3p9FO7TOxO2s37Hc BxDHbfE1Tk/KnIvgjzRPqzhXTT7GKkKPPUgK6VFght/S/+nuk1Sj0aQp93Rz3EJU0xGv wI4bdbsE6JIjWfuLG1uFjqsNB+rJlrghX7Vc01JlPDgaAn4NtRWSL8gzycmdWd/CdEND UUfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="EqaWQiP/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j34-20020a63fc22000000b005af21fd2c6fsi8299183pgi.898.2023.12.04.11.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:37:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="EqaWQiP/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C56FF80774B9; Mon, 4 Dec 2023 11:37:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233384AbjLDThj (ORCPT + 99 others); Mon, 4 Dec 2023 14:37:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbjLDThi (ORCPT ); Mon, 4 Dec 2023 14:37:38 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C7FF1B6; Mon, 4 Dec 2023 11:37:44 -0800 (PST) Received: from [192.168.178.49] (dynamic-adsl-84-220-28-122.clienti.tiscali.it [84.220.28.122]) by linux.microsoft.com (Postfix) with ESMTPSA id 9E63820B74C0; Mon, 4 Dec 2023 11:37:38 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9E63820B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1701718664; bh=6OgqpPIDYAhEvqdnTA5+1k8rBb0kW/Ne8m6QL+eFWfI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=EqaWQiP/J41/orn/yXK04P4ChSOua40DK3YNcn4gA8ZTD8x0gteOv8XXF3GUozHK1 GJxqPvmxT+VWDnynPZJ0J0nTLxQA0G0Z1tn8M7FYS4AUftBQXJJ1+hidwFvPYYT/3k CVSUZBqM0cDdKsnvb/kLcuUkMOAqjZge43lpcQXs= Message-ID: Date: Mon, 4 Dec 2023 20:37:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/3] x86/tdx: Check for TDX partitioning during early TDX init Content-Language: en-US To: Borislav Petkov Cc: linux-hyperv@vger.kernel.org, stefan.bader@canonical.com, tim.gardner@canonical.com, roxana.nicolescu@canonical.com, cascardo@canonical.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, sashal@kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, "H. Peter Anvin" , Dave Hansen , Ingo Molnar , "Kirill A. Shutemov" , Michael Kelley , Nikolay Borisov , Peter Zijlstra , Thomas Gleixner , Tom Lendacky , x86@kernel.org, Dexuan Cui References: <20231122170106.270266-1-jpiotrowski@linux.microsoft.com> <0799b692-4b26-4e00-9cec-fdc4c929ea58@linux.microsoft.com> <20231129164049.GVZWdpkVlc8nUvl/jx@fat_crate.local> From: Jeremi Piotrowski In-Reply-To: <20231129164049.GVZWdpkVlc8nUvl/jx@fat_crate.local> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 04 Dec 2023 11:37:53 -0800 (PST) On 29/11/2023 17:40, Borislav Petkov wrote: > On Wed, Nov 22, 2023 at 06:19:20PM +0100, Jeremi Piotrowski wrote: >> Which approach do you prefer? > > I'm trying to figure out from the whole thread, what this guest is. Wanted to clarify some things directly here. This type guest is supported in the kernel already[1], so this whole series is the kind of attempt to share more code that you advocated for in another email. [1]: https://lore.kernel.org/lkml/20230824080712.30327-1-decui@microsoft.com/#t > > * A HyperV second-level guest From Hyper-V's point of view it's a TDX guest with privilege levels inside, not second-level... > > * of type TDX ...but Intel TDX calls these privilege levels L1 and L2 instead of VMPL0/VMPL1-3. > > * Needs to defer cc_mask and page visibility bla... > The implementations in tdx_early_init() depend on TDX module calls (not avail) and the correct calls are standard Hyper-V hypercalls (same as vTOM SNP guests). > * needs to disable TDX module calls > > * stub out tdx_accept_memory This is actually a fix that for something that only works by accident right now and I meant to post separately from the rest of the discussion. If you look at arch/x86/include/asm/unaccepted_memory.h (below), it is used by both CONFIG_INTEL_TDX_GUEST and CONFIG_AMD_MEM_ENCRYPT, but there is no tdx_accept_memory implementation when CONFIG_INTEL_TDX_GUEST is not set. This is subtle and confusing, the stub should be there. static inline void arch_accept_memory(phys_addr_t start, phys_addr_t end) { /* Platform-specific memory-acceptance call goes here */ if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) { if (!tdx_accept_memory(start, end)) panic("TDX: Failed to accept memory\n"); } else if (cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) { snp_accept_memory(start, end); } else { panic("Cannot accept memory: unknown platform\n"); } } > > Anything else? > > And my worry is that this is going to become a mess and your patches > already show that it is going in that direction because you need to run > the TDX side but still have *some* things done differently. Which is > needed because this is a different type of guest, even if it is a TDX > one. > > Which reminds me, we have amd_cc_platform_vtom() which is a similar type > of thing. > > And the TDX side could do something similar and at least *try* to > abstract away all that stuff. > > Would it be nice? Of course not! > > How can one model a virt zoo of at least a dozen guest types but still > keep code sane... :-\ >