From patchwork Wed Jan 24 13:03:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 191589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1021928dyi; Wed, 24 Jan 2024 06:25:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJZC3xPlRQD27j4+l5axYzILLSsyGkUagpgcQ9L48mDhRVBM/BicsNDmqTM1c1Jh8uwagR X-Received: by 2002:a05:622a:1116:b0:42a:820:b140 with SMTP id e22-20020a05622a111600b0042a0820b140mr2736412qty.120.1706106318920; Wed, 24 Jan 2024 06:25:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706106318; cv=pass; d=google.com; s=arc-20160816; b=fEEFJ3gyYUwyDrYcL6S9cX6JTkx9Of6c5z1wmyqdXdjtpPAQEHiaaSX7A5WJasUCtB Sit1gshNy/XJ35cfbl4rF91kl15KRKlNiU72P4s6xH4v1pG1qjZ5dYNXZtjkF4951pJH Bm0WOsaZ+TI50dnhWWpObYjlPkjEqyXXF0R9yDFgm2+tObOJ9/2CCvUazPt19s55rv7g yI355MJEVSCuSkC2FZIFkFrbccvISqhyLGXJT25YA63wVRN3KBY+e+I9btqE+SXSMWbR 1NDmThd0Rjc/v6J9K55Qklm/dmW4082T5tk+wpGhgpxH1oVPM9l94sYi/NzJXxG2S7eF WJnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Wgj+EaDmQiKinDMzS1eMty8x9mykQ3y4tW8PHoz80u8=; fh=OIvGd1F+CZflq6PJKBpt4O1qnhYwSPnAihrSqFge+4c=; b=NYjcqh71E4+BSc8awvCc+3H/IsDXjXlIoGONrVoWW637uR+HaWuizZJHkNzBF4NHFp RhrDwbGl344b8hEV+HU3NHBmnCvWg6Sai+HQyMmSbwHLime9EHdptqKLheZCXd5vamIv nktyVAXtr82VsPBJ6oXRJogE74N6kZg53ZNRC1ZezZl2RQVgneCBpkNXGv8ihKo4vma0 dUYw/Kb2hw7fxTFwVxIr3KC9N2uup/pTf3jEXFq4l7ZffO4aacRgplflb4jzR5h80rDH 9JtmLc9Tr/yNihegpUHS1qNeGJHRXMGqHwrNSb4dmxSJKsp/U3jKZkm7AbWWywPrDnU3 vsEQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HT65R6BC; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-37051-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37051-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 2-20020ac84e82000000b0042a5ba06681si1733197qtp.517.2024.01.24.06.25.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 06:25:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37051-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=@intel.com header.s=Intel header.b=HT65R6BC; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-37051-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37051-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6EE351C26E4A for ; Wed, 24 Jan 2024 13:09:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0422377F23; Wed, 24 Jan 2024 13:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HT65R6BC" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 EF38777622; Wed, 24 Jan 2024 13:09:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706101752; cv=none; b=b6CwT6hPioh+lbgF8nmtSA6dPBYJ1OsJqIELc06KLOHvp36oTue3tltRBEwh1yYQ835mwBUgBqeSCDBl7jYO9tCbf9xQXeszivbDTEo/OplBUn+URu9ln01deGuNv8WQRBkcTYfU3MCKHXGpFAHLbkFEOpmqq7azWTUtngcYAnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706101752; c=relaxed/simple; bh=NFxolRs646jfhfXCCby0HyE2+Jgy/482MfM1tdDgMV8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NLRGW6PSt8mayIntNbrXMzkKJLNqK60amsFyNsJahjBobXIVPpunXutUxReVDySol6QWCeLYPj++4FzuprEfFPFtOSvXrHTxpM5fhuJ58pR3jY1bNYw8Gf+jV/EzdCbQ93c4CLbrh5TF6uNCBFE9BnzIcegTbh100E/5M74OmZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HT65R6BC; arc=none smtp.client-ip=192.198.163.9 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.helo=mgamail.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706101750; x=1737637750; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=NFxolRs646jfhfXCCby0HyE2+Jgy/482MfM1tdDgMV8=; b=HT65R6BC7no+3XQinNRlOrpAmMtSb7AAZ1AQm6tz/JrSQJUiCEm6R+cx siJ13n8WknxSDbcZ/6XLgXUnbRb+IT7/bor8APRHmjWqcKUrq45tCxx7Q 79HTqtUP0NVaoCUIAwcPJYsewej7TmqrzRuIOG16BqrU7fCcokJ4osRiH 3wpTK6clZfwpaJfMKrDFcgKwxDAlc+OgLyRtejwL5T/VYIA8tLDIxkqzo Rkj83w/czGsCyNwZM+QECp53s5+xPFZo/5aFxBSB61mFK0L5ikt6aI3zi OWDLQ6hQ6ta9ewxfBKS3DVDGyMkNbQAjhF5rtqggUjHjiIBeCPeb9GU3b Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="8597952" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="8597952" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2024 05:09:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="735925597" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="735925597" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 24 Jan 2024 05:09:05 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id A140F9F; Wed, 24 Jan 2024 15:03:23 +0200 (EET) From: "Kirill A. Shutemov" To: Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Tom Lendacky Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , David Rientjes Subject: [PATCH, RESEND] x86/sev: Fix SEV check in sev_map_percpu_data() Date: Wed, 24 Jan 2024 15:03:17 +0200 Message-ID: <20240124130317.495519-1-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788982139692480077 X-GMAIL-MSGID: 1788982139692480077 The function sev_map_percpu_data() checks if it is running on an SEV platform by checking the CC_ATTR_GUEST_MEM_ENCRYPT attribute. However, this attribute is also defined for TDX. To avoid false positives, add a cc_vendor check. Signed-off-by: Kirill A. Shutemov Fixes: 4d96f9109109 ("x86/sev: Replace occurrences of sev_active() with cc_platform_has()") Suggested-by: Borislav Petkov (AMD) Acked-by: David Rientjes --- arch/x86/kernel/kvm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index dfe9945b9bec..428ee74002e1 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -434,7 +434,8 @@ static void __init sev_map_percpu_data(void) { int cpu; - if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) + if (cc_vendor != CC_VENDOR_AMD || + !cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) return; for_each_possible_cpu(cpu) {