Skip to content

Commit ac4c403

Browse files
committed
xen: check required Xen features
Linux kernel is not supported to run on Xen versions older than 4.0. Add tests for required Xen features always being present in Xen 4.0 and newer. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Link: https://lore.kernel.org/r/20210730071804.4302-2-jgross@suse.com Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 4b511d5 commit ac4c403

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/xen/features.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@
99
#include <linux/types.h>
1010
#include <linux/cache.h>
1111
#include <linux/export.h>
12+
#include <linux/printk.h>
1213

1314
#include <asm/xen/hypercall.h>
1415

16+
#include <xen/xen.h>
1517
#include <xen/interface/xen.h>
1618
#include <xen/interface/version.h>
1719
#include <xen/features.h>
1820

21+
/*
22+
* Linux kernel expects at least Xen 4.0.
23+
*
24+
* Assume some features to be available for that reason (depending on guest
25+
* mode, of course).
26+
*/
27+
#define chk_required_feature(f) { \
28+
if (!xen_feature(f)) \
29+
panic("Xen: feature %s not available!\n", #f); \
30+
}
31+
1932
u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
2033
EXPORT_SYMBOL_GPL(xen_features);
2134

@@ -31,4 +44,9 @@ void xen_setup_features(void)
3144
for (j = 0; j < 32; j++)
3245
xen_features[i * 32 + j] = !!(fi.submap & 1<<j);
3346
}
47+
48+
if (xen_pv_domain()) {
49+
chk_required_feature(XENFEAT_mmu_pt_update_preserve_ad);
50+
chk_required_feature(XENFEAT_gnttab_map_avail_bits);
51+
}
3452
}

0 commit comments

Comments
 (0)