KVM: PPC: e500: enable magic page
Subsystems (3)
PATCH 9/13 KVM: PPC: e500: enable magic page
This is a shared page used for paravirtualization. It is always present in the guest kernel's effective address space at the address indicated by the hypercall that enables it.
The physical address specified by the hypercall is not used, as e500 does not have real mode.
--- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/booke.c | 11 +++++++++++ arch/powerpc/kvm/e500_tlb.c | 22 +++++++++++++++++++++- arch/powerpc/kvm/powerpc.c | 9 +++++---- 4 files changed, 38 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/kvm_ppc.h +1 -0
@@ -109,6 +109,7 @@ extern void kvmppc_booke_exit(void);extern void kvmppc_core_destroy_mmu (struct kvm_vcpu *vcpu);extern int kvmppc_kvm_pv (struct kvm_vcpu *vcpu); +extern void kvmppc_map_magic (struct kvm_vcpu *vcpu);/* * Cuts out inst bits with ordering according to spec.
arch/powerpc/kvm/booke.c +11 -0
@@ -472,6 +472,17 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,gpa_t gpaddr;gfn_t gfn; +#ifdef CONFIG_KVM_E500 +if (!(vcpu->arch.shared->msr &MSR_PR ) && + (eaddr &PAGE_MASK ) = vcpu->arch.magic_page_ea) { +kvmppc_map_magic (vcpu); +kvmppc_account_exit (vcpu,DTLB_VIRT_MISS_EXITS ); + r =RESUME_GUEST ; + +break ; + } +#endif +/* Check the guest TLB. */ gtlb_index =kvmppc_mmu_dtlb_index (vcpu, eaddr);if (gtlb_index <0 ) {
arch/powerpc/kvm/e500_tlb.c +21 -1
@@ -76,7 +76,8 @@ static inline unsigned int tlb0_get_next_victim(static inline unsigned int tlb1_max_shadow_size (void ) { -return tlb1_entry_num - tlbcam_index; +/* reserve one entry for magic page */ +return tlb1_entry_num - tlbcam_index -1 ; }static inline int tlbe_is_writable (struct tlbe *tlbe)
@@ -142,6 +143,25 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500, } } +void kvmppc_map_magic (struct kvm_vcpu *vcpu) +{ +struct tlbe magic; +ulong shared_page = ((ulong )vcpu->arch.shared) &PAGE_MASK ; +pfn_t pfn; + + pfn = (pfn_t )virt_to_phys ((void *)shared_page) >>PAGE_SHIFT ; +get_page (pfn_to_page (pfn)); + + magic.mas1 =MAS1_VALID |MAS1_TS | +MAS1_TSIZE (BOOK3E_PAGESZ_4K ); + magic.mas2 = vcpu->arch.magic_page_ea |MAS2_M ; + magic.mas3 = (pfn <<PAGE_SHIFT ) | +MAS3_SW |MAS3_SR |MAS3_UW |MAS3_UR ; + magic.mas7 = pfn >> (32 -PAGE_SHIFT ); + +__write_host_tlbe (&magic,MAS0_TLBSEL (1 ) |MAS0_ESEL (tlbcam_index)); +} +void kvmppc_e500_tlb_load (struct kvm_vcpu *vcpu,int cpu) { }
arch/powerpc/kvm/powerpc.c +5 -4
@@ -66,16 +66,17 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) vcpu->arch.magic_page_pa = param1; vcpu->arch.magic_page_ea = param2; - r2 =KVM_MAGIC_FEAT_SR ; +#ifdef CONFIG_KVM_E500 +kvmppc_map_magic (vcpu); +#endif + r2 =KVM_MAGIC_FEAT_SR ; r =HC_EV_SUCCESS ;break ; }case HC_VENDOR_KVM |KVM_HC_FEATURES : r =HC_EV_SUCCESS ; -#if defined(CONFIG_PPC_BOOK3S )/* XXX Missing magic page on BookE */ - r2 |= (1 <<KVM_FEATURE_MAGIC_PAGE ); -#endif + r2 = (1 <<KVM_FEATURE_MAGIC_PAGE );/* Second return value is in r4 */ break ;
Signature · 1 line
1.7.4.1
Quoted 6 lines · Scott Wood
This is a shared page used for paravirtualization. It is always present in the guest kernel's effective address space at the address indicated by the hypercall that enables it.
The physical address specified by the hypercall is not used, as e500 does not have real mode.
This also requires a documentation change.
Quoted 67 lines
Signed-off-by Scott Wood<[email protected]>--- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/booke.c | 11 +++++++++++ arch/powerpc/kvm/e500_tlb.c | 22 +++++++++++++++++++++- arch/powerpc/kvm/powerpc.c | 9 +++++---- 4 files changed, 38 insertions(+), 5 deletions(-)arch/powerpc/include/asm/kvm_ppc.h +1
-0@@ -109,6 +109,7 @@ extern void kvmppc_booke_exit(void);extern void kvmppc_core_destroy_mmu (struct kvm_vcpu *vcpu);extern int kvmppc_kvm_pv (struct kvm_vcpu *vcpu); +extern void kvmppc_map_magic (struct kvm_vcpu *vcpu);/* * Cuts out inst bits with ordering according to spec. arch/powerpc/kvm/booke.c +11
-0@@ -472,6 +472,17 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,gpa_t gpaddr;gfn_t gfn; +#ifdef CONFIG_KVM_E500 +if (!(vcpu->arch.shared->msr&MSR_PR )&& + (eaddr&PAGE_MASK ) = vcpu->arch.magic_page_ea) { +kvmppc_map_magic (vcpu); +kvmppc_account_exit (vcpu,DTLB_VIRT_MISS_EXITS ); + r =RESUME_GUEST ; + +break ; + } +#endif +/* Check the guest TLB. */ gtlb_index =kvmppc_mmu_dtlb_index (vcpu, eaddr);if (gtlb_index<0 ) {arch/powerpc/kvm/e500_tlb.c +9
-1@@ -76,7 +76,8 @@ static inline unsigned int tlb0_get_next_victim(static inline unsigned int tlb1_max_shadow_size (void ) { -return tlb1_entry_num - tlbcam_index; +/* reserve one entry for magic page */ +return tlb1_entry_num - tlbcam_index -1 ; }static inline int tlbe_is_writable (struct tlbe *tlbe)@@ -142,6 +143,25 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500, } } +void kvmppc_map_magic (struct kvm_vcpu *vcpu) +{ +struct tlbe magic; +ulong shared_page = ((ulong )vcpu->arch.shared)&PAGE_MASK ; +pfn_t pfn; + + pfn = (pfn_t )virt_to_phys ((void *)shared_page)>>PAGE_SHIFT ;
arch/powerpc/kvm/e500_tlb.c static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500, · line 162
Quoted 10 lines
arch/powerpc/kvm/e500_tlb.c +10
-0+get_page (pfn_to_page (pfn)); + + magic.mas1 =MAS1_VALID |MAS1_TS | +MAS1_TSIZE (BOOK3E_PAGESZ_4K ); + magic.mas2 = vcpu->arch.magic_page_ea |MAS2_M ; + magic.mas3 = (pfn<<PAGE_SHIFT ) | +MAS3_SW |MAS3_SR |MAS3_UW |MAS3_UR ; + magic.mas7 = pfn>> (32 -PAGE_SHIFT ); + +__write_host_tlbe (&magic,MAS0_TLBSEL (1 ) |MAS0_ESEL (tlbcam_index));
It's a 4k page, so why use TLB1? Also, you add this as PID0 mapping, no? Shouldn't it be restricted to the guest's kernel?
Alex
Quoted 12 lines · On Thu, 19 May 2011 12:43:21 +0200 Alexander Graf <[email protected]> wrote:
Quoted 11 lines · Scott Wood
arch/powerpc/kvm/e500_tlb.c +11
-0+void kvmppc_map_magic (struct kvm_vcpu *vcpu) +{ +struct tlbe magic; +ulong shared_page = ((ulong )vcpu->arch.shared)&PAGE_MASK ; +pfn_t pfn; + + pfn = (pfn_t )virt_to_phys ((void *)shared_page)>>PAGE_SHIFT ; +get_page (pfn_to_page (pfn)); + + magic.mas1 =MAS1_VALID |MAS1_TS | +MAS1_TSIZE (BOOK3E_PAGESZ_4K );
Quoted 8 lines
arch/powerpc/kvm/e500_tlb.c static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500, · line 162
Quoted 6 lines
arch/powerpc/kvm/e500_tlb.c +6
-0+ magic.mas2 = vcpu->arch.magic_page_ea |MAS2_M ; + magic.mas3 = (pfn<<PAGE_SHIFT ) | +MAS3_SW |MAS3_SR |MAS3_UW |MAS3_UR ; + magic.mas7 = pfn>> (32 -PAGE_SHIFT ); + +__write_host_tlbe (&magic,MAS0_TLBSEL (1 ) |MAS0_ESEL (tlbcam_index));It's a 4k page, so why use TLB1?
Seemed useful to keep it more or less pinned.
Quoted 2 lines
Also, you add this as PID0 mapping, no?
Shouldn't it be restricted to the guest's kernel?
As of this stage in the patchset, we're still dumping the TLB on guest privilege switch, and we don't call this function if the guest is in user mode.
Later when shadow PIDs are added, we use a shadow PID that corresponds to guest kernel mode.
-Scott
Quoted 29 lines · Scott Wood
Quoted 12 lines · On Thu, 19 May 2011 12:43:21 +0200 Alexander Graf <[email protected]> wrote:
Quoted 11 lines · Scott Wood
arch/powerpc/kvm/e500_tlb.c +11
-0+void kvmppc_map_magic (struct kvm_vcpu *vcpu) +{ +struct tlbe magic; +ulong shared_page = ((ulong )vcpu->arch.shared)&PAGE_MASK ; +pfn_t pfn; + + pfn = (pfn_t )virt_to_phys ((void *)shared_page)>>PAGE_SHIFT ; +get_page (pfn_to_page (pfn)); + + magic.mas1 =MAS1_VALID |MAS1_TS | +MAS1_TSIZE (BOOK3E_PAGESZ_4K );Quoted 8 lines
arch/powerpc/kvm/e500_tlb.c static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500, · line 162
Quoted 6 lines
arch/powerpc/kvm/e500_tlb.c +6
-0+ magic.mas2 = vcpu->arch.magic_page_ea |MAS2_M ; + magic.mas3 = (pfn<<PAGE_SHIFT ) | +MAS3_SW |MAS3_SR |MAS3_UW |MAS3_UR ; + magic.mas7 = pfn>> (32 -PAGE_SHIFT ); + +__write_host_tlbe (&magic,MAS0_TLBSEL (1 ) |MAS0_ESEL (tlbcam_index));It's a 4k page, so why use TLB1?
Seemed useful to keep it more or less pinned.
Quoted 2 lines
Also, you add this as PID0 mapping, no?
Shouldn't it be restricted to the guest's kernel?
Quoted 6 lines
As of this stage in the patchset, we're still dumping the TLB on guest privilege switch, and we don't call this function if the guest is in user mode.
Later when shadow PIDs are added, we use a shadow PID that corresponds to guest kernel mode.
Makes sense :).
Btw - have you considered moving the MAS registers into the shared page now that it's available on BookE? That should give quite a significant performance boost :)
Alex
Quoted 1 line · On Sat, 21 May 2011 18:39:01 +0200 Alexander Graf <[email protected]> wrote:
Btw - have you considered moving the MAS registers into the shared page now that it's available on BookE? That should give quite a significant performance boost :)
That's in the next patchset (among other paravirt stuff). :-)
-Scott
Quoted 6 lines · Scott Wood
Quoted 1 line · On Sat, 21 May 2011 18:39:01 +0200 Alexander Graf <[email protected]> wrote:
Btw - have you considered moving the MAS registers into the shared page now that it's available on BookE? That should give quite a significant performance boost :)
That's in the next patchset (among other paravirt stuff). :-)
Very nice :). Is anything still unclear or can we go to v2 and finally get some speed? :)
Alex
PATCH 9/13 KVM: PPC: e500: enable magic page
In reply to Scott WoodThis is a shared page used for paravirtualization. It is always present in the guest kernel's effective address space at the address indicated by the hypercall that enables it.
The physical address specified by the hypercall is not used, as e500 does not have real mode.
--- Documentation/virtual/kvm/ppc-pv.txt | 8 +++++--- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/booke.c | 11 +++++++++++ arch/powerpc/kvm/e500_tlb.c | 22 +++++++++++++++++++++- arch/powerpc/kvm/powerpc.c | 9 +++++---- 5 files changed, 43 insertions(+), 8 deletions(-)
Documentation/virtual/kvm/ppc-pv.txt +5 -3
@@ -68,9 +68,11 @@ page that contains parts of supervisor visible register state. The guest can map this shared page using the KVM hypercall KVM_HC_PPC_MAP_MAGIC_PAGE. With this hypercall issued the guest always gets the magic page mapped at the -desired location in effective and physical address space. For now, we always -map the page to -4096. This way we can access it using absolute load and store -functions. The following instruction reads the first field of the magic page: +desired location. The first parameter indicates the effective address when the +MMU is enabled. The second parameter indicates the address in real mode, if +applicable to the target. For now, we always map the page to -4096. This way we +can access it using absolute load and store functions. The following +instruction reads the first field of the magic page: ld rX, -4096(0)
arch/powerpc/include/asm/kvm_ppc.h +1 -0
@@ -109,6 +109,7 @@ extern void kvmppc_booke_exit(void);extern void kvmppc_core_destroy_mmu (struct kvm_vcpu *vcpu);extern int kvmppc_kvm_pv (struct kvm_vcpu *vcpu); +extern void kvmppc_map_magic (struct kvm_vcpu *vcpu);/* * Cuts out inst bits with ordering according to spec.
arch/powerpc/kvm/booke.c +11 -0
@@ -472,6 +472,17 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,gpa_t gpaddr;gfn_t gfn; +#ifdef CONFIG_KVM_E500 +if (!(vcpu->arch.shared->msr &MSR_PR ) && + (eaddr &PAGE_MASK ) = vcpu->arch.magic_page_ea) { +kvmppc_map_magic (vcpu); +kvmppc_account_exit (vcpu,DTLB_VIRT_MISS_EXITS ); + r =RESUME_GUEST ; + +break ; + } +#endif +/* Check the guest TLB. */ gtlb_index =kvmppc_mmu_dtlb_index (vcpu, eaddr);if (gtlb_index <0 ) {
arch/powerpc/kvm/e500_tlb.c +21 -1
@@ -76,7 +76,8 @@ static inline unsigned int tlb0_get_next_victim(static inline unsigned int tlb1_max_shadow_size (void ) { -return tlb1_entry_num - tlbcam_index; +/* reserve one entry for magic page */ +return tlb1_entry_num - tlbcam_index -1 ; }static inline int tlbe_is_writable (struct tlbe *tlbe)
@@ -142,6 +143,25 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500, } } +void kvmppc_map_magic (struct kvm_vcpu *vcpu) +{ +struct tlbe magic; +ulong shared_page = ((ulong )vcpu->arch.shared) &PAGE_MASK ; +pfn_t pfn; + + pfn = (pfn_t )virt_to_phys ((void *)shared_page) >>PAGE_SHIFT ; +get_page (pfn_to_page (pfn)); + + magic.mas1 =MAS1_VALID |MAS1_TS | +MAS1_TSIZE (BOOK3E_PAGESZ_4K ); + magic.mas2 = vcpu->arch.magic_page_ea |MAS2_M ; + magic.mas3 = (pfn <<PAGE_SHIFT ) | +MAS3_SW |MAS3_SR |MAS3_UW |MAS3_UR ; + magic.mas7 = pfn >> (32 -PAGE_SHIFT ); + +__write_host_tlbe (&magic,MAS0_TLBSEL (1 ) |MAS0_ESEL (tlbcam_index)); +} +void kvmppc_e500_tlb_load (struct kvm_vcpu *vcpu,int cpu) { }
arch/powerpc/kvm/powerpc.c +5 -4
@@ -66,16 +66,17 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) vcpu->arch.magic_page_pa = param1; vcpu->arch.magic_page_ea = param2; - r2 =KVM_MAGIC_FEAT_SR ; +#ifdef CONFIG_KVM_E500 +kvmppc_map_magic (vcpu); +#endif + r2 =KVM_MAGIC_FEAT_SR ; r =HC_EV_SUCCESS ;break ; }case HC_VENDOR_KVM |KVM_HC_FEATURES : r =HC_EV_SUCCESS ; -#if defined(CONFIG_PPC_BOOK3S )/* XXX Missing magic page on BookE */ - r2 |= (1 <<KVM_FEATURE_MAGIC_PAGE ); -#endif + r2 = (1 <<KVM_FEATURE_MAGIC_PAGE );/* Second return value is in r4 */ break ;
Signature · 1 line
1.7.4.1
Quoted 52 lines · Scott Wood
This is a shared page used for paravirtualization. It is always present in the guest kernel's effective address space at the address indicated by the hypercall that enables it.
The physical address specified by the hypercall is not used, as e500 does not have real mode.
Signed-off-by Scott Wood <[email protected]>---
Documentation/virtual/kvm/ppc-pv.txt | 8 +++++--- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/booke.c | 11 +++++++++++ arch/powerpc/kvm/e500_tlb.c | 22 +++++++++++++++++++++- arch/powerpc/kvm/powerpc.c | 9 +++++---- 5 files changed, 43 insertions(+), 8 deletions(-)Documentation/virtual/kvm/ppc-pv.txt +0
-0@@ -68,9 +68,11 @@ page that contains parts of supervisor visible register state. The guest canmap this shared page using the KVM hypercall
KVM_HC_PPC_MAP_MAGIC_PAGE.With this hypercall issued the guest always gets the magic page mapped at the
Documentation/virtual/kvm/ppc-pv.txt +5
-3-desired location in effective and physical address space. For now, we always -map the page to -4096. This way we can access it using absolute load and store -functions. The following instruction reads the first field of the magic page: +desired location. The first parameter indicates the effective address when the +MMU is enabled. The second parameter indicates the address in real mode, if +applicable to the target. For now, we always map the page to -4096. This way we +can access it using absolute load and store functions. The following +instruction reads the first field of the magic page:ld rX, -4096(0)arch/powerpc/include/asm/kvm_ppc.h +1
-0@@ -109,6 +109,7 @@ extern void kvmppc_booke_exit(void);extern void kvmppc_core_destroy_mmu (struct kvm_vcpu *vcpu);extern int kvmppc_kvm_pv (struct kvm_vcpu *vcpu); +extern void kvmppc_map_magic (struct kvm_vcpu *vcpu);/* * Cuts out inst bits with ordering according to spec. arch/powerpc/kvm/booke.c +0
-0
arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, · line 479
Quoted 8 lines
arch/powerpc/kvm/booke.c +5
-0@@ -472,6 +472,17 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,gpa_t gpaddr;gfn_t gfn; +#ifdef CONFIG_KVM_E500 +if (!(vcpu->arch.shared->msr &MSR_PR ) && + (eaddr &PAGE_MASK ) = vcpu->arch.magic_page_ea) { +kvmppc_map_magic (vcpu); +kvmppc_account_exit (vcpu,DTLB_VIRT_MISS_EXITS );
This is fine for now, but please note that I find it unpretty. The magic page hook should be in the guest tlb lookup and then reuse the same mapping mechanisms as real TLB entries, as it's basically the same.
However, for now just leave it like this.
Quoted 54 lines
arch/powerpc/kvm/booke.c +6
-0+ r =RESUME_GUEST ; + + break; + } +#endif +/* Check the guest TLB. */ gtlb_index =kvmppc_mmu_dtlb_index (vcpu, eaddr);if (gtlb_index <0 ) {arch/powerpc/kvm/e500_tlb.c +21
-1@@ -76,7 +76,8 @@ static inline unsigned int tlb0_get_next_victim(static inline unsigned int tlb1_max_shadow_size (void ) { -return tlb1_entry_num - tlbcam_index; +/* reserve one entry for magic page */ +return tlb1_entry_num - tlbcam_index -1 ; }static inline int tlbe_is_writable (struct tlbe *tlbe)@@ -142,6 +143,25 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500, } } +void kvmppc_map_magic (struct kvm_vcpu *vcpu) +{ +struct tlbe magic; +ulong shared_page = ((ulong )vcpu->arch.shared) &PAGE_MASK ; +pfn_t pfn; + + pfn = (pfn_t )virt_to_phys ((void *)shared_page) >>PAGE_SHIFT ; +get_page (pfn_to_page (pfn)); + + magic.mas1 =MAS1_VALID |MAS1_TS | +MAS1_TSIZE (BOOK3E_PAGESZ_4K ); + magic.mas2 = vcpu->arch.magic_page_ea |MAS2_M ; + magic.mas3 = (pfn <<PAGE_SHIFT ) | +MAS3_SW |MAS3_SR |MAS3_UW |MAS3_UR ; + magic.mas7 = pfn >> (32 -PAGE_SHIFT ); + +__write_host_tlbe (&magic,MAS0_TLBSEL (1 ) |MAS0_ESEL (tlbcam_index)); +} +void kvmppc_e500_tlb_load (struct kvm_vcpu *vcpu,int cpu) { }arch/powerpc/kvm/powerpc.c +0
-0
arch/powerpc/kvm/powerpc.c int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) · line 71
Quoted 7 lines
arch/powerpc/kvm/powerpc.c +3
-1@@ -66,16 +66,17 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) vcpu->arch.magic_page_pa = param1; vcpu->arch.magic_page_ea = param2; - r2 =KVM_MAGIC_FEAT_SR ; +#ifdef CONFIG_KVM_E500 +kvmppc_map_magic (vcpu); +#endif
Is this necessary? Sure, we save a few ms on the trap, but is it worth it? If we had a generic function that could map the magic page on all systems, sure, but I'd like to keep generic code clean of too many #ifdefs.
arch/powerpc/kvm/powerpc.c int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) · line 79
Quoted 11 lines
arch/powerpc/kvm/powerpc.c +2
-3+ r2 =KVM_MAGIC_FEAT_SR ; r =HC_EV_SUCCESS ;break ; }case HC_VENDOR_KVM |KVM_HC_FEATURES : r =HC_EV_SUCCESS ; -#if defined(CONFIG_PPC_BOOK3S )/* XXX Missing magic page on BookE */ - r2 |= (1 <<KVM_FEATURE_MAGIC_PAGE ); -#endif + r2 = (1 <<KVM_FEATURE_MAGIC_PAGE );
As you've noted already, this breaks 440. You can choose between implementing it there or changing the #ifdef :).
Alex
Quoted 19 lines · On Tue, 14 Jun 2011 11:55:11 +0200 Alexander Graf <[email protected]> wrote:
arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, · line 479
Quoted 13 lines · Scott Wood
arch/powerpc/kvm/booke.c +5
-0@@ -472,6 +472,17 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,gpa_t gpaddr;gfn_t gfn; +#ifdef CONFIG_KVM_E500 +if (!(vcpu->arch.shared->msr &MSR_PR ) && + (eaddr &PAGE_MASK ) = vcpu->arch.magic_page_ea) { +kvmppc_map_magic (vcpu); +kvmppc_account_exit (vcpu,DTLB_VIRT_MISS_EXITS );This is fine for now, but please note that I find it unpretty. The magic page hook should be in the guest tlb lookup and then reuse the same mapping mechanisms as real TLB entries, as it's basically the same.
Quoted 1 line
However, for now just leave it like this.
I'm not thrilled with it either, but it's different in that there is no entry for this in the guest TLB. If there were to be one, that would be a guest-visible change in the magic page interface.
Quoted 8 lines
Quoted 8 lines
arch/powerpc/kvm/powerpc.c +0
-0@@ -66,16 +66,17 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) vcpu->arch.magic_page_pa = param1; vcpu->arch.magic_page_ea = param2;
Quoted 6 lines
arch/powerpc/kvm/powerpc.c int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) · line 71
Quoted 4 lines
arch/powerpc/kvm/powerpc.c +3
-1- r2 =KVM_MAGIC_FEAT_SR ; +#ifdef CONFIG_KVM_E500 +kvmppc_map_magic (vcpu); +#endif Is this necessary? Sure, we save a few ms on the trap, but is it worth it? If we had a generic function that could map the magic page on all systems, sure, but I'd like to keep generic code clean of too many #ifdefs.
I think that's a relic from when I was trying to avoid adding code to the TLB miss path to load this on demand. It should be able to come out.
-Scott