Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1902082rdd; Thu, 11 Jan 2024 12:46:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/jKuS2GxkrYSwkFyWc6a3yumbgtqj+ejawq6E6zHB6/7l1rvwBnFH1/nSD9KKaO3VbwsZ X-Received: by 2002:a05:6870:1641:b0:206:ad04:9666 with SMTP id c1-20020a056870164100b00206ad049666mr371707oae.115.1705005983677; Thu, 11 Jan 2024 12:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705005983; cv=none; d=google.com; s=arc-20160816; b=Fy0s8dCk9LjhSqWP9v5ltd43Zcx7CRBjtQ7idoUGsR9DAj3b3Y45xFlX5qq7N8KXai nqccn+BE8yHDeoh0po+Xio72dgdkLh2Y0ET+q3XnPhBqaU5sWmrQx34EK3HQoVax5T44 DyyyYcDlUmsBBoWKg9BlYQMAejWINg9qKVsTLjsObcRS15tkUAD3pemYGyTDecDJwLkq JQ/xPkTh9NpaF1RQXPSGNbjj35JSx0btPThLFbvOboOFRWnXFLHoY6EuS03Us/ybUaR8 j2MmaET9583UeOlN4dVA7bKi+4WtJBDdbx9q+ELmxBMuSvbcnmBy9QmL44JwuRx2Dqfm jCPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=qIbM7zZMuVIepedzZ+iJAJWoi43qOzmKImLkX4NG4K4=; fh=lbwiTGTLc4MCKWfdjhjWZbgkkpp8J0bocHJHR1HmTtk=; b=0QY3UBarD4OJ7tnX5xBZzvbrPWd2OtVk4YThYMWnpWCnTxdqKM8hr2aftjbalvjwKp khM29cWL0bv0Stqjv1RVqYWWwpyJE84UT/FAUceGB4UMe9qbm/A5Y3L5x10wk3/VH3yg kf99YDMKk5C2p84IKr4dLFLAJuMoYWHkj6+eUnoggJ7yIB//k4wjQdbgFipxOrK0HYjp /I2nT6q/ect1eYPsfwkKtCtbKk0axsaV1gAqMqVkaAhzH+dQmVVOprdHE61botCQXaDH 7Yd0/y2OYxauIghQacQ4Uzsos9IkYf3Vc2JrAk3Rv+PSxkm2h3UkBKdFmaxcRTc8P8R5 mo8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VSoOycpo; spf=pass (google.com: domain of linux-kernel+bounces-24058-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e21-20020a637455000000b005ced346c5dbsi1723287pgn.776.2024.01.11.12.46.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 12:46:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24058-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VSoOycpo; spf=pass (google.com: domain of linux-kernel+bounces-24058-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 DFC8B2888AF for ; Thu, 11 Jan 2024 20:46:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 170D958117; Thu, 11 Jan 2024 20:46:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VSoOycpo" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F326C5810C for ; Thu, 11 Jan 2024 20:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705005973; x=1736541973; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=T2rvntaxntUFoByN0BT0fZMFdWSF0JFiW3RrtTg9eZA=; b=VSoOycpoYHgPQb3lBhFZpIp11tZCSC+jT72ZUKm292NpHRNWpTYgTNQ/ 5LhWBs88PZlqnVCcAMxi2vphd0bmUHewk0sAj1XB/azGiQu1rKyb1Qb5Q WkRiE404upLYKpchyKnI+8Xz/1KIoBKdrGbMEiwJEVhZjU826S8ITQBgS WmBt/a23iAiwBXxfmMNzr5KuJq309HADf2+4KX/Hx5+uHd5EejBv6IDnz OzzeSsVSD4v8kKdlcjA575jGFG1bKhgD71k0r+PwG53cTGm/6mB/XF177 PEXNRogw0jya52OfYJ2PQ2wnqMTjRxT9qxkoa2RcCKmw/tdYoGy8QCoEP w==; X-IronPort-AV: E=McAfee;i="6600,9927,10950"; a="465370237" X-IronPort-AV: E=Sophos;i="6.04,187,1695711600"; d="scan'208";a="465370237" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2024 12:46:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,187,1695711600"; d="scan'208";a="24769986" Received: from unknown (HELO [10.125.177.125]) ([10.125.177.125]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2024 12:46:12 -0800 Message-ID: <6926ef5e-e2fd-42b0-b7de-11a06ac1f81b@linux.intel.com> Date: Thu, 11 Jan 2024 12:46:11 -0800 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 From: Kuppuswamy Sathyanarayanan To: "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 , Jeremi Piotrowski References: <20240111111224.25289-1-kirill.shutemov@linux.intel.com> <1a3661d5-3539-4443-88da-003dea920188@linux.intel.com> In-Reply-To: <1a3661d5-3539-4443-88da-003dea920188@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/11/2024 6:19 AM, 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? > > IMO, since there is already a debug message for type identification, we > can remove this part. > >> >> Signed-off-by: Kirill A. Shutemov >> Cc: Dexuan Cui >> Cc: Jeremi Piotrowski >> --- Reviewed-by: Kuppuswamy Sathyanarayanan >> 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 */ > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer