Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1103550rdb; Wed, 24 Jan 2024 05:09:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTS6pXzX8FhOKxT233A5uUVcnnGjyNclFfo5PSgf2lgHDkyMPrIpuz9kwCRZvqIxre+/k0 X-Received: by 2002:ae9:f408:0:b0:783:b1f6:bcbf with SMTP id y8-20020ae9f408000000b00783b1f6bcbfmr1411093qkl.5.1706101767265; Wed, 24 Jan 2024 05:09:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706101767; cv=pass; d=google.com; s=arc-20160816; b=QbN4R25L7u8yo/ZEsxy5JFcGMGPS8b6GikTghVDaOdLCTyGc5zzWxjNJC/9o9UIiBX Xs21aTfsBf0g6U8nn+1fB8K5wQsJ4NcDenb83KpwRQBa+meEiFlMrAVdf3Y1+jT4sE6r 0mrc9e0h115WiQnEZLq2CaiiwTNFtNoAj+V63U0dzEsjh3iZuD5HeRvkSUWXygU9ThUa VMFPyEgvuCXFPHng5Swk0j3j+IaqrRjRCuwVlHX5L6hQ1T5Jzc4YBJBHi3i21qjQM5l9 z3ovNWF6EeAE8QQ1LI5A9dexQE5M5uqY5I3CjR/fYF3wyinlY52jzKWUDNgmOqIajO1A 6ksA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37051-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bl29-20020a05620a1a9d00b007814e1c733dsi11258795qkb.444.2024.01.24.05.09.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 05:09:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37051-linux.lists.archive=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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37051-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1E2A41C267C8 for ; Wed, 24 Jan 2024 13:09:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B72277F05; Wed, 24 Jan 2024 13:09:13 +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 Content-Transfer-Encoding: 8bit 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) { -- 2.43.0