Message ID | 20231018194104.1896415-3-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp5026176vqb; Wed, 18 Oct 2023 12:41:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwujxi+AjSYjHSStIwbViw/rF7gR4CwdE0qaE321mie3kT1xblJAAozV0NRvgSZ4ATKZTe X-Received: by 2002:a17:903:1c4:b0:1bb:994c:bc43 with SMTP id e4-20020a17090301c400b001bb994cbc43mr360704plh.18.1697658117339; Wed, 18 Oct 2023 12:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697658117; cv=none; d=google.com; s=arc-20160816; b=Wp3S5qfeenholi+KO35eGRgj0Ww1l3xpRcDjgTFVLFU4YCz7QBNDecT8VYMTRh7lTe rCRW/CDPomHFkTHY30A4wl85ksSfMA20N1ohb0yitlzIGl7I5foQ/WoFCiffCD9DbkRB Qp/M229+p5o9DeDpDHll/HtrRiHE4Vrrvldf03xMyHVlebKW8HZPPUq3u0Pk0kn+PENC 2igg/R2CzGF4Dy7DB4x2MoITX7WIh+x+AHw0Hh2hAJLVn79tTUyyeqeml74lVY7rVZTN zIuR8+jQ5B2dGikxDs3HaWyar2r6Ei0UBDaaMpADvC60k5tgeUyVI6STuR7Po5q/p4gA xjrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=Ofuuq8OnXnBwuNBiWtVLb1NEzqrH7XwtOSMnrh73sd8=; fh=Nq0oepwhCxvN5xgp/oTsTcwmzxolMYHrK7DBemx3XjM=; b=YXSLHTXd6PZ/r1Nh/nafXHRGcD1jiCSzdNJ2aRK+RA7S4qxl072VAMB8uxul0IRNK5 O+CxHWm/Fm8dvnG0DT94gQ/d3N9p5cam7lAsIAE7tMW1CbS5w2pk9mQCkq3RmxLYycPG TgfCouS6b41hyi1ldXQIxubRHXQmZ/CBXQv3GUMdJS7qYRPp3X9q0l4nqqmFWkK+BItW L62VGEBrj+uo2Mba/67Do5IlqeHvTbqZaVcxLXSQOvzl0d7maXenQyN3xOyeffHV0BJd b2+qnOFOwfwHkIWycbDz1Jmnx60L5muK6OFT3PIVuYsM3hooknW4RFpZhHt0WHkR0Jow TBuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KQUyfewp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id z7-20020a1709028f8700b001c0eefc0dfesi526774plo.130.2023.10.18.12.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 12:41:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KQUyfewp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 50C898244E64; Wed, 18 Oct 2023 12:41:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbjJRTlR (ORCPT <rfc822;zwp10758@gmail.com> + 24 others); Wed, 18 Oct 2023 15:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231621AbjJRTlN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 18 Oct 2023 15:41:13 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF19B95 for <linux-kernel@vger.kernel.org>; Wed, 18 Oct 2023 12:41:11 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a81a80097fso96092987b3.3 for <linux-kernel@vger.kernel.org>; Wed, 18 Oct 2023 12:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697658071; x=1698262871; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=Ofuuq8OnXnBwuNBiWtVLb1NEzqrH7XwtOSMnrh73sd8=; b=KQUyfewpiZDgHKhuBlxHffQ0dmFuq14bplh/X97tRzsZ1J4IVFw9LgSRusq4uePP7p I2fWrJB20gGOcn5OK3sPVx1Cws82eApx0yayMcRBTHMuag8ieLn/2rpiqGl3vYU4HPMP plDRDLUy8748Fghanx4KRrDiuZHDMRky8F4wOa8TUtlosUPPrnt8TW2Km2mHMOe1rfJT aNFAX76iUsrGF5vygVrg4yh/zpC/grDHqg9iEFeZfNT7U1Y0o/YXZDFBZvUTTCpBtV2t ZuO/MR0PUS/H22Pu5+Tp47+t0h+q8nJwrIqvaJ1iEY8W14kWB6immkZlwC+AABSEmehm PINg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697658071; x=1698262871; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ofuuq8OnXnBwuNBiWtVLb1NEzqrH7XwtOSMnrh73sd8=; b=YheTq6Hs+gORztHMIZLrnMW8TX763146xm+ac8jhjLLSbVeWh1vn5nZRuYlt9eokZx 8GtpTviwlALLQKoJ2xcmQjKbRJeitqvsRM7ueAc6rZr7jJ5YkhzuUz6xXivTR0e/LK7E aOjszPynv6eUrgG0pwWQaUBit0jITugfgLV4abI3Fbbnrstx9wmWGnmACxWrlCnGbqBk vVBTRHXdCV8Wdavk2JAHW8nVt/dTcXWZLDMSCNqFk5OPmw60fbrLlRmQAbFLzeYrnQwV Qe3FezSoyA8O7KV4HWXWahXTjCkqqaxLPOw4Kp5F5IoNq0NoiRbyNNwYJ8dj1y3WDtdm xu0A== X-Gm-Message-State: AOJu0YxCMKXIyG2tXBvna2XsShNIkoEFRiuCAMl9zdVoutVJdpWINAZn d+1hYSmwVnj5222JpCT3c6dzfKJ12EA= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1825:b0:d9a:d272:ee58 with SMTP id cf37-20020a056902182500b00d9ad272ee58mr7884ybb.9.1697658071068; Wed, 18 Oct 2023 12:41:11 -0700 (PDT) Reply-To: Sean Christopherson <seanjc@google.com> Date: Wed, 18 Oct 2023 12:41:04 -0700 In-Reply-To: <20231018194104.1896415-1-seanjc@google.com> Mime-Version: 1.0 References: <20231018194104.1896415-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog Message-ID: <20231018194104.1896415-3-seanjc@google.com> Subject: [PATCH 2/2] KVM: nSVM: Advertise support for flush-by-ASID From: Sean Christopherson <seanjc@google.com> To: Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Sterz <s.sterz@proxmox.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 12:41:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780123558176526767 X-GMAIL-MSGID: 1780123558176526767 |
Series |
KVM: nSVM: TLB_CONTROL / FLUSHBYASID "fixes"
|
|
Commit Message
Sean Christopherson
Oct. 18, 2023, 7:41 p.m. UTC
Advertise support for FLUSHBYASID when nested SVM is enabled, as KVM can
always emulate flushing TLB entries for a vmcb12 ASID, e.g. by running L2
with a new, fresh ASID in vmcb02. Some modern hypervisors, e.g. VMWare
Workstation 17, require FLUSHBYASID support and will refuse to run if it's
not present.
Punt on proper support, as "Honor L1's request to flush an ASID on nested
VMRUN" is one of the TODO items in the (incomplete) list of issues that
need to be addressed in order for KVM to NOT do a full TLB flush on every
nested SVM transition (see nested_svm_transition_tlb_flush()).
Reported-by: Stefan Sterz <s.sterz@proxmox.com>
Closes: https://lkml.kernel.org/r/b9915c9c-4cf6-051a-2d91-44cc6380f455%40proxmox.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/svm.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Wed, 2023-10-18 at 12:41 -0700, Sean Christopherson wrote: > Advertise support for FLUSHBYASID when nested SVM is enabled, as KVM can > always emulate flushing TLB entries for a vmcb12 ASID, e.g. by running L2 > with a new, fresh ASID in vmcb02. Some modern hypervisors, e.g. VMWare > Workstation 17, require FLUSHBYASID support and will refuse to run if it's > not present. > > Punt on proper support, as "Honor L1's request to flush an ASID on nested > VMRUN" is one of the TODO items in the (incomplete) list of issues that > need to be addressed in order for KVM to NOT do a full TLB flush on every > nested SVM transition (see nested_svm_transition_tlb_flush()). > > Reported-by: Stefan Sterz <s.sterz@proxmox.com> > Closes: https://lkml.kernel.org/r/b9915c9c-4cf6-051a-2d91-44cc6380f455%40proxmox.com > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > arch/x86/kvm/svm/svm.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index 1785de7dc98b..9cf7eef161ff 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -5083,6 +5083,7 @@ static __init void svm_set_cpu_caps(void) > if (nested) { > kvm_cpu_cap_set(X86_FEATURE_SVM); > kvm_cpu_cap_set(X86_FEATURE_VMCBCLEAN); > + kvm_cpu_cap_set(X86_FEATURE_FLUSHBYASID); > > if (nrips) > kvm_cpu_cap_set(X86_FEATURE_NRIPS); Nitpick: if you think that this is worth it, maybe we can add a comment here on why we can 'support' the flushbyasid feature? in addition to the commit message. Other than that: Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Best regards, Maxim Levitsky
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 1785de7dc98b..9cf7eef161ff 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -5083,6 +5083,7 @@ static __init void svm_set_cpu_caps(void) if (nested) { kvm_cpu_cap_set(X86_FEATURE_SVM); kvm_cpu_cap_set(X86_FEATURE_VMCBCLEAN); + kvm_cpu_cap_set(X86_FEATURE_FLUSHBYASID); if (nrips) kvm_cpu_cap_set(X86_FEATURE_NRIPS);