diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2014-06-05 08:08:05 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2014-07-28 09:22:10 -0400 |
commit | 06da28e76b87331ebccdb6d486cfd94835b8be5e (patch) | |
tree | 151e895b815cdb3f5b8039f41073052a615f9cd4 /arch/powerpc | |
parent | 8f42ab2749d00ea15157ab896cfbed73a247b3e1 (diff) |
KVM: PPC: BOOK3S: PR: Emulate instruction counter
Writing to IC is not allowed in the privileged mode.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_emulate.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_hv.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_pr.c | 4 |
5 files changed, 14 insertions, 6 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index bd3caeaeebe1..f9ae69682ce1 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -506,6 +506,7 @@ struct kvm_vcpu_arch { | |||
506 | /* Time base value when we entered the guest */ | 506 | /* Time base value when we entered the guest */ |
507 | u64 entry_tb; | 507 | u64 entry_tb; |
508 | u64 entry_vtb; | 508 | u64 entry_vtb; |
509 | u64 entry_ic; | ||
509 | u32 tcr; | 510 | u32 tcr; |
510 | ulong tsr; /* we need to perform set/clr_bits() which requires ulong */ | 511 | ulong tsr; /* we need to perform set/clr_bits() which requires ulong */ |
511 | u32 ivor[64]; | 512 | u32 ivor[64]; |
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index ddce1ea8ac4a..90aa5c750e08 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -649,6 +649,9 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) | |||
649 | case KVM_REG_PPC_VTB: | 649 | case KVM_REG_PPC_VTB: |
650 | val = get_reg_val(reg->id, vcpu->arch.vtb); | 650 | val = get_reg_val(reg->id, vcpu->arch.vtb); |
651 | break; | 651 | break; |
652 | case KVM_REG_PPC_IC: | ||
653 | val = get_reg_val(reg->id, vcpu->arch.ic); | ||
654 | break; | ||
652 | default: | 655 | default: |
653 | r = -EINVAL; | 656 | r = -EINVAL; |
654 | break; | 657 | break; |
@@ -756,6 +759,9 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) | |||
756 | case KVM_REG_PPC_VTB: | 759 | case KVM_REG_PPC_VTB: |
757 | vcpu->arch.vtb = set_reg_val(reg->id, val); | 760 | vcpu->arch.vtb = set_reg_val(reg->id, val); |
758 | break; | 761 | break; |
762 | case KVM_REG_PPC_IC: | ||
763 | vcpu->arch.ic = set_reg_val(reg->id, val); | ||
764 | break; | ||
759 | default: | 765 | default: |
760 | r = -EINVAL; | 766 | r = -EINVAL; |
761 | break; | 767 | break; |
diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 1bb16a59dcbc..84fddcd6c1f8 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c | |||
@@ -580,6 +580,9 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val | |||
580 | case SPRN_VTB: | 580 | case SPRN_VTB: |
581 | *spr_val = vcpu->arch.vtb; | 581 | *spr_val = vcpu->arch.vtb; |
582 | break; | 582 | break; |
583 | case SPRN_IC: | ||
584 | *spr_val = vcpu->arch.ic; | ||
585 | break; | ||
583 | case SPRN_GQR0: | 586 | case SPRN_GQR0: |
584 | case SPRN_GQR1: | 587 | case SPRN_GQR1: |
585 | case SPRN_GQR2: | 588 | case SPRN_GQR2: |
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 315e8849ecf3..1562acfa05bf 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c | |||
@@ -894,9 +894,6 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id, | |||
894 | case KVM_REG_PPC_CIABR: | 894 | case KVM_REG_PPC_CIABR: |
895 | *val = get_reg_val(id, vcpu->arch.ciabr); | 895 | *val = get_reg_val(id, vcpu->arch.ciabr); |
896 | break; | 896 | break; |
897 | case KVM_REG_PPC_IC: | ||
898 | *val = get_reg_val(id, vcpu->arch.ic); | ||
899 | break; | ||
900 | case KVM_REG_PPC_CSIGR: | 897 | case KVM_REG_PPC_CSIGR: |
901 | *val = get_reg_val(id, vcpu->arch.csigr); | 898 | *val = get_reg_val(id, vcpu->arch.csigr); |
902 | break; | 899 | break; |
@@ -1091,9 +1088,6 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id, | |||
1091 | if ((vcpu->arch.ciabr & CIABR_PRIV) == CIABR_PRIV_HYPER) | 1088 | if ((vcpu->arch.ciabr & CIABR_PRIV) == CIABR_PRIV_HYPER) |
1092 | vcpu->arch.ciabr &= ~CIABR_PRIV; /* disable */ | 1089 | vcpu->arch.ciabr &= ~CIABR_PRIV; /* disable */ |
1093 | break; | 1090 | break; |
1094 | case KVM_REG_PPC_IC: | ||
1095 | vcpu->arch.ic = set_reg_val(id, *val); | ||
1096 | break; | ||
1097 | case KVM_REG_PPC_CSIGR: | 1091 | case KVM_REG_PPC_CSIGR: |
1098 | vcpu->arch.csigr = set_reg_val(id, *val); | 1092 | vcpu->arch.csigr = set_reg_val(id, *val); |
1099 | break; | 1093 | break; |
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index d2deb9e45095..3da412e16b3a 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c | |||
@@ -126,6 +126,8 @@ void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu *svcpu, | |||
126 | */ | 126 | */ |
127 | vcpu->arch.entry_tb = get_tb(); | 127 | vcpu->arch.entry_tb = get_tb(); |
128 | vcpu->arch.entry_vtb = get_vtb(); | 128 | vcpu->arch.entry_vtb = get_vtb(); |
129 | if (cpu_has_feature(CPU_FTR_ARCH_207S)) | ||
130 | vcpu->arch.entry_ic = mfspr(SPRN_IC); | ||
129 | svcpu->in_use = true; | 131 | svcpu->in_use = true; |
130 | } | 132 | } |
131 | 133 | ||
@@ -178,6 +180,8 @@ void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, | |||
178 | vcpu->arch.purr += get_tb() - vcpu->arch.entry_tb; | 180 | vcpu->arch.purr += get_tb() - vcpu->arch.entry_tb; |
179 | vcpu->arch.spurr += get_tb() - vcpu->arch.entry_tb; | 181 | vcpu->arch.spurr += get_tb() - vcpu->arch.entry_tb; |
180 | vcpu->arch.vtb += get_vtb() - vcpu->arch.entry_vtb; | 182 | vcpu->arch.vtb += get_vtb() - vcpu->arch.entry_vtb; |
183 | if (cpu_has_feature(CPU_FTR_ARCH_207S)) | ||
184 | vcpu->arch.ic += mfspr(SPRN_IC) - vcpu->arch.entry_ic; | ||
181 | svcpu->in_use = false; | 185 | svcpu->in_use = false; |
182 | 186 | ||
183 | out: | 187 | out: |