1
Last lot of target-arm stuff: cleanups, bug fixes; nothing major here.
1
Dropped the tmp421 patch and the following patch that
2
depended on it; no other changes.
2
3
4
thanks
3
-- PMM
5
-- PMM
4
6
5
The following changes since commit 9d662a6b22a0838a85c5432385f35db2488a33a5:
7
The following changes since commit 43771d5d92312504305c19abe29ec5bfabd55f01:
6
8
7
Merge remote-tracking branch 'remotes/legoater/tags/pull-ppc-20220305' into staging (2022-03-05 18:03:15 +0000)
9
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-05-31' into staging (2017-06-01 16:39:16 +0100)
8
10
9
are available in the Git repository at:
11
are available in the git repository at:
10
12
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220307
13
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170602
12
14
13
for you to fetch changes up to 0942820408dc788560f6968e9b5f011803b846c2:
15
for you to fetch changes up to c7637c04be257968e6df30de961a6a23a0ac3dd8:
14
16
15
hw/arm/virt: Disable LPA2 for -machine virt-6.2 (2022-03-07 14:32:21 +0000)
17
hw/arm/virt: fdt: generate distance-map when needed (2017-06-02 11:51:49 +0100)
16
18
17
----------------------------------------------------------------
19
----------------------------------------------------------------
18
target-arm queue:
20
target-arm queue:
19
* cleanups of qemu_oom_check() and qemu_memalign()
21
* virt: numa: provide ACPI distance info when needed
20
* target/arm/translate-neon: UNDEF if VLD1/VST1 stride bits are non-zero
22
* aspeed: fix i2c controller bugs
21
* target/arm/translate-neon: Simplify align field check for VLD3
23
* M profile: support MPU
22
* GICv3 ITS: add more trace events
24
* gicv3: fix mishandling of BPR1, VBPR1
23
* GICv3 ITS: implement 8-byte accesses properly
25
* load_uboot_image: don't assume a full header read
24
* GICv3: fix minor issues with some trace/log messages
26
* libvixl: Correct build failures on NetBSD
25
* ui/cocoa: Use the standard about panel
26
* target/arm: Provide cpu property for controling FEAT_LPA2
27
* hw/arm/virt: Disable LPA2 for -machine virt-6.2
28
27
29
----------------------------------------------------------------
28
----------------------------------------------------------------
30
Akihiko Odaki (1):
29
Andrew Jones (3):
31
ui/cocoa: Use the standard about panel
30
load_uboot_image: don't assume a full header read
31
hw/arm/virt-acpi-build: build SLIT when needed
32
hw/arm/virt: fdt: generate distance-map when needed
32
33
33
Peter Maydell (15):
34
Cédric Le Goater (4):
34
util: Make qemu_oom_check() a static function
35
aspeed/i2c: improve command handling
35
util: Unify implementations of qemu_memalign()
36
aspeed/i2c: handle LAST command under the RX command
36
util: Return valid allocation for qemu_try_memalign() with zero size
37
aspeed/i2c: introduce a state machine
37
meson.build: Don't misdetect posix_memalign() on Windows
38
aspeed: add some I2C devices to the Aspeed machines
38
util: Share qemu_try_memalign() implementation between POSIX and Windows
39
util: Use meson checks for valloc() and memalign() presence
40
util: Put qemu_vfree() in memalign.c
41
osdep: Move memalign-related functions to their own header
42
target/arm/translate-neon: UNDEF if VLD1/VST1 stride bits are non-zero
43
target/arm/translate-neon: Simplify align field check for VLD3
44
hw/intc/arm_gicv3_its: Add trace events for commands
45
hw/intc/arm_gicv3_its: Add trace events for table reads and writes
46
hw/intc/arm_gicv3: Specify valid and impl in MemoryRegionOps
47
hw/intc/arm_gicv3: Fix missing spaces in error log messages
48
hw/intc/arm_gicv3_cpuif: Fix register names in ICV_HPPIR read trace event
49
39
50
Richard Henderson (2):
40
Kamil Rytarowski (1):
51
target/arm: Provide cpu property for controling FEAT_LPA2
41
libvixl: Correct build failures on NetBSD
52
hw/arm/virt: Disable LPA2 for -machine virt-6.2
53
42
54
meson.build | 7 ++-
43
Michael Davidsaver (4):
55
include/hw/arm/virt.h | 1 +
44
armv7m: Improve "-d mmu" tracing for PMSAv7 MPU
56
include/qemu-common.h | 2 -
45
armv7m: Implement M profile default memory map
57
include/qemu/memalign.h | 61 ++++++++++++++++++++++
46
armv7m: Classify faults as MemManage or BusFault
58
include/qemu/osdep.h | 18 -------
47
arm: add MPU support to M profile CPUs
59
target/arm/cpu.h | 5 +-
48
60
block/blkverify.c | 1 +
49
Peter Maydell (12):
61
block/block-copy.c | 1 +
50
hw/intc/arm_gicv3_cpuif: Fix reset value for VMCR_EL2.VBPR1
62
block/commit.c | 1 +
51
hw/intc/arm_gicv3_cpuif: Don't let BPR be set below its minimum
63
block/crypto.c | 1 +
52
hw/intc/arm_gicv3_cpuif: Fix priority masking for NS BPR1
64
block/dmg.c | 1 +
53
arm: Use the mmu_idx we're passed in arm_cpu_do_unaligned_access()
65
block/export/fuse.c | 1 +
54
arm: Add support for M profile CPUs having different MMU index semantics
66
block/file-posix.c | 1 +
55
arm: Use different ARMMMUIdx values for M profile
67
block/io.c | 1 +
56
arm: Clean up handling of no-MPU PMSA CPUs
68
block/mirror.c | 1 +
57
arm: Don't clear ARM_FEATURE_PMSA for no-mpu configs
69
block/nvme.c | 1 +
58
arm: Don't let no-MPU PMSA cores write to SCTLR.M
70
block/parallels-ext.c | 1 +
59
arm: Remove unnecessary check on cpu->pmsav7_dregion
71
block/parallels.c | 1 +
60
arm: All M profile cores are PMSA
72
block/qcow.c | 1 +
61
arm: Implement HFNMIENA support for M profile MPU
73
block/qcow2-cache.c | 1 +
62
74
block/qcow2-cluster.c | 1 +
63
Wei Huang (1):
75
block/qcow2-refcount.c | 1 +
64
target/arm: clear PMUVER field of AA64DFR0 when vPMU=off
76
block/qcow2-snapshot.c | 1 +
65
77
block/qcow2.c | 1 +
66
disas/libvixl/Makefile.objs | 3 +
78
block/qed-l2-cache.c | 1 +
67
target/arm/cpu.h | 118 ++++++++++++++--
79
block/qed-table.c | 1 +
68
target/arm/translate.h | 2 +-
80
block/qed.c | 1 +
69
hw/arm/aspeed.c | 27 ++++
81
block/quorum.c | 1 +
70
hw/arm/virt-acpi-build.c | 4 +
82
block/raw-format.c | 1 +
71
hw/arm/virt.c | 21 +++
83
block/vdi.c | 1 +
72
hw/core/loader.c | 3 +-
84
block/vhdx-log.c | 1 +
73
hw/i2c/aspeed_i2c.c | 65 +++++++--
85
block/vhdx.c | 1 +
74
hw/intc/arm_gicv3_cpuif.c | 50 ++++++-
86
block/vmdk.c | 1 +
75
hw/intc/armv7m_nvic.c | 104 ++++++++++++++
87
block/vpc.c | 1 +
76
target/arm/cpu.c | 28 +++-
88
block/win32-aio.c | 1 +
77
target/arm/helper.c | 338 ++++++++++++++++++++++++++++++--------------
89
hw/arm/virt.c | 7 +++
78
target/arm/machine.c | 7 +-
90
hw/block/dataplane/xen-block.c | 1 +
79
target/arm/op_helper.c | 3 +-
91
hw/block/fdc.c | 1 +
80
target/arm/translate-a64.c | 18 ++-
92
hw/ide/core.c | 1 +
81
target/arm/translate.c | 14 +-
93
hw/intc/arm_gicv3.c | 8 +++
82
16 files changed, 648 insertions(+), 157 deletions(-)
94
hw/intc/arm_gicv3_cpuif.c | 3 +-
83
95
hw/intc/arm_gicv3_dist.c | 4 +-
96
hw/intc/arm_gicv3_its.c | 69 +++++++++++++++++++++----
97
hw/ppc/spapr.c | 1 +
98
hw/ppc/spapr_softmmu.c | 1 +
99
hw/scsi/scsi-disk.c | 1 +
100
hw/tpm/tpm_ppi.c | 2 +-
101
nbd/server.c | 1 +
102
net/l2tpv3.c | 2 +-
103
plugins/loader.c | 1 +
104
qemu-img.c | 1 +
105
qemu-io-cmds.c | 1 +
106
qom/object.c | 1 +
107
softmmu/physmem.c | 1 +
108
target/arm/cpu.c | 6 +++
109
target/arm/cpu64.c | 24 +++++++++
110
target/arm/translate-neon.c | 13 +++--
111
target/i386/hvf/hvf.c | 1 +
112
target/i386/kvm/kvm.c | 1 +
113
tcg/region.c | 1 +
114
tests/bench/atomic_add-bench.c | 1 +
115
tests/bench/qht-bench.c | 1 +
116
util/atomic64.c | 1 +
117
util/memalign.c | 92 +++++++++++++++++++++++++++++++++
118
util/oslib-posix.c | 46 -----------------
119
util/oslib-win32.c | 35 -------------
120
util/qht.c | 1 +
121
hw/intc/trace-events | 21 ++++++++
122
tests/avocado/boot_linux.py | 2 +
123
ui/cocoa.m | 112 +++++++++--------------------------------
124
util/meson.build | 1 +
125
71 files changed, 377 insertions(+), 212 deletions(-)
126
create mode 100644 include/qemu/memalign.h
127
create mode 100644 util/memalign.c
diff view generated by jsdifflib
Deleted patch
1
The qemu_oom_check() function, which we define in both oslib-posix.c
2
and oslib-win32.c, is now used only locally in that file; make it
3
static.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220226180723.1706285-3-peter.maydell@linaro.org
9
---
10
include/qemu-common.h | 2 --
11
util/oslib-posix.c | 2 +-
12
util/oslib-win32.c | 2 +-
13
3 files changed, 2 insertions(+), 4 deletions(-)
14
15
diff --git a/include/qemu-common.h b/include/qemu-common.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/qemu-common.h
18
+++ b/include/qemu-common.h
19
@@ -XXX,XX +XXX,XX @@
20
int qemu_main(int argc, char **argv, char **envp);
21
#endif
22
23
-void *qemu_oom_check(void *ptr);
24
-
25
ssize_t qemu_write_full(int fd, const void *buf, size_t count)
26
QEMU_WARN_UNUSED_RESULT;
27
28
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/util/oslib-posix.c
31
+++ b/util/oslib-posix.c
32
@@ -XXX,XX +XXX,XX @@ fail_close:
33
return false;
34
}
35
36
-void *qemu_oom_check(void *ptr)
37
+static void *qemu_oom_check(void *ptr)
38
{
39
if (ptr == NULL) {
40
fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));
41
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/util/oslib-win32.c
44
+++ b/util/oslib-win32.c
45
@@ -XXX,XX +XXX,XX @@
46
/* this must come after including "trace.h" */
47
#include <shlobj.h>
48
49
-void *qemu_oom_check(void *ptr)
50
+static void *qemu_oom_check(void *ptr)
51
{
52
if (ptr == NULL) {
53
fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError());
54
--
55
2.25.1
56
57
diff view generated by jsdifflib
Deleted patch
1
We implement qemu_memalign() in both oslib-posix.c and oslib-win32.c,
2
but the two versions are essentially the same: they call
3
qemu_try_memalign(), and abort() after printing an error message if
4
it fails. The only difference is that the win32 version prints the
5
GetLastError() value whereas the POSIX version prints
6
strerror(errno). However, this is a bug in the win32 version: in
7
commit dfbd0b873a85021 in 2020 we changed the implementation of
8
qemu_try_memalign() from using VirtualAlloc() (which sets the
9
GetLastError() value) to using _aligned_malloc() (which sets errno),
10
but didn't update the error message to match.
11
1
12
Replace the two separate functions with a single version in a
13
new memalign.c file, which drops the unnecessary extra qemu_oom_check()
14
function and instead prints a more useful message including the
15
requested size and alignment as well as the errno string.
16
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20220226180723.1706285-4-peter.maydell@linaro.org
20
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
---
22
util/memalign.c | 39 +++++++++++++++++++++++++++++++++++++++
23
util/oslib-posix.c | 14 --------------
24
util/oslib-win32.c | 14 --------------
25
util/meson.build | 1 +
26
4 files changed, 40 insertions(+), 28 deletions(-)
27
create mode 100644 util/memalign.c
28
29
diff --git a/util/memalign.c b/util/memalign.c
30
new file mode 100644
31
index XXXXXXX..XXXXXXX
32
--- /dev/null
33
+++ b/util/memalign.c
34
@@ -XXX,XX +XXX,XX @@
35
+/*
36
+ * memalign.c: Allocate an aligned memory region
37
+ *
38
+ * Copyright (c) 2003-2008 Fabrice Bellard
39
+ * Copyright (c) 2010-2016 Red Hat, Inc.
40
+ * Copyright (c) 2022 Linaro Ltd
41
+ *
42
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
43
+ * of this software and associated documentation files (the "Software"), to deal
44
+ * in the Software without restriction, including without limitation the rights
45
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46
+ * copies of the Software, and to permit persons to whom the Software is
47
+ * furnished to do so, subject to the following conditions:
48
+ *
49
+ * The above copyright notice and this permission notice shall be included in
50
+ * all copies or substantial portions of the Software.
51
+ *
52
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
55
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58
+ * THE SOFTWARE.
59
+ */
60
+
61
+#include "qemu/osdep.h"
62
+
63
+void *qemu_memalign(size_t alignment, size_t size)
64
+{
65
+ void *p = qemu_try_memalign(alignment, size);
66
+ if (p) {
67
+ return p;
68
+ }
69
+ fprintf(stderr,
70
+ "qemu_memalign: failed to allocate %zu bytes at alignment %zu: %s\n",
71
+ size, alignment, strerror(errno));
72
+ abort();
73
+}
74
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
75
index XXXXXXX..XXXXXXX 100644
76
--- a/util/oslib-posix.c
77
+++ b/util/oslib-posix.c
78
@@ -XXX,XX +XXX,XX @@ fail_close:
79
return false;
80
}
81
82
-static void *qemu_oom_check(void *ptr)
83
-{
84
- if (ptr == NULL) {
85
- fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));
86
- abort();
87
- }
88
- return ptr;
89
-}
90
-
91
void *qemu_try_memalign(size_t alignment, size_t size)
92
{
93
void *ptr;
94
@@ -XXX,XX +XXX,XX @@ void *qemu_try_memalign(size_t alignment, size_t size)
95
return ptr;
96
}
97
98
-void *qemu_memalign(size_t alignment, size_t size)
99
-{
100
- return qemu_oom_check(qemu_try_memalign(alignment, size));
101
-}
102
-
103
/* alloc shared memory pages */
104
void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared,
105
bool noreserve)
106
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/util/oslib-win32.c
109
+++ b/util/oslib-win32.c
110
@@ -XXX,XX +XXX,XX @@
111
/* this must come after including "trace.h" */
112
#include <shlobj.h>
113
114
-static void *qemu_oom_check(void *ptr)
115
-{
116
- if (ptr == NULL) {
117
- fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError());
118
- abort();
119
- }
120
- return ptr;
121
-}
122
-
123
void *qemu_try_memalign(size_t alignment, size_t size)
124
{
125
void *ptr;
126
@@ -XXX,XX +XXX,XX @@ void *qemu_try_memalign(size_t alignment, size_t size)
127
return ptr;
128
}
129
130
-void *qemu_memalign(size_t alignment, size_t size)
131
-{
132
- return qemu_oom_check(qemu_try_memalign(alignment, size));
133
-}
134
-
135
static int get_allocation_granularity(void)
136
{
137
SYSTEM_INFO system_info;
138
diff --git a/util/meson.build b/util/meson.build
139
index XXXXXXX..XXXXXXX 100644
140
--- a/util/meson.build
141
+++ b/util/meson.build
142
@@ -XXX,XX +XXX,XX @@ util_ss.add(when: 'CONFIG_POSIX', if_true: files('drm.c'))
143
util_ss.add(files('guest-random.c'))
144
util_ss.add(files('yank.c'))
145
util_ss.add(files('int128.c'))
146
+util_ss.add(files('memalign.c'))
147
148
if have_user
149
util_ss.add(files('selfmap.c'))
150
--
151
2.25.1
152
153
diff view generated by jsdifflib
Deleted patch
1
Currently qemu_try_memalign()'s behaviour if asked to allocate
2
0 bytes is rather variable:
3
* on Windows, we will assert
4
* on POSIX platforms, we get the underlying behaviour of
5
the posix_memalign() or equivalent function, which may be
6
either "return a valid non-NULL pointer" or "return NULL"
7
1
8
Explictly check for 0 byte allocations, so we get consistent
9
behaviour across platforms. We handle them by incrementing the size
10
so that we return a valid non-NULL pointer that can later be passed
11
to qemu_vfree(). This is permitted behaviour for the
12
posix_memalign() API and is the most usual way that underlying
13
malloc() etc implementations handle a zero-sized allocation request,
14
because it won't trip up calling code that assumes NULL means an
15
error. (This includes our own qemu_memalign(), which will abort on
16
NULL.)
17
18
This change is a preparation for sharing the qemu_try_memalign() code
19
between Windows and POSIX.
20
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
24
---
25
util/oslib-posix.c | 3 +++
26
util/oslib-win32.c | 4 +++-
27
2 files changed, 6 insertions(+), 1 deletion(-)
28
29
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/util/oslib-posix.c
32
+++ b/util/oslib-posix.c
33
@@ -XXX,XX +XXX,XX @@ void *qemu_try_memalign(size_t alignment, size_t size)
34
g_assert(is_power_of_2(alignment));
35
}
36
37
+ if (size == 0) {
38
+ size++;
39
+ }
40
#if defined(CONFIG_POSIX_MEMALIGN)
41
int ret;
42
ret = posix_memalign(&ptr, alignment, size);
43
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/util/oslib-win32.c
46
+++ b/util/oslib-win32.c
47
@@ -XXX,XX +XXX,XX @@ void *qemu_try_memalign(size_t alignment, size_t size)
48
{
49
void *ptr;
50
51
- g_assert(size != 0);
52
if (alignment < sizeof(void *)) {
53
alignment = sizeof(void *);
54
} else {
55
g_assert(is_power_of_2(alignment));
56
}
57
+ if (size == 0) {
58
+ size++;
59
+ }
60
ptr = _aligned_malloc(size, alignment);
61
trace_qemu_memalign(alignment, size, ptr);
62
return ptr;
63
--
64
2.25.1
65
66
diff view generated by jsdifflib
Deleted patch
1
Currently we incorrectly think that posix_memalign() exists on
2
Windows. This is because of a combination of:
3
1
4
* the msys2/mingw toolchain/libc claim to have a
5
__builtin_posix_memalign when there isn't a builtin of that name
6
* meson will assume that if you have a __builtin_foo that
7
counts for has_function('foo')
8
9
Specifying a specific include file via prefix: causes meson to not
10
treat builtins as sufficient and actually look for the function
11
itself; see this meson pull request which added that as the official
12
way to get the right answer:
13
https://github.com/mesonbuild/meson/pull/1150
14
15
Currently this misdectection doesn't cause problems because we only
16
use CONFIG_POSIX_MEMALIGN in oslib-posix.c; however that will change
17
in a following commit.
18
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Message-id: 20220226180723.1706285-6-peter.maydell@linaro.org
22
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
23
---
24
meson.build | 4 +++-
25
1 file changed, 3 insertions(+), 1 deletion(-)
26
27
diff --git a/meson.build b/meson.build
28
index XXXXXXX..XXXXXXX 100644
29
--- a/meson.build
30
+++ b/meson.build
31
@@ -XXX,XX +XXX,XX @@ config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
32
config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
33
config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate'))
34
config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'))
35
-config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign'))
36
+# Note that we need to specify prefix: here to avoid incorrectly
37
+# thinking that Windows has posix_memalign()
38
+config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include <stdlib.h>'))
39
config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
40
config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
41
config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads))
42
--
43
2.25.1
44
45
diff view generated by jsdifflib
Deleted patch
1
The qemu_try_memalign() functions for POSIX and Windows used to be
2
significantly different, but these days they are identical except for
3
the actual allocation function called, and the POSIX version already
4
has to have ifdeffery for different allocation functions.
5
1
6
Move to a single implementation in memalign.c, which uses the Windows
7
_aligned_malloc if we detect that function in meson.
8
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20220226180723.1706285-7-peter.maydell@linaro.org
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
---
14
meson.build | 1 +
15
util/memalign.c | 39 +++++++++++++++++++++++++++++++++++++++
16
util/oslib-posix.c | 29 -----------------------------
17
util/oslib-win32.c | 17 -----------------
18
4 files changed, 40 insertions(+), 46 deletions(-)
19
20
diff --git a/meson.build b/meson.build
21
index XXXXXXX..XXXXXXX 100644
22
--- a/meson.build
23
+++ b/meson.build
24
@@ -XXX,XX +XXX,XX @@ config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'
25
# Note that we need to specify prefix: here to avoid incorrectly
26
# thinking that Windows has posix_memalign()
27
config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include <stdlib.h>'))
28
+config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc'))
29
config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
30
config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
31
config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads))
32
diff --git a/util/memalign.c b/util/memalign.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/util/memalign.c
35
+++ b/util/memalign.c
36
@@ -XXX,XX +XXX,XX @@
37
*/
38
39
#include "qemu/osdep.h"
40
+#include "qemu/host-utils.h"
41
+#include "trace.h"
42
+
43
+void *qemu_try_memalign(size_t alignment, size_t size)
44
+{
45
+ void *ptr;
46
+
47
+ if (alignment < sizeof(void*)) {
48
+ alignment = sizeof(void*);
49
+ } else {
50
+ g_assert(is_power_of_2(alignment));
51
+ }
52
+
53
+ /*
54
+ * Handling of 0 allocations varies among the different
55
+ * platform APIs (for instance _aligned_malloc() will
56
+ * fail) -- ensure that we always return a valid non-NULL
57
+ * pointer that can be freed by qemu_vfree().
58
+ */
59
+ if (size == 0) {
60
+ size++;
61
+ }
62
+#if defined(CONFIG_POSIX_MEMALIGN)
63
+ int ret;
64
+ ret = posix_memalign(&ptr, alignment, size);
65
+ if (ret != 0) {
66
+ errno = ret;
67
+ ptr = NULL;
68
+ }
69
+#elif defined(CONFIG_ALIGNED_MALLOC)
70
+ ptr = _aligned_malloc(size, alignment);
71
+#elif defined(CONFIG_BSD)
72
+ ptr = valloc(size);
73
+#else
74
+ ptr = memalign(alignment, size);
75
+#endif
76
+ trace_qemu_memalign(alignment, size, ptr);
77
+ return ptr;
78
+}
79
80
void *qemu_memalign(size_t alignment, size_t size)
81
{
82
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
83
index XXXXXXX..XXXXXXX 100644
84
--- a/util/oslib-posix.c
85
+++ b/util/oslib-posix.c
86
@@ -XXX,XX +XXX,XX @@ fail_close:
87
return false;
88
}
89
90
-void *qemu_try_memalign(size_t alignment, size_t size)
91
-{
92
- void *ptr;
93
-
94
- if (alignment < sizeof(void*)) {
95
- alignment = sizeof(void*);
96
- } else {
97
- g_assert(is_power_of_2(alignment));
98
- }
99
-
100
- if (size == 0) {
101
- size++;
102
- }
103
-#if defined(CONFIG_POSIX_MEMALIGN)
104
- int ret;
105
- ret = posix_memalign(&ptr, alignment, size);
106
- if (ret != 0) {
107
- errno = ret;
108
- ptr = NULL;
109
- }
110
-#elif defined(CONFIG_BSD)
111
- ptr = valloc(size);
112
-#else
113
- ptr = memalign(alignment, size);
114
-#endif
115
- trace_qemu_memalign(alignment, size, ptr);
116
- return ptr;
117
-}
118
-
119
/* alloc shared memory pages */
120
void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared,
121
bool noreserve)
122
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
123
index XXXXXXX..XXXXXXX 100644
124
--- a/util/oslib-win32.c
125
+++ b/util/oslib-win32.c
126
@@ -XXX,XX +XXX,XX @@
127
/* this must come after including "trace.h" */
128
#include <shlobj.h>
129
130
-void *qemu_try_memalign(size_t alignment, size_t size)
131
-{
132
- void *ptr;
133
-
134
- if (alignment < sizeof(void *)) {
135
- alignment = sizeof(void *);
136
- } else {
137
- g_assert(is_power_of_2(alignment));
138
- }
139
- if (size == 0) {
140
- size++;
141
- }
142
- ptr = _aligned_malloc(size, alignment);
143
- trace_qemu_memalign(alignment, size, ptr);
144
- return ptr;
145
-}
146
-
147
static int get_allocation_granularity(void)
148
{
149
SYSTEM_INFO system_info;
150
--
151
2.25.1
152
153
diff view generated by jsdifflib
Deleted patch
1
Instead of assuming that all CONFIG_BSD have valloc() and anything
2
else is memalign(), explicitly check for those functions in
3
meson.build and use the "is the function present" define. Tests for
4
specific functionality are better than which-OS checks; this also
5
lets us give a helpful error message if somehow there's no usable
6
function present.
7
1
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20220226180723.1706285-8-peter.maydell@linaro.org
12
---
13
meson.build | 2 ++
14
util/memalign.c | 6 ++++--
15
2 files changed, 6 insertions(+), 2 deletions(-)
16
17
diff --git a/meson.build b/meson.build
18
index XXXXXXX..XXXXXXX 100644
19
--- a/meson.build
20
+++ b/meson.build
21
@@ -XXX,XX +XXX,XX @@ config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'
22
# thinking that Windows has posix_memalign()
23
config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include <stdlib.h>'))
24
config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc'))
25
+config_host_data.set('CONFIG_VALLOC', cc.has_function('valloc'))
26
+config_host_data.set('CONFIG_MEMALIGN', cc.has_function('memalign'))
27
config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
28
config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
29
config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads))
30
diff --git a/util/memalign.c b/util/memalign.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/util/memalign.c
33
+++ b/util/memalign.c
34
@@ -XXX,XX +XXX,XX @@ void *qemu_try_memalign(size_t alignment, size_t size)
35
}
36
#elif defined(CONFIG_ALIGNED_MALLOC)
37
ptr = _aligned_malloc(size, alignment);
38
-#elif defined(CONFIG_BSD)
39
+#elif defined(CONFIG_VALLOC)
40
ptr = valloc(size);
41
-#else
42
+#elif defined(CONFIG_MEMALIGN)
43
ptr = memalign(alignment, size);
44
+#else
45
+ #error No function to allocate aligned memory available
46
#endif
47
trace_qemu_memalign(alignment, size, ptr);
48
return ptr;
49
--
50
2.25.1
51
52
diff view generated by jsdifflib
Deleted patch
1
qemu_vfree() is the companion free function to qemu_memalign(); put
2
it in memalign.c so the allocation and free functions are together.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20220226180723.1706285-9-peter.maydell@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
---
9
util/memalign.c | 11 +++++++++++
10
util/oslib-posix.c | 6 ------
11
util/oslib-win32.c | 6 ------
12
3 files changed, 11 insertions(+), 12 deletions(-)
13
14
diff --git a/util/memalign.c b/util/memalign.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/util/memalign.c
17
+++ b/util/memalign.c
18
@@ -XXX,XX +XXX,XX @@ void *qemu_memalign(size_t alignment, size_t size)
19
size, alignment, strerror(errno));
20
abort();
21
}
22
+
23
+void qemu_vfree(void *ptr)
24
+{
25
+ trace_qemu_vfree(ptr);
26
+#if !defined(CONFIG_POSIX_MEMALIGN) && defined(CONFIG_ALIGNED_MALLOC)
27
+ /* Only Windows _aligned_malloc needs a special free function */
28
+ _aligned_free(ptr);
29
+#else
30
+ free(ptr);
31
+#endif
32
+}
33
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/util/oslib-posix.c
36
+++ b/util/oslib-posix.c
37
@@ -XXX,XX +XXX,XX @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared,
38
return ptr;
39
}
40
41
-void qemu_vfree(void *ptr)
42
-{
43
- trace_qemu_vfree(ptr);
44
- free(ptr);
45
-}
46
-
47
void qemu_anon_ram_free(void *ptr, size_t size)
48
{
49
trace_qemu_anon_ram_free(ptr, size);
50
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/util/oslib-win32.c
53
+++ b/util/oslib-win32.c
54
@@ -XXX,XX +XXX,XX @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared,
55
return ptr;
56
}
57
58
-void qemu_vfree(void *ptr)
59
-{
60
- trace_qemu_vfree(ptr);
61
- _aligned_free(ptr);
62
-}
63
-
64
void qemu_anon_ram_free(void *ptr, size_t size)
65
{
66
trace_qemu_anon_ram_free(ptr, size);
67
--
68
2.25.1
69
70
diff view generated by jsdifflib
Deleted patch
1
Move the various memalign-related functions out of osdep.h and into
2
their own header, which we include only where they are used.
3
While we're doing this, add some brief documentation comments.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220226180723.1706285-10-peter.maydell@linaro.org
9
---
10
include/qemu/memalign.h | 61 ++++++++++++++++++++++++++++++++++
11
include/qemu/osdep.h | 18 ----------
12
block/blkverify.c | 1 +
13
block/block-copy.c | 1 +
14
block/commit.c | 1 +
15
block/crypto.c | 1 +
16
block/dmg.c | 1 +
17
block/export/fuse.c | 1 +
18
block/file-posix.c | 1 +
19
block/io.c | 1 +
20
block/mirror.c | 1 +
21
block/nvme.c | 1 +
22
block/parallels-ext.c | 1 +
23
block/parallels.c | 1 +
24
block/qcow.c | 1 +
25
block/qcow2-cache.c | 1 +
26
block/qcow2-cluster.c | 1 +
27
block/qcow2-refcount.c | 1 +
28
block/qcow2-snapshot.c | 1 +
29
block/qcow2.c | 1 +
30
block/qed-l2-cache.c | 1 +
31
block/qed-table.c | 1 +
32
block/qed.c | 1 +
33
block/quorum.c | 1 +
34
block/raw-format.c | 1 +
35
block/vdi.c | 1 +
36
block/vhdx-log.c | 1 +
37
block/vhdx.c | 1 +
38
block/vmdk.c | 1 +
39
block/vpc.c | 1 +
40
block/win32-aio.c | 1 +
41
hw/block/dataplane/xen-block.c | 1 +
42
hw/block/fdc.c | 1 +
43
hw/ide/core.c | 1 +
44
hw/ppc/spapr.c | 1 +
45
hw/ppc/spapr_softmmu.c | 1 +
46
hw/scsi/scsi-disk.c | 1 +
47
hw/tpm/tpm_ppi.c | 2 +-
48
nbd/server.c | 1 +
49
net/l2tpv3.c | 2 +-
50
plugins/loader.c | 1 +
51
qemu-img.c | 1 +
52
qemu-io-cmds.c | 1 +
53
qom/object.c | 1 +
54
softmmu/physmem.c | 1 +
55
target/i386/hvf/hvf.c | 1 +
56
target/i386/kvm/kvm.c | 1 +
57
tcg/region.c | 1 +
58
tests/bench/atomic_add-bench.c | 1 +
59
tests/bench/qht-bench.c | 1 +
60
util/atomic64.c | 1 +
61
util/memalign.c | 1 +
62
util/qht.c | 1 +
63
53 files changed, 112 insertions(+), 20 deletions(-)
64
create mode 100644 include/qemu/memalign.h
65
66
diff --git a/include/qemu/memalign.h b/include/qemu/memalign.h
67
new file mode 100644
68
index XXXXXXX..XXXXXXX
69
--- /dev/null
70
+++ b/include/qemu/memalign.h
71
@@ -XXX,XX +XXX,XX @@
72
+/*
73
+ * Allocation and free functions for aligned memory
74
+ *
75
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
76
+ * See the COPYING file in the top-level directory.
77
+ */
78
+
79
+#ifndef QEMU_MEMALIGN_H
80
+#define QEMU_MEMALIGN_H
81
+
82
+/**
83
+ * qemu_try_memalign: Allocate aligned memory
84
+ * @alignment: required alignment, in bytes
85
+ * @size: size of allocation, in bytes
86
+ *
87
+ * Allocate memory on an aligned boundary (i.e. the returned
88
+ * address will be an exact multiple of @alignment).
89
+ * @alignment must be a power of 2, or the function will assert().
90
+ * On success, returns allocated memory; on failure, returns NULL.
91
+ *
92
+ * The memory allocated through this function must be freed via
93
+ * qemu_vfree() (and not via free()).
94
+ */
95
+void *qemu_try_memalign(size_t alignment, size_t size);
96
+/**
97
+ * qemu_memalign: Allocate aligned memory, without failing
98
+ * @alignment: required alignment, in bytes
99
+ * @size: size of allocation, in bytes
100
+ *
101
+ * Allocate memory in the same way as qemu_try_memalign(), but
102
+ * abort() with an error message if the memory allocation fails.
103
+ *
104
+ * The memory allocated through this function must be freed via
105
+ * qemu_vfree() (and not via free()).
106
+ */
107
+void *qemu_memalign(size_t alignment, size_t size);
108
+/**
109
+ * qemu_vfree: Free memory allocated through qemu_memalign
110
+ * @ptr: memory to free
111
+ *
112
+ * This function must be used to free memory allocated via qemu_memalign()
113
+ * or qemu_try_memalign(). (Using the wrong free function will cause
114
+ * subtle bugs on Windows hosts.)
115
+ */
116
+void qemu_vfree(void *ptr);
117
+/*
118
+ * It's an analog of GLIB's g_autoptr_cleanup_generic_gfree(), used to define
119
+ * g_autofree macro.
120
+ */
121
+static inline void qemu_cleanup_generic_vfree(void *p)
122
+{
123
+ void **pp = (void **)p;
124
+ qemu_vfree(*pp);
125
+}
126
+
127
+/*
128
+ * Analog of g_autofree, but qemu_vfree is called on cleanup instead of g_free.
129
+ */
130
+#define QEMU_AUTO_VFREE __attribute__((cleanup(qemu_cleanup_generic_vfree)))
131
+
132
+#endif
133
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
134
index XXXXXXX..XXXXXXX 100644
135
--- a/include/qemu/osdep.h
136
+++ b/include/qemu/osdep.h
137
@@ -XXX,XX +XXX,XX @@ extern "C" {
138
#endif
139
140
int qemu_daemon(int nochdir, int noclose);
141
-void *qemu_try_memalign(size_t alignment, size_t size);
142
-void *qemu_memalign(size_t alignment, size_t size);
143
void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared,
144
bool noreserve);
145
-void qemu_vfree(void *ptr);
146
void qemu_anon_ram_free(void *ptr, size_t size);
147
148
-/*
149
- * It's an analog of GLIB's g_autoptr_cleanup_generic_gfree(), used to define
150
- * g_autofree macro.
151
- */
152
-static inline void qemu_cleanup_generic_vfree(void *p)
153
-{
154
- void **pp = (void **)p;
155
- qemu_vfree(*pp);
156
-}
157
-
158
-/*
159
- * Analog of g_autofree, but qemu_vfree is called on cleanup instead of g_free.
160
- */
161
-#define QEMU_AUTO_VFREE __attribute__((cleanup(qemu_cleanup_generic_vfree)))
162
-
163
#ifdef _WIN32
164
#define HAVE_CHARDEV_SERIAL 1
165
#elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
166
diff --git a/block/blkverify.c b/block/blkverify.c
167
index XXXXXXX..XXXXXXX 100644
168
--- a/block/blkverify.c
169
+++ b/block/blkverify.c
170
@@ -XXX,XX +XXX,XX @@
171
#include "qemu/cutils.h"
172
#include "qemu/module.h"
173
#include "qemu/option.h"
174
+#include "qemu/memalign.h"
175
176
typedef struct {
177
BdrvChild *test_file;
178
diff --git a/block/block-copy.c b/block/block-copy.c
179
index XXXXXXX..XXXXXXX 100644
180
--- a/block/block-copy.c
181
+++ b/block/block-copy.c
182
@@ -XXX,XX +XXX,XX @@
183
#include "qemu/coroutine.h"
184
#include "block/aio_task.h"
185
#include "qemu/error-report.h"
186
+#include "qemu/memalign.h"
187
188
#define BLOCK_COPY_MAX_COPY_RANGE (16 * MiB)
189
#define BLOCK_COPY_MAX_BUFFER (1 * MiB)
190
diff --git a/block/commit.c b/block/commit.c
191
index XXXXXXX..XXXXXXX 100644
192
--- a/block/commit.c
193
+++ b/block/commit.c
194
@@ -XXX,XX +XXX,XX @@
195
#include "qapi/error.h"
196
#include "qapi/qmp/qerror.h"
197
#include "qemu/ratelimit.h"
198
+#include "qemu/memalign.h"
199
#include "sysemu/block-backend.h"
200
201
enum {
202
diff --git a/block/crypto.c b/block/crypto.c
203
index XXXXXXX..XXXXXXX 100644
204
--- a/block/crypto.c
205
+++ b/block/crypto.c
206
@@ -XXX,XX +XXX,XX @@
207
#include "qemu/module.h"
208
#include "qemu/option.h"
209
#include "qemu/cutils.h"
210
+#include "qemu/memalign.h"
211
#include "crypto.h"
212
213
typedef struct BlockCrypto BlockCrypto;
214
diff --git a/block/dmg.c b/block/dmg.c
215
index XXXXXXX..XXXXXXX 100644
216
--- a/block/dmg.c
217
+++ b/block/dmg.c
218
@@ -XXX,XX +XXX,XX @@
219
#include "qemu/bswap.h"
220
#include "qemu/error-report.h"
221
#include "qemu/module.h"
222
+#include "qemu/memalign.h"
223
#include "dmg.h"
224
225
int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in,
226
diff --git a/block/export/fuse.c b/block/export/fuse.c
227
index XXXXXXX..XXXXXXX 100644
228
--- a/block/export/fuse.c
229
+++ b/block/export/fuse.c
230
@@ -XXX,XX +XXX,XX @@
231
#define FUSE_USE_VERSION 31
232
233
#include "qemu/osdep.h"
234
+#include "qemu/memalign.h"
235
#include "block/aio.h"
236
#include "block/block.h"
237
#include "block/export.h"
238
diff --git a/block/file-posix.c b/block/file-posix.c
239
index XXXXXXX..XXXXXXX 100644
240
--- a/block/file-posix.c
241
+++ b/block/file-posix.c
242
@@ -XXX,XX +XXX,XX @@
243
#include "qemu/module.h"
244
#include "qemu/option.h"
245
#include "qemu/units.h"
246
+#include "qemu/memalign.h"
247
#include "trace.h"
248
#include "block/thread-pool.h"
249
#include "qemu/iov.h"
250
diff --git a/block/io.c b/block/io.c
251
index XXXXXXX..XXXXXXX 100644
252
--- a/block/io.c
253
+++ b/block/io.c
254
@@ -XXX,XX +XXX,XX @@
255
#include "block/coroutines.h"
256
#include "block/write-threshold.h"
257
#include "qemu/cutils.h"
258
+#include "qemu/memalign.h"
259
#include "qapi/error.h"
260
#include "qemu/error-report.h"
261
#include "qemu/main-loop.h"
262
diff --git a/block/mirror.c b/block/mirror.c
263
index XXXXXXX..XXXXXXX 100644
264
--- a/block/mirror.c
265
+++ b/block/mirror.c
266
@@ -XXX,XX +XXX,XX @@
267
#include "qapi/qmp/qerror.h"
268
#include "qemu/ratelimit.h"
269
#include "qemu/bitmap.h"
270
+#include "qemu/memalign.h"
271
272
#define MAX_IN_FLIGHT 16
273
#define MAX_IO_BYTES (1 << 20) /* 1 Mb */
274
diff --git a/block/nvme.c b/block/nvme.c
275
index XXXXXXX..XXXXXXX 100644
276
--- a/block/nvme.c
277
+++ b/block/nvme.c
278
@@ -XXX,XX +XXX,XX @@
279
#include "qemu/module.h"
280
#include "qemu/cutils.h"
281
#include "qemu/option.h"
282
+#include "qemu/memalign.h"
283
#include "qemu/vfio-helpers.h"
284
#include "block/block_int.h"
285
#include "sysemu/replay.h"
286
diff --git a/block/parallels-ext.c b/block/parallels-ext.c
287
index XXXXXXX..XXXXXXX 100644
288
--- a/block/parallels-ext.c
289
+++ b/block/parallels-ext.c
290
@@ -XXX,XX +XXX,XX @@
291
#include "parallels.h"
292
#include "crypto/hash.h"
293
#include "qemu/uuid.h"
294
+#include "qemu/memalign.h"
295
296
#define PARALLELS_FORMAT_EXTENSION_MAGIC 0xAB234CEF23DCEA87ULL
297
298
diff --git a/block/parallels.c b/block/parallels.c
299
index XXXXXXX..XXXXXXX 100644
300
--- a/block/parallels.c
301
+++ b/block/parallels.c
302
@@ -XXX,XX +XXX,XX @@
303
#include "qapi/qapi-visit-block-core.h"
304
#include "qemu/bswap.h"
305
#include "qemu/bitmap.h"
306
+#include "qemu/memalign.h"
307
#include "migration/blocker.h"
308
#include "parallels.h"
309
310
diff --git a/block/qcow.c b/block/qcow.c
311
index XXXXXXX..XXXXXXX 100644
312
--- a/block/qcow.c
313
+++ b/block/qcow.c
314
@@ -XXX,XX +XXX,XX @@
315
#include "qemu/option.h"
316
#include "qemu/bswap.h"
317
#include "qemu/cutils.h"
318
+#include "qemu/memalign.h"
319
#include <zlib.h>
320
#include "qapi/qmp/qdict.h"
321
#include "qapi/qmp/qstring.h"
322
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
323
index XXXXXXX..XXXXXXX 100644
324
--- a/block/qcow2-cache.c
325
+++ b/block/qcow2-cache.c
326
@@ -XXX,XX +XXX,XX @@
327
*/
328
329
#include "qemu/osdep.h"
330
+#include "qemu/memalign.h"
331
#include "qcow2.h"
332
#include "trace.h"
333
334
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
335
index XXXXXXX..XXXXXXX 100644
336
--- a/block/qcow2-cluster.c
337
+++ b/block/qcow2-cluster.c
338
@@ -XXX,XX +XXX,XX @@
339
#include "qapi/error.h"
340
#include "qcow2.h"
341
#include "qemu/bswap.h"
342
+#include "qemu/memalign.h"
343
#include "trace.h"
344
345
int qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t exact_size)
346
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
347
index XXXXXXX..XXXXXXX 100644
348
--- a/block/qcow2-refcount.c
349
+++ b/block/qcow2-refcount.c
350
@@ -XXX,XX +XXX,XX @@
351
#include "qemu/range.h"
352
#include "qemu/bswap.h"
353
#include "qemu/cutils.h"
354
+#include "qemu/memalign.h"
355
#include "trace.h"
356
357
static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size,
358
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
359
index XXXXXXX..XXXXXXX 100644
360
--- a/block/qcow2-snapshot.c
361
+++ b/block/qcow2-snapshot.c
362
@@ -XXX,XX +XXX,XX @@
363
#include "qemu/bswap.h"
364
#include "qemu/error-report.h"
365
#include "qemu/cutils.h"
366
+#include "qemu/memalign.h"
367
368
static void qcow2_free_single_snapshot(BlockDriverState *bs, int i)
369
{
370
diff --git a/block/qcow2.c b/block/qcow2.c
371
index XXXXXXX..XXXXXXX 100644
372
--- a/block/qcow2.c
373
+++ b/block/qcow2.c
374
@@ -XXX,XX +XXX,XX @@
375
#include "qemu/option_int.h"
376
#include "qemu/cutils.h"
377
#include "qemu/bswap.h"
378
+#include "qemu/memalign.h"
379
#include "qapi/qobject-input-visitor.h"
380
#include "qapi/qapi-visit-block-core.h"
381
#include "crypto.h"
382
diff --git a/block/qed-l2-cache.c b/block/qed-l2-cache.c
383
index XXXXXXX..XXXXXXX 100644
384
--- a/block/qed-l2-cache.c
385
+++ b/block/qed-l2-cache.c
386
@@ -XXX,XX +XXX,XX @@
387
*/
388
389
#include "qemu/osdep.h"
390
+#include "qemu/memalign.h"
391
#include "trace.h"
392
#include "qed.h"
393
394
diff --git a/block/qed-table.c b/block/qed-table.c
395
index XXXXXXX..XXXXXXX 100644
396
--- a/block/qed-table.c
397
+++ b/block/qed-table.c
398
@@ -XXX,XX +XXX,XX @@
399
#include "qemu/sockets.h" /* for EINPROGRESS on Windows */
400
#include "qed.h"
401
#include "qemu/bswap.h"
402
+#include "qemu/memalign.h"
403
404
/* Called with table_lock held. */
405
static int coroutine_fn qed_read_table(BDRVQEDState *s, uint64_t offset,
406
diff --git a/block/qed.c b/block/qed.c
407
index XXXXXXX..XXXXXXX 100644
408
--- a/block/qed.c
409
+++ b/block/qed.c
410
@@ -XXX,XX +XXX,XX @@
411
#include "qemu/main-loop.h"
412
#include "qemu/module.h"
413
#include "qemu/option.h"
414
+#include "qemu/memalign.h"
415
#include "trace.h"
416
#include "qed.h"
417
#include "sysemu/block-backend.h"
418
diff --git a/block/quorum.c b/block/quorum.c
419
index XXXXXXX..XXXXXXX 100644
420
--- a/block/quorum.c
421
+++ b/block/quorum.c
422
@@ -XXX,XX +XXX,XX @@
423
#include "qemu/cutils.h"
424
#include "qemu/module.h"
425
#include "qemu/option.h"
426
+#include "qemu/memalign.h"
427
#include "block/block_int.h"
428
#include "block/coroutines.h"
429
#include "block/qdict.h"
430
diff --git a/block/raw-format.c b/block/raw-format.c
431
index XXXXXXX..XXXXXXX 100644
432
--- a/block/raw-format.c
433
+++ b/block/raw-format.c
434
@@ -XXX,XX +XXX,XX @@
435
#include "qapi/error.h"
436
#include "qemu/module.h"
437
#include "qemu/option.h"
438
+#include "qemu/memalign.h"
439
440
typedef struct BDRVRawState {
441
uint64_t offset;
442
diff --git a/block/vdi.c b/block/vdi.c
443
index XXXXXXX..XXXXXXX 100644
444
--- a/block/vdi.c
445
+++ b/block/vdi.c
446
@@ -XXX,XX +XXX,XX @@
447
#include "qemu/coroutine.h"
448
#include "qemu/cutils.h"
449
#include "qemu/uuid.h"
450
+#include "qemu/memalign.h"
451
452
/* Code configuration options. */
453
454
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
455
index XXXXXXX..XXXXXXX 100644
456
--- a/block/vhdx-log.c
457
+++ b/block/vhdx-log.c
458
@@ -XXX,XX +XXX,XX @@
459
#include "block/block_int.h"
460
#include "qemu/error-report.h"
461
#include "qemu/bswap.h"
462
+#include "qemu/memalign.h"
463
#include "vhdx.h"
464
465
466
diff --git a/block/vhdx.c b/block/vhdx.c
467
index XXXXXXX..XXXXXXX 100644
468
--- a/block/vhdx.c
469
+++ b/block/vhdx.c
470
@@ -XXX,XX +XXX,XX @@
471
#include "qemu/crc32c.h"
472
#include "qemu/bswap.h"
473
#include "qemu/error-report.h"
474
+#include "qemu/memalign.h"
475
#include "vhdx.h"
476
#include "migration/blocker.h"
477
#include "qemu/uuid.h"
478
diff --git a/block/vmdk.c b/block/vmdk.c
479
index XXXXXXX..XXXXXXX 100644
480
--- a/block/vmdk.c
481
+++ b/block/vmdk.c
482
@@ -XXX,XX +XXX,XX @@
483
#include "qemu/module.h"
484
#include "qemu/option.h"
485
#include "qemu/bswap.h"
486
+#include "qemu/memalign.h"
487
#include "migration/blocker.h"
488
#include "qemu/cutils.h"
489
#include <zlib.h>
490
diff --git a/block/vpc.c b/block/vpc.c
491
index XXXXXXX..XXXXXXX 100644
492
--- a/block/vpc.c
493
+++ b/block/vpc.c
494
@@ -XXX,XX +XXX,XX @@
495
#include "migration/blocker.h"
496
#include "qemu/bswap.h"
497
#include "qemu/uuid.h"
498
+#include "qemu/memalign.h"
499
#include "qapi/qmp/qdict.h"
500
#include "qapi/qobject-input-visitor.h"
501
#include "qapi/qapi-visit-block-core.h"
502
diff --git a/block/win32-aio.c b/block/win32-aio.c
503
index XXXXXXX..XXXXXXX 100644
504
--- a/block/win32-aio.c
505
+++ b/block/win32-aio.c
506
@@ -XXX,XX +XXX,XX @@
507
#include "block/raw-aio.h"
508
#include "qemu/event_notifier.h"
509
#include "qemu/iov.h"
510
+#include "qemu/memalign.h"
511
#include <windows.h>
512
#include <winioctl.h>
513
514
diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
515
index XXXXXXX..XXXXXXX 100644
516
--- a/hw/block/dataplane/xen-block.c
517
+++ b/hw/block/dataplane/xen-block.c
518
@@ -XXX,XX +XXX,XX @@
519
#include "qemu/osdep.h"
520
#include "qemu/error-report.h"
521
#include "qemu/main-loop.h"
522
+#include "qemu/memalign.h"
523
#include "qapi/error.h"
524
#include "hw/xen/xen_common.h"
525
#include "hw/block/xen_blkif.h"
526
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
527
index XXXXXXX..XXXXXXX 100644
528
--- a/hw/block/fdc.c
529
+++ b/hw/block/fdc.c
530
@@ -XXX,XX +XXX,XX @@
531
#include "qapi/error.h"
532
#include "qemu/error-report.h"
533
#include "qemu/timer.h"
534
+#include "qemu/memalign.h"
535
#include "hw/irq.h"
536
#include "hw/isa/isa.h"
537
#include "hw/qdev-properties.h"
538
diff --git a/hw/ide/core.c b/hw/ide/core.c
539
index XXXXXXX..XXXXXXX 100644
540
--- a/hw/ide/core.c
541
+++ b/hw/ide/core.c
542
@@ -XXX,XX +XXX,XX @@
543
#include "qemu/main-loop.h"
544
#include "qemu/timer.h"
545
#include "qemu/hw-version.h"
546
+#include "qemu/memalign.h"
547
#include "sysemu/sysemu.h"
548
#include "sysemu/blockdev.h"
549
#include "sysemu/dma.h"
550
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
551
index XXXXXXX..XXXXXXX 100644
552
--- a/hw/ppc/spapr.c
553
+++ b/hw/ppc/spapr.c
554
@@ -XXX,XX +XXX,XX @@
555
#include "qemu/osdep.h"
556
#include "qemu-common.h"
557
#include "qemu/datadir.h"
558
+#include "qemu/memalign.h"
559
#include "qapi/error.h"
560
#include "qapi/qapi-events-machine.h"
561
#include "qapi/qapi-events-qdev.h"
562
diff --git a/hw/ppc/spapr_softmmu.c b/hw/ppc/spapr_softmmu.c
563
index XXXXXXX..XXXXXXX 100644
564
--- a/hw/ppc/spapr_softmmu.c
565
+++ b/hw/ppc/spapr_softmmu.c
566
@@ -XXX,XX +XXX,XX @@
567
#include "qemu/osdep.h"
568
#include "qemu/cutils.h"
569
+#include "qemu/memalign.h"
570
#include "cpu.h"
571
#include "helper_regs.h"
572
#include "hw/ppc/spapr.h"
573
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
574
index XXXXXXX..XXXXXXX 100644
575
--- a/hw/scsi/scsi-disk.c
576
+++ b/hw/scsi/scsi-disk.c
577
@@ -XXX,XX +XXX,XX @@
578
#include "qemu/main-loop.h"
579
#include "qemu/module.h"
580
#include "qemu/hw-version.h"
581
+#include "qemu/memalign.h"
582
#include "hw/scsi/scsi.h"
583
#include "migration/qemu-file-types.h"
584
#include "migration/vmstate.h"
585
diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
586
index XXXXXXX..XXXXXXX 100644
587
--- a/hw/tpm/tpm_ppi.c
588
+++ b/hw/tpm/tpm_ppi.c
589
@@ -XXX,XX +XXX,XX @@
590
*/
591
592
#include "qemu/osdep.h"
593
-
594
+#include "qemu/memalign.h"
595
#include "qapi/error.h"
596
#include "sysemu/memory_mapping.h"
597
#include "migration/vmstate.h"
598
diff --git a/nbd/server.c b/nbd/server.c
599
index XXXXXXX..XXXXXXX 100644
600
--- a/nbd/server.c
601
+++ b/nbd/server.c
602
@@ -XXX,XX +XXX,XX @@
603
#include "trace.h"
604
#include "nbd-internal.h"
605
#include "qemu/units.h"
606
+#include "qemu/memalign.h"
607
608
#define NBD_META_ID_BASE_ALLOCATION 0
609
#define NBD_META_ID_ALLOCATION_DEPTH 1
610
diff --git a/net/l2tpv3.c b/net/l2tpv3.c
611
index XXXXXXX..XXXXXXX 100644
612
--- a/net/l2tpv3.c
613
+++ b/net/l2tpv3.c
614
@@ -XXX,XX +XXX,XX @@
615
#include "qemu/sockets.h"
616
#include "qemu/iov.h"
617
#include "qemu/main-loop.h"
618
-
619
+#include "qemu/memalign.h"
620
621
/* The buffer size needs to be investigated for optimum numbers and
622
* optimum means of paging in on different systems. This size is
623
diff --git a/plugins/loader.c b/plugins/loader.c
624
index XXXXXXX..XXXXXXX 100644
625
--- a/plugins/loader.c
626
+++ b/plugins/loader.c
627
@@ -XXX,XX +XXX,XX @@
628
#include "qemu/cacheinfo.h"
629
#include "qemu/xxhash.h"
630
#include "qemu/plugin.h"
631
+#include "qemu/memalign.h"
632
#include "hw/core/cpu.h"
633
#include "exec/exec-all.h"
634
#ifndef CONFIG_USER_ONLY
635
diff --git a/qemu-img.c b/qemu-img.c
636
index XXXXXXX..XXXXXXX 100644
637
--- a/qemu-img.c
638
+++ b/qemu-img.c
639
@@ -XXX,XX +XXX,XX @@
640
#include "qemu/module.h"
641
#include "qemu/sockets.h"
642
#include "qemu/units.h"
643
+#include "qemu/memalign.h"
644
#include "qom/object_interfaces.h"
645
#include "sysemu/block-backend.h"
646
#include "block/block_int.h"
647
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
648
index XXXXXXX..XXXXXXX 100644
649
--- a/qemu-io-cmds.c
650
+++ b/qemu-io-cmds.c
651
@@ -XXX,XX +XXX,XX @@
652
#include "qemu/option.h"
653
#include "qemu/timer.h"
654
#include "qemu/cutils.h"
655
+#include "qemu/memalign.h"
656
657
#define CMD_NOFILE_OK 0x01
658
659
diff --git a/qom/object.c b/qom/object.c
660
index XXXXXXX..XXXXXXX 100644
661
--- a/qom/object.c
662
+++ b/qom/object.c
663
@@ -XXX,XX +XXX,XX @@
664
#include "qom/object.h"
665
#include "qom/object_interfaces.h"
666
#include "qemu/cutils.h"
667
+#include "qemu/memalign.h"
668
#include "qapi/visitor.h"
669
#include "qapi/string-input-visitor.h"
670
#include "qapi/string-output-visitor.h"
671
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
672
index XXXXXXX..XXXXXXX 100644
673
--- a/softmmu/physmem.c
674
+++ b/softmmu/physmem.c
675
@@ -XXX,XX +XXX,XX @@
676
#include "qemu/config-file.h"
677
#include "qemu/error-report.h"
678
#include "qemu/qemu-print.h"
679
+#include "qemu/memalign.h"
680
#include "exec/memory.h"
681
#include "exec/ioport.h"
682
#include "sysemu/dma.h"
683
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
684
index XXXXXXX..XXXXXXX 100644
685
--- a/target/i386/hvf/hvf.c
686
+++ b/target/i386/hvf/hvf.c
687
@@ -XXX,XX +XXX,XX @@
688
#include "qemu/osdep.h"
689
#include "qemu-common.h"
690
#include "qemu/error-report.h"
691
+#include "qemu/memalign.h"
692
693
#include "sysemu/hvf.h"
694
#include "sysemu/hvf_int.h"
695
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
696
index XXXXXXX..XXXXXXX 100644
697
--- a/target/i386/kvm/kvm.c
698
+++ b/target/i386/kvm/kvm.c
699
@@ -XXX,XX +XXX,XX @@
700
#include "qemu/main-loop.h"
701
#include "qemu/config-file.h"
702
#include "qemu/error-report.h"
703
+#include "qemu/memalign.h"
704
#include "hw/i386/x86.h"
705
#include "hw/i386/apic.h"
706
#include "hw/i386/apic_internal.h"
707
diff --git a/tcg/region.c b/tcg/region.c
708
index XXXXXXX..XXXXXXX 100644
709
--- a/tcg/region.c
710
+++ b/tcg/region.c
711
@@ -XXX,XX +XXX,XX @@
712
#include "qemu/units.h"
713
#include "qemu/madvise.h"
714
#include "qemu/mprotect.h"
715
+#include "qemu/memalign.h"
716
#include "qemu/cacheinfo.h"
717
#include "qapi/error.h"
718
#include "exec/exec-all.h"
719
diff --git a/tests/bench/atomic_add-bench.c b/tests/bench/atomic_add-bench.c
720
index XXXXXXX..XXXXXXX 100644
721
--- a/tests/bench/atomic_add-bench.c
722
+++ b/tests/bench/atomic_add-bench.c
723
@@ -XXX,XX +XXX,XX @@
724
#include "qemu/thread.h"
725
#include "qemu/host-utils.h"
726
#include "qemu/processor.h"
727
+#include "qemu/memalign.h"
728
729
struct thread_info {
730
uint64_t r;
731
diff --git a/tests/bench/qht-bench.c b/tests/bench/qht-bench.c
732
index XXXXXXX..XXXXXXX 100644
733
--- a/tests/bench/qht-bench.c
734
+++ b/tests/bench/qht-bench.c
735
@@ -XXX,XX +XXX,XX @@
736
#include "qemu/qht.h"
737
#include "qemu/rcu.h"
738
#include "qemu/xxhash.h"
739
+#include "qemu/memalign.h"
740
741
struct thread_stats {
742
size_t rd;
743
diff --git a/util/atomic64.c b/util/atomic64.c
744
index XXXXXXX..XXXXXXX 100644
745
--- a/util/atomic64.c
746
+++ b/util/atomic64.c
747
@@ -XXX,XX +XXX,XX @@
748
#include "qemu/atomic.h"
749
#include "qemu/thread.h"
750
#include "qemu/cacheinfo.h"
751
+#include "qemu/memalign.h"
752
753
#ifdef CONFIG_ATOMIC64
754
#error This file must only be compiled if !CONFIG_ATOMIC64
755
diff --git a/util/memalign.c b/util/memalign.c
756
index XXXXXXX..XXXXXXX 100644
757
--- a/util/memalign.c
758
+++ b/util/memalign.c
759
@@ -XXX,XX +XXX,XX @@
760
761
#include "qemu/osdep.h"
762
#include "qemu/host-utils.h"
763
+#include "qemu/memalign.h"
764
#include "trace.h"
765
766
void *qemu_try_memalign(size_t alignment, size_t size)
767
diff --git a/util/qht.c b/util/qht.c
768
index XXXXXXX..XXXXXXX 100644
769
--- a/util/qht.c
770
+++ b/util/qht.c
771
@@ -XXX,XX +XXX,XX @@
772
#include "qemu/qht.h"
773
#include "qemu/atomic.h"
774
#include "qemu/rcu.h"
775
+#include "qemu/memalign.h"
776
777
//#define QHT_DEBUG
778
779
--
780
2.25.1
781
782
diff view generated by jsdifflib
Deleted patch
1
For VLD1/VST1 (single element to one lane) we are only accessing one
2
register, and so the 'stride' is meaningless. The bits that would
3
specify stride (insn bit [4] for size=1, bit [6] for size=2) are
4
specified to be zero in the encoding (which would correspond to a
5
stride of 1 for VLD2/VLD3/VLD4 etc), and we must UNDEF if they are
6
not.
7
1
8
We failed to make this check, which meant that we would incorrectly
9
handle some instruction patterns as loads or stores instead of
10
UNDEFing them. Enforce that stride == 1 for the nregs == 1 case.
11
12
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/890
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Tested-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 20220303113741.2156877-2-peter.maydell@linaro.org
17
---
18
target/arm/translate-neon.c | 3 +++
19
1 file changed, 3 insertions(+)
20
21
diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/translate-neon.c
24
+++ b/target/arm/translate-neon.c
25
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
26
/* Catch the UNDEF cases. This is unavoidably a bit messy. */
27
switch (nregs) {
28
case 1:
29
+ if (a->stride != 1) {
30
+ return false;
31
+ }
32
if (((a->align & (1 << a->size)) != 0) ||
33
(a->size == 2 && (a->align == 1 || a->align == 2))) {
34
return false;
35
--
36
2.25.1
diff view generated by jsdifflib
Deleted patch
1
For VLD3 (single 3-element structure to one lane), there is no
2
alignment specification and the alignment bits in the instruction
3
must be zero. This is bit [4] for the size=0 and size=1 cases, and
4
bits [5:4] for the size=2 case. We do this check correctly in
5
VLDST_single(), but we write it a bit oddly: in the 'case 3' code we
6
check for bit 0 of a->align (bit [4] of the insn), and then we fall
7
through to the 'case 2' code which checks bit 1 of a->align (bit [5]
8
of the insn) in the size 2 case. Replace this with just checking "is
9
a->align non-zero" for VLD3, which lets us drop the fall-through and
10
put the cases in this switch in numerical order.
11
1
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Tested-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20220303113741.2156877-3-peter.maydell@linaro.org
16
---
17
target/arm/translate-neon.c | 10 +++++-----
18
1 file changed, 5 insertions(+), 5 deletions(-)
19
20
diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/translate-neon.c
23
+++ b/target/arm/translate-neon.c
24
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
25
return false;
26
}
27
break;
28
- case 3:
29
- if ((a->align & 1) != 0) {
30
- return false;
31
- }
32
- /* fall through */
33
case 2:
34
if (a->size == 2 && (a->align & 2) != 0) {
35
return false;
36
}
37
break;
38
+ case 3:
39
+ if (a->align != 0) {
40
+ return false;
41
+ }
42
+ break;
43
case 4:
44
if (a->size == 2 && a->align == 3) {
45
return false;
46
--
47
2.25.1
diff view generated by jsdifflib
Deleted patch
1
When debugging code that's using the ITS, it's helpful to
2
see tracing of the ITS commands that the guest executes. Add
3
suitable trace events.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220303202341.2232284-2-peter.maydell@linaro.org
8
---
9
hw/intc/arm_gicv3_its.c | 28 ++++++++++++++++++++++++++--
10
hw/intc/trace-events | 12 ++++++++++++
11
2 files changed, 38 insertions(+), 2 deletions(-)
12
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
16
+++ b/hw/intc/arm_gicv3_its.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, const uint64_t *cmdpkt,
18
19
devid = (cmdpkt[0] & DEVID_MASK) >> DEVID_SHIFT;
20
eventid = cmdpkt[1] & EVENTID_MASK;
21
+ switch (cmd) {
22
+ case INTERRUPT:
23
+ trace_gicv3_its_cmd_int(devid, eventid);
24
+ break;
25
+ case CLEAR:
26
+ trace_gicv3_its_cmd_clear(devid, eventid);
27
+ break;
28
+ case DISCARD:
29
+ trace_gicv3_its_cmd_discard(devid, eventid);
30
+ break;
31
+ default:
32
+ g_assert_not_reached();
33
+ }
34
return do_process_its_cmd(s, devid, eventid, cmd);
35
}
36
37
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt,
38
39
devid = (cmdpkt[0] & DEVID_MASK) >> DEVID_SHIFT;
40
eventid = cmdpkt[1] & EVENTID_MASK;
41
+ icid = cmdpkt[2] & ICID_MASK;
42
43
if (ignore_pInt) {
44
pIntid = eventid;
45
+ trace_gicv3_its_cmd_mapi(devid, eventid, icid);
46
} else {
47
pIntid = (cmdpkt[1] & pINTID_MASK) >> pINTID_SHIFT;
48
+ trace_gicv3_its_cmd_mapti(devid, eventid, icid, pIntid);
49
}
50
51
- icid = cmdpkt[2] & ICID_MASK;
52
-
53
if (devid >= s->dt.num_entries) {
54
qemu_log_mask(LOG_GUEST_ERROR,
55
"%s: invalid command attributes: devid %d>=%d",
56
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, const uint64_t *cmdpkt)
57
} else {
58
cte.rdbase = 0;
59
}
60
+ trace_gicv3_its_cmd_mapc(icid, cte.rdbase, cte.valid);
61
62
if (icid >= s->ct.num_entries) {
63
qemu_log_mask(LOG_GUEST_ERROR, "ITS MAPC: invalid ICID 0x%d", icid);
64
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, const uint64_t *cmdpkt)
65
dte.ittaddr = (cmdpkt[2] & ITTADDR_MASK) >> ITTADDR_SHIFT;
66
dte.valid = cmdpkt[2] & CMD_FIELD_VALID_MASK;
67
68
+ trace_gicv3_its_cmd_mapd(devid, dte.size, dte.ittaddr, dte.valid);
69
+
70
if (devid >= s->dt.num_entries) {
71
qemu_log_mask(LOG_GUEST_ERROR,
72
"ITS MAPD: invalid device ID field 0x%x >= 0x%x\n",
73
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_movall(GICv3ITSState *s, const uint64_t *cmdpkt)
74
rd1 = FIELD_EX64(cmdpkt[2], MOVALL_2, RDBASE1);
75
rd2 = FIELD_EX64(cmdpkt[3], MOVALL_3, RDBASE2);
76
77
+ trace_gicv3_its_cmd_movall(rd1, rd2);
78
+
79
if (rd1 >= s->gicv3->num_cpu) {
80
qemu_log_mask(LOG_GUEST_ERROR,
81
"%s: RDBASE1 %" PRId64
82
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_movi(GICv3ITSState *s, const uint64_t *cmdpkt)
83
eventid = FIELD_EX64(cmdpkt[1], MOVI_1, EVENTID);
84
new_icid = FIELD_EX64(cmdpkt[2], MOVI_2, ICID);
85
86
+ trace_gicv3_its_cmd_movi(devid, eventid, new_icid);
87
+
88
if (devid >= s->dt.num_entries) {
89
qemu_log_mask(LOG_GUEST_ERROR,
90
"%s: invalid command attributes: devid %d>=%d",
91
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
92
* is already consistent by the time SYNC command is executed.
93
* Hence no further processing is required for SYNC command.
94
*/
95
+ trace_gicv3_its_cmd_sync();
96
break;
97
case GITS_CMD_MAPD:
98
result = process_mapd(s, cmdpkt);
99
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
100
* need to trigger lpi priority re-calculation to be in
101
* sync with LPI config table or pending table changes.
102
*/
103
+ trace_gicv3_its_cmd_inv();
104
for (i = 0; i < s->gicv3->num_cpu; i++) {
105
gicv3_redist_update_lpi(&s->gicv3->cpu[i]);
106
}
107
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
108
result = process_movall(s, cmdpkt);
109
break;
110
default:
111
+ trace_gicv3_its_cmd_unknown(cmd);
112
break;
113
}
114
if (result == CMD_CONTINUE) {
115
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
116
index XXXXXXX..XXXXXXX 100644
117
--- a/hw/intc/trace-events
118
+++ b/hw/intc/trace-events
119
@@ -XXX,XX +XXX,XX @@ gicv3_its_write(uint64_t offset, uint64_t data, unsigned size) "GICv3 ITS write:
120
gicv3_its_badwrite(uint64_t offset, uint64_t data, unsigned size) "GICv3 ITS write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u: error"
121
gicv3_its_translation_write(uint64_t offset, uint64_t data, unsigned size, uint32_t requester_id) "GICv3 ITS TRANSLATER write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u requester_id 0x%x"
122
gicv3_its_process_command(uint32_t rd_offset, uint8_t cmd) "GICv3 ITS: processing command at offset 0x%x: 0x%x"
123
+gicv3_its_cmd_int(uint32_t devid, uint32_t eventid) "GICv3 ITS: command INT DeviceID 0x%x EventID 0x%x"
124
+gicv3_its_cmd_clear(uint32_t devid, uint32_t eventid) "GICv3 ITS: command CLEAR DeviceID 0x%x EventID 0x%x"
125
+gicv3_its_cmd_discard(uint32_t devid, uint32_t eventid) "GICv3 ITS: command DISCARD DeviceID 0x%x EventID 0x%x"
126
+gicv3_its_cmd_sync(void) "GICv3 ITS: command SYNC"
127
+gicv3_its_cmd_mapd(uint32_t devid, uint32_t size, uint64_t ittaddr, int valid) "GICv3 ITS: command MAPD DeviceID 0x%x Size 0x%x ITT_addr 0x%" PRIx64 " V %d"
128
+gicv3_its_cmd_mapc(uint32_t icid, uint64_t rdbase, int valid) "GICv3 ITS: command MAPC ICID 0x%x RDbase 0x%" PRIx64 " V %d"
129
+gicv3_its_cmd_mapi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MAPI DeviceID 0x%x EventID 0x%x ICID 0x%x"
130
+gicv3_its_cmd_mapti(uint32_t devid, uint32_t eventid, uint32_t icid, uint32_t intid) "GICv3 ITS: command MAPTI DeviceID 0x%x EventID 0x%x ICID 0x%x pINTID 0x%x"
131
+gicv3_its_cmd_inv(void) "GICv3 ITS: command INV or INVALL"
132
+gicv3_its_cmd_movall(uint64_t rd1, uint64_t rd2) "GICv3 ITS: command MOVALL RDbase1 0x%" PRIx64 " RDbase2 0x%" PRIx64
133
+gicv3_its_cmd_movi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MOVI DeviceID 0x%x EventID 0x%x ICID 0x%x"
134
+gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x"
135
136
# armv7m_nvic.c
137
nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d"
138
--
139
2.25.1
diff view generated by jsdifflib
Deleted patch
1
For debugging guest use of the ITS, it can be helpful to trace
2
when the ITS reads and writes the in-memory tables.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20220303202341.2232284-3-peter.maydell@linaro.org
7
---
8
hw/intc/arm_gicv3_its.c | 37 +++++++++++++++++++++++++++++++------
9
hw/intc/trace-events | 9 +++++++++
10
2 files changed, 40 insertions(+), 6 deletions(-)
11
12
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/intc/arm_gicv3_its.c
15
+++ b/hw/intc/arm_gicv3_its.c
16
@@ -XXX,XX +XXX,XX @@ static MemTxResult get_cte(GICv3ITSState *s, uint16_t icid, CTEntry *cte)
17
if (entry_addr == -1) {
18
/* No L2 table entry, i.e. no valid CTE, or a memory error */
19
cte->valid = false;
20
- return res;
21
+ goto out;
22
}
23
24
cteval = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, &res);
25
if (res != MEMTX_OK) {
26
- return res;
27
+ goto out;
28
}
29
cte->valid = FIELD_EX64(cteval, CTE, VALID);
30
cte->rdbase = FIELD_EX64(cteval, CTE, RDBASE);
31
- return MEMTX_OK;
32
+out:
33
+ if (res != MEMTX_OK) {
34
+ trace_gicv3_its_cte_read_fault(icid);
35
+ } else {
36
+ trace_gicv3_its_cte_read(icid, cte->valid, cte->rdbase);
37
+ }
38
+ return res;
39
}
40
41
/*
42
@@ -XXX,XX +XXX,XX @@ static bool update_ite(GICv3ITSState *s, uint32_t eventid, const DTEntry *dte,
43
uint64_t itel = 0;
44
uint32_t iteh = 0;
45
46
+ trace_gicv3_its_ite_write(dte->ittaddr, eventid, ite->valid,
47
+ ite->inttype, ite->intid, ite->icid,
48
+ ite->vpeid, ite->doorbell);
49
+
50
if (ite->valid) {
51
itel = FIELD_DP64(itel, ITE_L, VALID, 1);
52
itel = FIELD_DP64(itel, ITE_L, INTTYPE, ite->inttype);
53
@@ -XXX,XX +XXX,XX @@ static MemTxResult get_ite(GICv3ITSState *s, uint32_t eventid,
54
55
itel = address_space_ldq_le(as, iteaddr, MEMTXATTRS_UNSPECIFIED, &res);
56
if (res != MEMTX_OK) {
57
+ trace_gicv3_its_ite_read_fault(dte->ittaddr, eventid);
58
return res;
59
}
60
61
iteh = address_space_ldl_le(as, iteaddr + 8, MEMTXATTRS_UNSPECIFIED, &res);
62
if (res != MEMTX_OK) {
63
+ trace_gicv3_its_ite_read_fault(dte->ittaddr, eventid);
64
return res;
65
}
66
67
@@ -XXX,XX +XXX,XX @@ static MemTxResult get_ite(GICv3ITSState *s, uint32_t eventid,
68
ite->icid = FIELD_EX64(itel, ITE_L, ICID);
69
ite->vpeid = FIELD_EX64(itel, ITE_L, VPEID);
70
ite->doorbell = FIELD_EX64(iteh, ITE_H, DOORBELL);
71
+ trace_gicv3_its_ite_read(dte->ittaddr, eventid, ite->valid,
72
+ ite->inttype, ite->intid, ite->icid,
73
+ ite->vpeid, ite->doorbell);
74
return MEMTX_OK;
75
}
76
77
@@ -XXX,XX +XXX,XX @@ static MemTxResult get_dte(GICv3ITSState *s, uint32_t devid, DTEntry *dte)
78
if (entry_addr == -1) {
79
/* No L2 table entry, i.e. no valid DTE, or a memory error */
80
dte->valid = false;
81
- return res;
82
+ goto out;
83
}
84
dteval = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, &res);
85
if (res != MEMTX_OK) {
86
- return res;
87
+ goto out;
88
}
89
dte->valid = FIELD_EX64(dteval, DTE, VALID);
90
dte->size = FIELD_EX64(dteval, DTE, SIZE);
91
/* DTE word field stores bits [51:8] of the ITT address */
92
dte->ittaddr = FIELD_EX64(dteval, DTE, ITTADDR) << ITTADDR_SHIFT;
93
- return MEMTX_OK;
94
+out:
95
+ if (res != MEMTX_OK) {
96
+ trace_gicv3_its_dte_read_fault(devid);
97
+ } else {
98
+ trace_gicv3_its_dte_read(devid, dte->valid, dte->size, dte->ittaddr);
99
+ }
100
+ return res;
101
}
102
103
/*
104
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, const CTEntry *cte)
105
uint64_t cteval = 0;
106
MemTxResult res = MEMTX_OK;
107
108
+ trace_gicv3_its_cte_write(icid, cte->valid, cte->rdbase);
109
+
110
if (cte->valid) {
111
/* add mapping entry to collection table */
112
cteval = FIELD_DP64(cteval, CTE, VALID, 1);
113
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, const DTEntry *dte)
114
uint64_t dteval = 0;
115
MemTxResult res = MEMTX_OK;
116
117
+ trace_gicv3_its_dte_write(devid, dte->valid, dte->size, dte->ittaddr);
118
+
119
if (dte->valid) {
120
/* add mapping entry to device table */
121
dteval = FIELD_DP64(dteval, DTE, VALID, 1);
122
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
123
index XXXXXXX..XXXXXXX 100644
124
--- a/hw/intc/trace-events
125
+++ b/hw/intc/trace-events
126
@@ -XXX,XX +XXX,XX @@ gicv3_its_cmd_inv(void) "GICv3 ITS: command INV or INVALL"
127
gicv3_its_cmd_movall(uint64_t rd1, uint64_t rd2) "GICv3 ITS: command MOVALL RDbase1 0x%" PRIx64 " RDbase2 0x%" PRIx64
128
gicv3_its_cmd_movi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MOVI DeviceID 0x%x EventID 0x%x ICID 0x%x"
129
gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x"
130
+gicv3_its_cte_read(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table read for ICID 0x%x: valid %d RDBase 0x%x"
131
+gicv3_its_cte_write(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table write for ICID 0x%x: valid %d RDBase 0x%x"
132
+gicv3_its_cte_read_fault(uint32_t icid) "GICv3 ITS: Collection Table read for ICID 0x%x: faulted"
133
+gicv3_its_ite_read(uint64_t ittaddr, uint32_t eventid, int valid, int inttype, uint32_t intid, uint32_t icid, uint32_t vpeid, uint32_t doorbell) "GICv3 ITS: Interrupt Table read for ITTaddr 0x%" PRIx64 " EventID 0x%x: valid %d inttype %d intid 0x%x ICID 0x%x vPEID 0x%x doorbell 0x%x"
134
+gicv3_its_ite_read_fault(uint64_t ittaddr, uint32_t eventid) "GICv3 ITS: Interrupt Table read for ITTaddr 0x%" PRIx64 " EventID 0x%x: faulted"
135
+gicv3_its_ite_write(uint64_t ittaddr, uint32_t eventid, int valid, int inttype, uint32_t intid, uint32_t icid, uint32_t vpeid, uint32_t doorbell) "GICv3 ITS: Interrupt Table write for ITTaddr 0x%" PRIx64 " EventID 0x%x: valid %d inttype %d intid 0x%x ICID 0x%x vPEID 0x%x doorbell 0x%x"
136
+gicv3_its_dte_read(uint32_t devid, int valid, uint32_t size, uint64_t ittaddr) "GICv3 ITS: Device Table read for DeviceID 0x%x: valid %d size 0x%x ITTaddr 0x%" PRIx64
137
+gicv3_its_dte_write(uint32_t devid, int valid, uint32_t size, uint64_t ittaddr) "GICv3 ITS: Device Table write for DeviceID 0x%x: valid %d size 0x%x ITTaddr 0x%" PRIx64
138
+gicv3_its_dte_read_fault(uint32_t devid) "GICv3 ITS: Device Table read for DeviceID 0x%x: faulted"
139
140
# armv7m_nvic.c
141
nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d"
142
--
143
2.25.1
diff view generated by jsdifflib
Deleted patch
1
The GICv3 has some registers that support byte accesses, and some
2
that support 8-byte accesses. Our TCG implementation implements all
3
of this, switching on the 'size' argument and handling the registers
4
that must support reads of that size while logging an error for
5
attempted accesses to registers that do not support that size access.
6
However we forgot to tell the core memory subsystem about this by
7
specifying the .impl and .valid fields in the MemoryRegionOps struct,
8
so the core was happily simulating 8 byte accesses by combining two 4
9
byte accesses. This doesn't have much guest-visible effect, since
10
there aren't many 8 byte registers and they all support being written
11
in two 4 byte parts.
12
1
13
Set the .impl and .valid fields to say that all sizes from 1 to 8
14
bytes are both valid and implemented by the device.
15
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20220303202341.2232284-4-peter.maydell@linaro.org
19
---
20
hw/intc/arm_gicv3.c | 8 ++++++++
21
1 file changed, 8 insertions(+)
22
23
diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c
24
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/intc/arm_gicv3.c
26
+++ b/hw/intc/arm_gicv3.c
27
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps gic_ops[] = {
28
.read_with_attrs = gicv3_dist_read,
29
.write_with_attrs = gicv3_dist_write,
30
.endianness = DEVICE_NATIVE_ENDIAN,
31
+ .valid.min_access_size = 1,
32
+ .valid.max_access_size = 8,
33
+ .impl.min_access_size = 1,
34
+ .impl.max_access_size = 8,
35
},
36
{
37
.read_with_attrs = gicv3_redist_read,
38
.write_with_attrs = gicv3_redist_write,
39
.endianness = DEVICE_NATIVE_ENDIAN,
40
+ .valid.min_access_size = 1,
41
+ .valid.max_access_size = 8,
42
+ .impl.min_access_size = 1,
43
+ .impl.max_access_size = 8,
44
}
45
};
46
47
--
48
2.25.1
diff view generated by jsdifflib
Deleted patch
1
We forgot a space in some log messages, so the output ended
2
up looking like
3
gicv3_dist_write: invalid guest write at offset 0000000000008000size 8
4
1
5
with a missing space before "size". Add the missing spaces.
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220303202341.2232284-5-peter.maydell@linaro.org
10
---
11
hw/intc/arm_gicv3_dist.c | 4 ++--
12
hw/intc/arm_gicv3_its.c | 4 ++--
13
2 files changed, 4 insertions(+), 4 deletions(-)
14
15
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/arm_gicv3_dist.c
18
+++ b/hw/intc/arm_gicv3_dist.c
19
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data,
20
if (!r) {
21
qemu_log_mask(LOG_GUEST_ERROR,
22
"%s: invalid guest read at offset " TARGET_FMT_plx
23
- "size %u\n", __func__, offset, size);
24
+ " size %u\n", __func__, offset, size);
25
trace_gicv3_dist_badread(offset, size, attrs.secure);
26
/* The spec requires that reserved registers are RAZ/WI;
27
* so use MEMTX_ERROR returns from leaf functions as a way to
28
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data,
29
if (!r) {
30
qemu_log_mask(LOG_GUEST_ERROR,
31
"%s: invalid guest write at offset " TARGET_FMT_plx
32
- "size %u\n", __func__, offset, size);
33
+ " size %u\n", __func__, offset, size);
34
trace_gicv3_dist_badwrite(offset, data, size, attrs.secure);
35
/* The spec requires that reserved registers are RAZ/WI;
36
* so use MEMTX_ERROR returns from leaf functions as a way to
37
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/intc/arm_gicv3_its.c
40
+++ b/hw/intc/arm_gicv3_its.c
41
@@ -XXX,XX +XXX,XX @@ static MemTxResult gicv3_its_read(void *opaque, hwaddr offset, uint64_t *data,
42
if (!result) {
43
qemu_log_mask(LOG_GUEST_ERROR,
44
"%s: invalid guest read at offset " TARGET_FMT_plx
45
- "size %u\n", __func__, offset, size);
46
+ " size %u\n", __func__, offset, size);
47
trace_gicv3_its_badread(offset, size);
48
/*
49
* The spec requires that reserved registers are RAZ/WI;
50
@@ -XXX,XX +XXX,XX @@ static MemTxResult gicv3_its_write(void *opaque, hwaddr offset, uint64_t data,
51
if (!result) {
52
qemu_log_mask(LOG_GUEST_ERROR,
53
"%s: invalid guest write at offset " TARGET_FMT_plx
54
- "size %u\n", __func__, offset, size);
55
+ " size %u\n", __func__, offset, size);
56
trace_gicv3_its_badwrite(offset, data, size);
57
/*
58
* The spec requires that reserved registers are RAZ/WI;
59
--
60
2.25.1
diff view generated by jsdifflib
Deleted patch
1
The trace_gicv3_icv_hppir_read trace event takes an integer value
2
which it uses to form the register name, which should be either
3
ICV_HPPIR0 or ICV_HPPIR1. We were passing in the 'grp' variable for
4
this, but that is either GICV3_G0 or GICV3_G1NS, which happen to be 0
5
and 2, which meant that tracing for the ICV_HPPIR1 register was
6
incorrectly printed as ICV_HPPIR2.
7
1
8
Use the same approach we do for all the other similar trace events,
9
and pass in 'ri->crm == 8 ? 0 : 1', deriving the index value
10
directly from the ARMCPRegInfo struct.
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20220303202341.2232284-6-peter.maydell@linaro.org
15
---
16
hw/intc/arm_gicv3_cpuif.c | 3 ++-
17
1 file changed, 2 insertions(+), 1 deletion(-)
18
19
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/intc/arm_gicv3_cpuif.c
22
+++ b/hw/intc/arm_gicv3_cpuif.c
23
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_hppir_read(CPUARMState *env, const ARMCPRegInfo *ri)
24
}
25
}
26
27
- trace_gicv3_icv_hppir_read(grp, gicv3_redist_affid(cs), value);
28
+ trace_gicv3_icv_hppir_read(ri->crm == 8 ? 0 : 1,
29
+ gicv3_redist_affid(cs), value);
30
return value;
31
}
32
33
--
34
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
1
3
This provides standard look and feel for the about panel and reduces
4
code.
5
6
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
7
Message-id: 20220227042241.1543-1-akihiko.odaki@gmail.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
ui/cocoa.m | 112 +++++++++++------------------------------------------
12
1 file changed, 23 insertions(+), 89 deletions(-)
13
14
diff --git a/ui/cocoa.m b/ui/cocoa.m
15
index XXXXXXX..XXXXXXX 100644
16
--- a/ui/cocoa.m
17
+++ b/ui/cocoa.m
18
@@ -XXX,XX +XXX,XX @@ static void cocoa_switch(DisplayChangeListener *dcl,
19
20
static void cocoa_refresh(DisplayChangeListener *dcl);
21
22
-static NSWindow *normalWindow, *about_window;
23
+static NSWindow *normalWindow;
24
static const DisplayChangeListenerOps dcl_ops = {
25
.dpy_name = "cocoa",
26
.dpy_gfx_update = cocoa_update,
27
@@ -XXX,XX +XXX,XX @@ QemuCocoaView *cocoaView;
28
- (BOOL)verifyQuit;
29
- (void)openDocumentation:(NSString *)filename;
30
- (IBAction) do_about_menu_item: (id) sender;
31
-- (void)make_about_window;
32
- (void)adjustSpeed:(id)sender;
33
@end
34
35
@@ -XXX,XX +XXX,XX @@ QemuCocoaView *cocoaView;
36
[pauseLabel setFont: [NSFont fontWithName: @"Helvetica" size: 90]];
37
[pauseLabel setTextColor: [NSColor blackColor]];
38
[pauseLabel sizeToFit];
39
-
40
- [self make_about_window];
41
}
42
return self;
43
}
44
@@ -XXX,XX +XXX,XX @@ QemuCocoaView *cocoaView;
45
/* The action method for the About menu item */
46
- (IBAction) do_about_menu_item: (id) sender
47
{
48
- [about_window makeKeyAndOrderFront: nil];
49
-}
50
-
51
-/* Create and display the about dialog */
52
-- (void)make_about_window
53
-{
54
- /* Make the window */
55
- int x = 0, y = 0, about_width = 400, about_height = 200;
56
- NSRect window_rect = NSMakeRect(x, y, about_width, about_height);
57
- about_window = [[NSWindow alloc] initWithContentRect:window_rect
58
- styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
59
- NSWindowStyleMaskMiniaturizable
60
- backing:NSBackingStoreBuffered
61
- defer:NO];
62
- [about_window setTitle: @"About"];
63
- [about_window setReleasedWhenClosed: NO];
64
- [about_window center];
65
- NSView *superView = [about_window contentView];
66
-
67
- /* Create the dimensions of the picture */
68
- int picture_width = 80, picture_height = 80;
69
- x = (about_width - picture_width)/2;
70
- y = about_height - picture_height - 10;
71
- NSRect picture_rect = NSMakeRect(x, y, picture_width, picture_height);
72
-
73
- /* Make the picture of QEMU */
74
- NSImageView *picture_view = [[NSImageView alloc] initWithFrame:
75
- picture_rect];
76
- char *qemu_image_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png");
77
- NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c];
78
- g_free(qemu_image_path_c);
79
- NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path];
80
- [picture_view setImage: qemu_image];
81
- [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown];
82
- [superView addSubview: picture_view];
83
-
84
- /* Make the name label */
85
- NSBundle *bundle = [NSBundle mainBundle];
86
- if (bundle) {
87
- x = 0;
88
- y = y - 25;
89
- int name_width = about_width, name_height = 20;
90
- NSRect name_rect = NSMakeRect(x, y, name_width, name_height);
91
- NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect];
92
- [name_label setEditable: NO];
93
- [name_label setBezeled: NO];
94
- [name_label setDrawsBackground: NO];
95
- [name_label setAlignment: NSTextAlignmentCenter];
96
- NSString *qemu_name = [[bundle executablePath] lastPathComponent];
97
- [name_label setStringValue: qemu_name];
98
- [superView addSubview: name_label];
99
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
100
+ char *icon_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png");
101
+ NSString *icon_path = [NSString stringWithUTF8String:icon_path_c];
102
+ g_free(icon_path_c);
103
+ NSImage *icon = [[NSImage alloc] initWithContentsOfFile:icon_path];
104
+ NSString *version = @"QEMU emulator version " QEMU_FULL_VERSION;
105
+ NSString *copyright = @QEMU_COPYRIGHT;
106
+ NSDictionary *options;
107
+ if (icon) {
108
+ options = @{
109
+ NSAboutPanelOptionApplicationIcon : icon,
110
+ NSAboutPanelOptionApplicationVersion : version,
111
+ @"Copyright" : copyright,
112
+ };
113
+ [icon release];
114
+ } else {
115
+ options = @{
116
+ NSAboutPanelOptionApplicationVersion : version,
117
+ @"Copyright" : copyright,
118
+ };
119
}
120
-
121
- /* Set the version label's attributes */
122
- x = 0;
123
- y = 50;
124
- int version_width = about_width, version_height = 20;
125
- NSRect version_rect = NSMakeRect(x, y, version_width, version_height);
126
- NSTextField *version_label = [[NSTextField alloc] initWithFrame:
127
- version_rect];
128
- [version_label setEditable: NO];
129
- [version_label setBezeled: NO];
130
- [version_label setAlignment: NSTextAlignmentCenter];
131
- [version_label setDrawsBackground: NO];
132
-
133
- /* Create the version string*/
134
- NSString *version_string;
135
- version_string = [[NSString alloc] initWithFormat:
136
- @"QEMU emulator version %s", QEMU_FULL_VERSION];
137
- [version_label setStringValue: version_string];
138
- [superView addSubview: version_label];
139
-
140
- /* Make copyright label */
141
- x = 0;
142
- y = 35;
143
- int copyright_width = about_width, copyright_height = 20;
144
- NSRect copyright_rect = NSMakeRect(x, y, copyright_width, copyright_height);
145
- NSTextField *copyright_label = [[NSTextField alloc] initWithFrame:
146
- copyright_rect];
147
- [copyright_label setEditable: NO];
148
- [copyright_label setBezeled: NO];
149
- [copyright_label setDrawsBackground: NO];
150
- [copyright_label setAlignment: NSTextAlignmentCenter];
151
- [copyright_label setStringValue: [NSString stringWithFormat: @"%s",
152
- QEMU_COPYRIGHT]];
153
- [superView addSubview: copyright_label];
154
+ [NSApp orderFrontStandardAboutPanelWithOptions:options];
155
+ [pool release];
156
}
157
158
/* Used by the Speed menu items */
159
--
160
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
There is a Linux kernel bug present until v5.12 that prevents
4
booting with FEAT_LPA2 enabled. As a workaround for TCG, allow
5
the feature to be disabled from -cpu max.
6
7
Since this kernel bug is present in the Fedora 31 image that
8
we test in avocado, disable lpa2 on the command-line.
9
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/cpu.h | 5 ++++-
15
target/arm/cpu.c | 6 ++++++
16
target/arm/cpu64.c | 24 ++++++++++++++++++++++++
17
tests/avocado/boot_linux.py | 2 ++
18
4 files changed, 36 insertions(+), 1 deletion(-)
19
20
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.h
23
+++ b/target/arm/cpu.h
24
@@ -XXX,XX +XXX,XX @@ typedef struct {
25
# define ARM_MAX_VQ 16
26
void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp);
27
void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp);
28
+void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp);
29
#else
30
# define ARM_MAX_VQ 1
31
static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { }
32
static inline void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { }
33
+static inline void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) { }
34
#endif
35
36
typedef struct ARMVectorReg {
37
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
38
39
/*
40
* Intermediate values used during property parsing.
41
- * Once finalized, the values should be read from ID_AA64ISAR1.
42
+ * Once finalized, the values should be read from ID_AA64*.
43
*/
44
bool prop_pauth;
45
bool prop_pauth_impdef;
46
+ bool prop_lpa2;
47
48
/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */
49
uint32_t dcz_blocksize;
50
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/cpu.c
53
+++ b/target/arm/cpu.c
54
@@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
55
error_propagate(errp, local_err);
56
return;
57
}
58
+
59
+ arm_cpu_lpa2_finalize(cpu, &local_err);
60
+ if (local_err != NULL) {
61
+ error_propagate(errp, local_err);
62
+ return;
63
+ }
64
}
65
66
if (kvm_enabled()) {
67
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/cpu64.c
70
+++ b/target/arm/cpu64.c
71
@@ -XXX,XX +XXX,XX @@ void aarch64_add_pauth_properties(Object *obj)
72
}
73
}
74
75
+static Property arm_cpu_lpa2_property =
76
+ DEFINE_PROP_BOOL("lpa2", ARMCPU, prop_lpa2, true);
77
+
78
+void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp)
79
+{
80
+ uint64_t t;
81
+
82
+ /*
83
+ * We only install the property for tcg -cpu max; this is the
84
+ * only situation in which the cpu field can be true.
85
+ */
86
+ if (!cpu->prop_lpa2) {
87
+ return;
88
+ }
89
+
90
+ t = cpu->isar.id_aa64mmfr0;
91
+ t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16, 2); /* 16k pages w/ LPA2 */
92
+ t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4, 1); /* 4k pages w/ LPA2 */
93
+ t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 3); /* 16k stage2 w/ LPA2 */
94
+ t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 3); /* 4k stage2 w/ LPA2 */
95
+ cpu->isar.id_aa64mmfr0 = t;
96
+}
97
+
98
static void aarch64_host_initfn(Object *obj)
99
{
100
#if defined(CONFIG_KVM)
101
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
102
aarch64_add_sve_properties(obj);
103
object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq,
104
cpu_max_set_sve_max_vq, NULL, NULL);
105
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property);
106
}
107
108
static void aarch64_a64fx_initfn(Object *obj)
109
diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py
110
index XXXXXXX..XXXXXXX 100644
111
--- a/tests/avocado/boot_linux.py
112
+++ b/tests/avocado/boot_linux.py
113
@@ -XXX,XX +XXX,XX @@ def test_virt_tcg_gicv2(self):
114
"""
115
self.require_accelerator("tcg")
116
self.vm.add_args("-accel", "tcg")
117
+ self.vm.add_args("-cpu", "max,lpa2=off")
118
self.vm.add_args("-machine", "virt,gic-version=2")
119
self.add_common_args()
120
self.launch_and_wait(set_up_ssh_connection=False)
121
@@ -XXX,XX +XXX,XX @@ def test_virt_tcg_gicv3(self):
122
"""
123
self.require_accelerator("tcg")
124
self.vm.add_args("-accel", "tcg")
125
+ self.vm.add_args("-cpu", "max,lpa2=off")
126
self.vm.add_args("-machine", "virt,gic-version=3")
127
self.add_common_args()
128
self.launch_and_wait(set_up_ssh_connection=False)
129
--
130
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
There is a Linux kernel bug present until v5.12 that prevents
4
booting with FEAT_LPA2 enabled. As a workaround for TCG,
5
disable this feature for machine versions prior to 7.0.
6
7
Cc: Daniel P. Berrangé <berrange@redhat.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/arm/virt.h | 1 +
13
hw/arm/virt.c | 7 +++++++
14
2 files changed, 8 insertions(+)
15
16
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/virt.h
19
+++ b/include/hw/arm/virt.h
20
@@ -XXX,XX +XXX,XX @@ struct VirtMachineClass {
21
bool no_secure_gpio;
22
/* Machines < 6.2 have no support for describing cpu topology to guest */
23
bool no_cpu_topology;
24
+ bool no_tcg_lpa2;
25
};
26
27
struct VirtMachineState {
28
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/virt.c
31
+++ b/hw/arm/virt.c
32
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
33
object_property_set_bool(cpuobj, "pmu", false, NULL);
34
}
35
36
+ if (vmc->no_tcg_lpa2 && object_property_find(cpuobj, "lpa2")) {
37
+ object_property_set_bool(cpuobj, "lpa2", false, NULL);
38
+ }
39
+
40
if (object_property_find(cpuobj, "reset-cbar")) {
41
object_property_set_int(cpuobj, "reset-cbar",
42
vms->memmap[VIRT_CPUPERIPHS].base,
43
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(7, 0)
44
45
static void virt_machine_6_2_options(MachineClass *mc)
46
{
47
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
48
+
49
virt_machine_7_0_options(mc);
50
compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
51
+ vmc->no_tcg_lpa2 = true;
52
}
53
DEFINE_VIRT_MACHINE(6, 2)
54
55
--
56
2.25.1
57
58
diff view generated by jsdifflib