Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp915460pxb; Wed, 3 Mar 2021 20:55:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzk8qkgA9R4uTzQRGQGQpMs4boc524cMu6pGj27ZzqS6yzT+CdidrFUNqHTysgfj3nHOkfA X-Received: by 2002:a05:6402:100b:: with SMTP id c11mr2335933edu.193.1614833730465; Wed, 03 Mar 2021 20:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614833730; cv=none; d=google.com; s=arc-20160816; b=mJB0V2MXPBuR+qwSURd6SC8PLrLyrINeDLHSl6eiWAmLwkaiwRst6CgEDvdoxUg6r/ 7y8FnlAizvUdwZip1aTC6/J8fbeIbIF+K6iBT0umPWq2IqKB9dtQ+UFD61Fh6WpUyLXa gz9MlnXtYdI+A7ZyLfQvkGk5/zPepzt1D/4RlyRL3MFrIZMIXY2MFLEiT3t8IysCixWP ctaWQNbPWoYDp2JogtYr9aVwYzBv/tA6cfeW3J3DWzkcQc0KNDLKJ8Ltb41oDEpii3B+ yjKjkh0+aqo42Q5SOxTnXPoxMnMgopErC9DN+/Ucop3W7WUnQjBCnUKe2ih8xh89xHHP JgPg== 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=AYwWK/ztQuFRAE2gBn+ArNcg+RrCLNYTU6LEx/Cakyo=; b=dViNcaxj8nSLwnqoddJP5Vpb8Tjly1JdMwya4oBBgPcIqEiy8SyS7Wvi/ko47Ya/kC W3URW6BhN1a64ZAnUpLsi6QRhaveyvK4fM+rCnRpd8Ap+3Ja0dKVJHqH101YHmwbF/cC wRqLrfqUDxJs28FGavU5AoU0fbi9fwjkgXicFAgzxbD1pZ/pRs1s15y16A94ZcsVtt9F 5ZBSIIvolTNwGzDFjGEH2qImClOI9LSCNYWU8i7mI3+zGG4FV9zJGbHwNw3FB/MEuF82 hiAdqT7EtN+q6WpCjl/EYguPy9qQqfFq64oOB7z20gw5/udLQ9aJexwMlFxcjGpB3Nbt LA7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KMsoo9N7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si14588915edr.331.2021.03.03.20.55.08; Wed, 03 Mar 2021 20:55:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KMsoo9N7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442940AbhCBCRR (ORCPT + 99 others); Mon, 1 Mar 2021 21:17:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:55162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242271AbhCAToU (ORCPT ); Mon, 1 Mar 2021 14:44:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 700A465238; Mon, 1 Mar 2021 17:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619549; bh=ub7hz0E+xEEE+/wRhthdhsTYdvKkVv6V5OhBMQYaaeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMsoo9N7zoMWuZQV1e0YPFXcibcjw/hOtvVfYg3Sp7GmgwPGbSzev2xLoC0cOP1ee SGnSoKJkWv0lZfbEzhCEKZ+uVdFfkQNiksIF6+QASNqVrftOQd2g98fxFlvKxbJQLz plriUZ2OGuwvA4Ro3UAA5lcThFvjWP9GRqA9AqIc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Babu Moger , Sean Christopherson , Jim Mattson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 464/663] KVM: SVM: Intercept INVPCID when its disabled to inject #UD Date: Mon, 1 Mar 2021 17:11:52 +0100 Message-Id: <20210301161204.818021439@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit 0a8ed2eaac102c746d8d114f2787f06cb3e55dfb ] Intercept INVPCID if it's disabled in the guest, even when using NPT, as KVM needs to inject #UD in this case. Fixes: 4407a797e941 ("KVM: SVM: Enable INVPCID feature on AMD") Cc: Babu Moger Signed-off-by: Sean Christopherson Message-Id: <20210212003411.1102677-2-seanjc@google.com> Reviewed-by: Jim Mattson Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/svm/svm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index f4ae3871e412a..76ab1ee0784ae 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1092,12 +1092,12 @@ static u64 svm_write_l1_tsc_offset(struct kvm_vcpu *vcpu, u64 offset) static void svm_check_invpcid(struct vcpu_svm *svm) { /* - * Intercept INVPCID instruction only if shadow page table is - * enabled. Interception is not required with nested page table - * enabled. + * Intercept INVPCID if shadow paging is enabled to sync/free shadow + * roots, or if INVPCID is disabled in the guest to inject #UD. */ if (kvm_cpu_cap_has(X86_FEATURE_INVPCID)) { - if (!npt_enabled) + if (!npt_enabled || + !guest_cpuid_has(&svm->vcpu, X86_FEATURE_INVPCID)) svm_set_intercept(svm, INTERCEPT_INVPCID); else svm_clr_intercept(svm, INTERCEPT_INVPCID); -- 2.27.0