Re: [PATCH 2/3] x86: add guest_late_init hook to hypervisor_x86 structure

From: Ingo Molnar
Date: Wed Nov 08 2017 - 04:40:24 EST



* Juergen Gross <jgross@xxxxxxxx> wrote:

> > Plus add a default empty function (which hypervisors can override). This avoids
> > all the hidden conditions and wrappery.
>
> Hmm, x86_hyper is just a pointer being NULL on bare metal. So we would
> have to add a pre-filled struct with dummy functions and in case a
> hypervisor is detected we'd need to copy all non-NULL pointers of the
> hypervisor specific struct to the pre-filled one.

Ok, I missed that detail - but yeah, since this is mostly about boot code,
where readability is king, I still think it would be an overall improvement.

This is the pattern we are trying to use with x86_platform ops for example, and
doing:

git grep -w x86_platform arch/x86

gives a pretty clear idea about how it's used - while if it was all within
wrappers it would be a lot more difficult to discover all the callsites.

Admittedly it's not done totally consistently:

arch/x86/kernel/apic/probe_32.c: if (x86_platform.apic_post_init)
arch/x86/kernel/apic/probe_64.c: if (x86_platform.apic_post_init)
arch/x86/kernel/ebda.c: if (!x86_platform.legacy.reserve_bios_regions)
arch/x86/kernel/platform-quirks.c: if (x86_platform.set_legacy_features)
arch/x86/platform/intel-mid/device_libs/platform_mrfld_rtc.c: if (!x86_platform.legacy.rtc)

... but the _idea_ behind it is consistent ;-)

> In case there are no objections I can add a patch to modify the current
> way x86_hyper is used to the pre-filled variant.

Yeah, sounds good to me!

Thanks,

Ingo