PPC: KVM: Introduce hypervisor call H_GET_TCE
Subsystems (3)
PATCH 1/1 PPC: KVM: Introduce hypervisor call H_GET_TCE
This fix introduces the H_GET_TCE hypervisor call which is basically the reverse of H_PUT_TCE, as defined in the Power Architecture Platform Requirements (PAPR).
The hcall H_GET_TCE is required by the kdump kernel which is calling it to retrieve the TCE set up by the panicing kernel.
--- arch/powerpc/include/asm/kvm_ppc.h | 2 ++ arch/powerpc/kvm/book3s_64_vio_hv.c | 28 ++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/kvm_ppc.h +2 -0
@@ -129,6 +129,8 @@ extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, struct kvm_create_spapr_tce *args);extern long kvmppc_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba,unsigned long tce); +extern long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba);extern struct kvm_rma_info *kvm_alloc_rma (void );extern void kvm_release_rma (struct kvm_rma_info *ri);extern struct page *kvm_alloc_hpt (unsigned long nr_pages);
arch/powerpc/kvm/book3s_64_vio_hv.c +28 -0
@@ -75,3 +75,31 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,return H_TOO_HARD ; }EXPORT_SYMBOL_GPL (kvmppc_h_put_tce); + +long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba) +{ +struct kvm *kvm = vcpu->kvm; +struct kvmppc_spapr_tce_table *stt; + +list_for_each_entry (stt, &kvm->arch.spapr_tce_tables, list) { +if (stt->liobn == liobn) { +unsigned long idx = ioba >>SPAPR_TCE_SHIFT ; +struct page *page; +u64 *tbl; + +if (ioba >= stt->window_size) +return H_PARAMETER ; + + page = stt->pages[idx /TCES_PER_PAGE ]; + tbl = (u64 *)page_address (page); + + vcpu->arch.gpr[4 ] = tbl[idx %TCES_PER_PAGE ]; +return H_SUCCESS ; + } + } + +/* Didn't find the liobn, punt it to userspace */ +return H_TOO_HARD ; +} +EXPORT_SYMBOL_GPL (kvmppc_h_get_tce);
arch/powerpc/kvm/book3s_hv_rmhandlers.S +1 -1
@@ -1758,7 +1758,7 @@ hcall_real_table: .long 0 /* 0x10 - H_CLEAR_MOD */ .long 0 /* 0x14 - H_CLEAR_REF */ .long .kvmppc_h_protect - hcall_real_table - .long 0 /* 0x1c - H_GET_TCE */ + .long .kvmppc_h_get_tce - hcall_real_table .long .kvmppc_h_put_tce - hcall_real_table .long 0 /* 0x24 - H_SET_SPRG0 */ .long .kvmppc_h_set_dabr - hcall_real_table
Quoted 8 lines · Laurent Dufour
This fix introduces the
H_GET_TCEhypervisor call which is basically the reverse ofH_PUT_TCE, as defined in the Power Architecture Platform Requirements (PAPR).The hcall
H_GET_TCEis required by the kdump kernel which is calling it to retrieve the TCE set up by the panicing kernel.Signed-off-by Laurent Dufour <[email protected]>
Thanks, applied to kvm-ppc-queue. Btw, why exactly are we using struct page pointers and alloc_page rather than __get_free_page() and simple page start pointers?
Alex
Quoted 6 lines · Laurent Dufour
This fix introduces the
H_GET_TCEhypervisor call which is basically the reverse ofH_PUT_TCE, as defined in the Power Architecture Platform Requirements (PAPR).The hcall
H_GET_TCEis required by the kdump kernel which is calling it to retrieve the TCE set up by the panicing kernel.
Alexey, will that work for VFIO ? Or are those patches *still* not upstream ?
Quoted 69 lines
Signed-off-by Laurent Dufour <[email protected]>--- arch/powerpc/include/asm/kvm_ppc.h | 2 ++ arch/powerpc/kvm/book3s_64_vio_hv.c | 28 ++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-)arch/powerpc/include/asm/kvm_ppc.h +2
-0@@ -129,6 +129,8 @@ extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, struct kvm_create_spapr_tce *args);extern long kvmppc_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba,unsigned long tce); +extern long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba);extern struct kvm_rma_info *kvm_alloc_rma (void );extern void kvm_release_rma (struct kvm_rma_info *ri);extern struct page *kvm_alloc_hpt (unsigned long nr_pages);arch/powerpc/kvm/book3s_64_vio_hv.c +28
-0@@ -75,3 +75,31 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,return H_TOO_HARD ; }EXPORT_SYMBOL_GPL (kvmppc_h_put_tce); + +long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba) +{ +struct kvm *kvm = vcpu->kvm; +struct kvmppc_spapr_tce_table *stt; + +list_for_each_entry (stt, &kvm->arch.spapr_tce_tables, list) { +if (stt->liobn == liobn) { +unsigned long idx = ioba >>SPAPR_TCE_SHIFT ; +struct page *page; +u64 *tbl; + +if (ioba >= stt->window_size) +return H_PARAMETER ; + + page = stt->pages[idx /TCES_PER_PAGE ]; + tbl = (u64 *)page_address (page); + + vcpu->arch.gpr[4 ] = tbl[idx %TCES_PER_PAGE ]; +return H_SUCCESS ; + } + } + +/* Didn't find the liobn, punt it to userspace */ +return H_TOO_HARD ; +} +EXPORT_SYMBOL_GPL (kvmppc_h_get_tce);arch/powerpc/kvm/book3s_hv_rmhandlers.S +1
-1@@ -1758,7 +1758,7 @@ hcall_real_table: .long 0 /* 0x10 - H_CLEAR_MOD */ .long 0 /* 0x14 - H_CLEAR_REF */ .long .kvmppc_h_protect - hcall_real_table - .long 0 /* 0x1c - H_GET_TCE */ + .long .kvmppc_h_get_tce - hcall_real_table .long .kvmppc_h_put_tce - hcall_real_table .long 0 /* 0x24 - H_SET_SPRG0 */ .long .kvmppc_h_set_dabr - hcall_real_table
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 6 lines · Laurent Dufour
This fix introduces the
H_GET_TCEhypervisor call which is basically the reverse ofH_PUT_TCE, as defined in the Power Architecture Platform Requirements (PAPR).The hcall
H_GET_TCEis required by the kdump kernel which is calling it to retrieve the TCE set up by the panicing kernel.Alexey, will that work for VFIO ?
Yes.
Quoted 2 lines
Or are those patches *still* not
upstream ?
Yes.
Quoted 77 lines
Quoted 62 lines
Signed-off-by Laurent Dufour <[email protected]>--- arch/powerpc/include/asm/kvm_ppc.h | 2 ++ arch/powerpc/kvm/book3s_64_vio_hv.c | 28 ++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-)arch/powerpc/include/asm/kvm_ppc.h +2
-0@@ -129,6 +129,8 @@ extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, struct kvm_create_spapr_tce *args);extern long kvmppc_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba,unsigned long tce); +extern long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba);extern struct kvm_rma_info *kvm_alloc_rma (void );extern void kvm_release_rma (struct kvm_rma_info *ri);extern struct page *kvm_alloc_hpt (unsigned long nr_pages);arch/powerpc/kvm/book3s_64_vio_hv.c +28
-0@@ -75,3 +75,31 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,return H_TOO_HARD ; }EXPORT_SYMBOL_GPL (kvmppc_h_put_tce); + +long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba) +{ +struct kvm *kvm = vcpu->kvm; +struct kvmppc_spapr_tce_table *stt; + +list_for_each_entry (stt, &kvm->arch.spapr_tce_tables, list) { +if (stt->liobn == liobn) { +unsigned long idx = ioba >>SPAPR_TCE_SHIFT ; +struct page *page; +u64 *tbl; + +if (ioba >= stt->window_size) +return H_PARAMETER ; + + page = stt->pages[idx /TCES_PER_PAGE ]; + tbl = (u64 *)page_address (page); + + vcpu->arch.gpr[4 ] = tbl[idx %TCES_PER_PAGE ]; +return H_SUCCESS ; + } + } + +/* Didn't find the liobn, punt it to userspace */ +return H_TOO_HARD ; +} +EXPORT_SYMBOL_GPL (kvmppc_h_get_tce);arch/powerpc/kvm/book3s_hv_rmhandlers.S +0
-0arch/powerpc/kvm/book3s_hv_rmhandlers.S hcall_real_table: · line 1764
Quoted 8 lines
arch/powerpc/kvm/book3s_hv_rmhandlers.S +1
-1@@ -1758,7 +1758,7 @@ hcall_real_table: .long 0 /* 0x10 - H_CLEAR_MOD */ .long 0 /* 0x14 - H_CLEAR_REF */ .long .kvmppc_h_protect - hcall_real_table - .long 0 /* 0x1c - H_GET_TCE */ + .long .kvmppc_h_get_tce - hcall_real_table .long .kvmppc_h_put_tce - hcall_real_table .long 0 /* 0x24 - H_SET_SPRG0 */ .long .kvmppc_h_set_dabr - hcall_real_table_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Signature · 1 line
Alexey
Quoted 6 lines · Alexey Kardashevskiy
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 4 lines · Laurent Dufour
This fix introduces the
H_GET_TCEhypervisor call which is basically the reverse ofH_PUT_TCE, as defined in the Power Architecture Platform Requirements (PAPR).
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
The hcall
H_GET_TCEis required by the kdump kernel which is calling it to retrieve the TCE set up by the panicing kernel.Alexey, will that work for VFIO ?
Yes.
Oh! My bad, this is _G_et. Not, this won't support VFIO but this should not break the current "slow" VFIO support in upstream.
Quoted 4 lines
Quoted 2 lines
Or are those patches *still* not
upstream ?Yes.
This part is still true. I cannot get Alex Graf attention even on much simpler things for several months.
Quoted 81 lines
Quoted 79 lines
Quoted 64 lines
Signed-off-by Laurent Dufour <[email protected]>--- arch/powerpc/include/asm/kvm_ppc.h | 2 ++ arch/powerpc/kvm/book3s_64_vio_hv.c | 28 ++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-)arch/powerpc/include/asm/kvm_ppc.h +2
-0@@ -129,6 +129,8 @@ extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, struct kvm_create_spapr_tce *args);extern long kvmppc_h_put_tce (struct kvm_vcpu *vcpu,unsigned long liobn,unsigned long ioba,unsigned long tce); +extern long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba);extern struct kvm_rma_info *kvm_alloc_rma (void );extern void kvm_release_rma (struct kvm_rma_info *ri);extern struct page *kvm_alloc_hpt (unsigned long nr_pages);arch/powerpc/kvm/book3s_64_vio_hv.c +28
-0@@ -75,3 +75,31 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,return H_TOO_HARD ; }EXPORT_SYMBOL_GPL (kvmppc_h_put_tce); + +long kvmppc_h_get_tce (struct kvm_vcpu *vcpu,unsigned long liobn, +unsigned long ioba) +{ +struct kvm *kvm = vcpu->kvm; +struct kvmppc_spapr_tce_table *stt; + +list_for_each_entry (stt, &kvm->arch.spapr_tce_tables, list) { +if (stt->liobn = liobn) { +unsigned long idx = ioba >>SPAPR_TCE_SHIFT ; +struct page *page; +u64 *tbl; + +if (ioba >= stt->window_size) +return H_PARAMETER ; + + page = stt->pages[idx /TCES_PER_PAGE ]; + tbl = (u64 *)page_address (page); + + vcpu->arch.gpr[4 ] = tbl[idx %TCES_PER_PAGE ]; +return H_SUCCESS ; + } + } + +/* Didn't find the liobn, punt it to userspace */ +return H_TOO_HARD ; +} +EXPORT_SYMBOL_GPL (kvmppc_h_get_tce);arch/powerpc/kvm/book3s_hv_rmhandlers.S +0
-0arch/powerpc/kvm/book3s_hv_rmhandlers.S hcall_real_table: · line 1764
Quoted 8 lines
arch/powerpc/kvm/book3s_hv_rmhandlers.S +1
-1@@ -1758,7 +1758,7 @@ hcall_real_table: .long 0 /* 0x10 - H_CLEAR_MOD */ .long 0 /* 0x14 - H_CLEAR_REF */ .long .kvmppc_h_protect - hcall_real_table - .long 0 /* 0x1c - H_GET_TCE */ + .long .kvmppc_h_get_tce - hcall_real_table .long .kvmppc_h_put_tce - hcall_real_table .long 0 /* 0x24 - H_SET_SPRG0 */ .long .kvmppc_h_set_dabr - hcall_real_table_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Signature · 5 lines
Alexey Kardashevskiy IBM OzLabs, LTC Team e-mail: [email protected] notes: Alexey Kardashevskiy/Australia/IBM
Quoted 7 lines · Alexander Graf
Quoted 4 lines · Laurent Dufour
This fix introduces the
H_GET_TCEhypervisor call which is basically the reverse ofH_PUT_TCE, as defined in the Power Architecture Platform Requirements (PAPR).
Quoted 6 lines
Quoted 4 lines
The hcall
H_GET_TCEis required by the kdump kernel which is calling it to retrieve the TCE set up by the panicing kernel.Signed-off-by Laurent Dufour <[email protected]>Thanks, applied to kvm-ppc-queue. Btw, why exactly are we using struct page pointers and
alloc_pagerather than__get_free_page()and simple page start pointers?
FWIW, I'm not so familiar with that part of code, it seems that this is due to the page fault handler (kvm_spapr_tce_fault) which is part of the mmap file operation handlers associated to the fd returned by kvm_vm_ioctl_create_spapr_tce. Underlying vma's operation requires the page fault handler to return a struct page value in the vm_fault structure.
Cheers,
Laurent.