diff options
author | Andre Przywara <andre.przywara@arm.com> | 2014-06-02 09:37:13 -0400 |
---|---|---|
committer | Christoffer Dall <christoffer.dall@linaro.org> | 2015-01-20 12:25:17 -0500 |
commit | 4429fc64b90368e9bc93f933ea8b011d8db3a2f2 (patch) | |
tree | a7cb2e3dbebe4c2d6dc7a17e648a04b1c82090b9 /arch/arm64/kvm | |
parent | 7276030a082c9c33150e5900a80e26c6e3189b16 (diff) |
arm/arm64: KVM: rework MPIDR assignment and add accessors
The virtual MPIDR registers (containing topology information) for the
guest are currently mapped linearily to the vcpu_id. Improve this
mapping for arm64 by using three levels to not artificially limit the
number of vCPUs.
To help this, change and rename the kvm_vcpu_get_mpidr() function to
mask off the non-affinity bits in the MPIDR register.
Also add an accessor to later allow easier access to a vCPU with a
given MPIDR. Use this new accessor in the PSCI emulation.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'arch/arm64/kvm')
-rw-r--r-- | arch/arm64/kvm/sys_regs.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 3d7c2df89946..136e6797676b 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c | |||
@@ -252,10 +252,19 @@ static void reset_amair_el1(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) | |||
252 | 252 | ||
253 | static void reset_mpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) | 253 | static void reset_mpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) |
254 | { | 254 | { |
255 | u64 mpidr; | ||
256 | |||
255 | /* | 257 | /* |
256 | * Simply map the vcpu_id into the Aff0 field of the MPIDR. | 258 | * Map the vcpu_id into the first three affinity level fields of |
259 | * the MPIDR. We limit the number of VCPUs in level 0 due to a | ||
260 | * limitation to 16 CPUs in that level in the ICC_SGIxR registers | ||
261 | * of the GICv3 to be able to address each CPU directly when | ||
262 | * sending IPIs. | ||
257 | */ | 263 | */ |
258 | vcpu_sys_reg(vcpu, MPIDR_EL1) = (1UL << 31) | (vcpu->vcpu_id & 0xff); | 264 | mpidr = (vcpu->vcpu_id & 0x0f) << MPIDR_LEVEL_SHIFT(0); |
265 | mpidr |= ((vcpu->vcpu_id >> 4) & 0xff) << MPIDR_LEVEL_SHIFT(1); | ||
266 | mpidr |= ((vcpu->vcpu_id >> 12) & 0xff) << MPIDR_LEVEL_SHIFT(2); | ||
267 | vcpu_sys_reg(vcpu, MPIDR_EL1) = (1ULL << 31) | mpidr; | ||
259 | } | 268 | } |
260 | 269 | ||
261 | /* Silly macro to expand the DBG{BCR,BVR,WVR,WCR}n_EL1 registers in one go */ | 270 | /* Silly macro to expand the DBG{BCR,BVR,WVR,WCR}n_EL1 registers in one go */ |