On Mon, Jan 18, 2021 at 04:28:27PM +1300, Kai Huang wrote: > From: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > > Export the gva_to_gpa() helpers for use by SGX virtualization when > executing ENCLS[ECREATE] and ENCLS[EINIT] on behalf of the guest. > To execute ECREATE and EINIT, KVM must obtain the GPA of the target > Secure Enclave Control Structure (SECS) in order to get its > corresponding HVA. > > Because the SECS must reside in the Enclave Page Cache (EPC), copying > the SECS's data to a host-controlled buffer via existing exported > helpers is not a viable option as the EPC is not readable or writable > by the kernel. > > SGX virtualization will also use gva_to_gpa() to obtain HVAs for > non-EPC pages in order to pass user pointers directly to ECREATE and > EINIT, which avoids having to copy pages worth of data into the kernel. > > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > Signed-off-by: Kai Huang <kai.huang@xxxxxxxxx> Acked-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx> /Jarkko > --- > arch/x86/kvm/x86.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 9a8969a6dd06..5ca7b181a3ae 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -5891,6 +5891,7 @@ gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, > u32 access = (kvm_x86_ops.get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; > return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, exception); > } > +EXPORT_SYMBOL_GPL(kvm_mmu_gva_to_gpa_read); > > gpa_t kvm_mmu_gva_to_gpa_fetch(struct kvm_vcpu *vcpu, gva_t gva, > struct x86_exception *exception) > @@ -5907,6 +5908,7 @@ gpa_t kvm_mmu_gva_to_gpa_write(struct kvm_vcpu *vcpu, gva_t gva, > access |= PFERR_WRITE_MASK; > return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, exception); > } > +EXPORT_SYMBOL_GPL(kvm_mmu_gva_to_gpa_write); > > /* uses this to access any guest's mapped memory without checking CPL */ > gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, > -- > 2.29.2 > >