aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2013-04-08 11:47:19 -0400
committerChristoffer Dall <cdall@cs.columbia.edu>2013-04-29 01:23:13 -0400
commit3de50da6901521f9e520b8eb47d092779512e83c (patch)
tree2cf4831d97ed5490c14b784581ddaad1ae21ceb7 /arch
parent17b1e31f9201fc102ee3ddd409988e47753e22f9 (diff)
ARM: KVM: promote vfp_host pointer to generic host cpu context
We use the vfp_host pointer to store the host VFP context, should the guest start using VFP itself. Actually, we can use this pointer in a more generic way to store CPU speficic data, and arm64 is using it to dump the whole host state before switching to the guest. Simply rename the vfp_host field to host_cpu_context, and the corresponding type to kvm_cpu_context_t. No change in functionnality. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <cdall@cs.columbia.edu>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/include/asm/kvm_host.h8
-rw-r--r--arch/arm/kernel/asm-offsets.c2
-rw-r--r--arch/arm/kvm/arm.c28
3 files changed, 20 insertions, 18 deletions
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index dcfcbf59fceb..57cb786a6203 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -87,7 +87,7 @@ struct kvm_vcpu_fault_info {
87 u32 hyp_pc; /* PC when exception was taken from Hyp mode */ 87 u32 hyp_pc; /* PC when exception was taken from Hyp mode */
88}; 88};
89 89
90typedef struct vfp_hard_struct kvm_kernel_vfp_t; 90typedef struct vfp_hard_struct kvm_cpu_context_t;
91 91
92struct kvm_vcpu_arch { 92struct kvm_vcpu_arch {
93 struct kvm_regs regs; 93 struct kvm_regs regs;
@@ -105,8 +105,10 @@ struct kvm_vcpu_arch {
105 struct kvm_vcpu_fault_info fault; 105 struct kvm_vcpu_fault_info fault;
106 106
107 /* Floating point registers (VFP and Advanced SIMD/NEON) */ 107 /* Floating point registers (VFP and Advanced SIMD/NEON) */
108 kvm_kernel_vfp_t vfp_guest; 108 struct vfp_hard_struct vfp_guest;
109 kvm_kernel_vfp_t *vfp_host; 109
110 /* Host FP context */
111 kvm_cpu_context_t *host_cpu_context;
110 112
111 /* VGIC state */ 113 /* VGIC state */
112 struct vgic_cpu vgic_cpu; 114 struct vgic_cpu vgic_cpu;
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index ee1ac39a58f0..92562a2e9793 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -154,7 +154,7 @@ int main(void)
154 DEFINE(VCPU_MIDR, offsetof(struct kvm_vcpu, arch.midr)); 154 DEFINE(VCPU_MIDR, offsetof(struct kvm_vcpu, arch.midr));
155 DEFINE(VCPU_CP15, offsetof(struct kvm_vcpu, arch.cp15)); 155 DEFINE(VCPU_CP15, offsetof(struct kvm_vcpu, arch.cp15));
156 DEFINE(VCPU_VFP_GUEST, offsetof(struct kvm_vcpu, arch.vfp_guest)); 156 DEFINE(VCPU_VFP_GUEST, offsetof(struct kvm_vcpu, arch.vfp_guest));
157 DEFINE(VCPU_VFP_HOST, offsetof(struct kvm_vcpu, arch.vfp_host)); 157 DEFINE(VCPU_VFP_HOST, offsetof(struct kvm_vcpu, arch.host_cpu_context));
158 DEFINE(VCPU_REGS, offsetof(struct kvm_vcpu, arch.regs)); 158 DEFINE(VCPU_REGS, offsetof(struct kvm_vcpu, arch.regs));
159 DEFINE(VCPU_USR_REGS, offsetof(struct kvm_vcpu, arch.regs.usr_regs)); 159 DEFINE(VCPU_USR_REGS, offsetof(struct kvm_vcpu, arch.regs.usr_regs));
160 DEFINE(VCPU_SVC_REGS, offsetof(struct kvm_vcpu, arch.regs.svc_regs)); 160 DEFINE(VCPU_SVC_REGS, offsetof(struct kvm_vcpu, arch.regs.svc_regs));
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index cc67cafc5b87..089c0a40514c 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -49,7 +49,7 @@ __asm__(".arch_extension virt");
49#endif 49#endif
50 50
51static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); 51static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page);
52static kvm_kernel_vfp_t __percpu *kvm_host_vfp_state; 52static kvm_cpu_context_t __percpu *kvm_host_cpu_state;
53static unsigned long hyp_default_vectors; 53static unsigned long hyp_default_vectors;
54 54
55/* Per-CPU variable containing the currently running vcpu. */ 55/* Per-CPU variable containing the currently running vcpu. */
@@ -317,7 +317,7 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
317void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 317void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
318{ 318{
319 vcpu->cpu = cpu; 319 vcpu->cpu = cpu;
320 vcpu->arch.vfp_host = this_cpu_ptr(kvm_host_vfp_state); 320 vcpu->arch.host_cpu_context = this_cpu_ptr(kvm_host_cpu_state);
321 321
322 /* 322 /*
323 * Check whether this vcpu requires the cache to be flushed on 323 * Check whether this vcpu requires the cache to be flushed on
@@ -882,24 +882,24 @@ static int init_hyp_mode(void)
882 } 882 }
883 883
884 /* 884 /*
885 * Map the host VFP structures 885 * Map the host CPU structures
886 */ 886 */
887 kvm_host_vfp_state = alloc_percpu(kvm_kernel_vfp_t); 887 kvm_host_cpu_state = alloc_percpu(kvm_cpu_context_t);
888 if (!kvm_host_vfp_state) { 888 if (!kvm_host_cpu_state) {
889 err = -ENOMEM; 889 err = -ENOMEM;
890 kvm_err("Cannot allocate host VFP state\n"); 890 kvm_err("Cannot allocate host CPU state\n");
891 goto out_free_mappings; 891 goto out_free_mappings;
892 } 892 }
893 893
894 for_each_possible_cpu(cpu) { 894 for_each_possible_cpu(cpu) {
895 kvm_kernel_vfp_t *vfp; 895 kvm_cpu_context_t *cpu_ctxt;
896 896
897 vfp = per_cpu_ptr(kvm_host_vfp_state, cpu); 897 cpu_ctxt = per_cpu_ptr(kvm_host_cpu_state, cpu);
898 err = create_hyp_mappings(vfp, vfp + 1); 898 err = create_hyp_mappings(cpu_ctxt, cpu_ctxt + 1);
899 899
900 if (err) { 900 if (err) {
901 kvm_err("Cannot map host VFP state: %d\n", err); 901 kvm_err("Cannot map host CPU state: %d\n", err);
902 goto out_free_vfp; 902 goto out_free_context;
903 } 903 }
904 } 904 }
905 905
@@ -913,7 +913,7 @@ static int init_hyp_mode(void)
913 */ 913 */
914 err = kvm_vgic_hyp_init(); 914 err = kvm_vgic_hyp_init();
915 if (err) 915 if (err)
916 goto out_free_vfp; 916 goto out_free_context;
917 917
918#ifdef CONFIG_KVM_ARM_VGIC 918#ifdef CONFIG_KVM_ARM_VGIC
919 vgic_present = true; 919 vgic_present = true;
@@ -935,8 +935,8 @@ static int init_hyp_mode(void)
935 kvm_info("Hyp mode initialized successfully\n"); 935 kvm_info("Hyp mode initialized successfully\n");
936 936
937 return 0; 937 return 0;
938out_free_vfp: 938out_free_context:
939 free_percpu(kvm_host_vfp_state); 939 free_percpu(kvm_host_cpu_state);
940out_free_mappings: 940out_free_mappings:
941 free_hyp_pgds(); 941 free_hyp_pgds();
942out_free_stack_pages: 942out_free_stack_pages: