diff options
author | Andrew Murray <andrew.murray@arm.com> | 2019-04-09 15:22:11 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2019-04-24 10:35:24 -0400 |
commit | 630a16854d2d28d13e96ff27ab43cc5caa4609fc (patch) | |
tree | bd32195f9eb59a05c7de43a44dcc3af859a3b97f /virt | |
parent | 21bb0ebf5d78c669ed887f30889f2d28cf6bf7db (diff) |
arm64: KVM: Encapsulate kvm_cpu_context in kvm_host_data
The virt/arm core allocates a kvm_cpu_context_t percpu, at present this is
a typedef to kvm_cpu_context and is used to store host cpu context. The
kvm_cpu_context structure is also used elsewhere to hold vcpu context.
In order to use the percpu to hold additional future host information we
encapsulate kvm_cpu_context in a new structure and rename the typedef and
percpu to match.
Signed-off-by: Andrew Murray <andrew.murray@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/arm/arm.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 156c09da9e2b..e960b91551d6 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c | |||
@@ -56,7 +56,7 @@ | |||
56 | __asm__(".arch_extension virt"); | 56 | __asm__(".arch_extension virt"); |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | DEFINE_PER_CPU(kvm_cpu_context_t, kvm_host_cpu_state); | 59 | DEFINE_PER_CPU(kvm_host_data_t, kvm_host_data); |
60 | static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); | 60 | static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); |
61 | 61 | ||
62 | /* Per-CPU variable containing the currently running vcpu. */ | 62 | /* Per-CPU variable containing the currently running vcpu. */ |
@@ -360,8 +360,10 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) | |||
360 | void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | 360 | void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) |
361 | { | 361 | { |
362 | int *last_ran; | 362 | int *last_ran; |
363 | kvm_host_data_t *cpu_data; | ||
363 | 364 | ||
364 | last_ran = this_cpu_ptr(vcpu->kvm->arch.last_vcpu_ran); | 365 | last_ran = this_cpu_ptr(vcpu->kvm->arch.last_vcpu_ran); |
366 | cpu_data = this_cpu_ptr(&kvm_host_data); | ||
365 | 367 | ||
366 | /* | 368 | /* |
367 | * We might get preempted before the vCPU actually runs, but | 369 | * We might get preempted before the vCPU actually runs, but |
@@ -373,7 +375,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
373 | } | 375 | } |
374 | 376 | ||
375 | vcpu->cpu = cpu; | 377 | vcpu->cpu = cpu; |
376 | vcpu->arch.host_cpu_context = this_cpu_ptr(&kvm_host_cpu_state); | 378 | vcpu->arch.host_cpu_context = &cpu_data->host_ctxt; |
377 | 379 | ||
378 | kvm_arm_set_running_vcpu(vcpu); | 380 | kvm_arm_set_running_vcpu(vcpu); |
379 | kvm_vgic_load(vcpu); | 381 | kvm_vgic_load(vcpu); |
@@ -1569,11 +1571,11 @@ static int init_hyp_mode(void) | |||
1569 | } | 1571 | } |
1570 | 1572 | ||
1571 | for_each_possible_cpu(cpu) { | 1573 | for_each_possible_cpu(cpu) { |
1572 | kvm_cpu_context_t *cpu_ctxt; | 1574 | kvm_host_data_t *cpu_data; |
1573 | 1575 | ||
1574 | cpu_ctxt = per_cpu_ptr(&kvm_host_cpu_state, cpu); | 1576 | cpu_data = per_cpu_ptr(&kvm_host_data, cpu); |
1575 | kvm_init_host_cpu_context(cpu_ctxt, cpu); | 1577 | kvm_init_host_cpu_context(&cpu_data->host_ctxt, cpu); |
1576 | err = create_hyp_mappings(cpu_ctxt, cpu_ctxt + 1, PAGE_HYP); | 1578 | err = create_hyp_mappings(cpu_data, cpu_data + 1, PAGE_HYP); |
1577 | 1579 | ||
1578 | if (err) { | 1580 | if (err) { |
1579 | kvm_err("Cannot map host CPU state: %d\n", err); | 1581 | kvm_err("Cannot map host CPU state: %d\n", err); |