1 // SPDX-License-Identifier: GPL-2.0-only
2 /******************************************************************************
7 * Copyright (c) 2006, Ian Campbell, XenSource Inc.
9 #include <linux/types.h>
10 #include <linux/cache.h>
11 #include <linux/export.h>
12 #include <linux/printk.h>
14 #include <asm/xen/hypercall.h>
17 #include <xen/interface/xen.h>
18 #include <xen/interface/version.h>
19 #include <xen/features.h>
22 * Linux kernel expects at least Xen 4.0.
24 * Assume some features to be available for that reason (depending on guest
27 #define chk_required_feature(f) { \
28 if (!xen_feature(f)) \
29 panic("Xen: feature %s not available!\n", #f); \
32 u8 xen_features
[XENFEAT_NR_SUBMAPS
* 32] __read_mostly
;
33 EXPORT_SYMBOL_GPL(xen_features
);
35 void xen_setup_features(void)
37 struct xen_feature_info fi
;
40 for (i
= 0; i
< XENFEAT_NR_SUBMAPS
; i
++) {
42 if (HYPERVISOR_xen_version(XENVER_get_features
, &fi
) < 0)
44 for (j
= 0; j
< 32; j
++)
45 xen_features
[i
* 32 + j
] = !!(fi
.submap
& 1U << j
);
48 if (xen_pv_domain()) {
49 chk_required_feature(XENFEAT_mmu_pt_update_preserve_ad
);
50 chk_required_feature(XENFEAT_gnttab_map_avail_bits
);