From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 07/39] KVM: PPC: Add helpers for CR, XER
Date: Sat, 13 Feb 2010 10:01:27 +0200 [thread overview]
Message-ID: <1266048119-14325-8-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1266048119-14325-1-git-send-email-avi@redhat.com>
From: Alexander Graf <agraf@suse.de>
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>
---
arch/powerpc/include/asm/kvm_ppc.h | 40 ++++++++++++++++++++++++++++++++++++
arch/powerpc/kvm/44x_tlb.c | 6 +++-
arch/powerpc/kvm/book3s.c | 8 +++---
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 ba01b9c..d60b2f0 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)
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
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)
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 /* __POWERPC_KVM_PPC_H__ */
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c
index 8b37736..2570fcc 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)
gtlb_index = kvmppc_44x_tlb_index(vcpu, ea, pid, as);
if (rc) {
+ u32 cr = kvmppc_get_cr(vcpu);
+
if (gtlb_index < 0)
- vcpu->arch.cr &= ~0x20000000;
+ kvmppc_set_cr(vcpu, cr & ~0x20000000);
else
- vcpu->arch.cr |= 0x20000000;
+ kvmppc_set_cr(vcpu, cr | 0x20000000);
}
kvmppc_set_gpr(vcpu, rt, gtlb_index);
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index 574b24f..09ba8db 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)
int i;
regs->pc = vcpu->arch.pc;
- regs->cr = vcpu->arch.cr;
+ regs->cr = kvmppc_get_cr(vcpu);
regs->ctr = vcpu->arch.ctr;
regs->lr = vcpu->arch.lr;
- regs->xer = vcpu->arch.xer;
+ regs->xer = kvmppc_get_xer(vcpu);
regs->msr = vcpu->arch.msr;
regs->srr0 = vcpu->arch.srr0;
regs->srr1 = vcpu->arch.srr1;
@@ -744,10 +744,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
int i;
vcpu->arch.pc = regs->pc;
- vcpu->arch.cr = regs->cr;
+ kvmppc_set_cr(vcpu, regs->cr);
vcpu->arch.ctr = regs->ctr;
vcpu->arch.lr = regs->lr;
- vcpu->arch.xer = regs->xer;
+ kvmppc_set_xer(vcpu, regs->xer);
kvmppc_set_msr(vcpu, regs->msr);
vcpu->arch.srr0 = regs->srr0;
vcpu->arch.srr1 = regs->srr1;
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 49af80e..338baf9 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)
int i;
regs->pc = vcpu->arch.pc;
- regs->cr = vcpu->arch.cr;
+ regs->cr = kvmppc_get_cr(vcpu);
regs->ctr = vcpu->arch.ctr;
regs->lr = vcpu->arch.lr;
- regs->xer = vcpu->arch.xer;
+ regs->xer = kvmppc_get_xer(vcpu);
regs->msr = vcpu->arch.msr;
regs->srr0 = vcpu->arch.srr0;
regs->srr1 = vcpu->arch.srr1;
@@ -476,10 +476,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
int i;
vcpu->arch.pc = regs->pc;
- vcpu->arch.cr = regs->cr;
+ kvmppc_set_cr(vcpu, regs->cr);
vcpu->arch.ctr = regs->ctr;
vcpu->arch.lr = regs->lr;
- vcpu->arch.xer = regs->xer;
+ kvmppc_set_xer(vcpu, regs->xer);
kvmppc_set_msr(vcpu, regs->msr);
vcpu->arch.srr0 = regs->srr0;
vcpu->arch.srr1 = regs->srr1;
--
1.6.5.3
next prev parent reply other threads:[~2010-02-13 8:09 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-13 8:01 [PATCH 00/39] KVM updates for the 2.6.34 merge window (batch 2/4) Avi Kivity
2010-02-13 8:01 ` [PATCH 01/39] KVM: PPC: Enable lightweight exits again Avi Kivity
2010-02-13 8:01 ` [PATCH 02/39] KVM: x86: Moving PT_*_LEVEL to mmu.h Avi Kivity
2010-02-13 8:01 ` [PATCH 03/39] KVM: x86: Rename gb_page_enable() to get_lpage_level() in kvm_x86_ops Avi Kivity
2010-02-13 8:01 ` [PATCH 04/39] KVM: VMX: Enable EPT 1GB page support Avi Kivity
2010-02-13 8:01 ` [PATCH 05/39] KVM: Fix the explanation of write_emulated Avi Kivity
2010-02-13 8:01 ` [PATCH 06/39] KVM: PPC: Use accessor functions for GPR access Avi Kivity
2010-02-13 8:01 ` Avi Kivity [this message]
2010-02-13 8:01 ` [PATCH 08/39] KVM: PPC: Use PACA backed shadow vcpu Avi Kivity
2010-02-13 8:01 ` [PATCH 09/39] KVM: PPC: Implement 'skip instruction' mode Avi Kivity
2010-02-13 8:01 ` [PATCH 10/39] KVM: PPC: Get rid of unnecessary RFI Avi Kivity
2010-02-13 8:01 ` [PATCH 11/39] KVM: PPC: Call SLB patching code in interrupt safe manner Avi Kivity
2010-02-13 8:01 ` [PATCH 12/39] KVM: PPC: Emulate trap SRR1 flags properly Avi Kivity
2010-02-13 8:01 ` [PATCH 13/39] KVM: PPC: Fix HID5 setting code Avi Kivity
2010-02-13 8:01 ` [PATCH 14/39] KVM: PPC: Pass program interrupt flags to the guest Avi Kivity
2010-02-13 8:01 ` [PATCH 15/39] KVM: PPC: Pass through program interrupts Avi Kivity
2010-02-13 8:01 ` [PATCH 16/39] KVM: PPC: Make large pages work Avi Kivity
2010-02-13 8:01 ` [PATCH 17/39] KVM: VMX: trace clts and lmsw instructions as cr accesses Avi Kivity
2010-02-13 8:01 ` [PATCH 18/39] KVM: Replace read accesses of vcpu->arch.cr0 by an accessor Avi Kivity
2010-02-13 8:01 ` [PATCH 19/39] KVM: VMX: Allow the guest to own some cr0 bits Avi Kivity
2010-02-13 8:01 ` [PATCH 20/39] KVM: Lazify fpu activation and deactivation Avi Kivity
2010-02-13 8:01 ` [PATCH 21/39] KVM: VMX: Give the guest ownership of cr0.ts when the fpu is active Avi Kivity
2010-02-13 8:01 ` [PATCH 22/39] KVM: Set cr0.et when the guest writes cr0 Avi Kivity
2010-02-13 8:01 ` [PATCH 23/39] KVM: SVM: Fix SVM_CR0_SELECTIVE_MASK Avi Kivity
2010-02-13 8:01 ` [PATCH 24/39] KVM: SVM: Initialize fpu_active in init_vmcb() Avi Kivity
2010-02-13 8:01 ` [PATCH 25/39] KVM: SVM: Restore unconditional cr0 intercept under npt Avi Kivity
2010-02-13 8:01 ` [PATCH 26/39] KVM: SVM: Selective cr0 intercept Avi Kivity
2010-02-13 8:01 ` [PATCH 27/39] KVM: SVM: Lazy fpu with npt Avi Kivity
2010-02-13 8:01 ` [PATCH 28/39] KVM: ia64: remove redundant kvm_get_exit_data() NULL tests Avi Kivity
2010-02-13 8:01 ` [PATCH 29/39] KVM: PPC: Export __giveup_vsx Avi Kivity
2010-02-13 8:01 ` [PATCH 30/39] KVM: PPC: Add helper functions to call real mode loaders Avi Kivity
2010-02-13 8:01 ` [PATCH 31/39] KVM: PPC: Add support for FPU/Altivec/VSX Avi Kivity
2010-02-13 8:01 ` [PATCH 32/39] KVM: PPC: Fix initial GPR settings Avi Kivity
2010-02-13 8:01 ` [PATCH 33/39] KVM: PPC: Keep SRR1 flags around in shadow_msr Avi Kivity
2010-02-13 8:01 ` [PATCH 34/39] KVM: PPC: Move Shadow MSR calculation to function Avi Kivity
2010-02-13 8:01 ` [PATCH 35/39] KVM: Add HYPER-V header file Avi Kivity
2010-02-13 8:01 ` [PATCH 36/39] KVM: Implement bare minimum of HYPER-V MSRs Avi Kivity
2010-02-13 8:01 ` [PATCH 37/39] KVM: Add HYPER-V apic access MSRs Avi Kivity
2010-02-13 8:01 ` [PATCH 38/39] KVM: Implement NotifyLongSpinWait HYPER-V hypercall Avi Kivity
2010-02-13 8:01 ` [PATCH 39/39] KVM: rename is_writeble_pte() to is_writable_pte() Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1266048119-14325-8-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome