From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16E0FC433F5 for ; Wed, 9 Feb 2022 18:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240051AbiBIS6B (ORCPT ); Wed, 9 Feb 2022 13:58:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241191AbiBIS5J (ORCPT ); Wed, 9 Feb 2022 13:57:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3147C050CC3; Wed, 9 Feb 2022 10:57:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A3CD8B82384; Wed, 9 Feb 2022 18:57:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20BE9C340ED; Wed, 9 Feb 2022 18:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644433027; bh=cHsPid5BwyM2TYSZCb78GZ0uJjtAROUGJf0j9hx1WQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SqMmKAGOsITM0nVkOa3u2DQaWQrT7h7iE7y5ZVgqKzgmTvz+l7VcZw9NPVWaqaszy sArtHqwEwcweZGFXXPXomPK6JGOHF+CZvAW0rJBwJke75mgnstOXRji5oLKYUHN7kx kj7YqbvxCWewF8HNMnGu1ybEgLKIrw2uKr1ffCdwTCElm95jgSME5qt8T9vNOE/2uz amXV3NvCq020TtgUPGHDdt/YiUylblfu+UIk6txRHU245MDtVjTQPXy7NS2idtSQC+ Ay1yI/VXUf5+rYAyzfwHXokYObhN+1Z5bNZliN/fYL7LaIZg0bynwIoFpgR2wi8XvZ OwZ4j0Zzezcvg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sean Christopherson , Liam Merwick , Paolo Bonzini , Sasha Levin , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, kvm@vger.kernel.org Subject: [PATCH MANUALSEL 5.15 6/8] KVM: SVM: Explicitly require DECODEASSISTS to enable SEV support Date: Wed, 9 Feb 2022 13:56:51 -0500 Message-Id: <20220209185653.48833-6-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209185653.48833-1-sashal@kernel.org> References: <20220209185653.48833-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson [ Upstream commit c532f2903b69b775d27016511fbe29a14a098f95 ] Add a sanity check on DECODEASSIST being support if SEV is supported, as KVM cannot read guest private memory and thus relies on the CPU to provide the instruction byte stream on #NPF for emulation. The intent of the check is to document the dependency, it should never fail in practice as producing hardware that supports SEV but not DECODEASSISTS would be non-sensical. Signed-off-by: Sean Christopherson Reviewed-by: Liam Merwick Message-Id: <20220120010719.711476-5-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/svm/sev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 134c4ea5e6ad8..d006eeb1d0321 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1887,8 +1887,13 @@ void __init sev_hardware_setup(void) if (!sev_enabled || !npt_enabled) goto out; - /* Does the CPU support SEV? */ - if (!boot_cpu_has(X86_FEATURE_SEV)) + /* + * SEV must obviously be supported in hardware. Sanity check that the + * CPU supports decode assists, which is mandatory for SEV guests to + * support instruction emulation. + */ + if (!boot_cpu_has(X86_FEATURE_SEV) || + WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS))) goto out; /* Retrieve SEV CPUID information */ -- 2.34.1