KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface
authorMihai Caraman <mihai.caraman@freescale.com>
Thu, 11 Oct 2012 06:13:29 +0000 (06:13 +0000)
committerAlexander Graf <agraf@suse.de>
Thu, 6 Dec 2012 00:34:20 +0000 (01:34 +0100)
Implement ONE_REG interface for EPCR register adding KVM_REG_PPC_EPCR to
the list of ONE_REG PPC supported registers.

Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
[agraf: remove HV dependency, use get/put_user]
Signed-off-by: Alexander Graf <agraf@suse.de>
Documentation/virtual/kvm/api.txt
arch/powerpc/include/uapi/asm/kvm.h
arch/powerpc/kvm/booke.c

index a5607c5..a4df553 100644 (file)
@@ -1773,6 +1773,7 @@ registers, find a list below:
   PPC   | KVM_REG_PPC_VPA_ADDR  | 64
   PPC   | KVM_REG_PPC_VPA_SLB   | 128
   PPC   | KVM_REG_PPC_VPA_DTL   | 128
+  PPC   | KVM_REG_PPC_EPCR     | 32
 
 4.69 KVM_GET_ONE_REG
 
index 514883d..2fba8a6 100644 (file)
@@ -411,4 +411,6 @@ struct kvm_get_htab_header {
 #define KVM_REG_PPC_VPA_SLB    (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x83)
 #define KVM_REG_PPC_VPA_DTL    (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84)
 
+#define KVM_REG_PPC_EPCR       (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85)
+
 #endif /* __LINUX_KVM_POWERPC_H */
index 037d045..69f1140 100644 (file)
@@ -1388,6 +1388,11 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
                                 &vcpu->arch.dbg_reg.dac[dac], sizeof(u64));
                break;
        }
+#if defined(CONFIG_64BIT)
+       case KVM_REG_PPC_EPCR:
+               r = put_user(vcpu->arch.epcr, (u32 __user *)(long)reg->addr);
+               break;
+#endif
        default:
                break;
        }
@@ -1415,6 +1420,15 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
                             (u64 __user *)(long)reg->addr, sizeof(u64));
                break;
        }
+#if defined(CONFIG_64BIT)
+       case KVM_REG_PPC_EPCR: {
+               u32 new_epcr;
+               r = get_user(new_epcr, (u32 __user *)(long)reg->addr);
+               if (r == 0)
+                       kvmppc_set_epcr(vcpu, new_epcr);
+               break;
+       }
+#endif
        default:
                break;
        }