On 2016-06-17 21:10, [email protected] wrote: > From: Antonios Motakis <[email protected]> > > PSCI actually takes CPU parameters by the MPIDR id, which may > differ from the logical id of the CPU. This patch is the first step > into properly handling the CPU affinity levels in the MPIDR. > > Signed-off-by: Antonios Motakis <[email protected]> > --- > hypervisor/arch/arm/include/asm/control.h | 1 + > hypervisor/arch/arm/include/asm/percpu.h | 1 + > hypervisor/arch/arm/lib.c | 14 ++++++++++++++ > hypervisor/arch/arm/psci.c | 5 ++--- > hypervisor/arch/arm/setup.c | 1 + > 5 files changed, 19 insertions(+), 3 deletions(-) > > diff --git a/hypervisor/arch/arm/include/asm/control.h > b/hypervisor/arch/arm/include/asm/control.h > index f050e76..1d64b98 100644 > --- a/hypervisor/arch/arm/include/asm/control.h > +++ b/hypervisor/arch/arm/include/asm/control.h > @@ -38,6 +38,7 @@ struct registers* arch_handle_exit(struct per_cpu *cpu_data, > bool arch_handle_phys_irq(struct per_cpu *cpu_data, u32 irqn); > void arch_reset_self(struct per_cpu *cpu_data); > void arch_shutdown_self(struct per_cpu *cpu_data); > +unsigned int arm_cpu_by_mpidr(struct cell *cell, unsigned long mpidr); > > void __attribute__((noreturn)) vmreturn(struct registers *guest_regs); > void __attribute__((noreturn)) arch_shutdown_mmu(struct per_cpu *cpu_data); > diff --git a/hypervisor/arch/arm/include/asm/percpu.h > b/hypervisor/arch/arm/include/asm/percpu.h > index ae026c4..0e9eac8 100644 > --- a/hypervisor/arch/arm/include/asm/percpu.h > +++ b/hypervisor/arch/arm/include/asm/percpu.h > @@ -62,6 +62,7 @@ struct per_cpu { > bool flush_vcpu_caches; > int shutdown_state; > bool shutdown; > + unsigned long mpidr; > bool failed; > } __attribute__((aligned(PAGE_SIZE))); > > diff --git a/hypervisor/arch/arm/lib.c b/hypervisor/arch/arm/lib.c > index 038bf9a..2fdcbe6 100644 > --- a/hypervisor/arch/arm/lib.c > +++ b/hypervisor/arch/arm/lib.c > @@ -10,9 +10,12 @@ > * the COPYING file in the top-level directory. > */ > > +#include <jailhouse/control.h> > #include <jailhouse/processor.h> > #include <jailhouse/string.h> > #include <jailhouse/types.h> > +#include <asm/control.h> > +#include <asm/percpu.h> > #include <asm/sysregs.h> > > unsigned long phys_processor_id(void) > @@ -22,3 +25,14 @@ unsigned long phys_processor_id(void) > arm_read_sysreg(MPIDR_EL1, mpidr); > return mpidr & MPIDR_CPUID_MASK; > } > + > +unsigned int arm_cpu_by_mpidr(struct cell *cell, unsigned long mpidr) > +{ > + unsigned int cpu; > + > + for_each_cpu(cpu, cell->cpu_set) > + if (mpidr == (per_cpu(cpu)->mpidr & MPIDR_CPUID_MASK)) > + return cpu; > + > + return -1; > +} > diff --git a/hypervisor/arch/arm/psci.c b/hypervisor/arch/arm/psci.c > index 3ebbd50..e0a6703 100644 > --- a/hypervisor/arch/arm/psci.c > +++ b/hypervisor/arch/arm/psci.c > @@ -78,11 +78,10 @@ int psci_wait_cpu_stopped(unsigned int cpu_id) > static long psci_emulate_cpu_on(struct per_cpu *cpu_data, > struct trap_context *ctx) > { > - unsigned int target = ctx->regs[1]; > unsigned int cpu; > struct psci_mbox *mbox; > > - cpu = arm_cpu_virt2phys(cpu_data->cell, target); > + cpu = arm_cpu_by_mpidr(cpu_data->cell, ctx->regs[1]); > if (cpu == -1) > /* Virtual id not in set */ > return PSCI_DENIED; > @@ -97,7 +96,7 @@ static long psci_emulate_cpu_on(struct per_cpu *cpu_data, > static long psci_emulate_affinity_info(struct per_cpu *cpu_data, > struct trap_context *ctx) > { > - unsigned int cpu = arm_cpu_virt2phys(cpu_data->cell, ctx->regs[1]); > + unsigned int cpu = arm_cpu_by_mpidr(cpu_data->cell, ctx->regs[1]); > > if (cpu == -1) > /* Virtual id not in set */ > diff --git a/hypervisor/arch/arm/setup.c b/hypervisor/arch/arm/setup.c > index f9f59d8..d11b9db 100644 > --- a/hypervisor/arch/arm/setup.c > +++ b/hypervisor/arch/arm/setup.c > @@ -56,6 +56,7 @@ int arch_cpu_init(struct per_cpu *cpu_data) > > cpu_data->psci_mbox.entry = 0; > cpu_data->virt_id = cpu_data->cpu_id; > + cpu_data->mpidr = phys_processor_id(); > > /* > * Copy the registers to restore from the linux stack here, because we >
This hunk lacks the corresponding processor.h include. If I can take this set without other changes, I'll fix it up. Do you have travis-ci activated for your branch on github? If not, might be valuable to catch such issues. We should be failing builds when there are warnings - let me try... Jan -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
