From: Jan Beulich Date: Fri, 5 Nov 2021 12:34:57 +0000 (+0100) Subject: x86/APIC: drop probe_default() X-Git-Tag: 4.17.0-rc1~1151 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0ee901ce4b439ef5a44bf6ac7471e75a20dffbbe;p=xen.git x86/APIC: drop probe_default() The function does nothing but return success. Simply treat absence of a probe hook to mean just this. This then eliminates the (purely theoretical at this point) risk of trying to call through apic_x2apic_{cluster,phys}'s respective NULL pointers. While doing this also eliminate generic_apic_probe()'s "changed" variable: apic_probe[]'s default entry will now be used unconditionally in yet more obvious a way, such that separately setting genapic from apic_default is (hopefully) no longer justified. Yet that was the main purpose of the variable. To help prove that apic_default's probe() hook doesn't get used elsewhere, further make apic_probe[] static at this occasion. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/xen/arch/x86/genapic/default.c b/xen/arch/x86/genapic/default.c index bfd068cdc6..2c63c1f917 100644 --- a/xen/arch/x86/genapic/default.c +++ b/xen/arch/x86/genapic/default.c @@ -14,12 +14,7 @@ #include /* should be called last. */ -static __init int probe_default(void) -{ - return 1; -} - const struct genapic __initconstrel apic_default = { - APIC_INIT("default", probe_default), + APIC_INIT("default", NULL), GENAPIC_FLAT }; diff --git a/xen/arch/x86/genapic/probe.c b/xen/arch/x86/genapic/probe.c index b963dc5ec0..1ee6cd73cd 100644 --- a/xen/arch/x86/genapic/probe.c +++ b/xen/arch/x86/genapic/probe.c @@ -18,7 +18,7 @@ struct genapic __read_mostly genapic; -const struct genapic *const __initconstrel apic_probe[] = { +static const struct genapic *const __initconstrel apic_probe[] = { &apic_bigsmp, &apic_default, /* must be last */ NULL, @@ -59,22 +59,20 @@ custom_param("apic", genapic_apic_force); void __init generic_apic_probe(void) { - bool changed; int i; record_boot_APIC_mode(); check_x2apic_preenabled(); - cmdline_apic = changed = !!genapic.name; - for (i = 0; !changed && apic_probe[i]; i++) { - if (apic_probe[i]->probe()) { - changed = 1; + cmdline_apic = genapic.name; + + for (i = 0; !genapic.name && apic_probe[i]; i++) { + if (!apic_probe[i]->probe || apic_probe[i]->probe()) genapic = *apic_probe[i]; - } } - if (!changed) - genapic = apic_default; + + BUG_ON(!genapic.name); printk(KERN_INFO "Using APIC driver %s\n", genapic.name); }