From patchwork Fri Jan 5 09:13:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 13511888 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DC36C3DA6E for ; Fri, 5 Jan 2024 09:43:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 783D210E596; Fri, 5 Jan 2024 09:43:11 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id BFE2210E596 for ; Fri, 5 Jan 2024 09:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704447790; x=1735983790; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=yLRKvEWofDO1K6stvr9i2IomNOvR/08Zs5+c4O/ibFk=; b=ZoIf+xOCUja/+xF6xyOHlmjoliHWOoFCtn9VtwXxc1nrttUKQz7wnTKt ePIytw3QiiMdUiiu6YH3SeX4krUlFxmjnwEyLwJXMZbCYgwFJcgR+eRdX FlMVlwqictEQ8be4FDr/FQE9+XGB5BwSTMPk+Nygqcx6Vk+6E1FOoqRcK aHcqxXPRM9bmjK/ef7HhTRYYpvnS3m5kVxKJp6jZneecv1mUHl59JEwE7 TP9cPzq0E0y6tYSoHkU6X2wP0VSD7jHcDDGbcv6aakpHGNxZl8TqGAPvC C47RzxDfIPf6dOxgV84xnwlXaljEd/QEc3pp39FHhXJQqnSYQ8LvWTI95 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="401260559" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="401260559" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 01:43:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="814920081" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="814920081" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 01:43:03 -0800 From: Yan Zhao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 1/4] KVM: Introduce a new memslot flag KVM_MEM_NON_COHERENT_DMA Date: Fri, 5 Jan 2024 17:13:46 +0800 Message-Id: <20240105091346.24637-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240105091237.24577-1-yan.y.zhao@intel.com> References: <20240105091237.24577-1-yan.y.zhao@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wanpengli@tencent.com, gurchetansingh@chromium.org, kraxel@redhat.com, maz@kernel.org, joro@8bytes.org, zzyiwei@google.com, jgg@nvidia.com, yuzenghui@huawei.com, kevin.tian@intel.com, Yan Zhao , suzuki.poulose@arm.com, alex.williamson@redhat.com, yongwei.ma@intel.com, zhiyuan.lv@intel.com, jmattson@google.com, zhenyu.z.wang@intel.com, seanjc@google.com, ankita@nvidia.com, oliver.upton@linux.dev, james.morse@arm.com, pbonzini@redhat.com, vkuznets@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce a new flag KVM_MEM_NON_COHERENT_DMA to provide user space a channel to notify KVM that guest memory specified by the memslot may be accessed by noncoherent DMA devices. KVM can start honoring guest memory type for this range of guest memory in platforms that do not always honoring guest PAT, e.g. in Intel's platform. Previously, the only way to let KVM be aware of noncoherent DMA devices is through KVM device for VFIO pass-through devices, in which case, KVM is notified that all guest memory may be accessed by noncoherent DMA devices. To avoid complication, flag KVM_MEM_NON_COHERENT_DMA is not allowed to be dynamically modified for a memslot. A KVM_CAP_USER_CONFIGURE_NONCOHERENT_DMA is added to let user space know if this new memslot flag is supported in KVM. Cc: Kevin Tian Cc: Zhenyu Wang Tested-by: Yongwei Ma Signed-off-by: Yan Zhao --- include/uapi/linux/kvm.h | 2 ++ virt/kvm/kvm_main.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index b1f92a0edc35..4cb615e46488 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -46,6 +46,7 @@ struct kvm_userspace_memory_region2 { #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) #define KVM_MEM_READONLY (1UL << 1) #define KVM_MEM_GUEST_MEMFD (1UL << 2) +#define KVM_MEM_NON_COHERENT_DMA (1UL << 3) /* for KVM_IRQ_LINE */ struct kvm_irq_level { @@ -1155,6 +1156,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_MEMORY_ATTRIBUTES 233 #define KVM_CAP_GUEST_MEMFD 234 #define KVM_CAP_VM_TYPES 235 +#define KVM_CAP_USER_CONFIGURE_NONCOHERENT_DMA 236 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index acd67fb40183..6d44dcf7322d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1607,7 +1607,7 @@ static void kvm_replace_memslot(struct kvm *kvm, * only allows these. */ #define KVM_SET_USER_MEMORY_REGION_V1_FLAGS \ - (KVM_MEM_LOG_DIRTY_PAGES | KVM_MEM_READONLY) + (KVM_MEM_LOG_DIRTY_PAGES | KVM_MEM_READONLY | KVM_MEM_NON_COHERENT_DMA) static int check_memory_region_flags(struct kvm *kvm, const struct kvm_userspace_memory_region2 *mem) @@ -1625,6 +1625,8 @@ static int check_memory_region_flags(struct kvm *kvm, valid_flags |= KVM_MEM_READONLY; #endif + valid_flags |= KVM_MEM_NON_COHERENT_DMA; + if (mem->flags & ~valid_flags) return -EINVAL; @@ -2095,7 +2097,8 @@ int __kvm_set_memory_region(struct kvm *kvm, return -EINVAL; if ((mem->userspace_addr != old->userspace_addr) || (npages != old->npages) || - ((mem->flags ^ old->flags) & KVM_MEM_READONLY)) + ((mem->flags ^ old->flags) & + (KVM_MEM_READONLY | KVM_MEM_NON_COHERENT_DMA))) return -EINVAL; if (base_gfn != old->base_gfn) @@ -4822,6 +4825,7 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) case KVM_CAP_USER_MEMORY2: case KVM_CAP_DESTROY_MEMORY_REGION_WORKS: case KVM_CAP_JOIN_MEMORY_REGIONS_WORKS: + case KVM_CAP_USER_CONFIGURE_NONCOHERENT_DMA: case KVM_CAP_INTERNAL_ERROR_DATA: #ifdef CONFIG_HAVE_KVM_MSI case KVM_CAP_SIGNAL_MSI: From patchwork Fri Jan 5 09:14:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 13511893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D263C3DA6E for ; Fri, 5 Jan 2024 09:44:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5280810E59D; Fri, 5 Jan 2024 09:44:14 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FDF010E59A for ; Fri, 5 Jan 2024 09:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704447853; x=1735983853; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=TAQv9JJR1XqAj6tjxwKS30HsTbZYt1Z095C7qYz5bks=; b=caget8ThtgtR60suaad3e2GpN8BRU9d63KkVcHsOijYx6Qu+gpuzXCYu 4hXAzQE7IU1gSpDdBfEZPtyBKVTuVIneCSk1ZAyBq5mtWJVgkHGjGOts3 d3maIBvSGlJQeP49c6hFFUaIocWXyMCJ4jlEHZ1zhXMt3YmTEXBrM1Sgw /osU6BAmXH+FR4TDSY4pJE4qdvdnNj8k/KBP/kImqNrlj1fwzgAe/Pju7 Vd5jtRlISakHWGFIaZM7fql+/H6SBIqP63+gv9BMIqR074QROKtl5AqzY lXb9JNXrTzvMv/dyGcIAWe+owWPqqhFX0u+kISj8EvPOidrOw+5fk/lsj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="10842968" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="10842968" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 01:44:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="22458420" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 01:44:07 -0800 From: Yan Zhao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] KVM: x86: Add a new param "slot" to op get_mt_mask in kvm_x86_ops Date: Fri, 5 Jan 2024 17:14:54 +0800 Message-Id: <20240105091454.24700-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240105091237.24577-1-yan.y.zhao@intel.com> References: <20240105091237.24577-1-yan.y.zhao@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wanpengli@tencent.com, gurchetansingh@chromium.org, kraxel@redhat.com, maz@kernel.org, joro@8bytes.org, zzyiwei@google.com, jgg@nvidia.com, yuzenghui@huawei.com, kevin.tian@intel.com, Yan Zhao , suzuki.poulose@arm.com, alex.williamson@redhat.com, yongwei.ma@intel.com, zhiyuan.lv@intel.com, jmattson@google.com, zhenyu.z.wang@intel.com, seanjc@google.com, ankita@nvidia.com, oliver.upton@linux.dev, james.morse@arm.com, pbonzini@redhat.com, vkuznets@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add param "slot" to op get_mt_mask in kvm_x86_ops. This is a preparation patch to later honor guest PATs for certain memslots. No functional change intended. Suggested-by: Sean Christopherson Cc: Kevin Tian Cc: Zhenyu Wang Tested-by: Yongwei Ma Signed-off-by: Yan Zhao --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/mmu/spte.c | 3 ++- arch/x86/kvm/vmx/vmx.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index a565a2e70f30..6be0d8ccff65 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1675,7 +1675,8 @@ struct kvm_x86_ops { int (*sync_pir_to_irr)(struct kvm_vcpu *vcpu); int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); int (*set_identity_map_addr)(struct kvm *kvm, u64 ident_addr); - u8 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); + u8 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio, + const struct kvm_memory_slot *slot); void (*load_mmu_pgd)(struct kvm_vcpu *vcpu, hpa_t root_hpa, int root_level); diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c index 4a599130e9c9..2c3ede3f27a9 100644 --- a/arch/x86/kvm/mmu/spte.c +++ b/arch/x86/kvm/mmu/spte.c @@ -191,7 +191,8 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, if (shadow_memtype_mask) spte |= static_call(kvm_x86_get_mt_mask)(vcpu, gfn, - kvm_is_mmio_pfn(pfn)); + kvm_is_mmio_pfn(pfn), + slot); if (host_writable) spte |= shadow_host_writable_mask; else diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 40e3780d73ae..85a23765e506 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7576,7 +7576,8 @@ static int vmx_vm_init(struct kvm *kvm) return 0; } -static u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) +static u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio, + const struct kvm_memory_slot *slot) { /* We wanted to honor guest CD/MTRR/PAT, but doing so could result in * memory aliases with conflicting memory types and sometimes MCEs. From patchwork Fri Jan 5 09:15:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 13511894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79348C3DA6E for ; Fri, 5 Jan 2024 09:44:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB24910E5A0; Fri, 5 Jan 2024 09:44:55 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1FA0210E5A9 for ; Fri, 5 Jan 2024 09:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704447894; x=1735983894; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=dRCZ1S0CO2msFURA90luHjWFusP5YsJ6PzRmy9EYQoE=; b=DX64LuvtPSLWbQIAuzW81DjVfHNiYIksK4C7p2LJyXDJHyQ9/xtDNQlJ 2de6RgPUsvVj4qDznfPC6KVWnrVOrIjKH6UWdDqfrSNfbP6lsj85bd8E4 2w/kn0FkXA5dqKiLinZjyzLtmzKnJggFsNvi+FM3+jDlXqvErpeBK0K3c cHJi7tqsLl7jcRcVAKN9RIuqF2w+g0QGdKuB1AEzNxV6HIlNlLSluUSR+ ZY4MbjYGb7JwSinoIueIMR5gXVHLKnGnxZ/l60xYfONnsa8pG7F3DpdWd NAHCssDs4iZCpN5OtOZ2icENDs/2GGymdckyv4AocyMEbAK2eRTrvU5J5 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="10959400" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="10959400" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 01:44:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="784158177" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="784158177" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 01:44:47 -0800 From: Yan Zhao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] KVM: VMX: Honor guest PATs for memslots of flag KVM_MEM_NON_COHERENT_DMA Date: Fri, 5 Jan 2024 17:15:35 +0800 Message-Id: <20240105091535.24760-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240105091237.24577-1-yan.y.zhao@intel.com> References: <20240105091237.24577-1-yan.y.zhao@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wanpengli@tencent.com, gurchetansingh@chromium.org, kraxel@redhat.com, maz@kernel.org, joro@8bytes.org, zzyiwei@google.com, jgg@nvidia.com, yuzenghui@huawei.com, kevin.tian@intel.com, Yan Zhao , suzuki.poulose@arm.com, alex.williamson@redhat.com, yongwei.ma@intel.com, zhiyuan.lv@intel.com, jmattson@google.com, zhenyu.z.wang@intel.com, seanjc@google.com, ankita@nvidia.com, oliver.upton@linux.dev, james.morse@arm.com, pbonzini@redhat.com, vkuznets@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Honor guest PATs in the range of memslots of flag KVM_MEM_NON_COHERENT_DMA set no matter the value of noncoherent dma count. Just honoring guest PATs (without honoring guest MTRRs) for memslots of flag KVM_MEM_NON_COHERENT_DMA is because - guest OS will ensure no page aliasing issue in guest side by honoring guest MTRRs in guest page table. Combinations like guest MTRR=WC or UC, guest PAT = WB is not allowed. (at least in Linux, see pat_x_mtrr_type()). - guest device driver programs device hardware according to guest PATs in modern platforms. Besides, we don't break down an EPT huge page if guest MTRRs in its range are not consistent, because - guest should have chosen correct guest PATs according to guest MTRRs. - in normal platforms, small guest pages with different PATs must correspond to different TLBs though they are mapped in a huge page in EPT. However, one condition may not be supported well by honoring guest PAT alone -- when guest MTRR=WC, guest PAT=UC-. By honoring guest MTRRs+PATs, the effective memory type is WC; while by honoring guest PATs alone, the effective memory type is UC. But it's arguable to support such a usage. Suggested-by: Sean Christopherson Cc: Kevin Tian Cc: Zhenyu Wang Tested-by: Yongwei Ma Signed-off-by: Yan Zhao --- arch/x86/kvm/vmx/vmx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 85a23765e506..99f22589fa6d 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7600,6 +7600,9 @@ static u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio, if (is_mmio) return MTRR_TYPE_UNCACHABLE << VMX_EPT_MT_EPTE_SHIFT; + if (slot->flags & KVM_MEM_NON_COHERENT_DMA) + return MTRR_TYPE_WRBACK << VMX_EPT_MT_EPTE_SHIFT; + if (!kvm_arch_has_noncoherent_dma(vcpu->kvm)) return (MTRR_TYPE_WRBACK << VMX_EPT_MT_EPTE_SHIFT) | VMX_EPT_IPAT_BIT; From patchwork Fri Jan 5 09:16:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 13511895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 653CAC47079 for ; Fri, 5 Jan 2024 09:45:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE50A10E59C; Fri, 5 Jan 2024 09:45:43 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5375110E59C for ; Fri, 5 Jan 2024 09:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704447942; x=1735983942; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Ipngyt99PQBot25YTtxsZ8y9PD4Q1alyU7StkGQNfLY=; b=L/lZCcm36ooQhwRvxEAisJ/Af8feo3UqfCPQiO0XCZ+4B5AcCiij9w9N e36oXygj4NhsS49YrPkXHbcvdj57GML2Vx8cH6j09ojXdpZ3aBMiK8cDh jvXCA1grDU3/RavkeSNk2ECimzwRIyguU5tLw0P0O5VHSX52rAsWUbil3 MPm/cAyEtSE8Ez82skK8ePb1zqkUZ2GVldmzJEY1eQbGhxAA6oFNu3ABL 13crwYsm7PbozliiXfoJx0Q40yUekjz27/j8Ba7s/hy53NGKMpdhtEQje obSl2OEoz4lTDnD/AE24R1s8jF7kvyR4TLMwkv1v0hkNTNNS9hmGilLh/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="10959503" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="10959503" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 01:45:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="784158335" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="784158335" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 01:45:36 -0800 From: Yan Zhao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] KVM: selftests: Set KVM_MEM_NON_COHERENT_DMA as a supported memslot flag Date: Fri, 5 Jan 2024 17:16:24 +0800 Message-Id: <20240105091624.24822-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240105091237.24577-1-yan.y.zhao@intel.com> References: <20240105091237.24577-1-yan.y.zhao@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wanpengli@tencent.com, gurchetansingh@chromium.org, kraxel@redhat.com, maz@kernel.org, joro@8bytes.org, zzyiwei@google.com, jgg@nvidia.com, yuzenghui@huawei.com, kevin.tian@intel.com, Yan Zhao , suzuki.poulose@arm.com, alex.williamson@redhat.com, yongwei.ma@intel.com, zhiyuan.lv@intel.com, jmattson@google.com, zhenyu.z.wang@intel.com, seanjc@google.com, ankita@nvidia.com, oliver.upton@linux.dev, james.morse@arm.com, pbonzini@redhat.com, vkuznets@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Update test_invalid_memory_region_flags() to treat KVM_MEM_NON_COHERENT_DMA as a supported memslot flag. Signed-off-by: Yan Zhao --- tools/testing/selftests/kvm/set_memory_region_test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c index 075b80dbe237..2d6f961734db 100644 --- a/tools/testing/selftests/kvm/set_memory_region_test.c +++ b/tools/testing/selftests/kvm/set_memory_region_test.c @@ -335,6 +335,9 @@ static void test_invalid_memory_region_flags(void) #if defined __aarch64__ || defined __x86_64__ supported_flags |= KVM_MEM_READONLY; + + if (kvm_has_cap(KVM_CAP_USER_CONFIGURE_NONCOHERENT_DMA)) + supported_flags |= KVM_MEM_NON_COHERENT_DMA; #endif #ifdef __x86_64__