X-Received: by 2002:a17:90a:1dd:b0:1bc:235f:a0b7 with SMTP id 29-20020a17090a01dd00b001bc235fa0b7mr2492224pjd.40.1645508718309; Mon, 21 Feb 2022 21:45:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645508718; cv=none; d=google.com; s=arc-20160816; b=IEuijfSVWnY5HSCs61It663E64h9o3aOQrk9sQpOcJW9ms2k40XsBNFCfQhxxM1GIO jbio/EqsAoajpMt801pGIBPfKKcywxR+426jiiFWhyf1pQm3iRDf/d1/yxxORgsna/4e HeF9adnRJ/abBVQUBEXO1RrQEP/S8sh3VmNipWJ3neWO8v3ZWFRWogyFKPsAohn8Kwxs zrAr1UPriE2cSBAUD0DgPB/uSWV11qg6zbIKiTjv1nmOarbWOXioxrQtvg4EQbbZwvK0 XbtQoughcF/KLnR0ZsftdsjLvfiKi6SI4UEWJrEAm4XuGJOh7dlUS4s/dCmTEAZeJAow PAhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cXHkPTTQHOAEYZnDAvxmDi20TlPacS6L9boDOFWry8Q=; b=X5RUZ1Zi1rkETZLFr6u18YUSvopUjgb+bme+zSJLKjv39R1bR5ED9MoZ0yUw0kA4sx eaq2VVoRkIwygp4ncJU8KrfX5qc5tVrOHV6HHuE3Zx5AhS//9P9dc8xs7Ab7uoJsmxnW qB1vtLD+QEkwBzobvWorMMnCIWCBKrrkktM/vLdRhXlE/n3+D93O1U33HwH9lyQQPW8c ox81Hv1/s8CS6H4SEDg9KAO8qaaSsPDjTjc2vdqE5P7PvvyXDKE4H8EL5+yWiBGmjTiv dwKVGZzsg18P9KIty0+N+31Xqwt5UDoBiKat0bd0DA9MW6gN43fgpsmvfdYNC0FCghLv aifQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sVfWQGN4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s74si9832061pfc.182.2022.02.21.21.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:45:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sVfWQGN4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 37F8C12F415; Mon, 21 Feb 2022 21:10:33 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348442AbiBUJTW (ORCPT + 99 others); Mon, 21 Feb 2022 04:19:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349056AbiBUJMA (ORCPT ); Mon, 21 Feb 2022 04:12:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB28229C97; Mon, 21 Feb 2022 01:04:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 45EEE60FB6; Mon, 21 Feb 2022 09:04:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D1D0C340E9; Mon, 21 Feb 2022 09:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645434288; bh=BlVGSWzcKf/HzPDNKVqs/ptJwKBbwsdtW1dVNKbX9Sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVfWQGN47SNDDdqBrWGri5ozVJmIpOOjbTxlUlMt8M+SJCU3TWPF2ioVDhXioWJIr RHSr8TV8TyfUQU8jk4w79EHvy7PCZG6yCmXOnJx02lcpj9JaQJkZtiZWoV4PJYIsel B+Du0PGSBo6/+rmBB6GlJVDXdIrZdtwTPT6RfM3s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Lendacky , Brijesh Singh , Sean Christopherson , Liam Merwick , Paolo Bonzini , Jack Wang Subject: [PATCH 5.10 077/121] KVM: SVM: Never reject emulation due to SMAP errata for !SEV guests Date: Mon, 21 Feb 2022 09:49:29 +0100 Message-Id: <20220221084923.816329383@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084921.147454846@linuxfoundation.org> References: <20220221084921.147454846@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit 55467fcd55b89c622e62b4afe60ac0eb2fae91f2 upstream. Always signal that emulation is possible for !SEV guests regardless of whether or not the CPU provided a valid instruction byte stream. KVM can read all guest state (memory and registers) for !SEV guests, i.e. can fetch the code stream from memory even if the CPU failed to do so because of the SMAP errata. Fixes: 05d5a4863525 ("KVM: SVM: Workaround errata#1096 (insn_len maybe zero on SMAP violation)") Cc: stable@vger.kernel.org Cc: Tom Lendacky Cc: Brijesh Singh Signed-off-by: Sean Christopherson Reviewed-by: Liam Merwick Message-Id: <20220120010719.711476-2-seanjc@google.com> Signed-off-by: Paolo Bonzini [jwang: adjust context for kernel 5.10.101] Signed-off-by: Jack Wang Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/svm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4103,6 +4103,10 @@ static bool svm_can_emulate_instruction( bool smep, smap, is_user; unsigned long cr4; + /* Emulation is always possible when KVM has access to all guest state. */ + if (!sev_guest(vcpu->kvm)) + return true; + /* * Detect and workaround Errata 1096 Fam_17h_00_0Fh. * @@ -4151,9 +4155,6 @@ static bool svm_can_emulate_instruction( smap = cr4 & X86_CR4_SMAP; is_user = svm_get_cpl(vcpu) == 3; if (smap && (!smep || is_user)) { - if (!sev_guest(vcpu->kvm)) - return true; - pr_err_ratelimited("KVM: SEV Guest triggered AMD Erratum 1096\n"); /*