From: Alexander Graf <agraf@suse.de>
To: kvm-ppc@vger.kernel.org
Cc: Linuxppc-dev <linuxppc-dev@ozlabs.org>, KVM list <kvm@vger.kernel.org>
Subject: [PATCH 14/35] KVM: PPC: Move BAT handling code into spr handler
Date: Tue, 31 Aug 2010 04:31:55 +0200 [thread overview]
Message-ID: <1283221937-21006-15-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1283221937-21006-1-git-send-email-agraf@suse.de>
The current approach duplicates the spr->bat finding logic and makes it harder
to reuse the actually used variables. So let's move everything down to the spr
handler.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
arch/powerpc/kvm/book3s_emulate.c | 48 ++++++++++++------------------------
1 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c
index f333cb4..4668465 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -264,7 +264,7 @@ void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, bool upper,
}
}
-static u32 kvmppc_read_bat(struct kvm_vcpu *vcpu, int sprn)
+static struct kvmppc_bat *kvmppc_find_bat(struct kvm_vcpu *vcpu, int sprn)
{
struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
struct kvmppc_bat *bat;
@@ -286,35 +286,7 @@ static u32 kvmppc_read_bat(struct kvm_vcpu *vcpu, int sprn)
BUG();
}
- if (sprn % 2)
- return bat->raw >> 32;
- else
- return bat->raw;
-}
-
-static void kvmppc_write_bat(struct kvm_vcpu *vcpu, int sprn, u32 val)
-{
- struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
- struct kvmppc_bat *bat;
-
- switch (sprn) {
- case SPRN_IBAT0U ... SPRN_IBAT3L:
- bat = &vcpu_book3s->ibat[(sprn - SPRN_IBAT0U) / 2];
- break;
- case SPRN_IBAT4U ... SPRN_IBAT7L:
- bat = &vcpu_book3s->ibat[4 + ((sprn - SPRN_IBAT4U) / 2)];
- break;
- case SPRN_DBAT0U ... SPRN_DBAT3L:
- bat = &vcpu_book3s->dbat[(sprn - SPRN_DBAT0U) / 2];
- break;
- case SPRN_DBAT4U ... SPRN_DBAT7L:
- bat = &vcpu_book3s->dbat[4 + ((sprn - SPRN_DBAT4U) / 2)];
- break;
- default:
- BUG();
- }
-
- kvmppc_set_bat(vcpu, bat, !(sprn % 2), val);
+ return bat;
}
int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
@@ -339,12 +311,16 @@ int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
case SPRN_IBAT4U ... SPRN_IBAT7L:
case SPRN_DBAT0U ... SPRN_DBAT3L:
case SPRN_DBAT4U ... SPRN_DBAT7L:
- kvmppc_write_bat(vcpu, sprn, (u32)spr_val);
+ {
+ struct kvmppc_bat *bat = kvmppc_find_bat(vcpu, sprn);
+
+ kvmppc_set_bat(vcpu, bat, !(sprn % 2), (u32)spr_val);
/* BAT writes happen so rarely that we're ok to flush
* everything here */
kvmppc_mmu_pte_flush(vcpu, 0, 0);
kvmppc_mmu_flush_segments(vcpu);
break;
+ }
case SPRN_HID0:
to_book3s(vcpu)->hid[0] = spr_val;
break;
@@ -434,8 +410,16 @@ int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
case SPRN_IBAT4U ... SPRN_IBAT7L:
case SPRN_DBAT0U ... SPRN_DBAT3L:
case SPRN_DBAT4U ... SPRN_DBAT7L:
- kvmppc_set_gpr(vcpu, rt, kvmppc_read_bat(vcpu, sprn));
+ {
+ struct kvmppc_bat *bat = kvmppc_find_bat(vcpu, sprn);
+
+ if (sprn % 2)
+ kvmppc_set_gpr(vcpu, rt, bat->raw >> 32);
+ else
+ kvmppc_set_gpr(vcpu, rt, bat->raw);
+
break;
+ }
case SPRN_SDR1:
kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->sdr1);
break;
--
1.6.0.2
next prev parent reply other threads:[~2010-08-31 2:32 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-31 2:31 [PULL 00/35] KVM: PPC: End-August patch queue Alexander Graf
2010-08-31 2:31 ` [PATCH 01/35] KVM: PPC: Move EXIT_DEBUG partially to tracepoints Alexander Graf
2010-08-31 2:31 ` [PATCH 02/35] KVM: PPC: Move book3s_64 mmu map debug print to trace point Alexander Graf
2010-08-31 2:31 ` [PATCH 07/35] KVM: PPC: Preload magic page when in kernel mode Alexander Graf
2010-08-31 2:31 ` [PATCH 08/35] KVM: PPC: Don't flush PTEs on NX/RO hit Alexander Graf
2010-08-31 2:31 ` [PATCH 10/35] KVM: PPC: Move slb debugging to tracepoints Alexander Graf
[not found] ` <1283221937-21006-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
2010-08-31 2:31 ` [PATCH 03/35] KVM: PPC: Add tracepoint for generic mmu map Alexander Graf
2010-08-31 2:31 ` [PATCH 04/35] KVM: PPC: Move pte invalidate debug code to tracepoint Alexander Graf
2010-08-31 2:31 ` [PATCH 05/35] KVM: PPC: Fix sid map search after flush Alexander Graf
2010-08-31 2:31 ` [PATCH 06/35] KVM: PPC: Add tracepoints for generic spte flushes Alexander Graf
2010-08-31 2:31 ` [PATCH 09/35] KVM: PPC: Make invalidation code more reliable Alexander Graf
2010-08-31 2:31 ` [PATCH 11/35] KVM: PPC: Revert "KVM: PPC: Use kernel hash function" Alexander Graf
2010-08-31 2:31 ` [PATCH 12/35] KVM: PPC: Remove unused define Alexander Graf
2010-08-31 2:31 ` [PATCH 16/35] KVM: PPC: Put segment registers in shared page Alexander Graf
2010-08-31 2:32 ` [PATCH 19/35] KVM: PPC: Update int_pending also on dequeue Alexander Graf
2010-08-31 2:32 ` [PATCH 21/35] KVM: PPC: Force enable nap on KVM Alexander Graf
2010-08-31 2:32 ` [PATCH 24/35] KVM: PPC: initialize IVORs in addition to IVPR Alexander Graf
2010-08-31 2:32 ` [PATCH 29/35] KVM: PPC: Fix CONFIG_KVM_GUEST && !CONFIG_KVM case Alexander Graf
2010-08-31 2:32 ` [PATCH 33/35] KVM: PPC: e500_tlb: Fix a minor copy-paste tracing bug Alexander Graf
2010-08-31 2:32 ` [PATCH 35/35] KVM: PPC: Add documentation for magic page enhancements Alexander Graf
2010-08-31 2:31 ` [PATCH 13/35] KVM: PPC: Add feature bitmap for magic page Alexander Graf
2010-08-31 2:31 ` Alexander Graf [this message]
2010-08-31 2:31 ` [PATCH 15/35] KVM: PPC: Interpret SR registers on demand Alexander Graf
2010-08-31 2:31 ` [PATCH 17/35] KVM: PPC: Add mtsrin PV code Alexander Graf
2010-08-31 2:31 ` [PATCH 18/35] KVM: PPC: Make PV mtmsr work with r30 and r31 Alexander Graf
2010-08-31 2:32 ` [PATCH 20/35] KVM: PPC: Make PV mtmsrd L=1 " Alexander Graf
2010-08-31 2:32 ` [PATCH 22/35] KVM: PPC: Implement correct SID mapping on Book3s_32 Alexander Graf
2010-08-31 2:32 ` [PATCH 23/35] KVM: PPC: Don't put MSR_POW in MSR Alexander Graf
2010-08-31 2:32 ` [PATCH 25/35] KVM: PPC: fix compilation of "dump tlbs" debug function Alexander Graf
2010-08-31 2:32 ` [PATCH 26/35] KVM: PPC: allow ppc440gp to pass the compatibility check Alexander Graf
2010-08-31 2:32 ` [PATCH 27/35] KVM: PPC: Enable napping only for Book3s_64 Alexander Graf
2010-08-31 2:32 ` [PATCH 28/35] KVM: PPC: Implement Level interrupts on Book3S Alexander Graf
2010-08-31 2:32 ` [PATCH 30/35] KVM: PPC: Expose level based interrupt cap Alexander Graf
2010-08-31 2:32 ` [PATCH 31/35] KVM: PPC: Implement level interrupts for BookE Alexander Graf
2010-08-31 2:32 ` [PATCH 32/35] KVM: PPC: Document KVM_INTERRUPT ioctl Alexander Graf
2010-08-31 2:32 ` [PATCH 34/35] KVM: PPC: Fix compile error in e500_tlb.c Alexander Graf
2010-09-01 7:50 ` [PULL 00/35] KVM: PPC: End-August patch queue 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=1283221937-21006-15-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).