Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1715518rdd; Thu, 11 Jan 2024 07:17:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhQSFBpM0bvkJawd5BoO+njgz0R3UOtLHCe10EnusdpwxP4ZbaSLVANXppY6p7/lXw/x2o X-Received: by 2002:a05:6808:1405:b0:3bd:341e:8e71 with SMTP id w5-20020a056808140500b003bd341e8e71mr1944513oiv.74.1704986270863; Thu, 11 Jan 2024 07:17:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704986270; cv=none; d=google.com; s=arc-20160816; b=bMkzpwE+uo3uaCqu5j6ZQj9TqY4lXnD//iGew/iPWQ58CIyGfv63oyZ6XUUOAQ+S4a 7l/ppTrlW6lInrJb1veWordVpHNLlJ4RLHF+mqagfPtNyQK+DqGaUpjO5Z0biJYRnbbv tFia2k/XJDPBuB9VikW8hPP/tD4FE+9BKm7s5LeRuHBpqrsTTvJyNSRObH9jGRo/5PlD +sncjoSMXfhq+IqSavd4/9Ix4CdxGh+iB0Bke6ZLAqrBpaf5DI+scah3xkPQWjJrD12J skXuNjPp6afjC9FI94GgmQhslQcuhUKCEhRsn+GQvuEogdbO9cpxlukUbH5Az6cM40DJ oGfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-filter; bh=pgqO97BKIOnbScawTDJ1tuVF8f+8OGImDL62MOlRvq0=; fh=qcZGNM/orr+qihmeUz105xaEwX38CQgF9HpnsQ63cnc=; b=iKkqBhz0RBKRUMxZniDStIbRAJ15deg9G/3mFKEPLOuwcNqVcQLvpKd68POqe719Qy +Q6zNmEqb9TXzcnJrV3g0GpvHI+QR0YH9tlgePWbjFX9daANx4LjgK8F5OIagSvrTXH/ NlmRtXX6niZlh54apl4yZbQc3B3jXgDhPdDv1/Su50bbTZkBzAmk1fhbPFkhCkurSZv7 z23k3i86jtkbXMYILT1DyQ62Vlpgazhm7A0evzrQL3f5hyo7Cvq36wjfHNtLwV/VPsvi dEcu2lvPaDnTETXY3DHGZ/Xnntg9aatqGV0Nu/cEX8CdyOeJnXdYZ8RHVZzSw7fk0vZv JhBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=d9pUtNpm; spf=pass (google.com: domain of linux-kernel+bounces-23776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k10-20020a6568ca000000b005be34495eedsi1266409pgt.118.2024.01.11.07.17.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 07:17:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=d9pUtNpm; spf=pass (google.com: domain of linux-kernel+bounces-23776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8D23A2841BD for ; Thu, 11 Jan 2024 15:15:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FBFE4F206; Thu, 11 Jan 2024 15:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="d9pUtNpm" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FAA74EB45 for ; Thu, 11 Jan 2024 15:14:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from [192.168.1.210] (181-28-144-85.ftth.glasoperator.nl [85.144.28.181]) by linux.microsoft.com (Postfix) with ESMTPSA id A6F8420B3CC1; Thu, 11 Jan 2024 07:14:46 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A6F8420B3CC1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1704986089; bh=pgqO97BKIOnbScawTDJ1tuVF8f+8OGImDL62MOlRvq0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=d9pUtNpmuoaI9O+TRWUiqwctGBspkfBhPjCcPK9kmDBiEtbimKz6GQxaXMW+i6V9A wKdxues79caHK1R61nEHWi3J9qAVq1Lx7LfDbWkVQfKxHyi1srYYGN/WT0dObO6J6A +FjHHbGjnMcyU8VuMQJe7KOk52ZWT5pcZj4LTru0= Message-ID: Date: Thu, 11 Jan 2024 16:14:45 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv2] x86/mm: Fix memory encryption features advertisement Content-Language: en-US To: Kuppuswamy Sathyanarayanan , "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Cc: x86@kernel.org, "H. Peter Anvin" , Tom Lendacky , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Dexuan Cui References: <20240111111224.25289-1-kirill.shutemov@linux.intel.com> <1a3661d5-3539-4443-88da-003dea920188@linux.intel.com> From: Jeremi Piotrowski In-Reply-To: <1a3661d5-3539-4443-88da-003dea920188@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/01/2024 15:19, Kuppuswamy Sathyanarayanan wrote: > > > On 1/11/2024 3:12 AM, Kirill A. Shutemov wrote: >> When memory encryption is enabled, the kernel prints the encryption >> flavor that the system supports. >> >> The check assumes that everything is AMD SME/SEV if it doesn't have >> the TDX CPU feature set. >> >> Hyper-V vTOM sets cc_vendor to CC_VENDOR_INTEL when it runs as L2 guest >> on top of TDX, but not X86_FEATURE_TDX_GUEST. Hyper-V only needs memory >> encryption enabled for I/O without the rest of CoCo enabling. >> >> To avoid confusion, check the cc_vendor directly. >> >> Possible alternative is to completely removing the print statement. >> For a regular TDX guest, the kernel already prints a message indicating >> that it is booting on TDX. Similarly, AMD and Hyper-V can also display >> a message during their enumeration process. > > With this change, will it print "Intel TDX" for Hyper-V? Yes, I just tested on AMD and Intel and the print is accurate now. Thanks. Reviewed-by: Jeremi Piotrowski > > IMO, since there is already a debug message for type identification, we > can remove this part. > If that's the only way to get a fix merged then so be it, but I appreciate having the possibility of greping for a single prefix for either vendor that the current code provides. >> >> Signed-off-by: Kirill A. Shutemov >> Cc: Dexuan Cui >> Cc: Jeremi Piotrowski >> --- >> arch/x86/mm/mem_encrypt.c | 56 +++++++++++++++++++++------------------ >> 1 file changed, 30 insertions(+), 26 deletions(-) >> >> diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c >> index c290c55b632b..d035bce3a2b0 100644 >> --- a/arch/x86/mm/mem_encrypt.c >> +++ b/arch/x86/mm/mem_encrypt.c >> @@ -42,38 +42,42 @@ bool force_dma_unencrypted(struct device *dev) >> >> static void print_mem_encrypt_feature_info(void) >> { >> - pr_info("Memory Encryption Features active:"); >> + pr_info("Memory Encryption Features active: "); >> >> - if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) { >> - pr_cont(" Intel TDX\n"); >> - return; >> - } >> + switch (cc_vendor) { >> + case CC_VENDOR_INTEL: >> + pr_cont("Intel TDX\n"); >> + break; >> + case CC_VENDOR_AMD: >> + pr_cont("AMD"); >> >> - pr_cont(" AMD"); >> - >> - /* Secure Memory Encryption */ >> - if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) { >> + /* Secure Memory Encryption */ >> + if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) { >> /* >> * SME is mutually exclusive with any of the SEV >> * features below. >> - */ >> - pr_cont(" SME\n"); >> - return; >> + */ >> + pr_cont(" SME\n"); >> + return; >> + } >> + >> + /* Secure Encrypted Virtualization */ >> + if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) >> + pr_cont(" SEV"); >> + >> + /* Encrypted Register State */ >> + if (cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT)) >> + pr_cont(" SEV-ES"); >> + >> + /* Secure Nested Paging */ >> + if (cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) >> + pr_cont(" SEV-SNP"); >> + >> + pr_cont("\n"); >> + break; >> + default: >> + pr_cont("Unknown\n"); >> } >> - >> - /* Secure Encrypted Virtualization */ >> - if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) >> - pr_cont(" SEV"); >> - >> - /* Encrypted Register State */ >> - if (cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT)) >> - pr_cont(" SEV-ES"); >> - >> - /* Secure Nested Paging */ >> - if (cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) >> - pr_cont(" SEV-SNP"); >> - >> - pr_cont("\n"); >> } >> >> /* Architecture __weak replacement functions */ >