Re: [PATCH v6 4/4] x86/xen: Add "nopv" support for HVM guest
From: Boris Ostrovsky
Date: Mon Jul 08 2019 - 09:48:44 EST
On 7/7/19 5:15 AM, Zhenzhong Duan wrote:
>
> +static uint32_t __init xen_platform_hvm(void)
> +{
> + if (xen_pv_domain())
> + return 0;
> +
> + if (xen_pvh_domain() && nopv) {
> + /* Guest booting via the Xen-PVH boot entry goes here */
> + pr_info("\"nopv\" parameter is ignored in PVH guest\n");
> + nopv = false;
> + } else if (nopv) {
> + /*
> + * Guest booting via normal boot entry (like via grub2) goes
> + * here.
> + */
> + x86_init.hyper.guest_late_init = xen_hvm_guest_late_init;
> + return 0;
After staring at this some more I don't think we can do this.
Hypervisor-specific code should not muck with with x86_init.hyper, it's
layering violation. That's what init_hypervisor_platform() is for.
So we may have to create another hypervisor_x86 ops structure for Xen
nopv (which I don't find very appealing TBH). Or update
x86_hyper_xen_hvm and return xen_cpuid_base() instead of zero (but then
you'd need to update all these structs from __initconst to _init or some
such). Or something else.
-boris
> + }
> + return xen_cpuid_base();
> +}
> +
> const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = {
> .name = "Xen HVM",
> .detect = xen_platform_hvm,
> @@ -268,4 +283,5 @@ static __init void xen_hvm_guest_late_init(void)
> .init.init_mem_mapping = xen_hvm_init_mem_mapping,
> .init.guest_late_init = xen_hvm_guest_late_init,
> .runtime.pin_vcpu = xen_pin_vcpu,
> + .ignore_nopv = true,
> };