1
First arm pullreq of the 2.13 cycle!
1
The following changes since commit 65cc5ccf06a74c98de73ec683d9a543baa302a12:
2
2
3
-- PMM
3
Merge tag 'pull-riscv-to-apply-20230120' of https://github.com/alistair23/qemu into staging (2023-01-20 16:17:56 +0000)
4
5
The following changes since commit 4743c23509a51bd4ee85cc272287a41917d1be35:
6
7
Update version for v2.12.0 release (2018-04-24 16:44:55 +0100)
8
4
9
are available in the Git repository at:
5
are available in the Git repository at:
10
6
11
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180426
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230123
12
8
13
for you to fetch changes up to fbf32752663878947de455ff57cb5b9318f14bec:
9
for you to fetch changes up to 3b07a936d3bfe97b07ddffcfbb532985a88033dd:
14
10
15
xilinx_spips: Correct SNOOP_NONE state when flushing the txfifo (2018-04-26 11:04:40 +0100)
11
target/arm: Look up ARMCPRegInfo at runtime (2023-01-23 13:32:38 +0000)
16
12
17
----------------------------------------------------------------
13
----------------------------------------------------------------
18
target-arm queue:
14
target-arm queue:
19
* xilinx_spips: Correct SNOOP_NONE state when flushing the txfifo
15
* Widen cnthctl_el2 to uint64_t
20
* timer/aspeed: fix vmstate version id
16
* Unify checking for M Main Extension in MRS/MSR
21
* hw/arm/aspeed_soc: don't use vmstate_register_ram_global for SRAM
17
* bitbang_i2c, versatile_i2c: code cleanups
22
* hw/arm/aspeed: don't make 'boot_rom' region 'nomigrate'
18
* SME: refactor SME SM/ZA handling
23
* hw/arm/highbank: don't make sysram 'nomigrate'
19
* Fix physical address resolution for MTE
24
* hw/arm/raspi: Don't bother setting default_cpu_type
20
* Fix in_debug path in S1_ptw_translate
25
* PMU emulation: some minor bugfixes and preparation for
21
* Don't set EXC_RETURN.ES if Security Extension not present
26
support of other events than just the cycle counter
22
* Implement DBGCLAIM registers
27
* target/arm: Use v7m_stack_read() for reading the frame signature
23
* Provide stubs for more external debug registers
28
* target/arm: Remove stale TODO comment
24
* Look up ARMCPRegInfo at runtime, not translate time
29
* arm: always start from first_cpu when registering loader cpu reset callback
30
* device_tree: Increase FDT_MAX_SIZE to 1 MiB
31
25
32
----------------------------------------------------------------
26
----------------------------------------------------------------
33
Aaron Lindsay (9):
27
David Reiss (1):
34
target/arm: Check PMCNTEN for whether PMCCNTR is enabled
28
target/arm: Unify checking for M Main Extension in MRS/MSR
35
target/arm: Treat PMCCNTR as alias of PMCCNTR_EL0
36
target/arm: Mask PMU register writes based on PMCR_EL0.N
37
target/arm: Fetch GICv3 state directly from CPUARMState
38
target/arm: Support multiple EL change hooks
39
target/arm: Add pre-EL change hooks
40
target/arm: Allow EL change hooks to do IO
41
target/arm: Fix bitmask for PMCCFILTR writes
42
target/arm: Make PMOVSCLR and PMUSERENR 64 bits wide
43
29
44
Cédric Le Goater (1):
30
Evgeny Iakovlev (2):
45
timer/aspeed: fix vmstate version id
31
target/arm: implement DBGCLAIM registers
32
target/arm: provide stubs for more external debug registers
46
33
47
Geert Uytterhoeven (1):
34
Peter Maydell (1):
48
device_tree: Increase FDT_MAX_SIZE to 1 MiB
35
target/arm: Don't set EXC_RETURN.ES if Security Extension not present
49
36
50
Igor Mammedov (1):
37
Philippe Mathieu-Daudé (10):
51
arm: always start from first_cpu when registering loader cpu reset callback
38
hw/i2c/bitbang_i2c: Define TYPE_GPIO_I2C in public header
39
hw/i2c/bitbang_i2c: Remove unused dummy MemoryRegion
40
hw/i2c/bitbang_i2c: Change state calling bitbang_i2c_set_state() helper
41
hw/i2c/bitbang_i2c: Trace state changes
42
hw/i2c/bitbang_i2c: Convert DPRINTF() to trace events
43
hw/i2c/versatile_i2c: Drop useless casts from void * to pointer
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
52
48
53
Peter Maydell (6):
49
Richard Henderson (12):
54
target/arm: Remove stale TODO comment
50
target/arm: Widen cnthctl_el2 to uint64_t
55
target/arm: Use v7m_stack_read() for reading the frame signature
51
target/arm/sme: Reorg SME access handling in handle_msr_i()
56
hw/arm/raspi: Don't bother setting default_cpu_type
52
target/arm/sme: Rebuild hflags in set_pstate() helpers
57
hw/arm/highbank: don't make sysram 'nomigrate'
53
target/arm/sme: Introduce aarch64_set_svcr()
58
hw/arm/aspeed: don't make 'boot_rom' region 'nomigrate'
54
target/arm/sme: Reset SVE state in aarch64_set_svcr()
59
hw/arm/aspeed_soc: don't use vmstate_register_ram_global for SRAM
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
60
62
61
Sai Pavan Boddu (1):
63
MAINTAINERS | 1 +
62
xilinx_spips: Correct SNOOP_NONE state when flushing the txfifo
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%)
63
93
64
target/arm/cpu.h | 48 +++++++++++++++++-------------
65
target/arm/internals.h | 14 +++++++--
66
device_tree.c | 2 +-
67
hw/arm/aspeed.c | 2 +-
68
hw/arm/aspeed_soc.c | 3 +-
69
hw/arm/boot.c | 2 +-
70
hw/arm/highbank.c | 2 +-
71
hw/arm/raspi.c | 2 --
72
hw/intc/arm_gicv3_cpuif.c | 10 ++-----
73
hw/ssi/xilinx_spips.c | 3 +-
74
hw/timer/aspeed_timer.c | 2 +-
75
target/arm/cpu.c | 37 +++++++++++++++++++----
76
target/arm/helper.c | 73 ++++++++++++++++++++++++++--------------------
77
target/arm/op_helper.c | 8 +++++
78
target/arm/translate-a64.c | 6 ++++
79
target/arm/translate.c | 12 ++++++++
80
16 files changed, 148 insertions(+), 78 deletions(-)
81
diff view generated by jsdifflib
1
From: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This is a bug fix to ensure 64-bit reads of these registers don't read
3
This is a 64-bit register on AArch64, even if the high 44 bits
4
adjacent data.
4
are RES0. Because this is defined as ARM_CP_STATE_BOTH, we are
5
asserting that the cpreg field is 64-bits.
5
6
6
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
7
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1400
7
Message-id: 1523997485-1905-13-git-send-email-alindsay@codeaurora.org
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230115171633.3171890-1-richard.henderson@linaro.org
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
target/arm/cpu.h | 4 ++--
13
target/arm/cpu.h | 2 +-
12
target/arm/helper.c | 5 +++--
14
1 file changed, 1 insertion(+), 1 deletion(-)
13
2 files changed, 5 insertions(+), 4 deletions(-)
14
15
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.h
18
--- a/target/arm/cpu.h
18
+++ b/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
19
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
20
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
20
uint32_t c9_data;
21
};
21
uint64_t c9_pmcr; /* performance monitor control register */
22
uint64_t c14_cntfrq; /* Counter Frequency register */
22
uint64_t c9_pmcnten; /* perf monitor counter enables */
23
uint64_t c14_cntkctl; /* Timer Control register */
23
- uint32_t c9_pmovsr; /* perf monitor overflow status */
24
- uint32_t cnthctl_el2; /* Counter/Timer Hyp Control register */
24
- uint32_t c9_pmuserenr; /* perf monitor user enable */
25
+ uint64_t cnthctl_el2; /* Counter/Timer Hyp Control register */
25
+ uint64_t c9_pmovsr; /* perf monitor overflow status */
26
uint64_t cntvoff_el2; /* Counter Virtual Offset register */
26
+ uint64_t c9_pmuserenr; /* perf monitor user enable */
27
ARMGenericTimer c14_timer[NUM_GTIMERS];
27
uint64_t c9_pmselr; /* perf monitor counter selection register */
28
uint32_t c15_cpar; /* XScale Coprocessor Access Register */
28
uint64_t c9_pminten; /* perf monitor interrupt enables */
29
union { /* Memory attribute redirection */
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/helper.c
33
+++ b/target/arm/helper.c
34
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
35
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmcnten),
36
.writefn = pmcntenclr_write },
37
{ .name = "PMOVSR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 3,
38
- .access = PL0_RW, .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr),
39
+ .access = PL0_RW,
40
+ .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmovsr),
41
.accessfn = pmreg_access,
42
.writefn = pmovsr_write,
43
.raw_writefn = raw_write },
44
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
45
.accessfn = pmreg_access_xevcntr },
46
{ .name = "PMUSERENR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 0,
47
.access = PL0_R | PL1_RW, .accessfn = access_tpm,
48
- .fieldoffset = offsetof(CPUARMState, cp15.c9_pmuserenr),
49
+ .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmuserenr),
50
.resetvalue = 0,
51
.writefn = pmuserenr_write, .raw_writefn = raw_write },
52
{ .name = "PMUSERENR_EL0", .state = ARM_CP_STATE_AA64,
53
--
29
--
54
2.17.0
30
2.34.1
55
56
diff view generated by jsdifflib
New patch
1
From: David Reiss <dreiss@meta.com>
1
2
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
1
From: Geert Uytterhoeven <geert+renesas@glider.be>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
It is not uncommon for a contemporary FDT to be larger than 64 KiB,
3
Define TYPE_GPIO_I2C in the public "hw/i2c/bitbang_i2c.h"
4
leading to failures loading the device tree from sysfs:
4
header and use it in hw/arm/musicpal.c.
5
5
6
qemu-system-aarch64: qemu_fdt_setprop: Couldn't set ...: FDT_ERR_NOSPACE
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Hence increase the limit to 1 MiB, like on PPC.
8
Acked-by: Corey Minyard <cminyard@mvista.com>
9
9
Message-id: 20230111085016.44551-2-philmd@linaro.org
10
For reference, the largest arm64 DTB created from the Linux sources is
11
ca. 75 KiB large (100 KiB when built with symbols/fixup support).
12
13
Cc: qemu-stable@nongnu.org
14
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
15
Message-id: 1523541337-23919-1-git-send-email-geert+renesas@glider.be
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
11
---
19
device_tree.c | 2 +-
12
include/hw/i2c/bitbang_i2c.h | 2 ++
20
1 file changed, 1 insertion(+), 1 deletion(-)
13
hw/arm/musicpal.c | 3 ++-
14
hw/i2c/bitbang_i2c.c | 1 -
15
3 files changed, 4 insertions(+), 2 deletions(-)
21
16
22
diff --git a/device_tree.c b/device_tree.c
17
diff --git a/include/hw/i2c/bitbang_i2c.h b/include/hw/i2c/bitbang_i2c.h
23
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
24
--- a/device_tree.c
19
--- a/include/hw/i2c/bitbang_i2c.h
25
+++ b/device_tree.c
20
+++ b/include/hw/i2c/bitbang_i2c.h
26
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@
27
22
28
#include <libfdt.h>
23
#include "hw/i2c/i2c.h"
29
24
30
-#define FDT_MAX_SIZE 0x10000
25
+#define TYPE_GPIO_I2C "gpio_i2c"
31
+#define FDT_MAX_SIZE 0x100000
26
+
32
27
typedef struct bitbang_i2c_interface bitbang_i2c_interface;
33
void *create_device_tree(int *sizep)
28
34
{
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 {
35
--
63
--
36
2.17.0
64
2.34.1
37
65
38
66
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
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: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
This is in preparation for enabling counters other than PMCCNTR
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
5
Acked-by: Corey Minyard <cminyard@mvista.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 20230111085016.44551-4-philmd@linaro.org
7
Message-id: 1523997485-1905-5-git-send-email-alindsay@codeaurora.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
8
---
10
target/arm/helper.c | 31 ++++++++++++++++++++++---------
9
hw/i2c/bitbang_i2c.c | 23 +++++++++++++++--------
11
1 file changed, 22 insertions(+), 9 deletions(-)
10
1 file changed, 15 insertions(+), 8 deletions(-)
12
11
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
14
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
14
--- a/hw/i2c/bitbang_i2c.c
16
+++ b/target/arm/helper.c
15
+++ b/hw/i2c/bitbang_i2c.c
17
@@ -XXX,XX +XXX,XX @@ typedef struct V8M_SAttributes {
16
@@ -XXX,XX +XXX,XX @@ do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0)
18
static void v8m_security_lookup(CPUARMState *env, uint32_t address,
17
#define DPRINTF(fmt, ...) do {} while(0)
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
20
V8M_SAttributes *sattrs);
21
-
22
-/* Definitions for the PMCCNTR and PMCR registers */
23
-#define PMCRD 0x8
24
-#define PMCRC 0x4
25
-#define PMCRE 0x1
26
#endif
18
#endif
27
19
28
static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg)
20
+static void bitbang_i2c_set_state(bitbang_i2c_interface *i2c,
29
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = {
21
+ bitbang_i2c_state state)
30
REGINFO_SENTINEL
31
};
32
33
+/* Definitions for the PMU registers */
34
+#define PMCRN_MASK 0xf800
35
+#define PMCRN_SHIFT 11
36
+#define PMCRD 0x8
37
+#define PMCRC 0x4
38
+#define PMCRE 0x1
39
+
40
+static inline uint32_t pmu_num_counters(CPUARMState *env)
41
+{
22
+{
42
+ return (env->cp15.c9_pmcr & PMCRN_MASK) >> PMCRN_SHIFT;
23
+ i2c->state = state;
43
+}
24
+}
44
+
25
+
45
+/* Bits allowed to be set/cleared for PMCNTEN* and PMINTEN* */
26
static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c)
46
+static inline uint64_t pmu_counter_mask(CPUARMState *env)
47
+{
48
+ return (1 << 31) | ((1 << pmu_num_counters(env)) - 1);
49
+}
50
+
51
static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri,
52
bool isread)
53
{
27
{
54
@@ -XXX,XX +XXX,XX @@ static void pmccfiltr_write(CPUARMState *env, const ARMCPRegInfo *ri,
28
DPRINTF("STOP\n");
55
static void pmcntenset_write(CPUARMState *env, const ARMCPRegInfo *ri,
29
if (i2c->current_addr >= 0)
56
uint64_t value)
30
i2c_end_transfer(i2c->bus);
57
{
31
i2c->current_addr = -1;
58
- value &= (1 << 31);
32
- i2c->state = STOPPED;
59
+ value &= pmu_counter_mask(env);
33
+ bitbang_i2c_set_state(i2c, STOPPED);
60
env->cp15.c9_pmcnten |= value;
61
}
34
}
62
35
63
static void pmcntenclr_write(CPUARMState *env, const ARMCPRegInfo *ri,
36
/* Set device data pin. */
64
uint64_t value)
37
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
65
{
38
if (level == 0) {
66
- value &= (1 << 31);
39
DPRINTF("START\n");
67
+ value &= pmu_counter_mask(env);
40
/* START condition. */
68
env->cp15.c9_pmcnten &= ~value;
41
- i2c->state = SENDING_BIT7;
69
}
42
+ bitbang_i2c_set_state(i2c, SENDING_BIT7);
70
43
i2c->current_addr = -1;
71
@@ -XXX,XX +XXX,XX @@ static void pmintenset_write(CPUARMState *env, const ARMCPRegInfo *ri,
44
} else {
72
uint64_t value)
45
/* STOP condition. */
73
{
46
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
74
/* We have no event counters so only the C bit can be changed */
47
case SENDING_BIT7 ... SENDING_BIT0:
75
- value &= (1 << 31);
48
i2c->buffer = (i2c->buffer << 1) | data;
76
+ value &= pmu_counter_mask(env);
49
/* will end up in WAITING_FOR_ACK */
77
env->cp15.c9_pminten |= value;
50
- i2c->state++;
78
}
51
+ bitbang_i2c_set_state(i2c, i2c->state + 1);
79
52
return bitbang_i2c_ret(i2c, 1);
80
static void pmintenclr_write(CPUARMState *env, const ARMCPRegInfo *ri,
53
81
uint64_t value)
54
case WAITING_FOR_ACK:
82
{
55
@@ -XXX,XX +XXX,XX @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
83
- value &= (1 << 31);
56
* device we were sending to decided to NACK us).
84
+ value &= pmu_counter_mask(env);
57
*/
85
env->cp15.c9_pminten &= ~value;
58
DPRINTF("Got NACK\n");
86
}
59
+ bitbang_i2c_set_state(i2c, SENT_NACK);
87
60
bitbang_i2c_enter_stop(i2c);
61
return bitbang_i2c_ret(i2c, 1);
62
}
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
}
88
--
94
--
89
2.17.0
95
2.34.1
90
96
91
97
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
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
1
Currently we use memory_region_init_ram_nomigrate() to create
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
the "aspeed.boot_rom" memory region, and we don't manually
3
register it with vmstate_register_ram(). This currently
4
means that its contents are migrated but as a ram block
5
whose name is the empty string; in future it may mean they
6
are not migrated at all. Use memory_region_init_ram() instead.
7
2
8
Note that would be a cross-version migration compatibility break
3
Convert the remaining DPRINTF debug macro uses to tracepoints.
9
for the "palmetto-bmc", "ast2500-evb" and "romulus-bmc" machines,
10
but migration is currently broken for them.
11
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
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Cédric Le Goater <clg@kaod.org>
14
Tested-by: Cédric Le Goater <clg@kaod.org>
15
Message-id: 20180420124835.7268-3-peter.maydell@linaro.org
16
---
10
---
17
hw/arm/aspeed.c | 2 +-
11
hw/i2c/bitbang_i2c.c | 18 ++++++------------
18
1 file changed, 1 insertion(+), 1 deletion(-)
12
hw/i2c/trace-events | 4 ++++
13
2 files changed, 10 insertions(+), 12 deletions(-)
19
14
20
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
15
diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/aspeed.c
17
--- a/hw/i2c/bitbang_i2c.c
23
+++ b/hw/arm/aspeed.c
18
+++ b/hw/i2c/bitbang_i2c.c
24
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
19
@@ -XXX,XX +XXX,XX @@
25
* SoC and 128MB for the AST2500 SoC, which is twice as big as
20
#include "qom/object.h"
26
* needed by the flash modules of the Aspeed machines.
21
#include "trace.h"
27
*/
22
28
- memory_region_init_rom_nomigrate(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
23
-//#define DEBUG_BITBANG_I2C
29
+ memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
24
-
30
fl->size, &error_abort);
25
-#ifdef DEBUG_BITBANG_I2C
31
memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
26
-#define DPRINTF(fmt, ...) \
32
boot_rom);
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
33
--
84
--
34
2.17.0
85
2.34.1
35
86
36
87
diff view generated by jsdifflib
1
Currently we use memory_region_init_ram_nomigrate() to create
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
the "highbank.sysram" memory region, and we don't manually
3
register it with vmstate_register_ram(). This currently
4
means that its contents are migrated but as a ram block
5
whose name is the empty string; in future it may mean they
6
are not migrated at all. Use memory_region_init_ram() instead.
7
2
8
Note that this is a cross-version migration compatibility
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
break for the "highbank" and "midway" machines.
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
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
12
Message-id: 20180420124835.7268-2-peter.maydell@linaro.org
13
---
14
hw/arm/highbank.c | 2 +-
15
1 file changed, 1 insertion(+), 1 deletion(-)
16
17
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
18
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/highbank.c
13
--- a/hw/i2c/versatile_i2c.c
20
+++ b/hw/arm/highbank.c
14
+++ b/hw/i2c/versatile_i2c.c
21
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
15
@@ -XXX,XX +XXX,XX @@ REG32(CONTROL_CLR, 4)
22
memory_region_add_subregion(sysmem, 0, dram);
16
static uint64_t versatile_i2c_read(void *opaque, hwaddr offset,
23
17
unsigned size)
24
sysram = g_new(MemoryRegion, 1);
18
{
25
- memory_region_init_ram_nomigrate(sysram, NULL, "highbank.sysram", 0x8000,
19
- VersatileI2CState *s = (VersatileI2CState *)opaque;
26
+ memory_region_init_ram(sysram, NULL, "highbank.sysram", 0x8000,
20
+ VersatileI2CState *s = opaque;
27
&error_fatal);
21
28
memory_region_add_subregion(sysmem, 0xfff88000, sysram);
22
switch (offset) {
29
if (bios_name != NULL) {
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:
30
--
33
--
31
2.17.0
34
2.34.1
32
35
33
36
diff view generated by jsdifflib
1
In commit 210f47840dd62, we changed the bcm2836 SoC object to
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
always create a CPU of the correct type for that SoC model. This
3
makes the default_cpu_type settings in the MachineClass structs
4
for the raspi2 and raspi3 boards redundant. We didn't change
5
those at the time because it would have meant a temporary
6
regression in a corner case of error handling if the user
7
requested a non-existing CPU type. The -cpu parse handling
8
changes in 2278b93941d42c3 mean that it no longer implicitly
9
depends on default_cpu_type for this to work, so we can now
10
delete the redundant default_cpu_type fields.
11
2
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
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Message-id: 20180420155547.9497-1-peter.maydell@linaro.org
15
---
10
---
16
hw/arm/raspi.c | 2 --
11
include/hw/i2c/arm_sbcon_i2c.h | 3 +--
17
1 file changed, 2 deletions(-)
12
hw/i2c/versatile_i2c.c | 10 +++++-----
13
2 files changed, 6 insertions(+), 7 deletions(-)
18
14
19
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
15
diff --git a/include/hw/i2c/arm_sbcon_i2c.h b/include/hw/i2c/arm_sbcon_i2c.h
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/arm/raspi.c
17
--- a/include/hw/i2c/arm_sbcon_i2c.h
22
+++ b/hw/arm/raspi.c
18
+++ b/include/hw/i2c/arm_sbcon_i2c.h
23
@@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc)
19
@@ -XXX,XX +XXX,XX @@
24
mc->no_parallel = 1;
20
#define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C
25
mc->no_floppy = 1;
21
26
mc->no_cdrom = 1;
22
typedef struct ArmSbconI2CState ArmSbconI2CState;
27
- mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a7");
23
-DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C,
28
mc->max_cpus = BCM283X_NCPUS;
24
- TYPE_ARM_SBCON_I2C)
29
mc->min_cpus = BCM283X_NCPUS;
25
+DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C, TYPE_ARM_SBCON_I2C)
30
mc->default_cpus = BCM283X_NCPUS;
26
31
@@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc)
27
struct ArmSbconI2CState {
32
mc->no_parallel = 1;
28
/*< private >*/
33
mc->no_floppy = 1;
29
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
34
mc->no_cdrom = 1;
30
index XXXXXXX..XXXXXXX 100644
35
- mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53");
31
--- a/hw/i2c/versatile_i2c.c
36
mc->max_cpus = BCM283X_NCPUS;
32
+++ b/hw/i2c/versatile_i2c.c
37
mc->min_cpus = BCM283X_NCPUS;
33
@@ -XXX,XX +XXX,XX @@
38
mc->default_cpus = BCM283X_NCPUS;
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
39
--
78
--
40
2.17.0
79
2.34.1
41
80
42
81
diff view generated by jsdifflib
1
From: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
It was shifted to the left one bit too few.
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
5
Message-id: 20230110082508.24038-4-philmd@linaro.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 1523997485-1905-10-git-send-email-alindsay@codeaurora.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
7
---
10
target/arm/helper.c | 2 +-
8
include/hw/i2c/arm_sbcon_i2c.h | 3 +--
11
1 file changed, 1 insertion(+), 1 deletion(-)
9
hw/arm/realview.c | 2 +-
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(-)
12
14
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/include/hw/i2c/arm_sbcon_i2c.h b/include/hw/i2c/arm_sbcon_i2c.h
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
17
--- a/include/hw/i2c/arm_sbcon_i2c.h
16
+++ b/target/arm/helper.c
18
+++ b/include/hw/i2c/arm_sbcon_i2c.h
17
@@ -XXX,XX +XXX,XX @@ static void pmccfiltr_write(CPUARMState *env, const ARMCPRegInfo *ri,
19
@@ -XXX,XX +XXX,XX @@
18
uint64_t value)
20
#include "hw/i2c/bitbang_i2c.h"
19
{
21
#include "qom/object.h"
20
pmccntr_sync(env);
22
21
- env->cp15.pmccfiltr_el0 = value & 0x7E000000;
23
-#define TYPE_VERSATILE_I2C "versatile_i2c"
22
+ env->cp15.pmccfiltr_el0 = value & 0xfc000000;
24
-#define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C
23
pmccntr_sync(env);
25
+#define TYPE_ARM_SBCON_I2C "versatile_i2c"
26
27
typedef struct ArmSbconI2CState ArmSbconI2CState;
28
DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, ARM_SBCON_I2C, TYPE_ARM_SBCON_I2C)
29
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
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
}
36
37
- dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL);
38
+ dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL);
39
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
40
i2c_slave_create_simple(i2c, "ds1338", 0x68);
41
42
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/arm/versatilepb.c
45
+++ b/hw/arm/versatilepb.c
46
@@ -XXX,XX +XXX,XX @@ static void versatile_init(MachineState *machine, int board_id)
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)
24
}
82
}
25
83
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,
26
--
90
--
27
2.17.0
91
2.34.1
28
92
29
93
diff view generated by jsdifflib
1
Currently we use vmstate_register_ram_global() for the SRAM;
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
this is not a good idea for devices, because it means that
3
you can only ever create one instance of the device, as
4
the second instance would get a RAM block name clash.
5
Instead, use memory_region_init_ram(), which automatically
6
registers the RAM block with a local-to-the-device name.
7
2
8
Note that this would be a cross-version migration compatibility break
3
ARM_SBCON_I2C() macro and ArmSbconI2CState typedef are
9
for the "palmetto-bmc", "ast2500-evb" and "romulus-bmc" machines,
4
already declared via the QOM DECLARE_INSTANCE_CHECKER()
10
but migration is currently broken for them.
5
macro in "hw/i2c/arm_sbcon_i2c.h". Drop the VERSATILE_I2C
6
declarations from versatile_i2c.c.
11
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
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Cédric Le Goater <clg@kaod.org>
14
Tested-by: Cédric Le Goater <clg@kaod.org>
15
Message-id: 20180420124835.7268-4-peter.maydell@linaro.org
16
---
12
---
17
hw/arm/aspeed_soc.c | 3 +--
13
hw/i2c/versatile_i2c.c | 7 +------
18
1 file changed, 1 insertion(+), 2 deletions(-)
14
1 file changed, 1 insertion(+), 6 deletions(-)
19
15
20
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
16
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
21
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/aspeed_soc.c
18
--- a/hw/i2c/versatile_i2c.c
23
+++ b/hw/arm/aspeed_soc.c
19
+++ b/hw/i2c/versatile_i2c.c
24
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
20
@@ -XXX,XX +XXX,XX @@
25
}
21
#include "qemu/module.h"
26
22
#include "qom/object.h"
27
/* SRAM */
23
28
- memory_region_init_ram_nomigrate(&s->sram, OBJECT(dev), "aspeed.sram",
24
-typedef ArmSbconI2CState VersatileI2CState;
29
+ memory_region_init_ram(&s->sram, OBJECT(dev), "aspeed.sram",
25
-DECLARE_INSTANCE_CHECKER(ArmSbconI2CState, VERSATILE_I2C,
30
sc->info->sram_size, &err);
26
- TYPE_ARM_SBCON_I2C)
31
if (err) {
27
-
32
error_propagate(errp, err);
28
-
33
return;
29
34
}
30
REG32(CONTROL_GET, 0)
35
- vmstate_register_ram_global(&s->sram);
31
REG32(CONTROL_SET, 0)
36
memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE,
32
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps versatile_i2c_ops = {
37
&s->sram);
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;
38
40
39
--
41
--
40
2.17.0
42
2.34.1
41
43
42
44
diff view generated by jsdifflib
1
From: Igor Mammedov <imammedo@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
if arm_load_kernel() were passed non first_cpu, QEMU would end up
3
This device model started with the Versatile board, named
4
with partially set do_cpu_reset() callback leaving some CPUs without it.
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
5
8
6
Make sure that do_cpu_reset() is registered for all CPUs by enumerating
9
Use the latter name as a better description.
7
CPUs from first_cpu.
8
10
9
(In practice every board that we have was passing us the first CPU
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
as the boot CPU, either directly or indirectly, so this wasn't
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
causing incorrect behaviour.)
13
Message-id: 20230110082508.24038-6-philmd@linaro.org
12
13
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
[PMM: added a note that this isn't a behaviour change]
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
15
---
18
hw/arm/boot.c | 2 +-
16
MAINTAINERS | 1 +
19
1 file changed, 1 insertion(+), 1 deletion(-)
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%)
20
23
21
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
24
diff --git a/MAINTAINERS b/MAINTAINERS
22
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/arm/boot.c
26
--- a/MAINTAINERS
24
+++ b/hw/arm/boot.c
27
+++ b/MAINTAINERS
25
@@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
28
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
26
* actually loading a kernel, the handler is also responsible for
29
L: qemu-arm@nongnu.org
27
* arranging that we start it correctly.
30
S: Maintained
28
*/
31
F: hw/*/versatile*
29
- for (cs = CPU(cpu); cs; cs = CPU_NEXT(cs)) {
32
+F: hw/i2c/arm_sbcon_i2c.c
30
+ for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) {
33
F: include/hw/i2c/arm_sbcon_i2c.h
31
qemu_register_reset(do_cpu_reset, ARM_CPU(cs));
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,
32
}
53
}
33
}
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'))
34
--
155
--
35
2.17.0
156
2.34.1
36
157
37
158
diff view generated by jsdifflib
1
From: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
They share the same underlying state
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 20230112102436.1913-2-philmd@linaro.org
7
Message-id: 1523997485-1905-3-git-send-email-alindsay@codeaurora.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>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
11
---
10
target/arm/helper.c | 2 +-
12
target/arm/translate-a64.c | 24 +++++++++++++-----------
11
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 13 insertions(+), 11 deletions(-)
12
14
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
17
--- a/target/arm/translate-a64.c
16
+++ b/target/arm/helper.c
18
+++ b/target/arm/translate-a64.c
17
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
19
@@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn,
18
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmselr),
20
goto do_unallocated;
19
.writefn = pmselr_write, .raw_writefn = raw_write, },
21
}
20
{ .name = "PMCCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 0,
22
if (sme_access_check(s)) {
21
- .access = PL0_RW, .resetvalue = 0, .type = ARM_CP_IO,
23
- bool i = crm & 1;
22
+ .access = PL0_RW, .resetvalue = 0, .type = ARM_CP_ALIAS | ARM_CP_IO,
24
- bool changed = false;
23
.readfn = pmccntr_read, .writefn = pmccntr_write32,
25
+ int old = s->pstate_sm | (s->pstate_za << 1);
24
.accessfn = pmreg_access_ccntr },
26
+ int new = (crm & 1) * 3;
25
{ .name = "PMCCNTR_EL0", .state = ARM_CP_STATE_AA64,
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;
26
--
51
--
27
2.17.0
52
2.34.1
28
53
29
54
diff view generated by jsdifflib
1
From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
SNOOP_NONE state handle is moved above in the if ladder, as it's same
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
as SNOOP_STRIPPING during data cycles.
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Signed-off-by: Sai Pavan Boddu <saipava@xilinx.com>
6
Message-id: 20230112102436.1913-3-philmd@linaro.org
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
7
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
8
Message-id: 1524119244-1240-1-git-send-email-saipava@xilinx.com
8
[PMD: Split patch in multiple tiny steps]
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
hw/ssi/xilinx_spips.c | 3 ++-
12
target/arm/sme_helper.c | 2 ++
12
1 file changed, 2 insertions(+), 1 deletion(-)
13
target/arm/translate-a64.c | 1 -
14
2 files changed, 2 insertions(+), 1 deletion(-)
13
15
14
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
16
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/ssi/xilinx_spips.c
18
--- a/target/arm/sme_helper.c
17
+++ b/hw/ssi/xilinx_spips.c
19
+++ b/target/arm/sme_helper.c
18
@@ -XXX,XX +XXX,XX @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s)
20
@@ -XXX,XX +XXX,XX @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
19
if (fifo8_is_empty(&s->tx_fifo)) {
21
}
20
xilinx_spips_update_ixr(s);
22
env->svcr ^= R_SVCR_SM_MASK;
21
return;
23
arm_reset_sve_state(env);
22
- } else if (s->snoop_state == SNOOP_STRIPING) {
24
+ arm_rebuild_hflags(env);
23
+ } else if (s->snoop_state == SNOOP_STRIPING ||
25
}
24
+ s->snoop_state == SNOOP_NONE) {
26
25
for (i = 0; i < num_effective_busses(s); ++i) {
27
void helper_set_pstate_za(CPUARMState *env, uint32_t i)
26
tx_rx[i] = fifo8_pop(&s->tx_fifo);
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;
27
}
47
}
28
--
48
--
29
2.17.0
49
2.34.1
30
50
31
51
diff view generated by jsdifflib
1
From: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Because the design of the PMU requires that the counter values be
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
converted between their delta and guest-visible forms for mode
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
filtering, an additional hook which occurs before the EL is changed is
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
necessary.
6
Message-id: 20230112102436.1913-4-philmd@linaro.org
7
7
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
8
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
8
[PMD: Split patch in multiple tiny steps]
9
Message-id: 1523997485-1905-8-git-send-email-alindsay@codeaurora.org
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
target/arm/cpu.h | 22 +++++++++++++++++++---
12
target/arm/cpu.h | 1 +
14
target/arm/internals.h | 7 +++++++
13
linux-user/aarch64/cpu_loop.c | 2 +-
15
target/arm/cpu.c | 16 ++++++++++++++++
14
linux-user/aarch64/signal.c | 2 +-
16
target/arm/helper.c | 14 ++++++++------
15
target/arm/helper.c | 8 ++++++++
17
target/arm/op_helper.c | 8 ++++++++
16
target/arm/sme_helper.c | 4 ++--
18
5 files changed, 58 insertions(+), 9 deletions(-)
17
5 files changed, 13 insertions(+), 4 deletions(-)
19
18
20
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.h
21
--- a/target/arm/cpu.h
23
+++ b/target/arm/cpu.h
22
+++ b/target/arm/cpu.h
24
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
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.
25
*/
52
*/
26
bool cfgend;
53
+ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
27
54
if (FIELD_EX64(env->svcr, SVCR, SM)) {
28
+ QLIST_HEAD(, ARMELChangeHook) pre_el_change_hooks;
55
arm_reset_sve_state(env);
29
QLIST_HEAD(, ARMELChangeHook) el_change_hooks;
56
}
30
57
if (env->svcr) {
31
int32_t node_id; /* NUMA node this CPU belongs to */
58
- env->svcr = 0;
32
@@ -XXX,XX +XXX,XX @@ static inline AddressSpace *arm_addressspace(CPUState *cs, MemTxAttrs attrs)
59
arm_rebuild_hflags(env);
33
#endif
60
}
34
61
35
/**
36
- * arm_register_el_change_hook:
37
- * Register a hook function which will be called back whenever this
38
+ * arm_register_pre_el_change_hook:
39
+ * Register a hook function which will be called immediately before this
40
* CPU changes exception level or mode. The hook function will be
41
* passed a pointer to the ARMCPU and the opaque data pointer passed
42
* to this function when the hook was registered.
43
+ *
44
+ * Note that if a pre-change hook is called, any registered post-change hooks
45
+ * are guaranteed to subsequently be called.
46
*/
47
-void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
48
+void arm_register_pre_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
49
void *opaque);
50
+/**
51
+ * arm_register_el_change_hook:
52
+ * Register a hook function which will be called immediately after this
53
+ * CPU changes exception level or mode. The hook function will be
54
+ * passed a pointer to the ARMCPU and the opaque data pointer passed
55
+ * to this function when the hook was registered.
56
+ *
57
+ * Note that any registered hooks registered here are guaranteed to be called
58
+ * if pre-change hooks have been.
59
+ */
60
+void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, void
61
+ *opaque);
62
63
/**
64
* aa32_vfp_dreg:
65
diff --git a/target/arm/internals.h b/target/arm/internals.h
66
index XXXXXXX..XXXXXXX 100644
67
--- a/target/arm/internals.h
68
+++ b/target/arm/internals.h
69
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
70
MemTxResult response, uintptr_t retaddr);
71
72
/* Call any registered EL change hooks */
73
+static inline void arm_call_pre_el_change_hook(ARMCPU *cpu)
74
+{
75
+ ARMELChangeHook *hook, *next;
76
+ QLIST_FOREACH_SAFE(hook, &cpu->pre_el_change_hooks, node, next) {
77
+ hook->hook(cpu, hook->opaque);
78
+ }
79
+}
80
static inline void arm_call_el_change_hook(ARMCPU *cpu)
81
{
82
ARMELChangeHook *hook, *next;
83
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/target/arm/cpu.c
86
+++ b/target/arm/cpu.c
87
@@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs)
88
| CPU_INTERRUPT_EXITTB);
89
}
90
91
+void arm_register_pre_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
92
+ void *opaque)
93
+{
94
+ ARMELChangeHook *entry = g_new0(ARMELChangeHook, 1);
95
+
96
+ entry->hook = hook;
97
+ entry->opaque = opaque;
98
+
99
+ QLIST_INSERT_HEAD(&cpu->pre_el_change_hooks, entry, node);
100
+}
101
+
102
void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
103
void *opaque)
104
{
105
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj)
106
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
107
g_free, g_free);
108
109
+ QLIST_INIT(&cpu->pre_el_change_hooks);
110
QLIST_INIT(&cpu->el_change_hooks);
111
112
#ifndef CONFIG_USER_ONLY
113
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj)
114
115
g_hash_table_destroy(cpu->cp_regs);
116
117
+ QLIST_FOREACH_SAFE(hook, &cpu->pre_el_change_hooks, node, next) {
118
+ QLIST_REMOVE(hook, node);
119
+ g_free(hook);
120
+ }
121
QLIST_FOREACH_SAFE(hook, &cpu->el_change_hooks, node, next) {
122
QLIST_REMOVE(hook, node);
123
g_free(hook);
124
diff --git a/target/arm/helper.c b/target/arm/helper.c
62
diff --git a/target/arm/helper.c b/target/arm/helper.c
125
index XXXXXXX..XXXXXXX 100644
63
index XXXXXXX..XXXXXXX 100644
126
--- a/target/arm/helper.c
64
--- a/target/arm/helper.c
127
+++ b/target/arm/helper.c
65
+++ b/target/arm/helper.c
128
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
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)) {
129
return;
92
return;
130
}
93
}
131
94
- env->svcr ^= R_SVCR_SM_MASK;
132
+ /* Hooks may change global state so BQL should be held, also the
95
+ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
133
+ * BQL needs to be held for any modification of
96
arm_reset_sve_state(env);
134
+ * cs->interrupt_request.
97
arm_rebuild_hflags(env);
135
+ */
98
}
136
+ g_assert(qemu_mutex_iothread_locked());
99
@@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i)
137
+
100
if (i == FIELD_EX64(env->svcr, SVCR, ZA)) {
138
+ arm_call_pre_el_change_hook(cpu);
101
return;
139
+
140
assert(!excp_is_internal(cs->exception_index));
141
if (arm_el_is_aa64(env, new_el)) {
142
arm_cpu_do_interrupt_aarch64(cs);
143
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
144
arm_cpu_do_interrupt_aarch32(cs);
145
}
102
}
146
103
- env->svcr ^= R_SVCR_ZA_MASK;
147
- /* Hooks may change global state so BQL should be held, also the
104
+ aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
148
- * BQL needs to be held for any modification of
105
149
- * cs->interrupt_request.
106
/*
150
- */
107
* ResetSMEState.
151
- g_assert(qemu_mutex_iothread_locked());
152
-
153
arm_call_el_change_hook(cpu);
154
155
if (!kvm_enabled()) {
156
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
157
index XXXXXXX..XXXXXXX 100644
158
--- a/target/arm/op_helper.c
159
+++ b/target/arm/op_helper.c
160
@@ -XXX,XX +XXX,XX @@ void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask)
161
/* Write the CPSR for a 32-bit exception return */
162
void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val)
163
{
164
+ qemu_mutex_lock_iothread();
165
+ arm_call_pre_el_change_hook(arm_env_get_cpu(env));
166
+ qemu_mutex_unlock_iothread();
167
+
168
cpsr_write(env, val, CPSR_ERET_MASK, CPSRWriteExceptionReturn);
169
170
/* Generated code has already stored the new PC value, but
171
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env)
172
goto illegal_return;
173
}
174
175
+ qemu_mutex_lock_iothread();
176
+ arm_call_pre_el_change_hook(arm_env_get_cpu(env));
177
+ qemu_mutex_unlock_iothread();
178
+
179
if (!return_to_aa64) {
180
env->aarch64 = 0;
181
/* We do a raw CPSR write because aarch64_sync_64_to_32()
182
--
108
--
183
2.17.0
109
2.34.1
184
110
185
111
diff view generated by jsdifflib
1
From: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This eliminates the need for fetching it from el_change_hook_opaque, and
3
Move arm_reset_sve_state() calls to aarch64_set_svcr().
4
allows for supporting multiple el_change_hooks without having to hack
5
something together to find the registered opaque belonging to GICv3.
6
4
7
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Fabiano Rosas <farosas@suse.de>
9
Message-id: 1523997485-1905-6-git-send-email-alindsay@codeaurora.org
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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
13
---
12
target/arm/cpu.h | 10 ----------
14
target/arm/cpu.h | 1 -
13
hw/intc/arm_gicv3_cpuif.c | 10 ++--------
15
linux-user/aarch64/cpu_loop.c | 1 -
14
2 files changed, 2 insertions(+), 18 deletions(-)
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(-)
15
20
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
23
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
24
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ static inline AddressSpace *arm_addressspace(CPUState *cs, MemTxAttrs attrs)
25
@@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
21
void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHook *hook,
26
void aarch64_sve_change_el(CPUARMState *env, int old_el,
22
void *opaque);
27
int new_el, bool el0_a64);
23
28
void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask);
24
-/**
29
-void arm_reset_sve_state(CPUARMState *env);
25
- * arm_get_el_change_hook_opaque:
30
26
- * Return the opaque data that will be used by the el_change_hook
31
/*
27
- * for this CPU.
32
* SVE registers are encoded in KVM's memory in an endianness-invariant format.
28
- */
33
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
29
-static inline void *arm_get_el_change_hook_opaque(ARMCPU *cpu)
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)
30
-{
104
-{
31
- return cpu->el_change_hook_opaque;
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);
32
-}
109
-}
33
-
110
-
34
/**
111
void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
35
* aa32_vfp_dreg:
36
* Return a pointer to the Dn register within env in 32-bit mode.
37
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/intc/arm_gicv3_cpuif.c
40
+++ b/hw/intc/arm_gicv3_cpuif.c
41
@@ -XXX,XX +XXX,XX @@ void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s)
42
43
static GICv3CPUState *icc_cs_from_env(CPUARMState *env)
44
{
112
{
45
- /* Given the CPU, find the right GICv3CPUState struct.
113
if (i == FIELD_EX64(env->svcr, SVCR, SM)) {
46
- * Since we registered the CPU interface with the EL change hook as
114
return;
47
- * the opaque pointer, we can just directly get from the CPU to it.
115
}
48
- */
116
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
49
- return arm_get_el_change_hook_opaque(arm_env_get_cpu(env));
117
- arm_reset_sve_state(env);
50
+ return env->gicv3state;
118
arm_rebuild_hflags(env);
51
}
119
}
52
120
53
static bool gicv3_use_ns_bank(CPUARMState *env)
54
@@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s)
55
* it might be with code translated by CPU 0 but run by CPU 1, in
56
* which case we'd get the wrong value.
57
* So instead we define the regs with no ri->opaque info, and
58
- * get back to the GICv3CPUState from the ARMCPU by reading back
59
- * the opaque pointer from the el_change_hook, which we're going
60
- * to need to register anyway.
61
+ * get back to the GICv3CPUState from the CPUARMState.
62
*/
63
define_arm_cp_regs(cpu, gicv3_cpuif_reginfo);
64
if (arm_feature(&cpu->env, ARM_FEATURE_EL2)
65
--
121
--
66
2.17.0
122
2.34.1
67
123
68
124
diff view generated by jsdifflib
1
From: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Fabiano Rosas <farosas@suse.de>
5
Message-id: 1523997485-1905-2-git-send-email-alindsay@codeaurora.org
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>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
target/arm/helper.c | 2 +-
12
target/arm/helper.c | 12 ++++++++++++
9
1 file changed, 1 insertion(+), 1 deletion(-)
13
target/arm/sme_helper.c | 12 ------------
14
2 files changed, 12 insertions(+), 12 deletions(-)
10
15
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
18
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
19
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@ static inline bool arm_ccnt_enabled(CPUARMState *env)
20
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
16
{
21
if (change & R_SVCR_SM_MASK) {
17
/* This does not support checking PMCCFILTR_EL0 register */
22
arm_reset_sve_state(env);
18
19
- if (!(env->cp15.c9_pmcr & PMCRE)) {
20
+ if (!(env->cp15.c9_pmcr & PMCRE) || !(env->cp15.c9_pmcnten & (1 << 31))) {
21
return false;
22
}
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
}
23
61
24
--
62
--
25
2.17.0
63
2.34.1
26
64
27
65
diff view generated by jsdifflib
1
In commit 95695effe8caa552b8f2 we changed the v7M/v8M stack
1
From: Richard Henderson <richard.henderson@linaro.org>
2
pop code to use a new v7m_stack_read() function that checks
3
whether the read should fail due to an MPU or bus abort.
4
We missed one call though, the one which reads the signature
5
word for the callee-saved register part of the frame.
6
2
7
Correct the omission.
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(-)
8
17
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
index XXXXXXX..XXXXXXX 100644
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
--- a/linux-user/aarch64/cpu_loop.c
12
Message-id: 20180419142106.9694-1-peter.maydell@linaro.org
21
+++ b/linux-user/aarch64/cpu_loop.c
13
---
22
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
14
target/arm/helper.c | 9 +++++----
23
15
1 file changed, 5 insertions(+), 4 deletions(-)
24
switch (trapnr) {
16
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);
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
52
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
index XXXXXXX..XXXXXXX 100644
53
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
54
--- a/target/arm/helper.c
20
+++ b/target/arm/helper.c
55
+++ b/target/arm/helper.c
21
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
56
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
22
static void do_v7m_exception_exit(ARMCPU *cpu)
23
{
57
{
24
CPUARMState *env = &cpu->env;
58
uint64_t change = (env->svcr ^ new) & mask;
25
- CPUState *cs = CPU(cpu);
59
26
uint32_t excret;
60
+ if (change == 0) {
27
uint32_t xpsr;
61
+ return;
28
bool ufault = false;
62
+ }
29
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
63
env->svcr ^= change;
30
((excret & R_V7M_EXCRET_ES_MASK) == 0 ||
64
31
(excret & R_V7M_EXCRET_DCRS_MASK) == 0)) {
65
if (change & R_SVCR_SM_MASK) {
32
uint32_t expected_sig = 0xfefa125b;
66
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
33
- uint32_t actual_sig = ldl_phys(cs->as, frameptr);
67
if (change & new & R_SVCR_ZA_MASK) {
34
+ uint32_t actual_sig;
68
memset(env->zarray, 0, sizeof(env->zarray));
35
69
}
36
- if (expected_sig != actual_sig) {
37
+ pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx);
38
+
70
+
39
+ if (pop_ok && expected_sig != actual_sig) {
71
+ arm_rebuild_hflags(env);
40
/* Take a SecureFault on the current stack */
72
}
41
env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
73
42
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
74
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
43
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
75
@@ -XXX,XX +XXX,XX @@ static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
44
return;
76
helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM));
45
}
77
helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA));
46
78
aarch64_set_svcr(env, value, -1);
47
- pop_ok =
79
- arm_rebuild_hflags(env);
48
+ pop_ok = pop_ok &&
80
}
49
v7m_stack_read(cpu, &env->regs[4], frameptr + 0x8, mmu_idx) &&
81
50
v7m_stack_read(cpu, &env->regs[4], frameptr + 0x8, mmu_idx) &&
82
static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
51
v7m_stack_read(cpu, &env->regs[5], frameptr + 0xc, mmu_idx) &&
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)
52
--
108
--
53
2.17.0
109
2.34.1
54
110
55
111
diff view generated by jsdifflib
1
Remove a stale TODO comment -- we have now made the arm_ldl_ptw()
1
From: Richard Henderson <richard.henderson@linaro.org>
2
and arm_ldq_ptw() functions propagate physical memory read errors
3
out to their callers.
4
2
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>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20180419142151.9862-1-peter.maydell@linaro.org
8
---
14
---
9
target/arm/helper.c | 8 +-------
15
target/arm/helper-sme.h | 3 +--
10
1 file changed, 1 insertion(+), 7 deletions(-)
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(-)
11
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
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
37
--- a/target/arm/helper.c
15
+++ b/target/arm/helper.c
38
+++ b/target/arm/helper.c
16
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
39
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
17
return addr;
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);
18
}
46
}
19
47
20
-/* All loads done in the course of a page table walk go through here.
48
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
21
- * TODO: rather than ignoring errors from physical memory reads (which
49
index XXXXXXX..XXXXXXX 100644
22
- * are external aborts in ARM terminology) we should propagate this
50
--- a/target/arm/sme_helper.c
23
- * error out so that we can turn it into a Data Abort if this walk
51
+++ b/target/arm/sme_helper.c
24
- * was being done for a CPU load/store or an address translation instruction
52
@@ -XXX,XX +XXX,XX @@
25
- * (but not if it was for a debug access).
53
#include "vec_internal.h"
26
- */
54
#include "sve_ldst_internal.h"
27
+/* All loads done in the course of a page table walk go through here. */
55
28
static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure,
56
-void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
29
ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi)
57
+void helper_set_svcr(CPUARMState *env, uint32_t val, uint32_t mask)
30
{
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
}
31
--
90
--
32
2.17.0
91
2.34.1
33
92
34
93
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
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
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
During the conversion, the test against get_phys_addr_lpae got inverted,
4
meaning that successful translations went to the 'failed' label.
5
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>
13
---
14
target/arm/ptw.c | 4 ++--
15
1 file changed, 2 insertions(+), 2 deletions(-)
16
17
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/ptw.c
20
+++ b/target/arm/ptw.c
21
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
22
};
23
GetPhysAddrResult s2 = { };
24
25
- if (!get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD,
26
- false, &s2, fi)) {
27
+ if (get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD,
28
+ false, &s2, fi)) {
29
goto fail;
30
}
31
ptw->out_phys = s2.f.phys_addr;
32
--
33
2.34.1
diff view generated by jsdifflib
New patch
1
In v7m_exception_taken(), for v8M we set the EXC_RETURN.ES bit if
2
either the exception targets Secure or if the CPU doesn't implement
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.
1
6
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>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
---
19
target/arm/m_helper.c | 2 +-
20
1 file changed, 1 insertion(+), 1 deletion(-)
21
22
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
23
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/m_helper.c
25
+++ b/target/arm/m_helper.c
26
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
27
}
28
29
lr &= ~R_V7M_EXCRET_ES_MASK;
30
- if (targets_secure || !arm_feature(env, ARM_FEATURE_M_SECURITY)) {
31
+ if (targets_secure) {
32
lr |= R_V7M_EXCRET_ES_MASK;
33
}
34
lr &= ~R_V7M_EXCRET_SPSEL_MASK;
35
--
36
2.34.1
diff view generated by jsdifflib
1
From: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
2
3
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
3
The architecture does not define any functionality for the CLAIM tag bits.
4
Message-id: 1523997485-1905-7-git-send-email-alindsay@codeaurora.org
4
So we will just keep the raw bits, as per spec.
5
6
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230120155929.32384-2-eiakovlev@linux.microsoft.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
target/arm/cpu.h | 20 ++++++++++----------
12
target/arm/cpu.h | 1 +
9
target/arm/internals.h | 7 ++++---
13
target/arm/debug_helper.c | 33 +++++++++++++++++++++++++++++++++
10
target/arm/cpu.c | 21 ++++++++++++++++-----
14
2 files changed, 34 insertions(+)
11
3 files changed, 30 insertions(+), 18 deletions(-)
12
15
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
18
--- a/target/arm/cpu.h
16
+++ b/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
17
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
20
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
18
} CPUARMState;
21
uint64_t dbgbcr[16]; /* breakpoint control registers */
19
22
uint64_t dbgwvr[16]; /* watchpoint value registers */
20
/**
23
uint64_t dbgwcr[16]; /* watchpoint control registers */
21
- * ARMELChangeHook:
24
+ uint64_t dbgclaim; /* DBGCLAIM bits */
22
+ * ARMELChangeHookFn:
25
uint64_t mdscr_el1;
23
* type of a function which can be registered via arm_register_el_change_hook()
26
uint64_t oslsr_el1; /* OS Lock Status */
24
* to get callbacks when the CPU changes its exception level or mode.
27
uint64_t osdlr_el1; /* OS DoubleLock status */
25
*/
28
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
26
-typedef void ARMELChangeHook(ARMCPU *cpu, void *opaque);
27
-
28
+typedef void ARMELChangeHookFn(ARMCPU *cpu, void *opaque);
29
+typedef struct ARMELChangeHook ARMELChangeHook;
30
+struct ARMELChangeHook {
31
+ ARMELChangeHookFn *hook;
32
+ void *opaque;
33
+ QLIST_ENTRY(ARMELChangeHook) node;
34
+};
35
36
/* These values map onto the return values for
37
* QEMU_PSCI_0_2_FN_AFFINITY_INFO */
38
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
39
*/
40
bool cfgend;
41
42
- ARMELChangeHook *el_change_hook;
43
- void *el_change_hook_opaque;
44
+ QLIST_HEAD(, ARMELChangeHook) el_change_hooks;
45
46
int32_t node_id; /* NUMA node this CPU belongs to */
47
48
@@ -XXX,XX +XXX,XX @@ static inline AddressSpace *arm_addressspace(CPUState *cs, MemTxAttrs attrs)
49
* CPU changes exception level or mode. The hook function will be
50
* passed a pointer to the ARMCPU and the opaque data pointer passed
51
* to this function when the hook was registered.
52
- *
53
- * Note that we currently only support registering a single hook function,
54
- * and will assert if this function is called twice.
55
- * This facility is intended for the use of the GICv3 emulation.
56
*/
57
-void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHook *hook,
58
+void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
59
void *opaque);
60
61
/**
62
diff --git a/target/arm/internals.h b/target/arm/internals.h
63
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
64
--- a/target/arm/internals.h
30
--- a/target/arm/debug_helper.c
65
+++ b/target/arm/internals.h
31
+++ b/target/arm/debug_helper.c
66
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
32
@@ -XXX,XX +XXX,XX @@ static void osdlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
67
int mmu_idx, MemTxAttrs attrs,
68
MemTxResult response, uintptr_t retaddr);
69
70
-/* Call the EL change hook if one has been registered */
71
+/* Call any registered EL change hooks */
72
static inline void arm_call_el_change_hook(ARMCPU *cpu)
73
{
74
- if (cpu->el_change_hook) {
75
- cpu->el_change_hook(cpu, cpu->el_change_hook_opaque);
76
+ ARMELChangeHook *hook, *next;
77
+ QLIST_FOREACH_SAFE(hook, &cpu->el_change_hooks, node, next) {
78
+ hook->hook(cpu, hook->opaque);
79
}
33
}
80
}
34
}
81
35
82
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
36
+static void dbgclaimset_write(CPUARMState *env, const ARMCPRegInfo *ri,
83
index XXXXXXX..XXXXXXX 100644
37
+ uint64_t value)
84
--- a/target/arm/cpu.c
38
+{
85
+++ b/target/arm/cpu.c
39
+ env->cp15.dbgclaim |= (value & 0xFF);
86
@@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs)
40
+}
87
| CPU_INTERRUPT_EXITTB);
88
}
89
90
-void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHook *hook,
91
+void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
92
void *opaque)
93
{
94
- /* We currently only support registering a single hook function */
95
- assert(!cpu->el_change_hook);
96
- cpu->el_change_hook = hook;
97
- cpu->el_change_hook_opaque = opaque;
98
+ ARMELChangeHook *entry = g_new0(ARMELChangeHook, 1);
99
+
41
+
100
+ entry->hook = hook;
42
+static uint64_t dbgclaimset_read(CPUARMState *env, const ARMCPRegInfo *ri)
101
+ entry->opaque = opaque;
43
+{
44
+ /* CLAIM bits are RAO */
45
+ return 0xFF;
46
+}
102
+
47
+
103
+ QLIST_INSERT_HEAD(&cpu->el_change_hooks, entry, node);
48
+static void dbgclaimclr_write(CPUARMState *env, const ARMCPRegInfo *ri,
104
}
49
+ uint64_t value)
105
50
+{
106
static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
51
+ env->cp15.dbgclaim &= ~(value & 0xFF);
107
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj)
52
+}
108
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
109
g_free, g_free);
110
111
+ QLIST_INIT(&cpu->el_change_hooks);
112
+
53
+
113
#ifndef CONFIG_USER_ONLY
54
static const ARMCPRegInfo debug_cp_reginfo[] = {
114
/* Our inbound IRQ and FIQ lines */
55
/*
115
if (kvm_enabled()) {
56
* DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped
116
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_post_init(Object *obj)
57
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
117
static void arm_cpu_finalizefn(Object *obj)
58
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0,
118
{
59
.access = PL1_RW, .accessfn = access_tda,
119
ARMCPU *cpu = ARM_CPU(obj);
60
.type = ARM_CP_NOP },
120
+ ARMELChangeHook *hook, *next;
61
+ /*
121
+
62
+ * Dummy DBGCLAIM registers.
122
g_hash_table_destroy(cpu->cp_regs);
63
+ * "The architecture does not define any functionality for the CLAIM tag bits.",
123
+
64
+ * so we only keep the raw bits
124
+ QLIST_FOREACH_SAFE(hook, &cpu->el_change_hooks, node, next) {
65
+ */
125
+ QLIST_REMOVE(hook, node);
66
+ { .name = "DBGCLAIMSET_EL1", .state = ARM_CP_STATE_BOTH,
126
+ g_free(hook);
67
+ .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 6,
127
+ }
68
+ .type = ARM_CP_ALIAS,
128
}
69
+ .access = PL1_RW, .accessfn = access_tda,
129
70
+ .writefn = dbgclaimset_write, .readfn = dbgclaimset_read },
130
static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
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[] = {
131
--
79
--
132
2.17.0
80
2.34.1
133
134
diff view generated by jsdifflib
New patch
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
1
2
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
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
commit 1d3e65aa7ac5 ("hw/timer: Add value matching support to
3
Move the ri == NULL case to the top of the function and return.
4
aspeed_timer") increased the vmstate version of aspeed.timer because
4
This allows the else to be removed and the code unindented.
5
the state had changed, but it also bumped the version of the
6
VMSTATE_STRUCT_ARRAY under the aspeed.timerctrl which did not need to.
7
5
8
Change back this version to fix migration.
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Message-id: 20230106194451.1213153-2-richard.henderson@linaro.org
11
Message-id: 20180423101433.17759-1-clg@kaod.org
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
11
---
15
hw/timer/aspeed_timer.c | 2 +-
12
target/arm/translate.c | 406 ++++++++++++++++++++---------------------
16
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 203 insertions(+), 203 deletions(-)
17
14
18
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
15
diff --git a/target/arm/translate.c b/target/arm/translate.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/timer/aspeed_timer.c
17
--- a/target/arm/translate.c
21
+++ b/hw/timer/aspeed_timer.c
18
+++ b/target/arm/translate.c
22
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_timer_state = {
19
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
23
VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
20
bool isread, int rt, int rt2)
24
VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),
21
{
25
VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState,
22
const ARMCPRegInfo *ri;
26
- ASPEED_TIMER_NR_TIMERS, 2, vmstate_aspeed_timer,
23
+ bool need_exit_tb;
27
+ ASPEED_TIMER_NR_TIMERS, 1, vmstate_aspeed_timer,
24
28
AspeedTimer),
25
ri = get_arm_cp_reginfo(s->cp_regs,
29
VMSTATE_END_OF_LIST()
26
ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2));
27
- if (ri) {
28
- bool need_exit_tb;
29
30
- /* Check access permissions */
31
- if (!cp_access_ok(s->current_el, ri, isread)) {
32
- unallocated_encoding(s);
33
- return;
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
- }
62
- break;
63
- case 15:
64
- if (is64) {
65
- syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
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
}
210
-
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;
30
}
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) */
31
--
443
--
32
2.17.0
444
2.34.1
33
445
34
446
diff view generated by jsdifflib
1
From: Aaron Lindsay <alindsay@codeaurora.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
During code generation, surround CPSR writes and exception returns which
3
Do not encode the pointer as a constant in the opcode stream.
4
call the EL change hooks with gen_io_start/end. The immediate need is
4
This pointer is specific to the cpu that first generated the
5
for the PMU to access the clock and icount during EL change to support
5
translation, which runs into problems with both hot-pluggable
6
mode filtering.
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.)
7
16
8
Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
17
Perform the lookup in either helper_access_check_cp_reg,
9
Message-id: 1523997485-1905-9-git-send-email-alindsay@codeaurora.org
18
or a new helper_lookup_cp_reg.
19
20
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
21
Message-id: 20230106194451.1213153-3-richard.henderson@linaro.org
22
[PMM: added note in commit message about correctness issue]
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
25
---
13
target/arm/translate-a64.c | 6 ++++++
26
target/arm/helper.h | 11 +++++----
14
target/arm/translate.c | 12 ++++++++++++
27
target/arm/translate.h | 7 ++++++
15
2 files changed, 18 insertions(+)
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(-)
16
32
33
diff --git a/target/arm/helper.h b/target/arm/helper.h
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/helper.h
36
+++ b/target/arm/helper.h
37
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v8m_stackcheck, void, env, i32)
38
39
DEF_HELPER_FLAGS_2(check_bxj_trap, TCG_CALL_NO_WG, void, env, i32)
40
41
-DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
42
-DEF_HELPER_3(set_cp_reg, void, env, ptr, i32)
43
-DEF_HELPER_2(get_cp_reg, i32, env, ptr)
44
-DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64)
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;
17
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
151
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
18
index XXXXXXX..XXXXXXX 100644
152
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/translate-a64.c
153
--- a/target/arm/translate-a64.c
20
+++ b/target/arm/translate-a64.c
154
+++ b/target/arm/translate-a64.c
21
@@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
155
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
22
unallocated_encoding(s);
156
unsigned int op0, unsigned int op1, unsigned int op2,
23
return;
157
unsigned int crn, unsigned int crm, unsigned int rt)
24
}
158
{
25
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
159
- const ARMCPRegInfo *ri;
26
+ gen_io_start();
160
+ uint32_t key = ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP,
27
+ }
161
+ crn, crm, op0, op1, op2);
28
gen_helper_exception_return(cpu_env);
162
+ const ARMCPRegInfo *ri = get_arm_cp_reginfo(s->cp_regs, key);
29
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
163
+ TCGv_ptr tcg_ri = NULL;
30
+ gen_io_end();
164
TCGv_i64 tcg_rt;
31
+ }
165
32
/* Must exit loop to check un-masked IRQs */
166
- ri = get_arm_cp_reginfo(s->cp_regs,
33
s->base.is_jmp = DISAS_EXIT;
167
- ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP,
34
return;
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
35
diff --git a/target/arm/translate.c b/target/arm/translate.c
288
diff --git a/target/arm/translate.c b/target/arm/translate.c
36
index XXXXXXX..XXXXXXX 100644
289
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/translate.c
290
--- a/target/arm/translate.c
38
+++ b/target/arm/translate.c
291
+++ b/target/arm/translate.c
39
@@ -XXX,XX +XXX,XX @@ static void gen_rfe(DisasContext *s, TCGv_i32 pc, TCGv_i32 cpsr)
292
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
40
* appropriately depending on the new Thumb bit, so it must
293
int opc1, int crn, int crm, int opc2,
41
* be called after storing the new PC.
294
bool isread, int rt, int rt2)
42
*/
295
{
43
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
296
- const ARMCPRegInfo *ri;
44
+ gen_io_start();
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);
45
+ }
409
+ }
46
gen_helper_cpsr_write_eret(cpu_env, cpsr);
410
}
47
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
411
48
+ gen_io_end();
412
/* Decode XScale DSP or iWMMXt insn (in the copro space, cp=0 or 1) */
49
+ }
50
tcg_temp_free_i32(cpsr);
51
/* Must exit loop to check un-masked IRQs */
52
s->base.is_jmp = DISAS_EXIT;
53
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
54
if (exc_return) {
55
/* Restore CPSR from SPSR. */
56
tmp = load_cpu_field(spsr);
57
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
58
+ gen_io_start();
59
+ }
60
gen_helper_cpsr_write_eret(cpu_env, tmp);
61
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
62
+ gen_io_end();
63
+ }
64
tcg_temp_free_i32(tmp);
65
/* Must exit loop to check un-masked IRQs */
66
s->base.is_jmp = DISAS_EXIT;
67
--
413
--
68
2.17.0
414
2.34.1
69
70
diff view generated by jsdifflib