From patchwork Tue Jan 30 16:26:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 194236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1342607dyb; Tue, 30 Jan 2024 08:32:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGP4IfGVmNR5yLyblvipvwFxC/ijHx0ypQwFnjUluk6BFBty1xbsurq81ycVqD9ye0od+2+ X-Received: by 2002:a05:620a:15ae:b0:783:40da:323b with SMTP id f14-20020a05620a15ae00b0078340da323bmr8072328qkk.66.1706632344834; Tue, 30 Jan 2024 08:32:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706632344; cv=pass; d=google.com; s=arc-20160816; b=YkR05w9+6INca7cNsfkvZv8eQuAO5egMRKXEshHXUZ5T/mm8L12Ocq92lkKTX4fk8X egFHUqYrYeyYN8sWfFGdiDlW+0ejLBDoXoFiDluMG2Uk8iYAr+wJWOMJ+DfRl8iHWz4g 0Agqwqp73NM+EdsLoz9aT3ZIAncH+Fn55SpOMfFBabA+kroq3ACGCCo2OwLsiRO8B8Io CJ2Zbz3cPjVh5lWEucN2Fdrg4StAQsCfG4UtRQNuPxxltn8tQqaN6fUcd1aBx/1L5dZi OJE/XxWdQ6+BovsZPJJg60zDditT/cpIwsW3UAPCmBZLlU2L3mqTcaxFNlHa9RnK+KZb 6Lrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=7vlBWR4ni7gRjWjPqo2lfaQlbNasDoG4pk6ry00Cg7g=; fh=LwsCHaoIdysadDUZVM9yfxUFS+QmEiI8n4ie80UfUVA=; b=JQixRqBpQf0AvK/oyMnK73JsJqAeeh2oasgsST3dfKXOcdK++A0UZyadP204xwFJOa U4tHXPM45LSbUmNUVTPZrzhyLVSYvT4ibRLPtnTpGzv9ioKSOuqtC8IUbP8Xfnk+Pj58 5MV4UJir26QlORmOF7Pci9s1bPG2fxItosBaNoBLJCzxnZN7euvBBcoWgUW3qEvi/BbH c8/mlPJKKJDpzFLXgADQyxa03Vo5xfdVfaj3rseTIRlM4te3tzG1P1K2pKBxdGmBzfg1 TZQZdvt64Hfk+AyZcOgHdJna3x11SDbcOtcGsS9csttw6xFMKgBdw5xNqsRdgGheqdla x/lg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Sacx46S6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-44945-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44945-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n6-20020a05622a040600b0042a09c94802si10237382qtx.563.2024.01.30.08.32.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 08:32:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44945-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Sacx46S6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-44945-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44945-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 90EA81C22DC8 for ; Tue, 30 Jan 2024 16:32:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 082F613DB95; Tue, 30 Jan 2024 16:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Sacx46S6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dKv42Ukd" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 097A2137C2B; Tue, 30 Jan 2024 16:26:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706631979; cv=none; b=KwgVpJKXQUNARSm7RnyJeMJHBhhVvMHu0gLhmSIk6c744ThDK6kmSHQ5rNYxuy1sjqr9f4aWBchOW6A1vUmN6GXrRhNNlkiyLO3cQJCl6kSxrWRNDA8fM+iS321phe0LqBQpPtlbqu6kR2NX5bbboTMEftsHvamBOfGkldwtAIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706631979; c=relaxed/simple; bh=2Z+DqwLrOTlEZtmtvqHrOMU4bM5HdTHPDUJrj8SQZpE=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=KRppRn9zdmx/L1ZpaffFd2b6bqwPjm9d0GSMlsKlZqXLPBBMx9IRPvaNrqogHnw8vH7G3LVC/BFlqRv/8lUy6U9VJvJiDwCY6izpwQgWPIOCOxp3HfmWRjiKHWKxVeAQvjrzTEiaHpkByG+93zXHiSgemQBmAuB8jUIjg1RVddE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Sacx46S6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dKv42Ukd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Tue, 30 Jan 2024 16:26:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706631975; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7vlBWR4ni7gRjWjPqo2lfaQlbNasDoG4pk6ry00Cg7g=; b=Sacx46S6h8jjg8rzPp6/fMBNU540s9lQwySdBoes5uxEVGSmvvUWOlo99oTJQLSavORkHl aOJUrP5tRIeyqYZL0ay1juzO4ik7R8JxP7GUmJEaHvo9qp1rqZ6FBcv17dWnlzqhyAS5wl s1lA2tt3t0B79QK6aIPJbqozZo8LsteMIViTw7AkA0kYJrvE93lNdNW5ifi94GRZT1Ou/W Va1fdq8KBeqBqiAXkZvlAlIMQ1CovZjuF1bD9cVmYecvVYa/Mmos7C3OBcgYix3iaMRRGy apihtQPkHbcjDuy1PA19y4vy/scut5wZzvQQgYg/4Bx1PJUnZ97BrW4cGU3bOA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706631975; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7vlBWR4ni7gRjWjPqo2lfaQlbNasDoG4pk6ry00Cg7g=; b=dKv42UkdRRbp0DNbrhvXJMSr8CKakpeOz9o5jf+Sq5wQc6c7R66Vqf6jbtpPjI0im6IQ8W yBHhtOblKC9UXtDg== From: "tip-bot2 for Kirill A. Shutemov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] x86/mm: Fix memory encryption features advertisement Cc: "Kirill A. Shutemov" , "Borislav Petkov (AMD)" , Jeremi Piotrowski , Kuppuswamy Sathyanarayanan , Tom Lendacky , Kai Huang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240124140217.533748-1-kirill.shutemov@linux.intel.com> References: <20240124140217.533748-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170663197449.398.3923766970691246483.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788990148762360998 X-GMAIL-MSGID: 1789533717361080142 The following commit has been merged into the x86/sev branch of tip: Commit-ID: 4cab62c058f5a150d9960c112362e5c76d204d9d Gitweb: https://git.kernel.org/tip/4cab62c058f5a150d9960c112362e5c76d204d9d Author: Kirill A. Shutemov AuthorDate: Wed, 24 Jan 2024 16:02:16 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 29 Jan 2024 17:08:27 +01:00 x86/mm: Fix memory encryption features advertisement 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. [ bp: Massage commit message. ] Signed-off-by: Kirill A. Shutemov Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Jeremi Piotrowski Reviewed-by: Kuppuswamy Sathyanarayanan Acked-by: Tom Lendacky Acked-by: Kai Huang Link: https://lore.kernel.org/r/20240124140217.533748-1-kirill.shutemov@linux.intel.com --- 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 c290c55..d035bce 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; - } - - pr_cont(" AMD"); + switch (cc_vendor) { + case CC_VENDOR_INTEL: + pr_cont("Intel TDX\n"); + break; + case CC_VENDOR_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 */