kvm: ppc: Rename "struct tlbe" to "struct
Subsystems (2)
PATCH 1/1 kvm: ppc: Rename "struct tlbe" to "struct
# HG changeset patch
# User Hollis Blanchard <[email protected]>
# Date 1221162418 18000
# Node ID b09c4d295a8e971b63bcd8409d544498fc71503c # Parent 0f01a4354a6aac06b3fe7062e6d4ee538286c405
kvm: ppc: Rename "struct tlbe" to "struct kvmppc_44x_tlbe"
This will ease ports to other cores.
Also remove unused "struct kvm_tlb" while we're at it.
---
6 files changed, 33 insertions(+), 34 deletions(-) arch/powerpc/include/asm/kvm_host.h | 6 +++--- arch/powerpc/include/asm/kvm_ppc.h | 5 ----- arch/powerpc/kernel/asm-offsets.c | 2 +- arch/powerpc/kvm/44x_tlb.c | 22 ++++++++++++---------- arch/powerpc/kvm/44x_tlb.h | 24 +++++++++++++----------- arch/powerpc/kvm/booke_guest.c | 8 ++++----
arch/powerpc/include/asm/kvm_host.h +3 -3
@@ -64,7 +64,7 @@ struct kvm_vcpu_stat {u32 halt_wakeup; }; -struct tlbe { +struct kvmppc_44x_tlbe {u32 tid;/* Only the low 8 bits are used. */ u32 word0;u32 word1;
@@ -76,9 +76,9 @@ struct kvm_arch {struct kvm_vcpu_arch {/* Unmodified copy of the guest's TLB. */ -struct tlbe guest_tlb[PPC44x_TLB_SIZE]; +struct kvmppc_44x_tlbe guest_tlb[PPC44x_TLB_SIZE];/* TLB that's actually used when the guest is running. */ -struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; +struct kvmppc_44x_tlbe shadow_tlb[PPC44x_TLB_SIZE];/* Pages which are referenced in the shadow TLB. */ struct page *shadow_pages[PPC44x_TLB_SIZE];
arch/powerpc/include/asm/kvm_ppc.h +0 -5
@@ -28,11 +28,6 @@#include <linux/types.h> #include <linux/kvm_types.h> #include <linux/kvm_host.h> - -struct kvm_tlb { -struct tlbe guest_tlb[PPC44x_TLB_SIZE]; -struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; -};enum emulation_result {EMULATE_DONE ,/* no further processing */
arch/powerpc/kernel/asm-offsets.c +1 -1
@@ -352,7 +352,7 @@ int main(void)DEFINE (PGD_TABLE_SIZE ,PGD_TABLE_SIZE );#ifdef CONFIG_KVM -DEFINE (TLBE_BYTES ,sizeof (struct tlbe )); +DEFINE (TLBE_BYTES ,sizeof (struct kvmppc_44x_tlbe )); DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack)); DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid));
arch/powerpc/kvm/44x_tlb.c +12 -10
@@ -86,7 +86,7 @@ int kvmppc_44x_tlb_index(struct kvm_vcpu/* XXX Replace loop with fancy data structures. */ for (i =0 ; i < PPC44x_TLB_SIZE; i++) { -struct tlbe *tlbe = &vcpu->arch.guest_tlb[i]; +struct kvmppc_44x_tlbe *tlbe = &vcpu->arch.guest_tlb[i];unsigned int tid;if (eaddr <get_tlb_eaddr (tlbe))
@@ -111,7 +111,8 @@ int kvmppc_44x_tlb_index(struct kvm_vcpureturn -1 ; } -struct tlbe *kvmppc_44x_itlb_search (struct kvm_vcpu *vcpu,gva_t eaddr) +struct kvmppc_44x_tlbe *kvmppc_44x_itlb_search (struct kvm_vcpu *vcpu, +gva_t eaddr) {unsigned int as = !!(vcpu->arch.msr &MSR_IS );unsigned int index;
@@ -122,7 +123,8 @@ struct tlbe *kvmppc_44x_itlb_search(strureturn &vcpu->arch.guest_tlb[index]; } -struct tlbe *kvmppc_44x_dtlb_search (struct kvm_vcpu *vcpu,gva_t eaddr) +struct kvmppc_44x_tlbe *kvmppc_44x_dtlb_search (struct kvm_vcpu *vcpu, +gva_t eaddr) {unsigned int as = !!(vcpu->arch.msr &MSR_DS );unsigned int index;
@@ -133,7 +135,7 @@ struct tlbe *kvmppc_44x_dtlb_search(strureturn &vcpu->arch.guest_tlb[index]; } -static int kvmppc_44x_tlbe_is_writable (struct tlbe *tlbe) +static int kvmppc_44x_tlbe_is_writable (struct kvmppc_44x_tlbe *tlbe) {return tlbe->word2 & (PPC44x_TLB_SW|PPC44x_TLB_UW); }
@@ -141,7 +143,7 @@ static void kvmppc_44x_shadow_release(ststatic void kvmppc_44x_shadow_release (struct kvm_vcpu *vcpu,unsigned int index) { -struct tlbe *stlbe = &vcpu->arch.shadow_tlb[index]; +struct kvmppc_44x_tlbe *stlbe = &vcpu->arch.shadow_tlb[index];struct page *page = vcpu->arch.shadow_pages[index];if (get_tlb_v (stlbe)) {
@@ -163,7 +165,7 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcp u32 flags) {struct page *new_page; -struct tlbe *stlbe; +struct kvmppc_44x_tlbe *stlbe;hpa_t hpaddr;unsigned int victim;
@@ -221,7 +223,7 @@ static void kvmppc_mmu_invalidate(struct/* XXX Replace loop with fancy data structures. */ for (i =0 ; i <= tlb_44x_hwater; i++) { -struct tlbe *stlbe = &vcpu->arch.shadow_tlb[i]; +struct kvmppc_44x_tlbe *stlbe = &vcpu->arch.shadow_tlb[i];unsigned int tid;if (!get_tlb_v (stlbe))
@@ -256,7 +258,7 @@ void kvmppc_mmu_priv_switch(struct kvm_vif (vcpu->arch.swap_pid) {/* XXX Replace loop with fancy data structures. */ for (i =0 ; i <= tlb_44x_hwater; i++) { -struct tlbe *stlbe = &vcpu->arch.shadow_tlb[i]; +struct kvmppc_44x_tlbe *stlbe = &vcpu->arch.shadow_tlb[i];/* Future optimization: clear only userspace mappings. */ kvmppc_44x_shadow_release (vcpu, i);
@@ -273,7 +275,7 @@ void kvmppc_mmu_priv_switch(struct kvm_v }static int tlbe_is_host_safe (const struct kvm_vcpu *vcpu, -const struct tlbe *tlbe) +const struct kvmppc_44x_tlbe *tlbe) {gpa_t gpa;
@@ -299,7 +301,7 @@ int kvmppc_emul_tlbwe(struct kvm_vcpu *vu64 raddr;u64 asid;u32 flags; -struct tlbe *tlbe; +struct kvmppc_44x_tlbe *tlbe;unsigned int index; index = vcpu->arch.gpr[ra];
arch/powerpc/kvm/44x_tlb.h +13 -11
@@ -25,48 +25,50 @@extern int kvmppc_44x_tlb_index (struct kvm_vcpu *vcpu,gva_t eaddr,unsigned int pid,unsigned int as); -extern struct tlbe *kvmppc_44x_dtlb_search (struct kvm_vcpu *vcpu,gva_t eaddr); -extern struct tlbe *kvmppc_44x_itlb_search (struct kvm_vcpu *vcpu,gva_t eaddr); +extern struct kvmppc_44x_tlbe *kvmppc_44x_dtlb_search (struct kvm_vcpu *vcpu, +gva_t eaddr); +extern struct kvmppc_44x_tlbe *kvmppc_44x_itlb_search (struct kvm_vcpu *vcpu, +gva_t eaddr);/* TLB helper functions */ -static inline unsigned int get_tlb_size (const struct tlbe *tlbe) +static inline unsigned int get_tlb_size (const struct kvmppc_44x_tlbe *tlbe) {return (tlbe->word0 >>4 ) &0xf ; } -static inline gva_t get_tlb_eaddr (const struct tlbe *tlbe) +static inline gva_t get_tlb_eaddr (const struct kvmppc_44x_tlbe *tlbe) {return tlbe->word0 &0xfffffc00 ; } -static inline gva_t get_tlb_bytes (const struct tlbe *tlbe) +static inline gva_t get_tlb_bytes (const struct kvmppc_44x_tlbe *tlbe) {unsigned int pgsize =get_tlb_size (tlbe);return 1 <<10 << (pgsize <<1 ); } -static inline gva_t get_tlb_end (const struct tlbe *tlbe) +static inline gva_t get_tlb_end (const struct kvmppc_44x_tlbe *tlbe) {return get_tlb_eaddr (tlbe) +get_tlb_bytes (tlbe) -1 ; } -static inline u64 get_tlb_raddr (const struct tlbe *tlbe) +static inline u64 get_tlb_raddr (const struct kvmppc_44x_tlbe *tlbe) {u64 word1 = tlbe->word1;return ((word1 &0xf ) <<32 ) | (word1 &0xfffffc00 ); } -static inline unsigned int get_tlb_tid (const struct tlbe *tlbe) +static inline unsigned int get_tlb_tid (const struct kvmppc_44x_tlbe *tlbe) {return tlbe->tid &0xff ; } -static inline unsigned int get_tlb_ts (const struct tlbe *tlbe) +static inline unsigned int get_tlb_ts (const struct kvmppc_44x_tlbe *tlbe) {return (tlbe->word0 >>8 ) &0x1 ; } -static inline unsigned int get_tlb_v (const struct tlbe *tlbe) +static inline unsigned int get_tlb_v (const struct kvmppc_44x_tlbe *tlbe) {return (tlbe->word0 >>9 ) &0x1 ; }
@@ -81,7 +83,7 @@ static inline unsigned int get_mmucr_stsreturn (vcpu->arch.mmucr >>16 ) &0x1 ; } -static inline gpa_t tlb_xlate (struct tlbe *tlbe,gva_t eaddr) +static inline gpa_t tlb_xlate (struct kvmppc_44x_tlbe *tlbe,gva_t eaddr) {unsigned int pgmask =get_tlb_bytes (tlbe) -1 ;
arch/powerpc/kvm/booke_guest.c +4 -4
@@ -307,7 +307,7 @@ int kvmppc_handle_exit(struct kvm_run *rbreak ;case BOOKE_INTERRUPT_DTLB_MISS : { -struct tlbe *gtlbe; +struct kvmppc_44x_tlbe *gtlbe;unsigned long eaddr = vcpu->arch.fault_dear;gfn_t gfn;
@@ -347,7 +347,7 @@ int kvmppc_handle_exit(struct kvm_run *r }case BOOKE_INTERRUPT_ITLB_MISS : { -struct tlbe *gtlbe; +struct kvmppc_44x_tlbe *gtlbe;unsigned long eaddr = vcpu->arch.pc;gfn_t gfn;
@@ -442,7 +442,7 @@ int kvmppc_handle_exit(struct kvm_run *r/* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */ int kvm_arch_vcpu_setup (struct kvm_vcpu *vcpu) { -struct tlbe *tlbe = &vcpu->arch.guest_tlb[0 ]; +struct kvmppc_44x_tlbe *tlbe = &vcpu->arch.guest_tlb[0 ]; tlbe->tid =0 ; tlbe->word0 = PPC44x_TLB_16M | PPC44x_TLB_VALID;
@@ -553,7 +553,7 @@ int kvm_arch_vcpu_ioctl_translate(structint kvm_arch_vcpu_ioctl_translate (struct kvm_vcpu *vcpu,struct kvm_translation *tr) { -struct tlbe *gtlbe; +struct kvmppc_44x_tlbe *gtlbe;int index;gva_t eaddr;u8 pid;
RE: [PATCH 2 of 2] kvm: ppc: Rename "struct tlbe" to "structkvmppc_44x_tlbe"
Quoted 47 lines
-----Original Message-----
From: Hollis Blanchard [mailto:[email protected]]
Sent: Friday, September 12, 2008 3:49 AM
To: [email protected]
Cc: Liu Yu-B13201
Subject: [PATCH 2 of 2] kvm: ppc: Rename "struct tlbe" to "structkvmppc_44x_tlbe"# HG changeset patch
# User Hollis Blanchard <[email protected]>
# Date 1221162418 18000
# Node IDb09c4d295a8e971b63bcd8409d544498fc71503c# Parent0f01a4354a6aac06b3fe7062e6d4ee538286c405
kvm: ppc: Rename "struct tlbe" to "structkvmppc_44x_tlbe"This will ease ports to other cores.
Also remove unused "struct
kvm_tlb" while we're at it.Signed-off-by Hollis Blanchard <[email protected]>---
6 files changed, 33 insertions(+), 34 deletions(-) arch/powerpc/include/asm/kvm_host.h | 6 +++--- arch/powerpc/include/asm/kvm_ppc.h | 5 ----- arch/powerpc/kernel/asm-offsets.c | 2 +- arch/powerpc/kvm/44x_tlb.c | 22 ++++++++++++---------- arch/powerpc/kvm/44x_tlb.h | 24 +++++++++++++----------- arch/powerpc/kvm/booke_guest.c | 8 ++++----arch/powerpc/include/asm/kvm_host.h +1
-1@@ -64,7 +64,7 @@ struct kvm_vcpu_stat {u32 halt_wakeup; }; -struct tlbe { +struct kvmppc_44x_tlbe {u32 tid;/* Only the low 8 bits are used. */ u32 word0;u32 word1;@@ -76,9 +76,9 @@ struct kvm_arch {
arch/powerpc/include/asm/kvm_host.h struct kvm_arch { · line 84
Quoted 10 lines
arch/powerpc/include/asm/kvm_host.h +2
-2struct kvm_vcpu_arch {/* Unmodified copy of the guest's TLB. */ -struct tlbe guest_tlb[PPC44x_TLB_SIZE]; +struct kvmppc_44x_tlbe guest_tlb[PPC44x_TLB_SIZE];/* TLB that's actually used when the guest is running. */ -struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; +struct kvmppc_44x_tlbe shadow_tlb[PPC44x_TLB_SIZE];/* Pages which are referenced in the shadow TLB. */ struct page *shadow_pages[PPC44x_TLB_SIZE];
I have been thinking about merge kvm_vcpu_arch of 44x and e500. But I'm not sure whether it's worth doing this.
RE: [PATCH 2 of 2] kvm: ppc: Rename "struct tlbe" to
In reply to Hollis BlanchardQuoted 16 lines · On Fri, 2008-09-12 at 11:10 +0800, Liu Yu-B13201 wrote:
arch/powerpc/include/asm/kvm_host.h struct kvm_arch { · line 84
Quoted 13 lines
arch/powerpc/include/asm/kvm_host.h +2
-2@@ -76,9 +76,9 @@ struct kvm_arch {struct kvm_vcpu_arch {/* Unmodified copy of the guest's TLB. */ -struct tlbe guest_tlb[PPC44x_TLB_SIZE]; +struct kvmppc_44x_tlbe guest_tlb[PPC44x_TLB_SIZE];/* TLB that's actually used when the guest is running. */ -struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; +struct kvmppc_44x_tlbe shadow_tlb[PPC44x_TLB_SIZE];/* Pages which are referenced in the shadow TLB. */ struct page *shadow_pages[PPC44x_TLB_SIZE];I have been thinking about merge
kvm_vcpu_archof 44x and e500. But I'm not sure whether it's worth doing this.
We could do implement a scheme like to_vmx() in arch/x86/kvm/vmx.c . See the thread around
http://article.gmane.org/gmane.comp.emulators.kvm.devel/8516/ for more discussion.
This approach will get a little weird in emulate.c, since right now we kvmppc_emulate_instruction() emulates all instructions for all cores. We may need to split that up, for example:
emulate.c:
switch (opcode) {
case MFSPR:
switch (sprn) {
case SRR0: vcpu->arch.gpr[rt] = vcpu->arch.srr0;
...
default:
r = kvmppc_emulate_mfspr(vcpu, sprn, rt); // core hook
if (r)
return EMULATE_FAIL;
}
}e500_emulate.c:
int kvmppc_emulate_mfspr(struct kvm_vcpu *vcpu, u32 sprn, unsigned gpr)
{
struct vcpu_e500 *vcpu_e500 = to_vcpu_e500(vcpu);
int r = 0;
switch (sprn) {
case MAS0: vcpu->arch.gpr[rt] = vcpu_e500->mas0;
...
default:
r = -1;
}
return r;
}I will be traveling and won't have time to look at this next week, so if this approach makes sense to you, do you want to send a patch?
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
RE: [PATCH 2 of 2] kvm: ppc: Rename "struct tlbe" to"structkvmppc_44x_tlbe"
In reply to Hollis BlanchardQuoted 70 lines
-----Original Message-----
From: Hollis Blanchard [mailto:[email protected]]
Sent: Friday, September 12, 2008 11:30 PM
To: Liu Yu-B13201
Cc: [email protected]
Subject: RE: [PATCH 2 of 2] kvm: ppc: Rename "struct tlbe" to"structkvmppc_44x_tlbe"Quoted 16 lines · On Fri, 2008-09-12 at 11:10 +0800, Liu Yu-B13201 wrote:
arch/powerpc/include/asm/kvm_host.h struct kvm_arch { · line 84
Quoted 13 lines
arch/powerpc/include/asm/kvm_host.h +2
-2@@ -76,9 +76,9 @@ struct kvm_arch {struct kvm_vcpu_arch {/* Unmodified copy of the guest's TLB. */ -struct tlbe guest_tlb[PPC44x_TLB_SIZE]; +struct kvmppc_44x_tlbe guest_tlb[PPC44x_TLB_SIZE];/* TLB that's actually used when the guest is running. */ -struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; +struct kvmppc_44x_tlbe shadow_tlb[PPC44x_TLB_SIZE];/* Pages which are referenced in the shadow TLB. */ struct page *shadow_pages[PPC44x_TLB_SIZE];I have been thinking about merge
kvm_vcpu_archof 44x and e500. But I'm not sure whether it's worth doing this.We could do implement a scheme like
to_vmx()inarch/x86/kvm/vmx.c. See
the thread around
http://article.gmane.org/gmane.comp.emulators.kvm.devel/8516/ for more discussion.This approach will get a little weird in
emulate.c, since right now wekvmppc_emulate_instruction()emulates all instructions for all cores. We
may need to split that up, for example:
emulate.c:switch (opcode) { case MFSPR: switch (sprn) { case SRR0: vcpu->arch.gpr[rt] = vcpu->arch.srr0; ... default: r = kvmppc_emulate_mfspr(vcpu, sprn, rt); // core hook if (r) return EMULATE_FAIL; } }
e500_emulate.c:
int kvmppc_emulate_mfspr(structkvm_vcpu*vcpu, u32
sprn, unsigned gpr){ struct vcpu_e500 *vcpu_e500 = to_vcpu_e500(vcpu); int r = 0; switch (sprn) { case MAS0: vcpu->arch.gpr[rt] = vcpu_e500->mas0; ... default: r = -1; } return r; }
Quoted 4 lines
I will be traveling and won't have time to look at this next week, so if
this approach makes sense to you, do you want to send a patch?
I'd like to.
Please commit these two patches.