11 Aug, 2021

5 commits

  • mbochs_close() iterates over global device state and frees it. Currently
    this is done every time a device FD is closed, but if multiple device FDs
    are open this could corrupt other still active FDs.

    Change this to use close_device() so it only runs on the last close.

    Reviewed-by: Cornelia Huck
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Link: https://lore.kernel.org/r/11-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • The core code no longer requires these ops to be defined, so delete these
    empty functions and leave the op as NULL. mtty's functions only log a
    pointless message, delete that entirely.

    Signed-off-by: Yishai Hadas
    Reviewed-by: Cornelia Huck
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Link: https://lore.kernel.org/r/5-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • This pairs with vfio_init_group_dev() and allows undoing any state that is
    stored in the vfio_device unrelated to registration. Add appropriately
    placed calls to all the drivers.

    The following patch will use this to add pre-registration state for the
    device set.

    Signed-off-by: Max Gurtovoy
    Reviewed-by: Cornelia Huck
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Link: https://lore.kernel.org/r/3-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com
    Signed-off-by: Alex Williamson

    Max Gurtovoy
     
  • Convert mbochs to use an atomic scheme for this like mtty was changed
    into. The atomic fixes various race conditions with probing. Add the
    missing error unwind. Also add the missing kfree of mdev_state->pages.

    Fixes: 681c1615f891 ("vfio/mbochs: Convert to use vfio_register_group_dev()")
    Reported-by: Cornelia Huck
    Co-developed-by: Alex Williamson
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Reviewed-by: Cornelia Huck
    Link: https://lore.kernel.org/r/2-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • The patch to move the get/put to core and the patch to convert the samples
    to use vfio_device crossed in a way that this was missed. When both
    patches are together the samples do not need their own get/put.

    Fixes: 437e41368c01 ("vfio/mdpy: Convert to use vfio_register_group_dev()")
    Fixes: 681c1615f891 ("vfio/mbochs: Convert to use vfio_register_group_dev()")
    Reviewed-by: Cornelia Huck
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Reviewed-by: Max Gurtovoy
    Link: https://lore.kernel.org/r/1-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     

29 Jun, 2021

1 commit

  • The sample mtty mdev driver doesn't actually enforce the number of
    device instances it claims are available. Implement this properly.

    Link: https://lore.kernel.org/r/162465624894.3338367.12935940647049917981.stgit@omen
    Reviewed-by: Jason Gunthorpe
    Reviewed-by: Cornelia Huck
    Reviewed by: Kirti Wankhede
    Signed-off-by: Alex Williamson

    Alex Williamson
     

28 Jun, 2021

1 commit

  • Dan points out that an error case left things on this list. It is also
    missing locking in available_instances_show().

    Further study shows the list isn't needed at all, just store the total
    ports in use in an atomic and delete the whole thing.

    Reported-by: Dan Carpenter
    Fixes: 09177ac91921 ("vfio/mtty: Convert to use vfio_register_group_dev()")
    Signed-off-by: Jason Gunthorpe
    Link: https://lore.kernel.org/r/0-v1-0bc56b362ca7+62-mtty_used_ports_jgg@nvidia.com
    Reviewed-by: Cornelia Huck
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     

25 Jun, 2021

1 commit

  • In the case where the call to vfio_register_group_dev fails the error
    return path kfree's mdev_state but not mdev_state->vconfig. Fix this
    by kfree'ing mdev_state->vconfig before returning.

    Addresses-Coverity: ("Resource leak")
    Fixes: 437e41368c01 ("vfio/mdpy: Convert to use vfio_register_group_dev()")
    Signed-off-by: Colin Ian King
    Link: https://lore.kernel.org/r/20210622183710.28954-1-colin.king@canonical.com
    Signed-off-by: Alex Williamson

    Colin Ian King
     

22 Jun, 2021

3 commits

  • This is straightforward conversion, the mdev_state is actually serving as
    the vfio_device and we can replace all the mdev_get_drvdata()'s and the
    wonky dead code with a simple container_of().

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Greg Kroah-Hartman
    Link: https://lore.kernel.org/r/20210617142218.1877096-11-hch@lst.de
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • This is straightforward conversion, the mdev_state is actually serving as
    the vfio_device and we can replace all the mdev_get_drvdata()'s and the
    wonky dead code with a simple container_of().

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Greg Kroah-Hartman
    Link: https://lore.kernel.org/r/20210617142218.1877096-10-hch@lst.de
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • This is straightforward conversion, the mdev_state is actually serving as
    the vfio_device and we can replace all the mdev_get_drvdata()'s and the
    wonky dead code with a simple container_of()

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Greg Kroah-Hartman
    Reviewed-by: Kirti Wankhede
    Link: https://lore.kernel.org/r/20210617142218.1877096-9-hch@lst.de
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     

25 May, 2021

1 commit

  • Fix to return a negative error code from the framebuffer_alloc() error
    handling case instead of 0, also release regions in some error handing
    cases.

    Fixes: cacade1946a4 ("sample: vfio mdev display - guest driver")
    Reported-by: Hulk Robot
    Signed-off-by: Wei Yongjun
    Message-Id:
    Signed-off-by: Alex Williamson

    Wei Yongjun
     

04 May, 2021

1 commit

  • Originally "type" could be NULL and these checks were required, but we
    recently changed how "type" is assigned and that's no longer the case.
    Now "type" points to an element in the middle of a non-NULL array.

    Removing the checks does not affect runtime at all, but it makes the
    code a little bit simpler to read.

    Fixes: 3d3a360e570616 ("vfio/mbochs: Use mdev_get_type_group_id()")
    Signed-off-by: Dan Carpenter
    Reviewed-by: Jason Gunthorpe
    Message-Id:
    Signed-off-by: Alex Williamson

    Dan Carpenter
     

01 May, 2021

1 commit

  • Patch series "remap_vmalloc_range cleanups".

    This series removes an open coded instance of remap_vmalloc_range and
    removes the unused remap_vmalloc_range_partial export.

    This patch (of 2):

    Use remap_vmalloc_range instead of open coding it using
    remap_vmalloc_range_partial.

    Link: https://lkml.kernel.org/r/20210301082235.932968-1-hch@lst.de
    Link: https://lkml.kernel.org/r/20210301082235.932968-2-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Cc: Kirti Wankhede
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

13 Apr, 2021

2 commits

  • The driver core standard is to pass in the properly typed object, the
    properly typed attribute and the buffer data. It stems from the root
    kobject method:

    ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..)

    Each subclass of kobject should provide their own function with the same
    signature but more specific types, eg struct device uses:

    ssize_t (*show)(struct device *dev, struct device_attribute *attr,..)

    In this case the existing signature is:

    ssize_t (*show)(struct kobject *kobj, struct device *dev,..)

    Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'.

    Change the mdev_type related sysfs attribute functions to:

    ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..)

    In order to restore type safety and match the driver core standard

    There are no current users of 'attr', but if it is ever needed it would be
    hard to add in retroactively, so do it now.

    Reviewed-by: Kevin Tian
    Reviewed-by: Cornelia Huck
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Message-Id:
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • The kobj here is a type-erased version of mdev_type, which is already
    stored in the struct mdev_device being passed in. It was only ever used to
    compute the type_group_id, which is now extracted directly from the mdev.

    Reviewed-by: Kevin Tian
    Reviewed-by: Cornelia Huck
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Message-Id:
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     

08 Apr, 2021

4 commits

  • The mbochs_types array is parallel to the supported_type_groups array, so
    the type_group_id indexes both. Instead of doing string searching just
    directly index with type_group_id in all places.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Message-Id:
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • The mdpy_types array is parallel to the supported_type_groups array, so
    the type_group_id indexes both. Instead of doing string searching just
    directly index with type_group_id in all places.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Message-Id:
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • The type_group_id directly gives the single or dual port index, no
    need for string searching.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe
    Message-Id:
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     
  • These should always be prefixed with static, otherwise compilation
    will fail on non-modular builds with

    ld: samples/vfio-mdev/mbochs.o:(.data+0x2e0): multiple definition of `mdev_type_attr_name'; samples/vfio-mdev/mdpy.o:(.data+0x240): first defined here

    Fixes: a5e6e6505f38 ("sample: vfio bochs vbe display (host device for bochs-drm)")
    Fixes: d61fc96f47fd ("sample: vfio mdev display - host device")
    Signed-off-by: Jason Gunthorpe
    Reviewed-by: Christoph Hellwig
    Message-Id:
    Signed-off-by: Alex Williamson

    Jason Gunthorpe
     

10 Sep, 2020

1 commit

  • The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function
    returns the number of the created entries in the DMA address space.
    However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and
    dma_unmap_sg must be called with the original number of the entries
    passed to the dma_map_sg().

    struct sg_table is a common structure used for describing a non-contiguous
    memory buffer, used commonly in the DRM and graphics subsystems. It
    consists of a scatterlist with memory pages and DMA addresses (sgl entry),
    as well as the number of scatterlist entries: CPU pages (orig_nents entry)
    and DMA mapped pages (nents entry).

    It turned out that it was a common mistake to misuse nents and orig_nents
    entries, calling DMA-mapping functions with a wrong number of entries or
    ignoring the number of mapped entries returned by the dma_map_sg()
    function.

    To avoid such issues, lets use a common dma-mapping wrappers operating
    directly on the struct sg_table objects and use scatterlist page
    iterators where possible. This, almost always, hides references to the
    nents and orig_nents entries, making the code robust, easier to follow
    and copy/paste safe.

    While touching this code, also add missing call to dma_unmap_sgtable.

    Signed-off-by: Marek Szyprowski
    Reviewed-by: Robin Murphy

    Marek Szyprowski
     

10 Jul, 2020

1 commit

  • Instead of duplicating the PCI_VENDOR_ID_REDHAT definition everywhere, move
    it to include/linux/pci_ids.h.

    [bhelgaas: also update MDPY_PCI_VENDOR_ID]
    Link: https://lore.kernel.org/r/1594195170-11119-1-git-send-email-chenhc@lemote.com
    Signed-off-by: Huacai Chen
    Signed-off-by: Bjorn Helgaas
    Acked-by: Gerd Hoffmann

    Huacai Chen
     

22 Apr, 2020

1 commit

  • remap_vmalloc_range() has had various issues with the bounds checks it
    promises to perform ("This function checks that addr is a valid
    vmalloc'ed area, and that it is big enough to cover the vma") over time,
    e.g.:

    - not detecting pgoff<<<<
    Signed-off-by: Andrew Morton
    Cc: stable@vger.kernel.org
    Cc: Alexei Starovoitov
    Cc: Daniel Borkmann
    Cc: Martin KaFai Lau
    Cc: Song Liu
    Cc: Yonghong Song
    Cc: Andrii Nakryiko
    Cc: John Fastabend
    Cc: KP Singh
    Link: http://lkml.kernel.org/r/20200415222312.236431-1-jannh@google.com
    Signed-off-by: Linus Torvalds

    Jann Horn
     

10 Dec, 2019

1 commit

  • Now that the fbops member of struct fb_info is const, we can start
    making the ops const as well.

    v2: fix typo (Christophe de Dinechin)

    Cc: Kirti Wankhede
    Cc: kvm@vger.kernel.org
    Reviewed-by: Daniel Vetter
    Acked-by: Kirti Wankhede
    Signed-off-by: Jani Nikula
    Link: https://patchwork.freedesktop.org/patch/msgid/ddb10df1316ef585930cda7718643a580f4fe37b.1575390741.git.jani.nikula@intel.com

    Jani Nikula
     

26 Nov, 2019

1 commit


20 Aug, 2019

1 commit

  • While generating interrupt, mdev_state is already available for which
    interrupt is generated.
    Instead of doing indirect way from state->device->uuid-> to searching
    state linearly in linked list on every interrupt generation,
    directly use the available state.

    Hence, simplify the code to use mdev_state and remove unused helper
    function with that.

    Reviewed-by: Cornelia Huck
    Signed-off-by: Parav Pandit
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Alex Williamson

    Parav Pandit
     

25 Jul, 2019

1 commit

  • The "WITH Linux-syscall-note" exception exists for headers exported to
    user space. It is strange to add it to non-exported headers.

    Commit 687a3e4d8e61 ("treewide: remove SPDX "WITH Linux-syscall-note"
    from kernel-space headers") did cleanups some months ago, but it looks
    like we need to do this periodically.

    This patch was generated by the following script:

    git grep -l -e Linux-syscall-note \
    -- :*.h :^arch/*/include/uapi/asm/*.h :^include/uapi/ :^tools |
    while read file
    do
    sed -i -e 's/(\(GPL-[^[:space:]]*\) WITH Linux-syscall-note)/\1/g' \
    -e 's/ WITH Linux-syscall-note//g' $file
    done

    I did not commit drivers/staging/android/uapi/ion.h . This header is
    not currently exported, but somebody may plan to move it to include/uapi/
    when the time comes. I am not sure. Anyway, it will be better to check
    the license inconsistency in drivers/staging/android/uapi/.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Masahiro Yamada
     

03 Jul, 2019

2 commits

  • Fixes gcc '-Wunused-but-set-variable' warning:

    samples/vfio-mdev/mbochs.c: In function mbochs_ioctl:
    samples/vfio-mdev/mbochs.c:1188:21: warning: variable mdev_state set but not used [-Wunused-but-set-variable]

    It's not used any more since commit 104c7405a64d ("vfio:
    add edid support to mbochs sample driver")

    Signed-off-by: YueHaibing
    Signed-off-by: Alex Williamson

    YueHaibing
     
  • Make some structs and functions static to fix build warning, parts of
    warning shown below,

    samples/vfio-mdev/mtty.c:730:5: warning: symbol 'mtty_create' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:780:5: warning: symbol 'mtty_remove' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:802:5: warning: symbol 'mtty_reset' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:818:9: warning: symbol 'mtty_read' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:877:9: warning: symbol 'mtty_write' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:1070:5: warning: symbol 'mtty_get_region_info' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:1119:5: warning: symbol 'mtty_get_irq_info' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:1143:5: warning: symbol 'mtty_get_device_info' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:1275:5: warning: symbol 'mtty_open' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:1281:6: warning: symbol 'mtty_close' was not declared. Should it be static?
    samples/vfio-mdev/mtty.c:1305:30: warning: symbol 'mtty_dev_groups' was not declared. Should it be static?

    Cc: Andy Shevchenko
    Cc: Alex Williamson
    Cc: Kirti Wankhede
    Reported-by: Hulk Robot
    Signed-off-by: Kefeng Wang
    Reviewed-by: Andy Shevchenko
    [aw: wrap long lines]
    Signed-off-by: Alex Williamson

    Kefeng Wang
     

19 Jun, 2019

1 commit

  • Based on 2 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation #

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 4122 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Enrico Weigelt
    Reviewed-by: Kate Stewart
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


13 Feb, 2019

3 commits


06 Feb, 2019

1 commit

  • There are new types and helpers that are supposed to be used in new code.

    As a preparation to get rid of legacy types and API functions do
    the conversion here.

    Cc: Kirti Wankhede
    Cc: Alex Williamson
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Alex Williamson

    Andy Shevchenko
     

18 Dec, 2018

1 commit

  • Clang warns:

    samples/vfio-mdev/mtty.c:592:39: warning: implicit conversion from 'int'
    to 'char' changes value from 162 to -94 [-Wconstant-conversion]
    *buf = UART_MSR_DSR | UART_MSR_DDSR | UART_MSR_DCD;
    ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
    1 warning generated.

    Turns out that all uses of buf in this function ultimately end up stored
    or cast to an unsigned type. Just use u8, which has the same number of
    bits but can store this larger number so Clang no longer warns.

    Signed-off-by: Nathan Chancellor
    Signed-off-by: Alex Williamson

    Nathan Chancellor
     

12 Oct, 2018

1 commit


12 Jul, 2018

1 commit


05 Jul, 2018

1 commit


26 Jun, 2018

1 commit