diff options
author | Alexander Graf <agraf@suse.de> | 2010-01-07 20:58:02 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-03-01 10:35:47 -0500 |
commit | 992b5b29b5ae254c416c62faf98d59a6cf970027 (patch) | |
tree | 52b4e5a8226261cc936225636d58d9b7e8c46976 /arch/powerpc | |
parent | 8e5b26b55a8b6aee2c789b1d20ec715f9e4bea5c (diff) |
KVM: PPC: Add helpers for CR, XER
We now have helpers for the GPRs, so let's also add some for CR and XER.
Having them in the PACA simplifies code a lot, as we don't need to care
about where to store CC or not to overflow any integers.
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/kvm_ppc.h | 40 | ||||
-rw-r--r-- | arch/powerpc/kvm/44x_tlb.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 8 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke.c | 8 |
4 files changed, 52 insertions, 10 deletions
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index ba01b9c1d388..d60b2f0cdcf2 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h | |||
@@ -108,6 +108,26 @@ static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) | |||
108 | return vcpu->arch.gpr[num]; | 108 | return vcpu->arch.gpr[num]; |
109 | } | 109 | } |
110 | 110 | ||
111 | static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) | ||
112 | { | ||
113 | vcpu->arch.cr = val; | ||
114 | } | ||
115 | |||
116 | static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) | ||
117 | { | ||
118 | return vcpu->arch.cr; | ||
119 | } | ||
120 | |||
121 | static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val) | ||
122 | { | ||
123 | vcpu->arch.xer = val; | ||
124 | } | ||
125 | |||
126 | static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu) | ||
127 | { | ||
128 | return vcpu->arch.xer; | ||
129 | } | ||
130 | |||
111 | #else | 131 | #else |
112 | 132 | ||
113 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) | 133 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) |
@@ -120,6 +140,26 @@ static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) | |||
120 | return vcpu->arch.gpr[num]; | 140 | return vcpu->arch.gpr[num]; |
121 | } | 141 | } |
122 | 142 | ||
143 | static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) | ||
144 | { | ||
145 | vcpu->arch.cr = val; | ||
146 | } | ||
147 | |||
148 | static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) | ||
149 | { | ||
150 | return vcpu->arch.cr; | ||
151 | } | ||
152 | |||
153 | static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val) | ||
154 | { | ||
155 | vcpu->arch.xer = val; | ||
156 | } | ||
157 | |||
158 | static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu) | ||
159 | { | ||
160 | return vcpu->arch.xer; | ||
161 | } | ||
162 | |||
123 | #endif | 163 | #endif |
124 | 164 | ||
125 | #endif /* __POWERPC_KVM_PPC_H__ */ | 165 | #endif /* __POWERPC_KVM_PPC_H__ */ |
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c index 8b3773669c97..2570fcc7665d 100644 --- a/arch/powerpc/kvm/44x_tlb.c +++ b/arch/powerpc/kvm/44x_tlb.c | |||
@@ -506,10 +506,12 @@ int kvmppc_44x_emul_tlbsx(struct kvm_vcpu *vcpu, u8 rt, u8 ra, u8 rb, u8 rc) | |||
506 | 506 | ||
507 | gtlb_index = kvmppc_44x_tlb_index(vcpu, ea, pid, as); | 507 | gtlb_index = kvmppc_44x_tlb_index(vcpu, ea, pid, as); |
508 | if (rc) { | 508 | if (rc) { |
509 | u32 cr = kvmppc_get_cr(vcpu); | ||
510 | |||
509 | if (gtlb_index < 0) | 511 | if (gtlb_index < 0) |
510 | vcpu->arch.cr &= ~0x20000000; | 512 | kvmppc_set_cr(vcpu, cr & ~0x20000000); |
511 | else | 513 | else |
512 | vcpu->arch.cr |= 0x20000000; | 514 | kvmppc_set_cr(vcpu, cr | 0x20000000); |
513 | } | 515 | } |
514 | kvmppc_set_gpr(vcpu, rt, gtlb_index); | 516 | kvmppc_set_gpr(vcpu, rt, gtlb_index); |
515 | 517 | ||
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 574b24fb6e0e..09ba8dbaabab 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -717,10 +717,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
717 | int i; | 717 | int i; |
718 | 718 | ||
719 | regs->pc = vcpu->arch.pc; | 719 | regs->pc = vcpu->arch.pc; |
720 | regs->cr = vcpu->arch.cr; | 720 | regs->cr = kvmppc_get_cr(vcpu); |
721 | regs->ctr = vcpu->arch.ctr; | 721 | regs->ctr = vcpu->arch.ctr; |
722 | regs->lr = vcpu->arch.lr; | 722 | regs->lr = vcpu->arch.lr; |
723 | regs->xer = vcpu->arch.xer; | 723 | regs->xer = kvmppc_get_xer(vcpu); |
724 | regs->msr = vcpu->arch.msr; | 724 | regs->msr = vcpu->arch.msr; |
725 | regs->srr0 = vcpu->arch.srr0; | 725 | regs->srr0 = vcpu->arch.srr0; |
726 | regs->srr1 = vcpu->arch.srr1; | 726 | regs->srr1 = vcpu->arch.srr1; |
@@ -744,10 +744,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
744 | int i; | 744 | int i; |
745 | 745 | ||
746 | vcpu->arch.pc = regs->pc; | 746 | vcpu->arch.pc = regs->pc; |
747 | vcpu->arch.cr = regs->cr; | 747 | kvmppc_set_cr(vcpu, regs->cr); |
748 | vcpu->arch.ctr = regs->ctr; | 748 | vcpu->arch.ctr = regs->ctr; |
749 | vcpu->arch.lr = regs->lr; | 749 | vcpu->arch.lr = regs->lr; |
750 | vcpu->arch.xer = regs->xer; | 750 | kvmppc_set_xer(vcpu, regs->xer); |
751 | kvmppc_set_msr(vcpu, regs->msr); | 751 | kvmppc_set_msr(vcpu, regs->msr); |
752 | vcpu->arch.srr0 = regs->srr0; | 752 | vcpu->arch.srr0 = regs->srr0; |
753 | vcpu->arch.srr1 = regs->srr1; | 753 | vcpu->arch.srr1 = regs->srr1; |
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 49af80e4a6e1..338baf9f6b28 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c | |||
@@ -449,10 +449,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
449 | int i; | 449 | int i; |
450 | 450 | ||
451 | regs->pc = vcpu->arch.pc; | 451 | regs->pc = vcpu->arch.pc; |
452 | regs->cr = vcpu->arch.cr; | 452 | regs->cr = kvmppc_get_cr(vcpu); |
453 | regs->ctr = vcpu->arch.ctr; | 453 | regs->ctr = vcpu->arch.ctr; |
454 | regs->lr = vcpu->arch.lr; | 454 | regs->lr = vcpu->arch.lr; |
455 | regs->xer = vcpu->arch.xer; | 455 | regs->xer = kvmppc_get_xer(vcpu); |
456 | regs->msr = vcpu->arch.msr; | 456 | regs->msr = vcpu->arch.msr; |
457 | regs->srr0 = vcpu->arch.srr0; | 457 | regs->srr0 = vcpu->arch.srr0; |
458 | regs->srr1 = vcpu->arch.srr1; | 458 | regs->srr1 = vcpu->arch.srr1; |
@@ -476,10 +476,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
476 | int i; | 476 | int i; |
477 | 477 | ||
478 | vcpu->arch.pc = regs->pc; | 478 | vcpu->arch.pc = regs->pc; |
479 | vcpu->arch.cr = regs->cr; | 479 | kvmppc_set_cr(vcpu, regs->cr); |
480 | vcpu->arch.ctr = regs->ctr; | 480 | vcpu->arch.ctr = regs->ctr; |
481 | vcpu->arch.lr = regs->lr; | 481 | vcpu->arch.lr = regs->lr; |
482 | vcpu->arch.xer = regs->xer; | 482 | kvmppc_set_xer(vcpu, regs->xer); |
483 | kvmppc_set_msr(vcpu, regs->msr); | 483 | kvmppc_set_msr(vcpu, regs->msr); |
484 | vcpu->arch.srr0 = regs->srr0; | 484 | vcpu->arch.srr0 = regs->srr0; |
485 | vcpu->arch.srr1 = regs->srr1; | 485 | vcpu->arch.srr1 = regs->srr1; |