KVM: PPC: Create a virtual-mode only TCE table handlers
Subsystems (3)
PATCH 1/1 KVM: PPC: Create a virtual-mode only TCE table handlers
Upcoming in-kernel VFIO acceleration needs different handling in real and virtual modes which makes it hard to support both modes in the same handler.
This creates a copy of kvmppc_rm_h_stuff_tce and kvmppc_rm_h_put_tce in addition to the existing kvmppc_rm_h_put_tce_indirect.
This also fixes linker breakage when only PR KVM was selected (leaving HV KVM off): the kvmppc_h_put_tce/kvmppc_h_stuff_tce functions would not compile at all and the linked would fail.
--- arch/powerpc/kvm/book3s_64_vio.c | 52 +++++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_64_vio_hv.c | 8 ++--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 4 +-- 3 files changed, 57 insertions(+), 7 deletions(-)
arch/powerpc/kvm/book3s_64_vio.c +52 -0
@@ -209,6 +209,32 @@ fail:return ret; } +long kvmppc_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba,unsigned long tce) +{ +struct kvmppc_spapr_tce_table *stt =kvmppc_find_table (vcpu, liobn); +long ret; + +/* udbg_printf("H_PUT_TCE(): liobn=0x%lx ioba=0x%lx, tce=0x%lx\n", */ +/* liobn, ioba, tce); */ + +if (!stt) +return H_TOO_HARD ; + + ret =kvmppc_ioba_validate (stt, ioba,1 ); +if (ret !=H_SUCCESS ) +return ret; + + ret =kvmppc_tce_validate (stt, tce); +if (ret !=H_SUCCESS ) +return ret; + +kvmppc_tce_put (stt, ioba >> stt->page_shift, tce); + +return H_SUCCESS ; +} +EXPORT_SYMBOL_GPL (kvmppc_h_put_tce); +long kvmppc_h_put_tce_indirect (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba,unsigned long tce_list,unsigned long npages)
@@ -264,3 +290,29 @@ unlock_exit:return ret; }EXPORT_SYMBOL_GPL (kvmppc_h_put_tce_indirect); + +long kvmppc_h_stuff_tce (struct kvm_vcpu *vcpu, +unsigned long liobn,unsigned long ioba, +unsigned long tce_value,unsigned long npages) +{ +struct kvmppc_spapr_tce_table *stt; +long i, ret; + + stt =kvmppc_find_table (vcpu, liobn); +if (!stt) +return H_TOO_HARD ; + + ret =kvmppc_ioba_validate (stt, ioba, npages); +if (ret !=H_SUCCESS ) +return ret; + +/* Check permission bits only to allow userspace poison TCE for debug */ +if (tce_value & (TCE_PCI_WRITE |TCE_PCI_READ )) +return H_PARAMETER ; + +for (i =0 ; i < npages; ++i, ioba += (1ULL << stt->page_shift)) +kvmppc_tce_put (stt, ioba >> stt->page_shift, tce_value); + +return H_SUCCESS ; +} +EXPORT_SYMBOL_GPL (kvmppc_h_stuff_tce);
arch/powerpc/kvm/book3s_64_vio_hv.c +3 -5
@@ -180,8 +180,8 @@ long kvmppc_gpa_to_ua(struct kvm *kvm, unsigned long gpa,EXPORT_SYMBOL_GPL (kvmppc_gpa_to_ua);#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE -long kvmppc_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn, -unsigned long ioba,unsigned long tce) +long kvmppc_rm_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba,unsigned long tce) {struct kvmppc_spapr_tce_table *stt =kvmppc_find_table (vcpu, liobn);long ret;
@@ -204,7 +204,6 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,return H_SUCCESS ; } -EXPORT_SYMBOL_GPL (kvmppc_h_put_tce);static long kvmppc_rm_ua_to_hpa (struct kvm_vcpu *vcpu,unsigned long ua,unsigned long *phpa)
@@ -296,7 +295,7 @@ unlock_exit:return ret; } -long kvmppc_h_stuff_tce (struct kvm_vcpu *vcpu, +long kvmppc_rm_h_stuff_tce (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba,unsigned long tce_value,unsigned long npages) {
@@ -320,7 +319,6 @@ long kvmppc_h_stuff_tce(struct kvm_vcpu *vcpu,return H_SUCCESS ; } -EXPORT_SYMBOL_GPL (kvmppc_h_stuff_tce);long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba)
arch/powerpc/kvm/book3s_hv_rmhandlers.S +2 -2
@@ -1942,7 +1942,7 @@ hcall_real_table: .long DOTSYM(kvmppc_h_clear_ref) - hcall_real_table .long DOTSYM(kvmppc_h_protect) - hcall_real_table .long DOTSYM(kvmppc_h_get_tce) - hcall_real_table - .long DOTSYM(kvmppc_h_put_tce) - hcall_real_table + .long DOTSYM(kvmppc_rm_h_put_tce) - hcall_real_table .long 0 /* 0x24 - H_SET_SPRG0 */ .long DOTSYM(kvmppc_h_set_dabr) - hcall_real_table .long 0 /* 0x2c */
@@ -2020,7 +2020,7 @@ hcall_real_table: .long 0 /* 0x12c */ .long 0 /* 0x130 */ .long DOTSYM(kvmppc_h_set_xdabr) - hcall_real_table - .long DOTSYM(kvmppc_h_stuff_tce) - hcall_real_table + .long DOTSYM(kvmppc_rm_h_stuff_tce) - hcall_real_table .long DOTSYM(kvmppc_rm_h_put_tce_indirect) - hcall_real_table .long 0 /* 0x140 */ .long 0 /* 0x144 */
Signature · 1 line
2.5.0.rc3
PATCH 1/1 KVM: PPC: Create a virtual-mode only TCE table handlers
Hi Alexey,
Many thanks for your really fast response. I successfully compiled the latest Git kernel with your new patch today. After that, I successfully tested it with Mac-on-Linux/PR KVM. Mac OS X Tiger PowerPC (virtual G3 CPU) works fantastic in MoL/PR KVM with the latest patched Git kernel.
Screenshot: https://plus.google.com/115515624056477014971/posts/hsQ2m6rYBdr
Have a nice day and thanks a lot to all for your hard work.
Cheers,
Christian
Quoted 147 lines · Alexey Kardashevskiy
Upcoming in-kernel VFIO acceleration needs different handling in real and virtual modes which makes it hard to support both modes in the same handler.
This creates a copy of
kvmppc_rm_h_stuff_tceandkvmppc_rm_h_put_tcein addition to the existingkvmppc_rm_h_put_tce_indirect.This also fixes linker breakage when only PR KVM was selected (leaving HV KVM off): the kvmppc_h_put_tce/kvmppc_h_stuff_tce functions would not compile at all and the linked would fail.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- arch/powerpc/kvm/book3s_64_vio.c | 52 +++++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_64_vio_hv.c | 8 ++--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 4 +-- 3 files changed, 57 insertions(+), 7 deletions(-)arch/powerpc/kvm/book3s_64_vio.c +52
-0@@ -209,6 +209,32 @@ fail:return ret; } +long kvmppc_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba,unsigned long tce) +{ +struct kvmppc_spapr_tce_table *stt =kvmppc_find_table (vcpu, liobn); +long ret; + +/* udbg_printf("H_PUT_TCE(): liobn=0x%lx ioba=0x%lx, tce=0x%lx\n", */ +/* liobn, ioba, tce); */ + +if (!stt) +return H_TOO_HARD ; + + ret =kvmppc_ioba_validate (stt, ioba,1 ); +if (ret !=H_SUCCESS ) +return ret; + + ret =kvmppc_tce_validate (stt, tce); +if (ret !=H_SUCCESS ) +return ret; + +kvmppc_tce_put (stt, ioba >> stt->page_shift, tce); + +return H_SUCCESS ; +} +EXPORT_SYMBOL_GPL (kvmppc_h_put_tce); +long kvmppc_h_put_tce_indirect (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba,unsigned long tce_list,unsigned long npages)@@ -264,3 +290,29 @@ unlock_exit:return ret; }EXPORT_SYMBOL_GPL (kvmppc_h_put_tce_indirect); + +long kvmppc_h_stuff_tce (struct kvm_vcpu *vcpu, +unsigned long liobn,unsigned long ioba, +unsigned long tce_value,unsigned long npages) +{ +struct kvmppc_spapr_tce_table *stt; +long i, ret; + + stt =kvmppc_find_table (vcpu, liobn); +if (!stt) +return H_TOO_HARD ; + + ret =kvmppc_ioba_validate (stt, ioba, npages); +if (ret !=H_SUCCESS ) +return ret; + +/* Check permission bits only to allow userspace poison TCE for debug */ +if (tce_value & (TCE_PCI_WRITE |TCE_PCI_READ )) +return H_PARAMETER ; + +for (i =0 ; i < npages; ++i, ioba += (1ULL << stt->page_shift)) +kvmppc_tce_put (stt, ioba >> stt->page_shift, tce_value); + +return H_SUCCESS ; +} +EXPORT_SYMBOL_GPL (kvmppc_h_stuff_tce);arch/powerpc/kvm/book3s_64_vio_hv.c +3
-5@@ -180,8 +180,8 @@ long kvmppc_gpa_to_ua(struct kvm *kvm, unsigned long gpa,EXPORT_SYMBOL_GPL (kvmppc_gpa_to_ua);#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE -long kvmppc_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn, -unsigned long ioba,unsigned long tce) +long kvmppc_rm_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba,unsigned long tce) {struct kvmppc_spapr_tce_table *stt =kvmppc_find_table (vcpu, liobn);long ret;@@ -204,7 +204,6 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,return H_SUCCESS ; } -EXPORT_SYMBOL_GPL (kvmppc_h_put_tce);static long kvmppc_rm_ua_to_hpa (struct kvm_vcpu *vcpu,unsigned long ua,unsigned long *phpa)@@ -296,7 +295,7 @@ unlock_exit:return ret; } -long kvmppc_h_stuff_tce (struct kvm_vcpu *vcpu, +long kvmppc_rm_h_stuff_tce (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba,unsigned long tce_value,unsigned long npages) {@@ -320,7 +319,6 @@ long kvmppc_h_stuff_tce(struct kvm_vcpu *vcpu,return H_SUCCESS ; } -EXPORT_SYMBOL_GPL (kvmppc_h_stuff_tce);long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba)arch/powerpc/kvm/book3s_hv_rmhandlers.S +2
-2@@ -1942,7 +1942,7 @@ hcall_real_table: .long DOTSYM(kvmppc_h_clear_ref) - hcall_real_table .long DOTSYM(kvmppc_h_protect) - hcall_real_table .long DOTSYM(kvmppc_h_get_tce) - hcall_real_table - .long DOTSYM(kvmppc_h_put_tce) - hcall_real_table + .long DOTSYM(kvmppc_rm_h_put_tce) - hcall_real_table .long 0 /* 0x24 - H_SET_SPRG0 */ .long DOTSYM(kvmppc_h_set_dabr) - hcall_real_table .long 0 /* 0x2c */@@ -2020,7 +2020,7 @@ hcall_real_table: .long 0 /* 0x12c */ .long 0 /* 0x130 */ .long DOTSYM(kvmppc_h_set_xdabr) - hcall_real_table - .long DOTSYM(kvmppc_h_stuff_tce) - hcall_real_table + .long DOTSYM(kvmppc_rm_h_stuff_tce) - hcall_real_table .long DOTSYM(kvmppc_rm_h_put_tce_indirect) - hcall_real_table .long 0 /* 0x140 */ .long 0 /* 0x144 */
Quoted 4 lines · Alexey Kardashevskiy
Upcoming in-kernel VFIO acceleration needs different handling in real and virtual modes which makes it hard to support both modes in the same handler.
Quoted 8 lines
This creates a copy of
kvmppc_rm_h_stuff_tceandkvmppc_rm_h_put_tcein addition to the existingkvmppc_rm_h_put_tce_indirect.This also fixes linker breakage when only PR KVM was selected (leaving HV KVM off): the kvmppc_h_put_tce/kvmppc_h_stuff_tce functions would not compile at all and the linked would fail.
Signed-off-by Alexey Kardashevskiy <[email protected]>
Paolo, will you take this directly, or do you want me to generate a pull request?
Paul.
Paolo Bonzini
maintainerQuoted 12 lines · Paul Mackerras
Quoted 11 lines · Alexey Kardashevskiy
Upcoming in-kernel VFIO acceleration needs different handling in real and virtual modes which makes it hard to support both modes in the same handler.
This creates a copy of
kvmppc_rm_h_stuff_tceandkvmppc_rm_h_put_tcein addition to the existingkvmppc_rm_h_put_tce_indirect.This also fixes linker breakage when only PR KVM was selected (leaving HV KVM off): the kvmppc_h_put_tce/kvmppc_h_stuff_tce functions would not compile at all and the linked would fail.
Quoted 6 lines
Quoted 1 line
Signed-off-by Alexey Kardashevskiy <[email protected]>Acked-by Paul Mackerras <[email protected]>Paolo, will you take this directly, or do you want me to generate a pull request?
I can take it directly.
Paolo
PATCH 1/1 KVM: PPC: Create a virtual-mode only TCE table handlers
Hi All,
Just for info: I successfully tested the latest Git kernel with the patched PR KVM today. I booted a ubuntu MATE 16.04 LTS PowerPC live DVD with a virtual Power Mac G3 machine today.
Screenshot: https://plus.google.com/115515624056477014971/posts/HAuxJT4WGPr
Have a nice day.
Cheers,
Christian