qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] b02c01: util/vfio-helpers: Pass page protecti


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] b02c01: util/vfio-helpers: Pass page protections to qemu_v...
Date: Tue, 06 Oct 2020 05:30:34 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: b02c01a513a17e03e2245feff19b3dcc8c408859
      
https://github.com/qemu/qemu/commit/b02c01a513a17e03e2245feff19b3dcc8c408859
  Author: Philippe Mathieu-Daudé <philmd@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/nvme.c
    M include/qemu/vfio-helpers.h
    M util/vfio-helpers.c

  Log Message:
  -----------
  util/vfio-helpers: Pass page protections to qemu_vfio_pci_map_bar()

Pages are currently mapped READ/WRITE. To be able to use different
protections, add a new argument to qemu_vfio_pci_map_bar().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200922083821.578519-2-philmd@redhat.com>


  Commit: f68453237b9c97f7d1948236a359524c45d7e2d8
      
https://github.com/qemu/qemu/commit/f68453237b9c97f7d1948236a359524c45d7e2d8
  Author: Philippe Mathieu-Daudé <philmd@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/nvme.c

  Log Message:
  -----------
  block/nvme: Map doorbells pages write-only

Per the datasheet sections 3.1.13/3.1.14:
  "The host should not read the doorbell registers."

As we don't need read access, map the doorbells with write-only
permission. We keep a reference to this mapped address in the
BDRVNVMeState structure.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200922083821.578519-3-philmd@redhat.com>


  Commit: 37d7a45abdfa7376ba04dc68ccc331a5b406d672
      
https://github.com/qemu/qemu/commit/37d7a45abdfa7376ba04dc68ccc331a5b406d672
  Author: Philippe Mathieu-Daudé <philmd@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/nvme.c

  Log Message:
  -----------
  block/nvme: Reduce I/O registers scope

We only access the I/O register in nvme_init().
Remove the reference in BDRVNVMeState and reduce its scope.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200922083821.578519-4-philmd@redhat.com>


  Commit: 9406e0d97ec1923b261b40f11667145fb29e89de
      
https://github.com/qemu/qemu/commit/9406e0d97ec1923b261b40f11667145fb29e89de
  Author: Philippe Mathieu-Daudé <philmd@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/nvme.c

  Log Message:
  -----------
  block/nvme: Drop NVMeRegs structure, directly use NvmeBar

NVMeRegs only contains NvmeBar. Simplify the code by using NvmeBar
directly.

This triggers a checkpatch.pl error:

  ERROR: Use of volatile is usually wrong, please add a comment
  #30: FILE: block/nvme.c:691:
  +    volatile NvmeBar *regs;

This is a false positive as in our case we are using I/O registers,
so the 'volatile' use is justified.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200922083821.578519-5-philmd@redhat.com>


  Commit: fad1eb68862fbd077ef14dc7a0643a6d1404b8ad
      
https://github.com/qemu/qemu/commit/fad1eb68862fbd077ef14dc7a0643a6d1404b8ad
  Author: Philippe Mathieu-Daudé <philmd@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/nvme.c

  Log Message:
  -----------
  block/nvme: Use register definitions from 'block/nvme.h'

Use the NVMe register definitions from "block/nvme.h" which
ease a bit reviewing the code while matching the datasheet.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200922083821.578519-6-philmd@redhat.com>


  Commit: eefffb0244eb72d9b21f30c521bb2ced72500131
      
https://github.com/qemu/qemu/commit/eefffb0244eb72d9b21f30c521bb2ced72500131
  Author: Philippe Mathieu-Daudé <philmd@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/nvme.c

  Log Message:
  -----------
  block/nvme: Replace magic value by SCALE_MS definition

Use self-explicit SCALE_MS definition instead of magic value
(missed in similar commit e4f310fe7f5).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200922083821.578519-7-philmd@redhat.com>


  Commit: 5416645fcf82a6cf520a83c82b577137058aaf32
      
https://github.com/qemu/qemu/commit/5416645fcf82a6cf520a83c82b577137058aaf32
  Author: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block.c
    M include/block/block.h

  Log Message:
  -----------
  block: return error-code from bdrv_invalidate_cache

This is the only coroutine wrapper from block.c and block/io.c which
doesn't return a value, so let's convert it to the common behavior, to
simplify moving to generated coroutine wrappers in a further commit.

Also, bdrv_invalidate_cache is a void function, returning error only
through **errp parameter, which is considered to be bad practice, as
it forces callers to define and propagate local_err variable, so
conversion is good anyway.

This patch leaves the conversion of .bdrv_co_invalidate_cache() driver
callbacks and bdrv_invalidate_cache_all() for another day.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200924185414.28642-2-vsementsov@virtuozzo.com>


  Commit: f9e694cb32403c7ebe8f8cc6949da47896afd561
      
https://github.com/qemu/qemu/commit/f9e694cb32403c7ebe8f8cc6949da47896afd561
  Author: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/io.c

  Log Message:
  -----------
  block/io: refactor coroutine wrappers

Most of our coroutine wrappers already follow this convention:

We have 'coroutine_fn bdrv_co_<something>(<normal argument list>)' as
the core function, and a wrapper 'bdrv_<something>(<same argument
list>)' which does parameter packing and calls bdrv_run_co().

The only outsiders are the bdrv_prwv_co and
bdrv_common_block_status_above wrappers. Let's refactor them to behave
as the others, it simplifies further conversion of coroutine wrappers.

This patch adds an indirection layer, but it will be compensated by
a further commit, which will drop bdrv_co_prwv together with the
is_write logic, to keep the read and write paths separate.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200924185414.28642-3-vsementsov@virtuozzo.com>


  Commit: 21c2283ebc8139108aee89c3a18881b29d3c075a
      
https://github.com/qemu/qemu/commit/21c2283ebc8139108aee89c3a18881b29d3c075a
  Author: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block.c
    A block/coroutines.h
    M block/io.c

  Log Message:
  -----------
  block: declare some coroutine functions in block/coroutines.h

We are going to keep coroutine-wrappers code (structure-packing
parameters, BDRV_POLL wrapper functions) in separate auto-generated
files. So, we'll need a header with declaration of original _co_
functions, for those which are static now. As well, we'll need
declarations for wrapper functions. Do these declarations now, as a
preparation step.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200924185414.28642-4-vsementsov@virtuozzo.com>


  Commit: aaaa20b69b93c961ed8064c553a3577f8c072982
      
https://github.com/qemu/qemu/commit/aaaa20b69b93c961ed8064c553a3577f8c072982
  Author: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    A block/block-gen.h
    M block/meson.build
    A docs/devel/block-coroutine-wrapper.rst
    M docs/devel/index.rst
    M include/block/block.h
    A scripts/block-coroutine-wrapper.py

  Log Message:
  -----------
  scripts: add block-coroutine-wrapper.py

We have a very frequent pattern of creating a coroutine from a function
with several arguments:

  - create a structure to pack parameters
  - create _entry function to call original function taking parameters
    from struct
  - do different magic to handle completion: set ret to NOT_DONE or
    EINPROGRESS or use separate bool field
  - fill the struct and create coroutine from _entry function with this
    struct as a parameter
  - do coroutine enter and BDRV_POLL_WHILE loop

Let's reduce code duplication by generating coroutine wrappers.

This patch adds scripts/block-coroutine-wrapper.py together with some
friends, which will generate functions with declared prototypes marked
by the 'generated_co_wrapper' specifier.

The usage of new code generation is as follows:

    1. define the coroutine function somewhere

        int coroutine_fn bdrv_co_NAME(...) {...}

    2. declare in some header file

        int generated_co_wrapper bdrv_NAME(...);

       with same list of parameters (generated_co_wrapper is
       defined in "include/block/block.h").

    3. Make sure the block_gen_c declaration in block/meson.build
       mentions the file with your marker function.

Still, no function is now marked, this work is for the following
commit.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200924185414.28642-5-vsementsov@virtuozzo.com>
[Added encoding='utf-8' to open() calls as requested by Vladimir. Fixed
typo and grammar issues pointed out by Eric Blake. Removed clang-format
dependency that caused build test issues.
--Stefan]
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: 9bb4b066cce7b3cc1f5893dd5f05bf9ee279d383
      
https://github.com/qemu/qemu/commit/9bb4b066cce7b3cc1f5893dd5f05bf9ee279d383
  Author: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block.c
    M block/coroutines.h
    M block/io.c
    M include/block/block.h

  Log Message:
  -----------
  block: generate coroutine-wrapper code

Use code generation implemented in previous commit to generated
coroutine wrappers in block.c and block/io.c

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200924185414.28642-6-vsementsov@virtuozzo.com>


  Commit: fae2681add3bb2f6a5172eceaec0b90a12a73e96
      
https://github.com/qemu/qemu/commit/fae2681add3bb2f6a5172eceaec0b90a12a73e96
  Author: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/coroutines.h
    M block/io.c
    M include/block/block.h
    M tests/test-bdrv-drain.c

  Log Message:
  -----------
  block: drop bdrv_prwv

Now that we are not maintaining boilerplate code for coroutine
wrappers, there is no more sense in keeping the extra indirection layer
of bdrv_prwv().  Let's drop it and instead generate pure bdrv_preadv()
and bdrv_pwritev().

Currently, bdrv_pwritev() and bdrv_preadv() are returning bytes on
success, auto generated functions will instead return zero, as their
_co_ prototype. Still, it's simple to make the conversion safe: the
only external user of bdrv_pwritev() is test-bdrv-drain, and it is
comfortable enough with bdrv_co_pwritev() instead. So prototypes are
moved to local block/coroutines.h. Next, the only internal use is
bdrv_pread() and bdrv_pwrite(), which are modified to return bytes on
success.

Of course, it would be great to convert bdrv_pread() and bdrv_pwrite()
to return 0 on success. But this requires audit (and probably
conversion) of all their users, let's leave it for another day
refactoring.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200924185414.28642-7-vsementsov@virtuozzo.com>


  Commit: b33b354f3a27e8860a6a7aca465e01c727211ee4
      
https://github.com/qemu/qemu/commit/b33b354f3a27e8860a6a7aca465e01c727211ee4
  Author: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M block/coroutines.h
    M block/io.c
    M include/block/block.h

  Log Message:
  -----------
  block/io: refactor save/load vmstate

Like for read/write in a previous commit, drop extra indirection layer,
generate directly bdrv_readv_vmstate() and bdrv_writev_vmstate().

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200924185414.28642-8-vsementsov@virtuozzo.com>


  Commit: 685257a284d781089bd6eccd9d2b341765a4e664
      
https://github.com/qemu/qemu/commit/685257a284d781089bd6eccd9d2b341765a4e664
  Author: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M include/block/block.h

  Log Message:
  -----------
  include/block/block.h: drop non-ascii quotation mark

This is the only non-ascii character in the file and it doesn't really
needed here. Let's use normal "'" symbol for consistency with the rest
11 occurrences of "'" in the file.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: ad1e691db208d2e04260f08f093bf22296344944
      
https://github.com/qemu/qemu/commit/ad1e691db208d2e04260f08f093bf22296344944
  Author: Stefano Garzarella <sgarzare@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M qemu-options.hx

  Log Message:
  -----------
  docs: add 'io_uring' option to 'aio' param in qemu-options.hx

When we added io_uring AIO engine, we forgot to update qemu-options.hx,
so qemu(1) man page and qemu help were outdated.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Julia Suvorova <jusual@redhat.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Message-Id: <20200924151511.131471-1-sgarzare@redhat.com>


  Commit: 4487d420d0d0d9b503bfb9308e474f0bbac54700
      
https://github.com/qemu/qemu/commit/4487d420d0d0d9b503bfb9308e474f0bbac54700
  Author: Eric Auger <eric.auger@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M util/vfio-helpers.c

  Log Message:
  -----------
  util/vfio-helpers: Collect IOVA reserved regions

The IOVA allocator currently ignores host reserved regions.
As a result some chosen IOVAs may collide with some of them,
resulting in VFIO MAP_DMA errors later on. This happens on ARM
where the MSI reserved window quickly is encountered:
[0x8000000, 0x8100000]. since 5.4 kernel, VFIO returns the usable
IOVA regions. So let's enumerate them in the prospect to avoid
them, later on.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Message-id: 20200929085550.30926-2-eric.auger@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: 9ab5741164b1727d22f69fe7001382baf0d56977
      
https://github.com/qemu/qemu/commit/9ab5741164b1727d22f69fe7001382baf0d56977
  Author: Eric Auger <eric.auger@redhat.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M util/vfio-helpers.c

  Log Message:
  -----------
  util/vfio-helpers: Rework the IOVA allocator to avoid IOVA reserved regions

Introduce the qemu_vfio_find_fixed/temp_iova helpers which
respectively allocate IOVAs from the bottom/top parts of the
usable IOVA range, without picking within host IOVA reserved
windows. The allocation remains basic: if the size is too big
for the remaining of the current usable IOVA range, we jump
to the next one, leaving a hole in the address map.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Message-id: 20200929085550.30926-3-eric.auger@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: d7c5b788295426c1ef48a9ffc3432c51220f69ba
      
https://github.com/qemu/qemu/commit/d7c5b788295426c1ef48a9ffc3432c51220f69ba
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2020-10-06 (Tue, 06 Oct 2020)

  Changed paths:
    M block.c
    A block/block-gen.h
    A block/coroutines.h
    M block/io.c
    M block/meson.build
    M block/nvme.c
    A docs/devel/block-coroutine-wrapper.rst
    M docs/devel/index.rst
    M include/block/block.h
    M include/qemu/vfio-helpers.h
    M qemu-options.hx
    A scripts/block-coroutine-wrapper.py
    M tests/test-bdrv-drain.c
    M util/vfio-helpers.c

  Log Message:
  -----------
  Merge remote-tracking branch 
'remotes/stefanha-gitlab/tags/block-pull-request' into staging

Pull request

v2:
 * Removed clang-format call from scripts/block-coroutine-wrapper.py. This
   avoids the issue with clang version incompatibility. It could be added back
   in the future but the code is readable without reformatting and it also
   makes the build less dependent on the environment.

# gpg: Signature made Mon 05 Oct 2020 16:42:28 BST
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha-gitlab/tags/block-pull-request:
  util/vfio-helpers: Rework the IOVA allocator to avoid IOVA reserved regions
  util/vfio-helpers: Collect IOVA reserved regions
  docs: add 'io_uring' option to 'aio' param in qemu-options.hx
  include/block/block.h: drop non-ascii quotation mark
  block/io: refactor save/load vmstate
  block: drop bdrv_prwv
  block: generate coroutine-wrapper code
  scripts: add block-coroutine-wrapper.py
  block: declare some coroutine functions in block/coroutines.h
  block/io: refactor coroutine wrappers
  block: return error-code from bdrv_invalidate_cache
  block/nvme: Replace magic value by SCALE_MS definition
  block/nvme: Use register definitions from 'block/nvme.h'
  block/nvme: Drop NVMeRegs structure, directly use NvmeBar
  block/nvme: Reduce I/O registers scope
  block/nvme: Map doorbells pages write-only
  util/vfio-helpers: Pass page protections to qemu_vfio_pci_map_bar()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/36d9c2883e55...d7c5b7882954



reply via email to

[Prev in Thread] Current Thread [Next in Thread]