]> www.infradead.org Git - nvme.git/commitdiff
KVM: arm64: Do not map the host fpsimd state to hyp in pKVM
authorFuad Tabba <tabba@google.com>
Tue, 23 Apr 2024 15:05:19 +0000 (16:05 +0100)
committerMarc Zyngier <maz@kernel.org>
Wed, 1 May 2024 15:48:14 +0000 (16:48 +0100)
pKVM maintains its own state at EL2 for tracking the host fpsimd
state. Therefore, no need to map and share the host's view with
it.

Signed-off-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240423150538.2103045-12-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/fpsimd.c
arch/arm64/kvm/reset.c

index 4609d1b9dddede6355c910238e621ae30fb7a408..74dc5a60f17185ee2e7ca1084d903171f19398ea 100644 (file)
@@ -663,8 +663,6 @@ struct kvm_vcpu_arch {
        struct kvm_guest_debug_arch vcpu_debug_state;
        struct kvm_guest_debug_arch external_debug_state;
 
-       struct task_struct *parent_task;
-
        /* VGIC state */
        struct vgic_cpu vgic_cpu;
        struct arch_timer_cpu timer_cpu;
@@ -1262,7 +1260,6 @@ void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_ctxflush_fp(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu);
-void kvm_vcpu_unshare_task_fp(struct kvm_vcpu *vcpu);
 
 static inline bool kvm_pmu_counter_deferred(struct perf_event_attr *attr)
 {
index d5837d65e4a1b6566a3834a3899d9714e064d534..63a6f82934a68d8bb393d0f74b649b31a846abb3 100644 (file)
 #include <asm/kvm_mmu.h>
 #include <asm/sysreg.h>
 
-void kvm_vcpu_unshare_task_fp(struct kvm_vcpu *vcpu)
-{
-       struct task_struct *p = vcpu->arch.parent_task;
-       struct user_fpsimd_state *fpsimd;
-
-       if (!is_protected_kvm_enabled() || !p)
-               return;
-
-       fpsimd = &p->thread.uw.fpsimd_state;
-       kvm_unshare_hyp(fpsimd, fpsimd + 1);
-       put_task_struct(p);
-}
-
 /*
  * Called on entry to KVM_RUN unless this vcpu previously ran at least
  * once and the most recent prior KVM_RUN for this vcpu was called from
@@ -38,28 +25,18 @@ void kvm_vcpu_unshare_task_fp(struct kvm_vcpu *vcpu)
  */
 int kvm_arch_vcpu_run_map_fp(struct kvm_vcpu *vcpu)
 {
-       int ret;
-
        struct user_fpsimd_state *fpsimd = &current->thread.uw.fpsimd_state;
+       int ret;
 
-       kvm_vcpu_unshare_task_fp(vcpu);
+       /* pKVM has its own tracking of the host fpsimd state. */
+       if (is_protected_kvm_enabled())
+               return 0;
 
        /* Make sure the host task fpsimd state is visible to hyp: */
        ret = kvm_share_hyp(fpsimd, fpsimd + 1);
        if (ret)
                return ret;
 
-       /*
-        * We need to keep current's task_struct pinned until its data has been
-        * unshared with the hypervisor to make sure it is not re-used by the
-        * kernel and donated to someone else while already shared -- see
-        * kvm_vcpu_unshare_task_fp() for the matching put_task_struct().
-        */
-       if (is_protected_kvm_enabled()) {
-               get_task_struct(current);
-               vcpu->arch.parent_task = current;
-       }
-
        return 0;
 }
 
index 68d1d05672bd4fea76329c936291f9b9c37cc5d3..1b7b58cb121f98c3746da33c2d973ef49a428500 100644 (file)
@@ -151,7 +151,6 @@ void kvm_arm_vcpu_destroy(struct kvm_vcpu *vcpu)
 {
        void *sve_state = vcpu->arch.sve_state;
 
-       kvm_vcpu_unshare_task_fp(vcpu);
        kvm_unshare_hyp(vcpu, vcpu + 1);
        if (sve_state)
                kvm_unshare_hyp(sve_state, sve_state + vcpu_sve_state_size(vcpu));