Message ID | 20231202093633.15991-1-yan.y.zhao@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1679675vqy; Sat, 2 Dec 2023 02:06:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmraEPE7yxaQ1LC6jW9hW/oEW5+8dmKLQ4uDTugr2esmKo9i4e1LTBScXSjN/0xqMUyM/6 X-Received: by 2002:a05:6a20:1587:b0:187:60da:4767 with SMTP id h7-20020a056a20158700b0018760da4767mr1307935pzj.25.1701511565786; Sat, 02 Dec 2023 02:06:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701511565; cv=none; d=google.com; s=arc-20160816; b=lU32eJm3bxM6GD/dwFZDQ8eqggb2zveG98exI/6pnRuExW4NFl6aJhtYC7xo79kimm hzeX1MsKYxp/ZiMDBME1qyjsyhILROQQm8wCM9TUkdfeDqVUq00aVbUtG+5Rt9OvAIX2 mgRbTD64VqvHEEOhyD1p1ZFYqMUuEU5OuoWLUaRgdJAVReh8cN9LaWdy9cL5jP7UAS2t 4wtohrcPcoLRoGA6fZt/3SCtkrnVdAICwWQExKMN/z9d+uAhPCCsFoJ1ejNMDtSICNei B6H2OueDxKF3j8qpe4Tk8LGremoGWu2YR474NxW5w7ORhpamvFAA4Zcn+Phjs2uOJjAN jx4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=lhtG9Ru0U468LtOYpaTjmLxpWzKBOTuw5au/7QqLX+s=; fh=+WI4m5k3dRLR+dR3neThuZkNBTzIm/a8HgtddERL9fA=; b=DJHLCBE3KQK//sa0/mSEHL1jL3fcsAmGa+aaHDBSxXtJL4n+ddGNb704fusDDqMCx2 QdQp/gloivf2V2GbzsVlHoRiS1Q2KS7QEITdQHmD7h7V4+SNpd4KY3dZIl+Iz6Rgq5j2 3WR7QRSAC7Fw87z0aQafk97kINFwsH+rowie6Rx3XSE2/k5JDl935FOa0BAgZpav5Tue BRXdVA0KD+5S7phaZZXqhuLs1NRGuPyvBSN3mDqf+O9wAi+FAzvUf8a+/RDmYtmam4pP Bfkz4iOt/N7mjkBnbJ07RjOVUTnR4NovMpzMynvN5vG6I2N8Zqtjp3keb6y32/NwDXhx IYJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KceNHWxV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id r6-20020a632b06000000b005c65defc400si867615pgr.624.2023.12.02.02.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 02:06:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KceNHWxV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1F85F80789F7; Sat, 2 Dec 2023 02:05:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232603AbjLBKF0 (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Sat, 2 Dec 2023 05:05:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232527AbjLBKFZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 2 Dec 2023 05:05:25 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E366B1A6; Sat, 2 Dec 2023 02:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701511531; x=1733047531; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=2TvSYcYyRxZJXd7jYUAEf7Q9pF2z8JkVIapNJrcQxZk=; b=KceNHWxVMoHHTCmvnwDci7v4XGhRA6PCaY/ADkAwT9wtdPMJuhU39Z95 lNJ5WhQo/wnsCjMXGFEtTODwDNVqzp9y1mUfL8dRoVhX4WCCqcQvtvaTk 4+3CCJHY3NTVG8LQiWyKwqMf1MIzguE8PFYHFVl+EFKwDwbYyLpfCm6Hg 5tiZDzi4uOg9vfXeHZispiHtTJHqZ26+4nIzECS3tCMCqJuzCWtS+SaHk khXqUGefse4Nz4Tk7ZRAlBNHgCrZYzDzsK7jtC6kKOKe7JGac1QSwK5mK qbEAKQNj5TDE4m0oIEe+vBaUlu2T/D/LTYsQ4EXVAO3p0pTaTtwDr/lmN Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="392459741" X-IronPort-AV: E=Sophos;i="6.04,245,1695711600"; d="scan'208";a="392459741" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2023 02:05:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="887939973" X-IronPort-AV: E=Sophos;i="6.04,245,1695711600"; d="scan'208";a="887939973" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2023 02:05:28 -0800 From: Yan Zhao <yan.y.zhao@intel.com> To: iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alex.williamson@redhat.com, jgg@nvidia.com, pbonzini@redhat.com, seanjc@google.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, kevin.tian@intel.com, baolu.lu@linux.intel.com, dwmw2@infradead.org, yi.l.liu@intel.com, Yan Zhao <yan.y.zhao@intel.com> Subject: [RFC PATCH 41/42] KVM: VMX: Implement ops .flush_remote_tlbs* in VMX when EPT is on Date: Sat, 2 Dec 2023 17:36:33 +0800 Message-Id: <20231202093633.15991-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231202091211.13376-1-yan.y.zhao@intel.com> References: <20231202091211.13376-1-yan.y.zhao@intel.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Sat, 02 Dec 2023 02:05:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784164191452448849 X-GMAIL-MSGID: 1784164191452448849 |
Series |
Sharing KVM TDP to IOMMU
|
|
Commit Message
Yan Zhao
Dec. 2, 2023, 9:36 a.m. UTC
Add VMX implementation of ops of flush_remote_tlbs* in kvm_x86_ops when
enable_ept is on and CONFIG_HYPERV is off.
Without ops flush_remote_tlbs* in VMX, kvm_flush_remote_tlbs*() just makes
all cpus request KVM_REQ_TLB_FLUSH after finding the two ops are
non-present.
So, by also making all cpu requests KVM_REQ_TLB_FLUSH in ops
flush_remote_tlbs* in VMX, no functional changes should be introduced.
The two ops allow vendor code (e.g. VMX) to control when to notify IOMMU
to flush TLBs. This is useful for contidions when sequence to flush CPU
TLBs and IOTLBs is important.
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
---
arch/x86/kvm/vmx/vmx.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 7965bc32f87de..2fec351a3fa5b 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7544,6 +7544,17 @@ static int vmx_vcpu_create(struct kvm_vcpu *vcpu) return err; } +static int vmx_flush_remote_tlbs_range(struct kvm *kvm, gfn_t gfn, gfn_t nr_pages) +{ + kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH); + return 0; +} + +static int vmx_flush_remote_tlbs(struct kvm *kvm) +{ + return vmx_flush_remote_tlbs_range(kvm, 0, -1ULL); +} + #define L1TF_MSG_SMT "L1TF CPU bug present and SMT on, data leak possible. See CVE-2018-3646 and https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/l1tf.html for details.\n" #define L1TF_MSG_L1D "L1TF CPU bug present and virtualization mitigation disabled, data leak possible. See CVE-2018-3646 and https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/l1tf.html for details.\n" @@ -8528,6 +8539,11 @@ static __init int hardware_setup(void) vmx_x86_ops.flush_remote_tlbs = hv_flush_remote_tlbs; vmx_x86_ops.flush_remote_tlbs_range = hv_flush_remote_tlbs_range; } +#else + if (enable_ept) { + vmx_x86_ops.flush_remote_tlbs = vmx_flush_remote_tlbs; + vmx_x86_ops.flush_remote_tlbs_range = vmx_flush_remote_tlbs_range; + } #endif if (!cpu_has_vmx_ple()) {