Re: [PATCH 03/10] x86: jailhouse: Enable APIC and SMP support

From: Konrad Rzeszutek Wilk
Date: Mon Nov 20 2017 - 09:40:22 EST


On Fri, Nov 17, 2017 at 11:42:02PM +0100, Thomas Gleixner wrote:
> On Thu, 16 Nov 2017, Jan Kiszka wrote:
>
> Just noticed, that all prefixes should be 'x86/jailhouse:' please
>
> > +static unsigned int x2apic_get_apic_id(unsigned long id)
> > +{
> > + return id;
> > +}
> > +
> > static void __init jailhouse_init_platform(void)
> > {
> > u64 pa_data = boot_params.hdr.setup_data;
> > struct jailhouse_setup_data *data;
> > + unsigned int cpu;
> >
> > data = early_memremap(pa_data, sizeof(*data));
> >
> > @@ -59,6 +66,23 @@ static void __init jailhouse_init_platform(void)
> > data->compatible_version > SETUP_REQUIRED_VERSION)
> > panic("Jailhouse: Unsupported setup data structure");
> >
> > +#ifdef CONFIG_X86_X2APIC
> > + /*
> > + * Register x2APIC handlers early. We need them when running
> > + * register_lapic_address.
> > + */
> > + if (x2apic_enabled()) {
> > + apic->read = native_apic_msr_read;
> > + apic->write = native_apic_msr_write;
> > + apic->get_apic_id = x2apic_get_apic_id;
>
> Uurgh. That looks hacky.

Could just create a new APIC driver (which would call most of these)?

>
> > + }
> > +#endif
> > + register_lapic_address(0xfee00000);
>
> No need to do all of this here. The right thing to do is to override
>
> x86_init.mpparse.get_smp_config
>
> which is invoked after generic_apic_probe() which should select
> x2apic_phys, but I might be wrong.
>
>
> > + for (cpu = 0; cpu < data->num_cpus; cpu++)
> > + generic_processor_info(data->cpu_ids[cpu],
> > + boot_cpu_apic_version);
>
> Please add brackets around multi line statements.
>
> Thanks,
>
> tglx