]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
KVM: arm/arm64: Convert kvm_host_cpu_state to a static per-cpu allocation
authorJames Morse <james.morse@arm.com>
Mon, 8 Jan 2018 15:38:04 +0000 (15:38 +0000)
committerSeth Forshee <seth.forshee@canonical.com>
Fri, 16 Mar 2018 15:45:14 +0000 (10:45 -0500)
BugLink: http://bugs.launchpad.net/bugs/1756096
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>
(cherry picked from commit 36989e7fd386a9a5822c48691473863f8fbb404d)
Signed-off-by: Manoj Iyer <manoj.iyer@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
virt/kvm/arm/arm.c

index 9a866459bff4cef0c22b20047d264c98a7d7124d..c2e055eb5e1847979862abf2a06a3268d4d60641 100644 (file)
@@ -53,8 +53,8 @@
 __asm__(".arch_extension       virt");
 #endif
 
+DEFINE_PER_CPU(kvm_cpu_context_t, kvm_host_cpu_state);
 static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page);
-static kvm_cpu_context_t __percpu *kvm_host_cpu_state;
 
 /* Per-CPU variable containing the currently running vcpu. */
 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)
        }
 
        vcpu->cpu = cpu;
-       vcpu->arch.host_cpu_context = this_cpu_ptr(kvm_host_cpu_state);
+       vcpu->arch.host_cpu_context = this_cpu_ptr(&kvm_host_cpu_state);
 
        kvm_arm_set_running_vcpu(vcpu);
        kvm_vgic_load(vcpu);
@@ -1273,19 +1273,8 @@ static inline void hyp_cpu_pm_exit(void)
 }
 #endif
 
-static void teardown_common_resources(void)
-{
-       free_percpu(kvm_host_cpu_state);
-}
-
 static int init_common_resources(void)
 {
-       kvm_host_cpu_state = alloc_percpu(kvm_cpu_context_t);
-       if (!kvm_host_cpu_state) {
-               kvm_err("Cannot allocate host CPU state\n");
-               return -ENOMEM;
-       }
-
        /* set size of VMID supported by CPU */
        kvm_vmid_bits = kvm_get_vmid_bits();
        kvm_info("%d-bit VMID\n", kvm_vmid_bits);
@@ -1427,7 +1416,7 @@ static int init_hyp_mode(void)
        for_each_possible_cpu(cpu) {
                kvm_cpu_context_t *cpu_ctxt;
 
-               cpu_ctxt = per_cpu_ptr(kvm_host_cpu_state, cpu);
+               cpu_ctxt = per_cpu_ptr(&kvm_host_cpu_state, cpu);
                err = create_hyp_mappings(cpu_ctxt, cpu_ctxt + 1, PAGE_HYP);
 
                if (err) {
@@ -1551,7 +1540,6 @@ out_hyp:
        if (!in_hyp_mode)
                teardown_hyp_mode();
 out_err:
-       teardown_common_resources();
        return err;
 }