1
Hi; this is the latest target-arm queue. Most of the patches
1
Hi; here's a relatively small target-arm queue, pretty much all
2
here are RTH's FEAT_HAFDBS finally landing. I've also included
2
bug fixes. (There are a few non-arm patches that I've thrown in
3
the RNG-seed randomization patches from Jason, as well as a few
3
there too for my convenience :-))
4
more minor things. The patches include a couple of regression
5
fixes:
6
* the resettable patch fixes a SCSI reset regression
7
* the 'do not re-randomize on snapshot load' patches fix
8
record-and-replay regressions
9
4
10
thanks
5
thanks
11
-- PMM
6
-- PMM
12
7
13
The following changes since commit e750a7ace492f0b450653d4ad368a77d6f660fb8:
8
The following changes since commit 278238505d28d292927bff7683f39fb4fbca7fd1:
14
9
15
Merge tag 'pull-9p-20221024' of https://github.com/cschoenebeck/qemu into staging (2022-10-24 14:27:12 -0400)
10
Merge tag 'pull-tcg-20230511-2' of https://gitlab.com/rth7680/qemu into staging (2023-05-11 11:44:23 +0100)
16
11
17
are available in the Git repository at:
12
are available in the Git repository at:
18
13
19
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20221025
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230512
20
15
21
for you to fetch changes up to e2114f701c78f76246e4b1872639dad94a6bdd21:
16
for you to fetch changes up to 478dccbb99db0bf8f00537dd0b4d0de88d5cb537:
22
17
23
rx: re-randomize rng-seed on reboot (2022-10-25 17:32:24 +0100)
18
target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check (2023-05-12 16:01:25 +0100)
24
19
25
----------------------------------------------------------------
20
----------------------------------------------------------------
26
target-arm queue:
21
target-arm queue:
27
* Implement FEAT_E0PD
22
* More refactoring of files into tcg/
28
* Implement FEAT_HAFDBS
23
* Don't allow stage 2 page table walks to downgrade to NS
29
* honor HCR_E2H and HCR_TGE in arm_excp_unmasked()
24
* Fix handling of SW and NSW bits for stage 2 walks
30
* hw/arm/virt: Fix devicetree warnings about the virtio-iommu node
25
* MAINTAINERS: Update Akihiko Odaki's email address
31
* hw/core/resettable: fix reset level counting
26
* ui: Fix pixel colour channel order for PNG screenshots
32
* hw/hyperv/hyperv.c: Use device_cold_reset() instead of device_legacy_reset()
27
* docs: Remove unused weirdly-named cross-reference targets
33
* imx: reload cmp timer outside of the reload ptimer transaction
28
* hw/mips/malta: Fix minor dead code issue
34
* x86: do not re-randomize RNG seed on snapshot load
29
* Fixes for the "allow CONFIG_TCG=n" changes
35
* m68k/virt: do not re-randomize RNG seed on snapshot load
30
* tests/qtest: Don't run cdrom boot tests if no accelerator is present
36
* m68k/q800: do not re-randomize RNG seed on snapshot load
31
* target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check
37
* arm: re-randomize rng-seed on reboot
38
* riscv: re-randomize rng-seed on reboot
39
* mips/boston: re-randomize rng-seed on reboot
40
* openrisc: re-randomize rng-seed on reboot
41
* rx: re-randomize rng-seed on reboot
42
32
43
----------------------------------------------------------------
33
----------------------------------------------------------------
44
Ake Koomsin (1):
34
Akihiko Odaki (1):
45
target/arm: honor HCR_E2H and HCR_TGE in arm_excp_unmasked()
35
MAINTAINERS: Update Akihiko Odaki's email address
46
36
47
Axel Heider (1):
37
Fabiano Rosas (3):
48
target/imx: reload cmp timer outside of the reload ptimer transaction
38
target/arm: Select SEMIHOSTING when using TCG
39
target/arm: Select CONFIG_ARM_V7M when TCG is enabled
40
tests/qtest: Don't run cdrom boot tests if no accelerator is present
49
41
50
Damien Hedde (1):
42
Peter Maydell (6):
51
hw/core/resettable: fix reset level counting
43
target/arm: Don't allow stage 2 page table walks to downgrade to NS
44
target/arm: Fix handling of SW and NSW bits for stage 2 walks
45
ui: Fix pixel colour channel order for PNG screenshots
46
docs: Remove unused weirdly-named cross-reference targets
47
hw/mips/malta: Fix minor dead code issue
48
target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check
52
49
53
Jason A. Donenfeld (10):
50
Richard Henderson (2):
54
reset: allow registering handlers that aren't called by snapshot loading
51
target/arm: Move translate-a32.h, arm_ldst.h, sve_ldst_internal.h to tcg/
55
device-tree: add re-randomization helper function
52
target/arm: Move helper-{a64,mve,sme,sve}.h to tcg/
56
x86: do not re-randomize RNG seed on snapshot load
57
arm: re-randomize rng-seed on reboot
58
riscv: re-randomize rng-seed on reboot
59
m68k/virt: do not re-randomize RNG seed on snapshot load
60
m68k/q800: do not re-randomize RNG seed on snapshot load
61
mips/boston: re-randomize rng-seed on reboot
62
openrisc: re-randomize rng-seed on reboot
63
rx: re-randomize rng-seed on reboot
64
53
65
Jean-Philippe Brucker (1):
54
MAINTAINERS | 4 +-
66
hw/arm/virt: Fix devicetree warnings about the virtio-iommu node
55
docs/system/devices/igb.rst | 2 +-
67
56
docs/system/devices/ivshmem.rst | 2 -
68
Peter Maydell (2):
57
docs/system/devices/net.rst | 2 +-
69
target/arm: Implement FEAT_E0PD
58
docs/system/devices/usb.rst | 2 -
70
hw/hyperv/hyperv.c: Use device_cold_reset() instead of device_legacy_reset()
59
docs/system/keys.rst | 2 +-
71
60
docs/system/linuxboot.rst | 2 +-
72
Richard Henderson (14):
61
docs/system/target-i386.rst | 4 --
73
target/arm: Introduce regime_is_stage2
62
target/arm/helper.h | 8 +--
74
target/arm: Add ptw_idx to S1Translate
63
target/arm/internals.h | 12 +++-
75
target/arm: Add isar predicates for FEAT_HAFDBS
64
target/arm/{ => tcg}/arm_ldst.h | 0
76
target/arm: Extract HA and HD in aa64_va_parameters
65
target/arm/{ => tcg}/helper-a64.h | 0
77
target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw
66
target/arm/{ => tcg}/helper-mve.h | 0
78
target/arm: Add ARMFault_UnsuppAtomicUpdate
67
target/arm/{ => tcg}/helper-sme.h | 0
79
target/arm: Remove loop from get_phys_addr_lpae
68
target/arm/{ => tcg}/helper-sve.h | 0
80
target/arm: Fix fault reporting in get_phys_addr_lpae
69
target/arm/{ => tcg}/sve_ldst_internal.h | 0
81
target/arm: Don't shift attrs in get_phys_addr_lpae
70
target/arm/{ => tcg}/translate-a32.h | 0
82
target/arm: Consider GP an attribute in get_phys_addr_lpae
71
hw/mips/malta.c | 5 +-
83
target/arm: Tidy merging of attributes from descriptor and table
72
target/arm/gdbstub64.c | 2 +-
84
target/arm: Implement FEAT_HAFDBS, access flag portion
73
target/arm/helper.c | 15 ++++-
85
target/arm: Implement FEAT_HAFDBS, dirty bit portion
74
target/arm/ptw.c | 95 +++++++++++++++++++-------------
86
target/arm: Use the max page size in a 2-stage ptw
75
target/arm/tcg/pauth_helper.c | 6 +-
87
76
tests/qtest/cdrom-test.c | 10 ++++
88
docs/devel/reset.rst | 8 +-
77
ui/console.c | 4 +-
89
docs/system/arm/emulation.rst | 2 +
78
target/arm/Kconfig | 9 +--
90
qapi/run-state.json | 6 +-
79
25 files changed, 109 insertions(+), 77 deletions(-)
91
include/hw/boards.h | 2 +-
80
rename target/arm/{ => tcg}/arm_ldst.h (100%)
92
include/sysemu/device_tree.h | 9 +
81
rename target/arm/{ => tcg}/helper-a64.h (100%)
93
include/sysemu/reset.h | 5 +-
82
rename target/arm/{ => tcg}/helper-mve.h (100%)
94
target/arm/cpu.h | 15 ++
83
rename target/arm/{ => tcg}/helper-sme.h (100%)
95
target/arm/internals.h | 30 +++
84
rename target/arm/{ => tcg}/helper-sve.h (100%)
96
hw/arm/aspeed.c | 4 +-
85
rename target/arm/{ => tcg}/sve_ldst_internal.h (100%)
97
hw/arm/boot.c | 2 +
86
rename target/arm/{ => tcg}/translate-a32.h (100%)
98
hw/arm/mps2-tz.c | 4 +-
99
hw/arm/virt.c | 5 +-
100
hw/core/reset.c | 17 +-
101
hw/core/resettable.c | 3 +-
102
hw/hppa/machine.c | 4 +-
103
hw/hyperv/hyperv.c | 2 +-
104
hw/i386/microvm.c | 4 +-
105
hw/i386/pc.c | 6 +-
106
hw/i386/x86.c | 2 +-
107
hw/m68k/q800.c | 33 ++-
108
hw/m68k/virt.c | 20 +-
109
hw/mips/boston.c | 3 +
110
hw/openrisc/boot.c | 3 +
111
hw/ppc/pegasos2.c | 4 +-
112
hw/ppc/pnv.c | 4 +-
113
hw/ppc/spapr.c | 4 +-
114
hw/riscv/boot.c | 3 +
115
hw/rx/rx-gdbsim.c | 3 +
116
hw/s390x/s390-virtio-ccw.c | 4 +-
117
hw/timer/imx_epit.c | 9 +-
118
migration/savevm.c | 2 +-
119
softmmu/device_tree.c | 21 ++
120
softmmu/runstate.c | 11 +-
121
target/arm/cpu.c | 24 +-
122
target/arm/cpu64.c | 2 +
123
target/arm/helper.c | 31 ++-
124
target/arm/ptw.c | 524 +++++++++++++++++++++++++++---------------
125
37 files changed, 572 insertions(+), 263 deletions(-)
diff view generated by jsdifflib
Deleted patch
1
FEAT_E0PD adds new bits E0PD0 and E0PD1 to TCR_EL1, which allow the
2
OS to forbid EL0 access to half of the address space. Since this is
3
an EL0-specific variation on the existing TCR_ELx.{EPD0,EPD1}, we can
4
implement it entirely in aa64_va_parameters().
5
1
6
This requires moving the existing regime_is_user() to internals.h
7
so that the code in helper.c can get at it.
8
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20221021160131.3531787-1-peter.maydell@linaro.org
12
---
13
docs/system/arm/emulation.rst | 1 +
14
target/arm/cpu.h | 5 +++++
15
target/arm/internals.h | 19 +++++++++++++++++++
16
target/arm/cpu64.c | 1 +
17
target/arm/helper.c | 9 +++++++++
18
target/arm/ptw.c | 19 -------------------
19
6 files changed, 35 insertions(+), 19 deletions(-)
20
21
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
22
index XXXXXXX..XXXXXXX 100644
23
--- a/docs/system/arm/emulation.rst
24
+++ b/docs/system/arm/emulation.rst
25
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
26
- FEAT_Debugv8p4 (Debug changes for v8.4)
27
- FEAT_DotProd (Advanced SIMD dot product instructions)
28
- FEAT_DoubleFault (Double Fault Extension)
29
+- FEAT_E0PD (Preventing EL0 access to halves of address maps)
30
- FEAT_ETS (Enhanced Translation Synchronization)
31
- FEAT_FCMA (Floating-point complex number instructions)
32
- FEAT_FHM (Floating-point half-precision multiplication instructions)
33
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/cpu.h
36
+++ b/target/arm/cpu.h
37
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_lva(const ARMISARegisters *id)
38
return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) != 0;
39
}
40
41
+static inline bool isar_feature_aa64_e0pd(const ARMISARegisters *id)
42
+{
43
+ return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) != 0;
44
+}
45
+
46
static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id)
47
{
48
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0;
49
diff --git a/target/arm/internals.h b/target/arm/internals.h
50
index XXXXXXX..XXXXXXX 100644
51
--- a/target/arm/internals.h
52
+++ b/target/arm/internals.h
53
@@ -XXX,XX +XXX,XX @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
54
}
55
}
56
57
+static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
58
+{
59
+ switch (mmu_idx) {
60
+ case ARMMMUIdx_E20_0:
61
+ case ARMMMUIdx_Stage1_E0:
62
+ case ARMMMUIdx_MUser:
63
+ case ARMMMUIdx_MSUser:
64
+ case ARMMMUIdx_MUserNegPri:
65
+ case ARMMMUIdx_MSUserNegPri:
66
+ return true;
67
+ default:
68
+ return false;
69
+ case ARMMMUIdx_E10_0:
70
+ case ARMMMUIdx_E10_1:
71
+ case ARMMMUIdx_E10_1_PAN:
72
+ g_assert_not_reached();
73
+ }
74
+}
75
+
76
/* Return the SCTLR value which controls this address translation regime */
77
static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx)
78
{
79
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/target/arm/cpu64.c
82
+++ b/target/arm/cpu64.c
83
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
84
t = FIELD_DP64(t, ID_AA64MMFR2, FWB, 1); /* FEAT_S2FWB */
85
t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */
86
t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */
87
+ t = FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */
88
cpu->isar.id_aa64mmfr2 = t;
89
90
t = cpu->isar.id_aa64zfr0;
91
diff --git a/target/arm/helper.c b/target/arm/helper.c
92
index XXXXXXX..XXXXXXX 100644
93
--- a/target/arm/helper.c
94
+++ b/target/arm/helper.c
95
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
96
ps = extract32(tcr, 16, 3);
97
ds = extract64(tcr, 32, 1);
98
} else {
99
+ bool e0pd;
100
+
101
/*
102
* Bit 55 is always between the two regions, and is canonical for
103
* determining if address tagging is enabled.
104
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
105
epd = extract32(tcr, 7, 1);
106
sh = extract32(tcr, 12, 2);
107
hpd = extract64(tcr, 41, 1);
108
+ e0pd = extract64(tcr, 55, 1);
109
} else {
110
tsz = extract32(tcr, 16, 6);
111
gran = tg1_to_gran_size(extract32(tcr, 30, 2));
112
epd = extract32(tcr, 23, 1);
113
sh = extract32(tcr, 28, 2);
114
hpd = extract64(tcr, 42, 1);
115
+ e0pd = extract64(tcr, 56, 1);
116
}
117
ps = extract64(tcr, 32, 3);
118
ds = extract64(tcr, 59, 1);
119
+
120
+ if (e0pd && cpu_isar_feature(aa64_e0pd, cpu) &&
121
+ regime_is_user(env, mmu_idx)) {
122
+ epd = true;
123
+ }
124
}
125
126
gran = sanitize_gran_size(cpu, gran, stage2);
127
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
128
index XXXXXXX..XXXXXXX 100644
129
--- a/target/arm/ptw.c
130
+++ b/target/arm/ptw.c
131
@@ -XXX,XX +XXX,XX @@ static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx)
132
return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0;
133
}
134
135
-static bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
136
-{
137
- switch (mmu_idx) {
138
- case ARMMMUIdx_E20_0:
139
- case ARMMMUIdx_Stage1_E0:
140
- case ARMMMUIdx_MUser:
141
- case ARMMMUIdx_MSUser:
142
- case ARMMMUIdx_MUserNegPri:
143
- case ARMMMUIdx_MSUserNegPri:
144
- return true;
145
- default:
146
- return false;
147
- case ARMMMUIdx_E10_0:
148
- case ARMMMUIdx_E10_1:
149
- case ARMMMUIdx_E10_1_PAN:
150
- g_assert_not_reached();
151
- }
152
-}
153
-
154
/* Return the TTBR associated with this translation regime */
155
static uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn)
156
{
157
--
158
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
2
1
3
The "PCI Bus Binding to: IEEE Std 1275-1994" defines the compatible
4
string for a PCIe bus or endpoint as "pci<vendorid>,<deviceid>" or
5
similar. Since the initial binding for PCI virtio-iommu didn't follow
6
this rule, it was modified to accept both strings and ensure backward
7
compatibility. Also, the unit-name for the node should be
8
"device,function".
9
10
Fix corresponding dt-validate and dtc warnings:
11
12
pcie@10000000: virtio_iommu@16:compatible: ['virtio,pci-iommu'] does not contain items matching the given schema
13
pcie@10000000: Unevaluated properties are not allowed (... 'virtio_iommu@16' were unexpected)
14
From schema: linux/Documentation/devicetree/bindings/pci/host-generic-pci.yaml
15
virtio_iommu@16: compatible: 'oneOf' conditional failed, one must be fixed:
16
['virtio,pci-iommu'] is too short
17
'pci1af4,1057' was expected
18
From schema: dtschema/schemas/pci/pci-bus.yaml
19
20
Warning (pci_device_reg): /pcie@10000000/virtio_iommu@16: PCI unit address format error, expected "2,0"
21
22
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
---
26
hw/arm/virt.c | 5 +++--
27
1 file changed, 3 insertions(+), 2 deletions(-)
28
29
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/virt.c
32
+++ b/hw/arm/virt.c
33
@@ -XXX,XX +XXX,XX @@ static void create_smmu(const VirtMachineState *vms,
34
35
static void create_virtio_iommu_dt_bindings(VirtMachineState *vms)
36
{
37
- const char compat[] = "virtio,pci-iommu";
38
+ const char compat[] = "virtio,pci-iommu\0pci1af4,1057";
39
uint16_t bdf = vms->virtio_iommu_bdf;
40
MachineState *ms = MACHINE(vms);
41
char *node;
42
43
vms->iommu_phandle = qemu_fdt_alloc_phandle(ms->fdt);
44
45
- node = g_strdup_printf("%s/virtio_iommu@%d", vms->pciehb_nodename, bdf);
46
+ node = g_strdup_printf("%s/virtio_iommu@%x,%x", vms->pciehb_nodename,
47
+ PCI_SLOT(bdf), PCI_FUNC(bdf));
48
qemu_fdt_add_subnode(ms->fdt, node);
49
qemu_fdt_setprop(ms->fdt, node, "compatible", compat, sizeof(compat));
50
qemu_fdt_setprop_sized_cells(ms->fdt, node, "reg",
51
--
52
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Ake Koomsin <ake@igel.co.jp>
2
1
3
An exception targeting EL2 from lower EL is actually maskable when
4
HCR_E2H and HCR_TGE are both set. This applies to both secure and
5
non-secure Security state.
6
7
We can remove the conditions that try to suppress masking of
8
interrupts when we are Secure and the exception targets EL2 and
9
Secure EL2 is disabled. This is OK because in that situation
10
arm_phys_excp_target_el() will never return 2 as the target EL. The
11
'not if secure' check in this function was originally written before
12
arm_hcr_el2_eff(), and back then the target EL returned by
13
arm_phys_excp_target_el() could be 2 even if we were in Secure
14
EL0/EL1; but it is no longer needed.
15
16
Signed-off-by: Ake Koomsin <ake@igel.co.jp>
17
Message-id: 20221017092432.546881-1-ake@igel.co.jp
18
[PMM: Add commit message paragraph explaining why it's OK to
19
remove the checks on secure and SCR_EEL2]
20
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
target/arm/cpu.c | 24 +++++++++++++++++-------
24
1 file changed, 17 insertions(+), 7 deletions(-)
25
26
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/cpu.c
29
+++ b/target/arm/cpu.c
30
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
31
if ((target_el > cur_el) && (target_el != 1)) {
32
/* Exceptions targeting a higher EL may not be maskable */
33
if (arm_feature(env, ARM_FEATURE_AARCH64)) {
34
- /*
35
- * 64-bit masking rules are simple: exceptions to EL3
36
- * can't be masked, and exceptions to EL2 can only be
37
- * masked from Secure state. The HCR and SCR settings
38
- * don't affect the masking logic, only the interrupt routing.
39
- */
40
- if (target_el == 3 || !secure || (env->cp15.scr_el3 & SCR_EEL2)) {
41
+ switch (target_el) {
42
+ case 2:
43
+ /*
44
+ * According to ARM DDI 0487H.a, an interrupt can be masked
45
+ * when HCR_E2H and HCR_TGE are both set regardless of the
46
+ * current Security state. Note that we need to revisit this
47
+ * part again once we need to support NMI.
48
+ */
49
+ if ((hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
50
+ unmasked = true;
51
+ }
52
+ break;
53
+ case 3:
54
+ /* Interrupt cannot be masked when the target EL is 3 */
55
unmasked = true;
56
+ break;
57
+ default:
58
+ g_assert_not_reached();
59
}
60
} else {
61
/*
62
--
63
2.25.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This fault type is to be used with FEAT_HAFDBS when
3
These files got missed when populating tcg/.
4
the guest enables hw updates, but places the tables
4
Because they are included with "", no change to the users required.
5
in memory where atomic updates are unsupported.
6
5
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Fabiano Rosas <farosas@suse.de>
10
Message-id: 20221024051851.3074715-7-richard.henderson@linaro.org
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Message-id: 20230504110412.1892411-2-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
target/arm/internals.h | 4 ++++
12
target/arm/{ => tcg}/arm_ldst.h | 0
14
1 file changed, 4 insertions(+)
13
target/arm/{ => tcg}/sve_ldst_internal.h | 0
14
target/arm/{ => tcg}/translate-a32.h | 0
15
3 files changed, 0 insertions(+), 0 deletions(-)
16
rename target/arm/{ => tcg}/arm_ldst.h (100%)
17
rename target/arm/{ => tcg}/sve_ldst_internal.h (100%)
18
rename target/arm/{ => tcg}/translate-a32.h (100%)
15
19
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
20
diff --git a/target/arm/arm_ldst.h b/target/arm/tcg/arm_ldst.h
17
index XXXXXXX..XXXXXXX 100644
21
similarity index 100%
18
--- a/target/arm/internals.h
22
rename from target/arm/arm_ldst.h
19
+++ b/target/arm/internals.h
23
rename to target/arm/tcg/arm_ldst.h
20
@@ -XXX,XX +XXX,XX @@ typedef enum ARMFaultType {
24
diff --git a/target/arm/sve_ldst_internal.h b/target/arm/tcg/sve_ldst_internal.h
21
ARMFault_AsyncExternal,
25
similarity index 100%
22
ARMFault_Debug,
26
rename from target/arm/sve_ldst_internal.h
23
ARMFault_TLBConflict,
27
rename to target/arm/tcg/sve_ldst_internal.h
24
+ ARMFault_UnsuppAtomicUpdate,
28
diff --git a/target/arm/translate-a32.h b/target/arm/tcg/translate-a32.h
25
ARMFault_Lockdown,
29
similarity index 100%
26
ARMFault_Exclusive,
30
rename from target/arm/translate-a32.h
27
ARMFault_ICacheMaint,
31
rename to target/arm/tcg/translate-a32.h
28
@@ -XXX,XX +XXX,XX @@ static inline uint32_t arm_fi_to_lfsc(ARMMMUFaultInfo *fi)
29
case ARMFault_TLBConflict:
30
fsc = 0x30;
31
break;
32
+ case ARMFault_UnsuppAtomicUpdate:
33
+ fsc = 0x31;
34
+ break;
35
case ARMFault_Lockdown:
36
fsc = 0x34;
37
break;
38
--
32
--
39
2.25.1
33
2.34.1
40
34
41
35
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Replace some gotos with some nested if statements.
3
While we cannot move the main "helper.h" out of target/arm/,
4
due to usage by generic code, we can move the sub-includes.
4
5
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Fabiano Rosas <farosas@suse.de>
7
Message-id: 20221024051851.3074715-12-richard.henderson@linaro.org
8
Message-id: 20230504110412.1892411-3-richard.henderson@linaro.org
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
11
---
10
target/arm/ptw.c | 34 ++++++++++++++++------------------
12
target/arm/helper.h | 8 ++++----
11
1 file changed, 16 insertions(+), 18 deletions(-)
13
target/arm/{ => tcg}/helper-a64.h | 0
14
target/arm/{ => tcg}/helper-mve.h | 0
15
target/arm/{ => tcg}/helper-sme.h | 0
16
target/arm/{ => tcg}/helper-sve.h | 0
17
5 files changed, 4 insertions(+), 4 deletions(-)
18
rename target/arm/{ => tcg}/helper-a64.h (100%)
19
rename target/arm/{ => tcg}/helper-mve.h (100%)
20
rename target/arm/{ => tcg}/helper-sme.h (100%)
21
rename target/arm/{ => tcg}/helper-sve.h (100%)
12
22
13
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
23
diff --git a/target/arm/helper.h b/target/arm/helper.h
14
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/ptw.c
25
--- a/target/arm/helper.h
16
+++ b/target/arm/ptw.c
26
+++ b/target/arm/helper.h
17
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
27
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_uclamp_d, TCG_CALL_NO_RWG,
18
page_size = (1ULL << ((stride * (4 - level)) + 3));
28
void, ptr, ptr, ptr, ptr, i32)
19
descaddr &= ~(hwaddr)(page_size - 1);
29
20
descaddr |= (address & (page_size - 1));
30
#ifdef TARGET_AARCH64
21
- /* Extract attributes from the descriptor */
31
-#include "helper-a64.h"
22
- attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
32
-#include "helper-sve.h"
23
33
-#include "helper-sme.h"
24
- if (regime_is_stage2(mmu_idx)) {
34
+#include "tcg/helper-a64.h"
25
- /* Stage 2 table descriptors do not include any attribute fields */
35
+#include "tcg/helper-sve.h"
26
- goto skip_attrs;
36
+#include "tcg/helper-sme.h"
27
- }
37
#endif
28
- /* Merge in attributes from table descriptors */
38
29
- attrs |= nstable << 5; /* NS */
39
-#include "helper-mve.h"
30
- if (param.hpd) {
40
+#include "tcg/helper-mve.h"
31
- /* HPD disables all the table attributes except NSTable. */
41
diff --git a/target/arm/helper-a64.h b/target/arm/tcg/helper-a64.h
32
- goto skip_attrs;
42
similarity index 100%
33
- }
43
rename from target/arm/helper-a64.h
34
- attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */
44
rename to target/arm/tcg/helper-a64.h
35
/*
45
diff --git a/target/arm/helper-mve.h b/target/arm/tcg/helper-mve.h
36
- * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
46
similarity index 100%
37
- * means "force PL1 access only", which means forcing AP[1] to 0.
47
rename from target/arm/helper-mve.h
38
+ * Extract attributes from the descriptor, and apply table descriptors.
48
rename to target/arm/tcg/helper-mve.h
39
+ * Stage 2 table descriptors do not include any attribute fields.
49
diff --git a/target/arm/helper-sme.h b/target/arm/tcg/helper-sme.h
40
+ * HPD disables all the table attributes except NSTable.
50
similarity index 100%
41
*/
51
rename from target/arm/helper-sme.h
42
- attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */
52
rename to target/arm/tcg/helper-sme.h
43
- attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */
53
diff --git a/target/arm/helper-sve.h b/target/arm/tcg/helper-sve.h
44
- skip_attrs:
54
similarity index 100%
45
+ attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
55
rename from target/arm/helper-sve.h
46
+ if (!regime_is_stage2(mmu_idx)) {
56
rename to target/arm/tcg/helper-sve.h
47
+ attrs |= nstable << 5; /* NS */
48
+ if (!param.hpd) {
49
+ attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */
50
+ /*
51
+ * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
52
+ * means "force PL1 access only", which means forcing AP[1] to 0.
53
+ */
54
+ attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */
55
+ attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */
56
+ }
57
+ }
58
59
/*
60
* Here descaddr is the final physical address, and attributes
61
--
57
--
62
2.25.1
58
2.34.1
63
59
64
60
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
Bit 63 in a Table descriptor is only the NSTable bit for stage 1
2
translations; in stage 2 it is RES0. We were incorrectly looking at
3
it all the time.
2
4
3
Always overriding fi->type was incorrect, as we would not properly
5
This causes problems if:
4
propagate the fault type from S1_ptw_translate, or arm_ldq_ptw.
6
* the stage 2 table descriptor was incorrectly setting the RES0 bit
5
Simplify things by providing a new label for a translation fault.
7
* we are doing a stage 2 translation in Secure address space for
6
For other faults, store into fi directly.
8
a NonSecure stage 1 regime -- in this case we would incorrectly
9
do an immediate downgrade to NonSecure
7
10
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
A bug elsewhere in the code currently prevents us from getting
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
to the second situation, but when we fix that it will be possible.
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
11
Message-id: 20221024051851.3074715-9-richard.henderson@linaro.org
14
Cc: qemu-stable@nongnu.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
18
Message-id: 20230504135425.2748672-2-peter.maydell@linaro.org
13
---
19
---
14
target/arm/ptw.c | 31 +++++++++++++------------------
20
target/arm/ptw.c | 5 +++--
15
1 file changed, 13 insertions(+), 18 deletions(-)
21
1 file changed, 3 insertions(+), 2 deletions(-)
16
22
17
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
23
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
18
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/ptw.c
25
--- a/target/arm/ptw.c
20
+++ b/target/arm/ptw.c
26
+++ b/target/arm/ptw.c
21
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
27
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
22
ARMCPU *cpu = env_archcpu(env);
28
descaddrmask &= ~indexmask_grainsize;
23
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
29
24
bool is_secure = ptw->in_secure;
30
/*
25
- /* Read an LPAE long-descriptor translation table. */
31
- * Secure accesses start with the page table in secure memory and
26
- ARMFaultType fault_type = ARMFault_Translation;
32
+ * Secure stage 1 accesses start with the page table in secure memory and
27
uint32_t level;
33
* can be downgraded to non-secure at any step. Non-secure accesses
28
ARMVAParameters param;
34
* remain non-secure. We implement this by just ORing in the NSTable/NS
29
uint64_t ttbr;
35
* bits at each step.
30
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
36
+ * Stage 2 never gets this kind of downgrade.
31
* so our choice is to always raise the fault.
32
*/
33
if (param.tsz_oob) {
34
- fault_type = ARMFault_Translation;
35
- goto do_fault;
36
+ goto do_translation_fault;
37
}
38
39
addrsize = 64 - 8 * param.tbi;
40
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
41
addrsize - inputsize);
42
if (-top_bits != param.select) {
43
/* The gap between the two regions is a Translation fault */
44
- fault_type = ARMFault_Translation;
45
- goto do_fault;
46
+ goto do_translation_fault;
47
}
48
}
49
50
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
51
* Translation table walk disabled => Translation fault on TLB miss
52
* Note: This is always 0 on 64-bit EL2 and EL3.
53
*/
54
- goto do_fault;
55
+ goto do_translation_fault;
56
}
57
58
if (!regime_is_stage2(mmu_idx)) {
59
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
60
if (param.ds && stride == 9 && sl2) {
61
if (sl0 != 0) {
62
level = 0;
63
- fault_type = ARMFault_Translation;
64
- goto do_fault;
65
+ goto do_translation_fault;
66
}
67
startlevel = -1;
68
} else if (!aarch64 || stride == 9) {
69
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
70
ok = check_s2_mmu_setup(cpu, aarch64, startlevel,
71
inputsize, stride, outputsize);
72
if (!ok) {
73
- fault_type = ARMFault_Translation;
74
- goto do_fault;
75
+ goto do_translation_fault;
76
}
77
level = startlevel;
78
}
79
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
80
descaddr |= extract64(ttbr, 2, 4) << 48;
81
} else if (descaddr >> outputsize) {
82
level = 0;
83
- fault_type = ARMFault_AddressSize;
84
+ fi->type = ARMFault_AddressSize;
85
goto do_fault;
86
}
87
88
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
89
90
if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) {
91
/* Invalid, or the Reserved level 3 encoding */
92
- goto do_fault;
93
+ goto do_translation_fault;
94
}
95
96
descaddr = descriptor & descaddrmask;
97
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
98
descaddr |= extract64(descriptor, 12, 4) << 48;
99
}
100
} else if (descaddr >> outputsize) {
101
- fault_type = ARMFault_AddressSize;
102
+ fi->type = ARMFault_AddressSize;
103
goto do_fault;
104
}
105
106
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
107
* Here descaddr is the final physical address, and attributes
108
* are all in attrs.
109
*/
37
*/
110
- fault_type = ARMFault_AccessFlag;
38
tableattrs = is_secure ? 0 : (1 << 4);
111
if ((attrs & (1 << 8)) == 0) {
39
112
/* Access flag */
40
next_level:
113
+ fi->type = ARMFault_AccessFlag;
41
descaddr |= (address >> (stride * (4 - level))) & indexmask;
114
goto do_fault;
42
descaddr &= ~7ULL;
115
}
43
- nstable = extract32(tableattrs, 4, 1);
116
44
+ nstable = !regime_is_stage2(mmu_idx) && extract32(tableattrs, 4, 1);
117
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
45
if (nstable) {
118
result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
46
/*
119
}
47
* Stage2_S -> Stage2 or Phys_S -> Phys_NS
120
121
- fault_type = ARMFault_Permission;
122
if (!(result->f.prot & (1 << access_type))) {
123
+ fi->type = ARMFault_Permission;
124
goto do_fault;
125
}
126
127
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
128
result->f.lg_page_size = ctz64(page_size);
129
return false;
130
131
-do_fault:
132
- fi->type = fault_type;
133
+ do_translation_fault:
134
+ fi->type = ARMFault_Translation;
135
+ do_fault:
136
fi->level = level;
137
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
138
fi->stage2 = fi->s1ptw || regime_is_stage2(mmu_idx);
139
--
48
--
140
2.25.1
49
2.34.1
141
50
142
51
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
We currently don't correctly handle the VSTCR_EL2.SW and VTCR_EL2.NSW
2
configuration bits. These allow configuration of whether the stage 2
3
page table walks for Secure IPA and NonSecure IPA should do their
4
descriptor reads from Secure or NonSecure physical addresses. (This
5
is separate from how the translation table base address and other
6
parameters are set: an NS IPA always uses VTTBR_EL2 and VTCR_EL2
7
for its base address and walk parameters, regardless of the NSW bit,
8
and similarly for Secure.)
2
9
3
Hoist the computation of the mmu_idx for the ptw up to
10
Provide a new function ptw_idx_for_stage_2() which returns the
4
get_phys_addr_with_struct and get_phys_addr_twostage.
11
MMU index to use for descriptor reads, and use it to set up
5
This removes the duplicate check for stage2 disabled
12
the .in_ptw_idx wherever we call get_phys_addr_lpae().
6
from the middle of the walk, performing it only once.
7
13
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
For a stage 2 walk, wherever we call get_phys_addr_lpae():
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
15
* .in_ptw_idx should be ptw_idx_for_stage_2() of the .in_mmu_idx
10
Tested-by: Alex Bennée <alex.bennee@linaro.org>
16
* .in_secure should be true if .in_mmu_idx is Stage2_S
11
Message-id: 20221024051851.3074715-3-richard.henderson@linaro.org
17
18
This allows us to correct S1_ptw_translate() so that it consistently
19
always sets its (out_secure, out_phys) to the result it gets from the
20
S2 walk (either by calling get_phys_addr_lpae() or by TLB lookup).
21
This makes better conceptual sense because the S2 walk should return
22
us an (address space, address) tuple, not an address that we then
23
randomly assign to S or NS.
24
25
Our previous handling of SW and NSW was broken, so guest code
26
trying to use these bits to put the s2 page tables in the "other"
27
address space wouldn't work correctly.
28
29
Cc: qemu-stable@nongnu.org
30
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1600
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
33
Message-id: 20230504135425.2748672-3-peter.maydell@linaro.org
13
---
34
---
14
target/arm/ptw.c | 71 ++++++++++++++++++++++++++++++++++++------------
35
target/arm/ptw.c | 76 ++++++++++++++++++++++++++++++++----------------
15
1 file changed, 54 insertions(+), 17 deletions(-)
36
1 file changed, 51 insertions(+), 25 deletions(-)
16
37
17
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
38
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
18
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/ptw.c
40
--- a/target/arm/ptw.c
20
+++ b/target/arm/ptw.c
41
+++ b/target/arm/ptw.c
21
@@ -XXX,XX +XXX,XX @@
42
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env)
22
43
return stage_1_mmu_idx(arm_mmu_idx(env));
23
typedef struct S1Translate {
44
}
24
ARMMMUIdx in_mmu_idx;
45
25
+ ARMMMUIdx in_ptw_idx;
46
+/*
26
bool in_secure;
47
+ * Return where we should do ptw loads from for a stage 2 walk.
27
bool in_debug;
48
+ * This depends on whether the address we are looking up is a
28
bool out_secure;
49
+ * Secure IPA or a NonSecure IPA, which we know from whether this is
50
+ * Stage2 or Stage2_S.
51
+ * If this is the Secure EL1&0 regime we need to check the NSW and SW bits.
52
+ */
53
+static ARMMMUIdx ptw_idx_for_stage_2(CPUARMState *env, ARMMMUIdx stage2idx)
54
+{
55
+ bool s2walk_secure;
56
+
57
+ /*
58
+ * We're OK to check the current state of the CPU here because
59
+ * (1) we always invalidate all TLBs when the SCR_EL3.NS bit changes
60
+ * (2) there's no way to do a lookup that cares about Stage 2 for a
61
+ * different security state to the current one for AArch64, and AArch32
62
+ * never has a secure EL2. (AArch32 ATS12NSO[UP][RW] allow EL3 to do
63
+ * an NS stage 1+2 lookup while the NS bit is 0.)
64
+ */
65
+ if (!arm_is_secure_below_el3(env) || !arm_el_is_aa64(env, 3)) {
66
+ return ARMMMUIdx_Phys_NS;
67
+ }
68
+ if (stage2idx == ARMMMUIdx_Stage2_S) {
69
+ s2walk_secure = !(env->cp15.vstcr_el2 & VSTCR_SW);
70
+ } else {
71
+ s2walk_secure = !(env->cp15.vtcr_el2 & VTCR_NSW);
72
+ }
73
+ return s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
74
+
75
+}
76
+
77
static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx)
78
{
79
return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0;
29
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
80
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
30
{
31
bool is_secure = ptw->in_secure;
32
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
81
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
33
- ARMMMUIdx s2_mmu_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
82
ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx;
34
- bool s2_phys = false;
35
+ ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx;
36
uint8_t pte_attrs;
83
uint8_t pte_attrs;
37
bool pte_secure;
84
- bool pte_secure;
38
85
39
- if (!arm_mmu_idx_is_stage1_of_2(mmu_idx)
86
ptw->out_virt = addr;
40
- || regime_translation_disabled(env, s2_mmu_idx, is_secure)) {
87
41
- s2_mmu_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
88
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
42
- s2_phys = true;
89
if (regime_is_stage2(s2_mmu_idx)) {
43
- }
44
-
45
if (unlikely(ptw->in_debug)) {
46
/*
47
* From gdbstub, do not use softmmu so that we don't modify the
48
* state of the cpu at all, including softmmu tlb contents.
49
*/
50
- if (s2_phys) {
51
- ptw->out_phys = addr;
52
- pte_attrs = 0;
53
- pte_secure = is_secure;
54
- } else {
55
+ if (regime_is_stage2(s2_mmu_idx)) {
56
S1Translate s2ptw = {
90
S1Translate s2ptw = {
57
.in_mmu_idx = s2_mmu_idx,
91
.in_mmu_idx = s2_mmu_idx,
58
+ .in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS,
92
- .in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS,
59
.in_secure = is_secure,
93
- .in_secure = is_secure,
94
+ .in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx),
95
+ .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S,
60
.in_debug = true,
96
.in_debug = true,
61
};
97
};
62
GetPhysAddrResult s2 = { };
98
GetPhysAddrResult s2 = { };
63
+
64
if (!get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD,
65
false, &s2, fi)) {
66
goto fail;
67
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
99
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
100
}
68
ptw->out_phys = s2.f.phys_addr;
101
ptw->out_phys = s2.f.phys_addr;
69
pte_attrs = s2.cacheattrs.attrs;
102
pte_attrs = s2.cacheattrs.attrs;
70
pte_secure = s2.f.attrs.secure;
103
- pte_secure = s2.f.attrs.secure;
71
+ } else {
104
+ ptw->out_secure = s2.f.attrs.secure;
72
+ /* Regime is physical. */
105
} else {
73
+ ptw->out_phys = addr;
106
/* Regime is physical. */
74
+ pte_attrs = 0;
107
ptw->out_phys = addr;
75
+ pte_secure = is_secure;
108
pte_attrs = 0;
109
- pte_secure = is_secure;
110
+ ptw->out_secure = s2_mmu_idx == ARMMMUIdx_Phys_S;
76
}
111
}
77
ptw->out_host = NULL;
112
ptw->out_host = NULL;
78
} else {
113
ptw->out_rw = false;
79
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
114
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
80
pte_secure = full->attrs.secure;
115
ptw->out_phys = full->phys_addr | (addr & ~TARGET_PAGE_MASK);
116
ptw->out_rw = full->prot & PAGE_WRITE;
117
pte_attrs = full->pte_attrs;
118
- pte_secure = full->attrs.secure;
119
+ ptw->out_secure = full->attrs.secure;
120
#else
121
g_assert_not_reached();
122
#endif
123
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
124
}
81
}
125
}
82
126
83
- if (!s2_phys) {
127
- /* Check if page table walk is to secure or non-secure PA space. */
84
+ if (regime_is_stage2(s2_mmu_idx)) {
128
- ptw->out_secure = (is_secure
85
uint64_t hcr = arm_hcr_el2_eff_secstate(env, is_secure);
129
- && !(pte_secure
86
130
- ? env->cp15.vstcr_el2 & VSTCR_SW
87
if ((hcr & HCR_PTW) && S2_attrs_are_device(hcr, pte_attrs)) {
131
- : env->cp15.vtcr_el2 & VTCR_NSW));
88
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
132
ptw->out_be = regime_translation_big_endian(env, mmu_idx);
89
descaddr |= (address >> (stride * (4 - level))) & indexmask;
133
return true;
90
descaddr &= ~7ULL;
134
91
nstable = extract32(tableattrs, 4, 1);
92
- ptw->in_secure = !nstable;
93
+ if (!nstable) {
94
+ /*
95
+ * Stage2_S -> Stage2 or Phys_S -> Phys_NS
96
+ * Assert that the non-secure idx are even, and relative order.
97
+ */
98
+ QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) != 0);
99
+ QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) != 0);
100
+ QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 != ARMMMUIdx_Phys_S);
101
+ QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 != ARMMMUIdx_Stage2_S);
102
+ ptw->in_ptw_idx &= ~1;
103
+ ptw->in_secure = false;
104
+ }
105
descriptor = arm_ldq_ptw(env, ptw, descaddr, fi);
106
if (fi->type != ARMFault_None) {
107
goto do_fault;
108
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
135
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
136
hwaddr ipa;
137
int s1_prot, s1_lgpgsz;
138
bool is_secure = ptw->in_secure;
139
- bool ret, ipa_secure, s2walk_secure;
140
+ bool ret, ipa_secure;
141
ARMCacheAttrs cacheattrs1;
142
bool is_el0;
143
uint64_t hcr;
144
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
145
146
ipa = result->f.phys_addr;
147
ipa_secure = result->f.attrs.secure;
148
- if (is_secure) {
149
- /* Select TCR based on the NS bit from the S1 walk. */
150
- s2walk_secure = !(ipa_secure
151
- ? env->cp15.vstcr_el2 & VSTCR_SW
152
- : env->cp15.vtcr_el2 & VTCR_NSW);
153
- } else {
154
- assert(!ipa_secure);
155
- s2walk_secure = false;
156
- }
109
157
110
is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0;
158
is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0;
111
ptw->in_mmu_idx = s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
159
- ptw->in_mmu_idx = s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
112
+ ptw->in_ptw_idx = s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
160
- ptw->in_ptw_idx = s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
113
ptw->in_secure = s2walk_secure;
161
- ptw->in_secure = s2walk_secure;
162
+ ptw->in_mmu_idx = ipa_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
163
+ ptw->in_secure = ipa_secure;
164
+ ptw->in_ptw_idx = ptw_idx_for_stage_2(env, ptw->in_mmu_idx);
114
165
115
/*
166
/*
167
* S1 is done, now do S2 translation.
116
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw,
168
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw,
117
ARMMMUFaultInfo *fi)
169
ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
118
{
170
break;
119
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
171
120
- ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx);
172
+ case ARMMMUIdx_Stage2:
121
bool is_secure = ptw->in_secure;
173
+ case ARMMMUIdx_Stage2_S:
122
+ ARMMMUIdx s1_mmu_idx;
174
+ /*
123
175
+ * Second stage lookup uses physical for ptw; whether this is S or
124
- if (mmu_idx != s1_mmu_idx) {
176
+ * NS may depend on the SW/NSW bits if this is a stage 2 lookup for
125
+ switch (mmu_idx) {
177
+ * the Secure EL2&0 regime.
126
+ case ARMMMUIdx_Phys_S:
178
+ */
127
+ case ARMMMUIdx_Phys_NS:
179
+ ptw->in_ptw_idx = ptw_idx_for_stage_2(env, mmu_idx);
128
+ /* Checking Phys early avoids special casing later vs regime_el. */
129
+ return get_phys_addr_disabled(env, address, access_type, mmu_idx,
130
+ is_secure, result, fi);
131
+
132
+ case ARMMMUIdx_Stage1_E0:
133
+ case ARMMMUIdx_Stage1_E1:
134
+ case ARMMMUIdx_Stage1_E1_PAN:
135
+ /* First stage lookup uses second stage for ptw. */
136
+ ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
137
+ break;
180
+ break;
138
+
181
+
139
+ case ARMMMUIdx_E10_0:
182
case ARMMMUIdx_E10_0:
140
+ s1_mmu_idx = ARMMMUIdx_Stage1_E0;
183
s1_mmu_idx = ARMMMUIdx_Stage1_E0;
141
+ goto do_twostage;
184
goto do_twostage;
142
+ case ARMMMUIdx_E10_1:
143
+ s1_mmu_idx = ARMMMUIdx_Stage1_E1;
144
+ goto do_twostage;
145
+ case ARMMMUIdx_E10_1_PAN:
146
+ s1_mmu_idx = ARMMMUIdx_Stage1_E1_PAN;
147
+ do_twostage:
148
/*
149
* Call ourselves recursively to do the stage 1 and then stage 2
150
* translations if mmu_idx is a two-stage regime, and EL2 present.
151
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw,
185
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw,
152
return get_phys_addr_twostage(env, ptw, address, access_type,
186
/* fall through */
153
result, fi);
187
154
}
188
default:
155
+ /* fall through */
189
- /* Single stage and second stage uses physical for ptw. */
156
+
190
+ /* Single stage uses physical for ptw. */
157
+ default:
191
ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
158
+ /* Single stage and second stage uses physical for ptw. */
192
break;
159
+ ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
160
+ break;
161
}
193
}
162
163
/*
164
--
194
--
165
2.25.1
195
2.34.1
166
167
diff view generated by jsdifflib
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
2
3
When the system reboots, the rng-seed that the FDT has should be
3
I am now employed by Daynix. Although my role as a reviewer of
4
re-randomized, so that the new boot gets a new seed. Since the FDT is in
4
macOS-related change is not very relevant to the employment, I decided
5
the ROM region at this point, we add a hook right after the ROM has been
5
to use the company email address to avoid confusions from different
6
added, so that we have a pointer to that copy of the FDT.
6
addresses.
7
7
8
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
8
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
9
Cc: Paul Burton <paulburton@kernel.org>
9
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
10
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11
Message-id: 20230506072333.32510-1-akihiko.odaki@daynix.com
12
Message-id: 20221025004327.568476-9-Jason@zx2c4.com
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
13
---
16
hw/mips/boston.c | 3 +++
14
MAINTAINERS | 4 ++--
17
1 file changed, 3 insertions(+)
15
1 file changed, 2 insertions(+), 2 deletions(-)
18
16
19
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
17
diff --git a/MAINTAINERS b/MAINTAINERS
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/mips/boston.c
19
--- a/MAINTAINERS
22
+++ b/hw/mips/boston.c
20
+++ b/MAINTAINERS
23
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ Core Audio framework backend
24
#include "sysemu/sysemu.h"
22
M: Gerd Hoffmann <kraxel@redhat.com>
25
#include "sysemu/qtest.h"
23
M: Philippe Mathieu-Daudé <philmd@linaro.org>
26
#include "sysemu/runstate.h"
24
R: Christian Schoenebeck <qemu_oss@crudebyte.com>
27
+#include "sysemu/reset.h"
25
-R: Akihiko Odaki <akihiko.odaki@gmail.com>
28
26
+R: Akihiko Odaki <akihiko.odaki@daynix.com>
29
#include <libfdt.h>
27
S: Odd Fixes
30
#include "qom/object.h"
28
F: audio/coreaudio.c
31
@@ -XXX,XX +XXX,XX @@ static void boston_mach_init(MachineState *machine)
29
32
/* Calculate real fdt size after filter */
30
@@ -XXX,XX +XXX,XX @@ F: docs/devel/ui.rst
33
dt_size = fdt_totalsize(dtb_load_data);
31
Cocoa graphics
34
rom_add_blob_fixed("dtb", dtb_load_data, dt_size, dtb_paddr);
32
M: Peter Maydell <peter.maydell@linaro.org>
35
+ qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
33
M: Philippe Mathieu-Daudé <philmd@linaro.org>
36
+ rom_ptr(dtb_paddr, dt_size));
34
-R: Akihiko Odaki <akihiko.odaki@gmail.com>
37
} else {
35
+R: Akihiko Odaki <akihiko.odaki@daynix.com>
38
/* Try to load file as FIT */
36
S: Odd Fixes
39
fit_err = load_fit(&boston_fit_loader, machine->kernel_filename, s);
37
F: ui/cocoa.m
38
40
--
39
--
41
2.25.1
40
2.34.1
42
41
43
42
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
When we take a PNG screenshot the ordering of the colour channels in
2
the data is not correct, resulting in the image having weird
3
colouring compared to the actual display. (Specifically, on a
4
little-endian host the blue and red channels are swapped; on
5
big-endian everything is wrong.)
2
6
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
This happens because the pixman idea of the pixel data and the libpng
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
idea differ. PIXMAN_a8r8g8b8 defines that pixels are 32-bit values,
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
with A in bits 24-31, R in bits 16-23, G in bits 8-15 and B in bits
6
Message-id: 20221024051851.3074715-5-richard.henderson@linaro.org
10
0-7. This means that on little-endian systems the bytes in memory
11
are
12
B G R A
13
and on big-endian systems they are
14
A R G B
15
16
libpng, on the other hand, thinks of pixels as being a series of
17
values for each channel, so its format PNG_COLOR_TYPE_RGB_ALPHA
18
always wants bytes in the order
19
R G B A
20
21
This isn't the same as the pixman order for either big or little
22
endian hosts.
23
24
The alpha channel is also unnecessary bulk in the output PNG file,
25
because there is no alpha information in a screenshot.
26
27
To handle the endianness issue, we already define in ui/qemu-pixman.h
28
various PIXMAN_BE_* and PIXMAN_LE_* values that give consistent
29
byte-order pixel channel formats. So we can use PIXMAN_BE_r8g8b8 and
30
PNG_COLOR_TYPE_RGB, which both have an in-memory byte order of
31
R G B
32
and 3 bytes per pixel.
33
34
(PPM format screenshots get this right; they already use the
35
PIXMAN_BE_r8g8b8 format.)
36
37
Cc: qemu-stable@nongnu.org
38
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1622
39
Fixes: 9a0a119a382867 ("Added parameter to take screenshot with screendump as PNG")
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
40
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
41
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
42
Message-id: 20230502135548.2451309-1-peter.maydell@linaro.org
8
---
43
---
9
target/arm/internals.h | 2 ++
44
ui/console.c | 4 ++--
10
target/arm/helper.c | 8 +++++++-
45
1 file changed, 2 insertions(+), 2 deletions(-)
11
2 files changed, 9 insertions(+), 1 deletion(-)
12
46
13
diff --git a/target/arm/internals.h b/target/arm/internals.h
47
diff --git a/ui/console.c b/ui/console.c
14
index XXXXXXX..XXXXXXX 100644
48
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/internals.h
49
--- a/ui/console.c
16
+++ b/target/arm/internals.h
50
+++ b/ui/console.c
17
@@ -XXX,XX +XXX,XX @@ typedef struct ARMVAParameters {
51
@@ -XXX,XX +XXX,XX @@ static bool png_save(int fd, pixman_image_t *image, Error **errp)
18
bool hpd : 1;
52
png_struct *png_ptr;
19
bool tsz_oob : 1; /* tsz has been clamped to legal range */
53
png_info *info_ptr;
20
bool ds : 1;
54
g_autoptr(pixman_image_t) linebuf =
21
+ bool ha : 1;
55
- qemu_pixman_linebuf_create(PIXMAN_a8r8g8b8, width);
22
+ bool hd : 1;
56
+ qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, width);
23
ARMGranuleSize gran : 2;
57
uint8_t *buf = (uint8_t *)pixman_image_get_data(linebuf);
24
} ARMVAParameters;
58
FILE *f = fdopen(fd, "wb");
25
59
int y;
26
diff --git a/target/arm/helper.c b/target/arm/helper.c
60
@@ -XXX,XX +XXX,XX @@ static bool png_save(int fd, pixman_image_t *image, Error **errp)
27
index XXXXXXX..XXXXXXX 100644
61
png_init_io(png_ptr, f);
28
--- a/target/arm/helper.c
62
29
+++ b/target/arm/helper.c
63
png_set_IHDR(png_ptr, info_ptr, width, height, 8,
30
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
64
- PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
31
ARMMMUIdx mmu_idx, bool data)
65
+ PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
32
{
66
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
33
uint64_t tcr = regime_tcr(env, mmu_idx);
67
34
- bool epd, hpd, tsz_oob, ds;
68
png_write_info(png_ptr, info_ptr);
35
+ bool epd, hpd, tsz_oob, ds, ha, hd;
36
int select, tsz, tbi, max_tsz, min_tsz, ps, sh;
37
ARMGranuleSize gran;
38
ARMCPU *cpu = env_archcpu(env);
39
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
40
epd = false;
41
sh = extract32(tcr, 12, 2);
42
ps = extract32(tcr, 16, 3);
43
+ ha = extract32(tcr, 21, 1) && cpu_isar_feature(aa64_hafs, cpu);
44
+ hd = extract32(tcr, 22, 1) && cpu_isar_feature(aa64_hdbs, cpu);
45
ds = extract64(tcr, 32, 1);
46
} else {
47
bool e0pd;
48
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
49
e0pd = extract64(tcr, 56, 1);
50
}
51
ps = extract64(tcr, 32, 3);
52
+ ha = extract64(tcr, 39, 1) && cpu_isar_feature(aa64_hafs, cpu);
53
+ hd = extract64(tcr, 40, 1) && cpu_isar_feature(aa64_hdbs, cpu);
54
ds = extract64(tcr, 59, 1);
55
56
if (e0pd && cpu_isar_feature(aa64_e0pd, cpu) &&
57
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
58
.hpd = hpd,
59
.tsz_oob = tsz_oob,
60
.ds = ds,
61
+ .ha = ha,
62
+ .hd = ha && hd,
63
.gran = gran,
64
};
65
}
66
--
69
--
67
2.25.1
70
2.34.1
68
71
69
72
diff view generated by jsdifflib
1
The semantic difference between the deprecated device_legacy_reset()
1
In the doc sources, we have a few cross-reference targets with odd
2
function and the newer device_cold_reset() function is that the new
2
names "pcsys_005fxyz". These are the legacy of the semi-automated
3
function resets both the device itself and any qbuses it owns,
3
conversion of the old info docs to rST (the '005f' is because ASCII
4
whereas the legacy function resets just the device itself and nothing
4
0x5f is '_' and the old info link names had underscores in them).
5
else. In hyperv_synic_reset() we reset a SynICState, which has no
5
6
qbuses, so for this purpose the two functions behave identically and
6
Remove the targets which nothing links to, and rename the two targets
7
we can stop using the deprecated one.
7
which are used to something a bit more descriptive.
8
8
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
10
Message-id: 20230421163642.1151904-1-peter.maydell@linaro.org
11
Message-id: 20221013171817.1447562-1-peter.maydell@linaro.org
11
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12
---
12
---
13
hw/hyperv/hyperv.c | 2 +-
13
docs/system/devices/igb.rst | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
14
docs/system/devices/ivshmem.rst | 2 --
15
docs/system/devices/net.rst | 2 +-
16
docs/system/devices/usb.rst | 2 --
17
docs/system/keys.rst | 2 +-
18
docs/system/linuxboot.rst | 2 +-
19
docs/system/target-i386.rst | 4 ----
20
7 files changed, 4 insertions(+), 12 deletions(-)
15
21
16
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
22
diff --git a/docs/system/devices/igb.rst b/docs/system/devices/igb.rst
17
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/hyperv/hyperv.c
24
--- a/docs/system/devices/igb.rst
19
+++ b/hw/hyperv/hyperv.c
25
+++ b/docs/system/devices/igb.rst
20
@@ -XXX,XX +XXX,XX @@ void hyperv_synic_reset(CPUState *cs)
26
@@ -XXX,XX +XXX,XX @@ Using igb
21
SynICState *synic = get_synic(cs);
27
=========
22
28
23
if (synic) {
29
Using igb should be nothing different from using another network device. See
24
- device_legacy_reset(DEVICE(synic));
30
-:ref:`pcsys_005fnetwork` in general.
25
+ device_cold_reset(DEVICE(synic));
31
+:ref:`Network_emulation` in general.
26
}
32
27
}
33
However, you may also need to perform additional steps to activate SR-IOV
34
feature on your guest. For Linux, refer to [4]_.
35
diff --git a/docs/system/devices/ivshmem.rst b/docs/system/devices/ivshmem.rst
36
index XXXXXXX..XXXXXXX 100644
37
--- a/docs/system/devices/ivshmem.rst
38
+++ b/docs/system/devices/ivshmem.rst
39
@@ -XXX,XX +XXX,XX @@
40
-.. _pcsys_005fivshmem:
41
-
42
Inter-VM Shared Memory device
43
-----------------------------
44
45
diff --git a/docs/system/devices/net.rst b/docs/system/devices/net.rst
46
index XXXXXXX..XXXXXXX 100644
47
--- a/docs/system/devices/net.rst
48
+++ b/docs/system/devices/net.rst
49
@@ -XXX,XX +XXX,XX @@
50
-.. _pcsys_005fnetwork:
51
+.. _Network_Emulation:
52
53
Network emulation
54
-----------------
55
diff --git a/docs/system/devices/usb.rst b/docs/system/devices/usb.rst
56
index XXXXXXX..XXXXXXX 100644
57
--- a/docs/system/devices/usb.rst
58
+++ b/docs/system/devices/usb.rst
59
@@ -XXX,XX +XXX,XX @@
60
-.. _pcsys_005fusb:
61
-
62
USB emulation
63
-------------
64
65
diff --git a/docs/system/keys.rst b/docs/system/keys.rst
66
index XXXXXXX..XXXXXXX 100644
67
--- a/docs/system/keys.rst
68
+++ b/docs/system/keys.rst
69
@@ -XXX,XX +XXX,XX @@
70
-.. _pcsys_005fkeys:
71
+.. _GUI_keys:
72
73
Keys in the graphical frontends
74
-------------------------------
75
diff --git a/docs/system/linuxboot.rst b/docs/system/linuxboot.rst
76
index XXXXXXX..XXXXXXX 100644
77
--- a/docs/system/linuxboot.rst
78
+++ b/docs/system/linuxboot.rst
79
@@ -XXX,XX +XXX,XX @@ virtual serial port and the QEMU monitor to the console with the
80
-append "root=/dev/hda console=ttyS0" -nographic
81
82
Use Ctrl-a c to switch between the serial console and the monitor (see
83
-:ref:`pcsys_005fkeys`).
84
+:ref:`GUI_keys`).
85
diff --git a/docs/system/target-i386.rst b/docs/system/target-i386.rst
86
index XXXXXXX..XXXXXXX 100644
87
--- a/docs/system/target-i386.rst
88
+++ b/docs/system/target-i386.rst
89
@@ -XXX,XX +XXX,XX @@
90
x86 System emulator
91
-------------------
92
93
-.. _pcsys_005fdevices:
94
-
95
Board-specific documentation
96
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97
98
@@ -XXX,XX +XXX,XX @@ Architectural features
99
i386/sgx
100
i386/amd-memory-encryption
101
102
-.. _pcsys_005freq:
103
-
104
OS requirements
105
~~~~~~~~~~~~~~~
28
106
29
--
107
--
30
2.25.1
108
2.34.1
diff view generated by jsdifflib
1
From: Damien Hedde <damien.hedde@greensocs.com>
1
Coverity points out (in CID 1508390) that write_bootloader has
2
some dead code, where we assign to 'p' and then in the following
3
line assign to it again. This happened as a result of the
4
refactoring in commit cd5066f8618b.
2
5
3
The code for handling the reset level count in the Resettable code
6
Fix the dead code by removing the 'void *v' variable entirely and
4
has two issues:
7
instead adding a cast when calling bl_setup_gt64120_jump_kernel(), as
8
we do at its other callsite in write_bootloader_nanomips().
5
9
6
The reset count is only decremented for the 1->0 case. This means
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
that if there's ever a nested reset that takes the count to 2 then it
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
will never again be decremented. Eventually the count will exceed
12
---
9
the '50' limit in resettable_phase_enter() and QEMU will trip over
13
hw/mips/malta.c | 5 +----
10
the assertion failure. The repro case in issue 1266 is an example of
14
1 file changed, 1 insertion(+), 4 deletions(-)
11
this that happens now the SCSI subsystem uses three-phase reset.
12
15
13
Secondly, the count is decremented only after the exit phase handler
16
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
14
is called. Moving the reset count decrement from "just after" to
15
"just before" calling the exit phase handler allows
16
resettable_is_in_reset() to return false during the handler
17
execution.
18
19
This simplifies reset handling in resettable devices. Typically, a
20
function that updates the device state will just need to read the
21
current reset state and not anymore treat the "in a reset-exit
22
transition" as a special case.
23
24
Note that the semantics change to the *_is_in_reset() functions
25
will have no effect on the current codebase, because only two
26
devices (hw/char/cadence_uart.c and hw/misc/zynq_sclr.c) currently
27
call those functions, and in neither case do they do it from the
28
device's exit phase methed.
29
30
Fixes: 4a5fc890 ("scsi: Use device_cold_reset() and bus_cold_reset()")
31
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1266
32
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
33
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
34
Reported-by: Michael Peter <michael.peter@hensoldt-cyber.com>
35
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
36
Message-id: 20221020142749.3357951-1-peter.maydell@linaro.org
37
Buglink: https://bugs.launchpad.net/qemu/+bug/1905297
38
Reported-by: Michael Peter <michael.peter@hensoldt-cyber.com>
39
[PMM: adjust the docs paragraph changed to get the name of the
40
'enter' phase right and to clarify exactly when the count is
41
adjusted; rewrite the commit message]
42
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
43
---
44
docs/devel/reset.rst | 8 +++++---
45
hw/core/resettable.c | 3 +--
46
2 files changed, 6 insertions(+), 5 deletions(-)
47
48
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
49
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
50
--- a/docs/devel/reset.rst
18
--- a/hw/mips/malta.c
51
+++ b/docs/devel/reset.rst
19
+++ b/hw/mips/malta.c
52
@@ -XXX,XX +XXX,XX @@ Polling the reset state
20
@@ -XXX,XX +XXX,XX @@ static void write_bootloader(uint8_t *base, uint64_t run_addr,
53
Resettable interface provides the ``resettable_is_in_reset()`` function.
21
uint64_t kernel_entry)
54
This function returns true if the object parameter is currently under reset.
22
{
55
23
uint32_t *p;
56
-An object is under reset from the beginning of the *init* phase to the end of
24
- void *v;
57
-the *exit* phase. During all three phases, the function will return that the
25
58
-object is in reset.
26
/* Small bootloader */
59
+An object is under reset from the beginning of the *enter* phase (before
27
p = (uint32_t *)base;
60
+either its children or its own enter method is called) to the *exit*
28
@@ -XXX,XX +XXX,XX @@ static void write_bootloader(uint8_t *base, uint64_t run_addr,
61
+phase. During *enter* and *hold* phase only, the function will return that the
29
*
62
+object is in reset. The state is changed after the *exit* is propagated to
30
*/
63
+its children and just before calling the object's own *exit* method.
31
64
32
- v = p;
65
This function may be used if the object behavior has to be adapted
33
- bl_setup_gt64120_jump_kernel(&v, run_addr, kernel_entry);
66
while in reset state. For example if a device has an irq input,
34
- p = v;
67
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
35
+ bl_setup_gt64120_jump_kernel((void **)&p, run_addr, kernel_entry);
68
index XXXXXXX..XXXXXXX 100644
36
69
--- a/hw/core/resettable.c
37
/* YAMON subroutines */
70
+++ b/hw/core/resettable.c
38
p = (uint32_t *) (base + 0x800);
71
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
72
resettable_child_foreach(rc, obj, resettable_phase_exit, NULL, type);
73
74
assert(s->count > 0);
75
- if (s->count == 1) {
76
+ if (--s->count == 0) {
77
trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
78
if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
79
rc->phases.exit(obj);
80
}
81
- s->count = 0;
82
}
83
s->exit_phase_in_progress = false;
84
trace_resettable_phase_exit_end(obj, obj_typename, s->count);
85
--
39
--
86
2.25.1
40
2.34.1
87
41
88
42
diff view generated by jsdifflib
Deleted patch
1
From: Axel Heider <axel.heider@hensoldt.net>
2
1
3
When running seL4 tests (https://docs.sel4.systems/projects/sel4test)
4
on the sabrelight platform, the timer tests fail. The arm/imx6 EPIT
5
timer interrupt does not fire properly, instead of a e.g. second in
6
can take up to a minute to finally see the interrupt.
7
8
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1263
9
10
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
11
Message-id: 166663118138.13362.1229967229046092876-0@git.sr.ht
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
hw/timer/imx_epit.c | 9 +++++++--
16
1 file changed, 7 insertions(+), 2 deletions(-)
17
18
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/timer/imx_epit.c
21
+++ b/hw/timer/imx_epit.c
22
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
23
/* If IOVW bit is set then set the timer value */
24
ptimer_set_count(s->timer_reload, s->lr);
25
}
26
-
27
+ /*
28
+ * Commit the change to s->timer_reload, so it can propagate. Otherwise
29
+ * the timer interrupt may not fire properly. The commit must happen
30
+ * before calling imx_epit_reload_compare_timer(), which reads
31
+ * s->timer_reload internally again.
32
+ */
33
+ ptimer_transaction_commit(s->timer_reload);
34
imx_epit_reload_compare_timer(s);
35
ptimer_transaction_commit(s->timer_cmp);
36
- ptimer_transaction_commit(s->timer_reload);
37
break;
38
39
case 3: /* CMP */
40
--
41
2.25.1
diff view generated by jsdifflib
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
When the system reboots, the rng-seed that the FDT has should be
3
Semihosting has been made a 'default y' entry in Kconfig, which does
4
re-randomized, so that the new boot gets a new seed. Since the FDT is in
4
not work because when building --without-default-devices, the
5
the ROM region at this point, we add a hook right after the ROM has been
5
semihosting code would not be available.
6
added, so that we have a pointer to that copy of the FDT.
7
6
8
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
7
Make semihosting unconditional when TCG is present.
9
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
8
10
Message-id: 20221025004327.568476-12-Jason@zx2c4.com
9
Fixes: 29d9efca16 ("arm/Kconfig: Do not build TCG-only boards on a KVM-only build")
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20230508181611.2621-2-farosas@suse.de
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
---
14
hw/rx/rx-gdbsim.c | 3 +++
15
target/arm/Kconfig | 8 +-------
15
1 file changed, 3 insertions(+)
16
1 file changed, 1 insertion(+), 7 deletions(-)
16
17
17
diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c
18
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/rx/rx-gdbsim.c
20
--- a/target/arm/Kconfig
20
+++ b/hw/rx/rx-gdbsim.c
21
+++ b/target/arm/Kconfig
21
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@
22
#include "hw/rx/rx62n.h"
23
config ARM
23
#include "sysemu/qtest.h"
24
bool
24
#include "sysemu/device_tree.h"
25
+ select ARM_COMPATIBLE_SEMIHOSTING if TCG
25
+#include "sysemu/reset.h"
26
26
#include "hw/boards.h"
27
config AARCH64
27
#include "qom/object.h"
28
bool
28
29
select ARM
29
@@ -XXX,XX +XXX,XX @@ static void rx_gdbsim_init(MachineState *machine)
30
-
30
dtb_offset = ROUND_DOWN(machine->ram_size - dtb_size, 16);
31
-# This config exists just so we can make SEMIHOSTING default when TCG
31
rom_add_blob_fixed("dtb", dtb, dtb_size,
32
-# is selected without also changing it for other architectures.
32
SDRAM_BASE + dtb_offset);
33
-config ARM_SEMIHOSTING
33
+ qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
34
- bool
34
+ rom_ptr(SDRAM_BASE + dtb_offset, dtb_size));
35
- default y if TCG && ARM
35
/* Set dtb address to R1 */
36
- select ARM_COMPATIBLE_SEMIHOSTING
36
RX_CPU(first_cpu)->env.regs[1] = SDRAM_BASE + dtb_offset;
37
}
38
--
37
--
39
2.25.1
38
2.34.1
diff view generated by jsdifflib
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
When the system reboots, the rng-seed that the FDT has should be
3
We cannot allow this config to be disabled at the moment as not all of
4
re-randomized, so that the new boot gets a new seed. Since the FDT is in
4
the relevant code is protected by it.
5
the ROM region at this point, we add a hook right after the ROM has been
6
added, so that we have a pointer to that copy of the FDT.
7
5
8
Cc: Stafford Horne <shorne@gmail.com>
6
Commit 29d9efca16 ("arm/Kconfig: Do not build TCG-only boards on a
9
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
7
KVM-only build") moved the CONFIGs of several boards to Kconfig, so it
10
Message-id: 20221025004327.568476-11-Jason@zx2c4.com
8
is now possible that nothing selects ARM_V7M (e.g. when doing a
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
--without-default-devices build).
10
11
Return the CONFIG_ARM_V7M entry to a state where it is always selected
12
whenever TCG is available.
13
14
Fixes: 29d9efca16 ("arm/Kconfig: Do not build TCG-only boards on a KVM-only build")
15
Signed-off-by: Fabiano Rosas <farosas@suse.de>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20230508181611.2621-3-farosas@suse.de
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
19
---
14
hw/openrisc/boot.c | 3 +++
20
target/arm/Kconfig | 1 +
15
1 file changed, 3 insertions(+)
21
1 file changed, 1 insertion(+)
16
22
17
diff --git a/hw/openrisc/boot.c b/hw/openrisc/boot.c
23
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
18
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/openrisc/boot.c
25
--- a/target/arm/Kconfig
20
+++ b/hw/openrisc/boot.c
26
+++ b/target/arm/Kconfig
21
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@
22
#include "hw/openrisc/boot.h"
28
config ARM
23
#include "sysemu/device_tree.h"
29
bool
24
#include "sysemu/qtest.h"
30
select ARM_COMPATIBLE_SEMIHOSTING if TCG
25
+#include "sysemu/reset.h"
31
+ select ARM_V7M if TCG
26
32
27
#include <libfdt.h>
33
config AARCH64
28
34
bool
29
@@ -XXX,XX +XXX,XX @@ uint32_t openrisc_load_fdt(void *fdt, hwaddr load_start,
30
31
rom_add_blob_fixed_as("fdt", fdt, fdtsize, fdt_addr,
32
&address_space_memory);
33
+ qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
34
+ rom_ptr_for_as(&address_space_memory, fdt_addr, fdtsize));
35
36
return fdt_addr;
37
}
38
--
35
--
39
2.25.1
36
2.34.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
The unconditional loop was used both to iterate over levels
3
On a build configured with: --disable-tcg --enable-xen it is possible
4
and to control parsing of attributes. Use an explicit goto
4
to produce a QEMU binary with no TCG nor KVM support. Skip the cdrom
5
in both cases.
5
boot tests if that's the case.
6
6
7
While this appears less clean for iterating over levels, we
7
Fixes: 0c1ae3ff9d ("tests/qtest: Fix tests when no KVM or TCG are present")
8
will need to jump back into the middle of this loop for
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
atomic updates, which is even uglier.
9
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
10
Message-id: 20230508181611.2621-4-farosas@suse.de
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20221024051851.3074715-8-richard.henderson@linaro.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
12
---
16
target/arm/ptw.c | 192 +++++++++++++++++++++++------------------------
13
tests/qtest/cdrom-test.c | 10 ++++++++++
17
1 file changed, 96 insertions(+), 96 deletions(-)
14
1 file changed, 10 insertions(+)
18
15
19
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
20
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/ptw.c
18
--- a/tests/qtest/cdrom-test.c
22
+++ b/target/arm/ptw.c
19
+++ b/tests/qtest/cdrom-test.c
23
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
20
@@ -XXX,XX +XXX,XX @@ static void test_cdboot(gconstpointer data)
24
uint64_t descaddrmask;
21
25
bool aarch64 = arm_el_is_aa64(env, el);
22
static void add_x86_tests(void)
26
bool guarded = false;
23
{
27
+ uint64_t descriptor;
24
+ if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
28
+ bool nstable;
25
+ g_test_skip("No KVM or TCG accelerator available, skipping boot tests");
29
26
+ return;
30
/* TODO: This code does not support shareability levels. */
31
if (aarch64) {
32
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
33
* bits at each step.
34
*/
35
tableattrs = is_secure ? 0 : (1 << 4);
36
- for (;;) {
37
- uint64_t descriptor;
38
- bool nstable;
39
-
40
- descaddr |= (address >> (stride * (4 - level))) & indexmask;
41
- descaddr &= ~7ULL;
42
- nstable = extract32(tableattrs, 4, 1);
43
- if (!nstable) {
44
- /*
45
- * Stage2_S -> Stage2 or Phys_S -> Phys_NS
46
- * Assert that the non-secure idx are even, and relative order.
47
- */
48
- QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) != 0);
49
- QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) != 0);
50
- QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 != ARMMMUIdx_Phys_S);
51
- QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 != ARMMMUIdx_Stage2_S);
52
- ptw->in_ptw_idx &= ~1;
53
- ptw->in_secure = false;
54
- }
55
- if (!S1_ptw_translate(env, ptw, descaddr, fi)) {
56
- goto do_fault;
57
- }
58
- descriptor = arm_ldq_ptw(env, ptw, fi);
59
- if (fi->type != ARMFault_None) {
60
- goto do_fault;
61
- }
62
-
63
- if (!(descriptor & 1) ||
64
- (!(descriptor & 2) && (level == 3))) {
65
- /* Invalid, or the Reserved level 3 encoding */
66
- goto do_fault;
67
- }
68
-
69
- descaddr = descriptor & descaddrmask;
70
71
+ next_level:
72
+ descaddr |= (address >> (stride * (4 - level))) & indexmask;
73
+ descaddr &= ~7ULL;
74
+ nstable = extract32(tableattrs, 4, 1);
75
+ if (!nstable) {
76
/*
77
- * For FEAT_LPA and PS=6, bits [51:48] of descaddr are in [15:12]
78
- * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of
79
- * descaddr are in [9:8]. Otherwise, if descaddr is out of range,
80
- * raise AddressSizeFault.
81
+ * Stage2_S -> Stage2 or Phys_S -> Phys_NS
82
+ * Assert that the non-secure idx are even, and relative order.
83
*/
84
- if (outputsize > 48) {
85
- if (param.ds) {
86
- descaddr |= extract64(descriptor, 8, 2) << 50;
87
- } else {
88
- descaddr |= extract64(descriptor, 12, 4) << 48;
89
- }
90
- } else if (descaddr >> outputsize) {
91
- fault_type = ARMFault_AddressSize;
92
- goto do_fault;
93
- }
94
-
95
- if ((descriptor & 2) && (level < 3)) {
96
- /*
97
- * Table entry. The top five bits are attributes which may
98
- * propagate down through lower levels of the table (and
99
- * which are all arranged so that 0 means "no effect", so
100
- * we can gather them up by ORing in the bits at each level).
101
- */
102
- tableattrs |= extract64(descriptor, 59, 5);
103
- level++;
104
- indexmask = indexmask_grainsize;
105
- continue;
106
- }
107
- /*
108
- * Block entry at level 1 or 2, or page entry at level 3.
109
- * These are basically the same thing, although the number
110
- * of bits we pull in from the vaddr varies. Note that although
111
- * descaddrmask masks enough of the low bits of the descriptor
112
- * to give a correct page or table address, the address field
113
- * in a block descriptor is smaller; so we need to explicitly
114
- * clear the lower bits here before ORing in the low vaddr bits.
115
- */
116
- page_size = (1ULL << ((stride * (4 - level)) + 3));
117
- descaddr &= ~(hwaddr)(page_size - 1);
118
- descaddr |= (address & (page_size - 1));
119
- /* Extract attributes from the descriptor */
120
- attrs = extract64(descriptor, 2, 10)
121
- | (extract64(descriptor, 52, 12) << 10);
122
-
123
- if (regime_is_stage2(mmu_idx)) {
124
- /* Stage 2 table descriptors do not include any attribute fields */
125
- break;
126
- }
127
- /* Merge in attributes from table descriptors */
128
- attrs |= nstable << 3; /* NS */
129
- guarded = extract64(descriptor, 50, 1); /* GP */
130
- if (param.hpd) {
131
- /* HPD disables all the table attributes except NSTable. */
132
- break;
133
- }
134
- attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */
135
- /*
136
- * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
137
- * means "force PL1 access only", which means forcing AP[1] to 0.
138
- */
139
- attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */
140
- attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */
141
- break;
142
+ QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) != 0);
143
+ QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) != 0);
144
+ QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 != ARMMMUIdx_Phys_S);
145
+ QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 != ARMMMUIdx_Stage2_S);
146
+ ptw->in_ptw_idx &= ~1;
147
+ ptw->in_secure = false;
148
}
149
+ if (!S1_ptw_translate(env, ptw, descaddr, fi)) {
150
+ goto do_fault;
151
+ }
152
+ descriptor = arm_ldq_ptw(env, ptw, fi);
153
+ if (fi->type != ARMFault_None) {
154
+ goto do_fault;
155
+ }
27
+ }
156
+
28
+
157
+ if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) {
29
qtest_add_data_func("cdrom/boot/default", "-cdrom ", test_cdboot);
158
+ /* Invalid, or the Reserved level 3 encoding */
30
qtest_add_data_func("cdrom/boot/virtio-scsi",
159
+ goto do_fault;
31
"-device virtio-scsi -device scsi-cd,drive=cdr "
32
@@ -XXX,XX +XXX,XX @@ static void add_x86_tests(void)
33
34
static void add_s390x_tests(void)
35
{
36
+ if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
37
+ g_test_skip("No KVM or TCG accelerator available, skipping boot tests");
38
+ return;
160
+ }
39
+ }
161
+
40
+
162
+ descaddr = descriptor & descaddrmask;
41
qtest_add_data_func("cdrom/boot/default", "-cdrom ", test_cdboot);
163
+
42
qtest_add_data_func("cdrom/boot/virtio-scsi",
164
+ /*
43
"-device virtio-scsi -device scsi-cd,drive=cdr "
165
+ * For FEAT_LPA and PS=6, bits [51:48] of descaddr are in [15:12]
166
+ * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of
167
+ * descaddr are in [9:8]. Otherwise, if descaddr is out of range,
168
+ * raise AddressSizeFault.
169
+ */
170
+ if (outputsize > 48) {
171
+ if (param.ds) {
172
+ descaddr |= extract64(descriptor, 8, 2) << 50;
173
+ } else {
174
+ descaddr |= extract64(descriptor, 12, 4) << 48;
175
+ }
176
+ } else if (descaddr >> outputsize) {
177
+ fault_type = ARMFault_AddressSize;
178
+ goto do_fault;
179
+ }
180
+
181
+ if ((descriptor & 2) && (level < 3)) {
182
+ /*
183
+ * Table entry. The top five bits are attributes which may
184
+ * propagate down through lower levels of the table (and
185
+ * which are all arranged so that 0 means "no effect", so
186
+ * we can gather them up by ORing in the bits at each level).
187
+ */
188
+ tableattrs |= extract64(descriptor, 59, 5);
189
+ level++;
190
+ indexmask = indexmask_grainsize;
191
+ goto next_level;
192
+ }
193
+
194
+ /*
195
+ * Block entry at level 1 or 2, or page entry at level 3.
196
+ * These are basically the same thing, although the number
197
+ * of bits we pull in from the vaddr varies. Note that although
198
+ * descaddrmask masks enough of the low bits of the descriptor
199
+ * to give a correct page or table address, the address field
200
+ * in a block descriptor is smaller; so we need to explicitly
201
+ * clear the lower bits here before ORing in the low vaddr bits.
202
+ */
203
+ page_size = (1ULL << ((stride * (4 - level)) + 3));
204
+ descaddr &= ~(hwaddr)(page_size - 1);
205
+ descaddr |= (address & (page_size - 1));
206
+ /* Extract attributes from the descriptor */
207
+ attrs = extract64(descriptor, 2, 10)
208
+ | (extract64(descriptor, 52, 12) << 10);
209
+
210
+ if (regime_is_stage2(mmu_idx)) {
211
+ /* Stage 2 table descriptors do not include any attribute fields */
212
+ goto skip_attrs;
213
+ }
214
+ /* Merge in attributes from table descriptors */
215
+ attrs |= nstable << 3; /* NS */
216
+ guarded = extract64(descriptor, 50, 1); /* GP */
217
+ if (param.hpd) {
218
+ /* HPD disables all the table attributes except NSTable. */
219
+ goto skip_attrs;
220
+ }
221
+ attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */
222
+ /*
223
+ * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
224
+ * means "force PL1 access only", which means forcing AP[1] to 0.
225
+ */
226
+ attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */
227
+ attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */
228
+ skip_attrs:
229
+
230
/*
231
* Here descaddr is the final physical address, and attributes
232
* are all in attrs.
233
--
44
--
234
2.25.1
45
2.34.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
In check_s2_mmu_setup() we have a check that is attempting to
2
implement the part of AArch64.S2MinTxSZ that is specific to when EL1
3
is AArch32:
2
4
3
Reduce the amount of typing required for this check.
5
if !s1aarch64 then
6
// EL1 is AArch32
7
min_txsz = Min(min_txsz, 24);
4
8
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Unfortunately we got this wrong in two ways:
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
(1) The minimum txsz corresponds to a maximum inputsize, but we got
8
Message-id: 20221024051851.3074715-2-richard.henderson@linaro.org
12
the sense of the comparison wrong and were faulting for all
13
inputsizes less than 40 bits
14
15
(2) We try to implement this as an extra check that happens after
16
we've done the same txsz checks we would do for an AArch64 EL1, but
17
in fact the pseudocode is *loosening* the requirements, so that txsz
18
values that would fault for an AArch64 EL1 do not fault for AArch32
19
EL1, because it does Min(old_min, 24), not Max(old_min, 24).
20
21
You can see this also in the text of the Arm ARM in table D8-8, which
22
shows that where the implemented PA size is less than 40 bits an
23
AArch32 EL1 is still OK with a configured stage2 T0SZ for a 40 bit
24
IPA, whereas if EL1 is AArch64 then the T0SZ must be big enough to
25
constrain the IPA to the implemented PA size.
26
27
Because of part (2), we can't do this as a separate check, but
28
have to integrate it into aa64_va_parameters(). Add a new argument
29
to that function to indicate that EL1 is 32-bit. All the existing
30
callsites except the one in get_phys_addr_lpae() can pass 'false',
31
because they are either doing a lookup for a stage 1 regime or
32
else they don't care about the tsz/tsz_oob fields.
33
34
Cc: qemu-stable@nongnu.org
35
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1627
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
36
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
37
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
38
Message-id: 20230509092059.3176487-1-peter.maydell@linaro.org
10
---
39
---
11
target/arm/internals.h | 5 +++++
40
target/arm/internals.h | 12 +++++++++++-
12
target/arm/helper.c | 14 +++++---------
41
target/arm/gdbstub64.c | 2 +-
13
target/arm/ptw.c | 14 ++++++--------
42
target/arm/helper.c | 15 +++++++++++++--
14
3 files changed, 16 insertions(+), 17 deletions(-)
43
target/arm/ptw.c | 14 ++------------
44
target/arm/tcg/pauth_helper.c | 6 +++---
45
5 files changed, 30 insertions(+), 19 deletions(-)
15
46
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
47
diff --git a/target/arm/internals.h b/target/arm/internals.h
17
index XXXXXXX..XXXXXXX 100644
48
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/internals.h
49
--- a/target/arm/internals.h
19
+++ b/target/arm/internals.h
50
+++ b/target/arm/internals.h
20
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx)
51
@@ -XXX,XX +XXX,XX @@ typedef struct ARMVAParameters {
21
}
52
ARMGranuleSize gran : 2;
22
}
53
} ARMVAParameters;
23
54
24
+static inline bool regime_is_stage2(ARMMMUIdx mmu_idx)
55
+/**
25
+{
56
+ * aa64_va_parameters: Return parameters for an AArch64 virtual address
26
+ return mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S;
57
+ * @env: CPU
27
+}
58
+ * @va: virtual address to look up
28
+
59
+ * @mmu_idx: determines translation regime to use
29
/* Return the exception level which controls this address translation regime */
60
+ * @data: true if this is a data access
30
static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
61
+ * @el1_is_aa32: true if we are asking about stage 2 when EL1 is AArch32
31
{
62
+ * (ignored if @mmu_idx is for a stage 1 regime; only affects tsz/tsz_oob)
63
+ */
64
ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
65
- ARMMMUIdx mmu_idx, bool data);
66
+ ARMMMUIdx mmu_idx, bool data,
67
+ bool el1_is_aa32);
68
69
int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx);
70
int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx);
71
diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/target/arm/gdbstub64.c
74
+++ b/target/arm/gdbstub64.c
75
@@ -XXX,XX +XXX,XX @@ int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg)
76
ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env);
77
ARMVAParameters param;
78
79
- param = aa64_va_parameters(env, -is_high, mmu_idx, is_data);
80
+ param = aa64_va_parameters(env, -is_high, mmu_idx, is_data, false);
81
return gdb_get_reg64(buf, pauth_ptr_mask(param));
82
}
83
default:
32
diff --git a/target/arm/helper.c b/target/arm/helper.c
84
diff --git a/target/arm/helper.c b/target/arm/helper.c
33
index XXXXXXX..XXXXXXX 100644
85
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/helper.c
86
--- a/target/arm/helper.c
35
+++ b/target/arm/helper.c
87
+++ b/target/arm/helper.c
36
@@ -XXX,XX +XXX,XX @@ int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx)
88
@@ -XXX,XX +XXX,XX @@ static TLBIRange tlbi_aa64_get_range(CPUARMState *env, ARMMMUIdx mmuidx,
89
unsigned int page_size_granule, page_shift, num, scale, exponent;
90
/* Extract one bit to represent the va selector in use. */
91
uint64_t select = sextract64(value, 36, 1);
92
- ARMVAParameters param = aa64_va_parameters(env, select, mmuidx, true);
93
+ ARMVAParameters param = aa64_va_parameters(env, select, mmuidx, true, false);
94
TLBIRange ret = { };
95
ARMGranuleSize gran;
96
97
@@ -XXX,XX +XXX,XX @@ static ARMGranuleSize sanitize_gran_size(ARMCPU *cpu, ARMGranuleSize gran,
98
}
99
100
ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
101
- ARMMMUIdx mmu_idx, bool data)
102
+ ARMMMUIdx mmu_idx, bool data,
103
+ bool el1_is_aa32)
37
{
104
{
38
if (regime_has_2_ranges(mmu_idx)) {
105
uint64_t tcr = regime_tcr(env, mmu_idx);
39
return extract64(tcr, 37, 2);
106
bool epd, hpd, tsz_oob, ds, ha, hd;
40
- } else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
41
+ } else if (regime_is_stage2(mmu_idx)) {
42
return 0; /* VTCR_EL2 */
43
} else {
44
/* Replicate the single TBI bit so we always have 2 bits. */
45
@@ -XXX,XX +XXX,XX @@ int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx)
46
{
47
if (regime_has_2_ranges(mmu_idx)) {
48
return extract64(tcr, 51, 2);
49
- } else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
50
+ } else if (regime_is_stage2(mmu_idx)) {
51
return 0; /* VTCR_EL2 */
52
} else {
53
/* Replicate the single TBID bit so we always have 2 bits. */
54
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
55
int select, tsz, tbi, max_tsz, min_tsz, ps, sh;
56
ARMGranuleSize gran;
57
ARMCPU *cpu = env_archcpu(env);
58
- bool stage2 = mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S;
59
+ bool stage2 = regime_is_stage2(mmu_idx);
60
61
if (!regime_has_2_ranges(mmu_idx)) {
62
select = 0;
63
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
107
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
64
}
108
}
65
ds = false;
109
}
66
} else if (ds) {
110
67
- switch (mmu_idx) {
111
+ if (stage2 && el1_is_aa32) {
68
- case ARMMMUIdx_Stage2:
112
+ /*
69
- case ARMMMUIdx_Stage2_S:
113
+ * For AArch32 EL1 the min txsz (and thus max IPA size) requirements
70
+ if (regime_is_stage2(mmu_idx)) {
114
+ * are loosened: a configured IPA of 40 bits is permitted even if
71
if (gran == Gran16K) {
115
+ * the implemented PA is less than that (and so a 40 bit IPA would
72
ds = cpu_isar_feature(aa64_tgran16_2_lpa2, cpu);
116
+ * fault for an AArch64 EL1). See R_DTLMN.
73
} else {
117
+ */
74
ds = cpu_isar_feature(aa64_tgran4_2_lpa2, cpu);
118
+ min_tsz = MIN(min_tsz, 24);
75
}
119
+ }
76
- break;
120
+
77
- default:
121
if (tsz > max_tsz) {
78
+ } else {
122
tsz = max_tsz;
79
if (gran == Gran16K) {
123
tsz_oob = true;
80
ds = cpu_isar_feature(aa64_tgran16_lpa2, cpu);
81
} else {
82
ds = cpu_isar_feature(aa64_tgran4_lpa2, cpu);
83
}
84
- break;
85
}
86
if (ds) {
87
min_tsz = 12;
88
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
124
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
89
index XXXXXXX..XXXXXXX 100644
125
index XXXXXXX..XXXXXXX 100644
90
--- a/target/arm/ptw.c
126
--- a/target/arm/ptw.c
91
+++ b/target/arm/ptw.c
127
+++ b/target/arm/ptw.c
92
@@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64,
128
@@ -XXX,XX +XXX,XX @@ static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr,
93
bool have_wxn;
129
94
int wxn = 0;
130
sl0 = extract32(tcr, 6, 2);
95
131
if (is_aa64) {
96
- assert(mmu_idx != ARMMMUIdx_Stage2);
132
- /*
97
- assert(mmu_idx != ARMMMUIdx_Stage2_S);
133
- * AArch64.S2InvalidTxSZ: While we checked tsz_oob near the top of
98
+ assert(!regime_is_stage2(mmu_idx));
134
- * get_phys_addr_lpae, that used aa64_va_parameters which apply
99
135
- * to aarch64. If Stage1 is aarch32, the min_txsz is larger.
100
user_rw = simple_ap_to_rw_prot_is_user(ap, true);
136
- * See AArch64.S2MinTxSZ, where min_tsz is 24, translated to
101
if (is_user) {
137
- * inputsize is 64 - 24 = 40.
138
- */
139
- if (iasize < 40 && !arm_el_is_aa64(&cpu->env, 1)) {
140
- goto fail;
141
- }
142
-
143
/*
144
* AArch64.S2InvalidSL: Interpretation of SL depends on the page size,
145
* so interleave AArch64.S2StartLevel.
102
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
146
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
103
goto do_fault;
147
int ps;
104
}
148
105
149
param = aa64_va_parameters(env, address, mmu_idx,
106
- if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) {
150
- access_type != MMU_INST_FETCH);
107
+ if (!regime_is_stage2(mmu_idx)) {
151
+ access_type != MMU_INST_FETCH,
152
+ !arm_el_is_aa64(env, 1));
153
level = 0;
154
108
/*
155
/*
109
* The starting level depends on the virtual address size (which can
156
diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c
110
* be up to 48 bits) and the translation granule size. It indicates
157
index XXXXXXX..XXXXXXX 100644
111
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
158
--- a/target/arm/tcg/pauth_helper.c
112
attrs = extract64(descriptor, 2, 10)
159
+++ b/target/arm/tcg/pauth_helper.c
113
| (extract64(descriptor, 52, 12) << 10);
160
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
114
161
ARMPACKey *key, bool data)
115
- if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
162
{
116
+ if (regime_is_stage2(mmu_idx)) {
163
ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env);
117
/* Stage 2 table descriptors do not include any attribute fields */
164
- ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data);
118
break;
165
+ ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data, false);
119
}
166
uint64_t pac, ext_ptr, ext, test;
120
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
167
int bot_bit, top_bit;
121
168
122
ap = extract32(attrs, 4, 2);
169
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
123
170
ARMPACKey *key, bool data, int keynumber)
124
- if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
171
{
125
+ if (regime_is_stage2(mmu_idx)) {
172
ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env);
126
ns = mmu_idx == ARMMMUIdx_Stage2;
173
- ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data);
127
xn = extract32(attrs, 11, 2);
174
+ ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data, false);
128
result->f.prot = get_S2prot(env, ap, xn, s1_is_el0);
175
int bot_bit, top_bit;
129
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
176
uint64_t pac, orig_ptr, test;
130
result->f.guarded = guarded;
177
131
}
178
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
132
179
static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data)
133
- if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
180
{
134
+ if (regime_is_stage2(mmu_idx)) {
181
ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env);
135
result->cacheattrs.is_s2_format = true;
182
- ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data);
136
result->cacheattrs.attrs = extract32(attrs, 0, 4);
183
+ ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data, false);
137
} else {
184
138
@@ -XXX,XX +XXX,XX @@ do_fault:
185
return pauth_original_ptr(ptr, param);
139
fi->type = fault_type;
140
fi->level = level;
141
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
142
- fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 ||
143
- mmu_idx == ARMMMUIdx_Stage2_S);
144
+ fi->stage2 = fi->s1ptw || regime_is_stage2(mmu_idx);
145
fi->s1ns = mmu_idx == ARMMMUIdx_Stage2;
146
return true;
147
}
186
}
148
--
187
--
149
2.25.1
188
2.34.1
150
151
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
The MMFR1 field may indicate support for hardware update of
4
access flag alone, or access flag and dirty bit.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20221024051851.3074715-4-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/cpu.h | 10 ++++++++++
12
1 file changed, 10 insertions(+)
13
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
17
+++ b/target/arm/cpu.h
18
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_e0pd(const ARMISARegisters *id)
19
return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) != 0;
20
}
21
22
+static inline bool isar_feature_aa64_hafs(const ARMISARegisters *id)
23
+{
24
+ return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) != 0;
25
+}
26
+
27
+static inline bool isar_feature_aa64_hdbs(const ARMISARegisters *id)
28
+{
29
+ return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) >= 2;
30
+}
31
+
32
static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id)
33
{
34
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0;
35
--
36
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Separate S1 translation from the actual lookup.
4
Will enable lpae hardware updates.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20221024051851.3074715-6-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/ptw.c | 41 ++++++++++++++++++++++-------------------
12
1 file changed, 22 insertions(+), 19 deletions(-)
13
14
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/ptw.c
17
+++ b/target/arm/ptw.c
18
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
19
}
20
21
/* All loads done in the course of a page table walk go through here. */
22
-static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, hwaddr addr,
23
+static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw,
24
ARMMMUFaultInfo *fi)
25
{
26
CPUState *cs = env_cpu(env);
27
uint32_t data;
28
29
- if (!S1_ptw_translate(env, ptw, addr, fi)) {
30
- /* Failure. */
31
- assert(fi->s1ptw);
32
- return 0;
33
- }
34
-
35
if (likely(ptw->out_host)) {
36
/* Page tables are in RAM, and we have the host address. */
37
if (ptw->out_be) {
38
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, hwaddr addr,
39
return data;
40
}
41
42
-static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, hwaddr addr,
43
+static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw,
44
ARMMMUFaultInfo *fi)
45
{
46
CPUState *cs = env_cpu(env);
47
uint64_t data;
48
49
- if (!S1_ptw_translate(env, ptw, addr, fi)) {
50
- /* Failure. */
51
- assert(fi->s1ptw);
52
- return 0;
53
- }
54
-
55
if (likely(ptw->out_host)) {
56
/* Page tables are in RAM, and we have the host address. */
57
if (ptw->out_be) {
58
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, S1Translate *ptw,
59
fi->type = ARMFault_Translation;
60
goto do_fault;
61
}
62
- desc = arm_ldl_ptw(env, ptw, table, fi);
63
+ if (!S1_ptw_translate(env, ptw, table, fi)) {
64
+ goto do_fault;
65
+ }
66
+ desc = arm_ldl_ptw(env, ptw, fi);
67
if (fi->type != ARMFault_None) {
68
goto do_fault;
69
}
70
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, S1Translate *ptw,
71
/* Fine pagetable. */
72
table = (desc & 0xfffff000) | ((address >> 8) & 0xffc);
73
}
74
- desc = arm_ldl_ptw(env, ptw, table, fi);
75
+ if (!S1_ptw_translate(env, ptw, table, fi)) {
76
+ goto do_fault;
77
+ }
78
+ desc = arm_ldl_ptw(env, ptw, fi);
79
if (fi->type != ARMFault_None) {
80
goto do_fault;
81
}
82
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw,
83
fi->type = ARMFault_Translation;
84
goto do_fault;
85
}
86
- desc = arm_ldl_ptw(env, ptw, table, fi);
87
+ if (!S1_ptw_translate(env, ptw, table, fi)) {
88
+ goto do_fault;
89
+ }
90
+ desc = arm_ldl_ptw(env, ptw, fi);
91
if (fi->type != ARMFault_None) {
92
goto do_fault;
93
}
94
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw,
95
ns = extract32(desc, 3, 1);
96
/* Lookup l2 entry. */
97
table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc);
98
- desc = arm_ldl_ptw(env, ptw, table, fi);
99
+ if (!S1_ptw_translate(env, ptw, table, fi)) {
100
+ goto do_fault;
101
+ }
102
+ desc = arm_ldl_ptw(env, ptw, fi);
103
if (fi->type != ARMFault_None) {
104
goto do_fault;
105
}
106
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
107
ptw->in_ptw_idx &= ~1;
108
ptw->in_secure = false;
109
}
110
- descriptor = arm_ldq_ptw(env, ptw, descaddr, fi);
111
+ if (!S1_ptw_translate(env, ptw, descaddr, fi)) {
112
+ goto do_fault;
113
+ }
114
+ descriptor = arm_ldq_ptw(env, ptw, fi);
115
if (fi->type != ARMFault_None) {
116
goto do_fault;
117
}
118
--
119
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Leave the upper and lower attributes in the place they originate
4
from in the descriptor. Shifting them around is confusing, since
5
one cannot read the bit numbers out of the manual. Also, new
6
attributes have been added which would alter the shifts.
7
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20221024051851.3074715-10-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/ptw.c | 31 +++++++++++++++----------------
15
1 file changed, 15 insertions(+), 16 deletions(-)
16
17
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/ptw.c
20
+++ b/target/arm/ptw.c
21
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
22
hwaddr descaddr, indexmask, indexmask_grainsize;
23
uint32_t tableattrs;
24
target_ulong page_size;
25
- uint32_t attrs;
26
+ uint64_t attrs;
27
int32_t stride;
28
int addrsize, inputsize, outputsize;
29
uint64_t tcr = regime_tcr(env, mmu_idx);
30
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
31
descaddr &= ~(hwaddr)(page_size - 1);
32
descaddr |= (address & (page_size - 1));
33
/* Extract attributes from the descriptor */
34
- attrs = extract64(descriptor, 2, 10)
35
- | (extract64(descriptor, 52, 12) << 10);
36
+ attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(52, 12));
37
38
if (regime_is_stage2(mmu_idx)) {
39
/* Stage 2 table descriptors do not include any attribute fields */
40
goto skip_attrs;
41
}
42
/* Merge in attributes from table descriptors */
43
- attrs |= nstable << 3; /* NS */
44
+ attrs |= nstable << 5; /* NS */
45
guarded = extract64(descriptor, 50, 1); /* GP */
46
if (param.hpd) {
47
/* HPD disables all the table attributes except NSTable. */
48
goto skip_attrs;
49
}
50
- attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */
51
+ attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */
52
/*
53
* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
54
* means "force PL1 access only", which means forcing AP[1] to 0.
55
*/
56
- attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */
57
- attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */
58
+ attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */
59
+ attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */
60
skip_attrs:
61
62
/*
63
* Here descaddr is the final physical address, and attributes
64
* are all in attrs.
65
*/
66
- if ((attrs & (1 << 8)) == 0) {
67
+ if ((attrs & (1 << 10)) == 0) {
68
/* Access flag */
69
fi->type = ARMFault_AccessFlag;
70
goto do_fault;
71
}
72
73
- ap = extract32(attrs, 4, 2);
74
+ ap = extract32(attrs, 6, 2);
75
76
if (regime_is_stage2(mmu_idx)) {
77
ns = mmu_idx == ARMMMUIdx_Stage2;
78
- xn = extract32(attrs, 11, 2);
79
+ xn = extract64(attrs, 53, 2);
80
result->f.prot = get_S2prot(env, ap, xn, s1_is_el0);
81
} else {
82
- ns = extract32(attrs, 3, 1);
83
- xn = extract32(attrs, 12, 1);
84
- pxn = extract32(attrs, 11, 1);
85
+ ns = extract32(attrs, 5, 1);
86
+ xn = extract64(attrs, 54, 1);
87
+ pxn = extract64(attrs, 53, 1);
88
result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
89
}
90
91
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
92
93
if (regime_is_stage2(mmu_idx)) {
94
result->cacheattrs.is_s2_format = true;
95
- result->cacheattrs.attrs = extract32(attrs, 0, 4);
96
+ result->cacheattrs.attrs = extract32(attrs, 2, 4);
97
} else {
98
/* Index into MAIR registers for cache attributes */
99
- uint8_t attrindx = extract32(attrs, 0, 3);
100
+ uint8_t attrindx = extract32(attrs, 2, 3);
101
uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)];
102
assert(attrindx <= 7);
103
result->cacheattrs.is_s2_format = false;
104
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
105
if (param.ds) {
106
result->cacheattrs.shareability = param.sh;
107
} else {
108
- result->cacheattrs.shareability = extract32(attrs, 6, 2);
109
+ result->cacheattrs.shareability = extract32(attrs, 8, 2);
110
}
111
112
result->f.phys_addr = descaddr;
113
--
114
2.25.1
115
116
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Both GP and DBM are in the upper attribute block.
4
Extend the computation of attrs to include them,
5
then simplify the setting of guarded.
6
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Message-id: 20221024051851.3074715-11-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/ptw.c | 6 ++----
15
1 file changed, 2 insertions(+), 4 deletions(-)
16
17
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/ptw.c
20
+++ b/target/arm/ptw.c
21
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
22
uint32_t el = regime_el(env, mmu_idx);
23
uint64_t descaddrmask;
24
bool aarch64 = arm_el_is_aa64(env, el);
25
- bool guarded = false;
26
uint64_t descriptor;
27
bool nstable;
28
29
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
30
descaddr &= ~(hwaddr)(page_size - 1);
31
descaddr |= (address & (page_size - 1));
32
/* Extract attributes from the descriptor */
33
- attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(52, 12));
34
+ attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
35
36
if (regime_is_stage2(mmu_idx)) {
37
/* Stage 2 table descriptors do not include any attribute fields */
38
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
39
}
40
/* Merge in attributes from table descriptors */
41
attrs |= nstable << 5; /* NS */
42
- guarded = extract64(descriptor, 50, 1); /* GP */
43
if (param.hpd) {
44
/* HPD disables all the table attributes except NSTable. */
45
goto skip_attrs;
46
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
47
48
/* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */
49
if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) {
50
- result->f.guarded = guarded;
51
+ result->f.guarded = extract64(attrs, 50, 1); /* GP */
52
}
53
54
if (regime_is_stage2(mmu_idx)) {
55
--
56
2.25.1
57
58
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Perform the atomic update for hardware management of the access flag.
4
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20221024051851.3074715-13-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
docs/system/arm/emulation.rst | 1 +
11
target/arm/cpu64.c | 1 +
12
target/arm/ptw.c | 176 +++++++++++++++++++++++++++++-----
13
3 files changed, 156 insertions(+), 22 deletions(-)
14
15
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
16
index XXXXXXX..XXXXXXX 100644
17
--- a/docs/system/arm/emulation.rst
18
+++ b/docs/system/arm/emulation.rst
19
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
20
- FEAT_FlagM (Flag manipulation instructions v2)
21
- FEAT_FlagM2 (Enhancements to flag manipulation instructions)
22
- FEAT_GTG (Guest translation granule size)
23
+- FEAT_HAFDBS (Hardware management of the access flag and dirty bit state)
24
- FEAT_HCX (Support for the HCRX_EL2 register)
25
- FEAT_HPDS (Hierarchical permission disables)
26
- FEAT_I8MM (AArch64 Int8 matrix multiplication instructions)
27
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu64.c
30
+++ b/target/arm/cpu64.c
31
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
32
cpu->isar.id_aa64mmfr0 = t;
33
34
t = cpu->isar.id_aa64mmfr1;
35
+ t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 1); /* FEAT_HAFDBS, AF only */
36
t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */
37
t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */
38
t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */
39
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/ptw.c
42
+++ b/target/arm/ptw.c
43
@@ -XXX,XX +XXX,XX @@ typedef struct S1Translate {
44
bool in_secure;
45
bool in_debug;
46
bool out_secure;
47
+ bool out_rw;
48
bool out_be;
49
+ hwaddr out_virt;
50
hwaddr out_phys;
51
void *out_host;
52
} S1Translate;
53
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
54
uint8_t pte_attrs;
55
bool pte_secure;
56
57
+ ptw->out_virt = addr;
58
+
59
if (unlikely(ptw->in_debug)) {
60
/*
61
* From gdbstub, do not use softmmu so that we don't modify the
62
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
63
pte_secure = is_secure;
64
}
65
ptw->out_host = NULL;
66
+ ptw->out_rw = false;
67
} else {
68
CPUTLBEntryFull *full;
69
int flags;
70
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
71
goto fail;
72
}
73
ptw->out_phys = full->phys_addr;
74
+ ptw->out_rw = full->prot & PROT_WRITE;
75
pte_attrs = full->pte_attrs;
76
pte_secure = full->attrs.secure;
77
}
78
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw,
79
ARMMMUFaultInfo *fi)
80
{
81
CPUState *cs = env_cpu(env);
82
+ void *host = ptw->out_host;
83
uint32_t data;
84
85
- if (likely(ptw->out_host)) {
86
+ if (likely(host)) {
87
/* Page tables are in RAM, and we have the host address. */
88
+ data = qatomic_read((uint32_t *)host);
89
if (ptw->out_be) {
90
- data = ldl_be_p(ptw->out_host);
91
+ data = be32_to_cpu(data);
92
} else {
93
- data = ldl_le_p(ptw->out_host);
94
+ data = le32_to_cpu(data);
95
}
96
} else {
97
/* Page tables are in MMIO. */
98
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw,
99
ARMMMUFaultInfo *fi)
100
{
101
CPUState *cs = env_cpu(env);
102
+ void *host = ptw->out_host;
103
uint64_t data;
104
105
- if (likely(ptw->out_host)) {
106
+ if (likely(host)) {
107
/* Page tables are in RAM, and we have the host address. */
108
+#ifdef CONFIG_ATOMIC64
109
+ data = qatomic_read__nocheck((uint64_t *)host);
110
if (ptw->out_be) {
111
- data = ldq_be_p(ptw->out_host);
112
+ data = be64_to_cpu(data);
113
} else {
114
- data = ldq_le_p(ptw->out_host);
115
+ data = le64_to_cpu(data);
116
}
117
+#else
118
+ if (ptw->out_be) {
119
+ data = ldq_be_p(host);
120
+ } else {
121
+ data = ldq_le_p(host);
122
+ }
123
+#endif
124
} else {
125
/* Page tables are in MMIO. */
126
MemTxAttrs attrs = { .secure = ptw->out_secure };
127
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw,
128
return data;
129
}
130
131
+static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val,
132
+ uint64_t new_val, S1Translate *ptw,
133
+ ARMMMUFaultInfo *fi)
134
+{
135
+ uint64_t cur_val;
136
+ void *host = ptw->out_host;
137
+
138
+ if (unlikely(!host)) {
139
+ fi->type = ARMFault_UnsuppAtomicUpdate;
140
+ fi->s1ptw = true;
141
+ return 0;
142
+ }
143
+
144
+ /*
145
+ * Raising a stage2 Protection fault for an atomic update to a read-only
146
+ * page is delayed until it is certain that there is a change to make.
147
+ */
148
+ if (unlikely(!ptw->out_rw)) {
149
+ int flags;
150
+ void *discard;
151
+
152
+ env->tlb_fi = fi;
153
+ flags = probe_access_flags(env, ptw->out_virt, MMU_DATA_STORE,
154
+ arm_to_core_mmu_idx(ptw->in_ptw_idx),
155
+ true, &discard, 0);
156
+ env->tlb_fi = NULL;
157
+
158
+ if (unlikely(flags & TLB_INVALID_MASK)) {
159
+ assert(fi->type != ARMFault_None);
160
+ fi->s2addr = ptw->out_virt;
161
+ fi->stage2 = true;
162
+ fi->s1ptw = true;
163
+ fi->s1ns = !ptw->in_secure;
164
+ return 0;
165
+ }
166
+
167
+ /* In case CAS mismatches and we loop, remember writability. */
168
+ ptw->out_rw = true;
169
+ }
170
+
171
+#ifdef CONFIG_ATOMIC64
172
+ if (ptw->out_be) {
173
+ old_val = cpu_to_be64(old_val);
174
+ new_val = cpu_to_be64(new_val);
175
+ cur_val = qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, new_val);
176
+ cur_val = be64_to_cpu(cur_val);
177
+ } else {
178
+ old_val = cpu_to_le64(old_val);
179
+ new_val = cpu_to_le64(new_val);
180
+ cur_val = qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, new_val);
181
+ cur_val = le64_to_cpu(cur_val);
182
+ }
183
+#else
184
+ /*
185
+ * We can't support the full 64-bit atomic cmpxchg on the host.
186
+ * Because this is only used for FEAT_HAFDBS, which is only for AA64,
187
+ * we know that TCG_OVERSIZED_GUEST is set, which means that we are
188
+ * running in round-robin mode and could only race with dma i/o.
189
+ */
190
+#ifndef TCG_OVERSIZED_GUEST
191
+# error "Unexpected configuration"
192
+#endif
193
+ bool locked = qemu_mutex_iothread_locked();
194
+ if (!locked) {
195
+ qemu_mutex_lock_iothread();
196
+ }
197
+ if (ptw->out_be) {
198
+ cur_val = ldq_be_p(host);
199
+ if (cur_val == old_val) {
200
+ stq_be_p(host, new_val);
201
+ }
202
+ } else {
203
+ cur_val = ldq_le_p(host);
204
+ if (cur_val == old_val) {
205
+ stq_le_p(host, new_val);
206
+ }
207
+ }
208
+ if (!locked) {
209
+ qemu_mutex_unlock_iothread();
210
+ }
211
+#endif
212
+
213
+ return cur_val;
214
+}
215
+
216
static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx,
217
uint32_t *table, uint32_t address)
218
{
219
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
220
uint32_t el = regime_el(env, mmu_idx);
221
uint64_t descaddrmask;
222
bool aarch64 = arm_el_is_aa64(env, el);
223
- uint64_t descriptor;
224
+ uint64_t descriptor, new_descriptor;
225
bool nstable;
226
227
/* TODO: This code does not support shareability levels. */
228
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
229
if (fi->type != ARMFault_None) {
230
goto do_fault;
231
}
232
+ new_descriptor = descriptor;
233
234
+ restart_atomic_update:
235
if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) {
236
/* Invalid, or the Reserved level 3 encoding */
237
goto do_translation_fault;
238
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
239
* to give a correct page or table address, the address field
240
* in a block descriptor is smaller; so we need to explicitly
241
* clear the lower bits here before ORing in the low vaddr bits.
242
+ *
243
+ * Afterward, descaddr is the final physical address.
244
*/
245
page_size = (1ULL << ((stride * (4 - level)) + 3));
246
descaddr &= ~(hwaddr)(page_size - 1);
247
descaddr |= (address & (page_size - 1));
248
249
+ if (likely(!ptw->in_debug)) {
250
+ /*
251
+ * Access flag.
252
+ * If HA is enabled, prepare to update the descriptor below.
253
+ * Otherwise, pass the access fault on to software.
254
+ */
255
+ if (!(descriptor & (1 << 10))) {
256
+ if (param.ha) {
257
+ new_descriptor |= 1 << 10; /* AF */
258
+ } else {
259
+ fi->type = ARMFault_AccessFlag;
260
+ goto do_fault;
261
+ }
262
+ }
263
+ }
264
+
265
/*
266
- * Extract attributes from the descriptor, and apply table descriptors.
267
- * Stage 2 table descriptors do not include any attribute fields.
268
- * HPD disables all the table attributes except NSTable.
269
+ * Extract attributes from the (modified) descriptor, and apply
270
+ * table descriptors. Stage 2 table descriptors do not include
271
+ * any attribute fields. HPD disables all the table attributes
272
+ * except NSTable.
273
*/
274
- attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
275
+ attrs = new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14));
276
if (!regime_is_stage2(mmu_idx)) {
277
attrs |= nstable << 5; /* NS */
278
if (!param.hpd) {
279
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
280
}
281
}
282
283
- /*
284
- * Here descaddr is the final physical address, and attributes
285
- * are all in attrs.
286
- */
287
- if ((attrs & (1 << 10)) == 0) {
288
- /* Access flag */
289
- fi->type = ARMFault_AccessFlag;
290
- goto do_fault;
291
- }
292
-
293
ap = extract32(attrs, 6, 2);
294
-
295
if (regime_is_stage2(mmu_idx)) {
296
ns = mmu_idx == ARMMMUIdx_Stage2;
297
xn = extract64(attrs, 53, 2);
298
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
299
goto do_fault;
300
}
301
302
+ /* If FEAT_HAFDBS has made changes, update the PTE. */
303
+ if (new_descriptor != descriptor) {
304
+ new_descriptor = arm_casq_ptw(env, descriptor, new_descriptor, ptw, fi);
305
+ if (fi->type != ARMFault_None) {
306
+ goto do_fault;
307
+ }
308
+ /*
309
+ * I_YZSVV says that if the in-memory descriptor has changed,
310
+ * then we must use the information in that new value
311
+ * (which might include a different output address, different
312
+ * attributes, or generate a fault).
313
+ * Restart the handling of the descriptor value from scratch.
314
+ */
315
+ if (new_descriptor != descriptor) {
316
+ descriptor = new_descriptor;
317
+ goto restart_atomic_update;
318
+ }
319
+ }
320
+
321
if (ns) {
322
/*
323
* The NS bit will (as required by the architecture) have no effect if
324
--
325
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Perform the atomic update for hardware management of the dirty bit.
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20221024051851.3074715-14-richard.henderson@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
target/arm/cpu64.c | 2 +-
10
target/arm/ptw.c | 16 ++++++++++++++++
11
2 files changed, 17 insertions(+), 1 deletion(-)
12
13
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu64.c
16
+++ b/target/arm/cpu64.c
17
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
18
cpu->isar.id_aa64mmfr0 = t;
19
20
t = cpu->isar.id_aa64mmfr1;
21
- t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 1); /* FEAT_HAFDBS, AF only */
22
+ t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */
23
t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */
24
t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */
25
t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */
26
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/ptw.c
29
+++ b/target/arm/ptw.c
30
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
31
goto do_fault;
32
}
33
}
34
+
35
+ /*
36
+ * Dirty Bit.
37
+ * If HD is enabled, pre-emptively set/clear the appropriate AP/S2AP
38
+ * bit for writeback. The actual write protection test may still be
39
+ * overridden by tableattrs, to be merged below.
40
+ */
41
+ if (param.hd
42
+ && extract64(descriptor, 51, 1) /* DBM */
43
+ && access_type == MMU_DATA_STORE) {
44
+ if (regime_is_stage2(mmu_idx)) {
45
+ new_descriptor |= 1ull << 7; /* set S2AP[1] */
46
+ } else {
47
+ new_descriptor &= ~(1ull << 7); /* clear AP[2] */
48
+ }
49
+ }
50
}
51
52
/*
53
--
54
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
We had only been reporting the stage2 page size. This causes
4
problems if stage1 is using a larger page size (16k, 2M, etc),
5
but stage2 is using a smaller page size, because cputlb does
6
not set large_page_{addr,mask} properly.
7
8
Fix by using the max of the two page sizes.
9
10
Reported-by: Marc Zyngier <maz@kernel.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20221024051851.3074715-15-richard.henderson@linaro.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
target/arm/ptw.c | 11 ++++++++++-
17
1 file changed, 10 insertions(+), 1 deletion(-)
18
19
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/ptw.c
22
+++ b/target/arm/ptw.c
23
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
24
ARMMMUFaultInfo *fi)
25
{
26
hwaddr ipa;
27
- int s1_prot;
28
+ int s1_prot, s1_lgpgsz;
29
bool is_secure = ptw->in_secure;
30
bool ret, ipa_secure, s2walk_secure;
31
ARMCacheAttrs cacheattrs1;
32
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
33
* Save the stage1 results so that we may merge prot and cacheattrs later.
34
*/
35
s1_prot = result->f.prot;
36
+ s1_lgpgsz = result->f.lg_page_size;
37
cacheattrs1 = result->cacheattrs;
38
memset(result, 0, sizeof(*result));
39
40
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
41
return ret;
42
}
43
44
+ /*
45
+ * Use the maximum of the S1 & S2 page size, so that invalidation
46
+ * of pages > TARGET_PAGE_SIZE works correctly.
47
+ */
48
+ if (result->f.lg_page_size < s1_lgpgsz) {
49
+ result->f.lg_page_size = s1_lgpgsz;
50
+ }
51
+
52
/* Combine the S1 and S2 cache attributes. */
53
hcr = arm_hcr_el2_eff_secstate(env, is_secure);
54
if (hcr & HCR_DC) {
55
--
56
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
2
1
3
Snapshot loading only expects to call deterministic handlers, not
4
non-deterministic ones. So introduce a way of registering handlers that
5
won't be called when reseting for snapshots.
6
7
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
8
Message-id: 20221025004327.568476-2-Jason@zx2c4.com
9
[PMM: updated json doc comment with Markus' text; fixed
10
checkpatch style nit]
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
qapi/run-state.json | 6 +++++-
15
include/hw/boards.h | 2 +-
16
include/sysemu/reset.h | 5 ++++-
17
hw/arm/aspeed.c | 4 ++--
18
hw/arm/mps2-tz.c | 4 ++--
19
hw/core/reset.c | 17 ++++++++++++++++-
20
hw/hppa/machine.c | 4 ++--
21
hw/i386/microvm.c | 4 ++--
22
hw/i386/pc.c | 6 +++---
23
hw/ppc/pegasos2.c | 4 ++--
24
hw/ppc/pnv.c | 4 ++--
25
hw/ppc/spapr.c | 4 ++--
26
hw/s390x/s390-virtio-ccw.c | 4 ++--
27
migration/savevm.c | 2 +-
28
softmmu/runstate.c | 11 ++++++++---
29
15 files changed, 54 insertions(+), 27 deletions(-)
30
31
diff --git a/qapi/run-state.json b/qapi/run-state.json
32
index XXXXXXX..XXXXXXX 100644
33
--- a/qapi/run-state.json
34
+++ b/qapi/run-state.json
35
@@ -XXX,XX +XXX,XX @@
36
# ignores --no-reboot. This is useful for sanitizing
37
# hypercalls on s390 that are used during kexec/kdump/boot
38
#
39
+# @snapshot-load: A snapshot is being loaded by the record & replay
40
+# subsystem. This value is used only within QEMU. It
41
+# doesn't occur in QMP. (since 7.2)
42
+#
43
##
44
{ 'enum': 'ShutdownCause',
45
# Beware, shutdown_caused_by_guest() depends on enumeration order
46
'data': [ 'none', 'host-error', 'host-qmp-quit', 'host-qmp-system-reset',
47
'host-signal', 'host-ui', 'guest-shutdown', 'guest-reset',
48
- 'guest-panic', 'subsystem-reset'] }
49
+ 'guest-panic', 'subsystem-reset', 'snapshot-load'] }
50
51
##
52
# @StatusInfo:
53
diff --git a/include/hw/boards.h b/include/hw/boards.h
54
index XXXXXXX..XXXXXXX 100644
55
--- a/include/hw/boards.h
56
+++ b/include/hw/boards.h
57
@@ -XXX,XX +XXX,XX @@ struct MachineClass {
58
const char *deprecation_reason;
59
60
void (*init)(MachineState *state);
61
- void (*reset)(MachineState *state);
62
+ void (*reset)(MachineState *state, ShutdownCause reason);
63
void (*wakeup)(MachineState *state);
64
int (*kvm_type)(MachineState *machine, const char *arg);
65
66
diff --git a/include/sysemu/reset.h b/include/sysemu/reset.h
67
index XXXXXXX..XXXXXXX 100644
68
--- a/include/sysemu/reset.h
69
+++ b/include/sysemu/reset.h
70
@@ -XXX,XX +XXX,XX @@
71
#ifndef QEMU_SYSEMU_RESET_H
72
#define QEMU_SYSEMU_RESET_H
73
74
+#include "qapi/qapi-events-run-state.h"
75
+
76
typedef void QEMUResetHandler(void *opaque);
77
78
void qemu_register_reset(QEMUResetHandler *func, void *opaque);
79
+void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaque);
80
void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
81
-void qemu_devices_reset(void);
82
+void qemu_devices_reset(ShutdownCause reason);
83
84
#endif
85
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/hw/arm/aspeed.c
88
+++ b/hw/arm/aspeed.c
89
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_bletchley_class_init(ObjectClass *oc, void *data)
90
aspeed_soc_num_cpus(amc->soc_name);
91
}
92
93
-static void fby35_reset(MachineState *state)
94
+static void fby35_reset(MachineState *state, ShutdownCause reason)
95
{
96
AspeedMachineState *bmc = ASPEED_MACHINE(state);
97
AspeedGPIOState *gpio = &bmc->soc.gpio;
98
99
- qemu_devices_reset();
100
+ qemu_devices_reset(reason);
101
102
/* Board ID: 7 (Class-1, 4 slots) */
103
object_property_set_bool(OBJECT(gpio), "gpioV4", true, &error_fatal);
104
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
105
index XXXXXXX..XXXXXXX 100644
106
--- a/hw/arm/mps2-tz.c
107
+++ b/hw/arm/mps2-tz.c
108
@@ -XXX,XX +XXX,XX @@ static void mps2_set_remap(Object *obj, const char *value, Error **errp)
109
}
110
}
111
112
-static void mps2_machine_reset(MachineState *machine)
113
+static void mps2_machine_reset(MachineState *machine, ShutdownCause reason)
114
{
115
MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine);
116
117
@@ -XXX,XX +XXX,XX @@ static void mps2_machine_reset(MachineState *machine)
118
* reset see the correct mapping.
119
*/
120
remap_memory(mms, mms->remap);
121
- qemu_devices_reset();
122
+ qemu_devices_reset(reason);
123
}
124
125
static void mps2tz_class_init(ObjectClass *oc, void *data)
126
diff --git a/hw/core/reset.c b/hw/core/reset.c
127
index XXXXXXX..XXXXXXX 100644
128
--- a/hw/core/reset.c
129
+++ b/hw/core/reset.c
130
@@ -XXX,XX +XXX,XX @@ typedef struct QEMUResetEntry {
131
QTAILQ_ENTRY(QEMUResetEntry) entry;
132
QEMUResetHandler *func;
133
void *opaque;
134
+ bool skip_on_snapshot_load;
135
} QEMUResetEntry;
136
137
static QTAILQ_HEAD(, QEMUResetEntry) reset_handlers =
138
@@ -XXX,XX +XXX,XX @@ void qemu_register_reset(QEMUResetHandler *func, void *opaque)
139
QTAILQ_INSERT_TAIL(&reset_handlers, re, entry);
140
}
141
142
+void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaque)
143
+{
144
+ QEMUResetEntry *re = g_new0(QEMUResetEntry, 1);
145
+
146
+ re->func = func;
147
+ re->opaque = opaque;
148
+ re->skip_on_snapshot_load = true;
149
+ QTAILQ_INSERT_TAIL(&reset_handlers, re, entry);
150
+}
151
+
152
void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
153
{
154
QEMUResetEntry *re;
155
@@ -XXX,XX +XXX,XX @@ void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
156
}
157
}
158
159
-void qemu_devices_reset(void)
160
+void qemu_devices_reset(ShutdownCause reason)
161
{
162
QEMUResetEntry *re, *nre;
163
164
/* reset all devices */
165
QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
166
+ if (reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD &&
167
+ re->skip_on_snapshot_load) {
168
+ continue;
169
+ }
170
re->func(re->opaque);
171
}
172
}
173
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
174
index XXXXXXX..XXXXXXX 100644
175
--- a/hw/hppa/machine.c
176
+++ b/hw/hppa/machine.c
177
@@ -XXX,XX +XXX,XX @@ static void machine_hppa_init(MachineState *machine)
178
cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
179
}
180
181
-static void hppa_machine_reset(MachineState *ms)
182
+static void hppa_machine_reset(MachineState *ms, ShutdownCause reason)
183
{
184
unsigned int smp_cpus = ms->smp.cpus;
185
int i;
186
187
- qemu_devices_reset();
188
+ qemu_devices_reset(reason);
189
190
/* Start all CPUs at the firmware entry point.
191
* Monarch CPU will initialize firmware, secondary CPUs
192
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
193
index XXXXXXX..XXXXXXX 100644
194
--- a/hw/i386/microvm.c
195
+++ b/hw/i386/microvm.c
196
@@ -XXX,XX +XXX,XX @@ static void microvm_machine_state_init(MachineState *machine)
197
microvm_devices_init(mms);
198
}
199
200
-static void microvm_machine_reset(MachineState *machine)
201
+static void microvm_machine_reset(MachineState *machine, ShutdownCause reason)
202
{
203
MicrovmMachineState *mms = MICROVM_MACHINE(machine);
204
CPUState *cs;
205
@@ -XXX,XX +XXX,XX @@ static void microvm_machine_reset(MachineState *machine)
206
mms->kernel_cmdline_fixed = true;
207
}
208
209
- qemu_devices_reset();
210
+ qemu_devices_reset(reason);
211
212
CPU_FOREACH(cs) {
213
cpu = X86_CPU(cs);
214
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
215
index XXXXXXX..XXXXXXX 100644
216
--- a/hw/i386/pc.c
217
+++ b/hw/i386/pc.c
218
@@ -XXX,XX +XXX,XX @@ static void pc_machine_initfn(Object *obj)
219
cxl_machine_init(obj, &pcms->cxl_devices_state);
220
}
221
222
-static void pc_machine_reset(MachineState *machine)
223
+static void pc_machine_reset(MachineState *machine, ShutdownCause reason)
224
{
225
CPUState *cs;
226
X86CPU *cpu;
227
228
- qemu_devices_reset();
229
+ qemu_devices_reset(reason);
230
231
/* Reset APIC after devices have been reset to cancel
232
* any changes that qemu_devices_reset() might have done.
233
@@ -XXX,XX +XXX,XX @@ static void pc_machine_reset(MachineState *machine)
234
static void pc_machine_wakeup(MachineState *machine)
235
{
236
cpu_synchronize_all_states();
237
- pc_machine_reset(machine);
238
+ pc_machine_reset(machine, SHUTDOWN_CAUSE_NONE);
239
cpu_synchronize_all_post_reset();
240
}
241
242
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
243
index XXXXXXX..XXXXXXX 100644
244
--- a/hw/ppc/pegasos2.c
245
+++ b/hw/ppc/pegasos2.c
246
@@ -XXX,XX +XXX,XX @@ static void pegasos2_pci_config_write(Pegasos2MachineState *pm, int bus,
247
pegasos2_mv_reg_write(pm, pcicfg + 4, len, val);
248
}
249
250
-static void pegasos2_machine_reset(MachineState *machine)
251
+static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason)
252
{
253
Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
254
void *fdt;
255
uint64_t d[2];
256
int sz;
257
258
- qemu_devices_reset();
259
+ qemu_devices_reset(reason);
260
if (!pm->vof) {
261
return; /* Firmware should set up machine so nothing to do */
262
}
263
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
264
index XXXXXXX..XXXXXXX 100644
265
--- a/hw/ppc/pnv.c
266
+++ b/hw/ppc/pnv.c
267
@@ -XXX,XX +XXX,XX @@ static void pnv_powerdown_notify(Notifier *n, void *opaque)
268
}
269
}
270
271
-static void pnv_reset(MachineState *machine)
272
+static void pnv_reset(MachineState *machine, ShutdownCause reason)
273
{
274
PnvMachineState *pnv = PNV_MACHINE(machine);
275
IPMIBmc *bmc;
276
void *fdt;
277
278
- qemu_devices_reset();
279
+ qemu_devices_reset(reason);
280
281
/*
282
* The machine should provide by default an internal BMC simulator.
283
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
284
index XXXXXXX..XXXXXXX 100644
285
--- a/hw/ppc/spapr.c
286
+++ b/hw/ppc/spapr.c
287
@@ -XXX,XX +XXX,XX @@ void spapr_check_mmu_mode(bool guest_radix)
288
}
289
}
290
291
-static void spapr_machine_reset(MachineState *machine)
292
+static void spapr_machine_reset(MachineState *machine, ShutdownCause reason)
293
{
294
SpaprMachineState *spapr = SPAPR_MACHINE(machine);
295
PowerPCCPU *first_ppc_cpu;
296
@@ -XXX,XX +XXX,XX @@ static void spapr_machine_reset(MachineState *machine)
297
spapr_setup_hpt(spapr);
298
}
299
300
- qemu_devices_reset();
301
+ qemu_devices_reset(reason);
302
303
spapr_ovec_cleanup(spapr->ov5_cas);
304
spapr->ov5_cas = spapr_ovec_new();
305
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
306
index XXXXXXX..XXXXXXX 100644
307
--- a/hw/s390x/s390-virtio-ccw.c
308
+++ b/hw/s390x/s390-virtio-ccw.c
309
@@ -XXX,XX +XXX,XX @@ static void s390_pv_prepare_reset(S390CcwMachineState *ms)
310
s390_pv_prep_reset();
311
}
312
313
-static void s390_machine_reset(MachineState *machine)
314
+static void s390_machine_reset(MachineState *machine, ShutdownCause reason)
315
{
316
S390CcwMachineState *ms = S390_CCW_MACHINE(machine);
317
enum s390_reset reset_type;
318
@@ -XXX,XX +XXX,XX @@ static void s390_machine_reset(MachineState *machine)
319
s390_machine_unprotect(ms);
320
}
321
322
- qemu_devices_reset();
323
+ qemu_devices_reset(reason);
324
s390_crypto_reset();
325
326
/* configure and start the ipl CPU only */
327
diff --git a/migration/savevm.c b/migration/savevm.c
328
index XXXXXXX..XXXXXXX 100644
329
--- a/migration/savevm.c
330
+++ b/migration/savevm.c
331
@@ -XXX,XX +XXX,XX @@ bool load_snapshot(const char *name, const char *vmstate,
332
goto err_drain;
333
}
334
335
- qemu_system_reset(SHUTDOWN_CAUSE_NONE);
336
+ qemu_system_reset(SHUTDOWN_CAUSE_SNAPSHOT_LOAD);
337
mis->from_src_file = f;
338
339
if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) {
340
diff --git a/softmmu/runstate.c b/softmmu/runstate.c
341
index XXXXXXX..XXXXXXX 100644
342
--- a/softmmu/runstate.c
343
+++ b/softmmu/runstate.c
344
@@ -XXX,XX +XXX,XX @@ void qemu_system_reset(ShutdownCause reason)
345
cpu_synchronize_all_states();
346
347
if (mc && mc->reset) {
348
- mc->reset(current_machine);
349
+ mc->reset(current_machine, reason);
350
} else {
351
- qemu_devices_reset();
352
+ qemu_devices_reset(reason);
353
}
354
- if (reason && reason != SHUTDOWN_CAUSE_SUBSYSTEM_RESET) {
355
+ switch (reason) {
356
+ case SHUTDOWN_CAUSE_NONE:
357
+ case SHUTDOWN_CAUSE_SUBSYSTEM_RESET:
358
+ case SHUTDOWN_CAUSE_SNAPSHOT_LOAD:
359
+ break;
360
+ default:
361
qapi_event_send_reset(shutdown_caused_by_guest(reason), reason);
362
}
363
cpu_synchronize_all_post_reset();
364
--
365
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
2
1
3
When the system reboots, the rng-seed that the FDT has should be
4
re-randomized, so that the new boot gets a new seed. Several
5
architectures require this functionality, so export a function for
6
injecting a new seed into the given FDT.
7
8
Cc: Alistair Francis <alistair.francis@wdc.com>
9
Cc: David Gibson <david@gibson.dropbear.id.au>
10
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-id: 20221025004327.568476-3-Jason@zx2c4.com
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
include/sysemu/device_tree.h | 9 +++++++++
16
softmmu/device_tree.c | 21 +++++++++++++++++++++
17
2 files changed, 30 insertions(+)
18
19
diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/sysemu/device_tree.h
22
+++ b/include/sysemu/device_tree.h
23
@@ -XXX,XX +XXX,XX @@ int qemu_fdt_setprop_sized_cells_from_array(void *fdt,
24
qdt_tmp); \
25
})
26
27
+
28
+/**
29
+ * qemu_fdt_randomize_seeds:
30
+ * @fdt: device tree blob
31
+ *
32
+ * Re-randomize all "rng-seed" properties with new seeds.
33
+ */
34
+void qemu_fdt_randomize_seeds(void *fdt);
35
+
36
#define FDT_PCI_RANGE_RELOCATABLE 0x80000000
37
#define FDT_PCI_RANGE_PREFETCHABLE 0x40000000
38
#define FDT_PCI_RANGE_ALIASED 0x20000000
39
diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/softmmu/device_tree.c
42
+++ b/softmmu/device_tree.c
43
@@ -XXX,XX +XXX,XX @@
44
#include "qemu/option.h"
45
#include "qemu/bswap.h"
46
#include "qemu/cutils.h"
47
+#include "qemu/guest-random.h"
48
#include "sysemu/device_tree.h"
49
#include "hw/loader.h"
50
#include "hw/boards.h"
51
@@ -XXX,XX +XXX,XX @@ void hmp_dumpdtb(Monitor *mon, const QDict *qdict)
52
53
info_report("dtb dumped to %s", filename);
54
}
55
+
56
+void qemu_fdt_randomize_seeds(void *fdt)
57
+{
58
+ int noffset, poffset, len;
59
+ const char *name;
60
+ uint8_t *data;
61
+
62
+ for (noffset = fdt_next_node(fdt, 0, NULL);
63
+ noffset >= 0;
64
+ noffset = fdt_next_node(fdt, noffset, NULL)) {
65
+ for (poffset = fdt_first_property_offset(fdt, noffset);
66
+ poffset >= 0;
67
+ poffset = fdt_next_property_offset(fdt, poffset)) {
68
+ data = (uint8_t *)fdt_getprop_by_offset(fdt, poffset, &name, &len);
69
+ if (!data || strcmp(name, "rng-seed"))
70
+ continue;
71
+ qemu_guest_getrandom_nofail(data, len);
72
+ }
73
+ }
74
+}
75
--
76
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
2
1
3
Snapshot loading is supposed to be deterministic, so we shouldn't
4
re-randomize the various seeds used.
5
6
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
7
Message-id: 20221025004327.568476-4-Jason@zx2c4.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/i386/x86.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/i386/x86.c
17
+++ b/hw/i386/x86.c
18
@@ -XXX,XX +XXX,XX @@ void x86_load_linux(X86MachineState *x86ms,
19
setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
20
setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
21
qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
22
- qemu_register_reset(reset_rng_seed, setup_data);
23
+ qemu_register_reset_nosnapshotload(reset_rng_seed, setup_data);
24
fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_seed, NULL,
25
setup_data, kernel, kernel_size, true);
26
} else {
27
--
28
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
2
1
3
When the system reboots, the rng-seed that the FDT has should be
4
re-randomized, so that the new boot gets a new seed. Since the FDT is in
5
the ROM region at this point, we add a hook right after the ROM has been
6
added, so that we have a pointer to that copy of the FDT.
7
8
Cc: Peter Maydell <peter.maydell@linaro.org>
9
Cc: qemu-arm@nongnu.org
10
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11
Message-id: 20221025004327.568476-5-Jason@zx2c4.com
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
hw/arm/boot.c | 2 ++
16
1 file changed, 2 insertions(+)
17
18
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/boot.c
21
+++ b/hw/arm/boot.c
22
@@ -XXX,XX +XXX,XX @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
23
* the DTB is copied again upon reset, even if addr points into RAM.
24
*/
25
rom_add_blob_fixed_as("dtb", fdt, size, addr, as);
26
+ qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
27
+ rom_ptr_for_as(as, addr, size));
28
29
g_free(fdt);
30
31
--
32
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
2
1
3
When the system reboots, the rng-seed that the FDT has should be
4
re-randomized, so that the new boot gets a new seed. Since the FDT is in
5
the ROM region at this point, we add a hook right after the ROM has been
6
added, so that we have a pointer to that copy of the FDT.
7
8
Cc: Palmer Dabbelt <palmer@dabbelt.com>
9
Cc: Alistair Francis <alistair.francis@wdc.com>
10
Cc: Bin Meng <bin.meng@windriver.com>
11
Cc: qemu-riscv@nongnu.org
12
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
14
Message-id: 20221025004327.568476-6-Jason@zx2c4.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
hw/riscv/boot.c | 3 +++
18
1 file changed, 3 insertions(+)
19
20
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/riscv/boot.c
23
+++ b/hw/riscv/boot.c
24
@@ -XXX,XX +XXX,XX @@
25
#include "sysemu/device_tree.h"
26
#include "sysemu/qtest.h"
27
#include "sysemu/kvm.h"
28
+#include "sysemu/reset.h"
29
30
#include <libfdt.h>
31
32
@@ -XXX,XX +XXX,XX @@ uint64_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt)
33
34
rom_add_blob_fixed_as("fdt", fdt, fdtsize, fdt_addr,
35
&address_space_memory);
36
+ qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
37
+ rom_ptr_for_as(&address_space_memory, fdt_addr, fdtsize));
38
39
return fdt_addr;
40
}
41
--
42
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
2
1
3
Snapshot loading is supposed to be deterministic, so we shouldn't
4
re-randomize the various seeds used.
5
6
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
7
Message-id: 20221025004327.568476-7-Jason@zx2c4.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/m68k/virt.c | 20 +++++++++++---------
12
1 file changed, 11 insertions(+), 9 deletions(-)
13
14
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/m68k/virt.c
17
+++ b/hw/m68k/virt.c
18
@@ -XXX,XX +XXX,XX @@ typedef struct {
19
M68kCPU *cpu;
20
hwaddr initial_pc;
21
hwaddr initial_stack;
22
- struct bi_record *rng_seed;
23
} ResetInfo;
24
25
static void main_cpu_reset(void *opaque)
26
@@ -XXX,XX +XXX,XX @@ static void main_cpu_reset(void *opaque)
27
M68kCPU *cpu = reset_info->cpu;
28
CPUState *cs = CPU(cpu);
29
30
- if (reset_info->rng_seed) {
31
- qemu_guest_getrandom_nofail((void *)reset_info->rng_seed->data + 2,
32
- be16_to_cpu(*(uint16_t *)reset_info->rng_seed->data));
33
- }
34
-
35
cpu_reset(cs);
36
cpu->env.aregs[7] = reset_info->initial_stack;
37
cpu->env.pc = reset_info->initial_pc;
38
}
39
40
+static void rerandomize_rng_seed(void *opaque)
41
+{
42
+ struct bi_record *rng_seed = opaque;
43
+ qemu_guest_getrandom_nofail((void *)rng_seed->data + 2,
44
+ be16_to_cpu(*(uint16_t *)rng_seed->data));
45
+}
46
+
47
static void virt_init(MachineState *machine)
48
{
49
M68kCPU *cpu = NULL;
50
@@ -XXX,XX +XXX,XX @@ static void virt_init(MachineState *machine)
51
BOOTINFO0(param_ptr, BI_LAST);
52
rom_add_blob_fixed_as("bootinfo", param_blob, param_ptr - param_blob,
53
parameters_base, cs->as);
54
- reset_info->rng_seed = rom_ptr_for_as(cs->as, parameters_base,
55
- param_ptr - param_blob) +
56
- (param_rng_seed - param_blob);
57
+ qemu_register_reset_nosnapshotload(rerandomize_rng_seed,
58
+ rom_ptr_for_as(cs->as, parameters_base,
59
+ param_ptr - param_blob) +
60
+ (param_rng_seed - param_blob));
61
g_free(param_blob);
62
}
63
}
64
--
65
2.25.1
diff view generated by jsdifflib
Deleted patch
1
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
2
1
3
Snapshot loading is supposed to be deterministic, so we shouldn't
4
re-randomize the various seeds used.
5
6
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
7
Message-id: 20221025004327.568476-8-Jason@zx2c4.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/m68k/q800.c | 33 +++++++++++++--------------------
12
1 file changed, 13 insertions(+), 20 deletions(-)
13
14
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/m68k/q800.c
17
+++ b/hw/m68k/q800.c
18
@@ -XXX,XX +XXX,XX @@ static const TypeInfo glue_info = {
19
},
20
};
21
22
-typedef struct {
23
- M68kCPU *cpu;
24
- struct bi_record *rng_seed;
25
-} ResetInfo;
26
-
27
static void main_cpu_reset(void *opaque)
28
{
29
- ResetInfo *reset_info = opaque;
30
- M68kCPU *cpu = reset_info->cpu;
31
+ M68kCPU *cpu = opaque;
32
CPUState *cs = CPU(cpu);
33
34
- if (reset_info->rng_seed) {
35
- qemu_guest_getrandom_nofail((void *)reset_info->rng_seed->data + 2,
36
- be16_to_cpu(*(uint16_t *)reset_info->rng_seed->data));
37
- }
38
-
39
cpu_reset(cs);
40
cpu->env.aregs[7] = ldl_phys(cs->as, 0);
41
cpu->env.pc = ldl_phys(cs->as, 4);
42
}
43
44
+static void rerandomize_rng_seed(void *opaque)
45
+{
46
+ struct bi_record *rng_seed = opaque;
47
+ qemu_guest_getrandom_nofail((void *)rng_seed->data + 2,
48
+ be16_to_cpu(*(uint16_t *)rng_seed->data));
49
+}
50
+
51
static uint8_t fake_mac_rom[] = {
52
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53
54
@@ -XXX,XX +XXX,XX @@ static void q800_init(MachineState *machine)
55
NubusBus *nubus;
56
DeviceState *glue;
57
DriveInfo *dinfo;
58
- ResetInfo *reset_info;
59
uint8_t rng_seed[32];
60
61
linux_boot = (kernel_filename != NULL);
62
@@ -XXX,XX +XXX,XX @@ static void q800_init(MachineState *machine)
63
exit(1);
64
}
65
66
- reset_info = g_new0(ResetInfo, 1);
67
-
68
/* init CPUs */
69
cpu = M68K_CPU(cpu_create(machine->cpu_type));
70
- reset_info->cpu = cpu;
71
- qemu_register_reset(main_cpu_reset, reset_info);
72
+ qemu_register_reset(main_cpu_reset, cpu);
73
74
/* RAM */
75
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
76
@@ -XXX,XX +XXX,XX @@ static void q800_init(MachineState *machine)
77
BOOTINFO0(param_ptr, BI_LAST);
78
rom_add_blob_fixed_as("bootinfo", param_blob, param_ptr - param_blob,
79
parameters_base, cs->as);
80
- reset_info->rng_seed = rom_ptr_for_as(cs->as, parameters_base,
81
- param_ptr - param_blob) +
82
- (param_rng_seed - param_blob);
83
+ qemu_register_reset_nosnapshotload(rerandomize_rng_seed,
84
+ rom_ptr_for_as(cs->as, parameters_base,
85
+ param_ptr - param_blob) +
86
+ (param_rng_seed - param_blob));
87
g_free(param_blob);
88
} else {
89
uint8_t *ptr;
90
--
91
2.25.1
diff view generated by jsdifflib