lkml.org 
[lkml]   [2022]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFT][PATCH v2 8/9] vfio/ccw: Add kmap_local_page() for memcpy
    On Tue, Jul 05, 2022 at 11:27:58PM -0700, Nicolin Chen wrote:
    > A PFN is not secure enough to promise that the memory is not IO. And
    > direct access via memcpy() that only handles CPU memory will crash on
    > S390 if the PFN is an IO PFN, as we have to use the memcpy_to/fromio()
    > that uses the special S390 IO access instructions. On the other hand,
    > a "struct page *" is always a CPU coherent thing that fits memcpy().
    >
    > Also, casting a PFN to "void *" for memcpy() is not a proper practice,
    > kmap_local_page() is the correct API to call here, though S390 doesn't
    > use highmem, which means kmap_local_page() is a NOP.
    >
    > There's a following patch changing the vfio_pin_pages() API to return
    > a list of "struct page *" instead of PFNs. It will block any IO memory
    > from ever getting into this call path, for such a security purpose. In
    > this patch, add kmap_local_page() to prepare for that.
    >
    > Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
    > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
    > ---
    > drivers/s390/cio/vfio_ccw_cp.c | 9 ++++++---
    > 1 file changed, 6 insertions(+), 3 deletions(-)

    Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

    Jason

    \
     
     \ /
      Last update: 2022-07-06 20:17    [W:4.055 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site