1
Hi; here's a collection of Arm bug fixes for rc2.
1
A last small test of bug fixes before rc1.
2
2
3
thanks
3
thanks
4
-- PMM
4
-- PMM
5
5
6
The following changes since commit a082fab9d259473a9d5d53307cf83b1223301181:
6
The following changes since commit ed8ad9728a9c0eec34db9dff61dfa2f1dd625637:
7
7
8
Merge tag 'pull-ppc-20221117' of https://gitlab.com/danielhb/qemu into staging (2022-11-17 12:39:38 -0500)
8
Merge tag 'pull-tpm-2023-07-14-1' of https://github.com/stefanberger/qemu-tpm into staging (2023-07-15 14:54:04 +0100)
9
9
10
are available in the Git repository at:
10
are available in the Git repository at:
11
11
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20221121
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230717
13
13
14
for you to fetch changes up to 312b71abce3005ca7294dc0db7d548dc7cc41fbf:
14
for you to fetch changes up to c2c1c4a35c7c2b1a4140b0942b9797c857e476a4:
15
15
16
target/arm: Limit LPA2 effective output address when TCR.DS == 0 (2022-11-21 11:46:46 +0000)
16
hw/nvram: Avoid unnecessary Xilinx eFuse backstore write (2023-07-17 11:05:52 +0100)
17
17
18
----------------------------------------------------------------
18
----------------------------------------------------------------
19
target-arm queue:
19
target-arm queue:
20
* hw/sd: Fix sun4i allwinner-sdhost for U-Boot
20
* hw/arm/sbsa-ref: set 'slots' property of xhci
21
* hw/intc: add implementation of GICD_IIDR to Arm GIC
21
* linux-user: Remove pointless NULL check in clock_adjtime handling
22
* tests/avocado/boot_linux.py: Bump aarch64 virt test timeout
22
* ptw: Fix S1_ptw_translate() debug path
23
* target/arm: Limit LPA2 effective output address when TCR.DS == 0
23
* ptw: Account for FEAT_RME when applying {N}SW, SA bits
24
* accel/tcg: Zero-pad PC in TCG CPU exec trace lines
25
* hw/nvram: Avoid unnecessary Xilinx eFuse backstore write
24
26
25
----------------------------------------------------------------
27
----------------------------------------------------------------
26
Alex Bennée (2):
28
Peter Maydell (5):
27
hw/intc: clean-up access to GIC multi-byte registers
29
linux-user: Remove pointless NULL check in clock_adjtime handling
28
hw/intc: add implementation of GICD_IIDR to Arm GIC
30
target/arm/ptw.c: Add comments to S1Translate struct fields
31
target/arm: Fix S1_ptw_translate() debug path
32
target/arm/ptw.c: Account for FEAT_RME when applying {N}SW, SA bits
33
accel/tcg: Zero-pad PC in TCG CPU exec trace lines
29
34
30
Ard Biesheuvel (1):
35
Tong Ho (1):
31
target/arm: Limit LPA2 effective output address when TCR.DS == 0
36
hw/nvram: Avoid unnecessary Xilinx eFuse backstore write
32
37
33
Peter Maydell (1):
38
Yuquan Wang (1):
34
tests/avocado/boot_linux.py: Bump aarch64 virt test timeout to 720s
39
hw/arm/sbsa-ref: set 'slots' property of xhci
35
40
36
Strahinja Jankovic (1):
41
accel/tcg/cpu-exec.c | 4 +--
37
hw/sd: Fix sun4i allwinner-sdhost for U-Boot
42
accel/tcg/translate-all.c | 2 +-
38
43
hw/arm/sbsa-ref.c | 1 +
39
include/hw/sd/allwinner-sdhost.h | 1 +
44
hw/nvram/xlnx-efuse.c | 11 ++++--
40
hw/intc/arm_gic.c | 28 ++++++++++++-----
45
linux-user/syscall.c | 12 +++----
41
hw/sd/allwinner-sdhost.c | 67 +++++++++++++++++++++++++++-------------
46
target/arm/ptw.c | 90 +++++++++++++++++++++++++++++++++++++++++------
42
target/arm/ptw.c | 8 +++++
47
6 files changed, 98 insertions(+), 22 deletions(-)
43
tests/avocado/boot_linux.py | 2 +-
44
5 files changed, 77 insertions(+), 29 deletions(-)
45
diff view generated by jsdifflib
New patch
1
From: Yuquan Wang <wangyuquan1236@phytium.com.cn>
1
2
3
This extends the slots of xhci to 64, since the default xhci_sysbus
4
just supports one slot.
5
6
Signed-off-by: Wang Yuquan <wangyuquan1236@phytium.com.cn>
7
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
10
Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
11
Message-id: 20230710063750.473510-2-wangyuquan1236@phytium.com.cn
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/arm/sbsa-ref.c | 1 +
15
1 file changed, 1 insertion(+)
16
17
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/sbsa-ref.c
20
+++ b/hw/arm/sbsa-ref.c
21
@@ -XXX,XX +XXX,XX @@ static void create_xhci(const SBSAMachineState *sms)
22
hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base;
23
int irq = sbsa_ref_irqmap[SBSA_XHCI];
24
DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS);
25
+ qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS);
26
27
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
28
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
29
--
30
2.34.1
diff view generated by jsdifflib
1
The two tests
1
In the code for TARGET_NR_clock_adjtime, we set the pointer phtx to
2
tests/avocado/boot_linux.py:BootLinuxAarch64.test_virt_tcg_gicv2
2
the address of the local variable htx. This means it can never be
3
tests/avocado/boot_linux.py:BootLinuxAarch64.test_virt_tcg_gicv3
3
NULL, but later in the code we check it for NULL anyway. Coverity
4
complains about this (CID 1507683) because the NULL check comes after
5
a call to clock_adjtime() that assumes it is non-NULL.
4
6
5
take quite a long time to run, and the current timeout of 240s
7
Since phtx is always &htx, and is used only in three places, it's not
6
is not enough for the tests to complete on slow machines:
8
really necessary. Remove it, bringing the code structure in to line
7
we've seen these tests time out in the gitlab CI in the
9
with that for TARGET_NR_clock_adjtime64, which already uses a simple
8
'avocado-system-alpine' CI job, for instance. The timeout
10
'&htx' when it wants a pointer to 'htx'.
9
is also insufficient for running the test with a debug build
10
of QEMU: on my machine the tests take over 10 minutes to run
11
in that config.
12
13
Push the timeout up to 720s so that the test definitely has
14
enough time to complete.
15
11
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Thomas Huth <thuth@redhat.com>
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20230623144410.1837261-1-peter.maydell@linaro.org
19
---
16
---
20
tests/avocado/boot_linux.py | 2 +-
17
linux-user/syscall.c | 12 +++++-------
21
1 file changed, 1 insertion(+), 1 deletion(-)
18
1 file changed, 5 insertions(+), 7 deletions(-)
22
19
23
diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py
20
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
24
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
25
--- a/tests/avocado/boot_linux.py
22
--- a/linux-user/syscall.c
26
+++ b/tests/avocado/boot_linux.py
23
+++ b/linux-user/syscall.c
27
@@ -XXX,XX +XXX,XX @@ class BootLinuxAarch64(LinuxTest):
24
@@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
28
:avocado: tags=machine:virt
25
#if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME)
29
:avocado: tags=machine:gic-version=2
26
case TARGET_NR_clock_adjtime:
30
"""
27
{
31
- timeout = 240
28
- struct timex htx, *phtx = &htx;
32
+ timeout = 720
29
+ struct timex htx;
33
30
34
def add_common_args(self):
31
- if (target_to_host_timex(phtx, arg2) != 0) {
35
self.vm.add_args('-bios',
32
+ if (target_to_host_timex(&htx, arg2) != 0) {
33
return -TARGET_EFAULT;
34
}
35
- ret = get_errno(clock_adjtime(arg1, phtx));
36
- if (!is_error(ret) && phtx) {
37
- if (host_to_target_timex(arg2, phtx) != 0) {
38
- return -TARGET_EFAULT;
39
- }
40
+ ret = get_errno(clock_adjtime(arg1, &htx));
41
+ if (!is_error(ret) && host_to_target_timex(arg2, &htx)) {
42
+ return -TARGET_EFAULT;
43
}
44
}
45
return ret;
36
--
46
--
37
2.25.1
47
2.34.1
38
48
39
49
diff view generated by jsdifflib
New patch
1
Add comments to the in_* fields in the S1Translate struct
2
that explain what they're doing.
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230710152130.3928330-2-peter.maydell@linaro.org
7
---
8
target/arm/ptw.c | 40 ++++++++++++++++++++++++++++++++++++++++
9
1 file changed, 40 insertions(+)
10
11
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/ptw.c
14
+++ b/target/arm/ptw.c
15
@@ -XXX,XX +XXX,XX @@
16
#endif
17
18
typedef struct S1Translate {
19
+ /*
20
+ * in_mmu_idx : specifies which TTBR, TCR, etc to use for the walk.
21
+ * Together with in_space, specifies the architectural translation regime.
22
+ */
23
ARMMMUIdx in_mmu_idx;
24
+ /*
25
+ * in_ptw_idx: specifies which mmuidx to use for the actual
26
+ * page table descriptor load operations. This will be one of the
27
+ * ARMMMUIdx_Stage2* or one of the ARMMMUIdx_Phys_* indexes.
28
+ * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit,
29
+ * this field is updated accordingly.
30
+ */
31
ARMMMUIdx in_ptw_idx;
32
+ /*
33
+ * in_space: the security space for this walk. This plus
34
+ * the in_mmu_idx specify the architectural translation regime.
35
+ * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit,
36
+ * this field is updated accordingly.
37
+ *
38
+ * Note that the security space for the in_ptw_idx may be different
39
+ * from that for the in_mmu_idx. We do not need to explicitly track
40
+ * the in_ptw_idx security space because:
41
+ * - if the in_ptw_idx is an ARMMMUIdx_Phys_* then the mmuidx
42
+ * itself specifies the security space
43
+ * - if the in_ptw_idx is an ARMMMUIdx_Stage2* then the security
44
+ * space used for ptw reads is the same as that of the security
45
+ * space of the stage 1 translation for all cases except where
46
+ * stage 1 is Secure; in that case the only possibilities for
47
+ * the ptw read are Secure and NonSecure, and the in_ptw_idx
48
+ * value being Stage2 vs Stage2_S distinguishes those.
49
+ */
50
ARMSecuritySpace in_space;
51
+ /*
52
+ * in_secure: whether the translation regime is a Secure one.
53
+ * This is always equal to arm_space_is_secure(in_space).
54
+ * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit,
55
+ * this field is updated accordingly.
56
+ */
57
bool in_secure;
58
+ /*
59
+ * in_debug: is this a QEMU debug access (gdbstub, etc)? Debug
60
+ * accesses will not update the guest page table access flags
61
+ * and will not change the state of the softmmu TLBs.
62
+ */
63
bool in_debug;
64
/*
65
* If this is stage 2 of a stage 1+2 page table walk, then this must
66
--
67
2.34.1
diff view generated by jsdifflib
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
1
In commit fe4a5472ccd6 we rearranged the logic in S1_ptw_translate()
2
so that the debug-access "call get_phys_addr_*" codepath is used both
3
when S1 is doing ptw reads from stage 2 and when it is doing ptw
4
reads from physical memory. However, we didn't update the
5
calculation of s2ptw->in_space and s2ptw->in_secure to account for
6
the "ptw reads from physical memory" case. This meant that debug
7
accesses when in Secure state broke.
2
8
3
Trying to run U-Boot for Cubieboard (Allwinner A10) fails because it cannot
9
Create a new function S2_security_space() which returns the
4
access SD card. The problem is that FIFO register in current
10
correct security space to use for the ptw load, and use it to
5
allwinner-sdhost implementation is at the address corresponding to
11
determine the correct .in_secure and .in_space fields for the
6
Allwinner H3, but not A10.
12
stage 2 lookup for the ptw load.
7
Linux kernel is not affected since Linux driver uses DMA access and does
8
not use FIFO register for reading/writing.
9
13
10
This patch adds new class parameter `is_sun4i` and based on that
14
Reported-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
11
parameter uses register at offset 0x100 either as FIFO register (if
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
sun4i) or as threshold register (if not sun4i; in this case register at
16
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
13
0x200 is FIFO register).
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
18
Message-id: 20230710152130.3928330-3-peter.maydell@linaro.org
15
Tested with U-Boot and Linux kernel image built for Cubieboard and
19
Fixes: fe4a5472ccd6 ("target/arm: Use get_phys_addr_with_struct in S1_ptw_translate")
16
OrangePi PC.
17
18
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
Message-id: 20221112214900.24152-1-strahinja.p.jankovic@gmail.com
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
21
---
23
include/hw/sd/allwinner-sdhost.h | 1 +
22
target/arm/ptw.c | 37 ++++++++++++++++++++++++++++++++-----
24
hw/sd/allwinner-sdhost.c | 67 ++++++++++++++++++++++----------
23
1 file changed, 32 insertions(+), 5 deletions(-)
25
2 files changed, 47 insertions(+), 21 deletions(-)
26
24
27
diff --git a/include/hw/sd/allwinner-sdhost.h b/include/hw/sd/allwinner-sdhost.h
25
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
28
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/sd/allwinner-sdhost.h
27
--- a/target/arm/ptw.c
30
+++ b/include/hw/sd/allwinner-sdhost.h
28
+++ b/target/arm/ptw.c
31
@@ -XXX,XX +XXX,XX @@ struct AwSdHostClass {
29
@@ -XXX,XX +XXX,XX @@ static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs)
32
33
/** Maximum buffer size in bytes per DMA descriptor */
34
size_t max_desc_size;
35
+ bool is_sun4i;
36
37
};
38
39
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/sd/allwinner-sdhost.c
42
+++ b/hw/sd/allwinner-sdhost.c
43
@@ -XXX,XX +XXX,XX @@ enum {
44
REG_SD_DLBA = 0x84, /* Descriptor List Base Address */
45
REG_SD_IDST = 0x88, /* Internal DMA Controller Status */
46
REG_SD_IDIE = 0x8C, /* Internal DMA Controller IRQ Enable */
47
- REG_SD_THLDC = 0x100, /* Card Threshold Control */
48
+ REG_SD_THLDC = 0x100, /* Card Threshold Control / FIFO (sun4i only)*/
49
REG_SD_DSBD = 0x10C, /* eMMC DDR Start Bit Detection Control */
50
REG_SD_RES_CRC = 0x110, /* Response CRC from card/eMMC */
51
REG_SD_DATA7_CRC = 0x114, /* CRC Data 7 from card/eMMC */
52
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_dma(AwSdHostState *s)
53
}
30
}
54
}
31
}
55
32
56
+static uint32_t allwinner_sdhost_fifo_read(AwSdHostState *s)
33
+static ARMSecuritySpace S2_security_space(ARMSecuritySpace s1_space,
34
+ ARMMMUIdx s2_mmu_idx)
57
+{
35
+{
58
+ uint32_t res = 0;
36
+ /*
59
+
37
+ * Return the security space to use for stage 2 when doing
60
+ if (sdbus_data_ready(&s->sdbus)) {
38
+ * the S1 page table descriptor load.
61
+ sdbus_read_data(&s->sdbus, &res, sizeof(uint32_t));
39
+ */
62
+ le32_to_cpus(&res);
40
+ if (regime_is_stage2(s2_mmu_idx)) {
63
+ allwinner_sdhost_update_transfer_cnt(s, sizeof(uint32_t));
41
+ /*
64
+ allwinner_sdhost_auto_stop(s);
42
+ * The security space for ptw reads is almost always the same
65
+ allwinner_sdhost_update_irq(s);
43
+ * as that of the security space of the stage 1 translation.
44
+ * The only exception is when stage 1 is Secure; in that case
45
+ * the ptw read might be to the Secure or the NonSecure space
46
+ * (but never Realm or Root), and the s2_mmu_idx tells us which.
47
+ * Root translations are always single-stage.
48
+ */
49
+ if (s1_space == ARMSS_Secure) {
50
+ return arm_secure_to_space(s2_mmu_idx == ARMMMUIdx_Stage2_S);
51
+ } else {
52
+ assert(s2_mmu_idx != ARMMMUIdx_Stage2_S);
53
+ assert(s1_space != ARMSS_Root);
54
+ return s1_space;
55
+ }
66
+ } else {
56
+ } else {
67
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: no data ready on SD bus\n",
57
+ /* ptw loads are from phys: the mmu idx itself says which space */
68
+ __func__);
58
+ return arm_phys_to_space(s2_mmu_idx);
69
+ }
59
+ }
70
+
71
+ return res;
72
+}
60
+}
73
+
61
+
74
static uint64_t allwinner_sdhost_read(void *opaque, hwaddr offset,
62
/* Translate a S1 pagetable walk through S2 if needed. */
75
unsigned size)
63
static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
64
hwaddr addr, ARMMMUFaultInfo *fi)
76
{
65
{
77
AwSdHostState *s = AW_SDHOST(opaque);
66
- ARMSecuritySpace space = ptw->in_space;
78
+ AwSdHostClass *sc = AW_SDHOST_GET_CLASS(s);
67
bool is_secure = ptw->in_secure;
79
uint32_t res = 0;
68
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
80
69
ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx;
81
switch (offset) {
70
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
82
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sdhost_read(void *opaque, hwaddr offset,
71
* From gdbstub, do not use softmmu so that we don't modify the
83
case REG_SD_IDIE: /* Internal DMA Controller Interrupt Enable */
72
* state of the cpu at all, including softmmu tlb contents.
84
res = s->dmac_irq;
73
*/
85
break;
74
+ ARMSecuritySpace s2_space = S2_security_space(ptw->in_space, s2_mmu_idx);
86
- case REG_SD_THLDC: /* Card Threshold Control */
75
S1Translate s2ptw = {
87
- res = s->card_threshold;
76
.in_mmu_idx = s2_mmu_idx,
88
+ case REG_SD_THLDC: /* Card Threshold Control or FIFO register (sun4i) */
77
.in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx),
89
+ if (sc->is_sun4i) {
78
- .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S,
90
+ res = allwinner_sdhost_fifo_read(s);
79
- .in_space = (s2_mmu_idx == ARMMMUIdx_Stage2_S ? ARMSS_Secure
91
+ } else {
80
- : space == ARMSS_Realm ? ARMSS_Realm
92
+ res = s->card_threshold;
81
- : ARMSS_NonSecure),
93
+ }
82
+ .in_secure = arm_space_is_secure(s2_space),
94
break;
83
+ .in_space = s2_space,
95
case REG_SD_DSBD: /* eMMC DDR Start Bit Detection Control */
84
.in_debug = true,
96
res = s->startbit_detect;
85
};
97
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sdhost_read(void *opaque, hwaddr offset,
86
GetPhysAddrResult s2 = { };
98
res = s->status_crc;
99
break;
100
case REG_SD_FIFO: /* Read/Write FIFO */
101
- if (sdbus_data_ready(&s->sdbus)) {
102
- sdbus_read_data(&s->sdbus, &res, sizeof(uint32_t));
103
- le32_to_cpus(&res);
104
- allwinner_sdhost_update_transfer_cnt(s, sizeof(uint32_t));
105
- allwinner_sdhost_auto_stop(s);
106
- allwinner_sdhost_update_irq(s);
107
- } else {
108
- qemu_log_mask(LOG_GUEST_ERROR, "%s: no data ready on SD bus\n",
109
- __func__);
110
- }
111
+ res = allwinner_sdhost_fifo_read(s);
112
break;
113
default:
114
qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset %"
115
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sdhost_read(void *opaque, hwaddr offset,
116
return res;
117
}
118
119
+static void allwinner_sdhost_fifo_write(AwSdHostState *s, uint64_t value)
120
+{
121
+ uint32_t u32 = cpu_to_le32(value);
122
+ sdbus_write_data(&s->sdbus, &u32, sizeof(u32));
123
+ allwinner_sdhost_update_transfer_cnt(s, sizeof(u32));
124
+ allwinner_sdhost_auto_stop(s);
125
+ allwinner_sdhost_update_irq(s);
126
+}
127
+
128
static void allwinner_sdhost_write(void *opaque, hwaddr offset,
129
uint64_t value, unsigned size)
130
{
131
AwSdHostState *s = AW_SDHOST(opaque);
132
- uint32_t u32;
133
+ AwSdHostClass *sc = AW_SDHOST_GET_CLASS(s);
134
135
trace_allwinner_sdhost_write(offset, value, size);
136
137
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_write(void *opaque, hwaddr offset,
138
s->dmac_irq = value;
139
allwinner_sdhost_update_irq(s);
140
break;
141
- case REG_SD_THLDC: /* Card Threshold Control */
142
- s->card_threshold = value;
143
+ case REG_SD_THLDC: /* Card Threshold Control or FIFO (sun4i) */
144
+ if (sc->is_sun4i) {
145
+ allwinner_sdhost_fifo_write(s, value);
146
+ } else {
147
+ s->card_threshold = value;
148
+ }
149
break;
150
case REG_SD_DSBD: /* eMMC DDR Start Bit Detection Control */
151
s->startbit_detect = value;
152
break;
153
case REG_SD_FIFO: /* Read/Write FIFO */
154
- u32 = cpu_to_le32(value);
155
- sdbus_write_data(&s->sdbus, &u32, sizeof(u32));
156
- allwinner_sdhost_update_transfer_cnt(s, sizeof(u32));
157
- allwinner_sdhost_auto_stop(s);
158
- allwinner_sdhost_update_irq(s);
159
+ allwinner_sdhost_fifo_write(s, value);
160
break;
161
case REG_SD_RES_CRC: /* Response CRC from card/eMMC */
162
case REG_SD_DATA7_CRC: /* CRC Data 7 from card/eMMC */
163
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_sun4i_class_init(ObjectClass *klass, void *data)
164
{
165
AwSdHostClass *sc = AW_SDHOST_CLASS(klass);
166
sc->max_desc_size = 8 * KiB;
167
+ sc->is_sun4i = true;
168
}
169
170
static void allwinner_sdhost_sun5i_class_init(ObjectClass *klass, void *data)
171
{
172
AwSdHostClass *sc = AW_SDHOST_CLASS(klass);
173
sc->max_desc_size = 64 * KiB;
174
+ sc->is_sun4i = false;
175
}
176
177
static const TypeInfo allwinner_sdhost_info = {
178
--
87
--
179
2.25.1
88
2.34.1
diff view generated by jsdifflib
1
From: Ard Biesheuvel <ardb@kernel.org>
1
In get_phys_addr_twostage() the code that applies the effects of
2
VSTCR.{SA,SW} and VTCR.{NSA,NSW} only updates result->f.attrs.secure.
3
Now we also have f.attrs.space for FEAT_RME, we need to keep the two
4
in sync.
2
5
3
With LPA2, the effective output address size is at most 48 bits when
6
These bits only have an effect for Secure space translations, not
4
TCR.DS == 0. This case is currently unhandled in the page table walker,
7
for Root, so use the input in_space field to determine whether to
5
where we happily assume LVA/64k granule when outputsize > 48 and
8
apply them rather than the input is_secure. This doesn't actually
6
param.ds == 0, resulting in the wrong conversion to be used from a
9
make a difference because Root translations are never two-stage,
7
page table descriptor to a physical address.
10
but it's a little clearer.
8
11
9
if (outputsize > 48) {
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
if (param.ds) {
11
descaddr |= extract64(descriptor, 8, 2) << 50;
12
} else {
13
descaddr |= extract64(descriptor, 12, 4) << 48;
14
}
15
16
So cap the outputsize to 48 when TCR.DS is cleared, as per the
17
architecture.
18
19
Cc: Peter Maydell <peter.maydell@linaro.org>
20
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Cc: Richard Henderson <richard.henderson@linaro.org>
22
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
23
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
24
Message-id: 20221116170316.259695-1-ardb@kernel.org
14
Message-id: 20230710152130.3928330-4-peter.maydell@linaro.org
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
15
---
27
target/arm/ptw.c | 8 ++++++++
16
target/arm/ptw.c | 13 ++++++++-----
28
1 file changed, 8 insertions(+)
17
1 file changed, 8 insertions(+), 5 deletions(-)
29
18
30
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
19
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
31
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/ptw.c
21
--- a/target/arm/ptw.c
33
+++ b/target/arm/ptw.c
22
+++ b/target/arm/ptw.c
34
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
23
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
35
ps = MIN(ps, param.ps);
24
hwaddr ipa;
36
assert(ps < ARRAY_SIZE(pamax_map));
25
int s1_prot, s1_lgpgsz;
37
outputsize = pamax_map[ps];
26
bool is_secure = ptw->in_secure;
38
+
27
+ ARMSecuritySpace in_space = ptw->in_space;
39
+ /*
28
bool ret, ipa_secure;
40
+ * With LPA2, the effective output address (OA) size is at most 48 bits
29
ARMCacheAttrs cacheattrs1;
41
+ * unless TCR.DS == 1
30
ARMSecuritySpace ipa_space;
42
+ */
31
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
43
+ if (!param.ds && param.gran != Gran64K) {
32
* Check if IPA translates to secure or non-secure PA space.
44
+ outputsize = MIN(outputsize, 48);
33
* Note that VSTCR overrides VTCR and {N}SW overrides {N}SA.
45
+ }
34
*/
46
} else {
35
- result->f.attrs.secure =
47
param = aa32_va_parameters(env, address, mmu_idx);
36
- (is_secure
48
level = 1;
37
- && !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW))
38
- && (ipa_secure
39
- || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))));
40
+ if (in_space == ARMSS_Secure) {
41
+ result->f.attrs.secure =
42
+ !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW))
43
+ && (ipa_secure
44
+ || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)));
45
+ result->f.attrs.space = arm_secure_to_space(result->f.attrs.secure);
46
+ }
47
48
return false;
49
}
49
--
50
--
50
2.25.1
51
2.34.1
51
52
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
In commit f0a08b0913befbd we changed the type of the PC from
2
target_ulong to vaddr. In doing so we inadvertently dropped the
3
zero-padding on the PC in trace lines (the second item inside the []
4
in these lines). They used to look like this on AArch64, for
5
instance:
2
6
3
gic_dist_readb was returning a word value which just happened to work
7
Trace 0: 0x7f2260000100 [00000000/0000000040000000/00000061/ff200000]
4
as a result of the way we OR the data together. Lets fix it so only
5
the explicit byte is returned for each part of GICD_TYPER. I've
6
changed the return type to uint8_t although the overflow is only
7
detected with an explicit -Wconversion.
8
8
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
9
and now they look like this:
10
Trace 0: 0x7f4f50000100 [00000000/40000000/00000061/ff200000]
11
12
and if the PC happens to be somewhere low like 0x5000
13
then the field is shown as /5000/.
14
15
This is because TARGET_FMT_lx is a "%08x" or "%016x" specifier,
16
depending on TARGET_LONG_SIZE, whereas VADDR_PRIx is just PRIx64
17
with no width specifier.
18
19
Restore the zero-padding by adding an 016 width specifier to
20
this tracing and a couple of others that were similarly recently
21
changed to use VADDR_PRIx without a width specifier.
22
23
We can't unfortunately restore the "32-bit guests are padded to
24
8 hex digits and 64-bit guests to 16 hex digits" behaviour so
25
easily.
26
27
Fixes: f0a08b0913befbd ("accel/tcg/cpu-exec.c: Widen pc to vaddr")
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
29
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
30
Reviewed-by: Anton Johansson <anjo@rev.ng>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
Message-id: 20230711165434.4123674-1-peter.maydell@linaro.org
14
---
32
---
15
hw/intc/arm_gic.c | 16 ++++++++++------
33
accel/tcg/cpu-exec.c | 4 ++--
16
1 file changed, 10 insertions(+), 6 deletions(-)
34
accel/tcg/translate-all.c | 2 +-
35
2 files changed, 3 insertions(+), 3 deletions(-)
17
36
18
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
37
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
19
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/intc/arm_gic.c
39
--- a/accel/tcg/cpu-exec.c
21
+++ b/hw/intc/arm_gic.c
40
+++ b/accel/tcg/cpu-exec.c
22
@@ -XXX,XX +XXX,XX @@ static void gic_complete_irq(GICState *s, int cpu, int irq, MemTxAttrs attrs)
41
@@ -XXX,XX +XXX,XX @@ static void log_cpu_exec(vaddr pc, CPUState *cpu,
23
gic_update(s);
42
if (qemu_log_in_addr_range(pc)) {
24
}
43
qemu_log_mask(CPU_LOG_EXEC,
25
44
"Trace %d: %p [%08" PRIx64
26
-static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs)
45
- "/%" VADDR_PRIx "/%08x/%08x] %s\n",
27
+static uint8_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs)
46
+ "/%016" VADDR_PRIx "/%08x/%08x] %s\n",
28
{
47
cpu->cpu_index, tb->tc.ptr, tb->cs_base, pc,
29
GICState *s = (GICState *)opaque;
48
tb->flags, tb->cflags, lookup_symbol(pc));
30
uint32_t res;
49
31
@@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs)
50
@@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
32
cm = 1 << cpu;
51
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
33
if (offset < 0x100) {
52
vaddr pc = log_pc(cpu, last_tb);
34
if (offset == 0) { /* GICD_CTLR */
53
if (qemu_log_in_addr_range(pc)) {
35
+ /* We rely here on the only non-zero bits being in byte 0 */
54
- qemu_log("Stopped execution of TB chain before %p [%"
36
if (s->security_extn && !attrs.secure) {
55
+ qemu_log("Stopped execution of TB chain before %p [%016"
37
/* The NS bank of this register is just an alias of the
56
VADDR_PRIx "] %s\n",
38
* EnableGrp1 bit in the S bank version.
57
last_tb->tc.ptr, pc, lookup_symbol(pc));
39
@@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs)
40
return s->ctlr;
41
}
58
}
59
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/accel/tcg/translate-all.c
62
+++ b/accel/tcg/translate-all.c
63
@@ -XXX,XX +XXX,XX @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
64
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
65
vaddr pc = log_pc(cpu, tb);
66
if (qemu_log_in_addr_range(pc)) {
67
- qemu_log("cpu_io_recompile: rewound execution of TB to %"
68
+ qemu_log("cpu_io_recompile: rewound execution of TB to %016"
69
VADDR_PRIx "\n", pc);
42
}
70
}
43
- if (offset == 4)
71
}
44
- /* Interrupt Controller Type Register */
45
- return ((s->num_irq / 32) - 1)
46
- | ((s->num_cpu - 1) << 5)
47
- | (s->security_extn << 10);
48
+ if (offset == 4) {
49
+ /* GICD_TYPER byte 0 */
50
+ return ((s->num_irq / 32) - 1) | ((s->num_cpu - 1) << 5);
51
+ }
52
+ if (offset == 5) {
53
+ /* GICD_TYPER byte 1 */
54
+ return (s->security_extn << 2);
55
+ }
56
if (offset < 0x08)
57
return 0;
58
if (offset >= 0x80) {
59
--
72
--
60
2.25.1
73
2.34.1
61
74
62
75
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
a66a24585f (hw/intc/arm_gic: Implement read of GICC_IIDR) implemented
3
Add a check in the bit-set operation to write the backstore
4
this for the CPU interface register. The fact we don't implement it
4
only if the affected bit is 0 before.
5
shows up when running Xen with -d guest_error which is definitely
6
wrong because the guest is perfectly entitled to read it.
7
5
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
With this in place, there will be no need for callers to
7
do the checking in order to avoid unnecessary writes.
8
9
Signed-off-by: Tong Ho <tong.ho@amd.com>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
14
---
13
hw/intc/arm_gic.c | 12 +++++++++++-
15
hw/nvram/xlnx-efuse.c | 11 +++++++++--
14
1 file changed, 11 insertions(+), 1 deletion(-)
16
1 file changed, 9 insertions(+), 2 deletions(-)
15
17
16
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
18
diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/intc/arm_gic.c
20
--- a/hw/nvram/xlnx-efuse.c
19
+++ b/hw/intc/arm_gic.c
21
+++ b/hw/nvram/xlnx-efuse.c
20
@@ -XXX,XX +XXX,XX @@ static uint8_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs)
22
@@ -XXX,XX +XXX,XX @@ static bool efuse_ro_bits_find(XlnxEFuse *s, uint32_t k)
21
/* GICD_TYPER byte 1 */
23
22
return (s->security_extn << 2);
24
bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit)
23
}
25
{
24
- if (offset < 0x08)
26
+ uint32_t set, *row;
25
+ if (offset == 8) {
27
+
26
+ /* GICD_IIDR byte 0 */
28
if (efuse_ro_bits_find(s, bit)) {
27
+ return 0x3b; /* Arm JEP106 identity */
29
g_autofree char *path = object_get_canonical_path(OBJECT(s));
28
+ }
30
29
+ if (offset == 9) {
31
@@ -XXX,XX +XXX,XX @@ bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit)
30
+ /* GICD_IIDR byte 1 */
32
return false;
31
+ return 0x04; /* Arm JEP106 identity */
33
}
32
+ }
34
33
+ if (offset < 0x0c) {
35
- s->fuse32[bit / 32] |= 1 << (bit % 32);
34
+ /* All other bytes in this range are RAZ */
36
- efuse_bdrv_sync(s, bit);
35
return 0;
37
+ /* Avoid back-end write unless there is a real update */
36
+ }
38
+ row = &s->fuse32[bit / 32];
37
if (offset >= 0x80) {
39
+ set = 1 << (bit % 32);
38
/* Interrupt Group Registers: these RAZ/WI if this is an NS
40
+ if (!(set & *row)) {
39
* access to a GIC with the security extensions, or if the GIC
41
+ *row |= set;
42
+ efuse_bdrv_sync(s, bit);
43
+ }
44
return true;
45
}
46
40
--
47
--
41
2.25.1
48
2.34.1
42
49
43
50
diff view generated by jsdifflib