Commit 992b5b29 authored by Alexander Graf's avatar Alexander Graf Committed by Marcelo Tosatti

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: default avatarAlexander Graf <agraf@suse.de>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 8e5b26b5
...@@ -108,6 +108,26 @@ static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) ...@@ -108,6 +108,26 @@ static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
return vcpu->arch.gpr[num]; return vcpu->arch.gpr[num];
} }
static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
{
vcpu->arch.cr = val;
}
static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
{
return vcpu->arch.cr;
}
static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
{
vcpu->arch.xer = val;
}
static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
{
return vcpu->arch.xer;
}
#else #else
static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) 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,6 +140,26 @@ static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
return vcpu->arch.gpr[num]; return vcpu->arch.gpr[num];
} }
static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
{
vcpu->arch.cr = val;
}
static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
{
return vcpu->arch.cr;
}
static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
{
vcpu->arch.xer = val;
}
static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
{
return vcpu->arch.xer;
}
#endif #endif
#endif /* __POWERPC_KVM_PPC_H__ */ #endif /* __POWERPC_KVM_PPC_H__ */
...@@ -506,10 +506,12 @@ int kvmppc_44x_emul_tlbsx(struct kvm_vcpu *vcpu, u8 rt, u8 ra, u8 rb, u8 rc) ...@@ -506,10 +506,12 @@ int kvmppc_44x_emul_tlbsx(struct kvm_vcpu *vcpu, u8 rt, u8 ra, u8 rb, u8 rc)
gtlb_index = kvmppc_44x_tlb_index(vcpu, ea, pid, as); gtlb_index = kvmppc_44x_tlb_index(vcpu, ea, pid, as);
if (rc) { if (rc) {
u32 cr = kvmppc_get_cr(vcpu);
if (gtlb_index < 0) if (gtlb_index < 0)
vcpu->arch.cr &= ~0x20000000; kvmppc_set_cr(vcpu, cr & ~0x20000000);
else else
vcpu->arch.cr |= 0x20000000; kvmppc_set_cr(vcpu, cr | 0x20000000);
} }
kvmppc_set_gpr(vcpu, rt, gtlb_index); kvmppc_set_gpr(vcpu, rt, gtlb_index);
......
...@@ -717,10 +717,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) ...@@ -717,10 +717,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
int i; int i;
regs->pc = vcpu->arch.pc; regs->pc = vcpu->arch.pc;
regs->cr = vcpu->arch.cr; regs->cr = kvmppc_get_cr(vcpu);
regs->ctr = vcpu->arch.ctr; regs->ctr = vcpu->arch.ctr;
regs->lr = vcpu->arch.lr; regs->lr = vcpu->arch.lr;
regs->xer = vcpu->arch.xer; regs->xer = kvmppc_get_xer(vcpu);
regs->msr = vcpu->arch.msr; regs->msr = vcpu->arch.msr;
regs->srr0 = vcpu->arch.srr0; regs->srr0 = vcpu->arch.srr0;
regs->srr1 = vcpu->arch.srr1; 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,10 +744,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
int i; int i;
vcpu->arch.pc = regs->pc; vcpu->arch.pc = regs->pc;
vcpu->arch.cr = regs->cr; kvmppc_set_cr(vcpu, regs->cr);
vcpu->arch.ctr = regs->ctr; vcpu->arch.ctr = regs->ctr;
vcpu->arch.lr = regs->lr; vcpu->arch.lr = regs->lr;
vcpu->arch.xer = regs->xer; kvmppc_set_xer(vcpu, regs->xer);
kvmppc_set_msr(vcpu, regs->msr); kvmppc_set_msr(vcpu, regs->msr);
vcpu->arch.srr0 = regs->srr0; vcpu->arch.srr0 = regs->srr0;
vcpu->arch.srr1 = regs->srr1; vcpu->arch.srr1 = regs->srr1;
......
...@@ -449,10 +449,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) ...@@ -449,10 +449,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
int i; int i;
regs->pc = vcpu->arch.pc; regs->pc = vcpu->arch.pc;
regs->cr = vcpu->arch.cr; regs->cr = kvmppc_get_cr(vcpu);
regs->ctr = vcpu->arch.ctr; regs->ctr = vcpu->arch.ctr;
regs->lr = vcpu->arch.lr; regs->lr = vcpu->arch.lr;
regs->xer = vcpu->arch.xer; regs->xer = kvmppc_get_xer(vcpu);
regs->msr = vcpu->arch.msr; regs->msr = vcpu->arch.msr;
regs->srr0 = vcpu->arch.srr0; regs->srr0 = vcpu->arch.srr0;
regs->srr1 = vcpu->arch.srr1; 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,10 +476,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
int i; int i;
vcpu->arch.pc = regs->pc; vcpu->arch.pc = regs->pc;
vcpu->arch.cr = regs->cr; kvmppc_set_cr(vcpu, regs->cr);
vcpu->arch.ctr = regs->ctr; vcpu->arch.ctr = regs->ctr;
vcpu->arch.lr = regs->lr; vcpu->arch.lr = regs->lr;
vcpu->arch.xer = regs->xer; kvmppc_set_xer(vcpu, regs->xer);
kvmppc_set_msr(vcpu, regs->msr); kvmppc_set_msr(vcpu, regs->msr);
vcpu->arch.srr0 = regs->srr0; vcpu->arch.srr0 = regs->srr0;
vcpu->arch.srr1 = regs->srr1; vcpu->arch.srr1 = regs->srr1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment