On Sun, Jun 18, 2017 at 21:20 +1000, Jonathan Matthew wrote:
> On Fri, Jun 16, 2017 at 10:25:29AM +0200, Mike Belopuhov wrote:
> > Now regarding the diff. pvbus_init_vcpu. Ah yes, please.
> > It was a chicken and the egg problem for me: I didn't have
> > Xen, but wanted a callback from cpu_hatch to setup shared
> > info pages and events (interrupt delivery) for all CPUs.
> > So please factor it out and let's get that committed.
>
> Updated version of this is below. The init_cpu function pointer is now in
> the pvbus_hv so it's easier to decide what it does at runtime.
>
[...]
> oks on this bit?
>
OK mikeb
> Index: arch/amd64/amd64/cpu.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/amd64/cpu.c,v
> retrieving revision 1.105
> diff -u -p -r1.105 cpu.c
> --- arch/amd64/amd64/cpu.c 30 May 2017 15:11:32 -0000 1.105
> +++ arch/amd64/amd64/cpu.c 18 Jun 2017 09:16:12 -0000
> @@ -67,6 +67,7 @@
> #include "lapic.h"
> #include "ioapic.h"
> #include "vmm.h"
> +#include "pvbus.h"
>
> #include <sys/param.h>
> #include <sys/timeout.h>
> @@ -103,6 +104,10 @@
> #include <machine/i82093var.h>
> #endif
>
> +#if NPVBUS > 0
> +#include <dev/pv/pvvar.h>
> +#endif
> +
> #include <dev/ic/mc146818reg.h>
> #include <amd64/isa/nvram.h>
> #include <dev/isa/isareg.h>
> @@ -728,6 +733,9 @@ cpu_hatch(void *v)
> lldt(0);
>
> cpu_init(ci);
> +#if NPVBUS > 0
> + pvbus_init_cpu();
> +#endif
>
> /* Re-initialise memory range handling on AP */
> if (mem_range_softc.mr_op != NULL)
> Index: arch/i386/i386/cpu.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/i386/cpu.c,v
> retrieving revision 1.84
> diff -u -p -r1.84 cpu.c
> --- arch/i386/i386/cpu.c 30 May 2017 15:11:32 -0000 1.84
> +++ arch/i386/i386/cpu.c 18 Jun 2017 09:16:13 -0000
> @@ -67,6 +67,7 @@
> #include "lapic.h"
> #include "ioapic.h"
> #include "vmm.h"
> +#include "pvbus.h"
>
> #include <sys/param.h>
> #include <sys/timeout.h>
> @@ -104,6 +105,10 @@
> #include <machine/i82093var.h>
> #endif
>
> +#if NPVBUS > 0
> +#include <dev/pv/pvvar.h>
> +#endif
> +
> #include <dev/ic/mc146818reg.h>
> #include <i386/isa/nvram.h>
> #include <dev/isa/isareg.h>
> @@ -626,6 +631,9 @@ cpu_hatch(void *v)
>
> ci->ci_curpmap = pmap_kernel();
> cpu_init(ci);
> +#if NPVBUS > 0
> + pvbus_init_cpu();
> +#endif
>
> /* Re-initialise memory range handling on AP */
> if (mem_range_softc.mr_op != NULL)
> Index: dev/pv/pvbus.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pv/pvbus.c,v
> retrieving revision 1.16
> diff -u -p -r1.16 pvbus.c
> --- dev/pv/pvbus.c 10 Jan 2017 17:16:39 -0000 1.16
> +++ dev/pv/pvbus.c 18 Jun 2017 09:16:17 -0000
> @@ -210,6 +210,19 @@ pvbus_identify(void)
> has_hv_cpuid = 1;
> }
>
> +void
> +pvbus_init_cpu(void)
> +{
> + int i;
> +
> + for (i = 0; i < PVBUS_MAX; i++) {
> + if (pvbus_hv[i].hv_base == 0)
> + continue;
> + if (pvbus_hv[i].hv_init_cpu != NULL)
> + (pvbus_hv[i].hv_init_cpu)(&pvbus_hv[i]);
> + }
> +}
> +
> int
> pvbus_activate(struct device *self, int act)
> {
> Index: dev/pv/pvvar.h
> ===================================================================
> RCS file: /cvs/src/sys/dev/pv/pvvar.h,v
> retrieving revision 1.9
> diff -u -p -r1.9 pvvar.h
> --- dev/pv/pvvar.h 10 Jan 2017 17:16:39 -0000 1.9
> +++ dev/pv/pvvar.h 18 Jun 2017 09:16:17 -0000
> @@ -56,6 +56,7 @@ struct pvbus_hv {
>
> void *hv_arg;
> int (*hv_kvop)(void *, int, char *, char *, size_t);
> + void (*hv_init_cpu)(struct pvbus_hv *);
> };
>
> struct pvbus_softc {
> @@ -77,6 +78,7 @@ struct pv_attach_args {
>
> void pvbus_identify(void);
> int pvbus_probe(void);
> +void pvbus_init_cpu(void);
> void pvbus_reboot(struct device *);
> void pvbus_shutdown(struct device *);
>