KVM: s390: clear the pfault queue if user space sets the invalid token
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Thu, 9 Oct 2014 13:01:38 +0000 (15:01 +0200)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Fri, 23 Jan 2015 12:25:36 +0000 (13:25 +0100)
We need a way to clear the async pfault queue from user space (e.g.
for resets and SIGP SET ARCHITECTURE).

This patch simply clears the queue as soon as user space sets the
invalid pfault token. The definition of the invalid token is moved
to uapi.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
arch/s390/include/asm/kvm_host.h
arch/s390/include/uapi/asm/kvm.h
arch/s390/kvm/kvm-s390.c

index 4de479e47f714aae86149887df9eb414526abc67..b6170520380b68b8048e6b081f18468e18e39656 100644 (file)
@@ -469,7 +469,6 @@ struct kvm_vcpu_arch {
        };
        struct gmap *gmap;
        struct kvm_guestdbg_info_arch guestdbg;
-#define KVM_S390_PFAULT_TOKEN_INVALID  (-1UL)
        unsigned long pfault_token;
        unsigned long pfault_select;
        unsigned long pfault_compare;
index 9c01159cf6678e23466d9c85383d6d73d2f58137..7e9165e1bec5094c0c2b904ef5fa3d61f396c068 100644 (file)
@@ -108,6 +108,9 @@ struct kvm_guest_debug_arch {
        struct kvm_hw_breakpoint __user *hw_bp;
 };
 
+/* for KVM_SYNC_PFAULT and KVM_REG_S390_PFTOKEN */
+#define KVM_S390_PFAULT_TOKEN_INVALID  0xffffffffffffffffULL
+
 #define KVM_SYNC_PREFIX (1UL << 0)
 #define KVM_SYNC_GPRS   (1UL << 1)
 #define KVM_SYNC_ACRS   (1UL << 2)
index 9bdc9f927e825a7d068bf52e117fa3d5eeada8b7..bfb2b990da9b4bc9a51feb1e9d8d152c02b5f1aa 100644 (file)
@@ -936,6 +936,8 @@ static int kvm_arch_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
        case KVM_REG_S390_PFTOKEN:
                r = get_user(vcpu->arch.pfault_token,
                             (u64 __user *)reg->addr);
+               if (vcpu->arch.pfault_token == KVM_S390_PFAULT_TOKEN_INVALID)
+                       kvm_clear_async_pf_completion_queue(vcpu);
                break;
        case KVM_REG_S390_PFCOMPARE:
                r = get_user(vcpu->arch.pfault_compare,
@@ -1408,6 +1410,8 @@ static void sync_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
                vcpu->arch.pfault_token = kvm_run->s.regs.pft;
                vcpu->arch.pfault_select = kvm_run->s.regs.pfs;
                vcpu->arch.pfault_compare = kvm_run->s.regs.pfc;
+               if (vcpu->arch.pfault_token == KVM_S390_PFAULT_TOKEN_INVALID)
+                       kvm_clear_async_pf_completion_queue(vcpu);
        }
        kvm_run->kvm_dirty_regs = 0;
 }