1
The following changes since commit 20d6c7312f1b812bb9c750f4087f69ac8485cc90:
1
The following changes since commit 15ef89d2a1a7b93845a6b09c2ee8e1979f6eb30b:
2
2
3
Merge remote-tracking branch 'remotes/palmer/tags/riscv-for-master-3.2-part1' into staging (2019-01-03 13:26:30 +0000)
3
Update version for v7.0.0-rc1 release (2022-03-22 22:58:44 +0000)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 39a0408e768cd00142f5b57d27ab234282bf4df5:
9
for you to fetch changes up to 2539eade4f689eda7e9fe45486f18334bfbafaf0:
10
10
11
dmg: don't skip zero chunk (2019-01-04 11:15:09 +0000)
11
hw: Fix misleading hexadecimal format (2022-03-24 10:38:42 +0000)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
Pull request
15
15
16
Bug fixes for the .dmg image file format.
16
Philippe found cases where the 0x%d format string was used, leading to
17
misleading output. The patches look harmless and could save people time, so I
18
think it's worth including them in 7.0.
17
19
18
----------------------------------------------------------------
20
----------------------------------------------------------------
19
21
20
Julio Faracco (1):
22
Philippe Mathieu-Daudé (2):
21
dmg: Fixing wrong dmg block type value for block terminator.
23
block: Fix misleading hexadecimal format
24
hw: Fix misleading hexadecimal format
22
25
23
yuchenlin (3):
26
block/parallels-ext.c | 2 +-
24
dmg: fix binary search
27
hw/i386/sgx.c | 2 +-
25
dmg: use enumeration type instead of hard coding number
28
hw/i386/trace-events | 6 +++---
26
dmg: don't skip zero chunk
29
hw/misc/trace-events | 4 ++--
27
30
hw/scsi/trace-events | 4 ++--
28
block/dmg.c | 31 ++++++++++++++++++++-----------
31
5 files changed, 9 insertions(+), 9 deletions(-)
29
1 file changed, 20 insertions(+), 11 deletions(-)
30
32
31
--
33
--
32
2.20.1
34
2.35.1
33
35
34
diff view generated by jsdifflib
1
From: Julio Faracco <jcfaracco@gmail.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
This is a trivial patch to fix a wrong value for block terminator.
3
"0x%u" format is very misleading, replace by "0x%x".
4
The old value was 0x7fffffff which is wrong. It was not affecting the
5
code because QEMU dmg block is not handling block terminator right now.
6
Neverthless, it should be fixed.
7
4
8
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
5
Found running:
9
Reviewed-by: yuchenlin <yuchenlin@synology.com>
6
10
Message-id: 20181228145055.18039-1-jcfaracco@gmail.com
7
$ git grep -E '0x%[0-9]*([lL]*|" ?PRI)[dDuU]' block/
8
9
Inspired-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
12
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
13
Reviewed-by: Denis V. Lunev <den@openvz.org>
14
Message-id: 20220323114718.58714-2-philippe.mathieu.daude@gmail.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
16
---
13
block/dmg.c | 2 +-
17
block/parallels-ext.c | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
18
1 file changed, 1 insertion(+), 1 deletion(-)
15
19
16
diff --git a/block/dmg.c b/block/dmg.c
20
diff --git a/block/parallels-ext.c b/block/parallels-ext.c
17
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
18
--- a/block/dmg.c
22
--- a/block/parallels-ext.c
19
+++ b/block/dmg.c
23
+++ b/block/parallels-ext.c
20
@@ -XXX,XX +XXX,XX @@ enum {
24
@@ -XXX,XX +XXX,XX @@ static int parallels_parse_format_extension(BlockDriverState *bs,
21
UDBZ,
25
break;
22
ULFO,
26
23
UDCM = 0x7ffffffe, /* Comments */
27
default:
24
- UDLE /* Last Entry */
28
- error_setg(errp, "Unknown feature: 0x%" PRIu64, fh.magic);
25
+ UDLE = 0xffffffff /* Last Entry */
29
+ error_setg(errp, "Unknown feature: 0x%" PRIx64, fh.magic);
26
};
30
goto fail;
27
31
}
28
static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
32
29
--
33
--
30
2.20.1
34
2.35.1
31
35
32
36
diff view generated by jsdifflib
Deleted patch
1
From: yuchenlin <npes87184@gmail.com>
2
1
3
There is a possible hang in original binary search implementation. That is
4
if chunk1 = 4, chunk2 = 5, chunk3 = 4, and we go else case.
5
6
The chunk1 will be still 4, and so on.
7
8
Signed-off-by: yuchenlin <npes87184@gmail.com>
9
Message-id: 20190103114700.9686-2-npes87184@gmail.com
10
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
---
12
block/dmg.c | 10 +++++++---
13
1 file changed, 7 insertions(+), 3 deletions(-)
14
15
diff --git a/block/dmg.c b/block/dmg.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/dmg.c
18
+++ b/block/dmg.c
19
@@ -XXX,XX +XXX,XX @@ static inline uint32_t search_chunk(BDRVDMGState *s, uint64_t sector_num)
20
{
21
/* binary search */
22
uint32_t chunk1 = 0, chunk2 = s->n_chunks, chunk3;
23
- while (chunk1 != chunk2) {
24
+ while (chunk1 <= chunk2) {
25
chunk3 = (chunk1 + chunk2) / 2;
26
if (s->sectors[chunk3] > sector_num) {
27
- chunk2 = chunk3;
28
+ if (chunk3 == 0) {
29
+ goto err;
30
+ }
31
+ chunk2 = chunk3 - 1;
32
} else if (s->sectors[chunk3] + s->sectorcounts[chunk3] > sector_num) {
33
return chunk3;
34
} else {
35
- chunk1 = chunk3;
36
+ chunk1 = chunk3 + 1;
37
}
38
}
39
+err:
40
return s->n_chunks; /* error */
41
}
42
43
--
44
2.20.1
45
46
diff view generated by jsdifflib
Deleted patch
1
From: yuchenlin <npes87184@gmail.com>
2
1
3
Signed-off-by: yuchenlin <npes87184@gmail.com>
4
Reviewed-by: Julio Faracco <jcfaracco@gmail.com>
5
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Message-id: 20190103114700.9686-3-npes87184@gmail.com
7
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8
---
9
block/dmg.c | 4 ++--
10
1 file changed, 2 insertions(+), 2 deletions(-)
11
12
diff --git a/block/dmg.c b/block/dmg.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/block/dmg.c
15
+++ b/block/dmg.c
16
@@ -XXX,XX +XXX,XX @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
17
18
/* all-zeroes sector (type 2) does not need to be "uncompressed" and can
19
* therefore be unbounded. */
20
- if (s->types[i] != 2 && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
21
+ if (s->types[i] != UDIG && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
22
error_report("sector count %" PRIu64 " for chunk %" PRIu32
23
" is larger than max (%u)",
24
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
25
@@ -XXX,XX +XXX,XX @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
26
/* Special case: current chunk is all zeroes. Do not perform a memcpy as
27
* s->uncompressed_chunk may be too small to cover the large all-zeroes
28
* section. dmg_read_chunk is called to find s->current_chunk */
29
- if (s->types[s->current_chunk] == 2) { /* all zeroes block entry */
30
+ if (s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */
31
qemu_iovec_memset(qiov, i * 512, 0, 512);
32
continue;
33
}
34
--
35
2.20.1
36
37
diff view generated by jsdifflib
1
From: yuchenlin <npes87184@gmail.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
The dmg file has many tables which describe: "start from sector XXX to
3
"0x%u" format is very misleading, replace by "0x%x".
4
sector XXX, the compression method is XXX and where the compressed data
5
resides on".
6
4
7
Each sector in the expanded file should be covered by a table. The table
5
Found running:
8
will describe the offset of compressed data (or raw depends on the type)
9
in the dmg.
10
6
11
For example:
7
$ git grep -E '0x%[0-9]*([lL]*|" ?PRI)[dDuU]' hw/
12
8
13
[-----------The expanded file------------]
9
Inspired-by: Richard Henderson <richard.henderson@linaro.org>
14
[---bzip table ---]/* zeros */[---zlib---]
10
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
^
11
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
16
| if we want to read this sector.
12
Message-id: 20220323114718.58714-3-philippe.mathieu.daude@gmail.com
17
18
we will find bzip table which contains this sector, and get the
19
compressed data offset, read it from dmg, uncompress it, finally write to
20
expanded file.
21
22
If we skip zero chunk (table), some sector cannot find the table which
23
will cause search_chunk() return s->n_chunks, dmg_read_chunk() return -1
24
and finally causing dmg_co_preadv() return EIO.
25
26
See:
27
28
[-----------The expanded file------------]
29
[---bzip table ---]/* zeros */[---zlib---]
30
^
31
| if we want to read this sector.
32
33
Oops, we cannot find the table contains it...
34
35
In the original implementation, we don't have zero table. When we try to
36
read sector inside the zero chunk. We will get EIO, and skip reading.
37
38
After this patch, we treat zero chunk the same as ignore chunk, it will
39
directly write zero and avoid some sector may not find the table.
40
41
After this patch:
42
43
[-----------The expanded file------------]
44
[---bzip table ---][--zeros--][---zlib---]
45
46
Signed-off-by: yuchenlin <npes87184@gmail.com>
47
Reviewed-by: Julio Faracco <jcfaracco@gmail.com>
48
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
49
Message-id: 20190103114700.9686-4-npes87184@gmail.com
50
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
51
---
14
---
52
block/dmg.c | 19 ++++++++++++-------
15
hw/i386/sgx.c | 2 +-
53
1 file changed, 12 insertions(+), 7 deletions(-)
16
hw/i386/trace-events | 6 +++---
17
hw/misc/trace-events | 4 ++--
18
hw/scsi/trace-events | 4 ++--
19
4 files changed, 8 insertions(+), 8 deletions(-)
54
20
55
diff --git a/block/dmg.c b/block/dmg.c
21
diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c
56
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
57
--- a/block/dmg.c
23
--- a/hw/i386/sgx.c
58
+++ b/block/dmg.c
24
+++ b/hw/i386/sgx.c
59
@@ -XXX,XX +XXX,XX @@ static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk,
25
@@ -XXX,XX +XXX,XX @@ void pc_machine_init_sgx_epc(PCMachineState *pcms)
60
case UDRW: /* copy */
26
}
61
uncompressed_sectors = DIV_ROUND_UP(s->lengths[chunk], 512);
27
62
break;
28
if ((sgx_epc->base + sgx_epc->size) < sgx_epc->base) {
63
- case UDIG: /* zero */
29
- error_report("Size of all 'sgx-epc' =0x%"PRIu64" causes EPC to wrap",
64
+ case UDZE: /* zero */
30
+ error_report("Size of all 'sgx-epc' =0x%"PRIx64" causes EPC to wrap",
65
+ case UDIG: /* ignore */
31
sgx_epc->size);
66
/* as the all-zeroes block may be large, it is treated specially: the
32
exit(EXIT_FAILURE);
67
* sector is not copied from a large buffer, a simple memset is used
33
}
68
* instead. Therefore uncompressed_sectors does not need to be set. */
34
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
69
@@ -XXX,XX +XXX,XX @@ typedef struct DmgHeaderState {
35
index XXXXXXX..XXXXXXX 100644
70
static bool dmg_is_known_block_type(uint32_t entry_type)
36
--- a/hw/i386/trace-events
71
{
37
+++ b/hw/i386/trace-events
72
switch (entry_type) {
38
@@ -XXX,XX +XXX,XX @@ vtd_fault_disabled(void) "Fault processing disabled for context entry"
73
+ case UDZE: /* zeros */
39
vtd_replay_ce_valid(const char *mode, uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint64_t hi, uint64_t lo) "%s: replay valid context device %02"PRIx8":%02"PRIx8".%02"PRIx8" domain 0x%"PRIx16" hi 0x%"PRIx64" lo 0x%"PRIx64
74
case UDRW: /* uncompressed */
40
vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8
75
- case UDIG: /* zeroes */
41
vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64
76
+ case UDIG: /* ignore */
42
-vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d"
77
case UDZO: /* zlib */
43
+vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIx16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d"
78
return true;
44
vtd_page_walk_one_skip_map(uint64_t iova, uint64_t mask, uint64_t translated) "iova 0x%"PRIx64" mask 0x%"PRIx64" translated 0x%"PRIx64
79
case UDBZ: /* bzip2 */
45
vtd_page_walk_one_skip_unmap(uint64_t iova, uint64_t mask) "iova 0x%"PRIx64" mask 0x%"PRIx64
80
@@ -XXX,XX +XXX,XX @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
46
vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read"
81
/* sector count */
47
vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set"
82
s->sectorcounts[i] = buff_read_uint64(buffer, offset + 0x10);
48
vtd_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, bool on) "Device %02x:%02x.%x switching address space (iommu enabled=%d)"
83
49
vtd_as_unmap_whole(uint8_t bus, uint8_t slot, uint8_t fn, uint64_t iova, uint64_t size) "Device %02x:%02x.%x start 0x%"PRIx64" size 0x%"PRIx64
84
- /* all-zeroes sector (type 2) does not need to be "uncompressed" and can
50
-vtd_translate_pt(uint16_t sid, uint64_t addr) "source id 0x%"PRIu16", iova 0x%"PRIx64
85
- * therefore be unbounded. */
51
-vtd_pt_enable_fast_path(uint16_t sid, bool success) "sid 0x%"PRIu16" %d"
86
- if (s->types[i] != UDIG && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
52
+vtd_translate_pt(uint16_t sid, uint64_t addr) "source id 0x%"PRIx16", iova 0x%"PRIx64
87
+ /* all-zeroes sector (type UDZE and UDIG) does not need to be
53
+vtd_pt_enable_fast_path(uint16_t sid, bool success) "sid 0x%"PRIx16" %d"
88
+ * "uncompressed" and can therefore be unbounded. */
54
vtd_irq_generate(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" data 0x%"PRIx64
89
+ if (s->types[i] != UDZE && s->types[i] != UDIG
55
vtd_reg_read(uint64_t addr, uint64_t size) "addr 0x%"PRIx64" size 0x%"PRIx64
90
+ && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
56
vtd_reg_write(uint64_t addr, uint64_t size, uint64_t val) "addr 0x%"PRIx64" size 0x%"PRIx64" value 0x%"PRIx64
91
error_report("sector count %" PRIu64 " for chunk %" PRIu32
57
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
92
" is larger than max (%u)",
58
index XXXXXXX..XXXXXXX 100644
93
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
59
--- a/hw/misc/trace-events
94
@@ -XXX,XX +XXX,XX @@ static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num)
60
+++ b/hw/misc/trace-events
95
return -1;
61
@@ -XXX,XX +XXX,XX @@
96
}
62
# See docs/devel/tracing.rst for syntax documentation.
97
break;
63
98
- case UDIG: /* zero */
64
# allwinner-cpucfg.c
99
+ case UDZE: /* zeros */
65
-allwinner_cpucfg_cpu_reset(uint8_t cpu_id, uint32_t reset_addr) "id %u, reset_addr 0x%" PRIu32
100
+ case UDIG: /* ignore */
66
+allwinner_cpucfg_cpu_reset(uint8_t cpu_id, uint32_t reset_addr) "id %u, reset_addr 0x%" PRIx32
101
/* see dmg_read, it is treated specially. No buffer needs to be
67
allwinner_cpucfg_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32
102
* pre-filled, the zeroes can be set directly. */
68
allwinner_cpucfg_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32
103
break;
69
104
@@ -XXX,XX +XXX,XX @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
70
@@ -XXX,XX +XXX,XX @@ imx7_gpr_write(uint64_t offset, uint64_t value) "addr 0x%08" PRIx64 "value 0x%08
105
/* Special case: current chunk is all zeroes. Do not perform a memcpy as
71
106
* s->uncompressed_chunk may be too small to cover the large all-zeroes
72
# mos6522.c
107
* section. dmg_read_chunk is called to find s->current_chunk */
73
mos6522_set_counter(int index, unsigned int val) "T%d.counter=%d"
108
- if (s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */
74
-mos6522_get_next_irq_time(uint16_t latch, int64_t d, int64_t delta) "latch=%d counter=0x%"PRId64 " delta_next=0x%"PRId64
109
+ if (s->types[s->current_chunk] == UDZE
75
+mos6522_get_next_irq_time(uint16_t latch, int64_t d, int64_t delta) "latch=%d counter=0x%"PRIx64 " delta_next=0x%"PRIx64
110
+ || s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */
76
mos6522_set_sr_int(void) "set sr_int"
111
qemu_iovec_memset(qiov, i * 512, 0, 512);
77
mos6522_write(uint64_t addr, const char *name, uint64_t val) "reg=0x%"PRIx64 " [%s] val=0x%"PRIx64
112
continue;
78
mos6522_read(uint64_t addr, const char *name, unsigned val) "reg=0x%"PRIx64 " [%s] val=0x%x"
113
}
79
diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events
80
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/scsi/trace-events
82
+++ b/hw/scsi/trace-events
83
@@ -XXX,XX +XXX,XX @@ lsi_bad_phase_interrupt(void) "Phase mismatch interrupt"
84
lsi_bad_selection(uint32_t id) "Selected absent target %"PRIu32
85
lsi_do_dma_unavailable(void) "DMA no data available"
86
lsi_do_dma(uint64_t addr, int len) "DMA addr=0x%"PRIx64" len=%d"
87
-lsi_queue_command(uint32_t tag) "Queueing tag=0x%"PRId32
88
+lsi_queue_command(uint32_t tag) "Queueing tag=0x%"PRIx32
89
lsi_add_msg_byte_error(void) "MSG IN data too long"
90
lsi_add_msg_byte(uint8_t data) "MSG IN 0x%02x"
91
lsi_reselect(int id) "Reselected target %d"
92
@@ -XXX,XX +XXX,XX @@ lsi_do_msgout_noop(void) "MSG: No Operation"
93
lsi_do_msgout_extended(uint8_t msg, uint8_t len) "Extended message 0x%x (len %d)"
94
lsi_do_msgout_ignored(const char *msg) "%s (ignored)"
95
lsi_do_msgout_simplequeue(uint8_t select_tag) "SIMPLE queue tag=0x%x"
96
-lsi_do_msgout_abort(uint32_t tag) "MSG: ABORT TAG tag=0x%"PRId32
97
+lsi_do_msgout_abort(uint32_t tag) "MSG: ABORT TAG tag=0x%"PRIx32
98
lsi_do_msgout_clearqueue(uint32_t tag) "MSG: CLEAR QUEUE tag=0x%"PRIx32
99
lsi_do_msgout_busdevicereset(uint32_t tag) "MSG: BUS DEVICE RESET tag=0x%"PRIx32
100
lsi_do_msgout_select(int id) "Select LUN %d"
114
--
101
--
115
2.20.1
102
2.35.1
116
103
117
104
diff view generated by jsdifflib