Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp996090rdh; Fri, 24 Nov 2023 03:05:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPetRPmIlnnLCaUlA0eX4S6Y3bMNABQlgL6UaiPoy/qxKQ7wsgjUS0GXigll5HOhS+ev4t X-Received: by 2002:a05:6870:3926:b0:1f9:f674:76a6 with SMTP id b38-20020a056870392600b001f9f67476a6mr1760616oap.37.1700823920001; Fri, 24 Nov 2023 03:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700823919; cv=none; d=google.com; s=arc-20160816; b=S0XQsdkQBQib4tex5X0H+F4Z+htaprtnx0/EdLuvM2/OZZIttF2RX3NJ2nJWDWJGvc 8RNYYGCbp5X5CEOLz196eF6hG4YWGpWuClwXXEBJCyakX9PFFiCJKHea53IkXqW0Aolx 7ulmQuCG8TcvFjlbKQgY8HTgC66ty9yQ/+VsADuVLLU/uYE2BM+22zn4EsiTdFry3FXc cmncjb+x72nbVAzF9agA7ToOc/Dx6lRSOQwr81UhEDEmZgr/e+1lFJLh6GiYthI/XuK9 981JkjDCaGErtLt4u5fPK4ktogjcs/axb1MUh6O104/HToEgo/K4FsO3ogeLMteB4OpF dYaA== 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=7jaZ0scpk4NByvTCBB0IHW+wWWfI9aApWVslFKRIx8s=; fh=CtPEWLGW3h0xHqpYmMk3bEL5pF6SAQdyssf4zEDqQSU=; b=NR+xufFpOmpO1yNOrV3ZLpBekohWpmtxY4F34CePWTu0VCvGEAtJw7gAaLOZhP+LcI ery8ybDS5S8rQyCl7RKcYD818npjIfmggoziFaehxlIhYfQv2WO5qzS4oau1JpVA7Om0 AM7y0e6QDnaTFreYirgm5lnsRSabuG5Vbp/V9LCJf1HQT20I09uqtimNhO91vwxVmsta hhsYD1uLKYgBnstdZzpHEnTNKF+BqhoX7FBoYKYun4XoSGxZKY2t5umik2EmvBrAWfHA tJBNJ9Xb9QKRmK0IIxt/tHO1ummXqkCtJ0L4NoQNdXLMMNknLcJnlUsoI7ZTcW3JiQLu qooA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=nXqb+Bzu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bs6-20020a056830398600b006ce2d2b5cebsi1339673otb.43.2023.11.24.03.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 03:05:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=nXqb+Bzu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 9D7E682B30EA; Fri, 24 Nov 2023 03:05:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345621AbjKXLE6 (ORCPT + 99 others); Fri, 24 Nov 2023 06:04:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345362AbjKXLE4 (ORCPT ); Fri, 24 Nov 2023 06:04:56 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A5564D6E; Fri, 24 Nov 2023 03:05:02 -0800 (PST) Received: from [192.168.1.150] (181-28-144-85.ftth.glasoperator.nl [85.144.28.181]) by linux.microsoft.com (Postfix) with ESMTPSA id 3571420B74C0; Fri, 24 Nov 2023 03:04:58 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3571420B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1700823902; bh=7jaZ0scpk4NByvTCBB0IHW+wWWfI9aApWVslFKRIx8s=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nXqb+Bzu6O/7N3ZWRXOm99TsvtglFjoQqN8btxWl2cQbPDnKJ9cZzWM7WP7FHqaoT k88jeDK15/O683dzQsHAukzlISzzRMID+4EIwy7BaWmKrJ+F+3EoTZrXSwEEWi3mjh Up+Dq/LtF41FV+wluqOVtVWxCr9o5lgV1AbxcJe8= Message-ID: <58c82110-45b2-4e23-9a82-90e1f3fa43c2@linux.microsoft.com> Date: Fri, 24 Nov 2023 12:04:56 +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: "Kirill A. Shutemov" Cc: linux-kernel@vger.kernel.org, Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Michael Kelley , Nikolay Borisov , Peter Zijlstra , Thomas Gleixner , Tom Lendacky , x86@kernel.org, Dexuan Cui , 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 References: <20231122170106.270266-1-jpiotrowski@linux.microsoft.com> <20231123135846.pakk44rqbbi7njmb@box.shutemov.name> <9f550947-9d13-479c-90c4-2e3f7674afee@linux.microsoft.com> <20231124104337.gjfyasjmo5pp666l@box.shutemov.name> From: Jeremi Piotrowski In-Reply-To: <20231124104337.gjfyasjmo5pp666l@box.shutemov.name> 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 24 Nov 2023 03:05:14 -0800 (PST) On 24/11/2023 11:43, Kirill A. Shutemov wrote: > On Fri, Nov 24, 2023 at 11:31:44AM +0100, Jeremi Piotrowski wrote: >> On 23/11/2023 14:58, Kirill A. Shutemov wrote: >>> On Wed, Nov 22, 2023 at 06:01:04PM +0100, Jeremi Piotrowski wrote: >>>> Check for additional CPUID bits to identify TDX guests running with Trust >>>> Domain (TD) partitioning enabled. TD partitioning is like nested virtualization >>>> inside the Trust Domain so there is a L1 TD VM(M) and there can be L2 TD VM(s). >>>> >>>> In this arrangement we are not guaranteed that the TDX_CPUID_LEAF_ID is visible >>>> to Linux running as an L2 TD VM. This is because a majority of TDX facilities >>>> are controlled by the L1 VMM and the L2 TDX guest needs to use TD partitioning >>>> aware mechanisms for what's left. So currently such guests do not have >>>> X86_FEATURE_TDX_GUEST set. >>>> >>>> We want the kernel to have X86_FEATURE_TDX_GUEST set for all TDX guests so we >>>> need to check these additional CPUID bits, but we skip further initialization >>>> in the function as we aren't guaranteed access to TDX module calls. >>> >>> I don't follow. The idea of partitioning is that L2 OS can be >>> unenlightened and have no idea if it runs indide of TD. But this patch >>> tries to enumerate TDX anyway. >>> >>> Why? >>> >> >> That's not the only idea of partitioning. Partitioning provides different privilege >> levels within the TD, and unenlightened L2 OS can be made to work but are inefficient. >> In our case Linux always runs enlightened (both with and without TD partitioning), and >> uses TDX functionality where applicable (TDX vmcalls, PTE encryption bit). > > What value L1 adds in this case? If L2 has to be enlightened just run the > enlightened OS directly as L1 and ditch half-measures. I think you can > gain some performance this way. > It's primarily about the privilege separation, performance is a reason one doesn't want to run unenlightened. The L1 makes the following possible: - TPM emulation within the trust domain but isolated from the OS - infrastructure interfaces for things like VM live migration - support for Virtual Trust Levels[1], Virtual Secure Mode[2] These provide a lot of value to users, it's not at all about half-measures. [1]: https://lore.kernel.org/lkml/1681192532-15460-1-git-send-email-ssengar@linux.microsoft.com/ [2]: https://lore.kernel.org/lkml/20231108111806.92604-1-nsaenz@amazon.com/