1
Hi; here's the first target-arm pullreq for the 8.1 cycle.
1
The following changes since commit 3214bec13d8d4c40f707d21d8350d04e4123ae97:
2
Nothing particularly huge in here, just the various things
3
that had accumulated during the freeze.
4
2
5
thanks
3
Merge tag 'migration-20250110-pull-request' of https://gitlab.com/farosas/qemu into staging (2025-01-10 13:39:19 -0500)
6
-- PMM
7
8
The following changes since commit 2d82c32b2ceaca3dc3da5e36e10976f34bfcb598:
9
10
Open 8.1 development tree (2023-04-20 10:05:25 +0100)
11
4
12
are available in the Git repository at:
5
are available in the Git repository at:
13
6
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230420
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20250113
15
8
16
for you to fetch changes up to 1ed1f338520cda0574b7e04f5e8e85e049740548:
9
for you to fetch changes up to 435d260e7ec5ff9c79e3e62f1d66ec82d2d691ae:
17
10
18
arm/mcimx7d-sabre: Set fec2-phy-connected property to false (2023-04-20 10:46:43 +0100)
11
docs/system/arm/virt: mention specific migration information (2025-01-13 12:35:35 +0000)
19
12
20
----------------------------------------------------------------
13
----------------------------------------------------------------
21
target-arm queue:
14
target-arm queue:
22
* hw/arm: Fix some typos in comments (most found by codespell)
15
* hw/arm_sysctl: fix extracting 31th bit of val
23
* exynos: Fix out-of-bounds access in exynos4210_gcomp_find debug printf
16
* hw/misc: cast rpm to uint64_t
24
* Orangepi-PC, Cubieboard: add Allwinner WDT watchdog emulation
17
* tests/qtest/boot-serial-test: Improve ASM
25
* tests/avocado: Add reboot tests to Cubieboard
18
* target/arm: Move minor arithmetic helpers out of helper.c
26
* hw/timer/imx_epit: Fix bugs in timer limit checking
19
* target/arm: change default pauth algorithm to impdef
27
* target/arm: Remove KVM AArch32 CPU definitions
28
* hw/arm/virt: Restrict Cortex-A7 check to TCG
29
* target/arm: Initialize debug capabilities only once
30
* target/arm: Implement FEAT_PAN3
31
* docs/devel/kconfig.rst: Fix incorrect markup
32
* target/arm: Report pauth information to gdb as 'pauth_v2'
33
* mcimxd7-sabre, mcimx6ul-evk: Correctly model the way the PHY
34
on the second ethernet device must be configured via the
35
first one
36
20
37
----------------------------------------------------------------
21
----------------------------------------------------------------
38
Akihiko Odaki (1):
22
Anastasia Belova (1):
39
target/arm: Initialize debug capabilities only once
23
hw/arm_sysctl: fix extracting 31th bit of val
40
24
41
Axel Heider (2):
25
Peter Maydell (2):
42
hw/timer/imx_epit: don't shadow variable
26
target/arm: Move minor arithmetic helpers out of helper.c
43
hw/timer/imx_epit: fix limit check
27
tests/tcg/aarch64: force qarma5 for pauth-3 test
44
28
45
Feng Jiang (1):
29
Philippe Mathieu-Daudé (4):
46
exynos: Fix out-of-bounds access in exynos4210_gcomp_find debug printf
30
tests/qtest/boot-serial-test: Improve ASM comments of PL011 tests
31
tests/qtest/boot-serial-test: Reduce for() loop in PL011 tests
32
tests/qtest/boot-serial-test: Reorder pair of instructions in PL011 test
33
tests/qtest/boot-serial-test: Initialize PL011 Control register
47
34
48
Guenter Roeck (5):
35
Pierrick Bouvier (3):
49
hw/net/imx_fec: Support two Ethernet interfaces connected to single MDIO bus
36
target/arm: add new property to select pauth-qarma5
50
fsl-imx6ul: Add fec[12]-phy-connected properties
37
target/arm: change default pauth algorithm to impdef
51
arm/mcimx6ul-evk: Set fec1-phy-connected property to false
38
docs/system/arm/virt: mention specific migration information
52
fsl-imx7: Add fec[12]-phy-connected properties
53
arm/mcimx7d-sabre: Set fec2-phy-connected property to false
54
39
55
Peter Maydell (5):
40
Tigran Sogomonian (1):
56
target/arm: Pass ARMMMUFaultInfo to merge_syn_data_abort()
41
hw/misc: cast rpm to uint64_t
57
target/arm: Don't set ISV when reporting stage 1 faults in ESR_EL2
58
target/arm: Implement FEAT_PAN3
59
docs/devel/kconfig.rst: Fix incorrect markup
60
target/arm: Report pauth information to gdb as 'pauth_v2'
61
42
62
Philippe Mathieu-Daudé (2):
43
docs/system/arm/cpu-features.rst | 7 +-
63
target/arm: Remove KVM AArch32 CPU definitions
44
docs/system/arm/virt.rst | 4 +
64
hw/arm/virt: Restrict Cortex-A7 check to TCG
45
docs/system/introduction.rst | 2 +-
46
target/arm/cpu.h | 4 +
47
hw/core/machine.c | 4 +-
48
hw/misc/arm_sysctl.c | 2 +-
49
hw/misc/npcm7xx_mft.c | 5 +-
50
target/arm/arm-qmp-cmds.c | 2 +-
51
target/arm/cpu.c | 2 +
52
target/arm/cpu64.c | 38 ++-
53
target/arm/helper.c | 285 -----------------------
54
target/arm/tcg/arith_helper.c | 296 ++++++++++++++++++++++++
55
tests/qtest/arm-cpu-features.c | 15 +-
56
tests/qtest/boot-serial-test.c | 23 +-
57
target/arm/{op_addsub.h => tcg/op_addsub.c.inc} | 0
58
target/arm/tcg/meson.build | 1 +
59
tests/tcg/aarch64/Makefile.softmmu-target | 3 +
60
17 files changed, 377 insertions(+), 316 deletions(-)
61
create mode 100644 target/arm/tcg/arith_helper.c
62
rename target/arm/{op_addsub.h => tcg/op_addsub.c.inc} (100%)
65
63
66
Stefan Weil (1):
67
hw/arm: Fix some typos in comments (most found by codespell)
68
69
Strahinja Jankovic (4):
70
hw/watchdog: Allwinner WDT emulation for system reset
71
hw/arm: Add WDT to Allwinner-A10 and Cubieboard
72
hw/arm: Add WDT to Allwinner-H3 and Orangepi-PC
73
tests/avocado: Add reboot tests to Cubieboard
74
75
docs/devel/kconfig.rst | 2 +-
76
docs/system/arm/cubieboard.rst | 1 +
77
docs/system/arm/emulation.rst | 1 +
78
docs/system/arm/orangepi.rst | 1 +
79
include/hw/arm/allwinner-a10.h | 2 +
80
include/hw/arm/allwinner-h3.h | 5 +-
81
include/hw/arm/fsl-imx6ul.h | 1 +
82
include/hw/arm/fsl-imx7.h | 1 +
83
include/hw/net/imx_fec.h | 2 +
84
include/hw/watchdog/allwinner-wdt.h | 123 +++++++++++
85
target/arm/cpu.h | 5 +
86
target/arm/kvm-consts.h | 9 +-
87
target/arm/kvm_arm.h | 8 +
88
hw/arm/allwinner-a10.c | 7 +
89
hw/arm/allwinner-h3.c | 8 +
90
hw/arm/exynos4210.c | 4 +-
91
hw/arm/fsl-imx6ul.c | 20 ++
92
hw/arm/fsl-imx7.c | 20 ++
93
hw/arm/mcimx6ul-evk.c | 2 +
94
hw/arm/mcimx7d-sabre.c | 2 +
95
hw/arm/musicpal.c | 2 +-
96
hw/arm/omap1.c | 2 +-
97
hw/arm/omap2.c | 2 +-
98
hw/arm/virt-acpi-build.c | 2 +-
99
hw/arm/virt.c | 4 +-
100
hw/arm/xlnx-versal-virt.c | 2 +-
101
hw/net/imx_fec.c | 27 ++-
102
hw/timer/exynos4210_mct.c | 13 +-
103
hw/timer/imx_epit.c | 2 +-
104
hw/watchdog/allwinner-wdt.c | 416 ++++++++++++++++++++++++++++++++++++
105
target/arm/cpu64.c | 2 +-
106
target/arm/cpu_tcg.c | 2 -
107
target/arm/gdbstub.c | 9 +-
108
target/arm/kvm.c | 2 +
109
target/arm/kvm64.c | 18 +-
110
target/arm/ptw.c | 14 +-
111
target/arm/tcg/tlb_helper.c | 26 ++-
112
gdb-xml/aarch64-pauth.xml | 2 +-
113
hw/arm/Kconfig | 4 +-
114
hw/watchdog/Kconfig | 4 +
115
hw/watchdog/meson.build | 1 +
116
hw/watchdog/trace-events | 7 +
117
tests/avocado/boot_linux_console.py | 15 +-
118
43 files changed, 738 insertions(+), 64 deletions(-)
119
create mode 100644 include/hw/watchdog/allwinner-wdt.h
120
create mode 100644 hw/watchdog/allwinner-wdt.c
121
diff view generated by jsdifflib
Deleted patch
1
From: Stefan Weil <sw@weilnetz.de>
2
1
3
Signed-off-by: Stefan Weil <sw@weilnetz.de>
4
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-id: 20230409200526.1156456-1-sw@weilnetz.de
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/arm/exynos4210.c | 4 ++--
9
hw/arm/musicpal.c | 2 +-
10
hw/arm/omap1.c | 2 +-
11
hw/arm/omap2.c | 2 +-
12
hw/arm/virt-acpi-build.c | 2 +-
13
hw/arm/virt.c | 2 +-
14
hw/arm/xlnx-versal-virt.c | 2 +-
15
hw/arm/Kconfig | 2 +-
16
8 files changed, 9 insertions(+), 9 deletions(-)
17
18
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/exynos4210.c
21
+++ b/hw/arm/exynos4210.c
22
@@ -XXX,XX +XXX,XX @@ static int mapline_size(const int *mapline)
23
24
/*
25
* Initialize board IRQs.
26
- * These IRQs contain splitted Int/External Combiner and External Gic IRQs.
27
+ * These IRQs contain split Int/External Combiner and External Gic IRQs.
28
*/
29
static void exynos4210_init_board_irqs(Exynos4210State *s)
30
{
31
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
32
* - SDMA
33
* - ADMA2
34
*
35
- * As this part of the Exynos4210 is not publically available,
36
+ * As this part of the Exynos4210 is not publicly available,
37
* we used the "HS-MMC Controller S3C2416X RISC Microprocessor"
38
* public datasheet which is very similar (implementing
39
* MMC Specification Version 4.0 being the only difference noted)
40
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/arm/musicpal.c
43
+++ b/hw/arm/musicpal.c
44
@@ -XXX,XX +XXX,XX @@
45
#define MP_LCD_SPI_CMD 0x00104011
46
#define MP_LCD_SPI_INVALID 0x00000000
47
48
-/* Commmands */
49
+/* Commands */
50
#define MP_LCD_INST_SETPAGE0 0xB0
51
/* ... */
52
#define MP_LCD_INST_SETPAGE7 0xB7
53
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/hw/arm/omap1.c
56
+++ b/hw/arm/omap1.c
57
@@ -XXX,XX +XXX,XX @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,
58
s->led[1] = omap_lpg_init(system_memory,
59
0xfffbd800, omap_findclk(s, "clk32-kHz"));
60
61
- /* Register mappings not currenlty implemented:
62
+ /* Register mappings not currently implemented:
63
* MCSI2 Comm    fffb2000 - fffb27ff (not mapped on OMAP310)
64
* MCSI1 Bluetooth    fffb2800 - fffb2fff (not mapped on OMAP310)
65
* USB W2FC        fffb4000 - fffb47ff
66
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/hw/arm/omap2.c
69
+++ b/hw/arm/omap2.c
70
@@ -XXX,XX +XXX,XX @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sdram,
71
omap_findclk(s, "func_96m_clk"),
72
omap_findclk(s, "core_l4_iclk"));
73
74
- /* All register mappings (includin those not currenlty implemented):
75
+ /* All register mappings (including those not currently implemented):
76
* SystemControlMod    48000000 - 48000fff
77
* SystemControlL4    48001000 - 48001fff
78
* 32kHz Timer Mod    48004000 - 48004fff
79
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/arm/virt-acpi-build.c
82
+++ b/hw/arm/virt-acpi-build.c
83
@@ -XXX,XX +XXX,XX @@ static void build_append_gicr(GArray *table_data, uint64_t base, uint32_t size)
84
build_append_int_noprefix(table_data, 0xE, 1); /* Type */
85
build_append_int_noprefix(table_data, 16, 1); /* Length */
86
build_append_int_noprefix(table_data, 0, 2); /* Reserved */
87
- /* Discovery Range Base Addres */
88
+ /* Discovery Range Base Address */
89
build_append_int_noprefix(table_data, base, 8);
90
build_append_int_noprefix(table_data, size, 4); /* Discovery Range Length */
91
}
92
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/hw/arm/virt.c
95
+++ b/hw/arm/virt.c
96
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
97
int pa_bits;
98
99
/*
100
- * Instanciate a temporary CPU object to find out about what
101
+ * Instantiate a temporary CPU object to find out about what
102
* we are about to deal with. Once this is done, get rid of
103
* the object.
104
*/
105
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/hw/arm/xlnx-versal-virt.c
108
+++ b/hw/arm/xlnx-versal-virt.c
109
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
110
fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz);
111
112
/* Make the APU cpu address space visible to virtio and other
113
- * modules unaware of muliple address-spaces. */
114
+ * modules unaware of multiple address-spaces. */
115
memory_region_add_subregion_overlap(get_system_memory(),
116
0, &s->soc.fpd.apu.mr, 0);
117
118
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
119
index XXXXXXX..XXXXXXX 100644
120
--- a/hw/arm/Kconfig
121
+++ b/hw/arm/Kconfig
122
@@ -XXX,XX +XXX,XX @@ config OLIMEX_STM32_H405
123
config NSERIES
124
bool
125
select OMAP
126
- select TMP105 # tempature sensor
127
+ select TMP105 # temperature sensor
128
select BLIZZARD # LCD/TV controller
129
select ONENAND
130
select TSC210X # touchscreen/sensors/audio
131
--
132
2.34.1
133
134
diff view generated by jsdifflib
Deleted patch
1
From: Feng Jiang <jiangfeng@kylinos.cn>
2
1
3
One of the debug printfs in exynos4210_gcomp_find() will
4
access outside the 's->g_timer.reg.comp[]' array if there
5
was no active comparator and 'res' is -1. Add a conditional
6
to avoid this.
7
8
This doesn't happen in normal use because the debug printfs
9
are by default not compiled in.
10
11
Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
12
Message-id: 20230404074506.112615-1-jiangfeng@kylinos.cn
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
[PMM: Adjusted commit message to clarify that the overrun
15
only happens if you've enabled debug printfs]
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
hw/timer/exynos4210_mct.c | 13 ++++++++-----
19
1 file changed, 8 insertions(+), 5 deletions(-)
20
21
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/timer/exynos4210_mct.c
24
+++ b/hw/timer/exynos4210_mct.c
25
@@ -XXX,XX +XXX,XX @@ static int32_t exynos4210_gcomp_find(Exynos4210MCTState *s)
26
res = min_comp_i;
27
}
28
29
- DPRINTF("found comparator %d: comp 0x%llx distance 0x%llx, gfrc 0x%llx\n",
30
- res,
31
- s->g_timer.reg.comp[res],
32
- distance_min,
33
- gfrc);
34
+ if (res >= 0) {
35
+ DPRINTF("found comparator %d: "
36
+ "comp 0x%llx distance 0x%llx, gfrc 0x%llx\n",
37
+ res,
38
+ s->g_timer.reg.comp[res],
39
+ distance_min,
40
+ gfrc);
41
+ }
42
43
return res;
44
}
45
--
46
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
1
3
This patch adds basic support for Allwinner WDT.
4
Both sun4i and sun6i variants are supported.
5
However, interrupt generation is not supported, so WDT can be used only to trigger system reset.
6
7
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
8
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
9
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
10
Message-id: 20230326202256.22980-2-strahinja.p.jankovic@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
include/hw/watchdog/allwinner-wdt.h | 123 ++++++++
14
hw/watchdog/allwinner-wdt.c | 416 ++++++++++++++++++++++++++++
15
hw/watchdog/Kconfig | 4 +
16
hw/watchdog/meson.build | 1 +
17
hw/watchdog/trace-events | 7 +
18
5 files changed, 551 insertions(+)
19
create mode 100644 include/hw/watchdog/allwinner-wdt.h
20
create mode 100644 hw/watchdog/allwinner-wdt.c
21
22
diff --git a/include/hw/watchdog/allwinner-wdt.h b/include/hw/watchdog/allwinner-wdt.h
23
new file mode 100644
24
index XXXXXXX..XXXXXXX
25
--- /dev/null
26
+++ b/include/hw/watchdog/allwinner-wdt.h
27
@@ -XXX,XX +XXX,XX @@
28
+/*
29
+ * Allwinner Watchdog emulation
30
+ *
31
+ * Copyright (C) 2023 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
32
+ *
33
+ * This file is derived from Allwinner RTC,
34
+ * by Niek Linnenbank.
35
+ *
36
+ * This program is free software: you can redistribute it and/or modify
37
+ * it under the terms of the GNU General Public License as published by
38
+ * the Free Software Foundation, either version 2 of the License, or
39
+ * (at your option) any later version.
40
+ *
41
+ * This program is distributed in the hope that it will be useful,
42
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
43
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44
+ * GNU General Public License for more details.
45
+ *
46
+ * You should have received a copy of the GNU General Public License
47
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
48
+ */
49
+
50
+#ifndef HW_WATCHDOG_ALLWINNER_WDT_H
51
+#define HW_WATCHDOG_ALLWINNER_WDT_H
52
+
53
+#include "qom/object.h"
54
+#include "hw/ptimer.h"
55
+#include "hw/sysbus.h"
56
+
57
+/*
58
+ * This is a model of the Allwinner watchdog.
59
+ * Since watchdog registers belong to the timer module (and are shared with the
60
+ * RTC module), the interrupt line from watchdog is not handled right now.
61
+ * In QEMU, we just wire up the watchdog reset to watchdog_perform_action(),
62
+ * at least for the moment.
63
+ */
64
+
65
+#define TYPE_AW_WDT "allwinner-wdt"
66
+
67
+/** Allwinner WDT sun4i family (A10, A12), also sun7i (A20) */
68
+#define TYPE_AW_WDT_SUN4I TYPE_AW_WDT "-sun4i"
69
+
70
+/** Allwinner WDT sun6i family and newer (A31, H2+, H3, etc) */
71
+#define TYPE_AW_WDT_SUN6I TYPE_AW_WDT "-sun6i"
72
+
73
+/** Number of WDT registers */
74
+#define AW_WDT_REGS_NUM (5)
75
+
76
+OBJECT_DECLARE_TYPE(AwWdtState, AwWdtClass, AW_WDT)
77
+
78
+/**
79
+ * Allwinner WDT object instance state.
80
+ */
81
+struct AwWdtState {
82
+ /*< private >*/
83
+ SysBusDevice parent_obj;
84
+
85
+ /*< public >*/
86
+ MemoryRegion iomem;
87
+ struct ptimer_state *timer;
88
+
89
+ uint32_t regs[AW_WDT_REGS_NUM];
90
+};
91
+
92
+/**
93
+ * Allwinner WDT class-level struct.
94
+ *
95
+ * This struct is filled by each sunxi device specific code
96
+ * such that the generic code can use this struct to support
97
+ * all devices.
98
+ */
99
+struct AwWdtClass {
100
+ /*< private >*/
101
+ SysBusDeviceClass parent_class;
102
+ /*< public >*/
103
+
104
+ /** Defines device specific register map */
105
+ const uint8_t *regmap;
106
+
107
+ /** Size of the regmap in bytes */
108
+ size_t regmap_size;
109
+
110
+ /**
111
+ * Read device specific register
112
+ *
113
+ * @offset: register offset to read
114
+ * @return true if register read successful, false otherwise
115
+ */
116
+ bool (*read)(AwWdtState *s, uint32_t offset);
117
+
118
+ /**
119
+ * Write device specific register
120
+ *
121
+ * @offset: register offset to write
122
+ * @data: value to set in register
123
+ * @return true if register write successful, false otherwise
124
+ */
125
+ bool (*write)(AwWdtState *s, uint32_t offset, uint32_t data);
126
+
127
+ /**
128
+ * Check if watchdog can generate system reset
129
+ *
130
+ * @return true if watchdog can generate system reset
131
+ */
132
+ bool (*can_reset_system)(AwWdtState *s);
133
+
134
+ /**
135
+ * Check if provided key is valid
136
+ *
137
+ * @value: value written to register
138
+ * @return true if key is valid, false otherwise
139
+ */
140
+ bool (*is_key_valid)(AwWdtState *s, uint32_t val);
141
+
142
+ /**
143
+ * Get current INTV_VALUE setting
144
+ *
145
+ * @return current INTV_VALUE (0-15)
146
+ */
147
+ uint8_t (*get_intv_value)(AwWdtState *s);
148
+};
149
+
150
+#endif /* HW_WATCHDOG_ALLWINNER_WDT_H */
151
diff --git a/hw/watchdog/allwinner-wdt.c b/hw/watchdog/allwinner-wdt.c
152
new file mode 100644
153
index XXXXXXX..XXXXXXX
154
--- /dev/null
155
+++ b/hw/watchdog/allwinner-wdt.c
156
@@ -XXX,XX +XXX,XX @@
157
+/*
158
+ * Allwinner Watchdog emulation
159
+ *
160
+ * Copyright (C) 2023 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
161
+ *
162
+ * This file is derived from Allwinner RTC,
163
+ * by Niek Linnenbank.
164
+ *
165
+ * This program is free software: you can redistribute it and/or modify
166
+ * it under the terms of the GNU General Public License as published by
167
+ * the Free Software Foundation, either version 2 of the License, or
168
+ * (at your option) any later version.
169
+ *
170
+ * This program is distributed in the hope that it will be useful,
171
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
172
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
173
+ * GNU General Public License for more details.
174
+ *
175
+ * You should have received a copy of the GNU General Public License
176
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
177
+ */
178
+
179
+#include "qemu/osdep.h"
180
+#include "qemu/log.h"
181
+#include "qemu/units.h"
182
+#include "qemu/module.h"
183
+#include "trace.h"
184
+#include "hw/sysbus.h"
185
+#include "hw/registerfields.h"
186
+#include "hw/watchdog/allwinner-wdt.h"
187
+#include "sysemu/watchdog.h"
188
+#include "migration/vmstate.h"
189
+
190
+/* WDT registers */
191
+enum {
192
+ REG_IRQ_EN = 0, /* Watchdog interrupt enable */
193
+ REG_IRQ_STA, /* Watchdog interrupt status */
194
+ REG_CTRL, /* Watchdog control register */
195
+ REG_CFG, /* Watchdog configuration register */
196
+ REG_MODE, /* Watchdog mode register */
197
+};
198
+
199
+/* Universal WDT register flags */
200
+#define WDT_RESTART_MASK (1 << 0)
201
+#define WDT_EN_MASK (1 << 0)
202
+
203
+/* sun4i specific WDT register flags */
204
+#define RST_EN_SUN4I_MASK (1 << 1)
205
+#define INTV_VALUE_SUN4I_SHIFT (3)
206
+#define INTV_VALUE_SUN4I_MASK (0xfu << INTV_VALUE_SUN4I_SHIFT)
207
+
208
+/* sun6i specific WDT register flags */
209
+#define RST_EN_SUN6I_MASK (1 << 0)
210
+#define KEY_FIELD_SUN6I_SHIFT (1)
211
+#define KEY_FIELD_SUN6I_MASK (0xfffu << KEY_FIELD_SUN6I_SHIFT)
212
+#define KEY_FIELD_SUN6I (0xA57u)
213
+#define INTV_VALUE_SUN6I_SHIFT (4)
214
+#define INTV_VALUE_SUN6I_MASK (0xfu << INTV_VALUE_SUN6I_SHIFT)
215
+
216
+/* Map of INTV_VALUE to 0.5s units. */
217
+static const uint8_t allwinner_wdt_count_map[] = {
218
+ 1,
219
+ 2,
220
+ 4,
221
+ 6,
222
+ 8,
223
+ 10,
224
+ 12,
225
+ 16,
226
+ 20,
227
+ 24,
228
+ 28,
229
+ 32
230
+};
231
+
232
+/* WDT sun4i register map (offset to name) */
233
+const uint8_t allwinner_wdt_sun4i_regmap[] = {
234
+ [0x0000] = REG_CTRL,
235
+ [0x0004] = REG_MODE,
236
+};
237
+
238
+/* WDT sun6i register map (offset to name) */
239
+const uint8_t allwinner_wdt_sun6i_regmap[] = {
240
+ [0x0000] = REG_IRQ_EN,
241
+ [0x0004] = REG_IRQ_STA,
242
+ [0x0010] = REG_CTRL,
243
+ [0x0014] = REG_CFG,
244
+ [0x0018] = REG_MODE,
245
+};
246
+
247
+static bool allwinner_wdt_sun4i_read(AwWdtState *s, uint32_t offset)
248
+{
249
+ /* no sun4i specific registers currently implemented */
250
+ return false;
251
+}
252
+
253
+static bool allwinner_wdt_sun4i_write(AwWdtState *s, uint32_t offset,
254
+ uint32_t data)
255
+{
256
+ /* no sun4i specific registers currently implemented */
257
+ return false;
258
+}
259
+
260
+static bool allwinner_wdt_sun4i_can_reset_system(AwWdtState *s)
261
+{
262
+ if (s->regs[REG_MODE] & RST_EN_SUN4I_MASK) {
263
+ return true;
264
+ } else {
265
+ return false;
266
+ }
267
+}
268
+
269
+static bool allwinner_wdt_sun4i_is_key_valid(AwWdtState *s, uint32_t val)
270
+{
271
+ /* sun4i has no key */
272
+ return true;
273
+}
274
+
275
+static uint8_t allwinner_wdt_sun4i_get_intv_value(AwWdtState *s)
276
+{
277
+ return ((s->regs[REG_MODE] & INTV_VALUE_SUN4I_MASK) >>
278
+ INTV_VALUE_SUN4I_SHIFT);
279
+}
280
+
281
+static bool allwinner_wdt_sun6i_read(AwWdtState *s, uint32_t offset)
282
+{
283
+ const AwWdtClass *c = AW_WDT_GET_CLASS(s);
284
+
285
+ switch (c->regmap[offset]) {
286
+ case REG_IRQ_EN:
287
+ case REG_IRQ_STA:
288
+ case REG_CFG:
289
+ return true;
290
+ default:
291
+ break;
292
+ }
293
+ return false;
294
+}
295
+
296
+static bool allwinner_wdt_sun6i_write(AwWdtState *s, uint32_t offset,
297
+ uint32_t data)
298
+{
299
+ const AwWdtClass *c = AW_WDT_GET_CLASS(s);
300
+
301
+ switch (c->regmap[offset]) {
302
+ case REG_IRQ_EN:
303
+ case REG_IRQ_STA:
304
+ case REG_CFG:
305
+ return true;
306
+ default:
307
+ break;
308
+ }
309
+ return false;
310
+}
311
+
312
+static bool allwinner_wdt_sun6i_can_reset_system(AwWdtState *s)
313
+{
314
+ if (s->regs[REG_CFG] & RST_EN_SUN6I_MASK) {
315
+ return true;
316
+ } else {
317
+ return false;
318
+ }
319
+}
320
+
321
+static bool allwinner_wdt_sun6i_is_key_valid(AwWdtState *s, uint32_t val)
322
+{
323
+ uint16_t key = (val & KEY_FIELD_SUN6I_MASK) >> KEY_FIELD_SUN6I_SHIFT;
324
+ return (key == KEY_FIELD_SUN6I);
325
+}
326
+
327
+static uint8_t allwinner_wdt_sun6i_get_intv_value(AwWdtState *s)
328
+{
329
+ return ((s->regs[REG_MODE] & INTV_VALUE_SUN6I_MASK) >>
330
+ INTV_VALUE_SUN6I_SHIFT);
331
+}
332
+
333
+static void allwinner_wdt_update_timer(AwWdtState *s)
334
+{
335
+ const AwWdtClass *c = AW_WDT_GET_CLASS(s);
336
+ uint8_t count = c->get_intv_value(s);
337
+
338
+ ptimer_transaction_begin(s->timer);
339
+ ptimer_stop(s->timer);
340
+
341
+ /* Use map to convert. */
342
+ if (count < sizeof(allwinner_wdt_count_map)) {
343
+ ptimer_set_count(s->timer, allwinner_wdt_count_map[count]);
344
+ } else {
345
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: incorrect INTV_VALUE 0x%02x\n",
346
+ __func__, count);
347
+ }
348
+
349
+ ptimer_run(s->timer, 1);
350
+ ptimer_transaction_commit(s->timer);
351
+
352
+ trace_allwinner_wdt_update_timer(count);
353
+}
354
+
355
+static uint64_t allwinner_wdt_read(void *opaque, hwaddr offset,
356
+ unsigned size)
357
+{
358
+ AwWdtState *s = AW_WDT(opaque);
359
+ const AwWdtClass *c = AW_WDT_GET_CLASS(s);
360
+ uint64_t r;
361
+
362
+ if (offset >= c->regmap_size) {
363
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
364
+ __func__, (uint32_t)offset);
365
+ return 0;
366
+ }
367
+
368
+ switch (c->regmap[offset]) {
369
+ case REG_CTRL:
370
+ case REG_MODE:
371
+ r = s->regs[c->regmap[offset]];
372
+ break;
373
+ default:
374
+ if (!c->read(s, offset)) {
375
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented register 0x%04x\n",
376
+ __func__, (uint32_t)offset);
377
+ return 0;
378
+ }
379
+ r = s->regs[c->regmap[offset]];
380
+ break;
381
+ }
382
+
383
+ trace_allwinner_wdt_read(offset, r, size);
384
+
385
+ return r;
386
+}
387
+
388
+static void allwinner_wdt_write(void *opaque, hwaddr offset,
389
+ uint64_t val, unsigned size)
390
+{
391
+ AwWdtState *s = AW_WDT(opaque);
392
+ const AwWdtClass *c = AW_WDT_GET_CLASS(s);
393
+ uint32_t old_val;
394
+
395
+ if (offset >= c->regmap_size) {
396
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
397
+ __func__, (uint32_t)offset);
398
+ return;
399
+ }
400
+
401
+ trace_allwinner_wdt_write(offset, val, size);
402
+
403
+ switch (c->regmap[offset]) {
404
+ case REG_CTRL:
405
+ if (c->is_key_valid(s, val)) {
406
+ if (val & WDT_RESTART_MASK) {
407
+ /* Kick timer */
408
+ allwinner_wdt_update_timer(s);
409
+ }
410
+ }
411
+ break;
412
+ case REG_MODE:
413
+ old_val = s->regs[REG_MODE];
414
+ s->regs[REG_MODE] = (uint32_t)val;
415
+
416
+ /* Check for rising edge on WDOG_MODE_EN */
417
+ if ((s->regs[REG_MODE] & ~old_val) & WDT_EN_MASK) {
418
+ allwinner_wdt_update_timer(s);
419
+ }
420
+ break;
421
+ default:
422
+ if (!c->write(s, offset, val)) {
423
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented register 0x%04x\n",
424
+ __func__, (uint32_t)offset);
425
+ }
426
+ s->regs[c->regmap[offset]] = (uint32_t)val;
427
+ break;
428
+ }
429
+}
430
+
431
+static const MemoryRegionOps allwinner_wdt_ops = {
432
+ .read = allwinner_wdt_read,
433
+ .write = allwinner_wdt_write,
434
+ .endianness = DEVICE_NATIVE_ENDIAN,
435
+ .valid = {
436
+ .min_access_size = 4,
437
+ .max_access_size = 4,
438
+ },
439
+ .impl.min_access_size = 4,
440
+};
441
+
442
+static void allwinner_wdt_expired(void *opaque)
443
+{
444
+ AwWdtState *s = AW_WDT(opaque);
445
+ const AwWdtClass *c = AW_WDT_GET_CLASS(s);
446
+
447
+ bool enabled = s->regs[REG_MODE] & WDT_EN_MASK;
448
+ bool reset_enabled = c->can_reset_system(s);
449
+
450
+ trace_allwinner_wdt_expired(enabled, reset_enabled);
451
+
452
+ /* Perform watchdog action if watchdog is enabled and can trigger reset */
453
+ if (enabled && reset_enabled) {
454
+ watchdog_perform_action();
455
+ }
456
+}
457
+
458
+static void allwinner_wdt_reset_enter(Object *obj, ResetType type)
459
+{
460
+ AwWdtState *s = AW_WDT(obj);
461
+
462
+ trace_allwinner_wdt_reset_enter();
463
+
464
+ /* Clear registers */
465
+ memset(s->regs, 0, sizeof(s->regs));
466
+}
467
+
468
+static const VMStateDescription allwinner_wdt_vmstate = {
469
+ .name = "allwinner-wdt",
470
+ .version_id = 1,
471
+ .minimum_version_id = 1,
472
+ .fields = (VMStateField[]) {
473
+ VMSTATE_PTIMER(timer, AwWdtState),
474
+ VMSTATE_UINT32_ARRAY(regs, AwWdtState, AW_WDT_REGS_NUM),
475
+ VMSTATE_END_OF_LIST()
476
+ }
477
+};
478
+
479
+static void allwinner_wdt_init(Object *obj)
480
+{
481
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
482
+ AwWdtState *s = AW_WDT(obj);
483
+ const AwWdtClass *c = AW_WDT_GET_CLASS(s);
484
+
485
+ /* Memory mapping */
486
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_wdt_ops, s,
487
+ TYPE_AW_WDT, c->regmap_size * 4);
488
+ sysbus_init_mmio(sbd, &s->iomem);
489
+}
490
+
491
+static void allwinner_wdt_realize(DeviceState *dev, Error **errp)
492
+{
493
+ AwWdtState *s = AW_WDT(dev);
494
+
495
+ s->timer = ptimer_init(allwinner_wdt_expired, s,
496
+ PTIMER_POLICY_NO_IMMEDIATE_TRIGGER |
497
+ PTIMER_POLICY_NO_IMMEDIATE_RELOAD |
498
+ PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
499
+
500
+ ptimer_transaction_begin(s->timer);
501
+ /* Set to 2Hz (0.5s period); other periods are multiples of 0.5s. */
502
+ ptimer_set_freq(s->timer, 2);
503
+ ptimer_set_limit(s->timer, 0xff, 1);
504
+ ptimer_transaction_commit(s->timer);
505
+}
506
+
507
+static void allwinner_wdt_class_init(ObjectClass *klass, void *data)
508
+{
509
+ DeviceClass *dc = DEVICE_CLASS(klass);
510
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
511
+
512
+ rc->phases.enter = allwinner_wdt_reset_enter;
513
+ dc->realize = allwinner_wdt_realize;
514
+ dc->vmsd = &allwinner_wdt_vmstate;
515
+}
516
+
517
+static void allwinner_wdt_sun4i_class_init(ObjectClass *klass, void *data)
518
+{
519
+ AwWdtClass *awc = AW_WDT_CLASS(klass);
520
+
521
+ awc->regmap = allwinner_wdt_sun4i_regmap;
522
+ awc->regmap_size = sizeof(allwinner_wdt_sun4i_regmap);
523
+ awc->read = allwinner_wdt_sun4i_read;
524
+ awc->write = allwinner_wdt_sun4i_write;
525
+ awc->can_reset_system = allwinner_wdt_sun4i_can_reset_system;
526
+ awc->is_key_valid = allwinner_wdt_sun4i_is_key_valid;
527
+ awc->get_intv_value = allwinner_wdt_sun4i_get_intv_value;
528
+}
529
+
530
+static void allwinner_wdt_sun6i_class_init(ObjectClass *klass, void *data)
531
+{
532
+ AwWdtClass *awc = AW_WDT_CLASS(klass);
533
+
534
+ awc->regmap = allwinner_wdt_sun6i_regmap;
535
+ awc->regmap_size = sizeof(allwinner_wdt_sun6i_regmap);
536
+ awc->read = allwinner_wdt_sun6i_read;
537
+ awc->write = allwinner_wdt_sun6i_write;
538
+ awc->can_reset_system = allwinner_wdt_sun6i_can_reset_system;
539
+ awc->is_key_valid = allwinner_wdt_sun6i_is_key_valid;
540
+ awc->get_intv_value = allwinner_wdt_sun6i_get_intv_value;
541
+}
542
+
543
+static const TypeInfo allwinner_wdt_info = {
544
+ .name = TYPE_AW_WDT,
545
+ .parent = TYPE_SYS_BUS_DEVICE,
546
+ .instance_init = allwinner_wdt_init,
547
+ .instance_size = sizeof(AwWdtState),
548
+ .class_init = allwinner_wdt_class_init,
549
+ .class_size = sizeof(AwWdtClass),
550
+ .abstract = true,
551
+};
552
+
553
+static const TypeInfo allwinner_wdt_sun4i_info = {
554
+ .name = TYPE_AW_WDT_SUN4I,
555
+ .parent = TYPE_AW_WDT,
556
+ .class_init = allwinner_wdt_sun4i_class_init,
557
+};
558
+
559
+static const TypeInfo allwinner_wdt_sun6i_info = {
560
+ .name = TYPE_AW_WDT_SUN6I,
561
+ .parent = TYPE_AW_WDT,
562
+ .class_init = allwinner_wdt_sun6i_class_init,
563
+};
564
+
565
+static void allwinner_wdt_register(void)
566
+{
567
+ type_register_static(&allwinner_wdt_info);
568
+ type_register_static(&allwinner_wdt_sun4i_info);
569
+ type_register_static(&allwinner_wdt_sun6i_info);
570
+}
571
+
572
+type_init(allwinner_wdt_register)
573
diff --git a/hw/watchdog/Kconfig b/hw/watchdog/Kconfig
574
index XXXXXXX..XXXXXXX 100644
575
--- a/hw/watchdog/Kconfig
576
+++ b/hw/watchdog/Kconfig
577
@@ -XXX,XX +XXX,XX @@ config WDT_IMX2
578
579
config WDT_SBSA
580
bool
581
+
582
+config ALLWINNER_WDT
583
+ bool
584
+ select PTIMER
585
diff --git a/hw/watchdog/meson.build b/hw/watchdog/meson.build
586
index XXXXXXX..XXXXXXX 100644
587
--- a/hw/watchdog/meson.build
588
+++ b/hw/watchdog/meson.build
589
@@ -XXX,XX +XXX,XX @@
590
softmmu_ss.add(files('watchdog.c'))
591
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_WDT', if_true: files('allwinner-wdt.c'))
592
softmmu_ss.add(when: 'CONFIG_CMSDK_APB_WATCHDOG', if_true: files('cmsdk-apb-watchdog.c'))
593
softmmu_ss.add(when: 'CONFIG_WDT_IB6300ESB', if_true: files('wdt_i6300esb.c'))
594
softmmu_ss.add(when: 'CONFIG_WDT_IB700', if_true: files('wdt_ib700.c'))
595
diff --git a/hw/watchdog/trace-events b/hw/watchdog/trace-events
596
index XXXXXXX..XXXXXXX 100644
597
--- a/hw/watchdog/trace-events
598
+++ b/hw/watchdog/trace-events
599
@@ -XXX,XX +XXX,XX @@
600
# See docs/devel/tracing.rst for syntax documentation.
601
602
+# allwinner-wdt.c
603
+allwinner_wdt_read(uint64_t offset, uint64_t data, unsigned size) "Allwinner watchdog read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
604
+allwinner_wdt_write(uint64_t offset, uint64_t data, unsigned size) "Allwinner watchdog write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
605
+allwinner_wdt_reset_enter(void) "Allwinner watchdog: reset"
606
+allwinner_wdt_update_timer(uint8_t count) "Allwinner watchdog: count %" PRIu8
607
+allwinner_wdt_expired(bool enabled, bool reset_enabled) "Allwinner watchdog: enabled %u reset_enabled %u"
608
+
609
# cmsdk-apb-watchdog.c
610
cmsdk_apb_watchdog_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB watchdog read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
611
cmsdk_apb_watchdog_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB watchdog write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
612
--
613
2.34.1
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Anastasia Belova <abelova@astralinux.ru>
2
2
3
Fix issue reported by Coverity.
3
1 << 31 is casted to uint64_t while bitwise and with val.
4
So this value may become 0xffffffff80000000 but only
5
31th "start" bit is required.
4
6
5
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
7
This is not possible in practice because the MemoryRegionOps
6
Message-id: 168070611775.20412.2883242077302841473-1@git.sr.ht
8
uses the default max access size of 4 bytes and so none
9
of the upper bytes of val will be set, but the bitfield
10
extract API is clearer anyway.
11
12
Use the bitfield extract() API instead.
13
14
Found by Linux Verification Center (linuxtesting.org) with SVACE.
15
16
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
17
Message-id: 20241220125429.7552-1-abelova@astralinux.ru
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
[PMM: add clarification to commit message]
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
21
---
10
hw/timer/imx_epit.c | 2 +-
22
hw/misc/arm_sysctl.c | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
23
1 file changed, 1 insertion(+), 1 deletion(-)
12
24
13
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
25
diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c
14
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/timer/imx_epit.c
27
--- a/hw/misc/arm_sysctl.c
16
+++ b/hw/timer/imx_epit.c
28
+++ b/hw/misc/arm_sysctl.c
17
@@ -XXX,XX +XXX,XX @@ static void imx_epit_update_compare_timer(IMXEPITState *s)
29
@@ -XXX,XX +XXX,XX @@ static void arm_sysctl_write(void *opaque, hwaddr offset,
18
* the compare value. Otherwise it may fire at most once in the
30
* as zero.
19
* current round.
20
*/
31
*/
21
- bool is_oneshot = (limit >= s->cmp);
32
s->sys_cfgctrl = val & ~((3 << 18) | (1 << 31));
22
+ is_oneshot = (limit >= s->cmp);
33
- if (val & (1 << 31)) {
23
if (counter >= s->cmp) {
34
+ if (extract64(val, 31, 1)) {
24
/* The compare timer fires in the current round. */
35
/* Start bit set -- actually do something */
25
counter -= s->cmp;
36
unsigned int dcc = extract32(s->sys_cfgctrl, 26, 4);
37
unsigned int function = extract32(s->sys_cfgctrl, 20, 6);
26
--
38
--
27
2.34.1
39
2.34.1
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Tigran Sogomonian <tsogomonian@astralinux.ru>
2
2
3
The SOC on i.MX6UL and i.MX7 has 2 Ethernet interfaces. The PHY on each may
3
The value of an arithmetic expression
4
be connected to separate MDIO busses, or both may be connected on the same
4
'rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION' is a subject
5
MDIO bus using different PHY addresses. Commit 461c51ad4275 ("Add a phy-num
5
to overflow because its operands are not cast to
6
property to the i.MX FEC emulator") added support for specifying PHY
6
a larger data type before performing arithmetic. Thus, need
7
addresses, but it did not provide support for linking the second PHY on
7
to cast rpm to uint64_t.
8
a given MDIO bus to the other Ethernet interface.
9
8
10
To be able to support two PHY instances on a single MDIO bus, two properties
9
Found by Linux Verification Center (linuxtesting.org) with SVACE.
11
are needed: First, there needs to be a flag indicating if the MDIO bus on
12
a given Ethernet interface is connected. If not, attempts to read from this
13
bus must always return 0xffff. Implement this property as phy-connected.
14
Second, if the MDIO bus on an interface is active, it needs a link to the
15
consumer interface to be able to provide PHY access for it. Implement this
16
property as phy-consumer.
17
10
18
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
11
Signed-off-by: Tigran Sogomonian <tsogomonian@astralinux.ru>
19
Message-id: 20230315145248.1639364-2-linux@roeck-us.net
12
Reviewed-by: Patrick Leis <venture@google.com>
20
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Hao Wu <wuhaotsh@google.com>
14
Message-id: 20241226130311.1349-1-tsogomonian@astralinux.ru
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
16
---
23
include/hw/net/imx_fec.h | 2 ++
17
hw/misc/npcm7xx_mft.c | 5 +++--
24
hw/net/imx_fec.c | 27 +++++++++++++++++++++++----
18
1 file changed, 3 insertions(+), 2 deletions(-)
25
2 files changed, 25 insertions(+), 4 deletions(-)
26
19
27
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
20
diff --git a/hw/misc/npcm7xx_mft.c b/hw/misc/npcm7xx_mft.c
28
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/net/imx_fec.h
22
--- a/hw/misc/npcm7xx_mft.c
30
+++ b/include/hw/net/imx_fec.h
23
+++ b/hw/misc/npcm7xx_mft.c
31
@@ -XXX,XX +XXX,XX @@ struct IMXFECState {
24
@@ -XXX,XX +XXX,XX @@ static NPCM7xxMFTCaptureState npcm7xx_mft_compute_cnt(
32
uint32_t phy_int;
25
* RPM = revolution/min. The time for one revlution (in ns) is
33
uint32_t phy_int_mask;
26
* MINUTE_TO_NANOSECOND / RPM.
34
uint32_t phy_num;
27
*/
35
+ bool phy_connected;
28
- count = clock_ns_to_ticks(clock, (60 * NANOSECONDS_PER_SECOND) /
36
+ struct IMXFECState *phy_consumer;
29
- (rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION));
37
30
+ count = clock_ns_to_ticks(clock,
38
bool is_fec;
31
+ (uint64_t)(60 * NANOSECONDS_PER_SECOND) /
39
32
+ ((uint64_t)rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION));
40
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/net/imx_fec.c
43
+++ b/hw/net/imx_fec.c
44
@@ -XXX,XX +XXX,XX @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)
45
uint32_t val;
46
uint32_t phy = reg / 32;
47
48
- if (phy != s->phy_num) {
49
- trace_imx_phy_read_num(phy, s->phy_num);
50
+ if (!s->phy_connected) {
51
return 0xffff;
52
}
33
}
53
34
54
+ if (phy != s->phy_num) {
35
if (count > NPCM7XX_MFT_MAX_CNT) {
55
+ if (s->phy_consumer && phy == s->phy_consumer->phy_num) {
56
+ s = s->phy_consumer;
57
+ } else {
58
+ trace_imx_phy_read_num(phy, s->phy_num);
59
+ return 0xffff;
60
+ }
61
+ }
62
+
63
reg %= 32;
64
65
switch (reg) {
66
@@ -XXX,XX +XXX,XX @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)
67
{
68
uint32_t phy = reg / 32;
69
70
- if (phy != s->phy_num) {
71
- trace_imx_phy_write_num(phy, s->phy_num);
72
+ if (!s->phy_connected) {
73
return;
74
}
75
76
+ if (phy != s->phy_num) {
77
+ if (s->phy_consumer && phy == s->phy_consumer->phy_num) {
78
+ s = s->phy_consumer;
79
+ } else {
80
+ trace_imx_phy_write_num(phy, s->phy_num);
81
+ return;
82
+ }
83
+ }
84
+
85
reg %= 32;
86
87
trace_imx_phy_write(val, phy, reg);
88
@@ -XXX,XX +XXX,XX @@ static Property imx_eth_properties[] = {
89
DEFINE_NIC_PROPERTIES(IMXFECState, conf),
90
DEFINE_PROP_UINT32("tx-ring-num", IMXFECState, tx_ring_num, 1),
91
DEFINE_PROP_UINT32("phy-num", IMXFECState, phy_num, 0),
92
+ DEFINE_PROP_BOOL("phy-connected", IMXFECState, phy_connected, true),
93
+ DEFINE_PROP_LINK("phy-consumer", IMXFECState, phy_consumer, TYPE_IMX_FEC,
94
+ IMXFECState *),
95
DEFINE_PROP_END_OF_LIST(),
96
};
97
98
--
36
--
99
2.34.1
37
2.34.1
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The Cortex-A7 core is only available when TCG is enabled (see
3
Re-indent ASM comments adding the 'loop:' label.
4
commit 80485d88f9 "target/arm: Restrict v7A TCG cpus to TCG accel").
5
4
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230405100848.76145-3-philmd@linaro.org
7
Reviewed-by: Fabiano Rosas <farosas@suse.de>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
9
---
11
hw/arm/virt.c | 2 ++
10
tests/qtest/boot-serial-test.c | 18 +++++++++---------
12
1 file changed, 2 insertions(+)
11
1 file changed, 9 insertions(+), 9 deletions(-)
13
12
14
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
13
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/virt.c
15
--- a/tests/qtest/boot-serial-test.c
17
+++ b/hw/arm/virt.c
16
+++ b/tests/qtest/boot-serial-test.c
18
@@ -XXX,XX +XXX,XX @@ static const int a15irqmap[] = {
17
@@ -XXX,XX +XXX,XX @@ static const uint8_t kernel_plml605[] = {
19
};
18
};
20
19
21
static const char *valid_cpus[] = {
20
static const uint8_t bios_raspi2[] = {
22
+#ifdef CONFIG_TCG
21
- 0x08, 0x30, 0x9f, 0xe5, /* ldr r3,[pc,#8] Get base */
23
ARM_CPU_TYPE_NAME("cortex-a7"),
22
- 0x54, 0x20, 0xa0, 0xe3, /* mov r2,#'T' */
24
+#endif
23
- 0x00, 0x20, 0xc3, 0xe5, /* strb r2,[r3] */
25
ARM_CPU_TYPE_NAME("cortex-a15"),
24
- 0xfb, 0xff, 0xff, 0xea, /* b loop */
26
ARM_CPU_TYPE_NAME("cortex-a35"),
25
- 0x00, 0x10, 0x20, 0x3f, /* 0x3f201000 = UART0 base addr */
27
ARM_CPU_TYPE_NAME("cortex-a53"),
26
+ 0x08, 0x30, 0x9f, 0xe5, /* loop: ldr r3, [pc, #8] Get &UART0 */
27
+ 0x54, 0x20, 0xa0, 0xe3, /* mov r2, #'T' */
28
+ 0x00, 0x20, 0xc3, 0xe5, /* strb r2, [r3] *TXDAT = 'T' */
29
+ 0xfb, 0xff, 0xff, 0xea, /* b -12 (loop) */
30
+ 0x00, 0x10, 0x20, 0x3f, /* UART0: 0x3f201000 */
31
};
32
33
static const uint8_t kernel_aarch64[] = {
34
- 0x81, 0x0a, 0x80, 0x52, /* mov w1, #0x54 */
35
- 0x02, 0x20, 0xa1, 0xd2, /* mov x2, #0x9000000 */
36
- 0x41, 0x00, 0x00, 0x39, /* strb w1, [x2] */
37
- 0xfd, 0xff, 0xff, 0x17, /* b -12 (loop) */
38
+ 0x81, 0x0a, 0x80, 0x52, /* loop: mov w1, #'T' */
39
+ 0x02, 0x20, 0xa1, 0xd2, /* mov x2, #0x9000000 Load UART0 */
40
+ 0x41, 0x00, 0x00, 0x39, /* strb w1, [x2] *TXDAT = 'T' */
41
+ 0xfd, 0xff, 0xff, 0x17, /* b -12 (loop) */
42
};
43
44
static const uint8_t kernel_nrf51[] = {
28
--
45
--
29
2.34.1
46
2.34.1
30
47
31
48
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Missed in commit 80485d88f9 ("target/arm: Restrict
3
Since registers are not modified, we don't need
4
v7A TCG cpus to TCG accel").
4
to refill their values. Directly jump to the previous
5
store instruction to keep filling the TXDAT register.
6
7
The equivalent C code remains:
8
9
while (true) {
10
*UART_DATA = 'T';
11
}
5
12
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230405100848.76145-2-philmd@linaro.org
15
Reviewed-by: Fabiano Rosas <farosas@suse.de>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
17
---
11
target/arm/kvm-consts.h | 9 +++------
18
tests/qtest/boot-serial-test.c | 12 ++++++------
12
target/arm/cpu_tcg.c | 2 --
19
1 file changed, 6 insertions(+), 6 deletions(-)
13
2 files changed, 3 insertions(+), 8 deletions(-)
14
20
15
diff --git a/target/arm/kvm-consts.h b/target/arm/kvm-consts.h
21
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/kvm-consts.h
23
--- a/tests/qtest/boot-serial-test.c
18
+++ b/target/arm/kvm-consts.h
24
+++ b/tests/qtest/boot-serial-test.c
19
@@ -XXX,XX +XXX,XX @@ MISMATCH_CHECK(QEMU_PSCI_RET_INTERNAL_FAILURE, PSCI_RET_INTERNAL_FAILURE);
25
@@ -XXX,XX +XXX,XX @@ static const uint8_t kernel_plml605[] = {
20
MISMATCH_CHECK(QEMU_PSCI_RET_NOT_PRESENT, PSCI_RET_NOT_PRESENT);
26
};
21
MISMATCH_CHECK(QEMU_PSCI_RET_DISABLED, PSCI_RET_DISABLED);
27
22
28
static const uint8_t bios_raspi2[] = {
23
-/* Note that KVM uses overlapping values for AArch32 and AArch64
29
- 0x08, 0x30, 0x9f, 0xe5, /* loop: ldr r3, [pc, #8] Get &UART0 */
24
- * target CPU numbers. AArch32 targets:
30
+ 0x08, 0x30, 0x9f, 0xe5, /* ldr r3, [pc, #8] Get &UART0 */
25
+/*
31
0x54, 0x20, 0xa0, 0xe3, /* mov r2, #'T' */
26
+ * Note that KVM uses overlapping values for AArch32 and AArch64
32
- 0x00, 0x20, 0xc3, 0xe5, /* strb r2, [r3] *TXDAT = 'T' */
27
+ * target CPU numbers. AArch64 targets:
33
- 0xfb, 0xff, 0xff, 0xea, /* b -12 (loop) */
28
*/
34
+ 0x00, 0x20, 0xc3, 0xe5, /* loop: strb r2, [r3] *TXDAT = 'T' */
29
-#define QEMU_KVM_ARM_TARGET_CORTEX_A15 0
35
+ 0xff, 0xff, 0xff, 0xea, /* b -4 (loop) */
30
-#define QEMU_KVM_ARM_TARGET_CORTEX_A7 1
36
0x00, 0x10, 0x20, 0x3f, /* UART0: 0x3f201000 */
31
-
37
};
32
-/* AArch64 targets: */
38
33
#define QEMU_KVM_ARM_TARGET_AEM_V8 0
39
static const uint8_t kernel_aarch64[] = {
34
#define QEMU_KVM_ARM_TARGET_FOUNDATION_V8 1
40
- 0x81, 0x0a, 0x80, 0x52, /* loop: mov w1, #'T' */
35
#define QEMU_KVM_ARM_TARGET_CORTEX_A57 2
41
+ 0x81, 0x0a, 0x80, 0x52, /* mov w1, #'T' */
36
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
42
0x02, 0x20, 0xa1, 0xd2, /* mov x2, #0x9000000 Load UART0 */
37
index XXXXXXX..XXXXXXX 100644
43
- 0x41, 0x00, 0x00, 0x39, /* strb w1, [x2] *TXDAT = 'T' */
38
--- a/target/arm/cpu_tcg.c
44
- 0xfd, 0xff, 0xff, 0x17, /* b -12 (loop) */
39
+++ b/target/arm/cpu_tcg.c
45
+ 0x41, 0x00, 0x00, 0x39, /* loop: strb w1, [x2] *TXDAT = 'T' */
40
@@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj)
46
+ 0xff, 0xff, 0xff, 0x17, /* b -4 (loop) */
41
set_feature(&cpu->env, ARM_FEATURE_EL2);
47
};
42
set_feature(&cpu->env, ARM_FEATURE_EL3);
48
43
set_feature(&cpu->env, ARM_FEATURE_PMU);
49
static const uint8_t kernel_nrf51[] = {
44
- cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A7;
45
cpu->midr = 0x410fc075;
46
cpu->reset_fpsid = 0x41023075;
47
cpu->isar.mvfr0 = 0x10110222;
48
@@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj)
49
set_feature(&cpu->env, ARM_FEATURE_EL2);
50
set_feature(&cpu->env, ARM_FEATURE_EL3);
51
set_feature(&cpu->env, ARM_FEATURE_PMU);
52
- cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A15;
53
/* r4p0 cpu, not requiring expensive tlb flush errata */
54
cpu->midr = 0x414fc0f0;
55
cpu->revidr = 0x0;
56
--
50
--
57
2.34.1
51
2.34.1
58
52
59
53
diff view generated by jsdifflib
1
In rST markup syntax, the inline markup (*italics*, **bold** and
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
``monospaced``) must be separated from the surrending text by
3
non-word characters, otherwise it is not interpreted as markup.
4
To force interpretation as markup in the middle of a word,
5
you need to use a backslash-escaped space (which will not
6
appear as a space in the output).
7
2
8
Fix a missing backslash-space in this file, which meant that the ``
3
In the next commit we are going to use a different value
9
after "select" was output literally and the monospacing was
4
for the $w1 register, maintaining the same $x2 value. In
10
incorrectly extended all the way to the end of the next monospaced
5
order to keep the next commit trivial to review, set $x2
11
word.
6
before $w1.
12
7
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Fabiano Rosas <farosas@suse.de>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
Message-id: 20230411105424.3994585-1-peter.maydell@linaro.org
17
---
12
---
18
docs/devel/kconfig.rst | 2 +-
13
tests/qtest/boot-serial-test.c | 2 +-
19
1 file changed, 1 insertion(+), 1 deletion(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
20
15
21
diff --git a/docs/devel/kconfig.rst b/docs/devel/kconfig.rst
16
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
22
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
23
--- a/docs/devel/kconfig.rst
18
--- a/tests/qtest/boot-serial-test.c
24
+++ b/docs/devel/kconfig.rst
19
+++ b/tests/qtest/boot-serial-test.c
25
@@ -XXX,XX +XXX,XX @@ or commenting out lines in the second group.
20
@@ -XXX,XX +XXX,XX @@ static const uint8_t bios_raspi2[] = {
26
21
};
27
It is also possible to run QEMU's configure script with the
22
28
``--without-default-devices`` option. When this is done, everything defaults
23
static const uint8_t kernel_aarch64[] = {
29
-to ``n`` unless it is ``select``ed or explicitly switched on in the
24
- 0x81, 0x0a, 0x80, 0x52, /* mov w1, #'T' */
30
+to ``n`` unless it is ``select``\ ed or explicitly switched on in the
25
0x02, 0x20, 0xa1, 0xd2, /* mov x2, #0x9000000 Load UART0 */
31
``.mak`` files. In other words, ``default`` and ``imply`` directives
26
+ 0x81, 0x0a, 0x80, 0x52, /* mov w1, #'T' */
32
are disabled. When QEMU is built with this option, the user will probably
27
0x41, 0x00, 0x00, 0x39, /* loop: strb w1, [x2] *TXDAT = 'T' */
33
want to change some lines in the first group, for example like this::
28
0xff, 0xff, 0xff, 0x17, /* b -4 (loop) */
29
};
34
--
30
--
35
2.34.1
31
2.34.1
36
32
37
33
diff view generated by jsdifflib
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
kvm_arm_init_debug() used to be called several times on a SMP system as
3
The tests using the PL011 UART of the virt and raspi machines
4
kvm_arch_init_vcpu() calls it. Move the call to kvm_arch_init() to make
4
weren't properly enabling the UART and its transmitter previous
5
sure it will be called only once; otherwise it will overwrite pointers
5
to sending characters. Follow the PL011 manual initialization
6
to memory allocated with the previous call and leak it.
6
recommendation by setting the proper bits of the control register.
7
7
8
Fixes: e4482ab7e3 ("target-arm: kvm - add support for HW assisted debug")
8
Update the ASM code prefixing:
9
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
10
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
10
*UART_CTRL = UART_ENABLE | TX_ENABLE;
11
Message-id: 20230405153644.25300-1-akihiko.odaki@daynix.com
11
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
to:
13
14
while (true) {
15
*UART_DATA = 'T';
16
}
17
18
Note, since commit 51b61dd4d56 ("hw/char/pl011: Warn when using
19
disabled transmitter") incomplete PL011 initialization can be
20
logged using the '-d guest_errors' command line option.
21
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
25
---
15
target/arm/kvm_arm.h | 8 ++++++++
26
tests/qtest/boot-serial-test.c | 7 ++++++-
16
target/arm/kvm.c | 2 ++
27
1 file changed, 6 insertions(+), 1 deletion(-)
17
target/arm/kvm64.c | 18 ++++--------------
18
3 files changed, 14 insertions(+), 14 deletions(-)
19
28
20
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
29
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
21
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/kvm_arm.h
31
--- a/tests/qtest/boot-serial-test.c
23
+++ b/target/arm/kvm_arm.h
32
+++ b/tests/qtest/boot-serial-test.c
24
@@ -XXX,XX +XXX,XX @@
33
@@ -XXX,XX +XXX,XX @@ static const uint8_t kernel_plml605[] = {
25
#define KVM_ARM_VGIC_V2 (1 << 0)
34
};
26
#define KVM_ARM_VGIC_V3 (1 << 1)
35
27
36
static const uint8_t bios_raspi2[] = {
28
+/**
37
- 0x08, 0x30, 0x9f, 0xe5, /* ldr r3, [pc, #8] Get &UART0 */
29
+ * kvm_arm_init_debug() - initialize guest debug capabilities
38
+ 0x10, 0x30, 0x9f, 0xe5, /* ldr r3, [pc, #16] Get &UART0 */
30
+ * @s: KVMState
39
+ 0x10, 0x20, 0x9f, 0xe5, /* ldr r2, [pc, #16] Get &CR */
31
+ *
40
+ 0xb0, 0x23, 0xc3, 0xe1, /* strh r2, [r3, #48] Set CR */
32
+ * Should be called only once before using guest debug capabilities.
41
0x54, 0x20, 0xa0, 0xe3, /* mov r2, #'T' */
33
+ */
42
0x00, 0x20, 0xc3, 0xe5, /* loop: strb r2, [r3] *TXDAT = 'T' */
34
+void kvm_arm_init_debug(KVMState *s);
43
0xff, 0xff, 0xff, 0xea, /* b -4 (loop) */
35
+
44
0x00, 0x10, 0x20, 0x3f, /* UART0: 0x3f201000 */
36
/**
45
+ 0x01, 0x01, 0x00, 0x00, /* CR: 0x101 = UARTEN|TXE */
37
* kvm_arm_vcpu_init:
46
};
38
* @cs: CPUState
47
39
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
48
static const uint8_t kernel_aarch64[] = {
40
index XXXXXXX..XXXXXXX 100644
49
0x02, 0x20, 0xa1, 0xd2, /* mov x2, #0x9000000 Load UART0 */
41
--- a/target/arm/kvm.c
50
+ 0x21, 0x20, 0x80, 0x52, /* mov w1, 0x101 CR = UARTEN|TXE */
42
+++ b/target/arm/kvm.c
51
+ 0x41, 0x60, 0x00, 0x79, /* strh w1, [x2, #48] Set CR */
43
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init(MachineState *ms, KVMState *s)
52
0x81, 0x0a, 0x80, 0x52, /* mov w1, #'T' */
44
}
53
0x41, 0x00, 0x00, 0x39, /* loop: strb w1, [x2] *TXDAT = 'T' */
45
}
54
0xff, 0xff, 0xff, 0x17, /* b -4 (loop) */
46
47
+ kvm_arm_init_debug(s);
48
+
49
return ret;
50
}
51
52
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/kvm64.c
55
+++ b/target/arm/kvm64.c
56
@@ -XXX,XX +XXX,XX @@ GArray *hw_breakpoints, *hw_watchpoints;
57
#define get_hw_bp(i) (&g_array_index(hw_breakpoints, HWBreakpoint, i))
58
#define get_hw_wp(i) (&g_array_index(hw_watchpoints, HWWatchpoint, i))
59
60
-/**
61
- * kvm_arm_init_debug() - check for guest debug capabilities
62
- * @cs: CPUState
63
- *
64
- * kvm_check_extension returns the number of debug registers we have
65
- * or 0 if we have none.
66
- *
67
- */
68
-static void kvm_arm_init_debug(CPUState *cs)
69
+void kvm_arm_init_debug(KVMState *s)
70
{
71
- have_guest_debug = kvm_check_extension(cs->kvm_state,
72
+ have_guest_debug = kvm_check_extension(s,
73
KVM_CAP_SET_GUEST_DEBUG);
74
75
- max_hw_wps = kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_HW_WPS);
76
+ max_hw_wps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_WPS);
77
hw_watchpoints = g_array_sized_new(true, true,
78
sizeof(HWWatchpoint), max_hw_wps);
79
80
- max_hw_bps = kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_HW_BPS);
81
+ max_hw_bps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_BPS);
82
hw_breakpoints = g_array_sized_new(true, true,
83
sizeof(HWBreakpoint), max_hw_bps);
84
return;
85
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
86
}
87
cpu->mp_affinity = mpidr & ARM64_AFFINITY_MASK;
88
89
- kvm_arm_init_debug(cs);
90
-
91
/* Check whether user space can specify guest syndrome value */
92
kvm_arm_init_serror_injection(cs);
93
94
--
55
--
95
2.34.1
56
2.34.1
96
57
97
58
diff view generated by jsdifflib
1
We already pass merge_syn_data_abort() two fields from the
1
helper.c includes some small TCG helper functions used for mostly
2
ARMMMUFaultInfo struct, and we're about to want to use a third field.
2
arithmetic instructions. These are TCG only and there's no need for
3
Refactor to just pass a pointer to the fault info.
3
them to be in the large and unwieldy helper.c. Move them out to
4
their own source file in the tcg/ subdirectory, together with the
5
op_addsub.h multiply-included template header that they use.
6
7
Since we are moving op_addsub.h, we take the opportunity to
8
give it a name which matches our convention for files which
9
are not true header files but which are #included from other
10
C files: op_addsub.c.inc.
11
12
(Ironically, this means that helper.c no longer contains
13
any TCG helper function definitions at all.)
4
14
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
17
Message-id: 20250110131211.2546314-1-peter.maydell@linaro.org
8
Message-id: 20230331145045.2584941-2-peter.maydell@linaro.org
18
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
---
19
---
10
target/arm/tcg/tlb_helper.c | 15 +++++++--------
20
target/arm/helper.c | 285 -----------------
11
1 file changed, 7 insertions(+), 8 deletions(-)
21
target/arm/tcg/arith_helper.c | 296 ++++++++++++++++++
22
.../arm/{op_addsub.h => tcg/op_addsub.c.inc} | 0
23
target/arm/tcg/meson.build | 1 +
24
4 files changed, 297 insertions(+), 285 deletions(-)
25
create mode 100644 target/arm/tcg/arith_helper.c
26
rename target/arm/{op_addsub.h => tcg/op_addsub.c.inc} (100%)
12
27
13
diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c
28
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/tcg/tlb_helper.c
30
--- a/target/arm/helper.c
16
+++ b/target/arm/tcg/tlb_helper.c
31
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx)
32
@@ -XXX,XX +XXX,XX @@
33
#include "qemu/main-loop.h"
34
#include "qemu/timer.h"
35
#include "qemu/bitops.h"
36
-#include "qemu/crc32c.h"
37
#include "qemu/qemu-print.h"
38
#include "exec/exec-all.h"
39
#include "exec/translation-block.h"
40
-#include <zlib.h> /* for crc32 */
41
#include "hw/irq.h"
42
#include "system/cpu-timers.h"
43
#include "system/kvm.h"
44
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
45
};
18
}
46
}
19
47
20
static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
48
-/*
21
+ ARMMMUFaultInfo *fi,
49
- * Note that signed overflow is undefined in C. The following routines are
22
unsigned int target_el,
50
- * careful to use unsigned types where modulo arithmetic is required.
23
- bool same_el, bool ea,
51
- * Failure to do so _will_ break on newer gcc.
24
- bool s1ptw, bool is_write,
52
- */
25
+ bool same_el, bool is_write,
53
-
26
int fsc)
54
-/* Signed saturating arithmetic. */
27
{
55
-
28
uint32_t syn;
56
-/* Perform 16-bit signed saturating addition. */
29
@@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
57
-static inline uint16_t add16_sat(uint16_t a, uint16_t b)
30
* ISS encoding for an exception from a Data Abort, the
58
-{
31
* ISV field.
59
- uint16_t res;
32
*/
60
-
33
- if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) {
61
- res = a + b;
34
+ if (!(template_syn & ARM_EL_ISV) || target_el != 2 || fi->s1ptw) {
62
- if (((res ^ a) & 0x8000) && !((a ^ b) & 0x8000)) {
35
syn = syn_data_abort_no_iss(same_el, 0,
63
- if (a & 0x8000) {
36
- ea, 0, s1ptw, is_write, fsc);
64
- res = 0x8000;
37
+ fi->ea, 0, fi->s1ptw, is_write, fsc);
65
- } else {
38
} else {
66
- res = 0x7fff;
39
/*
67
- }
40
* Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template
68
- }
41
@@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
69
- return res;
42
*/
70
-}
43
syn = syn_data_abort_with_iss(same_el,
71
-
44
0, 0, 0, 0, 0,
72
-/* Perform 8-bit signed saturating addition. */
45
- ea, 0, s1ptw, is_write, fsc,
73
-static inline uint8_t add8_sat(uint8_t a, uint8_t b)
46
+ fi->ea, 0, fi->s1ptw, is_write, fsc,
74
-{
47
true);
75
- uint8_t res;
48
/* Merge the runtime syndrome with the template syndrome. */
76
-
49
syn |= template_syn;
77
- res = a + b;
50
@@ -XXX,XX +XXX,XX @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr,
78
- if (((res ^ a) & 0x80) && !((a ^ b) & 0x80)) {
51
syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc);
79
- if (a & 0x80) {
52
exc = EXCP_PREFETCH_ABORT;
80
- res = 0x80;
53
} else {
81
- } else {
54
- syn = merge_syn_data_abort(env->exception.syndrome, target_el,
82
- res = 0x7f;
55
- same_el, fi->ea, fi->s1ptw,
83
- }
56
- access_type == MMU_DATA_STORE,
84
- }
57
+ syn = merge_syn_data_abort(env->exception.syndrome, fi, target_el,
85
- return res;
58
+ same_el, access_type == MMU_DATA_STORE,
86
-}
59
fsc);
87
-
60
if (access_type == MMU_DATA_STORE
88
-/* Perform 16-bit signed saturating subtraction. */
61
&& arm_feature(env, ARM_FEATURE_V6)) {
89
-static inline uint16_t sub16_sat(uint16_t a, uint16_t b)
90
-{
91
- uint16_t res;
92
-
93
- res = a - b;
94
- if (((res ^ a) & 0x8000) && ((a ^ b) & 0x8000)) {
95
- if (a & 0x8000) {
96
- res = 0x8000;
97
- } else {
98
- res = 0x7fff;
99
- }
100
- }
101
- return res;
102
-}
103
-
104
-/* Perform 8-bit signed saturating subtraction. */
105
-static inline uint8_t sub8_sat(uint8_t a, uint8_t b)
106
-{
107
- uint8_t res;
108
-
109
- res = a - b;
110
- if (((res ^ a) & 0x80) && ((a ^ b) & 0x80)) {
111
- if (a & 0x80) {
112
- res = 0x80;
113
- } else {
114
- res = 0x7f;
115
- }
116
- }
117
- return res;
118
-}
119
-
120
-#define ADD16(a, b, n) RESULT(add16_sat(a, b), n, 16);
121
-#define SUB16(a, b, n) RESULT(sub16_sat(a, b), n, 16);
122
-#define ADD8(a, b, n) RESULT(add8_sat(a, b), n, 8);
123
-#define SUB8(a, b, n) RESULT(sub8_sat(a, b), n, 8);
124
-#define PFX q
125
-
126
-#include "op_addsub.h"
127
-
128
-/* Unsigned saturating arithmetic. */
129
-static inline uint16_t add16_usat(uint16_t a, uint16_t b)
130
-{
131
- uint16_t res;
132
- res = a + b;
133
- if (res < a) {
134
- res = 0xffff;
135
- }
136
- return res;
137
-}
138
-
139
-static inline uint16_t sub16_usat(uint16_t a, uint16_t b)
140
-{
141
- if (a > b) {
142
- return a - b;
143
- } else {
144
- return 0;
145
- }
146
-}
147
-
148
-static inline uint8_t add8_usat(uint8_t a, uint8_t b)
149
-{
150
- uint8_t res;
151
- res = a + b;
152
- if (res < a) {
153
- res = 0xff;
154
- }
155
- return res;
156
-}
157
-
158
-static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
159
-{
160
- if (a > b) {
161
- return a - b;
162
- } else {
163
- return 0;
164
- }
165
-}
166
-
167
-#define ADD16(a, b, n) RESULT(add16_usat(a, b), n, 16);
168
-#define SUB16(a, b, n) RESULT(sub16_usat(a, b), n, 16);
169
-#define ADD8(a, b, n) RESULT(add8_usat(a, b), n, 8);
170
-#define SUB8(a, b, n) RESULT(sub8_usat(a, b), n, 8);
171
-#define PFX uq
172
-
173
-#include "op_addsub.h"
174
-
175
-/* Signed modulo arithmetic. */
176
-#define SARITH16(a, b, n, op) do { \
177
- int32_t sum; \
178
- sum = (int32_t)(int16_t)(a) op (int32_t)(int16_t)(b); \
179
- RESULT(sum, n, 16); \
180
- if (sum >= 0) \
181
- ge |= 3 << (n * 2); \
182
- } while (0)
183
-
184
-#define SARITH8(a, b, n, op) do { \
185
- int32_t sum; \
186
- sum = (int32_t)(int8_t)(a) op (int32_t)(int8_t)(b); \
187
- RESULT(sum, n, 8); \
188
- if (sum >= 0) \
189
- ge |= 1 << n; \
190
- } while (0)
191
-
192
-
193
-#define ADD16(a, b, n) SARITH16(a, b, n, +)
194
-#define SUB16(a, b, n) SARITH16(a, b, n, -)
195
-#define ADD8(a, b, n) SARITH8(a, b, n, +)
196
-#define SUB8(a, b, n) SARITH8(a, b, n, -)
197
-#define PFX s
198
-#define ARITH_GE
199
-
200
-#include "op_addsub.h"
201
-
202
-/* Unsigned modulo arithmetic. */
203
-#define ADD16(a, b, n) do { \
204
- uint32_t sum; \
205
- sum = (uint32_t)(uint16_t)(a) + (uint32_t)(uint16_t)(b); \
206
- RESULT(sum, n, 16); \
207
- if ((sum >> 16) == 1) \
208
- ge |= 3 << (n * 2); \
209
- } while (0)
210
-
211
-#define ADD8(a, b, n) do { \
212
- uint32_t sum; \
213
- sum = (uint32_t)(uint8_t)(a) + (uint32_t)(uint8_t)(b); \
214
- RESULT(sum, n, 8); \
215
- if ((sum >> 8) == 1) \
216
- ge |= 1 << n; \
217
- } while (0)
218
-
219
-#define SUB16(a, b, n) do { \
220
- uint32_t sum; \
221
- sum = (uint32_t)(uint16_t)(a) - (uint32_t)(uint16_t)(b); \
222
- RESULT(sum, n, 16); \
223
- if ((sum >> 16) == 0) \
224
- ge |= 3 << (n * 2); \
225
- } while (0)
226
-
227
-#define SUB8(a, b, n) do { \
228
- uint32_t sum; \
229
- sum = (uint32_t)(uint8_t)(a) - (uint32_t)(uint8_t)(b); \
230
- RESULT(sum, n, 8); \
231
- if ((sum >> 8) == 0) \
232
- ge |= 1 << n; \
233
- } while (0)
234
-
235
-#define PFX u
236
-#define ARITH_GE
237
-
238
-#include "op_addsub.h"
239
-
240
-/* Halved signed arithmetic. */
241
-#define ADD16(a, b, n) \
242
- RESULT(((int32_t)(int16_t)(a) + (int32_t)(int16_t)(b)) >> 1, n, 16)
243
-#define SUB16(a, b, n) \
244
- RESULT(((int32_t)(int16_t)(a) - (int32_t)(int16_t)(b)) >> 1, n, 16)
245
-#define ADD8(a, b, n) \
246
- RESULT(((int32_t)(int8_t)(a) + (int32_t)(int8_t)(b)) >> 1, n, 8)
247
-#define SUB8(a, b, n) \
248
- RESULT(((int32_t)(int8_t)(a) - (int32_t)(int8_t)(b)) >> 1, n, 8)
249
-#define PFX sh
250
-
251
-#include "op_addsub.h"
252
-
253
-/* Halved unsigned arithmetic. */
254
-#define ADD16(a, b, n) \
255
- RESULT(((uint32_t)(uint16_t)(a) + (uint32_t)(uint16_t)(b)) >> 1, n, 16)
256
-#define SUB16(a, b, n) \
257
- RESULT(((uint32_t)(uint16_t)(a) - (uint32_t)(uint16_t)(b)) >> 1, n, 16)
258
-#define ADD8(a, b, n) \
259
- RESULT(((uint32_t)(uint8_t)(a) + (uint32_t)(uint8_t)(b)) >> 1, n, 8)
260
-#define SUB8(a, b, n) \
261
- RESULT(((uint32_t)(uint8_t)(a) - (uint32_t)(uint8_t)(b)) >> 1, n, 8)
262
-#define PFX uh
263
-
264
-#include "op_addsub.h"
265
-
266
-static inline uint8_t do_usad(uint8_t a, uint8_t b)
267
-{
268
- if (a > b) {
269
- return a - b;
270
- } else {
271
- return b - a;
272
- }
273
-}
274
-
275
-/* Unsigned sum of absolute byte differences. */
276
-uint32_t HELPER(usad8)(uint32_t a, uint32_t b)
277
-{
278
- uint32_t sum;
279
- sum = do_usad(a, b);
280
- sum += do_usad(a >> 8, b >> 8);
281
- sum += do_usad(a >> 16, b >> 16);
282
- sum += do_usad(a >> 24, b >> 24);
283
- return sum;
284
-}
285
-
286
-/* For ARMv6 SEL instruction. */
287
-uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b)
288
-{
289
- uint32_t mask;
290
-
291
- mask = 0;
292
- if (flags & 1) {
293
- mask |= 0xff;
294
- }
295
- if (flags & 2) {
296
- mask |= 0xff00;
297
- }
298
- if (flags & 4) {
299
- mask |= 0xff0000;
300
- }
301
- if (flags & 8) {
302
- mask |= 0xff000000;
303
- }
304
- return (a & mask) | (b & ~mask);
305
-}
306
-
307
-/*
308
- * CRC helpers.
309
- * The upper bytes of val (above the number specified by 'bytes') must have
310
- * been zeroed out by the caller.
311
- */
312
-uint32_t HELPER(crc32)(uint32_t acc, uint32_t val, uint32_t bytes)
313
-{
314
- uint8_t buf[4];
315
-
316
- stl_le_p(buf, val);
317
-
318
- /* zlib crc32 converts the accumulator and output to one's complement. */
319
- return crc32(acc ^ 0xffffffff, buf, bytes) ^ 0xffffffff;
320
-}
321
-
322
-uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes)
323
-{
324
- uint8_t buf[4];
325
-
326
- stl_le_p(buf, val);
327
-
328
- /* Linux crc32c converts the output to one's complement. */
329
- return crc32c(acc, buf, bytes) ^ 0xffffffff;
330
-}
331
332
/*
333
* Return the exception level to which FP-disabled exceptions should
334
diff --git a/target/arm/tcg/arith_helper.c b/target/arm/tcg/arith_helper.c
335
new file mode 100644
336
index XXXXXXX..XXXXXXX
337
--- /dev/null
338
+++ b/target/arm/tcg/arith_helper.c
339
@@ -XXX,XX +XXX,XX @@
340
+/*
341
+ * ARM generic helpers for various arithmetical operations.
342
+ *
343
+ * This code is licensed under the GNU GPL v2 or later.
344
+ *
345
+ * SPDX-License-Identifier: GPL-2.0-or-later
346
+ */
347
+#include "qemu/osdep.h"
348
+#include "cpu.h"
349
+#include "exec/helper-proto.h"
350
+#include "qemu/crc32c.h"
351
+#include <zlib.h> /* for crc32 */
352
+
353
+/*
354
+ * Note that signed overflow is undefined in C. The following routines are
355
+ * careful to use unsigned types where modulo arithmetic is required.
356
+ * Failure to do so _will_ break on newer gcc.
357
+ */
358
+
359
+/* Signed saturating arithmetic. */
360
+
361
+/* Perform 16-bit signed saturating addition. */
362
+static inline uint16_t add16_sat(uint16_t a, uint16_t b)
363
+{
364
+ uint16_t res;
365
+
366
+ res = a + b;
367
+ if (((res ^ a) & 0x8000) && !((a ^ b) & 0x8000)) {
368
+ if (a & 0x8000) {
369
+ res = 0x8000;
370
+ } else {
371
+ res = 0x7fff;
372
+ }
373
+ }
374
+ return res;
375
+}
376
+
377
+/* Perform 8-bit signed saturating addition. */
378
+static inline uint8_t add8_sat(uint8_t a, uint8_t b)
379
+{
380
+ uint8_t res;
381
+
382
+ res = a + b;
383
+ if (((res ^ a) & 0x80) && !((a ^ b) & 0x80)) {
384
+ if (a & 0x80) {
385
+ res = 0x80;
386
+ } else {
387
+ res = 0x7f;
388
+ }
389
+ }
390
+ return res;
391
+}
392
+
393
+/* Perform 16-bit signed saturating subtraction. */
394
+static inline uint16_t sub16_sat(uint16_t a, uint16_t b)
395
+{
396
+ uint16_t res;
397
+
398
+ res = a - b;
399
+ if (((res ^ a) & 0x8000) && ((a ^ b) & 0x8000)) {
400
+ if (a & 0x8000) {
401
+ res = 0x8000;
402
+ } else {
403
+ res = 0x7fff;
404
+ }
405
+ }
406
+ return res;
407
+}
408
+
409
+/* Perform 8-bit signed saturating subtraction. */
410
+static inline uint8_t sub8_sat(uint8_t a, uint8_t b)
411
+{
412
+ uint8_t res;
413
+
414
+ res = a - b;
415
+ if (((res ^ a) & 0x80) && ((a ^ b) & 0x80)) {
416
+ if (a & 0x80) {
417
+ res = 0x80;
418
+ } else {
419
+ res = 0x7f;
420
+ }
421
+ }
422
+ return res;
423
+}
424
+
425
+#define ADD16(a, b, n) RESULT(add16_sat(a, b), n, 16);
426
+#define SUB16(a, b, n) RESULT(sub16_sat(a, b), n, 16);
427
+#define ADD8(a, b, n) RESULT(add8_sat(a, b), n, 8);
428
+#define SUB8(a, b, n) RESULT(sub8_sat(a, b), n, 8);
429
+#define PFX q
430
+
431
+#include "op_addsub.c.inc"
432
+
433
+/* Unsigned saturating arithmetic. */
434
+static inline uint16_t add16_usat(uint16_t a, uint16_t b)
435
+{
436
+ uint16_t res;
437
+ res = a + b;
438
+ if (res < a) {
439
+ res = 0xffff;
440
+ }
441
+ return res;
442
+}
443
+
444
+static inline uint16_t sub16_usat(uint16_t a, uint16_t b)
445
+{
446
+ if (a > b) {
447
+ return a - b;
448
+ } else {
449
+ return 0;
450
+ }
451
+}
452
+
453
+static inline uint8_t add8_usat(uint8_t a, uint8_t b)
454
+{
455
+ uint8_t res;
456
+ res = a + b;
457
+ if (res < a) {
458
+ res = 0xff;
459
+ }
460
+ return res;
461
+}
462
+
463
+static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
464
+{
465
+ if (a > b) {
466
+ return a - b;
467
+ } else {
468
+ return 0;
469
+ }
470
+}
471
+
472
+#define ADD16(a, b, n) RESULT(add16_usat(a, b), n, 16);
473
+#define SUB16(a, b, n) RESULT(sub16_usat(a, b), n, 16);
474
+#define ADD8(a, b, n) RESULT(add8_usat(a, b), n, 8);
475
+#define SUB8(a, b, n) RESULT(sub8_usat(a, b), n, 8);
476
+#define PFX uq
477
+
478
+#include "op_addsub.c.inc"
479
+
480
+/* Signed modulo arithmetic. */
481
+#define SARITH16(a, b, n, op) do { \
482
+ int32_t sum; \
483
+ sum = (int32_t)(int16_t)(a) op (int32_t)(int16_t)(b); \
484
+ RESULT(sum, n, 16); \
485
+ if (sum >= 0) \
486
+ ge |= 3 << (n * 2); \
487
+ } while (0)
488
+
489
+#define SARITH8(a, b, n, op) do { \
490
+ int32_t sum; \
491
+ sum = (int32_t)(int8_t)(a) op (int32_t)(int8_t)(b); \
492
+ RESULT(sum, n, 8); \
493
+ if (sum >= 0) \
494
+ ge |= 1 << n; \
495
+ } while (0)
496
+
497
+
498
+#define ADD16(a, b, n) SARITH16(a, b, n, +)
499
+#define SUB16(a, b, n) SARITH16(a, b, n, -)
500
+#define ADD8(a, b, n) SARITH8(a, b, n, +)
501
+#define SUB8(a, b, n) SARITH8(a, b, n, -)
502
+#define PFX s
503
+#define ARITH_GE
504
+
505
+#include "op_addsub.c.inc"
506
+
507
+/* Unsigned modulo arithmetic. */
508
+#define ADD16(a, b, n) do { \
509
+ uint32_t sum; \
510
+ sum = (uint32_t)(uint16_t)(a) + (uint32_t)(uint16_t)(b); \
511
+ RESULT(sum, n, 16); \
512
+ if ((sum >> 16) == 1) \
513
+ ge |= 3 << (n * 2); \
514
+ } while (0)
515
+
516
+#define ADD8(a, b, n) do { \
517
+ uint32_t sum; \
518
+ sum = (uint32_t)(uint8_t)(a) + (uint32_t)(uint8_t)(b); \
519
+ RESULT(sum, n, 8); \
520
+ if ((sum >> 8) == 1) \
521
+ ge |= 1 << n; \
522
+ } while (0)
523
+
524
+#define SUB16(a, b, n) do { \
525
+ uint32_t sum; \
526
+ sum = (uint32_t)(uint16_t)(a) - (uint32_t)(uint16_t)(b); \
527
+ RESULT(sum, n, 16); \
528
+ if ((sum >> 16) == 0) \
529
+ ge |= 3 << (n * 2); \
530
+ } while (0)
531
+
532
+#define SUB8(a, b, n) do { \
533
+ uint32_t sum; \
534
+ sum = (uint32_t)(uint8_t)(a) - (uint32_t)(uint8_t)(b); \
535
+ RESULT(sum, n, 8); \
536
+ if ((sum >> 8) == 0) \
537
+ ge |= 1 << n; \
538
+ } while (0)
539
+
540
+#define PFX u
541
+#define ARITH_GE
542
+
543
+#include "op_addsub.c.inc"
544
+
545
+/* Halved signed arithmetic. */
546
+#define ADD16(a, b, n) \
547
+ RESULT(((int32_t)(int16_t)(a) + (int32_t)(int16_t)(b)) >> 1, n, 16)
548
+#define SUB16(a, b, n) \
549
+ RESULT(((int32_t)(int16_t)(a) - (int32_t)(int16_t)(b)) >> 1, n, 16)
550
+#define ADD8(a, b, n) \
551
+ RESULT(((int32_t)(int8_t)(a) + (int32_t)(int8_t)(b)) >> 1, n, 8)
552
+#define SUB8(a, b, n) \
553
+ RESULT(((int32_t)(int8_t)(a) - (int32_t)(int8_t)(b)) >> 1, n, 8)
554
+#define PFX sh
555
+
556
+#include "op_addsub.c.inc"
557
+
558
+/* Halved unsigned arithmetic. */
559
+#define ADD16(a, b, n) \
560
+ RESULT(((uint32_t)(uint16_t)(a) + (uint32_t)(uint16_t)(b)) >> 1, n, 16)
561
+#define SUB16(a, b, n) \
562
+ RESULT(((uint32_t)(uint16_t)(a) - (uint32_t)(uint16_t)(b)) >> 1, n, 16)
563
+#define ADD8(a, b, n) \
564
+ RESULT(((uint32_t)(uint8_t)(a) + (uint32_t)(uint8_t)(b)) >> 1, n, 8)
565
+#define SUB8(a, b, n) \
566
+ RESULT(((uint32_t)(uint8_t)(a) - (uint32_t)(uint8_t)(b)) >> 1, n, 8)
567
+#define PFX uh
568
+
569
+#include "op_addsub.c.inc"
570
+
571
+static inline uint8_t do_usad(uint8_t a, uint8_t b)
572
+{
573
+ if (a > b) {
574
+ return a - b;
575
+ } else {
576
+ return b - a;
577
+ }
578
+}
579
+
580
+/* Unsigned sum of absolute byte differences. */
581
+uint32_t HELPER(usad8)(uint32_t a, uint32_t b)
582
+{
583
+ uint32_t sum;
584
+ sum = do_usad(a, b);
585
+ sum += do_usad(a >> 8, b >> 8);
586
+ sum += do_usad(a >> 16, b >> 16);
587
+ sum += do_usad(a >> 24, b >> 24);
588
+ return sum;
589
+}
590
+
591
+/* For ARMv6 SEL instruction. */
592
+uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b)
593
+{
594
+ uint32_t mask;
595
+
596
+ mask = 0;
597
+ if (flags & 1) {
598
+ mask |= 0xff;
599
+ }
600
+ if (flags & 2) {
601
+ mask |= 0xff00;
602
+ }
603
+ if (flags & 4) {
604
+ mask |= 0xff0000;
605
+ }
606
+ if (flags & 8) {
607
+ mask |= 0xff000000;
608
+ }
609
+ return (a & mask) | (b & ~mask);
610
+}
611
+
612
+/*
613
+ * CRC helpers.
614
+ * The upper bytes of val (above the number specified by 'bytes') must have
615
+ * been zeroed out by the caller.
616
+ */
617
+uint32_t HELPER(crc32)(uint32_t acc, uint32_t val, uint32_t bytes)
618
+{
619
+ uint8_t buf[4];
620
+
621
+ stl_le_p(buf, val);
622
+
623
+ /* zlib crc32 converts the accumulator and output to one's complement. */
624
+ return crc32(acc ^ 0xffffffff, buf, bytes) ^ 0xffffffff;
625
+}
626
+
627
+uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes)
628
+{
629
+ uint8_t buf[4];
630
+
631
+ stl_le_p(buf, val);
632
+
633
+ /* Linux crc32c converts the output to one's complement. */
634
+ return crc32c(acc, buf, bytes) ^ 0xffffffff;
635
+}
636
diff --git a/target/arm/op_addsub.h b/target/arm/tcg/op_addsub.c.inc
637
similarity index 100%
638
rename from target/arm/op_addsub.h
639
rename to target/arm/tcg/op_addsub.c.inc
640
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
641
index XXXXXXX..XXXXXXX 100644
642
--- a/target/arm/tcg/meson.build
643
+++ b/target/arm/tcg/meson.build
644
@@ -XXX,XX +XXX,XX @@ arm_ss.add(files(
645
'tlb_helper.c',
646
'vec_helper.c',
647
'tlb-insns.c',
648
+ 'arith_helper.c',
649
))
650
651
arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
62
--
652
--
63
2.34.1
653
2.34.1
64
654
65
655
diff view generated by jsdifflib
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
1
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
2
3
This patch adds WDT to Allwinner-A10 and Cubieboard.
3
Before changing default pauth algorithm, we need to make sure current
4
WDT is added as an overlay to the Timer module memory map.
4
default one (QARMA5) can still be selected.
5
5
6
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
6
$ qemu-system-aarch64 -cpu max,pauth-qarma5=on ...
7
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
7
8
Message-id: 20230326202256.22980-3-strahinja.p.jankovic@gmail.com
8
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20241219183211.3493974-2-pierrick.bouvier@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
docs/system/arm/cubieboard.rst | 1 +
13
docs/system/arm/cpu-features.rst | 5 ++++-
12
include/hw/arm/allwinner-a10.h | 2 ++
14
target/arm/cpu.h | 1 +
13
hw/arm/allwinner-a10.c | 7 +++++++
15
target/arm/arm-qmp-cmds.c | 2 +-
14
hw/arm/Kconfig | 1 +
16
target/arm/cpu64.c | 20 ++++++++++++++------
15
4 files changed, 11 insertions(+)
17
tests/qtest/arm-cpu-features.c | 15 +++++++++++----
18
5 files changed, 31 insertions(+), 12 deletions(-)
16
19
17
diff --git a/docs/system/arm/cubieboard.rst b/docs/system/arm/cubieboard.rst
20
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
18
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
19
--- a/docs/system/arm/cubieboard.rst
22
--- a/docs/system/arm/cpu-features.rst
20
+++ b/docs/system/arm/cubieboard.rst
23
+++ b/docs/system/arm/cpu-features.rst
21
@@ -XXX,XX +XXX,XX @@ Emulated devices:
24
@@ -XXX,XX +XXX,XX @@ Below is the list of TCG VCPU features and their descriptions.
22
- USB controller
25
``pauth-qarma3``
23
- SATA controller
26
When ``pauth`` is enabled, select the architected QARMA3 algorithm.
24
- TWI (I2C) controller
27
25
+- Watchdog timer
28
-Without either ``pauth-impdef`` or ``pauth-qarma3`` enabled,
26
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
29
+``pauth-qarma5``
30
+ When ``pauth`` is enabled, select the architected QARMA5 algorithm.
31
+
32
+Without ``pauth-impdef``, ``pauth-qarma3`` or ``pauth-qarma5`` enabled,
33
the architected QARMA5 algorithm is used. The architected QARMA5
34
and QARMA3 algorithms have good cryptographic properties, but can
35
be quite slow to emulate. The impdef algorithm used by QEMU is
36
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
27
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
28
--- a/include/hw/arm/allwinner-a10.h
38
--- a/target/arm/cpu.h
29
+++ b/include/hw/arm/allwinner-a10.h
39
+++ b/target/arm/cpu.h
30
@@ -XXX,XX +XXX,XX @@
40
@@ -XXX,XX +XXX,XX @@ struct ArchCPU {
31
#include "hw/misc/allwinner-a10-ccm.h"
41
bool prop_pauth;
32
#include "hw/misc/allwinner-a10-dramc.h"
42
bool prop_pauth_impdef;
33
#include "hw/i2c/allwinner-i2c.h"
43
bool prop_pauth_qarma3;
34
+#include "hw/watchdog/allwinner-wdt.h"
44
+ bool prop_pauth_qarma5;
35
#include "sysemu/block-backend.h"
45
bool prop_lpa2;
36
46
37
#include "target/arm/cpu.h"
47
/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */
38
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
48
diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
39
AwSdHostState mmc0;
40
AWI2CState i2c0;
41
AwRtcState rtc;
42
+ AwWdtState wdt;
43
MemoryRegion sram_a;
44
EHCISysBusState ehci[AW_A10_NUM_USB];
45
OHCISysBusState ohci[AW_A10_NUM_USB];
46
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
47
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/allwinner-a10.c
50
--- a/target/arm/arm-qmp-cmds.c
49
+++ b/hw/arm/allwinner-a10.c
51
+++ b/target/arm/arm-qmp-cmds.c
50
@@ -XXX,XX +XXX,XX @@
52
@@ -XXX,XX +XXX,XX @@ static const char *cpu_model_advertised_features[] = {
51
#define AW_A10_EHCI_BASE 0x01c14000
53
"sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280",
52
#define AW_A10_OHCI_BASE 0x01c14400
54
"sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048",
53
#define AW_A10_SATA_BASE 0x01c18000
55
"kvm-no-adjvtime", "kvm-steal-time",
54
+#define AW_A10_WDT_BASE 0x01c20c90
56
- "pauth", "pauth-impdef", "pauth-qarma3",
55
#define AW_A10_RTC_BASE 0x01c20d00
57
+ "pauth", "pauth-impdef", "pauth-qarma3", "pauth-qarma5",
56
#define AW_A10_I2C0_BASE 0x01c2ac00
58
NULL
57
59
};
58
@@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj)
60
59
object_initialize_child(obj, "mmc0", &s->mmc0, TYPE_AW_SDHOST_SUN4I);
61
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
60
62
index XXXXXXX..XXXXXXX 100644
61
object_initialize_child(obj, "rtc", &s->rtc, TYPE_AW_RTC_SUN4I);
63
--- a/target/arm/cpu64.c
62
+
64
+++ b/target/arm/cpu64.c
63
+ object_initialize_child(obj, "wdt", &s->wdt, TYPE_AW_WDT_SUN4I);
65
@@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
66
}
67
68
if (cpu->prop_pauth) {
69
- if (cpu->prop_pauth_impdef && cpu->prop_pauth_qarma3) {
70
+ if ((cpu->prop_pauth_impdef && cpu->prop_pauth_qarma3) ||
71
+ (cpu->prop_pauth_impdef && cpu->prop_pauth_qarma5) ||
72
+ (cpu->prop_pauth_qarma3 && cpu->prop_pauth_qarma5)) {
73
error_setg(errp,
74
- "cannot enable both pauth-impdef and pauth-qarma3");
75
+ "cannot enable pauth-impdef, pauth-qarma3 and "
76
+ "pauth-qarma5 at the same time");
77
return;
78
}
79
80
@@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
81
} else if (cpu->prop_pauth_qarma3) {
82
isar2 = FIELD_DP64(isar2, ID_AA64ISAR2, APA3, features);
83
isar2 = FIELD_DP64(isar2, ID_AA64ISAR2, GPA3, 1);
84
- } else {
85
+ } else { /* default is pauth-qarma5 */
86
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, APA, features);
87
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1);
88
}
89
- } else if (cpu->prop_pauth_impdef || cpu->prop_pauth_qarma3) {
90
- error_setg(errp, "cannot enable pauth-impdef or "
91
- "pauth-qarma3 without pauth");
92
+ } else if (cpu->prop_pauth_impdef ||
93
+ cpu->prop_pauth_qarma3 ||
94
+ cpu->prop_pauth_qarma5) {
95
+ error_setg(errp, "cannot enable pauth-impdef, pauth-qarma3 or "
96
+ "pauth-qarma5 without pauth");
97
error_append_hint(errp, "Add pauth=on to the CPU property list.\n");
98
}
99
}
100
@@ -XXX,XX +XXX,XX @@ static const Property arm_cpu_pauth_impdef_property =
101
DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
102
static const Property arm_cpu_pauth_qarma3_property =
103
DEFINE_PROP_BOOL("pauth-qarma3", ARMCPU, prop_pauth_qarma3, false);
104
+static Property arm_cpu_pauth_qarma5_property =
105
+ DEFINE_PROP_BOOL("pauth-qarma5", ARMCPU, prop_pauth_qarma5, false);
106
107
void aarch64_add_pauth_properties(Object *obj)
108
{
109
@@ -XXX,XX +XXX,XX @@ void aarch64_add_pauth_properties(Object *obj)
110
} else {
111
qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
112
qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma3_property);
113
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma5_property);
114
}
64
}
115
}
65
116
66
static void aw_a10_realize(DeviceState *dev, Error **errp)
117
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
67
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
118
index XXXXXXX..XXXXXXX 100644
68
sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal);
119
--- a/tests/qtest/arm-cpu-features.c
69
sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, AW_A10_I2C0_BASE);
120
+++ b/tests/qtest/arm-cpu-features.c
70
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0, qdev_get_gpio_in(dev, 7));
121
@@ -XXX,XX +XXX,XX @@ static void pauth_tests_default(QTestState *qts, const char *cpu_type)
71
+
122
assert_has_feature_enabled(qts, cpu_type, "pauth");
72
+ /* WDT */
123
assert_has_feature_disabled(qts, cpu_type, "pauth-impdef");
73
+ sysbus_realize(SYS_BUS_DEVICE(&s->wdt), &error_fatal);
124
assert_has_feature_disabled(qts, cpu_type, "pauth-qarma3");
74
+ sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->wdt), 0, AW_A10_WDT_BASE, 1);
125
+ assert_has_feature_disabled(qts, cpu_type, "pauth-qarma5");
126
assert_set_feature(qts, cpu_type, "pauth", false);
127
assert_set_feature(qts, cpu_type, "pauth", true);
128
assert_set_feature(qts, cpu_type, "pauth-impdef", true);
129
assert_set_feature(qts, cpu_type, "pauth-impdef", false);
130
assert_set_feature(qts, cpu_type, "pauth-qarma3", true);
131
assert_set_feature(qts, cpu_type, "pauth-qarma3", false);
132
+ assert_set_feature(qts, cpu_type, "pauth-qarma5", true);
133
+ assert_set_feature(qts, cpu_type, "pauth-qarma5", false);
134
assert_error(qts, cpu_type,
135
- "cannot enable pauth-impdef or pauth-qarma3 without pauth",
136
+ "cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5 without pauth",
137
"{ 'pauth': false, 'pauth-impdef': true }");
138
assert_error(qts, cpu_type,
139
- "cannot enable pauth-impdef or pauth-qarma3 without pauth",
140
+ "cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5 without pauth",
141
"{ 'pauth': false, 'pauth-qarma3': true }");
142
assert_error(qts, cpu_type,
143
- "cannot enable both pauth-impdef and pauth-qarma3",
144
- "{ 'pauth': true, 'pauth-impdef': true, 'pauth-qarma3': true }");
145
+ "cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5 without pauth",
146
+ "{ 'pauth': false, 'pauth-qarma5': true }");
147
+ assert_error(qts, cpu_type,
148
+ "cannot enable pauth-impdef, pauth-qarma3 and pauth-qarma5 at the same time",
149
+ "{ 'pauth': true, 'pauth-impdef': true, 'pauth-qarma3': true,"
150
+ " 'pauth-qarma5': true }");
75
}
151
}
76
152
77
static void aw_a10_class_init(ObjectClass *oc, void *data)
153
static void test_query_cpu_model_expansion(const void *data)
78
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/arm/Kconfig
81
+++ b/hw/arm/Kconfig
82
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
83
select ALLWINNER_A10_PIC
84
select ALLWINNER_A10_CCM
85
select ALLWINNER_A10_DRAMC
86
+ select ALLWINNER_WDT
87
select ALLWINNER_EMAC
88
select ALLWINNER_I2C
89
select AXP209_PMU
90
--
154
--
91
2.34.1
155
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
1
3
This patch adds WDT to Allwinner-H3 and Orangepi-PC.
4
WDT is added as an overlay to the Timer module memory area.
5
6
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
7
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
8
Message-id: 20230326202256.22980-4-strahinja.p.jankovic@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
docs/system/arm/orangepi.rst | 1 +
12
include/hw/arm/allwinner-h3.h | 5 ++++-
13
hw/arm/allwinner-h3.c | 8 ++++++++
14
hw/arm/Kconfig | 1 +
15
4 files changed, 14 insertions(+), 1 deletion(-)
16
17
diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst
18
index XXXXXXX..XXXXXXX 100644
19
--- a/docs/system/arm/orangepi.rst
20
+++ b/docs/system/arm/orangepi.rst
21
@@ -XXX,XX +XXX,XX @@ The Orange Pi PC machine supports the following devices:
22
* System Control module
23
* Security Identifier device
24
* TWI (I2C)
25
+ * Watchdog timer
26
27
Limitations
28
"""""""""""
29
diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h
30
index XXXXXXX..XXXXXXX 100644
31
--- a/include/hw/arm/allwinner-h3.h
32
+++ b/include/hw/arm/allwinner-h3.h
33
@@ -XXX,XX +XXX,XX @@
34
#include "hw/net/allwinner-sun8i-emac.h"
35
#include "hw/rtc/allwinner-rtc.h"
36
#include "hw/i2c/allwinner-i2c.h"
37
+#include "hw/watchdog/allwinner-wdt.h"
38
#include "target/arm/cpu.h"
39
#include "sysemu/block-backend.h"
40
41
@@ -XXX,XX +XXX,XX @@ enum {
42
AW_H3_DEV_RTC,
43
AW_H3_DEV_CPUCFG,
44
AW_H3_DEV_R_TWI,
45
- AW_H3_DEV_SDRAM
46
+ AW_H3_DEV_SDRAM,
47
+ AW_H3_DEV_WDT
48
};
49
50
/** Total number of CPU cores in the H3 SoC */
51
@@ -XXX,XX +XXX,XX @@ struct AwH3State {
52
AWI2CState r_twi;
53
AwSun8iEmacState emac;
54
AwRtcState rtc;
55
+ AwWdtState wdt;
56
GICState gic;
57
MemoryRegion sram_a1;
58
MemoryRegion sram_a2;
59
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/hw/arm/allwinner-h3.c
62
+++ b/hw/arm/allwinner-h3.c
63
@@ -XXX,XX +XXX,XX @@ const hwaddr allwinner_h3_memmap[] = {
64
[AW_H3_DEV_OHCI3] = 0x01c1d400,
65
[AW_H3_DEV_CCU] = 0x01c20000,
66
[AW_H3_DEV_PIT] = 0x01c20c00,
67
+ [AW_H3_DEV_WDT] = 0x01c20ca0,
68
[AW_H3_DEV_UART0] = 0x01c28000,
69
[AW_H3_DEV_UART1] = 0x01c28400,
70
[AW_H3_DEV_UART2] = 0x01c28800,
71
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_init(Object *obj)
72
object_initialize_child(obj, "twi1", &s->i2c1, TYPE_AW_I2C_SUN6I);
73
object_initialize_child(obj, "twi2", &s->i2c2, TYPE_AW_I2C_SUN6I);
74
object_initialize_child(obj, "r_twi", &s->r_twi, TYPE_AW_I2C_SUN6I);
75
+
76
+ object_initialize_child(obj, "wdt", &s->wdt, TYPE_AW_WDT_SUN6I);
77
}
78
79
static void allwinner_h3_realize(DeviceState *dev, Error **errp)
80
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
81
sysbus_connect_irq(SYS_BUS_DEVICE(&s->r_twi), 0,
82
qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_R_TWI));
83
84
+ /* WDT */
85
+ sysbus_realize(SYS_BUS_DEVICE(&s->wdt), &error_fatal);
86
+ sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->wdt), 0,
87
+ s->memmap[AW_H3_DEV_WDT], 1);
88
+
89
/* Unimplemented devices */
90
for (i = 0; i < ARRAY_SIZE(unimplemented); i++) {
91
create_unimplemented_device(unimplemented[i].device_name,
92
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
93
index XXXXXXX..XXXXXXX 100644
94
--- a/hw/arm/Kconfig
95
+++ b/hw/arm/Kconfig
96
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_H3
97
select ALLWINNER_A10_PIT
98
select ALLWINNER_SUN8I_EMAC
99
select ALLWINNER_I2C
100
+ select ALLWINNER_WDT
101
select SERIAL
102
select ARM_TIMER
103
select ARM_GIC
104
--
105
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
1
3
Cubieboard tests end with comment "reboot not functioning; omit test".
4
Fix this so reboot is done at the end of each test.
5
6
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
7
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
8
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
9
Message-id: 20230326202256.22980-5-strahinja.p.jankovic@gmail.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
tests/avocado/boot_linux_console.py | 15 ++++++++++++---
13
1 file changed, 12 insertions(+), 3 deletions(-)
14
15
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
16
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/avocado/boot_linux_console.py
18
+++ b/tests/avocado/boot_linux_console.py
19
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self):
20
'Allwinner sun4i/sun5i')
21
exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
22
'system-control@1c00000')
23
- # cubieboard's reboot is not functioning; omit reboot test.
24
+ exec_command_and_wait_for_pattern(self, 'reboot',
25
+ 'reboot: Restarting system')
26
+ # Wait for VM to shut down gracefully
27
+ self.vm.wait()
28
29
def test_arm_cubieboard_sata(self):
30
"""
31
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self):
32
'Allwinner sun4i/sun5i')
33
exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
34
'sda')
35
- # cubieboard's reboot is not functioning; omit reboot test.
36
+ exec_command_and_wait_for_pattern(self, 'reboot',
37
+ 'reboot: Restarting system')
38
+ # Wait for VM to shut down gracefully
39
+ self.vm.wait()
40
41
@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
42
def test_arm_cubieboard_openwrt_22_03_2(self):
43
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_openwrt_22_03_2(self):
44
45
exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
46
'Allwinner sun4i/sun5i')
47
- # cubieboard's reboot is not functioning; omit reboot test.
48
+ exec_command_and_wait_for_pattern(self, 'reboot',
49
+ 'reboot: Restarting system')
50
+ # Wait for VM to shut down gracefully
51
+ self.vm.wait()
52
53
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
54
def test_arm_quanta_gsj(self):
55
--
56
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Axel Heider <axel.heider@hensoldt.net>
2
1
3
Fix the limit check. If the limit is less than the compare value,
4
the timer can never reach this value, thus it will never fire.
5
6
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1491
7
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
8
Message-id: 168070611775.20412.2883242077302841473-2@git.sr.ht
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/timer/imx_epit.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/timer/imx_epit.c
18
+++ b/hw/timer/imx_epit.c
19
@@ -XXX,XX +XXX,XX @@ static void imx_epit_update_compare_timer(IMXEPITState *s)
20
* the compare value. Otherwise it may fire at most once in the
21
* current round.
22
*/
23
- is_oneshot = (limit >= s->cmp);
24
+ is_oneshot = (limit < s->cmp);
25
if (counter >= s->cmp) {
26
/* The compare timer fires in the current round. */
27
counter -= s->cmp;
28
--
29
2.34.1
diff view generated by jsdifflib
Deleted patch
1
The syndrome value reported to ESR_EL2 should only contain the
2
detailed instruction syndrome information when the fault has been
3
caused by a stage 2 abort, not when the fault was a stage 1 abort
4
(i.e. caused by execution at EL2). We were getting this wrong and
5
reporting the detailed ISV information all the time.
6
1
7
Fix the bug by checking fi->stage2. Add a TODO comment noting the
8
cases where we'll have to come back and revisit this when we
9
implement FEAT_LS64 and friends.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20230331145045.2584941-3-peter.maydell@linaro.org
14
---
15
target/arm/tcg/tlb_helper.c | 13 ++++++++++---
16
1 file changed, 10 insertions(+), 3 deletions(-)
17
18
diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/tcg/tlb_helper.c
21
+++ b/target/arm/tcg/tlb_helper.c
22
@@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
23
uint32_t syn;
24
25
/*
26
- * ISV is only set for data aborts routed to EL2 and
27
- * never for stage-1 page table walks faulting on stage 2.
28
+ * ISV is only set for stage-2 data aborts routed to EL2 and
29
+ * never for stage-1 page table walks faulting on stage 2
30
+ * or for stage-1 faults.
31
*
32
* Furthermore, ISV is only set for certain kinds of load/stores.
33
* If the template syndrome does not have ISV set, we should leave
34
@@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
35
* See ARMv8 specs, D7-1974:
36
* ISS encoding for an exception from a Data Abort, the
37
* ISV field.
38
+ *
39
+ * TODO: FEAT_LS64/FEAT_LS64_V/FEAT_SL64_ACCDATA: Translation,
40
+ * Access Flag, and Permission faults caused by LD64B, ST64B,
41
+ * ST64BV, or ST64BV0 insns report syndrome info even for stage-1
42
+ * faults and regardless of the target EL.
43
*/
44
- if (!(template_syn & ARM_EL_ISV) || target_el != 2 || fi->s1ptw) {
45
+ if (!(template_syn & ARM_EL_ISV) || target_el != 2
46
+ || fi->s1ptw || !fi->stage2) {
47
syn = syn_data_abort_no_iss(same_el, 0,
48
fi->ea, 0, fi->s1ptw, is_write, fsc);
49
} else {
50
--
51
2.34.1
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
The pauth-3 test explicitly tests that a computation of the
2
pointer-authentication produces the expected result. This means that
3
it must be run with the QARMA5 algorithm.
2
4
3
On mcimx7d-sabre, the MDIO bus is connected to the first Ethernet
5
Explicitly set the pauth algorithm when running this test, so that it
4
interface. Set fec2-phy-connected to false to reflect this.
6
doesn't break when we change the default algorithm the 'max' CPU
7
uses.
5
8
6
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7
Message-id: 20230315145248.1639364-6-linux@roeck-us.net
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
hw/arm/mcimx7d-sabre.c | 2 ++
11
tests/tcg/aarch64/Makefile.softmmu-target | 3 +++
12
1 file changed, 2 insertions(+)
12
1 file changed, 3 insertions(+)
13
13
14
diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c
14
diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/Makefile.softmmu-target
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/mcimx7d-sabre.c
16
--- a/tests/tcg/aarch64/Makefile.softmmu-target
17
+++ b/hw/arm/mcimx7d-sabre.c
17
+++ b/tests/tcg/aarch64/Makefile.softmmu-target
18
@@ -XXX,XX +XXX,XX @@ static void mcimx7d_sabre_init(MachineState *machine)
18
@@ -XXX,XX +XXX,XX @@ EXTRA_RUNS+=run-memory-replay
19
19
20
s = FSL_IMX7(object_new(TYPE_FSL_IMX7));
20
ifneq ($(CROSS_CC_HAS_ARMV8_3),)
21
object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
21
pauth-3: CFLAGS += $(CROSS_CC_HAS_ARMV8_3)
22
+ object_property_set_bool(OBJECT(s), "fec2-phy-connected", false,
22
+# This test explicitly checks the output of the pauth operation so we
23
+ &error_fatal);
23
+# must force the use of the QARMA5 algorithm for it.
24
qdev_realize(DEVICE(s), NULL, &error_fatal);
24
+run-pauth-3: QEMU_BASE_MACHINE=-M virt -cpu max,pauth-qarma5=on -display none
25
25
else
26
memory_region_add_subregion(get_system_memory(), FSL_IMX7_MMDC_ADDR,
26
pauth-3:
27
    $(call skip-test, "BUILD of $@", "missing compiler support")
27
--
28
--
28
2.34.1
29
2.34.1
diff view generated by jsdifflib
1
FEAT_PAN3 adds an EPAN bit to SCTLR_EL1 and SCTLR_EL2, which allows
1
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
the PAN bit to make memory non-privileged-read/write if it is
3
user-executable as well as if it is user-read/write.
4
2
5
Implement this feature and enable it in the AArch64 'max' CPU.
3
Pointer authentication on aarch64 is pretty expensive (up to 50% of
4
execution time) when running a virtual machine with tcg and -cpu max
5
(which enables pauth=on).
6
6
7
The advice is always: use pauth-impdef=on.
8
Our documentation even mentions it "by default" in
9
docs/system/introduction.rst.
10
11
Thus, we change the default to use impdef by default. This does not
12
affect kvm or hvf acceleration, since pauth algorithm used is the one
13
from host cpu.
14
15
This change is retro compatible, in terms of cli, with previous
16
versions, as the semantic of using -cpu max,pauth-impdef=on, and -cpu
17
max,pauth-qarma3=on is preserved.
18
The new option introduced in previous patch and matching old default is
19
-cpu max,pauth-qarma5=on.
20
It is retro compatible with migration as well, by defining a backcompat
21
property, that will use qarma5 by default for virt machine <= 9.2.
22
Tested by saving and restoring a vm from qemu 9.2.0 into qemu-master
23
(10.0) for cpus neoverse-n2 and max.
24
25
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
27
Message-id: 20241219183211.3493974-3-pierrick.bouvier@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230331145045.2584941-4-peter.maydell@linaro.org
10
---
29
---
11
docs/system/arm/emulation.rst | 1 +
30
docs/system/arm/cpu-features.rst | 2 +-
12
target/arm/cpu.h | 5 +++++
31
docs/system/introduction.rst | 2 +-
13
target/arm/cpu64.c | 2 +-
32
target/arm/cpu.h | 3 +++
14
target/arm/ptw.c | 14 +++++++++++++-
33
hw/core/machine.c | 4 +++-
15
4 files changed, 20 insertions(+), 2 deletions(-)
34
target/arm/cpu.c | 2 ++
35
target/arm/cpu64.c | 22 ++++++++++++++++------
36
6 files changed, 26 insertions(+), 9 deletions(-)
16
37
17
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
38
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
18
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
19
--- a/docs/system/arm/emulation.rst
40
--- a/docs/system/arm/cpu-features.rst
20
+++ b/docs/system/arm/emulation.rst
41
+++ b/docs/system/arm/cpu-features.rst
21
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
42
@@ -XXX,XX +XXX,XX @@ Below is the list of TCG VCPU features and their descriptions.
22
- FEAT_MTE3 (MTE Asymmetric Fault Handling)
43
When ``pauth`` is enabled, select the architected QARMA5 algorithm.
23
- FEAT_PAN (Privileged access never)
44
24
- FEAT_PAN2 (AT S1E1R and AT S1E1W instruction variants affected by PSTATE.PAN)
45
Without ``pauth-impdef``, ``pauth-qarma3`` or ``pauth-qarma5`` enabled,
25
+- FEAT_PAN3 (Support for SCTLR_ELx.EPAN)
46
-the architected QARMA5 algorithm is used. The architected QARMA5
26
- FEAT_PAuth (Pointer authentication)
47
+the QEMU impdef algorithm is used. The architected QARMA5
27
- FEAT_PMULL (PMULL, PMULL2 instructions)
48
and QARMA3 algorithms have good cryptographic properties, but can
28
- FEAT_PMUv3p1 (PMU Extensions v3.1)
49
be quite slow to emulate. The impdef algorithm used by QEMU is
50
non-cryptographic but significantly faster.
51
diff --git a/docs/system/introduction.rst b/docs/system/introduction.rst
52
index XXXXXXX..XXXXXXX 100644
53
--- a/docs/system/introduction.rst
54
+++ b/docs/system/introduction.rst
55
@@ -XXX,XX +XXX,XX @@ would default to it anyway.
56
57
.. code::
58
59
- -cpu max,pauth-impdef=on \
60
+ -cpu max \
61
-smp 4 \
62
-accel tcg \
63
29
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
64
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
30
index XXXXXXX..XXXXXXX 100644
65
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/cpu.h
66
--- a/target/arm/cpu.h
32
+++ b/target/arm/cpu.h
67
+++ b/target/arm/cpu.h
33
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ats1e1(const ARMISARegisters *id)
68
@@ -XXX,XX +XXX,XX @@ struct ArchCPU {
34
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 2;
69
/* QOM property to indicate we should use the back-compat CNTFRQ default */
35
}
70
bool backcompat_cntfrq;
36
71
37
+static inline bool isar_feature_aa64_pan3(const ARMISARegisters *id)
72
+ /* QOM property to indicate we should use the back-compat QARMA5 default */
38
+{
73
+ bool backcompat_pauth_default_use_qarma5;
39
+ return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 3;
40
+}
41
+
74
+
42
static inline bool isar_feature_aa64_hcx(const ARMISARegisters *id)
75
/* Specify the number of cores in this CPU cluster. Used for the L2CTLR
43
{
76
* register.
44
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HCX) != 0;
77
*/
78
diff --git a/hw/core/machine.c b/hw/core/machine.c
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/core/machine.c
81
+++ b/hw/core/machine.c
82
@@ -XXX,XX +XXX,XX @@
83
#include "hw/virtio/virtio-iommu.h"
84
#include "audio/audio.h"
85
86
-GlobalProperty hw_compat_9_2[] = {};
87
+GlobalProperty hw_compat_9_2[] = {
88
+ {"arm-cpu", "backcompat-pauth-default-use-qarma5", "true"},
89
+};
90
const size_t hw_compat_9_2_len = G_N_ELEMENTS(hw_compat_9_2);
91
92
GlobalProperty hw_compat_9_1[] = {
93
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/target/arm/cpu.c
96
+++ b/target/arm/cpu.c
97
@@ -XXX,XX +XXX,XX @@ static const Property arm_cpu_properties[] = {
98
DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1),
99
/* True to default to the backward-compat old CNTFRQ rather than 1Ghz */
100
DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, backcompat_cntfrq, false),
101
+ DEFINE_PROP_BOOL("backcompat-pauth-default-use-qarma5", ARMCPU,
102
+ backcompat_pauth_default_use_qarma5, false),
103
};
104
105
static const gchar *arm_gdb_arch_name(CPUState *cs)
45
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
106
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
46
index XXXXXXX..XXXXXXX 100644
107
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/cpu64.c
108
--- a/target/arm/cpu64.c
48
+++ b/target/arm/cpu64.c
109
+++ b/target/arm/cpu64.c
49
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
110
@@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
50
t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */
111
return;
51
t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */
112
}
52
t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */
113
53
- t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* FEAT_PAN2 */
114
- if (cpu->prop_pauth_impdef) {
54
+ t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 3); /* FEAT_PAN3 */
115
- isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, API, features);
55
t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */
116
- isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPI, 1);
56
t = FIELD_DP64(t, ID_AA64MMFR1, ETS, 1); /* FEAT_ETS */
117
+ bool use_default = !cpu->prop_pauth_qarma5 &&
57
t = FIELD_DP64(t, ID_AA64MMFR1, HCX, 1); /* FEAT_HCX */
118
+ !cpu->prop_pauth_qarma3 &&
58
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
119
+ !cpu->prop_pauth_impdef;
59
index XXXXXXX..XXXXXXX 100644
120
+
60
--- a/target/arm/ptw.c
121
+ if (cpu->prop_pauth_qarma5 ||
61
+++ b/target/arm/ptw.c
122
+ (use_default &&
62
@@ -XXX,XX +XXX,XX @@ static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0)
123
+ cpu->backcompat_pauth_default_use_qarma5)) {
63
static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64,
124
+ isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, APA, features);
64
int ap, int ns, int xn, int pxn)
125
+ isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1);
65
{
126
} else if (cpu->prop_pauth_qarma3) {
66
+ ARMCPU *cpu = env_archcpu(env);
127
isar2 = FIELD_DP64(isar2, ID_AA64ISAR2, APA3, features);
67
bool is_user = regime_is_user(env, mmu_idx);
128
isar2 = FIELD_DP64(isar2, ID_AA64ISAR2, GPA3, 1);
68
int prot_rw, user_rw;
129
- } else { /* default is pauth-qarma5 */
69
bool have_wxn;
130
- isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, APA, features);
70
@@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64,
131
- isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1);
71
if (is_user) {
132
+ } else if (cpu->prop_pauth_impdef ||
72
prot_rw = user_rw;
133
+ (use_default &&
73
} else {
134
+ !cpu->backcompat_pauth_default_use_qarma5)) {
74
+ /*
135
+ isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, API, features);
75
+ * PAN controls can forbid data accesses but don't affect insn fetch.
136
+ isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPI, 1);
76
+ * Plain PAN forbids data accesses if EL0 has data permissions;
137
+ } else {
77
+ * PAN3 forbids data accesses if EL0 has either data or exec perms.
138
+ g_assert_not_reached();
78
+ * Note that for AArch64 the 'user can exec' case is exactly !xn.
139
}
79
+ * We make the IMPDEF choices that SCR_EL3.SIF and Realm EL2&0
140
} else if (cpu->prop_pauth_impdef ||
80
+ * do not affect EPAN.
141
cpu->prop_pauth_qarma3 ||
81
+ */
82
if (user_rw && regime_is_pan(env, mmu_idx)) {
83
- /* PAN forbids data accesses but doesn't affect insn fetch */
84
+ prot_rw = 0;
85
+ } else if (cpu_isar_feature(aa64_pan3, cpu) && is_aa64 &&
86
+ regime_is_pan(env, mmu_idx) &&
87
+ (regime_sctlr(env, mmu_idx) & SCTLR_EPAN) && !xn) {
88
prot_rw = 0;
89
} else {
90
prot_rw = simple_ap_to_rw_prot_is_user(ap, false);
91
--
142
--
92
2.34.1
143
2.34.1
diff view generated by jsdifflib
Deleted patch
1
So that we can avoid the "older gdb crashes" problem described in
2
commit 5787d17a42f7af4 and which caused us to disable reporting pauth
3
information via the gdbstub, newer gdb is going to implement support
4
for recognizing the pauth information via a new feature name:
5
org.gnu.gdb.aarch64.pauth_v2
6
1
7
Older gdb won't recognize this feature name, so we can re-enable the
8
pauth support under the new name without risking them crashing.
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20230406150827.3322670-1-peter.maydell@linaro.org
13
---
14
target/arm/gdbstub.c | 9 ++++-----
15
gdb-xml/aarch64-pauth.xml | 2 +-
16
2 files changed, 5 insertions(+), 6 deletions(-)
17
18
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/gdbstub.c
21
+++ b/target/arm/gdbstub.c
22
@@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
23
aarch64_gdb_set_fpu_reg,
24
34, "aarch64-fpu.xml", 0);
25
}
26
-#if 0
27
/*
28
- * GDB versions 9 through 12 have a bug which means they will
29
- * crash if they see this XML from QEMU; disable it for the 8.0
30
- * release, pending a better solution.
31
+ * Note that we report pauth information via the feature name
32
+ * org.gnu.gdb.aarch64.pauth_v2, not org.gnu.gdb.aarch64.pauth.
33
+ * GDB versions 9 through 12 have a bug where they will crash
34
+ * if they see the latter XML from QEMU.
35
*/
36
if (isar_feature_aa64_pauth(&cpu->isar)) {
37
gdb_register_coprocessor(cs, aarch64_gdb_get_pauth_reg,
38
aarch64_gdb_set_pauth_reg,
39
4, "aarch64-pauth.xml", 0);
40
}
41
-#endif
42
#endif
43
} else {
44
if (arm_feature(env, ARM_FEATURE_NEON)) {
45
diff --git a/gdb-xml/aarch64-pauth.xml b/gdb-xml/aarch64-pauth.xml
46
index XXXXXXX..XXXXXXX 100644
47
--- a/gdb-xml/aarch64-pauth.xml
48
+++ b/gdb-xml/aarch64-pauth.xml
49
@@ -XXX,XX +XXX,XX @@
50
notice and this notice are preserved. -->
51
52
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
53
-<feature name="org.gnu.gdb.aarch64.pauth">
54
+<feature name="org.gnu.gdb.aarch64.pauth_v2">
55
<reg name="pauth_dmask" bitsize="64"/>
56
<reg name="pauth_cmask" bitsize="64"/>
57
<reg name="pauth_dmask_high" bitsize="64"/>
58
--
59
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Guenter Roeck <linux@roeck-us.net>
2
1
3
Add fec[12]-phy-connected properties and use it to set phy-connected
4
and phy-consumer properties for imx_fec.
5
6
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7
Message-id: 20230315145248.1639364-3-linux@roeck-us.net
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/arm/fsl-imx6ul.h | 1 +
12
hw/arm/fsl-imx6ul.c | 20 ++++++++++++++++++++
13
2 files changed, 21 insertions(+)
14
15
diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/fsl-imx6ul.h
18
+++ b/include/hw/arm/fsl-imx6ul.h
19
@@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState {
20
MemoryRegion ocram_alias;
21
22
uint32_t phy_num[FSL_IMX6UL_NUM_ETHS];
23
+ bool phy_connected[FSL_IMX6UL_NUM_ETHS];
24
};
25
26
enum FslIMX6ULMemoryMap {
27
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/arm/fsl-imx6ul.c
30
+++ b/hw/arm/fsl-imx6ul.c
31
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
32
33
/*
34
* Ethernet
35
+ *
36
+ * We must use two loops since phy_connected affects the other interface
37
+ * and we have to set all properties before calling sysbus_realize().
38
*/
39
+ for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) {
40
+ object_property_set_bool(OBJECT(&s->eth[i]), "phy-connected",
41
+ s->phy_connected[i], &error_abort);
42
+ /*
43
+ * If the MDIO bus on this controller is not connected, assume the
44
+ * other controller provides support for it.
45
+ */
46
+ if (!s->phy_connected[i]) {
47
+ object_property_set_link(OBJECT(&s->eth[1 - i]), "phy-consumer",
48
+ OBJECT(&s->eth[i]), &error_abort);
49
+ }
50
+ }
51
+
52
for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) {
53
static const hwaddr FSL_IMX6UL_ENETn_ADDR[FSL_IMX6UL_NUM_ETHS] = {
54
FSL_IMX6UL_ENET1_ADDR,
55
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
56
static Property fsl_imx6ul_properties[] = {
57
DEFINE_PROP_UINT32("fec1-phy-num", FslIMX6ULState, phy_num[0], 0),
58
DEFINE_PROP_UINT32("fec2-phy-num", FslIMX6ULState, phy_num[1], 1),
59
+ DEFINE_PROP_BOOL("fec1-phy-connected", FslIMX6ULState, phy_connected[0],
60
+ true),
61
+ DEFINE_PROP_BOOL("fec2-phy-connected", FslIMX6ULState, phy_connected[1],
62
+ true),
63
DEFINE_PROP_END_OF_LIST(),
64
};
65
66
--
67
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Guenter Roeck <linux@roeck-us.net>
2
1
3
On mcimx6ul-evk, the MDIO bus is connected to the second Ethernet
4
interface. Set fec1-phy-connected to false to reflect this.
5
6
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7
Message-id: 20230315145248.1639364-4-linux@roeck-us.net
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/arm/mcimx6ul-evk.c | 2 ++
12
1 file changed, 2 insertions(+)
13
14
diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/mcimx6ul-evk.c
17
+++ b/hw/arm/mcimx6ul-evk.c
18
@@ -XXX,XX +XXX,XX @@ static void mcimx6ul_evk_init(MachineState *machine)
19
object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
20
object_property_set_uint(OBJECT(s), "fec1-phy-num", 2, &error_fatal);
21
object_property_set_uint(OBJECT(s), "fec2-phy-num", 1, &error_fatal);
22
+ object_property_set_bool(OBJECT(s), "fec1-phy-connected", false,
23
+ &error_fatal);
24
qdev_realize(DEVICE(s), NULL, &error_fatal);
25
26
memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_MMDC_ADDR,
27
--
28
2.34.1
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
2
3
Add fec[12]-phy-connected properties and use it to set phy-connected
3
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
and phy-consumer properties for imx_fec.
4
Message-id: 20241219183211.3493974-4-pierrick.bouvier@linaro.org
5
5
[PMM: Removed a paragraph about using non-versioned models.]
6
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7
Message-id: 20230315145248.1639364-5-linux@roeck-us.net
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
7
---
11
include/hw/arm/fsl-imx7.h | 1 +
8
docs/system/arm/virt.rst | 4 ++++
12
hw/arm/fsl-imx7.c | 20 ++++++++++++++++++++
9
1 file changed, 4 insertions(+)
13
2 files changed, 21 insertions(+)
14
10
15
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
11
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/fsl-imx7.h
13
--- a/docs/system/arm/virt.rst
18
+++ b/include/hw/arm/fsl-imx7.h
14
+++ b/docs/system/arm/virt.rst
19
@@ -XXX,XX +XXX,XX @@ struct FslIMX7State {
15
@@ -XXX,XX +XXX,XX @@ of the 5.0 release and ``virt-5.0`` of the 5.1 release. Migration
20
ChipideaState usb[FSL_IMX7_NUM_USBS];
16
is not guaranteed to work between different QEMU releases for
21
DesignwarePCIEHost pcie;
17
the non-versioned ``virt`` machine type.
22
uint32_t phy_num[FSL_IMX7_NUM_ETHS];
18
23
+ bool phy_connected[FSL_IMX7_NUM_ETHS];
19
+VM migration is not guaranteed when using ``-cpu max``, as features
24
};
20
+supported may change between QEMU versions. To ensure your VM can be
25
21
+migrated, it is recommended to use another cpu model instead.
26
enum FslIMX7MemoryMap {
27
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/arm/fsl-imx7.c
30
+++ b/hw/arm/fsl-imx7.c
31
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
32
33
/*
34
* Ethernet
35
+ *
36
+ * We must use two loops since phy_connected affects the other interface
37
+ * and we have to set all properties before calling sysbus_realize().
38
*/
39
+ for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) {
40
+ object_property_set_bool(OBJECT(&s->eth[i]), "phy-connected",
41
+ s->phy_connected[i], &error_abort);
42
+ /*
43
+ * If the MDIO bus on this controller is not connected, assume the
44
+ * other controller provides support for it.
45
+ */
46
+ if (!s->phy_connected[i]) {
47
+ object_property_set_link(OBJECT(&s->eth[1 - i]), "phy-consumer",
48
+ OBJECT(&s->eth[i]), &error_abort);
49
+ }
50
+ }
51
+
22
+
52
for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) {
23
Supported devices
53
static const hwaddr FSL_IMX7_ENETn_ADDR[FSL_IMX7_NUM_ETHS] = {
24
"""""""""""""""""
54
FSL_IMX7_ENET1_ADDR,
55
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
56
static Property fsl_imx7_properties[] = {
57
DEFINE_PROP_UINT32("fec1-phy-num", FslIMX7State, phy_num[0], 0),
58
DEFINE_PROP_UINT32("fec2-phy-num", FslIMX7State, phy_num[1], 1),
59
+ DEFINE_PROP_BOOL("fec1-phy-connected", FslIMX7State, phy_connected[0],
60
+ true),
61
+ DEFINE_PROP_BOOL("fec2-phy-connected", FslIMX7State, phy_connected[1],
62
+ true),
63
DEFINE_PROP_END_OF_LIST(),
64
};
65
25
66
--
26
--
67
2.34.1
27
2.34.1
diff view generated by jsdifflib