Message ID | 20231202093601.15931-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 r17csp1679601vqy; Sat, 2 Dec 2023 02:05:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0pVh7rSXAfITwwZ0ZLxN9tJR99viAEv3ml1S+stRUuPV7Wj0upscFVsJfZ4AE/8jEUGMt X-Received: by 2002:a05:6808:1454:b0:3b8:b063:6b94 with SMTP id x20-20020a056808145400b003b8b0636b94mr1229990oiv.67.1701511554071; Sat, 02 Dec 2023 02:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701511554; cv=none; d=google.com; s=arc-20160816; b=v2aQIoxxXLluoqGE2DKUSUWguTKL/HICGD0+u44tEy5dn+PBNjKKAoO8GRlOB+1AuT 6FACIxSEj6jT2M9d3ogEuqUlHgHym9/J46Co3ELwGjC68EtXiZT00pMdaVIXui5alM/e cZO5y9uaPSI7GAuDqQnCahUO5BNigYbBNWMvP++fj8kTyVJFQgVaQ7++GGKssJ7ZcFgb 9BEvnahkIXccZRX16GvkAfr+QO6sUc8VOIshZgvqO0ARsLXyiPyIuwDVFd3uRwOvHj8l FSg4ea63+Uh7AIQGF0sr6JaLpLgwErzkDt32fTchuesAyE7ry0pDJsb2mnL+ehQmuzO5 HXZg== 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=WtB/6bZttJJ3twfHs8vNqpuK18Ax3g3+mKkSGNxAN/8=; fh=+WI4m5k3dRLR+dR3neThuZkNBTzIm/a8HgtddERL9fA=; b=tPWO9sFFPZJl7Qn3lDByfT7AlZyf1CdPNfOxyY5n09rI8glsGpuNEQTukHPpvfrlmP PzruMPOTRd5TORh30GcTA2GKzfqPedP38hUpqLII4KKn987XREKcbf3umZxpiIW0POX3 uZOhNQkgk186Upw35NNvnZQXss1P3kwVnIaB5VxupVXmL648CVb8wHZJZ/ZNB48GdXof pYG7egH+ppDhDz+Ed1ec5KZwKB+sB2vR1Lq4l0icPSGufr1JUc/WjrA0uJ7vUYHikK09 oFc/6pGFGYVpBpbKMDWs4t4046NGIyFfYg2jqkwQNzU1z8p0aHKtP3Fe+FMpDHM439Fd F54w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=oIzpXtFm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id y15-20020aa793cf000000b006cbfbb64e00si4653362pff.138.2023.12.02.02.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 02:05:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=oIzpXtFm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 5215480843C9; Sat, 2 Dec 2023 02:05:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232576AbjLBKE4 (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Sat, 2 Dec 2023 05:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232527AbjLBKEz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 2 Dec 2023 05:04:55 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 507AB197; Sat, 2 Dec 2023 02:05:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701511501; x=1733047501; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=salWrsDL9dpOvmr91p0gKRVzj1lK++JFGh51YeQPB6Q=; b=oIzpXtFmjMjZ3HkDSzsUvWt8FnfccUhdTn+CskBij29VX6Pa2Cdt+7XY sXFVClfmOJGKMiHUAKtJCuWs3M1Tp3NHMBrSYNanNEqhAbMzDrebyCwPU MSNJlY9i7tGr1IJ6DjJ+9/HYNHCYvKHAx+hUYiH4ZJzCaQtIsCZ1diHMy 8+aKynWhtMI3dO2AAC7Hn2hZgnbI9xatq8N2HvPmdZ1B3mQLRKnsO4IEH +sMC1c8TvLqj22F7DUNOIBoOmnlSSqK9cduzkVIyCE2X7hXwYwWwSEFLD 0mdc3DQgWhDNVUJvhwiKqmMnE8J2jg9rYpdGbfF8nQLNqDRDPvz4DORJC Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="457913864" X-IronPort-AV: E=Sophos;i="6.04,245,1695711600"; d="scan'208";a="457913864" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2023 02:05:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="840461606" X-IronPort-AV: E=Sophos;i="6.04,245,1695711600"; d="scan'208";a="840461606" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2023 02:04:57 -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 40/42] KVM: VMX: Compose VMX specific meta data for KVM exported TDP Date: Sat, 2 Dec 2023 17:36:01 +0800 Message-Id: <20231202093601.15931-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 morse.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 (morse.vger.email [0.0.0.0]); Sat, 02 Dec 2023 02:05:05 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784164178962034253 X-GMAIL-MSGID: 1784164178962034253 |
Series |
Sharing KVM TDP to IOMMU
|
|
Commit Message
Yan Zhao
Dec. 2, 2023, 9:36 a.m. UTC
Compose VMX specific meta data of KVM exported TDP. The format of the meta
data is defined in "asm/kvm_exported_tdp.h".
Intel VT-d driver can include "asm/kvm_exported_tdp.h" to decode this meta
data in order to check page table format, level, reserved zero bits before
loading KVM page tables with root HPA.
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
---
arch/x86/kvm/vmx/vmx.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index f290dd3094da6..7965bc32f87de 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -48,6 +48,7 @@ #include <asm/mwait.h> #include <asm/spec-ctrl.h> #include <asm/vmx.h> +#include <asm/kvm_exported_tdp.h> #include "capabilities.h" #include "cpuid.h" @@ -8216,6 +8217,22 @@ static void vmx_vm_destroy(struct kvm *kvm) free_pages((unsigned long)kvm_vmx->pid_table, vmx_get_pid_table_order(kvm)); } +#ifdef CONFIG_KVM_INTEL_EXPORTED_EPT +void kvm_exported_tdp_compose_meta(struct kvm_exported_tdp *tdp) +{ + struct kvm_exported_tdp_meta_vmx *meta = tdp->arch.meta; + struct kvm_mmu_common *context = &tdp->arch.mmu.common; + void *rsvd_bits_mask = context->shadow_zero_check.rsvd_bits_mask; + + meta->root_hpa = context->root.hpa; + meta->level = context->root_role.level; + meta->max_huge_page_level = min(ept_caps_to_lpage_level(vmx_capability.ept), + KVM_MAX_HUGEPAGE_LEVEL); + memcpy(meta->rsvd_bits_mask, rsvd_bits_mask, sizeof(meta->rsvd_bits_mask)); + meta->type = KVM_TDP_TYPE_EPT; +} +#endif + static struct kvm_x86_ops vmx_x86_ops __initdata = { .name = KBUILD_MODNAME, @@ -8357,6 +8374,11 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = { .complete_emulated_msr = kvm_complete_insn_gp, .vcpu_deliver_sipi_vector = kvm_vcpu_deliver_sipi_vector, + +#ifdef CONFIG_KVM_INTEL_EXPORTED_EPT + .exported_tdp_meta_size = sizeof(struct kvm_exported_tdp_meta_vmx), + .exported_tdp_meta_compose = kvm_exported_tdp_compose_meta, +#endif }; static unsigned int vmx_handle_intel_pt_intr(void)