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 #include -#include #include #include @@ -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); +}