1
The following changes since commit 66234fee9c2d37bfbc523aa8d0ae5300a14cc10e:
1
The following changes since commit 3521ade3510eb5cefb2e27a101667f25dad89935:
2
2
3
Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-202=
3
Merge remote-tracking branch 'remotes/thuth-gitlab/tags/pull-request-2021-07-29' into staging (2021-07-29 13:17:20 +0100)
4
00603' into staging (2020-06-04 11:38:48 +0100)
5
4
6
are available in the Git repository at:
5
are available in the Git repository at:
7
6
8
https://github.com/stefanha/qemu.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
9
8
10
for you to fetch changes up to 7d2410cea154bf915fb30179ebda3b17ac36e70e:
9
for you to fetch changes up to cc8eecd7f105a1dff5876adeb238a14696061a4a:
11
10
12
block: Factor out bdrv_run_co() (2020-06-05 09:54:48 +0100)
11
MAINTAINERS: Added myself as a reviewer for the NVMe Block Driver (2021-07-29 17:17:34 +0100)
13
12
14
----------------------------------------------------------------
13
----------------------------------------------------------------
15
Pull request
14
Pull request
16
15
16
The main fix here is for io_uring. Spurious -EAGAIN errors can happen and the
17
request needs to be resubmitted.
18
19
The MAINTAINERS changes carry no risk and we might as well include them in QEMU
20
6.1.
21
17
----------------------------------------------------------------
22
----------------------------------------------------------------
18
23
19
Alexander Bulekov (4):
24
Fabian Ebner (1):
20
fuzz: add datadir for oss-fuzz compatability
25
block/io_uring: resubmit when result is -EAGAIN
21
fuzz: fix typo in i440fx-qtest-reboot arguments
22
fuzz: add mangled object name to linker script
23
fuzz: run the main-loop in fork-server process
24
26
25
Philippe Mathieu-Daud=C3=A9 (4):
27
Philippe Mathieu-Daudé (1):
26
memory: Rename memory_region_do_writeback -> memory_region_writeback
28
MAINTAINERS: Added myself as a reviewer for the NVMe Block Driver
27
memory: Extract memory_region_msync() from memory_region_writeback()
28
hw/block: Let the NVMe emulated device be target-agnostic
29
exec: Rename qemu_ram_writeback() as qemu_ram_msync()
30
29
31
Stefano Garzarella (2):
30
Stefano Garzarella (1):
32
io_uring: retry io_uring_submit() if it fails with errno=3DEINTR
31
MAINTAINERS: add Stefano Garzarella as io_uring reviewer
33
io_uring: use io_uring_cq_ready() to check for ready cqes
34
32
35
Vladimir Sementsov-Ogievskiy (1):
33
MAINTAINERS | 2 ++
36
block: Factor out bdrv_run_co()
34
block/io_uring.c | 16 +++++++++++++++-
35
2 files changed, 17 insertions(+), 1 deletion(-)
37
36
38
hw/block/Makefile.objs | 2 +-
37
--
39
include/exec/memory.h | 15 ++-
38
2.31.1
40
include/exec/ram_addr.h | 4 +-
41
include/sysemu/sysemu.h | 2 +
42
block/io.c | 193 +++++++++++-----------------
43
block/io_uring.c | 11 +-
44
exec.c | 2 +-
45
hw/block/nvme.c | 6 +-
46
memory.c | 12 +-
47
softmmu/vl.c | 2 +-
48
target/arm/helper.c | 2 +-
49
tests/qtest/fuzz/fuzz.c | 15 +++
50
tests/qtest/fuzz/i440fx_fuzz.c | 3 +-
51
tests/qtest/fuzz/virtio_net_fuzz.c | 2 +
52
tests/qtest/fuzz/virtio_scsi_fuzz.c | 2 +
53
tests/qtest/fuzz/fork_fuzz.ld | 5 +
54
16 files changed, 134 insertions(+), 144 deletions(-)
55
39
56
--=20
57
2.25.4
58
diff view generated by jsdifflib
1
From: Stefano Garzarella <sgarzare@redhat.com>
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
2
3
In qemu_luring_poll_cb() we are not using the cqe peeked from the
3
I've been working with io_uring for a while so I'd like to help
4
CQ ring. We are using io_uring_peek_cqe() only to see if there
4
with reviews.
5
are cqes ready, so we can replace it with io_uring_cq_ready().
6
5
7
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
6
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
8
Message-id: 20200519134942.118178-1-sgarzare@redhat.com
7
Message-Id: <20210728131515.131045-1-sgarzare@redhat.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
---
9
---
11
block/io_uring.c | 9 +++------
10
MAINTAINERS | 1 +
12
1 file changed, 3 insertions(+), 6 deletions(-)
11
1 file changed, 1 insertion(+)
13
12
14
diff --git a/block/io_uring.c b/block/io_uring.c
13
diff --git a/MAINTAINERS b/MAINTAINERS
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/block/io_uring.c
15
--- a/MAINTAINERS
17
+++ b/block/io_uring.c
16
+++ b/MAINTAINERS
18
@@ -XXX,XX +XXX,XX @@ static void qemu_luring_completion_cb(void *opaque)
17
@@ -XXX,XX +XXX,XX @@ Linux io_uring
19
static bool qemu_luring_poll_cb(void *opaque)
18
M: Aarushi Mehta <mehta.aaru20@gmail.com>
20
{
19
M: Julia Suvorova <jusual@redhat.com>
21
LuringState *s = opaque;
20
M: Stefan Hajnoczi <stefanha@redhat.com>
22
- struct io_uring_cqe *cqes;
21
+R: Stefano Garzarella <sgarzare@redhat.com>
23
22
L: qemu-block@nongnu.org
24
- if (io_uring_peek_cqe(&s->ring, &cqes) == 0) {
23
S: Maintained
25
- if (cqes) {
24
F: block/io_uring.c
26
- luring_process_completions_and_submit(s);
27
- return true;
28
- }
29
+ if (io_uring_cq_ready(&s->ring)) {
30
+ luring_process_completions_and_submit(s);
31
+ return true;
32
}
33
34
return false;
35
--
25
--
36
2.25.4
26
2.31.1
37
27
diff view generated by jsdifflib
1
From: Stefano Garzarella <sgarzare@redhat.com>
1
From: Fabian Ebner <f.ebner@proxmox.com>
2
2
3
As recently documented [1], io_uring_enter(2) syscall can return an
3
Linux SCSI can throw spurious -EAGAIN in some corner cases in its
4
error (errno=EINTR) if the operation was interrupted by a delivery
4
completion path, which will end up being the result in the completed
5
of a signal before it could complete.
5
io_uring request.
6
6
7
This should happen when IORING_ENTER_GETEVENTS flag is used, for
7
Resubmitting such requests should allow block jobs to complete, even
8
example during io_uring_submit_and_wait() or during io_uring_submit()
8
if such spurious errors are encountered.
9
when IORING_SETUP_IOPOLL is enabled.
10
9
11
We shouldn't have this problem for now, but it's better to prevent it.
10
Co-authored-by: Stefan Hajnoczi <stefanha@gmail.com>
12
11
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
13
[1] https://github.com/axboe/liburing/commit/344355ec6619de8f4e64584c9736530b5346e4f4
12
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
14
13
Message-id: 20210729091029.65369-1-f.ebner@proxmox.com
15
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
16
Message-id: 20200519133041.112138-1-sgarzare@redhat.com
17
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18
---
15
---
19
block/io_uring.c | 2 +-
16
block/io_uring.c | 16 +++++++++++++++-
20
1 file changed, 1 insertion(+), 1 deletion(-)
17
1 file changed, 15 insertions(+), 1 deletion(-)
21
18
22
diff --git a/block/io_uring.c b/block/io_uring.c
19
diff --git a/block/io_uring.c b/block/io_uring.c
23
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
24
--- a/block/io_uring.c
21
--- a/block/io_uring.c
25
+++ b/block/io_uring.c
22
+++ b/block/io_uring.c
26
@@ -XXX,XX +XXX,XX @@ static int ioq_submit(LuringState *s)
23
@@ -XXX,XX +XXX,XX @@ static void luring_process_completions(LuringState *s)
27
trace_luring_io_uring_submit(s, ret);
24
total_bytes = ret + luringcb->total_read;
28
/* Prevent infinite loop if submission is refused */
25
29
if (ret <= 0) {
26
if (ret < 0) {
30
- if (ret == -EAGAIN) {
27
- if (ret == -EINTR) {
31
+ if (ret == -EAGAIN || ret == -EINTR) {
28
+ /*
29
+ * Only writev/readv/fsync requests on regular files or host block
30
+ * devices are submitted. Therefore -EAGAIN is not expected but it's
31
+ * known to happen sometimes with Linux SCSI. Submit again and hope
32
+ * the request completes successfully.
33
+ *
34
+ * For more information, see:
35
+ * https://lore.kernel.org/io-uring/20210727165811.284510-3-axboe@kernel.dk/T/#u
36
+ *
37
+ * If the code is changed to submit other types of requests in the
38
+ * future, then this workaround may need to be extended to deal with
39
+ * genuine -EAGAIN results that should not be resubmitted
40
+ * immediately.
41
+ */
42
+ if (ret == -EINTR || ret == -EAGAIN) {
43
luring_resubmit(s, luringcb);
32
continue;
44
continue;
33
}
45
}
34
break;
35
--
46
--
36
2.25.4
47
2.31.1
37
48
diff view generated by jsdifflib
Deleted patch
1
From: Alexander Bulekov <alxndr@bu.edu>
2
1
3
This allows us to keep pc-bios in executable_dir/pc-bios, rather than
4
executable_dir/../pc-bios, which is incompatible with oss-fuzz' file
5
structure.
6
7
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
8
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
9
Message-id: 20200512030133.29896-2-alxndr@bu.edu
10
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
---
12
include/sysemu/sysemu.h | 2 ++
13
softmmu/vl.c | 2 +-
14
tests/qtest/fuzz/fuzz.c | 15 +++++++++++++++
15
3 files changed, 18 insertions(+), 1 deletion(-)
16
17
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/sysemu/sysemu.h
20
+++ b/include/sysemu/sysemu.h
21
@@ -XXX,XX +XXX,XX @@ extern const char *qemu_name;
22
extern QemuUUID qemu_uuid;
23
extern bool qemu_uuid_set;
24
25
+void qemu_add_data_dir(const char *path);
26
+
27
void qemu_add_exit_notifier(Notifier *notify);
28
void qemu_remove_exit_notifier(Notifier *notify);
29
30
diff --git a/softmmu/vl.c b/softmmu/vl.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/softmmu/vl.c
33
+++ b/softmmu/vl.c
34
@@ -XXX,XX +XXX,XX @@ char *qemu_find_file(int type, const char *name)
35
return NULL;
36
}
37
38
-static void qemu_add_data_dir(const char *path)
39
+void qemu_add_data_dir(const char *path)
40
{
41
int i;
42
43
diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/tests/qtest/fuzz/fuzz.c
46
+++ b/tests/qtest/fuzz/fuzz.c
47
@@ -XXX,XX +XXX,XX @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
48
{
49
50
char *target_name;
51
+ char *dir;
52
53
/* Initialize qgraph and modules */
54
qos_graph_init();
55
@@ -XXX,XX +XXX,XX @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
56
target_name = strstr(**argv, "-target-");
57
if (target_name) { /* The binary name specifies the target */
58
target_name += strlen("-target-");
59
+ /*
60
+ * With oss-fuzz, the executable is kept in the root of a directory (we
61
+ * cannot assume the path). All data (including bios binaries) must be
62
+ * in the same dir, or a subdir. Thus, we cannot place the pc-bios so
63
+ * that it would be in exec_dir/../pc-bios.
64
+ * As a workaround, oss-fuzz allows us to use argv[0] to get the
65
+ * location of the executable. Using this we add exec_dir/pc-bios to
66
+ * the datadirs.
67
+ */
68
+ dir = g_build_filename(g_path_get_dirname(**argv), "pc-bios", NULL);
69
+ if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
70
+ qemu_add_data_dir(dir);
71
+ }
72
+ g_free(dir);
73
} else if (*argc > 1) { /* The target is specified as an argument */
74
target_name = (*argv)[1];
75
if (!strstr(target_name, "--fuzz-target=")) {
76
--
77
2.25.4
78
diff view generated by jsdifflib
Deleted patch
1
From: Alexander Bulekov <alxndr@bu.edu>
2
1
3
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
4
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Message-id: 20200512030133.29896-3-alxndr@bu.edu
7
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8
---
9
tests/qtest/fuzz/i440fx_fuzz.c | 2 +-
10
1 file changed, 1 insertion(+), 1 deletion(-)
11
12
diff --git a/tests/qtest/fuzz/i440fx_fuzz.c b/tests/qtest/fuzz/i440fx_fuzz.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qtest/fuzz/i440fx_fuzz.c
15
+++ b/tests/qtest/fuzz/i440fx_fuzz.c
16
@@ -XXX,XX +XXX,XX @@ static void i440fx_fuzz_qos_fork(QTestState *s,
17
}
18
19
static const char *i440fx_qtest_argv = TARGET_NAME " -machine accel=qtest"
20
- "-m 0 -display none";
21
+ " -m 0 -display none";
22
static const char *i440fx_argv(FuzzTarget *t)
23
{
24
return i440fx_qtest_argv;
25
--
26
2.25.4
27
diff view generated by jsdifflib
Deleted patch
1
From: Alexander Bulekov <alxndr@bu.edu>
2
1
3
Previously, we relied on "FuzzerTracePC*(.bss*)" to place libfuzzer's
4
fuzzer::TPC object into our contiguous shared-memory region. This does
5
not work for some libfuzzer builds, so this addition identifies the
6
region by its mangled name: *(.bss._ZN6fuzzer3TPCE);
7
8
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
9
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
10
Message-id: 20200512030133.29896-4-alxndr@bu.edu
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
13
tests/qtest/fuzz/fork_fuzz.ld | 5 +++++
14
1 file changed, 5 insertions(+)
15
16
diff --git a/tests/qtest/fuzz/fork_fuzz.ld b/tests/qtest/fuzz/fork_fuzz.ld
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qtest/fuzz/fork_fuzz.ld
19
+++ b/tests/qtest/fuzz/fork_fuzz.ld
20
@@ -XXX,XX +XXX,XX @@ SECTIONS
21
22
/* Internal Libfuzzer TracePC object which contains the ValueProfileMap */
23
FuzzerTracePC*(.bss*);
24
+ /*
25
+ * In case the above line fails, explicitly specify the (mangled) name of
26
+ * the object we care about
27
+ */
28
+ *(.bss._ZN6fuzzer3TPCE);
29
}
30
.data.fuzz_end : ALIGN(4K)
31
{
32
--
33
2.25.4
34
diff view generated by jsdifflib
Deleted patch
1
From: Alexander Bulekov <alxndr@bu.edu>
2
1
3
Without this, the time since the last main-loop keeps increasing, as the
4
fuzzer runs. The forked children need to handle all the "past-due"
5
timers, slowing them down, over time. With this change, the
6
parent/fork-server process runs the main-loop, while waiting on the
7
child, ensuring that the timer events do not pile up, over time.
8
9
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
10
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
11
Message-id: 20200512030133.29896-5-alxndr@bu.edu
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
14
tests/qtest/fuzz/i440fx_fuzz.c | 1 +
15
tests/qtest/fuzz/virtio_net_fuzz.c | 2 ++
16
tests/qtest/fuzz/virtio_scsi_fuzz.c | 2 ++
17
3 files changed, 5 insertions(+)
18
19
diff --git a/tests/qtest/fuzz/i440fx_fuzz.c b/tests/qtest/fuzz/i440fx_fuzz.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/qtest/fuzz/i440fx_fuzz.c
22
+++ b/tests/qtest/fuzz/i440fx_fuzz.c
23
@@ -XXX,XX +XXX,XX @@ static void i440fx_fuzz_qos_fork(QTestState *s,
24
i440fx_fuzz_qos(s, Data, Size);
25
_Exit(0);
26
} else {
27
+ flush_events(s);
28
wait(NULL);
29
}
30
}
31
diff --git a/tests/qtest/fuzz/virtio_net_fuzz.c b/tests/qtest/fuzz/virtio_net_fuzz.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/tests/qtest/fuzz/virtio_net_fuzz.c
34
+++ b/tests/qtest/fuzz/virtio_net_fuzz.c
35
@@ -XXX,XX +XXX,XX @@ static void virtio_net_fork_fuzz(QTestState *s,
36
flush_events(s);
37
_Exit(0);
38
} else {
39
+ flush_events(s);
40
wait(NULL);
41
}
42
}
43
@@ -XXX,XX +XXX,XX @@ static void virtio_net_fork_fuzz_check_used(QTestState *s,
44
flush_events(s);
45
_Exit(0);
46
} else {
47
+ flush_events(s);
48
wait(NULL);
49
}
50
}
51
diff --git a/tests/qtest/fuzz/virtio_scsi_fuzz.c b/tests/qtest/fuzz/virtio_scsi_fuzz.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/tests/qtest/fuzz/virtio_scsi_fuzz.c
54
+++ b/tests/qtest/fuzz/virtio_scsi_fuzz.c
55
@@ -XXX,XX +XXX,XX @@ static void virtio_scsi_fork_fuzz(QTestState *s,
56
flush_events(s);
57
_Exit(0);
58
} else {
59
+ flush_events(s);
60
wait(NULL);
61
}
62
}
63
@@ -XXX,XX +XXX,XX @@ static void virtio_scsi_with_flag_fuzz(QTestState *s,
64
}
65
_Exit(0);
66
} else {
67
+ flush_events(s);
68
wait(NULL);
69
}
70
}
71
--
72
2.25.4
73
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
We usually use '_do_' for internal functions. Rename
4
memory_region_do_writeback() as memory_region_writeback().
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
10
Message-id: 20200508062456.23344-2-philmd@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
13
include/exec/memory.h | 4 ++--
14
memory.c | 2 +-
15
target/arm/helper.c | 2 +-
16
3 files changed, 4 insertions(+), 4 deletions(-)
17
18
diff --git a/include/exec/memory.h b/include/exec/memory.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/exec/memory.h
21
+++ b/include/exec/memory.h
22
@@ -XXX,XX +XXX,XX @@ void *memory_region_get_ram_ptr(MemoryRegion *mr);
23
void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize,
24
Error **errp);
25
/**
26
- * memory_region_do_writeback: Trigger cache writeback or msync for
27
+ * memory_region_writeback: Trigger cache writeback or msync for
28
* selected address range
29
*
30
* @mr: the memory region to be updated
31
* @addr: the initial address of the range to be written back
32
* @size: the size of the range to be written back
33
*/
34
-void memory_region_do_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size);
35
+void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size);
36
37
/**
38
* memory_region_set_log: Turn dirty logging on or off for a region.
39
diff --git a/memory.c b/memory.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/memory.c
42
+++ b/memory.c
43
@@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp
44
}
45
46
47
-void memory_region_do_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size)
48
+void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size)
49
{
50
/*
51
* Might be extended case needed to cover
52
diff --git a/target/arm/helper.c b/target/arm/helper.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/helper.c
55
+++ b/target/arm/helper.c
56
@@ -XXX,XX +XXX,XX @@ static void dccvap_writefn(CPUARMState *env, const ARMCPRegInfo *opaque,
57
mr = memory_region_from_host(haddr, &offset);
58
59
if (mr) {
60
- memory_region_do_writeback(mr, offset, dline_size);
61
+ memory_region_writeback(mr, offset, dline_size);
62
}
63
}
64
}
65
--
66
2.25.4
67
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
8
Message-id: 20200508062456.23344-3-philmd@redhat.com
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
---
11
include/exec/memory.h | 13 ++++++++++++-
12
memory.c | 10 ++++++++--
13
2 files changed, 20 insertions(+), 3 deletions(-)
14
15
diff --git a/include/exec/memory.h b/include/exec/memory.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/exec/memory.h
18
+++ b/include/exec/memory.h
19
@@ -XXX,XX +XXX,XX @@ void *memory_region_get_ram_ptr(MemoryRegion *mr);
20
*/
21
void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize,
22
Error **errp);
23
+
24
/**
25
- * memory_region_writeback: Trigger cache writeback or msync for
26
+ * memory_region_msync: Synchronize selected address range of
27
+ * a memory mapped region
28
+ *
29
+ * @mr: the memory region to be msync
30
+ * @addr: the initial address of the range to be sync
31
+ * @size: the size of the range to be sync
32
+ */
33
+void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size);
34
+
35
+/**
36
+ * memory_region_writeback: Trigger cache writeback for
37
* selected address range
38
*
39
* @mr: the memory region to be updated
40
diff --git a/memory.c b/memory.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/memory.c
43
+++ b/memory.c
44
@@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp
45
qemu_ram_resize(mr->ram_block, newsize, errp);
46
}
47
48
+void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size)
49
+{
50
+ if (mr->ram_block) {
51
+ qemu_ram_writeback(mr->ram_block, addr, size);
52
+ }
53
+}
54
55
void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size)
56
{
57
@@ -XXX,XX +XXX,XX @@ void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size)
58
* Might be extended case needed to cover
59
* different types of memory regions
60
*/
61
- if (mr->ram_block && mr->dirty_log_mask) {
62
- qemu_ram_writeback(mr->ram_block, addr, size);
63
+ if (mr->dirty_log_mask) {
64
+ memory_region_msync(mr, addr, size);
65
}
66
}
67
68
--
69
2.25.4
70
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Now than the non-target specific memory_region_msync() function
3
I'm interested in following the activity around the NVMe bdrv.
4
is available, use it to make this device target-agnostic.
5
4
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Message-id: 20210728183340.2018313-1-philmd@redhat.com
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
10
Message-id: 20200508062456.23344-4-philmd@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
8
---
13
hw/block/Makefile.objs | 2 +-
9
MAINTAINERS | 1 +
14
hw/block/nvme.c | 6 ++----
10
1 file changed, 1 insertion(+)
15
2 files changed, 3 insertions(+), 5 deletions(-)
16
11
17
diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs
12
diff --git a/MAINTAINERS b/MAINTAINERS
18
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/block/Makefile.objs
14
--- a/MAINTAINERS
20
+++ b/hw/block/Makefile.objs
15
+++ b/MAINTAINERS
21
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_SH4) += tc58128.o
16
@@ -XXX,XX +XXX,XX @@ F: block/null.c
22
17
NVMe Block Driver
23
obj-$(CONFIG_VIRTIO_BLK) += virtio-blk.o
18
M: Stefan Hajnoczi <stefanha@redhat.com>
24
obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk.o
19
R: Fam Zheng <fam@euphon.net>
25
-obj-$(CONFIG_NVME_PCI) += nvme.o
20
+R: Philippe Mathieu-Daudé <philmd@redhat.com>
26
+common-obj-$(CONFIG_NVME_PCI) += nvme.o
21
L: qemu-block@nongnu.org
27
22
S: Supported
28
obj-y += dataplane/
23
F: block/nvme*
29
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/block/nvme.c
32
+++ b/hw/block/nvme.c
33
@@ -XXX,XX +XXX,XX @@
34
#include "qapi/visitor.h"
35
#include "sysemu/hostmem.h"
36
#include "sysemu/block-backend.h"
37
-#include "exec/ram_addr.h"
38
-
39
+#include "exec/memory.h"
40
#include "qemu/log.h"
41
#include "qemu/module.h"
42
#include "qemu/cutils.h"
43
@@ -XXX,XX +XXX,XX @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr addr, unsigned size)
44
*/
45
if (addr == 0xE08 &&
46
(NVME_PMRCAP_PMRWBM(n->bar.pmrcap) & 0x02)) {
47
- qemu_ram_writeback(n->pmrdev->mr.ram_block,
48
- 0, n->pmrdev->size);
49
+ memory_region_msync(&n->pmrdev->mr, 0, n->pmrdev->size);
50
}
51
memcpy(&val, ptr + addr, size);
52
} else {
53
--
24
--
54
2.25.4
25
2.31.1
55
26
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Rename qemu_ram_writeback() as qemu_ram_msync() to better
4
match what it does.
5
6
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
11
Message-id: 20200508062456.23344-5-philmd@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
14
include/exec/ram_addr.h | 4 ++--
15
exec.c | 2 +-
16
memory.c | 2 +-
17
3 files changed, 4 insertions(+), 4 deletions(-)
18
19
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/exec/ram_addr.h
22
+++ b/include/exec/ram_addr.h
23
@@ -XXX,XX +XXX,XX @@ void qemu_ram_free(RAMBlock *block);
24
25
int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);
26
27
-void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length);
28
+void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length);
29
30
/* Clear whole block of mem */
31
static inline void qemu_ram_block_writeback(RAMBlock *block)
32
{
33
- qemu_ram_writeback(block, 0, block->used_length);
34
+ qemu_ram_msync(block, 0, block->used_length);
35
}
36
37
#define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1)
38
diff --git a/exec.c b/exec.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/exec.c
41
+++ b/exec.c
42
@@ -XXX,XX +XXX,XX @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
43
* Otherwise no-op.
44
* @Note: this is supposed to be a synchronous op.
45
*/
46
-void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length)
47
+void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length)
48
{
49
/* The requested range should fit in within the block range */
50
g_assert((start + length) <= block->used_length);
51
diff --git a/memory.c b/memory.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/memory.c
54
+++ b/memory.c
55
@@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp
56
void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size)
57
{
58
if (mr->ram_block) {
59
- qemu_ram_writeback(mr->ram_block, addr, size);
60
+ qemu_ram_msync(mr->ram_block, addr, size);
61
}
62
}
63
64
--
65
2.25.4
66
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
We have a few bdrv_*() functions that can either spawn a new coroutine
4
and wait for it with BDRV_POLL_WHILE() or use a fastpath if they are
5
alreeady running in a coroutine. All of them duplicate basically the
6
same code.
7
8
Factor the common code into a new function bdrv_run_co().
9
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
Message-id: 20200520144901.16589-1-vsementsov@virtuozzo.com
13
[Factor out bdrv_run_co_entry too]
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
---
16
block/io.c | 193 ++++++++++++++++++++---------------------------------
17
1 file changed, 72 insertions(+), 121 deletions(-)
18
19
diff --git a/block/io.c b/block/io.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/io.c
22
+++ b/block/io.c
23
@@ -XXX,XX +XXX,XX @@
24
#include "qemu/main-loop.h"
25
#include "sysemu/replay.h"
26
27
-#define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
28
-
29
/* Maximum bounce buffer for copy-on-read and write zeroes, in bytes */
30
#define MAX_BOUNCE_BUFFER (32768 << BDRV_SECTOR_BITS)
31
32
@@ -XXX,XX +XXX,XX @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
33
return 0;
34
}
35
36
+typedef int coroutine_fn BdrvRequestEntry(void *opaque);
37
+typedef struct BdrvRunCo {
38
+ BdrvRequestEntry *entry;
39
+ void *opaque;
40
+ int ret;
41
+ bool done;
42
+ Coroutine *co; /* Coroutine, running bdrv_run_co_entry, for debugging */
43
+} BdrvRunCo;
44
+
45
+static void coroutine_fn bdrv_run_co_entry(void *opaque)
46
+{
47
+ BdrvRunCo *arg = opaque;
48
+
49
+ arg->ret = arg->entry(arg->opaque);
50
+ arg->done = true;
51
+ aio_wait_kick();
52
+}
53
+
54
+static int bdrv_run_co(BlockDriverState *bs, BdrvRequestEntry *entry,
55
+ void *opaque)
56
+{
57
+ if (qemu_in_coroutine()) {
58
+ /* Fast-path if already in coroutine context */
59
+ return entry(opaque);
60
+ } else {
61
+ BdrvRunCo s = { .entry = entry, .opaque = opaque };
62
+
63
+ s.co = qemu_coroutine_create(bdrv_run_co_entry, &s);
64
+ bdrv_coroutine_enter(bs, s.co);
65
+
66
+ BDRV_POLL_WHILE(bs, !s.done);
67
+
68
+ return s.ret;
69
+ }
70
+}
71
+
72
typedef struct RwCo {
73
BdrvChild *child;
74
int64_t offset;
75
QEMUIOVector *qiov;
76
bool is_write;
77
- int ret;
78
BdrvRequestFlags flags;
79
} RwCo;
80
81
-static void coroutine_fn bdrv_rw_co_entry(void *opaque)
82
+static int coroutine_fn bdrv_rw_co_entry(void *opaque)
83
{
84
RwCo *rwco = opaque;
85
86
if (!rwco->is_write) {
87
- rwco->ret = bdrv_co_preadv(rwco->child, rwco->offset,
88
- rwco->qiov->size, rwco->qiov,
89
- rwco->flags);
90
+ return bdrv_co_preadv(rwco->child, rwco->offset,
91
+ rwco->qiov->size, rwco->qiov,
92
+ rwco->flags);
93
} else {
94
- rwco->ret = bdrv_co_pwritev(rwco->child, rwco->offset,
95
- rwco->qiov->size, rwco->qiov,
96
- rwco->flags);
97
+ return bdrv_co_pwritev(rwco->child, rwco->offset,
98
+ rwco->qiov->size, rwco->qiov,
99
+ rwco->flags);
100
}
101
- aio_wait_kick();
102
}
103
104
/*
105
@@ -XXX,XX +XXX,XX @@ static int bdrv_prwv_co(BdrvChild *child, int64_t offset,
106
QEMUIOVector *qiov, bool is_write,
107
BdrvRequestFlags flags)
108
{
109
- Coroutine *co;
110
RwCo rwco = {
111
.child = child,
112
.offset = offset,
113
.qiov = qiov,
114
.is_write = is_write,
115
- .ret = NOT_DONE,
116
.flags = flags,
117
};
118
119
- if (qemu_in_coroutine()) {
120
- /* Fast-path if already in coroutine context */
121
- bdrv_rw_co_entry(&rwco);
122
- } else {
123
- co = qemu_coroutine_create(bdrv_rw_co_entry, &rwco);
124
- bdrv_coroutine_enter(child->bs, co);
125
- BDRV_POLL_WHILE(child->bs, rwco.ret == NOT_DONE);
126
- }
127
- return rwco.ret;
128
+ return bdrv_run_co(child->bs, bdrv_rw_co_entry, &rwco);
129
}
130
131
int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset,
132
@@ -XXX,XX +XXX,XX @@ typedef struct BdrvCoBlockStatusData {
133
int64_t *pnum;
134
int64_t *map;
135
BlockDriverState **file;
136
- int ret;
137
- bool done;
138
} BdrvCoBlockStatusData;
139
140
int coroutine_fn bdrv_co_block_status_from_file(BlockDriverState *bs,
141
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs,
142
}
143
144
/* Coroutine wrapper for bdrv_block_status_above() */
145
-static void coroutine_fn bdrv_block_status_above_co_entry(void *opaque)
146
+static int coroutine_fn bdrv_block_status_above_co_entry(void *opaque)
147
{
148
BdrvCoBlockStatusData *data = opaque;
149
150
- data->ret = bdrv_co_block_status_above(data->bs, data->base,
151
- data->want_zero,
152
- data->offset, data->bytes,
153
- data->pnum, data->map, data->file);
154
- data->done = true;
155
- aio_wait_kick();
156
+ return bdrv_co_block_status_above(data->bs, data->base,
157
+ data->want_zero,
158
+ data->offset, data->bytes,
159
+ data->pnum, data->map, data->file);
160
}
161
162
/*
163
@@ -XXX,XX +XXX,XX @@ static int bdrv_common_block_status_above(BlockDriverState *bs,
164
int64_t *map,
165
BlockDriverState **file)
166
{
167
- Coroutine *co;
168
BdrvCoBlockStatusData data = {
169
.bs = bs,
170
.base = base,
171
@@ -XXX,XX +XXX,XX @@ static int bdrv_common_block_status_above(BlockDriverState *bs,
172
.pnum = pnum,
173
.map = map,
174
.file = file,
175
- .done = false,
176
};
177
178
- if (qemu_in_coroutine()) {
179
- /* Fast-path if already in coroutine context */
180
- bdrv_block_status_above_co_entry(&data);
181
- } else {
182
- co = qemu_coroutine_create(bdrv_block_status_above_co_entry, &data);
183
- bdrv_coroutine_enter(bs, co);
184
- BDRV_POLL_WHILE(bs, !data.done);
185
- }
186
- return data.ret;
187
+ return bdrv_run_co(bs, bdrv_block_status_above_co_entry, &data);
188
}
189
190
int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base,
191
@@ -XXX,XX +XXX,XX @@ typedef struct BdrvVmstateCo {
192
QEMUIOVector *qiov;
193
int64_t pos;
194
bool is_read;
195
- int ret;
196
} BdrvVmstateCo;
197
198
static int coroutine_fn
199
@@ -XXX,XX +XXX,XX @@ bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos,
200
return ret;
201
}
202
203
-static void coroutine_fn bdrv_co_rw_vmstate_entry(void *opaque)
204
+static int coroutine_fn bdrv_co_rw_vmstate_entry(void *opaque)
205
{
206
BdrvVmstateCo *co = opaque;
207
- co->ret = bdrv_co_rw_vmstate(co->bs, co->qiov, co->pos, co->is_read);
208
- aio_wait_kick();
209
+
210
+ return bdrv_co_rw_vmstate(co->bs, co->qiov, co->pos, co->is_read);
211
}
212
213
static inline int
214
bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos,
215
bool is_read)
216
{
217
- if (qemu_in_coroutine()) {
218
- return bdrv_co_rw_vmstate(bs, qiov, pos, is_read);
219
- } else {
220
- BdrvVmstateCo data = {
221
- .bs = bs,
222
- .qiov = qiov,
223
- .pos = pos,
224
- .is_read = is_read,
225
- .ret = -EINPROGRESS,
226
- };
227
- Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data);
228
+ BdrvVmstateCo data = {
229
+ .bs = bs,
230
+ .qiov = qiov,
231
+ .pos = pos,
232
+ .is_read = is_read,
233
+ };
234
235
- bdrv_coroutine_enter(bs, co);
236
- BDRV_POLL_WHILE(bs, data.ret == -EINPROGRESS);
237
- return data.ret;
238
- }
239
+ return bdrv_run_co(bs, bdrv_co_rw_vmstate_entry, &data);
240
}
241
242
int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
243
@@ -XXX,XX +XXX,XX @@ void bdrv_aio_cancel_async(BlockAIOCB *acb)
244
/**************************************************************/
245
/* Coroutine block device emulation */
246
247
-typedef struct FlushCo {
248
- BlockDriverState *bs;
249
- int ret;
250
-} FlushCo;
251
-
252
-
253
-static void coroutine_fn bdrv_flush_co_entry(void *opaque)
254
+static int coroutine_fn bdrv_flush_co_entry(void *opaque)
255
{
256
- FlushCo *rwco = opaque;
257
-
258
- rwco->ret = bdrv_co_flush(rwco->bs);
259
- aio_wait_kick();
260
+ return bdrv_co_flush(opaque);
261
}
262
263
int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
264
@@ -XXX,XX +XXX,XX @@ early_exit:
265
266
int bdrv_flush(BlockDriverState *bs)
267
{
268
- Coroutine *co;
269
- FlushCo flush_co = {
270
- .bs = bs,
271
- .ret = NOT_DONE,
272
- };
273
-
274
- if (qemu_in_coroutine()) {
275
- /* Fast-path if already in coroutine context */
276
- bdrv_flush_co_entry(&flush_co);
277
- } else {
278
- co = qemu_coroutine_create(bdrv_flush_co_entry, &flush_co);
279
- bdrv_coroutine_enter(bs, co);
280
- BDRV_POLL_WHILE(bs, flush_co.ret == NOT_DONE);
281
- }
282
-
283
- return flush_co.ret;
284
+ return bdrv_run_co(bs, bdrv_flush_co_entry, bs);
285
}
286
287
typedef struct DiscardCo {
288
BdrvChild *child;
289
int64_t offset;
290
int64_t bytes;
291
- int ret;
292
} DiscardCo;
293
-static void coroutine_fn bdrv_pdiscard_co_entry(void *opaque)
294
+
295
+static int coroutine_fn bdrv_pdiscard_co_entry(void *opaque)
296
{
297
DiscardCo *rwco = opaque;
298
299
- rwco->ret = bdrv_co_pdiscard(rwco->child, rwco->offset, rwco->bytes);
300
- aio_wait_kick();
301
+ return bdrv_co_pdiscard(rwco->child, rwco->offset, rwco->bytes);
302
}
303
304
int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset,
305
@@ -XXX,XX +XXX,XX @@ out:
306
307
int bdrv_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes)
308
{
309
- Coroutine *co;
310
DiscardCo rwco = {
311
.child = child,
312
.offset = offset,
313
.bytes = bytes,
314
- .ret = NOT_DONE,
315
};
316
317
- if (qemu_in_coroutine()) {
318
- /* Fast-path if already in coroutine context */
319
- bdrv_pdiscard_co_entry(&rwco);
320
- } else {
321
- co = qemu_coroutine_create(bdrv_pdiscard_co_entry, &rwco);
322
- bdrv_coroutine_enter(child->bs, co);
323
- BDRV_POLL_WHILE(child->bs, rwco.ret == NOT_DONE);
324
- }
325
-
326
- return rwco.ret;
327
+ return bdrv_run_co(child->bs, bdrv_pdiscard_co_entry, &rwco);
328
}
329
330
int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf)
331
@@ -XXX,XX +XXX,XX @@ typedef struct TruncateCo {
332
PreallocMode prealloc;
333
BdrvRequestFlags flags;
334
Error **errp;
335
- int ret;
336
} TruncateCo;
337
338
-static void coroutine_fn bdrv_truncate_co_entry(void *opaque)
339
+static int coroutine_fn bdrv_truncate_co_entry(void *opaque)
340
{
341
TruncateCo *tco = opaque;
342
- tco->ret = bdrv_co_truncate(tco->child, tco->offset, tco->exact,
343
- tco->prealloc, tco->flags, tco->errp);
344
- aio_wait_kick();
345
+
346
+ return bdrv_co_truncate(tco->child, tco->offset, tco->exact,
347
+ tco->prealloc, tco->flags, tco->errp);
348
}
349
350
int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact,
351
PreallocMode prealloc, BdrvRequestFlags flags, Error **errp)
352
{
353
- Coroutine *co;
354
TruncateCo tco = {
355
.child = child,
356
.offset = offset,
357
@@ -XXX,XX +XXX,XX @@ int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact,
358
.prealloc = prealloc,
359
.flags = flags,
360
.errp = errp,
361
- .ret = NOT_DONE,
362
};
363
364
- if (qemu_in_coroutine()) {
365
- /* Fast-path if already in coroutine context */
366
- bdrv_truncate_co_entry(&tco);
367
- } else {
368
- co = qemu_coroutine_create(bdrv_truncate_co_entry, &tco);
369
- bdrv_coroutine_enter(child->bs, co);
370
- BDRV_POLL_WHILE(child->bs, tco.ret == NOT_DONE);
371
- }
372
-
373
- return tco.ret;
374
+ return bdrv_run_co(child->bs, bdrv_truncate_co_entry, &tco);
375
}
376
--
377
2.25.4
378
diff view generated by jsdifflib