diff options
author | James Morse <james.morse@arm.com> | 2018-01-08 10:38:04 -0500 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2018-01-13 05:44:14 -0500 |
commit | 36989e7fd386a9a5822c48691473863f8fbb404d (patch) | |
tree | 3691d9acbc79860ecc7878e6d2d7d3a6f3b27ca4 /virt | |
parent | 32b03d1059667a39e089c45ee38ec9c16332430f (diff) |
KVM: arm/arm64: Convert kvm_host_cpu_state to a static per-cpu allocation
kvm_host_cpu_state is a per-cpu allocation made from kvm_arch_init()
used to store the host EL1 registers when KVM switches to a guest.
Make it easier for ASM to generate pointers into this per-cpu memory
by making it a static allocation.
Signed-off-by: James Morse <james.morse@arm.com>
Acked-by: Christoffer Dall <cdall@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/arm/arm.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 2df6a5c42f77..2fc6009a766c 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c | |||
@@ -53,8 +53,8 @@ | |||
53 | __asm__(".arch_extension virt"); | 53 | __asm__(".arch_extension virt"); |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | DEFINE_PER_CPU(kvm_cpu_context_t, kvm_host_cpu_state); | ||
56 | static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); | 57 | static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); |
57 | static kvm_cpu_context_t __percpu *kvm_host_cpu_state; | ||
58 | 58 | ||
59 | /* Per-CPU variable containing the currently running vcpu. */ | 59 | /* Per-CPU variable containing the currently running vcpu. */ |
60 | static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu); | 60 | static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu); |
@@ -354,7 +354,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
354 | } | 354 | } |
355 | 355 | ||
356 | vcpu->cpu = cpu; | 356 | vcpu->cpu = cpu; |
357 | vcpu->arch.host_cpu_context = this_cpu_ptr(kvm_host_cpu_state); | 357 | vcpu->arch.host_cpu_context = this_cpu_ptr(&kvm_host_cpu_state); |
358 | 358 | ||
359 | kvm_arm_set_running_vcpu(vcpu); | 359 | kvm_arm_set_running_vcpu(vcpu); |
360 | kvm_vgic_load(vcpu); | 360 | kvm_vgic_load(vcpu); |
@@ -1272,19 +1272,8 @@ static inline void hyp_cpu_pm_exit(void) | |||
1272 | } | 1272 | } |
1273 | #endif | 1273 | #endif |
1274 | 1274 | ||
1275 | static void teardown_common_resources(void) | ||
1276 | { | ||
1277 | free_percpu(kvm_host_cpu_state); | ||
1278 | } | ||
1279 | |||
1280 | static int init_common_resources(void) | 1275 | static int init_common_resources(void) |
1281 | { | 1276 | { |
1282 | kvm_host_cpu_state = alloc_percpu(kvm_cpu_context_t); | ||
1283 | if (!kvm_host_cpu_state) { | ||
1284 | kvm_err("Cannot allocate host CPU state\n"); | ||
1285 | return -ENOMEM; | ||
1286 | } | ||
1287 | |||
1288 | /* set size of VMID supported by CPU */ | 1277 | /* set size of VMID supported by CPU */ |
1289 | kvm_vmid_bits = kvm_get_vmid_bits(); | 1278 | kvm_vmid_bits = kvm_get_vmid_bits(); |
1290 | kvm_info("%d-bit VMID\n", kvm_vmid_bits); | 1279 | kvm_info("%d-bit VMID\n", kvm_vmid_bits); |
@@ -1426,7 +1415,7 @@ static int init_hyp_mode(void) | |||
1426 | for_each_possible_cpu(cpu) { | 1415 | for_each_possible_cpu(cpu) { |
1427 | kvm_cpu_context_t *cpu_ctxt; | 1416 | kvm_cpu_context_t *cpu_ctxt; |
1428 | 1417 | ||
1429 | cpu_ctxt = per_cpu_ptr(kvm_host_cpu_state, cpu); | 1418 | cpu_ctxt = per_cpu_ptr(&kvm_host_cpu_state, cpu); |
1430 | err = create_hyp_mappings(cpu_ctxt, cpu_ctxt + 1, PAGE_HYP); | 1419 | err = create_hyp_mappings(cpu_ctxt, cpu_ctxt + 1, PAGE_HYP); |
1431 | 1420 | ||
1432 | if (err) { | 1421 | if (err) { |
@@ -1550,7 +1539,6 @@ out_hyp: | |||
1550 | if (!in_hyp_mode) | 1539 | if (!in_hyp_mode) |
1551 | teardown_hyp_mode(); | 1540 | teardown_hyp_mode(); |
1552 | out_err: | 1541 | out_err: |
1553 | teardown_common_resources(); | ||
1554 | return err; | 1542 | return err; |
1555 | } | 1543 | } |
1556 | 1544 | ||