1
The following changes since commit 65cc5ccf06a74c98de73ec683d9a543baa302a12:
1
A last small test of bug fixes before rc1.
2
2
3
Merge tag 'pull-riscv-to-apply-20230120' of https://github.com/alistair23/qemu into staging (2023-01-20 16:17:56 +0000)
3
thanks
4
-- PMM
5
6
The following changes since commit ed8ad9728a9c0eec34db9dff61dfa2f1dd625637:
7
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)
4
9
5
are available in the Git repository at:
10
are available in the Git repository at:
6
11
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230123
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230717
8
13
9
for you to fetch changes up to 3b07a936d3bfe97b07ddffcfbb532985a88033dd:
14
for you to fetch changes up to c2c1c4a35c7c2b1a4140b0942b9797c857e476a4:
10
15
11
target/arm: Look up ARMCPRegInfo at runtime (2023-01-23 13:32:38 +0000)
16
hw/nvram: Avoid unnecessary Xilinx eFuse backstore write (2023-07-17 11:05:52 +0100)
12
17
13
----------------------------------------------------------------
18
----------------------------------------------------------------
14
target-arm queue:
19
target-arm queue:
15
* Widen cnthctl_el2 to uint64_t
20
* hw/arm/sbsa-ref: set 'slots' property of xhci
16
* Unify checking for M Main Extension in MRS/MSR
21
* linux-user: Remove pointless NULL check in clock_adjtime handling
17
* bitbang_i2c, versatile_i2c: code cleanups
22
* ptw: Fix S1_ptw_translate() debug path
18
* SME: refactor SME SM/ZA handling
23
* ptw: Account for FEAT_RME when applying {N}SW, SA bits
19
* Fix physical address resolution for MTE
24
* accel/tcg: Zero-pad PC in TCG CPU exec trace lines
20
* Fix in_debug path in S1_ptw_translate
25
* hw/nvram: Avoid unnecessary Xilinx eFuse backstore write
21
* Don't set EXC_RETURN.ES if Security Extension not present
22
* Implement DBGCLAIM registers
23
* Provide stubs for more external debug registers
24
* Look up ARMCPRegInfo at runtime, not translate time
25
26
26
----------------------------------------------------------------
27
----------------------------------------------------------------
27
David Reiss (1):
28
Peter Maydell (5):
28
target/arm: Unify checking for M Main Extension in MRS/MSR
29
linux-user: Remove pointless NULL check in clock_adjtime handling
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
Evgeny Iakovlev (2):
35
Tong Ho (1):
31
target/arm: implement DBGCLAIM registers
36
hw/nvram: Avoid unnecessary Xilinx eFuse backstore write
32
target/arm: provide stubs for more external debug registers
33
37
34
Peter Maydell (1):
38
Yuquan Wang (1):
35
target/arm: Don't set EXC_RETURN.ES if Security Extension not present
39
hw/arm/sbsa-ref: set 'slots' property of xhci
36
40
37
Philippe Mathieu-Daudé (10):
41
accel/tcg/cpu-exec.c | 4 +--
38
hw/i2c/bitbang_i2c: Define TYPE_GPIO_I2C in public header
42
accel/tcg/translate-all.c | 2 +-
39
hw/i2c/bitbang_i2c: Remove unused dummy MemoryRegion
43
hw/arm/sbsa-ref.c | 1 +
40
hw/i2c/bitbang_i2c: Change state calling bitbang_i2c_set_state() helper
44
hw/nvram/xlnx-efuse.c | 11 ++++--
41
hw/i2c/bitbang_i2c: Trace state changes
45
linux-user/syscall.c | 12 +++----
42
hw/i2c/bitbang_i2c: Convert DPRINTF() to trace events
46
target/arm/ptw.c | 90 +++++++++++++++++++++++++++++++++++++++++------
43
hw/i2c/versatile_i2c: Drop useless casts from void * to pointer
47
6 files changed, 98 insertions(+), 22 deletions(-)
44
hw/i2c/versatile_i2c: Replace VersatileI2CState -> ArmSbconI2CState
45
hw/i2c/versatile_i2c: Replace TYPE_VERSATILE_I2C -> TYPE_ARM_SBCON_I2C
46
hw/i2c/versatile_i2c: Use ARM_SBCON_I2C() macro
47
hw/i2c/versatile_i2c: Rename versatile_i2c -> arm_sbcon_i2c
48
49
Richard Henderson (12):
50
target/arm: Widen cnthctl_el2 to uint64_t
51
target/arm/sme: Reorg SME access handling in handle_msr_i()
52
target/arm/sme: Rebuild hflags in set_pstate() helpers
53
target/arm/sme: Introduce aarch64_set_svcr()
54
target/arm/sme: Reset SVE state in aarch64_set_svcr()
55
target/arm/sme: Reset ZA state in aarch64_set_svcr()
56
target/arm/sme: Rebuild hflags in aarch64_set_svcr()
57
target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr()
58
target/arm: Fix physical address resolution for MTE
59
target/arm: Fix in_debug path in S1_ptw_translate
60
target/arm: Reorg do_coproc_insn
61
target/arm: Look up ARMCPRegInfo at runtime
62
63
MAINTAINERS | 1 +
64
include/hw/i2c/arm_sbcon_i2c.h | 6 +-
65
include/hw/i2c/bitbang_i2c.h | 2 +
66
target/arm/cpu.h | 5 +-
67
target/arm/helper-sme.h | 3 +-
68
target/arm/helper.h | 11 +-
69
target/arm/translate.h | 7 +
70
hw/arm/musicpal.c | 3 +-
71
hw/arm/realview.c | 2 +-
72
hw/arm/versatilepb.c | 2 +-
73
hw/arm/vexpress.c | 2 +-
74
hw/i2c/{versatile_i2c.c => arm_sbcon_i2c.c} | 39 ++-
75
hw/i2c/bitbang_i2c.c | 80 ++++--
76
linux-user/aarch64/cpu_loop.c | 11 +-
77
linux-user/aarch64/signal.c | 13 +-
78
target/arm/debug_helper.c | 54 ++++
79
target/arm/helper.c | 41 ++-
80
target/arm/m_helper.c | 24 +-
81
target/arm/mte_helper.c | 2 +-
82
target/arm/op_helper.c | 27 +-
83
target/arm/ptw.c | 4 +-
84
target/arm/sme_helper.c | 37 +--
85
target/arm/translate-a64.c | 68 +++--
86
target/arm/translate.c | 430 +++++++++++++++-------------
87
hw/arm/Kconfig | 4 +-
88
hw/i2c/Kconfig | 2 +-
89
hw/i2c/meson.build | 2 +-
90
hw/i2c/trace-events | 7 +
91
28 files changed, 506 insertions(+), 383 deletions(-)
92
rename hw/i2c/{versatile_i2c.c => arm_sbcon_i2c.c} (70%)
93
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
This is a 64-bit register on AArch64, even if the high 44 bits
4
are RES0. Because this is defined as ARM_CP_STATE_BOTH, we are
5
asserting that the cpreg field is 64-bits.
6
7
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1400
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230115171633.3171890-1-richard.henderson@linaro.org
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/cpu.h | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
15
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
21
};
22
uint64_t c14_cntfrq; /* Counter Frequency register */
23
uint64_t c14_cntkctl; /* Timer Control register */
24
- uint32_t cnthctl_el2; /* Counter/Timer Hyp Control register */
25
+ uint64_t cnthctl_el2; /* Counter/Timer Hyp Control register */
26
uint64_t cntvoff_el2; /* Counter Virtual Offset register */
27
ARMGenericTimer c14_timer[NUM_GTIMERS];
28
uint32_t c15_cpar; /* XScale Coprocessor Access Register */
29
--
30
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: David Reiss <dreiss@meta.com>
2
1
3
BASEPRI, FAULTMASK, and their _NS equivalents only exist on devices with
4
the Main Extension. However, the MRS instruction did not check this,
5
and the MSR instruction handled it inconsistently (warning BASEPRI, but
6
silently ignoring writes to BASEPRI_NS). Unify this behavior and always
7
warn when reading or writing any of these registers if the extension is
8
not present.
9
10
Signed-off-by: David Reiss <dreiss@meta.com>
11
Message-id: 167330628518.10497.13100425787268927786-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
target/arm/m_helper.c | 22 ++++++++++++++++++++--
16
1 file changed, 20 insertions(+), 2 deletions(-)
17
18
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/m_helper.c
21
+++ b/target/arm/m_helper.c
22
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
23
}
24
return env->v7m.primask[M_REG_NS];
25
case 0x91: /* BASEPRI_NS */
26
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
27
+ goto bad_reg;
28
+ }
29
if (!env->v7m.secure) {
30
return 0;
31
}
32
return env->v7m.basepri[M_REG_NS];
33
case 0x93: /* FAULTMASK_NS */
34
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
35
+ goto bad_reg;
36
+ }
37
if (!env->v7m.secure) {
38
return 0;
39
}
40
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
41
return env->v7m.primask[env->v7m.secure];
42
case 17: /* BASEPRI */
43
case 18: /* BASEPRI_MAX */
44
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
45
+ goto bad_reg;
46
+ }
47
return env->v7m.basepri[env->v7m.secure];
48
case 19: /* FAULTMASK */
49
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
50
+ goto bad_reg;
51
+ }
52
return env->v7m.faultmask[env->v7m.secure];
53
default:
54
bad_reg:
55
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
56
env->v7m.primask[M_REG_NS] = val & 1;
57
return;
58
case 0x91: /* BASEPRI_NS */
59
- if (!env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_MAIN)) {
60
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
61
+ goto bad_reg;
62
+ }
63
+ if (!env->v7m.secure) {
64
return;
65
}
66
env->v7m.basepri[M_REG_NS] = val & 0xff;
67
return;
68
case 0x93: /* FAULTMASK_NS */
69
- if (!env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_MAIN)) {
70
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
71
+ goto bad_reg;
72
+ }
73
+ if (!env->v7m.secure) {
74
return;
75
}
76
env->v7m.faultmask[M_REG_NS] = val & 1;
77
--
78
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Define TYPE_GPIO_I2C in the public "hw/i2c/bitbang_i2c.h"
4
header and use it in hw/arm/musicpal.c.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Acked-by: Corey Minyard <cminyard@mvista.com>
9
Message-id: 20230111085016.44551-2-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/i2c/bitbang_i2c.h | 2 ++
13
hw/arm/musicpal.c | 3 ++-
14
hw/i2c/bitbang_i2c.c | 1 -
15
3 files changed, 4 insertions(+), 2 deletions(-)
16
17
diff --git a/include/hw/i2c/bitbang_i2c.h b/include/hw/i2c/bitbang_i2c.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/i2c/bitbang_i2c.h
20
+++ b/include/hw/i2c/bitbang_i2c.h
21
@@ -XXX,XX +XXX,XX @@
22
23
#include "hw/i2c/i2c.h"
24
25
+#define TYPE_GPIO_I2C "gpio_i2c"
26
+
27
typedef struct bitbang_i2c_interface bitbang_i2c_interface;
28
29
#define BITBANG_I2C_SDA 0
30
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/arm/musicpal.c
33
+++ b/hw/arm/musicpal.c
34
@@ -XXX,XX +XXX,XX @@
35
#include "hw/block/flash.h"
36
#include "ui/console.h"
37
#include "hw/i2c/i2c.h"
38
+#include "hw/i2c/bitbang_i2c.h"
39
#include "hw/irq.h"
40
#include "hw/or-irq.h"
41
#include "hw/audio/wm8750.h"
42
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
43
44
dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE,
45
qdev_get_gpio_in(pic, MP_GPIO_IRQ));
46
- i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
47
+ i2c_dev = sysbus_create_simple(TYPE_GPIO_I2C, -1, NULL);
48
i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, "i2c");
49
50
lcd_dev = sysbus_create_simple(TYPE_MUSICPAL_LCD, MP_LCD_BASE, NULL);
51
diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/i2c/bitbang_i2c.c
54
+++ b/hw/i2c/bitbang_i2c.c
55
@@ -XXX,XX +XXX,XX @@ void bitbang_i2c_init(bitbang_i2c_interface *s, I2CBus *bus)
56
57
/* GPIO interface. */
58
59
-#define TYPE_GPIO_I2C "gpio_i2c"
60
OBJECT_DECLARE_SIMPLE_TYPE(GPIOI2CState, GPIO_I2C)
61
62
struct GPIOI2CState {
63
--
64
2.34.1
65
66
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Acked-by: Corey Minyard <cminyard@mvista.com>
6
Message-id: 20230111085016.44551-3-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
hw/i2c/bitbang_i2c.c | 7 ++-----
10
1 file changed, 2 insertions(+), 5 deletions(-)
11
12
diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/i2c/bitbang_i2c.c
15
+++ b/hw/i2c/bitbang_i2c.c
16
@@ -XXX,XX +XXX,XX @@ void bitbang_i2c_init(bitbang_i2c_interface *s, I2CBus *bus)
17
OBJECT_DECLARE_SIMPLE_TYPE(GPIOI2CState, GPIO_I2C)
18
19
struct GPIOI2CState {
20
+ /*< private >*/
21
SysBusDevice parent_obj;
22
+ /*< public >*/
23
24
- MemoryRegion dummy_iomem;
25
bitbang_i2c_interface bitbang;
26
int last_level;
27
qemu_irq out;
28
@@ -XXX,XX +XXX,XX @@ static void gpio_i2c_init(Object *obj)
29
{
30
DeviceState *dev = DEVICE(obj);
31
GPIOI2CState *s = GPIO_I2C(obj);
32
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
33
I2CBus *bus;
34
35
- memory_region_init(&s->dummy_iomem, obj, "gpio_i2c", 0);
36
- sysbus_init_mmio(sbd, &s->dummy_iomem);
37
-
38
bus = i2c_init_bus(dev, "i2c");
39
bitbang_i2c_init(&s->bitbang, bus);
40
41
--
42
2.34.1
43
44
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Yuquan Wang <wangyuquan1236@phytium.com.cn>
2
2
3
Do not encode the pointer as a constant in the opcode stream.
3
This extends the slots of xhci to 64, since the default xhci_sysbus
4
This pointer is specific to the cpu that first generated the
4
just supports one slot.
5
translation, which runs into problems with both hot-pluggable
6
cpus and user-only threads, as cpus are removed. It's also a
7
potential correctness issue in the theoretical case of a
8
slightly-heterogenous system, because if CPU 0 generates a
9
TB and then CPU 1 executes it, CPU 1 will end up using CPU 0's
10
hash table, which might have a wrong set of registers in it.
11
(All our current systems are either completely homogenous,
12
M-profile, or have CPUs sufficiently different that they
13
wouldn't be sharing TBs anyway because the differences would
14
show up in the TB flags, so the correctness issue is only
15
theoretical, not practical.)
16
5
17
Perform the lookup in either helper_access_check_cp_reg,
6
Signed-off-by: Wang Yuquan <wangyuquan1236@phytium.com.cn>
18
or a new helper_lookup_cp_reg.
7
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
19
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
21
Message-id: 20230106194451.1213153-3-richard.henderson@linaro.org
10
Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
22
[PMM: added note in commit message about correctness issue]
11
Message-id: 20230710063750.473510-2-wangyuquan1236@phytium.com.cn
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
---
13
---
26
target/arm/helper.h | 11 +++++----
14
hw/arm/sbsa-ref.c | 1 +
27
target/arm/translate.h | 7 ++++++
15
1 file changed, 1 insertion(+)
28
target/arm/op_helper.c | 27 ++++++++++++++------
29
target/arm/translate-a64.c | 49 ++++++++++++++++++++++---------------
30
target/arm/translate.c | 50 +++++++++++++++++++++++++-------------
31
5 files changed, 95 insertions(+), 49 deletions(-)
32
16
33
diff --git a/target/arm/helper.h b/target/arm/helper.h
17
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
34
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/helper.h
19
--- a/hw/arm/sbsa-ref.c
36
+++ b/target/arm/helper.h
20
+++ b/hw/arm/sbsa-ref.c
37
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v8m_stackcheck, void, env, i32)
21
@@ -XXX,XX +XXX,XX @@ static void create_xhci(const SBSAMachineState *sms)
38
22
hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base;
39
DEF_HELPER_FLAGS_2(check_bxj_trap, TCG_CALL_NO_WG, void, env, i32)
23
int irq = sbsa_ref_irqmap[SBSA_XHCI];
40
24
DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS);
41
-DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
25
+ qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS);
42
-DEF_HELPER_3(set_cp_reg, void, env, ptr, i32)
26
43
-DEF_HELPER_2(get_cp_reg, i32, env, ptr)
27
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
44
-DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64)
28
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
45
-DEF_HELPER_2(get_cp_reg64, i64, env, ptr)
46
+DEF_HELPER_4(access_check_cp_reg, cptr, env, i32, i32, i32)
47
+DEF_HELPER_FLAGS_2(lookup_cp_reg, TCG_CALL_NO_RWG_SE, cptr, env, i32)
48
+DEF_HELPER_3(set_cp_reg, void, env, cptr, i32)
49
+DEF_HELPER_2(get_cp_reg, i32, env, cptr)
50
+DEF_HELPER_3(set_cp_reg64, void, env, cptr, i64)
51
+DEF_HELPER_2(get_cp_reg64, i64, env, cptr)
52
53
DEF_HELPER_2(get_r13_banked, i32, env, i32)
54
DEF_HELPER_3(set_r13_banked, void, env, i32, i32)
55
diff --git a/target/arm/translate.h b/target/arm/translate.h
56
index XXXXXXX..XXXXXXX 100644
57
--- a/target/arm/translate.h
58
+++ b/target/arm/translate.h
59
@@ -XXX,XX +XXX,XX @@ static inline void set_disas_label(DisasContext *s, DisasLabel l)
60
s->pc_save = l.pc_save;
61
}
62
63
+static inline TCGv_ptr gen_lookup_cp_reg(uint32_t key)
64
+{
65
+ TCGv_ptr ret = tcg_temp_new_ptr();
66
+ gen_helper_lookup_cp_reg(ret, cpu_env, tcg_constant_i32(key));
67
+ return ret;
68
+}
69
+
70
/*
71
* Helpers for implementing sets of trans_* functions.
72
* Defer the implementation of NAME to FUNC, with optional extra arguments.
73
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/target/arm/op_helper.c
76
+++ b/target/arm/op_helper.c
77
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t tgtmode, uint32_t regno)
78
}
79
}
80
81
-void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
82
- uint32_t isread)
83
+const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key,
84
+ uint32_t syndrome, uint32_t isread)
85
{
86
ARMCPU *cpu = env_archcpu(env);
87
- const ARMCPRegInfo *ri = rip;
88
+ const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, key);
89
CPAccessResult res = CP_ACCESS_OK;
90
int target_el;
91
92
+ assert(ri != NULL);
93
+
94
if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14
95
&& extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) {
96
res = CP_ACCESS_TRAP;
97
@@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
98
res = ri->accessfn(env, ri, isread);
99
}
100
if (likely(res == CP_ACCESS_OK)) {
101
- return;
102
+ return ri;
103
}
104
105
fail:
106
@@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
107
raise_exception(env, EXCP_UDEF, syndrome, target_el);
108
}
109
110
-void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value)
111
+const void *HELPER(lookup_cp_reg)(CPUARMState *env, uint32_t key)
112
+{
113
+ ARMCPU *cpu = env_archcpu(env);
114
+ const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, key);
115
+
116
+ assert(ri != NULL);
117
+ return ri;
118
+}
119
+
120
+void HELPER(set_cp_reg)(CPUARMState *env, const void *rip, uint32_t value)
121
{
122
const ARMCPRegInfo *ri = rip;
123
124
@@ -XXX,XX +XXX,XX @@ void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value)
125
}
126
}
127
128
-uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip)
129
+uint32_t HELPER(get_cp_reg)(CPUARMState *env, const void *rip)
130
{
131
const ARMCPRegInfo *ri = rip;
132
uint32_t res;
133
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip)
134
return res;
135
}
136
137
-void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value)
138
+void HELPER(set_cp_reg64)(CPUARMState *env, const void *rip, uint64_t value)
139
{
140
const ARMCPRegInfo *ri = rip;
141
142
@@ -XXX,XX +XXX,XX @@ void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value)
143
}
144
}
145
146
-uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip)
147
+uint64_t HELPER(get_cp_reg64)(CPUARMState *env, const void *rip)
148
{
149
const ARMCPRegInfo *ri = rip;
150
uint64_t res;
151
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
152
index XXXXXXX..XXXXXXX 100644
153
--- a/target/arm/translate-a64.c
154
+++ b/target/arm/translate-a64.c
155
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
156
unsigned int op0, unsigned int op1, unsigned int op2,
157
unsigned int crn, unsigned int crm, unsigned int rt)
158
{
159
- const ARMCPRegInfo *ri;
160
+ uint32_t key = ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP,
161
+ crn, crm, op0, op1, op2);
162
+ const ARMCPRegInfo *ri = get_arm_cp_reginfo(s->cp_regs, key);
163
+ TCGv_ptr tcg_ri = NULL;
164
TCGv_i64 tcg_rt;
165
166
- ri = get_arm_cp_reginfo(s->cp_regs,
167
- ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP,
168
- crn, crm, op0, op1, op2));
169
-
170
if (!ri) {
171
/* Unknown register; this might be a guest error or a QEMU
172
* unimplemented feature.
173
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
174
175
syndrome = syn_aa64_sysregtrap(op0, op1, op2, crn, crm, rt, isread);
176
gen_a64_update_pc(s, 0);
177
- gen_helper_access_check_cp_reg(cpu_env,
178
- tcg_constant_ptr(ri),
179
+ tcg_ri = tcg_temp_new_ptr();
180
+ gen_helper_access_check_cp_reg(tcg_ri, cpu_env,
181
+ tcg_constant_i32(key),
182
tcg_constant_i32(syndrome),
183
tcg_constant_i32(isread));
184
} else if (ri->type & ARM_CP_RAISES_EXC) {
185
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
186
case 0:
187
break;
188
case ARM_CP_NOP:
189
- return;
190
+ goto exit;
191
case ARM_CP_NZCV:
192
tcg_rt = cpu_reg(s, rt);
193
if (isread) {
194
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
195
} else {
196
gen_set_nzcv(tcg_rt);
197
}
198
- return;
199
+ goto exit;
200
case ARM_CP_CURRENTEL:
201
/* Reads as current EL value from pstate, which is
202
* guaranteed to be constant by the tb flags.
203
*/
204
tcg_rt = cpu_reg(s, rt);
205
tcg_gen_movi_i64(tcg_rt, s->current_el << 2);
206
- return;
207
+ goto exit;
208
case ARM_CP_DC_ZVA:
209
/* Writes clear the aligned block of memory which rt points into. */
210
if (s->mte_active[0]) {
211
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
212
tcg_rt = clean_data_tbi(s, cpu_reg(s, rt));
213
}
214
gen_helper_dc_zva(cpu_env, tcg_rt);
215
- return;
216
+ goto exit;
217
case ARM_CP_DC_GVA:
218
{
219
TCGv_i64 clean_addr, tag;
220
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
221
tcg_temp_free_i64(tag);
222
}
223
}
224
- return;
225
+ goto exit;
226
case ARM_CP_DC_GZVA:
227
{
228
TCGv_i64 clean_addr, tag;
229
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
230
tcg_temp_free_i64(tag);
231
}
232
}
233
- return;
234
+ goto exit;
235
default:
236
g_assert_not_reached();
237
}
238
if ((ri->type & ARM_CP_FPU) && !fp_access_check_only(s)) {
239
- return;
240
+ goto exit;
241
} else if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) {
242
- return;
243
+ goto exit;
244
} else if ((ri->type & ARM_CP_SME) && !sme_access_check(s)) {
245
- return;
246
+ goto exit;
247
}
248
249
if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) {
250
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
251
if (ri->type & ARM_CP_CONST) {
252
tcg_gen_movi_i64(tcg_rt, ri->resetvalue);
253
} else if (ri->readfn) {
254
- gen_helper_get_cp_reg64(tcg_rt, cpu_env, tcg_constant_ptr(ri));
255
+ if (!tcg_ri) {
256
+ tcg_ri = gen_lookup_cp_reg(key);
257
+ }
258
+ gen_helper_get_cp_reg64(tcg_rt, cpu_env, tcg_ri);
259
} else {
260
tcg_gen_ld_i64(tcg_rt, cpu_env, ri->fieldoffset);
261
}
262
} else {
263
if (ri->type & ARM_CP_CONST) {
264
/* If not forbidden by access permissions, treat as WI */
265
- return;
266
+ goto exit;
267
} else if (ri->writefn) {
268
- gen_helper_set_cp_reg64(cpu_env, tcg_constant_ptr(ri), tcg_rt);
269
+ if (!tcg_ri) {
270
+ tcg_ri = gen_lookup_cp_reg(key);
271
+ }
272
+ gen_helper_set_cp_reg64(cpu_env, tcg_ri, tcg_rt);
273
} else {
274
tcg_gen_st_i64(tcg_rt, cpu_env, ri->fieldoffset);
275
}
276
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
277
*/
278
s->base.is_jmp = DISAS_UPDATE_EXIT;
279
}
280
+
281
+ exit:
282
+ if (tcg_ri) {
283
+ tcg_temp_free_ptr(tcg_ri);
284
+ }
285
}
286
287
/* System
288
diff --git a/target/arm/translate.c b/target/arm/translate.c
289
index XXXXXXX..XXXXXXX 100644
290
--- a/target/arm/translate.c
291
+++ b/target/arm/translate.c
292
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
293
int opc1, int crn, int crm, int opc2,
294
bool isread, int rt, int rt2)
295
{
296
- const ARMCPRegInfo *ri;
297
+ uint32_t key = ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2);
298
+ const ARMCPRegInfo *ri = get_arm_cp_reginfo(s->cp_regs, key);
299
+ TCGv_ptr tcg_ri = NULL;
300
bool need_exit_tb;
301
302
- ri = get_arm_cp_reginfo(s->cp_regs,
303
- ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2));
304
-
305
if (!ri) {
306
/*
307
* Unknown register; this might be a guest error or a QEMU
308
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
309
310
gen_set_condexec(s);
311
gen_update_pc(s, 0);
312
- gen_helper_access_check_cp_reg(cpu_env,
313
- tcg_constant_ptr(ri),
314
+ tcg_ri = tcg_temp_new_ptr();
315
+ gen_helper_access_check_cp_reg(tcg_ri, cpu_env,
316
+ tcg_constant_i32(key),
317
tcg_constant_i32(syndrome),
318
tcg_constant_i32(isread));
319
} else if (ri->type & ARM_CP_RAISES_EXC) {
320
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
321
case 0:
322
break;
323
case ARM_CP_NOP:
324
- return;
325
+ goto exit;
326
case ARM_CP_WFI:
327
if (isread) {
328
unallocated_encoding(s);
329
- return;
330
+ } else {
331
+ gen_update_pc(s, curr_insn_len(s));
332
+ s->base.is_jmp = DISAS_WFI;
333
}
334
- gen_update_pc(s, curr_insn_len(s));
335
- s->base.is_jmp = DISAS_WFI;
336
- return;
337
+ goto exit;
338
default:
339
g_assert_not_reached();
340
}
341
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
342
if (ri->type & ARM_CP_CONST) {
343
tmp64 = tcg_constant_i64(ri->resetvalue);
344
} else if (ri->readfn) {
345
+ if (!tcg_ri) {
346
+ tcg_ri = gen_lookup_cp_reg(key);
347
+ }
348
tmp64 = tcg_temp_new_i64();
349
- gen_helper_get_cp_reg64(tmp64, cpu_env,
350
- tcg_constant_ptr(ri));
351
+ gen_helper_get_cp_reg64(tmp64, cpu_env, tcg_ri);
352
} else {
353
tmp64 = tcg_temp_new_i64();
354
tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset);
355
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
356
if (ri->type & ARM_CP_CONST) {
357
tmp = tcg_constant_i32(ri->resetvalue);
358
} else if (ri->readfn) {
359
+ if (!tcg_ri) {
360
+ tcg_ri = gen_lookup_cp_reg(key);
361
+ }
362
tmp = tcg_temp_new_i32();
363
- gen_helper_get_cp_reg(tmp, cpu_env, tcg_constant_ptr(ri));
364
+ gen_helper_get_cp_reg(tmp, cpu_env, tcg_ri);
365
} else {
366
tmp = load_cpu_offset(ri->fieldoffset);
367
}
368
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
369
/* Write */
370
if (ri->type & ARM_CP_CONST) {
371
/* If not forbidden by access permissions, treat as WI */
372
- return;
373
+ goto exit;
374
}
375
376
if (is64) {
377
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
378
tcg_temp_free_i32(tmplo);
379
tcg_temp_free_i32(tmphi);
380
if (ri->writefn) {
381
- gen_helper_set_cp_reg64(cpu_env, tcg_constant_ptr(ri), tmp64);
382
+ if (!tcg_ri) {
383
+ tcg_ri = gen_lookup_cp_reg(key);
384
+ }
385
+ gen_helper_set_cp_reg64(cpu_env, tcg_ri, tmp64);
386
} else {
387
tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset);
388
}
389
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
390
} else {
391
TCGv_i32 tmp = load_reg(s, rt);
392
if (ri->writefn) {
393
- gen_helper_set_cp_reg(cpu_env, tcg_constant_ptr(ri), tmp);
394
+ if (!tcg_ri) {
395
+ tcg_ri = gen_lookup_cp_reg(key);
396
+ }
397
+ gen_helper_set_cp_reg(cpu_env, tcg_ri, tmp);
398
tcg_temp_free_i32(tmp);
399
} else {
400
store_cpu_offset(tmp, ri->fieldoffset, 4);
401
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
402
if (need_exit_tb) {
403
gen_lookup_tb(s);
404
}
405
+
406
+ exit:
407
+ if (tcg_ri) {
408
+ tcg_temp_free_ptr(tcg_ri);
409
+ }
410
}
411
412
/* Decode XScale DSP or iWMMXt insn (in the copro space, cp=0 or 1) */
413
--
29
--
414
2.34.1
30
2.34.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
In the code for TARGET_NR_clock_adjtime, we set the pointer phtx to
2
the address of the local variable htx. This means it can never be
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.
2
6
3
Move the ri == NULL case to the top of the function and return.
7
Since phtx is always &htx, and is used only in three places, it's not
4
This allows the else to be removed and the code unindented.
8
really necessary. Remove it, bringing the code structure in to line
9
with that for TARGET_NR_clock_adjtime64, which already uses a simple
10
'&htx' when it wants a pointer to 'htx'.
5
11
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Message-id: 20230106194451.1213153-2-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: 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
11
---
16
---
12
target/arm/translate.c | 406 ++++++++++++++++++++---------------------
17
linux-user/syscall.c | 12 +++++-------
13
1 file changed, 203 insertions(+), 203 deletions(-)
18
1 file changed, 5 insertions(+), 7 deletions(-)
14
19
15
diff --git a/target/arm/translate.c b/target/arm/translate.c
20
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate.c
22
--- a/linux-user/syscall.c
18
+++ b/target/arm/translate.c
23
+++ b/linux-user/syscall.c
19
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
24
@@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
20
bool isread, int rt, int rt2)
25
#if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME)
21
{
26
case TARGET_NR_clock_adjtime:
22
const ARMCPRegInfo *ri;
27
{
23
+ bool need_exit_tb;
28
- struct timex htx, *phtx = &htx;
24
29
+ struct timex htx;
25
ri = get_arm_cp_reginfo(s->cp_regs,
30
26
ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2));
31
- if (target_to_host_timex(phtx, arg2) != 0) {
27
- if (ri) {
32
+ if (target_to_host_timex(&htx, arg2) != 0) {
28
- bool need_exit_tb;
33
return -TARGET_EFAULT;
29
34
}
30
- /* Check access permissions */
35
- ret = get_errno(clock_adjtime(arg1, phtx));
31
- if (!cp_access_ok(s->current_el, ri, isread)) {
36
- if (!is_error(ret) && phtx) {
32
- unallocated_encoding(s);
37
- if (host_to_target_timex(arg2, phtx) != 0) {
33
- return;
38
- return -TARGET_EFAULT;
34
- }
35
-
36
- if (s->hstr_active || ri->accessfn ||
37
- (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) {
38
- /* Emit code to perform further access permissions checks at
39
- * runtime; this may result in an exception.
40
- * Note that on XScale all cp0..c13 registers do an access check
41
- * call in order to handle c15_cpar.
42
- */
43
- uint32_t syndrome;
44
-
45
- /* Note that since we are an implementation which takes an
46
- * exception on a trapped conditional instruction only if the
47
- * instruction passes its condition code check, we can take
48
- * advantage of the clause in the ARM ARM that allows us to set
49
- * the COND field in the instruction to 0xE in all cases.
50
- * We could fish the actual condition out of the insn (ARM)
51
- * or the condexec bits (Thumb) but it isn't necessary.
52
- */
53
- switch (cpnum) {
54
- case 14:
55
- if (is64) {
56
- syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
57
- isread, false);
58
- } else {
59
- syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm,
60
- rt, isread, false);
61
- }
39
- }
62
- break;
40
+ ret = get_errno(clock_adjtime(arg1, &htx));
63
- case 15:
41
+ if (!is_error(ret) && host_to_target_timex(arg2, &htx)) {
64
- if (is64) {
42
+ return -TARGET_EFAULT;
65
- syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
43
}
66
- isread, false);
67
- } else {
68
- syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm,
69
- rt, isread, false);
70
- }
71
- break;
72
- default:
73
- /* ARMv8 defines that only coprocessors 14 and 15 exist,
74
- * so this can only happen if this is an ARMv7 or earlier CPU,
75
- * in which case the syndrome information won't actually be
76
- * guest visible.
77
- */
78
- assert(!arm_dc_feature(s, ARM_FEATURE_V8));
79
- syndrome = syn_uncategorized();
80
- break;
81
- }
82
-
83
- gen_set_condexec(s);
84
- gen_update_pc(s, 0);
85
- gen_helper_access_check_cp_reg(cpu_env,
86
- tcg_constant_ptr(ri),
87
- tcg_constant_i32(syndrome),
88
- tcg_constant_i32(isread));
89
- } else if (ri->type & ARM_CP_RAISES_EXC) {
90
- /*
91
- * The readfn or writefn might raise an exception;
92
- * synchronize the CPU state in case it does.
93
- */
94
- gen_set_condexec(s);
95
- gen_update_pc(s, 0);
96
- }
97
-
98
- /* Handle special cases first */
99
- switch (ri->type & ARM_CP_SPECIAL_MASK) {
100
- case 0:
101
- break;
102
- case ARM_CP_NOP:
103
- return;
104
- case ARM_CP_WFI:
105
- if (isread) {
106
- unallocated_encoding(s);
107
- return;
108
- }
109
- gen_update_pc(s, curr_insn_len(s));
110
- s->base.is_jmp = DISAS_WFI;
111
- return;
112
- default:
113
- g_assert_not_reached();
114
- }
115
-
116
- if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) {
117
- gen_io_start();
118
- }
119
-
120
- if (isread) {
121
- /* Read */
122
- if (is64) {
123
- TCGv_i64 tmp64;
124
- TCGv_i32 tmp;
125
- if (ri->type & ARM_CP_CONST) {
126
- tmp64 = tcg_constant_i64(ri->resetvalue);
127
- } else if (ri->readfn) {
128
- tmp64 = tcg_temp_new_i64();
129
- gen_helper_get_cp_reg64(tmp64, cpu_env,
130
- tcg_constant_ptr(ri));
131
- } else {
132
- tmp64 = tcg_temp_new_i64();
133
- tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset);
134
- }
135
- tmp = tcg_temp_new_i32();
136
- tcg_gen_extrl_i64_i32(tmp, tmp64);
137
- store_reg(s, rt, tmp);
138
- tmp = tcg_temp_new_i32();
139
- tcg_gen_extrh_i64_i32(tmp, tmp64);
140
- tcg_temp_free_i64(tmp64);
141
- store_reg(s, rt2, tmp);
142
- } else {
143
- TCGv_i32 tmp;
144
- if (ri->type & ARM_CP_CONST) {
145
- tmp = tcg_constant_i32(ri->resetvalue);
146
- } else if (ri->readfn) {
147
- tmp = tcg_temp_new_i32();
148
- gen_helper_get_cp_reg(tmp, cpu_env, tcg_constant_ptr(ri));
149
- } else {
150
- tmp = load_cpu_offset(ri->fieldoffset);
151
- }
152
- if (rt == 15) {
153
- /* Destination register of r15 for 32 bit loads sets
154
- * the condition codes from the high 4 bits of the value
155
- */
156
- gen_set_nzcv(tmp);
157
- tcg_temp_free_i32(tmp);
158
- } else {
159
- store_reg(s, rt, tmp);
160
- }
161
- }
162
+ if (!ri) {
163
+ /*
164
+ * Unknown register; this might be a guest error or a QEMU
165
+ * unimplemented feature.
166
+ */
167
+ if (is64) {
168
+ qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 "
169
+ "64 bit system register cp:%d opc1: %d crm:%d "
170
+ "(%s)\n",
171
+ isread ? "read" : "write", cpnum, opc1, crm,
172
+ s->ns ? "non-secure" : "secure");
173
} else {
174
- /* Write */
175
- if (ri->type & ARM_CP_CONST) {
176
- /* If not forbidden by access permissions, treat as WI */
177
- return;
178
- }
179
-
180
- if (is64) {
181
- TCGv_i32 tmplo, tmphi;
182
- TCGv_i64 tmp64 = tcg_temp_new_i64();
183
- tmplo = load_reg(s, rt);
184
- tmphi = load_reg(s, rt2);
185
- tcg_gen_concat_i32_i64(tmp64, tmplo, tmphi);
186
- tcg_temp_free_i32(tmplo);
187
- tcg_temp_free_i32(tmphi);
188
- if (ri->writefn) {
189
- gen_helper_set_cp_reg64(cpu_env, tcg_constant_ptr(ri),
190
- tmp64);
191
- } else {
192
- tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset);
193
- }
194
- tcg_temp_free_i64(tmp64);
195
- } else {
196
- TCGv_i32 tmp = load_reg(s, rt);
197
- if (ri->writefn) {
198
- gen_helper_set_cp_reg(cpu_env, tcg_constant_ptr(ri), tmp);
199
- tcg_temp_free_i32(tmp);
200
- } else {
201
- store_cpu_offset(tmp, ri->fieldoffset, 4);
202
- }
203
- }
204
+ qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 "
205
+ "system register cp:%d opc1:%d crn:%d crm:%d "
206
+ "opc2:%d (%s)\n",
207
+ isread ? "read" : "write", cpnum, opc1, crn,
208
+ crm, opc2, s->ns ? "non-secure" : "secure");
209
}
44
}
210
-
45
return ret;
211
- /* I/O operations must end the TB here (whether read or write) */
212
- need_exit_tb = ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) &&
213
- (ri->type & ARM_CP_IO));
214
-
215
- if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) {
216
- /*
217
- * A write to any coprocessor register that ends a TB
218
- * must rebuild the hflags for the next TB.
219
- */
220
- gen_rebuild_hflags(s, ri->type & ARM_CP_NEWEL);
221
- /*
222
- * We default to ending the TB on a coprocessor register write,
223
- * but allow this to be suppressed by the register definition
224
- * (usually only necessary to work around guest bugs).
225
- */
226
- need_exit_tb = true;
227
- }
228
- if (need_exit_tb) {
229
- gen_lookup_tb(s);
230
- }
231
-
232
+ unallocated_encoding(s);
233
return;
234
}
235
236
- /* Unknown register; this might be a guest error or a QEMU
237
- * unimplemented feature.
238
- */
239
- if (is64) {
240
- qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 "
241
- "64 bit system register cp:%d opc1: %d crm:%d "
242
- "(%s)\n",
243
- isread ? "read" : "write", cpnum, opc1, crm,
244
- s->ns ? "non-secure" : "secure");
245
- } else {
246
- qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 "
247
- "system register cp:%d opc1:%d crn:%d crm:%d opc2:%d "
248
- "(%s)\n",
249
- isread ? "read" : "write", cpnum, opc1, crn, crm, opc2,
250
- s->ns ? "non-secure" : "secure");
251
+ /* Check access permissions */
252
+ if (!cp_access_ok(s->current_el, ri, isread)) {
253
+ unallocated_encoding(s);
254
+ return;
255
}
256
257
- unallocated_encoding(s);
258
- return;
259
+ if (s->hstr_active || ri->accessfn ||
260
+ (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) {
261
+ /*
262
+ * Emit code to perform further access permissions checks at
263
+ * runtime; this may result in an exception.
264
+ * Note that on XScale all cp0..c13 registers do an access check
265
+ * call in order to handle c15_cpar.
266
+ */
267
+ uint32_t syndrome;
268
+
269
+ /*
270
+ * Note that since we are an implementation which takes an
271
+ * exception on a trapped conditional instruction only if the
272
+ * instruction passes its condition code check, we can take
273
+ * advantage of the clause in the ARM ARM that allows us to set
274
+ * the COND field in the instruction to 0xE in all cases.
275
+ * We could fish the actual condition out of the insn (ARM)
276
+ * or the condexec bits (Thumb) but it isn't necessary.
277
+ */
278
+ switch (cpnum) {
279
+ case 14:
280
+ if (is64) {
281
+ syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
282
+ isread, false);
283
+ } else {
284
+ syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm,
285
+ rt, isread, false);
286
+ }
287
+ break;
288
+ case 15:
289
+ if (is64) {
290
+ syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
291
+ isread, false);
292
+ } else {
293
+ syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm,
294
+ rt, isread, false);
295
+ }
296
+ break;
297
+ default:
298
+ /*
299
+ * ARMv8 defines that only coprocessors 14 and 15 exist,
300
+ * so this can only happen if this is an ARMv7 or earlier CPU,
301
+ * in which case the syndrome information won't actually be
302
+ * guest visible.
303
+ */
304
+ assert(!arm_dc_feature(s, ARM_FEATURE_V8));
305
+ syndrome = syn_uncategorized();
306
+ break;
307
+ }
308
+
309
+ gen_set_condexec(s);
310
+ gen_update_pc(s, 0);
311
+ gen_helper_access_check_cp_reg(cpu_env,
312
+ tcg_constant_ptr(ri),
313
+ tcg_constant_i32(syndrome),
314
+ tcg_constant_i32(isread));
315
+ } else if (ri->type & ARM_CP_RAISES_EXC) {
316
+ /*
317
+ * The readfn or writefn might raise an exception;
318
+ * synchronize the CPU state in case it does.
319
+ */
320
+ gen_set_condexec(s);
321
+ gen_update_pc(s, 0);
322
+ }
323
+
324
+ /* Handle special cases first */
325
+ switch (ri->type & ARM_CP_SPECIAL_MASK) {
326
+ case 0:
327
+ break;
328
+ case ARM_CP_NOP:
329
+ return;
330
+ case ARM_CP_WFI:
331
+ if (isread) {
332
+ unallocated_encoding(s);
333
+ return;
334
+ }
335
+ gen_update_pc(s, curr_insn_len(s));
336
+ s->base.is_jmp = DISAS_WFI;
337
+ return;
338
+ default:
339
+ g_assert_not_reached();
340
+ }
341
+
342
+ if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) {
343
+ gen_io_start();
344
+ }
345
+
346
+ if (isread) {
347
+ /* Read */
348
+ if (is64) {
349
+ TCGv_i64 tmp64;
350
+ TCGv_i32 tmp;
351
+ if (ri->type & ARM_CP_CONST) {
352
+ tmp64 = tcg_constant_i64(ri->resetvalue);
353
+ } else if (ri->readfn) {
354
+ tmp64 = tcg_temp_new_i64();
355
+ gen_helper_get_cp_reg64(tmp64, cpu_env,
356
+ tcg_constant_ptr(ri));
357
+ } else {
358
+ tmp64 = tcg_temp_new_i64();
359
+ tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset);
360
+ }
361
+ tmp = tcg_temp_new_i32();
362
+ tcg_gen_extrl_i64_i32(tmp, tmp64);
363
+ store_reg(s, rt, tmp);
364
+ tmp = tcg_temp_new_i32();
365
+ tcg_gen_extrh_i64_i32(tmp, tmp64);
366
+ tcg_temp_free_i64(tmp64);
367
+ store_reg(s, rt2, tmp);
368
+ } else {
369
+ TCGv_i32 tmp;
370
+ if (ri->type & ARM_CP_CONST) {
371
+ tmp = tcg_constant_i32(ri->resetvalue);
372
+ } else if (ri->readfn) {
373
+ tmp = tcg_temp_new_i32();
374
+ gen_helper_get_cp_reg(tmp, cpu_env, tcg_constant_ptr(ri));
375
+ } else {
376
+ tmp = load_cpu_offset(ri->fieldoffset);
377
+ }
378
+ if (rt == 15) {
379
+ /* Destination register of r15 for 32 bit loads sets
380
+ * the condition codes from the high 4 bits of the value
381
+ */
382
+ gen_set_nzcv(tmp);
383
+ tcg_temp_free_i32(tmp);
384
+ } else {
385
+ store_reg(s, rt, tmp);
386
+ }
387
+ }
388
+ } else {
389
+ /* Write */
390
+ if (ri->type & ARM_CP_CONST) {
391
+ /* If not forbidden by access permissions, treat as WI */
392
+ return;
393
+ }
394
+
395
+ if (is64) {
396
+ TCGv_i32 tmplo, tmphi;
397
+ TCGv_i64 tmp64 = tcg_temp_new_i64();
398
+ tmplo = load_reg(s, rt);
399
+ tmphi = load_reg(s, rt2);
400
+ tcg_gen_concat_i32_i64(tmp64, tmplo, tmphi);
401
+ tcg_temp_free_i32(tmplo);
402
+ tcg_temp_free_i32(tmphi);
403
+ if (ri->writefn) {
404
+ gen_helper_set_cp_reg64(cpu_env, tcg_constant_ptr(ri), tmp64);
405
+ } else {
406
+ tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset);
407
+ }
408
+ tcg_temp_free_i64(tmp64);
409
+ } else {
410
+ TCGv_i32 tmp = load_reg(s, rt);
411
+ if (ri->writefn) {
412
+ gen_helper_set_cp_reg(cpu_env, tcg_constant_ptr(ri), tmp);
413
+ tcg_temp_free_i32(tmp);
414
+ } else {
415
+ store_cpu_offset(tmp, ri->fieldoffset, 4);
416
+ }
417
+ }
418
+ }
419
+
420
+ /* I/O operations must end the TB here (whether read or write) */
421
+ need_exit_tb = ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) &&
422
+ (ri->type & ARM_CP_IO));
423
+
424
+ if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) {
425
+ /*
426
+ * A write to any coprocessor register that ends a TB
427
+ * must rebuild the hflags for the next TB.
428
+ */
429
+ gen_rebuild_hflags(s, ri->type & ARM_CP_NEWEL);
430
+ /*
431
+ * We default to ending the TB on a coprocessor register write,
432
+ * but allow this to be suppressed by the register definition
433
+ * (usually only necessary to work around guest bugs).
434
+ */
435
+ need_exit_tb = true;
436
+ }
437
+ if (need_exit_tb) {
438
+ gen_lookup_tb(s);
439
+ }
440
}
441
442
/* Decode XScale DSP or iWMMXt insn (in the copro space, cp=0 or 1) */
443
--
46
--
444
2.34.1
47
2.34.1
445
48
446
49
diff view generated by jsdifflib
1
In v7m_exception_taken(), for v8M we set the EXC_RETURN.ES bit if
1
Add comments to the in_* fields in the S1Translate struct
2
either the exception targets Secure or if the CPU doesn't implement
2
that explain what they're doing.
3
the Security Extension. This is incorrect: the v8M Arm ARM specifies
4
that the ES bit should be RES0 if the Security Extension is not
5
implemented, and the pseudocode agrees.
6
3
7
Remove the incorrect condition, so that we leave the ES bit 0
8
if the Security Extension isn't implemented.
9
10
This doesn't have any guest-visible effects for our current set of
11
emulated CPUs, because all our v8M CPUs implement the Security
12
Extension; but it's worth fixing in case we add a v8M CPU without
13
the extension in future.
14
15
Reported-by: Igor Kotrasinski <i.kotrasinsk@samsung.com>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230710152130.3928330-2-peter.maydell@linaro.org
18
---
7
---
19
target/arm/m_helper.c | 2 +-
8
target/arm/ptw.c | 40 ++++++++++++++++++++++++++++++++++++++++
20
1 file changed, 1 insertion(+), 1 deletion(-)
9
1 file changed, 40 insertions(+)
21
10
22
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
11
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
23
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/m_helper.c
13
--- a/target/arm/ptw.c
25
+++ b/target/arm/m_helper.c
14
+++ b/target/arm/ptw.c
26
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
15
@@ -XXX,XX +XXX,XX @@
27
}
16
#endif
28
17
29
lr &= ~R_V7M_EXCRET_ES_MASK;
18
typedef struct S1Translate {
30
- if (targets_secure || !arm_feature(env, ARM_FEATURE_M_SECURITY)) {
19
+ /*
31
+ if (targets_secure) {
20
+ * in_mmu_idx : specifies which TTBR, TCR, etc to use for the walk.
32
lr |= R_V7M_EXCRET_ES_MASK;
21
+ * Together with in_space, specifies the architectural translation regime.
33
}
22
+ */
34
lr &= ~R_V7M_EXCRET_SPSEL_MASK;
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
35
--
66
--
36
2.34.1
67
2.34.1
diff view generated by jsdifflib
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.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
The architecture does not define any functionality for the CLAIM tag bits.
9
Create a new function S2_security_space() which returns the
4
So we will just keep the raw bits, as per spec.
10
correct security space to use for the ptw load, and use it to
11
determine the correct .in_secure and .in_space fields for the
12
stage 2 lookup for the ptw load.
5
13
6
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
14
Reported-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230120155929.32384-2-eiakovlev@linux.microsoft.com
18
Message-id: 20230710152130.3928330-3-peter.maydell@linaro.org
19
Fixes: fe4a5472ccd6 ("target/arm: Use get_phys_addr_with_struct in S1_ptw_translate")
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
21
---
12
target/arm/cpu.h | 1 +
22
target/arm/ptw.c | 37 ++++++++++++++++++++++++++++++++-----
13
target/arm/debug_helper.c | 33 +++++++++++++++++++++++++++++++++
23
1 file changed, 32 insertions(+), 5 deletions(-)
14
2 files changed, 34 insertions(+)
15
24
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
25
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
17
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
27
--- a/target/arm/ptw.c
19
+++ b/target/arm/cpu.h
28
+++ b/target/arm/ptw.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
29
@@ -XXX,XX +XXX,XX @@ static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs)
21
uint64_t dbgbcr[16]; /* breakpoint control registers */
22
uint64_t dbgwvr[16]; /* watchpoint value registers */
23
uint64_t dbgwcr[16]; /* watchpoint control registers */
24
+ uint64_t dbgclaim; /* DBGCLAIM bits */
25
uint64_t mdscr_el1;
26
uint64_t oslsr_el1; /* OS Lock Status */
27
uint64_t osdlr_el1; /* OS DoubleLock status */
28
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/debug_helper.c
31
+++ b/target/arm/debug_helper.c
32
@@ -XXX,XX +XXX,XX @@ static void osdlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
33
}
30
}
34
}
31
}
35
32
36
+static void dbgclaimset_write(CPUARMState *env, const ARMCPRegInfo *ri,
33
+static ARMSecuritySpace S2_security_space(ARMSecuritySpace s1_space,
37
+ uint64_t value)
34
+ ARMMMUIdx s2_mmu_idx)
38
+{
35
+{
39
+ env->cp15.dbgclaim |= (value & 0xFF);
36
+ /*
37
+ * Return the security space to use for stage 2 when doing
38
+ * the S1 page table descriptor load.
39
+ */
40
+ if (regime_is_stage2(s2_mmu_idx)) {
41
+ /*
42
+ * The security space for ptw reads is almost always the same
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
+ }
56
+ } else {
57
+ /* ptw loads are from phys: the mmu idx itself says which space */
58
+ return arm_phys_to_space(s2_mmu_idx);
59
+ }
40
+}
60
+}
41
+
61
+
42
+static uint64_t dbgclaimset_read(CPUARMState *env, const ARMCPRegInfo *ri)
62
/* Translate a S1 pagetable walk through S2 if needed. */
43
+{
63
static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
44
+ /* CLAIM bits are RAO */
64
hwaddr addr, ARMMMUFaultInfo *fi)
45
+ return 0xFF;
65
{
46
+}
66
- ARMSecuritySpace space = ptw->in_space;
47
+
67
bool is_secure = ptw->in_secure;
48
+static void dbgclaimclr_write(CPUARMState *env, const ARMCPRegInfo *ri,
68
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
49
+ uint64_t value)
69
ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx;
50
+{
70
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
51
+ env->cp15.dbgclaim &= ~(value & 0xFF);
71
* From gdbstub, do not use softmmu so that we don't modify the
52
+}
72
* state of the cpu at all, including softmmu tlb contents.
53
+
73
*/
54
static const ARMCPRegInfo debug_cp_reginfo[] = {
74
+ ARMSecuritySpace s2_space = S2_security_space(ptw->in_space, s2_mmu_idx);
55
/*
75
S1Translate s2ptw = {
56
* DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped
76
.in_mmu_idx = s2_mmu_idx,
57
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
77
.in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx),
58
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0,
78
- .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S,
59
.access = PL1_RW, .accessfn = access_tda,
79
- .in_space = (s2_mmu_idx == ARMMMUIdx_Stage2_S ? ARMSS_Secure
60
.type = ARM_CP_NOP },
80
- : space == ARMSS_Realm ? ARMSS_Realm
61
+ /*
81
- : ARMSS_NonSecure),
62
+ * Dummy DBGCLAIM registers.
82
+ .in_secure = arm_space_is_secure(s2_space),
63
+ * "The architecture does not define any functionality for the CLAIM tag bits.",
83
+ .in_space = s2_space,
64
+ * so we only keep the raw bits
84
.in_debug = true,
65
+ */
85
};
66
+ { .name = "DBGCLAIMSET_EL1", .state = ARM_CP_STATE_BOTH,
86
GetPhysAddrResult s2 = { };
67
+ .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 6,
68
+ .type = ARM_CP_ALIAS,
69
+ .access = PL1_RW, .accessfn = access_tda,
70
+ .writefn = dbgclaimset_write, .readfn = dbgclaimset_read },
71
+ { .name = "DBGCLAIMCLR_EL1", .state = ARM_CP_STATE_BOTH,
72
+ .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 6,
73
+ .access = PL1_RW, .accessfn = access_tda,
74
+ .writefn = dbgclaimclr_write, .raw_writefn = raw_write,
75
+ .fieldoffset = offsetof(CPUARMState, cp15.dbgclaim) },
76
};
77
78
static const ARMCPRegInfo debug_lpae_cp_reginfo[] = {
79
--
87
--
80
2.34.1
88
2.34.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.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
During the conversion, the test against get_phys_addr_lpae got inverted,
6
These bits only have an effect for Secure space translations, not
4
meaning that successful translations went to the 'failed' label.
7
for Root, so use the input in_space field to determine whether to
8
apply them rather than the input is_secure. This doesn't actually
9
make a difference because Root translations are never two-stage,
10
but it's a little clearer.
5
11
6
Cc: qemu-stable@nongnu.org
7
Fixes: f3639a64f60 ("target/arm: Use softmmu tlbs for page table walking")
8
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1417
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230114054605.2977022-1-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20230710152130.3928330-4-peter.maydell@linaro.org
13
---
15
---
14
target/arm/ptw.c | 4 ++--
16
target/arm/ptw.c | 13 ++++++++-----
15
1 file changed, 2 insertions(+), 2 deletions(-)
17
1 file changed, 8 insertions(+), 5 deletions(-)
16
18
17
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
18
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/ptw.c
21
--- a/target/arm/ptw.c
20
+++ b/target/arm/ptw.c
22
+++ b/target/arm/ptw.c
21
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
23
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
22
};
24
hwaddr ipa;
23
GetPhysAddrResult s2 = { };
25
int s1_prot, s1_lgpgsz;
24
26
bool is_secure = ptw->in_secure;
25
- if (!get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD,
27
+ ARMSecuritySpace in_space = ptw->in_space;
26
- false, &s2, fi)) {
28
bool ret, ipa_secure;
27
+ if (get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD,
29
ARMCacheAttrs cacheattrs1;
28
+ false, &s2, fi)) {
30
ARMSecuritySpace ipa_space;
29
goto fail;
31
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
30
}
32
* Check if IPA translates to secure or non-secure PA space.
31
ptw->out_phys = s2.f.phys_addr;
33
* Note that VSTCR overrides VTCR and {N}SW overrides {N}SA.
34
*/
35
- result->f.attrs.secure =
36
- (is_secure
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
}
32
--
50
--
33
2.34.1
51
2.34.1
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@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
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Trace 0: 0x7f2260000100 [00000000/0000000040000000/00000061/ff200000]
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
5
Acked-by: Corey Minyard <cminyard@mvista.com>
9
and now they look like this:
6
Message-id: 20230111085016.44551-4-philmd@linaro.org
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")
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
30
Reviewed-by: Anton Johansson <anjo@rev.ng>
31
Message-id: 20230711165434.4123674-1-peter.maydell@linaro.org
8
---
32
---
9
hw/i2c/bitbang_i2c.c | 23 +++++++++++++++--------
33
accel/tcg/cpu-exec.c | 4 ++--
10
1 file changed, 15 insertions(+), 8 deletions(-)
34
accel/tcg/translate-all.c | 2 +-
35
2 files changed, 3 insertions(+), 3 deletions(-)
11
36
12
diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
37
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
13
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/i2c/bitbang_i2c.c
39
--- a/accel/tcg/cpu-exec.c
15
+++ b/hw/i2c/bitbang_i2c.c
40
+++ b/accel/tcg/cpu-exec.c
16
@@ -XXX,XX +XXX,XX @@ do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0)
41
@@ -XXX,XX +XXX,XX @@ static void log_cpu_exec(vaddr pc, CPUState *cpu,
17
#define DPRINTF(fmt, ...) do {} while(0)
42
if (qemu_log_in_addr_range(pc)) {
18
#endif
43
qemu_log_mask(CPU_LOG_EXEC,
19
44
"Trace %d: %p [%08" PRIx64
20
+static void bitbang_i2c_set_state(bitbang_i2c_interface *i2c,
45
- "/%" VADDR_PRIx "/%08x/%08x] %s\n",
21
+ bitbang_i2c_state state)
46
+ "/%016" VADDR_PRIx "/%08x/%08x] %s\n",
22
+{
47
cpu->cpu_index, tb->tc.ptr, tb->cs_base, pc,
23
+ i2c->state = state;
48
tb->flags, tb->cflags, lookup_symbol(pc));
24
+}
49
25
+
50
@@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
26
static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c)
51
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
27
{
52
vaddr pc = log_pc(cpu, last_tb);
28
DPRINTF("STOP\n");
53
if (qemu_log_in_addr_range(pc)) {
29
if (i2c->current_addr >= 0)
54
- qemu_log("Stopped execution of TB chain before %p [%"
30
i2c_end_transfer(i2c->bus);
55
+ qemu_log("Stopped execution of TB chain before %p [%016"
31
i2c->current_addr = -1;
56
VADDR_PRIx "] %s\n",
32
- i2c->state = STOPPED;
57
last_tb->tc.ptr, pc, lookup_symbol(pc));
33
+ bitbang_i2c_set_state(i2c, STOPPED);
58
}
34
}
59
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
35
60
index XXXXXXX..XXXXXXX 100644
36
/* Set device data pin. */
61
--- a/accel/tcg/translate-all.c
37
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
62
+++ b/accel/tcg/translate-all.c
38
if (level == 0) {
63
@@ -XXX,XX +XXX,XX @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
39
DPRINTF("START\n");
64
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
40
/* START condition. */
65
vaddr pc = log_pc(cpu, tb);
41
- i2c->state = SENDING_BIT7;
66
if (qemu_log_in_addr_range(pc)) {
42
+ bitbang_i2c_set_state(i2c, SENDING_BIT7);
67
- qemu_log("cpu_io_recompile: rewound execution of TB to %"
43
i2c->current_addr = -1;
68
+ qemu_log("cpu_io_recompile: rewound execution of TB to %016"
44
} else {
69
VADDR_PRIx "\n", pc);
45
/* STOP condition. */
46
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
47
case SENDING_BIT7 ... SENDING_BIT0:
48
i2c->buffer = (i2c->buffer << 1) | data;
49
/* will end up in WAITING_FOR_ACK */
50
- i2c->state++;
51
+ bitbang_i2c_set_state(i2c, i2c->state + 1);
52
return bitbang_i2c_ret(i2c, 1);
53
54
case WAITING_FOR_ACK:
55
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
56
* device we were sending to decided to NACK us).
57
*/
58
DPRINTF("Got NACK\n");
59
+ bitbang_i2c_set_state(i2c, SENT_NACK);
60
bitbang_i2c_enter_stop(i2c);
61
return bitbang_i2c_ret(i2c, 1);
62
}
70
}
63
if (i2c->current_addr & 1) {
64
- i2c->state = RECEIVING_BIT7;
65
+ bitbang_i2c_set_state(i2c, RECEIVING_BIT7);
66
} else {
67
- i2c->state = SENDING_BIT7;
68
+ bitbang_i2c_set_state(i2c, SENDING_BIT7);
69
}
70
return bitbang_i2c_ret(i2c, 0);
71
}
72
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
73
case RECEIVING_BIT6 ... RECEIVING_BIT0:
74
data = i2c->buffer >> 7;
75
/* will end up in SENDING_ACK */
76
- i2c->state++;
77
+ bitbang_i2c_set_state(i2c, i2c->state + 1);
78
i2c->buffer <<= 1;
79
return bitbang_i2c_ret(i2c, data);
80
81
case SENDING_ACK:
82
- i2c->state = RECEIVING_BIT7;
83
if (data != 0) {
84
DPRINTF("NACKED\n");
85
- i2c->state = SENT_NACK;
86
+ bitbang_i2c_set_state(i2c, SENT_NACK);
87
i2c_nack(i2c->bus);
88
} else {
89
DPRINTF("ACKED\n");
90
+ bitbang_i2c_set_state(i2c, RECEIVING_BIT7);
91
}
92
return bitbang_i2c_ret(i2c, 1);
93
}
71
}
94
--
72
--
95
2.34.1
73
2.34.1
96
74
97
75
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Trace bitbang state machine changes with trace events.
4
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Acked-by: Corey Minyard <cminyard@mvista.com>
8
Message-id: 20230111085016.44551-5-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/i2c/bitbang_i2c.c | 33 ++++++++++++++++++++++++++++-----
12
hw/i2c/trace-events | 3 +++
13
2 files changed, 31 insertions(+), 5 deletions(-)
14
15
diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/i2c/bitbang_i2c.c
18
+++ b/hw/i2c/bitbang_i2c.c
19
@@ -XXX,XX +XXX,XX @@
20
#include "hw/sysbus.h"
21
#include "qemu/module.h"
22
#include "qom/object.h"
23
+#include "trace.h"
24
25
//#define DEBUG_BITBANG_I2C
26
27
@@ -XXX,XX +XXX,XX @@ do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0)
28
#define DPRINTF(fmt, ...) do {} while(0)
29
#endif
30
31
+/* bitbang_i2c_state enum to name */
32
+static const char * const sname[] = {
33
+#define NAME(e) [e] = stringify(e)
34
+ NAME(STOPPED),
35
+ [SENDING_BIT7] = "SENDING_BIT7 (START)",
36
+ NAME(SENDING_BIT6),
37
+ NAME(SENDING_BIT5),
38
+ NAME(SENDING_BIT4),
39
+ NAME(SENDING_BIT3),
40
+ NAME(SENDING_BIT2),
41
+ NAME(SENDING_BIT1),
42
+ NAME(SENDING_BIT0),
43
+ NAME(WAITING_FOR_ACK),
44
+ [RECEIVING_BIT7] = "RECEIVING_BIT7 (ACK)",
45
+ NAME(RECEIVING_BIT6),
46
+ NAME(RECEIVING_BIT5),
47
+ NAME(RECEIVING_BIT4),
48
+ NAME(RECEIVING_BIT3),
49
+ NAME(RECEIVING_BIT2),
50
+ NAME(RECEIVING_BIT1),
51
+ NAME(RECEIVING_BIT0),
52
+ NAME(SENDING_ACK),
53
+ NAME(SENT_NACK)
54
+#undef NAME
55
+};
56
+
57
static void bitbang_i2c_set_state(bitbang_i2c_interface *i2c,
58
bitbang_i2c_state state)
59
{
60
+ trace_bitbang_i2c_state(sname[i2c->state], sname[state]);
61
i2c->state = state;
62
}
63
64
static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c)
65
{
66
- DPRINTF("STOP\n");
67
if (i2c->current_addr >= 0)
68
i2c_end_transfer(i2c->bus);
69
i2c->current_addr = -1;
70
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
71
return bitbang_i2c_nop(i2c);
72
}
73
if (level == 0) {
74
- DPRINTF("START\n");
75
/* START condition. */
76
bitbang_i2c_set_state(i2c, SENDING_BIT7);
77
i2c->current_addr = -1;
78
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
79
/* NACK (either addressing a nonexistent device, or the
80
* device we were sending to decided to NACK us).
81
*/
82
- DPRINTF("Got NACK\n");
83
bitbang_i2c_set_state(i2c, SENT_NACK);
84
bitbang_i2c_enter_stop(i2c);
85
return bitbang_i2c_ret(i2c, 1);
86
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
87
88
case SENDING_ACK:
89
if (data != 0) {
90
- DPRINTF("NACKED\n");
91
bitbang_i2c_set_state(i2c, SENT_NACK);
92
i2c_nack(i2c->bus);
93
} else {
94
- DPRINTF("ACKED\n");
95
bitbang_i2c_set_state(i2c, RECEIVING_BIT7);
96
}
97
return bitbang_i2c_ret(i2c, 1);
98
diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events
99
index XXXXXXX..XXXXXXX 100644
100
--- a/hw/i2c/trace-events
101
+++ b/hw/i2c/trace-events
102
@@ -XXX,XX +XXX,XX @@
103
# See docs/devel/tracing.rst for syntax documentation.
104
105
+# bitbang_i2c.c
106
+bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s"
107
+
108
# core.c
109
110
i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)"
111
--
112
2.34.1
113
114
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Convert the remaining DPRINTF debug macro uses to tracepoints.
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Acked-by: Corey Minyard <cminyard@mvista.com>
8
Message-id: 20230111085016.44551-6-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/i2c/bitbang_i2c.c | 18 ++++++------------
12
hw/i2c/trace-events | 4 ++++
13
2 files changed, 10 insertions(+), 12 deletions(-)
14
15
diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/i2c/bitbang_i2c.c
18
+++ b/hw/i2c/bitbang_i2c.c
19
@@ -XXX,XX +XXX,XX @@
20
#include "qom/object.h"
21
#include "trace.h"
22
23
-//#define DEBUG_BITBANG_I2C
24
-
25
-#ifdef DEBUG_BITBANG_I2C
26
-#define DPRINTF(fmt, ...) \
27
-do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0)
28
-#else
29
-#define DPRINTF(fmt, ...) do {} while(0)
30
-#endif
31
32
/* bitbang_i2c_state enum to name */
33
static const char * const sname[] = {
34
@@ -XXX,XX +XXX,XX @@ static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c)
35
/* Set device data pin. */
36
static int bitbang_i2c_ret(bitbang_i2c_interface *i2c, int level)
37
{
38
+ trace_bitbang_i2c_data(i2c->last_clock, i2c->last_data,
39
+ i2c->device_out, level);
40
i2c->device_out = level;
41
- //DPRINTF("%d %d %d\n", i2c->last_clock, i2c->last_data, i2c->device_out);
42
+
43
return level & i2c->last_data;
44
}
45
46
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
47
48
if (i2c->current_addr < 0) {
49
i2c->current_addr = i2c->buffer;
50
- DPRINTF("Address 0x%02x\n", i2c->current_addr);
51
+ trace_bitbang_i2c_addr(i2c->current_addr);
52
ret = i2c_start_transfer(i2c->bus, i2c->current_addr >> 1,
53
i2c->current_addr & 1);
54
} else {
55
- DPRINTF("Sent 0x%02x\n", i2c->buffer);
56
+ trace_bitbang_i2c_send(i2c->buffer);
57
ret = i2c_send(i2c->bus, i2c->buffer);
58
}
59
if (ret) {
60
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
61
}
62
case RECEIVING_BIT7:
63
i2c->buffer = i2c_recv(i2c->bus);
64
- DPRINTF("RX byte 0x%02x\n", i2c->buffer);
65
+ trace_bitbang_i2c_recv(i2c->buffer);
66
/* Fall through... */
67
case RECEIVING_BIT6 ... RECEIVING_BIT0:
68
data = i2c->buffer >> 7;
69
diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events
70
index XXXXXXX..XXXXXXX 100644
71
--- a/hw/i2c/trace-events
72
+++ b/hw/i2c/trace-events
73
@@ -XXX,XX +XXX,XX @@
74
75
# bitbang_i2c.c
76
bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s"
77
+bitbang_i2c_addr(uint8_t addr) "Address 0x%02x"
78
+bitbang_i2c_send(uint8_t byte) "TX byte 0x%02x"
79
+bitbang_i2c_recv(uint8_t byte) "RX byte 0x%02x"
80
+bitbang_i2c_data(unsigned dat, unsigned clk, unsigned old_out, unsigned new_out) "dat %u clk %u out %u -> %u"
81
82
# core.c
83
84
--
85
2.34.1
86
87
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20230110082508.24038-2-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/i2c/versatile_i2c.c | 4 ++--
9
1 file changed, 2 insertions(+), 2 deletions(-)
10
11
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/i2c/versatile_i2c.c
14
+++ b/hw/i2c/versatile_i2c.c
15
@@ -XXX,XX +XXX,XX @@ REG32(CONTROL_CLR, 4)
16
static uint64_t versatile_i2c_read(void *opaque, hwaddr offset,
17
unsigned size)
18
{
19
- VersatileI2CState *s = (VersatileI2CState *)opaque;
20
+ VersatileI2CState *s = opaque;
21
22
switch (offset) {
23
case A_CONTROL_SET:
24
@@ -XXX,XX +XXX,XX @@ static uint64_t versatile_i2c_read(void *opaque, hwaddr offset,
25
static void versatile_i2c_write(void *opaque, hwaddr offset,
26
uint64_t value, unsigned size)
27
{
28
- VersatileI2CState *s = (VersatileI2CState *)opaque;
29
+ VersatileI2CState *s = opaque;
30
31
switch (offset) {
32
case A_CONTROL_SET:
33
--
34
2.34.1
35
36
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
In order to rename TYPE_VERSATILE_I2C as TYPE_ARM_SBCON_I2C
4
(the formal ARM naming), start renaming its state.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230110082508.24038-3-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/i2c/arm_sbcon_i2c.h | 3 +--
12
hw/i2c/versatile_i2c.c | 10 +++++-----
13
2 files changed, 6 insertions(+), 7 deletions(-)
14
15
diff --git a/include/hw/i2c/arm_sbcon_i2c.h b/include/hw/i2c/arm_sbcon_i2c.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/i2c/arm_sbcon_i2c.h
18
+++ b/include/hw/i2c/arm_sbcon_i2c.h
19
@@ -XXX,XX +XXX,XX @@
20
#define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C
21
22
typedef struct ArmSbconI2CState ArmSbconI2CState;
23
-DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C,
24
- TYPE_ARM_SBCON_I2C)
25
+DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C, TYPE_ARM_SBCON_I2C)
26
27
struct ArmSbconI2CState {
28
/*< private >*/
29
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/i2c/versatile_i2c.c
32
+++ b/hw/i2c/versatile_i2c.c
33
@@ -XXX,XX +XXX,XX @@
34
#include "qom/object.h"
35
36
typedef ArmSbconI2CState VersatileI2CState;
37
-DECLARE_INSTANCE_CHECKER(VersatileI2CState, VERSATILE_I2C,
38
+DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, VERSATILE_I2C,
39
TYPE_VERSATILE_I2C)
40
41
42
@@ -XXX,XX +XXX,XX @@ REG32(CONTROL_CLR, 4)
43
static uint64_t versatile_i2c_read(void *opaque, hwaddr offset,
44
unsigned size)
45
{
46
- VersatileI2CState *s = opaque;
47
+ ArmSbconI2CState *s = opaque;
48
49
switch (offset) {
50
case A_CONTROL_SET:
51
@@ -XXX,XX +XXX,XX @@ static uint64_t versatile_i2c_read(void *opaque, hwaddr offset,
52
static void versatile_i2c_write(void *opaque, hwaddr offset,
53
uint64_t value, unsigned size)
54
{
55
- VersatileI2CState *s = opaque;
56
+ ArmSbconI2CState *s = opaque;
57
58
switch (offset) {
59
case A_CONTROL_SET:
60
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps versatile_i2c_ops = {
61
static void versatile_i2c_init(Object *obj)
62
{
63
DeviceState *dev = DEVICE(obj);
64
- VersatileI2CState *s = VERSATILE_I2C(obj);
65
+ ArmSbconI2CState *s = VERSATILE_I2C(obj);
66
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
67
I2CBus *bus;
68
69
@@ -XXX,XX +XXX,XX @@ static void versatile_i2c_init(Object *obj)
70
static const TypeInfo versatile_i2c_info = {
71
.name = TYPE_VERSATILE_I2C,
72
.parent = TYPE_SYS_BUS_DEVICE,
73
- .instance_size = sizeof(VersatileI2CState),
74
+ .instance_size = sizeof(ArmSbconI2CState),
75
.instance_init = versatile_i2c_init,
76
};
77
78
--
79
2.34.1
80
81
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
3
Add a check in the bit-set operation to write the backstore
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
only if the affected bit is 0 before.
5
Message-id: 20230110082508.24038-4-philmd@linaro.org
5
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>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
14
---
8
include/hw/i2c/arm_sbcon_i2c.h | 3 +--
15
hw/nvram/xlnx-efuse.c | 11 +++++++++--
9
hw/arm/realview.c | 2 +-
16
1 file changed, 9 insertions(+), 2 deletions(-)
10
hw/arm/versatilepb.c | 2 +-
11
hw/arm/vexpress.c | 2 +-
12
hw/i2c/versatile_i2c.c | 4 ++--
13
5 files changed, 6 insertions(+), 7 deletions(-)
14
17
15
diff --git a/include/hw/i2c/arm_sbcon_i2c.h b/include/hw/i2c/arm_sbcon_i2c.h
18
diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c
16
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/i2c/arm_sbcon_i2c.h
20
--- a/hw/nvram/xlnx-efuse.c
18
+++ b/include/hw/i2c/arm_sbcon_i2c.h
21
+++ b/hw/nvram/xlnx-efuse.c
19
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ static bool efuse_ro_bits_find(XlnxEFuse *s, uint32_t k)
20
#include "hw/i2c/bitbang_i2c.h"
23
21
#include "qom/object.h"
24
bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit)
22
25
{
23
-#define TYPE_VERSATILE_I2C "versatile_i2c"
26
+ uint32_t set, *row;
24
-#define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C
27
+
25
+#define TYPE_ARM_SBCON_I2C "versatile_i2c"
28
if (efuse_ro_bits_find(s, bit)) {
26
29
g_autofree char *path = object_get_canonical_path(OBJECT(s));
27
typedef struct ArmSbconI2CState ArmSbconI2CState;
30
28
DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C, TYPE_ARM_SBCON_I2C)
31
@@ -XXX,XX +XXX,XX @@ bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit)
29
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
32
return false;
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/realview.c
32
+++ b/hw/arm/realview.c
33
@@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine,
34
}
35
}
33
}
36
34
37
- dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL);
35
- s->fuse32[bit / 32] |= 1 << (bit % 32);
38
+ dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL);
36
- efuse_bdrv_sync(s, bit);
39
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
37
+ /* Avoid back-end write unless there is a real update */
40
i2c_slave_create_simple(i2c, "ds1338", 0x68);
38
+ row = &s->fuse32[bit / 32];
41
39
+ set = 1 << (bit % 32);
42
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
40
+ if (!(set & *row)) {
43
index XXXXXXX..XXXXXXX 100644
41
+ *row |= set;
44
--- a/hw/arm/versatilepb.c
42
+ efuse_bdrv_sync(s, bit);
45
+++ b/hw/arm/versatilepb.c
43
+ }
46
@@ -XXX,XX +XXX,XX @@ static void versatile_init(MachineState *machine, int board_id)
44
return true;
47
/* Add PL031 Real Time Clock. */
48
sysbus_create_simple("pl031", 0x101e8000, pic[10]);
49
50
- dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL);
51
+ dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL);
52
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
53
i2c_slave_create_simple(i2c, "ds1338", 0x68);
54
55
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/arm/vexpress.c
58
+++ b/hw/arm/vexpress.c
59
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
60
sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
61
sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
62
63
- dev = sysbus_create_simple(TYPE_VERSATILE_I2C, map[VE_SERIALDVI], NULL);
64
+ dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, map[VE_SERIALDVI], NULL);
65
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
66
i2c_slave_create_simple(i2c, "sii9022", 0x39);
67
68
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/i2c/versatile_i2c.c
71
+++ b/hw/i2c/versatile_i2c.c
72
@@ -XXX,XX +XXX,XX @@
73
74
typedef ArmSbconI2CState VersatileI2CState;
75
DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, VERSATILE_I2C,
76
- TYPE_VERSATILE_I2C)
77
+ TYPE_ARM_SBCON_I2C)
78
79
80
81
@@ -XXX,XX +XXX,XX @@ static void versatile_i2c_init(Object *obj)
82
}
45
}
83
46
84
static const TypeInfo versatile_i2c_info = {
85
- .name = TYPE_VERSATILE_I2C,
86
+ .name = TYPE_ARM_SBCON_I2C,
87
.parent = TYPE_SYS_BUS_DEVICE,
88
.instance_size = sizeof(ArmSbconI2CState),
89
.instance_init = versatile_i2c_init,
90
--
47
--
91
2.34.1
48
2.34.1
92
49
93
50
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
ARM_SBCON_I2C() macro and ArmSbconI2CState typedef are
4
already declared via the QOM DECLARE_INSTANCE_CHECKER()
5
macro in "hw/i2c/arm_sbcon_i2c.h". Drop the VERSATILE_I2C
6
declarations from versatile_i2c.c.
7
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230110082508.24038-5-philmd@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
hw/i2c/versatile_i2c.c | 7 +------
14
1 file changed, 1 insertion(+), 6 deletions(-)
15
16
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/i2c/versatile_i2c.c
19
+++ b/hw/i2c/versatile_i2c.c
20
@@ -XXX,XX +XXX,XX @@
21
#include "qemu/module.h"
22
#include "qom/object.h"
23
24
-typedef ArmSbconI2CState VersatileI2CState;
25
-DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, VERSATILE_I2C,
26
- TYPE_ARM_SBCON_I2C)
27
-
28
-
29
30
REG32(CONTROL_GET, 0)
31
REG32(CONTROL_SET, 0)
32
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps versatile_i2c_ops = {
33
static void versatile_i2c_init(Object *obj)
34
{
35
DeviceState *dev = DEVICE(obj);
36
- ArmSbconI2CState *s = VERSATILE_I2C(obj);
37
+ ArmSbconI2CState *s = ARM_SBCON_I2C(obj);
38
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
39
I2CBus *bus;
40
41
--
42
2.34.1
43
44
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
This device model started with the Versatile board, named
4
TYPE_VERSATILE_I2C, then ended up renamed TYPE_ARM_SBCON_I2C
5
as per the official "ARM SBCon two-wire serial bus interface"
6
description from:
7
https://developer.arm.com/documentation/dui0440/b/programmer-s-reference/two-wire-serial-bus-interface--sbcon
8
9
Use the latter name as a better description.
10
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20230110082508.24038-6-philmd@linaro.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
MAINTAINERS | 1 +
17
hw/i2c/{versatile_i2c.c => arm_sbcon_i2c.c} | 24 ++++++++++-----------
18
hw/arm/Kconfig | 4 ++--
19
hw/i2c/Kconfig | 2 +-
20
hw/i2c/meson.build | 2 +-
21
5 files changed, 17 insertions(+), 16 deletions(-)
22
rename hw/i2c/{versatile_i2c.c => arm_sbcon_i2c.c} (81%)
23
24
diff --git a/MAINTAINERS b/MAINTAINERS
25
index XXXXXXX..XXXXXXX 100644
26
--- a/MAINTAINERS
27
+++ b/MAINTAINERS
28
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
29
L: qemu-arm@nongnu.org
30
S: Maintained
31
F: hw/*/versatile*
32
+F: hw/i2c/arm_sbcon_i2c.c
33
F: include/hw/i2c/arm_sbcon_i2c.h
34
F: hw/misc/arm_sysctl.c
35
F: docs/system/arm/versatile.rst
36
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/arm_sbcon_i2c.c
37
similarity index 81%
38
rename from hw/i2c/versatile_i2c.c
39
rename to hw/i2c/arm_sbcon_i2c.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/i2c/versatile_i2c.c
42
+++ b/hw/i2c/arm_sbcon_i2c.c
43
@@ -XXX,XX +XXX,XX @@ REG32(CONTROL_CLR, 4)
44
#define SCL BIT(0)
45
#define SDA BIT(1)
46
47
-static uint64_t versatile_i2c_read(void *opaque, hwaddr offset,
48
+static uint64_t arm_sbcon_i2c_read(void *opaque, hwaddr offset,
49
unsigned size)
50
{
51
ArmSbconI2CState *s = opaque;
52
@@ -XXX,XX +XXX,XX @@ static uint64_t versatile_i2c_read(void *opaque, hwaddr offset,
53
}
54
}
55
56
-static void versatile_i2c_write(void *opaque, hwaddr offset,
57
+static void arm_sbcon_i2c_write(void *opaque, hwaddr offset,
58
uint64_t value, unsigned size)
59
{
60
ArmSbconI2CState *s = opaque;
61
@@ -XXX,XX +XXX,XX @@ static void versatile_i2c_write(void *opaque, hwaddr offset,
62
s->in = bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SDA, (s->out & SDA) != 0);
63
}
64
65
-static const MemoryRegionOps versatile_i2c_ops = {
66
- .read = versatile_i2c_read,
67
- .write = versatile_i2c_write,
68
+static const MemoryRegionOps arm_sbcon_i2c_ops = {
69
+ .read = arm_sbcon_i2c_read,
70
+ .write = arm_sbcon_i2c_write,
71
.endianness = DEVICE_NATIVE_ENDIAN,
72
};
73
74
-static void versatile_i2c_init(Object *obj)
75
+static void arm_sbcon_i2c_init(Object *obj)
76
{
77
DeviceState *dev = DEVICE(obj);
78
ArmSbconI2CState *s = ARM_SBCON_I2C(obj);
79
@@ -XXX,XX +XXX,XX @@ static void versatile_i2c_init(Object *obj)
80
81
bus = i2c_init_bus(dev, "i2c");
82
bitbang_i2c_init(&s->bitbang, bus);
83
- memory_region_init_io(&s->iomem, obj, &versatile_i2c_ops, s,
84
+ memory_region_init_io(&s->iomem, obj, &arm_sbcon_i2c_ops, s,
85
"arm_sbcon_i2c", 0x1000);
86
sysbus_init_mmio(sbd, &s->iomem);
87
}
88
89
-static const TypeInfo versatile_i2c_info = {
90
+static const TypeInfo arm_sbcon_i2c_info = {
91
.name = TYPE_ARM_SBCON_I2C,
92
.parent = TYPE_SYS_BUS_DEVICE,
93
.instance_size = sizeof(ArmSbconI2CState),
94
- .instance_init = versatile_i2c_init,
95
+ .instance_init = arm_sbcon_i2c_init,
96
};
97
98
-static void versatile_i2c_register_types(void)
99
+static void arm_sbcon_i2c_register_types(void)
100
{
101
- type_register_static(&versatile_i2c_info);
102
+ type_register_static(&arm_sbcon_i2c_info);
103
}
104
105
-type_init(versatile_i2c_register_types)
106
+type_init(arm_sbcon_i2c_register_types)
107
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
108
index XXXXXXX..XXXXXXX 100644
109
--- a/hw/arm/Kconfig
110
+++ b/hw/arm/Kconfig
111
@@ -XXX,XX +XXX,XX @@ config REALVIEW
112
select PL110
113
select PL181 # display
114
select PL310 # cache controller
115
- select VERSATILE_I2C
116
+ select ARM_SBCON_I2C
117
select DS1338 # I2C RTC+NVRAM
118
select USB_OHCI
119
120
@@ -XXX,XX +XXX,XX @@ config MPS2
121
select SPLIT_IRQ
122
select UNIMP
123
select CMSDK_APB_WATCHDOG
124
- select VERSATILE_I2C
125
+ select ARM_SBCON_I2C
126
127
config FSL_IMX7
128
bool
129
diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig
130
index XXXXXXX..XXXXXXX 100644
131
--- a/hw/i2c/Kconfig
132
+++ b/hw/i2c/Kconfig
133
@@ -XXX,XX +XXX,XX @@ config SMBUS_EEPROM
134
bool
135
select SMBUS
136
137
-config VERSATILE_I2C
138
+config ARM_SBCON_I2C
139
bool
140
select BITBANG_I2C
141
142
diff --git a/hw/i2c/meson.build b/hw/i2c/meson.build
143
index XXXXXXX..XXXXXXX 100644
144
--- a/hw/i2c/meson.build
145
+++ b/hw/i2c/meson.build
146
@@ -XXX,XX +XXX,XX @@ i2c_ss.add(when: 'CONFIG_ALLWINNER_I2C', if_true: files('allwinner-i2c.c'))
147
i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c'))
148
i2c_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_smbus.c'))
149
i2c_ss.add(when: 'CONFIG_SMBUS_EEPROM', if_true: files('smbus_eeprom.c'))
150
-i2c_ss.add(when: 'CONFIG_VERSATILE_I2C', if_true: files('versatile_i2c.c'))
151
+i2c_ss.add(when: 'CONFIG_ARM_SBCON_I2C', if_true: files('arm_sbcon_i2c.c'))
152
i2c_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_i2c.c'))
153
i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_i2c.c'))
154
i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c'))
155
--
156
2.34.1
157
158
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Message-id: 20230112102436.1913-2-philmd@linaro.org
7
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
8
[PMD: Split patch in multiple tiny steps]
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/translate-a64.c | 24 +++++++++++++-----------
13
1 file changed, 13 insertions(+), 11 deletions(-)
14
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
18
+++ b/target/arm/translate-a64.c
19
@@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn,
20
goto do_unallocated;
21
}
22
if (sme_access_check(s)) {
23
- bool i = crm & 1;
24
- bool changed = false;
25
+ int old = s->pstate_sm | (s->pstate_za << 1);
26
+ int new = (crm & 1) * 3;
27
+ int msk = (crm >> 1) & 3;
28
29
- if ((crm & 2) && i != s->pstate_sm) {
30
- gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i));
31
- changed = true;
32
- }
33
- if ((crm & 4) && i != s->pstate_za) {
34
- gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i));
35
- changed = true;
36
- }
37
- if (changed) {
38
+ if ((old ^ new) & msk) {
39
+ /* At least one bit changes. */
40
+ bool i = crm & 1;
41
+
42
+ if ((crm & 2) && i != s->pstate_sm) {
43
+ gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i));
44
+ }
45
+ if ((crm & 4) && i != s->pstate_za) {
46
+ gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i));
47
+ }
48
gen_rebuild_hflags(s);
49
} else {
50
s->base.is_jmp = DISAS_NEXT;
51
--
52
2.34.1
53
54
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Message-id: 20230112102436.1913-3-philmd@linaro.org
7
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
8
[PMD: Split patch in multiple tiny steps]
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/sme_helper.c | 2 ++
13
target/arm/translate-a64.c | 1 -
14
2 files changed, 2 insertions(+), 1 deletion(-)
15
16
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/sme_helper.c
19
+++ b/target/arm/sme_helper.c
20
@@ -XXX,XX +XXX,XX @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
21
}
22
env->svcr ^= R_SVCR_SM_MASK;
23
arm_reset_sve_state(env);
24
+ arm_rebuild_hflags(env);
25
}
26
27
void helper_set_pstate_za(CPUARMState *env, uint32_t i)
28
@@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i)
29
if (i) {
30
memset(env->zarray, 0, sizeof(env->zarray));
31
}
32
+ arm_rebuild_hflags(env);
33
}
34
35
void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
36
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/translate-a64.c
39
+++ b/target/arm/translate-a64.c
40
@@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn,
41
if ((crm & 4) && i != s->pstate_za) {
42
gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i));
43
}
44
- gen_rebuild_hflags(s);
45
} else {
46
s->base.is_jmp = DISAS_NEXT;
47
}
48
--
49
2.34.1
50
51
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Message-id: 20230112102436.1913-4-philmd@linaro.org
7
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
8
[PMD: Split patch in multiple tiny steps]
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/cpu.h | 1 +
13
linux-user/aarch64/cpu_loop.c | 2 +-
14
linux-user/aarch64/signal.c | 2 +-
15
target/arm/helper.c | 8 ++++++++
16
target/arm/sme_helper.c | 4 ++--
17
5 files changed, 13 insertions(+), 4 deletions(-)
18
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.h
22
+++ b/target/arm/cpu.h
23
@@ -XXX,XX +XXX,XX @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
24
void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
25
void aarch64_sve_change_el(CPUARMState *env, int old_el,
26
int new_el, bool el0_a64);
27
+void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask);
28
void arm_reset_sve_state(CPUARMState *env);
29
30
/*
31
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/linux-user/aarch64/cpu_loop.c
34
+++ b/linux-user/aarch64/cpu_loop.c
35
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
36
* On syscall, PSTATE.ZA is preserved, along with the ZA matrix.
37
* PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState.
38
*/
39
+ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
40
if (FIELD_EX64(env->svcr, SVCR, SM)) {
41
- env->svcr = FIELD_DP64(env->svcr, SVCR, SM, 0);
42
arm_rebuild_hflags(env);
43
arm_reset_sve_state(env);
44
}
45
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/linux-user/aarch64/signal.c
48
+++ b/linux-user/aarch64/signal.c
49
@@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
50
* Invoke the signal handler with both SM and ZA disabled.
51
* When clearing SM, ResetSVEState, per SMSTOP.
52
*/
53
+ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
54
if (FIELD_EX64(env->svcr, SVCR, SM)) {
55
arm_reset_sve_state(env);
56
}
57
if (env->svcr) {
58
- env->svcr = 0;
59
arm_rebuild_hflags(env);
60
}
61
62
diff --git a/target/arm/helper.c b/target/arm/helper.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/target/arm/helper.c
65
+++ b/target/arm/helper.c
66
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri,
67
return CP_ACCESS_OK;
68
}
69
70
+void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
71
+{
72
+ uint64_t change = (env->svcr ^ new) & mask;
73
+
74
+ env->svcr ^= change;
75
+}
76
+
77
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
78
uint64_t value)
79
{
80
helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM));
81
helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA));
82
+ aarch64_set_svcr(env, value, -1);
83
arm_rebuild_hflags(env);
84
}
85
86
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/target/arm/sme_helper.c
89
+++ b/target/arm/sme_helper.c
90
@@ -XXX,XX +XXX,XX @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
91
if (i == FIELD_EX64(env->svcr, SVCR, SM)) {
92
return;
93
}
94
- env->svcr ^= R_SVCR_SM_MASK;
95
+ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
96
arm_reset_sve_state(env);
97
arm_rebuild_hflags(env);
98
}
99
@@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i)
100
if (i == FIELD_EX64(env->svcr, SVCR, ZA)) {
101
return;
102
}
103
- env->svcr ^= R_SVCR_ZA_MASK;
104
+ aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
105
106
/*
107
* ResetSMEState.
108
--
109
2.34.1
110
111
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Move arm_reset_sve_state() calls to aarch64_set_svcr().
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Fabiano Rosas <farosas@suse.de>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20230112102436.1913-5-philmd@linaro.org
9
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
10
[PMD: Split patch in multiple tiny steps]
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/cpu.h | 1 -
15
linux-user/aarch64/cpu_loop.c | 1 -
16
linux-user/aarch64/signal.c | 8 +-------
17
target/arm/helper.c | 13 +++++++++++++
18
target/arm/sme_helper.c | 10 ----------
19
5 files changed, 14 insertions(+), 19 deletions(-)
20
21
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/cpu.h
24
+++ b/target/arm/cpu.h
25
@@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
26
void aarch64_sve_change_el(CPUARMState *env, int old_el,
27
int new_el, bool el0_a64);
28
void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask);
29
-void arm_reset_sve_state(CPUARMState *env);
30
31
/*
32
* SVE registers are encoded in KVM's memory in an endianness-invariant format.
33
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/linux-user/aarch64/cpu_loop.c
36
+++ b/linux-user/aarch64/cpu_loop.c
37
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
38
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
39
if (FIELD_EX64(env->svcr, SVCR, SM)) {
40
arm_rebuild_hflags(env);
41
- arm_reset_sve_state(env);
42
}
43
ret = do_syscall(env,
44
env->xregs[8],
45
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/linux-user/aarch64/signal.c
48
+++ b/linux-user/aarch64/signal.c
49
@@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
50
env->btype = 2;
51
}
52
53
- /*
54
- * Invoke the signal handler with both SM and ZA disabled.
55
- * When clearing SM, ResetSVEState, per SMSTOP.
56
- */
57
+ /* Invoke the signal handler with both SM and ZA disabled. */
58
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
59
- if (FIELD_EX64(env->svcr, SVCR, SM)) {
60
- arm_reset_sve_state(env);
61
- }
62
if (env->svcr) {
63
arm_rebuild_hflags(env);
64
}
65
diff --git a/target/arm/helper.c b/target/arm/helper.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/target/arm/helper.c
68
+++ b/target/arm/helper.c
69
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri,
70
return CP_ACCESS_OK;
71
}
72
73
+/* ResetSVEState */
74
+static void arm_reset_sve_state(CPUARMState *env)
75
+{
76
+ memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
77
+ /* Recall that FFR is stored as pregs[16]. */
78
+ memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
79
+ vfp_set_fpcr(env, 0x0800009f);
80
+}
81
+
82
void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
83
{
84
uint64_t change = (env->svcr ^ new) & mask;
85
86
env->svcr ^= change;
87
+
88
+ if (change & R_SVCR_SM_MASK) {
89
+ arm_reset_sve_state(env);
90
+ }
91
}
92
93
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
94
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
95
index XXXXXXX..XXXXXXX 100644
96
--- a/target/arm/sme_helper.c
97
+++ b/target/arm/sme_helper.c
98
@@ -XXX,XX +XXX,XX @@
99
#include "vec_internal.h"
100
#include "sve_ldst_internal.h"
101
102
-/* ResetSVEState */
103
-void arm_reset_sve_state(CPUARMState *env)
104
-{
105
- memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
106
- /* Recall that FFR is stored as pregs[16]. */
107
- memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
108
- vfp_set_fpcr(env, 0x0800009f);
109
-}
110
-
111
void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
112
{
113
if (i == FIELD_EX64(env->svcr, SVCR, SM)) {
114
return;
115
}
116
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
117
- arm_reset_sve_state(env);
118
arm_rebuild_hflags(env);
119
}
120
121
--
122
2.34.1
123
124
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Message-id: 20230112102436.1913-6-philmd@linaro.org
7
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
8
[PMD: Split patch in multiple tiny steps]
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/helper.c | 12 ++++++++++++
13
target/arm/sme_helper.c | 12 ------------
14
2 files changed, 12 insertions(+), 12 deletions(-)
15
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper.c
19
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
21
if (change & R_SVCR_SM_MASK) {
22
arm_reset_sve_state(env);
23
}
24
+
25
+ /*
26
+ * ResetSMEState.
27
+ *
28
+ * SetPSTATE_ZA zeros on enable and disable. We can zero this only
29
+ * on enable: while disabled, the storage is inaccessible and the
30
+ * value does not matter. We're not saving the storage in vmstate
31
+ * when disabled either.
32
+ */
33
+ if (change & new & R_SVCR_ZA_MASK) {
34
+ memset(env->zarray, 0, sizeof(env->zarray));
35
+ }
36
}
37
38
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
39
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/sme_helper.c
42
+++ b/target/arm/sme_helper.c
43
@@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i)
44
return;
45
}
46
aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
47
-
48
- /*
49
- * ResetSMEState.
50
- *
51
- * SetPSTATE_ZA zeros on enable and disable. We can zero this only
52
- * on enable: while disabled, the storage is inaccessible and the
53
- * value does not matter. We're not saving the storage in vmstate
54
- * when disabled either.
55
- */
56
- if (i) {
57
- memset(env->zarray, 0, sizeof(env->zarray));
58
- }
59
arm_rebuild_hflags(env);
60
}
61
62
--
63
2.34.1
64
65
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Message-id: 20230112102436.1913-7-philmd@linaro.org
7
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
8
[PMD: Split patch in multiple tiny steps]
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
linux-user/aarch64/cpu_loop.c | 8 +-------
13
linux-user/aarch64/signal.c | 3 ---
14
target/arm/helper.c | 6 +++++-
15
target/arm/sme_helper.c | 8 --------
16
4 files changed, 6 insertions(+), 19 deletions(-)
17
18
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/linux-user/aarch64/cpu_loop.c
21
+++ b/linux-user/aarch64/cpu_loop.c
22
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
23
24
switch (trapnr) {
25
case EXCP_SWI:
26
- /*
27
- * On syscall, PSTATE.ZA is preserved, along with the ZA matrix.
28
- * PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState.
29
- */
30
+ /* On syscall, PSTATE.ZA is preserved, PSTATE.SM is cleared. */
31
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
32
- if (FIELD_EX64(env->svcr, SVCR, SM)) {
33
- arm_rebuild_hflags(env);
34
- }
35
ret = do_syscall(env,
36
env->xregs[8],
37
env->xregs[0],
38
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/linux-user/aarch64/signal.c
41
+++ b/linux-user/aarch64/signal.c
42
@@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
43
44
/* Invoke the signal handler with both SM and ZA disabled. */
45
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
46
- if (env->svcr) {
47
- arm_rebuild_hflags(env);
48
- }
49
50
if (info) {
51
tswap_siginfo(&frame->info, info);
52
diff --git a/target/arm/helper.c b/target/arm/helper.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/helper.c
55
+++ b/target/arm/helper.c
56
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
57
{
58
uint64_t change = (env->svcr ^ new) & mask;
59
60
+ if (change == 0) {
61
+ return;
62
+ }
63
env->svcr ^= change;
64
65
if (change & R_SVCR_SM_MASK) {
66
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
67
if (change & new & R_SVCR_ZA_MASK) {
68
memset(env->zarray, 0, sizeof(env->zarray));
69
}
70
+
71
+ arm_rebuild_hflags(env);
72
}
73
74
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
75
@@ -XXX,XX +XXX,XX @@ static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
76
helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM));
77
helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA));
78
aarch64_set_svcr(env, value, -1);
79
- arm_rebuild_hflags(env);
80
}
81
82
static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
83
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/target/arm/sme_helper.c
86
+++ b/target/arm/sme_helper.c
87
@@ -XXX,XX +XXX,XX @@
88
89
void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
90
{
91
- if (i == FIELD_EX64(env->svcr, SVCR, SM)) {
92
- return;
93
- }
94
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
95
- arm_rebuild_hflags(env);
96
}
97
98
void helper_set_pstate_za(CPUARMState *env, uint32_t i)
99
{
100
- if (i == FIELD_EX64(env->svcr, SVCR, ZA)) {
101
- return;
102
- }
103
aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
104
- arm_rebuild_hflags(env);
105
}
106
107
void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
108
--
109
2.34.1
110
111
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Unify the two helper_set_pstate_{sm,za} in this function.
4
Do not call helper_* functions from svcr_write.
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Fabiano Rosas <farosas@suse.de>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Message-id: 20230112102436.1913-8-philmd@linaro.org
10
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
11
[PMD: Split patch in multiple tiny steps]
12
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
target/arm/helper-sme.h | 3 +--
16
target/arm/helper.c | 2 --
17
target/arm/sme_helper.c | 9 ++-------
18
target/arm/translate-a64.c | 10 ++--------
19
4 files changed, 5 insertions(+), 19 deletions(-)
20
21
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/helper-sme.h
24
+++ b/target/arm/helper-sme.h
25
@@ -XXX,XX +XXX,XX @@
26
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
27
*/
28
29
-DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32)
30
-DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32)
31
+DEF_HELPER_FLAGS_3(set_svcr, TCG_CALL_NO_RWG, void, env, i32, i32)
32
33
DEF_HELPER_FLAGS_3(sme_zero, TCG_CALL_NO_RWG, void, env, i32, i32)
34
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/helper.c
38
+++ b/target/arm/helper.c
39
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
40
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
41
uint64_t value)
42
{
43
- helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM));
44
- helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA));
45
aarch64_set_svcr(env, value, -1);
46
}
47
48
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/target/arm/sme_helper.c
51
+++ b/target/arm/sme_helper.c
52
@@ -XXX,XX +XXX,XX @@
53
#include "vec_internal.h"
54
#include "sve_ldst_internal.h"
55
56
-void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
57
+void helper_set_svcr(CPUARMState *env, uint32_t val, uint32_t mask)
58
{
59
- aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
60
-}
61
-
62
-void helper_set_pstate_za(CPUARMState *env, uint32_t i)
63
-{
64
- aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
65
+ aarch64_set_svcr(env, val, mask);
66
}
67
68
void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
69
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/target/arm/translate-a64.c
72
+++ b/target/arm/translate-a64.c
73
@@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn,
74
75
if ((old ^ new) & msk) {
76
/* At least one bit changes. */
77
- bool i = crm & 1;
78
-
79
- if ((crm & 2) && i != s->pstate_sm) {
80
- gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i));
81
- }
82
- if ((crm & 4) && i != s->pstate_za) {
83
- gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i));
84
- }
85
+ gen_helper_set_svcr(cpu_env, tcg_constant_i32(new),
86
+ tcg_constant_i32(msk));
87
} else {
88
s->base.is_jmp = DISAS_NEXT;
89
}
90
--
91
2.34.1
92
93
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Conversion to probe_access_full missed applying the page offset.
4
5
Fixes: b8967ddf ("target/arm: Use probe_access_full for MTE")
6
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1416
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230114031213.2970349-1-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/mte_helper.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/mte_helper.c
18
+++ b/target/arm/mte_helper.c
19
@@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx,
20
* Remember these values across the second lookup below,
21
* which may invalidate this pointer via tlb resize.
22
*/
23
- ptr_paddr = full->phys_addr;
24
+ ptr_paddr = full->phys_addr | (ptr & ~TARGET_PAGE_MASK);
25
attrs = full->attrs;
26
full = NULL;
27
28
--
29
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
1
3
Qemu doesn't implement Debug Communication Channel, as well as the rest
4
of external debug interface. However, Microsoft Hyper-V in tries to
5
access some of those registers during an EL2 context switch.
6
7
Since there is no architectural way to not advertise support for external
8
debug, provide RAZ/WI stubs for OSDTRRX_EL1, OSDTRTX_EL1 and OSECCR_EL1
9
registers in the same way the rest of DCM is currently done. Do account
10
for access traps though with access_tda.
11
12
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Message-id: 20230120155929.32384-3-eiakovlev@linux.microsoft.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
target/arm/debug_helper.c | 21 +++++++++++++++++++++
18
1 file changed, 21 insertions(+)
19
20
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/debug_helper.c
23
+++ b/target/arm/debug_helper.c
24
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
25
.opc0 = 2, .opc1 = 3, .crn = 0, .crm = 1, .opc2 = 0,
26
.access = PL0_R, .accessfn = access_tda,
27
.type = ARM_CP_CONST, .resetvalue = 0 },
28
+ /*
29
+ * OSDTRRX_EL1/OSDTRTX_EL1 are used for save and restore of DBGDTRRX_EL0.
30
+ * It is a component of the Debug Communications Channel, which is not implemented.
31
+ */
32
+ { .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14,
33
+ .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2,
34
+ .access = PL1_RW, .accessfn = access_tda,
35
+ .type = ARM_CP_CONST, .resetvalue = 0 },
36
+ { .name = "OSDTRTX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14,
37
+ .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2,
38
+ .access = PL1_RW, .accessfn = access_tda,
39
+ .type = ARM_CP_CONST, .resetvalue = 0 },
40
+ /*
41
+ * OSECCR_EL1 provides a mechanism for an operating system
42
+ * to access the contents of EDECCR. EDECCR is not implemented though,
43
+ * as is the rest of external device mechanism.
44
+ */
45
+ { .name = "OSECCR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14,
46
+ .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2,
47
+ .access = PL1_RW, .accessfn = access_tda,
48
+ .type = ARM_CP_CONST, .resetvalue = 0 },
49
/*
50
* DBGDSCRint[15,12,5:2] map to MDSCR_EL1[15,12,5:2]. Map all bits as
51
* it is unlikely a guest will care.
52
--
53
2.34.1
diff view generated by jsdifflib