Message ID | 20230928150428.199929-3-mlevitsk@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3383100vqu; Thu, 28 Sep 2023 08:09:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdRz/EWO9/dGo2q+ta8seKff1sojmqnPlC30k0dVBUP+/ngtMtx3Dh5XhCaa1hu48oFJGN X-Received: by 2002:a17:902:7046:b0:1c3:ed30:cdf4 with SMTP id h6-20020a170902704600b001c3ed30cdf4mr1235916plt.4.1695913797097; Thu, 28 Sep 2023 08:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695913797; cv=none; d=google.com; s=arc-20160816; b=jTbspog8L/nfaCdm0dW9MJU2yau5JpjJwGhAWGahE5/8rKqXjTPoj4iWE7cfIu86Zd UHuFqiTcVwtcTfzkY1S5B2HPcukJp7sTfv7PoKJP9oa5ieSnq7zPPoiXd5rj+wlCuo21 vIB/sbxpZqjNQrn7eMNQqDQ+AkV90j1zrB1Sc/DjoTAvXRyrkxHb5mUo5Afjsn6J6tZk aCsUgurgxncH0hHuqzOcFmYaun2xfHJNpDUoAl4hZDnDvnWd5ni+zn8A+Yy1WZZSSzde o3C5qGTnsIWdlo0/0ME6gNlEVs4J11gxJB0aoTnhjUGaicQzlhqozwKR8D6DQLCirA00 ZnHA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/zSW4L47PrK+7DJbUcadmA8oL8chw/9RJFYn/fvmJlQ=; fh=k8YxIaPvIPXsZjGxhmoFEFw2FthFvsrwXSIogQNrxiI=; b=Y8/8FjZ4LRIHZiraAyuBz48VRTdp984vSFy/j4iWxhCp1TEfgiof3XSPSx4vVSRbws 2Tk3vrjD4JWjjKN4pO/wqkSIniolJXtvC+9OMyPifPtgWGSFCcMHYlkuI7aAkU+xGv2k OLXv8gasrLWIZB9nPqBaMJRFLKpwt/opte48SUgqbO+JZcjYLLGbZ326kPVFneFAkRoS iSQIZblgDfCSJ2IIecmQJo1OmnkLGCi0rK2EHNgLsIEyjPFqQakaBFevPkWmDASKDAco pGdTY8FlRfEGmeHoatw+99GgszS7eOdxNg4WYmZflovs9P8byqkLDFXzwS36C7NO3F/B WkhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y35kKURB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m12-20020a170902db0c00b001c5f80bf574si15504131plx.487.2023.09.28.08.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 08:09:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y35kKURB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 05E88823D9F6; Thu, 28 Sep 2023 08:05:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231550AbjI1PFm (ORCPT <rfc822;pwkd43@gmail.com> + 21 others); Thu, 28 Sep 2023 11:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbjI1PFi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 28 Sep 2023 11:05:38 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5173F1A3 for <linux-kernel@vger.kernel.org>; Thu, 28 Sep 2023 08:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695913489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/zSW4L47PrK+7DJbUcadmA8oL8chw/9RJFYn/fvmJlQ=; b=Y35kKURBpMmvCUw+8sti1NrL94VIZ79XRgwzwhNLXrc9pwinAILrgzldGX51A20nqS6CwU iC3EdPVBWxfYvQSGQfkZ7iEiTCqIug57OjcPDJXByZkZ9VWc7nGkurV9LU0idNcnXIdCjw is9Rpvm+Dup8nme8Q4l93bT4yQv3V8s= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-UUxYy2WWNlqjcdm6QvOhzQ-1; Thu, 28 Sep 2023 11:04:42 -0400 X-MC-Unique: UUxYy2WWNlqjcdm6QvOhzQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 187D438145AB; Thu, 28 Sep 2023 15:04:41 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1A0540C6E76; Thu, 28 Sep 2023 15:04:36 +0000 (UTC) From: Maxim Levitsky <mlevitsk@redhat.com> To: kvm@vger.kernel.org Cc: Will Deacon <will@kernel.org>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>, Thomas Gleixner <tglx@linutronix.de>, Paolo Bonzini <pbonzini@redhat.com>, x86@kernel.org, Robin Murphy <robin.murphy@arm.com>, iommu@lists.linux.dev, Ingo Molnar <mingo@redhat.com>, Joerg Roedel <joro@8bytes.org>, Sean Christopherson <seanjc@google.com>, "H. Peter Anvin" <hpa@zytor.com>, linux-kernel@vger.kernel.org, Maxim Levitsky <mlevitsk@redhat.com>, stable@vger.kernel.org Subject: [PATCH 2/5] x86: KVM: SVM: add support for Invalid IPI Vector interception Date: Thu, 28 Sep 2023 18:04:25 +0300 Message-Id: <20230928150428.199929-3-mlevitsk@redhat.com> In-Reply-To: <20230928150428.199929-1-mlevitsk@redhat.com> References: <20230928150428.199929-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 28 Sep 2023 08:05:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778294505597323268 X-GMAIL-MSGID: 1778294505597323268 |
Series |
AVIC bugfixes and workarounds
|
|
Commit Message
Maxim Levitsky
Sept. 28, 2023, 3:04 p.m. UTC
In later revisions of AMD's APM, there is a new 'incomplete IPI' exit code:
"Invalid IPI Vector - The vector for the specified IPI was set to an
illegal value (VEC < 16)"
Note that tests on Zen2 machine show that this VM exit doesn't happen and
instead AVIC just does nothing.
Add support for this exit code by doing nothing, instead of filling
the kernel log with errors.
Also replace an unthrottled 'pr_err()' if another unknown incomplete
IPI exit happens with WARN_ON_ONCE()
(e.g in case AMD adds yet another 'Invalid IPI' exit reason)
Cc: <stable@vger.kernel.org>
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
arch/x86/include/asm/svm.h | 1 +
arch/x86/kvm/svm/avic.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
Comments
On Thu, Sep 28, 2023, Maxim Levitsky wrote: > In later revisions of AMD's APM, there is a new 'incomplete IPI' exit code: > > "Invalid IPI Vector - The vector for the specified IPI was set to an > illegal value (VEC < 16)" > > Note that tests on Zen2 machine show that this VM exit doesn't happen and > instead AVIC just does nothing. > > Add support for this exit code by doing nothing, instead of filling > the kernel log with errors. > > Also replace an unthrottled 'pr_err()' if another unknown incomplete > IPI exit happens with WARN_ON_ONCE() > > (e.g in case AMD adds yet another 'Invalid IPI' exit reason) > > Cc: <stable@vger.kernel.org> > > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> > --- > arch/x86/include/asm/svm.h | 1 + > arch/x86/kvm/svm/avic.c | 5 ++++- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h > index 19bf955b67e0da0..3ac0ffc4f3e202b 100644 > --- a/arch/x86/include/asm/svm.h > +++ b/arch/x86/include/asm/svm.h > @@ -268,6 +268,7 @@ enum avic_ipi_failure_cause { > AVIC_IPI_FAILURE_TARGET_NOT_RUNNING, > AVIC_IPI_FAILURE_INVALID_TARGET, > AVIC_IPI_FAILURE_INVALID_BACKING_PAGE, > + AVIC_IPI_FAILURE_INVALID_IPI_VECTOR, > }; > > #define AVIC_PHYSICAL_MAX_INDEX_MASK GENMASK_ULL(8, 0) > diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c > index 2092db892d7d052..c44b65af494e3ff 100644 > --- a/arch/x86/kvm/svm/avic.c > +++ b/arch/x86/kvm/svm/avic.c > @@ -529,8 +529,11 @@ int avic_incomplete_ipi_interception(struct kvm_vcpu *vcpu) > case AVIC_IPI_FAILURE_INVALID_BACKING_PAGE: > WARN_ONCE(1, "Invalid backing page\n"); > break; > + case AVIC_IPI_FAILURE_INVALID_IPI_VECTOR: > + /* Invalid IPI with vector < 16 */ > + break; > default: > - pr_err("Unknown IPI interception\n"); > + WARN_ONCE(1, "Unknown avic incomplete IPI interception\n"); Hrm, I'm not sure KVM should WARN here. E.g. if someone runs with panic_on_warn=1, running on new hardware might crash the host. I hope that AMD is smart enough to make any future failure types "optional" in the sense that they're either opt-in, or are largely informational-only (like AVIC_IPI_FAILURE_INVALID_IPI_VECTOR). I think switching to vcpu_unimpl(), or maybe even pr_err_once(), is more appropriate.
diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 19bf955b67e0da0..3ac0ffc4f3e202b 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -268,6 +268,7 @@ enum avic_ipi_failure_cause { AVIC_IPI_FAILURE_TARGET_NOT_RUNNING, AVIC_IPI_FAILURE_INVALID_TARGET, AVIC_IPI_FAILURE_INVALID_BACKING_PAGE, + AVIC_IPI_FAILURE_INVALID_IPI_VECTOR, }; #define AVIC_PHYSICAL_MAX_INDEX_MASK GENMASK_ULL(8, 0) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index 2092db892d7d052..c44b65af494e3ff 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -529,8 +529,11 @@ int avic_incomplete_ipi_interception(struct kvm_vcpu *vcpu) case AVIC_IPI_FAILURE_INVALID_BACKING_PAGE: WARN_ONCE(1, "Invalid backing page\n"); break; + case AVIC_IPI_FAILURE_INVALID_IPI_VECTOR: + /* Invalid IPI with vector < 16 */ + break; default: - pr_err("Unknown IPI interception\n"); + WARN_ONCE(1, "Unknown avic incomplete IPI interception\n"); } return 1;