1
target-arm queue. The big thing here is the landing of the 3-phase
1
The following changes since commit 5767815218efd3cbfd409505ed824d5f356044ae:
2
reset patches...
3
2
4
-- PMM
3
Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging (2024-02-14 15:45:52 +0000)
5
6
The following changes since commit 204aa60b37c23a89e690d418f49787d274303ca7:
7
8
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-jan-29-2020' into staging (2020-01-30 14:18:45 +0000)
9
4
10
are available in the Git repository at:
5
are available in the Git repository at:
11
6
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200130
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240215
13
8
14
for you to fetch changes up to dea101a1ae9968c9fec6ab0291489dad7c49f36f:
9
for you to fetch changes up to f780e63fe731b058fe52d43653600d8729a1b5f2:
15
10
16
target/arm/cpu: Add the kvm-no-adjvtime CPU property (2020-01-30 16:02:06 +0000)
11
docs: Add documentation for the mps3-an536 board (2024-02-15 14:32:39 +0000)
17
12
18
----------------------------------------------------------------
13
----------------------------------------------------------------
19
target-arm queue:
14
target-arm queue:
20
* hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
15
* hw/arm/xilinx_zynq: Wire FIQ between CPU <> GIC
21
* target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr
16
* linux-user/aarch64: Choose SYNC as the preferred MTE mode
22
* aspeed: some minor bugfixes
17
* Fix some errors in SVE/SME handling of MTE tags
23
* aspeed: add eMMC controller model for AST2600 SoC
18
* hw/pci-host/raven.c: Mark raven_io_ops as implementing unaligned accesses
24
* hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus'
19
* hw/block/tc58128: Don't emit deprecation warning under qtest
25
* New 3-phase reset API for device models
20
* tests/qtest: Fix handling of npcm7xx and GMAC tests
26
* hw/intc/arm_gicv3_kvm: Stop wrongly programming GICR_PENDBASER.PTZ bit
21
* hw/arm/virt: Wire up non-secure EL2 virtual timer IRQ
27
* Arm KVM: stop/restart the guest counter when the VM is stopped and started
22
* tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend
23
* Don't assert on vmload/vmsave of M-profile CPUs
24
* hw/arm/smmuv3: add support for stage 1 access fault
25
* hw/arm/stellaris: QOM cleanups
26
* Use new CBAR encoding for all v8 CPUs, not all aarch64 CPUs
27
* Improve Cortex_R52 IMPDEF sysreg modelling
28
* Allow access to SPSR_hyp from hyp mode
29
* New board model mps3-an536 (Cortex-R52)
28
30
29
----------------------------------------------------------------
31
----------------------------------------------------------------
30
Andrew Jeffery (2):
32
Luc Michel (1):
31
hw/sd: Configure number of slots exposed by the ASPEED SDHCI model
33
hw/arm/smmuv3: add support for stage 1 access fault
32
hw/arm: ast2600: Wire up the eMMC controller
33
34
34
Andrew Jones (6):
35
Nabih Estefan (1):
35
target/arm/kvm: trivial: Clean up header documentation
36
tests/qtest: Fix GMAC test to run on a machine in upstream QEMU
36
hw/arm/virt: Add missing 5.0 options call to 4.2 options
37
target/arm/kvm64: kvm64 cpus have timer registers
38
tests/arm-cpu-features: Check feature default values
39
target/arm/kvm: Implement virtual time adjustment
40
target/arm/cpu: Add the kvm-no-adjvtime CPU property
41
37
42
Cédric Le Goater (2):
38
Peter Maydell (22):
43
ftgmac100: check RX and TX buffer alignment
39
hw/pci-host/raven.c: Mark raven_io_ops as implementing unaligned accesses
44
hw/arm/aspeed: add a 'execute-in-place' property to boot directly from CE0
40
hw/block/tc58128: Don't emit deprecation warning under qtest
41
tests/qtest/meson.build: Don't include qtests_npcm7xx in qtests_aarch64
42
tests/qtest/bios-tables-test: Allow changes to virt GTDT
43
hw/arm/virt: Wire up non-secure EL2 virtual timer IRQ
44
tests/qtest/bios-tables-tests: Update virt golden reference
45
hw/arm/npcm7xx: Call qemu_configure_nic_device() for GMAC modules
46
tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend
47
target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU
48
target/arm: Use new CBAR encoding for all v8 CPUs, not all aarch64 CPUs
49
target/arm: The Cortex-R52 has a read-only CBAR
50
target/arm: Add Cortex-R52 IMPDEF sysregs
51
target/arm: Allow access to SPSR_hyp from hyp mode
52
hw/misc/mps2-scc: Fix condition for CFG3 register
53
hw/misc/mps2-scc: Factor out which-board conditionals
54
hw/misc/mps2-scc: Make changes needed for AN536 FPGA image
55
hw/arm/mps3r: Initial skeleton for mps3-an536 board
56
hw/arm/mps3r: Add CPUs, GIC, and per-CPU RAM
57
hw/arm/mps3r: Add UARTs
58
hw/arm/mps3r: Add GPIO, watchdog, dual-timer, I2C devices
59
hw/arm/mps3r: Add remaining devices
60
docs: Add documentation for the mps3-an536 board
45
61
46
Damien Hedde (11):
62
Philippe Mathieu-Daudé (5):
47
add device_legacy_reset function to prepare for reset api change
63
hw/arm/xilinx_zynq: Wire FIQ between CPU <> GIC
48
hw/core/qdev: add trace events to help with resettable transition
64
hw/arm/stellaris: Convert ADC controller to Resettable interface
49
hw/core: create Resettable QOM interface
65
hw/arm/stellaris: Convert I2C controller to Resettable interface
50
hw/core: add Resettable support to BusClass and DeviceClass
66
hw/arm/stellaris: Add missing QOM 'machine' parent
51
hw/core/resettable: add support for changing parent
67
hw/arm/stellaris: Add missing QOM 'SoC' parent
52
hw/core/qdev: handle parent bus change regarding resettable
53
hw/core/qdev: update hotplug reset regarding resettable
54
hw/core: deprecate old reset functions and introduce new ones
55
docs/devel/reset.rst: add doc about Resettable interface
56
vl: replace deprecated qbus_reset_all registration
57
hw/s390x/ipl: replace deprecated qdev_reset_all registration
58
68
59
Joel Stanley (1):
69
Richard Henderson (6):
60
misc/pca9552: Add qom set and get
70
linux-user/aarch64: Choose SYNC as the preferred MTE mode
71
target/arm: Fix nregs computation in do_{ld,st}_zpa
72
target/arm: Adjust and validate mtedesc sizem1
73
target/arm: Split out make_svemte_desc
74
target/arm: Handle mte in do_ldrq, do_ldro
75
target/arm: Fix SVE/SME gross MTE suppression checks
61
76
62
Peter Maydell (2):
77
MAINTAINERS | 3 +-
63
hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
78
docs/system/arm/mps2.rst | 37 +-
64
target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr
79
configs/devices/arm-softmmu/default.mak | 1 +
80
hw/arm/smmuv3-internal.h | 1 +
81
include/hw/arm/smmu-common.h | 1 +
82
include/hw/arm/virt.h | 2 +
83
include/hw/misc/mps2-scc.h | 1 +
84
linux-user/aarch64/target_prctl.h | 29 +-
85
target/arm/internals.h | 2 +-
86
target/arm/tcg/translate-a64.h | 2 +
87
hw/arm/mps3r.c | 640 ++++++++++++++++++++++++++++++++
88
hw/arm/npcm7xx.c | 1 +
89
hw/arm/smmu-common.c | 11 +
90
hw/arm/smmuv3.c | 1 +
91
hw/arm/stellaris.c | 47 ++-
92
hw/arm/virt-acpi-build.c | 20 +-
93
hw/arm/virt.c | 60 ++-
94
hw/arm/xilinx_zynq.c | 2 +
95
hw/block/tc58128.c | 4 +-
96
hw/misc/mps2-scc.c | 138 ++++++-
97
hw/pci-host/raven.c | 1 +
98
target/arm/helper.c | 14 +-
99
target/arm/tcg/cpu32.c | 109 ++++++
100
target/arm/tcg/op_helper.c | 43 ++-
101
target/arm/tcg/sme_helper.c | 8 +-
102
target/arm/tcg/sve_helper.c | 12 +-
103
target/arm/tcg/translate-sme.c | 15 +-
104
target/arm/tcg/translate-sve.c | 83 +++--
105
target/arm/tcg/translate.c | 19 +-
106
tests/qtest/npcm7xx_emc-test.c | 5 +-
107
tests/qtest/npcm_gmac-test.c | 84 +----
108
hw/arm/Kconfig | 5 +
109
hw/arm/meson.build | 1 +
110
tests/data/acpi/virt/FACP | Bin 276 -> 276 bytes
111
tests/data/acpi/virt/GTDT | Bin 96 -> 104 bytes
112
tests/qtest/meson.build | 4 +-
113
36 files changed, 1184 insertions(+), 222 deletions(-)
114
create mode 100644 hw/arm/mps3r.c
65
115
66
Philippe Mathieu-Daudé (1):
67
hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus'
68
69
Zenghui Yu (1):
70
hw/intc/arm_gicv3_kvm: Stop wrongly programming GICR_PENDBASER.PTZ bit
71
72
hw/core/Makefile.objs | 1 +
73
tests/Makefile.include | 1 +
74
include/hw/arm/aspeed.h | 2 +
75
include/hw/arm/aspeed_soc.h | 2 +
76
include/hw/arm/virt.h | 1 +
77
include/hw/qdev-core.h | 58 +++++++-
78
include/hw/resettable.h | 247 +++++++++++++++++++++++++++++++++
79
include/hw/sd/aspeed_sdhci.h | 1 +
80
target/arm/cpu.h | 7 +
81
target/arm/kvm_arm.h | 95 ++++++++++---
82
hw/arm/aspeed.c | 72 ++++++++--
83
hw/arm/aspeed_ast2600.c | 31 ++++-
84
hw/arm/aspeed_soc.c | 2 +
85
hw/arm/raspi.c | 2 -
86
hw/arm/virt.c | 9 ++
87
hw/audio/intel-hda.c | 2 +-
88
hw/core/bus.c | 102 ++++++++++++++
89
hw/core/or-irq.c | 2 +-
90
hw/core/qdev.c | 160 ++++++++++++++++++++--
91
hw/core/resettable.c | 301 +++++++++++++++++++++++++++++++++++++++++
92
hw/hyperv/hyperv.c | 2 +-
93
hw/i386/microvm.c | 2 +-
94
hw/i386/pc.c | 2 +-
95
hw/ide/microdrive.c | 8 +-
96
hw/intc/arm_gicv3_kvm.c | 11 +-
97
hw/intc/spapr_xive.c | 2 +-
98
hw/misc/pca9552.c | 90 ++++++++++++
99
hw/net/ftgmac100.c | 13 ++
100
hw/ppc/pnv_psi.c | 4 +-
101
hw/ppc/spapr_pci.c | 2 +-
102
hw/ppc/spapr_vio.c | 2 +-
103
hw/s390x/ipl.c | 10 +-
104
hw/s390x/s390-pci-inst.c | 2 +-
105
hw/scsi/vmw_pvscsi.c | 2 +-
106
hw/sd/aspeed_sdhci.c | 11 +-
107
hw/sd/omap_mmc.c | 2 +-
108
hw/sd/pl181.c | 2 +-
109
target/arm/arm-semi.c | 9 ++
110
target/arm/cpu.c | 2 +
111
target/arm/cpu64.c | 1 +
112
target/arm/kvm.c | 120 ++++++++++++++++
113
target/arm/kvm32.c | 3 +
114
target/arm/kvm64.c | 4 +
115
target/arm/machine.c | 7 +
116
target/arm/monitor.c | 1 +
117
tests/qtest/arm-cpu-features.c | 41 ++++--
118
vl.c | 10 +-
119
docs/arm-cpu-features.rst | 37 ++++-
120
docs/devel/index.rst | 1 +
121
docs/devel/reset.rst | 289 +++++++++++++++++++++++++++++++++++++++
122
hw/core/trace-events | 27 ++++
123
51 files changed, 1727 insertions(+), 90 deletions(-)
124
create mode 100644 include/hw/resettable.h
125
create mode 100644 hw/core/resettable.c
126
create mode 100644 docs/devel/reset.rst
127
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Andrew Jones <drjones@redhat.com>
3
Similarly to commits dadbb58f59..5ae79fe825 for other ARM boards,
4
Message-id: 20200120101023.16030-2-drjones@redhat.com
4
connect FIQ output of the GIC CPU interfaces to the CPU.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Message-id: 20240130152548.17855-1-philmd@linaro.org
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
target/arm/kvm_arm.h | 46 ++++++++++++++++++++++++++------------------
11
hw/arm/xilinx_zynq.c | 2 ++
9
1 file changed, 27 insertions(+), 19 deletions(-)
12
1 file changed, 2 insertions(+)
10
13
11
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
14
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
12
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/kvm_arm.h
16
--- a/hw/arm/xilinx_zynq.c
14
+++ b/target/arm/kvm_arm.h
17
+++ b/hw/arm/xilinx_zynq.c
15
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine)
16
int kvm_arm_vcpu_init(CPUState *cs);
19
sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);
17
20
sysbus_connect_irq(busdev, 0,
18
/**
21
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
19
- * kvm_arm_vcpu_finalize
22
+ sysbus_connect_irq(busdev, 1,
20
+ * kvm_arm_vcpu_finalize:
23
+ qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_FIQ));
21
* @cs: CPUState
24
22
- * @feature: int
25
for (n = 0; n < 64; n++) {
23
+ * @feature: feature to finalize
26
pic[n] = qdev_get_gpio_in(dev, n);
24
*
25
* Finalizes the configuration of the specified VCPU feature by
26
* invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring
27
@@ -XXX,XX +XXX,XX @@ void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
28
int kvm_arm_init_cpreg_list(ARMCPU *cpu);
29
30
/**
31
- * kvm_arm_reg_syncs_via_cpreg_list
32
- * regidx: KVM register index
33
+ * kvm_arm_reg_syncs_via_cpreg_list:
34
+ * @regidx: KVM register index
35
*
36
* Return true if this KVM register should be synchronized via the
37
* cpreg list of arbitrary system registers, false if it is synchronized
38
@@ -XXX,XX +XXX,XX @@ int kvm_arm_init_cpreg_list(ARMCPU *cpu);
39
bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx);
40
41
/**
42
- * kvm_arm_cpreg_level
43
- * regidx: KVM register index
44
+ * kvm_arm_cpreg_level:
45
+ * @regidx: KVM register index
46
*
47
* Return the level of this coprocessor/system register. Return value is
48
* either KVM_PUT_RUNTIME_STATE, KVM_PUT_RESET_STATE, or KVM_PUT_FULL_STATE.
49
@@ -XXX,XX +XXX,XX @@ void kvm_arm_init_serror_injection(CPUState *cs);
50
* @cpu: ARMCPU
51
*
52
* Get VCPU related state from kvm.
53
+ *
54
+ * Returns: 0 if success else < 0 error code
55
*/
56
int kvm_get_vcpu_events(ARMCPU *cpu);
57
58
@@ -XXX,XX +XXX,XX @@ int kvm_get_vcpu_events(ARMCPU *cpu);
59
* @cpu: ARMCPU
60
*
61
* Put VCPU related state to kvm.
62
+ *
63
+ * Returns: 0 if success else < 0 error code
64
*/
65
int kvm_put_vcpu_events(ARMCPU *cpu);
66
67
@@ -XXX,XX +XXX,XX @@ typedef struct ARMHostCPUFeatures {
68
69
/**
70
* kvm_arm_get_host_cpu_features:
71
- * @ahcc: ARMHostCPUClass to fill in
72
+ * @ahcf: ARMHostCPUClass to fill in
73
*
74
* Probe the capabilities of the host kernel's preferred CPU and fill
75
* in the ARMHostCPUClass struct accordingly.
76
+ *
77
+ * Returns true on success and false otherwise.
78
*/
79
bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf);
80
81
@@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);
82
bool kvm_arm_aarch32_supported(CPUState *cs);
83
84
/**
85
- * bool kvm_arm_pmu_supported:
86
+ * kvm_arm_pmu_supported:
87
* @cs: CPUState
88
*
89
* Returns: true if the KVM VCPU can enable its PMU
90
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_aarch32_supported(CPUState *cs);
91
bool kvm_arm_pmu_supported(CPUState *cs);
92
93
/**
94
- * bool kvm_arm_sve_supported:
95
+ * kvm_arm_sve_supported:
96
* @cs: CPUState
97
*
98
* Returns true if the KVM VCPU can enable SVE and false otherwise.
99
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_pmu_supported(CPUState *cs);
100
bool kvm_arm_sve_supported(CPUState *cs);
101
102
/**
103
- * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the
104
- * IPA address space supported by KVM
105
- *
106
+ * kvm_arm_get_max_vm_ipa_size:
107
* @ms: Machine state handle
108
+ *
109
+ * Returns the number of bits in the IPA address space supported by KVM
110
*/
111
int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
112
113
/**
114
- * kvm_arm_sync_mpstate_to_kvm
115
+ * kvm_arm_sync_mpstate_to_kvm:
116
* @cpu: ARMCPU
117
*
118
* If supported set the KVM MP_STATE based on QEMU's model.
119
+ *
120
+ * Returns 0 on success and -1 on failure.
121
*/
122
int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu);
123
124
/**
125
- * kvm_arm_sync_mpstate_to_qemu
126
+ * kvm_arm_sync_mpstate_to_qemu:
127
* @cpu: ARMCPU
128
*
129
* If supported get the MP_STATE from KVM and store in QEMU's model.
130
+ *
131
+ * Returns 0 on success and aborts on failure.
132
*/
133
int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu);
134
135
@@ -XXX,XX +XXX,XX @@ int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
136
137
static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
138
{
139
- /* This should never actually be called in the "not KVM" case,
140
+ /*
141
+ * This should never actually be called in the "not KVM" case,
142
* but set up the fields to indicate an error anyway.
143
*/
144
cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
145
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit);
146
*
147
* Return: TRUE if any hardware breakpoints in use.
148
*/
149
-
150
bool kvm_arm_hw_debug_active(CPUState *cs);
151
152
/**
153
* kvm_arm_copy_hw_debug_data:
154
- *
155
* @ptr: kvm_guest_debug_arch structure
156
*
157
* Copy the architecture specific debug registers into the
158
* kvm_guest_debug ioctl structure.
159
*/
160
struct kvm_guest_debug_arch;
161
-
162
void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr);
163
164
/**
165
- * its_class_name
166
+ * its_class_name:
167
*
168
* Return the ITS class name to use depending on whether KVM acceleration
169
* and KVM CAP_SIGNAL_MSI are supported
170
--
27
--
171
2.20.1
28
2.34.1
172
29
173
30
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
The API does not generate an error for setting ASYNC | SYNC; that merely
4
constrains the selection vs the per-cpu default. For qemu linux-user,
5
choose SYNC as the default.
6
7
Cc: qemu-stable@nongnu.org
8
Reported-by: Gustavo Romero <gustavo.romero@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
11
Message-id: 20240207025210.8837-2-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
linux-user/aarch64/target_prctl.h | 29 +++++++++++++++++------------
15
1 file changed, 17 insertions(+), 12 deletions(-)
16
17
diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/linux-user/aarch64/target_prctl.h
20
+++ b/linux-user/aarch64/target_prctl.h
21
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_set_tagged_addr_ctrl(CPUArchState *env, abi_long arg2)
22
env->tagged_addr_enable = arg2 & PR_TAGGED_ADDR_ENABLE;
23
24
if (cpu_isar_feature(aa64_mte, cpu)) {
25
- switch (arg2 & PR_MTE_TCF_MASK) {
26
- case PR_MTE_TCF_NONE:
27
- case PR_MTE_TCF_SYNC:
28
- case PR_MTE_TCF_ASYNC:
29
- break;
30
- default:
31
- return -EINVAL;
32
- }
33
-
34
/*
35
* Write PR_MTE_TCF to SCTLR_EL1[TCF0].
36
- * Note that the syscall values are consistent with hw.
37
+ *
38
+ * The kernel has a per-cpu configuration for the sysadmin,
39
+ * /sys/devices/system/cpu/cpu<N>/mte_tcf_preferred,
40
+ * which qemu does not implement.
41
+ *
42
+ * Because there is no performance difference between the modes, and
43
+ * because SYNC is most useful for debugging MTE errors, choose SYNC
44
+ * as the preferred mode. With this preference, and the way the API
45
+ * uses only two bits, there is no way for the program to select
46
+ * ASYMM mode.
47
*/
48
- env->cp15.sctlr_el[1] =
49
- deposit64(env->cp15.sctlr_el[1], 38, 2, arg2 >> PR_MTE_TCF_SHIFT);
50
+ unsigned tcf = 0;
51
+ if (arg2 & PR_MTE_TCF_SYNC) {
52
+ tcf = 1;
53
+ } else if (arg2 & PR_MTE_TCF_ASYNC) {
54
+ tcf = 2;
55
+ }
56
+ env->cp15.sctlr_el[1] = deposit64(env->cp15.sctlr_el[1], 38, 2, tcf);
57
58
/*
59
* Write PR_MTE_TAG to GCR_EL1[Exclude].
60
--
61
2.34.1
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When a VM is stopped (such as when it's paused) guest virtual time
3
The field is encoded as [0-3], which is convenient for
4
should stop counting. Otherwise, when the VM is resumed it will
4
indexing our array of function pointers, but the true
5
experience time jumps and its kernel may report soft lockups. Not
5
value is [1-4]. Adjust before calling do_mem_zpa.
6
counting virtual time while the VM is stopped has the side effect
7
of making the guest's time appear to lag when compared with real
8
time, and even with time derived from the physical counter. For
9
this reason, this change, which is enabled by default, comes with
10
a KVM CPU feature allowing it to be disabled, restoring legacy
11
behavior.
12
6
13
This patch only provides the implementation of the virtual time
7
Add an assert, and move the comment re passing ZT to
14
adjustment. A subsequent patch will provide the CPU property
8
the helper back next to the relevant code.
15
allowing the change to be enabled and disabled.
16
9
17
Reported-by: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
10
Cc: qemu-stable@nongnu.org
18
Signed-off-by: Andrew Jones <drjones@redhat.com>
11
Fixes: 206adacfb8d ("target/arm: Add mte helpers for sve scalar + int loads")
19
Message-id: 20200120101023.16030-6-drjones@redhat.com
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
14
Message-id: 20240207025210.8837-3-richard.henderson@linaro.org
20
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
17
---
23
target/arm/cpu.h | 7 ++++
18
target/arm/tcg/translate-sve.c | 16 ++++++++--------
24
target/arm/kvm_arm.h | 38 ++++++++++++++++++
19
1 file changed, 8 insertions(+), 8 deletions(-)
25
target/arm/kvm.c | 92 ++++++++++++++++++++++++++++++++++++++++++++
26
target/arm/kvm32.c | 3 ++
27
target/arm/kvm64.c | 3 ++
28
target/arm/machine.c | 7 ++++
29
6 files changed, 150 insertions(+)
30
20
31
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
32
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/cpu.h
23
--- a/target/arm/tcg/translate-sve.c
34
+++ b/target/arm/cpu.h
24
+++ b/target/arm/tcg/translate-sve.c
35
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
25
@@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
36
/* KVM init features for this CPU */
26
TCGv_ptr t_pg;
37
uint32_t kvm_init_features[7];
27
int desc = 0;
38
28
39
+ /* KVM CPU state */
29
- /*
40
+
30
- * For e.g. LD4, there are not enough arguments to pass all 4
41
+ /* KVM virtual time adjustment */
31
- * registers as pointers, so encode the regno into the data field.
42
+ bool kvm_adjvtime;
32
- * For consistency, do this even for LD1.
43
+ bool kvm_vtime_dirty;
33
- */
44
+ uint64_t kvm_vtime;
34
+ assert(mte_n >= 1 && mte_n <= 4);
45
+
35
if (s->mte_active[0]) {
46
/* Uniprocessor system with MP extensions */
36
int msz = dtype_msz(dtype);
47
bool mp_is_up;
37
48
38
@@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
49
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
39
addr = clean_data_tbi(s, addr);
50
index XXXXXXX..XXXXXXX 100644
40
}
51
--- a/target/arm/kvm_arm.h
41
52
+++ b/target/arm/kvm_arm.h
42
+ /*
53
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level);
43
+ * For e.g. LD4, there are not enough arguments to pass all 4
54
*/
44
+ * registers as pointers, so encode the regno into the data field.
55
bool write_kvmstate_to_list(ARMCPU *cpu);
45
+ * For consistency, do this even for LD1.
56
46
+ */
57
+/**
47
desc = simd_desc(vsz, vsz, zt | desc);
58
+ * kvm_arm_cpu_pre_save:
48
t_pg = tcg_temp_new_ptr();
59
+ * @cpu: ARMCPU
49
60
+ *
50
@@ -XXX,XX +XXX,XX @@ static void do_ld_zpa(DisasContext *s, int zt, int pg,
61
+ * Called after write_kvmstate_to_list() from cpu_pre_save() to update
51
* accessible via the instruction encoding.
62
+ * the cpreg list with KVM CPU state.
52
*/
63
+ */
53
assert(fn != NULL);
64
+void kvm_arm_cpu_pre_save(ARMCPU *cpu);
54
- do_mem_zpa(s, zt, pg, addr, dtype, nreg, false, fn);
65
+
55
+ do_mem_zpa(s, zt, pg, addr, dtype, nreg + 1, false, fn);
66
+/**
67
+ * kvm_arm_cpu_post_load:
68
+ * @cpu: ARMCPU
69
+ *
70
+ * Called from cpu_post_load() to update KVM CPU state from the cpreg list.
71
+ */
72
+void kvm_arm_cpu_post_load(ARMCPU *cpu);
73
+
74
/**
75
* kvm_arm_reset_vcpu:
76
* @cpu: ARMCPU
77
@@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu);
78
*/
79
int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu);
80
81
+/**
82
+ * kvm_arm_get_virtual_time:
83
+ * @cs: CPUState
84
+ *
85
+ * Gets the VCPU's virtual counter and stores it in the KVM CPU state.
86
+ */
87
+void kvm_arm_get_virtual_time(CPUState *cs);
88
+
89
+/**
90
+ * kvm_arm_put_virtual_time:
91
+ * @cs: CPUState
92
+ *
93
+ * Sets the VCPU's virtual counter to the value stored in the KVM CPU state.
94
+ */
95
+void kvm_arm_put_virtual_time(CPUState *cs);
96
+
97
+void kvm_arm_vm_state_change(void *opaque, int running, RunState state);
98
+
99
int kvm_arm_vgic_probe(void);
100
101
void kvm_arm_pmu_set_irq(CPUState *cs, int irq);
102
@@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {}
103
static inline void kvm_arm_pmu_init(CPUState *cs) {}
104
105
static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {}
106
+
107
+static inline void kvm_arm_get_virtual_time(CPUState *cs) {}
108
+static inline void kvm_arm_put_virtual_time(CPUState *cs) {}
109
#endif
110
111
static inline const char *gic_class_name(void)
112
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
113
index XXXXXXX..XXXXXXX 100644
114
--- a/target/arm/kvm.c
115
+++ b/target/arm/kvm.c
116
@@ -XXX,XX +XXX,XX @@ static int compare_u64(const void *a, const void *b)
117
return 0;
118
}
56
}
119
57
120
+/*
58
static bool trans_LD_zprr(DisasContext *s, arg_rprr_load *a)
121
+ * cpreg_values are sorted in ascending order by KVM register ID
59
@@ -XXX,XX +XXX,XX @@ static void do_st_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
122
+ * (see kvm_arm_init_cpreg_list). This allows us to cheaply find
60
if (nreg == 0) {
123
+ * the storage for a KVM register by ID with a binary search.
61
/* ST1 */
124
+ */
62
fn = fn_single[s->mte_active[0]][be][msz][esz];
125
+static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, uint64_t regidx)
63
- nreg = 1;
126
+{
64
} else {
127
+ uint64_t *res;
65
/* ST2, ST3, ST4 -- msz == esz, enforced by encoding */
128
+
66
assert(msz == esz);
129
+ res = bsearch(&regidx, cpu->cpreg_indexes, cpu->cpreg_array_len,
67
fn = fn_multiple[s->mte_active[0]][be][nreg - 1][msz];
130
+ sizeof(uint64_t), compare_u64);
68
}
131
+ assert(res);
69
assert(fn != NULL);
132
+
70
- do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg, true, fn);
133
+ return &cpu->cpreg_values[res - cpu->cpreg_indexes];
71
+ do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg + 1, true, fn);
134
+}
135
+
136
/* Initialize the ARMCPU cpreg list according to the kernel's
137
* definition of what CPU registers it knows about (and throw away
138
* the previous TCG-created cpreg list).
139
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
140
return ok;
141
}
72
}
142
73
143
+void kvm_arm_cpu_pre_save(ARMCPU *cpu)
74
static bool trans_ST_zprr(DisasContext *s, arg_rprr_store *a)
144
+{
145
+ /* KVM virtual time adjustment */
146
+ if (cpu->kvm_vtime_dirty) {
147
+ *kvm_arm_get_cpreg_ptr(cpu, KVM_REG_ARM_TIMER_CNT) = cpu->kvm_vtime;
148
+ }
149
+}
150
+
151
+void kvm_arm_cpu_post_load(ARMCPU *cpu)
152
+{
153
+ /* KVM virtual time adjustment */
154
+ if (cpu->kvm_adjvtime) {
155
+ cpu->kvm_vtime = *kvm_arm_get_cpreg_ptr(cpu, KVM_REG_ARM_TIMER_CNT);
156
+ cpu->kvm_vtime_dirty = true;
157
+ }
158
+}
159
+
160
void kvm_arm_reset_vcpu(ARMCPU *cpu)
161
{
162
int ret;
163
@@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu)
164
return 0;
165
}
166
167
+void kvm_arm_get_virtual_time(CPUState *cs)
168
+{
169
+ ARMCPU *cpu = ARM_CPU(cs);
170
+ struct kvm_one_reg reg = {
171
+ .id = KVM_REG_ARM_TIMER_CNT,
172
+ .addr = (uintptr_t)&cpu->kvm_vtime,
173
+ };
174
+ int ret;
175
+
176
+ if (cpu->kvm_vtime_dirty) {
177
+ return;
178
+ }
179
+
180
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
181
+ if (ret) {
182
+ error_report("Failed to get KVM_REG_ARM_TIMER_CNT");
183
+ abort();
184
+ }
185
+
186
+ cpu->kvm_vtime_dirty = true;
187
+}
188
+
189
+void kvm_arm_put_virtual_time(CPUState *cs)
190
+{
191
+ ARMCPU *cpu = ARM_CPU(cs);
192
+ struct kvm_one_reg reg = {
193
+ .id = KVM_REG_ARM_TIMER_CNT,
194
+ .addr = (uintptr_t)&cpu->kvm_vtime,
195
+ };
196
+ int ret;
197
+
198
+ if (!cpu->kvm_vtime_dirty) {
199
+ return;
200
+ }
201
+
202
+ ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
203
+ if (ret) {
204
+ error_report("Failed to set KVM_REG_ARM_TIMER_CNT");
205
+ abort();
206
+ }
207
+
208
+ cpu->kvm_vtime_dirty = false;
209
+}
210
+
211
int kvm_put_vcpu_events(ARMCPU *cpu)
212
{
213
CPUARMState *env = &cpu->env;
214
@@ -XXX,XX +XXX,XX @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
215
return MEMTXATTRS_UNSPECIFIED;
216
}
217
218
+void kvm_arm_vm_state_change(void *opaque, int running, RunState state)
219
+{
220
+ CPUState *cs = opaque;
221
+ ARMCPU *cpu = ARM_CPU(cs);
222
+
223
+ if (running) {
224
+ if (cpu->kvm_adjvtime) {
225
+ kvm_arm_put_virtual_time(cs);
226
+ }
227
+ } else {
228
+ if (cpu->kvm_adjvtime) {
229
+ kvm_arm_get_virtual_time(cs);
230
+ }
231
+ }
232
+}
233
234
int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
235
{
236
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
237
index XXXXXXX..XXXXXXX 100644
238
--- a/target/arm/kvm32.c
239
+++ b/target/arm/kvm32.c
240
@@ -XXX,XX +XXX,XX @@
241
#include "qemu-common.h"
242
#include "cpu.h"
243
#include "qemu/timer.h"
244
+#include "sysemu/runstate.h"
245
#include "sysemu/kvm.h"
246
#include "kvm_arm.h"
247
#include "internals.h"
248
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
249
return -EINVAL;
250
}
251
252
+ qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs);
253
+
254
/* Determine init features for this CPU */
255
memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
256
if (cpu->start_powered_off) {
257
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
258
index XXXXXXX..XXXXXXX 100644
259
--- a/target/arm/kvm64.c
260
+++ b/target/arm/kvm64.c
261
@@ -XXX,XX +XXX,XX @@
262
#include "qemu/host-utils.h"
263
#include "qemu/main-loop.h"
264
#include "exec/gdbstub.h"
265
+#include "sysemu/runstate.h"
266
#include "sysemu/kvm.h"
267
#include "sysemu/kvm_int.h"
268
#include "kvm_arm.h"
269
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
270
return -EINVAL;
271
}
272
273
+ qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs);
274
+
275
/* Determine init features for this CPU */
276
memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
277
if (cpu->start_powered_off) {
278
diff --git a/target/arm/machine.c b/target/arm/machine.c
279
index XXXXXXX..XXXXXXX 100644
280
--- a/target/arm/machine.c
281
+++ b/target/arm/machine.c
282
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
283
/* This should never fail */
284
abort();
285
}
286
+
287
+ /*
288
+ * kvm_arm_cpu_pre_save() must be called after
289
+ * write_kvmstate_to_list()
290
+ */
291
+ kvm_arm_cpu_pre_save(cpu);
292
} else {
293
if (!write_cpustate_to_list(cpu, false)) {
294
/* This should never fail. */
295
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
296
* we're using it.
297
*/
298
write_list_to_cpustate(cpu);
299
+ kvm_arm_cpu_post_load(cpu);
300
} else {
301
if (!write_list_to_cpustate(cpu)) {
302
return -1;
303
--
75
--
304
2.20.1
76
2.34.1
305
306
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
When we added SVE_MTEDESC_SHIFT, we effectively limited the
4
maximum size of MTEDESC. Adjust SIZEM1 to consume the remaining
5
bits (32 - 10 - 5 - 12 == 5). Assert that the data to be stored
6
fits within the field (expecting 8 * 4 - 1 == 31, exact fit).
7
8
Cc: qemu-stable@nongnu.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
12
Message-id: 20240207025210.8837-4-richard.henderson@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
target/arm/internals.h | 2 +-
16
target/arm/tcg/translate-sve.c | 7 ++++---
17
2 files changed, 5 insertions(+), 4 deletions(-)
18
19
diff --git a/target/arm/internals.h b/target/arm/internals.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/internals.h
22
+++ b/target/arm/internals.h
23
@@ -XXX,XX +XXX,XX @@ FIELD(MTEDESC, TBI, 4, 2)
24
FIELD(MTEDESC, TCMA, 6, 2)
25
FIELD(MTEDESC, WRITE, 8, 1)
26
FIELD(MTEDESC, ALIGN, 9, 3)
27
-FIELD(MTEDESC, SIZEM1, 12, SIMD_DATA_BITS - 12) /* size - 1 */
28
+FIELD(MTEDESC, SIZEM1, 12, SIMD_DATA_BITS - SVE_MTEDESC_SHIFT - 12) /* size - 1 */
29
30
bool mte_probe(CPUARMState *env, uint32_t desc, uint64_t ptr);
31
uint64_t mte_check(CPUARMState *env, uint32_t desc, uint64_t ptr, uintptr_t ra);
32
diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/tcg/translate-sve.c
35
+++ b/target/arm/tcg/translate-sve.c
36
@@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
37
{
38
unsigned vsz = vec_full_reg_size(s);
39
TCGv_ptr t_pg;
40
+ uint32_t sizem1;
41
int desc = 0;
42
43
assert(mte_n >= 1 && mte_n <= 4);
44
+ sizem1 = (mte_n << dtype_msz(dtype)) - 1;
45
+ assert(sizem1 <= R_MTEDESC_SIZEM1_MASK >> R_MTEDESC_SIZEM1_SHIFT);
46
if (s->mte_active[0]) {
47
- int msz = dtype_msz(dtype);
48
-
49
desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s));
50
desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid);
51
desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma);
52
desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write);
53
- desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (mte_n << msz) - 1);
54
+ desc = FIELD_DP32(desc, MTEDESC, SIZEM1, sizem1);
55
desc <<= SVE_MTEDESC_SHIFT;
56
} else {
57
addr = clean_data_tbi(s, addr);
58
--
59
2.34.1
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This commit make use of the resettable API to reset the device being
3
Share code that creates mtedesc and embeds within simd_desc.
4
hotplugged when it is realized. Also it ensures it is put in a reset
5
state coherent with the parent it is plugged into.
6
4
7
Note that there is a difference in the reset. Instead of resetting
5
Cc: qemu-stable@nongnu.org
8
only the hotplugged device, we reset also its subtree (switch to
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
resettable API). This is not expected to be a problem because
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
sub-buses are just realized too. If a hotplugged device has any
8
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
11
sub-buses it is logical to reset them too at this point.
9
Message-id: 20240207025210.8837-5-richard.henderson@linaro.org
12
13
The recently added should_be_hidden and PCI's partially_hotplugged
14
mechanisms do not interfere with realize operation:
15
+ In the should_be_hidden use case, device creation is
16
delayed.
17
+ The partially_hotplugged mechanism prevents a device to be
18
unplugged and unrealized from qdev POV and unrealized.
19
20
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
23
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
24
Message-id: 20200123132823.1117486-8-damien.hedde@greensocs.com
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
11
---
27
include/hw/resettable.h | 11 +++++++++++
12
target/arm/tcg/translate-a64.h | 2 ++
28
hw/core/qdev.c | 15 ++++++++++++++-
13
target/arm/tcg/translate-sme.c | 15 +++--------
29
2 files changed, 25 insertions(+), 1 deletion(-)
14
target/arm/tcg/translate-sve.c | 47 ++++++++++++++++++----------------
15
3 files changed, 31 insertions(+), 33 deletions(-)
30
16
31
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
17
diff --git a/target/arm/tcg/translate-a64.h b/target/arm/tcg/translate-a64.h
32
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
33
--- a/include/hw/resettable.h
19
--- a/target/arm/tcg/translate-a64.h
34
+++ b/include/hw/resettable.h
20
+++ b/target/arm/tcg/translate-a64.h
35
@@ -XXX,XX +XXX,XX @@ struct ResettableState {
21
@@ -XXX,XX +XXX,XX @@ bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn,
36
bool exit_phase_in_progress;
22
bool sve_access_check(DisasContext *s);
23
bool sme_enabled_check(DisasContext *s);
24
bool sme_enabled_check_with_svcr(DisasContext *s, unsigned);
25
+uint32_t make_svemte_desc(DisasContext *s, unsigned vsz, uint32_t nregs,
26
+ uint32_t msz, bool is_write, uint32_t data);
27
28
/* This function corresponds to CheckStreamingSVEEnabled. */
29
static inline bool sme_sm_enabled_check(DisasContext *s)
30
diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/tcg/translate-sme.c
33
+++ b/target/arm/tcg/translate-sme.c
34
@@ -XXX,XX +XXX,XX @@ static bool trans_LDST1(DisasContext *s, arg_LDST1 *a)
35
36
TCGv_ptr t_za, t_pg;
37
TCGv_i64 addr;
38
- int svl, desc = 0;
39
+ uint32_t desc;
40
bool be = s->be_data == MO_BE;
41
bool mte = s->mte_active[0];
42
43
@@ -XXX,XX +XXX,XX @@ static bool trans_LDST1(DisasContext *s, arg_LDST1 *a)
44
tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), a->esz);
45
tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn));
46
47
- if (mte) {
48
- desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s));
49
- desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid);
50
- desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma);
51
- desc = FIELD_DP32(desc, MTEDESC, WRITE, a->st);
52
- desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << a->esz) - 1);
53
- desc <<= SVE_MTEDESC_SHIFT;
54
- } else {
55
+ if (!mte) {
56
addr = clean_data_tbi(s, addr);
57
}
58
- svl = streaming_vec_reg_size(s);
59
- desc = simd_desc(svl, svl, desc);
60
+
61
+ desc = make_svemte_desc(s, streaming_vec_reg_size(s), 1, a->esz, a->st, 0);
62
63
fns[a->esz][be][a->v][mte][a->st](tcg_env, t_za, t_pg, addr,
64
tcg_constant_i32(desc));
65
diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/target/arm/tcg/translate-sve.c
68
+++ b/target/arm/tcg/translate-sve.c
69
@@ -XXX,XX +XXX,XX @@ static const uint8_t dtype_esz[16] = {
70
3, 2, 1, 3
37
};
71
};
38
72
39
+/**
73
-static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
40
+ * resettable_state_clear:
74
- int dtype, uint32_t mte_n, bool is_write,
41
+ * Clear the state. It puts the state to the initial (zeroed) state required
75
- gen_helper_gvec_mem *fn)
42
+ * to reuse an object. Typically used in realize step of base classes
76
+uint32_t make_svemte_desc(DisasContext *s, unsigned vsz, uint32_t nregs,
43
+ * implementing the interface.
77
+ uint32_t msz, bool is_write, uint32_t data)
44
+ */
78
{
45
+static inline void resettable_state_clear(ResettableState *state)
79
- unsigned vsz = vec_full_reg_size(s);
46
+{
80
- TCGv_ptr t_pg;
47
+ memset(state, 0, sizeof(ResettableState));
81
uint32_t sizem1;
82
- int desc = 0;
83
+ uint32_t desc = 0;
84
85
- assert(mte_n >= 1 && mte_n <= 4);
86
- sizem1 = (mte_n << dtype_msz(dtype)) - 1;
87
+ /* Assert all of the data fits, with or without MTE enabled. */
88
+ assert(nregs >= 1 && nregs <= 4);
89
+ sizem1 = (nregs << msz) - 1;
90
assert(sizem1 <= R_MTEDESC_SIZEM1_MASK >> R_MTEDESC_SIZEM1_SHIFT);
91
+ assert(data < 1u << SVE_MTEDESC_SHIFT);
92
+
93
if (s->mte_active[0]) {
94
desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s));
95
desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid);
96
@@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
97
desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write);
98
desc = FIELD_DP32(desc, MTEDESC, SIZEM1, sizem1);
99
desc <<= SVE_MTEDESC_SHIFT;
100
- } else {
101
+ }
102
+ return simd_desc(vsz, vsz, desc | data);
48
+}
103
+}
49
+
104
+
50
/**
105
+static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
51
* resettable_reset:
106
+ int dtype, uint32_t nregs, bool is_write,
52
* Trigger a reset on an object @obj of type @type. @obj must implement
107
+ gen_helper_gvec_mem *fn)
53
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
108
+{
54
index XXXXXXX..XXXXXXX 100644
109
+ TCGv_ptr t_pg;
55
--- a/hw/core/qdev.c
110
+ uint32_t desc;
56
+++ b/hw/core/qdev.c
57
@@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp)
58
}
59
}
60
61
+ /*
62
+ * Clear the reset state, in case the object was previously unrealized
63
+ * with a dirty state.
64
+ */
65
+ resettable_state_clear(&dev->reset);
66
+
111
+
67
QLIST_FOREACH(bus, &dev->child_bus, sibling) {
112
+ if (!s->mte_active[0]) {
68
object_property_set_bool(OBJECT(bus), true, "realized",
113
addr = clean_data_tbi(s, addr);
69
&local_err);
114
}
70
@@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp)
115
71
}
116
@@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
72
}
117
* registers as pointers, so encode the regno into the data field.
73
if (dev->hotplugged) {
118
* For consistency, do this even for LD1.
74
- device_legacy_reset(dev);
119
*/
75
+ /*
120
- desc = simd_desc(vsz, vsz, zt | desc);
76
+ * Reset the device, as well as its subtree which, at this point,
121
+ desc = make_svemte_desc(s, vec_full_reg_size(s), nregs,
77
+ * should be realized too.
122
+ dtype_msz(dtype), is_write, zt);
78
+ */
123
t_pg = tcg_temp_new_ptr();
79
+ resettable_assert_reset(OBJECT(dev), RESET_TYPE_COLD);
124
80
+ resettable_change_parent(OBJECT(dev), OBJECT(dev->parent_bus),
125
tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, pg));
81
+ NULL);
126
@@ -XXX,XX +XXX,XX @@ static void do_mem_zpz(DisasContext *s, int zt, int pg, int zm,
82
+ resettable_release_reset(OBJECT(dev), RESET_TYPE_COLD);
127
int scale, TCGv_i64 scalar, int msz, bool is_write,
83
}
128
gen_helper_gvec_mem_scatter *fn)
84
dev->pending_deleted_event = false;
129
{
130
- unsigned vsz = vec_full_reg_size(s);
131
TCGv_ptr t_zm = tcg_temp_new_ptr();
132
TCGv_ptr t_pg = tcg_temp_new_ptr();
133
TCGv_ptr t_zt = tcg_temp_new_ptr();
134
- int desc = 0;
135
-
136
- if (s->mte_active[0]) {
137
- desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s));
138
- desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid);
139
- desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma);
140
- desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write);
141
- desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << msz) - 1);
142
- desc <<= SVE_MTEDESC_SHIFT;
143
- }
144
- desc = simd_desc(vsz, vsz, desc | scale);
145
+ uint32_t desc;
146
147
tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, pg));
148
tcg_gen_addi_ptr(t_zm, tcg_env, vec_full_reg_offset(s, zm));
149
tcg_gen_addi_ptr(t_zt, tcg_env, vec_full_reg_offset(s, zt));
150
+
151
+ desc = make_svemte_desc(s, vec_full_reg_size(s), 1, msz, is_write, scale);
152
fn(tcg_env, t_zt, t_pg, t_zm, scalar, tcg_constant_i32(desc));
153
}
85
154
86
--
155
--
87
2.20.1
156
2.34.1
88
89
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
These functions "use the standard load helpers", but
4
fail to clean_data_tbi or populate mtedesc.
5
6
Cc: qemu-stable@nongnu.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
10
Message-id: 20240207025210.8837-6-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/tcg/translate-sve.c | 15 +++++++++++++--
14
1 file changed, 13 insertions(+), 2 deletions(-)
15
16
diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/tcg/translate-sve.c
19
+++ b/target/arm/tcg/translate-sve.c
20
@@ -XXX,XX +XXX,XX @@ static void do_ldrq(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype)
21
unsigned vsz = vec_full_reg_size(s);
22
TCGv_ptr t_pg;
23
int poff;
24
+ uint32_t desc;
25
26
/* Load the first quadword using the normal predicated load helpers. */
27
+ if (!s->mte_active[0]) {
28
+ addr = clean_data_tbi(s, addr);
29
+ }
30
+
31
poff = pred_full_reg_offset(s, pg);
32
if (vsz > 16) {
33
/*
34
@@ -XXX,XX +XXX,XX @@ static void do_ldrq(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype)
35
36
gen_helper_gvec_mem *fn
37
= ldr_fns[s->mte_active[0]][s->be_data == MO_BE][dtype][0];
38
- fn(tcg_env, t_pg, addr, tcg_constant_i32(simd_desc(16, 16, zt)));
39
+ desc = make_svemte_desc(s, 16, 1, dtype_msz(dtype), false, zt);
40
+ fn(tcg_env, t_pg, addr, tcg_constant_i32(desc));
41
42
/* Replicate that first quadword. */
43
if (vsz > 16) {
44
@@ -XXX,XX +XXX,XX @@ static void do_ldro(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype)
45
unsigned vsz_r32;
46
TCGv_ptr t_pg;
47
int poff, doff;
48
+ uint32_t desc;
49
50
if (vsz < 32) {
51
/*
52
@@ -XXX,XX +XXX,XX @@ static void do_ldro(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype)
53
}
54
55
/* Load the first octaword using the normal predicated load helpers. */
56
+ if (!s->mte_active[0]) {
57
+ addr = clean_data_tbi(s, addr);
58
+ }
59
60
poff = pred_full_reg_offset(s, pg);
61
if (vsz > 32) {
62
@@ -XXX,XX +XXX,XX @@ static void do_ldro(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype)
63
64
gen_helper_gvec_mem *fn
65
= ldr_fns[s->mte_active[0]][s->be_data == MO_BE][dtype][0];
66
- fn(tcg_env, t_pg, addr, tcg_constant_i32(simd_desc(32, 32, zt)));
67
+ desc = make_svemte_desc(s, 32, 1, dtype_msz(dtype), false, zt);
68
+ fn(tcg_env, t_pg, addr, tcg_constant_i32(desc));
69
70
/*
71
* Replicate that first octaword.
72
--
73
2.34.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
The TBI and TCMA bits are located within mtedesc, not desc.
4
5
Cc: qemu-stable@nongnu.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
9
Message-id: 20240207025210.8837-7-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/tcg/sme_helper.c | 8 ++++----
13
target/arm/tcg/sve_helper.c | 12 ++++++------
14
2 files changed, 10 insertions(+), 10 deletions(-)
15
16
diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/tcg/sme_helper.c
19
+++ b/target/arm/tcg/sme_helper.c
20
@@ -XXX,XX +XXX,XX @@ void sme_ld1_mte(CPUARMState *env, void *za, uint64_t *vg,
21
desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
22
23
/* Perform gross MTE suppression early. */
24
- if (!tbi_check(desc, bit55) ||
25
- tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
26
+ if (!tbi_check(mtedesc, bit55) ||
27
+ tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
28
mtedesc = 0;
29
}
30
31
@@ -XXX,XX +XXX,XX @@ void sme_st1_mte(CPUARMState *env, void *za, uint64_t *vg, target_ulong addr,
32
desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
33
34
/* Perform gross MTE suppression early. */
35
- if (!tbi_check(desc, bit55) ||
36
- tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
37
+ if (!tbi_check(mtedesc, bit55) ||
38
+ tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
39
mtedesc = 0;
40
}
41
42
diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/target/arm/tcg/sve_helper.c
45
+++ b/target/arm/tcg/sve_helper.c
46
@@ -XXX,XX +XXX,XX @@ void sve_ldN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr,
47
desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
48
49
/* Perform gross MTE suppression early. */
50
- if (!tbi_check(desc, bit55) ||
51
- tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
52
+ if (!tbi_check(mtedesc, bit55) ||
53
+ tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
54
mtedesc = 0;
55
}
56
57
@@ -XXX,XX +XXX,XX @@ void sve_ldnfff1_r_mte(CPUARMState *env, void *vg, target_ulong addr,
58
desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
59
60
/* Perform gross MTE suppression early. */
61
- if (!tbi_check(desc, bit55) ||
62
- tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
63
+ if (!tbi_check(mtedesc, bit55) ||
64
+ tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
65
mtedesc = 0;
66
}
67
68
@@ -XXX,XX +XXX,XX @@ void sve_stN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr,
69
desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
70
71
/* Perform gross MTE suppression early. */
72
- if (!tbi_check(desc, bit55) ||
73
- tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
74
+ if (!tbi_check(mtedesc, bit55) ||
75
+ tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
76
mtedesc = 0;
77
}
78
79
--
80
2.34.1
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
The raven_io_ops MemoryRegionOps is the only one in the source tree
2
which sets .valid.unaligned to indicate that it should support
3
unaligned accesses and which does not also set .impl.unaligned to
4
indicate that its read and write functions can do the unaligned
5
handling themselves. This is a problem, because at the moment the
6
core memory system does not implement the support for handling
7
unaligned accesses by doing a series of aligned accesses and
8
combining them (system/memory.c:access_with_adjusted_size() has a
9
TODO comment noting this).
2
10
3
Add the missing GENERIC_TIMER feature to kvm64 cpus.
11
Fortunately raven_io_read() and raven_io_write() will correctly deal
12
with the case of being passed an unaligned address, so we can fix the
13
missing unaligned access support by setting .impl.unaligned in the
14
MemoryRegionOps struct.
4
15
5
We don't currently use these registers when KVM is enabled, but it's
16
Fixes: 9a1839164c9c8f06 ("raven: Implement non-contiguous I/O region")
6
probably best we add the feature flag for consistency and potential
7
future use. There's also precedent, as we add the PMU feature flag to
8
KVM enabled guests, even though we don't use those registers either.
9
10
This change was originally posted as a hunk of a different, never
11
merged patch from Bijan Mottahedeh.
12
13
Signed-off-by: Andrew Jones <drjones@redhat.com>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20200120101023.16030-4-drjones@redhat.com
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Tested-by: Cédric Le Goater <clg@redhat.com>
19
Reviewed-by: Cédric Le Goater <clg@redhat.com>
20
Message-id: 20240112134640.1775041-1-peter.maydell@linaro.org
17
---
21
---
18
target/arm/kvm64.c | 1 +
22
hw/pci-host/raven.c | 1 +
19
1 file changed, 1 insertion(+)
23
1 file changed, 1 insertion(+)
20
24
21
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
25
diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
22
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/kvm64.c
27
--- a/hw/pci-host/raven.c
24
+++ b/target/arm/kvm64.c
28
+++ b/hw/pci-host/raven.c
25
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
29
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps raven_io_ops = {
26
set_feature(&features, ARM_FEATURE_NEON);
30
.write = raven_io_write,
27
set_feature(&features, ARM_FEATURE_AARCH64);
31
.endianness = DEVICE_LITTLE_ENDIAN,
28
set_feature(&features, ARM_FEATURE_PMU);
32
.impl.max_access_size = 4,
29
+ set_feature(&features, ARM_FEATURE_GENERIC_TIMER);
33
+ .impl.unaligned = true,
30
34
.valid.unaligned = true,
31
ahcf->features = features;
35
};
32
36
33
--
37
--
34
2.20.1
38
2.34.1
35
39
36
40
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
Suppress the deprecation warning when we're running under qtest,
2
to avoid "make check" including warning messages in its output.
2
3
3
If we know what the default value should be then we can test for
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
that as well as the feature existence.
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Message-id: 20240206154151.155620-1-peter.maydell@linaro.org
7
---
8
hw/block/tc58128.c | 4 +++-
9
1 file changed, 3 insertions(+), 1 deletion(-)
5
10
6
Signed-off-by: Andrew Jones <drjones@redhat.com>
11
diff --git a/hw/block/tc58128.c b/hw/block/tc58128.c
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200120101023.16030-5-drjones@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
tests/qtest/arm-cpu-features.c | 37 +++++++++++++++++++++++++---------
12
1 file changed, 28 insertions(+), 9 deletions(-)
13
14
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
15
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/arm-cpu-features.c
13
--- a/hw/block/tc58128.c
17
+++ b/tests/qtest/arm-cpu-features.c
14
+++ b/hw/block/tc58128.c
18
@@ -XXX,XX +XXX,XX @@ static bool resp_get_feature(QDict *resp, const char *feature)
15
@@ -XXX,XX +XXX,XX @@ static sh7750_io_device tc58128 = {
19
qobject_unref(_resp); \
16
20
})
17
int tc58128_init(struct SH7750State *s, const char *zone1, const char *zone2)
21
22
+#define assert_feature(qts, cpu_type, feature, expected_value) \
23
+({ \
24
+ QDict *_resp, *_props; \
25
+ \
26
+ _resp = do_query_no_props(qts, cpu_type); \
27
+ g_assert(_resp); \
28
+ g_assert(resp_has_props(_resp)); \
29
+ _props = resp_get_props(_resp); \
30
+ g_assert(qdict_get(_props, feature)); \
31
+ g_assert(qdict_get_bool(_props, feature) == (expected_value)); \
32
+ qobject_unref(_resp); \
33
+})
34
+
35
+#define assert_has_feature_enabled(qts, cpu_type, feature) \
36
+ assert_feature(qts, cpu_type, feature, true)
37
+
38
+#define assert_has_feature_disabled(qts, cpu_type, feature) \
39
+ assert_feature(qts, cpu_type, feature, false)
40
+
41
static void assert_type_full(QTestState *qts)
42
{
18
{
43
const char *error;
19
- warn_report_once("The TC58128 flash device is deprecated");
44
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data)
20
+ if (!qtest_enabled()) {
45
assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);
21
+ warn_report_once("The TC58128 flash device is deprecated");
46
22
+ }
47
/* Test expected feature presence/absence for some cpu types */
23
init_dev(&tc58128_devs[0], zone1);
48
- assert_has_feature(qts, "max", "pmu");
24
init_dev(&tc58128_devs[1], zone2);
49
- assert_has_feature(qts, "cortex-a15", "pmu");
25
return sh7750_register_io_device(s, &tc58128);
50
+ assert_has_feature_enabled(qts, "max", "pmu");
51
+ assert_has_feature_enabled(qts, "cortex-a15", "pmu");
52
assert_has_not_feature(qts, "cortex-a15", "aarch64");
53
54
if (g_str_equal(qtest_get_arch(), "aarch64")) {
55
- assert_has_feature(qts, "max", "aarch64");
56
- assert_has_feature(qts, "max", "sve");
57
- assert_has_feature(qts, "max", "sve128");
58
- assert_has_feature(qts, "cortex-a57", "pmu");
59
- assert_has_feature(qts, "cortex-a57", "aarch64");
60
+ assert_has_feature_enabled(qts, "max", "aarch64");
61
+ assert_has_feature_enabled(qts, "max", "sve");
62
+ assert_has_feature_enabled(qts, "max", "sve128");
63
+ assert_has_feature_enabled(qts, "cortex-a57", "pmu");
64
+ assert_has_feature_enabled(qts, "cortex-a57", "aarch64");
65
66
sve_tests_default(qts, "max");
67
68
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
69
QDict *resp;
70
char *error;
71
72
- assert_has_feature(qts, "host", "aarch64");
73
- assert_has_feature(qts, "host", "pmu");
74
+ assert_has_feature_enabled(qts, "host", "aarch64");
75
+ assert_has_feature_enabled(qts, "host", "pmu");
76
77
assert_error(qts, "cortex-a15",
78
"We cannot guarantee the CPU type 'cortex-a15' works "
79
--
26
--
80
2.20.1
27
2.34.1
81
28
82
29
diff view generated by jsdifflib
1
From: Zenghui Yu <yuzenghui@huawei.com>
1
We deliberately don't include qtests_npcm7xx in qtests_aarch64,
2
because we already get the coverage of those tests via qtests_arm,
3
and we don't want to use extra CI minutes testing them twice.
2
4
3
If LPIs are disabled, KVM will just ignore the GICR_PENDBASER.PTZ bit when
5
In commit 327b680877b79c4b we added it to qtests_aarch64; revert
4
restoring GICR_CTLR. Setting PTZ here makes littlt sense in "reduce GIC
6
that change.
5
initialization time".
6
7
7
And what's worse, PTZ is generally programmed by guest to indicate to the
8
Fixes: 327b680877b79c4b ("tests/qtest: Creating qtest for GMAC Module")
8
Redistributor whether the LPI Pending table is zero when enabling LPIs.
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
If migration is triggered when the PTZ has just been cleared by guest (and
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
before enabling LPIs), we will see PTZ==1 on the destination side, which
11
Message-id: 20240206163043.315535-1-peter.maydell@linaro.org
11
is not as expected. Let's just drop this hackish userspace behavior.
12
---
13
tests/qtest/meson.build | 1 -
14
1 file changed, 1 deletion(-)
12
15
13
Also take this chance to refine the comment a bit.
16
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
14
15
Fixes: 367b9f527bec ("hw/intc/arm_gicv3_kvm: Implement get/put functions")
16
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
17
Message-id: 20200119133051.642-1-yuzenghui@huawei.com
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
hw/intc/arm_gicv3_kvm.c | 11 ++++-------
22
1 file changed, 4 insertions(+), 7 deletions(-)
23
24
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
25
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/intc/arm_gicv3_kvm.c
18
--- a/tests/qtest/meson.build
27
+++ b/hw/intc/arm_gicv3_kvm.c
19
+++ b/tests/qtest/meson.build
28
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_put(GICv3State *s)
20
@@ -XXX,XX +XXX,XX @@ qtests_aarch64 = \
29
kvm_gicd_access(s, GICD_CTLR, &reg, true);
21
(config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \
30
22
(config_all_accel.has_key('CONFIG_TCG') and \
31
if (redist_typer & GICR_TYPER_PLPIS) {
23
config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
32
- /* Set base addresses before LPIs are enabled by GICR_CTLR write */
24
- (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
33
+ /*
25
['arm-cpu-features',
34
+ * Restore base addresses before LPIs are potentially enabled by
26
'numa-test',
35
+ * GICR_CTLR write
27
'boot-serial-test',
36
+ */
37
for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
38
GICv3CPUState *c = &s->cpu[ncpu];
39
40
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_put(GICv3State *s)
41
kvm_gicr_access(s, GICR_PROPBASER + 4, ncpu, &regh, true);
42
43
reg64 = c->gicr_pendbaser;
44
- if (!(c->gicr_ctlr & GICR_CTLR_ENABLE_LPIS)) {
45
- /* Setting PTZ is advised if LPIs are disabled, to reduce
46
- * GIC initialization time.
47
- */
48
- reg64 |= GICR_PENDBASER_PTZ;
49
- }
50
regl = (uint32_t)reg64;
51
kvm_gicr_access(s, GICR_PENDBASER, ncpu, &regl, true);
52
regh = (uint32_t)(reg64 >> 32);
53
--
28
--
54
2.20.1
29
2.34.1
55
30
56
31
diff view generated by jsdifflib
New patch
1
Allow changes to the virt GTDT -- we are going to add the IRQ
2
entry for a new timer to it.
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
6
Message-id: 20240122143537.233498-2-peter.maydell@linaro.org
7
---
8
tests/qtest/bios-tables-test-allowed-diff.h | 2 ++
9
1 file changed, 2 insertions(+)
10
11
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qtest/bios-tables-test-allowed-diff.h
14
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
15
@@ -1 +1,3 @@
16
/* List of comma-separated changed AML files to ignore */
17
+"tests/data/acpi/virt/FACP",
18
+"tests/data/acpi/virt/GTDT",
19
--
20
2.34.1
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
Armv8.1+ CPUs have the Virtual Host Extension (VHE) which adds a
2
2
non-secure EL2 virtual timer. We implemented the timer itself in the
3
kvm-no-adjvtime is a KVM specific CPU property and a first of its
3
CPU model, but never wired up its IRQ line to the GIC.
4
kind. To accommodate it we also add kvm_arm_add_vcpu_properties()
4
5
and a KVM specific CPU properties description to the CPU features
5
Wire up the IRQ line (this is always safe whether the CPU has the
6
document.
6
interrupt or not, since it always creates the outbound IRQ line).
7
7
Report it to the guest via dtb and ACPI if the CPU has the feature.
8
Signed-off-by: Andrew Jones <drjones@redhat.com>
8
9
Message-id: 20200120101023.16030-7-drjones@redhat.com
9
The DTB binding is documented in the kernel's
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Documentation/devicetree/bindings/timer/arm\,arch_timer.yaml
11
and the ACPI table entries are documented in the ACPI specification
12
version 6.3 or later.
13
14
Because the IRQ line ACPI binding is new in 6.3, we need to bump the
15
FADT table rev to show that we might be using 6.3 features.
16
17
Note that exposing this IRQ in the DTB will trigger a bug in EDK2
18
versions prior to edk2-stable202311, for users who use the virt board
19
with 'virtualization=on' to enable EL2 emulation and are booting an
20
EDK2 guest BIOS, if that EDK2 has assertions enabled. The effect is
21
that EDK2 will assert on bootup:
22
23
ASSERT [ArmTimerDxe] /home/kraxel/projects/qemu/roms/edk2/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c(72): PropSize == 36 || PropSize == 48
24
25
If you see that assertion you should do one of:
26
* update your EDK2 binaries to edk2-stable202311 or newer
27
* use the 'virt-8.2' versioned machine type
28
* not use 'virtualization=on'
29
30
(The versions shipped with QEMU itself have the fix.)
31
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
33
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
34
Message-id: 20240122143537.233498-3-peter.maydell@linaro.org
12
---
35
---
13
include/hw/arm/virt.h | 1 +
36
include/hw/arm/virt.h | 2 ++
14
target/arm/kvm_arm.h | 11 ++++++++++
37
hw/arm/virt-acpi-build.c | 20 ++++++++++----
15
hw/arm/virt.c | 8 ++++++++
38
hw/arm/virt.c | 60 ++++++++++++++++++++++++++++++++++------
16
target/arm/cpu.c | 2 ++
39
3 files changed, 67 insertions(+), 15 deletions(-)
17
target/arm/cpu64.c | 1 +
18
target/arm/kvm.c | 28 +++++++++++++++++++++++++
19
target/arm/monitor.c | 1 +
20
tests/qtest/arm-cpu-features.c | 4 ++++
21
docs/arm-cpu-features.rst | 37 +++++++++++++++++++++++++++++++++-
22
9 files changed, 92 insertions(+), 1 deletion(-)
23
40
24
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
41
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
25
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/arm/virt.h
43
--- a/include/hw/arm/virt.h
27
+++ b/include/hw/arm/virt.h
44
+++ b/include/hw/arm/virt.h
28
@@ -XXX,XX +XXX,XX @@ typedef struct {
45
@@ -XXX,XX +XXX,XX @@ struct VirtMachineClass {
29
bool smbios_old_sys_ver;
46
/* Machines < 6.2 have no support for describing cpu topology to guest */
30
bool no_highmem_ecam;
47
bool no_cpu_topology;
31
bool no_ged; /* Machines < 4.2 has no support for ACPI GED device */
48
bool no_tcg_lpa2;
32
+ bool kvm_no_adjvtime;
49
+ bool no_ns_el2_virt_timer_irq;
33
} VirtMachineClass;
50
};
34
51
35
typedef struct {
52
struct VirtMachineState {
36
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
53
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
54
PCIBus *bus;
55
char *oem_id;
56
char *oem_table_id;
57
+ bool ns_el2_virt_timer_irq;
58
};
59
60
#define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
61
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
37
index XXXXXXX..XXXXXXX 100644
62
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/kvm_arm.h
63
--- a/hw/arm/virt-acpi-build.c
39
+++ b/target/arm/kvm_arm.h
64
+++ b/hw/arm/virt-acpi-build.c
40
@@ -XXX,XX +XXX,XX @@ void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map);
65
@@ -XXX,XX +XXX,XX @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
66
}
67
68
/*
69
- * ACPI spec, Revision 5.1
70
- * 5.2.24 Generic Timer Description Table (GTDT)
71
+ * ACPI spec, Revision 6.5
72
+ * 5.2.25 Generic Timer Description Table (GTDT)
41
*/
73
*/
42
void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);
74
static void
43
75
build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
44
+/**
76
@@ -XXX,XX +XXX,XX @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
45
+ * kvm_arm_add_vcpu_properties:
77
uint32_t irqflags = vmc->claim_edge_triggered_timers ?
46
+ * @obj: The CPU object to add the properties to
78
1 : /* Interrupt is Edge triggered */
47
+ *
79
0; /* Interrupt is Level triggered */
48
+ * Add all KVM specific CPU properties to the CPU object. These
80
- AcpiTable table = { .sig = "GTDT", .rev = 2, .oem_id = vms->oem_id,
49
+ * are the CPU properties with "kvm-" prefixed names.
81
+ AcpiTable table = { .sig = "GTDT", .rev = 3, .oem_id = vms->oem_id,
50
+ */
82
.oem_table_id = vms->oem_table_id };
51
+void kvm_arm_add_vcpu_properties(Object *obj);
83
52
+
84
acpi_table_begin(&table, table_data);
53
/**
85
@@ -XXX,XX +XXX,XX @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
54
* kvm_arm_aarch32_supported:
86
build_append_int_noprefix(table_data, 0, 4);
55
* @cs: CPUState
87
/* Platform Timer Offset */
56
@@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
88
build_append_int_noprefix(table_data, 0, 4);
57
cpu->host_cpu_probe_failed = true;
89
-
58
}
90
+ if (vms->ns_el2_virt_timer_irq) {
59
91
+ /* Virtual EL2 Timer GSIV */
60
+static inline void kvm_arm_add_vcpu_properties(Object *obj) {}
92
+ build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_VIRT_IRQ, 4);
61
+
93
+ /* Virtual EL2 Timer Flags */
62
static inline bool kvm_arm_aarch32_supported(CPUState *cs)
94
+ build_append_int_noprefix(table_data, irqflags, 4);
95
+ } else {
96
+ build_append_int_noprefix(table_data, 0, 4);
97
+ build_append_int_noprefix(table_data, 0, 4);
98
+ }
99
acpi_table_end(linker, &table);
100
}
101
102
@@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
103
static void build_fadt_rev6(GArray *table_data, BIOSLinker *linker,
104
VirtMachineState *vms, unsigned dsdt_tbl_offset)
63
{
105
{
64
return false;
106
- /* ACPI v6.0 */
107
+ /* ACPI v6.3 */
108
AcpiFadtData fadt = {
109
.rev = 6,
110
- .minor_ver = 0,
111
+ .minor_ver = 3,
112
.flags = 1 << ACPI_FADT_F_HW_REDUCED_ACPI,
113
.xdsdt_tbl_offset = &dsdt_tbl_offset,
114
};
65
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
115
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
66
index XXXXXXX..XXXXXXX 100644
116
index XXXXXXX..XXXXXXX 100644
67
--- a/hw/arm/virt.c
117
--- a/hw/arm/virt.c
68
+++ b/hw/arm/virt.c
118
+++ b/hw/arm/virt.c
119
@@ -XXX,XX +XXX,XX @@ static void create_randomness(MachineState *ms, const char *node)
120
qemu_fdt_setprop(ms->fdt, node, "rng-seed", seed.rng, sizeof(seed.rng));
121
}
122
123
+/*
124
+ * The CPU object always exposes the NS EL2 virt timer IRQ line,
125
+ * but we don't want to advertise it to the guest in the dtb or ACPI
126
+ * table unless it's really going to do something.
127
+ */
128
+static bool ns_el2_virt_timer_present(void)
129
+{
130
+ ARMCPU *cpu = ARM_CPU(qemu_get_cpu(0));
131
+ CPUARMState *env = &cpu->env;
132
+
133
+ return arm_feature(env, ARM_FEATURE_AARCH64) &&
134
+ arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu);
135
+}
136
+
137
static void create_fdt(VirtMachineState *vms)
138
{
139
MachineState *ms = MACHINE(vms);
140
@@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms)
141
"arm,armv7-timer");
142
}
143
qemu_fdt_setprop(ms->fdt, "/timer", "always-on", NULL, 0);
144
- qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts",
145
- GIC_FDT_IRQ_TYPE_PPI,
146
- INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags,
147
- GIC_FDT_IRQ_TYPE_PPI,
148
- INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags,
149
- GIC_FDT_IRQ_TYPE_PPI,
150
- INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags,
151
- GIC_FDT_IRQ_TYPE_PPI,
152
- INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags);
153
+ if (vms->ns_el2_virt_timer_irq) {
154
+ qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts",
155
+ GIC_FDT_IRQ_TYPE_PPI,
156
+ INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags,
157
+ GIC_FDT_IRQ_TYPE_PPI,
158
+ INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags,
159
+ GIC_FDT_IRQ_TYPE_PPI,
160
+ INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags,
161
+ GIC_FDT_IRQ_TYPE_PPI,
162
+ INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags,
163
+ GIC_FDT_IRQ_TYPE_PPI,
164
+ INTID_TO_PPI(ARCH_TIMER_NS_EL2_VIRT_IRQ), irqflags);
165
+ } else {
166
+ qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts",
167
+ GIC_FDT_IRQ_TYPE_PPI,
168
+ INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags,
169
+ GIC_FDT_IRQ_TYPE_PPI,
170
+ INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags,
171
+ GIC_FDT_IRQ_TYPE_PPI,
172
+ INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags,
173
+ GIC_FDT_IRQ_TYPE_PPI,
174
+ INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags);
175
+ }
176
}
177
178
static void fdt_add_cpu_nodes(const VirtMachineState *vms)
179
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
180
[GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ,
181
[GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ,
182
[GTIMER_SEC] = ARCH_TIMER_S_EL1_IRQ,
183
+ [GTIMER_HYPVIRT] = ARCH_TIMER_NS_EL2_VIRT_IRQ,
184
};
185
186
for (unsigned irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
69
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
187
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
70
}
188
qdev_realize(DEVICE(cpuobj), NULL, &error_fatal);
71
}
189
object_unref(cpuobj);
72
190
}
73
+ if (vmc->kvm_no_adjvtime &&
191
+
74
+ object_property_find(cpuobj, "kvm-no-adjvtime", NULL)) {
192
+ /* Now we've created the CPUs we can see if they have the hypvirt timer */
75
+ object_property_set_bool(cpuobj, true, "kvm-no-adjvtime", NULL);
193
+ vms->ns_el2_virt_timer_irq = ns_el2_virt_timer_present() &&
76
+ }
194
+ !vmc->no_ns_el2_virt_timer_irq;
77
+
195
+
78
if (vmc->no_pmu && object_property_find(cpuobj, "pmu", NULL)) {
196
fdt_add_timer_nodes(vms);
79
object_property_set_bool(cpuobj, false, "pmu", NULL);
197
fdt_add_cpu_nodes(vms);
80
}
198
81
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 0)
199
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(9, 0)
82
200
83
static void virt_machine_4_2_options(MachineClass *mc)
201
static void virt_machine_8_2_options(MachineClass *mc)
84
{
202
{
85
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
203
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
86
+
204
+
87
virt_machine_5_0_options(mc);
205
virt_machine_9_0_options(mc);
88
compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
206
compat_props_add(mc->compat_props, hw_compat_8_2, hw_compat_8_2_len);
89
+ vmc->kvm_no_adjvtime = true;
207
+ /*
90
}
208
+ * Don't expose NS_EL2_VIRT timer IRQ in DTB on ACPI on 8.2 and
91
DEFINE_VIRT_MACHINE(4, 2)
209
+ * earlier machines. (Exposing it tickles a bug in older EDK2
92
210
+ * guest BIOS binaries.)
93
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
211
+ */
94
index XXXXXXX..XXXXXXX 100644
212
+ vmc->no_ns_el2_virt_timer_irq = true;
95
--- a/target/arm/cpu.c
213
}
96
+++ b/target/arm/cpu.c
214
DEFINE_VIRT_MACHINE(8, 2)
97
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
98
99
if (kvm_enabled()) {
100
kvm_arm_set_cpu_features_from_host(cpu);
101
+ kvm_arm_add_vcpu_properties(obj);
102
} else {
103
cortex_a15_initfn(obj);
104
105
@@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj)
106
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
107
aarch64_add_sve_properties(obj);
108
}
109
+ kvm_arm_add_vcpu_properties(obj);
110
arm_cpu_post_init(obj);
111
}
112
113
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
114
index XXXXXXX..XXXXXXX 100644
115
--- a/target/arm/cpu64.c
116
+++ b/target/arm/cpu64.c
117
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
118
119
if (kvm_enabled()) {
120
kvm_arm_set_cpu_features_from_host(cpu);
121
+ kvm_arm_add_vcpu_properties(obj);
122
} else {
123
uint64_t t;
124
uint32_t u;
125
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
126
index XXXXXXX..XXXXXXX 100644
127
--- a/target/arm/kvm.c
128
+++ b/target/arm/kvm.c
129
@@ -XXX,XX +XXX,XX @@
130
#include "qemu/timer.h"
131
#include "qemu/error-report.h"
132
#include "qemu/main-loop.h"
133
+#include "qom/object.h"
134
+#include "qapi/error.h"
135
#include "sysemu/sysemu.h"
136
#include "sysemu/kvm.h"
137
#include "sysemu/kvm_int.h"
138
@@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
139
env->features = arm_host_cpu_features.features;
140
}
141
142
+static bool kvm_no_adjvtime_get(Object *obj, Error **errp)
143
+{
144
+ return !ARM_CPU(obj)->kvm_adjvtime;
145
+}
146
+
147
+static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp)
148
+{
149
+ ARM_CPU(obj)->kvm_adjvtime = !value;
150
+}
151
+
152
+/* KVM VCPU properties should be prefixed with "kvm-". */
153
+void kvm_arm_add_vcpu_properties(Object *obj)
154
+{
155
+ if (!kvm_enabled()) {
156
+ return;
157
+ }
158
+
159
+ ARM_CPU(obj)->kvm_adjvtime = true;
160
+ object_property_add_bool(obj, "kvm-no-adjvtime", kvm_no_adjvtime_get,
161
+ kvm_no_adjvtime_set, &error_abort);
162
+ object_property_set_description(obj, "kvm-no-adjvtime",
163
+ "Set on to disable the adjustment of "
164
+ "the virtual counter. VM stopped time "
165
+ "will be counted.", &error_abort);
166
+}
167
+
168
bool kvm_arm_pmu_supported(CPUState *cpu)
169
{
170
return kvm_check_extension(cpu->kvm_state, KVM_CAP_ARM_PMU_V3);
171
diff --git a/target/arm/monitor.c b/target/arm/monitor.c
172
index XXXXXXX..XXXXXXX 100644
173
--- a/target/arm/monitor.c
174
+++ b/target/arm/monitor.c
175
@@ -XXX,XX +XXX,XX @@ static const char *cpu_model_advertised_features[] = {
176
"sve128", "sve256", "sve384", "sve512",
177
"sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280",
178
"sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048",
179
+ "kvm-no-adjvtime",
180
NULL
181
};
182
183
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
184
index XXXXXXX..XXXXXXX 100644
185
--- a/tests/qtest/arm-cpu-features.c
186
+++ b/tests/qtest/arm-cpu-features.c
187
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data)
188
assert_has_feature_enabled(qts, "cortex-a15", "pmu");
189
assert_has_not_feature(qts, "cortex-a15", "aarch64");
190
191
+ assert_has_not_feature(qts, "max", "kvm-no-adjvtime");
192
+
193
if (g_str_equal(qtest_get_arch(), "aarch64")) {
194
assert_has_feature_enabled(qts, "max", "aarch64");
195
assert_has_feature_enabled(qts, "max", "sve");
196
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
197
return;
198
}
199
200
+ assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");
201
+
202
if (g_str_equal(qtest_get_arch(), "aarch64")) {
203
bool kvm_supports_sve;
204
char max_name[8], name[8];
205
diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst
206
index XXXXXXX..XXXXXXX 100644
207
--- a/docs/arm-cpu-features.rst
208
+++ b/docs/arm-cpu-features.rst
209
@@ -XXX,XX +XXX,XX @@ supporting the feature or only supporting the feature under certain
210
configurations. For example, the `aarch64` CPU feature, which, when
211
disabled, enables the optional AArch32 CPU feature, is only supported
212
when using the KVM accelerator and when running on a host CPU type that
213
-supports the feature.
214
+supports the feature. While `aarch64` currently only works with KVM,
215
+it could work with TCG. CPU features that are specific to KVM are
216
+prefixed with "kvm-" and are described in "KVM VCPU Features".
217
218
CPU Feature Probing
219
===================
220
@@ -XXX,XX +XXX,XX @@ disabling many SVE vector lengths would be quite verbose, the `sve<N>` CPU
221
properties have special semantics (see "SVE CPU Property Parsing
222
Semantics").
223
224
+KVM VCPU Features
225
+=================
226
+
227
+KVM VCPU features are CPU features that are specific to KVM, such as
228
+paravirt features or features that enable CPU virtualization extensions.
229
+The features' CPU properties are only available when KVM is enabled and
230
+are named with the prefix "kvm-". KVM VCPU features may be probed,
231
+enabled, and disabled in the same way as other CPU features. Below is
232
+the list of KVM VCPU features and their descriptions.
233
+
234
+ kvm-no-adjvtime By default kvm-no-adjvtime is disabled. This
235
+ means that by default the virtual time
236
+ adjustment is enabled (vtime is *not not*
237
+ adjusted).
238
+
239
+ When virtual time adjustment is enabled each
240
+ time the VM transitions back to running state
241
+ the VCPU's virtual counter is updated to ensure
242
+ stopped time is not counted. This avoids time
243
+ jumps surprising guest OSes and applications,
244
+ as long as they use the virtual counter for
245
+ timekeeping. However it has the side effect of
246
+ the virtual and physical counters diverging.
247
+ All timekeeping based on the virtual counter
248
+ will appear to lag behind any timekeeping that
249
+ does not subtract VM stopped time. The guest
250
+ may resynchronize its virtual counter with
251
+ other time sources as needed.
252
+
253
+ Enable kvm-no-adjvtime to disable virtual time
254
+ adjustment, also restoring the legacy (pre-5.0)
255
+ behavior.
256
+
257
SVE CPU Properties
258
==================
259
215
260
--
216
--
261
2.20.1
217
2.34.1
262
263
diff view generated by jsdifflib
New patch
1
1
Update the virt golden reference files to say that the FACP is ACPI
2
v6.3, and the GTDT table is a revision 3 table with space for the
3
virtual EL2 timer.
4
5
Diffs from iasl:
6
7
@@ -XXX,XX +XXX,XX @@
8
/*
9
* Intel ACPI Component Architecture
10
* AML/ASL+ Disassembler version 20200925 (64-bit version)
11
* Copyright (c) 2000 - 2020 Intel Corporation
12
*
13
- * Disassembly of tests/data/acpi/virt/FACP, Mon Jan 22 13:48:40 2024
14
+ * Disassembly of /tmp/aml-W8RZH2, Mon Jan 22 13:48:40 2024
15
*
16
* ACPI Data Table [FACP]
17
*
18
* Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue
19
*/
20
21
[000h 0000 4] Signature : "FACP" [Fixed ACPI Description Table (FADT)]
22
[004h 0004 4] Table Length : 00000114
23
[008h 0008 1] Revision : 06
24
-[009h 0009 1] Checksum : 15
25
+[009h 0009 1] Checksum : 12
26
[00Ah 0010 6] Oem ID : "BOCHS "
27
[010h 0016 8] Oem Table ID : "BXPC "
28
[018h 0024 4] Oem Revision : 00000001
29
[01Ch 0028 4] Asl Compiler ID : "BXPC"
30
[020h 0032 4] Asl Compiler Revision : 00000001
31
32
[024h 0036 4] FACS Address : 00000000
33
[028h 0040 4] DSDT Address : 00000000
34
[02Ch 0044 1] Model : 00
35
[02Dh 0045 1] PM Profile : 00 [Unspecified]
36
[02Eh 0046 2] SCI Interrupt : 0000
37
[030h 0048 4] SMI Command Port : 00000000
38
[034h 0052 1] ACPI Enable Value : 00
39
[035h 0053 1] ACPI Disable Value : 00
40
[036h 0054 1] S4BIOS Command : 00
41
[037h 0055 1] P-State Control : 00
42
@@ -XXX,XX +XXX,XX @@
43
Use APIC Physical Destination Mode (V4) : 0
44
Hardware Reduced (V5) : 1
45
Low Power S0 Idle (V5) : 0
46
47
[074h 0116 12] Reset Register : [Generic Address Structure]
48
[074h 0116 1] Space ID : 00 [SystemMemory]
49
[075h 0117 1] Bit Width : 00
50
[076h 0118 1] Bit Offset : 00
51
[077h 0119 1] Encoded Access Width : 00 [Undefined/Legacy]
52
[078h 0120 8] Address : 0000000000000000
53
54
[080h 0128 1] Value to cause reset : 00
55
[081h 0129 2] ARM Flags (decoded below) : 0003
56
PSCI Compliant : 1
57
Must use HVC for PSCI : 1
58
59
-[083h 0131 1] FADT Minor Revision : 00
60
+[083h 0131 1] FADT Minor Revision : 03
61
[084h 0132 8] FACS Address : 0000000000000000
62
[08Ch 0140 8] DSDT Address : 0000000000000000
63
[094h 0148 12] PM1A Event Block : [Generic Address Structure]
64
[094h 0148 1] Space ID : 00 [SystemMemory]
65
[095h 0149 1] Bit Width : 00
66
[096h 0150 1] Bit Offset : 00
67
[097h 0151 1] Encoded Access Width : 00 [Undefined/Legacy]
68
[098h 0152 8] Address : 0000000000000000
69
70
[0A0h 0160 12] PM1B Event Block : [Generic Address Structure]
71
[0A0h 0160 1] Space ID : 00 [SystemMemory]
72
[0A1h 0161 1] Bit Width : 00
73
[0A2h 0162 1] Bit Offset : 00
74
[0A3h 0163 1] Encoded Access Width : 00 [Undefined/Legacy]
75
[0A4h 0164 8] Address : 0000000000000000
76
77
@@ -XXX,XX +XXX,XX @@
78
[0F5h 0245 1] Bit Width : 00
79
[0F6h 0246 1] Bit Offset : 00
80
[0F7h 0247 1] Encoded Access Width : 00 [Undefined/Legacy]
81
[0F8h 0248 8] Address : 0000000000000000
82
83
[100h 0256 12] Sleep Status Register : [Generic Address Structure]
84
[100h 0256 1] Space ID : 00 [SystemMemory]
85
[101h 0257 1] Bit Width : 00
86
[102h 0258 1] Bit Offset : 00
87
[103h 0259 1] Encoded Access Width : 00 [Undefined/Legacy]
88
[104h 0260 8] Address : 0000000000000000
89
90
[10Ch 0268 8] Hypervisor ID : 00000000554D4551
91
92
Raw Table Data: Length 276 (0x114)
93
94
- 0000: 46 41 43 50 14 01 00 00 06 15 42 4F 43 48 53 20 // FACP......BOCHS
95
+ 0000: 46 41 43 50 14 01 00 00 06 12 42 4F 43 48 53 20 // FACP......BOCHS
96
0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC
97
0020: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
98
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
99
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
100
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
101
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
102
0070: 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
103
- 0080: 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
104
+ 0080: 00 03 00 03 00 00 00 00 00 00 00 00 00 00 00 00 // ................
105
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
106
00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
107
00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
108
00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
109
00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
110
00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
111
00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
112
0100: 00 00 00 00 00 00 00 00 00 00 00 00 51 45 4D 55 // ............QEMU
113
0110: 00 00 00 00 // ....
114
115
@@ -XXX,XX +XXX,XX @@
116
/*
117
* Intel ACPI Component Architecture
118
* AML/ASL+ Disassembler version 20200925 (64-bit version)
119
* Copyright (c) 2000 - 2020 Intel Corporation
120
*
121
- * Disassembly of tests/data/acpi/virt/GTDT, Mon Jan 22 13:48:40 2024
122
+ * Disassembly of /tmp/aml-XDSZH2, Mon Jan 22 13:48:40 2024
123
*
124
* ACPI Data Table [GTDT]
125
*
126
* Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue
127
*/
128
129
[000h 0000 4] Signature : "GTDT" [Generic Timer Description Table]
130
-[004h 0004 4] Table Length : 00000060
131
-[008h 0008 1] Revision : 02
132
-[009h 0009 1] Checksum : 9C
133
+[004h 0004 4] Table Length : 00000068
134
+[008h 0008 1] Revision : 03
135
+[009h 0009 1] Checksum : 93
136
[00Ah 0010 6] Oem ID : "BOCHS "
137
[010h 0016 8] Oem Table ID : "BXPC "
138
[018h 0024 4] Oem Revision : 00000001
139
[01Ch 0028 4] Asl Compiler ID : "BXPC"
140
[020h 0032 4] Asl Compiler Revision : 00000001
141
142
[024h 0036 8] Counter Block Address : FFFFFFFFFFFFFFFF
143
[02Ch 0044 4] Reserved : 00000000
144
145
[030h 0048 4] Secure EL1 Interrupt : 0000001D
146
[034h 0052 4] EL1 Flags (decoded below) : 00000000
147
Trigger Mode : 0
148
Polarity : 0
149
Always On : 0
150
151
[038h 0056 4] Non-Secure EL1 Interrupt : 0000001E
152
@@ -XXX,XX +XXX,XX @@
153
154
[040h 0064 4] Virtual Timer Interrupt : 0000001B
155
[044h 0068 4] VT Flags (decoded below) : 00000000
156
Trigger Mode : 0
157
Polarity : 0
158
Always On : 0
159
160
[048h 0072 4] Non-Secure EL2 Interrupt : 0000001A
161
[04Ch 0076 4] NEL2 Flags (decoded below) : 00000000
162
Trigger Mode : 0
163
Polarity : 0
164
Always On : 0
165
[050h 0080 8] Counter Read Block Address : FFFFFFFFFFFFFFFF
166
167
[058h 0088 4] Platform Timer Count : 00000000
168
[05Ch 0092 4] Platform Timer Offset : 00000000
169
+[060h 0096 4] Virtual EL2 Timer GSIV : 00000000
170
+[064h 0100 4] Virtual EL2 Timer Flags : 00000000
171
172
-Raw Table Data: Length 96 (0x60)
173
+Raw Table Data: Length 104 (0x68)
174
175
- 0000: 47 54 44 54 60 00 00 00 02 9C 42 4F 43 48 53 20 // GTDT`.....BOCHS
176
+ 0000: 47 54 44 54 68 00 00 00 03 93 42 4F 43 48 53 20 // GTDTh.....BOCHS
177
0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC
178
0020: 01 00 00 00 FF FF FF FF FF FF FF FF 00 00 00 00 // ................
179
0030: 1D 00 00 00 00 00 00 00 1E 00 00 00 04 00 00 00 // ................
180
0040: 1B 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 // ................
181
0050: FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 // ................
182
+ 0060: 00 00 00 00 00 00 00 00 // ........
183
184
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
185
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
186
Message-id: 20240122143537.233498-4-peter.maydell@linaro.org
187
---
188
tests/qtest/bios-tables-test-allowed-diff.h | 2 --
189
tests/data/acpi/virt/FACP | Bin 276 -> 276 bytes
190
tests/data/acpi/virt/GTDT | Bin 96 -> 104 bytes
191
3 files changed, 2 deletions(-)
192
193
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
194
index XXXXXXX..XXXXXXX 100644
195
--- a/tests/qtest/bios-tables-test-allowed-diff.h
196
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
197
@@ -1,3 +1 @@
198
/* List of comma-separated changed AML files to ignore */
199
-"tests/data/acpi/virt/FACP",
200
-"tests/data/acpi/virt/GTDT",
201
diff --git a/tests/data/acpi/virt/FACP b/tests/data/acpi/virt/FACP
202
index XXXXXXX..XXXXXXX 100644
203
GIT binary patch
204
delta 25
205
gcmbQjG=+)F&CxkPgpq-PO=u!l<;2F$$vli407<0<)c^nh
206
207
delta 28
208
kcmbQjG=+)F&CxkPgpq-PO>`nx<-|!<6Akz$^DuG%0AAS!ssI20
209
210
diff --git a/tests/data/acpi/virt/GTDT b/tests/data/acpi/virt/GTDT
211
index XXXXXXX..XXXXXXX 100644
212
GIT binary patch
213
delta 25
214
bcmYeu;BpUf3CUn!U|^m+kt>V?$N&QXMtB4L
215
216
delta 16
217
Xcmc~u;BpUf2}xjJU|^avkt+-UB60)u
218
219
--
220
2.34.1
diff view generated by jsdifflib
New patch
1
The patchset adding the GMAC ethernet to this SoC crossed in the
2
mail with the patchset cleaning up the NIC handling. When we
3
create the GMAC modules we must call qemu_configure_nic_device()
4
so that the user has the opportunity to use the -nic commandline
5
option to create a network backend and connect it to the GMACs.
1
6
7
Add the missing call.
8
9
Fixes: 21e5326a7c ("hw/arm: Add GMAC devices to NPCM7XX SoC")
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
12
Message-id: 20240206171231.396392-2-peter.maydell@linaro.org
13
---
14
hw/arm/npcm7xx.c | 1 +
15
1 file changed, 1 insertion(+)
16
17
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/npcm7xx.c
20
+++ b/hw/arm/npcm7xx.c
21
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
22
for (i = 0; i < ARRAY_SIZE(s->gmac); i++) {
23
SysBusDevice *sbd = SYS_BUS_DEVICE(&s->gmac[i]);
24
25
+ qemu_configure_nic_device(DEVICE(sbd), false, NULL);
26
/*
27
* The device exists regardless of whether it's connected to a QEMU
28
* netdev backend. So always instantiate it even if there is no
29
--
30
2.34.1
diff view generated by jsdifflib
New patch
1
Currently QEMU will warn if there is a NIC on the board that
2
is not connected to a backend. By default the '-nic user' will
3
get used for all NICs, but if you manually connect a specific
4
NIC to a specific backend, then the other NICs on the board
5
have no backend and will be warned about:
1
6
7
qemu-system-arm: warning: nic npcm7xx-emc.1 has no peer
8
qemu-system-arm: warning: nic npcm-gmac.0 has no peer
9
qemu-system-arm: warning: nic npcm-gmac.1 has no peer
10
11
So suppress those warnings by manually connecting every NIC
12
on the board to some backend.
13
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
16
Reviewed-by: Thomas Huth <thuth@redhat.com>
17
Message-id: 20240206171231.396392-3-peter.maydell@linaro.org
18
---
19
tests/qtest/npcm7xx_emc-test.c | 5 ++++-
20
1 file changed, 4 insertions(+), 1 deletion(-)
21
22
diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
23
index XXXXXXX..XXXXXXX 100644
24
--- a/tests/qtest/npcm7xx_emc-test.c
25
+++ b/tests/qtest/npcm7xx_emc-test.c
26
@@ -XXX,XX +XXX,XX @@ static int *packet_test_init(int module_num, GString *cmd_line)
27
* KISS and use -nic. The driver accepts 'emc0' and 'emc1' as aliases
28
* in the 'model' field to specify the device to match.
29
*/
30
- g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d ",
31
+ g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d "
32
+ "-nic user,model=npcm7xx-emc "
33
+ "-nic user,model=npcm-gmac "
34
+ "-nic user,model=npcm-gmac",
35
test_sockets[1], module_num);
36
37
g_test_queue_destroy(packet_test_clear, test_sockets);
38
--
39
2.34.1
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
It doesn't make sense to read the value of MDCR_EL2 on a non-A-profile
2
CPU, and in fact if you try to do it we will assert:
2
3
3
Replace deprecated qdev_reset_all by resettable_cold_reset_fn for
4
#6 0x00007ffff4b95e96 in __GI___assert_fail
4
the ipl registration in the main reset handlers.
5
(assertion=0x5555565a8c70 "!arm_feature(env, ARM_FEATURE_M)", file=0x5555565a6e5c "../../target/arm/helper.c", line=12600, function=0x5555565a9560 <__PRETTY_FUNCTION__.0> "arm_security_space_below_el3") at ./assert/assert.c:101
6
#7 0x0000555555ebf412 in arm_security_space_below_el3 (env=0x555557bc8190) at ../../target/arm/helper.c:12600
7
#8 0x0000555555ea6f89 in arm_is_el2_enabled (env=0x555557bc8190) at ../../target/arm/cpu.h:2595
8
#9 0x0000555555ea942f in arm_mdcr_el2_eff (env=0x555557bc8190) at ../../target/arm/internals.h:1512
5
9
6
This does not impact the behavior for the following reasons:
10
We might call pmu_counter_enabled() on an M-profile CPU (for example
7
+ at this point resettable just call the old reset methods of devices
11
from the migration pre/post hooks in machine.c); this should always
8
and buses in the same order than qdev/qbus.
12
return false because these CPUs don't set ARM_FEATURE_PMU.
9
+ resettable handlers registered with qemu_register_reset are
10
serialized; there is no interleaving.
11
+ eventual explicit calls to legacy reset API (device_reset or
12
qdev/qbus_reset) inside this reset handler will not be masked out
13
by resettable mechanism; they do not go through resettable api.
14
13
15
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
14
Avoid the assertion by not calling arm_mdcr_el2_eff() before we
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
15
have done the early return for "PMU not present".
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
18
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
17
This fixes an assertion failure if you try to do a loadvm or
18
savevm for an M-profile board.
19
20
Cc: qemu-stable@nongnu.org
21
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2155
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
24
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20200123132823.1117486-12-damien.hedde@greensocs.com
25
Message-id: 20240208153346.970021-1-peter.maydell@linaro.org
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
26
---
23
hw/s390x/ipl.c | 10 +++++++++-
27
target/arm/helper.c | 12 ++++++++++--
24
1 file changed, 9 insertions(+), 1 deletion(-)
28
1 file changed, 10 insertions(+), 2 deletions(-)
25
29
26
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
27
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/s390x/ipl.c
32
--- a/target/arm/helper.c
29
+++ b/hw/s390x/ipl.c
33
+++ b/target/arm/helper.c
30
@@ -XXX,XX +XXX,XX @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
34
@@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)
31
*/
35
bool enabled, prohibited = false, filtered;
32
ipl->compat_start_addr = ipl->start_addr;
36
bool secure = arm_is_secure(env);
33
ipl->compat_bios_start_addr = ipl->bios_start_addr;
37
int el = arm_current_el(env);
34
- qemu_register_reset(qdev_reset_all_fn, dev);
38
- uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
39
- uint8_t hpmn = mdcr_el2 & MDCR_HPMN;
40
+ uint64_t mdcr_el2;
41
+ uint8_t hpmn;
42
35
+ /*
43
+ /*
36
+ * Because this Device is not on any bus in the qbus tree (it is
44
+ * We might be called for M-profile cores where MDCR_EL2 doesn't
37
+ * not a sysbus device and it's not on some other bus like a PCI
45
+ * exist and arm_mdcr_el2_eff() will assert, so this early-exit check
38
+ * bus) it will not be automatically reset by the 'reset the
46
+ * must be before we read that value.
39
+ * sysbus' hook registered by vl.c like most devices. So we must
40
+ * manually register a reset hook for it.
41
+ * TODO: there should be a better way to do this.
42
+ */
47
+ */
43
+ qemu_register_reset(resettable_cold_reset_fn, dev);
48
if (!arm_feature(env, ARM_FEATURE_PMU)) {
44
error:
49
return false;
45
error_propagate(errp, err);
50
}
46
}
51
52
+ mdcr_el2 = arm_mdcr_el2_eff(env);
53
+ hpmn = mdcr_el2 & MDCR_HPMN;
54
+
55
if (!arm_feature(env, ARM_FEATURE_EL2) ||
56
(counter < hpmn || counter == 31)) {
57
e = env->cp15.c9_pmcr & PMCRE;
47
--
58
--
48
2.20.1
59
2.34.1
49
60
50
61
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
From: Nabih Estefan <nabihestefan@google.com>
2
2
3
Adds trace events to reset procedure and when updating the parent
3
Fix the nocm_gmac-test.c file to run on a nuvoton 7xx machine instead
4
bus of a device.
4
of 8xx. Also fix comments referencing this and values expecting 8xx.
5
5
6
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
6
Change-Id: Iabd0fba14910c3f1e883c4a9521350f3db9ffab8
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-Off-By: Nabih Estefan <nabihestefan@google.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
9
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
9
Message-id: 20240208194759.2858582-2-nabihestefan@google.com
10
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20200123132823.1117486-3-damien.hedde@greensocs.com
11
[PMM: commit message tweaks]
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
13
---
14
hw/core/qdev.c | 29 ++++++++++++++++++++++++++---
14
tests/qtest/npcm_gmac-test.c | 84 +-----------------------------------
15
hw/core/trace-events | 9 +++++++++
15
tests/qtest/meson.build | 3 +-
16
2 files changed, 35 insertions(+), 3 deletions(-)
16
2 files changed, 4 insertions(+), 83 deletions(-)
17
17
18
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
18
diff --git a/tests/qtest/npcm_gmac-test.c b/tests/qtest/npcm_gmac-test.c
19
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/core/qdev.c
20
--- a/tests/qtest/npcm_gmac-test.c
21
+++ b/hw/core/qdev.c
21
+++ b/tests/qtest/npcm_gmac-test.c
22
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ typedef struct TestData {
23
#include "hw/boards.h"
23
const GMACModule *module;
24
#include "hw/sysbus.h"
24
} TestData;
25
#include "migration/vmstate.h"
25
26
+#include "trace.h"
26
-/* Values extracted from hw/arm/npcm8xx.c */
27
27
+/* Values extracted from hw/arm/npcm7xx.c */
28
bool qdev_hotplug = false;
28
static const GMACModule gmac_module_list[] = {
29
static bool qdev_hot_added = false;
29
{
30
@@ -XXX,XX +XXX,XX @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
30
.irq = 14,
31
bool replugging = dev->parent_bus != NULL;
31
@@ -XXX,XX +XXX,XX @@ static const GMACModule gmac_module_list[] = {
32
32
.irq = 15,
33
if (replugging) {
33
.base_addr = 0xf0804000
34
- /* Keep a reference to the device while it's not plugged into
34
},
35
+ trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)),
35
- {
36
+ dev->parent_bus, object_get_typename(OBJECT(dev->parent_bus)),
36
- .irq = 16,
37
+ OBJECT(bus), object_get_typename(OBJECT(bus)));
37
- .base_addr = 0xf0806000
38
+ /*
38
- },
39
+ * Keep a reference to the device while it's not plugged into
39
- {
40
* any bus, to avoid it potentially evaporating when it is
40
- .irq = 17,
41
* dereffed in bus_remove_child().
41
- .base_addr = 0xf0808000
42
*/
42
- }
43
@@ -XXX,XX +XXX,XX @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
43
};
44
return hotplug_ctrl;
44
45
/* Returns the index of the GMAC module. */
46
@@ -XXX,XX +XXX,XX @@ static uint32_t gmac_read(QTestState *qts, const GMACModule *mod,
47
return qtest_readl(qts, mod->base_addr + regno);
45
}
48
}
46
49
47
+static int qdev_prereset(DeviceState *dev, void *opaque)
50
-static uint16_t pcs_read(QTestState *qts, const GMACModule *mod,
48
+{
51
- NPCMRegister regno)
49
+ trace_qdev_reset_tree(dev, object_get_typename(OBJECT(dev)));
52
-{
50
+ return 0;
53
- uint32_t write_value = (regno & 0x3ffe00) >> 9;
51
+}
54
- qtest_writel(qts, PCS_BASE_ADDRESS + NPCM_PCS_IND_AC_BA, write_value);
52
+
55
- uint32_t read_offset = regno & 0x1ff;
53
+static int qbus_prereset(BusState *bus, void *opaque)
56
- return qtest_readl(qts, PCS_BASE_ADDRESS + read_offset);
54
+{
57
-}
55
+ trace_qbus_reset_tree(bus, object_get_typename(OBJECT(bus)));
58
-
56
+ return 0;
59
/* Check that GMAC registers are reset to default value */
57
+}
60
static void test_init(gconstpointer test_data)
58
+
59
static int qdev_reset_one(DeviceState *dev, void *opaque)
60
{
61
{
61
device_legacy_reset(dev);
62
const TestData *td = test_data;
62
@@ -XXX,XX +XXX,XX @@ static int qdev_reset_one(DeviceState *dev, void *opaque)
63
const GMACModule *mod = td->module;
63
static int qbus_reset_one(BusState *bus, void *opaque)
64
- QTestState *qts = qtest_init("-machine npcm845-evb");
64
{
65
+ QTestState *qts = qtest_init("-machine npcm750-evb");
65
BusClass *bc = BUS_GET_CLASS(bus);
66
66
+ trace_qbus_reset(bus, object_get_typename(OBJECT(bus)));
67
#define CHECK_REG32(regno, value) \
67
if (bc->reset) {
68
do { \
68
bc->reset(bus);
69
g_assert_cmphex(gmac_read(qts, mod, (regno)), ==, (value)); \
69
}
70
} while (0)
70
@@ -XXX,XX +XXX,XX @@ static int qbus_reset_one(BusState *bus, void *opaque)
71
71
72
-#define CHECK_REG_PCS(regno, value) \
72
void qdev_reset_all(DeviceState *dev)
73
- do { \
73
{
74
- g_assert_cmphex(pcs_read(qts, mod, (regno)), ==, (value)); \
74
- qdev_walk_children(dev, NULL, NULL, qdev_reset_one, qbus_reset_one, NULL);
75
- } while (0)
75
+ trace_qdev_reset_all(dev, object_get_typename(OBJECT(dev)));
76
-
76
+ qdev_walk_children(dev, qdev_prereset, qbus_prereset,
77
CHECK_REG32(NPCM_DMA_BUS_MODE, 0x00020100);
77
+ qdev_reset_one, qbus_reset_one, NULL);
78
CHECK_REG32(NPCM_DMA_XMT_POLL_DEMAND, 0);
79
CHECK_REG32(NPCM_DMA_RCV_POLL_DEMAND, 0);
80
@@ -XXX,XX +XXX,XX @@ static void test_init(gconstpointer test_data)
81
CHECK_REG32(NPCM_GMAC_PTP_TAR, 0);
82
CHECK_REG32(NPCM_GMAC_PTP_TTSR, 0);
83
84
- /* TODO Add registers PCS */
85
- if (mod->base_addr == 0xf0802000) {
86
- CHECK_REG_PCS(NPCM_PCS_SR_CTL_ID1, 0x699e);
87
- CHECK_REG_PCS(NPCM_PCS_SR_CTL_ID2, 0);
88
- CHECK_REG_PCS(NPCM_PCS_SR_CTL_STS, 0x8000);
89
-
90
- CHECK_REG_PCS(NPCM_PCS_SR_MII_CTRL, 0x1140);
91
- CHECK_REG_PCS(NPCM_PCS_SR_MII_STS, 0x0109);
92
- CHECK_REG_PCS(NPCM_PCS_SR_MII_DEV_ID1, 0x699e);
93
- CHECK_REG_PCS(NPCM_PCS_SR_MII_DEV_ID2, 0x0ced0);
94
- CHECK_REG_PCS(NPCM_PCS_SR_MII_AN_ADV, 0x0020);
95
- CHECK_REG_PCS(NPCM_PCS_SR_MII_LP_BABL, 0);
96
- CHECK_REG_PCS(NPCM_PCS_SR_MII_AN_EXPN, 0);
97
- CHECK_REG_PCS(NPCM_PCS_SR_MII_EXT_STS, 0xc000);
98
-
99
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_ABL, 0x0003);
100
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_TX_MAX_DLY_LWR, 0x0038);
101
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_TX_MAX_DLY_UPR, 0);
102
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_TX_MIN_DLY_LWR, 0x0038);
103
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_TX_MIN_DLY_UPR, 0);
104
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_RX_MAX_DLY_LWR, 0x0058);
105
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_RX_MAX_DLY_UPR, 0);
106
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_RX_MIN_DLY_LWR, 0x0048);
107
- CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_RX_MIN_DLY_UPR, 0);
108
-
109
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MMD_DIG_CTRL1, 0x2400);
110
- CHECK_REG_PCS(NPCM_PCS_VR_MII_AN_CTRL, 0);
111
- CHECK_REG_PCS(NPCM_PCS_VR_MII_AN_INTR_STS, 0x000a);
112
- CHECK_REG_PCS(NPCM_PCS_VR_MII_TC, 0);
113
- CHECK_REG_PCS(NPCM_PCS_VR_MII_DBG_CTRL, 0);
114
- CHECK_REG_PCS(NPCM_PCS_VR_MII_EEE_MCTRL0, 0x899c);
115
- CHECK_REG_PCS(NPCM_PCS_VR_MII_EEE_TXTIMER, 0);
116
- CHECK_REG_PCS(NPCM_PCS_VR_MII_EEE_RXTIMER, 0);
117
- CHECK_REG_PCS(NPCM_PCS_VR_MII_LINK_TIMER_CTRL, 0);
118
- CHECK_REG_PCS(NPCM_PCS_VR_MII_EEE_MCTRL1, 0);
119
- CHECK_REG_PCS(NPCM_PCS_VR_MII_DIG_STS, 0x0010);
120
- CHECK_REG_PCS(NPCM_PCS_VR_MII_ICG_ERRCNT1, 0);
121
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MISC_STS, 0);
122
- CHECK_REG_PCS(NPCM_PCS_VR_MII_RX_LSTS, 0);
123
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_BSTCTRL0, 0x00a);
124
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_LVLCTRL0, 0x007f);
125
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_GENCTRL0, 0x0001);
126
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_GENCTRL1, 0);
127
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_STS, 0);
128
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_RX_GENCTRL0, 0x0100);
129
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_RX_GENCTRL1, 0x1100);
130
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_RX_LOS_CTRL0, 0x000e);
131
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MPLL_CTRL0, 0x0100);
132
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MPLL_CTRL1, 0x0032);
133
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MPLL_STS, 0x0001);
134
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MISC_CTRL2, 0);
135
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_LVL_CTRL, 0x0019);
136
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MISC_CTRL0, 0);
137
- CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MISC_CTRL1, 0);
138
- CHECK_REG_PCS(NPCM_PCS_VR_MII_DIG_CTRL2, 0);
139
- CHECK_REG_PCS(NPCM_PCS_VR_MII_DIG_ERRCNT_SEL, 0);
140
- }
141
-
142
qtest_quit(qts);
78
}
143
}
79
144
80
void qdev_reset_all_fn(void *opaque)
145
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
81
@@ -XXX,XX +XXX,XX @@ void qdev_reset_all_fn(void *opaque)
82
83
void qbus_reset_all(BusState *bus)
84
{
85
- qbus_walk_children(bus, NULL, NULL, qdev_reset_one, qbus_reset_one, NULL);
86
+ trace_qbus_reset_all(bus, object_get_typename(OBJECT(bus)));
87
+ qbus_walk_children(bus, qdev_prereset, qbus_prereset,
88
+ qdev_reset_one, qbus_reset_one, NULL);
89
}
90
91
void qbus_reset_all_fn(void *opaque)
92
@@ -XXX,XX +XXX,XX @@ void device_legacy_reset(DeviceState *dev)
93
{
94
DeviceClass *klass = DEVICE_GET_CLASS(dev);
95
96
+ trace_qdev_reset(dev, object_get_typename(OBJECT(dev)));
97
if (klass->reset) {
98
klass->reset(dev);
99
}
100
diff --git a/hw/core/trace-events b/hw/core/trace-events
101
index XXXXXXX..XXXXXXX 100644
146
index XXXXXXX..XXXXXXX 100644
102
--- a/hw/core/trace-events
147
--- a/tests/qtest/meson.build
103
+++ b/hw/core/trace-events
148
+++ b/tests/qtest/meson.build
104
@@ -XXX,XX +XXX,XX @@
149
@@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \
105
# loader.c
150
'npcm7xx_sdhci-test',
106
loader_write_rom(const char *name, uint64_t gpa, uint64_t size, bool isrom) "%s: @0x%"PRIx64" size=0x%"PRIx64" ROM=%d"
151
'npcm7xx_smbus-test',
107
+
152
'npcm7xx_timer-test',
108
+# qdev.c
153
- 'npcm7xx_watchdog_timer-test'] + \
109
+qdev_reset(void *obj, const char *objtype) "obj=%p(%s)"
154
+ 'npcm7xx_watchdog_timer-test',
110
+qdev_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
155
+ 'npcm_gmac-test'] + \
111
+qdev_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
156
(slirp.found() ? ['npcm7xx_emc-test'] : [])
112
+qbus_reset(void *obj, const char *objtype) "obj=%p(%s)"
157
qtests_aspeed = \
113
+qbus_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
158
['aspeed_hace-test',
114
+qbus_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
115
+qdev_update_parent_bus(void *obj, const char *objtype, void *oldp, const char *oldptype, void *newp, const char *newptype) "obj=%p(%s) old_parent=%p(%s) new_parent=%p(%s)"
116
--
159
--
117
2.20.1
160
2.34.1
118
119
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Luc Michel <luc.michel@amd.com>
2
2
3
These buffers should be aligned on 16 bytes.
3
An access fault is raised when the Access Flag is not set in the
4
looked-up PTE and the AFFD field is not set in the corresponding context
5
descriptor. This was already implemented for stage 2. Implement it for
6
stage 1 as well.
4
7
5
Ignore invalid RX and TX buffer addresses and log an error. All
8
Signed-off-by: Luc Michel <luc.michel@amd.com>
6
incoming and outgoing traffic will be dropped because no valid RX or
9
Reviewed-by: Mostafa Saleh <smostafa@google.com>
7
TX descriptors will be available.
10
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
11
Tested-by: Mostafa Saleh <smostafa@google.com>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
Message-id: 20240213082211.3330400-1-luc.michel@amd.com
10
Message-id: 20200114103433.30534-4-clg@kaod.org
13
[PMM: tweaked comment text]
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
15
---
14
hw/net/ftgmac100.c | 13 +++++++++++++
16
hw/arm/smmuv3-internal.h | 1 +
15
1 file changed, 13 insertions(+)
17
include/hw/arm/smmu-common.h | 1 +
18
hw/arm/smmu-common.c | 11 +++++++++++
19
hw/arm/smmuv3.c | 1 +
20
4 files changed, 14 insertions(+)
16
21
17
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
22
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
18
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/net/ftgmac100.c
24
--- a/hw/arm/smmuv3-internal.h
20
+++ b/hw/net/ftgmac100.c
25
+++ b/hw/arm/smmuv3-internal.h
21
@@ -XXX,XX +XXX,XX @@ typedef struct {
26
@@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste)
22
uint32_t des3;
27
#define CD_EPD(x, sel) extract32((x)->word[0], (16 * (sel)) + 14, 1)
23
} FTGMAC100Desc;
28
#define CD_ENDI(x) extract32((x)->word[0], 15, 1)
24
29
#define CD_IPS(x) extract32((x)->word[1], 0 , 3)
25
+#define FTGMAC100_DESC_ALIGNMENT 16
30
+#define CD_AFFD(x) extract32((x)->word[1], 3 , 1)
31
#define CD_TBI(x) extract32((x)->word[1], 6 , 2)
32
#define CD_HD(x) extract32((x)->word[1], 10 , 1)
33
#define CD_HA(x) extract32((x)->word[1], 11 , 1)
34
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/arm/smmu-common.h
37
+++ b/include/hw/arm/smmu-common.h
38
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUTransCfg {
39
bool disabled; /* smmu is disabled */
40
bool bypassed; /* translation is bypassed */
41
bool aborted; /* translation is aborted */
42
+ bool affd; /* AF fault disable */
43
uint32_t iotlb_hits; /* counts IOTLB hits */
44
uint32_t iotlb_misses; /* counts IOTLB misses*/
45
/* Used by stage-1 only. */
46
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/smmu-common.c
49
+++ b/hw/arm/smmu-common.c
50
@@ -XXX,XX +XXX,XX @@ static int smmu_ptw_64_s1(SMMUTransCfg *cfg,
51
pte_addr, pte, iova, gpa,
52
block_size >> 20);
53
}
26
+
54
+
27
/*
55
+ /*
28
* Specific RTL8211E MII Registers
56
+ * QEMU does not currently implement HTTU, so if AFFD and PTE.AF
29
*/
57
+ * are 0 we take an Access flag fault. (5.4. Context Descriptor)
30
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_write(void *opaque, hwaddr addr,
58
+ * An Access flag fault takes priority over a Permission fault.
31
s->itc = value;
59
+ */
32
break;
60
+ if (!PTE_AF(pte) && !cfg->affd) {
33
case FTGMAC100_RXR_BADR: /* Ring buffer address */
61
+ info->type = SMMU_PTW_ERR_ACCESS;
34
+ if (!QEMU_IS_ALIGNED(value, FTGMAC100_DESC_ALIGNMENT)) {
62
+ goto error;
35
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad RX buffer alignment 0x%"
36
+ HWADDR_PRIx "\n", __func__, value);
37
+ return;
38
+ }
63
+ }
39
+
64
+
40
s->rx_ring = value;
65
ap = PTE_AP(pte);
41
s->rx_descriptor = s->rx_ring;
66
if (is_permission_fault(ap, perm)) {
42
break;
67
info->type = SMMU_PTW_ERR_PERMISSION;
43
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_write(void *opaque, hwaddr addr,
68
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
44
break;
69
index XXXXXXX..XXXXXXX 100644
45
70
--- a/hw/arm/smmuv3.c
46
case FTGMAC100_NPTXR_BADR: /* Transmit buffer address */
71
+++ b/hw/arm/smmuv3.c
47
+ if (!QEMU_IS_ALIGNED(value, FTGMAC100_DESC_ALIGNMENT)) {
72
@@ -XXX,XX +XXX,XX @@ static int decode_cd(SMMUTransCfg *cfg, CD *cd, SMMUEventInfo *event)
48
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad TX buffer alignment 0x%"
73
cfg->oas = MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas);
49
+ HWADDR_PRIx "\n", __func__, value);
74
cfg->tbi = CD_TBI(cd);
50
+ return;
75
cfg->asid = CD_ASID(cd);
51
+ }
76
+ cfg->affd = CD_AFFD(cd);
52
s->tx_ring = value;
77
53
s->tx_descriptor = s->tx_ring;
78
trace_smmuv3_decode_cd(cfg->oas);
54
break;
79
55
--
80
--
56
2.20.1
81
2.34.1
57
58
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Initialise another SDHCI model instance for the AST2600's eMMC
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
controller and use the SDHCI's num_slots value introduced previously to
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
determine whether we should create an SD card instance for the new slot.
5
Message-id: 20240213155214.13619-2-philmd@linaro.org
6
7
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
Message-id: 20200114103433.30534-3-clg@kaod.org
12
[ clg : - removed ternary operator from sdhci_attach_drive()
13
- renamed SDHCI objects with a '-controller' prefix ]
14
Signed-off-by: Cédric Le Goater <clg@kaod.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
7
---
17
include/hw/arm/aspeed_soc.h | 2 ++
8
hw/arm/stellaris.c | 6 ++++--
18
hw/arm/aspeed.c | 26 +++++++++++++++++---------
9
1 file changed, 4 insertions(+), 2 deletions(-)
19
hw/arm/aspeed_ast2600.c | 29 ++++++++++++++++++++++++++---
20
3 files changed, 45 insertions(+), 12 deletions(-)
21
10
22
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
11
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
23
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
24
--- a/include/hw/arm/aspeed_soc.h
13
--- a/hw/arm/stellaris.c
25
+++ b/include/hw/arm/aspeed_soc.h
14
+++ b/hw/arm/stellaris.c
26
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
15
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level)
27
AspeedGPIOState gpio;
28
AspeedGPIOState gpio_1_8v;
29
AspeedSDHCIState sdhci;
30
+ AspeedSDHCIState emmc;
31
} AspeedSoCState;
32
33
#define TYPE_ASPEED_SOC "aspeed-soc"
34
@@ -XXX,XX +XXX,XX @@ enum {
35
ASPEED_MII4,
36
ASPEED_SDRAM,
37
ASPEED_XDMA,
38
+ ASPEED_EMMC,
39
};
40
41
#endif /* ASPEED_SOC_H */
42
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/arm/aspeed.c
45
+++ b/hw/arm/aspeed.c
46
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
47
}
16
}
48
}
17
}
49
18
50
+static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
19
-static void stellaris_adc_reset(StellarisADCState *s)
51
+{
20
+static void stellaris_adc_reset_hold(Object *obj)
52
+ DeviceState *card;
53
+
54
+ card = qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
55
+ TYPE_SD_CARD);
56
+ if (dinfo) {
57
+ qdev_prop_set_drive(card, "drive", blk_by_legacy_dinfo(dinfo),
58
+ &error_fatal);
59
+ }
60
+ object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
61
+}
62
+
63
static void aspeed_machine_init(MachineState *machine)
64
{
21
{
65
AspeedBoardState *bmc;
22
+ StellarisADCState *s = STELLARIS_ADC(obj);
66
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
23
int n;
67
}
24
68
25
for (n = 0; n < 4; n++) {
69
for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
26
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_init(Object *obj)
70
- SDHCIState *sdhci = &bmc->soc.sdhci.slots[i];
27
memory_region_init_io(&s->iomem, obj, &stellaris_adc_ops, s,
71
- DriveInfo *dinfo = drive_get_next(IF_SD);
28
"adc", 0x1000);
72
- BlockBackend *blk;
29
sysbus_init_mmio(sbd, &s->iomem);
73
- DeviceState *card;
30
- stellaris_adc_reset(s);
74
+ sdhci_attach_drive(&bmc->soc.sdhci.slots[i], drive_get_next(IF_SD));
31
qdev_init_gpio_in(dev, stellaris_adc_trigger, 1);
75
+ }
76
77
- blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
78
- card = qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
79
- TYPE_SD_CARD);
80
- qdev_prop_set_drive(card, "drive", blk, &error_fatal);
81
- object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
82
+ if (bmc->soc.emmc.num_slots) {
83
+ sdhci_attach_drive(&bmc->soc.emmc.slots[0], drive_get_next(IF_SD));
84
}
85
86
arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
87
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/hw/arm/aspeed_ast2600.c
90
+++ b/hw/arm/aspeed_ast2600.c
91
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
92
[ASPEED_ADC] = 0x1E6E9000,
93
[ASPEED_VIDEO] = 0x1E700000,
94
[ASPEED_SDHCI] = 0x1E740000,
95
+ [ASPEED_EMMC] = 0x1E750000,
96
[ASPEED_GPIO] = 0x1E780000,
97
[ASPEED_GPIO_1_8V] = 0x1E780800,
98
[ASPEED_RTC] = 0x1E781000,
99
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
100
101
#define ASPEED_SOC_AST2600_MAX_IRQ 128
102
103
+/* Shared Peripheral Interrupt values below are offset by -32 from datasheet */
104
static const int aspeed_soc_ast2600_irqmap[] = {
105
[ASPEED_UART1] = 47,
106
[ASPEED_UART2] = 48,
107
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
108
[ASPEED_ADC] = 78,
109
[ASPEED_XDMA] = 6,
110
[ASPEED_SDHCI] = 43,
111
+ [ASPEED_EMMC] = 15,
112
[ASPEED_GPIO] = 40,
113
[ASPEED_GPIO_1_8V] = 11,
114
[ASPEED_RTC] = 13,
115
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
116
sysbus_init_child_obj(obj, "gpio_1_8v", OBJECT(&s->gpio_1_8v),
117
sizeof(s->gpio_1_8v), typename);
118
119
- sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
120
- TYPE_ASPEED_SDHCI);
121
+ sysbus_init_child_obj(obj, "sd-controller", OBJECT(&s->sdhci),
122
+ sizeof(s->sdhci), TYPE_ASPEED_SDHCI);
123
124
object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
125
126
/* Init sd card slot class here so that they're under the correct parent */
127
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
128
- sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
129
+ sysbus_init_child_obj(obj, "sd-controller.sdhci[*]",
130
+ OBJECT(&s->sdhci.slots[i]),
131
sizeof(s->sdhci.slots[i]), TYPE_SYSBUS_SDHCI);
132
}
133
+
134
+ sysbus_init_child_obj(obj, "emmc-controller", OBJECT(&s->emmc),
135
+ sizeof(s->emmc), TYPE_ASPEED_SDHCI);
136
+
137
+ object_property_set_int(OBJECT(&s->emmc), 1, "num-slots", &error_abort);
138
+
139
+ sysbus_init_child_obj(obj, "emmc-controller.sdhci",
140
+ OBJECT(&s->emmc.slots[0]), sizeof(s->emmc.slots[0]),
141
+ TYPE_SYSBUS_SDHCI);
142
}
32
}
143
33
144
/*
34
@@ -XXX,XX +XXX,XX @@ static const TypeInfo stellaris_i2c_info = {
145
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
35
static void stellaris_adc_class_init(ObjectClass *klass, void *data)
146
sc->memmap[ASPEED_SDHCI]);
36
{
147
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0,
37
DeviceClass *dc = DEVICE_CLASS(klass);
148
aspeed_soc_get_irq(s, ASPEED_SDHCI));
38
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
149
+
39
150
+ /* eMMC */
40
+ rc->phases.hold = stellaris_adc_reset_hold;
151
+ object_property_set_bool(OBJECT(&s->emmc), true, "realized", &err);
41
dc->vmsd = &vmstate_stellaris_adc;
152
+ if (err) {
153
+ error_propagate(errp, err);
154
+ return;
155
+ }
156
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_EMMC]);
157
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0,
158
+ aspeed_soc_get_irq(s, ASPEED_EMMC));
159
}
42
}
160
43
161
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
162
--
44
--
163
2.20.1
45
2.34.1
164
46
165
47
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Deprecate device_legacy_reset(), qdev_reset_all() and
3
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
4
qbus_reset_all() to be replaced by new functions
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
device_cold_reset() and bus_cold_reset() which uses resettable API.
5
Message-id: 20240213155214.13619-3-philmd@linaro.org
6
7
Also introduce resettable_cold_reset_fn() which may be used as a
8
replacement for qdev_reset_all_fn and qbus_reset_all_fn().
9
10
Following patches will be needed to look at legacy reset call sites
11
and switch to resettable api. The legacy functions will be removed
12
when unused.
13
14
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
19
Message-id: 20200123132823.1117486-9-damien.hedde@greensocs.com
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
8
---
22
include/hw/qdev-core.h | 27 +++++++++++++++++++++++++++
9
hw/arm/stellaris.c | 26 ++++++++++++++++++++++----
23
include/hw/resettable.h | 9 +++++++++
10
1 file changed, 22 insertions(+), 4 deletions(-)
24
hw/core/bus.c | 5 +++++
25
hw/core/qdev.c | 5 +++++
26
hw/core/resettable.c | 5 +++++
27
5 files changed, 51 insertions(+)
28
11
29
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
12
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
30
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
31
--- a/include/hw/qdev-core.h
14
--- a/hw/arm/stellaris.c
32
+++ b/include/hw/qdev-core.h
15
+++ b/hw/arm/stellaris.c
33
@@ -XXX,XX +XXX,XX @@ int qdev_walk_children(DeviceState *dev,
16
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_instance_init(Object *obj)
34
qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
17
s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK");
35
void *opaque);
18
}
36
19
37
+/**
20
-/* I2C controller. */
38
+ * @qdev_reset_all:
21
+/*
39
+ * Reset @dev. See @qbus_reset_all() for more details.
22
+ * I2C controller.
40
+ *
23
+ * ??? For now we only implement the master interface.
41
+ * Note: This function is deprecated and will be removed when it becomes unused.
42
+ * Please use device_cold_reset() now.
43
+ */
24
+ */
44
void qdev_reset_all(DeviceState *dev);
25
45
void qdev_reset_all_fn(void *opaque);
26
#define TYPE_STELLARIS_I2C "stellaris-i2c"
46
27
OBJECT_DECLARE_SIMPLE_TYPE(stellaris_i2c_state, STELLARIS_I2C)
47
@@ -XXX,XX +XXX,XX @@ void qdev_reset_all_fn(void *opaque);
28
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_write(void *opaque, hwaddr offset,
48
* hard reset means that qbus_reset_all will reset all state of the device.
29
stellaris_i2c_update(s);
49
* For PCI devices, for example, this will include the base address registers
30
}
50
* or configuration space.
31
51
+ *
32
-static void stellaris_i2c_reset(stellaris_i2c_state *s)
52
+ * Note: This function is deprecated and will be removed when it becomes unused.
33
+static void stellaris_i2c_reset_enter(Object *obj, ResetType type)
53
+ * Please use bus_cold_reset() now.
34
{
54
*/
35
+ stellaris_i2c_state *s = STELLARIS_I2C(obj);
55
void qbus_reset_all(BusState *bus);
56
void qbus_reset_all_fn(void *opaque);
57
58
+/**
59
+ * device_cold_reset:
60
+ * Reset device @dev and perform a recursive processing using the resettable
61
+ * interface. It triggers a RESET_TYPE_COLD.
62
+ */
63
+void device_cold_reset(DeviceState *dev);
64
+
36
+
65
+/**
37
if (s->mcs & STELLARIS_I2C_MCS_BUSBSY)
66
+ * bus_cold_reset:
38
i2c_end_transfer(s->bus);
67
+ *
68
+ * Reset bus @bus and perform a recursive processing using the resettable
69
+ * interface. It triggers a RESET_TYPE_COLD.
70
+ */
71
+void bus_cold_reset(BusState *bus);
72
+
73
/**
74
* device_is_in_reset:
75
* Return true if the device @dev is currently being reset.
76
@@ -XXX,XX +XXX,XX @@ void qdev_machine_init(void);
77
* device_legacy_reset:
78
*
79
* Reset a single device (by calling the reset method).
80
+ * Note: This function is deprecated and will be removed when it becomes unused.
81
+ * Please use device_cold_reset() now.
82
*/
83
void device_legacy_reset(DeviceState *dev);
84
85
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
86
index XXXXXXX..XXXXXXX 100644
87
--- a/include/hw/resettable.h
88
+++ b/include/hw/resettable.h
89
@@ -XXX,XX +XXX,XX @@ bool resettable_is_in_reset(Object *obj);
90
*/
91
void resettable_change_parent(Object *obj, Object *newp, Object *oldp);
92
93
+/**
94
+ * resettable_cold_reset_fn:
95
+ * Helper to call resettable_reset((Object *) opaque, RESET_TYPE_COLD).
96
+ *
97
+ * This function is typically useful to register a reset handler with
98
+ * qemu_register_reset.
99
+ */
100
+void resettable_cold_reset_fn(void *opaque);
101
+
102
/**
103
* resettable_class_set_parent_phases:
104
*
105
diff --git a/hw/core/bus.c b/hw/core/bus.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/hw/core/bus.c
108
+++ b/hw/core/bus.c
109
@@ -XXX,XX +XXX,XX @@ int qbus_walk_children(BusState *bus,
110
return 0;
111
}
112
113
+void bus_cold_reset(BusState *bus)
114
+{
115
+ resettable_reset(OBJECT(bus), RESET_TYPE_COLD);
116
+}
39
+}
117
+
40
+
118
bool bus_is_in_reset(BusState *bus)
41
+static void stellaris_i2c_reset_hold(Object *obj)
119
{
120
return resettable_is_in_reset(OBJECT(bus));
121
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/hw/core/qdev.c
124
+++ b/hw/core/qdev.c
125
@@ -XXX,XX +XXX,XX @@ void qbus_reset_all_fn(void *opaque)
126
qbus_reset_all(bus);
127
}
128
129
+void device_cold_reset(DeviceState *dev)
130
+{
42
+{
131
+ resettable_reset(OBJECT(dev), RESET_TYPE_COLD);
43
+ stellaris_i2c_state *s = STELLARIS_I2C(obj);
44
45
s->msa = 0;
46
s->mcs = 0;
47
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset(stellaris_i2c_state *s)
48
s->mimr = 0;
49
s->mris = 0;
50
s->mcr = 0;
132
+}
51
+}
133
+
52
+
134
bool device_is_in_reset(DeviceState *dev)
53
+static void stellaris_i2c_reset_exit(Object *obj)
54
+{
55
+ stellaris_i2c_state *s = STELLARIS_I2C(obj);
56
+
57
stellaris_i2c_update(s);
58
}
59
60
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_init(Object *obj)
61
memory_region_init_io(&s->iomem, obj, &stellaris_i2c_ops, s,
62
"i2c", 0x1000);
63
sysbus_init_mmio(sbd, &s->iomem);
64
- /* ??? For now we only implement the master interface. */
65
- stellaris_i2c_reset(s);
66
}
67
68
/* Analogue to Digital Converter. This is only partially implemented,
69
@@ -XXX,XX +XXX,XX @@ type_init(stellaris_machine_init)
70
static void stellaris_i2c_class_init(ObjectClass *klass, void *data)
135
{
71
{
136
return resettable_is_in_reset(OBJECT(dev));
72
DeviceClass *dc = DEVICE_CLASS(klass);
137
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
73
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
138
index XXXXXXX..XXXXXXX 100644
74
139
--- a/hw/core/resettable.c
75
+ rc->phases.enter = stellaris_i2c_reset_enter;
140
+++ b/hw/core/resettable.c
76
+ rc->phases.hold = stellaris_i2c_reset_hold;
141
@@ -XXX,XX +XXX,XX @@ void resettable_change_parent(Object *obj, Object *newp, Object *oldp)
77
+ rc->phases.exit = stellaris_i2c_reset_exit;
142
}
78
dc->vmsd = &vmstate_stellaris_i2c;
143
}
79
}
144
80
145
+void resettable_cold_reset_fn(void *opaque)
146
+{
147
+ resettable_reset((Object *) opaque, RESET_TYPE_COLD);
148
+}
149
+
150
void resettable_class_set_parent_phases(ResettableClass *rc,
151
ResettableEnterPhase enter,
152
ResettableHoldPhase hold,
153
--
81
--
154
2.20.1
82
2.34.1
155
83
156
84
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Replace deprecated qbus_reset_all by resettable_cold_reset_fn for
3
QDev objects created with qdev_new() need to manually add
4
the sysbus reset registration.
4
their parent relationship with object_property_add_child().
5
5
6
Apart for the raspi machines, this does not impact the behavior
6
This commit plug the devices which aren't part of the SoC;
7
because:
7
they will be plugged into a SoC container in the next one.
8
+ at this point resettable just calls the old reset methods of devices
9
and buses in the same order as qdev/qbus.
10
+ resettable handlers registered with qemu_register_reset are
11
serialized; there is no interleaving.
12
+ eventual explicit calls to legacy reset API (device_reset or
13
qdev/qbus_reset) inside this reset handler will not be masked out
14
by resettable mechanism; they do not go through resettable api.
15
8
16
For the raspi machines, during the sysbus reset the sd-card is not
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
17
reset twice anymore but only once. This is a consequence of switching
18
both sysbus reset and changing parent to resettable; it detects the
19
second reset is not needed. This has no impact on the state after
20
reset; the sd-card reset method only reset local state and query
21
information from the block backend.
22
23
The raspi reset change can be observed by using the following command
24
(reset will occurs, then do Ctrl-C to end qemu; no firmware is
25
given here).
26
qemu-system-aarch64 -M raspi3 \
27
-trace resettable_phase_hold_exec \
28
-trace qdev_update_parent_bus \
29
-trace resettable_change_parent \
30
-trace qdev_reset -trace qbus_reset
31
32
Before the patch, the qdev/qbus_reset traces show when reset method are
33
called. After the patch, the resettable_phase_hold_exec show when reset
34
method are called.
35
36
The traced reset order of the raspi3 is listed below. I've added empty
37
lines and the tree structure.
38
39
+->bcm2835-peripherals reset
40
|
41
| +->sd-card reset
42
| +->sd-bus reset
43
+->bcm2835_gpio reset
44
| -> dev_update_parent_bus (move the sd-card on the sdhci-bus)
45
| -> resettable_change_parent
46
|
47
+->bcm2835-dma reset
48
|
49
| +->bcm2835-sdhost-bus reset
50
+->bcm2835-sdhost reset
51
|
52
| +->sd-card (reset ONLY BEFORE BEFORE THE PATCH)
53
| +->sdhci-bus reset
54
+->generic-sdhci reset
55
|
56
+->bcm2835-rng reset
57
+->bcm2835-property reset
58
+->bcm2835-fb reset
59
+->bcm2835-mbox reset
60
+->bcm2835-aux reset
61
+->pl011 reset
62
+->bcm2835-ic reset
63
+->bcm2836-control reset
64
System reset
65
66
In both case, the sd-card is reset (being on bcm2835_gpio/sd-bus) then moved
67
to generic-sdhci/sdhci-bus by the bcm2835_gpio reset method.
68
69
Before the patch, it is then reset again being part of generic-sdhci/sdhci-bus.
70
After the patch, it considered again for reset but its reset method is not
71
called because it is already flagged as reset.
72
73
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
74
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
75
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20240213155214.13619-4-philmd@linaro.org
76
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
77
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
78
Message-id: 20200123132823.1117486-11-damien.hedde@greensocs.com
79
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
80
---
13
---
81
vl.c | 10 +++++++++-
14
hw/arm/stellaris.c | 4 ++++
82
1 file changed, 9 insertions(+), 1 deletion(-)
15
1 file changed, 4 insertions(+)
83
16
84
diff --git a/vl.c b/vl.c
17
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
85
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
86
--- a/vl.c
19
--- a/hw/arm/stellaris.c
87
+++ b/vl.c
20
+++ b/hw/arm/stellaris.c
88
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
21
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
89
22
&error_fatal);
90
/* TODO: once all bus devices are qdevified, this should be done
23
91
* when bus is created by qdev.c */
24
ssddev = qdev_new("ssd0323");
92
- qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
25
+ object_property_add_child(OBJECT(ms), "oled", OBJECT(ssddev));
93
+ /*
26
qdev_prop_set_uint8(ssddev, "cs", 1);
94
+ * TODO: If we had a main 'reset container' that the whole system
27
qdev_realize_and_unref(ssddev, bus, &error_fatal);
95
+ * lived in, we could reset that using the multi-phase reset
28
96
+ * APIs. For the moment, we just reset the sysbus, which will cause
29
gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ);
97
+ * all devices hanging off it (and all their child buses, recursively)
30
+ object_property_add_child(OBJECT(ms), "splitter",
98
+ * to be reset. Note that this will *not* reset any Device objects
31
+ OBJECT(gpio_d_splitter));
99
+ * which are not attached to some part of the qbus tree!
32
qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2);
100
+ */
33
qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal);
101
+ qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default());
34
qdev_connect_gpio_out(
102
qemu_run_machine_init_done_notifiers();
35
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
103
36
DeviceState *gpad;
104
if (rom_check_and_register_reset() != 0) {
37
38
gpad = qdev_new(TYPE_STELLARIS_GAMEPAD);
39
+ object_property_add_child(OBJECT(ms), "gamepad", OBJECT(gpad));
40
for (i = 0; i < ARRAY_SIZE(gpad_keycode); i++) {
41
qlist_append_int(gpad_keycode_list, gpad_keycode[i]);
42
}
105
--
43
--
106
2.20.1
44
2.34.1
107
45
108
46
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
In qdev_set_parent_bus(), when changing the parent bus of a
3
QDev objects created with qdev_new() need to manually add
4
realized device, if the source and destination buses are not in the
4
their parent relationship with object_property_add_child().
5
same reset state, some adaptations are required. This patch adds
6
needed call to resettable_change_parent() to make sure a device reset
7
state stays coherent with its parent bus.
8
5
9
The addition is a no-op if:
6
Since we don't model the SoC, just use a QOM container.
10
1. the device being parented is not realized.
11
2. the device is realized, but both buses are not under reset.
12
7
13
Case 2 means that as long as qdev_set_parent_bus() is called
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
during the machine realization procedure (which is before the
15
machine reset so nothing is in reset), it is a no op.
16
17
There are 52 call sites of qdev_set_parent_bus(). All but one fall
18
into the no-op case:
19
+ 29 trivial calls related to virtio (in hw/{s390x,display,virtio}/
20
{vhost,virtio}-xxx.c) to set a vdev(or vgpu) composing device
21
parent bus just before realizing the same vdev(vgpu).
22
+ hw/core/qdev.c: when creating a device in qdev_try_create()
23
+ hw/core/sysbus.c: when initializing a device in the sysbus
24
+ hw/i386/amd_iommu.c: before realizing AMDVIState/pci
25
+ hw/isa/piix4.c: before realizing PIIX4State/rtc
26
+ hw/misc/auxbus.c: when creating an AUXBus
27
+ hw/misc/auxbus.c: when creating an AUXBus child
28
+ hw/misc/macio/macio.c: when initializing a MACIOState child
29
+ hw/misc/macio/macio.c: before realizing NewWorldMacIOState/pmu
30
+ hw/misc/macio/macio.c: before realizing NewWorldMacIOState/cuda
31
+ hw/net/virtio-net.c: Used for migration when using the failover
32
mechanism to migration a vfio-pci/net. It is
33
a no-op because at this point the device is
34
already on the bus.
35
+ hw/pci-host/designware.c: before realizing DesignwarePCIEHost/root
36
+ hw/pci-host/gpex.c: before realizing GPEXHost/root
37
+ hw/pci-host/prep.c: when initialiazing PREPPCIState/pci_dev
38
+ hw/pci-host/q35.c: before realizing Q35PCIHost/mch
39
+ hw/pci-host/versatile.c: when initializing PCIVPBState/pci_dev
40
+ hw/pci-host/xilinx-pcie.c: before realizing XilinxPCIEHost/root
41
+ hw/s390x/event-facility.c: when creating SCLPEventFacility/
42
TYPE_SCLP_QUIESCE
43
+ hw/s390x/event-facility.c: ditto with SCLPEventFacility/
44
TYPE_SCLP_CPU_HOTPLUG
45
+ hw/s390x/sclp.c: Not trivial because it is called on a SLCPDevice
46
just after realizing it. Ok because at this point the destination
47
bus (sysbus) is not in reset; the realize step is before the
48
machine reset.
49
+ hw/sd/core.c: Not OK. Used in sdbus_reparent_card(). See below.
50
+ hw/ssi/ssi.c: Used to put spi slave on spi bus and connect the cs
51
line in ssi_auto_connect_slave(). Ok because this function is only
52
used in realize step in hw/ssi/aspeed_smc.ci, hw/ssi/imx_spi.c,
53
hw/ssi/mss-spi.c, hw/ssi/xilinx_spi.c and hw/ssi/xilinx_spips.c.
54
+ hw/xen/xen-legacy-backend.c: when creating a XenLegacyDevice device
55
+ qdev-monitor.c: in device hotplug creation procedure before realize
56
57
Note that this commit alone will have no effect, right now there is no
58
use of resettable API to reset anything. So a bus will never be tagged
59
as in-reset by this same API.
60
61
The one place where side-effect will occurs is in hw/sd/core.c in
62
sdbus_reparent_card(). This function is only used in the raspi machines,
63
including during the sysbus reset procedure. This case will be
64
carrefully handled when doing the multiple phase reset transition.
65
66
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
67
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
68
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20240213155214.13619-5-philmd@linaro.org
69
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
70
Message-id: 20200123132823.1117486-7-damien.hedde@greensocs.com
71
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
72
---
12
---
73
hw/core/qdev.c | 16 +++++++++++-----
13
hw/arm/stellaris.c | 11 ++++++++++-
74
1 file changed, 11 insertions(+), 5 deletions(-)
14
1 file changed, 10 insertions(+), 1 deletion(-)
75
15
76
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
16
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
77
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
78
--- a/hw/core/qdev.c
18
--- a/hw/arm/stellaris.c
79
+++ b/hw/core/qdev.c
19
+++ b/hw/arm/stellaris.c
80
@@ -XXX,XX +XXX,XX @@ static void bus_add_child(BusState *bus, DeviceState *child)
20
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
81
21
* 400fe000 system control
82
void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
22
*/
83
{
23
84
- bool replugging = dev->parent_bus != NULL;
24
+ Object *soc_container;
85
+ BusState *old_parent_bus = dev->parent_bus;
25
DeviceState *gpio_dev[7], *nvic;
86
26
qemu_irq gpio_in[7][8];
87
- if (replugging) {
27
qemu_irq gpio_out[7][8];
88
+ if (old_parent_bus) {
28
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
89
trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)),
29
flash_size = (((board->dc0 & 0xffff) + 1) << 1) * 1024;
90
- dev->parent_bus, object_get_typename(OBJECT(dev->parent_bus)),
30
sram_size = ((board->dc0 >> 18) + 1) * 1024;
91
+ old_parent_bus, object_get_typename(OBJECT(old_parent_bus)),
31
92
OBJECT(bus), object_get_typename(OBJECT(bus)));
32
+ soc_container = object_new("container");
93
/*
33
+ object_property_add_child(OBJECT(ms), "soc", soc_container);
94
* Keep a reference to the device while it's not plugged into
34
+
95
* any bus, to avoid it potentially evaporating when it is
35
/* Flash programming is done via the SCU, so pretend it is ROM. */
96
* dereffed in bus_remove_child().
36
memory_region_init_rom(flash, NULL, "stellaris.flash", flash_size,
97
+ * Also keep the ref of the parent bus until the end, so that
37
&error_fatal);
98
+ * we can safely call resettable_change_parent() below.
38
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
99
*/
39
* need its sysclk output.
100
object_ref(OBJECT(dev));
40
*/
101
bus_remove_child(dev->parent_bus, dev);
41
ssys_dev = qdev_new(TYPE_STELLARIS_SYS);
102
- object_unref(OBJECT(dev->parent_bus));
42
+ object_property_add_child(soc_container, "sys", OBJECT(ssys_dev));
103
}
43
104
dev->parent_bus = bus;
44
/*
105
object_ref(OBJECT(bus));
45
* Most devices come preprogrammed with a MAC address in the user data.
106
bus_add_child(bus, dev);
46
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
107
- if (replugging) {
47
sysbus_realize_and_unref(SYS_BUS_DEVICE(ssys_dev), &error_fatal);
108
+ if (dev->realized) {
48
109
+ resettable_change_parent(OBJECT(dev), OBJECT(bus),
49
nvic = qdev_new(TYPE_ARMV7M);
110
+ OBJECT(old_parent_bus));
50
+ object_property_add_child(soc_container, "v7m", OBJECT(nvic));
111
+ }
51
qdev_prop_set_uint32(nvic, "num-irq", NUM_IRQ_LINES);
112
+ if (old_parent_bus) {
52
qdev_prop_set_uint8(nvic, "num-prio-bits", NUM_PRIO_BITS);
113
+ object_unref(OBJECT(old_parent_bus));
53
qdev_prop_set_string(nvic, "cpu-type", ms->cpu_type);
114
object_unref(OBJECT(dev));
54
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
115
}
55
116
}
56
dev = qdev_new(TYPE_STELLARIS_GPTM);
57
sbd = SYS_BUS_DEVICE(dev);
58
+ object_property_add_child(soc_container, "gptm[*]", OBJECT(dev));
59
qdev_connect_clock_in(dev, "clk",
60
qdev_get_clock_out(ssys_dev, "SYSCLK"));
61
sysbus_realize_and_unref(sbd, &error_fatal);
62
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
63
64
if (board->dc1 & (1 << 3)) { /* watchdog present */
65
dev = qdev_new(TYPE_LUMINARY_WATCHDOG);
66
-
67
+ object_property_add_child(soc_container, "wdg", OBJECT(dev));
68
qdev_connect_clock_in(dev, "WDOGCLK",
69
qdev_get_clock_out(ssys_dev, "SYSCLK"));
70
71
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
72
SysBusDevice *sbd;
73
74
dev = qdev_new("pl011_luminary");
75
+ object_property_add_child(soc_container, "uart[*]", OBJECT(dev));
76
sbd = SYS_BUS_DEVICE(dev);
77
qdev_prop_set_chr(dev, "chardev", serial_hd(i));
78
sysbus_realize_and_unref(sbd, &error_fatal);
79
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
80
DeviceState *enet;
81
82
enet = qdev_new("stellaris_enet");
83
+ object_property_add_child(soc_container, "enet", OBJECT(enet));
84
if (nd) {
85
qdev_set_nic_properties(enet, nd);
86
} else {
117
--
87
--
118
2.20.1
88
2.34.1
119
89
120
90
diff view generated by jsdifflib
New patch
1
We support two different encodings for the AArch32 IMPDEF
2
CBAR register -- older cores like the Cortex A9, A7, A15
3
have this at 4, c15, c0, 0; newer cores like the
4
Cortex A35, A53, A57 and A72 have it at 1 c15 c0 0.
1
5
6
When we implemented this we picked which encoding to
7
use based on whether the CPU set ARM_FEATURE_AARCH64.
8
However this isn't right for three cases:
9
* the qemu-system-arm 'max' CPU, which is supposed to be
10
a variant on a Cortex-A57; it ought to use the same
11
encoding the A57 does and which the AArch64 'max'
12
exposes to AArch32 guest code
13
* the Cortex-R52, which is AArch32-only but has the CBAR
14
at the newer encoding (and where we incorrectly are
15
not yet setting ARM_FEATURE_CBAR_RO anyway)
16
* any possible future support for other v8 AArch32
17
only CPUs, or for supporting "boot the CPU into
18
AArch32 mode" on our existing cores like the A57 etc
19
20
Make the decision of the encoding be based on whether
21
the CPU implements the ARM_FEATURE_V8 flag instead.
22
23
This changes the behaviour only for the qemu-system-arm
24
'-cpu max'. We don't expect anybody to be relying on the
25
old behaviour because:
26
* it's not what the real hardware Cortex-A57 does
27
(and that's what our ID register claims we are)
28
* we don't implement the memory-mapped GICv3 support
29
which is the only thing that exists at the peripheral
30
base address pointed to by the register
31
32
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
33
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
34
Message-id: 20240206132931.38376-2-peter.maydell@linaro.org
35
---
36
target/arm/helper.c | 2 +-
37
1 file changed, 1 insertion(+), 1 deletion(-)
38
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/helper.c
42
+++ b/target/arm/helper.c
43
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
44
* AArch64 cores we might need to add a specific feature flag
45
* to indicate cores with "flavour 2" CBAR.
46
*/
47
- if (arm_feature(env, ARM_FEATURE_AARCH64)) {
48
+ if (arm_feature(env, ARM_FEATURE_V8)) {
49
/* 32 bit view is [31:18] 0...0 [43:32]. */
50
uint32_t cbar32 = (extract64(cpu->reset_cbar, 18, 14) << 18)
51
| extract64(cpu->reset_cbar, 32, 12);
52
--
53
2.34.1
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
The Cortex-R52 implements the Configuration Base Address Register
2
(CBAR), as a read-only register. Add ARM_FEATURE_CBAR_RO to this CPU
3
type, so that our implementation provides the register and the
4
associated qdev property.
2
5
3
Signed-off-by: Andrew Jones <drjones@redhat.com>
4
Message-id: 20200120101023.16030-3-drjones@redhat.com
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20240206132931.38376-3-peter.maydell@linaro.org
7
---
9
---
8
hw/arm/virt.c | 1 +
10
target/arm/tcg/cpu32.c | 1 +
9
1 file changed, 1 insertion(+)
11
1 file changed, 1 insertion(+)
10
12
11
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
13
diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c
12
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/virt.c
15
--- a/target/arm/tcg/cpu32.c
14
+++ b/hw/arm/virt.c
16
+++ b/target/arm/tcg/cpu32.c
15
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 0)
17
@@ -XXX,XX +XXX,XX @@ static void cortex_r52_initfn(Object *obj)
16
18
set_feature(&cpu->env, ARM_FEATURE_PMSA);
17
static void virt_machine_4_2_options(MachineClass *mc)
19
set_feature(&cpu->env, ARM_FEATURE_NEON);
18
{
20
set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
19
+ virt_machine_5_0_options(mc);
21
+ set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
20
compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
22
cpu->midr = 0x411fd133; /* r1p3 */
21
}
23
cpu->revidr = 0x00000000;
22
DEFINE_VIRT_MACHINE(4, 2)
24
cpu->reset_fpsid = 0x41034023;
23
--
25
--
24
2.20.1
26
2.34.1
25
26
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
Add the Cortex-R52 IMPDEF sysregs, by defining them here and
2
also by enabling the AUXCR feature which defines the ACTLR
3
and HACTLR registers. As is our usual practice, we make these
4
simple reads-as-zero stubs for now.
2
5
3
The AST2600 includes a second cut-down version of the SD/MMC controller
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
found in the AST2500, named the eMMC controller. It's cut down in the
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
sense that it only supports one slot rather than two, but it brings the
8
Message-id: 20240206132931.38376-4-peter.maydell@linaro.org
6
total number of slots supported by the AST2600 to three.
9
---
10
target/arm/tcg/cpu32.c | 108 +++++++++++++++++++++++++++++++++++++++++
11
1 file changed, 108 insertions(+)
7
12
8
The existing code assumed that the SD controller always provided two
13
diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c
9
slots. Rework the SDHCI object to expose the number of slots as a
10
property to be set by the SoC configuration.
11
12
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Signed-off-by: Cédric Le Goater <clg@kaod.org>
16
Message-id: 20200114103433.30534-2-clg@kaod.org
17
[PMM: fixed up to use device_class_set_props()]
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
20
include/hw/sd/aspeed_sdhci.h | 1 +
21
hw/arm/aspeed.c | 2 +-
22
hw/arm/aspeed_ast2600.c | 2 ++
23
hw/arm/aspeed_soc.c | 2 ++
24
hw/sd/aspeed_sdhci.c | 11 +++++++++--
25
5 files changed, 15 insertions(+), 3 deletions(-)
26
27
diff --git a/include/hw/sd/aspeed_sdhci.h b/include/hw/sd/aspeed_sdhci.h
28
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/sd/aspeed_sdhci.h
15
--- a/target/arm/tcg/cpu32.c
30
+++ b/include/hw/sd/aspeed_sdhci.h
16
+++ b/target/arm/tcg/cpu32.c
31
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSDHCIState {
17
@@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj)
32
SysBusDevice parent;
18
define_arm_cp_regs(cpu, cortexr5_cp_reginfo);
33
19
}
34
SDHCIState slots[ASPEED_SDHCI_NUM_SLOTS];
20
35
+ uint8_t num_slots;
21
+static const ARMCPRegInfo cortex_r52_cp_reginfo[] = {
36
22
+ { .name = "CPUACTLR", .cp = 15, .opc1 = 0, .crm = 15,
37
MemoryRegion iomem;
23
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
38
qemu_irq irq;
24
+ { .name = "IMP_ATCMREGIONR",
39
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
25
+ .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
40
index XXXXXXX..XXXXXXX 100644
26
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
41
--- a/hw/arm/aspeed.c
27
+ { .name = "IMP_BTCMREGIONR",
42
+++ b/hw/arm/aspeed.c
28
+ .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1,
43
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
29
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
44
amc->i2c_init(bmc);
30
+ { .name = "IMP_CTCMREGIONR",
45
}
31
+ .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 2,
46
32
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
47
- for (i = 0; i < ARRAY_SIZE(bmc->soc.sdhci.slots); i++) {
33
+ { .name = "IMP_CSCTLR",
48
+ for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
34
+ .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 0,
49
SDHCIState *sdhci = &bmc->soc.sdhci.slots[i];
35
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
50
DriveInfo *dinfo = drive_get_next(IF_SD);
36
+ { .name = "IMP_BPCTLR",
51
BlockBackend *blk;
37
+ .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 1,
52
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
38
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
53
index XXXXXXX..XXXXXXX 100644
39
+ { .name = "IMP_MEMPROTCLR",
54
--- a/hw/arm/aspeed_ast2600.c
40
+ .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 2,
55
+++ b/hw/arm/aspeed_ast2600.c
41
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
56
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
42
+ { .name = "IMP_SLAVEPCTLR",
57
sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
43
+ .cp = 15, .opc1 = 0, .crn = 11, .crm = 0, .opc2 = 0,
58
TYPE_ASPEED_SDHCI);
44
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
59
45
+ { .name = "IMP_PERIPHREGIONR",
60
+ object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
46
+ .cp = 15, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 0,
61
+
47
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
62
/* Init sd card slot class here so that they're under the correct parent */
48
+ { .name = "IMP_FLASHIFREGIONR",
63
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
49
+ .cp = 15, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 1,
64
sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
50
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
65
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
51
+ { .name = "IMP_BUILDOPTR",
66
index XXXXXXX..XXXXXXX 100644
52
+ .cp = 15, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0,
67
--- a/hw/arm/aspeed_soc.c
53
+ .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
68
+++ b/hw/arm/aspeed_soc.c
54
+ { .name = "IMP_PINOPTR",
69
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
55
+ .cp = 15, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7,
70
sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
56
+ .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
71
TYPE_ASPEED_SDHCI);
57
+ { .name = "IMP_QOSR",
72
58
+ .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 1,
73
+ object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
59
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
74
+
60
+ { .name = "IMP_BUSTIMEOUTR",
75
/* Init sd card slot class here so that they're under the correct parent */
61
+ .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 2,
76
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
62
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
77
sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
63
+ { .name = "IMP_INTMONR",
78
diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c
64
+ .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 4,
79
index XXXXXXX..XXXXXXX 100644
65
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
80
--- a/hw/sd/aspeed_sdhci.c
66
+ { .name = "IMP_ICERR0",
81
+++ b/hw/sd/aspeed_sdhci.c
67
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 0, .opc2 = 0,
82
@@ -XXX,XX +XXX,XX @@
68
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
83
#include "qapi/error.h"
69
+ { .name = "IMP_ICERR1",
84
#include "hw/irq.h"
70
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 0, .opc2 = 1,
85
#include "migration/vmstate.h"
71
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
86
+#include "hw/qdev-properties.h"
72
+ { .name = "IMP_DCERR0",
87
73
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 1, .opc2 = 0,
88
#define ASPEED_SDHCI_INFO 0x00
74
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
89
#define ASPEED_SDHCI_INFO_RESET 0x00030000
75
+ { .name = "IMP_DCERR1",
90
@@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_realize(DeviceState *dev, Error **errp)
76
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 1, .opc2 = 1,
91
77
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
92
/* Create input irqs for the slots */
78
+ { .name = "IMP_TCMERR0",
93
qdev_init_gpio_in_named_with_opaque(DEVICE(sbd), aspeed_sdhci_set_irq,
79
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 0,
94
- sdhci, NULL, ASPEED_SDHCI_NUM_SLOTS);
80
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
95
+ sdhci, NULL, sdhci->num_slots);
81
+ { .name = "IMP_TCMERR1",
96
82
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 1,
97
sysbus_init_irq(sbd, &sdhci->irq);
83
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
98
memory_region_init_io(&sdhci->iomem, OBJECT(sdhci), &aspeed_sdhci_ops,
84
+ { .name = "IMP_TCMSYNDR0",
99
sdhci, TYPE_ASPEED_SDHCI, 0x1000);
85
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 2,
100
sysbus_init_mmio(sbd, &sdhci->iomem);
86
+ .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
101
87
+ { .name = "IMP_TCMSYNDR1",
102
- for (int i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
88
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 3,
103
+ for (int i = 0; i < sdhci->num_slots; ++i) {
89
+ .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
104
Object *sdhci_slot = OBJECT(&sdhci->slots[i]);
90
+ { .name = "IMP_FLASHERR0",
105
SysBusDevice *sbd_slot = SYS_BUS_DEVICE(&sdhci->slots[i]);
91
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 3, .opc2 = 0,
106
92
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
107
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_sdhci = {
93
+ { .name = "IMP_FLASHERR1",
108
},
94
+ .cp = 15, .opc1 = 2, .crn = 15, .crm = 3, .opc2 = 1,
109
};
95
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
110
96
+ { .name = "IMP_CDBGDR0",
111
+static Property aspeed_sdhci_properties[] = {
97
+ .cp = 15, .opc1 = 3, .crn = 15, .crm = 0, .opc2 = 0,
112
+ DEFINE_PROP_UINT8("num-slots", AspeedSDHCIState, num_slots, 0),
98
+ .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
113
+ DEFINE_PROP_END_OF_LIST(),
99
+ { .name = "IMP_CBDGBR1",
100
+ .cp = 15, .opc1 = 3, .crn = 15, .crm = 0, .opc2 = 1,
101
+ .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
102
+ { .name = "IMP_TESTR0",
103
+ .cp = 15, .opc1 = 4, .crn = 15, .crm = 0, .opc2 = 0,
104
+ .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
105
+ { .name = "IMP_TESTR1",
106
+ .cp = 15, .opc1 = 4, .crn = 15, .crm = 0, .opc2 = 1,
107
+ .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
108
+ { .name = "IMP_CDBGDCI",
109
+ .cp = 15, .opc1 = 0, .crn = 15, .crm = 15, .opc2 = 0,
110
+ .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
111
+ { .name = "IMP_CDBGDCT",
112
+ .cp = 15, .opc1 = 3, .crn = 15, .crm = 2, .opc2 = 0,
113
+ .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
114
+ { .name = "IMP_CDBGICT",
115
+ .cp = 15, .opc1 = 3, .crn = 15, .crm = 2, .opc2 = 1,
116
+ .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
117
+ { .name = "IMP_CDBGDCD",
118
+ .cp = 15, .opc1 = 3, .crn = 15, .crm = 4, .opc2 = 0,
119
+ .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
120
+ { .name = "IMP_CDBGICD",
121
+ .cp = 15, .opc1 = 3, .crn = 15, .crm = 4, .opc2 = 1,
122
+ .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
114
+};
123
+};
115
+
124
+
116
static void aspeed_sdhci_class_init(ObjectClass *classp, void *data)
125
+
126
static void cortex_r52_initfn(Object *obj)
117
{
127
{
118
DeviceClass *dc = DEVICE_CLASS(classp);
128
ARMCPU *cpu = ARM_CPU(obj);
119
@@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_class_init(ObjectClass *classp, void *data)
129
@@ -XXX,XX +XXX,XX @@ static void cortex_r52_initfn(Object *obj)
120
dc->realize = aspeed_sdhci_realize;
130
set_feature(&cpu->env, ARM_FEATURE_NEON);
121
dc->reset = aspeed_sdhci_reset;
131
set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
122
dc->vmsd = &vmstate_aspeed_sdhci;
132
set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
123
+ device_class_set_props(dc, aspeed_sdhci_properties);
133
+ set_feature(&cpu->env, ARM_FEATURE_AUXCR);
134
cpu->midr = 0x411fd133; /* r1p3 */
135
cpu->revidr = 0x00000000;
136
cpu->reset_fpsid = 0x41034023;
137
@@ -XXX,XX +XXX,XX @@ static void cortex_r52_initfn(Object *obj)
138
139
cpu->pmsav7_dregion = 16;
140
cpu->pmsav8r_hdregion = 16;
141
+
142
+ define_arm_cp_regs(cpu, cortex_r52_cp_reginfo);
124
}
143
}
125
144
126
static TypeInfo aspeed_sdhci_info = {
145
static void cortex_r5f_initfn(Object *obj)
127
--
146
--
128
2.20.1
147
2.34.1
129
130
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Architecturally, the AArch32 MSR/MRS to/from banked register
2
instructions are UNPREDICTABLE for attempts to access a banked
3
register that the guest could access in a more direct way (e.g.
4
using this insn to access r8_fiq when already in FIQ mode). QEMU has
5
chosen to UNDEF on all of these.
2
6
3
Provide a temporary device_legacy_reset function doing what
7
However, for the case of accessing SPSR_hyp from hyp mode, it turns
4
device_reset does to prepare for the transition with Resettable
8
out that real hardware permits this, with the same effect as if the
5
API.
9
guest had directly written to SPSR. Further, there is some
10
guest code out there that assumes it can do this, because it
11
happens to work on hardware: an example Cortex-R52 startup code
12
fragment uses this, and it got copied into various other places,
13
including Zephyr. Zephyr was fixed to not use this:
14
https://github.com/zephyrproject-rtos/zephyr/issues/47330
15
but other examples are still out there, like the selftest
16
binary for the MPS3-AN536.
6
17
7
All occurrence of device_reset in the code tree are also replaced
18
For convenience of being able to run guest code, permit
8
by device_legacy_reset.
19
this UNPREDICTABLE access instead of UNDEFing it.
9
20
10
The new resettable API has different prototype and semantics
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
(resetting child buses as well as the specified device). Subsequent
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
commits will make the changeover for each call site individually; once
23
Message-id: 20240206132931.38376-5-peter.maydell@linaro.org
13
that is complete device_legacy_reset() will be removed.
24
---
25
target/arm/tcg/op_helper.c | 43 ++++++++++++++++++++++++++------------
26
target/arm/tcg/translate.c | 19 +++++++++++------
27
2 files changed, 43 insertions(+), 19 deletions(-)
14
28
15
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
29
diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Acked-by: David Gibson <david@gibson.dropbear.id.au>
19
Acked-by: Cornelia Huck <cohuck@redhat.com>
20
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
21
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
Message-id: 20200123132823.1117486-2-damien.hedde@greensocs.com
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
25
include/hw/qdev-core.h | 4 ++--
26
hw/audio/intel-hda.c | 2 +-
27
hw/core/qdev.c | 6 +++---
28
hw/hyperv/hyperv.c | 2 +-
29
hw/i386/microvm.c | 2 +-
30
hw/i386/pc.c | 2 +-
31
hw/ide/microdrive.c | 8 ++++----
32
hw/intc/spapr_xive.c | 2 +-
33
hw/ppc/pnv_psi.c | 4 ++--
34
hw/ppc/spapr_pci.c | 2 +-
35
hw/ppc/spapr_vio.c | 2 +-
36
hw/s390x/s390-pci-inst.c | 2 +-
37
hw/scsi/vmw_pvscsi.c | 2 +-
38
hw/sd/omap_mmc.c | 2 +-
39
hw/sd/pl181.c | 2 +-
40
15 files changed, 22 insertions(+), 22 deletions(-)
41
42
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
43
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
44
--- a/include/hw/qdev-core.h
31
--- a/target/arm/tcg/op_helper.c
45
+++ b/include/hw/qdev-core.h
32
+++ b/target/arm/tcg/op_helper.c
46
@@ -XXX,XX +XXX,XX @@ char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev);
33
@@ -XXX,XX +XXX,XX @@ static void msr_mrs_banked_exc_checks(CPUARMState *env, uint32_t tgtmode,
47
void qdev_machine_init(void);
34
*/
48
35
int curmode = env->uncached_cpsr & CPSR_M;
49
/**
36
50
- * @device_reset
37
- if (regno == 17) {
51
+ * device_legacy_reset:
38
- /* ELR_Hyp: a special case because access from tgtmode is OK */
52
*
39
- if (curmode != ARM_CPU_MODE_HYP && curmode != ARM_CPU_MODE_MON) {
53
* Reset a single device (by calling the reset method).
40
- goto undef;
54
*/
41
+ if (tgtmode == ARM_CPU_MODE_HYP) {
55
-void device_reset(DeviceState *dev);
42
+ /*
56
+void device_legacy_reset(DeviceState *dev);
43
+ * Handle Hyp target regs first because some are special cases
57
44
+ * which don't want the usual "not accessible from tgtmode" check.
58
void device_class_set_props(DeviceClass *dc, Property *props);
45
+ */
59
46
+ switch (regno) {
60
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
47
+ case 16 ... 17: /* ELR_Hyp, SPSR_Hyp */
61
index XXXXXXX..XXXXXXX 100644
48
+ if (curmode != ARM_CPU_MODE_HYP && curmode != ARM_CPU_MODE_MON) {
62
--- a/hw/audio/intel-hda.c
49
+ goto undef;
63
+++ b/hw/audio/intel-hda.c
50
+ }
64
@@ -XXX,XX +XXX,XX @@ static void intel_hda_reset(DeviceState *dev)
51
+ break;
65
QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) {
52
+ case 13:
66
DeviceState *qdev = kid->child;
53
+ if (curmode != ARM_CPU_MODE_MON) {
67
cdev = HDA_CODEC_DEVICE(qdev);
54
+ goto undef;
68
- device_reset(DEVICE(cdev));
55
+ }
69
+ device_legacy_reset(DEVICE(cdev));
56
+ break;
70
d->state_sts |= (1 << cdev->cad);
57
+ default:
58
+ g_assert_not_reached();
59
}
60
return;
71
}
61
}
72
intel_hda_update_irq(d);
62
@@ -XXX,XX +XXX,XX @@ static void msr_mrs_banked_exc_checks(CPUARMState *env, uint32_t tgtmode,
73
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/hw/core/qdev.c
76
+++ b/hw/core/qdev.c
77
@@ -XXX,XX +XXX,XX @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
78
79
static int qdev_reset_one(DeviceState *dev, void *opaque)
80
{
81
- device_reset(dev);
82
+ device_legacy_reset(dev);
83
84
return 0;
85
}
86
@@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp)
87
}
88
}
89
if (dev->hotplugged) {
90
- device_reset(dev);
91
+ device_legacy_reset(dev);
92
}
93
dev->pending_deleted_event = false;
94
95
@@ -XXX,XX +XXX,XX @@ void device_class_set_parent_unrealize(DeviceClass *dc,
96
dc->unrealize = dev_unrealize;
97
}
98
99
-void device_reset(DeviceState *dev)
100
+void device_legacy_reset(DeviceState *dev)
101
{
102
DeviceClass *klass = DEVICE_GET_CLASS(dev);
103
104
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
105
index XXXXXXX..XXXXXXX 100644
106
--- a/hw/hyperv/hyperv.c
107
+++ b/hw/hyperv/hyperv.c
108
@@ -XXX,XX +XXX,XX @@ void hyperv_synic_reset(CPUState *cs)
109
SynICState *synic = get_synic(cs);
110
111
if (synic) {
112
- device_reset(DEVICE(synic));
113
+ device_legacy_reset(DEVICE(synic));
114
}
115
}
116
117
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
118
index XXXXXXX..XXXXXXX 100644
119
--- a/hw/i386/microvm.c
120
+++ b/hw/i386/microvm.c
121
@@ -XXX,XX +XXX,XX @@ static void microvm_machine_reset(MachineState *machine)
122
cpu = X86_CPU(cs);
123
124
if (cpu->apic_state) {
125
- device_reset(cpu->apic_state);
126
+ device_legacy_reset(cpu->apic_state);
127
}
63
}
128
}
64
}
129
}
65
130
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
66
- if (tgtmode == ARM_CPU_MODE_HYP) {
67
- /* SPSR_Hyp, r13_hyp: accessible from Monitor mode only */
68
- if (curmode != ARM_CPU_MODE_MON) {
69
- goto undef;
70
- }
71
- }
72
-
73
return;
74
75
undef:
76
@@ -XXX,XX +XXX,XX @@ void HELPER(msr_banked)(CPUARMState *env, uint32_t value, uint32_t tgtmode,
77
78
switch (regno) {
79
case 16: /* SPSRs */
80
- env->banked_spsr[bank_number(tgtmode)] = value;
81
+ if (tgtmode == (env->uncached_cpsr & CPSR_M)) {
82
+ /* Only happens for SPSR_Hyp access in Hyp mode */
83
+ env->spsr = value;
84
+ } else {
85
+ env->banked_spsr[bank_number(tgtmode)] = value;
86
+ }
87
break;
88
case 17: /* ELR_Hyp */
89
env->elr_el[2] = value;
90
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t tgtmode, uint32_t regno)
91
92
switch (regno) {
93
case 16: /* SPSRs */
94
- return env->banked_spsr[bank_number(tgtmode)];
95
+ if (tgtmode == (env->uncached_cpsr & CPSR_M)) {
96
+ /* Only happens for SPSR_Hyp access in Hyp mode */
97
+ return env->spsr;
98
+ } else {
99
+ return env->banked_spsr[bank_number(tgtmode)];
100
+ }
101
case 17: /* ELR_Hyp */
102
return env->elr_el[2];
103
case 13:
104
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
131
index XXXXXXX..XXXXXXX 100644
105
index XXXXXXX..XXXXXXX 100644
132
--- a/hw/i386/pc.c
106
--- a/target/arm/tcg/translate.c
133
+++ b/hw/i386/pc.c
107
+++ b/target/arm/tcg/translate.c
134
@@ -XXX,XX +XXX,XX @@ static void pc_machine_reset(MachineState *machine)
108
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
135
cpu = X86_CPU(cs);
109
break;
136
110
case ARM_CPU_MODE_HYP:
137
if (cpu->apic_state) {
111
/*
138
- device_reset(cpu->apic_state);
112
- * SPSR_hyp and r13_hyp can only be accessed from Monitor mode
139
+ device_legacy_reset(cpu->apic_state);
113
- * (and so we can forbid accesses from EL2 or below). elr_hyp
114
- * can be accessed also from Hyp mode, so forbid accesses from
115
- * EL0 or EL1.
116
+ * r13_hyp can only be accessed from Monitor mode, and so we
117
+ * can forbid accesses from EL2 or below.
118
+ * elr_hyp can be accessed also from Hyp mode, so forbid
119
+ * accesses from EL0 or EL1.
120
+ * SPSR_hyp is supposed to be in the same category as r13_hyp
121
+ * and UNPREDICTABLE if accessed from anything except Monitor
122
+ * mode. However there is some real-world code that will do
123
+ * it because at least some hardware happens to permit the
124
+ * access. (Notably a standard Cortex-R52 startup code fragment
125
+ * does this.) So we permit SPSR_hyp from Hyp mode also, to allow
126
+ * this (incorrect) guest code to run.
127
*/
128
- if (!arm_dc_feature(s, ARM_FEATURE_EL2) || s->current_el < 2 ||
129
- (s->current_el < 3 && *regno != 17)) {
130
+ if (!arm_dc_feature(s, ARM_FEATURE_EL2) || s->current_el < 2
131
+ || (s->current_el < 3 && *regno != 16 && *regno != 17)) {
132
goto undef;
140
}
133
}
141
}
142
}
143
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
144
index XXXXXXX..XXXXXXX 100644
145
--- a/hw/ide/microdrive.c
146
+++ b/hw/ide/microdrive.c
147
@@ -XXX,XX +XXX,XX @@ static void md_attr_write(PCMCIACardState *card, uint32_t at, uint8_t value)
148
case 0x00:    /* Configuration Option Register */
149
s->opt = value & 0xcf;
150
if (value & OPT_SRESET) {
151
- device_reset(DEVICE(s));
152
+ device_legacy_reset(DEVICE(s));
153
}
154
md_interrupt_update(s);
155
break;
134
break;
156
@@ -XXX,XX +XXX,XX @@ static void md_common_write(PCMCIACardState *card, uint32_t at, uint16_t value)
157
case 0xe:    /* Device Control */
158
s->ctrl = value;
159
if (value & CTRL_SRST) {
160
- device_reset(DEVICE(s));
161
+ device_legacy_reset(DEVICE(s));
162
}
163
md_interrupt_update(s);
164
break;
165
@@ -XXX,XX +XXX,XX @@ static int dscm1xxxx_attach(PCMCIACardState *card)
166
md->attr_base = pcc->cis[0x74] | (pcc->cis[0x76] << 8);
167
md->io_base = 0x0;
168
169
- device_reset(DEVICE(md));
170
+ device_legacy_reset(DEVICE(md));
171
md_interrupt_update(md);
172
173
return 0;
174
@@ -XXX,XX +XXX,XX @@ static int dscm1xxxx_detach(PCMCIACardState *card)
175
{
176
MicroDriveState *md = MICRODRIVE(card);
177
178
- device_reset(DEVICE(md));
179
+ device_legacy_reset(DEVICE(md));
180
return 0;
181
}
182
183
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
184
index XXXXXXX..XXXXXXX 100644
185
--- a/hw/intc/spapr_xive.c
186
+++ b/hw/intc/spapr_xive.c
187
@@ -XXX,XX +XXX,XX @@ static target_ulong h_int_reset(PowerPCCPU *cpu,
188
return H_PARAMETER;
189
}
190
191
- device_reset(DEVICE(xive));
192
+ device_legacy_reset(DEVICE(xive));
193
194
if (kvm_irqchip_in_kernel()) {
195
Error *local_err = NULL;
196
diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
197
index XXXXXXX..XXXXXXX 100644
198
--- a/hw/ppc/pnv_psi.c
199
+++ b/hw/ppc/pnv_psi.c
200
@@ -XXX,XX +XXX,XX @@ static void pnv_psi_reset(DeviceState *dev)
201
202
static void pnv_psi_reset_handler(void *dev)
203
{
204
- device_reset(DEVICE(dev));
205
+ device_legacy_reset(DEVICE(dev));
206
}
207
208
static void pnv_psi_realize(DeviceState *dev, Error **errp)
209
@@ -XXX,XX +XXX,XX @@ static void pnv_psi_p9_mmio_write(void *opaque, hwaddr addr,
210
break;
211
case PSIHB9_INTERRUPT_CONTROL:
212
if (val & PSIHB9_IRQ_RESET) {
213
- device_reset(DEVICE(&psi9->source));
214
+ device_legacy_reset(DEVICE(&psi9->source));
215
}
216
psi->regs[reg] = val;
217
break;
218
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
219
index XXXXXXX..XXXXXXX 100644
220
--- a/hw/ppc/spapr_pci.c
221
+++ b/hw/ppc/spapr_pci.c
222
@@ -XXX,XX +XXX,XX @@ static int spapr_phb_children_reset(Object *child, void *opaque)
223
DeviceState *dev = (DeviceState *) object_dynamic_cast(child, TYPE_DEVICE);
224
225
if (dev) {
226
- device_reset(dev);
227
+ device_legacy_reset(dev);
228
}
229
230
return 0;
231
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
232
index XXXXXXX..XXXXXXX 100644
233
--- a/hw/ppc/spapr_vio.c
234
+++ b/hw/ppc/spapr_vio.c
235
@@ -XXX,XX +XXX,XX @@ int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq)
236
static void spapr_vio_quiesce_one(SpaprVioDevice *dev)
237
{
238
if (dev->tcet) {
239
- device_reset(DEVICE(dev->tcet));
240
+ device_legacy_reset(DEVICE(dev->tcet));
241
}
242
free_crq(dev);
243
}
244
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
245
index XXXXXXX..XXXXXXX 100644
246
--- a/hw/s390x/s390-pci-inst.c
247
+++ b/hw/s390x/s390-pci-inst.c
248
@@ -XXX,XX +XXX,XX @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra)
249
stw_p(&ressetpci->hdr.rsp, CLP_RC_SETPCIFN_FHOP);
250
goto out;
251
}
252
- device_reset(DEVICE(pbdev));
253
+ device_legacy_reset(DEVICE(pbdev));
254
pbdev->fh &= ~FH_MASK_ENABLE;
255
pbdev->state = ZPCI_FS_DISABLED;
256
stl_p(&ressetpci->fh, pbdev->fh);
257
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
258
index XXXXXXX..XXXXXXX 100644
259
--- a/hw/scsi/vmw_pvscsi.c
260
+++ b/hw/scsi/vmw_pvscsi.c
261
@@ -XXX,XX +XXX,XX @@ pvscsi_on_cmd_reset_device(PVSCSIState *s)
262
263
if (sdev != NULL) {
264
s->resetting++;
265
- device_reset(&sdev->qdev);
266
+ device_legacy_reset(&sdev->qdev);
267
s->resetting--;
268
return PVSCSI_COMMAND_PROCESSING_SUCCEEDED;
269
}
270
diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c
271
index XXXXXXX..XXXXXXX 100644
272
--- a/hw/sd/omap_mmc.c
273
+++ b/hw/sd/omap_mmc.c
274
@@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host)
275
* into any bus, and we must reset it manually. When omap_mmc is
276
* QOMified this must move into the QOM reset function.
277
*/
278
- device_reset(DEVICE(host->card));
279
+ device_legacy_reset(DEVICE(host->card));
280
}
281
282
static uint64_t omap_mmc_read(void *opaque, hwaddr offset,
283
diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c
284
index XXXXXXX..XXXXXXX 100644
285
--- a/hw/sd/pl181.c
286
+++ b/hw/sd/pl181.c
287
@@ -XXX,XX +XXX,XX @@ static void pl181_reset(DeviceState *d)
288
/* Since we're still using the legacy SD API the card is not plugged
289
* into any bus, and we must reset it manually.
290
*/
291
- device_reset(DEVICE(s->card));
292
+ device_legacy_reset(DEVICE(s->card));
293
}
294
295
static void pl181_init(Object *obj)
296
--
135
--
297
2.20.1
136
2.34.1
298
299
diff view generated by jsdifflib
1
The num-lines property of the TYPE_OR_GATE device sets the number
1
We currently guard the CFG3 register read with
2
of input lines it has. An assert() in or_irq_realize() restricts
2
(scc_partno(s) == 0x524 && scc_partno(s) == 0x547)
3
this to the maximum supported by the implementation. However we
3
which is clearly wrong as it is never true.
4
got the condition in the assert wrong: it should be using <=,
5
because num-lines == MAX_OR_LINES is permitted, and means that
6
all entries from 0 to MAX_OR_LINES-1 in the s->levels[] array
7
are used.
8
4
9
We didn't notice this previously because no user has so far
5
This register is present on all board types except AN524
10
needed that many input lines.
6
and AN527; correct the condition.
11
7
12
Reported-by: Guenter Roeck <linux@roeck-us.net>
8
Fixes: 6ac80818941829c0 ("hw/misc/mps2-scc: Implement changes for AN547")
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 20200120142235.10432-1-peter.maydell@linaro.org
12
Message-id: 20240206132931.38376-6-peter.maydell@linaro.org
17
---
13
---
18
hw/core/or-irq.c | 2 +-
14
hw/misc/mps2-scc.c | 2 +-
19
1 file changed, 1 insertion(+), 1 deletion(-)
15
1 file changed, 1 insertion(+), 1 deletion(-)
20
16
21
diff --git a/hw/core/or-irq.c b/hw/core/or-irq.c
17
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
22
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/core/or-irq.c
19
--- a/hw/misc/mps2-scc.c
24
+++ b/hw/core/or-irq.c
20
+++ b/hw/misc/mps2-scc.c
25
@@ -XXX,XX +XXX,XX @@ static void or_irq_realize(DeviceState *dev, Error **errp)
21
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size)
26
{
22
r = s->cfg2;
27
qemu_or_irq *s = OR_IRQ(dev);
23
break;
28
24
case A_CFG3:
29
- assert(s->num_lines < MAX_OR_LINES);
25
- if (scc_partno(s) == 0x524 && scc_partno(s) == 0x547) {
30
+ assert(s->num_lines <= MAX_OR_LINES);
26
+ if (scc_partno(s) == 0x524 || scc_partno(s) == 0x547) {
31
27
/* CFG3 reserved on AN524 */
32
qdev_init_gpio_in(dev, or_irq_handler, s->num_lines);
28
goto bad_offset;
33
}
29
}
34
--
30
--
35
2.20.1
31
2.34.1
36
32
37
33
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
The MPS SCC device has a lot of different flavours for the various
2
different MPS FPGA images, which look mostly similar but have
3
differences in how particular registers are handled. Currently we
4
deal with this with a lot of open-coded checks on scc_partno(), but
5
as we add more board types this is getting a bit hard to read.
2
6
3
The overhead for the OpenBMC firmware images using the a custom U-Boot
7
Factor out the conditions into some functions which we can
4
is around 2 seconds, which is fine, but with a U-Boot from mainline,
8
give more descriptive names to.
5
it takes an extra 50 seconds or so to reach Linux. A quick survey on
6
the number of reads performed on the flash memory region gives the
7
following figures :
8
9
9
OpenBMC U-Boot 922478 (~ 3.5 MBytes)
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Mainline U-Boot 20569977 (~ 80 MBytes)
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20240206132931.38376-7-peter.maydell@linaro.org
14
---
15
hw/misc/mps2-scc.c | 45 +++++++++++++++++++++++++++++++--------------
16
1 file changed, 31 insertions(+), 14 deletions(-)
11
17
12
QEMU must be trashing the TCG TBs and reloading text very often. Some
18
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
13
addresses are read more than 250.000 times. Until we find a solution
14
to improve boot time, execution from MMIO is not activated by default.
15
16
Setting this option also breaks migration compatibility.
17
18
Signed-off-by: Cédric Le Goater <clg@kaod.org>
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
21
Message-id: 20200114103433.30534-5-clg@kaod.org
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
24
include/hw/arm/aspeed.h | 2 ++
25
hw/arm/aspeed.c | 44 ++++++++++++++++++++++++++++++++++++-----
26
2 files changed, 41 insertions(+), 5 deletions(-)
27
28
diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
29
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
30
--- a/include/hw/arm/aspeed.h
20
--- a/hw/misc/mps2-scc.c
31
+++ b/include/hw/arm/aspeed.h
21
+++ b/hw/misc/mps2-scc.c
32
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedBoardState AspeedBoardState;
22
@@ -XXX,XX +XXX,XX @@ static int scc_partno(MPS2SCC *s)
33
23
return extract32(s->id, 4, 8);
34
typedef struct AspeedMachine {
35
MachineState parent_obj;
36
+
37
+ bool mmio_exec;
38
} AspeedMachine;
39
40
#define ASPEED_MACHINE_CLASS(klass) \
41
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/arm/aspeed.c
44
+++ b/hw/arm/aspeed.c
45
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
46
* SoC and 128MB for the AST2500 SoC, which is twice as big as
47
* needed by the flash modules of the Aspeed machines.
48
*/
49
- memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
50
- fl->size, &error_abort);
51
- memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
52
- boot_rom);
53
- write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort);
54
+ if (ASPEED_MACHINE(machine)->mmio_exec) {
55
+ memory_region_init_alias(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
56
+ &fl->mmio, 0, fl->size);
57
+ memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
58
+ boot_rom);
59
+ } else {
60
+ memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
61
+ fl->size, &error_abort);
62
+ memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
63
+ boot_rom);
64
+ write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort);
65
+ }
66
}
67
68
aspeed_board_binfo.ram_size = ram_size;
69
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
70
/* Bus 11: TODO ucd90160@64 */
71
}
24
}
72
25
73
+static bool aspeed_get_mmio_exec(Object *obj, Error **errp)
26
+/* Is CFG_REG2 present? */
27
+static bool have_cfg2(MPS2SCC *s)
74
+{
28
+{
75
+ return ASPEED_MACHINE(obj)->mmio_exec;
29
+ return scc_partno(s) == 0x524 || scc_partno(s) == 0x547;
76
+}
30
+}
77
+
31
+
78
+static void aspeed_set_mmio_exec(Object *obj, bool value, Error **errp)
32
+/* Is CFG_REG3 present? */
33
+static bool have_cfg3(MPS2SCC *s)
79
+{
34
+{
80
+ ASPEED_MACHINE(obj)->mmio_exec = value;
35
+ return scc_partno(s) != 0x524 && scc_partno(s) != 0x547;
81
+}
36
+}
82
+
37
+
83
+static void aspeed_machine_instance_init(Object *obj)
38
+/* Is CFG_REG5 present? */
39
+static bool have_cfg5(MPS2SCC *s)
84
+{
40
+{
85
+ ASPEED_MACHINE(obj)->mmio_exec = false;
41
+ return scc_partno(s) == 0x524 || scc_partno(s) == 0x547;
86
+}
42
+}
87
+
43
+
88
+static void aspeed_machine_class_props_init(ObjectClass *oc)
44
+/* Is CFG_REG6 present? */
45
+static bool have_cfg6(MPS2SCC *s)
89
+{
46
+{
90
+ object_class_property_add_bool(oc, "execute-in-place",
47
+ return scc_partno(s) == 0x524;
91
+ aspeed_get_mmio_exec,
92
+ aspeed_set_mmio_exec, &error_abort);
93
+ object_class_property_set_description(oc, "execute-in-place",
94
+ "boot directly from CE0 flash device", &error_abort);
95
+}
48
+}
96
+
49
+
97
static void aspeed_machine_class_init(ObjectClass *oc, void *data)
50
/* Handle a write via the SYS_CFG channel to the specified function/device.
98
{
51
* Return false on error (reported to guest via SYS_CFGCTRL ERROR bit).
99
MachineClass *mc = MACHINE_CLASS(oc);
52
*/
100
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data)
53
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size)
101
mc->no_floppy = 1;
54
r = s->cfg1;
102
mc->no_cdrom = 1;
55
break;
103
mc->no_parallel = 1;
56
case A_CFG2:
104
+
57
- if (scc_partno(s) != 0x524 && scc_partno(s) != 0x547) {
105
+ aspeed_machine_class_props_init(oc);
58
- /* CFG2 reserved on other boards */
106
}
59
+ if (!have_cfg2(s)) {
107
60
goto bad_offset;
108
static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
61
}
109
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = {
62
r = s->cfg2;
110
.name = TYPE_ASPEED_MACHINE,
63
break;
111
.parent = TYPE_MACHINE,
64
case A_CFG3:
112
.instance_size = sizeof(AspeedMachine),
65
- if (scc_partno(s) == 0x524 || scc_partno(s) == 0x547) {
113
+ .instance_init = aspeed_machine_instance_init,
66
- /* CFG3 reserved on AN524 */
114
.class_size = sizeof(AspeedMachineClass),
67
+ if (!have_cfg3(s)) {
115
.class_init = aspeed_machine_class_init,
68
goto bad_offset;
116
.abstract = true,
69
}
70
/* These are user-settable DIP switches on the board. We don't
71
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size)
72
r = s->cfg4;
73
break;
74
case A_CFG5:
75
- if (scc_partno(s) != 0x524 && scc_partno(s) != 0x547) {
76
- /* CFG5 reserved on other boards */
77
+ if (!have_cfg5(s)) {
78
goto bad_offset;
79
}
80
r = s->cfg5;
81
break;
82
case A_CFG6:
83
- if (scc_partno(s) != 0x524) {
84
- /* CFG6 reserved on other boards */
85
+ if (!have_cfg6(s)) {
86
goto bad_offset;
87
}
88
r = s->cfg6;
89
@@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value,
90
}
91
break;
92
case A_CFG2:
93
- if (scc_partno(s) != 0x524 && scc_partno(s) != 0x547) {
94
- /* CFG2 reserved on other boards */
95
+ if (!have_cfg2(s)) {
96
goto bad_offset;
97
}
98
/* AN524: QSPI Select signal */
99
s->cfg2 = value;
100
break;
101
case A_CFG5:
102
- if (scc_partno(s) != 0x524 && scc_partno(s) != 0x547) {
103
- /* CFG5 reserved on other boards */
104
+ if (!have_cfg5(s)) {
105
goto bad_offset;
106
}
107
/* AN524: ACLK frequency in Hz */
108
s->cfg5 = value;
109
break;
110
case A_CFG6:
111
- if (scc_partno(s) != 0x524) {
112
- /* CFG6 reserved on other boards */
113
+ if (!have_cfg6(s)) {
114
goto bad_offset;
115
}
116
/* AN524: Clock divider for BRAM */
117
--
117
--
118
2.20.1
118
2.34.1
119
119
120
120
diff view generated by jsdifflib
1
The guest can use the semihosting API to open a handle
1
The MPS2 SCC device is broadly the same for all FPGA images, but has
2
corresponding to QEMU's own stdin, stdout, or stderr.
2
minor differences in the behaviour of the CFG registers depending on
3
When the guest closes this handle, we should not
3
the image. In many cases we don't really care about the functionality
4
close the underlying host stdin/stdout/stderr
4
controlled by these registers and a reads-as-written or similar
5
the way we would do if the handle corresponded to
5
behaviour is sufficient for the moment.
6
a host fd we'd opened on behalf of the guest in SYS_OPEN.
6
7
For the AN536 the required behaviour is:
8
9
* A_CFG0 has CPU reset and halt bits
10
- implement as reads-as-written for the moment
11
* A_CFG1 has flash or ATCM address 0 remap handling
12
- QEMU doesn't model this; implement as reads-as-written
13
* A_CFG2 has QSPI select (like AN524)
14
- implemented (no behaviour, as with AN524)
15
* A_CFG3 is MCC_MSB_ADDR "additional MCC addressing bits"
16
- QEMU doesn't care about these, so use the existing
17
RAZ behaviour for convenience
18
* A_CFG4 is board rev (like all other images)
19
- no change needed
20
* A_CFG5 is ACLK frq in hz (like AN524)
21
- implemented as reads-as-written, as for other boards
22
* A_CFG6 is core 0 vector table base address
23
- implemented as reads-as-written for the moment
24
* A_CFG7 is core 1 vector table base address
25
- implemented as reads-as-written for the moment
26
27
Make the changes necessary for this; leave TODO comments where
28
appropriate to indicate where we might want to come back and
29
implement things like CPU reset.
30
31
The other aspects of the device specific to this FPGA image (like the
32
values of the board ID and similar registers) will be set via the
33
device's qdev properties.
7
34
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
36
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
37
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20200124172954.28481-1-peter.maydell@linaro.org
38
Message-id: 20240206132931.38376-8-peter.maydell@linaro.org
12
---
39
---
13
target/arm/arm-semi.c | 9 +++++++++
40
include/hw/misc/mps2-scc.h | 1 +
14
1 file changed, 9 insertions(+)
41
hw/misc/mps2-scc.c | 101 +++++++++++++++++++++++++++++++++----
15
42
2 files changed, 92 insertions(+), 10 deletions(-)
16
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
43
44
diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h
17
index XXXXXXX..XXXXXXX 100644
45
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/arm-semi.c
46
--- a/include/hw/misc/mps2-scc.h
19
+++ b/target/arm/arm-semi.c
47
+++ b/include/hw/misc/mps2-scc.h
20
@@ -XXX,XX +XXX,XX @@ static uint32_t host_closefn(ARMCPU *cpu, GuestFD *gf)
48
@@ -XXX,XX +XXX,XX @@ struct MPS2SCC {
21
{
49
uint32_t cfg4;
22
CPUARMState *env = &cpu->env;
50
uint32_t cfg5;
23
51
uint32_t cfg6;
24
+ /*
52
+ uint32_t cfg7;
25
+ * Only close the underlying host fd if it's one we opened on behalf
53
uint32_t cfgdata_rtn;
26
+ * of the guest in SYS_OPEN.
54
uint32_t cfgdata_out;
27
+ */
55
uint32_t cfgctrl;
28
+ if (gf->hostfd == STDIN_FILENO ||
56
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
29
+ gf->hostfd == STDOUT_FILENO ||
57
index XXXXXXX..XXXXXXX 100644
30
+ gf->hostfd == STDERR_FILENO) {
58
--- a/hw/misc/mps2-scc.c
31
+ return 0;
59
+++ b/hw/misc/mps2-scc.c
60
@@ -XXX,XX +XXX,XX @@ REG32(CFG3, 0xc)
61
REG32(CFG4, 0x10)
62
REG32(CFG5, 0x14)
63
REG32(CFG6, 0x18)
64
+REG32(CFG7, 0x1c)
65
REG32(CFGDATA_RTN, 0xa0)
66
REG32(CFGDATA_OUT, 0xa4)
67
REG32(CFGCTRL, 0xa8)
68
@@ -XXX,XX +XXX,XX @@ static int scc_partno(MPS2SCC *s)
69
/* Is CFG_REG2 present? */
70
static bool have_cfg2(MPS2SCC *s)
71
{
72
- return scc_partno(s) == 0x524 || scc_partno(s) == 0x547;
73
+ return scc_partno(s) == 0x524 || scc_partno(s) == 0x547 ||
74
+ scc_partno(s) == 0x536;
75
}
76
77
/* Is CFG_REG3 present? */
78
static bool have_cfg3(MPS2SCC *s)
79
{
80
- return scc_partno(s) != 0x524 && scc_partno(s) != 0x547;
81
+ return scc_partno(s) != 0x524 && scc_partno(s) != 0x547 &&
82
+ scc_partno(s) != 0x536;
83
}
84
85
/* Is CFG_REG5 present? */
86
static bool have_cfg5(MPS2SCC *s)
87
{
88
- return scc_partno(s) == 0x524 || scc_partno(s) == 0x547;
89
+ return scc_partno(s) == 0x524 || scc_partno(s) == 0x547 ||
90
+ scc_partno(s) == 0x536;
91
}
92
93
/* Is CFG_REG6 present? */
94
static bool have_cfg6(MPS2SCC *s)
95
{
96
- return scc_partno(s) == 0x524;
97
+ return scc_partno(s) == 0x524 || scc_partno(s) == 0x536;
98
+}
99
+
100
+/* Is CFG_REG7 present? */
101
+static bool have_cfg7(MPS2SCC *s)
102
+{
103
+ return scc_partno(s) == 0x536;
104
+}
105
+
106
+/* Does CFG_REG0 drive the 'remap' GPIO output? */
107
+static bool cfg0_is_remap(MPS2SCC *s)
108
+{
109
+ return scc_partno(s) != 0x536;
110
+}
111
+
112
+/* Is CFG_REG1 driving a set of LEDs? */
113
+static bool cfg1_is_leds(MPS2SCC *s)
114
+{
115
+ return scc_partno(s) != 0x536;
116
}
117
118
/* Handle a write via the SYS_CFG channel to the specified function/device.
119
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size)
120
if (!have_cfg3(s)) {
121
goto bad_offset;
122
}
123
- /* These are user-settable DIP switches on the board. We don't
124
+ /*
125
+ * These are user-settable DIP switches on the board. We don't
126
* model that, so just return zeroes.
127
+ *
128
+ * TODO: for AN536 this is MCC_MSB_ADDR "additional MCC addressing
129
+ * bits". These change which part of the DDR4 the motherboard
130
+ * configuration controller can see in its memory map (see the
131
+ * appnote section 2.4). QEMU doesn't model the MCC at all, so these
132
+ * bits are not interesting to us; read-as-zero is as good as anything
133
+ * else.
134
*/
135
r = 0;
136
break;
137
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size)
138
}
139
r = s->cfg6;
140
break;
141
+ case A_CFG7:
142
+ if (!have_cfg7(s)) {
143
+ goto bad_offset;
144
+ }
145
+ r = s->cfg7;
146
+ break;
147
case A_CFGDATA_RTN:
148
r = s->cfgdata_rtn;
149
break;
150
@@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value,
151
* we always reflect bit 0 in the 'remap' GPIO output line,
152
* and let the board wire it up or not as it chooses.
153
* TODO on some boards bit 1 is CPU_WAIT.
154
+ *
155
+ * TODO: on the AN536 this register controls reset and halt
156
+ * for both CPUs. For the moment we don't implement this, so the
157
+ * register just reads as written.
158
*/
159
s->cfg0 = value;
160
- qemu_set_irq(s->remap, s->cfg0 & 1);
161
+ if (cfg0_is_remap(s)) {
162
+ qemu_set_irq(s->remap, s->cfg0 & 1);
163
+ }
164
break;
165
case A_CFG1:
166
s->cfg1 = value;
167
- for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) {
168
- led_set_state(s->led[i], extract32(value, i, 1));
169
+ /*
170
+ * On most boards this register drives LEDs.
171
+ *
172
+ * TODO: for AN536 this controls whether flash and ATCM are
173
+ * enabled or disabled on reset. QEMU doesn't model this, and
174
+ * always wires up RAM in the ATCM area and ROM in the flash area.
175
+ */
176
+ if (cfg1_is_leds(s)) {
177
+ for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) {
178
+ led_set_state(s->led[i], extract32(value, i, 1));
179
+ }
180
}
181
break;
182
case A_CFG2:
183
if (!have_cfg2(s)) {
184
goto bad_offset;
185
}
186
- /* AN524: QSPI Select signal */
187
+ /* AN524, AN536: QSPI Select signal */
188
s->cfg2 = value;
189
break;
190
case A_CFG5:
191
if (!have_cfg5(s)) {
192
goto bad_offset;
193
}
194
- /* AN524: ACLK frequency in Hz */
195
+ /* AN524, AN536: ACLK frequency in Hz */
196
s->cfg5 = value;
197
break;
198
case A_CFG6:
199
@@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value,
200
goto bad_offset;
201
}
202
/* AN524: Clock divider for BRAM */
203
+ /* AN536: Core 0 vector table base address */
204
+ s->cfg6 = value;
205
+ break;
206
+ case A_CFG7:
207
+ if (!have_cfg7(s)) {
208
+ goto bad_offset;
209
+ }
210
+ /* AN536: Core 1 vector table base address */
211
s->cfg6 = value;
212
break;
213
case A_CFGDATA_OUT:
214
@@ -XXX,XX +XXX,XX @@ static void mps2_scc_finalize(Object *obj)
215
g_free(s->oscclk_reset);
216
}
217
218
+static bool cfg7_needed(void *opaque)
219
+{
220
+ MPS2SCC *s = opaque;
221
+
222
+ return have_cfg7(s);
223
+}
224
+
225
+static const VMStateDescription vmstate_cfg7 = {
226
+ .name = "mps2-scc/cfg7",
227
+ .version_id = 1,
228
+ .minimum_version_id = 1,
229
+ .needed = cfg7_needed,
230
+ .fields = (const VMStateField[]) {
231
+ VMSTATE_UINT32(cfg7, MPS2SCC),
232
+ VMSTATE_END_OF_LIST()
32
+ }
233
+ }
33
return set_swi_errno(env, close(gf->hostfd));
234
+};
34
}
235
+
236
static const VMStateDescription mps2_scc_vmstate = {
237
.name = "mps2-scc",
238
.version_id = 3,
239
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription mps2_scc_vmstate = {
240
VMSTATE_VARRAY_UINT32(oscclk, MPS2SCC, num_oscclk,
241
0, vmstate_info_uint32, uint32_t),
242
VMSTATE_END_OF_LIST()
243
+ },
244
+ .subsections = (const VMStateDescription * const []) {
245
+ &vmstate_cfg7,
246
+ NULL
247
}
248
};
35
249
36
--
250
--
37
2.20.1
251
2.34.1
38
252
39
253
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
The AN536 is another FPGA image for the MPS3 development board. Unlike
2
2
the existing FPGA images we already model, this board uses a Cortex-R
3
This commit defines an interface allowing multi-phase reset. This aims
3
family CPU, and it does not use any equivalent to the M-profile
4
to solve a problem of the actual single-phase reset (built in
4
"Subsystem for Embedded" SoC-equivalent that we model in hw/arm/armsse.c.
5
DeviceClass and BusClass): reset behavior is dependent on the order
5
It's therefore more convenient for us to model it as a completely
6
in which reset handlers are called. In particular doing external
6
separate C file.
7
side-effect (like setting an qemu_irq) is problematic because receiving
7
8
object may not be reset yet.
8
This commit adds the basic skeleton of the board model, and the
9
9
code to create all the RAM and ROM. We assume that we're probably
10
The Resettable interface divides the reset in 3 well defined phases.
10
going to want to add more images in future, so use the same
11
To reset an object tree, all 1st phases are executed then all 2nd then
11
base class/subclass setup that mps2-tz.c uses, even though at
12
all 3rd. See the comments in include/hw/resettable.h for a more complete
12
the moment there's only a single subclass.
13
description. The interface defines 3 phases to let the future
13
14
possibility of holding an object into reset for some time.
14
Following commits will add the CPUs and the peripherals.
15
15
16
The qdev/qbus reset in DeviceClass and BusClass will be modified in
17
following commits to use this interface. A mechanism is provided
18
to allow executing a transitional reset handler in place of the 2nd
19
phase which is executed in children-then-parent order inside a tree.
20
This will allow to transition devices and buses smoothly while
21
keeping the exact current qdev/qbus reset behavior for now.
22
23
Documentation will be added in a following commit.
24
25
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
27
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
28
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
29
Message-id: 20200123132823.1117486-4-damien.hedde@greensocs.com
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
18
Message-id: 20240206132931.38376-9-peter.maydell@linaro.org
31
---
19
---
32
hw/core/Makefile.objs | 1 +
20
MAINTAINERS | 3 +-
33
include/hw/resettable.h | 211 +++++++++++++++++++++++++++++++++++
21
configs/devices/arm-softmmu/default.mak | 1 +
34
hw/core/resettable.c | 238 ++++++++++++++++++++++++++++++++++++++++
22
hw/arm/mps3r.c | 239 ++++++++++++++++++++++++
35
hw/core/trace-events | 17 +++
23
hw/arm/Kconfig | 5 +
36
4 files changed, 467 insertions(+)
24
hw/arm/meson.build | 1 +
37
create mode 100644 include/hw/resettable.h
25
5 files changed, 248 insertions(+), 1 deletion(-)
38
create mode 100644 hw/core/resettable.c
26
create mode 100644 hw/arm/mps3r.c
39
27
40
diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
28
diff --git a/MAINTAINERS b/MAINTAINERS
41
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/core/Makefile.objs
30
--- a/MAINTAINERS
43
+++ b/hw/core/Makefile.objs
31
+++ b/MAINTAINERS
44
@@ -XXX,XX +XXX,XX @@
32
@@ -XXX,XX +XXX,XX @@ F: include/hw/misc/imx7_*.h
45
common-obj-y += qdev.o qdev-properties.o
33
F: hw/pci-host/designware.c
46
common-obj-y += bus.o
34
F: include/hw/pci-host/designware.h
47
common-obj-y += cpu.o
35
48
+common-obj-y += resettable.o
36
-MPS2
49
common-obj-y += hotplug.o
37
+MPS2 / MPS3
50
common-obj-y += vmstate-if.o
38
M: Peter Maydell <peter.maydell@linaro.org>
51
# irq.o needed for qdev GPIO handling:
39
L: qemu-arm@nongnu.org
52
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
40
S: Maintained
41
F: hw/arm/mps2.c
42
F: hw/arm/mps2-tz.c
43
+F: hw/arm/mps3r.c
44
F: hw/misc/mps2-*.c
45
F: include/hw/misc/mps2-*.h
46
F: hw/arm/armsse.c
47
diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak
48
index XXXXXXX..XXXXXXX 100644
49
--- a/configs/devices/arm-softmmu/default.mak
50
+++ b/configs/devices/arm-softmmu/default.mak
51
@@ -XXX,XX +XXX,XX @@ CONFIG_ARM_VIRT=y
52
# CONFIG_INTEGRATOR=n
53
# CONFIG_FSL_IMX31=n
54
# CONFIG_MUSICPAL=n
55
+# CONFIG_MPS3R=n
56
# CONFIG_MUSCA=n
57
# CONFIG_CHEETAH=n
58
# CONFIG_SX1=n
59
diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c
53
new file mode 100644
60
new file mode 100644
54
index XXXXXXX..XXXXXXX
61
index XXXXXXX..XXXXXXX
55
--- /dev/null
62
--- /dev/null
56
+++ b/include/hw/resettable.h
63
+++ b/hw/arm/mps3r.c
57
@@ -XXX,XX +XXX,XX @@
64
@@ -XXX,XX +XXX,XX @@
58
+/*
65
+/*
59
+ * Resettable interface header.
66
+ * Arm MPS3 board emulation for Cortex-R-based FPGA images.
67
+ * (For M-profile images see mps2.c and mps2tz.c.)
60
+ *
68
+ *
61
+ * Copyright (c) 2019 GreenSocs SAS
69
+ * Copyright (c) 2017 Linaro Limited
70
+ * Written by Peter Maydell
62
+ *
71
+ *
63
+ * Authors:
72
+ * This program is free software; you can redistribute it and/or modify
64
+ * Damien Hedde
73
+ * it under the terms of the GNU General Public License version 2 or
74
+ * (at your option) any later version.
75
+ */
76
+
77
+/*
78
+ * The MPS3 is an FPGA based dev board. This file handles FPGA images
79
+ * which use the Cortex-R CPUs. We model these separately from the
80
+ * M-profile images, because on M-profile the FPGA image is based on
81
+ * a "Subsystem for Embedded" which is similar to an SoC, whereas
82
+ * the R-profile FPGA images don't have that abstraction layer.
65
+ *
83
+ *
66
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
84
+ * We model the following FPGA images here:
67
+ * See the COPYING file in the top-level directory.
85
+ * "mps3-an536" -- dual Cortex-R52 as documented in Arm Application Note AN536
86
+ *
87
+ * Application Note AN536:
88
+ * https://developer.arm.com/documentation/dai0536/latest/
68
+ */
89
+ */
69
+
90
+
70
+#ifndef HW_RESETTABLE_H
91
+#include "qemu/osdep.h"
71
+#define HW_RESETTABLE_H
92
+#include "qemu/units.h"
72
+
93
+#include "qapi/error.h"
73
+#include "qom/object.h"
94
+#include "exec/address-spaces.h"
74
+
95
+#include "cpu.h"
75
+#define TYPE_RESETTABLE_INTERFACE "resettable"
96
+#include "hw/boards.h"
76
+
97
+#include "hw/arm/boot.h"
77
+#define RESETTABLE_CLASS(class) \
98
+
78
+ OBJECT_CLASS_CHECK(ResettableClass, (class), TYPE_RESETTABLE_INTERFACE)
99
+/* Define the layout of RAM and ROM in a board */
79
+
100
+typedef struct RAMInfo {
80
+#define RESETTABLE_GET_CLASS(obj) \
101
+ const char *name;
81
+ OBJECT_GET_CLASS(ResettableClass, (obj), TYPE_RESETTABLE_INTERFACE)
102
+ hwaddr base;
82
+
103
+ hwaddr size;
83
+typedef struct ResettableState ResettableState;
104
+ int mrindex; /* index into rams[]; -1 for the system RAM block */
84
+
105
+ int flags;
85
+/**
106
+} RAMInfo;
86
+ * ResetType:
107
+
87
+ * Types of reset.
108
+/*
88
+ *
109
+ * The MPS3 DDR is 3GiB, but on a 32-bit host QEMU doesn't permit
89
+ * + Cold: reset resulting from a power cycle of the object.
110
+ * emulation of that much guest RAM, so artificially make it smaller.
90
+ *
91
+ * TODO: Support has to be added to handle more types. In particular,
92
+ * ResettableState structure needs to be expanded.
93
+ */
111
+ */
94
+typedef enum ResetType {
112
+#if HOST_LONG_BITS == 32
95
+ RESET_TYPE_COLD,
113
+#define MPS3_DDR_SIZE (1 * GiB)
96
+} ResetType;
114
+#else
115
+#define MPS3_DDR_SIZE (3 * GiB)
116
+#endif
97
+
117
+
98
+/*
118
+/*
99
+ * ResettableClass:
119
+ * Flag values:
100
+ * Interface for resettable objects.
120
+ * IS_MAIN: this is the main machine RAM
101
+ *
121
+ * IS_ROM: this area is read-only
102
+ * See docs/devel/reset.rst for more detailed information about how QEMU models
103
+ * reset. This whole API must only be used when holding the iothread mutex.
104
+ *
105
+ * All objects which can be reset must implement this interface;
106
+ * it is usually provided by a base class such as DeviceClass or BusClass.
107
+ * Every Resettable object must maintain some state tracking the
108
+ * progress of a reset operation by providing a ResettableState structure.
109
+ * The functions defined in this module take care of updating the
110
+ * state of the reset.
111
+ * The base class implementation of the interface provides this
112
+ * state and implements the associated method: get_state.
113
+ *
114
+ * Concrete object implementations (typically specific devices
115
+ * such as a UART model) should provide the functions
116
+ * for the phases.enter, phases.hold and phases.exit methods, which
117
+ * they can set in their class init function, either directly or
118
+ * by calling resettable_class_set_parent_phases().
119
+ * The phase methods are guaranteed to only only ever be called once
120
+ * for any reset event, in the order 'enter', 'hold', 'exit'.
121
+ * An object will always move quickly from 'enter' to 'hold'
122
+ * but might remain in 'hold' for an arbitrary period of time
123
+ * before eventually reset is deasserted and the 'exit' phase is called.
124
+ * Object implementations should be prepared for functions handling
125
+ * inbound connections from other devices (such as qemu_irq handler
126
+ * functions) to be called at any point during reset after their
127
+ * 'enter' method has been called.
128
+ *
129
+ * Users of a resettable object should not call these methods
130
+ * directly, but instead use the function resettable_reset().
131
+ *
132
+ * @phases.enter: This phase is called when the object enters reset. It
133
+ * should reset local state of the object, but it must not do anything that
134
+ * has a side-effect on other objects, such as raising or lowering a qemu_irq
135
+ * line or reading or writing guest memory. It takes the reset's type as
136
+ * argument.
137
+ *
138
+ * @phases.hold: This phase is called for entry into reset, once every object
139
+ * in the system which is being reset has had its @phases.enter method called.
140
+ * At this point devices can do actions that affect other objects.
141
+ *
142
+ * @phases.exit: This phase is called when the object leaves the reset state.
143
+ * Actions affecting other objects are permitted.
144
+ *
145
+ * @get_state: Mandatory method which must return a pointer to a
146
+ * ResettableState.
147
+ *
148
+ * @get_transitional_function: transitional method to handle Resettable objects
149
+ * not yet fully moved to this interface. It will be removed as soon as it is
150
+ * not needed anymore. This method is optional and may return a pointer to a
151
+ * function to be used instead of the phases. If the method exists and returns
152
+ * a non-NULL function pointer then that function is executed as a replacement
153
+ * of the 'hold' phase method taking the object as argument. The two other phase
154
+ * methods are not executed.
155
+ *
156
+ * @child_foreach: Executes a given callback on every Resettable child. Child
157
+ * in this context means a child in the qbus tree, so the children of a qbus
158
+ * are the devices on it, and the children of a device are all the buses it
159
+ * owns. This is not the same as the QOM object hierarchy. The function takes
160
+ * additional opaque and ResetType arguments which must be passed unmodified to
161
+ * the callback.
162
+ */
122
+ */
163
+typedef void (*ResettableEnterPhase)(Object *obj, ResetType type);
123
+#define IS_MAIN 1
164
+typedef void (*ResettableHoldPhase)(Object *obj);
124
+#define IS_ROM 2
165
+typedef void (*ResettableExitPhase)(Object *obj);
125
+
166
+typedef ResettableState * (*ResettableGetState)(Object *obj);
126
+#define MPS3R_RAM_MAX 9
167
+typedef void (*ResettableTrFunction)(Object *obj);
127
+
168
+typedef ResettableTrFunction (*ResettableGetTrFunction)(Object *obj);
128
+typedef enum MPS3RFPGAType {
169
+typedef void (*ResettableChildCallback)(Object *, void *opaque,
129
+ FPGA_AN536,
170
+ ResetType type);
130
+} MPS3RFPGAType;
171
+typedef void (*ResettableChildForeach)(Object *obj,
131
+
172
+ ResettableChildCallback cb,
132
+struct MPS3RMachineClass {
173
+ void *opaque, ResetType type);
133
+ MachineClass parent;
174
+typedef struct ResettablePhases {
134
+ MPS3RFPGAType fpga_type;
175
+ ResettableEnterPhase enter;
135
+ const RAMInfo *raminfo;
176
+ ResettableHoldPhase hold;
177
+ ResettableExitPhase exit;
178
+} ResettablePhases;
179
+typedef struct ResettableClass {
180
+ InterfaceClass parent_class;
181
+
182
+ /* Phase methods */
183
+ ResettablePhases phases;
184
+
185
+ /* State access method */
186
+ ResettableGetState get_state;
187
+
188
+ /* Transitional method for legacy reset compatibility */
189
+ ResettableGetTrFunction get_transitional_function;
190
+
191
+ /* Hierarchy handling method */
192
+ ResettableChildForeach child_foreach;
193
+} ResettableClass;
194
+
195
+/**
196
+ * ResettableState:
197
+ * Structure holding reset related state. The fields should not be accessed
198
+ * directly; the definition is here to allow further inclusion into other
199
+ * objects.
200
+ *
201
+ * @count: Number of reset level the object is into. It is incremented when
202
+ * the reset operation starts and decremented when it finishes.
203
+ * @hold_phase_pending: flag which indicates that we need to invoke the 'hold'
204
+ * phase handler for this object.
205
+ * @exit_phase_in_progress: true if we are currently in the exit phase
206
+ */
207
+struct ResettableState {
208
+ unsigned count;
209
+ bool hold_phase_pending;
210
+ bool exit_phase_in_progress;
211
+};
136
+};
212
+
137
+
213
+/**
138
+struct MPS3RMachineState {
214
+ * resettable_reset:
139
+ MachineState parent;
215
+ * Trigger a reset on an object @obj of type @type. @obj must implement
140
+ MemoryRegion ram[MPS3R_RAM_MAX];
216
+ * Resettable interface.
141
+};
217
+ *
142
+
218
+ * Calling this function is equivalent to calling @resettable_assert_reset()
143
+#define TYPE_MPS3R_MACHINE "mps3r"
219
+ * then @resettable_release_reset().
144
+#define TYPE_MPS3R_AN536_MACHINE MACHINE_TYPE_NAME("mps3-an536")
220
+ */
145
+
221
+void resettable_reset(Object *obj, ResetType type);
146
+OBJECT_DECLARE_TYPE(MPS3RMachineState, MPS3RMachineClass, MPS3R_MACHINE)
222
+
147
+
223
+/**
148
+static const RAMInfo an536_raminfo[] = {
224
+ * resettable_assert_reset:
149
+ {
225
+ * Put an object @obj into reset. @obj must implement Resettable interface.
150
+ .name = "ATCM",
226
+ *
151
+ .base = 0x00000000,
227
+ * @resettable_release_reset() must eventually be called after this call.
152
+ .size = 0x00008000,
228
+ * There must be one call to @resettable_release_reset() per call of
153
+ .mrindex = 0,
229
+ * @resettable_assert_reset(), with the same type argument.
154
+ }, {
230
+ *
155
+ /* We model the QSPI flash as simple ROM for now */
231
+ * NOTE: Until support for migration is added, the @resettable_release_reset()
156
+ .name = "QSPI",
232
+ * must not be delayed. It must occur just after @resettable_assert_reset() so
157
+ .base = 0x08000000,
233
+ * that migration cannot be triggered in between. Prefer using
158
+ .size = 0x00800000,
234
+ * @resettable_reset() for now.
159
+ .flags = IS_ROM,
235
+ */
160
+ .mrindex = 1,
236
+void resettable_assert_reset(Object *obj, ResetType type);
161
+ }, {
237
+
162
+ .name = "BRAM",
238
+/**
163
+ .base = 0x10000000,
239
+ * resettable_release_reset:
164
+ .size = 0x00080000,
240
+ * Release the object @obj from reset. @obj must implement Resettable interface.
165
+ .mrindex = 2,
241
+ *
166
+ }, {
242
+ * See @resettable_assert_reset() description for details.
167
+ .name = "DDR",
243
+ */
168
+ .base = 0x20000000,
244
+void resettable_release_reset(Object *obj, ResetType type);
169
+ .size = MPS3_DDR_SIZE,
245
+
170
+ .mrindex = -1,
246
+/**
171
+ }, {
247
+ * resettable_is_in_reset:
172
+ .name = "ATCM0",
248
+ * Return true if @obj is under reset.
173
+ .base = 0xee000000,
249
+ *
174
+ .size = 0x00008000,
250
+ * @obj must implement Resettable interface.
175
+ .mrindex = 3,
251
+ */
176
+ }, {
252
+bool resettable_is_in_reset(Object *obj);
177
+ .name = "BTCM0",
253
+
178
+ .base = 0xee100000,
254
+/**
179
+ .size = 0x00008000,
255
+ * resettable_class_set_parent_phases:
180
+ .mrindex = 4,
256
+ *
181
+ }, {
257
+ * Save @rc current reset phases into @parent_phases and override @rc phases
182
+ .name = "CTCM0",
258
+ * by the given new methods (@enter, @hold and @exit).
183
+ .base = 0xee200000,
259
+ * Each phase is overridden only if the new one is not NULL allowing to
184
+ .size = 0x00008000,
260
+ * override a subset of phases.
185
+ .mrindex = 5,
261
+ */
186
+ }, {
262
+void resettable_class_set_parent_phases(ResettableClass *rc,
187
+ .name = "ATCM1",
263
+ ResettableEnterPhase enter,
188
+ .base = 0xee400000,
264
+ ResettableHoldPhase hold,
189
+ .size = 0x00008000,
265
+ ResettableExitPhase exit,
190
+ .mrindex = 6,
266
+ ResettablePhases *parent_phases);
191
+ }, {
267
+
192
+ .name = "BTCM1",
268
+#endif
193
+ .base = 0xee500000,
269
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
194
+ .size = 0x00008000,
270
new file mode 100644
195
+ .mrindex = 7,
271
index XXXXXXX..XXXXXXX
196
+ }, {
272
--- /dev/null
197
+ .name = "CTCM1",
273
+++ b/hw/core/resettable.c
198
+ .base = 0xee600000,
274
@@ -XXX,XX +XXX,XX @@
199
+ .size = 0x00008000,
275
+/*
200
+ .mrindex = 8,
276
+ * Resettable interface.
201
+ }, {
277
+ *
202
+ .name = NULL,
278
+ * Copyright (c) 2019 GreenSocs SAS
203
+ }
279
+ *
204
+};
280
+ * Authors:
205
+
281
+ * Damien Hedde
206
+static MemoryRegion *mr_for_raminfo(MPS3RMachineState *mms,
282
+ *
207
+ const RAMInfo *raminfo)
283
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
208
+{
284
+ * See the COPYING file in the top-level directory.
209
+ /* Return an initialized MemoryRegion for the RAMInfo. */
285
+ */
210
+ MemoryRegion *ram;
286
+
211
+
287
+#include "qemu/osdep.h"
212
+ if (raminfo->mrindex < 0) {
288
+#include "qemu/module.h"
213
+ /* Means this RAMInfo is for QEMU's "system memory" */
289
+#include "hw/resettable.h"
214
+ MachineState *machine = MACHINE(mms);
290
+#include "trace.h"
215
+ assert(!(raminfo->flags & IS_ROM));
291
+
216
+ return machine->ram;
292
+/**
217
+ }
293
+ * resettable_phase_enter/hold/exit:
218
+
294
+ * Function executing a phase recursively in a resettable object and its
219
+ assert(raminfo->mrindex < MPS3R_RAM_MAX);
295
+ * children.
220
+ ram = &mms->ram[raminfo->mrindex];
296
+ */
221
+
297
+static void resettable_phase_enter(Object *obj, void *opaque, ResetType type);
222
+ memory_region_init_ram(ram, NULL, raminfo->name,
298
+static void resettable_phase_hold(Object *obj, void *opaque, ResetType type);
223
+ raminfo->size, &error_fatal);
299
+static void resettable_phase_exit(Object *obj, void *opaque, ResetType type);
224
+ if (raminfo->flags & IS_ROM) {
300
+
225
+ memory_region_set_readonly(ram, true);
301
+/**
226
+ }
302
+ * enter_phase_in_progress:
227
+ return ram;
303
+ * True if we are currently in reset enter phase.
228
+}
304
+ *
229
+
305
+ * Note: This flag is only used to guarantee (using asserts) that the reset
230
+static void mps3r_common_init(MachineState *machine)
306
+ * API is used correctly. We can use a global variable because we rely on the
231
+{
307
+ * iothread mutex to ensure only one reset operation is in a progress at a
232
+ MPS3RMachineState *mms = MPS3R_MACHINE(machine);
308
+ * given time.
233
+ MPS3RMachineClass *mmc = MPS3R_MACHINE_GET_CLASS(mms);
309
+ */
234
+ MemoryRegion *sysmem = get_system_memory();
310
+static bool enter_phase_in_progress;
235
+
311
+
236
+ for (const RAMInfo *ri = mmc->raminfo; ri->name; ri++) {
312
+void resettable_reset(Object *obj, ResetType type)
237
+ MemoryRegion *mr = mr_for_raminfo(mms, ri);
313
+{
238
+ memory_region_add_subregion(sysmem, ri->base, mr);
314
+ trace_resettable_reset(obj, type);
239
+ }
315
+ resettable_assert_reset(obj, type);
240
+}
316
+ resettable_release_reset(obj, type);
241
+
317
+}
242
+static void mps3r_set_default_ram_info(MPS3RMachineClass *mmc)
318
+
243
+{
319
+void resettable_assert_reset(Object *obj, ResetType type)
320
+{
321
+ /* TODO: change this assert when adding support for other reset types */
322
+ assert(type == RESET_TYPE_COLD);
323
+ trace_resettable_reset_assert_begin(obj, type);
324
+ assert(!enter_phase_in_progress);
325
+
326
+ enter_phase_in_progress = true;
327
+ resettable_phase_enter(obj, NULL, type);
328
+ enter_phase_in_progress = false;
329
+
330
+ resettable_phase_hold(obj, NULL, type);
331
+
332
+ trace_resettable_reset_assert_end(obj);
333
+}
334
+
335
+void resettable_release_reset(Object *obj, ResetType type)
336
+{
337
+ /* TODO: change this assert when adding support for other reset types */
338
+ assert(type == RESET_TYPE_COLD);
339
+ trace_resettable_reset_release_begin(obj, type);
340
+ assert(!enter_phase_in_progress);
341
+
342
+ resettable_phase_exit(obj, NULL, type);
343
+
344
+ trace_resettable_reset_release_end(obj);
345
+}
346
+
347
+bool resettable_is_in_reset(Object *obj)
348
+{
349
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
350
+ ResettableState *s = rc->get_state(obj);
351
+
352
+ return s->count > 0;
353
+}
354
+
355
+/**
356
+ * resettable_child_foreach:
357
+ * helper to avoid checking the existence of the method.
358
+ */
359
+static void resettable_child_foreach(ResettableClass *rc, Object *obj,
360
+ ResettableChildCallback cb,
361
+ void *opaque, ResetType type)
362
+{
363
+ if (rc->child_foreach) {
364
+ rc->child_foreach(obj, cb, opaque, type);
365
+ }
366
+}
367
+
368
+/**
369
+ * resettable_get_tr_func:
370
+ * helper to fetch transitional reset callback if any.
371
+ */
372
+static ResettableTrFunction resettable_get_tr_func(ResettableClass *rc,
373
+ Object *obj)
374
+{
375
+ ResettableTrFunction tr_func = NULL;
376
+ if (rc->get_transitional_function) {
377
+ tr_func = rc->get_transitional_function(obj);
378
+ }
379
+ return tr_func;
380
+}
381
+
382
+static void resettable_phase_enter(Object *obj, void *opaque, ResetType type)
383
+{
384
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
385
+ ResettableState *s = rc->get_state(obj);
386
+ const char *obj_typename = object_get_typename(obj);
387
+ bool action_needed = false;
388
+
389
+ /* exit phase has to finish properly before entering back in reset */
390
+ assert(!s->exit_phase_in_progress);
391
+
392
+ trace_resettable_phase_enter_begin(obj, obj_typename, s->count, type);
393
+
394
+ /* Only take action if we really enter reset for the 1st time. */
395
+ /*
244
+ /*
396
+ * TODO: if adding more ResetType support, some additional checks
245
+ * Set mc->default_ram_size and default_ram_id from the
397
+ * are probably needed here.
246
+ * information in mmc->raminfo.
398
+ */
247
+ */
399
+ if (s->count++ == 0) {
248
+ MachineClass *mc = MACHINE_CLASS(mmc);
400
+ action_needed = true;
249
+ const RAMInfo *p;
401
+ }
250
+
402
+ /*
251
+ for (p = mmc->raminfo; p->name; p++) {
403
+ * We limit the count to an arbitrary "big" value. The value is big
252
+ if (p->mrindex < 0) {
404
+ * enough not to be triggered normally.
253
+ /* Found the entry for "system memory" */
405
+ * The assert will stop an infinite loop if there is a cycle in the
254
+ mc->default_ram_size = p->size;
406
+ * reset tree. The loop goes through resettable_foreach_child below
255
+ mc->default_ram_id = p->name;
407
+ * which at some point will call us again.
256
+ return;
408
+ */
409
+ assert(s->count <= 50);
410
+
411
+ /*
412
+ * handle the children even if action_needed is at false so that
413
+ * child counts are incremented too
414
+ */
415
+ resettable_child_foreach(rc, obj, resettable_phase_enter, NULL, type);
416
+
417
+ /* execute enter phase for the object if needed */
418
+ if (action_needed) {
419
+ trace_resettable_phase_enter_exec(obj, obj_typename, type,
420
+ !!rc->phases.enter);
421
+ if (rc->phases.enter && !resettable_get_tr_func(rc, obj)) {
422
+ rc->phases.enter(obj, type);
423
+ }
257
+ }
424
+ s->hold_phase_pending = true;
258
+ }
425
+ }
259
+ g_assert_not_reached();
426
+ trace_resettable_phase_enter_end(obj, obj_typename, s->count);
260
+}
427
+}
261
+
428
+
262
+static void mps3r_class_init(ObjectClass *oc, void *data)
429
+static void resettable_phase_hold(Object *obj, void *opaque, ResetType type)
263
+{
430
+{
264
+ MachineClass *mc = MACHINE_CLASS(oc);
431
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
265
+
432
+ ResettableState *s = rc->get_state(obj);
266
+ mc->init = mps3r_common_init;
433
+ const char *obj_typename = object_get_typename(obj);
267
+}
434
+
268
+
435
+ /* exit phase has to finish properly before entering back in reset */
269
+static void mps3r_an536_class_init(ObjectClass *oc, void *data)
436
+ assert(!s->exit_phase_in_progress);
270
+{
437
+
271
+ MachineClass *mc = MACHINE_CLASS(oc);
438
+ trace_resettable_phase_hold_begin(obj, obj_typename, s->count, type);
272
+ MPS3RMachineClass *mmc = MPS3R_MACHINE_CLASS(oc);
439
+
273
+ static const char * const valid_cpu_types[] = {
440
+ /* handle children first */
274
+ ARM_CPU_TYPE_NAME("cortex-r52"),
441
+ resettable_child_foreach(rc, obj, resettable_phase_hold, NULL, type);
275
+ NULL
442
+
276
+ };
443
+ /* exec hold phase */
277
+
444
+ if (s->hold_phase_pending) {
278
+ mc->desc = "ARM MPS3 with AN536 FPGA image for Cortex-R52";
445
+ s->hold_phase_pending = false;
279
+ mc->default_cpus = 2;
446
+ ResettableTrFunction tr_func = resettable_get_tr_func(rc, obj);
280
+ mc->min_cpus = mc->default_cpus;
447
+ trace_resettable_phase_hold_exec(obj, obj_typename, !!rc->phases.hold);
281
+ mc->max_cpus = mc->default_cpus;
448
+ if (tr_func) {
282
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-r52");
449
+ trace_resettable_transitional_function(obj, obj_typename);
283
+ mc->valid_cpu_types = valid_cpu_types;
450
+ tr_func(obj);
284
+ mmc->raminfo = an536_raminfo;
451
+ } else if (rc->phases.hold) {
285
+ mps3r_set_default_ram_info(mmc);
452
+ rc->phases.hold(obj);
286
+}
453
+ }
287
+
454
+ }
288
+static const TypeInfo mps3r_machine_types[] = {
455
+ trace_resettable_phase_hold_end(obj, obj_typename, s->count);
289
+ {
456
+}
290
+ .name = TYPE_MPS3R_MACHINE,
457
+
291
+ .parent = TYPE_MACHINE,
458
+static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
292
+ .abstract = true,
459
+{
293
+ .instance_size = sizeof(MPS3RMachineState),
460
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
294
+ .class_size = sizeof(MPS3RMachineClass),
461
+ ResettableState *s = rc->get_state(obj);
295
+ .class_init = mps3r_class_init,
462
+ const char *obj_typename = object_get_typename(obj);
296
+ }, {
463
+
297
+ .name = TYPE_MPS3R_AN536_MACHINE,
464
+ assert(!s->exit_phase_in_progress);
298
+ .parent = TYPE_MPS3R_MACHINE,
465
+ trace_resettable_phase_exit_begin(obj, obj_typename, s->count, type);
299
+ .class_init = mps3r_an536_class_init,
466
+
300
+ },
467
+ /* exit_phase_in_progress ensures this phase is 'atomic' */
468
+ s->exit_phase_in_progress = true;
469
+ resettable_child_foreach(rc, obj, resettable_phase_exit, NULL, type);
470
+
471
+ assert(s->count > 0);
472
+ if (s->count == 1) {
473
+ trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
474
+ if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
475
+ rc->phases.exit(obj);
476
+ }
477
+ s->count = 0;
478
+ }
479
+ s->exit_phase_in_progress = false;
480
+ trace_resettable_phase_exit_end(obj, obj_typename, s->count);
481
+}
482
+
483
+void resettable_class_set_parent_phases(ResettableClass *rc,
484
+ ResettableEnterPhase enter,
485
+ ResettableHoldPhase hold,
486
+ ResettableExitPhase exit,
487
+ ResettablePhases *parent_phases)
488
+{
489
+ *parent_phases = rc->phases;
490
+ if (enter) {
491
+ rc->phases.enter = enter;
492
+ }
493
+ if (hold) {
494
+ rc->phases.hold = hold;
495
+ }
496
+ if (exit) {
497
+ rc->phases.exit = exit;
498
+ }
499
+}
500
+
501
+static const TypeInfo resettable_interface_info = {
502
+ .name = TYPE_RESETTABLE_INTERFACE,
503
+ .parent = TYPE_INTERFACE,
504
+ .class_size = sizeof(ResettableClass),
505
+};
301
+};
506
+
302
+
507
+static void reset_register_types(void)
303
+DEFINE_TYPES(mps3r_machine_types);
508
+{
304
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
509
+ type_register_static(&resettable_interface_info);
510
+}
511
+
512
+type_init(reset_register_types)
513
diff --git a/hw/core/trace-events b/hw/core/trace-events
514
index XXXXXXX..XXXXXXX 100644
305
index XXXXXXX..XXXXXXX 100644
515
--- a/hw/core/trace-events
306
--- a/hw/arm/Kconfig
516
+++ b/hw/core/trace-events
307
+++ b/hw/arm/Kconfig
517
@@ -XXX,XX +XXX,XX @@ qbus_reset(void *obj, const char *objtype) "obj=%p(%s)"
308
@@ -XXX,XX +XXX,XX @@ config MAINSTONE
518
qbus_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
309
select PFLASH_CFI01
519
qbus_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
310
select SMC91C111
520
qdev_update_parent_bus(void *obj, const char *objtype, void *oldp, const char *oldptype, void *newp, const char *newptype) "obj=%p(%s) old_parent=%p(%s) new_parent=%p(%s)"
311
521
+
312
+config MPS3R
522
+# resettable.c
313
+ bool
523
+resettable_reset(void *obj, int cold) "obj=%p cold=%d"
314
+ default y
524
+resettable_reset_assert_begin(void *obj, int cold) "obj=%p cold=%d"
315
+ depends on TCG && ARM
525
+resettable_reset_assert_end(void *obj) "obj=%p"
316
+
526
+resettable_reset_release_begin(void *obj, int cold) "obj=%p cold=%d"
317
config MUSCA
527
+resettable_reset_release_end(void *obj) "obj=%p"
318
bool
528
+resettable_phase_enter_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
319
default y
529
+resettable_phase_enter_exec(void *obj, const char *objtype, int type, int has_method) "obj=%p(%s) type=%d method=%d"
320
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
530
+resettable_phase_enter_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
321
index XXXXXXX..XXXXXXX 100644
531
+resettable_phase_hold_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
322
--- a/hw/arm/meson.build
532
+resettable_phase_hold_exec(void *obj, const char *objtype, int has_method) "obj=%p(%s) method=%d"
323
+++ b/hw/arm/meson.build
533
+resettable_phase_hold_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
324
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c'))
534
+resettable_phase_exit_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
325
arm_ss.add(when: 'CONFIG_INTEGRATOR', if_true: files('integratorcp.c'))
535
+resettable_phase_exit_exec(void *obj, const char *objtype, int has_method) "obj=%p(%s) method=%d"
326
arm_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mainstone.c'))
536
+resettable_phase_exit_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
327
arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c'))
537
+resettable_transitional_function(void *obj, const char *objtype) "obj=%p(%s)"
328
+arm_ss.add(when: 'CONFIG_MPS3R', if_true: files('mps3r.c'))
329
arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c'))
330
arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c'))
331
arm_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c'))
538
--
332
--
539
2.20.1
333
2.34.1
540
334
541
335
diff view generated by jsdifflib
1
From: Joel Stanley <joel@jms.id.au>
1
Create the CPUs, the GIC, and the per-CPU RAM block for
2
the mps3-an536 board.
2
3
3
Following the pattern of the work recently done with the ASPEED GPIO
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
model, this adds support for inspecting and modifying the PCA9552 LEDs
5
Message-id: 20240206132931.38376-10-peter.maydell@linaro.org
5
from the monitor.
6
---
7
hw/arm/mps3r.c | 180 ++++++++++++++++++++++++++++++++++++++++++++++++-
8
1 file changed, 177 insertions(+), 3 deletions(-)
6
9
7
(qemu) qom-set /machine/unattached/device[17] led0 on
10
diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c
8
(qemu) qom-set /machine/unattached/device[17] led0 off
9
(qemu) qom-set /machine/unattached/device[17] led0 pwm0
10
(qemu) qom-set /machine/unattached/device[17] led0 pwm1
11
12
Signed-off-by: Joel Stanley <joel@jms.id.au>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
Message-id: 20200114103433.30534-6-clg@kaod.org
15
[clg: - removed the "qom-get" examples from the commit log
16
- merged memory leak fixes from Joel ]
17
Signed-off-by: Cédric Le Goater <clg@kaod.org>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
hw/misc/pca9552.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++
22
1 file changed, 90 insertions(+)
23
24
diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c
25
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/misc/pca9552.c
12
--- a/hw/arm/mps3r.c
27
+++ b/hw/misc/pca9552.c
13
+++ b/hw/arm/mps3r.c
28
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@
29
#include "hw/misc/pca9552.h"
15
#include "qemu/osdep.h"
30
#include "hw/misc/pca9552_regs.h"
16
#include "qemu/units.h"
31
#include "migration/vmstate.h"
17
#include "qapi/error.h"
32
+#include "qapi/error.h"
18
+#include "qapi/qmp/qlist.h"
33
+#include "qapi/visitor.h"
19
#include "exec/address-spaces.h"
34
20
#include "cpu.h"
35
#define PCA9552_LED_ON 0x0
21
#include "hw/boards.h"
36
#define PCA9552_LED_OFF 0x1
22
+#include "hw/qdev-properties.h"
37
#define PCA9552_LED_PWM0 0x2
23
#include "hw/arm/boot.h"
38
#define PCA9552_LED_PWM1 0x3
24
+#include "hw/arm/bsa.h"
39
25
+#include "hw/intc/arm_gicv3.h"
40
+static const char *led_state[] = {"on", "off", "pwm0", "pwm1"};
26
41
+
27
/* Define the layout of RAM and ROM in a board */
42
static uint8_t pca9552_pin_get_config(PCA9552State *s, int pin)
28
typedef struct RAMInfo {
43
{
29
@@ -XXX,XX +XXX,XX @@ typedef struct RAMInfo {
44
uint8_t reg = PCA9552_LS0 + (pin / 4);
30
#define IS_ROM 2
45
@@ -XXX,XX +XXX,XX @@ static int pca9552_event(I2CSlave *i2c, enum i2c_event event)
31
46
return 0;
32
#define MPS3R_RAM_MAX 9
33
+#define MPS3R_CPU_MAX 2
34
+
35
+#define PERIPHBASE 0xf0000000
36
+#define NUM_SPIS 96
37
38
typedef enum MPS3RFPGAType {
39
FPGA_AN536,
40
@@ -XXX,XX +XXX,XX @@ struct MPS3RMachineClass {
41
MachineClass parent;
42
MPS3RFPGAType fpga_type;
43
const RAMInfo *raminfo;
44
+ hwaddr loader_start;
45
};
46
47
struct MPS3RMachineState {
48
MachineState parent;
49
+ struct arm_boot_info bootinfo;
50
MemoryRegion ram[MPS3R_RAM_MAX];
51
+ Object *cpu[MPS3R_CPU_MAX];
52
+ MemoryRegion cpu_sysmem[MPS3R_CPU_MAX];
53
+ MemoryRegion sysmem_alias[MPS3R_CPU_MAX];
54
+ MemoryRegion cpu_ram[MPS3R_CPU_MAX];
55
+ GICv3State gic;
56
};
57
58
#define TYPE_MPS3R_MACHINE "mps3r"
59
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *mr_for_raminfo(MPS3RMachineState *mms,
60
return ram;
47
}
61
}
48
62
49
+static void pca9552_get_led(Object *obj, Visitor *v, const char *name,
63
+/*
50
+ void *opaque, Error **errp)
64
+ * There is no defined secondary boot protocol for Linux for the AN536,
65
+ * because real hardware has a restriction that atomic operations between
66
+ * the two CPUs do not function correctly, and so true SMP is not
67
+ * possible. Therefore for cases where the user is directly booting
68
+ * a kernel, we treat the system as essentially uniprocessor, and
69
+ * put the secondary CPU into power-off state (as if the user on the
70
+ * real hardware had configured the secondary to be halted via the
71
+ * SCC config registers).
72
+ *
73
+ * Note that the default secondary boot code would not work here anyway
74
+ * as it assumes a GICv2, and we have a GICv3.
75
+ */
76
+static void mps3r_write_secondary_boot(ARMCPU *cpu,
77
+ const struct arm_boot_info *info)
51
+{
78
+{
52
+ PCA9552State *s = PCA9552(obj);
53
+ int led, rc, reg;
54
+ uint8_t state;
55
+
56
+ rc = sscanf(name, "led%2d", &led);
57
+ if (rc != 1) {
58
+ error_setg(errp, "%s: error reading %s", __func__, name);
59
+ return;
60
+ }
61
+ if (led < 0 || led > s->nr_leds) {
62
+ error_setg(errp, "%s invalid led %s", __func__, name);
63
+ return;
64
+ }
65
+ /*
79
+ /*
66
+ * Get the LSx register as the qom interface should expose the device
80
+ * Power the secondary CPU off. This means we don't need to write any
67
+ * state, not the modeled 'input line' behaviour which would come from
81
+ * boot code into guest memory. Note that the 'cpu' argument to this
68
+ * reading the INPUTx reg
82
+ * function is the primary CPU we passed to arm_load_kernel(), not
83
+ * the secondary. Loop around all the other CPUs, as the boot.c
84
+ * code does for the "disable secondaries if PSCI is enabled" case.
69
+ */
85
+ */
70
+ reg = PCA9552_LS0 + led / 4;
86
+ for (CPUState *cs = first_cpu; cs; cs = CPU_NEXT(cs)) {
71
+ state = (pca9552_read(s, reg) >> (led % 8)) & 0x3;
87
+ if (cs != first_cpu) {
72
+ visit_type_str(v, name, (char **)&led_state[state], errp);
88
+ object_property_set_bool(OBJECT(cs), "start-powered-off", true,
73
+}
89
+ &error_abort);
74
+
75
+/*
76
+ * Return an LED selector register value based on an existing one, with
77
+ * the appropriate 2-bit state value set for the given LED number (0-3).
78
+ */
79
+static inline uint8_t pca955x_ledsel(uint8_t oldval, int led_num, int state)
80
+{
81
+ return (oldval & (~(0x3 << (led_num << 1)))) |
82
+ ((state & 0x3) << (led_num << 1));
83
+}
84
+
85
+static void pca9552_set_led(Object *obj, Visitor *v, const char *name,
86
+ void *opaque, Error **errp)
87
+{
88
+ PCA9552State *s = PCA9552(obj);
89
+ Error *local_err = NULL;
90
+ int led, rc, reg, val;
91
+ uint8_t state;
92
+ char *state_str;
93
+
94
+ visit_type_str(v, name, &state_str, &local_err);
95
+ if (local_err) {
96
+ error_propagate(errp, local_err);
97
+ return;
98
+ }
99
+ rc = sscanf(name, "led%2d", &led);
100
+ if (rc != 1) {
101
+ error_setg(errp, "%s: error reading %s", __func__, name);
102
+ return;
103
+ }
104
+ if (led < 0 || led > s->nr_leds) {
105
+ error_setg(errp, "%s invalid led %s", __func__, name);
106
+ return;
107
+ }
108
+
109
+ for (state = 0; state < ARRAY_SIZE(led_state); state++) {
110
+ if (!strcmp(state_str, led_state[state])) {
111
+ break;
112
+ }
90
+ }
113
+ }
91
+ }
114
+ if (state >= ARRAY_SIZE(led_state)) {
92
+}
115
+ error_setg(errp, "%s invalid led state %s", __func__, state_str);
93
+
116
+ return;
94
+static void mps3r_secondary_cpu_reset(ARMCPU *cpu,
95
+ const struct arm_boot_info *info)
96
+{
97
+ /* We don't need to do anything here because the CPU will be off */
98
+}
99
+
100
+static void create_gic(MPS3RMachineState *mms, MemoryRegion *sysmem)
101
+{
102
+ MachineState *machine = MACHINE(mms);
103
+ DeviceState *gicdev;
104
+ QList *redist_region_count;
105
+
106
+ object_initialize_child(OBJECT(mms), "gic", &mms->gic, TYPE_ARM_GICV3);
107
+ gicdev = DEVICE(&mms->gic);
108
+ qdev_prop_set_uint32(gicdev, "num-cpu", machine->smp.cpus);
109
+ qdev_prop_set_uint32(gicdev, "num-irq", NUM_SPIS + GIC_INTERNAL);
110
+ redist_region_count = qlist_new();
111
+ qlist_append_int(redist_region_count, machine->smp.cpus);
112
+ qdev_prop_set_array(gicdev, "redist-region-count", redist_region_count);
113
+ object_property_set_link(OBJECT(&mms->gic), "sysmem",
114
+ OBJECT(sysmem), &error_fatal);
115
+ sysbus_realize(SYS_BUS_DEVICE(&mms->gic), &error_fatal);
116
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->gic), 0, PERIPHBASE);
117
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->gic), 1, PERIPHBASE + 0x100000);
118
+ /*
119
+ * Wire the outputs from each CPU's generic timer and the GICv3
120
+ * maintenance interrupt signal to the appropriate GIC PPI inputs,
121
+ * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs.
122
+ */
123
+ for (int i = 0; i < machine->smp.cpus; i++) {
124
+ DeviceState *cpudev = DEVICE(mms->cpu[i]);
125
+ SysBusDevice *gicsbd = SYS_BUS_DEVICE(&mms->gic);
126
+ int intidbase = NUM_SPIS + i * GIC_INTERNAL;
127
+ int irq;
128
+ /*
129
+ * Mapping from the output timer irq lines from the CPU to the
130
+ * GIC PPI inputs used for this board. This isn't a BSA board,
131
+ * but it uses the standard convention for the PPI numbers.
132
+ */
133
+ const int timer_irq[] = {
134
+ [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ,
135
+ [GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ,
136
+ [GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ,
137
+ };
138
+
139
+ for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
140
+ qdev_connect_gpio_out(cpudev, irq,
141
+ qdev_get_gpio_in(gicdev,
142
+ intidbase + timer_irq[irq]));
143
+ }
144
+
145
+ qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0,
146
+ qdev_get_gpio_in(gicdev,
147
+ intidbase + ARCH_GIC_MAINT_IRQ));
148
+
149
+ qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
150
+ qdev_get_gpio_in(gicdev,
151
+ intidbase + VIRTUAL_PMU_IRQ));
152
+
153
+ sysbus_connect_irq(gicsbd, i,
154
+ qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
155
+ sysbus_connect_irq(gicsbd, i + machine->smp.cpus,
156
+ qdev_get_gpio_in(cpudev, ARM_CPU_FIQ));
157
+ sysbus_connect_irq(gicsbd, i + 2 * machine->smp.cpus,
158
+ qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ));
159
+ sysbus_connect_irq(gicsbd, i + 3 * machine->smp.cpus,
160
+ qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ));
117
+ }
161
+ }
118
+
119
+ reg = PCA9552_LS0 + led / 4;
120
+ val = pca9552_read(s, reg);
121
+ val = pca955x_ledsel(val, led % 4, state);
122
+ pca9552_write(s, reg, val);
123
+}
162
+}
124
+
163
+
125
static const VMStateDescription pca9552_vmstate = {
164
static void mps3r_common_init(MachineState *machine)
126
.name = "PCA9552",
127
.version_id = 0,
128
@@ -XXX,XX +XXX,XX @@ static void pca9552_reset(DeviceState *dev)
129
static void pca9552_initfn(Object *obj)
130
{
165
{
131
PCA9552State *s = PCA9552(obj);
166
MPS3RMachineState *mms = MPS3R_MACHINE(machine);
132
+ int led;
167
@@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine)
133
168
MemoryRegion *mr = mr_for_raminfo(mms, ri);
134
/* If support for the other PCA955X devices are implemented, these
169
memory_region_add_subregion(sysmem, ri->base, mr);
135
* constant values might be part of class structure describing the
170
}
136
@@ -XXX,XX +XXX,XX @@ static void pca9552_initfn(Object *obj)
171
+
137
*/
172
+ assert(machine->smp.cpus <= MPS3R_CPU_MAX);
138
s->max_reg = PCA9552_LS3;
173
+ for (int i = 0; i < machine->smp.cpus; i++) {
139
s->nr_leds = 16;
174
+ g_autofree char *sysmem_name = g_strdup_printf("cpu-%d-memory", i);
140
+
175
+ g_autofree char *ramname = g_strdup_printf("cpu-%d-memory", i);
141
+ for (led = 0; led < s->nr_leds; led++) {
176
+ g_autofree char *alias_name = g_strdup_printf("sysmem-alias-%d", i);
142
+ char *name;
177
+
143
+
178
+ /*
144
+ name = g_strdup_printf("led%d", led);
179
+ * Each CPU has some private RAM/peripherals, so create the container
145
+ object_property_add(obj, name, "bool", pca9552_get_led, pca9552_set_led,
180
+ * which will house those, with the whole-machine system memory being
146
+ NULL, NULL, NULL);
181
+ * used where there's no CPU-specific device. Note that we need the
147
+ g_free(name);
182
+ * sysmem_alias aliases because we can't put one MR (the original
183
+ * 'sysmem') into more than one other MR.
184
+ */
185
+ memory_region_init(&mms->cpu_sysmem[i], OBJECT(machine),
186
+ sysmem_name, UINT64_MAX);
187
+ memory_region_init_alias(&mms->sysmem_alias[i], OBJECT(machine),
188
+ alias_name, sysmem, 0, UINT64_MAX);
189
+ memory_region_add_subregion_overlap(&mms->cpu_sysmem[i], 0,
190
+ &mms->sysmem_alias[i], -1);
191
+
192
+ mms->cpu[i] = object_new(machine->cpu_type);
193
+ object_property_set_link(mms->cpu[i], "memory",
194
+ OBJECT(&mms->cpu_sysmem[i]), &error_abort);
195
+ object_property_set_int(mms->cpu[i], "reset-cbar",
196
+ PERIPHBASE, &error_abort);
197
+ qdev_realize(DEVICE(mms->cpu[i]), NULL, &error_fatal);
198
+ object_unref(mms->cpu[i]);
199
+
200
+ /* Per-CPU RAM */
201
+ memory_region_init_ram(&mms->cpu_ram[i], NULL, ramname,
202
+ 0x1000, &error_fatal);
203
+ memory_region_add_subregion(&mms->cpu_sysmem[i], 0xe7c01000,
204
+ &mms->cpu_ram[i]);
148
+ }
205
+ }
206
+
207
+ create_gic(mms, sysmem);
208
+
209
+ mms->bootinfo.ram_size = machine->ram_size;
210
+ mms->bootinfo.board_id = -1;
211
+ mms->bootinfo.loader_start = mmc->loader_start;
212
+ mms->bootinfo.write_secondary_boot = mps3r_write_secondary_boot;
213
+ mms->bootinfo.secondary_cpu_reset_hook = mps3r_secondary_cpu_reset;
214
+ arm_load_kernel(ARM_CPU(mms->cpu[0]), machine, &mms->bootinfo);
149
}
215
}
150
216
151
static void pca9552_class_init(ObjectClass *klass, void *data)
217
static void mps3r_set_default_ram_info(MPS3RMachineClass *mmc)
218
@@ -XXX,XX +XXX,XX @@ static void mps3r_set_default_ram_info(MPS3RMachineClass *mmc)
219
/* Found the entry for "system memory" */
220
mc->default_ram_size = p->size;
221
mc->default_ram_id = p->name;
222
+ mmc->loader_start = p->base;
223
return;
224
}
225
}
226
@@ -XXX,XX +XXX,XX @@ static void mps3r_an536_class_init(ObjectClass *oc, void *data)
227
};
228
229
mc->desc = "ARM MPS3 with AN536 FPGA image for Cortex-R52";
230
- mc->default_cpus = 2;
231
- mc->min_cpus = mc->default_cpus;
232
- mc->max_cpus = mc->default_cpus;
233
+ /*
234
+ * In the real FPGA image there are always two cores, but the standard
235
+ * initial setting for the SCC SYSCON 0x000 register is 0x21, meaning
236
+ * that the second core is held in reset and halted. Many images built for
237
+ * the board do not expect the second core to run at startup (especially
238
+ * since on the real FPGA image it is not possible to use LDREX/STREX
239
+ * in RAM between the two cores, so a true SMP setup isn't supported).
240
+ *
241
+ * As QEMU's equivalent of this, we support both -smp 1 and -smp 2,
242
+ * with the default being -smp 1. This seems a more intuitive UI for
243
+ * QEMU users than, for instance, having a machine property to allow
244
+ * the user to set the initial value of the SYSCON 0x000 register.
245
+ */
246
+ mc->default_cpus = 1;
247
+ mc->min_cpus = 1;
248
+ mc->max_cpus = 2;
249
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-r52");
250
mc->valid_cpu_types = valid_cpu_types;
251
mmc->raminfo = an536_raminfo;
152
--
252
--
153
2.20.1
253
2.34.1
154
155
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
This board has a lot of UARTs: there is one UART per CPU in the
2
per-CPU peripheral part of the address map, whose interrupts are
3
connected as per-CPU interrupt lines. Then there are 4 UARTs in the
4
normal part of the peripheral space, whose interrupts are shared
5
peripheral interrupts.
2
6
3
Add a function resettable_change_parent() to do the required
7
Connect and wire them all up; this involves some OR gates where
4
plumbing when changing the parent a of Resettable object.
8
multiple overflow interrupts are wired into one GIC input.
5
9
6
We need to make sure that the reset state of the object remains
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
coherent with the reset state of the new parent.
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Message-id: 20240206132931.38376-11-peter.maydell@linaro.org
13
---
14
hw/arm/mps3r.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++
15
1 file changed, 94 insertions(+)
8
16
9
We make the 2 following hypothesis:
17
diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c
10
+ when an object is put in a parent under reset, the object goes in
11
reset.
12
+ when an object is removed from a parent under reset, the object
13
leaves reset.
14
15
The added function avoids any glitch if both old and new parent are
16
already in reset.
17
18
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
21
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
Message-id: 20200123132823.1117486-6-damien.hedde@greensocs.com
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
25
include/hw/resettable.h | 16 +++++++++++
26
hw/core/resettable.c | 62 +++++++++++++++++++++++++++++++++++++++--
27
hw/core/trace-events | 1 +
28
3 files changed, 77 insertions(+), 2 deletions(-)
29
30
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
31
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
32
--- a/include/hw/resettable.h
19
--- a/hw/arm/mps3r.c
33
+++ b/include/hw/resettable.h
20
+++ b/hw/arm/mps3r.c
34
@@ -XXX,XX +XXX,XX @@ void resettable_release_reset(Object *obj, ResetType type);
21
@@ -XXX,XX +XXX,XX @@
35
*/
22
#include "qapi/qmp/qlist.h"
36
bool resettable_is_in_reset(Object *obj);
23
#include "exec/address-spaces.h"
37
24
#include "cpu.h"
38
+/**
25
+#include "sysemu/sysemu.h"
39
+ * resettable_change_parent:
26
#include "hw/boards.h"
40
+ * Indicate that the parent of Ressettable @obj is changing from @oldp to @newp.
27
+#include "hw/or-irq.h"
41
+ * All 3 objects must implement resettable interface. @oldp or @newp may be
28
#include "hw/qdev-properties.h"
42
+ * NULL.
29
#include "hw/arm/boot.h"
43
+ *
30
#include "hw/arm/bsa.h"
44
+ * This function will adapt the reset state of @obj so that it is coherent
31
+#include "hw/char/cmsdk-apb-uart.h"
45
+ * with the reset state of @newp. It may trigger @resettable_assert_reset()
32
#include "hw/intc/arm_gicv3.h"
46
+ * or @resettable_release_reset(). It will do such things only if the reset
33
47
+ * state of @newp and @oldp are different.
34
/* Define the layout of RAM and ROM in a board */
48
+ *
35
@@ -XXX,XX +XXX,XX @@ typedef struct RAMInfo {
49
+ * When using this function during reset, it must only be called during
36
50
+ * a hold phase method. Calling this during enter or exit phase is an error.
37
#define MPS3R_RAM_MAX 9
38
#define MPS3R_CPU_MAX 2
39
+#define MPS3R_UART_MAX 4 /* shared UART count */
40
41
#define PERIPHBASE 0xf0000000
42
#define NUM_SPIS 96
43
@@ -XXX,XX +XXX,XX @@ struct MPS3RMachineState {
44
MemoryRegion sysmem_alias[MPS3R_CPU_MAX];
45
MemoryRegion cpu_ram[MPS3R_CPU_MAX];
46
GICv3State gic;
47
+ /* per-CPU UARTs followed by the shared UARTs */
48
+ CMSDKAPBUART uart[MPS3R_CPU_MAX + MPS3R_UART_MAX];
49
+ OrIRQState cpu_uart_oflow[MPS3R_CPU_MAX];
50
+ OrIRQState uart_oflow;
51
};
52
53
#define TYPE_MPS3R_MACHINE "mps3r"
54
@@ -XXX,XX +XXX,XX @@ struct MPS3RMachineState {
55
56
OBJECT_DECLARE_TYPE(MPS3RMachineState, MPS3RMachineClass, MPS3R_MACHINE)
57
58
+/*
59
+ * Main clock frequency CLK in Hz (50MHz). In the image there are also
60
+ * ACLK, MCLK, GPUCLK and PERIPHCLK at the same frequency; for our
61
+ * model we just roll them all into one.
51
+ */
62
+ */
52
+void resettable_change_parent(Object *obj, Object *newp, Object *oldp);
63
+#define CLK_FRQ 50000000
53
+
64
+
54
/**
65
static const RAMInfo an536_raminfo[] = {
55
* resettable_class_set_parent_phases:
66
{
56
*
67
.name = "ATCM",
57
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
68
@@ -XXX,XX +XXX,XX @@ static void create_gic(MPS3RMachineState *mms, MemoryRegion *sysmem)
58
index XXXXXXX..XXXXXXX 100644
69
}
59
--- a/hw/core/resettable.c
60
+++ b/hw/core/resettable.c
61
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type);
62
* enter_phase_in_progress:
63
* True if we are currently in reset enter phase.
64
*
65
- * Note: This flag is only used to guarantee (using asserts) that the reset
66
- * API is used correctly. We can use a global variable because we rely on the
67
+ * exit_phase_in_progress:
68
+ * count the number of exit phase we are in.
69
+ *
70
+ * Note: These flags are only used to guarantee (using asserts) that the reset
71
+ * API is used correctly. We can use global variables because we rely on the
72
* iothread mutex to ensure only one reset operation is in a progress at a
73
* given time.
74
*/
75
static bool enter_phase_in_progress;
76
+static unsigned exit_phase_in_progress;
77
78
void resettable_reset(Object *obj, ResetType type)
79
{
80
@@ -XXX,XX +XXX,XX @@ void resettable_release_reset(Object *obj, ResetType type)
81
trace_resettable_reset_release_begin(obj, type);
82
assert(!enter_phase_in_progress);
83
84
+ exit_phase_in_progress += 1;
85
resettable_phase_exit(obj, NULL, type);
86
+ exit_phase_in_progress -= 1;
87
88
trace_resettable_reset_release_end(obj);
89
}
70
}
90
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
91
trace_resettable_phase_exit_end(obj, obj_typename, s->count);
92
}
93
71
94
+/*
72
+/*
95
+ * resettable_get_count:
73
+ * Create UART uartno, and map it into the MemoryRegion mem at address baseaddr.
96
+ * Get the count of the Resettable object @obj. Return 0 if @obj is NULL.
74
+ * The qemu_irq arguments are where we connect the various IRQs from the UART.
97
+ */
75
+ */
98
+static unsigned resettable_get_count(Object *obj)
76
+static void create_uart(MPS3RMachineState *mms, int uartno, MemoryRegion *mem,
77
+ hwaddr baseaddr, qemu_irq txirq, qemu_irq rxirq,
78
+ qemu_irq txoverirq, qemu_irq rxoverirq,
79
+ qemu_irq combirq)
99
+{
80
+{
100
+ if (obj) {
81
+ g_autofree char *s = g_strdup_printf("uart%d", uartno);
101
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
82
+ SysBusDevice *sbd;
102
+ return rc->get_state(obj)->count;
83
+
103
+ }
84
+ assert(uartno < ARRAY_SIZE(mms->uart));
104
+ return 0;
85
+ object_initialize_child(OBJECT(mms), s, &mms->uart[uartno],
86
+ TYPE_CMSDK_APB_UART);
87
+ qdev_prop_set_uint32(DEVICE(&mms->uart[uartno]), "pclk-frq", CLK_FRQ);
88
+ qdev_prop_set_chr(DEVICE(&mms->uart[uartno]), "chardev", serial_hd(uartno));
89
+ sbd = SYS_BUS_DEVICE(&mms->uart[uartno]);
90
+ sysbus_realize(sbd, &error_fatal);
91
+ memory_region_add_subregion(mem, baseaddr,
92
+ sysbus_mmio_get_region(sbd, 0));
93
+ sysbus_connect_irq(sbd, 0, txirq);
94
+ sysbus_connect_irq(sbd, 1, rxirq);
95
+ sysbus_connect_irq(sbd, 2, txoverirq);
96
+ sysbus_connect_irq(sbd, 3, rxoverirq);
97
+ sysbus_connect_irq(sbd, 4, combirq);
105
+}
98
+}
106
+
99
+
107
+void resettable_change_parent(Object *obj, Object *newp, Object *oldp)
100
static void mps3r_common_init(MachineState *machine)
108
+{
101
{
109
+ ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
102
MPS3RMachineState *mms = MPS3R_MACHINE(machine);
110
+ ResettableState *s = rc->get_state(obj);
103
MPS3RMachineClass *mmc = MPS3R_MACHINE_GET_CLASS(mms);
111
+ unsigned newp_count = resettable_get_count(newp);
104
MemoryRegion *sysmem = get_system_memory();
112
+ unsigned oldp_count = resettable_get_count(oldp);
105
+ DeviceState *gicdev;
106
107
for (const RAMInfo *ri = mmc->raminfo; ri->name; ri++) {
108
MemoryRegion *mr = mr_for_raminfo(mms, ri);
109
@@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine)
110
}
111
112
create_gic(mms, sysmem);
113
+ gicdev = DEVICE(&mms->gic);
113
+
114
+
114
+ /*
115
+ /*
115
+ * Ensure we do not change parent when in enter or exit phase.
116
+ * UARTs 0 and 1 are per-CPU; their interrupts are wired to
116
+ * During these phases, the reset subtree being updated is partly in reset
117
+ * the relevant CPU's PPI 0..3, aka INTID 16..19
117
+ * and partly not in reset (it depends on the actual position in
118
+ * resettable_child_foreach()s). We are not able to tell in which part is a
119
+ * leaving or arriving device. Thus we cannot set the reset count of the
120
+ * moving device to the proper value.
121
+ */
118
+ */
122
+ assert(!enter_phase_in_progress && !exit_phase_in_progress);
119
+ for (int i = 0; i < machine->smp.cpus; i++) {
123
+ trace_resettable_change_parent(obj, oldp, oldp_count, newp, newp_count);
120
+ int intidbase = NUM_SPIS + i * GIC_INTERNAL;
121
+ g_autofree char *s = g_strdup_printf("cpu-uart-oflow-orgate%d", i);
122
+ DeviceState *orgate;
124
+
123
+
125
+ /*
124
+ /* The two overflow IRQs from the UART are ORed together into PPI 3 */
126
+ * At most one of the two 'for' loops will be executed below
125
+ object_initialize_child(OBJECT(mms), s, &mms->cpu_uart_oflow[i],
127
+ * in order to cope with the difference between the two counts.
126
+ TYPE_OR_IRQ);
128
+ */
127
+ orgate = DEVICE(&mms->cpu_uart_oflow[i]);
129
+ /* if newp is more reset than oldp */
128
+ qdev_prop_set_uint32(orgate, "num-lines", 2);
130
+ for (unsigned i = oldp_count; i < newp_count; i++) {
129
+ qdev_realize(orgate, NULL, &error_fatal);
131
+ resettable_assert_reset(obj, RESET_TYPE_COLD);
130
+ qdev_connect_gpio_out(orgate, 0,
131
+ qdev_get_gpio_in(gicdev, intidbase + 19));
132
+
133
+ create_uart(mms, i, &mms->cpu_sysmem[i], 0xe7c00000,
134
+ qdev_get_gpio_in(gicdev, intidbase + 17), /* tx */
135
+ qdev_get_gpio_in(gicdev, intidbase + 16), /* rx */
136
+ qdev_get_gpio_in(orgate, 0), /* txover */
137
+ qdev_get_gpio_in(orgate, 1), /* rxover */
138
+ qdev_get_gpio_in(gicdev, intidbase + 18) /* combined */);
132
+ }
139
+ }
133
+ /*
140
+ /*
134
+ * if obj is leaving a bus under reset, we need to ensure
141
+ * UARTs 2 to 5 are whole-system; all overflow IRQs are ORed
135
+ * hold phase is not pending.
142
+ * together into IRQ 17
136
+ */
143
+ */
137
+ if (oldp_count && s->hold_phase_pending) {
144
+ object_initialize_child(OBJECT(mms), "uart-oflow-orgate",
138
+ resettable_phase_hold(obj, NULL, RESET_TYPE_COLD);
145
+ &mms->uart_oflow, TYPE_OR_IRQ);
146
+ qdev_prop_set_uint32(DEVICE(&mms->uart_oflow), "num-lines",
147
+ MPS3R_UART_MAX * 2);
148
+ qdev_realize(DEVICE(&mms->uart_oflow), NULL, &error_fatal);
149
+ qdev_connect_gpio_out(DEVICE(&mms->uart_oflow), 0,
150
+ qdev_get_gpio_in(gicdev, 17));
151
+
152
+ for (int i = 0; i < MPS3R_UART_MAX; i++) {
153
+ hwaddr baseaddr = 0xe0205000 + i * 0x1000;
154
+ int rxirq = 5 + i * 2, txirq = 6 + i * 2, combirq = 13 + i;
155
+
156
+ create_uart(mms, i + MPS3R_CPU_MAX, sysmem, baseaddr,
157
+ qdev_get_gpio_in(gicdev, txirq),
158
+ qdev_get_gpio_in(gicdev, rxirq),
159
+ qdev_get_gpio_in(DEVICE(&mms->uart_oflow), i * 2),
160
+ qdev_get_gpio_in(DEVICE(&mms->uart_oflow), i * 2 + 1),
161
+ qdev_get_gpio_in(gicdev, combirq));
139
+ }
162
+ }
140
+ /* if oldp is more reset than newp */
163
141
+ for (unsigned i = newp_count; i < oldp_count; i++) {
164
mms->bootinfo.ram_size = machine->ram_size;
142
+ resettable_release_reset(obj, RESET_TYPE_COLD);
165
mms->bootinfo.board_id = -1;
143
+ }
144
+}
145
+
146
void resettable_class_set_parent_phases(ResettableClass *rc,
147
ResettableEnterPhase enter,
148
ResettableHoldPhase hold,
149
diff --git a/hw/core/trace-events b/hw/core/trace-events
150
index XXXXXXX..XXXXXXX 100644
151
--- a/hw/core/trace-events
152
+++ b/hw/core/trace-events
153
@@ -XXX,XX +XXX,XX @@ resettable_reset_assert_begin(void *obj, int cold) "obj=%p cold=%d"
154
resettable_reset_assert_end(void *obj) "obj=%p"
155
resettable_reset_release_begin(void *obj, int cold) "obj=%p cold=%d"
156
resettable_reset_release_end(void *obj) "obj=%p"
157
+resettable_change_parent(void *obj, void *o, unsigned oc, void *n, unsigned nc) "obj=%p from=%p(%d) to=%p(%d)"
158
resettable_phase_enter_begin(void *obj, const char *objtype, unsigned count, int type) "obj=%p(%s) count=%d type=%d"
159
resettable_phase_enter_exec(void *obj, const char *objtype, int type, int has_method) "obj=%p(%s) type=%d method=%d"
160
resettable_phase_enter_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d"
161
--
166
--
162
2.20.1
167
2.34.1
163
168
164
169
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Add the GPIO, watchdog, dual-timer and I2C devices to the mps3-an536
2
board. These are all simple devices that just need to be created and
3
wired up.
2
4
3
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200123132823.1117486-10-damien.hedde@greensocs.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Message-id: 20240206132931.38376-12-peter.maydell@linaro.org
8
---
8
---
9
docs/devel/index.rst | 1 +
9
hw/arm/mps3r.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
10
docs/devel/reset.rst | 289 +++++++++++++++++++++++++++++++++++++++++++
10
1 file changed, 59 insertions(+)
11
2 files changed, 290 insertions(+)
12
create mode 100644 docs/devel/reset.rst
13
11
14
diff --git a/docs/devel/index.rst b/docs/devel/index.rst
12
diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c
15
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/devel/index.rst
14
--- a/hw/arm/mps3r.c
17
+++ b/docs/devel/index.rst
15
+++ b/hw/arm/mps3r.c
18
@@ -XXX,XX +XXX,XX @@ Contents:
19
tcg
20
tcg-plugins
21
bitops
22
+ reset
23
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
24
new file mode 100644
25
index XXXXXXX..XXXXXXX
26
--- /dev/null
27
+++ b/docs/devel/reset.rst
28
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@
17
#include "sysemu/sysemu.h"
18
#include "hw/boards.h"
19
#include "hw/or-irq.h"
20
+#include "hw/qdev-clock.h"
21
#include "hw/qdev-properties.h"
22
#include "hw/arm/boot.h"
23
#include "hw/arm/bsa.h"
24
#include "hw/char/cmsdk-apb-uart.h"
25
+#include "hw/i2c/arm_sbcon_i2c.h"
26
#include "hw/intc/arm_gicv3.h"
27
+#include "hw/misc/unimp.h"
28
+#include "hw/timer/cmsdk-apb-dualtimer.h"
29
+#include "hw/watchdog/cmsdk-apb-watchdog.h"
30
31
/* Define the layout of RAM and ROM in a board */
32
typedef struct RAMInfo {
33
@@ -XXX,XX +XXX,XX @@ struct MPS3RMachineState {
34
CMSDKAPBUART uart[MPS3R_CPU_MAX + MPS3R_UART_MAX];
35
OrIRQState cpu_uart_oflow[MPS3R_CPU_MAX];
36
OrIRQState uart_oflow;
37
+ CMSDKAPBWatchdog watchdog;
38
+ CMSDKAPBDualTimer dualtimer;
39
+ ArmSbconI2CState i2c[5];
40
+ Clock *clk;
41
};
42
43
#define TYPE_MPS3R_MACHINE "mps3r"
44
@@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine)
45
MemoryRegion *sysmem = get_system_memory();
46
DeviceState *gicdev;
47
48
+ mms->clk = clock_new(OBJECT(machine), "CLK");
49
+ clock_set_hz(mms->clk, CLK_FRQ);
29
+
50
+
30
+=======================================
51
for (const RAMInfo *ri = mmc->raminfo; ri->name; ri++) {
31
+Reset in QEMU: the Resettable interface
52
MemoryRegion *mr = mr_for_raminfo(mms, ri);
32
+=======================================
53
memory_region_add_subregion(sysmem, ri->base, mr);
33
+
54
@@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine)
34
+The reset of qemu objects is handled using the resettable interface declared
55
qdev_get_gpio_in(gicdev, combirq));
35
+in ``include/hw/resettable.h``.
56
}
36
+
57
37
+This interface allows objects to be grouped (on a tree basis); so that the
58
+ for (int i = 0; i < 4; i++) {
38
+whole group can be reset consistently. Each individual member object does not
59
+ /* CMSDK GPIO controllers */
39
+have to care about others; in particular, problems of order (which object is
60
+ g_autofree char *s = g_strdup_printf("gpio%d", i);
40
+reset first) are addressed.
61
+ create_unimplemented_device(s, 0xe0000000 + i * 0x1000, 0x1000);
41
+
42
+As of now DeviceClass and BusClass implement this interface.
43
+
44
+
45
+Triggering reset
46
+----------------
47
+
48
+This section documents the APIs which "users" of a resettable object should use
49
+to control it. All resettable control functions must be called while holding
50
+the iothread lock.
51
+
52
+You can apply a reset to an object using ``resettable_assert_reset()``. You need
53
+to call ``resettable_release_reset()`` to release the object from reset. To
54
+instantly reset an object, without keeping it in reset state, just call
55
+``resettable_reset()``. These functions take two parameters: a pointer to the
56
+object to reset and a reset type.
57
+
58
+Several types of reset will be supported. For now only cold reset is defined;
59
+others may be added later. The Resettable interface handles reset types with an
60
+enum:
61
+
62
+``RESET_TYPE_COLD``
63
+ Cold reset is supported by every resettable object. In QEMU, it means we reset
64
+ to the initial state corresponding to the start of QEMU; this might differ
65
+ from what is a real hardware cold reset. It differs from other resets (like
66
+ warm or bus resets) which may keep certain parts untouched.
67
+
68
+Calling ``resettable_reset()`` is equivalent to calling
69
+``resettable_assert_reset()`` then ``resettable_release_reset()``. It is
70
+possible to interleave multiple calls to these three functions. There may
71
+be several reset sources/controllers of a given object. The interface handles
72
+everything and the different reset controllers do not need to know anything
73
+about each others. The object will leave reset state only when each other
74
+controllers end their reset operation. This point is handled internally by
75
+maintaining a count of in-progress resets; it is crucial to call
76
+``resettable_release_reset()`` one time and only one time per
77
+``resettable_assert_reset()`` call.
78
+
79
+For now migration of a device or bus in reset is not supported. Care must be
80
+taken not to delay ``resettable_release_reset()`` after its
81
+``resettable_assert_reset()`` counterpart.
82
+
83
+Note that, since resettable is an interface, the API takes a simple Object as
84
+parameter. Still, it is a programming error to call a resettable function on a
85
+non-resettable object and it will trigger a run time assert error. Since most
86
+calls to resettable interface are done through base class functions, such an
87
+error is not likely to happen.
88
+
89
+For Devices and Buses, the following helper functions exist:
90
+
91
+- ``device_cold_reset()``
92
+- ``bus_cold_reset()``
93
+
94
+These are simple wrappers around resettable_reset() function; they only cast the
95
+Device or Bus into an Object and pass the cold reset type. When possible
96
+prefer to use these functions instead of ``resettable_reset()``.
97
+
98
+Device and bus functions co-exist because there can be semantic differences
99
+between resetting a bus and resetting the controller bridge which owns it.
100
+For example, consider a SCSI controller. Resetting the controller puts all
101
+its registers back to what reset state was as well as reset everything on the
102
+SCSI bus, whereas resetting just the SCSI bus only resets everything that's on
103
+it but not the controller.
104
+
105
+
106
+Multi-phase mechanism
107
+---------------------
108
+
109
+This section documents the internals of the resettable interface.
110
+
111
+The resettable interface uses a multi-phase system to relieve objects and
112
+machines from reset ordering problems. To address this, the reset operation
113
+of an object is split into three well defined phases.
114
+
115
+When resetting several objects (for example the whole machine at simulation
116
+startup), all first phases of all objects are executed, then all second phases
117
+and then all third phases.
118
+
119
+The three phases are:
120
+
121
+1. The **enter** phase is executed when the object enters reset. It resets only
122
+ local state of the object; it must not do anything that has a side-effect
123
+ on other objects, such as raising or lowering a qemu_irq line or reading or
124
+ writing guest memory.
125
+
126
+2. The **hold** phase is executed for entry into reset, once every object in the
127
+ group which is being reset has had its *enter* phase executed. At this point
128
+ devices can do actions that affect other objects.
129
+
130
+3. The **exit** phase is executed when the object leaves the reset state.
131
+ Actions affecting other objects are permitted.
132
+
133
+As said in previous section, the interface maintains a count of reset. This
134
+count is used to ensure phases are executed only when required. *enter* and
135
+*hold* phases are executed only when asserting reset for the first time
136
+(if an object is already in reset state when calling
137
+``resettable_assert_reset()`` or ``resettable_reset()``, they are not
138
+executed).
139
+The *exit* phase is executed only when the last reset operation ends. Therefore
140
+the object does not need to care how many of reset controllers it has and how
141
+many of them have started a reset.
142
+
143
+
144
+Handling reset in a resettable object
145
+-------------------------------------
146
+
147
+This section documents the APIs that an implementation of a resettable object
148
+must provide and what functions it has access to. It is intended for people
149
+who want to implement or convert a class which has the resettable interface;
150
+for example when specializing an existing device or bus.
151
+
152
+Methods to implement
153
+....................
154
+
155
+Three methods should be defined or left empty. Each method corresponds to a
156
+phase of the reset; they are name ``phases.enter()``, ``phases.hold()`` and
157
+``phases.exit()``. They all take the object as parameter. The *enter* method
158
+also take the reset type as second parameter.
159
+
160
+When extending an existing class, these methods may need to be extended too.
161
+The ``resettable_class_set_parent_phases()`` class function may be used to
162
+backup parent class methods.
163
+
164
+Here follows an example to implement reset for a Device which sets an IO while
165
+in reset.
166
+
167
+::
168
+
169
+ static void mydev_reset_enter(Object *obj, ResetType type)
170
+ {
171
+ MyDevClass *myclass = MYDEV_GET_CLASS(obj);
172
+ MyDevState *mydev = MYDEV(obj);
173
+ /* call parent class enter phase */
174
+ if (myclass->parent_phases.enter) {
175
+ myclass->parent_phases.enter(obj, type);
176
+ }
177
+ /* initialize local state only */
178
+ mydev->var = 0;
179
+ }
62
+ }
180
+
63
+
181
+ static void mydev_reset_hold(Object *obj)
64
+ object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog,
182
+ {
65
+ TYPE_CMSDK_APB_WATCHDOG);
183
+ MyDevClass *myclass = MYDEV_GET_CLASS(obj);
66
+ qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->clk);
184
+ MyDevState *mydev = MYDEV(obj);
67
+ sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal);
185
+ /* call parent class hold phase */
68
+ sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0,
186
+ if (myclass->parent_phases.hold) {
69
+ qdev_get_gpio_in(gicdev, 0));
187
+ myclass->parent_phases.hold(obj);
70
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->watchdog), 0, 0xe0100000);
71
+
72
+ object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer,
73
+ TYPE_CMSDK_APB_DUALTIMER);
74
+ qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->clk);
75
+ sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal);
76
+ sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0,
77
+ qdev_get_gpio_in(gicdev, 3));
78
+ sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 1,
79
+ qdev_get_gpio_in(gicdev, 1));
80
+ sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 2,
81
+ qdev_get_gpio_in(gicdev, 2));
82
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0xe0101000);
83
+
84
+ for (int i = 0; i < ARRAY_SIZE(mms->i2c); i++) {
85
+ static const hwaddr i2cbase[] = {0xe0102000, /* Touch */
86
+ 0xe0103000, /* Audio */
87
+ 0xe0107000, /* Shield0 */
88
+ 0xe0108000, /* Shield1 */
89
+ 0xe0109000}; /* DDR4 EEPROM */
90
+ g_autofree char *s = g_strdup_printf("i2c%d", i);
91
+
92
+ object_initialize_child(OBJECT(mms), s, &mms->i2c[i],
93
+ TYPE_ARM_SBCON_I2C);
94
+ sysbus_realize(SYS_BUS_DEVICE(&mms->i2c[i]), &error_fatal);
95
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->i2c[i]), 0, i2cbase[i]);
96
+ if (i != 2 && i != 3) {
97
+ /*
98
+ * internal-only bus: mark it full to avoid user-created
99
+ * i2c devices being plugged into it.
100
+ */
101
+ qbus_mark_full(qdev_get_child_bus(DEVICE(&mms->i2c[i]), "i2c"));
188
+ }
102
+ }
189
+ /* set an IO */
190
+ qemu_set_irq(mydev->irq, 1);
191
+ }
103
+ }
192
+
104
+
193
+ static void mydev_reset_exit(Object *obj)
105
mms->bootinfo.ram_size = machine->ram_size;
194
+ {
106
mms->bootinfo.board_id = -1;
195
+ MyDevClass *myclass = MYDEV_GET_CLASS(obj);
107
mms->bootinfo.loader_start = mmc->loader_start;
196
+ MyDevState *mydev = MYDEV(obj);
197
+ /* call parent class exit phase */
198
+ if (myclass->parent_phases.exit) {
199
+ myclass->parent_phases.exit(obj);
200
+ }
201
+ /* clear an IO */
202
+ qemu_set_irq(mydev->irq, 0);
203
+ }
204
+
205
+ typedef struct MyDevClass {
206
+ MyParentClass parent_class;
207
+ /* to store eventual parent reset methods */
208
+ ResettablePhases parent_phases;
209
+ } MyDevClass;
210
+
211
+ static void mydev_class_init(ObjectClass *class, void *data)
212
+ {
213
+ MyDevClass *myclass = MYDEV_CLASS(class);
214
+ ResettableClass *rc = RESETTABLE_CLASS(class);
215
+ resettable_class_set_parent_reset_phases(rc,
216
+ mydev_reset_enter,
217
+ mydev_reset_hold,
218
+ mydev_reset_exit,
219
+ &myclass->parent_phases);
220
+ }
221
+
222
+In the above example, we override all three phases. It is possible to override
223
+only some of them by passing NULL instead of a function pointer to
224
+``resettable_class_set_parent_reset_phases()``. For example, the following will
225
+only override the *enter* phase and leave *hold* and *exit* untouched::
226
+
227
+ resettable_class_set_parent_reset_phases(rc, mydev_reset_enter,
228
+ NULL, NULL,
229
+ &myclass->parent_phases);
230
+
231
+This is equivalent to providing a trivial implementation of the hold and exit
232
+phases which does nothing but call the parent class's implementation of the
233
+phase.
234
+
235
+Polling the reset state
236
+.......................
237
+
238
+Resettable interface provides the ``resettable_is_in_reset()`` function.
239
+This function returns true if the object parameter is currently under reset.
240
+
241
+An object is under reset from the beginning of the *init* phase to the end of
242
+the *exit* phase. During all three phases, the function will return that the
243
+object is in reset.
244
+
245
+This function may be used if the object behavior has to be adapted
246
+while in reset state. For example if a device has an irq input,
247
+it will probably need to ignore it while in reset; then it can for
248
+example check the reset state at the beginning of the irq callback.
249
+
250
+Note that until migration of the reset state is supported, an object
251
+should not be left in reset. So apart from being currently executing
252
+one of the reset phases, the only cases when this function will return
253
+true is if an external interaction (like changing an io) is made during
254
+*hold* or *exit* phase of another object in the same reset group.
255
+
256
+Helpers ``device_is_in_reset()`` and ``bus_is_in_reset()`` are also provided
257
+for devices and buses and should be preferred.
258
+
259
+
260
+Base class handling of reset
261
+----------------------------
262
+
263
+This section documents parts of the reset mechanism that you only need to know
264
+about if you are extending it to work with a new base class other than
265
+DeviceClass or BusClass, or maintaining the existing code in those classes. Most
266
+people can ignore it.
267
+
268
+Methods to implement
269
+....................
270
+
271
+There are two other methods that need to exist in a class implementing the
272
+interface: ``get_state()`` and ``child_foreach()``.
273
+
274
+``get_state()`` is simple. *resettable* is an interface and, as a consequence,
275
+does not have any class state structure. But in order to factorize the code, we
276
+need one. This method must return a pointer to ``ResettableState`` structure.
277
+The structure must be allocated by the base class; preferably it should be
278
+located inside the object instance structure.
279
+
280
+``child_foreach()`` is more complex. It should execute the given callback on
281
+every reset child of the given resettable object. All children must be
282
+resettable too. Additional parameters (a reset type and an opaque pointer) must
283
+be passed to the callback too.
284
+
285
+In ``DeviceClass`` and ``BusClass`` the ``ResettableState`` is located
286
+``DeviceState`` and ``BusState`` structure. ``child_foreach()`` is implemented
287
+to follow the bus hierarchy; for a bus, it calls the function on every child
288
+device; for a device, it calls the function on every bus child. When we reset
289
+the main system bus, we reset the whole machine bus tree.
290
+
291
+Changing a resettable parent
292
+............................
293
+
294
+One thing which should be taken care of by the base class is handling reset
295
+hierarchy changes.
296
+
297
+The reset hierarchy is supposed to be static and built during machine creation.
298
+But there are actually some exceptions. To cope with this, the resettable API
299
+provides ``resettable_change_parent()``. This function allows to set, update or
300
+remove the parent of a resettable object after machine creation is done. As
301
+parameters, it takes the object being moved, the old parent if any and the new
302
+parent if any.
303
+
304
+This function can be used at any time when not in a reset operation. During
305
+a reset operation it must be used only in *hold* phase. Using it in *enter* or
306
+*exit* phase is an error.
307
+Also it should not be used during machine creation, although it is harmless to
308
+do so: the function is a no-op as long as old and new parent are NULL or not
309
+in reset.
310
+
311
+There is currently 2 cases where this function is used:
312
+
313
+1. *device hotplug*; it means a new device is introduced on a live bus.
314
+
315
+2. *hot bus change*; it means an existing live device is added, moved or
316
+ removed in the bus hierarchy. At the moment, it occurs only in the raspi
317
+ machines for changing the sdbus used by sd card.
318
--
108
--
319
2.20.1
109
2.34.1
320
110
321
111
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Add the remaining devices (or unimplemented-device stubs) for
2
this board: SPI controllers, SCC, FPGAIO, I2S, RTC, the
3
QSPI write-config block, and ethernet.
2
4
3
This commit adds support of Resettable interface to buses and devices:
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
+ ResettableState structure is added in the Bus/Device state
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
+ Resettable methods are implemented.
7
Message-id: 20240206132931.38376-13-peter.maydell@linaro.org
6
+ device/bus_is_in_reset function defined
8
---
9
hw/arm/mps3r.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
10
1 file changed, 74 insertions(+)
7
11
8
This commit allows to transition the objects to the new
12
diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c
9
multi-phase interface without changing the reset behavior at all.
10
Object single reset method can be split into the 3 different phases
11
but the 3 phases are still executed in a row for a given object.
12
From the qdev/qbus reset api point of view, nothing is changed.
13
qdev_reset_all() and qbus_reset_all() are not modified as well as
14
device_legacy_reset().
15
16
Transition of an object must be done from parent class to child class.
17
Care has been taken to allow the transition of a parent class
18
without requiring the child classes to be transitioned at the same
19
time. Note that SysBus and SysBusDevice class do not need any transition
20
because they do not override the legacy reset method.
21
22
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
23
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
26
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
27
Message-id: 20200123132823.1117486-5-damien.hedde@greensocs.com
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
---
30
tests/Makefile.include | 1 +
31
include/hw/qdev-core.h | 27 ++++++++++++
32
hw/core/bus.c | 97 ++++++++++++++++++++++++++++++++++++++++++
33
hw/core/qdev.c | 93 ++++++++++++++++++++++++++++++++++++++++
34
4 files changed, 218 insertions(+)
35
36
diff --git a/tests/Makefile.include b/tests/Makefile.include
37
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
38
--- a/tests/Makefile.include
14
--- a/hw/arm/mps3r.c
39
+++ b/tests/Makefile.include
15
+++ b/hw/arm/mps3r.c
40
@@ -XXX,XX +XXX,XX @@ tests/fp/%:
41
tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
42
    hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\
43
    hw/core/bus.o \
44
+    hw/core/resettable.o \
45
    hw/core/irq.o \
46
    hw/core/fw-path-provider.o \
47
    hw/core/reset.o \
48
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
49
index XXXXXXX..XXXXXXX 100644
50
--- a/include/hw/qdev-core.h
51
+++ b/include/hw/qdev-core.h
52
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@
53
#include "qemu/bitmap.h"
17
#include "hw/char/cmsdk-apb-uart.h"
54
#include "qom/object.h"
18
#include "hw/i2c/arm_sbcon_i2c.h"
55
#include "hw/hotplug.h"
19
#include "hw/intc/arm_gicv3.h"
56
+#include "hw/resettable.h"
20
+#include "hw/misc/mps2-scc.h"
57
21
+#include "hw/misc/mps2-fpgaio.h"
58
enum {
22
#include "hw/misc/unimp.h"
59
DEV_NVECTORS_UNSPECIFIED = -1,
23
+#include "hw/net/lan9118.h"
60
@@ -XXX,XX +XXX,XX @@ typedef struct DeviceClass {
24
+#include "hw/rtc/pl031.h"
61
bool hotpluggable;
25
+#include "hw/ssi/pl022.h"
62
26
#include "hw/timer/cmsdk-apb-dualtimer.h"
63
/* callbacks */
27
#include "hw/watchdog/cmsdk-apb-watchdog.h"
64
+ /*
28
65
+ * Reset method here is deprecated and replaced by methods in the
29
@@ -XXX,XX +XXX,XX @@ struct MPS3RMachineState {
66
+ * resettable class interface to implement a multi-phase reset.
30
CMSDKAPBWatchdog watchdog;
67
+ * TODO: remove once every reset callback is unused
31
CMSDKAPBDualTimer dualtimer;
68
+ */
32
ArmSbconI2CState i2c[5];
69
DeviceReset reset;
33
+ PL022State spi[3];
70
DeviceRealize realize;
34
+ MPS2SCC scc;
71
DeviceUnrealize unrealize;
35
+ MPS2FPGAIO fpgaio;
72
@@ -XXX,XX +XXX,XX @@ struct NamedGPIOList {
36
+ UnimplementedDeviceState i2s_audio;
73
/**
37
+ PL031State rtc;
74
* DeviceState:
38
Clock *clk;
75
* @realized: Indicates whether the device has been fully constructed.
76
+ * @reset: ResettableState for the device; handled by Resettable interface.
77
*
78
* This structure should not be accessed directly. We declare it here
79
* so that it can be embedded in individual device state structures.
80
@@ -XXX,XX +XXX,XX @@ struct DeviceState {
81
int num_child_bus;
82
int instance_id_alias;
83
int alias_required_for_version;
84
+ ResettableState reset;
85
};
39
};
86
40
87
struct DeviceListener {
41
@@ -XXX,XX +XXX,XX @@ static const RAMInfo an536_raminfo[] = {
88
@@ -XXX,XX +XXX,XX @@ typedef struct BusChild {
42
}
89
/**
90
* BusState:
91
* @hotplug_handler: link to a hotplug handler associated with bus.
92
+ * @reset: ResettableState for the bus; handled by Resettable interface.
93
*/
94
struct BusState {
95
Object obj;
96
@@ -XXX,XX +XXX,XX @@ struct BusState {
97
int num_children;
98
QTAILQ_HEAD(, BusChild) children;
99
QLIST_ENTRY(BusState) sibling;
100
+ ResettableState reset;
101
};
43
};
102
44
103
/**
45
+static const int an536_oscclk[] = {
104
@@ -XXX,XX +XXX,XX @@ void qdev_reset_all_fn(void *opaque);
46
+ 24000000, /* 24MHz reference for RTC and timers */
105
void qbus_reset_all(BusState *bus);
47
+ 50000000, /* 50MHz ACLK */
106
void qbus_reset_all_fn(void *opaque);
48
+ 50000000, /* 50MHz MCLK */
107
49
+ 50000000, /* 50MHz GPUCLK */
108
+/**
50
+ 24576000, /* 24.576MHz AUDCLK */
109
+ * device_is_in_reset:
51
+ 23750000, /* 23.75MHz HDLCDCLK */
110
+ * Return true if the device @dev is currently being reset.
52
+ 100000000, /* 100MHz DDR4_REF_CLK */
111
+ */
53
+};
112
+bool device_is_in_reset(DeviceState *dev);
113
+
54
+
114
+/**
55
static MemoryRegion *mr_for_raminfo(MPS3RMachineState *mms,
115
+ * bus_is_in_reset:
56
const RAMInfo *raminfo)
116
+ * Return true if the bus @bus is currently being reset.
57
{
117
+ */
58
@@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine)
118
+bool bus_is_in_reset(BusState *bus);
59
MPS3RMachineClass *mmc = MPS3R_MACHINE_GET_CLASS(mms);
60
MemoryRegion *sysmem = get_system_memory();
61
DeviceState *gicdev;
62
+ QList *oscclk;
63
64
mms->clk = clock_new(OBJECT(machine), "CLK");
65
clock_set_hz(mms->clk, CLK_FRQ);
66
@@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine)
67
}
68
}
69
70
+ for (int i = 0; i < ARRAY_SIZE(mms->spi); i++) {
71
+ g_autofree char *s = g_strdup_printf("spi%d", i);
72
+ hwaddr baseaddr = 0xe0104000 + i * 0x1000;
119
+
73
+
120
/* This should go away once we get rid of the NULL bus hack */
74
+ object_initialize_child(OBJECT(mms), s, &mms->spi[i], TYPE_PL022);
121
BusState *sysbus_get_default(void);
75
+ sysbus_realize(SYS_BUS_DEVICE(&mms->spi[i]), &error_fatal);
122
76
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->spi[i]), 0, baseaddr);
123
@@ -XXX,XX +XXX,XX @@ void device_legacy_reset(DeviceState *dev);
77
+ sysbus_connect_irq(SYS_BUS_DEVICE(&mms->spi[i]), 0,
124
78
+ qdev_get_gpio_in(gicdev, 22 + i));
125
void device_class_set_props(DeviceClass *dc, Property *props);
79
+ }
126
127
+/**
128
+ * device_class_set_parent_reset:
129
+ * TODO: remove the function when DeviceClass's reset method
130
+ * is not used anymore.
131
+ */
132
void device_class_set_parent_reset(DeviceClass *dc,
133
DeviceReset dev_reset,
134
DeviceReset *parent_reset);
135
diff --git a/hw/core/bus.c b/hw/core/bus.c
136
index XXXXXXX..XXXXXXX 100644
137
--- a/hw/core/bus.c
138
+++ b/hw/core/bus.c
139
@@ -XXX,XX +XXX,XX @@ int qbus_walk_children(BusState *bus,
140
return 0;
141
}
142
143
+bool bus_is_in_reset(BusState *bus)
144
+{
145
+ return resettable_is_in_reset(OBJECT(bus));
146
+}
147
+
80
+
148
+static ResettableState *bus_get_reset_state(Object *obj)
81
+ object_initialize_child(OBJECT(mms), "scc", &mms->scc, TYPE_MPS2_SCC);
149
+{
82
+ qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-cfg0", 0);
150
+ BusState *bus = BUS(obj);
83
+ qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-cfg4", 0x2);
151
+ return &bus->reset;
84
+ qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-aid", 0x00200008);
152
+}
85
+ qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-id", 0x41055360);
86
+ oscclk = qlist_new();
87
+ for (int i = 0; i < ARRAY_SIZE(an536_oscclk); i++) {
88
+ qlist_append_int(oscclk, an536_oscclk[i]);
89
+ }
90
+ qdev_prop_set_array(DEVICE(&mms->scc), "oscclk", oscclk);
91
+ sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal);
92
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->scc), 0, 0xe0200000);
153
+
93
+
154
+static void bus_reset_child_foreach(Object *obj, ResettableChildCallback cb,
94
+ create_unimplemented_device("i2s-audio", 0xe0201000, 0x1000);
155
+ void *opaque, ResetType type)
156
+{
157
+ BusState *bus = BUS(obj);
158
+ BusChild *kid;
159
+
95
+
160
+ QTAILQ_FOREACH(kid, &bus->children, sibling) {
96
+ object_initialize_child(OBJECT(mms), "fpgaio", &mms->fpgaio,
161
+ cb(OBJECT(kid->child), opaque, type);
97
+ TYPE_MPS2_FPGAIO);
162
+ }
98
+ qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "prescale-clk", an536_oscclk[1]);
163
+}
99
+ qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "num-leds", 10);
100
+ qdev_prop_set_bit(DEVICE(&mms->fpgaio), "has-switches", true);
101
+ qdev_prop_set_bit(DEVICE(&mms->fpgaio), "has-dbgctrl", false);
102
+ sysbus_realize(SYS_BUS_DEVICE(&mms->fpgaio), &error_fatal);
103
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->fpgaio), 0, 0xe0202000);
164
+
104
+
165
static void qbus_realize(BusState *bus, DeviceState *parent, const char *name)
105
+ create_unimplemented_device("clcd", 0xe0209000, 0x1000);
166
{
167
const char *typename = object_get_typename(OBJECT(bus));
168
@@ -XXX,XX +XXX,XX @@ static char *default_bus_get_fw_dev_path(DeviceState *dev)
169
return g_strdup(object_get_typename(OBJECT(dev)));
170
}
171
172
+/**
173
+ * bus_phases_reset:
174
+ * Transition reset method for buses to allow moving
175
+ * smoothly from legacy reset method to multi-phases
176
+ */
177
+static void bus_phases_reset(BusState *bus)
178
+{
179
+ ResettableClass *rc = RESETTABLE_GET_CLASS(bus);
180
+
106
+
181
+ if (rc->phases.enter) {
107
+ object_initialize_child(OBJECT(mms), "rtc", &mms->rtc, TYPE_PL031);
182
+ rc->phases.enter(OBJECT(bus), RESET_TYPE_COLD);
108
+ sysbus_realize(SYS_BUS_DEVICE(&mms->rtc), &error_fatal);
183
+ }
109
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->rtc), 0, 0xe020a000);
184
+ if (rc->phases.hold) {
110
+ sysbus_connect_irq(SYS_BUS_DEVICE(&mms->rtc), 0,
185
+ rc->phases.hold(OBJECT(bus));
111
+ qdev_get_gpio_in(gicdev, 4));
186
+ }
187
+ if (rc->phases.exit) {
188
+ rc->phases.exit(OBJECT(bus));
189
+ }
190
+}
191
+
192
+static void bus_transitional_reset(Object *obj)
193
+{
194
+ BusClass *bc = BUS_GET_CLASS(obj);
195
+
112
+
196
+ /*
113
+ /*
197
+ * This will call either @bus_phases_reset (for multi-phases transitioned
114
+ * In hardware this is a LAN9220; the LAN9118 is software compatible
198
+ * buses) or a bus's specific method for not-yet transitioned buses.
115
+ * except that it doesn't support the checksum-offload feature.
199
+ * In both case, it does not reset children.
200
+ */
116
+ */
201
+ if (bc->reset) {
117
+ lan9118_init(0xe0300000,
202
+ bc->reset(BUS(obj));
118
+ qdev_get_gpio_in(gicdev, 18));
203
+ }
204
+}
205
+
119
+
206
+/**
120
+ create_unimplemented_device("usb", 0xe0301000, 0x1000);
207
+ * bus_get_transitional_reset:
121
+ create_unimplemented_device("qspi-write-config", 0xe0600000, 0x1000);
208
+ * check if the bus's class is ready for multi-phase
209
+ */
210
+static ResettableTrFunction bus_get_transitional_reset(Object *obj)
211
+{
212
+ BusClass *dc = BUS_GET_CLASS(obj);
213
+ if (dc->reset != bus_phases_reset) {
214
+ /*
215
+ * dc->reset has been overridden by a subclass,
216
+ * the bus is not ready for multi phase yet.
217
+ */
218
+ return bus_transitional_reset;
219
+ }
220
+ return NULL;
221
+}
222
+
122
+
223
static void bus_class_init(ObjectClass *class, void *data)
123
mms->bootinfo.ram_size = machine->ram_size;
224
{
124
mms->bootinfo.board_id = -1;
225
BusClass *bc = BUS_CLASS(class);
125
mms->bootinfo.loader_start = mmc->loader_start;
226
+ ResettableClass *rc = RESETTABLE_CLASS(class);
227
228
class->unparent = bus_unparent;
229
bc->get_fw_dev_path = default_bus_get_fw_dev_path;
230
+
231
+ rc->get_state = bus_get_reset_state;
232
+ rc->child_foreach = bus_reset_child_foreach;
233
+
234
+ /*
235
+ * @bus_phases_reset is put as the default reset method below, allowing
236
+ * to do the multi-phase transition from base classes to leaf classes. It
237
+ * allows a legacy-reset Bus class to extend a multi-phases-reset
238
+ * Bus class for the following reason:
239
+ * + If a base class B has been moved to multi-phase, then it does not
240
+ * override this default reset method and may have defined phase methods.
241
+ * + A child class C (extending class B) which uses
242
+ * bus_class_set_parent_reset() (or similar means) to override the
243
+ * reset method will still work as expected. @bus_phases_reset function
244
+ * will be registered as the parent reset method and effectively call
245
+ * parent reset phases.
246
+ */
247
+ bc->reset = bus_phases_reset;
248
+ rc->get_transitional_function = bus_get_transitional_reset;
249
}
250
251
static void qbus_finalize(Object *obj)
252
@@ -XXX,XX +XXX,XX @@ static const TypeInfo bus_info = {
253
.instance_init = qbus_initfn,
254
.instance_finalize = qbus_finalize,
255
.class_init = bus_class_init,
256
+ .interfaces = (InterfaceInfo[]) {
257
+ { TYPE_RESETTABLE_INTERFACE },
258
+ { }
259
+ },
260
};
261
262
static void bus_register_types(void)
263
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
264
index XXXXXXX..XXXXXXX 100644
265
--- a/hw/core/qdev.c
266
+++ b/hw/core/qdev.c
267
@@ -XXX,XX +XXX,XX @@ void qbus_reset_all_fn(void *opaque)
268
qbus_reset_all(bus);
269
}
270
271
+bool device_is_in_reset(DeviceState *dev)
272
+{
273
+ return resettable_is_in_reset(OBJECT(dev));
274
+}
275
+
276
+static ResettableState *device_get_reset_state(Object *obj)
277
+{
278
+ DeviceState *dev = DEVICE(obj);
279
+ return &dev->reset;
280
+}
281
+
282
+static void device_reset_child_foreach(Object *obj, ResettableChildCallback cb,
283
+ void *opaque, ResetType type)
284
+{
285
+ DeviceState *dev = DEVICE(obj);
286
+ BusState *bus;
287
+
288
+ QLIST_FOREACH(bus, &dev->child_bus, sibling) {
289
+ cb(OBJECT(bus), opaque, type);
290
+ }
291
+}
292
+
293
/* can be used as ->unplug() callback for the simple cases */
294
void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
295
DeviceState *dev, Error **errp)
296
@@ -XXX,XX +XXX,XX @@ device_vmstate_if_get_id(VMStateIf *obj)
297
return qdev_get_dev_path(dev);
298
}
299
300
+/**
301
+ * device_phases_reset:
302
+ * Transition reset method for devices to allow moving
303
+ * smoothly from legacy reset method to multi-phases
304
+ */
305
+static void device_phases_reset(DeviceState *dev)
306
+{
307
+ ResettableClass *rc = RESETTABLE_GET_CLASS(dev);
308
+
309
+ if (rc->phases.enter) {
310
+ rc->phases.enter(OBJECT(dev), RESET_TYPE_COLD);
311
+ }
312
+ if (rc->phases.hold) {
313
+ rc->phases.hold(OBJECT(dev));
314
+ }
315
+ if (rc->phases.exit) {
316
+ rc->phases.exit(OBJECT(dev));
317
+ }
318
+}
319
+
320
+static void device_transitional_reset(Object *obj)
321
+{
322
+ DeviceClass *dc = DEVICE_GET_CLASS(obj);
323
+
324
+ /*
325
+ * This will call either @device_phases_reset (for multi-phases transitioned
326
+ * devices) or a device's specific method for not-yet transitioned devices.
327
+ * In both case, it does not reset children.
328
+ */
329
+ if (dc->reset) {
330
+ dc->reset(DEVICE(obj));
331
+ }
332
+}
333
+
334
+/**
335
+ * device_get_transitional_reset:
336
+ * check if the device's class is ready for multi-phase
337
+ */
338
+static ResettableTrFunction device_get_transitional_reset(Object *obj)
339
+{
340
+ DeviceClass *dc = DEVICE_GET_CLASS(obj);
341
+ if (dc->reset != device_phases_reset) {
342
+ /*
343
+ * dc->reset has been overridden by a subclass,
344
+ * the device is not ready for multi phase yet.
345
+ */
346
+ return device_transitional_reset;
347
+ }
348
+ return NULL;
349
+}
350
+
351
static void device_class_init(ObjectClass *class, void *data)
352
{
353
DeviceClass *dc = DEVICE_CLASS(class);
354
VMStateIfClass *vc = VMSTATE_IF_CLASS(class);
355
+ ResettableClass *rc = RESETTABLE_CLASS(class);
356
357
class->unparent = device_unparent;
358
359
@@ -XXX,XX +XXX,XX @@ static void device_class_init(ObjectClass *class, void *data)
360
dc->hotpluggable = true;
361
dc->user_creatable = true;
362
vc->get_id = device_vmstate_if_get_id;
363
+ rc->get_state = device_get_reset_state;
364
+ rc->child_foreach = device_reset_child_foreach;
365
+
366
+ /*
367
+ * @device_phases_reset is put as the default reset method below, allowing
368
+ * to do the multi-phase transition from base classes to leaf classes. It
369
+ * allows a legacy-reset Device class to extend a multi-phases-reset
370
+ * Device class for the following reason:
371
+ * + If a base class B has been moved to multi-phase, then it does not
372
+ * override this default reset method and may have defined phase methods.
373
+ * + A child class C (extending class B) which uses
374
+ * device_class_set_parent_reset() (or similar means) to override the
375
+ * reset method will still work as expected. @device_phases_reset function
376
+ * will be registered as the parent reset method and effectively call
377
+ * parent reset phases.
378
+ */
379
+ dc->reset = device_phases_reset;
380
+ rc->get_transitional_function = device_get_transitional_reset;
381
382
object_class_property_add_bool(class, "realized",
383
device_get_realized, device_set_realized,
384
@@ -XXX,XX +XXX,XX @@ static const TypeInfo device_type_info = {
385
.class_size = sizeof(DeviceClass),
386
.interfaces = (InterfaceInfo[]) {
387
{ TYPE_VMSTATE_IF },
388
+ { TYPE_RESETTABLE_INTERFACE },
389
{ }
390
}
391
};
392
--
126
--
393
2.20.1
127
2.34.1
394
128
395
129
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
Add documentation for the mps3-an536 board type.
2
2
3
Since we enabled parallel TCG code generation for softmmu (see
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
commit 3468b59 "tcg: enable multiple TCG contexts in softmmu")
4
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
and its subsequent fix (commit 72649619 "add .min_cpus and
5
Message-id: 20240206132931.38376-14-peter.maydell@linaro.org
6
.default_cpus fields to machine_class"), the raspi machines are
6
---
7
restricted to always use their 4 cores:
7
docs/system/arm/mps2.rst | 37 ++++++++++++++++++++++++++++++++++---
8
1 file changed, 34 insertions(+), 3 deletions(-)
8
9
9
See in hw/arm/raspi2 (with BCM283X_NCPUS set to 4):
10
diff --git a/docs/system/arm/mps2.rst b/docs/system/arm/mps2.rst
10
11
222 static void raspi2_machine_init(MachineClass *mc)
12
223 {
13
224 mc->desc = "Raspberry Pi 2";
14
230 mc->max_cpus = BCM283X_NCPUS;
15
231 mc->min_cpus = BCM283X_NCPUS;
16
232 mc->default_cpus = BCM283X_NCPUS;
17
235 };
18
236 DEFINE_MACHINE("raspi2", raspi2_machine_init)
19
20
We can no longer use the -smp option, as we get:
21
22
$ qemu-system-arm -M raspi2 -smp 1
23
qemu-system-arm: Invalid SMP CPUs 1. The min CPUs supported by machine 'raspi2' is 4
24
25
Since we can not set the TYPE_BCM283x SOC "enabled-cpus" with -smp,
26
remove the unuseful code.
27
28
We can achieve the same by using the '-global bcm2836.enabled-cpus=1'
29
option.
30
31
Reported-by: Laurent Bonnans <laurent.bonnans@here.com>
32
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
33
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
34
Message-id: 20200120235159.18510-2-f4bug@amsat.org
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
36
---
37
hw/arm/raspi.c | 2 --
38
1 file changed, 2 deletions(-)
39
40
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
41
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/arm/raspi.c
12
--- a/docs/system/arm/mps2.rst
43
+++ b/hw/arm/raspi.c
13
+++ b/docs/system/arm/mps2.rst
44
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
14
@@ -XXX,XX +XXX,XX @@
45
/* Setup the SOC */
15
-Arm MPS2 and MPS3 boards (``mps2-an385``, ``mps2-an386``, ``mps2-an500``, ``mps2-an505``, ``mps2-an511``, ``mps2-an521``, ``mps3-an524``, ``mps3-an547``)
46
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
16
-=========================================================================================================================================================
47
&error_abort);
17
+Arm MPS2 and MPS3 boards (``mps2-an385``, ``mps2-an386``, ``mps2-an500``, ``mps2-an505``, ``mps2-an511``, ``mps2-an521``, ``mps3-an524``, ``mps3-an536``, ``mps3-an547``)
48
- object_property_set_int(OBJECT(&s->soc), machine->smp.cpus, "enabled-cpus",
18
+=========================================================================================================================================================================
49
- &error_abort);
19
50
int board_rev = version == 3 ? 0xa02082 : 0xa21041;
20
-These board models all use Arm M-profile CPUs.
51
object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev",
21
+These board models use Arm M-profile or R-profile CPUs.
52
&error_abort);
22
23
The Arm MPS2, MPS2+ and MPS3 dev boards are FPGA based (the 2+ has a
24
bigger FPGA but is otherwise the same as the 2; the 3 has a bigger
25
@@ -XXX,XX +XXX,XX @@ FPGA image.
26
27
QEMU models the following FPGA images:
28
29
+FPGA images using M-profile CPUs:
30
+
31
``mps2-an385``
32
Cortex-M3 as documented in Arm Application Note AN385
33
``mps2-an386``
34
@@ -XXX,XX +XXX,XX @@ QEMU models the following FPGA images:
35
``mps3-an547``
36
Cortex-M55 on an MPS3, as documented in Arm Application Note AN547
37
38
+FPGA images using R-profile CPUs:
39
+
40
+``mps3-an536``
41
+ Dual Cortex-R52 on an MPS3, as documented in Arm Application Note AN536
42
+
43
Differences between QEMU and real hardware:
44
45
- AN385/AN386 remapping of low 16K of memory to either ZBT SSRAM1 or to
46
@@ -XXX,XX +XXX,XX @@ Differences between QEMU and real hardware:
47
flash, but only as simple ROM, so attempting to rewrite the flash
48
from the guest will fail
49
- QEMU does not model the USB controller in MPS3 boards
50
+- AN536 does not support runtime control of CPU reset and halt via
51
+ the SCC CFG_REG0 register.
52
+- AN536 does not support enabling or disabling the flash and ATCM
53
+ interfaces via the SCC CFG_REG1 register.
54
+- AN536 does not support setting of the initial vector table
55
+ base address via the SCC CFG_REG6 and CFG_REG7 register config,
56
+ and does not provide a mechanism for specifying these values at
57
+ startup, so all guest images must be built to start from TCM
58
+ (i.e. to expect the interrupt vector base at 0 from reset).
59
+- AN536 defaults to only creating a single CPU; this is the equivalent
60
+ of the way the real FPGA image usually runs with the second Cortex-R52
61
+ held in halt via the initial SCC CFG_REG0 register setting. You can
62
+ create the second CPU with ``-smp 2``; both CPUs will then start
63
+ execution immediately on startup.
64
+
65
+Note that for the AN536 the first UART is accessible only by
66
+CPU0, and the second UART is accessible only by CPU1. The
67
+first UART accessible shared between both CPUs is the third
68
+UART. Guest software might therefore be built to use either
69
+the first UART or the third UART; if you don't see any output
70
+from the UART you are looking at, try one of the others.
71
+(Even if the AN536 machine is started with a single CPU and so
72
+no "CPU1-only UART", the UART numbering remains the same,
73
+with the third UART being the first of the shared ones.)
74
75
Machine-specific options
76
""""""""""""""""""""""""
53
--
77
--
54
2.20.1
78
2.34.1
55
79
56
80
diff view generated by jsdifflib