1
Changes v1->v2: it turns out that the raspi3 support exposes a
1
The following changes since commit b10d00d8811fa4eed4862963273d7353ce310c82:
2
preexisting bug in our register definitions for VMPIDR/VMIDR:
3
https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg04181.html
4
2
5
So I've dropped the final "enable raspi3 board" patch for the
3
Merge remote-tracking branch 'remotes/kraxel/tags/seabios-20220118-pull-request' into staging (2022-01-19 18:46:28 +0000)
6
moment. When that VMIDR/VMPIDR patch gets reviewed we can
7
put the raspi3 patch in with it.
8
9
10
thanks
11
-- PMM
12
13
The following changes since commit f003d07337a6d4d02c43429b26a4270459afb51a:
14
15
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2018-02-15 15:45:33 +0000)
16
4
17
are available in the Git repository at:
5
are available in the Git repository at:
18
6
19
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180215-1
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220120
20
8
21
for you to fetch changes up to bade58166f4466546600d824a2695a00269d10eb:
9
for you to fetch changes up to 9705e3c1dcff96b0b3c7e594b6cd68d27d6c4ced:
22
10
23
raspi: Raspberry Pi 3 support (2018-02-15 18:33:46 +0000)
11
hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR (2022-01-20 11:47:54 +0000)
24
12
25
----------------------------------------------------------------
13
----------------------------------------------------------------
26
target-arm queue:
14
target-arm:
27
* aspeed: code cleanup to use unimplemented_device
15
* hw/intc/arm_gicv3_its: Fix various minor bugs
28
* preparatory work for 'raspi3' RaspberryPi 3 machine model
16
* hw/arm/aspeed: Add the i3c device to the AST2600 SoC
29
* more SVE prep work
17
* hw/arm: kudo: add lm75s behind bus 1 switch at 75
30
* v8M: add minor missing registers
18
* hw/arm/virt: Fix support for running guests on hosts
31
* v7M: fix bug where we weren't migrating v7m.other_sp
19
with restricted IPA ranges
32
* v7M: fix bugs in handling of interrupt registers for
20
* hw/intc/arm_gic: Allow reset of the running priority
33
external interrupts beyond 32
21
* hw/intc/arm_gic: Implement read of GICC_IIDR
22
* hw/arm/virt: Support for virtio-mem-pci
23
* hw/arm/virt: Support CPU cluster on ARM virt machine
24
* docs/can: convert to restructuredText
25
* hw/net: Move MV88W8618 network device out of hw/arm/ directory
26
* hw/arm/virt: KVM: Enable PAuth when supported by the host
34
27
35
----------------------------------------------------------------
28
----------------------------------------------------------------
36
Pekka Enberg (2):
29
Gavin Shan (2):
37
bcm2836: Make CPU type configurable
30
virtio-mem: Correct default THP size for ARM64
38
raspi: Raspberry Pi 3 support
31
hw/arm/virt: Support for virtio-mem-pci
39
32
40
Peter Maydell (11):
33
Lucas Ramage (1):
41
hw/intc/armv7m_nvic: Don't hardcode M profile ID registers in NVIC
34
docs/can: convert to restructuredText
42
hw/intc/armv7m_nvic: Fix ICSR PENDNMISET/CLR handling
43
hw/intc/armv7m_nvic: Implement M profile cache maintenance ops
44
hw/intc/armv7m_nvic: Implement v8M CPPWR register
45
hw/intc/armv7m_nvic: Implement cache ID registers
46
hw/intc/armv7m_nvic: Implement SCR
47
target/arm: Implement writing to CONTROL_NS for v8M
48
hw/intc/armv7m_nvic: Fix byte-to-interrupt number conversions
49
target/arm: Add AIRCR to vmstate struct
50
target/arm: Migrate v7m.other_sp
51
target/arm: Implement v8M MSPLIM and PSPLIM registers
52
35
53
Philippe Mathieu-Daudé (2):
36
Marc Zyngier (7):
54
hw/arm/aspeed: directly map the serial device to the system address space
37
hw/arm/virt: KVM: Enable PAuth when supported by the host
55
hw/arm/aspeed: simplify using the 'unimplemented device' for aspeed_soc.io
38
hw/arm/virt: Add a control for the the highmem PCIe MMIO
39
hw/arm/virt: Add a control for the the highmem redistributors
40
hw/arm/virt: Honor highmem setting when computing the memory map
41
hw/arm/virt: Use the PA range to compute the memory map
42
hw/arm/virt: Disable highmem devices that don't fit in the PA range
43
hw/arm/virt: Drop superfluous checks against highmem
56
44
57
Richard Henderson (5):
45
Patrick Venture (1):
58
target/arm: Remove ARM_CP_64BIT from ZCR_EL registers
46
hw/arm: kudo add lm75s behind bus 1 switch at 75
59
target/arm: Enforce FP access to FPCR/FPSR
60
target/arm: Suppress TB end for FPCR/FPSR
61
target/arm: Enforce access to ZCR_EL at translation
62
target/arm: Handle SVE registers when using clear_vec_high
63
47
64
include/hw/arm/aspeed_soc.h | 1 -
48
Peter Maydell (13):
65
include/hw/arm/bcm2836.h | 1 +
49
hw/intc/arm_gicv3_its: Fix event ID bounds checks
66
target/arm/cpu.h | 71 ++++++++++++-----
50
hw/intc/arm_gicv3_its: Convert int ID check to num_intids convention
67
target/arm/internals.h | 6 ++
51
hw/intc/arm_gicv3_its: Fix handling of process_its_cmd() return value
68
hw/arm/aspeed_soc.c | 35 ++-------
52
hw/intc/arm_gicv3_its: Don't use data if reading command failed
69
hw/arm/bcm2836.c | 17 +++--
53
hw/intc/arm_gicv3_its: Use enum for return value of process_* functions
70
hw/arm/raspi.c | 34 ++++++---
54
hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd()
71
hw/intc/armv7m_nvic.c | 98 ++++++++++++++++++------
55
hw/intc/arm_gicv3_its: Refactor process_its_cmd() to reduce nesting
72
target/arm/cpu.c | 28 +++++++
56
hw/intc/arm_gicv3_its: Fix return codes in process_mapti()
73
target/arm/helper.c | 84 +++++++++++++++-----
57
hw/intc/arm_gicv3_its: Fix return codes in process_mapc()
74
target/arm/machine.c | 84 ++++++++++++++++++++
58
hw/intc/arm_gicv3_its: Fix return codes in process_mapd()
75
target/arm/translate-a64.c | 181 ++++++++++++++++++++------------------------
59
hw/intc/arm_gicv3_its: Factor out "find address of table entry" code
76
12 files changed, 429 insertions(+), 211 deletions(-)
60
hw/intc/arm_gicv3_its: Check indexes before use, not after
61
hw/intc/arm_gicv3_its: Range-check ICID before indexing into collection table
77
62
63
Petr Pavlu (2):
64
hw/intc/arm_gic: Implement read of GICC_IIDR
65
hw/intc/arm_gic: Allow reset of the running priority
66
67
Philippe Mathieu-Daudé (4):
68
hw: Move MARVELL_88W8618 Kconfig from audio/ to arm/
69
hw/arm/musicpal: Fix coding style of code related to MV88W8618 device
70
hw/net: Move MV88W8618 network device out of hw/arm/ directory
71
hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR
72
73
Troy Lee (2):
74
hw/misc/aspeed_i3c.c: Introduce a dummy AST2600 I3C model.
75
hw/arm/aspeed: Add the i3c device to the AST2600 SoC
76
77
Yanan Wang (6):
78
hw/arm/virt: Support CPU cluster on ARM virt machine
79
hw/arm/virt: Support cluster level in DT cpu-map
80
hw/acpi/aml-build: Improve scalability of PPTT generation
81
tests/acpi/bios-tables-test: Allow changes to virt/PPTT file
82
hw/acpi/aml-build: Support cluster level in PPTT generation
83
tests/acpi/bios-table-test: Update expected virt/PPTT file
84
85
docs/system/arm/cpu-features.rst | 4 -
86
docs/system/device-emulation.rst | 1 +
87
docs/{can.txt => system/devices/can.rst} | 90 +++---
88
include/hw/arm/aspeed_soc.h | 3 +
89
include/hw/arm/virt.h | 5 +-
90
include/hw/misc/aspeed_i3c.h | 48 +++
91
include/hw/net/mv88w8618_eth.h | 12 +
92
target/arm/cpu.h | 1 +
93
hw/acpi/aml-build.c | 68 +++--
94
hw/arm/aspeed_ast2600.c | 16 +
95
hw/arm/musicpal.c | 381 +-----------------------
96
hw/arm/npcm7xx_boards.c | 10 +-
97
hw/arm/virt-acpi-build.c | 10 +-
98
hw/arm/virt.c | 184 ++++++++++--
99
hw/intc/arm_gic.c | 11 +
100
hw/intc/arm_gicv3_its.c | 492 ++++++++++++++-----------------
101
hw/intc/arm_gicv3_redist.c | 4 +-
102
hw/misc/aspeed_i3c.c | 381 ++++++++++++++++++++++++
103
hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++
104
hw/virtio/virtio-mem.c | 36 ++-
105
target/arm/cpu.c | 16 +-
106
target/arm/cpu64.c | 31 +-
107
target/arm/kvm64.c | 21 ++
108
MAINTAINERS | 2 +
109
hw/arm/Kconfig | 4 +
110
hw/audio/Kconfig | 3 -
111
hw/misc/meson.build | 1 +
112
hw/misc/trace-events | 6 +
113
hw/net/meson.build | 1 +
114
qemu-options.hx | 10 +
115
tests/data/acpi/virt/PPTT | Bin 76 -> 96 bytes
116
31 files changed, 1473 insertions(+), 782 deletions(-)
117
rename docs/{can.txt => system/devices/can.rst} (68%)
118
create mode 100644 include/hw/misc/aspeed_i3c.h
119
create mode 100644 include/hw/net/mv88w8618_eth.h
120
create mode 100644 hw/misc/aspeed_i3c.c
121
create mode 100644 hw/net/mv88w8618_eth.c
122
diff view generated by jsdifflib
1
The v8M architecture includes hardware support for enforcing
1
From: Marc Zyngier <maz@kernel.org>
2
stack pointer limits. We don't implement this behaviour yet,
2
3
but provide the MSPLIM and PSPLIM stack pointer limit registers
3
Add basic support for Pointer Authentication when running a KVM
4
as reads-as-written, so that when we do implement the checks
4
guest and that the host supports it, loosely based on the SVE
5
in future this won't break guest migration.
5
support.
6
6
7
Although the feature is enabled by default when the host advertises
8
it, it is possible to disable it by setting the 'pauth=off' CPU
9
property. The 'pauth' comment is removed from cpu-features.rst,
10
as it is now common to both TCG and KVM.
11
12
Tested on an Apple M1 running 5.16-rc6.
13
14
Cc: Eric Auger <eric.auger@redhat.com>
15
Cc: Richard Henderson <richard.henderson@linaro.org>
16
Cc: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Andrew Jones <drjones@redhat.com>
18
Signed-off-by: Marc Zyngier <maz@kernel.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20220107150154.2490308-1-maz@kernel.org
21
[PMM: fixed indentation]
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180209165810.6668-12-peter.maydell@linaro.org
10
---
23
---
11
target/arm/cpu.h | 2 ++
24
docs/system/arm/cpu-features.rst | 4 ----
12
target/arm/helper.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
25
target/arm/cpu.h | 1 +
13
target/arm/machine.c | 21 +++++++++++++++++++++
26
target/arm/cpu.c | 16 +++++-----------
14
3 files changed, 69 insertions(+)
27
target/arm/cpu64.c | 31 +++++++++++++++++++++++++++----
15
28
target/arm/kvm64.c | 21 +++++++++++++++++++++
29
5 files changed, 54 insertions(+), 19 deletions(-)
30
31
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
32
index XXXXXXX..XXXXXXX 100644
33
--- a/docs/system/arm/cpu-features.rst
34
+++ b/docs/system/arm/cpu-features.rst
35
@@ -XXX,XX +XXX,XX @@ TCG VCPU Features
36
TCG VCPU features are CPU features that are specific to TCG.
37
Below is the list of TCG VCPU features and their descriptions.
38
39
- pauth Enable or disable ``FEAT_Pauth``, pointer
40
- authentication. By default, the feature is
41
- enabled with ``-cpu max``.
42
-
43
pauth-impdef When ``FEAT_Pauth`` is enabled, either the
44
*impdef* (Implementation Defined) algorithm
45
is enabled or the *architected* QARMA algorithm
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
46
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
48
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
49
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
50
@@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
21
uint32_t secure; /* Is CPU in Secure state? (not guest visible) */
51
void aarch64_sve_change_el(CPUARMState *env, int old_el,
22
uint32_t csselr[M_REG_NUM_BANKS];
52
int new_el, bool el0_a64);
23
uint32_t scr[M_REG_NUM_BANKS];
53
void aarch64_add_sve_properties(Object *obj);
24
+ uint32_t msplim[M_REG_NUM_BANKS];
54
+void aarch64_add_pauth_properties(Object *obj);
25
+ uint32_t psplim[M_REG_NUM_BANKS];
55
26
} v7m;
56
/*
27
57
* SVE registers are encoded in KVM's memory in an endianness-invariant format.
28
/* Information associated with an exception about to be taken:
58
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
29
diff --git a/target/arm/helper.c b/target/arm/helper.c
59
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/cpu.c
31
--- a/target/arm/helper.c
61
+++ b/target/arm/cpu.c
32
+++ b/target/arm/helper.c
62
@@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
33
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
63
return;
34
return 0;
64
}
35
}
65
36
return env->v7m.other_ss_psp;
66
- /*
37
+ case 0x8a: /* MSPLIM_NS */
67
- * KVM does not support modifications to this feature.
38
+ if (!env->v7m.secure) {
68
- * We have not registered the cpu properties when KVM
39
+ return 0;
69
- * is in use, so the user will not be able to set them.
40
+ }
70
- */
41
+ return env->v7m.msplim[M_REG_NS];
71
- if (!kvm_enabled()) {
42
+ case 0x8b: /* PSPLIM_NS */
72
- arm_cpu_pauth_finalize(cpu, &local_err);
43
+ if (!env->v7m.secure) {
73
- if (local_err != NULL) {
44
+ return 0;
74
- error_propagate(errp, local_err);
45
+ }
75
- return;
46
+ return env->v7m.psplim[M_REG_NS];
76
- }
47
case 0x90: /* PRIMASK_NS */
77
+ arm_cpu_pauth_finalize(cpu, &local_err);
48
if (!env->v7m.secure) {
78
+ if (local_err != NULL) {
49
return 0;
79
+ error_propagate(errp, local_err);
50
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
80
+ return;
51
return v7m_using_psp(env) ? env->v7m.other_sp : env->regs[13];
81
}
52
case 9: /* PSP */
82
}
53
return v7m_using_psp(env) ? env->regs[13] : env->v7m.other_sp;
83
54
+ case 10: /* MSPLIM */
84
@@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj)
55
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
85
kvm_arm_set_cpu_features_from_host(cpu);
56
+ goto bad_reg;
86
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
87
aarch64_add_sve_properties(obj);
88
+ aarch64_add_pauth_properties(obj);
89
}
90
#else
91
hvf_arm_set_cpu_features_from_host(cpu);
92
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/target/arm/cpu64.c
95
+++ b/target/arm/cpu64.c
96
@@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
97
int arch_val = 0, impdef_val = 0;
98
uint64_t t;
99
100
+ /* Exit early if PAuth is enabled, and fall through to disable it */
101
+ if (kvm_enabled() && cpu->prop_pauth) {
102
+ if (!cpu_isar_feature(aa64_pauth, cpu)) {
103
+ error_setg(errp, "'pauth' feature not supported by KVM on this host");
57
+ }
104
+ }
58
+ return env->v7m.msplim[env->v7m.secure];
105
+
59
+ case 11: /* PSPLIM */
106
+ return;
60
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
107
+ }
61
+ goto bad_reg;
108
+
62
+ }
109
/* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */
63
+ return env->v7m.psplim[env->v7m.secure];
110
if (cpu->prop_pauth) {
64
case 16: /* PRIMASK */
111
if (cpu->prop_pauth_impdef) {
65
return env->v7m.primask[env->v7m.secure];
112
@@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pauth_property =
66
case 17: /* BASEPRI */
113
static Property arm_cpu_pauth_impdef_property =
67
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
114
DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
68
case 19: /* FAULTMASK */
115
69
return env->v7m.faultmask[env->v7m.secure];
116
+void aarch64_add_pauth_properties(Object *obj)
70
default:
71
+ bad_reg:
72
qemu_log_mask(LOG_GUEST_ERROR, "Attempt to read unknown special"
73
" register %d\n", reg);
74
return 0;
75
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
76
}
77
env->v7m.other_ss_psp = val;
78
return;
79
+ case 0x8a: /* MSPLIM_NS */
80
+ if (!env->v7m.secure) {
81
+ return;
82
+ }
83
+ env->v7m.msplim[M_REG_NS] = val & ~7;
84
+ return;
85
+ case 0x8b: /* PSPLIM_NS */
86
+ if (!env->v7m.secure) {
87
+ return;
88
+ }
89
+ env->v7m.psplim[M_REG_NS] = val & ~7;
90
+ return;
91
case 0x90: /* PRIMASK_NS */
92
if (!env->v7m.secure) {
93
return;
94
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
95
env->v7m.other_sp = val;
96
}
97
break;
98
+ case 10: /* MSPLIM */
99
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
100
+ goto bad_reg;
101
+ }
102
+ env->v7m.msplim[env->v7m.secure] = val & ~7;
103
+ break;
104
+ case 11: /* PSPLIM */
105
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
106
+ goto bad_reg;
107
+ }
108
+ env->v7m.psplim[env->v7m.secure] = val & ~7;
109
+ break;
110
case 16: /* PRIMASK */
111
env->v7m.primask[env->v7m.secure] = val & 1;
112
break;
113
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
114
env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK;
115
break;
116
default:
117
+ bad_reg:
118
qemu_log_mask(LOG_GUEST_ERROR, "Attempt to write unknown special"
119
" register %d\n", reg);
120
return;
121
diff --git a/target/arm/machine.c b/target/arm/machine.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/target/arm/machine.c
124
+++ b/target/arm/machine.c
125
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_other_sp = {
126
}
127
};
128
129
+static bool m_v8m_needed(void *opaque)
130
+{
117
+{
131
+ ARMCPU *cpu = opaque;
118
+ ARMCPU *cpu = ARM_CPU(obj);
132
+ CPUARMState *env = &cpu->env;
119
+
133
+
120
+ /* Default to PAUTH on, with the architected algorithm on TCG. */
134
+ return arm_feature(env, ARM_FEATURE_M) && arm_feature(env, ARM_FEATURE_V8);
121
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
122
+ if (kvm_enabled()) {
123
+ /*
124
+ * Mirror PAuth support from the probed sysregs back into the
125
+ * property for KVM. Is it just a bit backward? Yes it is!
126
+ */
127
+ cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu);
128
+ } else {
129
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
130
+ }
135
+}
131
+}
136
+
132
+
137
+static const VMStateDescription vmstate_m_v8m = {
133
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
138
+ .name = "cpu/m/v8m",
134
* otherwise, a CPU with as many features enabled as our emulation supports.
139
+ .version_id = 1,
135
* The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
140
+ .minimum_version_id = 1,
136
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
141
+ .needed = m_v8m_needed,
137
cpu->dcz_blocksize = 7; /* 512 bytes */
142
+ .fields = (VMStateField[]) {
138
#endif
143
+ VMSTATE_UINT32_ARRAY(env.v7m.msplim, ARMCPU, M_REG_NUM_BANKS),
139
144
+ VMSTATE_UINT32_ARRAY(env.v7m.psplim, ARMCPU, M_REG_NUM_BANKS),
140
- /* Default to PAUTH on, with the architected algorithm. */
145
+ VMSTATE_END_OF_LIST()
141
- qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
146
+ }
142
- qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
147
+};
143
-
148
+
144
bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ);
149
static const VMStateDescription vmstate_m = {
145
}
150
.name = "cpu/m",
146
151
.version_id = 4,
147
+ aarch64_add_pauth_properties(obj);
152
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
148
aarch64_add_sve_properties(obj);
153
&vmstate_m_csselr,
149
object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq,
154
&vmstate_m_scr,
150
cpu_max_set_sve_max_vq, NULL, NULL);
155
&vmstate_m_other_sp,
151
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
156
+ &vmstate_m_v8m,
152
index XXXXXXX..XXXXXXX 100644
157
NULL
153
--- a/target/arm/kvm64.c
158
}
154
+++ b/target/arm/kvm64.c
159
};
155
@@ -XXX,XX +XXX,XX @@ static int read_sys_reg64(int fd, uint64_t *pret, uint64_t id)
156
return ioctl(fd, KVM_GET_ONE_REG, &idreg);
157
}
158
159
+static bool kvm_arm_pauth_supported(void)
160
+{
161
+ return (kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_ADDRESS) &&
162
+ kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC));
163
+}
164
+
165
bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
166
{
167
/* Identify the feature bits corresponding to the host CPU, and
168
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
169
*/
170
struct kvm_vcpu_init init = { .target = -1, };
171
172
+ /*
173
+ * Ask for Pointer Authentication if supported. We can't play the
174
+ * SVE trick of synthesising the ID reg as KVM won't tell us
175
+ * whether we have the architected or IMPDEF version of PAuth, so
176
+ * we have to use the actual ID regs.
177
+ */
178
+ if (kvm_arm_pauth_supported()) {
179
+ init.features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
180
+ 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
181
+ }
182
+
183
if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) {
184
return false;
185
}
186
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
187
assert(kvm_arm_sve_supported());
188
cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE;
189
}
190
+ if (cpu_isar_feature(aa64_pauth, cpu)) {
191
+ cpu->kvm_init_features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
192
+ 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
193
+ }
194
195
/* Do KVM_ARM_VCPU_INIT ioctl */
196
ret = kvm_arm_vcpu_init(cs);
160
--
197
--
161
2.16.1
198
2.25.1
162
199
163
200
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
2
3
The Marvell 88W8618 is a system-on-chip with an ARM core.
4
We implement its audio codecs and network interface.
5
Homogeneous SoC Kconfig are usually defined in the hw/$ARCH
6
directory. Move it there.
7
8
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20220107184429.423572-2-f4bug@amsat.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/arm/Kconfig | 3 +++
15
hw/audio/Kconfig | 3 ---
16
2 files changed, 3 insertions(+), 3 deletions(-)
17
18
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/Kconfig
21
+++ b/hw/arm/Kconfig
22
@@ -XXX,XX +XXX,XX @@ config MUSCA
23
select SPLIT_IRQ
24
select UNIMP
25
26
+config MARVELL_88W8618
27
+ bool
28
+
29
config MUSICPAL
30
bool
31
select OR_IRQ
32
diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/audio/Kconfig
35
+++ b/hw/audio/Kconfig
36
@@ -XXX,XX +XXX,XX @@ config PL041
37
38
config CS4231
39
bool
40
-
41
-config MARVELL_88W8618
42
- bool
43
--
44
2.25.1
45
46
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
(qemu) info mtree
3
We are going to move this code, so fix its style first to avoid:
4
address-space: cpu-memory-0
5
0000000000000000-ffffffffffffffff (prio 0, i/o): system
6
0000000000000000-0000000007ffffff (prio 0, rom): aspeed.boot_rom
7
000000001e600000-000000001e7fffff (prio -1, i/o): aspeed_soc.io
8
- 000000001e784000-000000001e78401f (prio 0, i/o): serial
9
000000001e620000-000000001e6200ff (prio 0, i/o): aspeed.smc.ast2500-fmc
10
000000001e630000-000000001e6300ff (prio 0, i/o): aspeed.smc.ast2500-spi1
11
[...]
12
000000001e720000-000000001e728fff (prio 0, ram): aspeed.sram
13
000000001e782000-000000001e782fff (prio 0, i/o): aspeed.timer
14
+ 000000001e784000-000000001e78401f (prio 0, i/o): serial
15
000000001e785000-000000001e78501f (prio 0, i/o): aspeed.wdt
16
000000001e785020-000000001e78503f (prio 0, i/o): aspeed.wdt
17
4
5
ERROR: spaces required around that '/' (ctx:VxV)
6
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Message-id: 20220107184429.423572-3-f4bug@amsat.org
20
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
21
Message-id: 20180209085755.30414-2-f4bug@amsat.org
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
11
---
24
hw/arm/aspeed_soc.c | 3 ++-
12
hw/arm/musicpal.c | 14 +++++++-------
25
1 file changed, 2 insertions(+), 1 deletion(-)
13
1 file changed, 7 insertions(+), 7 deletions(-)
26
14
27
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
15
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
28
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/arm/aspeed_soc.c
17
--- a/hw/arm/musicpal.c
30
+++ b/hw/arm/aspeed_soc.c
18
+++ b/hw/arm/musicpal.c
31
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
19
@@ -XXX,XX +XXX,XX @@ static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
32
/* UART - attach an 8250 to the IO space as our UART5 */
20
return s->imr;
33
if (serial_hds[0]) {
21
34
qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
22
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
35
- serial_mm_init(&s->iomem, ASPEED_SOC_UART_5_BASE, 2,
23
- return s->frx_queue[(offset - MP_ETH_FRDP0)/4];
36
+ serial_mm_init(get_system_memory(),
24
+ return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
37
+ ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2,
25
38
uart5, 38400, serial_hds[0], DEVICE_LITTLE_ENDIAN);
26
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
27
- return s->rx_queue[(offset - MP_ETH_CRDP0)/4];
28
+ return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
29
30
case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
31
- return s->tx_queue[(offset - MP_ETH_CTDP0)/4];
32
+ return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
33
34
default:
35
return 0;
36
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_eth_write(void *opaque, hwaddr offset,
37
break;
38
39
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
40
- s->frx_queue[(offset - MP_ETH_FRDP0)/4] = value;
41
+ s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
42
break;
43
44
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
45
- s->rx_queue[(offset - MP_ETH_CRDP0)/4] =
46
- s->cur_rx[(offset - MP_ETH_CRDP0)/4] = value;
47
+ s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
48
+ s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
49
break;
50
51
case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
52
- s->tx_queue[(offset - MP_ETH_CTDP0)/4] = value;
53
+ s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
54
break;
39
}
55
}
40
56
}
41
--
57
--
42
2.16.1
58
2.25.1
43
59
44
60
diff view generated by jsdifflib
1
We were previously making the system control register (SCR)
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
just RAZ/WI. Although we don't implement the functionality
3
this register controls, we should at least provide the state,
4
including the banked state for v8M.
5
2
3
The Marvell 88W8618 network device is hidden in the Musicpal
4
machine. Move it into a new unit file under the hw/net/ directory.
5
6
Acked-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220107184429.423572-4-f4bug@amsat.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180209165810.6668-7-peter.maydell@linaro.org
9
---
11
---
10
target/arm/cpu.h | 7 +++++++
12
include/hw/net/mv88w8618_eth.h | 12 +
11
hw/intc/armv7m_nvic.c | 12 ++++++++----
13
hw/arm/musicpal.c | 381 +------------------------------
12
target/arm/machine.c | 12 ++++++++++++
14
hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++++++++++
13
3 files changed, 27 insertions(+), 4 deletions(-)
15
MAINTAINERS | 2 +
16
hw/net/meson.build | 1 +
17
5 files changed, 419 insertions(+), 380 deletions(-)
18
create mode 100644 include/hw/net/mv88w8618_eth.h
19
create mode 100644 hw/net/mv88w8618_eth.c
14
20
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
diff --git a/include/hw/net/mv88w8618_eth.h b/include/hw/net/mv88w8618_eth.h
22
new file mode 100644
23
index XXXXXXX..XXXXXXX
24
--- /dev/null
25
+++ b/include/hw/net/mv88w8618_eth.h
26
@@ -XXX,XX +XXX,XX @@
27
+/* SPDX-License-Identifier: GPL-2.0-or-later */
28
+/*
29
+ * Marvell MV88W8618 / Freecom MusicPal emulation.
30
+ *
31
+ * Copyright (c) 2008-2021 QEMU contributors
32
+ */
33
+#ifndef HW_NET_MV88W8618_H
34
+#define HW_NET_MV88W8618_H
35
+
36
+#define TYPE_MV88W8618_ETH "mv88w8618_eth"
37
+
38
+#endif
39
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
16
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.h
41
--- a/hw/arm/musicpal.c
18
+++ b/target/arm/cpu.h
42
+++ b/hw/arm/musicpal.c
19
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
43
@@ -XXX,XX +XXX,XX @@
20
uint32_t aircr; /* only holds r/w state if security extn implemented */
44
#include "ui/pixel_ops.h"
21
uint32_t secure; /* Is CPU in Secure state? (not guest visible) */
45
#include "qemu/cutils.h"
22
uint32_t csselr[M_REG_NUM_BANKS];
46
#include "qom/object.h"
23
+ uint32_t scr[M_REG_NUM_BANKS];
47
+#include "hw/net/mv88w8618_eth.h"
24
} v7m;
48
25
49
#define MP_MISC_BASE 0x80002000
26
/* Information associated with an exception about to be taken:
50
#define MP_MISC_SIZE 0x00001000
27
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_CCR, STKALIGN, 9, 1)
51
28
FIELD(V7M_CCR, DC, 16, 1)
52
#define MP_ETH_BASE 0x80008000
29
FIELD(V7M_CCR, IC, 17, 1)
53
-#define MP_ETH_SIZE 0x00001000
30
54
31
+/* V7M SCR bits */
55
#define MP_WLAN_BASE 0x8000C000
32
+FIELD(V7M_SCR, SLEEPONEXIT, 1, 1)
56
#define MP_WLAN_SIZE 0x00000800
33
+FIELD(V7M_SCR, SLEEPDEEP, 2, 1)
57
@@ -XXX,XX +XXX,XX @@
34
+FIELD(V7M_SCR, SLEEPDEEPS, 3, 1)
58
/* Wolfson 8750 I2C address */
35
+FIELD(V7M_SCR, SEVONPEND, 4, 1)
59
#define MP_WM_ADDR 0x1A
36
+
60
37
/* V7M AIRCR bits */
61
-/* Ethernet register offsets */
38
FIELD(V7M_AIRCR, VECTRESET, 0, 1)
62
-#define MP_ETH_SMIR 0x010
39
FIELD(V7M_AIRCR, VECTCLRACTIVE, 1, 1)
63
-#define MP_ETH_PCXR 0x408
40
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
64
-#define MP_ETH_SDCMR 0x448
41
index XXXXXXX..XXXXXXX 100644
65
-#define MP_ETH_ICR 0x450
42
--- a/hw/intc/armv7m_nvic.c
66
-#define MP_ETH_IMR 0x458
43
+++ b/hw/intc/armv7m_nvic.c
67
-#define MP_ETH_FRDP0 0x480
44
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
68
-#define MP_ETH_FRDP1 0x484
45
}
69
-#define MP_ETH_FRDP2 0x488
46
return val;
70
-#define MP_ETH_FRDP3 0x48C
47
case 0xd10: /* System Control. */
71
-#define MP_ETH_CRDP0 0x4A0
48
- /* TODO: Implement SLEEPONEXIT. */
72
-#define MP_ETH_CRDP1 0x4A4
73
-#define MP_ETH_CRDP2 0x4A8
74
-#define MP_ETH_CRDP3 0x4AC
75
-#define MP_ETH_CTDP0 0x4E0
76
-#define MP_ETH_CTDP1 0x4E4
77
-
78
-/* MII PHY access */
79
-#define MP_ETH_SMIR_DATA 0x0000FFFF
80
-#define MP_ETH_SMIR_ADDR 0x03FF0000
81
-#define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */
82
-#define MP_ETH_SMIR_RDVALID (1 << 27)
83
-
84
-/* PHY registers */
85
-#define MP_ETH_PHY1_BMSR 0x00210000
86
-#define MP_ETH_PHY1_PHYSID1 0x00410000
87
-#define MP_ETH_PHY1_PHYSID2 0x00610000
88
-
89
-#define MP_PHY_BMSR_LINK 0x0004
90
-#define MP_PHY_BMSR_AUTONEG 0x0008
91
-
92
-#define MP_PHY_88E3015 0x01410E20
93
-
94
-/* TX descriptor status */
95
-#define MP_ETH_TX_OWN (1U << 31)
96
-
97
-/* RX descriptor status */
98
-#define MP_ETH_RX_OWN (1U << 31)
99
-
100
-/* Interrupt cause/mask bits */
101
-#define MP_ETH_IRQ_RX_BIT 0
102
-#define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT)
103
-#define MP_ETH_IRQ_TXHI_BIT 2
104
-#define MP_ETH_IRQ_TXLO_BIT 3
105
-
106
-/* Port config bits */
107
-#define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */
108
-
109
-/* SDMA command bits */
110
-#define MP_ETH_CMD_TXHI (1 << 23)
111
-#define MP_ETH_CMD_TXLO (1 << 22)
112
-
113
-typedef struct mv88w8618_tx_desc {
114
- uint32_t cmdstat;
115
- uint16_t res;
116
- uint16_t bytes;
117
- uint32_t buffer;
118
- uint32_t next;
119
-} mv88w8618_tx_desc;
120
-
121
-typedef struct mv88w8618_rx_desc {
122
- uint32_t cmdstat;
123
- uint16_t bytes;
124
- uint16_t buffer_size;
125
- uint32_t buffer;
126
- uint32_t next;
127
-} mv88w8618_rx_desc;
128
-
129
-#define TYPE_MV88W8618_ETH "mv88w8618_eth"
130
-OBJECT_DECLARE_SIMPLE_TYPE(mv88w8618_eth_state, MV88W8618_ETH)
131
-
132
-struct mv88w8618_eth_state {
133
- /*< private >*/
134
- SysBusDevice parent_obj;
135
- /*< public >*/
136
-
137
- MemoryRegion iomem;
138
- qemu_irq irq;
139
- MemoryRegion *dma_mr;
140
- AddressSpace dma_as;
141
- uint32_t smir;
142
- uint32_t icr;
143
- uint32_t imr;
144
- int mmio_index;
145
- uint32_t vlan_header;
146
- uint32_t tx_queue[2];
147
- uint32_t rx_queue[4];
148
- uint32_t frx_queue[4];
149
- uint32_t cur_rx[4];
150
- NICState *nic;
151
- NICConf conf;
152
-};
153
-
154
-static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr,
155
- mv88w8618_rx_desc *desc)
156
-{
157
- cpu_to_le32s(&desc->cmdstat);
158
- cpu_to_le16s(&desc->bytes);
159
- cpu_to_le16s(&desc->buffer_size);
160
- cpu_to_le32s(&desc->buffer);
161
- cpu_to_le32s(&desc->next);
162
- dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
163
-}
164
-
165
-static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
166
- mv88w8618_rx_desc *desc)
167
-{
168
- dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
169
- le32_to_cpus(&desc->cmdstat);
170
- le16_to_cpus(&desc->bytes);
171
- le16_to_cpus(&desc->buffer_size);
172
- le32_to_cpus(&desc->buffer);
173
- le32_to_cpus(&desc->next);
174
-}
175
-
176
-static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
177
-{
178
- mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
179
- uint32_t desc_addr;
180
- mv88w8618_rx_desc desc;
181
- int i;
182
-
183
- for (i = 0; i < 4; i++) {
184
- desc_addr = s->cur_rx[i];
185
- if (!desc_addr) {
186
- continue;
187
- }
188
- do {
189
- eth_rx_desc_get(&s->dma_as, desc_addr, &desc);
190
- if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
191
- dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header,
192
- buf, size, MEMTXATTRS_UNSPECIFIED);
193
- desc.bytes = size + s->vlan_header;
194
- desc.cmdstat &= ~MP_ETH_RX_OWN;
195
- s->cur_rx[i] = desc.next;
196
-
197
- s->icr |= MP_ETH_IRQ_RX;
198
- if (s->icr & s->imr) {
199
- qemu_irq_raise(s->irq);
200
- }
201
- eth_rx_desc_put(&s->dma_as, desc_addr, &desc);
202
- return size;
203
- }
204
- desc_addr = desc.next;
205
- } while (desc_addr != s->rx_queue[i]);
206
- }
207
- return size;
208
-}
209
-
210
-static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr,
211
- mv88w8618_tx_desc *desc)
212
-{
213
- cpu_to_le32s(&desc->cmdstat);
214
- cpu_to_le16s(&desc->res);
215
- cpu_to_le16s(&desc->bytes);
216
- cpu_to_le32s(&desc->buffer);
217
- cpu_to_le32s(&desc->next);
218
- dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
219
-}
220
-
221
-static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr,
222
- mv88w8618_tx_desc *desc)
223
-{
224
- dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
225
- le32_to_cpus(&desc->cmdstat);
226
- le16_to_cpus(&desc->res);
227
- le16_to_cpus(&desc->bytes);
228
- le32_to_cpus(&desc->buffer);
229
- le32_to_cpus(&desc->next);
230
-}
231
-
232
-static void eth_send(mv88w8618_eth_state *s, int queue_index)
233
-{
234
- uint32_t desc_addr = s->tx_queue[queue_index];
235
- mv88w8618_tx_desc desc;
236
- uint32_t next_desc;
237
- uint8_t buf[2048];
238
- int len;
239
-
240
- do {
241
- eth_tx_desc_get(&s->dma_as, desc_addr, &desc);
242
- next_desc = desc.next;
243
- if (desc.cmdstat & MP_ETH_TX_OWN) {
244
- len = desc.bytes;
245
- if (len < 2048) {
246
- dma_memory_read(&s->dma_as, desc.buffer, buf, len,
247
- MEMTXATTRS_UNSPECIFIED);
248
- qemu_send_packet(qemu_get_queue(s->nic), buf, len);
249
- }
250
- desc.cmdstat &= ~MP_ETH_TX_OWN;
251
- s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
252
- eth_tx_desc_put(&s->dma_as, desc_addr, &desc);
253
- }
254
- desc_addr = next_desc;
255
- } while (desc_addr != s->tx_queue[queue_index]);
256
-}
257
-
258
-static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
259
- unsigned size)
260
-{
261
- mv88w8618_eth_state *s = opaque;
262
-
263
- switch (offset) {
264
- case MP_ETH_SMIR:
265
- if (s->smir & MP_ETH_SMIR_OPCODE) {
266
- switch (s->smir & MP_ETH_SMIR_ADDR) {
267
- case MP_ETH_PHY1_BMSR:
268
- return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
269
- MP_ETH_SMIR_RDVALID;
270
- case MP_ETH_PHY1_PHYSID1:
271
- return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
272
- case MP_ETH_PHY1_PHYSID2:
273
- return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
274
- default:
275
- return MP_ETH_SMIR_RDVALID;
276
- }
277
- }
49
- return 0;
278
- return 0;
50
+ return cpu->env.v7m.scr[attrs.secure];
279
-
51
case 0xd14: /* Configuration Control. */
280
- case MP_ETH_ICR:
52
/* The BFHFNMIGN bit is the only non-banked bit; we
281
- return s->icr;
53
* keep it in the non-secure copy of the register.
282
-
54
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
283
- case MP_ETH_IMR:
55
}
284
- return s->imr;
56
break;
285
-
57
case 0xd10: /* System Control. */
286
- case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
58
- /* TODO: Implement control registers. */
287
- return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
59
- qemu_log_mask(LOG_UNIMP, "NVIC: SCR unimplemented\n");
288
-
60
+ /* We don't implement deep-sleep so these bits are RAZ/WI.
289
- case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
61
+ * The other bits in the register are banked.
290
- return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
62
+ * QEMU's implementation ignores SEVONPEND and SLEEPONEXIT, which
291
-
63
+ * is architecturally permitted.
292
- case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
64
+ */
293
- return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
65
+ value &= ~(R_V7M_SCR_SLEEPDEEP_MASK | R_V7M_SCR_SLEEPDEEPS_MASK);
294
-
66
+ cpu->env.v7m.scr[attrs.secure] = value;
295
- default:
67
break;
296
- return 0;
68
case 0xd14: /* Configuration Control. */
297
- }
69
/* Enforce RAZ/WI on reserved and must-RAZ/WI bits */
298
-}
70
diff --git a/target/arm/machine.c b/target/arm/machine.c
299
-
71
index XXXXXXX..XXXXXXX 100644
300
-static void mv88w8618_eth_write(void *opaque, hwaddr offset,
72
--- a/target/arm/machine.c
301
- uint64_t value, unsigned size)
73
+++ b/target/arm/machine.c
302
-{
74
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_csselr = {
303
- mv88w8618_eth_state *s = opaque;
75
}
304
-
76
};
305
- switch (offset) {
77
306
- case MP_ETH_SMIR:
78
+static const VMStateDescription vmstate_m_scr = {
307
- s->smir = value;
79
+ .name = "cpu/m/scr",
308
- break;
309
-
310
- case MP_ETH_PCXR:
311
- s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2;
312
- break;
313
-
314
- case MP_ETH_SDCMR:
315
- if (value & MP_ETH_CMD_TXHI) {
316
- eth_send(s, 1);
317
- }
318
- if (value & MP_ETH_CMD_TXLO) {
319
- eth_send(s, 0);
320
- }
321
- if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) {
322
- qemu_irq_raise(s->irq);
323
- }
324
- break;
325
-
326
- case MP_ETH_ICR:
327
- s->icr &= value;
328
- break;
329
-
330
- case MP_ETH_IMR:
331
- s->imr = value;
332
- if (s->icr & s->imr) {
333
- qemu_irq_raise(s->irq);
334
- }
335
- break;
336
-
337
- case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
338
- s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
339
- break;
340
-
341
- case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
342
- s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
343
- s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
344
- break;
345
-
346
- case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
347
- s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
348
- break;
349
- }
350
-}
351
-
352
-static const MemoryRegionOps mv88w8618_eth_ops = {
353
- .read = mv88w8618_eth_read,
354
- .write = mv88w8618_eth_write,
355
- .endianness = DEVICE_NATIVE_ENDIAN,
356
-};
357
-
358
-static void eth_cleanup(NetClientState *nc)
359
-{
360
- mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
361
-
362
- s->nic = NULL;
363
-}
364
-
365
-static NetClientInfo net_mv88w8618_info = {
366
- .type = NET_CLIENT_DRIVER_NIC,
367
- .size = sizeof(NICState),
368
- .receive = eth_receive,
369
- .cleanup = eth_cleanup,
370
-};
371
-
372
-static void mv88w8618_eth_init(Object *obj)
373
-{
374
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
375
- DeviceState *dev = DEVICE(sbd);
376
- mv88w8618_eth_state *s = MV88W8618_ETH(dev);
377
-
378
- sysbus_init_irq(sbd, &s->irq);
379
- memory_region_init_io(&s->iomem, obj, &mv88w8618_eth_ops, s,
380
- "mv88w8618-eth", MP_ETH_SIZE);
381
- sysbus_init_mmio(sbd, &s->iomem);
382
-}
383
-
384
-static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
385
-{
386
- mv88w8618_eth_state *s = MV88W8618_ETH(dev);
387
-
388
- if (!s->dma_mr) {
389
- error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set");
390
- return;
391
- }
392
-
393
- address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
394
- s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
395
- object_get_typename(OBJECT(dev)), dev->id, s);
396
-}
397
-
398
-static const VMStateDescription mv88w8618_eth_vmsd = {
399
- .name = "mv88w8618_eth",
400
- .version_id = 1,
401
- .minimum_version_id = 1,
402
- .fields = (VMStateField[]) {
403
- VMSTATE_UINT32(smir, mv88w8618_eth_state),
404
- VMSTATE_UINT32(icr, mv88w8618_eth_state),
405
- VMSTATE_UINT32(imr, mv88w8618_eth_state),
406
- VMSTATE_UINT32(vlan_header, mv88w8618_eth_state),
407
- VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2),
408
- VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4),
409
- VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4),
410
- VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4),
411
- VMSTATE_END_OF_LIST()
412
- }
413
-};
414
-
415
-static Property mv88w8618_eth_properties[] = {
416
- DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
417
- DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr,
418
- TYPE_MEMORY_REGION, MemoryRegion *),
419
- DEFINE_PROP_END_OF_LIST(),
420
-};
421
-
422
-static void mv88w8618_eth_class_init(ObjectClass *klass, void *data)
423
-{
424
- DeviceClass *dc = DEVICE_CLASS(klass);
425
-
426
- dc->vmsd = &mv88w8618_eth_vmsd;
427
- device_class_set_props(dc, mv88w8618_eth_properties);
428
- dc->realize = mv88w8618_eth_realize;
429
-}
430
-
431
-static const TypeInfo mv88w8618_eth_info = {
432
- .name = TYPE_MV88W8618_ETH,
433
- .parent = TYPE_SYS_BUS_DEVICE,
434
- .instance_size = sizeof(mv88w8618_eth_state),
435
- .instance_init = mv88w8618_eth_init,
436
- .class_init = mv88w8618_eth_class_init,
437
-};
438
-
439
/* LCD register offsets */
440
#define MP_LCD_IRQCTRL 0x180
441
#define MP_LCD_IRQSTAT 0x184
442
@@ -XXX,XX +XXX,XX @@ static void musicpal_register_types(void)
443
type_register_static(&mv88w8618_pic_info);
444
type_register_static(&mv88w8618_pit_info);
445
type_register_static(&mv88w8618_flashcfg_info);
446
- type_register_static(&mv88w8618_eth_info);
447
type_register_static(&mv88w8618_wlan_info);
448
type_register_static(&musicpal_lcd_info);
449
type_register_static(&musicpal_gpio_info);
450
diff --git a/hw/net/mv88w8618_eth.c b/hw/net/mv88w8618_eth.c
451
new file mode 100644
452
index XXXXXXX..XXXXXXX
453
--- /dev/null
454
+++ b/hw/net/mv88w8618_eth.c
455
@@ -XXX,XX +XXX,XX @@
456
+/* SPDX-License-Identifier: GPL-2.0-or-later */
457
+/*
458
+ * Marvell MV88W8618 / Freecom MusicPal emulation.
459
+ *
460
+ * Copyright (c) 2008 Jan Kiszka
461
+ */
462
+
463
+#include "qemu/osdep.h"
464
+#include "qapi/error.h"
465
+#include "hw/qdev-properties.h"
466
+#include "hw/sysbus.h"
467
+#include "hw/irq.h"
468
+#include "hw/net/mv88w8618_eth.h"
469
+#include "migration/vmstate.h"
470
+#include "sysemu/dma.h"
471
+#include "net/net.h"
472
+
473
+#define MP_ETH_SIZE 0x00001000
474
+
475
+/* Ethernet register offsets */
476
+#define MP_ETH_SMIR 0x010
477
+#define MP_ETH_PCXR 0x408
478
+#define MP_ETH_SDCMR 0x448
479
+#define MP_ETH_ICR 0x450
480
+#define MP_ETH_IMR 0x458
481
+#define MP_ETH_FRDP0 0x480
482
+#define MP_ETH_FRDP1 0x484
483
+#define MP_ETH_FRDP2 0x488
484
+#define MP_ETH_FRDP3 0x48C
485
+#define MP_ETH_CRDP0 0x4A0
486
+#define MP_ETH_CRDP1 0x4A4
487
+#define MP_ETH_CRDP2 0x4A8
488
+#define MP_ETH_CRDP3 0x4AC
489
+#define MP_ETH_CTDP0 0x4E0
490
+#define MP_ETH_CTDP1 0x4E4
491
+
492
+/* MII PHY access */
493
+#define MP_ETH_SMIR_DATA 0x0000FFFF
494
+#define MP_ETH_SMIR_ADDR 0x03FF0000
495
+#define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */
496
+#define MP_ETH_SMIR_RDVALID (1 << 27)
497
+
498
+/* PHY registers */
499
+#define MP_ETH_PHY1_BMSR 0x00210000
500
+#define MP_ETH_PHY1_PHYSID1 0x00410000
501
+#define MP_ETH_PHY1_PHYSID2 0x00610000
502
+
503
+#define MP_PHY_BMSR_LINK 0x0004
504
+#define MP_PHY_BMSR_AUTONEG 0x0008
505
+
506
+#define MP_PHY_88E3015 0x01410E20
507
+
508
+/* TX descriptor status */
509
+#define MP_ETH_TX_OWN (1U << 31)
510
+
511
+/* RX descriptor status */
512
+#define MP_ETH_RX_OWN (1U << 31)
513
+
514
+/* Interrupt cause/mask bits */
515
+#define MP_ETH_IRQ_RX_BIT 0
516
+#define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT)
517
+#define MP_ETH_IRQ_TXHI_BIT 2
518
+#define MP_ETH_IRQ_TXLO_BIT 3
519
+
520
+/* Port config bits */
521
+#define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */
522
+
523
+/* SDMA command bits */
524
+#define MP_ETH_CMD_TXHI (1 << 23)
525
+#define MP_ETH_CMD_TXLO (1 << 22)
526
+
527
+typedef struct mv88w8618_tx_desc {
528
+ uint32_t cmdstat;
529
+ uint16_t res;
530
+ uint16_t bytes;
531
+ uint32_t buffer;
532
+ uint32_t next;
533
+} mv88w8618_tx_desc;
534
+
535
+typedef struct mv88w8618_rx_desc {
536
+ uint32_t cmdstat;
537
+ uint16_t bytes;
538
+ uint16_t buffer_size;
539
+ uint32_t buffer;
540
+ uint32_t next;
541
+} mv88w8618_rx_desc;
542
+
543
+OBJECT_DECLARE_SIMPLE_TYPE(mv88w8618_eth_state, MV88W8618_ETH)
544
+
545
+struct mv88w8618_eth_state {
546
+ /*< private >*/
547
+ SysBusDevice parent_obj;
548
+ /*< public >*/
549
+
550
+ MemoryRegion iomem;
551
+ qemu_irq irq;
552
+ MemoryRegion *dma_mr;
553
+ AddressSpace dma_as;
554
+ uint32_t smir;
555
+ uint32_t icr;
556
+ uint32_t imr;
557
+ int mmio_index;
558
+ uint32_t vlan_header;
559
+ uint32_t tx_queue[2];
560
+ uint32_t rx_queue[4];
561
+ uint32_t frx_queue[4];
562
+ uint32_t cur_rx[4];
563
+ NICState *nic;
564
+ NICConf conf;
565
+};
566
+
567
+static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr,
568
+ mv88w8618_rx_desc *desc)
569
+{
570
+ cpu_to_le32s(&desc->cmdstat);
571
+ cpu_to_le16s(&desc->bytes);
572
+ cpu_to_le16s(&desc->buffer_size);
573
+ cpu_to_le32s(&desc->buffer);
574
+ cpu_to_le32s(&desc->next);
575
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
576
+}
577
+
578
+static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
579
+ mv88w8618_rx_desc *desc)
580
+{
581
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
582
+ le32_to_cpus(&desc->cmdstat);
583
+ le16_to_cpus(&desc->bytes);
584
+ le16_to_cpus(&desc->buffer_size);
585
+ le32_to_cpus(&desc->buffer);
586
+ le32_to_cpus(&desc->next);
587
+}
588
+
589
+static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
590
+{
591
+ mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
592
+ uint32_t desc_addr;
593
+ mv88w8618_rx_desc desc;
594
+ int i;
595
+
596
+ for (i = 0; i < 4; i++) {
597
+ desc_addr = s->cur_rx[i];
598
+ if (!desc_addr) {
599
+ continue;
600
+ }
601
+ do {
602
+ eth_rx_desc_get(&s->dma_as, desc_addr, &desc);
603
+ if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
604
+ dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header,
605
+ buf, size, MEMTXATTRS_UNSPECIFIED);
606
+ desc.bytes = size + s->vlan_header;
607
+ desc.cmdstat &= ~MP_ETH_RX_OWN;
608
+ s->cur_rx[i] = desc.next;
609
+
610
+ s->icr |= MP_ETH_IRQ_RX;
611
+ if (s->icr & s->imr) {
612
+ qemu_irq_raise(s->irq);
613
+ }
614
+ eth_rx_desc_put(&s->dma_as, desc_addr, &desc);
615
+ return size;
616
+ }
617
+ desc_addr = desc.next;
618
+ } while (desc_addr != s->rx_queue[i]);
619
+ }
620
+ return size;
621
+}
622
+
623
+static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr,
624
+ mv88w8618_tx_desc *desc)
625
+{
626
+ cpu_to_le32s(&desc->cmdstat);
627
+ cpu_to_le16s(&desc->res);
628
+ cpu_to_le16s(&desc->bytes);
629
+ cpu_to_le32s(&desc->buffer);
630
+ cpu_to_le32s(&desc->next);
631
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
632
+}
633
+
634
+static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr,
635
+ mv88w8618_tx_desc *desc)
636
+{
637
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
638
+ le32_to_cpus(&desc->cmdstat);
639
+ le16_to_cpus(&desc->res);
640
+ le16_to_cpus(&desc->bytes);
641
+ le32_to_cpus(&desc->buffer);
642
+ le32_to_cpus(&desc->next);
643
+}
644
+
645
+static void eth_send(mv88w8618_eth_state *s, int queue_index)
646
+{
647
+ uint32_t desc_addr = s->tx_queue[queue_index];
648
+ mv88w8618_tx_desc desc;
649
+ uint32_t next_desc;
650
+ uint8_t buf[2048];
651
+ int len;
652
+
653
+ do {
654
+ eth_tx_desc_get(&s->dma_as, desc_addr, &desc);
655
+ next_desc = desc.next;
656
+ if (desc.cmdstat & MP_ETH_TX_OWN) {
657
+ len = desc.bytes;
658
+ if (len < 2048) {
659
+ dma_memory_read(&s->dma_as, desc.buffer, buf, len,
660
+ MEMTXATTRS_UNSPECIFIED);
661
+ qemu_send_packet(qemu_get_queue(s->nic), buf, len);
662
+ }
663
+ desc.cmdstat &= ~MP_ETH_TX_OWN;
664
+ s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
665
+ eth_tx_desc_put(&s->dma_as, desc_addr, &desc);
666
+ }
667
+ desc_addr = next_desc;
668
+ } while (desc_addr != s->tx_queue[queue_index]);
669
+}
670
+
671
+static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
672
+ unsigned size)
673
+{
674
+ mv88w8618_eth_state *s = opaque;
675
+
676
+ switch (offset) {
677
+ case MP_ETH_SMIR:
678
+ if (s->smir & MP_ETH_SMIR_OPCODE) {
679
+ switch (s->smir & MP_ETH_SMIR_ADDR) {
680
+ case MP_ETH_PHY1_BMSR:
681
+ return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
682
+ MP_ETH_SMIR_RDVALID;
683
+ case MP_ETH_PHY1_PHYSID1:
684
+ return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
685
+ case MP_ETH_PHY1_PHYSID2:
686
+ return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
687
+ default:
688
+ return MP_ETH_SMIR_RDVALID;
689
+ }
690
+ }
691
+ return 0;
692
+
693
+ case MP_ETH_ICR:
694
+ return s->icr;
695
+
696
+ case MP_ETH_IMR:
697
+ return s->imr;
698
+
699
+ case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
700
+ return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
701
+
702
+ case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
703
+ return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
704
+
705
+ case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
706
+ return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
707
+
708
+ default:
709
+ return 0;
710
+ }
711
+}
712
+
713
+static void mv88w8618_eth_write(void *opaque, hwaddr offset,
714
+ uint64_t value, unsigned size)
715
+{
716
+ mv88w8618_eth_state *s = opaque;
717
+
718
+ switch (offset) {
719
+ case MP_ETH_SMIR:
720
+ s->smir = value;
721
+ break;
722
+
723
+ case MP_ETH_PCXR:
724
+ s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2;
725
+ break;
726
+
727
+ case MP_ETH_SDCMR:
728
+ if (value & MP_ETH_CMD_TXHI) {
729
+ eth_send(s, 1);
730
+ }
731
+ if (value & MP_ETH_CMD_TXLO) {
732
+ eth_send(s, 0);
733
+ }
734
+ if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) {
735
+ qemu_irq_raise(s->irq);
736
+ }
737
+ break;
738
+
739
+ case MP_ETH_ICR:
740
+ s->icr &= value;
741
+ break;
742
+
743
+ case MP_ETH_IMR:
744
+ s->imr = value;
745
+ if (s->icr & s->imr) {
746
+ qemu_irq_raise(s->irq);
747
+ }
748
+ break;
749
+
750
+ case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
751
+ s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
752
+ break;
753
+
754
+ case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
755
+ s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
756
+ s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
757
+ break;
758
+
759
+ case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
760
+ s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
761
+ break;
762
+ }
763
+}
764
+
765
+static const MemoryRegionOps mv88w8618_eth_ops = {
766
+ .read = mv88w8618_eth_read,
767
+ .write = mv88w8618_eth_write,
768
+ .endianness = DEVICE_NATIVE_ENDIAN,
769
+};
770
+
771
+static void eth_cleanup(NetClientState *nc)
772
+{
773
+ mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
774
+
775
+ s->nic = NULL;
776
+}
777
+
778
+static NetClientInfo net_mv88w8618_info = {
779
+ .type = NET_CLIENT_DRIVER_NIC,
780
+ .size = sizeof(NICState),
781
+ .receive = eth_receive,
782
+ .cleanup = eth_cleanup,
783
+};
784
+
785
+static void mv88w8618_eth_init(Object *obj)
786
+{
787
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
788
+ DeviceState *dev = DEVICE(sbd);
789
+ mv88w8618_eth_state *s = MV88W8618_ETH(dev);
790
+
791
+ sysbus_init_irq(sbd, &s->irq);
792
+ memory_region_init_io(&s->iomem, obj, &mv88w8618_eth_ops, s,
793
+ "mv88w8618-eth", MP_ETH_SIZE);
794
+ sysbus_init_mmio(sbd, &s->iomem);
795
+}
796
+
797
+static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
798
+{
799
+ mv88w8618_eth_state *s = MV88W8618_ETH(dev);
800
+
801
+ if (!s->dma_mr) {
802
+ error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set");
803
+ return;
804
+ }
805
+
806
+ address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
807
+ s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
808
+ object_get_typename(OBJECT(dev)), dev->id, s);
809
+}
810
+
811
+static const VMStateDescription mv88w8618_eth_vmsd = {
812
+ .name = "mv88w8618_eth",
80
+ .version_id = 1,
813
+ .version_id = 1,
81
+ .minimum_version_id = 1,
814
+ .minimum_version_id = 1,
82
+ .fields = (VMStateField[]) {
815
+ .fields = (VMStateField[]) {
83
+ VMSTATE_UINT32(env.v7m.scr[M_REG_NS], ARMCPU),
816
+ VMSTATE_UINT32(smir, mv88w8618_eth_state),
817
+ VMSTATE_UINT32(icr, mv88w8618_eth_state),
818
+ VMSTATE_UINT32(imr, mv88w8618_eth_state),
819
+ VMSTATE_UINT32(vlan_header, mv88w8618_eth_state),
820
+ VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2),
821
+ VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4),
822
+ VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4),
823
+ VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4),
84
+ VMSTATE_END_OF_LIST()
824
+ VMSTATE_END_OF_LIST()
85
+ }
825
+ }
86
+};
826
+};
87
+
827
+
88
static const VMStateDescription vmstate_m = {
828
+static Property mv88w8618_eth_properties[] = {
89
.name = "cpu/m",
829
+ DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
90
.version_id = 4,
830
+ DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr,
91
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
831
+ TYPE_MEMORY_REGION, MemoryRegion *),
92
.subsections = (const VMStateDescription*[]) {
832
+ DEFINE_PROP_END_OF_LIST(),
93
&vmstate_m_faultmask_primask,
833
+};
94
&vmstate_m_csselr,
834
+
95
+ &vmstate_m_scr,
835
+static void mv88w8618_eth_class_init(ObjectClass *klass, void *data)
96
NULL
836
+{
97
}
837
+ DeviceClass *dc = DEVICE_CLASS(klass);
98
};
838
+
99
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_security = {
839
+ dc->vmsd = &mv88w8618_eth_vmsd;
100
VMSTATE_UINT32(env.sau.rnr, ARMCPU),
840
+ device_class_set_props(dc, mv88w8618_eth_properties);
101
VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate),
841
+ dc->realize = mv88w8618_eth_realize;
102
VMSTATE_UINT32(env.sau.ctrl, ARMCPU),
842
+}
103
+ VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU),
843
+
104
VMSTATE_END_OF_LIST()
844
+static const TypeInfo mv88w8618_eth_info = {
105
}
845
+ .name = TYPE_MV88W8618_ETH,
106
};
846
+ .parent = TYPE_SYS_BUS_DEVICE,
847
+ .instance_size = sizeof(mv88w8618_eth_state),
848
+ .instance_init = mv88w8618_eth_init,
849
+ .class_init = mv88w8618_eth_class_init,
850
+};
851
+
852
+static void musicpal_register_types(void)
853
+{
854
+ type_register_static(&mv88w8618_eth_info);
855
+}
856
+
857
+type_init(musicpal_register_types)
858
+
859
diff --git a/MAINTAINERS b/MAINTAINERS
860
index XXXXXXX..XXXXXXX 100644
861
--- a/MAINTAINERS
862
+++ b/MAINTAINERS
863
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
864
L: qemu-arm@nongnu.org
865
S: Odd Fixes
866
F: hw/arm/musicpal.c
867
+F: hw/net/mv88w8618_eth.c
868
+F: include/hw/net/mv88w8618_eth.h
869
F: docs/system/arm/musicpal.rst
870
871
Nuvoton NPCM7xx
872
diff --git a/hw/net/meson.build b/hw/net/meson.build
873
index XXXXXXX..XXXXXXX 100644
874
--- a/hw/net/meson.build
875
+++ b/hw/net/meson.build
876
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ALLWINNER_EMAC', if_true: files('allwinner_emac.c')
877
softmmu_ss.add(when: 'CONFIG_ALLWINNER_SUN8I_EMAC', if_true: files('allwinner-sun8i-emac.c'))
878
softmmu_ss.add(when: 'CONFIG_IMX_FEC', if_true: files('imx_fec.c'))
879
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-emac.c'))
880
+softmmu_ss.add(when: 'CONFIG_MARVELL_88W8618', if_true: files('mv88w8618_eth.c'))
881
882
softmmu_ss.add(when: 'CONFIG_CADENCE', if_true: files('cadence_gem.c'))
883
softmmu_ss.add(when: 'CONFIG_STELLARIS_ENET', if_true: files('stellaris_enet.c'))
107
--
884
--
108
2.16.1
885
2.25.1
109
886
110
887
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
ARM64 machines like Kunpeng Family Server Chips have a level
4
of hardware topology in which a group of CPU cores share L3
5
cache tag or L2 cache. For example, Kunpeng 920 typically
6
has 6 or 8 clusters in each NUMA node (also represent range
7
of CPU die), and each cluster has 4 CPU cores. All clusters
8
share L3 cache data, but CPU cores in each cluster share a
9
local L3 tag.
10
11
Running a guest kernel with Cluster-Aware Scheduling on the
12
Hosts which have physical clusters, if we can design a vCPU
13
topology with cluster level for guest kernel and then have
14
a dedicated vCPU pinning, the guest will gain scheduling
15
performance improvement from cache affinity of CPU cluster.
16
17
So let's enable the support for this new parameter on ARM
18
virt machines. After this patch, we can define a 4-level
19
CPU hierarchy like: cpus=*,maxcpus=*,sockets=*,clusters=*,
20
cores=*,threads=*.
21
22
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
23
Reviewed-by: Andrew Jones <drjones@redhat.com>
24
Message-id: 20220107083232.16256-2-wangyanan55@huawei.com
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
27
hw/arm/virt.c | 1 +
28
qemu-options.hx | 10 ++++++++++
29
2 files changed, 11 insertions(+)
30
31
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/virt.c
34
+++ b/hw/arm/virt.c
35
@@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
36
hc->unplug_request = virt_machine_device_unplug_request_cb;
37
hc->unplug = virt_machine_device_unplug_cb;
38
mc->nvdimm_supported = true;
39
+ mc->smp_props.clusters_supported = true;
40
mc->auto_enable_numa_with_memhp = true;
41
mc->auto_enable_numa_with_memdev = true;
42
mc->default_ram_id = "mach-virt.ram";
43
diff --git a/qemu-options.hx b/qemu-options.hx
44
index XXXXXXX..XXXXXXX 100644
45
--- a/qemu-options.hx
46
+++ b/qemu-options.hx
47
@@ -XXX,XX +XXX,XX @@ SRST
48
49
-smp 16,sockets=2,dies=2,cores=2,threads=2,maxcpus=16
50
51
+ The following sub-option defines a CPU topology hierarchy (2 sockets
52
+ totally on the machine, 2 clusters per socket, 2 cores per cluster,
53
+ 2 threads per core) for ARM virt machines which support sockets/clusters
54
+ /cores/threads. Some members of the option can be omitted but their values
55
+ will be automatically computed:
56
+
57
+ ::
58
+
59
+ -smp 16,sockets=2,clusters=2,cores=2,threads=2,maxcpus=16
60
+
61
Historically preference was given to the coarsest topology parameters
62
when computing missing values (ie sockets preferred over cores, which
63
were preferred over threads), however, this behaviour is considered
64
--
65
2.25.1
66
67
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
Support one cluster level between core and physical package in the
4
cpu-map of Arm/virt devicetree. This is also consistent with Linux
5
Doc "Documentation/devicetree/bindings/cpu/cpu-topology.txt".
6
7
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
8
Reviewed-by: Andrew Jones <drjones@redhat.com>
9
Message-id: 20220107083232.16256-3-wangyanan55@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/virt.c | 15 ++++++++-------
13
1 file changed, 8 insertions(+), 7 deletions(-)
14
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
18
+++ b/hw/arm/virt.c
19
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
20
* can contain several layers of clustering within a single physical
21
* package and cluster nodes can be contained in parent cluster nodes.
22
*
23
- * Given that cluster is not yet supported in the vCPU topology,
24
- * we currently generate one cluster node within each socket node
25
- * by default.
26
+ * Note: currently we only support one layer of clustering within
27
+ * each physical package.
28
*/
29
qemu_fdt_add_subnode(ms->fdt, "/cpus/cpu-map");
30
31
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
32
33
if (ms->smp.threads > 1) {
34
map_path = g_strdup_printf(
35
- "/cpus/cpu-map/socket%d/cluster0/core%d/thread%d",
36
- cpu / (ms->smp.cores * ms->smp.threads),
37
+ "/cpus/cpu-map/socket%d/cluster%d/core%d/thread%d",
38
+ cpu / (ms->smp.clusters * ms->smp.cores * ms->smp.threads),
39
+ (cpu / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters,
40
(cpu / ms->smp.threads) % ms->smp.cores,
41
cpu % ms->smp.threads);
42
} else {
43
map_path = g_strdup_printf(
44
- "/cpus/cpu-map/socket%d/cluster0/core%d",
45
- cpu / ms->smp.cores,
46
+ "/cpus/cpu-map/socket%d/cluster%d/core%d",
47
+ cpu / (ms->smp.clusters * ms->smp.cores),
48
+ (cpu / ms->smp.cores) % ms->smp.clusters,
49
cpu % ms->smp.cores);
50
}
51
qemu_fdt_add_path(ms->fdt, map_path);
52
--
53
2.25.1
54
55
diff view generated by jsdifflib
1
From: Pekka Enberg <penberg@iki.fi>
1
From: Yanan Wang <wangyanan55@huawei.com>
2
2
3
This patch adds a "cpu-type" property to BCM2836 SoC in preparation for
3
Use g_queue APIs to reduce the nested loops and code indentation
4
reusing the code for the Raspberry Pi 3, which has a different processor
4
with the processor hierarchy levels increasing. Consenquently,
5
model.
5
it's more scalable to add new topology level to build_pptt.
6
6
7
Signed-off-by: Pekka Enberg <penberg@iki.fi>
7
No functional change intended.
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
9
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
10
Reviewed-by: Andrew Jones <drjones@redhat.com>
11
Message-id: 20220107083232.16256-4-wangyanan55@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
include/hw/arm/bcm2836.h | 1 +
14
hw/acpi/aml-build.c | 50 +++++++++++++++++++++++++++++----------------
12
hw/arm/bcm2836.c | 17 +++++++++--------
15
1 file changed, 32 insertions(+), 18 deletions(-)
13
hw/arm/raspi.c | 3 +++
14
3 files changed, 13 insertions(+), 8 deletions(-)
15
16
16
diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h
17
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/bcm2836.h
19
--- a/hw/acpi/aml-build.c
19
+++ b/include/hw/arm/bcm2836.h
20
+++ b/hw/acpi/aml-build.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State {
21
@@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
21
DeviceState parent_obj;
22
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
22
/*< public >*/
23
const char *oem_id, const char *oem_table_id)
23
24
+ char *cpu_type;
25
uint32_t enabled_cpus;
26
27
ARMCPU cpus[BCM2836_NCPUS];
28
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/bcm2836.c
31
+++ b/hw/arm/bcm2836.c
32
@@ -XXX,XX +XXX,XX @@
33
static void bcm2836_init(Object *obj)
34
{
24
{
35
BCM2836State *s = BCM2836(obj);
25
- int pptt_start = table_data->len;
36
- int n;
26
+ GQueue *list = g_queue_new();
27
+ guint pptt_start = table_data->len;
28
+ guint parent_offset;
29
+ guint length, i;
30
int uid = 0;
31
int socket;
32
AcpiTable table = { .sig = "PPTT", .rev = 2,
33
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
34
acpi_table_begin(&table, table_data);
35
36
for (socket = 0; socket < ms->smp.sockets; socket++) {
37
- uint32_t socket_offset = table_data->len - pptt_start;
38
- int core;
37
-
39
-
38
- for (n = 0; n < BCM2836_NCPUS; n++) {
40
+ g_queue_push_tail(list,
39
- object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
41
+ GUINT_TO_POINTER(table_data->len - pptt_start));
40
- "cortex-a15-" TYPE_ARM_CPU);
42
build_processor_hierarchy_node(
41
- object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
43
table_data,
42
- &error_abort);
44
/*
43
- }
45
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
44
46
*/
45
object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL);
47
(1 << 0),
46
object_property_add_child(obj, "control", OBJECT(&s->control), NULL);
48
0, socket, NULL, 0);
47
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
49
+ }
48
50
49
/* common peripherals from bcm2835 */
51
+ length = g_queue_get_length(list);
50
52
+ for (i = 0; i < length; i++) {
51
+ obj = OBJECT(dev);
53
+ int core;
52
+ for (n = 0; n < BCM2836_NCPUS; n++) {
54
+
53
+ object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
55
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
54
+ s->cpu_type);
56
for (core = 0; core < ms->smp.cores; core++) {
55
+ object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
57
- uint32_t core_offset = table_data->len - pptt_start;
56
+ &error_abort);
58
- int thread;
59
-
60
if (ms->smp.threads > 1) {
61
+ g_queue_push_tail(list,
62
+ GUINT_TO_POINTER(table_data->len - pptt_start));
63
build_processor_hierarchy_node(
64
table_data,
65
(0 << 0), /* not a physical package */
66
- socket_offset, core, NULL, 0);
67
-
68
- for (thread = 0; thread < ms->smp.threads; thread++) {
69
- build_processor_hierarchy_node(
70
- table_data,
71
- (1 << 1) | /* ACPI Processor ID valid */
72
- (1 << 2) | /* Processor is a Thread */
73
- (1 << 3), /* Node is a Leaf */
74
- core_offset, uid++, NULL, 0);
75
- }
76
+ parent_offset, core, NULL, 0);
77
} else {
78
build_processor_hierarchy_node(
79
table_data,
80
(1 << 1) | /* ACPI Processor ID valid */
81
(1 << 3), /* Node is a Leaf */
82
- socket_offset, uid++, NULL, 0);
83
+ parent_offset, uid++, NULL, 0);
84
}
85
}
86
}
87
88
+ length = g_queue_get_length(list);
89
+ for (i = 0; i < length; i++) {
90
+ int thread;
91
+
92
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
93
+ for (thread = 0; thread < ms->smp.threads; thread++) {
94
+ build_processor_hierarchy_node(
95
+ table_data,
96
+ (1 << 1) | /* ACPI Processor ID valid */
97
+ (1 << 2) | /* Processor is a Thread */
98
+ (1 << 3), /* Node is a Leaf */
99
+ parent_offset, uid++, NULL, 0);
100
+ }
57
+ }
101
+ }
58
+
102
+
59
obj = object_property_get_link(OBJECT(dev), "ram", &err);
103
+ g_queue_free(list);
60
if (obj == NULL) {
104
acpi_table_end(linker, &table);
61
error_setg(errp, "%s: required ram link not found: %s",
62
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
63
}
105
}
64
106
65
static Property bcm2836_props[] = {
66
+ DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type),
67
DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS),
68
DEFINE_PROP_END_OF_LIST()
69
};
70
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/arm/raspi.c
73
+++ b/hw/arm/raspi.c
74
@@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine)
75
/* Setup the SOC */
76
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
77
&error_abort);
78
+ object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type",
79
+ &error_abort);
80
object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
81
&error_abort);
82
object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev",
83
@@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc)
84
mc->no_parallel = 1;
85
mc->no_floppy = 1;
86
mc->no_cdrom = 1;
87
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
88
mc->max_cpus = BCM2836_NCPUS;
89
mc->min_cpus = BCM2836_NCPUS;
90
mc->default_cpus = BCM2836_NCPUS;
91
--
107
--
92
2.16.1
108
2.25.1
93
109
94
110
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
List test/data/acpi/virt/PPTT as the expected files allowed to
4
be changed in tests/qtest/bios-tables-test-allowed-diff.h
5
6
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
7
Acked-by: Ani Sinha <ani@anisinha.ca>
8
Message-id: 20220107083232.16256-5-wangyanan55@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
tests/qtest/bios-tables-test-allowed-diff.h | 1 +
12
1 file changed, 1 insertion(+)
13
14
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/bios-tables-test-allowed-diff.h
17
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
18
@@ -1 +1,2 @@
19
/* List of comma-separated changed AML files to ignore */
20
+"tests/data/acpi/virt/PPTT",
21
--
22
2.25.1
23
24
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
Support CPU cluster topology level in generation of ACPI
4
Processor Properties Topology Table (PPTT).
5
6
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
7
Reviewed-by: Andrew Jones <drjones@redhat.com>
8
Message-id: 20220107083232.16256-6-wangyanan55@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/acpi/aml-build.c | 18 ++++++++++++++++++
12
1 file changed, 18 insertions(+)
13
14
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/acpi/aml-build.c
17
+++ b/hw/acpi/aml-build.c
18
@@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
19
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
20
const char *oem_id, const char *oem_table_id)
21
{
22
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
23
GQueue *list = g_queue_new();
24
guint pptt_start = table_data->len;
25
guint parent_offset;
26
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
27
0, socket, NULL, 0);
28
}
29
30
+ if (mc->smp_props.clusters_supported) {
31
+ length = g_queue_get_length(list);
32
+ for (i = 0; i < length; i++) {
33
+ int cluster;
34
+
35
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
36
+ for (cluster = 0; cluster < ms->smp.clusters; cluster++) {
37
+ g_queue_push_tail(list,
38
+ GUINT_TO_POINTER(table_data->len - pptt_start));
39
+ build_processor_hierarchy_node(
40
+ table_data,
41
+ (0 << 0), /* not a physical package */
42
+ parent_offset, cluster, NULL, 0);
43
+ }
44
+ }
45
+ }
46
+
47
length = g_queue_get_length(list);
48
for (i = 0; i < length; i++) {
49
int core;
50
--
51
2.25.1
52
53
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
Run ./tests/data/acpi/rebuild-expected-aml.sh from build directory
4
to update PPTT binary. Also empty bios-tables-test-allowed-diff.h.
5
6
The disassembled differences between actual and expected PPTT:
7
8
/*
9
* Intel ACPI Component Architecture
10
* AML/ASL+ Disassembler version 20200528 (64-bit version)
11
* Copyright (c) 2000 - 2020 Intel Corporation
12
*
13
- * Disassembly of tests/data/acpi/virt/PPTT, Tue Jan 4 12:51:11 2022
14
+ * Disassembly of /tmp/aml-2ZGOF1, Tue Jan 4 12:51:11 2022
15
*
16
* ACPI Data Table [PPTT]
17
*
18
* Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue
19
*/
20
21
[000h 0000 4] Signature : "PPTT" [Processor Properties Topology Table]
22
-[004h 0004 4] Table Length : 0000004C
23
+[004h 0004 4] Table Length : 00000060
24
[008h 0008 1] Revision : 02
25
-[009h 0009 1] Checksum : A8
26
+[009h 0009 1] Checksum : 48
27
[00Ah 0010 6] Oem ID : "BOCHS "
28
[010h 0016 8] Oem Table ID : "BXPC "
29
[018h 0024 4] Oem Revision : 00000001
30
[01Ch 0028 4] Asl Compiler ID : "BXPC"
31
[020h 0032 4] Asl Compiler Revision : 00000001
32
33
[024h 0036 1] Subtable Type : 00 [Processor Hierarchy Node]
34
[025h 0037 1] Length : 14
35
[026h 0038 2] Reserved : 0000
36
[028h 0040 4] Flags (decoded below) : 00000001
37
Physical package : 1
38
ACPI Processor ID valid : 0
39
Processor is a thread : 0
40
Node is a leaf : 0
41
Identical Implementation : 0
42
[02Ch 0044 4] Parent : 00000000
43
[030h 0048 4] ACPI Processor ID : 00000000
44
[034h 0052 4] Private Resource Number : 00000000
45
46
[038h 0056 1] Subtable Type : 00 [Processor Hierarchy Node]
47
[039h 0057 1] Length : 14
48
[03Ah 0058 2] Reserved : 0000
49
-[03Ch 0060 4] Flags (decoded below) : 0000000A
50
+[03Ch 0060 4] Flags (decoded below) : 00000000
51
Physical package : 0
52
- ACPI Processor ID valid : 1
53
+ ACPI Processor ID valid : 0
54
Processor is a thread : 0
55
- Node is a leaf : 1
56
+ Node is a leaf : 0
57
Identical Implementation : 0
58
[040h 0064 4] Parent : 00000024
59
[044h 0068 4] ACPI Processor ID : 00000000
60
[048h 0072 4] Private Resource Number : 00000000
61
62
-Raw Table Data: Length 76 (0x4C)
63
+[04Ch 0076 1] Subtable Type : 00 [Processor Hierarchy Node]
64
+[04Dh 0077 1] Length : 14
65
+[04Eh 0078 2] Reserved : 0000
66
+[050h 0080 4] Flags (decoded below) : 0000000A
67
+ Physical package : 0
68
+ ACPI Processor ID valid : 1
69
+ Processor is a thread : 0
70
+ Node is a leaf : 1
71
+ Identical Implementation : 0
72
+[054h 0084 4] Parent : 00000038
73
+[058h 0088 4] ACPI Processor ID : 00000000
74
+[05Ch 0092 4] Private Resource Number : 00000000
75
+
76
+Raw Table Data: Length 96 (0x60)
77
78
- 0000: 50 50 54 54 4C 00 00 00 02 A8 42 4F 43 48 53 20 // PPTTL.....BOCHS
79
+ 0000: 50 50 54 54 60 00 00 00 02 48 42 4F 43 48 53 20 // PPTT`....HBOCHS
80
0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC
81
0020: 01 00 00 00 00 14 00 00 01 00 00 00 00 00 00 00 // ................
82
- 0030: 00 00 00 00 00 00 00 00 00 14 00 00 0A 00 00 00 // ................
83
- 0040: 24 00 00 00 00 00 00 00 00 00 00 00 // $...........
84
+ 0030: 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 // ................
85
+ 0040: 24 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 // $...............
86
+ 0050: 0A 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 // ....8...........
87
88
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
89
Reviewed-by: Ani Sinha <ani@anisinha.ca>
90
Message-id: 20220107083232.16256-7-wangyanan55@huawei.com
91
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
92
---
93
tests/qtest/bios-tables-test-allowed-diff.h | 1 -
94
tests/data/acpi/virt/PPTT | Bin 76 -> 96 bytes
95
2 files changed, 1 deletion(-)
96
97
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
98
index XXXXXXX..XXXXXXX 100644
99
--- a/tests/qtest/bios-tables-test-allowed-diff.h
100
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
101
@@ -1,2 +1 @@
102
/* List of comma-separated changed AML files to ignore */
103
-"tests/data/acpi/virt/PPTT",
104
diff --git a/tests/data/acpi/virt/PPTT b/tests/data/acpi/virt/PPTT
105
index XXXXXXX..XXXXXXX 100644
106
GIT binary patch
107
delta 53
108
pcmeZC;0g!`2}xjJU|{l?$YrDgWH5jU5Ca567#O&Klm(arApowi1QY-O
109
110
delta 32
111
fcmYfB;R*-{3GrcIU|?D?k;`ae01J-_kOKn%ZFdCM
112
113
--
114
2.25.1
115
116
diff view generated by jsdifflib
New patch
1
1
From: Lucas Ramage <lucas.ramage@infinite-omicron.com>
2
3
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/527
4
Signed-off-by: Lucas Ramage <lucas.ramage@infinite-omicron.com>
5
Message-id: 20220105205628.5491-1-oxr463@gmx.us
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
[PMM: Move to docs/system/devices/ rather than top-level;
8
fix a pre-existing typo in passing]
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
docs/system/device-emulation.rst | 1 +
12
docs/{can.txt => system/devices/can.rst} | 90 +++++++++++-------------
13
2 files changed, 41 insertions(+), 50 deletions(-)
14
rename docs/{can.txt => system/devices/can.rst} (68%)
15
16
diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst
17
index XXXXXXX..XXXXXXX 100644
18
--- a/docs/system/device-emulation.rst
19
+++ b/docs/system/device-emulation.rst
20
@@ -XXX,XX +XXX,XX @@ Emulated Devices
21
.. toctree::
22
:maxdepth: 1
23
24
+ devices/can.rst
25
devices/ivshmem.rst
26
devices/net.rst
27
devices/nvme.rst
28
diff --git a/docs/can.txt b/docs/system/devices/can.rst
29
similarity index 68%
30
rename from docs/can.txt
31
rename to docs/system/devices/can.rst
32
index XXXXXXX..XXXXXXX 100644
33
--- a/docs/can.txt
34
+++ b/docs/system/devices/can.rst
35
@@ -XXX,XX +XXX,XX @@
36
-QEMU CAN bus emulation support
37
-==============================
38
-
39
+CAN Bus Emulation Support
40
+=========================
41
The CAN bus emulation provides mechanism to connect multiple
42
emulated CAN controller chips together by one or multiple CAN busses
43
(the controller device "canbus" parameter). The individual busses
44
@@ -XXX,XX +XXX,XX @@ emulated environment for testing and RTEMS GSoC slot has been donated
45
to work on CAN hardware emulation on QEMU.
46
47
Examples how to use CAN emulation for SJA1000 based boards
48
-==========================================================
49
-
50
+----------------------------------------------------------
51
When QEMU with CAN PCI support is compiled then one of the next
52
CAN boards can be selected
53
54
- (1) CAN bus Kvaser PCI CAN-S (single SJA1000 channel) boad. QEMU startup options
55
+(1) CAN bus Kvaser PCI CAN-S (single SJA1000 channel) board. QEMU startup options::
56
+
57
-object can-bus,id=canbus0
58
-device kvaser_pci,canbus=canbus0
59
- Add "can-host-socketcan" object to connect device to host system CAN bus
60
+
61
+Add "can-host-socketcan" object to connect device to host system CAN bus::
62
+
63
-object can-host-socketcan,id=canhost0,if=can0,canbus=canbus0
64
65
- (2) CAN bus PCM-3680I PCI (dual SJA1000 channel) emulation
66
+(2) CAN bus PCM-3680I PCI (dual SJA1000 channel) emulation::
67
+
68
-object can-bus,id=canbus0
69
-device pcm3680_pci,canbus0=canbus0,canbus1=canbus0
70
71
- another example:
72
+Another example::
73
+
74
-object can-bus,id=canbus0
75
-object can-bus,id=canbus1
76
-device pcm3680_pci,canbus0=canbus0,canbus1=canbus1
77
78
- (3) CAN bus MIOe-3680 PCI (dual SJA1000 channel) emulation
79
+(3) CAN bus MIOe-3680 PCI (dual SJA1000 channel) emulation::
80
+
81
-device mioe3680_pci,canbus0=canbus0
82
83
-
84
The ''kvaser_pci'' board/device model is compatible with and has been tested with
85
-''kvaser_pci'' driver included in mainline Linux kernel.
86
+the ''kvaser_pci'' driver included in mainline Linux kernel.
87
The tested setup was Linux 4.9 kernel on the host and guest side.
88
-Example for qemu-system-x86_64:
89
+
90
+Example for qemu-system-x86_64::
91
92
qemu-system-x86_64 -accel kvm -kernel /boot/vmlinuz-4.9.0-4-amd64 \
93
-initrd ramdisk.cpio \
94
@@ -XXX,XX +XXX,XX @@ Example for qemu-system-x86_64:
95
-device kvaser_pci,canbus=canbus0 \
96
-nographic -append "console=ttyS0"
97
98
-Example for qemu-system-arm:
99
+Example for qemu-system-arm::
100
101
qemu-system-arm -cpu arm1176 -m 256 -M versatilepb \
102
-kernel kernel-qemu-arm1176-versatilepb \
103
@@ -XXX,XX +XXX,XX @@ Example for qemu-system-arm:
104
The CAN interface of the host system has to be configured for proper
105
bitrate and set up. Configuration is not propagated from emulated
106
devices through bus to the physical host device. Example configuration
107
-for 1 Mbit/s
108
+for 1 Mbit/s::
109
110
ip link set can0 type can bitrate 1000000
111
ip link set can0 up
112
113
Virtual (host local only) can interface can be used on the host
114
-side instead of physical interface
115
+side instead of physical interface::
116
117
ip link add dev can0 type vcan
118
119
The CAN interface on the host side can be used to analyze CAN
120
-traffic with "candump" command which is included in "can-utils".
121
+traffic with "candump" command which is included in "can-utils"::
122
123
candump can0
124
125
CTU CAN FD support examples
126
-===========================
127
-
128
+---------------------------
129
This open-source core provides CAN FD support. CAN FD drames are
130
delivered even to the host systems when SocketCAN interface is found
131
CAN FD capable.
132
@@ -XXX,XX +XXX,XX @@ on the board.
133
Example how to connect the canbus0-bus (virtual wire) to the host
134
Linux system (SocketCAN used) and to both CTU CAN FD cores emulated
135
on the corresponding PCI card expects that host system CAN bus
136
-is setup according to the previous SJA1000 section.
137
+is setup according to the previous SJA1000 section::
138
139
qemu-system-x86_64 -enable-kvm -kernel /boot/vmlinuz-4.19.52+ \
140
-initrd ramdisk.cpio \
141
@@ -XXX,XX +XXX,XX @@ is setup according to the previous SJA1000 section.
142
-device ctucan_pci,canbus0=canbus0-bus,canbus1=canbus0-bus \
143
-nographic
144
145
-Setup of CTU CAN FD controller in a guest Linux system
146
+Setup of CTU CAN FD controller in a guest Linux system::
147
148
insmod ctucanfd.ko || modprobe ctucanfd
149
insmod ctucanfd_pci.ko || modprobe ctucanfd_pci
150
@@ -XXX,XX +XXX,XX @@ Setup of CTU CAN FD controller in a guest Linux system
151
/bin/ip link set $ifc up
152
done
153
154
-The test can run for example
155
+The test can run for example::
156
157
candump can1
158
159
-in the guest system and next commands in the host system for basic CAN
160
+in the guest system and next commands in the host system for basic CAN::
161
162
cangen can0
163
164
-for CAN FD without bitrate switch
165
+for CAN FD without bitrate switch::
166
167
cangen can0 -f
168
169
-and with bitrate switch
170
+and with bitrate switch::
171
172
cangen can0 -b
173
174
@@ -XXX,XX +XXX,XX @@ The test can be run viceversa, generate messages in the guest system and capture
175
in the host one and much more combinations.
176
177
Links to other resources
178
-========================
179
+------------------------
180
181
- (1) CAN related projects at Czech Technical University, Faculty of Electrical Engineering
182
- http://canbus.pages.fel.cvut.cz/
183
- (2) Repository with development can-pci branch at Czech Technical University
184
- https://gitlab.fel.cvut.cz/canbus/qemu-canbus
185
- (3) RTEMS page describing project
186
- https://devel.rtems.org/wiki/Developer/Simulators/QEMU/CANEmulation
187
- (4) RTLWS 2015 article about the project and its use with CANopen emulation
188
- http://cmp.felk.cvut.cz/~pisa/can/doc/rtlws-17-pisa-qemu-can.pdf
189
- (5) GNU/Linux, CAN and CANopen in Real-time Control Applications
190
- Slides from LinuxDays 2017 (include updated RTLWS 2015 content)
191
- https://www.linuxdays.cz/2017/video/Pavel_Pisa-CAN_canopen.pdf
192
- (6) Linux SocketCAN utilities
193
- https://github.com/linux-can/can-utils/
194
- (7) CTU CAN FD project including core VHDL design, Linux driver,
195
- test utilities etc.
196
- https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core
197
- (8) CTU CAN FD Core Datasheet Documentation
198
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/Progdokum.pdf
199
- (9) CTU CAN FD Core System Architecture Documentation
200
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/ctu_can_fd_architecture.pdf
201
- (10) CTU CAN FD Driver Documentation
202
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/driver_doc/ctucanfd-driver.html
203
- (11) Integration with PCIe interfacing for Intel/Altera Cyclone IV based board
204
- https://gitlab.fel.cvut.cz/canbus/pcie-ctu_can_fd
205
+ (1) `CAN related projects at Czech Technical University, Faculty of Electrical Engineering <http://canbus.pages.fel.cvut.cz>`_
206
+ (2) `Repository with development can-pci branch at Czech Technical University <https://gitlab.fel.cvut.cz/canbus/qemu-canbus>`_
207
+ (3) `RTEMS page describing project <https://devel.rtems.org/wiki/Developer/Simulators/QEMU/CANEmulation>`_
208
+ (4) `RTLWS 2015 article about the project and its use with CANopen emulation <http://cmp.felk.cvut.cz/~pisa/can/doc/rtlws-17-pisa-qemu-can.pdf>`_
209
+ (5) `GNU/Linux, CAN and CANopen in Real-time Control Applications Slides from LinuxDays 2017 (include updated RTLWS 2015 content) <https://www.linuxdays.cz/2017/video/Pavel_Pisa-CAN_canopen.pdf>`_
210
+ (6) `Linux SocketCAN utilities <https://github.com/linux-can/can-utils>`_
211
+ (7) `CTU CAN FD project including core VHDL design, Linux driver, test utilities etc. <https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core>`_
212
+ (8) `CTU CAN FD Core Datasheet Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/Progdokum.pdf>`_
213
+ (9) `CTU CAN FD Core System Architecture Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/ctu_can_fd_architecture.pdf>`_
214
+ (10) `CTU CAN FD Driver Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/driver_doc/ctucanfd-driver.html>`_
215
+ (11) `Integration with PCIe interfacing for Intel/Altera Cyclone IV based board <https://gitlab.fel.cvut.cz/canbus/pcie-ctu_can_fd>`_
216
--
217
2.25.1
218
219
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Gavin Shan <gshan@redhat.com>
2
2
3
This also makes sure that we get the correct ordering of
3
The default block size is same as to the THP size, which is either
4
SVE vs FP exceptions.
4
retrieved from "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size"
5
or hardcoded to 2MB. There are flaws in both mechanisms and this
6
intends to fix them up.
5
7
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
* When "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size" is
7
Message-id: 20180211205848.4568-5-richard.henderson@linaro.org
9
used to getting the THP size, 32MB and 512MB are valid values
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
when we have 16KB and 64KB page size on ARM64.
11
12
* When the hardcoded THP size is used, 2MB, 32MB and 512MB are
13
valid values when we have 4KB, 16KB and 64KB page sizes on
14
ARM64.
15
16
Co-developed-by: David Hildenbrand <david@redhat.com>
17
Signed-off-by: Gavin Shan <gshan@redhat.com>
18
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
19
Reviewed-by: David Hildenbrand <david@redhat.com>
20
Message-id: 20220111063329.74447-2-gshan@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
22
---
11
target/arm/cpu.h | 3 ++-
23
hw/virtio/virtio-mem.c | 32 ++++++++++++++++++++------------
12
target/arm/internals.h | 6 ++++++
24
1 file changed, 20 insertions(+), 12 deletions(-)
13
target/arm/helper.c | 22 ++++------------------
14
target/arm/translate-a64.c | 16 ++++++++++++++++
15
4 files changed, 28 insertions(+), 19 deletions(-)
16
25
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
26
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
18
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
28
--- a/hw/virtio/virtio-mem.c
20
+++ b/target/arm/cpu.h
29
+++ b/hw/virtio/virtio-mem.c
21
@@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
30
@@ -XXX,XX +XXX,XX @@
22
#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500)
31
*/
23
#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA
32
#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)(1 * MiB))
24
#define ARM_CP_FPU 0x1000
33
25
+#define ARM_CP_SVE 0x2000
34
-#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
26
/* Used only as a terminator for ARMCPRegInfo lists */
35
- defined(__powerpc64__)
27
#define ARM_CP_SENTINEL 0xffff
36
-#define VIRTIO_MEM_DEFAULT_THP_SIZE ((uint32_t)(2 * MiB))
28
/* Mask of only the flag bits in a type field */
37
-#else
29
-#define ARM_CP_FLAG_MASK 0x10ff
38
- /* fallback to 1 MiB (e.g., the THP size on s390x) */
30
+#define ARM_CP_FLAG_MASK 0x30ff
39
-#define VIRTIO_MEM_DEFAULT_THP_SIZE VIRTIO_MEM_MIN_BLOCK_SIZE
31
40
+static uint32_t virtio_mem_default_thp_size(void)
32
/* Valid values for ARMCPRegInfo state field, indicating which of
33
* the AArch32 and AArch64 execution states this register is visible in.
34
diff --git a/target/arm/internals.h b/target/arm/internals.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/arm/internals.h
37
+++ b/target/arm/internals.h
38
@@ -XXX,XX +XXX,XX @@ enum arm_exception_class {
39
EC_AA64_HVC = 0x16,
40
EC_AA64_SMC = 0x17,
41
EC_SYSTEMREGISTERTRAP = 0x18,
42
+ EC_SVEACCESSTRAP = 0x19,
43
EC_INSNABORT = 0x20,
44
EC_INSNABORT_SAME_EL = 0x21,
45
EC_PCALIGNMENT = 0x22,
46
@@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit)
47
| (cv << 24) | (cond << 20);
48
}
49
50
+static inline uint32_t syn_sve_access_trap(void)
51
+{
41
+{
52
+ return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT;
42
+ uint32_t default_thp_size = VIRTIO_MEM_MIN_BLOCK_SIZE;
53
+}
54
+
43
+
55
static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
44
+#if defined(__x86_64__) || defined(__arm__) || defined(__powerpc64__)
56
{
45
+ default_thp_size = 2 * MiB;
57
return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
46
+#elif defined(__aarch64__)
58
diff --git a/target/arm/helper.c b/target/arm/helper.c
47
+ if (qemu_real_host_page_size == 4 * KiB) {
59
index XXXXXXX..XXXXXXX 100644
48
+ default_thp_size = 2 * MiB;
60
--- a/target/arm/helper.c
49
+ } else if (qemu_real_host_page_size == 16 * KiB) {
61
+++ b/target/arm/helper.c
50
+ default_thp_size = 32 * MiB;
62
@@ -XXX,XX +XXX,XX @@ static int sve_exception_el(CPUARMState *env)
51
+ } else if (qemu_real_host_page_size == 64 * KiB) {
63
return 0;
52
+ default_thp_size = 512 * MiB;
64
}
65
66
-static CPAccessResult zcr_access(CPUARMState *env, const ARMCPRegInfo *ri,
67
- bool isread)
68
-{
69
- switch (sve_exception_el(env)) {
70
- case 3:
71
- return CP_ACCESS_TRAP_EL3;
72
- case 2:
73
- return CP_ACCESS_TRAP_EL2;
74
- case 1:
75
- return CP_ACCESS_TRAP;
76
- }
77
- return CP_ACCESS_OK;
78
-}
79
-
80
static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
81
uint64_t value)
82
{
83
@@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
84
static const ARMCPRegInfo zcr_el1_reginfo = {
85
.name = "ZCR_EL1", .state = ARM_CP_STATE_AA64,
86
.opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0,
87
- .access = PL1_RW, .accessfn = zcr_access,
88
+ .access = PL1_RW, .type = ARM_CP_SVE | ARM_CP_FPU,
89
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]),
90
.writefn = zcr_write, .raw_writefn = raw_write
91
};
92
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el1_reginfo = {
93
static const ARMCPRegInfo zcr_el2_reginfo = {
94
.name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
95
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
96
- .access = PL2_RW, .accessfn = zcr_access,
97
+ .access = PL2_RW, .type = ARM_CP_SVE | ARM_CP_FPU,
98
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]),
99
.writefn = zcr_write, .raw_writefn = raw_write
100
};
101
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el2_reginfo = {
102
static const ARMCPRegInfo zcr_no_el2_reginfo = {
103
.name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
104
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
105
- .access = PL2_RW,
106
+ .access = PL2_RW, .type = ARM_CP_SVE | ARM_CP_FPU,
107
.readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore
108
};
109
110
static const ARMCPRegInfo zcr_el3_reginfo = {
111
.name = "ZCR_EL3", .state = ARM_CP_STATE_AA64,
112
.opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0,
113
- .access = PL3_RW, .accessfn = zcr_access,
114
+ .access = PL3_RW, .type = ARM_CP_SVE | ARM_CP_FPU,
115
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]),
116
.writefn = zcr_write, .raw_writefn = raw_write
117
};
118
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
119
index XXXXXXX..XXXXXXX 100644
120
--- a/target/arm/translate-a64.c
121
+++ b/target/arm/translate-a64.c
122
@@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s)
123
return false;
124
}
125
126
+/* Check that SVE access is enabled. If it is, return true.
127
+ * If not, emit code to generate an appropriate exception and return false.
128
+ */
129
+static inline bool sve_access_check(DisasContext *s)
130
+{
131
+ if (s->sve_excp_el) {
132
+ gen_exception_insn(s, 4, EXCP_UDEF, syn_sve_access_trap(),
133
+ s->sve_excp_el);
134
+ return false;
135
+ }
53
+ }
136
+ return true;
54
#endif
55
56
+ return default_thp_size;
137
+}
57
+}
138
+
58
+
139
/*
59
/*
140
* This utility function is for doing register extension with an
60
* We want to have a reasonable default block size such that
141
* optional shift. You will likely want to pass a temporary for the
61
* 1. We avoid splitting THPs when unplugging memory, which degrades
142
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
62
@@ -XXX,XX +XXX,XX @@ static uint32_t virtio_mem_thp_size(void)
143
default:
63
if (g_file_get_contents(HPAGE_PMD_SIZE_PATH, &content, NULL, NULL) &&
144
break;
64
!qemu_strtou64(content, &endptr, 0, &tmp) &&
65
(!endptr || *endptr == '\n')) {
66
- /*
67
- * Sanity-check the value, if it's too big (e.g., aarch64 with 64k base
68
- * pages) or weird, fallback to something smaller.
69
- */
70
- if (!tmp || !is_power_of_2(tmp) || tmp > 16 * MiB) {
71
+ /* Sanity-check the value and fallback to something reasonable. */
72
+ if (!tmp || !is_power_of_2(tmp)) {
73
warn_report("Read unsupported THP size: %" PRIx64, tmp);
74
} else {
75
thp_size = tmp;
76
@@ -XXX,XX +XXX,XX @@ static uint32_t virtio_mem_thp_size(void)
145
}
77
}
146
+ if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) {
78
147
+ return;
79
if (!thp_size) {
148
+ }
80
- thp_size = VIRTIO_MEM_DEFAULT_THP_SIZE;
149
if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) {
81
+ thp_size = virtio_mem_default_thp_size();
150
return;
82
warn_report("Could not detect THP size, falling back to %" PRIx64
83
" MiB.", thp_size / MiB);
151
}
84
}
152
--
85
--
153
2.16.1
86
2.25.1
154
87
155
88
diff view generated by jsdifflib
1
M profile cores have a similar setup for cache ID registers
1
From: Gavin Shan <gshan@redhat.com>
2
to A profile:
3
* Cache Level ID Register (CLIDR) is a fixed value
4
* Cache Type Register (CTR) is a fixed value
5
* Cache Size ID Registers (CCSIDR) are a bank of registers;
6
which one you see is selected by the Cache Size Selection
7
Register (CSSELR)
8
2
9
The only difference is that they're in the NVIC memory mapped
3
This supports virtio-mem-pci device on "virt" platform, by simply
10
register space rather than being coprocessor registers.
4
following the implementation on x86.
11
Implement the M profile view of them.
12
5
13
Since neither Cortex-M3 nor Cortex-M4 implement caches,
6
* This implements the hotplug handlers to support virtio-mem-pci
14
we don't need to update their init functions and can leave
7
device hot-add, while the hot-remove isn't supported as we have
15
the ctr/clidr/ccsidr[] fields in their ARMCPU structs at zero.
8
on x86.
16
Newer cores (like the Cortex-M33) will want to be able to
17
set these ID registers to non-zero values, though.
18
9
10
* The block size is 512MB on ARM64 instead of 128MB on x86.
11
12
* It has been passing the tests with various combinations like 64KB
13
and 4KB page sizes on host and guest, different memory device
14
backends like normal, transparent huge page and HugeTLB, plus
15
migration.
16
17
Co-developed-by: David Hildenbrand <david@redhat.com>
18
Co-developed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
19
Signed-off-by: Gavin Shan <gshan@redhat.com>
20
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
21
Reviewed-by: David Hildenbrand <david@redhat.com>
22
Message-id: 20220111063329.74447-3-gshan@redhat.com
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Message-id: 20180209165810.6668-6-peter.maydell@linaro.org
22
---
24
---
23
target/arm/cpu.h | 26 ++++++++++++++++++++++++++
25
hw/arm/virt.c | 70 ++++++++++++++++++++++++++++++++++++++++++
24
hw/intc/armv7m_nvic.c | 16 ++++++++++++++++
26
hw/virtio/virtio-mem.c | 4 ++-
25
target/arm/machine.c | 36 ++++++++++++++++++++++++++++++++++++
27
hw/arm/Kconfig | 1 +
26
3 files changed, 78 insertions(+)
28
3 files changed, 74 insertions(+), 1 deletion(-)
27
29
28
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
30
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
29
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/cpu.h
32
--- a/hw/arm/virt.c
31
+++ b/target/arm/cpu.h
33
+++ b/hw/arm/virt.c
32
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
34
@@ -XXX,XX +XXX,XX @@
33
uint32_t faultmask[M_REG_NUM_BANKS];
35
#include "hw/arm/smmuv3.h"
34
uint32_t aircr; /* only holds r/w state if security extn implemented */
36
#include "hw/acpi/acpi.h"
35
uint32_t secure; /* Is CPU in Secure state? (not guest visible) */
37
#include "target/arm/internals.h"
36
+ uint32_t csselr[M_REG_NUM_BANKS];
38
+#include "hw/mem/memory-device.h"
37
} v7m;
39
#include "hw/mem/pc-dimm.h"
38
40
#include "hw/mem/nvdimm.h"
39
/* Information associated with an exception about to be taken:
41
#include "hw/acpi/generic_event_device.h"
40
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_MPU_CTRL, ENABLE, 0, 1)
42
+#include "hw/virtio/virtio-mem-pci.h"
41
FIELD(V7M_MPU_CTRL, HFNMIENA, 1, 1)
43
#include "hw/virtio/virtio-iommu.h"
42
FIELD(V7M_MPU_CTRL, PRIVDEFENA, 2, 1)
44
#include "hw/char/pl011.h"
43
45
#include "qemu/guest-random.h"
44
+/* v7M CLIDR bits */
46
@@ -XXX,XX +XXX,XX @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
45
+FIELD(V7M_CLIDR, CTYPE_ALL, 0, 21)
47
dev, &error_abort);
46
+FIELD(V7M_CLIDR, LOUIS, 21, 3)
48
}
47
+FIELD(V7M_CLIDR, LOC, 24, 3)
49
48
+FIELD(V7M_CLIDR, LOUU, 27, 3)
50
+static void virt_virtio_md_pci_pre_plug(HotplugHandler *hotplug_dev,
49
+FIELD(V7M_CLIDR, ICB, 30, 2)
51
+ DeviceState *dev, Error **errp)
52
+{
53
+ HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
54
+ Error *local_err = NULL;
50
+
55
+
51
+FIELD(V7M_CSSELR, IND, 0, 1)
56
+ if (!hotplug_dev2 && dev->hotplugged) {
52
+FIELD(V7M_CSSELR, LEVEL, 1, 3)
57
+ /*
53
+/* We use the combination of InD and Level to index into cpu->ccsidr[];
58
+ * Without a bus hotplug handler, we cannot control the plug/unplug
54
+ * define a mask for this and check that it doesn't permit running off
59
+ * order. We should never reach this point when hotplugging on ARM.
55
+ * the end of the array.
60
+ * However, it's nice to add a safety net, similar to what we have
56
+ */
61
+ * on x86.
57
+FIELD(V7M_CSSELR, INDEX, 0, 4)
62
+ */
58
+
63
+ error_setg(errp, "hotplug of virtio based memory devices not supported"
59
+QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK);
64
+ " on this bus.");
60
+
65
+ return;
61
/* If adding a feature bit which corresponds to a Linux ELF
66
+ }
62
* HWCAP bit, remember to update the feature-bit-to-hwcap
67
+ /*
63
* mapping in linux-user/elfload.c:get_elf_hwcap().
68
+ * First, see if we can plug this memory device at all. If that
64
@@ -XXX,XX +XXX,XX @@ static inline int arm_debug_target_el(CPUARMState *env)
69
+ * succeeds, branch of to the actual hotplug handler.
65
}
66
}
67
68
+static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu)
69
+{
70
+ /* If all the CLIDR.Ctypem bits are 0 there are no caches, and
71
+ * CSSELR is RAZ/WI.
72
+ */
70
+ */
73
+ return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0;
71
+ memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), NULL,
72
+ &local_err);
73
+ if (!local_err && hotplug_dev2) {
74
+ hotplug_handler_pre_plug(hotplug_dev2, dev, &local_err);
75
+ }
76
+ error_propagate(errp, local_err);
74
+}
77
+}
75
+
78
+
76
static inline bool aa64_generate_debug_exceptions(CPUARMState *env)
79
+static void virt_virtio_md_pci_plug(HotplugHandler *hotplug_dev,
77
{
80
+ DeviceState *dev, Error **errp)
78
if (arm_is_secure(env)) {
81
+{
79
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
82
+ HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
80
index XXXXXXX..XXXXXXX 100644
83
+ Error *local_err = NULL;
81
--- a/hw/intc/armv7m_nvic.c
84
+
82
+++ b/hw/intc/armv7m_nvic.c
85
+ /*
83
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
86
+ * Plug the memory device first and then branch off to the actual
84
return cpu->id_isar4;
87
+ * hotplug handler. If that one fails, we can easily undo the memory
85
case 0xd74: /* ISAR5. */
88
+ * device bits.
86
return cpu->id_isar5;
89
+ */
87
+ case 0xd78: /* CLIDR */
90
+ memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
88
+ return cpu->clidr;
91
+ if (hotplug_dev2) {
89
+ case 0xd7c: /* CTR */
92
+ hotplug_handler_plug(hotplug_dev2, dev, &local_err);
90
+ return cpu->ctr;
93
+ if (local_err) {
91
+ case 0xd80: /* CSSIDR */
94
+ memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
92
+ {
95
+ }
93
+ int idx = cpu->env.v7m.csselr[attrs.secure] & R_V7M_CSSELR_INDEX_MASK;
94
+ return cpu->ccsidr[idx];
95
+ }
96
+ }
96
+ case 0xd84: /* CSSELR */
97
+ error_propagate(errp, local_err);
97
+ return cpu->env.v7m.csselr[attrs.secure];
98
/* TODO: Implement debug registers. */
99
case 0xd90: /* MPU_TYPE */
100
/* Unified MPU; if the MPU is not present this value is zero */
101
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
102
qemu_log_mask(LOG_UNIMP,
103
"NVIC: Aux fault status registers unimplemented\n");
104
break;
105
+ case 0xd84: /* CSSELR */
106
+ if (!arm_v7m_csselr_razwi(cpu)) {
107
+ cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK;
108
+ }
109
+ break;
110
case 0xd90: /* MPU_TYPE */
111
return; /* RO */
112
case 0xd94: /* MPU_CTRL */
113
diff --git a/target/arm/machine.c b/target/arm/machine.c
114
index XXXXXXX..XXXXXXX 100644
115
--- a/target/arm/machine.c
116
+++ b/target/arm/machine.c
117
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_faultmask_primask = {
118
}
119
};
120
121
+/* CSSELR is in a subsection because we didn't implement it previously.
122
+ * Migration from an old implementation will leave it at zero, which
123
+ * is OK since the only CPUs in the old implementation make the
124
+ * register RAZ/WI.
125
+ * Since there was no version of QEMU which implemented the CSSELR for
126
+ * just non-secure, we transfer both banks here rather than putting
127
+ * the secure banked version in the m-security subsection.
128
+ */
129
+static bool csselr_vmstate_validate(void *opaque, int version_id)
130
+{
131
+ ARMCPU *cpu = opaque;
132
+
133
+ return cpu->env.v7m.csselr[M_REG_NS] <= R_V7M_CSSELR_INDEX_MASK
134
+ && cpu->env.v7m.csselr[M_REG_S] <= R_V7M_CSSELR_INDEX_MASK;
135
+}
98
+}
136
+
99
+
137
+static bool m_csselr_needed(void *opaque)
100
+static void virt_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev,
101
+ DeviceState *dev, Error **errp)
138
+{
102
+{
139
+ ARMCPU *cpu = opaque;
103
+ /* We don't support hot unplug of virtio based memory devices */
140
+
104
+ error_setg(errp, "virtio based memory devices cannot be unplugged.");
141
+ return !arm_v7m_csselr_razwi(cpu);
142
+}
105
+}
143
+
106
+
144
+static const VMStateDescription vmstate_m_csselr = {
107
+
145
+ .name = "cpu/m/csselr",
108
static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
146
+ .version_id = 1,
109
DeviceState *dev, Error **errp)
147
+ .minimum_version_id = 1,
110
{
148
+ .needed = m_csselr_needed,
111
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
149
+ .fields = (VMStateField[]) {
112
150
+ VMSTATE_UINT32_ARRAY(env.v7m.csselr, ARMCPU, M_REG_NUM_BANKS),
113
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
151
+ VMSTATE_VALIDATE("CSSELR is valid", csselr_vmstate_validate),
114
virt_memory_pre_plug(hotplug_dev, dev, errp);
152
+ VMSTATE_END_OF_LIST()
115
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
116
+ virt_virtio_md_pci_pre_plug(hotplug_dev, dev, errp);
117
} else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
118
hwaddr db_start = 0, db_end = 0;
119
char *resv_prop_str;
120
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
121
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
122
virt_memory_plug(hotplug_dev, dev, errp);
123
}
124
+
125
+ if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
126
+ virt_virtio_md_pci_plug(hotplug_dev, dev, errp);
153
+ }
127
+ }
154
+};
155
+
128
+
156
static const VMStateDescription vmstate_m = {
129
if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
157
.name = "cpu/m",
130
PCIDevice *pdev = PCI_DEVICE(dev);
158
.version_id = 4,
131
159
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
132
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
160
},
133
{
161
.subsections = (const VMStateDescription*[]) {
134
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
162
&vmstate_m_faultmask_primask,
135
virt_dimm_unplug_request(hotplug_dev, dev, errp);
163
+ &vmstate_m_csselr,
136
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
164
NULL
137
+ virt_virtio_md_pci_unplug_request(hotplug_dev, dev, errp);
138
} else {
139
error_setg(errp, "device unplug request for unsupported device"
140
" type: %s", object_get_typename(OBJECT(dev)));
141
@@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
142
143
if (device_is_dynamic_sysbus(mc, dev) ||
144
object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
145
+ object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) ||
146
object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
147
return HOTPLUG_HANDLER(machine);
165
}
148
}
166
};
149
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
150
index XXXXXXX..XXXXXXX 100644
151
--- a/hw/virtio/virtio-mem.c
152
+++ b/hw/virtio/virtio-mem.c
153
@@ -XXX,XX +XXX,XX @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
154
* The memory block size corresponds mostly to the section size.
155
*
156
* This allows e.g., to add 20MB with a section size of 128MB on x86_64, and
157
- * a section size of 1GB on arm64 (as long as the start address is properly
158
+ * a section size of 512MB on arm64 (as long as the start address is properly
159
* aligned, similar to ordinary DIMMs).
160
*
161
* We can change this at any time and maybe even make it configurable if
162
@@ -XXX,XX +XXX,XX @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
163
*/
164
#if defined(TARGET_X86_64) || defined(TARGET_I386)
165
#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB))
166
+#elif defined(TARGET_ARM)
167
+#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB))
168
#else
169
#error VIRTIO_MEM_USABLE_EXTENT not defined
170
#endif
171
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
172
index XXXXXXX..XXXXXXX 100644
173
--- a/hw/arm/Kconfig
174
+++ b/hw/arm/Kconfig
175
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
176
select ACPI_HW_REDUCED
177
select ACPI_APEI
178
select ACPI_VIOT
179
+ select VIRTIO_MEM_SUPPORTED
180
181
config CHEETAH
182
bool
167
--
183
--
168
2.16.1
184
2.25.1
169
185
170
186
diff view generated by jsdifflib
1
For M profile cores, cache maintenance operations are done by
1
From: Petr Pavlu <petr.pavlu@suse.com>
2
writing to special registers in the system register space.
3
For QEMU, cache operations are always NOPs, since we don't
4
implement the cache. Implementing these explicitly avoids
5
a spurious LOG_GUEST_ERROR when the guest uses them.
6
2
3
Implement support for reading GICC_IIDR. This register is used by the
4
Linux kernel to recognize that GICv2 with GICC_APRn is present.
5
6
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
7
Message-id: 20220113151916.17978-2-ppavlu@suse.cz
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180209165810.6668-4-peter.maydell@linaro.org
10
---
10
---
11
hw/intc/armv7m_nvic.c | 12 ++++++++++++
11
hw/intc/arm_gic.c | 9 +++++++++
12
1 file changed, 12 insertions(+)
12
1 file changed, 9 insertions(+)
13
13
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
16
--- a/hw/intc/arm_gic.c
17
+++ b/hw/intc/armv7m_nvic.c
17
+++ b/hw/intc/arm_gic.c
18
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
18
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_read(GICState *s, int cpu, int offset,
19
}
19
}
20
break;
20
break;
21
}
21
}
22
+ case 0xf50: /* ICIALLU */
22
+ case 0xfc:
23
+ case 0xf58: /* ICIMVAU */
23
+ if (s->revision == REV_11MPCORE) {
24
+ case 0xf5c: /* DCIMVAC */
24
+ /* Reserved on 11MPCore */
25
+ case 0xf60: /* DCISW */
25
+ *data = 0;
26
+ case 0xf64: /* DCCMVAU */
26
+ } else {
27
+ case 0xf68: /* DCCMVAC */
27
+ /* GICv1 or v2; Arm implementation */
28
+ case 0xf6c: /* DCCSW */
28
+ *data = (s->revision << 16) | 0x43b;
29
+ case 0xf70: /* DCCIMVAC */
29
+ }
30
+ case 0xf74: /* DCCISW */
31
+ case 0xf78: /* BPIALL */
32
+ /* Cache and branch predictor maintenance: for QEMU these always NOP */
33
+ break;
30
+ break;
34
default:
31
default:
35
bad_offset:
36
qemu_log_mask(LOG_GUEST_ERROR,
32
qemu_log_mask(LOG_GUEST_ERROR,
33
"gic_cpu_read: Bad offset %x\n", (int)offset);
37
--
34
--
38
2.16.1
35
2.25.1
39
36
40
37
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Petr Pavlu <petr.pavlu@suse.com>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
When running Linux on a machine with GICv2, the kernel can crash while
4
Message-id: 20180211205848.4568-3-richard.henderson@linaro.org
4
processing an interrupt and can subsequently start a kdump kernel from
5
the active interrupt handler. In such a case, the crashed kernel might
6
not gracefully signal the end of interrupt to the GICv2 hardware. The
7
kdump kernel will however try to reset the GIC state on startup to get
8
the controller into a sane state, in particular the kernel writes ones
9
to GICD_ICACTIVERn and wipes out GICC_APRn to make sure that no
10
interrupt is active.
11
12
The patch adds a logic to recalculate the running priority when
13
GICC_APRn/GICC_NSAPRn is written which makes sure that the mentioned
14
reset works with the GICv2 emulation in QEMU too and the kdump kernel
15
starts receiving interrupts.
16
17
The described scenario can be reproduced on an AArch64 QEMU virt machine
18
with a kdump-enabled Linux system by using the softdog module. The kdump
19
kernel will hang at some point because QEMU still thinks the running
20
priority is that of the timer interrupt and asserts no new interrupts to
21
the system:
22
$ modprobe softdog soft_margin=10 soft_panic=1
23
$ cat > /dev/watchdog
24
[Press Enter to start the watchdog, wait for its timeout and observe
25
that the kdump kernel hangs on startup.]
26
27
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
28
Message-id: 20220113151916.17978-3-ppavlu@suse.cz
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
29
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
31
---
8
target/arm/cpu.h | 35 ++++++++++++++++++-----------------
32
hw/intc/arm_gic.c | 2 ++
9
target/arm/helper.c | 6 ++++--
33
1 file changed, 2 insertions(+)
10
target/arm/translate-a64.c | 3 +++
11
3 files changed, 25 insertions(+), 19 deletions(-)
12
34
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
35
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
14
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
37
--- a/hw/intc/arm_gic.c
16
+++ b/target/arm/cpu.h
38
+++ b/hw/intc/arm_gic.c
17
@@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
39
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,
18
}
40
} else {
19
41
s->apr[regno][cpu] = value;
20
/* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a
42
}
21
- * special-behaviour cp reg and bits [15..8] indicate what behaviour
43
+ s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu);
22
+ * special-behaviour cp reg and bits [11..8] indicate what behaviour
23
* it has. Otherwise it is a simple cp reg, where CONST indicates that
24
* TCG can assume the value to be constant (ie load at translate time)
25
* and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END
26
@@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
27
* need to be surrounded by gen_io_start()/gen_io_end(). In particular,
28
* registers which implement clocks or timers require this.
29
*/
30
-#define ARM_CP_SPECIAL 1
31
-#define ARM_CP_CONST 2
32
-#define ARM_CP_64BIT 4
33
-#define ARM_CP_SUPPRESS_TB_END 8
34
-#define ARM_CP_OVERRIDE 16
35
-#define ARM_CP_ALIAS 32
36
-#define ARM_CP_IO 64
37
-#define ARM_CP_NO_RAW 128
38
-#define ARM_CP_NOP (ARM_CP_SPECIAL | (1 << 8))
39
-#define ARM_CP_WFI (ARM_CP_SPECIAL | (2 << 8))
40
-#define ARM_CP_NZCV (ARM_CP_SPECIAL | (3 << 8))
41
-#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | (4 << 8))
42
-#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | (5 << 8))
43
-#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA
44
+#define ARM_CP_SPECIAL 0x0001
45
+#define ARM_CP_CONST 0x0002
46
+#define ARM_CP_64BIT 0x0004
47
+#define ARM_CP_SUPPRESS_TB_END 0x0008
48
+#define ARM_CP_OVERRIDE 0x0010
49
+#define ARM_CP_ALIAS 0x0020
50
+#define ARM_CP_IO 0x0040
51
+#define ARM_CP_NO_RAW 0x0080
52
+#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100)
53
+#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200)
54
+#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300)
55
+#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400)
56
+#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500)
57
+#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA
58
+#define ARM_CP_FPU 0x1000
59
/* Used only as a terminator for ARMCPRegInfo lists */
60
-#define ARM_CP_SENTINEL 0xffff
61
+#define ARM_CP_SENTINEL 0xffff
62
/* Mask of only the flag bits in a type field */
63
-#define ARM_CP_FLAG_MASK 0xff
64
+#define ARM_CP_FLAG_MASK 0x10ff
65
66
/* Valid values for ARMCPRegInfo state field, indicating which of
67
* the AArch32 and AArch64 execution states this register is visible in.
68
diff --git a/target/arm/helper.c b/target/arm/helper.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/target/arm/helper.c
71
+++ b/target/arm/helper.c
72
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
73
.writefn = aa64_daif_write, .resetfn = arm_cp_reset_ignore },
74
{ .name = "FPCR", .state = ARM_CP_STATE_AA64,
75
.opc0 = 3, .opc1 = 3, .opc2 = 0, .crn = 4, .crm = 4,
76
- .access = PL0_RW, .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write },
77
+ .access = PL0_RW, .type = ARM_CP_FPU,
78
+ .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write },
79
{ .name = "FPSR", .state = ARM_CP_STATE_AA64,
80
.opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4,
81
- .access = PL0_RW, .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write },
82
+ .access = PL0_RW, .type = ARM_CP_FPU,
83
+ .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write },
84
{ .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64,
85
.opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0,
86
.access = PL0_R, .type = ARM_CP_NO_RAW,
87
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/target/arm/translate-a64.c
90
+++ b/target/arm/translate-a64.c
91
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
92
default:
93
break;
44
break;
94
}
45
}
95
+ if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) {
46
case 0xe0: case 0xe4: case 0xe8: case 0xec:
96
+ return;
47
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,
97
+ }
48
return MEMTX_OK;
98
49
}
99
if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) {
50
s->nsapr[regno][cpu] = value;
100
gen_io_start();
51
+ s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu);
52
break;
53
}
54
case 0x1000:
101
--
55
--
102
2.16.1
56
2.25.1
103
57
104
58
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
Just like we can control the enablement of the highmem PCIe ECAM
4
region using highmem_ecam, let's add a control for the highmem
5
PCIe MMIO region.
6
7
Similarily to highmem_ecam, this region is disabled when highmem
8
is off.
9
10
Signed-off-by: Marc Zyngier <maz@kernel.org>
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
Message-id: 20220114140741.1358263-2-maz@kernel.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
include/hw/arm/virt.h | 1 +
16
hw/arm/virt-acpi-build.c | 10 ++++------
17
hw/arm/virt.c | 7 +++++--
18
3 files changed, 10 insertions(+), 8 deletions(-)
19
20
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/arm/virt.h
23
+++ b/include/hw/arm/virt.h
24
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
25
bool secure;
26
bool highmem;
27
bool highmem_ecam;
28
+ bool highmem_mmio;
29
bool its;
30
bool tcg_its;
31
bool virt;
32
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/virt-acpi-build.c
35
+++ b/hw/arm/virt-acpi-build.c
36
@@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_virtio(Aml *scope,
37
}
38
39
static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
40
- uint32_t irq, bool use_highmem, bool highmem_ecam,
41
- VirtMachineState *vms)
42
+ uint32_t irq, VirtMachineState *vms)
43
{
44
- int ecam_id = VIRT_ECAM_ID(highmem_ecam);
45
+ int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
46
struct GPEXConfig cfg = {
47
.mmio32 = memmap[VIRT_PCIE_MMIO],
48
.pio = memmap[VIRT_PCIE_PIO],
49
@@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
50
.bus = vms->bus,
51
};
52
53
- if (use_highmem) {
54
+ if (vms->highmem_mmio) {
55
cfg.mmio64 = memmap[VIRT_HIGH_PCIE_MMIO];
56
}
57
58
@@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
59
acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
60
acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
61
(irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
62
- acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
63
- vms->highmem, vms->highmem_ecam, vms);
64
+ acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms);
65
if (vms->acpi_dev) {
66
build_ged_aml(scope, "\\_SB."GED_DEVICE,
67
HOTPLUG_HANDLER(vms->acpi_dev),
68
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/arm/virt.c
71
+++ b/hw/arm/virt.c
72
@@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms)
73
mmio_reg, base_mmio, size_mmio);
74
memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);
75
76
- if (vms->highmem) {
77
+ if (vms->highmem_mmio) {
78
/* Map high MMIO space */
79
MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1);
80
81
@@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms)
82
qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg",
83
2, base_ecam, 2, size_ecam);
84
85
- if (vms->highmem) {
86
+ if (vms->highmem_mmio) {
87
qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "ranges",
88
1, FDT_PCI_RANGE_IOPORT, 2, 0,
89
2, base_pio, 2, size_pio,
90
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
91
92
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
93
94
+ vms->highmem_mmio &= vms->highmem;
95
+
96
create_gic(vms, sysmem);
97
98
virt_cpu_post_init(vms, sysmem);
99
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
100
vms->gic_version = VIRT_GIC_VERSION_NOSEL;
101
102
vms->highmem_ecam = !vmc->no_highmem_ecam;
103
+ vms->highmem_mmio = true;
104
105
if (vmc->no_its) {
106
vms->its = false;
107
--
108
2.25.1
109
110
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
Just like we can control the enablement of the highmem PCIe region
4
using highmem_ecam, let's add a control for the highmem GICv3
5
redistributor region.
6
7
Similarily to highmem_ecam, these redistributors are disabled when
8
highmem is off.
9
10
Reviewed-by: Andrew Jones <drjones@redhat.com>
11
Signed-off-by: Marc Zyngier <maz@kernel.org>
12
Reviewed-by: Eric Auger <eric.auger@redhat.com>
13
Message-id: 20220114140741.1358263-3-maz@kernel.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
include/hw/arm/virt.h | 4 +++-
17
hw/arm/virt-acpi-build.c | 2 ++
18
hw/arm/virt.c | 2 ++
19
3 files changed, 7 insertions(+), 1 deletion(-)
20
21
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/virt.h
24
+++ b/include/hw/arm/virt.h
25
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
26
bool highmem;
27
bool highmem_ecam;
28
bool highmem_mmio;
29
+ bool highmem_redists;
30
bool its;
31
bool tcg_its;
32
bool virt;
33
@@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
34
35
assert(vms->gic_version == VIRT_GIC_VERSION_3);
36
37
- return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1;
38
+ return (MACHINE(vms)->smp.cpus > redist0_capacity &&
39
+ vms->highmem_redists) ? 2 : 1;
40
}
41
42
#endif /* QEMU_ARM_VIRT_H */
43
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/arm/virt-acpi-build.c
46
+++ b/hw/arm/virt-acpi-build.c
47
@@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
48
acpi_add_table(table_offsets, tables_blob);
49
build_fadt_rev5(tables_blob, tables->linker, vms, dsdt);
50
51
+ vms->highmem_redists &= vms->highmem;
52
+
53
acpi_add_table(table_offsets, tables_blob);
54
build_madt(tables_blob, tables->linker, vms);
55
56
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/arm/virt.c
59
+++ b/hw/arm/virt.c
60
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
61
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
62
63
vms->highmem_mmio &= vms->highmem;
64
+ vms->highmem_redists &= vms->highmem;
65
66
create_gic(vms, sysmem);
67
68
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
69
70
vms->highmem_ecam = !vmc->no_highmem_ecam;
71
vms->highmem_mmio = true;
72
+ vms->highmem_redists = true;
73
74
if (vmc->no_its) {
75
vms->its = false;
76
--
77
2.25.1
78
79
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
Even when the VM is configured with highmem=off, the highest_gpa
4
field includes devices that are above the 4GiB limit.
5
Similarily, nothing seem to check that the memory is within
6
the limit set by the highmem=off option.
7
8
This leads to failures in virt_kvm_type() on systems that have
9
a crippled IPA range, as the reported IPA space is larger than
10
what it should be.
11
12
Instead, honor the user-specified limit to only use the devices
13
at the lowest end of the spectrum, and fail if we have memory
14
crossing the 4GiB limit.
15
16
Reviewed-by: Andrew Jones <drjones@redhat.com>
17
Reviewed-by: Eric Auger <eric.auger@redhat.com>
18
Signed-off-by: Marc Zyngier <maz@kernel.org>
19
Message-id: 20220114140741.1358263-4-maz@kernel.org
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
22
hw/arm/virt.c | 10 +++++++---
23
1 file changed, 7 insertions(+), 3 deletions(-)
24
25
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/arm/virt.c
28
+++ b/hw/arm/virt.c
29
@@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
30
static void virt_set_memmap(VirtMachineState *vms)
31
{
32
MachineState *ms = MACHINE(vms);
33
- hwaddr base, device_memory_base, device_memory_size;
34
+ hwaddr base, device_memory_base, device_memory_size, memtop;
35
int i;
36
37
vms->memmap = extended_memmap;
38
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
39
device_memory_size = ms->maxram_size - ms->ram_size + ms->ram_slots * GiB;
40
41
/* Base address of the high IO region */
42
- base = device_memory_base + ROUND_UP(device_memory_size, GiB);
43
+ memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
44
+ if (!vms->highmem && memtop > 4 * GiB) {
45
+ error_report("highmem=off, but memory crosses the 4GiB limit\n");
46
+ exit(EXIT_FAILURE);
47
+ }
48
if (base < device_memory_base) {
49
error_report("maxmem/slots too huge");
50
exit(EXIT_FAILURE);
51
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
52
vms->memmap[i].size = size;
53
base += size;
54
}
55
- vms->highest_gpa = base - 1;
56
+ vms->highest_gpa = (vms->highmem ? base : memtop) - 1;
57
if (device_memory_size > 0) {
58
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
59
ms->device_memory->base = device_memory_base;
60
--
61
2.25.1
62
63
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
The highmem attribute is nothing but another way to express the
4
PA range of a VM. To support HW that has a smaller PA range then
5
what QEMU assumes, pass this PA range to the virt_set_memmap()
6
function, allowing it to correctly exclude highmem devices
7
if they are outside of the PA range.
8
9
Signed-off-by: Marc Zyngier <maz@kernel.org>
10
Reviewed-by: Eric Auger <eric.auger@redhat.com>
11
Message-id: 20220114140741.1358263-5-maz@kernel.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/arm/virt.c | 64 +++++++++++++++++++++++++++++++++++++++++----------
15
1 file changed, 52 insertions(+), 12 deletions(-)
16
17
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/virt.c
20
+++ b/hw/arm/virt.c
21
@@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
22
return arm_cpu_mp_affinity(idx, clustersz);
23
}
24
25
-static void virt_set_memmap(VirtMachineState *vms)
26
+static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
27
{
28
MachineState *ms = MACHINE(vms);
29
hwaddr base, device_memory_base, device_memory_size, memtop;
30
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
31
exit(EXIT_FAILURE);
32
}
33
34
+ /*
35
+ * !highmem is exactly the same as limiting the PA space to 32bit,
36
+ * irrespective of the underlying capabilities of the HW.
37
+ */
38
+ if (!vms->highmem) {
39
+ pa_bits = 32;
40
+ }
41
+
42
/*
43
* We compute the base of the high IO region depending on the
44
* amount of initial and device memory. The device memory start/size
45
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
46
47
/* Base address of the high IO region */
48
memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
49
- if (!vms->highmem && memtop > 4 * GiB) {
50
- error_report("highmem=off, but memory crosses the 4GiB limit\n");
51
+ if (memtop > BIT_ULL(pa_bits)) {
52
+     error_report("Addressing limited to %d bits, but memory exceeds it by %llu bytes\n",
53
+             pa_bits, memtop - BIT_ULL(pa_bits));
54
exit(EXIT_FAILURE);
55
}
56
if (base < device_memory_base) {
57
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
58
vms->memmap[i].size = size;
59
base += size;
60
}
61
- vms->highest_gpa = (vms->highmem ? base : memtop) - 1;
62
+
63
+ /*
64
+ * If base fits within pa_bits, all good. If it doesn't, limit it
65
+ * to the end of RAM, which is guaranteed to fit within pa_bits.
66
+ */
67
+ vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1;
68
+
69
if (device_memory_size > 0) {
70
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
71
ms->device_memory->base = device_memory_base;
72
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
73
unsigned int smp_cpus = machine->smp.cpus;
74
unsigned int max_cpus = machine->smp.max_cpus;
75
76
+ if (!cpu_type_valid(machine->cpu_type)) {
77
+ error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
78
+ exit(1);
79
+ }
80
+
81
+ possible_cpus = mc->possible_cpu_arch_ids(machine);
82
+
83
/*
84
* In accelerated mode, the memory map is computed earlier in kvm_type()
85
* to create a VM with the right number of IPA bits.
86
*/
87
if (!vms->memmap) {
88
- virt_set_memmap(vms);
89
+ Object *cpuobj;
90
+ ARMCPU *armcpu;
91
+ int pa_bits;
92
+
93
+ /*
94
+ * Instanciate a temporary CPU object to find out about what
95
+ * we are about to deal with. Once this is done, get rid of
96
+ * the object.
97
+ */
98
+ cpuobj = object_new(possible_cpus->cpus[0].type);
99
+ armcpu = ARM_CPU(cpuobj);
100
+
101
+ if (object_property_get_bool(cpuobj, "aarch64", NULL)) {
102
+ pa_bits = arm_pamax(armcpu);
103
+ } else if (arm_feature(&armcpu->env, ARM_FEATURE_LPAE)) {
104
+ /* v7 with LPAE */
105
+ pa_bits = 40;
106
+ } else {
107
+ /* Anything else */
108
+ pa_bits = 32;
109
+ }
110
+
111
+ object_unref(cpuobj);
112
+
113
+ virt_set_memmap(vms, pa_bits);
114
}
115
116
/* We can probe only here because during property set
117
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
118
*/
119
finalize_gic_version(vms);
120
121
- if (!cpu_type_valid(machine->cpu_type)) {
122
- error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
123
- exit(1);
124
- }
125
-
126
if (vms->secure) {
127
/*
128
* The Secure view of the world is the same as the NonSecure,
129
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
130
131
create_fdt(vms);
132
133
- possible_cpus = mc->possible_cpu_arch_ids(machine);
134
assert(possible_cpus->len == max_cpus);
135
for (n = 0; n < possible_cpus->len; n++) {
136
Object *cpuobj;
137
@@ -XXX,XX +XXX,XX @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
138
max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa);
139
140
/* we freeze the memory map to compute the highest gpa */
141
- virt_set_memmap(vms);
142
+ virt_set_memmap(vms, max_vm_pa_size);
143
144
requested_pa_size = 64 - clz64(vms->highest_gpa);
145
146
--
147
2.25.1
148
149
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
In order to only keep the highmem devices that actually fit in
4
the PA range, check their location against the range and update
5
highest_gpa if they fit. If they don't, mark them as disabled.
6
7
Signed-off-by: Marc Zyngier <maz@kernel.org>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Message-id: 20220114140741.1358263-6-maz@kernel.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/virt.c | 34 ++++++++++++++++++++++++++++------
13
1 file changed, 28 insertions(+), 6 deletions(-)
14
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
18
+++ b/hw/arm/virt.c
19
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
20
base = vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES;
21
}
22
23
+ /* We know for sure that at least the memory fits in the PA space */
24
+ vms->highest_gpa = memtop - 1;
25
+
26
for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
27
hwaddr size = extended_memmap[i].size;
28
+ bool fits;
29
30
base = ROUND_UP(base, size);
31
vms->memmap[i].base = base;
32
vms->memmap[i].size = size;
33
+
34
+ /*
35
+ * Check each device to see if they fit in the PA space,
36
+ * moving highest_gpa as we go.
37
+ *
38
+ * For each device that doesn't fit, disable it.
39
+ */
40
+ fits = (base + size) <= BIT_ULL(pa_bits);
41
+ if (fits) {
42
+ vms->highest_gpa = base + size - 1;
43
+ }
44
+
45
+ switch (i) {
46
+ case VIRT_HIGH_GIC_REDIST2:
47
+ vms->highmem_redists &= fits;
48
+ break;
49
+ case VIRT_HIGH_PCIE_ECAM:
50
+ vms->highmem_ecam &= fits;
51
+ break;
52
+ case VIRT_HIGH_PCIE_MMIO:
53
+ vms->highmem_mmio &= fits;
54
+ break;
55
+ }
56
+
57
base += size;
58
}
59
60
- /*
61
- * If base fits within pa_bits, all good. If it doesn't, limit it
62
- * to the end of RAM, which is guaranteed to fit within pa_bits.
63
- */
64
- vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1;
65
-
66
if (device_memory_size > 0) {
67
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
68
ms->device_memory->base = device_memory_base;
69
--
70
2.25.1
71
72
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
Now that the devices present in the extended memory map are checked
4
against the available PA space and disabled when they don't fit,
5
there is no need to keep the same checks against highmem, as
6
highmem really is a shortcut for the PA space being 32bit.
7
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Marc Zyngier <maz@kernel.org>
10
Message-id: 20220114140741.1358263-7-maz@kernel.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
hw/arm/virt-acpi-build.c | 2 --
14
hw/arm/virt.c | 5 +----
15
2 files changed, 1 insertion(+), 6 deletions(-)
16
17
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/virt-acpi-build.c
20
+++ b/hw/arm/virt-acpi-build.c
21
@@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
22
acpi_add_table(table_offsets, tables_blob);
23
build_fadt_rev5(tables_blob, tables->linker, vms, dsdt);
24
25
- vms->highmem_redists &= vms->highmem;
26
-
27
acpi_add_table(table_offsets, tables_blob);
28
build_madt(tables_blob, tables->linker, vms);
29
30
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/arm/virt.c
33
+++ b/hw/arm/virt.c
34
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
35
36
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
37
38
- vms->highmem_mmio &= vms->highmem;
39
- vms->highmem_redists &= vms->highmem;
40
-
41
create_gic(vms, sysmem);
42
43
virt_cpu_post_init(vms, sysmem);
44
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
45
machine->ram_size, "mach-virt.tag");
46
}
47
48
- vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64);
49
+ vms->highmem_ecam &= (!firmware_loaded || aarch64);
50
51
create_rtc(vms);
52
53
--
54
2.25.1
55
56
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Patrick Venture <venture@google.com>
2
2
3
Because they are ARM_CP_STATE_AA64, ARM_CP_64BIT is implied.
3
Reviewed-by: Hao Wu <wuhaotsh@google.com>
4
4
Signed-off-by: Patrick Venture <venture@google.com>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220111172338.1525587-1-venture@google.com
6
Message-id: 20180211205848.4568-2-richard.henderson@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
8
---
10
target/arm/helper.c | 8 ++++----
9
hw/arm/npcm7xx_boards.c | 10 +++++++++-
11
1 file changed, 4 insertions(+), 4 deletions(-)
10
1 file changed, 9 insertions(+), 1 deletion(-)
12
11
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
14
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
14
--- a/hw/arm/npcm7xx_boards.c
16
+++ b/target/arm/helper.c
15
+++ b/hw/arm/npcm7xx_boards.c
17
@@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
16
@@ -XXX,XX +XXX,XX @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
18
static const ARMCPRegInfo zcr_el1_reginfo = {
17
{
19
.name = "ZCR_EL1", .state = ARM_CP_STATE_AA64,
18
I2CSlave *i2c_mux;
20
.opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0,
19
21
- .access = PL1_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT,
20
- i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x75);
22
+ .access = PL1_RW, .accessfn = zcr_access,
21
+ i2c_mux = i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1),
23
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]),
22
+ TYPE_PCA9548, 0x75);
24
.writefn = zcr_write, .raw_writefn = raw_write
23
+
25
};
24
+ /* tmp105 is compatible with the lm75 */
26
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el1_reginfo = {
25
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x5c);
27
static const ARMCPRegInfo zcr_el2_reginfo = {
26
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x5c);
28
.name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
27
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 6), "tmp105", 0x5c);
29
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
28
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 7), "tmp105", 0x5c);
30
- .access = PL2_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT,
29
+
31
+ .access = PL2_RW, .accessfn = zcr_access,
30
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x77);
32
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]),
31
33
.writefn = zcr_write, .raw_writefn = raw_write
32
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77);
34
};
35
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el2_reginfo = {
36
static const ARMCPRegInfo zcr_no_el2_reginfo = {
37
.name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
38
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
39
- .access = PL2_RW, .type = ARM_CP_64BIT,
40
+ .access = PL2_RW,
41
.readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore
42
};
43
44
static const ARMCPRegInfo zcr_el3_reginfo = {
45
.name = "ZCR_EL3", .state = ARM_CP_STATE_AA64,
46
.opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0,
47
- .access = PL3_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT,
48
+ .access = PL3_RW, .accessfn = zcr_access,
49
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]),
50
.writefn = zcr_write, .raw_writefn = raw_write
51
};
52
--
33
--
53
2.16.1
34
2.25.1
54
35
55
36
diff view generated by jsdifflib
1
In commit abc24d86cc0364f we accidentally broke migration of
1
From: Troy Lee <troy_lee@aspeedtech.com>
2
the stack pointer value for the mode (process, handler) the CPU
3
is not currently running as. (The commit correctly removed the
4
no-longer-used v7m.current_sp flag from the VMState but also
5
deleted the still very much in use v7m.other_sp SP value field.)
6
2
7
Add a subsection to migrate it again. (We don't need to care
3
Aspeed 2600 SDK enables I3C support by default. The I3C driver will try
8
about trying to retain compatibility with pre-abc24d86cc0364f
4
to reset the device controller and set it up through device address table
9
versions of QEMU, because that commit bumped the version_id
5
register. This dummy model responds to these registers with default values
10
and we've since bumped it again a couple of times.)
6
as listed in the ast2600v10 datasheet chapter 54.2.
11
7
8
This avoids a guest machine kernel panic due to referencing an
9
invalid kernel address if the device address table register isn't
10
set correctly.
11
12
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
13
Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Tested-by: Graeme Gregory <quic_ggregory@quicinc.com>
16
Message-id: 20220111084546.4145785-2-troy_lee@aspeedtech.com
17
[PMM: tidied commit message]
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20180209165810.6668-11-peter.maydell@linaro.org
15
---
19
---
16
target/arm/machine.c | 11 +++++++++++
20
include/hw/misc/aspeed_i3c.h | 48 +++++
17
1 file changed, 11 insertions(+)
21
hw/misc/aspeed_i3c.c | 381 +++++++++++++++++++++++++++++++++++
22
hw/misc/meson.build | 1 +
23
hw/misc/trace-events | 6 +
24
4 files changed, 436 insertions(+)
25
create mode 100644 include/hw/misc/aspeed_i3c.h
26
create mode 100644 hw/misc/aspeed_i3c.c
18
27
19
diff --git a/target/arm/machine.c b/target/arm/machine.c
28
diff --git a/include/hw/misc/aspeed_i3c.h b/include/hw/misc/aspeed_i3c.h
20
index XXXXXXX..XXXXXXX 100644
29
new file mode 100644
21
--- a/target/arm/machine.c
30
index XXXXXXX..XXXXXXX
22
+++ b/target/arm/machine.c
31
--- /dev/null
23
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_scr = {
32
+++ b/include/hw/misc/aspeed_i3c.h
24
}
33
@@ -XXX,XX +XXX,XX @@
25
};
34
+/*
26
35
+ * ASPEED I3C Controller
27
+static const VMStateDescription vmstate_m_other_sp = {
36
+ *
28
+ .name = "cpu/m/other-sp",
37
+ * Copyright (C) 2021 ASPEED Technology Inc.
38
+ *
39
+ * This code is licensed under the GPL version 2 or later. See
40
+ * the COPYING file in the top-level directory.
41
+ */
42
+
43
+#ifndef ASPEED_I3C_H
44
+#define ASPEED_I3C_H
45
+
46
+#include "hw/sysbus.h"
47
+
48
+#define TYPE_ASPEED_I3C "aspeed.i3c"
49
+#define TYPE_ASPEED_I3C_DEVICE "aspeed.i3c.device"
50
+OBJECT_DECLARE_TYPE(AspeedI3CState, AspeedI3CClass, ASPEED_I3C)
51
+
52
+#define ASPEED_I3C_NR_REGS (0x70 >> 2)
53
+#define ASPEED_I3C_DEVICE_NR_REGS (0x300 >> 2)
54
+#define ASPEED_I3C_NR_DEVICES 6
55
+
56
+OBJECT_DECLARE_SIMPLE_TYPE(AspeedI3CDevice, ASPEED_I3C_DEVICE)
57
+typedef struct AspeedI3CDevice {
58
+ /* <private> */
59
+ SysBusDevice parent;
60
+
61
+ /* <public> */
62
+ MemoryRegion mr;
63
+ qemu_irq irq;
64
+
65
+ uint8_t id;
66
+ uint32_t regs[ASPEED_I3C_DEVICE_NR_REGS];
67
+} AspeedI3CDevice;
68
+
69
+typedef struct AspeedI3CState {
70
+ /* <private> */
71
+ SysBusDevice parent;
72
+
73
+ /* <public> */
74
+ MemoryRegion iomem;
75
+ MemoryRegion iomem_container;
76
+ qemu_irq irq;
77
+
78
+ uint32_t regs[ASPEED_I3C_NR_REGS];
79
+ AspeedI3CDevice devices[ASPEED_I3C_NR_DEVICES];
80
+} AspeedI3CState;
81
+#endif /* ASPEED_I3C_H */
82
diff --git a/hw/misc/aspeed_i3c.c b/hw/misc/aspeed_i3c.c
83
new file mode 100644
84
index XXXXXXX..XXXXXXX
85
--- /dev/null
86
+++ b/hw/misc/aspeed_i3c.c
87
@@ -XXX,XX +XXX,XX @@
88
+/*
89
+ * ASPEED I3C Controller
90
+ *
91
+ * Copyright (C) 2021 ASPEED Technology Inc.
92
+ *
93
+ * This code is licensed under the GPL version 2 or later. See
94
+ * the COPYING file in the top-level directory.
95
+ */
96
+
97
+#include "qemu/osdep.h"
98
+#include "qemu/log.h"
99
+#include "qemu/error-report.h"
100
+#include "hw/misc/aspeed_i3c.h"
101
+#include "hw/registerfields.h"
102
+#include "hw/qdev-properties.h"
103
+#include "qapi/error.h"
104
+#include "migration/vmstate.h"
105
+#include "trace.h"
106
+
107
+/* I3C Controller Registers */
108
+REG32(I3C1_REG0, 0x10)
109
+REG32(I3C1_REG1, 0x14)
110
+ FIELD(I3C1_REG1, I2C_MODE, 0, 1)
111
+ FIELD(I3C1_REG1, SA_EN, 15, 1)
112
+REG32(I3C2_REG0, 0x20)
113
+REG32(I3C2_REG1, 0x24)
114
+ FIELD(I3C2_REG1, I2C_MODE, 0, 1)
115
+ FIELD(I3C2_REG1, SA_EN, 15, 1)
116
+REG32(I3C3_REG0, 0x30)
117
+REG32(I3C3_REG1, 0x34)
118
+ FIELD(I3C3_REG1, I2C_MODE, 0, 1)
119
+ FIELD(I3C3_REG1, SA_EN, 15, 1)
120
+REG32(I3C4_REG0, 0x40)
121
+REG32(I3C4_REG1, 0x44)
122
+ FIELD(I3C4_REG1, I2C_MODE, 0, 1)
123
+ FIELD(I3C4_REG1, SA_EN, 15, 1)
124
+REG32(I3C5_REG0, 0x50)
125
+REG32(I3C5_REG1, 0x54)
126
+ FIELD(I3C5_REG1, I2C_MODE, 0, 1)
127
+ FIELD(I3C5_REG1, SA_EN, 15, 1)
128
+REG32(I3C6_REG0, 0x60)
129
+REG32(I3C6_REG1, 0x64)
130
+ FIELD(I3C6_REG1, I2C_MODE, 0, 1)
131
+ FIELD(I3C6_REG1, SA_EN, 15, 1)
132
+
133
+/* I3C Device Registers */
134
+REG32(DEVICE_CTRL, 0x00)
135
+REG32(DEVICE_ADDR, 0x04)
136
+REG32(HW_CAPABILITY, 0x08)
137
+REG32(COMMAND_QUEUE_PORT, 0x0c)
138
+REG32(RESPONSE_QUEUE_PORT, 0x10)
139
+REG32(RX_TX_DATA_PORT, 0x14)
140
+REG32(IBI_QUEUE_STATUS, 0x18)
141
+REG32(IBI_QUEUE_DATA, 0x18)
142
+REG32(QUEUE_THLD_CTRL, 0x1c)
143
+REG32(DATA_BUFFER_THLD_CTRL, 0x20)
144
+REG32(IBI_QUEUE_CTRL, 0x24)
145
+REG32(IBI_MR_REQ_REJECT, 0x2c)
146
+REG32(IBI_SIR_REQ_REJECT, 0x30)
147
+REG32(RESET_CTRL, 0x34)
148
+REG32(SLV_EVENT_CTRL, 0x38)
149
+REG32(INTR_STATUS, 0x3c)
150
+REG32(INTR_STATUS_EN, 0x40)
151
+REG32(INTR_SIGNAL_EN, 0x44)
152
+REG32(INTR_FORCE, 0x48)
153
+REG32(QUEUE_STATUS_LEVEL, 0x4c)
154
+REG32(DATA_BUFFER_STATUS_LEVEL, 0x50)
155
+REG32(PRESENT_STATE, 0x54)
156
+REG32(CCC_DEVICE_STATUS, 0x58)
157
+REG32(DEVICE_ADDR_TABLE_POINTER, 0x5c)
158
+ FIELD(DEVICE_ADDR_TABLE_POINTER, DEPTH, 16, 16)
159
+ FIELD(DEVICE_ADDR_TABLE_POINTER, ADDR, 0, 16)
160
+REG32(DEV_CHAR_TABLE_POINTER, 0x60)
161
+REG32(VENDOR_SPECIFIC_REG_POINTER, 0x6c)
162
+REG32(SLV_MIPI_PID_VALUE, 0x70)
163
+REG32(SLV_PID_VALUE, 0x74)
164
+REG32(SLV_CHAR_CTRL, 0x78)
165
+REG32(SLV_MAX_LEN, 0x7c)
166
+REG32(MAX_READ_TURNAROUND, 0x80)
167
+REG32(MAX_DATA_SPEED, 0x84)
168
+REG32(SLV_DEBUG_STATUS, 0x88)
169
+REG32(SLV_INTR_REQ, 0x8c)
170
+REG32(DEVICE_CTRL_EXTENDED, 0xb0)
171
+REG32(SCL_I3C_OD_TIMING, 0xb4)
172
+REG32(SCL_I3C_PP_TIMING, 0xb8)
173
+REG32(SCL_I2C_FM_TIMING, 0xbc)
174
+REG32(SCL_I2C_FMP_TIMING, 0xc0)
175
+REG32(SCL_EXT_LCNT_TIMING, 0xc8)
176
+REG32(SCL_EXT_TERMN_LCNT_TIMING, 0xcc)
177
+REG32(BUS_FREE_TIMING, 0xd4)
178
+REG32(BUS_IDLE_TIMING, 0xd8)
179
+REG32(I3C_VER_ID, 0xe0)
180
+REG32(I3C_VER_TYPE, 0xe4)
181
+REG32(EXTENDED_CAPABILITY, 0xe8)
182
+REG32(SLAVE_CONFIG, 0xec)
183
+
184
+static const uint32_t ast2600_i3c_device_resets[ASPEED_I3C_DEVICE_NR_REGS] = {
185
+ [R_HW_CAPABILITY] = 0x000e00bf,
186
+ [R_QUEUE_THLD_CTRL] = 0x01000101,
187
+ [R_I3C_VER_ID] = 0x3130302a,
188
+ [R_I3C_VER_TYPE] = 0x6c633033,
189
+ [R_DEVICE_ADDR_TABLE_POINTER] = 0x00080280,
190
+ [R_DEV_CHAR_TABLE_POINTER] = 0x00020200,
191
+ [A_VENDOR_SPECIFIC_REG_POINTER] = 0x000000b0,
192
+ [R_SLV_MAX_LEN] = 0x00ff00ff,
193
+};
194
+
195
+static uint64_t aspeed_i3c_device_read(void *opaque, hwaddr offset,
196
+ unsigned size)
197
+{
198
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(opaque);
199
+ uint32_t addr = offset >> 2;
200
+ uint64_t value;
201
+
202
+ switch (addr) {
203
+ case R_COMMAND_QUEUE_PORT:
204
+ value = 0;
205
+ break;
206
+ default:
207
+ value = s->regs[addr];
208
+ break;
209
+ }
210
+
211
+ trace_aspeed_i3c_device_read(s->id, offset, value);
212
+
213
+ return value;
214
+}
215
+
216
+static void aspeed_i3c_device_write(void *opaque, hwaddr offset,
217
+ uint64_t value, unsigned size)
218
+{
219
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(opaque);
220
+ uint32_t addr = offset >> 2;
221
+
222
+ trace_aspeed_i3c_device_write(s->id, offset, value);
223
+
224
+ switch (addr) {
225
+ case R_HW_CAPABILITY:
226
+ case R_RESPONSE_QUEUE_PORT:
227
+ case R_IBI_QUEUE_DATA:
228
+ case R_QUEUE_STATUS_LEVEL:
229
+ case R_PRESENT_STATE:
230
+ case R_CCC_DEVICE_STATUS:
231
+ case R_DEVICE_ADDR_TABLE_POINTER:
232
+ case R_VENDOR_SPECIFIC_REG_POINTER:
233
+ case R_SLV_CHAR_CTRL:
234
+ case R_SLV_MAX_LEN:
235
+ case R_MAX_READ_TURNAROUND:
236
+ case R_I3C_VER_ID:
237
+ case R_I3C_VER_TYPE:
238
+ case R_EXTENDED_CAPABILITY:
239
+ qemu_log_mask(LOG_GUEST_ERROR,
240
+ "%s: write to readonly register[%02lx] = %08lx\n",
241
+ __func__, offset, value);
242
+ break;
243
+ case R_RX_TX_DATA_PORT:
244
+ break;
245
+ case R_RESET_CTRL:
246
+ break;
247
+ default:
248
+ s->regs[addr] = value;
249
+ break;
250
+ }
251
+}
252
+
253
+static const VMStateDescription aspeed_i3c_device_vmstate = {
254
+ .name = TYPE_ASPEED_I3C,
255
+ .version_id = 1,
256
+ .minimum_version_id = 1,
257
+ .fields = (VMStateField[]){
258
+ VMSTATE_UINT32_ARRAY(regs, AspeedI3CDevice, ASPEED_I3C_DEVICE_NR_REGS),
259
+ VMSTATE_END_OF_LIST(),
260
+ }
261
+};
262
+
263
+static const MemoryRegionOps aspeed_i3c_device_ops = {
264
+ .read = aspeed_i3c_device_read,
265
+ .write = aspeed_i3c_device_write,
266
+ .endianness = DEVICE_LITTLE_ENDIAN,
267
+};
268
+
269
+static void aspeed_i3c_device_reset(DeviceState *dev)
270
+{
271
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(dev);
272
+
273
+ memcpy(s->regs, ast2600_i3c_device_resets, sizeof(s->regs));
274
+}
275
+
276
+static void aspeed_i3c_device_realize(DeviceState *dev, Error **errp)
277
+{
278
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(dev);
279
+ g_autofree char *name = g_strdup_printf(TYPE_ASPEED_I3C_DEVICE ".%d",
280
+ s->id);
281
+
282
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
283
+
284
+ memory_region_init_io(&s->mr, OBJECT(s), &aspeed_i3c_device_ops,
285
+ s, name, ASPEED_I3C_DEVICE_NR_REGS << 2);
286
+}
287
+
288
+static uint64_t aspeed_i3c_read(void *opaque, hwaddr addr, unsigned int size)
289
+{
290
+ AspeedI3CState *s = ASPEED_I3C(opaque);
291
+ uint64_t val = 0;
292
+
293
+ val = s->regs[addr >> 2];
294
+
295
+ trace_aspeed_i3c_read(addr, val);
296
+
297
+ return val;
298
+}
299
+
300
+static void aspeed_i3c_write(void *opaque,
301
+ hwaddr addr,
302
+ uint64_t data,
303
+ unsigned int size)
304
+{
305
+ AspeedI3CState *s = ASPEED_I3C(opaque);
306
+
307
+ trace_aspeed_i3c_write(addr, data);
308
+
309
+ addr >>= 2;
310
+
311
+ /* I3C controller register */
312
+ switch (addr) {
313
+ case R_I3C1_REG1:
314
+ case R_I3C2_REG1:
315
+ case R_I3C3_REG1:
316
+ case R_I3C4_REG1:
317
+ case R_I3C5_REG1:
318
+ case R_I3C6_REG1:
319
+ if (data & R_I3C1_REG1_I2C_MODE_MASK) {
320
+ qemu_log_mask(LOG_UNIMP,
321
+ "%s: Not support I2C mode [%08lx]=%08lx",
322
+ __func__, addr << 2, data);
323
+ break;
324
+ }
325
+ if (data & R_I3C1_REG1_SA_EN_MASK) {
326
+ qemu_log_mask(LOG_UNIMP,
327
+ "%s: Not support slave mode [%08lx]=%08lx",
328
+ __func__, addr << 2, data);
329
+ break;
330
+ }
331
+ s->regs[addr] = data;
332
+ break;
333
+ default:
334
+ s->regs[addr] = data;
335
+ break;
336
+ }
337
+}
338
+
339
+static const MemoryRegionOps aspeed_i3c_ops = {
340
+ .read = aspeed_i3c_read,
341
+ .write = aspeed_i3c_write,
342
+ .endianness = DEVICE_LITTLE_ENDIAN,
343
+ .valid = {
344
+ .min_access_size = 1,
345
+ .max_access_size = 4,
346
+ }
347
+};
348
+
349
+static void aspeed_i3c_reset(DeviceState *dev)
350
+{
351
+ AspeedI3CState *s = ASPEED_I3C(dev);
352
+ memset(s->regs, 0, sizeof(s->regs));
353
+}
354
+
355
+static void aspeed_i3c_instance_init(Object *obj)
356
+{
357
+ AspeedI3CState *s = ASPEED_I3C(obj);
358
+ int i;
359
+
360
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) {
361
+ object_initialize_child(obj, "device[*]", &s->devices[i],
362
+ TYPE_ASPEED_I3C_DEVICE);
363
+ }
364
+}
365
+
366
+static void aspeed_i3c_realize(DeviceState *dev, Error **errp)
367
+{
368
+ int i;
369
+ AspeedI3CState *s = ASPEED_I3C(dev);
370
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
371
+
372
+ memory_region_init(&s->iomem_container, OBJECT(s),
373
+ TYPE_ASPEED_I3C ".container", 0x8000);
374
+
375
+ sysbus_init_mmio(sbd, &s->iomem_container);
376
+
377
+ memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_i3c_ops, s,
378
+ TYPE_ASPEED_I3C ".regs", ASPEED_I3C_NR_REGS << 2);
379
+
380
+ memory_region_add_subregion(&s->iomem_container, 0x0, &s->iomem);
381
+
382
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) {
383
+ Object *dev = OBJECT(&s->devices[i]);
384
+
385
+ if (!object_property_set_uint(dev, "device-id", i, errp)) {
386
+ return;
387
+ }
388
+
389
+ if (!sysbus_realize(SYS_BUS_DEVICE(dev), errp)) {
390
+ return;
391
+ }
392
+
393
+ /*
394
+ * Register Address of I3CX Device =
395
+ * (Base Address of Global Register) + (Offset of I3CX) + Offset
396
+ * X = 0, 1, 2, 3, 4, 5
397
+ * Offset of I3C0 = 0x2000
398
+ * Offset of I3C1 = 0x3000
399
+ * Offset of I3C2 = 0x4000
400
+ * Offset of I3C3 = 0x5000
401
+ * Offset of I3C4 = 0x6000
402
+ * Offset of I3C5 = 0x7000
403
+ */
404
+ memory_region_add_subregion(&s->iomem_container,
405
+ 0x2000 + i * 0x1000, &s->devices[i].mr);
406
+ }
407
+
408
+}
409
+
410
+static Property aspeed_i3c_device_properties[] = {
411
+ DEFINE_PROP_UINT8("device-id", AspeedI3CDevice, id, 0),
412
+ DEFINE_PROP_END_OF_LIST(),
413
+};
414
+
415
+static void aspeed_i3c_device_class_init(ObjectClass *klass, void *data)
416
+{
417
+ DeviceClass *dc = DEVICE_CLASS(klass);
418
+
419
+ dc->desc = "Aspeed I3C Device";
420
+ dc->realize = aspeed_i3c_device_realize;
421
+ dc->reset = aspeed_i3c_device_reset;
422
+ device_class_set_props(dc, aspeed_i3c_device_properties);
423
+}
424
+
425
+static const TypeInfo aspeed_i3c_device_info = {
426
+ .name = TYPE_ASPEED_I3C_DEVICE,
427
+ .parent = TYPE_SYS_BUS_DEVICE,
428
+ .instance_size = sizeof(AspeedI3CDevice),
429
+ .class_init = aspeed_i3c_device_class_init,
430
+};
431
+
432
+static const VMStateDescription vmstate_aspeed_i3c = {
433
+ .name = TYPE_ASPEED_I3C,
29
+ .version_id = 1,
434
+ .version_id = 1,
30
+ .minimum_version_id = 1,
435
+ .minimum_version_id = 1,
31
+ .fields = (VMStateField[]) {
436
+ .fields = (VMStateField[]) {
32
+ VMSTATE_UINT32(env.v7m.other_sp, ARMCPU),
437
+ VMSTATE_UINT32_ARRAY(regs, AspeedI3CState, ASPEED_I3C_NR_REGS),
33
+ VMSTATE_END_OF_LIST()
438
+ VMSTATE_STRUCT_ARRAY(devices, AspeedI3CState, ASPEED_I3C_NR_DEVICES, 1,
34
+ }
439
+ aspeed_i3c_device_vmstate, AspeedI3CDevice),
35
+};
440
+ VMSTATE_END_OF_LIST(),
36
+
441
+ }
37
static const VMStateDescription vmstate_m = {
442
+};
38
.name = "cpu/m",
443
+
39
.version_id = 4,
444
+static void aspeed_i3c_class_init(ObjectClass *klass, void *data)
40
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
445
+{
41
&vmstate_m_faultmask_primask,
446
+ DeviceClass *dc = DEVICE_CLASS(klass);
42
&vmstate_m_csselr,
447
+
43
&vmstate_m_scr,
448
+ dc->realize = aspeed_i3c_realize;
44
+ &vmstate_m_other_sp,
449
+ dc->reset = aspeed_i3c_reset;
45
NULL
450
+ dc->desc = "Aspeed I3C Controller";
46
}
451
+ dc->vmsd = &vmstate_aspeed_i3c;
47
};
452
+}
453
+
454
+static const TypeInfo aspeed_i3c_info = {
455
+ .name = TYPE_ASPEED_I3C,
456
+ .parent = TYPE_SYS_BUS_DEVICE,
457
+ .instance_init = aspeed_i3c_instance_init,
458
+ .instance_size = sizeof(AspeedI3CState),
459
+ .class_init = aspeed_i3c_class_init,
460
+};
461
+
462
+static void aspeed_i3c_register_types(void)
463
+{
464
+ type_register_static(&aspeed_i3c_device_info);
465
+ type_register_static(&aspeed_i3c_info);
466
+}
467
+
468
+type_init(aspeed_i3c_register_types);
469
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
470
index XXXXXXX..XXXXXXX 100644
471
--- a/hw/misc/meson.build
472
+++ b/hw/misc/meson.build
473
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
474
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
475
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
476
'aspeed_hace.c',
477
+ 'aspeed_i3c.c',
478
'aspeed_lpc.c',
479
'aspeed_scu.c',
480
'aspeed_sdmc.c',
481
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
482
index XXXXXXX..XXXXXXX 100644
483
--- a/hw/misc/trace-events
484
+++ b/hw/misc/trace-events
485
@@ -XXX,XX +XXX,XX @@ armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU wri
486
# aspeed_xdma.c
487
aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64
488
489
+# aspeed_i3c.c
490
+aspeed_i3c_read(uint64_t offset, uint64_t data) "I3C read: offset 0x%" PRIx64 " data 0x%" PRIx64
491
+aspeed_i3c_write(uint64_t offset, uint64_t data) "I3C write: offset 0x%" PRIx64 " data 0x%" PRIx64
492
+aspeed_i3c_device_read(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] read: offset 0x%" PRIx64 " data 0x%" PRIx64
493
+aspeed_i3c_device_write(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] write: offset 0x%" PRIx64 " data 0x%" PRIx64
494
+
495
# bcm2835_property.c
496
bcm2835_mbox_property(uint32_t tag, uint32_t bufsize, size_t resplen) "mbox property tag:0x%08x in_sz:%u out_sz:%zu"
497
48
--
498
--
49
2.16.1
499
2.25.1
50
500
51
501
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Troy Lee <troy_lee@aspeedtech.com>
2
2
3
(qemu) info mtree
3
Add the new i3c device to the AST2600 SoC.
4
address-space: cpu-memory-0
5
0000000000000000-ffffffffffffffff (prio 0, i/o): system
6
0000000000000000-0000000007ffffff (prio 0, rom): aspeed.boot_rom
7
- 000000001e600000-000000001e7fffff (prio -1, i/o): aspeed_soc.io
8
+ 000000001e600000-000000001e7fffff (prio -1000, i/o): aspeed_soc.io
9
000000001e620000-000000001e6200ff (prio 0, i/o): aspeed.smc.ast2500-fmc
10
000000001e630000-000000001e6300ff (prio 0, i/o): aspeed.smc.ast2500-spi1
11
000000001e631000-000000001e6310ff (prio 0, i/o): aspeed.smc.ast2500-spi2
12
4
13
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
6
Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
8
Tested-by: Graeme Gregory <quic_ggregory@quicinc.com>
16
Message-id: 20180209085755.30414-3-f4bug@amsat.org
9
Message-id: 20220111084546.4145785-3-troy_lee@aspeedtech.com
10
[PMM: tidied commit message]
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
12
---
19
include/hw/arm/aspeed_soc.h | 1 -
13
include/hw/arm/aspeed_soc.h | 3 +++
20
hw/arm/aspeed_soc.c | 32 +++-----------------------------
14
hw/arm/aspeed_ast2600.c | 16 ++++++++++++++++
21
2 files changed, 3 insertions(+), 30 deletions(-)
15
2 files changed, 19 insertions(+)
22
16
23
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
17
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
24
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/arm/aspeed_soc.h
19
--- a/include/hw/arm/aspeed_soc.h
26
+++ b/include/hw/arm/aspeed_soc.h
20
+++ b/include/hw/arm/aspeed_soc.h
27
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
21
@@ -XXX,XX +XXX,XX @@
28
22
#include "hw/timer/aspeed_timer.h"
29
/*< public >*/
23
#include "hw/rtc/aspeed_rtc.h"
30
ARMCPU cpu;
24
#include "hw/i2c/aspeed_i2c.h"
31
- MemoryRegion iomem;
25
+#include "hw/misc/aspeed_i3c.h"
32
MemoryRegion sram;
26
#include "hw/ssi/aspeed_smc.h"
33
AspeedVICState vic;
27
#include "hw/misc/aspeed_hace.h"
28
#include "hw/watchdog/wdt_aspeed.h"
29
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
30
AspeedRtcState rtc;
34
AspeedTimerCtrlState timerctrl;
31
AspeedTimerCtrlState timerctrl;
35
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
32
AspeedI2CState i2c;
33
+ AspeedI3CState i3c;
34
AspeedSCUState scu;
35
AspeedHACEState hace;
36
AspeedXDMAState xdma;
37
@@ -XXX,XX +XXX,XX @@ enum {
38
ASPEED_DEV_HACE,
39
ASPEED_DEV_DPMCU,
40
ASPEED_DEV_DP,
41
+ ASPEED_DEV_I3C,
42
};
43
44
#endif /* ASPEED_SOC_H */
45
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
36
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/arm/aspeed_soc.c
47
--- a/hw/arm/aspeed_ast2600.c
38
+++ b/hw/arm/aspeed_soc.c
48
+++ b/hw/arm/aspeed_ast2600.c
39
@@ -XXX,XX +XXX,XX @@
49
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
40
#include "qemu-common.h"
50
[ASPEED_DEV_UART1] = 0x1E783000,
41
#include "cpu.h"
51
[ASPEED_DEV_UART5] = 0x1E784000,
42
#include "exec/address-spaces.h"
52
[ASPEED_DEV_VUART] = 0x1E787000,
43
+#include "hw/misc/unimp.h"
53
+ [ASPEED_DEV_I3C] = 0x1E7A0000,
44
#include "hw/arm/aspeed_soc.h"
54
[ASPEED_DEV_SDRAM] = 0x80000000,
45
#include "hw/char/serial.h"
46
#include "qemu/log.h"
47
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
48
},
49
};
55
};
50
56
51
-/*
57
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
52
- * IO handlers: simply catch any reads/writes to IO addresses that aren't
58
[ASPEED_DEV_ETH4] = 33,
53
- * handled by a device mapping.
59
[ASPEED_DEV_KCS] = 138, /* 138 -> 142 */
54
- */
60
[ASPEED_DEV_DP] = 62,
55
-
61
+ [ASPEED_DEV_I3C] = 102, /* 102 -> 107 */
56
-static uint64_t aspeed_soc_io_read(void *p, hwaddr offset, unsigned size)
62
};
57
-{
63
58
- qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
64
static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)
59
- __func__, offset, size);
65
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
60
- return 0;
66
61
-}
67
snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname);
62
-
68
object_initialize_child(obj, "hace", &s->hace, typename);
63
-static void aspeed_soc_io_write(void *opaque, hwaddr offset, uint64_t value,
69
+
64
- unsigned size)
70
+ object_initialize_child(obj, "i3c", &s->i3c, TYPE_ASPEED_I3C);
65
-{
71
}
66
- qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " <- 0x%" PRIx64 " [%u]\n",
72
67
- __func__, offset, value, size);
73
/*
68
-}
74
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
69
-
75
sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]);
70
-static const MemoryRegionOps aspeed_soc_io_ops = {
76
sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
71
- .read = aspeed_soc_io_read,
77
aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
72
- .write = aspeed_soc_io_write,
78
+
73
- .endianness = DEVICE_LITTLE_ENDIAN,
79
+ /* I3C */
74
-};
80
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i3c), errp)) {
75
-
81
+ return;
76
static void aspeed_soc_init(Object *obj)
82
+ }
77
{
83
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]);
78
AspeedSoCState *s = ASPEED_SOC(obj);
84
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) {
79
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
85
+ qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
80
Error *err = NULL, *local_err = NULL;
86
+ sc->irqmap[ASPEED_DEV_I3C] + i);
81
87
+ /* The AST2600 I3C controller has one IRQ per bus. */
82
/* IO space */
88
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq);
83
- memory_region_init_io(&s->iomem, NULL, &aspeed_soc_io_ops, NULL,
89
+ }
84
- "aspeed_soc.io", ASPEED_SOC_IOMEM_SIZE);
90
}
85
- memory_region_add_subregion_overlap(get_system_memory(),
91
86
- ASPEED_SOC_IOMEM_BASE, &s->iomem, -1);
92
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
87
+ create_unimplemented_device("aspeed_soc.io",
88
+ ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE);
89
90
/* CPU */
91
object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
92
--
93
--
93
2.16.1
94
2.25.1
94
95
95
96
diff view generated by jsdifflib
New patch
1
In process_its_cmd() and process_mapti() we must check the
2
event ID against a limit defined by the size field in the DTE,
3
which specifies the number of ID bits minus one. Convert
4
this code to our num_foo convention:
5
* change the variable names
6
* use uint64_t and 1ULL when calculating the number
7
of valid event IDs, because DTE.SIZE is 5 bits and
8
so num_eventids may be up to 2^32
9
* fix the off-by-one error in the comparison
1
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Message-id: 20220111171048.3545974-2-peter.maydell@linaro.org
14
---
15
hw/intc/arm_gicv3_its.c | 18 ++++++++++--------
16
1 file changed, 10 insertions(+), 8 deletions(-)
17
18
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/intc/arm_gicv3_its.c
21
+++ b/hw/intc/arm_gicv3_its.c
22
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
23
MemTxResult res = MEMTX_OK;
24
bool dte_valid;
25
uint64_t dte = 0;
26
- uint32_t max_eventid;
27
+ uint64_t num_eventids;
28
uint16_t icid = 0;
29
uint32_t pIntid = 0;
30
bool ite_valid = false;
31
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
32
dte_valid = FIELD_EX64(dte, DTE, VALID);
33
34
if (dte_valid) {
35
- max_eventid = 1UL << (FIELD_EX64(dte, DTE, SIZE) + 1);
36
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
37
38
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
39
40
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
41
dte_valid ? "valid" : "invalid",
42
ite_valid ? "valid" : "invalid",
43
cte_valid ? "valid" : "invalid");
44
- } else if (eventid > max_eventid) {
45
+ } else if (eventid >= num_eventids) {
46
qemu_log_mask(LOG_GUEST_ERROR,
47
- "%s: invalid command attributes: eventid %d > %d\n",
48
- __func__, eventid, max_eventid);
49
+ "%s: invalid command attributes: eventid %d >= %"
50
+ PRId64 "\n",
51
+ __func__, eventid, num_eventids);
52
} else {
53
/*
54
* Current implementation only supports rdbase == procnum
55
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
56
AddressSpace *as = &s->gicv3->dma_as;
57
uint32_t devid, eventid;
58
uint32_t pIntid = 0;
59
- uint32_t max_eventid, max_Intid;
60
+ uint64_t num_eventids;
61
+ uint32_t max_Intid;
62
bool dte_valid;
63
MemTxResult res = MEMTX_OK;
64
uint16_t icid = 0;
65
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
66
return result;
67
}
68
dte_valid = FIELD_EX64(dte, DTE, VALID);
69
- max_eventid = 1UL << (FIELD_EX64(dte, DTE, SIZE) + 1);
70
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
71
max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1;
72
73
if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
74
- || !dte_valid || (eventid > max_eventid) ||
75
+ || !dte_valid || (eventid >= num_eventids) ||
76
(((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) &&
77
(pIntid != INTID_SPURIOUS))) {
78
qemu_log_mask(LOG_GUEST_ERROR,
79
--
80
2.25.1
81
82
diff view generated by jsdifflib
1
The PENDNMISET/CLR bits in the ICSR should be RAZ/WI from
1
The bounds check on the number of interrupt IDs is correct, but
2
NonSecure state if the AIRCR.BFHFNMINS bit is zero. We had
2
doesn't match our convention; change the variable name, initialize it
3
misimplemented this as making the bits RAZ/WI from both
3
to the 2^n value rather than (2^n)-1, and use >= instead of > in the
4
Secure and NonSecure states. Fix this bug by checking
4
comparison.
5
attrs.secure so that Secure code can pend and unpend NMIs.
6
5
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Message-id: 20180209165810.6668-3-peter.maydell@linaro.org
8
Message-id: 20220111171048.3545974-3-peter.maydell@linaro.org
10
---
9
---
11
hw/intc/armv7m_nvic.c | 6 +++---
10
hw/intc/arm_gicv3_its.c | 6 +++---
12
1 file changed, 3 insertions(+), 3 deletions(-)
11
1 file changed, 3 insertions(+), 3 deletions(-)
13
12
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
15
--- a/hw/intc/arm_gicv3_its.c
17
+++ b/hw/intc/armv7m_nvic.c
16
+++ b/hw/intc/arm_gicv3_its.c
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
17
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
19
}
18
uint32_t devid, eventid;
20
}
19
uint32_t pIntid = 0;
21
/* NMIPENDSET */
20
uint64_t num_eventids;
22
- if ((cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) &&
21
- uint32_t max_Intid;
23
- s->vectors[ARMV7M_EXCP_NMI].pending) {
22
+ uint32_t num_intids;
24
+ if ((attrs.secure || (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))
23
bool dte_valid;
25
+ && s->vectors[ARMV7M_EXCP_NMI].pending) {
24
MemTxResult res = MEMTX_OK;
26
val |= (1 << 31);
25
uint16_t icid = 0;
27
}
26
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
28
/* ISRPREEMPT: RES0 when halting debug not implemented */
29
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
30
break;
31
}
27
}
32
case 0xd04: /* Interrupt Control State (ICSR) */
28
dte_valid = FIELD_EX64(dte, DTE, VALID);
33
- if (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
29
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
34
+ if (attrs.secure || cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
30
- max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1;
35
if (value & (1 << 31)) {
31
+ num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);
36
armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI, false);
32
37
} else if (value & (1 << 30) &&
33
if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
34
|| !dte_valid || (eventid >= num_eventids) ||
35
- (((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) &&
36
+ (((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) &&
37
(pIntid != INTID_SPURIOUS))) {
38
qemu_log_mask(LOG_GUEST_ERROR,
39
"%s: invalid command attributes "
38
--
40
--
39
2.16.1
41
2.25.1
40
42
41
43
diff view generated by jsdifflib
New patch
1
process_its_cmd() returns a bool, like all the other process_ functions.
2
However we were putting its return value into 'res', not 'result',
3
which meant we would ignore it when deciding whether to continue
4
or stall the command queue. Fix the typo.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20220111171048.3545974-4-peter.maydell@linaro.org
11
---
12
hw/intc/arm_gicv3_its.c | 4 ++--
13
1 file changed, 2 insertions(+), 2 deletions(-)
14
15
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/arm_gicv3_its.c
18
+++ b/hw/intc/arm_gicv3_its.c
19
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
20
21
switch (cmd) {
22
case GITS_CMD_INT:
23
- res = process_its_cmd(s, data, cq_offset, INTERRUPT);
24
+ result = process_its_cmd(s, data, cq_offset, INTERRUPT);
25
break;
26
case GITS_CMD_CLEAR:
27
- res = process_its_cmd(s, data, cq_offset, CLEAR);
28
+ result = process_its_cmd(s, data, cq_offset, CLEAR);
29
break;
30
case GITS_CMD_SYNC:
31
/*
32
--
33
2.25.1
34
35
diff view generated by jsdifflib
New patch
1
In process_cmdq(), we read 64 bits of the command packet, which
2
contain the command identifier, which we then switch() on to dispatch
3
to an appropriate sub-function. However, if address_space_ldq_le()
4
reports a memory transaction failure, we still read the command
5
identifier out of the data and switch() on it. Restructure the code
6
so that we stop immediately (stalling the command queue) in this
7
case.
1
8
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20220111171048.3545974-5-peter.maydell@linaro.org
13
---
14
hw/intc/arm_gicv3_its.c | 7 ++++++-
15
1 file changed, 6 insertions(+), 1 deletion(-)
16
17
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/intc/arm_gicv3_its.c
20
+++ b/hw/intc/arm_gicv3_its.c
21
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
22
data = address_space_ldq_le(as, s->cq.base_addr + cq_offset,
23
MEMTXATTRS_UNSPECIFIED, &res);
24
if (res != MEMTX_OK) {
25
- result = false;
26
+ s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1);
27
+ qemu_log_mask(LOG_GUEST_ERROR,
28
+ "%s: could not read command at 0x%" PRIx64 "\n",
29
+ __func__, s->cq.base_addr + cq_offset);
30
+ break;
31
}
32
+
33
cmd = (data & CMD_MASK);
34
35
switch (cmd) {
36
--
37
2.25.1
38
39
diff view generated by jsdifflib
New patch
1
1
When an ITS detects an error in a command, it has an
2
implementation-defined (CONSTRAINED UNPREDICTABLE) choice of whether
3
to ignore the command, proceeding to the next one in the queue, or to
4
stall the ITS command queue, processing nothing further. The
5
behaviour required when the read of the command packet from memory
6
fails is less clearly documented, but the same set of choices as for
7
command errors seem reasonable.
8
9
The intention of the QEMU implementation, as documented in the
10
comments, is that if we encounter a memory error reading the command
11
packet or one of the various data tables then we should stall, but
12
for command parameter errors we should ignore the queue and continue.
13
However, we don't actually do this. To get the desired behaviour,
14
the various process_* functions need to return true to cause
15
process_cmdq() to advance to the next command and keep processing,
16
and false to stall command processing. What they mostly do is return
17
false for any kind of error.
18
19
To make the code clearer, replace the 'bool' return from the process_
20
functions with an enum which may be either CMD_STALL or CMD_CONTINUE.
21
In this commit no behaviour changes; in subsequent commits we will
22
adjust the error-return paths for the process_ functions one by one.
23
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
27
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
28
Message-id: 20220111171048.3545974-6-peter.maydell@linaro.org
29
---
30
hw/intc/arm_gicv3_its.c | 59 ++++++++++++++++++++++++++---------------
31
1 file changed, 38 insertions(+), 21 deletions(-)
32
33
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/intc/arm_gicv3_its.c
36
+++ b/hw/intc/arm_gicv3_its.c
37
@@ -XXX,XX +XXX,XX @@ typedef struct {
38
uint64_t itel;
39
} IteEntry;
40
41
+/*
42
+ * The ITS spec permits a range of CONSTRAINED UNPREDICTABLE options
43
+ * if a command parameter is not correct. These include both "stall
44
+ * processing of the command queue" and "ignore this command, and
45
+ * keep processing the queue". In our implementation we choose that
46
+ * memory transaction errors reading the command packet provoke a
47
+ * stall, but errors in parameters cause us to ignore the command
48
+ * and continue processing.
49
+ * The process_* functions which handle individual ITS commands all
50
+ * return an ItsCmdResult which tells process_cmdq() whether it should
51
+ * stall or keep going.
52
+ */
53
+typedef enum ItsCmdResult {
54
+ CMD_STALL = 0,
55
+ CMD_CONTINUE = 1,
56
+} ItsCmdResult;
57
+
58
static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
59
{
60
uint64_t result = 0;
61
@@ -XXX,XX +XXX,XX @@ static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res)
62
* 3. handling of ITS CLEAR command
63
* 4. handling of ITS DISCARD command
64
*/
65
-static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
66
- ItsCmdType cmd)
67
+static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
68
+ uint32_t offset, ItsCmdType cmd)
69
{
70
AddressSpace *as = &s->gicv3->dma_as;
71
uint32_t devid, eventid;
72
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
73
bool ite_valid = false;
74
uint64_t cte = 0;
75
bool cte_valid = false;
76
- bool result = false;
77
+ ItsCmdResult result = CMD_STALL;
78
uint64_t rdbase;
79
80
if (cmd == NONE) {
81
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
82
if (cmd == DISCARD) {
83
IteEntry ite = {};
84
/* remove mapping from interrupt translation table */
85
- result = update_ite(s, eventid, dte, ite);
86
+ result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
87
}
88
}
89
90
return result;
91
}
92
93
-static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
94
- bool ignore_pInt)
95
+static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
96
+ uint32_t offset, bool ignore_pInt)
97
{
98
AddressSpace *as = &s->gicv3->dma_as;
99
uint32_t devid, eventid;
100
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
101
MemTxResult res = MEMTX_OK;
102
uint16_t icid = 0;
103
uint64_t dte = 0;
104
- bool result = false;
105
+ ItsCmdResult result = CMD_STALL;
106
107
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
108
offset += NUM_BYTES_IN_DW;
109
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
110
ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
111
ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
112
113
- result = update_ite(s, eventid, dte, ite);
114
+ result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
115
}
116
117
return result;
118
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
119
}
120
}
121
122
-static bool process_mapc(GICv3ITSState *s, uint32_t offset)
123
+static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
124
{
125
AddressSpace *as = &s->gicv3->dma_as;
126
uint16_t icid;
127
uint64_t rdbase;
128
bool valid;
129
MemTxResult res = MEMTX_OK;
130
- bool result = false;
131
+ ItsCmdResult result = CMD_STALL;
132
uint64_t value;
133
134
offset += NUM_BYTES_IN_DW;
135
@@ -XXX,XX +XXX,XX @@ static bool process_mapc(GICv3ITSState *s, uint32_t offset)
136
* command in the queue
137
*/
138
} else {
139
- result = update_cte(s, icid, valid, rdbase);
140
+ result = update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
141
}
142
143
return result;
144
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
145
}
146
}
147
148
-static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
149
+static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
150
+ uint32_t offset)
151
{
152
AddressSpace *as = &s->gicv3->dma_as;
153
uint32_t devid;
154
@@ -XXX,XX +XXX,XX @@ static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
155
uint64_t itt_addr;
156
bool valid;
157
MemTxResult res = MEMTX_OK;
158
- bool result = false;
159
+ ItsCmdResult result = CMD_STALL;
160
161
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
162
163
@@ -XXX,XX +XXX,XX @@ static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
164
* command in the queue
165
*/
166
} else {
167
- result = update_dte(s, devid, valid, size, itt_addr);
168
+ result = update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
169
}
170
171
return result;
172
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
173
uint64_t data;
174
AddressSpace *as = &s->gicv3->dma_as;
175
MemTxResult res = MEMTX_OK;
176
- bool result = true;
177
uint8_t cmd;
178
int i;
179
180
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
181
}
182
183
while (wr_offset != rd_offset) {
184
+ ItsCmdResult result = CMD_CONTINUE;
185
+
186
cq_offset = (rd_offset * GITS_CMDQ_ENTRY_SIZE);
187
data = address_space_ldq_le(as, s->cq.base_addr + cq_offset,
188
MEMTXATTRS_UNSPECIFIED, &res);
189
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
190
default:
191
break;
192
}
193
- if (result) {
194
+ if (result == CMD_CONTINUE) {
195
rd_offset++;
196
rd_offset %= s->cq.num_entries;
197
s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, OFFSET, rd_offset);
198
} else {
199
- /*
200
- * in this implementation, in case of dma read/write error
201
- * we stall the command processing
202
- */
203
+ /* CMD_STALL */
204
s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1);
205
qemu_log_mask(LOG_GUEST_ERROR,
206
- "%s: %x cmd processing failed\n", __func__, cmd);
207
+ "%s: 0x%x cmd processing failed, stalling\n",
208
+ __func__, cmd);
209
break;
210
}
211
}
212
--
213
2.25.1
214
215
diff view generated by jsdifflib
1
From: Pekka Enberg <penberg@iki.fi>
1
Fix process_its_cmd() to consistently return CMD_STALL for
2
memory errors and CMD_CONTINUE for parameter errors, as
3
we claim in the comments that we do.
2
4
3
This patch adds Raspberry Pi 3 support to hw/arm/raspi.c. The
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
differences to Pi 2 are:
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-7-peter.maydell@linaro.org
9
---
10
hw/intc/arm_gicv3_its.c | 22 +++++++++++-----------
11
1 file changed, 11 insertions(+), 11 deletions(-)
5
12
6
- Firmware address
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
7
- Board ID
8
- Board revision
9
10
The CPU is different too, but that's going to be configured as part of
11
the machine default CPU when we introduce a new machine type.
12
13
The patch was written from scratch by me but the logic is similar to
14
Zoltán Baldaszti's previous work, which I used as a reference (with
15
permission from the author):
16
17
https://github.com/bztsrc/qemu-raspi3
18
19
Signed-off-by: Pekka Enberg <penberg@iki.fi>
20
[PMM: fixed trailing whitespace on one line]
21
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
24
hw/arm/raspi.c | 31 +++++++++++++++++++++----------
25
1 file changed, 21 insertions(+), 10 deletions(-)
26
27
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
28
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/arm/raspi.c
15
--- a/hw/intc/arm_gicv3_its.c
30
+++ b/hw/arm/raspi.c
16
+++ b/hw/intc/arm_gicv3_its.c
31
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
32
* Rasperry Pi 2 emulation Copyright (c) 2015, Microsoft
18
bool ite_valid = false;
33
* Written by Andrew Baumann
19
uint64_t cte = 0;
34
*
20
bool cte_valid = false;
35
+ * Raspberry Pi 3 emulation Copyright (c) 2018 Zoltán Baldaszti
21
- ItsCmdResult result = CMD_STALL;
36
+ * Upstream code cleanup (c) 2018 Pekka Enberg
22
uint64_t rdbase;
37
+ *
23
38
* This code is licensed under the GNU GPLv2 and later.
24
if (cmd == NONE) {
39
*/
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
40
26
}
41
@@ -XXX,XX +XXX,XX @@
27
42
#define SMPBOOT_ADDR 0x300 /* this should leave enough space for ATAGS */
28
if (res != MEMTX_OK) {
43
#define MVBAR_ADDR 0x400 /* secure vectors */
29
- return result;
44
#define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
30
+ return CMD_STALL;
45
-#define FIRMWARE_ADDR 0x8000 /* Pi loads kernel.img here by default */
31
}
46
+#define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */
32
47
+#define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */
33
eventid = (value & EVENTID_MASK);
48
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
49
/* Table of Linux board IDs for different Pi versions */
35
dte = get_dte(s, devid, &res);
50
-static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43};
36
51
+static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44};
37
if (res != MEMTX_OK) {
52
38
- return result;
53
typedef struct RasPiState {
39
+ return CMD_STALL;
54
BCM2836State soc;
40
}
55
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
41
dte_valid = FIELD_EX64(dte, DTE, VALID);
56
binfo.secure_board_setup = true;
42
57
binfo.secure_boot = true;
43
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
58
44
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
59
- /* Pi2 requires SMP setup */
45
60
- if (version == 2) {
46
if (res != MEMTX_OK) {
61
+ /* Pi2 and Pi3 requires SMP setup */
47
- return result;
62
+ if (version >= 2) {
48
+ return CMD_STALL;
63
binfo.smp_loader_start = SMPBOOT_ADDR;
64
binfo.write_secondary_boot = write_smpboot;
65
binfo.secondary_cpu_reset_hook = reset_secondary;
66
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
67
* the normal Linux boot process
68
*/
69
if (machine->firmware) {
70
+ hwaddr firmware_addr = version == 3 ? FIRMWARE_ADDR_3 : FIRMWARE_ADDR_2;
71
/* load the firmware image (typically kernel.img) */
72
- r = load_image_targphys(machine->firmware, FIRMWARE_ADDR,
73
- ram_size - FIRMWARE_ADDR);
74
+ r = load_image_targphys(machine->firmware, firmware_addr,
75
+ ram_size - firmware_addr);
76
if (r < 0) {
77
error_report("Failed to load firmware from %s", machine->firmware);
78
exit(1);
79
}
49
}
80
50
81
- binfo.entry = FIRMWARE_ADDR;
51
if (ite_valid) {
82
+ binfo.entry = firmware_addr;
52
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
83
binfo.firmware_loaded = true;
53
}
54
55
if (res != MEMTX_OK) {
56
- return result;
57
+ return CMD_STALL;
58
}
84
} else {
59
} else {
85
binfo.kernel_filename = machine->kernel_filename;
60
qemu_log_mask(LOG_GUEST_ERROR,
86
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
61
"%s: invalid command attributes: "
87
arm_load_kernel(ARM_CPU(first_cpu), &binfo);
62
"invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n",
63
__func__, dte, devid, res);
64
- return result;
65
+ return CMD_CONTINUE;
66
}
67
68
69
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
70
qemu_log_mask(LOG_GUEST_ERROR,
71
"%s: invalid command attributes: devid %d>=%d",
72
__func__, devid, s->dt.num_ids);
73
-
74
+ return CMD_CONTINUE;
75
} else if (!dte_valid || !ite_valid || !cte_valid) {
76
qemu_log_mask(LOG_GUEST_ERROR,
77
"%s: invalid command attributes: "
78
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
79
dte_valid ? "valid" : "invalid",
80
ite_valid ? "valid" : "invalid",
81
cte_valid ? "valid" : "invalid");
82
+ return CMD_CONTINUE;
83
} else if (eventid >= num_eventids) {
84
qemu_log_mask(LOG_GUEST_ERROR,
85
"%s: invalid command attributes: eventid %d >= %"
86
PRId64 "\n",
87
__func__, eventid, num_eventids);
88
+ return CMD_CONTINUE;
89
} else {
90
/*
91
* Current implementation only supports rdbase == procnum
92
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
93
rdbase = FIELD_EX64(cte, CTE, RDBASE);
94
95
if (rdbase >= s->gicv3->num_cpu) {
96
- return result;
97
+ return CMD_CONTINUE;
98
}
99
100
if ((cmd == CLEAR) || (cmd == DISCARD)) {
101
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
102
if (cmd == DISCARD) {
103
IteEntry ite = {};
104
/* remove mapping from interrupt translation table */
105
- result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
106
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
107
}
108
+ return CMD_CONTINUE;
109
}
110
-
111
- return result;
88
}
112
}
89
113
90
-static void raspi2_init(MachineState *machine)
114
static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
91
+static void raspi_init(MachineState *machine, int version)
92
{
93
RasPiState *s = g_new0(RasPiState, 1);
94
uint32_t vcram_size;
95
@@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine)
96
&error_abort);
97
object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
98
&error_abort);
99
- object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev",
100
+ int board_rev = version == 3 ? 0xa02082 : 0xa21041;
101
+ object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev",
102
&error_abort);
103
object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abort);
104
105
@@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine)
106
107
vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size",
108
&error_abort);
109
- setup_boot(machine, 2, machine->ram_size - vcram_size);
110
+ setup_boot(machine, version, machine->ram_size - vcram_size);
111
+}
112
+
113
+static void raspi2_init(MachineState *machine)
114
+{
115
+ raspi_init(machine, 2);
116
}
117
118
static void raspi2_machine_init(MachineClass *mc)
119
--
115
--
120
2.16.1
116
2.25.1
121
117
122
118
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
Refactor process_its_cmd() so that it consistently uses
2
the structure
3
do thing;
4
if (error condition) {
5
return early;
6
}
7
do next thing;
2
8
3
When storing to an AdvSIMD FP register, all of the high
9
rather than doing some of the work nested inside if (not error)
4
bits of the SVE register are zeroed. Therefore, call it
10
code blocks.
5
more often with is_q as a parameter.
6
11
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180211205848.4568-6-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20220111171048.3545974-8-peter.maydell@linaro.org
11
---
16
---
12
target/arm/translate-a64.c | 162 +++++++++++++++++----------------------------
17
hw/intc/arm_gicv3_its.c | 103 +++++++++++++++++++---------------------
13
1 file changed, 62 insertions(+), 100 deletions(-)
18
1 file changed, 50 insertions(+), 53 deletions(-)
14
19
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
20
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
22
--- a/hw/intc/arm_gicv3_its.c
18
+++ b/target/arm/translate-a64.c
23
+++ b/hw/intc/arm_gicv3_its.c
19
@@ -XXX,XX +XXX,XX @@ static TCGv_i32 read_fp_sreg(DisasContext *s, int reg)
24
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
20
return v;
21
}
22
23
+/* Clear the bits above an N-bit vector, for N = (is_q ? 128 : 64).
24
+ * If SVE is not enabled, then there are only 128 bits in the vector.
25
+ */
26
+static void clear_vec_high(DisasContext *s, bool is_q, int rd)
27
+{
28
+ unsigned ofs = fp_reg_offset(s, rd, MO_64);
29
+ unsigned vsz = vec_full_reg_size(s);
30
+
31
+ if (!is_q) {
32
+ TCGv_i64 tcg_zero = tcg_const_i64(0);
33
+ tcg_gen_st_i64(tcg_zero, cpu_env, ofs + 8);
34
+ tcg_temp_free_i64(tcg_zero);
35
+ }
36
+ if (vsz > 16) {
37
+ tcg_gen_gvec_dup8i(ofs + 16, vsz - 16, vsz - 16, 0);
38
+ }
39
+}
40
+
41
static void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v)
42
{
43
- TCGv_i64 tcg_zero = tcg_const_i64(0);
44
+ unsigned ofs = fp_reg_offset(s, reg, MO_64);
45
46
- tcg_gen_st_i64(v, cpu_env, fp_reg_offset(s, reg, MO_64));
47
- tcg_gen_st_i64(tcg_zero, cpu_env, fp_reg_hi_offset(s, reg));
48
- tcg_temp_free_i64(tcg_zero);
49
+ tcg_gen_st_i64(v, cpu_env, ofs);
50
+ clear_vec_high(s, false, reg);
51
}
52
53
static void write_fp_sreg(DisasContext *s, int reg, TCGv_i32 v)
54
@@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size)
55
56
tcg_temp_free_i64(tmplo);
57
tcg_temp_free_i64(tmphi);
58
+
59
+ clear_vec_high(s, true, destidx);
60
}
61
62
/*
63
@@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src,
64
}
25
}
65
}
26
dte_valid = FIELD_EX64(dte, DTE, VALID);
66
27
67
-/* Clear the high 64 bits of a 128 bit vector (in general non-quad
28
- if (dte_valid) {
68
- * vector ops all need to do this).
29
- num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
69
- */
70
-static void clear_vec_high(DisasContext *s, int rd)
71
-{
72
- TCGv_i64 tcg_zero = tcg_const_i64(0);
73
-
30
-
74
- write_vec_element(s, tcg_zero, rd, 1, MO_64);
31
- ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
75
- tcg_temp_free_i64(tcg_zero);
76
-}
77
-
32
-
78
/* Store from vector register to memory */
33
- if (res != MEMTX_OK) {
79
static void do_vec_st(DisasContext *s, int srcidx, int element,
34
- return CMD_STALL;
80
TCGv_i64 tcg_addr, int size)
81
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn)
82
/* For non-quad operations, setting a slice of the low
83
* 64 bits of the register clears the high 64 bits (in
84
* the ARM ARM pseudocode this is implicit in the fact
85
- * that 'rval' is a 64 bit wide variable). We optimize
86
- * by noticing that we only need to do this the first
87
- * time we touch a register.
88
+ * that 'rval' is a 64 bit wide variable).
89
+ * For quad operations, we might still need to zero the
90
+ * high bits of SVE. We optimize by noticing that we only
91
+ * need to do this the first time we touch a register.
92
*/
93
- if (!is_q && e == 0 && (r == 0 || xs == selem - 1)) {
94
- clear_vec_high(s, tt);
95
+ if (e == 0 && (r == 0 || xs == selem - 1)) {
96
+ clear_vec_high(s, is_q, tt);
97
}
98
}
99
tcg_gen_addi_i64(tcg_addr, tcg_addr, ebytes);
100
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn)
101
write_vec_element(s, tcg_tmp, rt, 0, MO_64);
102
if (is_q) {
103
write_vec_element(s, tcg_tmp, rt, 1, MO_64);
104
- } else {
105
- clear_vec_high(s, rt);
106
}
107
tcg_temp_free_i64(tcg_tmp);
108
+ clear_vec_high(s, is_q, rt);
109
} else {
110
/* Load/store one element per register */
111
if (is_load) {
112
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_sqshrn(DisasContext *s, bool is_scalar, bool is_q,
113
}
114
115
if (!is_q) {
116
- clear_vec_high(s, rd);
117
write_vec_element(s, tcg_final, rd, 0, MO_64);
118
} else {
119
write_vec_element(s, tcg_final, rd, 1, MO_64);
120
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_sqshrn(DisasContext *s, bool is_scalar, bool is_q,
121
tcg_temp_free_i64(tcg_rd);
122
tcg_temp_free_i32(tcg_rd_narrowed);
123
tcg_temp_free_i64(tcg_final);
124
- return;
125
+
126
+ clear_vec_high(s, is_q, rd);
127
}
128
129
/* SQSHLU, UQSHL, SQSHL: saturating left shifts */
130
@@ -XXX,XX +XXX,XX @@ static void handle_simd_qshl(DisasContext *s, bool scalar, bool is_q,
131
tcg_temp_free_i64(tcg_op);
132
}
133
tcg_temp_free_i64(tcg_shift);
134
-
135
- if (!is_q) {
136
- clear_vec_high(s, rd);
137
- }
138
+ clear_vec_high(s, is_q, rd);
139
} else {
140
TCGv_i32 tcg_shift = tcg_const_i32(shift);
141
static NeonGenTwoOpEnvFn * const fns[2][2][3] = {
142
@@ -XXX,XX +XXX,XX @@ static void handle_simd_qshl(DisasContext *s, bool scalar, bool is_q,
143
}
144
tcg_temp_free_i32(tcg_shift);
145
146
- if (!is_q && !scalar) {
147
- clear_vec_high(s, rd);
148
+ if (!scalar) {
149
+ clear_vec_high(s, is_q, rd);
150
}
151
}
152
}
153
@@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
154
}
155
}
156
157
- if (!is_double && elements == 2) {
158
- clear_vec_high(s, rd);
159
- }
160
-
161
tcg_temp_free_i64(tcg_int);
162
tcg_temp_free_ptr(tcg_fpst);
163
tcg_temp_free_i32(tcg_shift);
164
+
165
+ clear_vec_high(s, elements << size == 16, rd);
166
}
167
168
/* UCVTF/SCVTF - Integer to FP conversion */
169
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
170
write_vec_element(s, tcg_op, rd, pass, MO_64);
171
tcg_temp_free_i64(tcg_op);
172
}
173
- if (!is_q) {
174
- clear_vec_high(s, rd);
175
- }
176
+ clear_vec_high(s, is_q, rd);
177
} else {
178
int maxpass = is_scalar ? 1 : is_q ? 4 : 2;
179
for (pass = 0; pass < maxpass; pass++) {
180
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
181
}
182
tcg_temp_free_i32(tcg_op);
183
}
184
- if (!is_q && !is_scalar) {
185
- clear_vec_high(s, rd);
186
+ if (!is_scalar) {
187
+ clear_vec_high(s, is_q, rd);
188
}
189
}
190
191
@@ -XXX,XX +XXX,XX @@ static void handle_3same_float(DisasContext *s, int size, int elements,
192
193
tcg_temp_free_ptr(fpst);
194
195
- if ((elements << size) < 4) {
196
- /* scalar, or non-quad vector op */
197
- clear_vec_high(s, rd);
198
- }
199
+ clear_vec_high(s, elements * (size ? 8 : 4) > 8, rd);
200
}
201
202
/* AdvSIMD scalar three same
203
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
204
}
205
write_vec_element(s, tcg_res, rd, pass, MO_64);
206
}
207
- if (is_scalar) {
208
- clear_vec_high(s, rd);
209
- }
35
- }
210
-
36
-
211
tcg_temp_free_i64(tcg_res);
37
- if (ite_valid) {
212
tcg_temp_free_i64(tcg_zero);
38
- cte_valid = get_cte(s, icid, &cte, &res);
213
tcg_temp_free_i64(tcg_op);
214
+
215
+ clear_vec_high(s, !is_scalar, rd);
216
} else {
217
TCGv_i32 tcg_op = tcg_temp_new_i32();
218
TCGv_i32 tcg_zero = tcg_const_i32(0);
219
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
220
tcg_temp_free_i32(tcg_res);
221
tcg_temp_free_i32(tcg_zero);
222
tcg_temp_free_i32(tcg_op);
223
- if (!is_q && !is_scalar) {
224
- clear_vec_high(s, rd);
225
+ if (!is_scalar) {
226
+ clear_vec_high(s, is_q, rd);
227
}
228
}
229
230
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode,
231
}
232
write_vec_element(s, tcg_res, rd, pass, MO_64);
233
}
234
- if (is_scalar) {
235
- clear_vec_high(s, rd);
236
- }
39
- }
237
-
40
-
238
tcg_temp_free_i64(tcg_res);
41
- if (res != MEMTX_OK) {
239
tcg_temp_free_i64(tcg_op);
42
- return CMD_STALL;
240
+ clear_vec_high(s, !is_scalar, rd);
43
- }
241
} else {
44
- } else {
242
TCGv_i32 tcg_op = tcg_temp_new_i32();
45
+ if (!dte_valid) {
243
TCGv_i32 tcg_res = tcg_temp_new_i32();
46
qemu_log_mask(LOG_GUEST_ERROR,
244
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode,
47
"%s: invalid command attributes: "
245
}
48
- "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n",
246
tcg_temp_free_i32(tcg_res);
49
- __func__, dte, devid, res);
247
tcg_temp_free_i32(tcg_op);
50
+ "invalid dte: %"PRIx64" for %d\n",
248
- if (!is_q && !is_scalar) {
51
+ __func__, dte, devid);
249
- clear_vec_high(s, rd);
52
return CMD_CONTINUE;
250
+ if (!is_scalar) {
251
+ clear_vec_high(s, is_q, rd);
252
}
253
}
53
}
254
tcg_temp_free_ptr(fpst);
54
255
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_narrow(DisasContext *s, bool scalar,
55
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
256
write_vec_element_i32(s, tcg_res[pass], rd, destelt + pass, MO_32);
56
+
257
tcg_temp_free_i32(tcg_res[pass]);
57
+ ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
258
}
58
+ if (res != MEMTX_OK) {
259
- if (!is_q) {
59
+ return CMD_STALL;
260
- clear_vec_high(s, rd);
60
+ }
261
- }
61
+
262
+ clear_vec_high(s, is_q, rd);
62
+ if (!ite_valid) {
263
}
63
+ qemu_log_mask(LOG_GUEST_ERROR,
264
64
+ "%s: invalid command attributes: invalid ITE\n",
265
/* Remaining saturating accumulating ops */
65
+ __func__);
266
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_satacc(DisasContext *s, bool is_scalar, bool is_u,
66
+ return CMD_CONTINUE;
267
}
67
+ }
268
write_vec_element(s, tcg_rd, rd, pass, MO_64);
68
+
269
}
69
+ cte_valid = get_cte(s, icid, &cte, &res);
270
- if (is_scalar) {
70
+ if (res != MEMTX_OK) {
271
- clear_vec_high(s, rd);
71
+ return CMD_STALL;
72
+ }
73
+ if (!cte_valid) {
74
+ qemu_log_mask(LOG_GUEST_ERROR,
75
+ "%s: invalid command attributes: "
76
+ "invalid cte: %"PRIx64"\n",
77
+ __func__, cte);
78
+ return CMD_CONTINUE;
79
+ }
80
81
- /*
82
- * In this implementation, in case of guest errors we ignore the
83
- * command and move onto the next command in the queue.
84
- */
85
if (devid >= s->dt.num_ids) {
86
qemu_log_mask(LOG_GUEST_ERROR,
87
"%s: invalid command attributes: devid %d>=%d",
88
__func__, devid, s->dt.num_ids);
89
return CMD_CONTINUE;
90
- } else if (!dte_valid || !ite_valid || !cte_valid) {
91
- qemu_log_mask(LOG_GUEST_ERROR,
92
- "%s: invalid command attributes: "
93
- "dte: %s, ite: %s, cte: %s\n",
94
- __func__,
95
- dte_valid ? "valid" : "invalid",
96
- ite_valid ? "valid" : "invalid",
97
- cte_valid ? "valid" : "invalid");
98
- return CMD_CONTINUE;
99
- } else if (eventid >= num_eventids) {
100
+ }
101
+ if (eventid >= num_eventids) {
102
qemu_log_mask(LOG_GUEST_ERROR,
103
"%s: invalid command attributes: eventid %d >= %"
104
PRId64 "\n",
105
__func__, eventid, num_eventids);
106
return CMD_CONTINUE;
107
- } else {
108
- /*
109
- * Current implementation only supports rdbase == procnum
110
- * Hence rdbase physical address is ignored
111
- */
112
- rdbase = FIELD_EX64(cte, CTE, RDBASE);
113
+ }
114
115
- if (rdbase >= s->gicv3->num_cpu) {
116
- return CMD_CONTINUE;
117
- }
118
+ /*
119
+ * Current implementation only supports rdbase == procnum
120
+ * Hence rdbase physical address is ignored
121
+ */
122
+ rdbase = FIELD_EX64(cte, CTE, RDBASE);
123
124
- if ((cmd == CLEAR) || (cmd == DISCARD)) {
125
- gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0);
126
- } else {
127
- gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1);
272
- }
128
- }
273
-
129
-
274
tcg_temp_free_i64(tcg_rd);
130
- if (cmd == DISCARD) {
275
tcg_temp_free_i64(tcg_rn);
131
- IteEntry ite = {};
276
+ clear_vec_high(s, !is_scalar, rd);
132
- /* remove mapping from interrupt translation table */
277
} else {
133
- return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
278
TCGv_i32 tcg_rn = tcg_temp_new_i32();
279
TCGv_i32 tcg_rd = tcg_temp_new_i32();
280
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_satacc(DisasContext *s, bool is_scalar, bool is_u,
281
}
282
write_vec_element_i32(s, tcg_rd, rd, pass, MO_32);
283
}
284
-
285
- if (!is_q) {
286
- clear_vec_high(s, rd);
287
- }
134
- }
288
-
135
+ if (rdbase >= s->gicv3->num_cpu) {
289
tcg_temp_free_i32(tcg_rd);
136
return CMD_CONTINUE;
290
tcg_temp_free_i32(tcg_rn);
291
+ clear_vec_high(s, is_q, rd);
292
}
137
}
138
+
139
+ if ((cmd == CLEAR) || (cmd == DISCARD)) {
140
+ gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0);
141
+ } else {
142
+ gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1);
143
+ }
144
+
145
+ if (cmd == DISCARD) {
146
+ IteEntry ite = {};
147
+ /* remove mapping from interrupt translation table */
148
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
149
+ }
150
+ return CMD_CONTINUE;
293
}
151
}
294
152
295
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u,
153
static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
296
tcg_temp_free_i64(tcg_round);
297
298
done:
299
- if (!is_q) {
300
- clear_vec_high(s, rd);
301
- }
302
+ clear_vec_high(s, is_q, rd);
303
}
304
305
static void gen_shl8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift)
306
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shrn(DisasContext *s, bool is_q,
307
}
308
309
if (!is_q) {
310
- clear_vec_high(s, rd);
311
write_vec_element(s, tcg_final, rd, 0, MO_64);
312
} else {
313
write_vec_element(s, tcg_final, rd, 1, MO_64);
314
}
315
-
316
if (round) {
317
tcg_temp_free_i64(tcg_round);
318
}
319
tcg_temp_free_i64(tcg_rn);
320
tcg_temp_free_i64(tcg_rd);
321
tcg_temp_free_i64(tcg_final);
322
- return;
323
+
324
+ clear_vec_high(s, is_q, rd);
325
}
326
327
328
@@ -XXX,XX +XXX,XX @@ static void handle_3rd_narrowing(DisasContext *s, int is_q, int is_u, int size,
329
write_vec_element_i32(s, tcg_res[pass], rd, pass + part, MO_32);
330
tcg_temp_free_i32(tcg_res[pass]);
331
}
332
- if (!is_q) {
333
- clear_vec_high(s, rd);
334
- }
335
+ clear_vec_high(s, is_q, rd);
336
}
337
338
static void handle_pmull_64(DisasContext *s, int is_q, int rd, int rn, int rm)
339
@@ -XXX,XX +XXX,XX @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode,
340
write_vec_element_i32(s, tcg_res[pass], rd, pass, MO_32);
341
tcg_temp_free_i32(tcg_res[pass]);
342
}
343
- if (!is_q) {
344
- clear_vec_high(s, rd);
345
- }
346
+ clear_vec_high(s, is_q, rd);
347
}
348
349
if (fpst) {
350
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)
351
tcg_temp_free_i32(tcg_op2);
352
}
353
}
354
-
355
- if (!is_q) {
356
- clear_vec_high(s, rd);
357
- }
358
+ clear_vec_high(s, is_q, rd);
359
}
360
361
/* AdvSIMD three same
362
@@ -XXX,XX +XXX,XX @@ static void handle_rev(DisasContext *s, int opcode, bool u,
363
write_vec_element(s, tcg_tmp, rd, i, grp_size);
364
tcg_temp_free_i64(tcg_tmp);
365
}
366
- if (!is_q) {
367
- clear_vec_high(s, rd);
368
- }
369
+ clear_vec_high(s, is_q, rd);
370
} else {
371
int revmask = (1 << grp_size) - 1;
372
int esize = 8 << size;
373
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
374
tcg_temp_free_i32(tcg_op);
375
}
376
}
377
- if (!is_q) {
378
- clear_vec_high(s, rd);
379
- }
380
+ clear_vec_high(s, is_q, rd);
381
382
if (need_rmode) {
383
gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
384
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
385
tcg_temp_free_i64(tcg_res);
386
}
387
388
- if (is_scalar) {
389
- clear_vec_high(s, rd);
390
- }
391
-
392
tcg_temp_free_i64(tcg_idx);
393
+ clear_vec_high(s, !is_scalar, rd);
394
} else if (!is_long) {
395
/* 32 bit floating point, or 16 or 32 bit integer.
396
* For the 16 bit scalar case we use the usual Neon helpers and
397
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
398
}
399
400
tcg_temp_free_i32(tcg_idx);
401
-
402
- if (!is_q) {
403
- clear_vec_high(s, rd);
404
- }
405
+ clear_vec_high(s, is_q, rd);
406
} else {
407
/* long ops: 16x16->32 or 32x32->64 */
408
TCGv_i64 tcg_res[2];
409
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
410
}
411
tcg_temp_free_i64(tcg_idx);
412
413
- if (is_scalar) {
414
- clear_vec_high(s, rd);
415
- }
416
+ clear_vec_high(s, !is_scalar, rd);
417
} else {
418
TCGv_i32 tcg_idx = tcg_temp_new_i32();
419
420
--
154
--
421
2.16.1
155
2.25.1
422
156
423
157
diff view generated by jsdifflib
1
In commit commit 3b2e934463121 we added support for the AIRCR
1
Fix process_mapti() to consistently return CMD_STALL for memory
2
register holding state, but forgot to add it to the vmstate
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
structs. Since it only holds r/w state if the security extension
3
comments that we do.
4
is implemented, we can just add it to vmstate_m_security.
5
4
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180209165810.6668-10-peter.maydell@linaro.org
8
Message-id: 20220111171048.3545974-9-peter.maydell@linaro.org
9
---
9
---
10
target/arm/machine.c | 4 ++++
10
hw/intc/arm_gicv3_its.c | 28 +++++++++++++---------------
11
1 file changed, 4 insertions(+)
11
1 file changed, 13 insertions(+), 15 deletions(-)
12
12
13
diff --git a/target/arm/machine.c b/target/arm/machine.c
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/machine.c
15
--- a/hw/intc/arm_gicv3_its.c
16
+++ b/target/arm/machine.c
16
+++ b/hw/intc/arm_gicv3_its.c
17
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_security = {
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
18
VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate),
18
MemTxResult res = MEMTX_OK;
19
VMSTATE_UINT32(env.sau.ctrl, ARMCPU),
19
uint16_t icid = 0;
20
VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU),
20
uint64_t dte = 0;
21
+ /* AIRCR is not secure-only, but our implementation is R/O if the
21
- ItsCmdResult result = CMD_STALL;
22
+ * security extension is unimplemented, so we migrate it here.
22
+ IteEntry ite = {};
23
+ */
23
24
+ VMSTATE_UINT32(env.v7m.aircr, ARMCPU),
24
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
25
VMSTATE_END_OF_LIST()
25
offset += NUM_BYTES_IN_DW;
26
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
27
MEMTXATTRS_UNSPECIFIED, &res);
28
29
if (res != MEMTX_OK) {
30
- return result;
31
+ return CMD_STALL;
26
}
32
}
27
};
33
34
eventid = (value & EVENTID_MASK);
35
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
36
MEMTXATTRS_UNSPECIFIED, &res);
37
38
if (res != MEMTX_OK) {
39
- return result;
40
+ return CMD_STALL;
41
}
42
43
icid = value & ICID_MASK;
44
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
45
dte = get_dte(s, devid, &res);
46
47
if (res != MEMTX_OK) {
48
- return result;
49
+ return CMD_STALL;
50
}
51
dte_valid = FIELD_EX64(dte, DTE, VALID);
52
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
53
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
54
* we ignore this command and move onto the next
55
* command in the queue
56
*/
57
- } else {
58
- /* add ite entry to interrupt translation table */
59
- IteEntry ite = {};
60
- ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid);
61
- ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL);
62
- ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid);
63
- ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
64
- ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
65
-
66
- result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
67
+ return CMD_CONTINUE;
68
}
69
70
- return result;
71
+ /* add ite entry to interrupt translation table */
72
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid);
73
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL);
74
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid);
75
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
76
+ ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
77
+
78
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
79
}
80
81
static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
28
--
82
--
29
2.16.1
83
2.25.1
30
84
31
85
diff view generated by jsdifflib
1
In many of the NVIC registers relating to interrupts, we
1
Fix process_mapc() to consistently return CMD_STALL for memory
2
have to convert from a byte offset within a register set
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
into the number of the first interrupt which is affected.
3
comments that we do.
4
We were getting this wrong for:
5
* reads of NVIC_ISPR<n>, NVIC_ISER<n>, NVIC_ICPR<n>, NVIC_ICER<n>,
6
NVIC_IABR<n> -- in all these cases we were missing the "* 8"
7
needed to convert from the byte offset to the interrupt number
8
(since all these registers use one bit per interrupt)
9
* writes of NVIC_IPR<n> had the opposite problem of a spurious
10
"* 8" (since these registers use one byte per interrupt)
11
4
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
14
Message-id: 20180209165810.6668-9-peter.maydell@linaro.org
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-10-peter.maydell@linaro.org
15
---
9
---
16
hw/intc/armv7m_nvic.c | 8 ++++----
10
hw/intc/arm_gicv3_its.c | 8 +++-----
17
1 file changed, 4 insertions(+), 4 deletions(-)
11
1 file changed, 3 insertions(+), 5 deletions(-)
18
12
19
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
20
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/intc/armv7m_nvic.c
15
--- a/hw/intc/arm_gicv3_its.c
22
+++ b/hw/intc/armv7m_nvic.c
16
+++ b/hw/intc/arm_gicv3_its.c
23
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
24
/* fall through */
18
uint64_t rdbase;
25
case 0x180 ... 0x1bf: /* NVIC Clear enable */
19
bool valid;
26
val = 0;
20
MemTxResult res = MEMTX_OK;
27
- startvec = offset - 0x180 + NVIC_FIRST_IRQ; /* vector # */
21
- ItsCmdResult result = CMD_STALL;
28
+ startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ; /* vector # */
22
uint64_t value;
29
23
30
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
24
offset += NUM_BYTES_IN_DW;
31
if (s->vectors[startvec + i].enabled &&
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
32
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
26
MEMTXATTRS_UNSPECIFIED, &res);
33
/* fall through */
27
34
case 0x280 ... 0x2bf: /* NVIC Clear pend */
28
if (res != MEMTX_OK) {
35
val = 0;
29
- return result;
36
- startvec = offset - 0x280 + NVIC_FIRST_IRQ; /* vector # */
30
+ return CMD_STALL;
37
+ startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ; /* vector # */
31
}
38
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
32
39
if (s->vectors[startvec + i].pending &&
33
icid = value & ICID_MASK;
40
(attrs.secure || s->itns[startvec + i])) {
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
41
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
35
* we ignore this command and move onto the next
42
break;
36
* command in the queue
43
case 0x300 ... 0x33f: /* NVIC Active */
37
*/
44
val = 0;
38
- } else {
45
- startvec = offset - 0x300 + NVIC_FIRST_IRQ; /* vector # */
39
- result = update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
46
+ startvec = 8 * (offset - 0x300) + NVIC_FIRST_IRQ; /* vector # */
40
+ return CMD_CONTINUE;
47
41
}
48
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
42
49
if (s->vectors[startvec + i].active &&
43
- return result;
50
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
44
+ return update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
51
case 0x300 ... 0x33f: /* NVIC Active */
45
}
52
return MEMTX_OK; /* R/O */
46
53
case 0x400 ... 0x5ef: /* NVIC Priority */
47
static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
54
- startvec = 8 * (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */
55
+ startvec = (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */
56
57
for (i = 0; i < size && startvec + i < s->num_irq; i++) {
58
if (attrs.secure || s->itns[startvec + i]) {
59
--
48
--
60
2.16.1
49
2.25.1
61
50
62
51
diff view generated by jsdifflib
1
Instead of hardcoding the values of M profile ID registers in the
1
Fix process_mapd() to consistently return CMD_STALL for memory
2
NVIC, use the fields in the CPU struct. This will allow us to
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
give different M profile CPU types different ID register values.
3
comments that we do.
4
5
This commit includes the addition of the missing ID_ISAR5,
6
which exists as RES0 in both v7M and v8M.
7
8
(The values of the ID registers might be wrong for the M4 --
9
this commit leaves the behaviour there unchanged.)
10
4
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20180209165810.6668-2-peter.maydell@linaro.org
8
Message-id: 20220111171048.3545974-11-peter.maydell@linaro.org
15
---
9
---
16
hw/intc/armv7m_nvic.c | 30 ++++++++++++++++--------------
10
hw/intc/arm_gicv3_its.c | 10 ++++------
17
target/arm/cpu.c | 28 ++++++++++++++++++++++++++++
11
1 file changed, 4 insertions(+), 6 deletions(-)
18
2 files changed, 44 insertions(+), 14 deletions(-)
19
12
20
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
21
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/intc/armv7m_nvic.c
15
--- a/hw/intc/arm_gicv3_its.c
23
+++ b/hw/intc/armv7m_nvic.c
16
+++ b/hw/intc/arm_gicv3_its.c
24
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
25
"Aux Fault status registers unimplemented\n");
18
uint64_t itt_addr;
26
return 0;
19
bool valid;
27
case 0xd40: /* PFR0. */
20
MemTxResult res = MEMTX_OK;
28
- return 0x00000030;
21
- ItsCmdResult result = CMD_STALL;
29
- case 0xd44: /* PRF1. */
22
30
- return 0x00000200;
23
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
31
+ return cpu->id_pfr0;
24
32
+ case 0xd44: /* PFR1. */
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
33
+ return cpu->id_pfr1;
26
MEMTXATTRS_UNSPECIFIED, &res);
34
case 0xd48: /* DFR0. */
27
35
- return 0x00100000;
28
if (res != MEMTX_OK) {
36
+ return cpu->id_dfr0;
29
- return result;
37
case 0xd4c: /* AFR0. */
30
+ return CMD_STALL;
38
- return 0x00000000;
31
}
39
+ return cpu->id_afr0;
32
40
case 0xd50: /* MMFR0. */
33
size = (value & SIZE_MASK);
41
- return 0x00000030;
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
42
+ return cpu->id_mmfr0;
35
MEMTXATTRS_UNSPECIFIED, &res);
43
case 0xd54: /* MMFR1. */
36
44
- return 0x00000000;
37
if (res != MEMTX_OK) {
45
+ return cpu->id_mmfr1;
38
- return result;
46
case 0xd58: /* MMFR2. */
39
+ return CMD_STALL;
47
- return 0x00000000;
40
}
48
+ return cpu->id_mmfr2;
41
49
case 0xd5c: /* MMFR3. */
42
itt_addr = (value & ITTADDR_MASK) >> ITTADDR_SHIFT;
50
- return 0x00000000;
43
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
51
+ return cpu->id_mmfr3;
44
* we ignore this command and move onto the next
52
case 0xd60: /* ISAR0. */
45
* command in the queue
53
- return 0x01141110;
46
*/
54
+ return cpu->id_isar0;
47
- } else {
55
case 0xd64: /* ISAR1. */
48
- result = update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
56
- return 0x02111000;
49
+ return CMD_CONTINUE;
57
+ return cpu->id_isar1;
50
}
58
case 0xd68: /* ISAR2. */
51
59
- return 0x21112231;
52
- return result;
60
+ return cpu->id_isar2;
53
+ return update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
61
case 0xd6c: /* ISAR3. */
62
- return 0x01111110;
63
+ return cpu->id_isar3;
64
case 0xd70: /* ISAR4. */
65
- return 0x01310102;
66
+ return cpu->id_isar4;
67
+ case 0xd74: /* ISAR5. */
68
+ return cpu->id_isar5;
69
/* TODO: Implement debug registers. */
70
case 0xd90: /* MPU_TYPE */
71
/* Unified MPU; if the MPU is not present this value is zero */
72
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/target/arm/cpu.c
75
+++ b/target/arm/cpu.c
76
@@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj)
77
set_feature(&cpu->env, ARM_FEATURE_M);
78
cpu->midr = 0x410fc231;
79
cpu->pmsav7_dregion = 8;
80
+ cpu->id_pfr0 = 0x00000030;
81
+ cpu->id_pfr1 = 0x00000200;
82
+ cpu->id_dfr0 = 0x00100000;
83
+ cpu->id_afr0 = 0x00000000;
84
+ cpu->id_mmfr0 = 0x00000030;
85
+ cpu->id_mmfr1 = 0x00000000;
86
+ cpu->id_mmfr2 = 0x00000000;
87
+ cpu->id_mmfr3 = 0x00000000;
88
+ cpu->id_isar0 = 0x01141110;
89
+ cpu->id_isar1 = 0x02111000;
90
+ cpu->id_isar2 = 0x21112231;
91
+ cpu->id_isar3 = 0x01111110;
92
+ cpu->id_isar4 = 0x01310102;
93
+ cpu->id_isar5 = 0x00000000;
94
}
54
}
95
55
96
static void cortex_m4_initfn(Object *obj)
56
/*
97
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
98
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
99
cpu->midr = 0x410fc240; /* r0p0 */
100
cpu->pmsav7_dregion = 8;
101
+ cpu->id_pfr0 = 0x00000030;
102
+ cpu->id_pfr1 = 0x00000200;
103
+ cpu->id_dfr0 = 0x00100000;
104
+ cpu->id_afr0 = 0x00000000;
105
+ cpu->id_mmfr0 = 0x00000030;
106
+ cpu->id_mmfr1 = 0x00000000;
107
+ cpu->id_mmfr2 = 0x00000000;
108
+ cpu->id_mmfr3 = 0x00000000;
109
+ cpu->id_isar0 = 0x01141110;
110
+ cpu->id_isar1 = 0x02111000;
111
+ cpu->id_isar2 = 0x21112231;
112
+ cpu->id_isar3 = 0x01111110;
113
+ cpu->id_isar4 = 0x01310102;
114
+ cpu->id_isar5 = 0x00000000;
115
}
116
117
static void arm_v7m_class_init(ObjectClass *oc, void *data)
118
--
57
--
119
2.16.1
58
2.25.1
120
59
121
60
diff view generated by jsdifflib
New patch
1
1
The ITS has several tables which all share a similar format,
2
described by the TableDesc struct: the guest may configure them
3
to be a single-level table or a two-level table. Currently we
4
open-code the process of finding the table entry in all the
5
functions which read or write the device table or the collection
6
table. Factor out the "get the address of the table entry"
7
logic into a new function, so that the code which needs to
8
read or write a table entry only needs to call table_entry_addr()
9
and then perform a suitable load or store to that address.
10
11
Note that the error handling is slightly complicated because
12
we want to handle two cases differently:
13
* failure to read the L1 table entry should end up causing
14
a command stall, like other kinds of DMA error
15
* an L1 table entry that says there is no L2 table for this
16
index (ie whose valid bit is 0) must result in us treating
17
the table entry as not-valid on read, and discarding
18
writes (this is mandated by the spec)
19
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
23
Message-id: 20220111171048.3545974-12-peter.maydell@linaro.org
24
---
25
hw/intc/arm_gicv3_its.c | 212 +++++++++++++---------------------------
26
1 file changed, 70 insertions(+), 142 deletions(-)
27
28
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/intc/arm_gicv3_its.c
31
+++ b/hw/intc/arm_gicv3_its.c
32
@@ -XXX,XX +XXX,XX @@ static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
33
return result;
34
}
35
36
+static uint64_t table_entry_addr(GICv3ITSState *s, TableDesc *td,
37
+ uint32_t idx, MemTxResult *res)
38
+{
39
+ /*
40
+ * Given a TableDesc describing one of the ITS in-guest-memory
41
+ * tables and an index into it, return the guest address
42
+ * corresponding to that table entry.
43
+ * If there was a memory error reading the L1 table of an
44
+ * indirect table, *res is set accordingly, and we return -1.
45
+ * If the L1 table entry is marked not valid, we return -1 with
46
+ * *res set to MEMTX_OK.
47
+ *
48
+ * The specification defines the format of level 1 entries of a
49
+ * 2-level table, but the format of level 2 entries and the format
50
+ * of flat-mapped tables is IMPDEF.
51
+ */
52
+ AddressSpace *as = &s->gicv3->dma_as;
53
+ uint32_t l2idx;
54
+ uint64_t l2;
55
+ uint32_t num_l2_entries;
56
+
57
+ *res = MEMTX_OK;
58
+
59
+ if (!td->indirect) {
60
+ /* Single level table */
61
+ return td->base_addr + idx * td->entry_sz;
62
+ }
63
+
64
+ /* Two level table */
65
+ l2idx = idx / (td->page_sz / L1TABLE_ENTRY_SIZE);
66
+
67
+ l2 = address_space_ldq_le(as,
68
+ td->base_addr + (l2idx * L1TABLE_ENTRY_SIZE),
69
+ MEMTXATTRS_UNSPECIFIED, res);
70
+ if (*res != MEMTX_OK) {
71
+ return -1;
72
+ }
73
+ if (!(l2 & L2_TABLE_VALID_MASK)) {
74
+ return -1;
75
+ }
76
+
77
+ num_l2_entries = td->page_sz / td->entry_sz;
78
+ return (l2 & ((1ULL << 51) - 1)) + (idx % num_l2_entries) * td->entry_sz;
79
+}
80
+
81
static bool get_cte(GICv3ITSState *s, uint16_t icid, uint64_t *cte,
82
MemTxResult *res)
83
{
84
AddressSpace *as = &s->gicv3->dma_as;
85
- uint64_t l2t_addr;
86
- uint64_t value;
87
- bool valid_l2t;
88
- uint32_t l2t_id;
89
- uint32_t num_l2_entries;
90
+ uint64_t entry_addr = table_entry_addr(s, &s->ct, icid, res);
91
92
- if (s->ct.indirect) {
93
- l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE);
94
-
95
- value = address_space_ldq_le(as,
96
- s->ct.base_addr +
97
- (l2t_id * L1TABLE_ENTRY_SIZE),
98
- MEMTXATTRS_UNSPECIFIED, res);
99
-
100
- if (*res == MEMTX_OK) {
101
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
102
-
103
- if (valid_l2t) {
104
- num_l2_entries = s->ct.page_sz / s->ct.entry_sz;
105
-
106
- l2t_addr = value & ((1ULL << 51) - 1);
107
-
108
- *cte = address_space_ldq_le(as, l2t_addr +
109
- ((icid % num_l2_entries) * GITS_CTE_SIZE),
110
- MEMTXATTRS_UNSPECIFIED, res);
111
- }
112
- }
113
- } else {
114
- /* Flat level table */
115
- *cte = address_space_ldq_le(as, s->ct.base_addr +
116
- (icid * GITS_CTE_SIZE),
117
- MEMTXATTRS_UNSPECIFIED, res);
118
+ if (entry_addr == -1) {
119
+ return false; /* not valid */
120
}
121
122
+ *cte = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res);
123
return FIELD_EX64(*cte, CTE, VALID);
124
}
125
126
@@ -XXX,XX +XXX,XX @@ static bool get_ite(GICv3ITSState *s, uint32_t eventid, uint64_t dte,
127
static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res)
128
{
129
AddressSpace *as = &s->gicv3->dma_as;
130
- uint64_t l2t_addr;
131
- uint64_t value;
132
- bool valid_l2t;
133
- uint32_t l2t_id;
134
- uint32_t num_l2_entries;
135
+ uint64_t entry_addr = table_entry_addr(s, &s->dt, devid, res);
136
137
- if (s->dt.indirect) {
138
- l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE);
139
-
140
- value = address_space_ldq_le(as,
141
- s->dt.base_addr +
142
- (l2t_id * L1TABLE_ENTRY_SIZE),
143
- MEMTXATTRS_UNSPECIFIED, res);
144
-
145
- if (*res == MEMTX_OK) {
146
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
147
-
148
- if (valid_l2t) {
149
- num_l2_entries = s->dt.page_sz / s->dt.entry_sz;
150
-
151
- l2t_addr = value & ((1ULL << 51) - 1);
152
-
153
- value = address_space_ldq_le(as, l2t_addr +
154
- ((devid % num_l2_entries) * GITS_DTE_SIZE),
155
- MEMTXATTRS_UNSPECIFIED, res);
156
- }
157
- }
158
- } else {
159
- /* Flat level table */
160
- value = address_space_ldq_le(as, s->dt.base_addr +
161
- (devid * GITS_DTE_SIZE),
162
- MEMTXATTRS_UNSPECIFIED, res);
163
+ if (entry_addr == -1) {
164
+ return 0; /* a DTE entry with the Valid bit clear */
165
}
166
-
167
- return value;
168
+ return address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res);
169
}
170
171
/*
172
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
173
uint64_t rdbase)
174
{
175
AddressSpace *as = &s->gicv3->dma_as;
176
- uint64_t value;
177
- uint64_t l2t_addr;
178
- bool valid_l2t;
179
- uint32_t l2t_id;
180
- uint32_t num_l2_entries;
181
+ uint64_t entry_addr;
182
uint64_t cte = 0;
183
MemTxResult res = MEMTX_OK;
184
185
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
186
cte = FIELD_DP64(cte, CTE, RDBASE, rdbase);
187
}
188
189
- /*
190
- * The specification defines the format of level 1 entries of a
191
- * 2-level table, but the format of level 2 entries and the format
192
- * of flat-mapped tables is IMPDEF.
193
- */
194
- if (s->ct.indirect) {
195
- l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE);
196
-
197
- value = address_space_ldq_le(as,
198
- s->ct.base_addr +
199
- (l2t_id * L1TABLE_ENTRY_SIZE),
200
- MEMTXATTRS_UNSPECIFIED, &res);
201
-
202
- if (res != MEMTX_OK) {
203
- return false;
204
- }
205
-
206
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
207
-
208
- if (valid_l2t) {
209
- num_l2_entries = s->ct.page_sz / s->ct.entry_sz;
210
-
211
- l2t_addr = value & ((1ULL << 51) - 1);
212
-
213
- address_space_stq_le(as, l2t_addr +
214
- ((icid % num_l2_entries) * GITS_CTE_SIZE),
215
- cte, MEMTXATTRS_UNSPECIFIED, &res);
216
- }
217
- } else {
218
- /* Flat level table */
219
- address_space_stq_le(as, s->ct.base_addr + (icid * GITS_CTE_SIZE),
220
- cte, MEMTXATTRS_UNSPECIFIED, &res);
221
- }
222
+ entry_addr = table_entry_addr(s, &s->ct, icid, &res);
223
if (res != MEMTX_OK) {
224
+ /* memory access error: stall */
225
return false;
226
- } else {
227
+ }
228
+ if (entry_addr == -1) {
229
+ /* No L2 table for this index: discard write and continue */
230
return true;
231
}
232
+
233
+ address_space_stq_le(as, entry_addr, cte, MEMTXATTRS_UNSPECIFIED, &res);
234
+ return res == MEMTX_OK;
235
}
236
237
static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
238
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
239
uint8_t size, uint64_t itt_addr)
240
{
241
AddressSpace *as = &s->gicv3->dma_as;
242
- uint64_t value;
243
- uint64_t l2t_addr;
244
- bool valid_l2t;
245
- uint32_t l2t_id;
246
- uint32_t num_l2_entries;
247
+ uint64_t entry_addr;
248
uint64_t dte = 0;
249
MemTxResult res = MEMTX_OK;
250
251
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
252
return true;
253
}
254
255
- /*
256
- * The specification defines the format of level 1 entries of a
257
- * 2-level table, but the format of level 2 entries and the format
258
- * of flat-mapped tables is IMPDEF.
259
- */
260
- if (s->dt.indirect) {
261
- l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE);
262
-
263
- value = address_space_ldq_le(as,
264
- s->dt.base_addr +
265
- (l2t_id * L1TABLE_ENTRY_SIZE),
266
- MEMTXATTRS_UNSPECIFIED, &res);
267
-
268
- if (res != MEMTX_OK) {
269
- return false;
270
- }
271
-
272
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
273
-
274
- if (valid_l2t) {
275
- num_l2_entries = s->dt.page_sz / s->dt.entry_sz;
276
-
277
- l2t_addr = value & ((1ULL << 51) - 1);
278
-
279
- address_space_stq_le(as, l2t_addr +
280
- ((devid % num_l2_entries) * GITS_DTE_SIZE),
281
- dte, MEMTXATTRS_UNSPECIFIED, &res);
282
- }
283
- } else {
284
- /* Flat level table */
285
- address_space_stq_le(as, s->dt.base_addr + (devid * GITS_DTE_SIZE),
286
- dte, MEMTXATTRS_UNSPECIFIED, &res);
287
- }
288
+ entry_addr = table_entry_addr(s, &s->dt, devid, &res);
289
if (res != MEMTX_OK) {
290
+ /* memory access error: stall */
291
return false;
292
- } else {
293
+ }
294
+ if (entry_addr == -1) {
295
+ /* No L2 table for this index: discard write and continue */
296
return true;
297
}
298
+ address_space_stq_le(as, entry_addr, dte, MEMTXATTRS_UNSPECIFIED, &res);
299
+ return res == MEMTX_OK;
300
}
301
302
static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
303
--
304
2.25.1
305
306
diff view generated by jsdifflib
1
In commit 50f11062d4c896 we added support for MSR/MRS access
1
In a few places in the ITS command handling functions, we were
2
to the NS banked special registers, but we forgot to implement
2
doing the range-check of an event ID or device ID only after using
3
the support for writing to CONTROL_NS. Correct the omission.
3
it as a table index; move the checks to before the uses.
4
5
This misordering wouldn't have very bad effects because the
6
tables are in guest memory anyway.
4
7
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Message-id: 20180209165810.6668-8-peter.maydell@linaro.org
10
Message-id: 20220111171048.3545974-13-peter.maydell@linaro.org
8
---
11
---
9
target/arm/helper.c | 10 ++++++++++
12
hw/intc/arm_gicv3_its.c | 42 ++++++++++++++++++++++++-----------------
10
1 file changed, 10 insertions(+)
13
1 file changed, 25 insertions(+), 17 deletions(-)
11
14
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
13
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
17
--- a/hw/intc/arm_gicv3_its.c
15
+++ b/target/arm/helper.c
18
+++ b/hw/intc/arm_gicv3_its.c
16
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
19
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
17
}
20
18
env->v7m.faultmask[M_REG_NS] = val & 1;
21
eventid = (value & EVENTID_MASK);
19
return;
22
20
+ case 0x94: /* CONTROL_NS */
23
+ if (devid >= s->dt.num_ids) {
21
+ if (!env->v7m.secure) {
24
+ qemu_log_mask(LOG_GUEST_ERROR,
22
+ return;
25
+ "%s: invalid command attributes: devid %d>=%d",
23
+ }
26
+ __func__, devid, s->dt.num_ids);
24
+ write_v7m_control_spsel_for_secstate(env,
27
+ return CMD_CONTINUE;
25
+ val & R_V7M_CONTROL_SPSEL_MASK,
28
+ }
26
+ M_REG_NS);
29
+
27
+ env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK;
30
dte = get_dte(s, devid, &res);
28
+ env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK;
31
29
+ return;
32
if (res != MEMTX_OK) {
30
case 0x98: /* SP_NS */
33
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
31
{
34
32
/* This gives the non-secure SP selected based on whether we're
35
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
36
37
+ if (eventid >= num_eventids) {
38
+ qemu_log_mask(LOG_GUEST_ERROR,
39
+ "%s: invalid command attributes: eventid %d >= %"
40
+ PRId64 "\n",
41
+ __func__, eventid, num_eventids);
42
+ return CMD_CONTINUE;
43
+ }
44
+
45
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
46
if (res != MEMTX_OK) {
47
return CMD_STALL;
48
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
49
return CMD_CONTINUE;
50
}
51
52
- if (devid >= s->dt.num_ids) {
53
- qemu_log_mask(LOG_GUEST_ERROR,
54
- "%s: invalid command attributes: devid %d>=%d",
55
- __func__, devid, s->dt.num_ids);
56
- return CMD_CONTINUE;
57
- }
58
- if (eventid >= num_eventids) {
59
- qemu_log_mask(LOG_GUEST_ERROR,
60
- "%s: invalid command attributes: eventid %d >= %"
61
- PRId64 "\n",
62
- __func__, eventid, num_eventids);
63
- return CMD_CONTINUE;
64
- }
65
-
66
/*
67
* Current implementation only supports rdbase == procnum
68
* Hence rdbase physical address is ignored
69
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
70
71
icid = value & ICID_MASK;
72
73
+ if (devid >= s->dt.num_ids) {
74
+ qemu_log_mask(LOG_GUEST_ERROR,
75
+ "%s: invalid command attributes: devid %d>=%d",
76
+ __func__, devid, s->dt.num_ids);
77
+ return CMD_CONTINUE;
78
+ }
79
+
80
dte = get_dte(s, devid, &res);
81
82
if (res != MEMTX_OK) {
83
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
84
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
85
num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);
86
87
- if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
88
+ if ((icid >= s->ct.num_ids)
89
|| !dte_valid || (eventid >= num_eventids) ||
90
(((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) &&
91
(pIntid != INTID_SPURIOUS))) {
92
qemu_log_mask(LOG_GUEST_ERROR,
93
"%s: invalid command attributes "
94
- "devid %d or icid %d or eventid %d or pIntid %d or"
95
- "unmapped dte %d\n", __func__, devid, icid, eventid,
96
+ "icid %d or eventid %d or pIntid %d or"
97
+ "unmapped dte %d\n", __func__, icid, eventid,
98
pIntid, dte_valid);
99
/*
100
* in this implementation, in case of error
33
--
101
--
34
2.16.1
102
2.25.1
35
103
36
104
diff view generated by jsdifflib
1
The Coprocessor Power Control Register (CPPWR) is new in v8M.
1
In process_its_cmd(), we read an ICID out of the interrupt table
2
It allows software to control whether coprocessors are allowed
2
entry, and then use it as an index into the collection table. Add a
3
to power down and lose their state. QEMU doesn't have any
3
check that it is within range for the collection table first.
4
notion of power control, so we choose the IMPDEF option of
4
5
making the whole register RAZ/WI (indicating that no coprocessors
5
This check is not strictly necessary, because:
6
can ever power down and lose state).
6
* we range check the ICID from the guest before writing it into
7
the interrupt table entry, so the the only way to get an
8
out of range ICID in process_its_cmd() is if a badly-behaved
9
guest is writing directly to the interrupt table memory
10
* the collection table is in guest memory, so QEMU won't fall
11
over if we read off the end of it
12
13
However, it seems clearer to include the check.
7
14
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Message-id: 20180209165810.6668-5-peter.maydell@linaro.org
17
Message-id: 20220111171048.3545974-14-peter.maydell@linaro.org
11
---
18
---
12
hw/intc/armv7m_nvic.c | 14 ++++++++++++++
19
hw/intc/arm_gicv3_its.c | 7 +++++++
13
1 file changed, 14 insertions(+)
20
1 file changed, 7 insertions(+)
14
21
15
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
22
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
16
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/armv7m_nvic.c
24
--- a/hw/intc/arm_gicv3_its.c
18
+++ b/hw/intc/armv7m_nvic.c
25
+++ b/hw/intc/arm_gicv3_its.c
19
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
26
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
20
switch (offset) {
27
return CMD_CONTINUE;
21
case 4: /* Interrupt Control Type. */
28
}
22
return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1;
29
23
+ case 0xc: /* CPPWR */
30
+ if (icid >= s->ct.num_ids) {
24
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
31
+ qemu_log_mask(LOG_GUEST_ERROR,
25
+ goto bad_offset;
32
+ "%s: invalid ICID 0x%x in ITE (table corrupted?)\n",
26
+ }
33
+ __func__, icid);
27
+ /* We make the IMPDEF choice that nothing can ever go into a
34
+ return CMD_CONTINUE;
28
+ * non-retentive power state, which allows us to RAZ/WI this.
35
+ }
29
+ */
36
+
30
+ return 0;
37
cte_valid = get_cte(s, icid, &cte, &res);
31
case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */
38
if (res != MEMTX_OK) {
32
{
39
return CMD_STALL;
33
int startvec = 8 * (offset - 0x380) + NVIC_FIRST_IRQ;
34
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
35
ARMCPU *cpu = s->cpu;
36
37
switch (offset) {
38
+ case 0xc: /* CPPWR */
39
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
40
+ goto bad_offset;
41
+ }
42
+ /* Make the IMPDEF choice to RAZ/WI this. */
43
+ break;
44
case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */
45
{
46
int startvec = 8 * (offset - 0x380) + NVIC_FIRST_IRQ;
47
--
40
--
48
2.16.1
41
2.25.1
49
42
50
43
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Nothing in either register affects the TB.
3
Quoting Peter Maydell:
4
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
"These MEMTX_* aren't from the memory transaction
6
Message-id: 20180211205848.4568-4-richard.henderson@linaro.org
6
API functions; they're just being used by gicd_readl() and
7
friends as a way to indicate a success/failure so that the
8
actual MemoryRegionOps read/write fns like gicv3_dist_read()
9
can log a guest error."
10
11
We are going to introduce more MemTxResult bits, so it is
12
safer to check for !MEMTX_OK rather than MEMTX_ERROR.
13
14
Reviewed-by: Peter Xu <peterx@redhat.com>
15
Reviewed-by: David Hildenbrand <david@redhat.com>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
18
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
20
---
10
target/arm/helper.c | 4 ++--
21
hw/intc/arm_gicv3_redist.c | 4 ++--
11
1 file changed, 2 insertions(+), 2 deletions(-)
22
1 file changed, 2 insertions(+), 2 deletions(-)
12
23
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
24
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
14
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
26
--- a/hw/intc/arm_gicv3_redist.c
16
+++ b/target/arm/helper.c
27
+++ b/hw/intc/arm_gicv3_redist.c
17
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
28
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data,
18
.writefn = aa64_daif_write, .resetfn = arm_cp_reset_ignore },
29
break;
19
{ .name = "FPCR", .state = ARM_CP_STATE_AA64,
30
}
20
.opc0 = 3, .opc1 = 3, .opc2 = 0, .crn = 4, .crm = 4,
31
21
- .access = PL0_RW, .type = ARM_CP_FPU,
32
- if (r == MEMTX_ERROR) {
22
+ .access = PL0_RW, .type = ARM_CP_FPU | ARM_CP_SUPPRESS_TB_END,
33
+ if (r != MEMTX_OK) {
23
.readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write },
34
qemu_log_mask(LOG_GUEST_ERROR,
24
{ .name = "FPSR", .state = ARM_CP_STATE_AA64,
35
"%s: invalid guest read at offset " TARGET_FMT_plx
25
.opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4,
36
" size %u\n", __func__, offset, size);
26
- .access = PL0_RW, .type = ARM_CP_FPU,
37
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data,
27
+ .access = PL0_RW, .type = ARM_CP_FPU | ARM_CP_SUPPRESS_TB_END,
38
break;
28
.readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write },
39
}
29
{ .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64,
40
30
.opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0,
41
- if (r == MEMTX_ERROR) {
42
+ if (r != MEMTX_OK) {
43
qemu_log_mask(LOG_GUEST_ERROR,
44
"%s: invalid guest write at offset " TARGET_FMT_plx
45
" size %u\n", __func__, offset, size);
31
--
46
--
32
2.16.1
47
2.25.1
33
48
34
49
diff view generated by jsdifflib