1
target-arm queue: mostly just cleanup/minor stuff, but this does
1
Arm patch queue -- these are all bug fix patches but we might
2
include the raspi3 board model.
2
as well put them in to rc0...
3
3
4
thanks
4
-- PMM
5
-- PMM
5
6
6
The following changes since commit 9f9c53368b219a9115eddb39f0ff5ad19c977134:
7
The following changes since commit 2c8cfc0b52b5a4d123c26c0b5fdf941be24805be:
7
8
8
Merge remote-tracking branch 'remotes/vivier/tags/m68k-for-2.12-pull-request' into staging (2018-02-15 10:14:11 +0000)
9
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000)
9
10
10
are available in the Git repository at:
11
are available in the Git repository at:
11
12
12
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180215
13
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180319
13
14
14
for you to fetch changes up to e545f0f9be1f9e60951017c1e6558216732cc14e:
15
for you to fetch changes up to ff72cb6b46b95bb530787add5277c211af3d31c6:
15
16
16
target/arm: Implement v8M MSPLIM and PSPLIM registers (2018-02-15 13:48:11 +0000)
17
hw/arm/raspi: Provide spin-loop code for AArch64 CPUs (2018-03-19 18:23:24 +0000)
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
target-arm queue:
20
target-arm queue:
20
* aspeed: code cleanup to use unimplemented_device
21
* fsl-imx6: Fix incorrect Ethernet interrupt defines
21
* add 'raspi3' RaspberryPi 3 machine model
22
* dump: Update correct kdump phys_base field for AArch64
22
* more SVE prep work
23
* char: i.MX: Add support for "TX complete" interrupt
23
* v8M: add minor missing registers
24
* bcm2836/raspi: Fix various bugs resulting in panics trying
24
* v7M: fix bug where we weren't migrating v7m.other_sp
25
to boot a Debian Linux kernel on raspi3
25
* v7M: fix bugs in handling of interrupt registers for
26
external interrupts beyond 32
27
26
28
----------------------------------------------------------------
27
----------------------------------------------------------------
29
Pekka Enberg (3):
28
Andrey Smirnov (2):
30
bcm2836: Make CPU type configurable
29
char: i.MX: Simplify imx_update()
31
raspi: Raspberry Pi 3 support
30
char: i.MX: Add support for "TX complete" interrupt
32
raspi: Add "raspi3" machine type
33
31
34
Peter Maydell (11):
32
Guenter Roeck (1):
35
hw/intc/armv7m_nvic: Don't hardcode M profile ID registers in NVIC
33
fsl-imx6: Swap Ethernet interrupt defines
36
hw/intc/armv7m_nvic: Fix ICSR PENDNMISET/CLR handling
37
hw/intc/armv7m_nvic: Implement M profile cache maintenance ops
38
hw/intc/armv7m_nvic: Implement v8M CPPWR register
39
hw/intc/armv7m_nvic: Implement cache ID registers
40
hw/intc/armv7m_nvic: Implement SCR
41
target/arm: Implement writing to CONTROL_NS for v8M
42
hw/intc/armv7m_nvic: Fix byte-to-interrupt number conversions
43
target/arm: Add AIRCR to vmstate struct
44
target/arm: Migrate v7m.other_sp
45
target/arm: Implement v8M MSPLIM and PSPLIM registers
46
34
47
Philippe Mathieu-Daudé (2):
35
Peter Maydell (9):
48
hw/arm/aspeed: directly map the serial device to the system address space
36
hw/arm/raspi: Don't do board-setup or secure-boot for raspi3
49
hw/arm/aspeed: simplify using the 'unimplemented device' for aspeed_soc.io
37
hw/arm/boot: assert that secure_boot and secure_board_setup are false for AArch64
38
hw/arm/boot: If booting a kernel in EL2, set SCR_EL3.HCE
39
hw/arm/bcm2386: Fix parent type of bcm2386
40
hw/arm/bcm2836: Rename bcm2836 type/struct to bcm283x
41
hw/arm/bcm2836: Create proper bcm2837 device
42
hw/arm/bcm2836: Use correct affinity values for BCM2837
43
hw/arm/bcm2836: Hardcode correct CPU type
44
hw/arm/raspi: Provide spin-loop code for AArch64 CPUs
50
45
51
Richard Henderson (5):
46
Wei Huang (1):
52
target/arm: Remove ARM_CP_64BIT from ZCR_EL registers
47
dump: Update correct kdump phys_base field for AArch64
53
target/arm: Enforce FP access to FPCR/FPSR
54
target/arm: Suppress TB end for FPCR/FPSR
55
target/arm: Enforce access to ZCR_EL at translation
56
target/arm: Handle SVE registers when using clear_vec_high
57
48
58
include/hw/arm/aspeed_soc.h | 1 -
49
include/hw/arm/bcm2836.h | 31 +++++++++++++---
59
include/hw/arm/bcm2836.h | 1 +
50
include/hw/arm/fsl-imx6.h | 4 +-
60
target/arm/cpu.h | 71 ++++++++++++-----
51
include/hw/char/imx_serial.h | 3 ++
61
target/arm/internals.h | 6 ++
52
dump.c | 14 +++++--
62
hw/arm/aspeed_soc.c | 35 ++-------
53
hw/arm/bcm2836.c | 87 +++++++++++++++++++++++++++++++-------------
63
hw/arm/bcm2836.c | 17 +++--
54
hw/arm/boot.c | 12 ++++++
64
hw/arm/raspi.c | 57 +++++++++++---
55
hw/arm/raspi.c | 77 +++++++++++++++++++++++++++++++--------
65
hw/intc/armv7m_nvic.c | 98 ++++++++++++++++++------
56
hw/char/imx_serial.c | 44 ++++++++++++++++------
66
target/arm/cpu.c | 28 +++++++
57
hw/net/imx_fec.c | 28 +++++++++++++-
67
target/arm/helper.c | 84 +++++++++++++++-----
58
9 files changed, 237 insertions(+), 63 deletions(-)
68
target/arm/machine.c | 84 ++++++++++++++++++++
69
target/arm/translate-a64.c | 181 ++++++++++++++++++++------------------------
70
12 files changed, 452 insertions(+), 211 deletions(-)
71
59
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
(qemu) info mtree
4
address-space: cpu-memory-0
5
0000000000000000-ffffffffffffffff (prio 0, i/o): system
6
0000000000000000-0000000007ffffff (prio 0, rom): aspeed.boot_rom
7
000000001e600000-000000001e7fffff (prio -1, i/o): aspeed_soc.io
8
- 000000001e784000-000000001e78401f (prio 0, i/o): serial
9
000000001e620000-000000001e6200ff (prio 0, i/o): aspeed.smc.ast2500-fmc
10
000000001e630000-000000001e6300ff (prio 0, i/o): aspeed.smc.ast2500-spi1
11
[...]
12
000000001e720000-000000001e728fff (prio 0, ram): aspeed.sram
13
000000001e782000-000000001e782fff (prio 0, i/o): aspeed.timer
14
+ 000000001e784000-000000001e78401f (prio 0, i/o): serial
15
000000001e785000-000000001e78501f (prio 0, i/o): aspeed.wdt
16
000000001e785020-000000001e78503f (prio 0, i/o): aspeed.wdt
17
18
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Reviewed-by: Cédric Le Goater <clg@kaod.org>
20
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
21
Message-id: 20180209085755.30414-2-f4bug@amsat.org
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
24
hw/arm/aspeed_soc.c | 3 ++-
25
1 file changed, 2 insertions(+), 1 deletion(-)
26
27
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/arm/aspeed_soc.c
30
+++ b/hw/arm/aspeed_soc.c
31
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
32
/* UART - attach an 8250 to the IO space as our UART5 */
33
if (serial_hds[0]) {
34
qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
35
- serial_mm_init(&s->iomem, ASPEED_SOC_UART_5_BASE, 2,
36
+ serial_mm_init(get_system_memory(),
37
+ ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2,
38
uart5, 38400, serial_hds[0], DEVICE_LITTLE_ENDIAN);
39
}
40
41
--
42
2.16.1
43
44
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Guenter Roeck <linux@roeck-us.net>
2
2
3
Because they are ARM_CP_STATE_AA64, ARM_CP_64BIT is implied.
3
The sabrelite machine model used by qemu-system-arm is based on the
4
Freescale/NXP i.MX6Q processor. This SoC has an on-board ethernet
5
controller which is supported in QEMU using the imx_fec.c module
6
(actually called imx.enet for this model.)
4
7
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
The include/hw/arm/fsm-imx6.h file defines the interrupt vectors for the
6
Message-id: 20180211205848.4568-2-richard.henderson@linaro.org
9
imx.enet device like this:
10
11
#define FSL_IMX6_ENET_MAC_1588_IRQ 118
12
#define FSL_IMX6_ENET_MAC_IRQ 119
13
14
According to https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf,
15
page 225, in Table 3-1. ARM Cortex A9 domain interrupt summary,
16
interrupts are as follows.
17
18
150 ENET MAC 0 IRQ
19
151 ENET MAC 0 1588 Timer interrupt
20
21
where
22
23
150 - 32 == 118
24
151 - 32 == 119
25
26
In other words, the vector definitions in the fsl-imx6.h file are reversed.
27
28
Fixing the interrupts alone causes problems with older Linux kernels:
29
The Ethernet interface will fail to probe with Linux v4.9 and earlier.
30
Linux v4.1 and earlier will crash due to a bug in Ethernet driver probe
31
error handling. This is a Linux kernel problem, not a qemu problem:
32
the Linux kernel only worked by accident since it requested both interrupts.
33
34
For backward compatibility, generate the Ethernet interrupt on both interrupt
35
lines. This was shown to work from all Linux kernel releases starting with
36
v3.16.
37
38
Link: https://bugs.launchpad.net/qemu/+bug/1753309
39
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
40
Message-id: 1520723090-22130-1-git-send-email-linux@roeck-us.net
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
41
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
43
---
10
target/arm/helper.c | 8 ++++----
44
include/hw/arm/fsl-imx6.h | 4 ++--
11
1 file changed, 4 insertions(+), 4 deletions(-)
45
hw/net/imx_fec.c | 28 +++++++++++++++++++++++++++-
46
2 files changed, 29 insertions(+), 3 deletions(-)
12
47
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
48
diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h
14
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
50
--- a/include/hw/arm/fsl-imx6.h
16
+++ b/target/arm/helper.c
51
+++ b/include/hw/arm/fsl-imx6.h
17
@@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
52
@@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State {
18
static const ARMCPRegInfo zcr_el1_reginfo = {
53
#define FSL_IMX6_HDMI_MASTER_IRQ 115
19
.name = "ZCR_EL1", .state = ARM_CP_STATE_AA64,
54
#define FSL_IMX6_HDMI_CEC_IRQ 116
20
.opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0,
55
#define FSL_IMX6_MLB150_LOW_IRQ 117
21
- .access = PL1_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT,
56
-#define FSL_IMX6_ENET_MAC_1588_IRQ 118
22
+ .access = PL1_RW, .accessfn = zcr_access,
57
-#define FSL_IMX6_ENET_MAC_IRQ 119
23
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]),
58
+#define FSL_IMX6_ENET_MAC_IRQ 118
24
.writefn = zcr_write, .raw_writefn = raw_write
59
+#define FSL_IMX6_ENET_MAC_1588_IRQ 119
25
};
60
#define FSL_IMX6_PCIE1_IRQ 120
26
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el1_reginfo = {
61
#define FSL_IMX6_PCIE2_IRQ 121
27
static const ARMCPRegInfo zcr_el2_reginfo = {
62
#define FSL_IMX6_PCIE3_IRQ 122
28
.name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
63
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
29
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
64
index XXXXXXX..XXXXXXX 100644
30
- .access = PL2_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT,
65
--- a/hw/net/imx_fec.c
31
+ .access = PL2_RW, .accessfn = zcr_access,
66
+++ b/hw/net/imx_fec.c
32
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]),
67
@@ -XXX,XX +XXX,XX @@ static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr)
33
.writefn = zcr_write, .raw_writefn = raw_write
68
34
};
69
static void imx_eth_update(IMXFECState *s)
35
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el2_reginfo = {
70
{
36
static const ARMCPRegInfo zcr_no_el2_reginfo = {
71
- if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & ENET_INT_TS_TIMER) {
37
.name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
72
+ /*
38
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
73
+ * Previous versions of qemu had the ENET_INT_MAC and ENET_INT_TS_TIMER
39
- .access = PL2_RW, .type = ARM_CP_64BIT,
74
+ * interrupts swapped. This worked with older versions of Linux (4.14
40
+ .access = PL2_RW,
75
+ * and older) since Linux associated both interrupt lines with Ethernet
41
.readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore
76
+ * MAC interrupts. Specifically,
42
};
77
+ * - Linux 4.15 and later have separate interrupt handlers for the MAC and
43
78
+ * timer interrupts. Those versions of Linux fail with versions of QEMU
44
static const ARMCPRegInfo zcr_el3_reginfo = {
79
+ * with swapped interrupt assignments.
45
.name = "ZCR_EL3", .state = ARM_CP_STATE_AA64,
80
+ * - In linux 4.14, both interrupt lines were registered with the Ethernet
46
.opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0,
81
+ * MAC interrupt handler. As a result, all versions of qemu happen to
47
- .access = PL3_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT,
82
+ * work, though that is accidental.
48
+ .access = PL3_RW, .accessfn = zcr_access,
83
+ * - In Linux 4.9 and older, the timer interrupt was registered directly
49
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]),
84
+ * with the Ethernet MAC interrupt handler. The MAC interrupt was
50
.writefn = zcr_write, .raw_writefn = raw_write
85
+ * redirected to a GPIO interrupt to work around erratum ERR006687.
51
};
86
+ * This was implemented using the SOC's IOMUX block. In qemu, this GPIO
87
+ * interrupt never fired since IOMUX is currently not supported in qemu.
88
+ * Linux instead received MAC interrupts on the timer interrupt.
89
+ * As a result, qemu versions with the swapped interrupt assignment work,
90
+ * albeit accidentally, but qemu versions with the correct interrupt
91
+ * assignment fail.
92
+ *
93
+ * To ensure that all versions of Linux work, generate ENET_INT_MAC
94
+ * interrrupts on both interrupt lines. This should be changed if and when
95
+ * qemu supports IOMUX.
96
+ */
97
+ if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] &
98
+ (ENET_INT_MAC | ENET_INT_TS_TIMER)) {
99
qemu_set_irq(s->irq[1], 1);
100
} else {
101
qemu_set_irq(s->irq[1], 0);
52
--
102
--
53
2.16.1
103
2.16.2
54
104
55
105
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Wei Huang <wei@redhat.com>
2
2
3
When storing to an AdvSIMD FP register, all of the high
3
For guest kernel that supports KASLR, the load address can change every
4
bits of the SVE register are zeroed. Therefore, call it
4
time when guest VM runs. To find the physical base address correctly,
5
more often with is_q as a parameter.
5
current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=".
6
However this string pattern is only available on x86_64. AArch64 uses a
7
different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure
8
QEMU dump uses the correct string on AArch64.
6
9
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Wei Huang <wei@redhat.com>
8
Message-id: 20180211205848.4568-6-richard.henderson@linaro.org
11
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 1520615003-20869-1-git-send-email-wei@redhat.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
14
---
12
target/arm/translate-a64.c | 162 +++++++++++++++++----------------------------
15
dump.c | 14 +++++++++++---
13
1 file changed, 62 insertions(+), 100 deletions(-)
16
1 file changed, 11 insertions(+), 3 deletions(-)
14
17
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
18
diff --git a/dump.c b/dump.c
16
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
20
--- a/dump.c
18
+++ b/target/arm/translate-a64.c
21
+++ b/dump.c
19
@@ -XXX,XX +XXX,XX @@ static TCGv_i32 read_fp_sreg(DisasContext *s, int reg)
22
@@ -XXX,XX +XXX,XX @@ static void vmcoreinfo_update_phys_base(DumpState *s)
20
return v;
23
21
}
24
lines = g_strsplit((char *)vmci, "\n", -1);
22
25
for (i = 0; lines[i]; i++) {
23
+/* Clear the bits above an N-bit vector, for N = (is_q ? 128 : 64).
26
- if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) {
24
+ * If SVE is not enabled, then there are only 128 bits in the vector.
27
- if (qemu_strtou64(lines[i] + 18, NULL, 16,
25
+ */
28
+ const char *prefix = NULL;
26
+static void clear_vec_high(DisasContext *s, bool is_q, int rd)
27
+{
28
+ unsigned ofs = fp_reg_offset(s, rd, MO_64);
29
+ unsigned vsz = vec_full_reg_size(s);
30
+
29
+
31
+ if (!is_q) {
30
+ if (s->dump_info.d_machine == EM_X86_64) {
32
+ TCGv_i64 tcg_zero = tcg_const_i64(0);
31
+ prefix = "NUMBER(phys_base)=";
33
+ tcg_gen_st_i64(tcg_zero, cpu_env, ofs + 8);
32
+ } else if (s->dump_info.d_machine == EM_AARCH64) {
34
+ tcg_temp_free_i64(tcg_zero);
33
+ prefix = "NUMBER(PHYS_OFFSET)=";
35
+ }
34
+ }
36
+ if (vsz > 16) {
37
+ tcg_gen_gvec_dup8i(ofs + 16, vsz - 16, vsz - 16, 0);
38
+ }
39
+}
40
+
35
+
41
static void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v)
36
+ if (prefix && g_str_has_prefix(lines[i], prefix)) {
42
{
37
+ if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16,
43
- TCGv_i64 tcg_zero = tcg_const_i64(0);
38
&phys_base) < 0) {
44
+ unsigned ofs = fp_reg_offset(s, reg, MO_64);
39
- warn_report("Failed to read NUMBER(phys_base)=");
45
40
+ warn_report("Failed to read %s", prefix);
46
- tcg_gen_st_i64(v, cpu_env, fp_reg_offset(s, reg, MO_64));
41
} else {
47
- tcg_gen_st_i64(tcg_zero, cpu_env, fp_reg_hi_offset(s, reg));
42
s->dump_info.phys_base = phys_base;
48
- tcg_temp_free_i64(tcg_zero);
49
+ tcg_gen_st_i64(v, cpu_env, ofs);
50
+ clear_vec_high(s, false, reg);
51
}
52
53
static void write_fp_sreg(DisasContext *s, int reg, TCGv_i32 v)
54
@@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size)
55
56
tcg_temp_free_i64(tmplo);
57
tcg_temp_free_i64(tmphi);
58
+
59
+ clear_vec_high(s, true, destidx);
60
}
61
62
/*
63
@@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src,
64
}
65
}
66
67
-/* Clear the high 64 bits of a 128 bit vector (in general non-quad
68
- * vector ops all need to do this).
69
- */
70
-static void clear_vec_high(DisasContext *s, int rd)
71
-{
72
- TCGv_i64 tcg_zero = tcg_const_i64(0);
73
-
74
- write_vec_element(s, tcg_zero, rd, 1, MO_64);
75
- tcg_temp_free_i64(tcg_zero);
76
-}
77
-
78
/* Store from vector register to memory */
79
static void do_vec_st(DisasContext *s, int srcidx, int element,
80
TCGv_i64 tcg_addr, int size)
81
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn)
82
/* For non-quad operations, setting a slice of the low
83
* 64 bits of the register clears the high 64 bits (in
84
* the ARM ARM pseudocode this is implicit in the fact
85
- * that 'rval' is a 64 bit wide variable). We optimize
86
- * by noticing that we only need to do this the first
87
- * time we touch a register.
88
+ * that 'rval' is a 64 bit wide variable).
89
+ * For quad operations, we might still need to zero the
90
+ * high bits of SVE. We optimize by noticing that we only
91
+ * need to do this the first time we touch a register.
92
*/
93
- if (!is_q && e == 0 && (r == 0 || xs == selem - 1)) {
94
- clear_vec_high(s, tt);
95
+ if (e == 0 && (r == 0 || xs == selem - 1)) {
96
+ clear_vec_high(s, is_q, tt);
97
}
98
}
99
tcg_gen_addi_i64(tcg_addr, tcg_addr, ebytes);
100
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn)
101
write_vec_element(s, tcg_tmp, rt, 0, MO_64);
102
if (is_q) {
103
write_vec_element(s, tcg_tmp, rt, 1, MO_64);
104
- } else {
105
- clear_vec_high(s, rt);
106
}
43
}
107
tcg_temp_free_i64(tcg_tmp);
108
+ clear_vec_high(s, is_q, rt);
109
} else {
110
/* Load/store one element per register */
111
if (is_load) {
112
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_sqshrn(DisasContext *s, bool is_scalar, bool is_q,
113
}
114
115
if (!is_q) {
116
- clear_vec_high(s, rd);
117
write_vec_element(s, tcg_final, rd, 0, MO_64);
118
} else {
119
write_vec_element(s, tcg_final, rd, 1, MO_64);
120
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_sqshrn(DisasContext *s, bool is_scalar, bool is_q,
121
tcg_temp_free_i64(tcg_rd);
122
tcg_temp_free_i32(tcg_rd_narrowed);
123
tcg_temp_free_i64(tcg_final);
124
- return;
125
+
126
+ clear_vec_high(s, is_q, rd);
127
}
128
129
/* SQSHLU, UQSHL, SQSHL: saturating left shifts */
130
@@ -XXX,XX +XXX,XX @@ static void handle_simd_qshl(DisasContext *s, bool scalar, bool is_q,
131
tcg_temp_free_i64(tcg_op);
132
}
133
tcg_temp_free_i64(tcg_shift);
134
-
135
- if (!is_q) {
136
- clear_vec_high(s, rd);
137
- }
138
+ clear_vec_high(s, is_q, rd);
139
} else {
140
TCGv_i32 tcg_shift = tcg_const_i32(shift);
141
static NeonGenTwoOpEnvFn * const fns[2][2][3] = {
142
@@ -XXX,XX +XXX,XX @@ static void handle_simd_qshl(DisasContext *s, bool scalar, bool is_q,
143
}
144
tcg_temp_free_i32(tcg_shift);
145
146
- if (!is_q && !scalar) {
147
- clear_vec_high(s, rd);
148
+ if (!scalar) {
149
+ clear_vec_high(s, is_q, rd);
150
}
151
}
152
}
153
@@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
154
}
155
}
156
157
- if (!is_double && elements == 2) {
158
- clear_vec_high(s, rd);
159
- }
160
-
161
tcg_temp_free_i64(tcg_int);
162
tcg_temp_free_ptr(tcg_fpst);
163
tcg_temp_free_i32(tcg_shift);
164
+
165
+ clear_vec_high(s, elements << size == 16, rd);
166
}
167
168
/* UCVTF/SCVTF - Integer to FP conversion */
169
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
170
write_vec_element(s, tcg_op, rd, pass, MO_64);
171
tcg_temp_free_i64(tcg_op);
172
}
173
- if (!is_q) {
174
- clear_vec_high(s, rd);
175
- }
176
+ clear_vec_high(s, is_q, rd);
177
} else {
178
int maxpass = is_scalar ? 1 : is_q ? 4 : 2;
179
for (pass = 0; pass < maxpass; pass++) {
180
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
181
}
182
tcg_temp_free_i32(tcg_op);
183
}
184
- if (!is_q && !is_scalar) {
185
- clear_vec_high(s, rd);
186
+ if (!is_scalar) {
187
+ clear_vec_high(s, is_q, rd);
188
}
189
}
190
191
@@ -XXX,XX +XXX,XX @@ static void handle_3same_float(DisasContext *s, int size, int elements,
192
193
tcg_temp_free_ptr(fpst);
194
195
- if ((elements << size) < 4) {
196
- /* scalar, or non-quad vector op */
197
- clear_vec_high(s, rd);
198
- }
199
+ clear_vec_high(s, elements * (size ? 8 : 4) > 8, rd);
200
}
201
202
/* AdvSIMD scalar three same
203
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
204
}
205
write_vec_element(s, tcg_res, rd, pass, MO_64);
206
}
207
- if (is_scalar) {
208
- clear_vec_high(s, rd);
209
- }
210
-
211
tcg_temp_free_i64(tcg_res);
212
tcg_temp_free_i64(tcg_zero);
213
tcg_temp_free_i64(tcg_op);
214
+
215
+ clear_vec_high(s, !is_scalar, rd);
216
} else {
217
TCGv_i32 tcg_op = tcg_temp_new_i32();
218
TCGv_i32 tcg_zero = tcg_const_i32(0);
219
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
220
tcg_temp_free_i32(tcg_res);
221
tcg_temp_free_i32(tcg_zero);
222
tcg_temp_free_i32(tcg_op);
223
- if (!is_q && !is_scalar) {
224
- clear_vec_high(s, rd);
225
+ if (!is_scalar) {
226
+ clear_vec_high(s, is_q, rd);
227
}
228
}
229
230
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode,
231
}
232
write_vec_element(s, tcg_res, rd, pass, MO_64);
233
}
234
- if (is_scalar) {
235
- clear_vec_high(s, rd);
236
- }
237
-
238
tcg_temp_free_i64(tcg_res);
239
tcg_temp_free_i64(tcg_op);
240
+ clear_vec_high(s, !is_scalar, rd);
241
} else {
242
TCGv_i32 tcg_op = tcg_temp_new_i32();
243
TCGv_i32 tcg_res = tcg_temp_new_i32();
244
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode,
245
}
246
tcg_temp_free_i32(tcg_res);
247
tcg_temp_free_i32(tcg_op);
248
- if (!is_q && !is_scalar) {
249
- clear_vec_high(s, rd);
250
+ if (!is_scalar) {
251
+ clear_vec_high(s, is_q, rd);
252
}
253
}
254
tcg_temp_free_ptr(fpst);
255
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_narrow(DisasContext *s, bool scalar,
256
write_vec_element_i32(s, tcg_res[pass], rd, destelt + pass, MO_32);
257
tcg_temp_free_i32(tcg_res[pass]);
258
}
259
- if (!is_q) {
260
- clear_vec_high(s, rd);
261
- }
262
+ clear_vec_high(s, is_q, rd);
263
}
264
265
/* Remaining saturating accumulating ops */
266
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_satacc(DisasContext *s, bool is_scalar, bool is_u,
267
}
268
write_vec_element(s, tcg_rd, rd, pass, MO_64);
269
}
270
- if (is_scalar) {
271
- clear_vec_high(s, rd);
272
- }
273
-
274
tcg_temp_free_i64(tcg_rd);
275
tcg_temp_free_i64(tcg_rn);
276
+ clear_vec_high(s, !is_scalar, rd);
277
} else {
278
TCGv_i32 tcg_rn = tcg_temp_new_i32();
279
TCGv_i32 tcg_rd = tcg_temp_new_i32();
280
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_satacc(DisasContext *s, bool is_scalar, bool is_u,
281
}
282
write_vec_element_i32(s, tcg_rd, rd, pass, MO_32);
283
}
284
-
285
- if (!is_q) {
286
- clear_vec_high(s, rd);
287
- }
288
-
289
tcg_temp_free_i32(tcg_rd);
290
tcg_temp_free_i32(tcg_rn);
291
+ clear_vec_high(s, is_q, rd);
292
}
293
}
294
295
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u,
296
tcg_temp_free_i64(tcg_round);
297
298
done:
299
- if (!is_q) {
300
- clear_vec_high(s, rd);
301
- }
302
+ clear_vec_high(s, is_q, rd);
303
}
304
305
static void gen_shl8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift)
306
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shrn(DisasContext *s, bool is_q,
307
}
308
309
if (!is_q) {
310
- clear_vec_high(s, rd);
311
write_vec_element(s, tcg_final, rd, 0, MO_64);
312
} else {
313
write_vec_element(s, tcg_final, rd, 1, MO_64);
314
}
315
-
316
if (round) {
317
tcg_temp_free_i64(tcg_round);
318
}
319
tcg_temp_free_i64(tcg_rn);
320
tcg_temp_free_i64(tcg_rd);
321
tcg_temp_free_i64(tcg_final);
322
- return;
323
+
324
+ clear_vec_high(s, is_q, rd);
325
}
326
327
328
@@ -XXX,XX +XXX,XX @@ static void handle_3rd_narrowing(DisasContext *s, int is_q, int is_u, int size,
329
write_vec_element_i32(s, tcg_res[pass], rd, pass + part, MO_32);
330
tcg_temp_free_i32(tcg_res[pass]);
331
}
332
- if (!is_q) {
333
- clear_vec_high(s, rd);
334
- }
335
+ clear_vec_high(s, is_q, rd);
336
}
337
338
static void handle_pmull_64(DisasContext *s, int is_q, int rd, int rn, int rm)
339
@@ -XXX,XX +XXX,XX @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode,
340
write_vec_element_i32(s, tcg_res[pass], rd, pass, MO_32);
341
tcg_temp_free_i32(tcg_res[pass]);
342
}
343
- if (!is_q) {
344
- clear_vec_high(s, rd);
345
- }
346
+ clear_vec_high(s, is_q, rd);
347
}
348
349
if (fpst) {
350
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)
351
tcg_temp_free_i32(tcg_op2);
352
}
353
}
354
-
355
- if (!is_q) {
356
- clear_vec_high(s, rd);
357
- }
358
+ clear_vec_high(s, is_q, rd);
359
}
360
361
/* AdvSIMD three same
362
@@ -XXX,XX +XXX,XX @@ static void handle_rev(DisasContext *s, int opcode, bool u,
363
write_vec_element(s, tcg_tmp, rd, i, grp_size);
364
tcg_temp_free_i64(tcg_tmp);
365
}
366
- if (!is_q) {
367
- clear_vec_high(s, rd);
368
- }
369
+ clear_vec_high(s, is_q, rd);
370
} else {
371
int revmask = (1 << grp_size) - 1;
372
int esize = 8 << size;
373
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
374
tcg_temp_free_i32(tcg_op);
375
}
376
}
377
- if (!is_q) {
378
- clear_vec_high(s, rd);
379
- }
380
+ clear_vec_high(s, is_q, rd);
381
382
if (need_rmode) {
383
gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
384
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
385
tcg_temp_free_i64(tcg_res);
386
}
387
388
- if (is_scalar) {
389
- clear_vec_high(s, rd);
390
- }
391
-
392
tcg_temp_free_i64(tcg_idx);
393
+ clear_vec_high(s, !is_scalar, rd);
394
} else if (!is_long) {
395
/* 32 bit floating point, or 16 or 32 bit integer.
396
* For the 16 bit scalar case we use the usual Neon helpers and
397
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
398
}
399
400
tcg_temp_free_i32(tcg_idx);
401
-
402
- if (!is_q) {
403
- clear_vec_high(s, rd);
404
- }
405
+ clear_vec_high(s, is_q, rd);
406
} else {
407
/* long ops: 16x16->32 or 32x32->64 */
408
TCGv_i64 tcg_res[2];
409
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
410
}
411
tcg_temp_free_i64(tcg_idx);
412
413
- if (is_scalar) {
414
- clear_vec_high(s, rd);
415
- }
416
+ clear_vec_high(s, !is_scalar, rd);
417
} else {
418
TCGv_i32 tcg_idx = tcg_temp_new_i32();
419
420
--
44
--
421
2.16.1
45
2.16.2
422
46
423
47
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
2
3
This also makes sure that we get the correct ordering of
3
Code of imx_update() is slightly confusing since the "flags" variable
4
SVE vs FP exceptions.
4
doesn't really corespond to anything in real hardware and server as a
5
kitchensink accumulating events normally reported via USR1 and USR2
6
registers.
5
7
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Change the code to explicitly evaluate state of interrupts reported
7
Message-id: 20180211205848.4568-5-richard.henderson@linaro.org
9
via USR1 and USR2 against corresponding masking bits and use the to
10
detemine if IRQ line should be asserted or not.
11
12
NOTE: Check for UTS1_TXEMPTY being set has been dropped for two
13
reasons:
14
15
1. Emulation code implements a single character FIFO, so this flag
16
will always be set since characters are trasmitted as a part of
17
the code emulating "push" into the FIFO
18
19
2. imx_update() is really just a function doing ORing and maksing
20
of reported events, so checking for UTS1_TXEMPTY should happen,
21
if it's ever really needed should probably happen outside of
22
it.
23
24
Cc: qemu-devel@nongnu.org
25
Cc: qemu-arm@nongnu.org
26
Cc: Bill Paul <wpaul@windriver.com>
27
Cc: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
29
Message-id: 20180315191141.6789-1-andrew.smirnov@gmail.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
30
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
32
---
11
target/arm/cpu.h | 3 ++-
33
hw/char/imx_serial.c | 24 ++++++++++++++++--------
12
target/arm/internals.h | 6 ++++++
34
1 file changed, 16 insertions(+), 8 deletions(-)
13
target/arm/helper.c | 22 ++++------------------
14
target/arm/translate-a64.c | 16 ++++++++++++++++
15
4 files changed, 28 insertions(+), 19 deletions(-)
16
35
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
36
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
18
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
38
--- a/hw/char/imx_serial.c
20
+++ b/target/arm/cpu.h
39
+++ b/hw/char/imx_serial.c
21
@@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
40
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = {
22
#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500)
41
23
#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA
42
static void imx_update(IMXSerialState *s)
24
#define ARM_CP_FPU 0x1000
43
{
25
+#define ARM_CP_SVE 0x2000
44
- uint32_t flags;
26
/* Used only as a terminator for ARMCPRegInfo lists */
45
+ uint32_t usr1;
27
#define ARM_CP_SENTINEL 0xffff
46
+ uint32_t usr2;
28
/* Mask of only the flag bits in a type field */
47
+ uint32_t mask;
29
-#define ARM_CP_FLAG_MASK 0x10ff
48
30
+#define ARM_CP_FLAG_MASK 0x30ff
49
- flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY);
31
50
- if (s->ucr1 & UCR1_TXMPTYEN) {
32
/* Valid values for ARMCPRegInfo state field, indicating which of
51
- flags |= (s->uts1 & UTS1_TXEMPTY);
33
* the AArch32 and AArch64 execution states this register is visible in.
52
- } else {
34
diff --git a/target/arm/internals.h b/target/arm/internals.h
53
- flags &= ~USR1_TRDY;
35
index XXXXXXX..XXXXXXX 100644
54
- }
36
--- a/target/arm/internals.h
55
+ /*
37
+++ b/target/arm/internals.h
56
+ * Lucky for us TRDY and RRDY has the same offset in both USR1 and
38
@@ -XXX,XX +XXX,XX @@ enum arm_exception_class {
57
+ * UCR1, so we can get away with something as simple as the
39
EC_AA64_HVC = 0x16,
58
+ * following:
40
EC_AA64_SMC = 0x17,
59
+ */
41
EC_SYSTEMREGISTERTRAP = 0x18,
60
+ usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY);
42
+ EC_SVEACCESSTRAP = 0x19,
61
+ /*
43
EC_INSNABORT = 0x20,
62
+ * Bits that we want in USR2 are not as conveniently laid out,
44
EC_INSNABORT_SAME_EL = 0x21,
63
+ * unfortunately.
45
EC_PCALIGNMENT = 0x22,
64
+ */
46
@@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit)
65
+ mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0;
47
| (cv << 24) | (cond << 20);
66
+ usr2 = s->usr2 & mask;
67
68
- qemu_set_irq(s->irq, !!flags);
69
+ qemu_set_irq(s->irq, usr1 || usr2);
48
}
70
}
49
71
50
+static inline uint32_t syn_sve_access_trap(void)
72
static void imx_serial_reset(IMXSerialState *s)
51
+{
52
+ return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT;
53
+}
54
+
55
static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
56
{
57
return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
58
diff --git a/target/arm/helper.c b/target/arm/helper.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/helper.c
61
+++ b/target/arm/helper.c
62
@@ -XXX,XX +XXX,XX @@ static int sve_exception_el(CPUARMState *env)
63
return 0;
64
}
65
66
-static CPAccessResult zcr_access(CPUARMState *env, const ARMCPRegInfo *ri,
67
- bool isread)
68
-{
69
- switch (sve_exception_el(env)) {
70
- case 3:
71
- return CP_ACCESS_TRAP_EL3;
72
- case 2:
73
- return CP_ACCESS_TRAP_EL2;
74
- case 1:
75
- return CP_ACCESS_TRAP;
76
- }
77
- return CP_ACCESS_OK;
78
-}
79
-
80
static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
81
uint64_t value)
82
{
83
@@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
84
static const ARMCPRegInfo zcr_el1_reginfo = {
85
.name = "ZCR_EL1", .state = ARM_CP_STATE_AA64,
86
.opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0,
87
- .access = PL1_RW, .accessfn = zcr_access,
88
+ .access = PL1_RW, .type = ARM_CP_SVE | ARM_CP_FPU,
89
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]),
90
.writefn = zcr_write, .raw_writefn = raw_write
91
};
92
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el1_reginfo = {
93
static const ARMCPRegInfo zcr_el2_reginfo = {
94
.name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
95
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
96
- .access = PL2_RW, .accessfn = zcr_access,
97
+ .access = PL2_RW, .type = ARM_CP_SVE | ARM_CP_FPU,
98
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]),
99
.writefn = zcr_write, .raw_writefn = raw_write
100
};
101
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el2_reginfo = {
102
static const ARMCPRegInfo zcr_no_el2_reginfo = {
103
.name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
104
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
105
- .access = PL2_RW,
106
+ .access = PL2_RW, .type = ARM_CP_SVE | ARM_CP_FPU,
107
.readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore
108
};
109
110
static const ARMCPRegInfo zcr_el3_reginfo = {
111
.name = "ZCR_EL3", .state = ARM_CP_STATE_AA64,
112
.opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0,
113
- .access = PL3_RW, .accessfn = zcr_access,
114
+ .access = PL3_RW, .type = ARM_CP_SVE | ARM_CP_FPU,
115
.fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]),
116
.writefn = zcr_write, .raw_writefn = raw_write
117
};
118
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
119
index XXXXXXX..XXXXXXX 100644
120
--- a/target/arm/translate-a64.c
121
+++ b/target/arm/translate-a64.c
122
@@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s)
123
return false;
124
}
125
126
+/* Check that SVE access is enabled. If it is, return true.
127
+ * If not, emit code to generate an appropriate exception and return false.
128
+ */
129
+static inline bool sve_access_check(DisasContext *s)
130
+{
131
+ if (s->sve_excp_el) {
132
+ gen_exception_insn(s, 4, EXCP_UDEF, syn_sve_access_trap(),
133
+ s->sve_excp_el);
134
+ return false;
135
+ }
136
+ return true;
137
+}
138
+
139
/*
140
* This utility function is for doing register extension with an
141
* optional shift. You will likely want to pass a temporary for the
142
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
143
default:
144
break;
145
}
146
+ if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) {
147
+ return;
148
+ }
149
if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) {
150
return;
151
}
152
--
73
--
153
2.16.1
74
2.16.2
154
75
155
76
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
2
3
(qemu) info mtree
3
Add support for "TX complete"/TXDC interrupt generate by real HW since
4
address-space: cpu-memory-0
4
it is needed to support guests other than Linux.
5
0000000000000000-ffffffffffffffff (prio 0, i/o): system
6
0000000000000000-0000000007ffffff (prio 0, rom): aspeed.boot_rom
7
- 000000001e600000-000000001e7fffff (prio -1, i/o): aspeed_soc.io
8
+ 000000001e600000-000000001e7fffff (prio -1000, i/o): aspeed_soc.io
9
000000001e620000-000000001e6200ff (prio 0, i/o): aspeed.smc.ast2500-fmc
10
000000001e630000-000000001e6300ff (prio 0, i/o): aspeed.smc.ast2500-spi1
11
000000001e631000-000000001e6310ff (prio 0, i/o): aspeed.smc.ast2500-spi2
12
5
13
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Based on the patch by Bill Paul as found here:
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
7
https://bugs.launchpad.net/qemu/+bug/1753314
15
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
8
16
Message-id: 20180209085755.30414-3-f4bug@amsat.org
9
Cc: qemu-devel@nongnu.org
10
Cc: qemu-arm@nongnu.org
11
Cc: Bill Paul <wpaul@windriver.com>
12
Cc: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Bill Paul <wpaul@windriver.com>
14
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
15
Message-id: 20180315191141.6789-2-andrew.smirnov@gmail.com
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
18
---
19
include/hw/arm/aspeed_soc.h | 1 -
19
include/hw/char/imx_serial.h | 3 +++
20
hw/arm/aspeed_soc.c | 32 +++-----------------------------
20
hw/char/imx_serial.c | 20 +++++++++++++++++---
21
2 files changed, 3 insertions(+), 30 deletions(-)
21
2 files changed, 20 insertions(+), 3 deletions(-)
22
22
23
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
23
diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h
24
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/arm/aspeed_soc.h
25
--- a/include/hw/char/imx_serial.h
26
+++ b/include/hw/arm/aspeed_soc.h
26
+++ b/include/hw/char/imx_serial.h
27
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
27
@@ -XXX,XX +XXX,XX @@
28
28
#define UCR2_RXEN (1<<1) /* Receiver enable */
29
/*< public >*/
29
#define UCR2_SRST (1<<0) /* Reset complete */
30
ARMCPU cpu;
30
31
- MemoryRegion iomem;
31
+#define UCR4_TCEN BIT(3) /* TX complete interrupt enable */
32
MemoryRegion sram;
32
+
33
AspeedVICState vic;
33
#define UTS1_TXEMPTY (1<<6)
34
AspeedTimerCtrlState timerctrl;
34
#define UTS1_RXEMPTY (1<<5)
35
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
35
#define UTS1_TXFULL (1<<4)
36
@@ -XXX,XX +XXX,XX @@ typedef struct IMXSerialState {
37
uint32_t ubmr;
38
uint32_t ubrc;
39
uint32_t ucr3;
40
+ uint32_t ucr4;
41
42
qemu_irq irq;
43
CharBackend chr;
44
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
36
index XXXXXXX..XXXXXXX 100644
45
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/arm/aspeed_soc.c
46
--- a/hw/char/imx_serial.c
38
+++ b/hw/arm/aspeed_soc.c
47
+++ b/hw/char/imx_serial.c
39
@@ -XXX,XX +XXX,XX @@
48
@@ -XXX,XX +XXX,XX @@
40
#include "qemu-common.h"
49
41
#include "cpu.h"
50
static const VMStateDescription vmstate_imx_serial = {
42
#include "exec/address-spaces.h"
51
.name = TYPE_IMX_SERIAL,
43
+#include "hw/misc/unimp.h"
52
- .version_id = 1,
44
#include "hw/arm/aspeed_soc.h"
53
- .minimum_version_id = 1,
45
#include "hw/char/serial.h"
54
+ .version_id = 2,
46
#include "qemu/log.h"
55
+ .minimum_version_id = 2,
47
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
56
.fields = (VMStateField[]) {
57
VMSTATE_INT32(readbuff, IMXSerialState),
58
VMSTATE_UINT32(usr1, IMXSerialState),
59
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = {
60
VMSTATE_UINT32(ubmr, IMXSerialState),
61
VMSTATE_UINT32(ubrc, IMXSerialState),
62
VMSTATE_UINT32(ucr3, IMXSerialState),
63
+ VMSTATE_UINT32(ucr4, IMXSerialState),
64
VMSTATE_END_OF_LIST()
48
},
65
},
49
};
66
};
50
67
@@ -XXX,XX +XXX,XX @@ static void imx_update(IMXSerialState *s)
51
-/*
68
* unfortunately.
52
- * IO handlers: simply catch any reads/writes to IO addresses that aren't
69
*/
53
- * handled by a device mapping.
70
mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0;
54
- */
71
+ /*
55
-
72
+ * TCEN and TXDC are both bit 3
56
-static uint64_t aspeed_soc_io_read(void *p, hwaddr offset, unsigned size)
73
+ */
57
-{
74
+ mask |= s->ucr4 & UCR4_TCEN;
58
- qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
75
+
59
- __func__, offset, size);
76
usr2 = s->usr2 & mask;
60
- return 0;
77
61
-}
78
qemu_set_irq(s->irq, usr1 || usr2);
62
-
79
@@ -XXX,XX +XXX,XX @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset,
63
-static void aspeed_soc_io_write(void *opaque, hwaddr offset, uint64_t value,
80
return s->ucr3;
64
- unsigned size)
81
65
-{
82
case 0x23: /* UCR4 */
66
- qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " <- 0x%" PRIx64 " [%u]\n",
83
+ return s->ucr4;
67
- __func__, offset, value, size);
84
+
68
-}
85
case 0x29: /* BRM Incremental */
69
-
86
return 0x0; /* TODO */
70
-static const MemoryRegionOps aspeed_soc_io_ops = {
87
71
- .read = aspeed_soc_io_read,
88
@@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset,
72
- .write = aspeed_soc_io_write,
89
* qemu_chr_fe_write and background I/O callbacks */
73
- .endianness = DEVICE_LITTLE_ENDIAN,
90
qemu_chr_fe_write_all(&s->chr, &ch, 1);
74
-};
91
s->usr1 &= ~USR1_TRDY;
75
-
92
+ s->usr2 &= ~USR2_TXDC;
76
static void aspeed_soc_init(Object *obj)
93
imx_update(s);
77
{
94
s->usr1 |= USR1_TRDY;
78
AspeedSoCState *s = ASPEED_SOC(obj);
95
+ s->usr2 |= USR2_TXDC;
79
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
96
imx_update(s);
80
Error *err = NULL, *local_err = NULL;
97
}
81
98
break;
82
/* IO space */
99
@@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset,
83
- memory_region_init_io(&s->iomem, NULL, &aspeed_soc_io_ops, NULL,
100
s->ucr3 = value & 0xffff;
84
- "aspeed_soc.io", ASPEED_SOC_IOMEM_SIZE);
101
break;
85
- memory_region_add_subregion_overlap(get_system_memory(),
102
86
- ASPEED_SOC_IOMEM_BASE, &s->iomem, -1);
103
- case 0x2d: /* UTS1 */
87
+ create_unimplemented_device("aspeed_soc.io",
104
case 0x23: /* UCR4 */
88
+ ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE);
105
+ s->ucr4 = value & 0xffff;
89
106
+ imx_update(s);
90
/* CPU */
107
+ break;
91
object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
108
+
109
+ case 0x2d: /* UTS1 */
110
qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%"
111
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
112
/* TODO */
92
--
113
--
93
2.16.1
114
2.16.2
94
115
95
116
diff view generated by jsdifflib
1
From: Pekka Enberg <penberg@iki.fi>
1
For the rpi1 and 2 we want to boot the Linux kernel via some
2
custom setup code that makes sure that the SMC instruction
3
acts as a no-op, because it's used for cache maintenance.
4
The rpi3 boots AArch64 kernels, which don't need SMC for
5
cache maintenance and always expect to be booted non-secure.
6
Don't fill in the aarch32-specific parts of the binfo struct.
2
7
3
This patch adds a "raspi3" machine type, which can now be selected as
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
the machine to run on by users via the "-M" command line option to QEMU.
9
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
5
6
The machine type does *not* ignore memory transaction failures so we
7
likely need to add some dummy devices later when people run something
8
more complicated than what I'm using for testing.
9
10
Signed-off-by: Pekka Enberg <penberg@iki.fi>
11
[PMM: added #ifdef TARGET_AARCH64 so we don't provide the 64-bit
12
board in the 32-bit only arm-softmmu build.]
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20180313153458.26822-2-peter.maydell@linaro.org
16
---
12
---
17
hw/arm/raspi.c | 23 +++++++++++++++++++++++
13
hw/arm/raspi.c | 17 +++++++++++++----
18
1 file changed, 23 insertions(+)
14
1 file changed, 13 insertions(+), 4 deletions(-)
19
15
20
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
16
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
21
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/raspi.c
18
--- a/hw/arm/raspi.c
23
+++ b/hw/arm/raspi.c
19
+++ b/hw/arm/raspi.c
24
@@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc)
20
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
25
mc->ignore_memory_transaction_failures = true;
21
binfo.board_id = raspi_boardid[version];
26
};
22
binfo.ram_size = ram_size;
27
DEFINE_MACHINE("raspi2", raspi2_machine_init)
23
binfo.nb_cpus = smp_cpus;
24
- binfo.board_setup_addr = BOARDSETUP_ADDR;
25
- binfo.write_board_setup = write_board_setup;
26
- binfo.secure_board_setup = true;
27
- binfo.secure_boot = true;
28
+
28
+
29
+#ifdef TARGET_AARCH64
29
+ if (version <= 2) {
30
+static void raspi3_init(MachineState *machine)
30
+ /* The rpi1 and 2 require some custom setup code to run in Secure
31
+{
31
+ * mode before booting a kernel (to set up the SMC vectors so
32
+ raspi_init(machine, 3);
32
+ * that we get a no-op SMC; this is used by Linux to call the
33
+}
33
+ * firmware for some cache maintenance operations.
34
+
34
+ * The rpi3 doesn't need this.
35
+static void raspi3_machine_init(MachineClass *mc)
35
+ */
36
+{
36
+ binfo.board_setup_addr = BOARDSETUP_ADDR;
37
+ mc->desc = "Raspberry Pi 3";
37
+ binfo.write_board_setup = write_board_setup;
38
+ mc->init = raspi3_init;
38
+ binfo.secure_board_setup = true;
39
+ mc->block_default_type = IF_SD;
39
+ binfo.secure_boot = true;
40
+ mc->no_parallel = 1;
40
+ }
41
+ mc->no_floppy = 1;
41
42
+ mc->no_cdrom = 1;
42
/* Pi2 and Pi3 requires SMP setup */
43
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53");
43
if (version >= 2) {
44
+ mc->max_cpus = BCM2836_NCPUS;
45
+ mc->min_cpus = BCM2836_NCPUS;
46
+ mc->default_cpus = BCM2836_NCPUS;
47
+ mc->default_ram_size = 1024 * 1024 * 1024;
48
+}
49
+DEFINE_MACHINE("raspi3", raspi3_machine_init)
50
+#endif
51
--
44
--
52
2.16.1
45
2.16.2
53
46
54
47
diff view generated by jsdifflib
1
In many of the NVIC registers relating to interrupts, we
1
Add some assertions that if we're about to boot an AArch64 kernel,
2
have to convert from a byte offset within a register set
2
the board code has not mistakenly set either secure_boot or
3
into the number of the first interrupt which is affected.
3
secure_board_setup. It doesn't make sense to set secure_boot,
4
We were getting this wrong for:
4
because all AArch64 kernels must be booted in non-secure mode.
5
* reads of NVIC_ISPR<n>, NVIC_ISER<n>, NVIC_ICPR<n>, NVIC_ICER<n>,
5
6
NVIC_IABR<n> -- in all these cases we were missing the "* 8"
6
It might in theory make sense to set secure_board_setup, but
7
needed to convert from the byte offset to the interrupt number
7
we don't currently support that, because only the AArch32
8
(since all these registers use one bit per interrupt)
8
bootloader[] code calls this hook; bootloader_aarch64[] does not.
9
* writes of NVIC_IPR<n> had the opposite problem of a spurious
9
Since we don't have a current need for this functionality, just
10
"* 8" (since these registers use one byte per interrupt)
10
assert that we don't try to use it. If it's needed we'll add
11
it later.
11
12
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Message-id: 20180209165810.6668-9-peter.maydell@linaro.org
15
Message-id: 20180313153458.26822-3-peter.maydell@linaro.org
15
---
16
---
16
hw/intc/armv7m_nvic.c | 8 ++++----
17
hw/arm/boot.c | 7 +++++++
17
1 file changed, 4 insertions(+), 4 deletions(-)
18
1 file changed, 7 insertions(+)
18
19
19
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
20
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
20
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/intc/armv7m_nvic.c
22
--- a/hw/arm/boot.c
22
+++ b/hw/intc/armv7m_nvic.c
23
+++ b/hw/arm/boot.c
23
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
24
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
24
/* fall through */
25
} else {
25
case 0x180 ... 0x1bf: /* NVIC Clear enable */
26
env->pstate = PSTATE_MODE_EL1h;
26
val = 0;
27
}
27
- startvec = offset - 0x180 + NVIC_FIRST_IRQ; /* vector # */
28
+ /* AArch64 kernels never boot in secure mode */
28
+ startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ; /* vector # */
29
+ assert(!info->secure_boot);
29
30
+ /* This hook is only supported for AArch32 currently:
30
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
31
+ * bootloader_aarch64[] will not call the hook, and
31
if (s->vectors[startvec + i].enabled &&
32
+ * the code above has already dropped us into EL2 or EL1.
32
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
33
+ */
33
/* fall through */
34
+ assert(!info->secure_board_setup);
34
case 0x280 ... 0x2bf: /* NVIC Clear pend */
35
}
35
val = 0;
36
36
- startvec = offset - 0x280 + NVIC_FIRST_IRQ; /* vector # */
37
/* Set to non-secure if not a secure boot */
37
+ startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ; /* vector # */
38
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
39
if (s->vectors[startvec + i].pending &&
40
(attrs.secure || s->itns[startvec + i])) {
41
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
42
break;
43
case 0x300 ... 0x33f: /* NVIC Active */
44
val = 0;
45
- startvec = offset - 0x300 + NVIC_FIRST_IRQ; /* vector # */
46
+ startvec = 8 * (offset - 0x300) + NVIC_FIRST_IRQ; /* vector # */
47
48
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
49
if (s->vectors[startvec + i].active &&
50
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
51
case 0x300 ... 0x33f: /* NVIC Active */
52
return MEMTX_OK; /* R/O */
53
case 0x400 ... 0x5ef: /* NVIC Priority */
54
- startvec = 8 * (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */
55
+ startvec = (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */
56
57
for (i = 0; i < size && startvec + i < s->num_irq; i++) {
58
if (attrs.secure || s->itns[startvec + i]) {
59
--
38
--
60
2.16.1
39
2.16.2
61
40
62
41
diff view generated by jsdifflib
1
The v8M architecture includes hardware support for enforcing
1
If we're directly booting a Linux kernel and the CPU supports both
2
stack pointer limits. We don't implement this behaviour yet,
2
EL3 and EL2, we start the kernel in EL2, as it expects. We must also
3
but provide the MSPLIM and PSPLIM stack pointer limit registers
3
set the SCR_EL3.HCE bit in this situation, so that the HVC
4
as reads-as-written, so that when we do implement the checks
4
instruction is enabled rather than UNDEFing. Otherwise at least some
5
in future this won't break guest migration.
5
kernels will panic when trying to initialize KVM in the guest.
6
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180313153458.26822-4-peter.maydell@linaro.org
9
Message-id: 20180209165810.6668-12-peter.maydell@linaro.org
10
---
9
---
11
target/arm/cpu.h | 2 ++
10
hw/arm/boot.c | 5 +++++
12
target/arm/helper.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
11
1 file changed, 5 insertions(+)
13
target/arm/machine.c | 21 +++++++++++++++++++++
14
3 files changed, 69 insertions(+)
15
12
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
15
--- a/hw/arm/boot.c
19
+++ b/target/arm/cpu.h
16
+++ b/hw/arm/boot.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
17
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
21
uint32_t secure; /* Is CPU in Secure state? (not guest visible) */
18
assert(!info->secure_board_setup);
22
uint32_t csselr[M_REG_NUM_BANKS];
19
}
23
uint32_t scr[M_REG_NUM_BANKS];
20
24
+ uint32_t msplim[M_REG_NUM_BANKS];
21
+ if (arm_feature(env, ARM_FEATURE_EL2)) {
25
+ uint32_t psplim[M_REG_NUM_BANKS];
22
+ /* If we have EL2 then Linux expects the HVC insn to work */
26
} v7m;
23
+ env->cp15.scr_el3 |= SCR_HCE;
27
24
+ }
28
/* Information associated with an exception about to be taken:
29
diff --git a/target/arm/helper.c b/target/arm/helper.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/helper.c
32
+++ b/target/arm/helper.c
33
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
34
return 0;
35
}
36
return env->v7m.other_ss_psp;
37
+ case 0x8a: /* MSPLIM_NS */
38
+ if (!env->v7m.secure) {
39
+ return 0;
40
+ }
41
+ return env->v7m.msplim[M_REG_NS];
42
+ case 0x8b: /* PSPLIM_NS */
43
+ if (!env->v7m.secure) {
44
+ return 0;
45
+ }
46
+ return env->v7m.psplim[M_REG_NS];
47
case 0x90: /* PRIMASK_NS */
48
if (!env->v7m.secure) {
49
return 0;
50
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
51
return v7m_using_psp(env) ? env->v7m.other_sp : env->regs[13];
52
case 9: /* PSP */
53
return v7m_using_psp(env) ? env->regs[13] : env->v7m.other_sp;
54
+ case 10: /* MSPLIM */
55
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
56
+ goto bad_reg;
57
+ }
58
+ return env->v7m.msplim[env->v7m.secure];
59
+ case 11: /* PSPLIM */
60
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
61
+ goto bad_reg;
62
+ }
63
+ return env->v7m.psplim[env->v7m.secure];
64
case 16: /* PRIMASK */
65
return env->v7m.primask[env->v7m.secure];
66
case 17: /* BASEPRI */
67
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
68
case 19: /* FAULTMASK */
69
return env->v7m.faultmask[env->v7m.secure];
70
default:
71
+ bad_reg:
72
qemu_log_mask(LOG_GUEST_ERROR, "Attempt to read unknown special"
73
" register %d\n", reg);
74
return 0;
75
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
76
}
77
env->v7m.other_ss_psp = val;
78
return;
79
+ case 0x8a: /* MSPLIM_NS */
80
+ if (!env->v7m.secure) {
81
+ return;
82
+ }
83
+ env->v7m.msplim[M_REG_NS] = val & ~7;
84
+ return;
85
+ case 0x8b: /* PSPLIM_NS */
86
+ if (!env->v7m.secure) {
87
+ return;
88
+ }
89
+ env->v7m.psplim[M_REG_NS] = val & ~7;
90
+ return;
91
case 0x90: /* PRIMASK_NS */
92
if (!env->v7m.secure) {
93
return;
94
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
95
env->v7m.other_sp = val;
96
}
97
break;
98
+ case 10: /* MSPLIM */
99
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
100
+ goto bad_reg;
101
+ }
102
+ env->v7m.msplim[env->v7m.secure] = val & ~7;
103
+ break;
104
+ case 11: /* PSPLIM */
105
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
106
+ goto bad_reg;
107
+ }
108
+ env->v7m.psplim[env->v7m.secure] = val & ~7;
109
+ break;
110
case 16: /* PRIMASK */
111
env->v7m.primask[env->v7m.secure] = val & 1;
112
break;
113
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
114
env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK;
115
break;
116
default:
117
+ bad_reg:
118
qemu_log_mask(LOG_GUEST_ERROR, "Attempt to write unknown special"
119
" register %d\n", reg);
120
return;
121
diff --git a/target/arm/machine.c b/target/arm/machine.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/target/arm/machine.c
124
+++ b/target/arm/machine.c
125
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_other_sp = {
126
}
127
};
128
129
+static bool m_v8m_needed(void *opaque)
130
+{
131
+ ARMCPU *cpu = opaque;
132
+ CPUARMState *env = &cpu->env;
133
+
25
+
134
+ return arm_feature(env, ARM_FEATURE_M) && arm_feature(env, ARM_FEATURE_V8);
26
/* Set to non-secure if not a secure boot */
135
+}
27
if (!info->secure_boot &&
136
+
28
(cs != first_cpu || !info->secure_board_setup)) {
137
+static const VMStateDescription vmstate_m_v8m = {
138
+ .name = "cpu/m/v8m",
139
+ .version_id = 1,
140
+ .minimum_version_id = 1,
141
+ .needed = m_v8m_needed,
142
+ .fields = (VMStateField[]) {
143
+ VMSTATE_UINT32_ARRAY(env.v7m.msplim, ARMCPU, M_REG_NUM_BANKS),
144
+ VMSTATE_UINT32_ARRAY(env.v7m.psplim, ARMCPU, M_REG_NUM_BANKS),
145
+ VMSTATE_END_OF_LIST()
146
+ }
147
+};
148
+
149
static const VMStateDescription vmstate_m = {
150
.name = "cpu/m",
151
.version_id = 4,
152
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
153
&vmstate_m_csselr,
154
&vmstate_m_scr,
155
&vmstate_m_other_sp,
156
+ &vmstate_m_v8m,
157
NULL
158
}
159
};
160
--
29
--
161
2.16.1
30
2.16.2
162
31
163
32
diff view generated by jsdifflib
1
In commit abc24d86cc0364f we accidentally broke migration of
1
The TypeInfo and state struct for bcm2386 disagree about what the
2
the stack pointer value for the mode (process, handler) the CPU
2
parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE,
3
is not currently running as. (The commit correctly removed the
3
but the BCM2386State struct only defines the parent_obj field
4
no-longer-used v7m.current_sp flag from the VMState but also
4
as DeviceState. This would have caused problems if anything
5
deleted the still very much in use v7m.other_sp SP value field.)
5
actually tried to treat the object as a TYPE_SYS_BUS_DEVICE.
6
6
Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't
7
Add a subsection to migrate it again. (We don't need to care
7
need any of the additional functionality TYPE_SYS_BUS_DEVICE
8
about trying to retain compatibility with pre-abc24d86cc0364f
8
provides.
9
versions of QEMU, because that commit bumped the version_id
10
and we've since bumped it again a couple of times.)
11
9
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
14
Message-id: 20180209165810.6668-11-peter.maydell@linaro.org
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20180313153458.26822-5-peter.maydell@linaro.org
15
---
14
---
16
target/arm/machine.c | 11 +++++++++++
15
hw/arm/bcm2836.c | 2 +-
17
1 file changed, 11 insertions(+)
16
1 file changed, 1 insertion(+), 1 deletion(-)
18
17
19
diff --git a/target/arm/machine.c b/target/arm/machine.c
18
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
20
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/machine.c
20
--- a/hw/arm/bcm2836.c
22
+++ b/target/arm/machine.c
21
+++ b/hw/arm/bcm2836.c
23
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_scr = {
22
@@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data)
24
}
23
25
};
24
static const TypeInfo bcm2836_type_info = {
26
25
.name = TYPE_BCM2836,
27
+static const VMStateDescription vmstate_m_other_sp = {
26
- .parent = TYPE_SYS_BUS_DEVICE,
28
+ .name = "cpu/m/other-sp",
27
+ .parent = TYPE_DEVICE,
29
+ .version_id = 1,
28
.instance_size = sizeof(BCM2836State),
30
+ .minimum_version_id = 1,
29
.instance_init = bcm2836_init,
31
+ .fields = (VMStateField[]) {
30
.class_init = bcm2836_class_init,
32
+ VMSTATE_UINT32(env.v7m.other_sp, ARMCPU),
33
+ VMSTATE_END_OF_LIST()
34
+ }
35
+};
36
+
37
static const VMStateDescription vmstate_m = {
38
.name = "cpu/m",
39
.version_id = 4,
40
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
41
&vmstate_m_faultmask_primask,
42
&vmstate_m_csselr,
43
&vmstate_m_scr,
44
+ &vmstate_m_other_sp,
45
NULL
46
}
47
};
48
--
31
--
49
2.16.1
32
2.16.2
50
33
51
34
diff view generated by jsdifflib
1
From: Pekka Enberg <penberg@iki.fi>
1
Our BCM2836 type is really a generic one that can be any of
2
the bcm283x family. Rename it accordingly. We change only
3
the names which are visible via the header file to the
4
rest of the QEMU code, leaving private function names
5
in bcm2836.c as they are.
2
6
3
This patch adds a "cpu-type" property to BCM2836 SoC in preparation for
7
This is a preliminary to making bcm283x be an abstract
4
reusing the code for the Raspberry Pi 3, which has a different processor
8
parent class to specific types for the bcm2836 and bcm2837.
5
model.
6
9
7
Signed-off-by: Pekka Enberg <penberg@iki.fi>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20180313153458.26822-6-peter.maydell@linaro.org
10
---
14
---
11
include/hw/arm/bcm2836.h | 1 +
15
include/hw/arm/bcm2836.h | 12 ++++++------
12
hw/arm/bcm2836.c | 17 +++++++++--------
16
hw/arm/bcm2836.c | 17 +++++++++--------
13
hw/arm/raspi.c | 3 +++
17
hw/arm/raspi.c | 16 ++++++++--------
14
3 files changed, 13 insertions(+), 8 deletions(-)
18
3 files changed, 23 insertions(+), 22 deletions(-)
15
19
16
diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h
20
diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h
17
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/bcm2836.h
22
--- a/include/hw/arm/bcm2836.h
19
+++ b/include/hw/arm/bcm2836.h
23
+++ b/include/hw/arm/bcm2836.h
20
@@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State {
24
@@ -XXX,XX +XXX,XX @@
25
#include "hw/arm/bcm2835_peripherals.h"
26
#include "hw/intc/bcm2836_control.h"
27
28
-#define TYPE_BCM2836 "bcm2836"
29
-#define BCM2836(obj) OBJECT_CHECK(BCM2836State, (obj), TYPE_BCM2836)
30
+#define TYPE_BCM283X "bcm283x"
31
+#define BCM283X(obj) OBJECT_CHECK(BCM283XState, (obj), TYPE_BCM283X)
32
33
-#define BCM2836_NCPUS 4
34
+#define BCM283X_NCPUS 4
35
36
-typedef struct BCM2836State {
37
+typedef struct BCM283XState {
38
/*< private >*/
21
DeviceState parent_obj;
39
DeviceState parent_obj;
22
/*< public >*/
40
/*< public >*/
23
41
@@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State {
24
+ char *cpu_type;
42
char *cpu_type;
25
uint32_t enabled_cpus;
43
uint32_t enabled_cpus;
26
44
27
ARMCPU cpus[BCM2836_NCPUS];
45
- ARMCPU cpus[BCM2836_NCPUS];
46
+ ARMCPU cpus[BCM283X_NCPUS];
47
BCM2836ControlState control;
48
BCM2835PeripheralState peripherals;
49
-} BCM2836State;
50
+} BCM283XState;
51
52
#endif /* BCM2836_H */
28
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
53
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
29
index XXXXXXX..XXXXXXX 100644
54
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/bcm2836.c
55
--- a/hw/arm/bcm2836.c
31
+++ b/hw/arm/bcm2836.c
56
+++ b/hw/arm/bcm2836.c
32
@@ -XXX,XX +XXX,XX @@
57
@@ -XXX,XX +XXX,XX @@
58
33
static void bcm2836_init(Object *obj)
59
static void bcm2836_init(Object *obj)
34
{
60
{
35
BCM2836State *s = BCM2836(obj);
61
- BCM2836State *s = BCM2836(obj);
36
- int n;
62
+ BCM283XState *s = BCM283X(obj);
37
-
38
- for (n = 0; n < BCM2836_NCPUS; n++) {
39
- object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
40
- "cortex-a15-" TYPE_ARM_CPU);
41
- object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
42
- &error_abort);
43
- }
44
63
45
object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL);
64
object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL);
46
object_property_add_child(obj, "control", OBJECT(&s->control), NULL);
65
object_property_add_child(obj, "control", OBJECT(&s->control), NULL);
66
@@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj)
67
68
static void bcm2836_realize(DeviceState *dev, Error **errp)
69
{
70
- BCM2836State *s = BCM2836(dev);
71
+ BCM283XState *s = BCM283X(dev);
72
Object *obj;
73
Error *err = NULL;
74
int n;
47
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
75
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
48
49
/* common peripherals from bcm2835 */
76
/* common peripherals from bcm2835 */
50
77
51
+ obj = OBJECT(dev);
78
obj = OBJECT(dev);
52
+ for (n = 0; n < BCM2836_NCPUS; n++) {
79
- for (n = 0; n < BCM2836_NCPUS; n++) {
53
+ object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
80
+ for (n = 0; n < BCM283X_NCPUS; n++) {
54
+ s->cpu_type);
81
object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
55
+ object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
82
s->cpu_type);
56
+ &error_abort);
83
object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
57
+ }
84
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
58
+
85
sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1,
59
obj = object_property_get_link(OBJECT(dev), "ram", &err);
86
qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));
60
if (obj == NULL) {
87
61
error_setg(errp, "%s: required ram link not found: %s",
88
- for (n = 0; n < BCM2836_NCPUS; n++) {
89
+ for (n = 0; n < BCM283X_NCPUS; n++) {
90
/* Mirror bcm2836, which has clusterid set to 0xf
91
* TODO: this should be converted to a property of ARM_CPU
92
*/
62
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
93
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
63
}
94
}
64
95
65
static Property bcm2836_props[] = {
96
static Property bcm2836_props[] = {
66
+ DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type),
97
- DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type),
67
DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS),
98
- DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS),
99
+ DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type),
100
+ DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus,
101
+ BCM283X_NCPUS),
68
DEFINE_PROP_END_OF_LIST()
102
DEFINE_PROP_END_OF_LIST()
103
};
104
105
@@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data)
106
}
107
108
static const TypeInfo bcm2836_type_info = {
109
- .name = TYPE_BCM2836,
110
+ .name = TYPE_BCM283X,
111
.parent = TYPE_DEVICE,
112
- .instance_size = sizeof(BCM2836State),
113
+ .instance_size = sizeof(BCM283XState),
114
.instance_init = bcm2836_init,
115
.class_init = bcm2836_class_init,
69
};
116
};
70
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
117
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
71
index XXXXXXX..XXXXXXX 100644
118
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/arm/raspi.c
119
--- a/hw/arm/raspi.c
73
+++ b/hw/arm/raspi.c
120
+++ b/hw/arm/raspi.c
74
@@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine)
121
@@ -XXX,XX +XXX,XX @@
75
/* Setup the SOC */
122
static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44};
76
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
123
77
&error_abort);
124
typedef struct RasPiState {
78
+ object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type",
125
- BCM2836State soc;
79
+ &error_abort);
126
+ BCM283XState soc;
80
object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
127
MemoryRegion ram;
81
&error_abort);
128
} RasPiState;
82
object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev",
129
130
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
131
BusState *bus;
132
DeviceState *carddev;
133
134
- object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM2836);
135
+ object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X);
136
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
137
&error_abort);
138
83
@@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc)
139
@@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc)
84
mc->no_parallel = 1;
85
mc->no_floppy = 1;
140
mc->no_floppy = 1;
86
mc->no_cdrom = 1;
141
mc->no_cdrom = 1;
87
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
142
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
88
mc->max_cpus = BCM2836_NCPUS;
143
- mc->max_cpus = BCM2836_NCPUS;
89
mc->min_cpus = BCM2836_NCPUS;
144
- mc->min_cpus = BCM2836_NCPUS;
90
mc->default_cpus = BCM2836_NCPUS;
145
- mc->default_cpus = BCM2836_NCPUS;
146
+ mc->max_cpus = BCM283X_NCPUS;
147
+ mc->min_cpus = BCM283X_NCPUS;
148
+ mc->default_cpus = BCM283X_NCPUS;
149
mc->default_ram_size = 1024 * 1024 * 1024;
150
mc->ignore_memory_transaction_failures = true;
151
};
152
@@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc)
153
mc->no_floppy = 1;
154
mc->no_cdrom = 1;
155
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53");
156
- mc->max_cpus = BCM2836_NCPUS;
157
- mc->min_cpus = BCM2836_NCPUS;
158
- mc->default_cpus = BCM2836_NCPUS;
159
+ mc->max_cpus = BCM283X_NCPUS;
160
+ mc->min_cpus = BCM283X_NCPUS;
161
+ mc->default_cpus = BCM283X_NCPUS;
162
mc->default_ram_size = 1024 * 1024 * 1024;
163
}
164
DEFINE_MACHINE("raspi3", raspi3_machine_init)
91
--
165
--
92
2.16.1
166
2.16.2
93
167
94
168
diff view generated by jsdifflib
1
Instead of hardcoding the values of M profile ID registers in the
1
The bcm2837 is pretty similar to the bcm2836, but it does have
2
NVIC, use the fields in the CPU struct. This will allow us to
2
some differences. Notably, the MPIDR affinity aff1 values it
3
give different M profile CPU types different ID register values.
3
sets for the CPUs are 0x0, rather than the 0xf that the bcm2836
4
uses, and if this is wrong Linux will not boot.
4
5
5
This commit includes the addition of the missing ID_ISAR5,
6
Rather than trying to have one device with properties that
6
which exists as RES0 in both v7M and v8M.
7
configure it differently for the two cases, create two
7
8
separate QOM devices for the two SoCs. We use the same approach
8
(The values of the ID registers might be wrong for the M4 --
9
as hw/arm/aspeed_soc.c and share code and have a data table
9
this commit leaves the behaviour there unchanged.)
10
that might differ per-SoC. For the moment the two types don't
11
actually have different behaviour.
10
12
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20180313153458.26822-7-peter.maydell@linaro.org
14
Message-id: 20180209165810.6668-2-peter.maydell@linaro.org
15
---
16
---
16
hw/intc/armv7m_nvic.c | 30 ++++++++++++++++--------------
17
include/hw/arm/bcm2836.h | 19 +++++++++++++++++++
17
target/arm/cpu.c | 28 ++++++++++++++++++++++++++++
18
hw/arm/bcm2836.c | 37 ++++++++++++++++++++++++++++++++-----
18
2 files changed, 44 insertions(+), 14 deletions(-)
19
hw/arm/raspi.c | 3 ++-
20
3 files changed, 53 insertions(+), 6 deletions(-)
19
21
20
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
22
diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h
21
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/intc/armv7m_nvic.c
24
--- a/include/hw/arm/bcm2836.h
23
+++ b/hw/intc/armv7m_nvic.c
25
+++ b/include/hw/arm/bcm2836.h
24
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
26
@@ -XXX,XX +XXX,XX @@
25
"Aux Fault status registers unimplemented\n");
27
26
return 0;
28
#define BCM283X_NCPUS 4
27
case 0xd40: /* PFR0. */
29
28
- return 0x00000030;
30
+/* These type names are for specific SoCs; other than instantiating
29
- case 0xd44: /* PRF1. */
31
+ * them, code using these devices should always handle them via the
30
- return 0x00000200;
32
+ * BCM283x base class, so they have no BCM2836(obj) etc macros.
31
+ return cpu->id_pfr0;
33
+ */
32
+ case 0xd44: /* PFR1. */
34
+#define TYPE_BCM2836 "bcm2836"
33
+ return cpu->id_pfr1;
35
+#define TYPE_BCM2837 "bcm2837"
34
case 0xd48: /* DFR0. */
36
+
35
- return 0x00100000;
37
typedef struct BCM283XState {
36
+ return cpu->id_dfr0;
38
/*< private >*/
37
case 0xd4c: /* AFR0. */
39
DeviceState parent_obj;
38
- return 0x00000000;
40
@@ -XXX,XX +XXX,XX @@ typedef struct BCM283XState {
39
+ return cpu->id_afr0;
41
BCM2835PeripheralState peripherals;
40
case 0xd50: /* MMFR0. */
42
} BCM283XState;
41
- return 0x00000030;
43
42
+ return cpu->id_mmfr0;
44
+typedef struct BCM283XInfo BCM283XInfo;
43
case 0xd54: /* MMFR1. */
45
+
44
- return 0x00000000;
46
+typedef struct BCM283XClass {
45
+ return cpu->id_mmfr1;
47
+ DeviceClass parent_class;
46
case 0xd58: /* MMFR2. */
48
+ const BCM283XInfo *info;
47
- return 0x00000000;
49
+} BCM283XClass;
48
+ return cpu->id_mmfr2;
50
+
49
case 0xd5c: /* MMFR3. */
51
+#define BCM283X_CLASS(klass) \
50
- return 0x00000000;
52
+ OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X)
51
+ return cpu->id_mmfr3;
53
+#define BCM283X_GET_CLASS(obj) \
52
case 0xd60: /* ISAR0. */
54
+ OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X)
53
- return 0x01141110;
55
+
54
+ return cpu->id_isar0;
56
#endif /* BCM2836_H */
55
case 0xd64: /* ISAR1. */
57
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
56
- return 0x02111000;
57
+ return cpu->id_isar1;
58
case 0xd68: /* ISAR2. */
59
- return 0x21112231;
60
+ return cpu->id_isar2;
61
case 0xd6c: /* ISAR3. */
62
- return 0x01111110;
63
+ return cpu->id_isar3;
64
case 0xd70: /* ISAR4. */
65
- return 0x01310102;
66
+ return cpu->id_isar4;
67
+ case 0xd74: /* ISAR5. */
68
+ return cpu->id_isar5;
69
/* TODO: Implement debug registers. */
70
case 0xd90: /* MPU_TYPE */
71
/* Unified MPU; if the MPU is not present this value is zero */
72
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
73
index XXXXXXX..XXXXXXX 100644
58
index XXXXXXX..XXXXXXX 100644
74
--- a/target/arm/cpu.c
59
--- a/hw/arm/bcm2836.c
75
+++ b/target/arm/cpu.c
60
+++ b/hw/arm/bcm2836.c
76
@@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj)
61
@@ -XXX,XX +XXX,XX @@
77
set_feature(&cpu->env, ARM_FEATURE_M);
62
/* "QA7" (Pi2) interrupt controller and mailboxes etc. */
78
cpu->midr = 0x410fc231;
63
#define BCM2836_CONTROL_BASE 0x40000000
79
cpu->pmsav7_dregion = 8;
64
80
+ cpu->id_pfr0 = 0x00000030;
65
+struct BCM283XInfo {
81
+ cpu->id_pfr1 = 0x00000200;
66
+ const char *name;
82
+ cpu->id_dfr0 = 0x00100000;
67
+};
83
+ cpu->id_afr0 = 0x00000000;
68
+
84
+ cpu->id_mmfr0 = 0x00000030;
69
+static const BCM283XInfo bcm283x_socs[] = {
85
+ cpu->id_mmfr1 = 0x00000000;
70
+ {
86
+ cpu->id_mmfr2 = 0x00000000;
71
+ .name = TYPE_BCM2836,
87
+ cpu->id_mmfr3 = 0x00000000;
72
+ },
88
+ cpu->id_isar0 = 0x01141110;
73
+ {
89
+ cpu->id_isar1 = 0x02111000;
74
+ .name = TYPE_BCM2837,
90
+ cpu->id_isar2 = 0x21112231;
75
+ },
91
+ cpu->id_isar3 = 0x01111110;
76
+};
92
+ cpu->id_isar4 = 0x01310102;
77
+
93
+ cpu->id_isar5 = 0x00000000;
78
static void bcm2836_init(Object *obj)
79
{
80
BCM283XState *s = BCM283X(obj);
81
@@ -XXX,XX +XXX,XX @@ static Property bcm2836_props[] = {
82
DEFINE_PROP_END_OF_LIST()
83
};
84
85
-static void bcm2836_class_init(ObjectClass *oc, void *data)
86
+static void bcm283x_class_init(ObjectClass *oc, void *data)
87
{
88
DeviceClass *dc = DEVICE_CLASS(oc);
89
+ BCM283XClass *bc = BCM283X_CLASS(oc);
90
91
- dc->props = bcm2836_props;
92
+ bc->info = data;
93
dc->realize = bcm2836_realize;
94
+ dc->props = bcm2836_props;
94
}
95
}
95
96
96
static void cortex_m4_initfn(Object *obj)
97
-static const TypeInfo bcm2836_type_info = {
97
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
98
+static const TypeInfo bcm283x_type_info = {
98
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
99
.name = TYPE_BCM283X,
99
cpu->midr = 0x410fc240; /* r0p0 */
100
.parent = TYPE_DEVICE,
100
cpu->pmsav7_dregion = 8;
101
.instance_size = sizeof(BCM283XState),
101
+ cpu->id_pfr0 = 0x00000030;
102
.instance_init = bcm2836_init,
102
+ cpu->id_pfr1 = 0x00000200;
103
- .class_init = bcm2836_class_init,
103
+ cpu->id_dfr0 = 0x00100000;
104
+ .class_size = sizeof(BCM283XClass),
104
+ cpu->id_afr0 = 0x00000000;
105
+ .abstract = true,
105
+ cpu->id_mmfr0 = 0x00000030;
106
};
106
+ cpu->id_mmfr1 = 0x00000000;
107
107
+ cpu->id_mmfr2 = 0x00000000;
108
static void bcm2836_register_types(void)
108
+ cpu->id_mmfr3 = 0x00000000;
109
{
109
+ cpu->id_isar0 = 0x01141110;
110
- type_register_static(&bcm2836_type_info);
110
+ cpu->id_isar1 = 0x02111000;
111
+ int i;
111
+ cpu->id_isar2 = 0x21112231;
112
+
112
+ cpu->id_isar3 = 0x01111110;
113
+ type_register_static(&bcm283x_type_info);
113
+ cpu->id_isar4 = 0x01310102;
114
+ for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) {
114
+ cpu->id_isar5 = 0x00000000;
115
+ TypeInfo ti = {
116
+ .name = bcm283x_socs[i].name,
117
+ .parent = TYPE_BCM283X,
118
+ .class_init = bcm283x_class_init,
119
+ .class_data = (void *) &bcm283x_socs[i],
120
+ };
121
+ type_register(&ti);
122
+ }
115
}
123
}
116
124
117
static void arm_v7m_class_init(ObjectClass *oc, void *data)
125
type_init(bcm2836_register_types)
126
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
127
index XXXXXXX..XXXXXXX 100644
128
--- a/hw/arm/raspi.c
129
+++ b/hw/arm/raspi.c
130
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
131
BusState *bus;
132
DeviceState *carddev;
133
134
- object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X);
135
+ object_initialize(&s->soc, sizeof(s->soc),
136
+ version == 3 ? TYPE_BCM2837 : TYPE_BCM2836);
137
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
138
&error_abort);
139
118
--
140
--
119
2.16.1
141
2.16.2
120
142
121
143
diff view generated by jsdifflib
1
We were previously making the system control register (SCR)
1
The BCM2837 sets the Aff1 field of the MPIDR affinity values for the
2
just RAZ/WI. Although we don't implement the functionality
2
CPUs to 0, whereas the BCM2836 uses 0xf. Set this correctly, as it
3
this register controls, we should at least provide the state,
3
is required for Linux to boot.
4
including the banked state for v8M.
5
4
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
8
Message-id: 20180209165810.6668-7-peter.maydell@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20180313153458.26822-8-peter.maydell@linaro.org
9
---
9
---
10
target/arm/cpu.h | 7 +++++++
10
hw/arm/bcm2836.c | 11 +++++++----
11
hw/intc/armv7m_nvic.c | 12 ++++++++----
11
1 file changed, 7 insertions(+), 4 deletions(-)
12
target/arm/machine.c | 12 ++++++++++++
13
3 files changed, 27 insertions(+), 4 deletions(-)
14
12
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.h
15
--- a/hw/arm/bcm2836.c
18
+++ b/target/arm/cpu.h
16
+++ b/hw/arm/bcm2836.c
19
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
17
@@ -XXX,XX +XXX,XX @@
20
uint32_t aircr; /* only holds r/w state if security extn implemented */
18
21
uint32_t secure; /* Is CPU in Secure state? (not guest visible) */
19
struct BCM283XInfo {
22
uint32_t csselr[M_REG_NUM_BANKS];
20
const char *name;
23
+ uint32_t scr[M_REG_NUM_BANKS];
21
+ int clusterid;
24
} v7m;
25
26
/* Information associated with an exception about to be taken:
27
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_CCR, STKALIGN, 9, 1)
28
FIELD(V7M_CCR, DC, 16, 1)
29
FIELD(V7M_CCR, IC, 17, 1)
30
31
+/* V7M SCR bits */
32
+FIELD(V7M_SCR, SLEEPONEXIT, 1, 1)
33
+FIELD(V7M_SCR, SLEEPDEEP, 2, 1)
34
+FIELD(V7M_SCR, SLEEPDEEPS, 3, 1)
35
+FIELD(V7M_SCR, SEVONPEND, 4, 1)
36
+
37
/* V7M AIRCR bits */
38
FIELD(V7M_AIRCR, VECTRESET, 0, 1)
39
FIELD(V7M_AIRCR, VECTCLRACTIVE, 1, 1)
40
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/intc/armv7m_nvic.c
43
+++ b/hw/intc/armv7m_nvic.c
44
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
45
}
46
return val;
47
case 0xd10: /* System Control. */
48
- /* TODO: Implement SLEEPONEXIT. */
49
- return 0;
50
+ return cpu->env.v7m.scr[attrs.secure];
51
case 0xd14: /* Configuration Control. */
52
/* The BFHFNMIGN bit is the only non-banked bit; we
53
* keep it in the non-secure copy of the register.
54
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
55
}
56
break;
57
case 0xd10: /* System Control. */
58
- /* TODO: Implement control registers. */
59
- qemu_log_mask(LOG_UNIMP, "NVIC: SCR unimplemented\n");
60
+ /* We don't implement deep-sleep so these bits are RAZ/WI.
61
+ * The other bits in the register are banked.
62
+ * QEMU's implementation ignores SEVONPEND and SLEEPONEXIT, which
63
+ * is architecturally permitted.
64
+ */
65
+ value &= ~(R_V7M_SCR_SLEEPDEEP_MASK | R_V7M_SCR_SLEEPDEEPS_MASK);
66
+ cpu->env.v7m.scr[attrs.secure] = value;
67
break;
68
case 0xd14: /* Configuration Control. */
69
/* Enforce RAZ/WI on reserved and must-RAZ/WI bits */
70
diff --git a/target/arm/machine.c b/target/arm/machine.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/target/arm/machine.c
73
+++ b/target/arm/machine.c
74
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_csselr = {
75
}
76
};
22
};
77
23
78
+static const VMStateDescription vmstate_m_scr = {
24
static const BCM283XInfo bcm283x_socs[] = {
79
+ .name = "cpu/m/scr",
25
{
80
+ .version_id = 1,
26
.name = TYPE_BCM2836,
81
+ .minimum_version_id = 1,
27
+ .clusterid = 0xf,
82
+ .fields = (VMStateField[]) {
28
},
83
+ VMSTATE_UINT32(env.v7m.scr[M_REG_NS], ARMCPU),
29
{
84
+ VMSTATE_END_OF_LIST()
30
.name = TYPE_BCM2837,
85
+ }
31
+ .clusterid = 0x0,
86
+};
32
},
87
+
88
static const VMStateDescription vmstate_m = {
89
.name = "cpu/m",
90
.version_id = 4,
91
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
92
.subsections = (const VMStateDescription*[]) {
93
&vmstate_m_faultmask_primask,
94
&vmstate_m_csselr,
95
+ &vmstate_m_scr,
96
NULL
97
}
98
};
33
};
99
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_security = {
34
100
VMSTATE_UINT32(env.sau.rnr, ARMCPU),
35
@@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj)
101
VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate),
36
static void bcm2836_realize(DeviceState *dev, Error **errp)
102
VMSTATE_UINT32(env.sau.ctrl, ARMCPU),
37
{
103
+ VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU),
38
BCM283XState *s = BCM283X(dev);
104
VMSTATE_END_OF_LIST()
39
+ BCM283XClass *bc = BCM283X_GET_CLASS(dev);
105
}
40
+ const BCM283XInfo *info = bc->info;
106
};
41
Object *obj;
42
Error *err = NULL;
43
int n;
44
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
45
qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));
46
47
for (n = 0; n < BCM283X_NCPUS; n++) {
48
- /* Mirror bcm2836, which has clusterid set to 0xf
49
- * TODO: this should be converted to a property of ARM_CPU
50
- */
51
- s->cpus[n].mp_affinity = 0xF00 | n;
52
+ /* TODO: this should be converted to a property of ARM_CPU */
53
+ s->cpus[n].mp_affinity = (info->clusterid << 8) | n;
54
55
/* set periphbase/CBAR value for CPU-local registers */
56
object_property_set_int(OBJECT(&s->cpus[n]),
107
--
57
--
108
2.16.1
58
2.16.2
109
59
110
60
diff view generated by jsdifflib
1
M profile cores have a similar setup for cache ID registers
1
Now we have separate types for BCM2386 and BCM2387, we might as well
2
to A profile:
2
just hard-code the CPU type they use rather than having it passed
3
* Cache Level ID Register (CLIDR) is a fixed value
3
through as an object property. This then lets us put the initialization
4
* Cache Type Register (CTR) is a fixed value
4
of the CPU object in init rather than realize.
5
* Cache Size ID Registers (CCSIDR) are a bank of registers;
6
which one you see is selected by the Cache Size Selection
7
Register (CSSELR)
8
5
9
The only difference is that they're in the NVIC memory mapped
6
Note that this change means that it's no longer possible on
10
register space rather than being coprocessor registers.
7
the command line to use -cpu to ask for a different kind of
11
Implement the M profile view of them.
8
CPU than the SoC supports. This was never a supported thing to
9
do anyway; we were just not sanity-checking the command line.
12
10
13
Since neither Cortex-M3 nor Cortex-M4 implement caches,
11
This does require us to only build the bcm2837 object on
14
we don't need to update their init functions and can leave
12
TARGET_AARCH64 configs, since otherwise it won't instantiate
15
the ctr/clidr/ccsidr[] fields in their ARMCPU structs at zero.
13
due to the missing cortex-a53 device and "make check" will fail.
16
Newer cores (like the Cortex-M33) will want to be able to
17
set these ID registers to non-zero values, though.
18
14
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
21
Message-id: 20180209165810.6668-6-peter.maydell@linaro.org
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Message-id: 20180313153458.26822-9-peter.maydell@linaro.org
22
---
19
---
23
target/arm/cpu.h | 26 ++++++++++++++++++++++++++
20
hw/arm/bcm2836.c | 24 +++++++++++++++---------
24
hw/intc/armv7m_nvic.c | 16 ++++++++++++++++
21
hw/arm/raspi.c | 2 --
25
target/arm/machine.c | 36 ++++++++++++++++++++++++++++++++++++
22
2 files changed, 15 insertions(+), 11 deletions(-)
26
3 files changed, 78 insertions(+)
27
23
28
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
24
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
29
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/cpu.h
26
--- a/hw/arm/bcm2836.c
31
+++ b/target/arm/cpu.h
27
+++ b/hw/arm/bcm2836.c
32
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
28
@@ -XXX,XX +XXX,XX @@
33
uint32_t faultmask[M_REG_NUM_BANKS];
29
34
uint32_t aircr; /* only holds r/w state if security extn implemented */
30
struct BCM283XInfo {
35
uint32_t secure; /* Is CPU in Secure state? (not guest visible) */
31
const char *name;
36
+ uint32_t csselr[M_REG_NUM_BANKS];
32
+ const char *cpu_type;
37
} v7m;
33
int clusterid;
38
34
};
39
/* Information associated with an exception about to be taken:
35
40
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_MPU_CTRL, ENABLE, 0, 1)
36
static const BCM283XInfo bcm283x_socs[] = {
41
FIELD(V7M_MPU_CTRL, HFNMIENA, 1, 1)
37
{
42
FIELD(V7M_MPU_CTRL, PRIVDEFENA, 2, 1)
38
.name = TYPE_BCM2836,
43
39
+ .cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"),
44
+/* v7M CLIDR bits */
40
.clusterid = 0xf,
45
+FIELD(V7M_CLIDR, CTYPE_ALL, 0, 21)
41
},
46
+FIELD(V7M_CLIDR, LOUIS, 21, 3)
42
+#ifdef TARGET_AARCH64
47
+FIELD(V7M_CLIDR, LOC, 24, 3)
43
{
48
+FIELD(V7M_CLIDR, LOUU, 27, 3)
44
.name = TYPE_BCM2837,
49
+FIELD(V7M_CLIDR, ICB, 30, 2)
45
+ .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"),
46
.clusterid = 0x0,
47
},
48
+#endif
49
};
50
51
static void bcm2836_init(Object *obj)
52
{
53
BCM283XState *s = BCM283X(obj);
54
+ BCM283XClass *bc = BCM283X_GET_CLASS(obj);
55
+ const BCM283XInfo *info = bc->info;
56
+ int n;
50
+
57
+
51
+FIELD(V7M_CSSELR, IND, 0, 1)
58
+ for (n = 0; n < BCM283X_NCPUS; n++) {
52
+FIELD(V7M_CSSELR, LEVEL, 1, 3)
59
+ object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
53
+/* We use the combination of InD and Level to index into cpu->ccsidr[];
60
+ info->cpu_type);
54
+ * define a mask for this and check that it doesn't permit running off
61
+ object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
55
+ * the end of the array.
62
+ &error_abort);
56
+ */
63
+ }
57
+FIELD(V7M_CSSELR, INDEX, 0, 4)
64
58
+
65
object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL);
59
+QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK);
66
object_property_add_child(obj, "control", OBJECT(&s->control), NULL);
60
+
67
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
61
/* If adding a feature bit which corresponds to a Linux ELF
68
62
* HWCAP bit, remember to update the feature-bit-to-hwcap
69
/* common peripherals from bcm2835 */
63
* mapping in linux-user/elfload.c:get_elf_hwcap().
70
64
@@ -XXX,XX +XXX,XX @@ static inline int arm_debug_target_el(CPUARMState *env)
71
- obj = OBJECT(dev);
65
}
72
- for (n = 0; n < BCM283X_NCPUS; n++) {
73
- object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
74
- s->cpu_type);
75
- object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
76
- &error_abort);
77
- }
78
-
79
obj = object_property_get_link(OBJECT(dev), "ram", &err);
80
if (obj == NULL) {
81
error_setg(errp, "%s: required ram link not found: %s",
82
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
66
}
83
}
67
84
68
+static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu)
85
static Property bcm2836_props[] = {
69
+{
86
- DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type),
70
+ /* If all the CLIDR.Ctypem bits are 0 there are no caches, and
87
DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus,
71
+ * CSSELR is RAZ/WI.
88
BCM283X_NCPUS),
72
+ */
89
DEFINE_PROP_END_OF_LIST()
73
+ return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0;
90
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
74
+}
75
+
76
static inline bool aa64_generate_debug_exceptions(CPUARMState *env)
77
{
78
if (arm_is_secure(env)) {
79
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
80
index XXXXXXX..XXXXXXX 100644
91
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/intc/armv7m_nvic.c
92
--- a/hw/arm/raspi.c
82
+++ b/hw/intc/armv7m_nvic.c
93
+++ b/hw/arm/raspi.c
83
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
94
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
84
return cpu->id_isar4;
95
/* Setup the SOC */
85
case 0xd74: /* ISAR5. */
96
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
86
return cpu->id_isar5;
97
&error_abort);
87
+ case 0xd78: /* CLIDR */
98
- object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type",
88
+ return cpu->clidr;
99
- &error_abort);
89
+ case 0xd7c: /* CTR */
100
object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
90
+ return cpu->ctr;
101
&error_abort);
91
+ case 0xd80: /* CSSIDR */
102
int board_rev = version == 3 ? 0xa02082 : 0xa21041;
92
+ {
93
+ int idx = cpu->env.v7m.csselr[attrs.secure] & R_V7M_CSSELR_INDEX_MASK;
94
+ return cpu->ccsidr[idx];
95
+ }
96
+ case 0xd84: /* CSSELR */
97
+ return cpu->env.v7m.csselr[attrs.secure];
98
/* TODO: Implement debug registers. */
99
case 0xd90: /* MPU_TYPE */
100
/* Unified MPU; if the MPU is not present this value is zero */
101
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
102
qemu_log_mask(LOG_UNIMP,
103
"NVIC: Aux fault status registers unimplemented\n");
104
break;
105
+ case 0xd84: /* CSSELR */
106
+ if (!arm_v7m_csselr_razwi(cpu)) {
107
+ cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK;
108
+ }
109
+ break;
110
case 0xd90: /* MPU_TYPE */
111
return; /* RO */
112
case 0xd94: /* MPU_CTRL */
113
diff --git a/target/arm/machine.c b/target/arm/machine.c
114
index XXXXXXX..XXXXXXX 100644
115
--- a/target/arm/machine.c
116
+++ b/target/arm/machine.c
117
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_faultmask_primask = {
118
}
119
};
120
121
+/* CSSELR is in a subsection because we didn't implement it previously.
122
+ * Migration from an old implementation will leave it at zero, which
123
+ * is OK since the only CPUs in the old implementation make the
124
+ * register RAZ/WI.
125
+ * Since there was no version of QEMU which implemented the CSSELR for
126
+ * just non-secure, we transfer both banks here rather than putting
127
+ * the secure banked version in the m-security subsection.
128
+ */
129
+static bool csselr_vmstate_validate(void *opaque, int version_id)
130
+{
131
+ ARMCPU *cpu = opaque;
132
+
133
+ return cpu->env.v7m.csselr[M_REG_NS] <= R_V7M_CSSELR_INDEX_MASK
134
+ && cpu->env.v7m.csselr[M_REG_S] <= R_V7M_CSSELR_INDEX_MASK;
135
+}
136
+
137
+static bool m_csselr_needed(void *opaque)
138
+{
139
+ ARMCPU *cpu = opaque;
140
+
141
+ return !arm_v7m_csselr_razwi(cpu);
142
+}
143
+
144
+static const VMStateDescription vmstate_m_csselr = {
145
+ .name = "cpu/m/csselr",
146
+ .version_id = 1,
147
+ .minimum_version_id = 1,
148
+ .needed = m_csselr_needed,
149
+ .fields = (VMStateField[]) {
150
+ VMSTATE_UINT32_ARRAY(env.v7m.csselr, ARMCPU, M_REG_NUM_BANKS),
151
+ VMSTATE_VALIDATE("CSSELR is valid", csselr_vmstate_validate),
152
+ VMSTATE_END_OF_LIST()
153
+ }
154
+};
155
+
156
static const VMStateDescription vmstate_m = {
157
.name = "cpu/m",
158
.version_id = 4,
159
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
160
},
161
.subsections = (const VMStateDescription*[]) {
162
&vmstate_m_faultmask_primask,
163
+ &vmstate_m_csselr,
164
NULL
165
}
166
};
167
--
103
--
168
2.16.1
104
2.16.2
169
105
170
106
diff view generated by jsdifflib
1
From: Pekka Enberg <penberg@iki.fi>
1
The raspi3 has AArch64 CPUs, which means that our smpboot
2
code for keeping the secondary CPUs in a pen needs to have
3
a version for A64 as well as A32. Without this, the
4
secondary CPUs go into an infinite loop of taking undefined
5
instruction exceptions.
2
6
3
This patch adds Raspberry Pi 3 support to hw/arm/raspi.c. The
4
differences to Pi 2 are:
5
6
- Firmware address
7
- Board ID
8
- Board revision
9
10
The CPU is different too, but that's going to be configured as part of
11
the machine default CPU when we introduce a new machine type.
12
13
The patch was written from scratch by me but the logic is similar to
14
Zoltán Baldaszti's previous work, which I used as a reference (with
15
permission from the author):
16
17
https://github.com/bztsrc/qemu-raspi3
18
19
Signed-off-by: Pekka Enberg <penberg@iki.fi>
20
[PMM: fixed trailing whitespace on one line]
21
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20180313153458.26822-10-peter.maydell@linaro.org
23
---
10
---
24
hw/arm/raspi.c | 31 +++++++++++++++++++++----------
11
hw/arm/raspi.c | 41 ++++++++++++++++++++++++++++++++++++++++-
25
1 file changed, 21 insertions(+), 10 deletions(-)
12
1 file changed, 40 insertions(+), 1 deletion(-)
26
13
27
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
14
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
28
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/arm/raspi.c
16
--- a/hw/arm/raspi.c
30
+++ b/hw/arm/raspi.c
17
+++ b/hw/arm/raspi.c
31
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@
32
* Rasperry Pi 2 emulation Copyright (c) 2015, Microsoft
33
* Written by Andrew Baumann
34
*
35
+ * Raspberry Pi 3 emulation Copyright (c) 2018 Zoltán Baldaszti
36
+ * Upstream code cleanup (c) 2018 Pekka Enberg
37
+ *
38
* This code is licensed under the GNU GPLv2 and later.
39
*/
40
41
@@ -XXX,XX +XXX,XX @@
42
#define SMPBOOT_ADDR 0x300 /* this should leave enough space for ATAGS */
43
#define MVBAR_ADDR 0x400 /* secure vectors */
44
#define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
19
#define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
45
-#define FIRMWARE_ADDR 0x8000 /* Pi loads kernel.img here by default */
20
#define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */
46
+#define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */
21
#define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */
47
+#define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */
22
+#define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */
48
23
49
/* Table of Linux board IDs for different Pi versions */
24
/* Table of Linux board IDs for different Pi versions */
50
-static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43};
25
static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44};
51
+static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44};
26
@@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
52
27
info->smp_loader_start);
53
typedef struct RasPiState {
54
BCM2836State soc;
55
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
56
binfo.secure_board_setup = true;
57
binfo.secure_boot = true;
58
59
- /* Pi2 requires SMP setup */
60
- if (version == 2) {
61
+ /* Pi2 and Pi3 requires SMP setup */
62
+ if (version >= 2) {
63
binfo.smp_loader_start = SMPBOOT_ADDR;
64
binfo.write_secondary_boot = write_smpboot;
65
binfo.secondary_cpu_reset_hook = reset_secondary;
66
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
67
* the normal Linux boot process
68
*/
69
if (machine->firmware) {
70
+ hwaddr firmware_addr = version == 3 ? FIRMWARE_ADDR_3 : FIRMWARE_ADDR_2;
71
/* load the firmware image (typically kernel.img) */
72
- r = load_image_targphys(machine->firmware, FIRMWARE_ADDR,
73
- ram_size - FIRMWARE_ADDR);
74
+ r = load_image_targphys(machine->firmware, firmware_addr,
75
+ ram_size - firmware_addr);
76
if (r < 0) {
77
error_report("Failed to load firmware from %s", machine->firmware);
78
exit(1);
79
}
80
81
- binfo.entry = FIRMWARE_ADDR;
82
+ binfo.entry = firmware_addr;
83
binfo.firmware_loaded = true;
84
} else {
85
binfo.kernel_filename = machine->kernel_filename;
86
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
87
arm_load_kernel(ARM_CPU(first_cpu), &binfo);
88
}
28
}
89
29
90
-static void raspi2_init(MachineState *machine)
30
+static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
91
+static void raspi_init(MachineState *machine, int version)
31
+{
92
{
32
+ /* Unlike the AArch32 version we don't need to call the board setup hook.
93
RasPiState *s = g_new0(RasPiState, 1);
33
+ * The mechanism for doing the spin-table is also entirely different.
94
uint32_t vcram_size;
34
+ * We must have four 64-bit fields at absolute addresses
95
@@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine)
35
+ * 0xd8, 0xe0, 0xe8, 0xf0 in RAM, which are the flag variables for
96
&error_abort);
36
+ * our CPUs, and which we must ensure are zero initialized before
97
object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
37
+ * the primary CPU goes into the kernel. We put these variables inside
98
&error_abort);
38
+ * a rom blob, so that the reset for ROM contents zeroes them for us.
99
- object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev",
39
+ */
100
+ int board_rev = version == 3 ? 0xa02082 : 0xa21041;
40
+ static const uint32_t smpboot[] = {
101
+ object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev",
41
+ 0xd2801b05, /* mov x5, 0xd8 */
102
&error_abort);
42
+ 0xd53800a6, /* mrs x6, mpidr_el1 */
103
object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abort);
43
+ 0x924004c6, /* and x6, x6, #0x3 */
104
44
+ 0xd503205f, /* spin: wfe */
105
@@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine)
45
+ 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */
106
46
+ 0xb4ffffc4, /* cbz x4, spin */
107
vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size",
47
+ 0xd2800000, /* mov x0, #0x0 */
108
&error_abort);
48
+ 0xd2800001, /* mov x1, #0x0 */
109
- setup_boot(machine, 2, machine->ram_size - vcram_size);
49
+ 0xd2800002, /* mov x2, #0x0 */
110
+ setup_boot(machine, version, machine->ram_size - vcram_size);
50
+ 0xd2800003, /* mov x3, #0x0 */
51
+ 0xd61f0080, /* br x4 */
52
+ };
53
+
54
+ static const uint64_t spintables[] = {
55
+ 0, 0, 0, 0
56
+ };
57
+
58
+ rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot),
59
+ info->smp_loader_start);
60
+ rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables),
61
+ SPINTABLE_ADDR);
111
+}
62
+}
112
+
63
+
113
+static void raspi2_init(MachineState *machine)
64
static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info)
114
+{
65
{
115
+ raspi_init(machine, 2);
66
arm_write_secure_board_setup_dummy_smc(cpu, info, MVBAR_ADDR);
116
}
67
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
117
68
/* Pi2 and Pi3 requires SMP setup */
118
static void raspi2_machine_init(MachineClass *mc)
69
if (version >= 2) {
70
binfo.smp_loader_start = SMPBOOT_ADDR;
71
- binfo.write_secondary_boot = write_smpboot;
72
+ if (version == 2) {
73
+ binfo.write_secondary_boot = write_smpboot;
74
+ } else {
75
+ binfo.write_secondary_boot = write_smpboot64;
76
+ }
77
binfo.secondary_cpu_reset_hook = reset_secondary;
78
}
79
119
--
80
--
120
2.16.1
81
2.16.2
121
82
122
83
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20180211205848.4568-3-richard.henderson@linaro.org
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/cpu.h | 35 ++++++++++++++++++-----------------
9
target/arm/helper.c | 6 ++++--
10
target/arm/translate-a64.c | 3 +++
11
3 files changed, 25 insertions(+), 19 deletions(-)
12
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
16
+++ b/target/arm/cpu.h
17
@@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
18
}
19
20
/* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a
21
- * special-behaviour cp reg and bits [15..8] indicate what behaviour
22
+ * special-behaviour cp reg and bits [11..8] indicate what behaviour
23
* it has. Otherwise it is a simple cp reg, where CONST indicates that
24
* TCG can assume the value to be constant (ie load at translate time)
25
* and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END
26
@@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
27
* need to be surrounded by gen_io_start()/gen_io_end(). In particular,
28
* registers which implement clocks or timers require this.
29
*/
30
-#define ARM_CP_SPECIAL 1
31
-#define ARM_CP_CONST 2
32
-#define ARM_CP_64BIT 4
33
-#define ARM_CP_SUPPRESS_TB_END 8
34
-#define ARM_CP_OVERRIDE 16
35
-#define ARM_CP_ALIAS 32
36
-#define ARM_CP_IO 64
37
-#define ARM_CP_NO_RAW 128
38
-#define ARM_CP_NOP (ARM_CP_SPECIAL | (1 << 8))
39
-#define ARM_CP_WFI (ARM_CP_SPECIAL | (2 << 8))
40
-#define ARM_CP_NZCV (ARM_CP_SPECIAL | (3 << 8))
41
-#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | (4 << 8))
42
-#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | (5 << 8))
43
-#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA
44
+#define ARM_CP_SPECIAL 0x0001
45
+#define ARM_CP_CONST 0x0002
46
+#define ARM_CP_64BIT 0x0004
47
+#define ARM_CP_SUPPRESS_TB_END 0x0008
48
+#define ARM_CP_OVERRIDE 0x0010
49
+#define ARM_CP_ALIAS 0x0020
50
+#define ARM_CP_IO 0x0040
51
+#define ARM_CP_NO_RAW 0x0080
52
+#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100)
53
+#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200)
54
+#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300)
55
+#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400)
56
+#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500)
57
+#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA
58
+#define ARM_CP_FPU 0x1000
59
/* Used only as a terminator for ARMCPRegInfo lists */
60
-#define ARM_CP_SENTINEL 0xffff
61
+#define ARM_CP_SENTINEL 0xffff
62
/* Mask of only the flag bits in a type field */
63
-#define ARM_CP_FLAG_MASK 0xff
64
+#define ARM_CP_FLAG_MASK 0x10ff
65
66
/* Valid values for ARMCPRegInfo state field, indicating which of
67
* the AArch32 and AArch64 execution states this register is visible in.
68
diff --git a/target/arm/helper.c b/target/arm/helper.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/target/arm/helper.c
71
+++ b/target/arm/helper.c
72
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
73
.writefn = aa64_daif_write, .resetfn = arm_cp_reset_ignore },
74
{ .name = "FPCR", .state = ARM_CP_STATE_AA64,
75
.opc0 = 3, .opc1 = 3, .opc2 = 0, .crn = 4, .crm = 4,
76
- .access = PL0_RW, .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write },
77
+ .access = PL0_RW, .type = ARM_CP_FPU,
78
+ .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write },
79
{ .name = "FPSR", .state = ARM_CP_STATE_AA64,
80
.opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4,
81
- .access = PL0_RW, .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write },
82
+ .access = PL0_RW, .type = ARM_CP_FPU,
83
+ .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write },
84
{ .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64,
85
.opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0,
86
.access = PL0_R, .type = ARM_CP_NO_RAW,
87
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/target/arm/translate-a64.c
90
+++ b/target/arm/translate-a64.c
91
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
92
default:
93
break;
94
}
95
+ if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) {
96
+ return;
97
+ }
98
99
if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) {
100
gen_io_start();
101
--
102
2.16.1
103
104
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Nothing in either register affects the TB.
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20180211205848.4568-4-richard.henderson@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/helper.c | 4 ++--
11
1 file changed, 2 insertions(+), 2 deletions(-)
12
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
18
.writefn = aa64_daif_write, .resetfn = arm_cp_reset_ignore },
19
{ .name = "FPCR", .state = ARM_CP_STATE_AA64,
20
.opc0 = 3, .opc1 = 3, .opc2 = 0, .crn = 4, .crm = 4,
21
- .access = PL0_RW, .type = ARM_CP_FPU,
22
+ .access = PL0_RW, .type = ARM_CP_FPU | ARM_CP_SUPPRESS_TB_END,
23
.readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write },
24
{ .name = "FPSR", .state = ARM_CP_STATE_AA64,
25
.opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4,
26
- .access = PL0_RW, .type = ARM_CP_FPU,
27
+ .access = PL0_RW, .type = ARM_CP_FPU | ARM_CP_SUPPRESS_TB_END,
28
.readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write },
29
{ .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64,
30
.opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0,
31
--
32
2.16.1
33
34
diff view generated by jsdifflib
Deleted patch
1
The PENDNMISET/CLR bits in the ICSR should be RAZ/WI from
2
NonSecure state if the AIRCR.BFHFNMINS bit is zero. We had
3
misimplemented this as making the bits RAZ/WI from both
4
Secure and NonSecure states. Fix this bug by checking
5
attrs.secure so that Secure code can pend and unpend NMIs.
6
1
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180209165810.6668-3-peter.maydell@linaro.org
10
---
11
hw/intc/armv7m_nvic.c | 6 +++---
12
1 file changed, 3 insertions(+), 3 deletions(-)
13
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
17
+++ b/hw/intc/armv7m_nvic.c
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
19
}
20
}
21
/* NMIPENDSET */
22
- if ((cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) &&
23
- s->vectors[ARMV7M_EXCP_NMI].pending) {
24
+ if ((attrs.secure || (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))
25
+ && s->vectors[ARMV7M_EXCP_NMI].pending) {
26
val |= (1 << 31);
27
}
28
/* ISRPREEMPT: RES0 when halting debug not implemented */
29
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
30
break;
31
}
32
case 0xd04: /* Interrupt Control State (ICSR) */
33
- if (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
34
+ if (attrs.secure || cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
35
if (value & (1 << 31)) {
36
armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI, false);
37
} else if (value & (1 << 30) &&
38
--
39
2.16.1
40
41
diff view generated by jsdifflib
Deleted patch
1
For M profile cores, cache maintenance operations are done by
2
writing to special registers in the system register space.
3
For QEMU, cache operations are always NOPs, since we don't
4
implement the cache. Implementing these explicitly avoids
5
a spurious LOG_GUEST_ERROR when the guest uses them.
6
1
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180209165810.6668-4-peter.maydell@linaro.org
10
---
11
hw/intc/armv7m_nvic.c | 12 ++++++++++++
12
1 file changed, 12 insertions(+)
13
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
17
+++ b/hw/intc/armv7m_nvic.c
18
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
19
}
20
break;
21
}
22
+ case 0xf50: /* ICIALLU */
23
+ case 0xf58: /* ICIMVAU */
24
+ case 0xf5c: /* DCIMVAC */
25
+ case 0xf60: /* DCISW */
26
+ case 0xf64: /* DCCMVAU */
27
+ case 0xf68: /* DCCMVAC */
28
+ case 0xf6c: /* DCCSW */
29
+ case 0xf70: /* DCCIMVAC */
30
+ case 0xf74: /* DCCISW */
31
+ case 0xf78: /* BPIALL */
32
+ /* Cache and branch predictor maintenance: for QEMU these always NOP */
33
+ break;
34
default:
35
bad_offset:
36
qemu_log_mask(LOG_GUEST_ERROR,
37
--
38
2.16.1
39
40
diff view generated by jsdifflib
Deleted patch
1
The Coprocessor Power Control Register (CPPWR) is new in v8M.
2
It allows software to control whether coprocessors are allowed
3
to power down and lose their state. QEMU doesn't have any
4
notion of power control, so we choose the IMPDEF option of
5
making the whole register RAZ/WI (indicating that no coprocessors
6
can ever power down and lose state).
7
1
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180209165810.6668-5-peter.maydell@linaro.org
11
---
12
hw/intc/armv7m_nvic.c | 14 ++++++++++++++
13
1 file changed, 14 insertions(+)
14
15
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/armv7m_nvic.c
18
+++ b/hw/intc/armv7m_nvic.c
19
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
20
switch (offset) {
21
case 4: /* Interrupt Control Type. */
22
return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1;
23
+ case 0xc: /* CPPWR */
24
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
25
+ goto bad_offset;
26
+ }
27
+ /* We make the IMPDEF choice that nothing can ever go into a
28
+ * non-retentive power state, which allows us to RAZ/WI this.
29
+ */
30
+ return 0;
31
case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */
32
{
33
int startvec = 8 * (offset - 0x380) + NVIC_FIRST_IRQ;
34
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
35
ARMCPU *cpu = s->cpu;
36
37
switch (offset) {
38
+ case 0xc: /* CPPWR */
39
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
40
+ goto bad_offset;
41
+ }
42
+ /* Make the IMPDEF choice to RAZ/WI this. */
43
+ break;
44
case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */
45
{
46
int startvec = 8 * (offset - 0x380) + NVIC_FIRST_IRQ;
47
--
48
2.16.1
49
50
diff view generated by jsdifflib
Deleted patch
1
In commit 50f11062d4c896 we added support for MSR/MRS access
2
to the NS banked special registers, but we forgot to implement
3
the support for writing to CONTROL_NS. Correct the omission.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180209165810.6668-8-peter.maydell@linaro.org
8
---
9
target/arm/helper.c | 10 ++++++++++
10
1 file changed, 10 insertions(+)
11
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
15
+++ b/target/arm/helper.c
16
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
17
}
18
env->v7m.faultmask[M_REG_NS] = val & 1;
19
return;
20
+ case 0x94: /* CONTROL_NS */
21
+ if (!env->v7m.secure) {
22
+ return;
23
+ }
24
+ write_v7m_control_spsel_for_secstate(env,
25
+ val & R_V7M_CONTROL_SPSEL_MASK,
26
+ M_REG_NS);
27
+ env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK;
28
+ env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK;
29
+ return;
30
case 0x98: /* SP_NS */
31
{
32
/* This gives the non-secure SP selected based on whether we're
33
--
34
2.16.1
35
36
diff view generated by jsdifflib
Deleted patch
1
In commit commit 3b2e934463121 we added support for the AIRCR
2
register holding state, but forgot to add it to the vmstate
3
structs. Since it only holds r/w state if the security extension
4
is implemented, we can just add it to vmstate_m_security.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180209165810.6668-10-peter.maydell@linaro.org
9
---
10
target/arm/machine.c | 4 ++++
11
1 file changed, 4 insertions(+)
12
13
diff --git a/target/arm/machine.c b/target/arm/machine.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/machine.c
16
+++ b/target/arm/machine.c
17
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_security = {
18
VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate),
19
VMSTATE_UINT32(env.sau.ctrl, ARMCPU),
20
VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU),
21
+ /* AIRCR is not secure-only, but our implementation is R/O if the
22
+ * security extension is unimplemented, so we migrate it here.
23
+ */
24
+ VMSTATE_UINT32(env.v7m.aircr, ARMCPU),
25
VMSTATE_END_OF_LIST()
26
}
27
};
28
--
29
2.16.1
30
31
diff view generated by jsdifflib