• Yu Ning's avatar
    goldfish_pipe: Pass physical addresses to the device if supported · 4f42071c
    Yu Ning authored
    For reading and writing guest user space buffers, currently the kernel
    sends the guest virtual address of the buffer to the pipe device. This
    virtual address has to be first converted to a guest physical address.
    Doing this translation on the QEMU side is inefficient and requires
    additional handling when KVM is enabled, whose implementation would
    either incur intrusive changes to QEMU's KVM support code or suffer
    from poor performance, see commit 08c7228c50f8 ("x86-kvm: only sync
    SREGS when doing address translation") of $AOSP/external/qemu for
    details, and thus should be avoided if possible.
    
    There is a TODO comment in hw/misc/android_pipe.c in the new Android
    emulator source tree ($AOSP/external/qemu-android) which requests that
    the translation be done on the kernel side and that physical addresses
    be passed to the device instead of virtual ones. Once the QEMU-side
    implementation is done, the kernel will need to support both the new
    paddr-based pipe device and the old vaddr-based one (which will
    continue to be used by the classic emulator). This patch achieves that
    by leveraging the device version register available in the new device.
    
    See https://android-review.googlesource.com/128280 for the QEMU-side
    patch.
    
    In addition, use the mmap semaphore (in read mode) to safeguard the
    call to get_user_pages().
    Signed-off-by: default avatarYu Ning <yu.ning@intel.com>
    Signed-off-by: default avatarJin Qian <jinqian@android.com>
    Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    4f42071c
goldfish_pipe.c 18.4 KB