git: 091febc04a5d - main - xen/blkback: do not use x86 CPUID in generic code
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 28 Jun 2022 07:53:12 UTC
The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=091febc04a5d5065fe633fe29c11f008dc392ab8 commit 091febc04a5d5065fe633fe29c11f008dc392ab8 Author: Roger Pau Monné <royger@FreeBSD.org> AuthorDate: 2022-06-17 13:29:05 +0000 Commit: Roger Pau Monné <royger@FreeBSD.org> CommitDate: 2022-06-28 07:51:57 +0000 xen/blkback: do not use x86 CPUID in generic code Move checker for whether Xen creates IOMMU mappings for foreign pages into a helper that's defined in arch-specific code. Reported by: Elliott Mitchell <ehem+freebsd@m5p.com> Fixes: 1d528f95e8ce ('xen/blkback: remove bounce buffering mode') Sponsored by: Citrix Systems R&D --- sys/dev/xen/blkback/blkback.c | 7 +------ sys/x86/include/xen/xen-os.h | 2 ++ sys/x86/xen/hvm.c | 11 +++++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index b15dbb1e9155..bd550695e719 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -80,7 +80,6 @@ __FBSDID("$FreeBSD$"); #include <xen/gnttab.h> #include <xen/xen_intr.h> -#include <contrib/xen/arch-x86/cpuid.h> #include <contrib/xen/event_channel.h> #include <contrib/xen/grant_table.h> @@ -3318,16 +3317,12 @@ xbb_attach_failed(struct xbb_softc *xbb, int err, const char *fmt, ...) static int xbb_probe(device_t dev) { - uint32_t regs[4]; if (strcmp(xenbus_get_type(dev), "vbd")) return (ENXIO); - KASSERT(xen_cpuid_base != 0, ("Invalid base Xen CPUID leaf")); - cpuid_count(xen_cpuid_base + 4, 0, regs); - /* Only attach if Xen creates IOMMU entries for grant mapped pages. */ - if (!(regs[0] & XEN_HVM_CPUID_IOMMU_MAPPINGS)) { + if (!xen_has_iommu_maps()) { static bool warned; if (!warned) { diff --git a/sys/x86/include/xen/xen-os.h b/sys/x86/include/xen/xen-os.h index 4d4aa64955ba..861ad10e3d78 100644 --- a/sys/x86/include/xen/xen-os.h +++ b/sys/x86/include/xen/xen-os.h @@ -72,6 +72,8 @@ xen_pv_nics_disabled(void) return (xen_hvm_domain() && xen_disable_pv_nics != 0); } +bool xen_has_iommu_maps(void); + #endif /* !__ASSEMBLY__ */ #endif /* _MACHINE_X86_XEN_XEN_OS_H_ */ diff --git a/sys/x86/xen/hvm.c b/sys/x86/xen/hvm.c index 544b6e6439e8..8d25e35e5151 100644 --- a/sys/x86/xen/hvm.c +++ b/sys/x86/xen/hvm.c @@ -489,3 +489,14 @@ xen_hvm_cpu_init(void) DPCPU_SET(vcpu_info, vcpu_info); } SYSINIT(xen_hvm_cpu_init, SI_SUB_INTR, SI_ORDER_FIRST, xen_hvm_cpu_init, NULL); + +bool +xen_has_iommu_maps(void) +{ + uint32_t regs[4]; + + KASSERT(xen_cpuid_base != 0, ("Invalid base Xen CPUID leaf")); + cpuid_count(xen_cpuid_base + 4, 0, regs); + + return (regs[0] & XEN_HVM_CPUID_IOMMU_MAPPINGS); +}