1
First arm pullreq for 7.1. The bulk of this is the qemu_split_irq
1
Hi; this pullreq contains mainly a chunk of RTH's refactoring
2
removal.
2
of the Arm pagetable walk code, plus a series from me fixing
3
3
configure checkpatch warnings, and some old patches to various
4
I have enough stuff in my to-review queue that I expect to do another
4
files all over the tree getting rid of dynamic stack allocation.
5
pullreq early next week, but 31 patches is enough to not hang on to.
6
5
7
thanks
6
thanks
8
-- PMM
7
-- PMM
9
8
10
The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b:
9
The following changes since commit 6338c30111d596d955e6bc933a82184a0b910c43:
11
10
12
Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700)
11
Merge tag 'm68k-for-7.2-pull-request' of https://github.com/vivier/qemu-m68k into staging (2022-09-21 13:12:36 -0400)
13
12
14
are available in the Git repository at:
13
are available in the Git repository at:
15
14
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220421
15
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220922
17
16
18
for you to fetch changes up to 5b415dd61bdbf61fb4be0e9f1a7172b8bce682c6:
17
for you to fetch changes up to b3b5472db0ab7a53499441c1fe1dedec05b1e285:
19
18
20
hw/arm: Use bit fields for NPCM7XX PWRON STRAPs (2022-04-21 11:37:05 +0100)
19
configure: Avoid use of 'local' as it is non-POSIX (2022-09-22 16:38:29 +0100)
21
20
22
----------------------------------------------------------------
21
----------------------------------------------------------------
23
target-arm queue:
22
target-arm queue:
24
* hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF
23
* hw/net/can: fix Xilinx ZynqMP CAN RX FIFO logic
25
* versal: Add the Cortex-R5s in the Real-Time Processing Unit (RPU) subsystem
24
* Fix alignment for Neon VLD4.32
26
* versal: model enough of the Clock/Reset Low-power domain (CRL) to allow control of the Cortex-R5s
25
* Refactoring of page-table-walk code
27
* xlnx-zynqmp: Connect 4 TTC timers
26
* hw/acpi: Add ospm_status hook implementation for acpi-ged
28
* exynos4210: Refactor GIC/combiner code to stop using qemu_split_irq
27
* hw/net/lan9118: Signal TSFL_INT flag when TX FIFO reaches specified level
29
* realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ'
28
* chardev/baum: avoid variable-length arrays
30
* stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ'
29
* io/channel-websock: avoid variable-length arrays
31
* hw/core/irq: remove unused 'qemu_irq_split' function
30
* hw/net/e1000e_core: Use definition to avoid dynamic stack allocation
32
* npcm7xx: use symbolic constants for PWRON STRAP bit fields
31
* hw/ppc/pnv: Avoid dynamic stack allocation
33
* virt: document impact of gic-version on max CPUs
32
* hw/intc/xics: Avoid dynamic stack allocation
33
* hw/i386/multiboot: Avoid dynamic stack allocation
34
* hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation
35
* ui/curses: Avoid dynamic stack allocation
36
* tests/unit/test-vmstate: Avoid dynamic stack allocation
37
* configure: fix various shellcheck-spotted issues and nits
34
38
35
----------------------------------------------------------------
39
----------------------------------------------------------------
36
Edgar E. Iglesias (6):
40
Anton Kochkov (1):
37
timer: cadence_ttc: Break out header file to allow embedding
41
hw/net/can: fix Xilinx ZynqMP CAN RX FIFO logic
38
hw/arm/xlnx-zynqmp: Connect 4 TTC timers
39
hw/arm: versal: Create an APU CPU Cluster
40
hw/arm: versal: Add the Cortex-R5Fs
41
hw/misc: Add a model of the Xilinx Versal CRL
42
hw/arm: versal: Connect the CRL
43
42
44
Hao Wu (2):
43
Clément Chigot (1):
45
hw/misc: Add PWRON STRAP bit fields in GCR module
44
target/arm: Fix alignment for VLD4.32
46
hw/arm: Use bit fields for NPCM7XX PWRON STRAPs
47
45
48
Heinrich Schuchardt (1):
46
Keqian Zhu (1):
49
hw/arm/virt: impact of gic-version on max CPUs
47
hw/acpi: Add ospm_status hook implementation for acpi-ged
50
48
51
Peter Maydell (19):
49
Lucas Dietrich (1):
52
hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF
50
hw/net/lan9118: Signal TSFL_INT flag when TX FIFO reaches specified level
53
hw/arm/exynos4210: Use TYPE_OR_IRQ instead of custom OR-gate device
54
hw/intc/exynos4210_gic: Remove unused TYPE_EXYNOS4210_IRQ_GATE
55
hw/arm/exynos4210: Put a9mpcore device into state struct
56
hw/arm/exynos4210: Drop int_gic_irq[] from Exynos4210Irq struct
57
hw/arm/exynos4210: Coalesce board_irqs and irq_table
58
hw/arm/exynos4210: Fix code style nit in combiner_grp_to_gic_id[]
59
hw/arm/exynos4210: Move exynos4210_init_board_irqs() into exynos4210.c
60
hw/arm/exynos4210: Put external GIC into state struct
61
hw/arm/exynos4210: Drop ext_gic_irq[] from Exynos4210Irq struct
62
hw/arm/exynos4210: Move exynos4210_combiner_get_gpioin() into exynos4210.c
63
hw/arm/exynos4210: Delete unused macro definitions
64
hw/arm/exynos4210: Use TYPE_SPLIT_IRQ in exynos4210_init_board_irqs()
65
hw/arm/exynos4210: Fill in irq_table[] for internal-combiner-only IRQ lines
66
hw/arm/exynos4210: Connect MCT_G0 and MCT_G1 to both combiners
67
hw/arm/exynos4210: Don't connect multiple lines to external GIC inputs
68
hw/arm/exynos4210: Fold combiner splits into exynos4210_init_board_irqs()
69
hw/arm/exynos4210: Put combiners into state struct
70
hw/arm/exynos4210: Drop Exynos4210Irq struct
71
51
72
Zongyuan Li (3):
52
Peter Maydell (7):
73
hw/arm/realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ'
53
configure: Remove unused python_version variable
74
hw/arm/stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ'
54
configure: Remove unused meson_args variable
75
hw/core/irq: remove unused 'qemu_irq_split' function
55
configure: Add missing quoting for some easy cases
56
configure: Add './' on front of glob of */config-devices.mak.d
57
configure: Remove use of backtick `...` syntax
58
configure: Check mkdir result directly, not via $?
59
configure: Avoid use of 'local' as it is non-POSIX
76
60
77
docs/system/arm/virt.rst | 4 +-
61
Philippe Mathieu-Daudé (11):
78
include/hw/arm/exynos4210.h | 50 ++--
62
chardev/baum: Replace magic values by X_MAX / Y_MAX definitions
79
include/hw/arm/xlnx-versal.h | 16 ++
63
chardev/baum: Use definitions to avoid dynamic stack allocation
80
include/hw/arm/xlnx-zynqmp.h | 4 +
64
chardev/baum: Avoid dynamic stack allocation
81
include/hw/intc/exynos4210_combiner.h | 57 +++++
65
io/channel-websock: Replace strlen(const_str) by sizeof(const_str) - 1
82
include/hw/intc/exynos4210_gic.h | 43 ++++
66
hw/net/e1000e_core: Use definition to avoid dynamic stack allocation
83
include/hw/irq.h | 5 -
67
hw/ppc/pnv: Avoid dynamic stack allocation
84
include/hw/misc/npcm7xx_gcr.h | 30 +++
68
hw/intc/xics: Avoid dynamic stack allocation
85
include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++++
69
hw/i386/multiboot: Avoid dynamic stack allocation
86
include/hw/timer/cadence_ttc.h | 54 +++++
70
hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation
87
hw/arm/exynos4210.c | 430 ++++++++++++++++++++++++++++++----
71
ui/curses: Avoid dynamic stack allocation
88
hw/arm/npcm7xx_boards.c | 24 +-
72
tests/unit/test-vmstate: Avoid dynamic stack allocation
89
hw/arm/realview.c | 33 ++-
73
90
hw/arm/stellaris.c | 15 +-
74
Richard Henderson (17):
91
hw/arm/virt.c | 7 +
75
target/arm: Create GetPhysAddrResult
92
hw/arm/xlnx-versal-virt.c | 6 +-
76
target/arm: Use GetPhysAddrResult in get_phys_addr_lpae
93
hw/arm/xlnx-versal.c | 99 +++++++-
77
target/arm: Use GetPhysAddrResult in get_phys_addr_v6
94
hw/arm/xlnx-zynqmp.c | 22 ++
78
target/arm: Use GetPhysAddrResult in get_phys_addr_v5
95
hw/core/irq.c | 15 --
79
target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav5
96
hw/intc/exynos4210_combiner.c | 108 +--------
80
target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav7
97
hw/intc/exynos4210_gic.c | 344 +--------------------------
81
target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav8
98
hw/misc/xlnx-versal-crl.c | 421 +++++++++++++++++++++++++++++++++
82
target/arm: Use GetPhysAddrResult in pmsav8_mpu_lookup
99
hw/timer/cadence_ttc.c | 32 +--
83
target/arm: Remove is_subpage argument to pmsav8_mpu_lookup
100
MAINTAINERS | 2 +-
84
target/arm: Add is_secure parameter to v8m_security_lookup
101
hw/misc/meson.build | 1 +
85
target/arm: Add secure parameter to pmsav8_mpu_lookup
102
25 files changed, 1457 insertions(+), 600 deletions(-)
86
target/arm: Add is_secure parameter to get_phys_addr_v5
103
create mode 100644 include/hw/intc/exynos4210_combiner.h
87
target/arm: Add is_secure parameter to get_phys_addr_v6
104
create mode 100644 include/hw/intc/exynos4210_gic.h
88
target/arm: Add secure parameter to get_phys_addr_pmsav8
105
create mode 100644 include/hw/misc/xlnx-versal-crl.h
89
target/arm: Add is_secure parameter to pmsav7_use_background_region
106
create mode 100644 include/hw/timer/cadence_ttc.h
90
target/arm: Add secure parameter to get_phys_addr_pmsav7
107
create mode 100644 hw/misc/xlnx-versal-crl.c
91
target/arm: Add is_secure parameter to get_phys_addr_pmsav5
92
93
configure | 82 +++++-----
94
target/arm/internals.h | 26 +--
95
chardev/baum.c | 22 ++-
96
hw/acpi/generic_event_device.c | 8 +
97
hw/i386/multiboot.c | 5 +-
98
hw/intc/xics.c | 2 +-
99
hw/net/can/xlnx-zynqmp-can.c | 32 ++--
100
hw/net/e1000e_core.c | 7 +-
101
hw/net/lan9118.c | 8 +
102
hw/ppc/pnv.c | 4 +-
103
hw/ppc/spapr.c | 8 +-
104
hw/ppc/spapr_pci_nvlink2.c | 2 +-
105
hw/usb/hcd-ohci.c | 7 +-
106
io/channel-websock.c | 2 +-
107
target/arm/helper.c | 27 ++-
108
target/arm/m_helper.c | 78 ++++-----
109
target/arm/ptw.c | 364 +++++++++++++++++++----------------------
110
target/arm/tlb_helper.c | 22 +--
111
target/arm/translate-neon.c | 6 +-
112
tests/unit/test-vmstate.c | 7 +-
113
ui/curses.c | 2 +-
114
21 files changed, 347 insertions(+), 374 deletions(-)
115
diff view generated by jsdifflib
1
From: Zongyuan Li <zongyuan.li@smartx.com>
1
From: Anton Kochkov <anton.kochkov@proton.me>
2
2
3
Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com>
3
For consistency, function "update_rx_fifo()" should use the RX FIFO
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
register field names, not the TX FIFO ones, even if they refer to the
5
Message-id: 20220324181557.203805-2-zongyuan.li@smartx.com
5
same bit positions in the register.
6
7
Signed-off-by: Anton Kochkov <anton.kochkov@proton.me>
8
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Message-id: 20220817141754.2105981-1-anton.kochkov@proton.me
10
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1123
11
[PMM: tweaked commit message]
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
13
---
8
hw/arm/realview.c | 33 ++++++++++++++++++++++++---------
14
hw/net/can/xlnx-zynqmp-can.c | 32 ++++++++++++++++----------------
9
1 file changed, 24 insertions(+), 9 deletions(-)
15
1 file changed, 16 insertions(+), 16 deletions(-)
10
16
11
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
17
diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c
12
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/realview.c
19
--- a/hw/net/can/xlnx-zynqmp-can.c
14
+++ b/hw/arm/realview.c
20
+++ b/hw/net/can/xlnx-zynqmp-can.c
15
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ static void update_rx_fifo(XlnxZynqMPCANState *s, const qemu_can_frame *frame)
16
#include "hw/sysbus.h"
22
timestamp));
17
#include "hw/arm/boot.h"
23
18
#include "hw/arm/primecell.h"
24
/* First 32 bit of the data. */
19
+#include "hw/core/split-irq.h"
25
- fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA1_DB3_SHIFT,
20
#include "hw/net/lan9118.h"
26
- R_TXFIFO_DATA1_DB3_LENGTH,
21
#include "hw/net/smc91c111.h"
27
+ fifo32_push(&s->rx_fifo, deposit32(0, R_RXFIFO_DATA1_DB3_SHIFT,
22
#include "hw/pci/pci.h"
28
+ R_RXFIFO_DATA1_DB3_LENGTH,
23
+#include "hw/qdev-core.h"
29
frame->data[0]) |
24
#include "net/net.h"
30
- deposit32(0, R_TXFIFO_DATA1_DB2_SHIFT,
25
#include "sysemu/sysemu.h"
31
- R_TXFIFO_DATA1_DB2_LENGTH,
26
#include "hw/boards.h"
32
+ deposit32(0, R_RXFIFO_DATA1_DB2_SHIFT,
27
@@ -XXX,XX +XXX,XX @@ static const int realview_board_id[] = {
33
+ R_RXFIFO_DATA1_DB2_LENGTH,
28
0x76d
34
frame->data[1]) |
29
};
35
- deposit32(0, R_TXFIFO_DATA1_DB1_SHIFT,
30
36
- R_TXFIFO_DATA1_DB1_LENGTH,
31
+static void split_irq_from_named(DeviceState *src, const char* outname,
37
+ deposit32(0, R_RXFIFO_DATA1_DB1_SHIFT,
32
+ qemu_irq out1, qemu_irq out2) {
38
+ R_RXFIFO_DATA1_DB1_LENGTH,
33
+ DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ);
39
frame->data[2]) |
34
+
40
- deposit32(0, R_TXFIFO_DATA1_DB0_SHIFT,
35
+ qdev_prop_set_uint32(splitter, "num-lines", 2);
41
- R_TXFIFO_DATA1_DB0_LENGTH,
36
+
42
+ deposit32(0, R_RXFIFO_DATA1_DB0_SHIFT,
37
+ qdev_realize_and_unref(splitter, NULL, &error_fatal);
43
+ R_RXFIFO_DATA1_DB0_LENGTH,
38
+
44
frame->data[3]));
39
+ qdev_connect_gpio_out(splitter, 0, out1);
45
/* Last 32 bit of the data. */
40
+ qdev_connect_gpio_out(splitter, 1, out2);
46
- fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA2_DB7_SHIFT,
41
+ qdev_connect_gpio_out_named(src, outname, 0,
47
- R_TXFIFO_DATA2_DB7_LENGTH,
42
+ qdev_get_gpio_in(splitter, 0));
48
+ fifo32_push(&s->rx_fifo, deposit32(0, R_RXFIFO_DATA2_DB7_SHIFT,
43
+}
49
+ R_RXFIFO_DATA2_DB7_LENGTH,
44
+
50
frame->data[4]) |
45
static void realview_init(MachineState *machine,
51
- deposit32(0, R_TXFIFO_DATA2_DB6_SHIFT,
46
enum realview_board_type board_type)
52
- R_TXFIFO_DATA2_DB6_LENGTH,
47
{
53
+ deposit32(0, R_RXFIFO_DATA2_DB6_SHIFT,
48
@@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine,
54
+ R_RXFIFO_DATA2_DB6_LENGTH,
49
DeviceState *dev, *sysctl, *gpio2, *pl041;
55
frame->data[5]) |
50
SysBusDevice *busdev;
56
- deposit32(0, R_TXFIFO_DATA2_DB5_SHIFT,
51
qemu_irq pic[64];
57
- R_TXFIFO_DATA2_DB5_LENGTH,
52
- qemu_irq mmc_irq[2];
58
+ deposit32(0, R_RXFIFO_DATA2_DB5_SHIFT,
53
PCIBus *pci_bus = NULL;
59
+ R_RXFIFO_DATA2_DB5_LENGTH,
54
NICInfo *nd;
60
frame->data[6]) |
55
DriveInfo *dinfo;
61
- deposit32(0, R_TXFIFO_DATA2_DB4_SHIFT,
56
@@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine,
62
- R_TXFIFO_DATA2_DB4_LENGTH,
57
* and the PL061 has them the other way about. Also the card
63
+ deposit32(0, R_RXFIFO_DATA2_DB4_SHIFT,
58
* detect line is inverted.
64
+ R_RXFIFO_DATA2_DB4_LENGTH,
59
*/
65
frame->data[7]));
60
- mmc_irq[0] = qemu_irq_split(
66
61
- qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT),
67
ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 1);
62
- qdev_get_gpio_in(gpio2, 1));
63
- mmc_irq[1] = qemu_irq_split(
64
- qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN),
65
- qemu_irq_invert(qdev_get_gpio_in(gpio2, 0)));
66
- qdev_connect_gpio_out_named(dev, "card-read-only", 0, mmc_irq[0]);
67
- qdev_connect_gpio_out_named(dev, "card-inserted", 0, mmc_irq[1]);
68
+ split_irq_from_named(dev, "card-read-only",
69
+ qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT),
70
+ qdev_get_gpio_in(gpio2, 1));
71
+
72
+ split_irq_from_named(dev, "card-inserted",
73
+ qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN),
74
+ qemu_irq_invert(qdev_get_gpio_in(gpio2, 0)));
75
+
76
dinfo = drive_get(IF_SD, 0, 0);
77
if (dinfo) {
78
DeviceState *card;
79
--
68
--
80
2.25.1
69
2.25.1
diff view generated by jsdifflib
New patch
1
From: Clément Chigot <chigot@adacore.com>
1
2
3
When requested, the alignment for VLD4.32 is 8 and not 16.
4
5
See ARM documentation about VLD4 encoding:
6
ebytes = 1 << UInt(size);
7
if size == '10' then
8
alignment = if a == '0' then 1 else 8;
9
else
10
alignment = if a == '0' then 1 else 4*ebytes;
11
12
Signed-off-by: Clément Chigot <chigot@adacore.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20220914105058.2787404-1-chigot@adacore.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
target/arm/translate-neon.c | 6 +++++-
18
1 file changed, 5 insertions(+), 1 deletion(-)
19
20
diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/translate-neon.c
23
+++ b/target/arm/translate-neon.c
24
@@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a)
25
case 3:
26
return false;
27
case 4:
28
- align = pow2_align(size + 2);
29
+ if (size == 2) {
30
+ align = pow2_align(3);
31
+ } else {
32
+ align = pow2_align(size + 2);
33
+ }
34
break;
35
default:
36
g_assert_not_reached();
37
--
38
2.25.1
39
40
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Create an APU CPU Cluster. This is in preparation to add the RPU.
3
Combine 5 output pointer arguments from get_phys_addr
4
into a single struct. Adjust all callers.
4
5
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
7
Message-id: 20220822152741.1617527-2-richard.henderson@linaro.org
7
Message-id: 20220406174303.2022038-2-edgar.iglesias@xilinx.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
---
10
include/hw/arm/xlnx-versal.h | 2 ++
11
target/arm/internals.h | 13 ++++-
11
hw/arm/xlnx-versal.c | 9 ++++++++-
12
target/arm/helper.c | 27 ++++-----
12
2 files changed, 10 insertions(+), 1 deletion(-)
13
target/arm/m_helper.c | 52 ++++++-----------
14
target/arm/ptw.c | 120 +++++++++++++++++++++-------------------
15
target/arm/tlb_helper.c | 22 +++-----
16
5 files changed, 109 insertions(+), 125 deletions(-)
13
17
14
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
15
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/arm/xlnx-versal.h
20
--- a/target/arm/internals.h
17
+++ b/include/hw/arm/xlnx-versal.h
21
+++ b/target/arm/internals.h
18
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ typedef struct ARMCacheAttrs {
19
23
bool is_s2_format:1;
20
#include "hw/sysbus.h"
24
} ARMCacheAttrs;
21
#include "hw/arm/boot.h"
25
22
+#include "hw/cpu/cluster.h"
26
+/* Fields that are valid upon success. */
23
#include "hw/or-irq.h"
27
+typedef struct GetPhysAddrResult {
24
#include "hw/sd/sdhci.h"
28
+ hwaddr phys;
25
#include "hw/intc/arm_gicv3.h"
29
+ target_ulong page_size;
26
@@ -XXX,XX +XXX,XX @@ struct Versal {
30
+ int prot;
27
struct {
31
+ MemTxAttrs attrs;
28
struct {
32
+ ARMCacheAttrs cacheattrs;
29
MemoryRegion mr;
33
+} GetPhysAddrResult;
30
+ CPUClusterState cluster;
34
+
31
ARMCPU cpu[XLNX_VERSAL_NR_ACPUS];
35
bool get_phys_addr(CPUARMState *env, target_ulong address,
32
GICv3State gic;
36
MMUAccessType access_type, ARMMMUIdx mmu_idx,
33
} apu;
37
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
34
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
38
- target_ulong *page_size,
39
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
40
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
41
__attribute__((nonnull));
42
43
void arm_log_exception(CPUState *cs);
44
diff --git a/target/arm/helper.c b/target/arm/helper.c
35
index XXXXXXX..XXXXXXX 100644
45
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/arm/xlnx-versal.c
46
--- a/target/arm/helper.c
37
+++ b/hw/arm/xlnx-versal.c
47
+++ b/target/arm/helper.c
38
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
48
@@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri,
49
static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
50
MMUAccessType access_type, ARMMMUIdx mmu_idx)
39
{
51
{
40
int i;
52
- hwaddr phys_addr;
41
53
- target_ulong page_size;
42
+ object_initialize_child(OBJECT(s), "apu-cluster", &s->fpd.apu.cluster,
54
- int prot;
43
+ TYPE_CPU_CLUSTER);
55
bool ret;
44
+ qdev_prop_set_uint32(DEVICE(&s->fpd.apu.cluster), "cluster-id", 0);
56
uint64_t par64;
57
bool format64 = false;
58
- MemTxAttrs attrs = {};
59
ARMMMUFaultInfo fi = {};
60
- ARMCacheAttrs cacheattrs = {};
61
+ GetPhysAddrResult res = {};
62
63
- ret = get_phys_addr(env, value, access_type, mmu_idx, &phys_addr, &attrs,
64
- &prot, &page_size, &fi, &cacheattrs);
65
+ ret = get_phys_addr(env, value, access_type, mmu_idx, &res, &fi);
66
67
/*
68
* ATS operations only do S1 or S1+S2 translations, so we never
69
* have to deal with the ARMCacheAttrs format for S2 only.
70
*/
71
- assert(!cacheattrs.is_s2_format);
72
+ assert(!res.cacheattrs.is_s2_format);
73
74
if (ret) {
75
/*
76
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
77
/* Create a 64-bit PAR */
78
par64 = (1 << 11); /* LPAE bit always set */
79
if (!ret) {
80
- par64 |= phys_addr & ~0xfffULL;
81
- if (!attrs.secure) {
82
+ par64 |= res.phys & ~0xfffULL;
83
+ if (!res.attrs.secure) {
84
par64 |= (1 << 9); /* NS */
85
}
86
- par64 |= (uint64_t)cacheattrs.attrs << 56; /* ATTR */
87
- par64 |= cacheattrs.shareability << 7; /* SH */
88
+ par64 |= (uint64_t)res.cacheattrs.attrs << 56; /* ATTR */
89
+ par64 |= res.cacheattrs.shareability << 7; /* SH */
90
} else {
91
uint32_t fsr = arm_fi_to_lfsc(&fi);
92
93
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
94
*/
95
if (!ret) {
96
/* We do not set any attribute bits in the PAR */
97
- if (page_size == (1 << 24)
98
+ if (res.page_size == (1 << 24)
99
&& arm_feature(env, ARM_FEATURE_V7)) {
100
- par64 = (phys_addr & 0xff000000) | (1 << 1);
101
+ par64 = (res.phys & 0xff000000) | (1 << 1);
102
} else {
103
- par64 = phys_addr & 0xfffff000;
104
+ par64 = res.phys & 0xfffff000;
105
}
106
- if (!attrs.secure) {
107
+ if (!res.attrs.secure) {
108
par64 |= (1 << 9); /* NS */
109
}
110
} else {
111
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
112
index XXXXXXX..XXXXXXX 100644
113
--- a/target/arm/m_helper.c
114
+++ b/target/arm/m_helper.c
115
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
116
{
117
CPUState *cs = CPU(cpu);
118
CPUARMState *env = &cpu->env;
119
- MemTxAttrs attrs = {};
120
MemTxResult txres;
121
- target_ulong page_size;
122
- hwaddr physaddr;
123
- int prot;
124
+ GetPhysAddrResult res = {};
125
ARMMMUFaultInfo fi = {};
126
- ARMCacheAttrs cacheattrs = {};
127
bool secure = mmu_idx & ARM_MMU_IDX_M_S;
128
int exc;
129
bool exc_secure;
130
131
- if (get_phys_addr(env, addr, MMU_DATA_STORE, mmu_idx, &physaddr,
132
- &attrs, &prot, &page_size, &fi, &cacheattrs)) {
133
+ if (get_phys_addr(env, addr, MMU_DATA_STORE, mmu_idx, &res, &fi)) {
134
/* MPU/SAU lookup failed */
135
if (fi.type == ARMFault_QEMU_SFault) {
136
if (mode == STACK_LAZYFP) {
137
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
138
}
139
goto pend_fault;
140
}
141
- address_space_stl_le(arm_addressspace(cs, attrs), physaddr, value,
142
- attrs, &txres);
143
+ address_space_stl_le(arm_addressspace(cs, res.attrs), res.phys, value,
144
+ res.attrs, &txres);
145
if (txres != MEMTX_OK) {
146
/* BusFault trying to write the data */
147
if (mode == STACK_LAZYFP) {
148
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,
149
{
150
CPUState *cs = CPU(cpu);
151
CPUARMState *env = &cpu->env;
152
- MemTxAttrs attrs = {};
153
MemTxResult txres;
154
- target_ulong page_size;
155
- hwaddr physaddr;
156
- int prot;
157
+ GetPhysAddrResult res = {};
158
ARMMMUFaultInfo fi = {};
159
- ARMCacheAttrs cacheattrs = {};
160
bool secure = mmu_idx & ARM_MMU_IDX_M_S;
161
int exc;
162
bool exc_secure;
163
uint32_t value;
164
165
- if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &physaddr,
166
- &attrs, &prot, &page_size, &fi, &cacheattrs)) {
167
+ if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) {
168
/* MPU/SAU lookup failed */
169
if (fi.type == ARMFault_QEMU_SFault) {
170
qemu_log_mask(CPU_LOG_INT,
171
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,
172
goto pend_fault;
173
}
174
175
- value = address_space_ldl(arm_addressspace(cs, attrs), physaddr,
176
- attrs, &txres);
177
+ value = address_space_ldl(arm_addressspace(cs, res.attrs), res.phys,
178
+ res.attrs, &txres);
179
if (txres != MEMTX_OK) {
180
/* BusFault trying to read the data */
181
qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.UNSTKERR\n");
182
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
183
CPUState *cs = CPU(cpu);
184
CPUARMState *env = &cpu->env;
185
V8M_SAttributes sattrs = {};
186
- MemTxAttrs attrs = {};
187
+ GetPhysAddrResult res = {};
188
ARMMMUFaultInfo fi = {};
189
- ARMCacheAttrs cacheattrs = {};
190
MemTxResult txres;
191
- target_ulong page_size;
192
- hwaddr physaddr;
193
- int prot;
194
195
v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs);
196
if (!sattrs.nsc || sattrs.ns) {
197
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
198
"...really SecureFault with SFSR.INVEP\n");
199
return false;
200
}
201
- if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, &physaddr,
202
- &attrs, &prot, &page_size, &fi, &cacheattrs)) {
203
+ if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, &res, &fi)) {
204
/* the MPU lookup failed */
205
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK;
206
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, env->v7m.secure);
207
qemu_log_mask(CPU_LOG_INT, "...really MemManage with CFSR.IACCVIOL\n");
208
return false;
209
}
210
- *insn = address_space_lduw_le(arm_addressspace(cs, attrs), physaddr,
211
- attrs, &txres);
212
+ *insn = address_space_lduw_le(arm_addressspace(cs, res.attrs), res.phys,
213
+ res.attrs, &txres);
214
if (txres != MEMTX_OK) {
215
env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK;
216
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
217
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx,
218
*/
219
CPUState *cs = CPU(cpu);
220
CPUARMState *env = &cpu->env;
221
- MemTxAttrs attrs = {};
222
MemTxResult txres;
223
- target_ulong page_size;
224
- hwaddr physaddr;
225
- int prot;
226
+ GetPhysAddrResult res = {};
227
ARMMMUFaultInfo fi = {};
228
- ARMCacheAttrs cacheattrs = {};
229
uint32_t value;
230
231
- if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &physaddr,
232
- &attrs, &prot, &page_size, &fi, &cacheattrs)) {
233
+ if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) {
234
/* MPU/SAU lookup failed */
235
if (fi.type == ARMFault_QEMU_SFault) {
236
qemu_log_mask(CPU_LOG_INT,
237
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx,
238
}
239
return false;
240
}
241
- value = address_space_ldl(arm_addressspace(cs, attrs), physaddr,
242
- attrs, &txres);
243
+ value = address_space_ldl(arm_addressspace(cs, res.attrs), res.phys,
244
+ res.attrs, &txres);
245
if (txres != MEMTX_OK) {
246
/* BusFault trying to read the data */
247
qemu_log_mask(CPU_LOG_INT,
248
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
249
index XXXXXXX..XXXXXXX 100644
250
--- a/target/arm/ptw.c
251
+++ b/target/arm/ptw.c
252
@@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(CPUARMState *env,
253
* @address: virtual address to get physical address for
254
* @access_type: 0 for read, 1 for write, 2 for execute
255
* @mmu_idx: MMU index indicating required translation regime
256
- * @phys_ptr: set to the physical address corresponding to the virtual address
257
- * @attrs: set to the memory transaction attributes to use
258
- * @prot: set to the permissions for the page containing phys_ptr
259
- * @page_size: set to the size of the page containing phys_ptr
260
+ * @result: set on translation success.
261
* @fi: set to fault info if the translation fails
262
- * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
263
*/
264
bool get_phys_addr(CPUARMState *env, target_ulong address,
265
MMUAccessType access_type, ARMMMUIdx mmu_idx,
266
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
267
- target_ulong *page_size,
268
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
269
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
270
{
271
ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx);
272
273
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
274
*/
275
if (arm_feature(env, ARM_FEATURE_EL2)) {
276
hwaddr ipa;
277
- int s2_prot;
278
+ int s1_prot;
279
int ret;
280
bool ipa_secure;
281
- ARMCacheAttrs cacheattrs2 = {};
282
+ ARMCacheAttrs cacheattrs1;
283
ARMMMUIdx s2_mmu_idx;
284
bool is_el0;
285
286
- ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa,
287
- attrs, prot, page_size, fi, cacheattrs);
288
+ ret = get_phys_addr(env, address, access_type, s1_mmu_idx,
289
+ result, fi);
290
291
/* If S1 fails or S2 is disabled, return early. */
292
if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2)) {
293
- *phys_ptr = ipa;
294
return ret;
295
}
296
297
- ipa_secure = attrs->secure;
298
+ ipa = result->phys;
299
+ ipa_secure = result->attrs.secure;
300
if (arm_is_secure_below_el3(env)) {
301
if (ipa_secure) {
302
- attrs->secure = !(env->cp15.vstcr_el2 & VSTCR_SW);
303
+ result->attrs.secure = !(env->cp15.vstcr_el2 & VSTCR_SW);
304
} else {
305
- attrs->secure = !(env->cp15.vtcr_el2 & VTCR_NSW);
306
+ result->attrs.secure = !(env->cp15.vtcr_el2 & VTCR_NSW);
307
}
308
} else {
309
assert(!ipa_secure);
310
}
311
312
- s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
313
+ s2_mmu_idx = (result->attrs.secure
314
+ ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2);
315
is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0;
316
317
- /* S1 is done. Now do S2 translation. */
318
+ /*
319
+ * S1 is done, now do S2 translation.
320
+ * Save the stage1 results so that we may merge
321
+ * prot and cacheattrs later.
322
+ */
323
+ s1_prot = result->prot;
324
+ cacheattrs1 = result->cacheattrs;
325
+ memset(result, 0, sizeof(*result));
45
+
326
+
46
for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) {
327
ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0,
47
Object *obj;
328
- phys_ptr, attrs, &s2_prot,
48
329
- page_size, fi, &cacheattrs2);
49
- object_initialize_child(OBJECT(s), "apu-cpu[*]", &s->fpd.apu.cpu[i],
330
+ &result->phys, &result->attrs,
50
+ object_initialize_child(OBJECT(&s->fpd.apu.cluster),
331
+ &result->prot, &result->page_size,
51
+ "apu-cpu[*]", &s->fpd.apu.cpu[i],
332
+ fi, &result->cacheattrs);
52
XLNX_VERSAL_ACPU_TYPE);
333
fi->s2addr = ipa;
53
obj = OBJECT(&s->fpd.apu.cpu[i]);
54
if (i) {
55
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
56
&error_abort);
57
qdev_realize(DEVICE(obj), NULL, &error_fatal);
58
}
59
+
334
+
60
+ qdev_realize(DEVICE(&s->fpd.apu.cluster), NULL, &error_fatal);
335
/* Combine the S1 and S2 perms. */
336
- *prot &= s2_prot;
337
+ result->prot &= s1_prot;
338
339
/* If S2 fails, return early. */
340
if (ret) {
341
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
342
* Outer Write-Back Read-Allocate Write-Allocate.
343
* Do not overwrite Tagged within attrs.
344
*/
345
- if (cacheattrs->attrs != 0xf0) {
346
- cacheattrs->attrs = 0xff;
347
+ if (cacheattrs1.attrs != 0xf0) {
348
+ cacheattrs1.attrs = 0xff;
349
}
350
- cacheattrs->shareability = 0;
351
+ cacheattrs1.shareability = 0;
352
}
353
- *cacheattrs = combine_cacheattrs(env, *cacheattrs, cacheattrs2);
354
+ result->cacheattrs = combine_cacheattrs(env, cacheattrs1,
355
+ result->cacheattrs);
356
357
/* Check if IPA translates to secure or non-secure PA space. */
358
if (arm_is_secure_below_el3(env)) {
359
if (ipa_secure) {
360
- attrs->secure =
361
+ result->attrs.secure =
362
!(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW));
363
} else {
364
- attrs->secure =
365
+ result->attrs.secure =
366
!((env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))
367
|| (env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)));
368
}
369
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
370
* cannot upgrade an non-secure translation regime's attributes
371
* to secure.
372
*/
373
- attrs->secure = regime_is_secure(env, mmu_idx);
374
- attrs->user = regime_is_user(env, mmu_idx);
375
+ result->attrs.secure = regime_is_secure(env, mmu_idx);
376
+ result->attrs.user = regime_is_user(env, mmu_idx);
377
378
/*
379
* Fast Context Switch Extension. This doesn't exist at all in v8.
380
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
381
382
if (arm_feature(env, ARM_FEATURE_PMSA)) {
383
bool ret;
384
- *page_size = TARGET_PAGE_SIZE;
385
+ result->page_size = TARGET_PAGE_SIZE;
386
387
if (arm_feature(env, ARM_FEATURE_V8)) {
388
/* PMSAv8 */
389
ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx,
390
- phys_ptr, attrs, prot, page_size, fi);
391
+ &result->phys, &result->attrs,
392
+ &result->prot, &result->page_size, fi);
393
} else if (arm_feature(env, ARM_FEATURE_V7)) {
394
/* PMSAv7 */
395
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
396
- phys_ptr, prot, page_size, fi);
397
+ &result->phys, &result->prot,
398
+ &result->page_size, fi);
399
} else {
400
/* Pre-v7 MPU */
401
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
402
- phys_ptr, prot, fi);
403
+ &result->phys, &result->prot, fi);
404
}
405
qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32
406
" mmu_idx %u -> %s (prot %c%c%c)\n",
407
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
408
(access_type == MMU_DATA_STORE ? "writing" : "execute"),
409
(uint32_t)address, mmu_idx,
410
ret ? "Miss" : "Hit",
411
- *prot & PAGE_READ ? 'r' : '-',
412
- *prot & PAGE_WRITE ? 'w' : '-',
413
- *prot & PAGE_EXEC ? 'x' : '-');
414
+ result->prot & PAGE_READ ? 'r' : '-',
415
+ result->prot & PAGE_WRITE ? 'w' : '-',
416
+ result->prot & PAGE_EXEC ? 'x' : '-');
417
418
return ret;
419
}
420
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
421
address = extract64(address, 0, 52);
422
}
423
}
424
- *phys_ptr = address;
425
- *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
426
- *page_size = TARGET_PAGE_SIZE;
427
+ result->phys = address;
428
+ result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
429
+ result->page_size = TARGET_PAGE_SIZE;
430
431
/* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */
432
hcr = arm_hcr_el2_eff(env);
433
- cacheattrs->shareability = 0;
434
- cacheattrs->is_s2_format = false;
435
+ result->cacheattrs.shareability = 0;
436
+ result->cacheattrs.is_s2_format = false;
437
if (hcr & HCR_DC) {
438
if (hcr & HCR_DCT) {
439
memattr = 0xf0; /* Tagged, Normal, WB, RWA */
440
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
441
} else {
442
memattr = 0x44; /* Normal, NC, No */
443
}
444
- cacheattrs->shareability = 2; /* outer sharable */
445
+ result->cacheattrs.shareability = 2; /* outer sharable */
446
} else {
447
memattr = 0x00; /* Device, nGnRnE */
448
}
449
- cacheattrs->attrs = memattr;
450
+ result->cacheattrs.attrs = memattr;
451
return 0;
452
}
453
454
if (regime_using_lpae_format(env, mmu_idx)) {
455
return get_phys_addr_lpae(env, address, access_type, mmu_idx, false,
456
- phys_ptr, attrs, prot, page_size,
457
- fi, cacheattrs);
458
+ &result->phys, &result->attrs,
459
+ &result->prot, &result->page_size,
460
+ fi, &result->cacheattrs);
461
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
462
return get_phys_addr_v6(env, address, access_type, mmu_idx,
463
- phys_ptr, attrs, prot, page_size, fi);
464
+ &result->phys, &result->attrs,
465
+ &result->prot, &result->page_size, fi);
466
} else {
467
return get_phys_addr_v5(env, address, access_type, mmu_idx,
468
- phys_ptr, prot, page_size, fi);
469
+ &result->phys, &result->prot,
470
+ &result->page_size, fi);
471
}
61
}
472
}
62
473
63
static void versal_create_apu_gic(Versal *s, qemu_irq *pic)
474
@@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
475
{
476
ARMCPU *cpu = ARM_CPU(cs);
477
CPUARMState *env = &cpu->env;
478
- hwaddr phys_addr;
479
- target_ulong page_size;
480
- int prot;
481
- bool ret;
482
+ GetPhysAddrResult res = {};
483
ARMMMUFaultInfo fi = {};
484
ARMMMUIdx mmu_idx = arm_mmu_idx(env);
485
- ARMCacheAttrs cacheattrs = {};
486
+ bool ret;
487
488
- *attrs = (MemTxAttrs) {};
489
-
490
- ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr,
491
- attrs, &prot, &page_size, &fi, &cacheattrs);
492
+ ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi);
493
+ *attrs = res.attrs;
494
495
if (ret) {
496
return -1;
497
}
498
- return phys_addr;
499
+ return res.phys;
500
}
501
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
502
index XXXXXXX..XXXXXXX 100644
503
--- a/target/arm/tlb_helper.c
504
+++ b/target/arm/tlb_helper.c
505
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
506
{
507
ARMCPU *cpu = ARM_CPU(cs);
508
ARMMMUFaultInfo fi = {};
509
- hwaddr phys_addr;
510
- target_ulong page_size;
511
- int prot, ret;
512
- MemTxAttrs attrs = {};
513
- ARMCacheAttrs cacheattrs = {};
514
+ GetPhysAddrResult res = {};
515
+ int ret;
516
517
/*
518
* Walk the page table and (if the mapping exists) add the page
519
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
520
*/
521
ret = get_phys_addr(&cpu->env, address, access_type,
522
core_to_arm_mmu_idx(&cpu->env, mmu_idx),
523
- &phys_addr, &attrs, &prot, &page_size,
524
- &fi, &cacheattrs);
525
+ &res, &fi);
526
if (likely(!ret)) {
527
/*
528
* Map a single [sub]page. Regions smaller than our declared
529
* target page size are handled specially, so for those we
530
* pass in the exact addresses.
531
*/
532
- if (page_size >= TARGET_PAGE_SIZE) {
533
- phys_addr &= TARGET_PAGE_MASK;
534
+ if (res.page_size >= TARGET_PAGE_SIZE) {
535
+ res.phys &= TARGET_PAGE_MASK;
536
address &= TARGET_PAGE_MASK;
537
}
538
/* Notice and record tagged memory. */
539
- if (cpu_isar_feature(aa64_mte, cpu) && cacheattrs.attrs == 0xf0) {
540
- arm_tlb_mte_tagged(&attrs) = true;
541
+ if (cpu_isar_feature(aa64_mte, cpu) && res.cacheattrs.attrs == 0xf0) {
542
+ arm_tlb_mte_tagged(&res.attrs) = true;
543
}
544
545
- tlb_set_page_with_attrs(cs, address, phys_addr, attrs,
546
- prot, mmu_idx, page_size);
547
+ tlb_set_page_with_attrs(cs, address, res.phys, res.attrs,
548
+ res.prot, mmu_idx, res.page_size);
549
return true;
550
} else if (probe) {
551
return false;
64
--
552
--
65
2.25.1
553
2.25.1
diff view generated by jsdifflib
1
From: Zongyuan Li <zongyuan.li@smartx.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com>
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-4-richard.henderson@linaro.org
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20220324181557.203805-3-zongyuan.li@smartx.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
---
8
hw/arm/stellaris.c | 15 +++++++++++++--
9
target/arm/ptw.c | 69 ++++++++++++++++++------------------------------
9
1 file changed, 13 insertions(+), 2 deletions(-)
10
1 file changed, 26 insertions(+), 43 deletions(-)
10
11
11
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
12
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/stellaris.c
14
--- a/target/arm/ptw.c
14
+++ b/hw/arm/stellaris.c
15
+++ b/target/arm/ptw.c
15
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@
16
17
17
#include "qemu/osdep.h"
18
static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
18
#include "qapi/error.h"
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
19
+#include "hw/core/split-irq.h"
20
- bool s1_is_el0, hwaddr *phys_ptr,
20
#include "hw/sysbus.h"
21
- MemTxAttrs *txattrs, int *prot,
21
#include "hw/sd/sd.h"
22
- target_ulong *page_size_ptr,
22
#include "hw/ssi/ssi.h"
23
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
23
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
24
+ bool s1_is_el0, GetPhysAddrResult *result,
24
DeviceState *ssddev;
25
+ ARMMMUFaultInfo *fi)
25
DriveInfo *dinfo;
26
__attribute__((nonnull));
26
DeviceState *carddev;
27
27
+ DeviceState *gpio_d_splitter;
28
/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */
28
BlockBackend *blk;
29
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
29
30
{
31
if (arm_mmu_idx_is_stage1_of_2(mmu_idx) &&
32
!regime_translation_disabled(env, ARMMMUIdx_Stage2)) {
33
- target_ulong s2size;
34
- hwaddr s2pa;
35
- int s2prot;
36
- int ret;
37
ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S
38
: ARMMMUIdx_Stage2;
39
- ARMCacheAttrs cacheattrs = {};
40
- MemTxAttrs txattrs = {};
41
+ GetPhysAddrResult s2 = {};
42
+ int ret;
43
44
ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, false,
45
- &s2pa, &txattrs, &s2prot, &s2size, fi,
46
- &cacheattrs);
47
+ &s2, fi);
48
if (ret) {
49
assert(fi->type != ARMFault_None);
50
fi->s2addr = addr;
51
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
52
return ~0;
53
}
54
if ((arm_hcr_el2_eff(env) & HCR_PTW) &&
55
- ptw_attrs_are_device(env, cacheattrs)) {
56
+ ptw_attrs_are_device(env, s2.cacheattrs)) {
30
/*
57
/*
31
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
58
* PTW set and S1 walk touched S2 Device memory:
32
&error_fatal);
59
* generate Permission fault.
33
60
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
34
ssddev = ssi_create_peripheral(bus, "ssd0323");
61
assert(!*is_secure);
35
- gpio_out[GPIO_D][0] = qemu_irq_split(
62
}
36
- qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0),
63
37
+
64
- addr = s2pa;
38
+ gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ);
65
+ addr = s2.phys;
39
+ qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2);
66
}
40
+ qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal);
67
return addr;
41
+ qdev_connect_gpio_out(
68
}
42
+ gpio_d_splitter, 0,
69
@@ -XXX,XX +XXX,XX @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level,
43
+ qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0));
70
* table walk), must be true if this is stage 2 of a stage 1+2
44
+ qdev_connect_gpio_out(
71
* walk for an EL0 access. If @mmu_idx is anything else,
45
+ gpio_d_splitter, 1,
72
* @s1_is_el0 is ignored.
46
qdev_get_gpio_in_named(ssddev, SSI_GPIO_CS, 0));
73
- * @phys_ptr: set to the physical address corresponding to the virtual address
47
+ gpio_out[GPIO_D][0] = qdev_get_gpio_in(gpio_d_splitter, 0);
74
- * @attrs: set to the memory transaction attributes to use
48
+
75
- * @prot: set to the permissions for the page containing phys_ptr
49
gpio_out[GPIO_C][7] = qdev_get_gpio_in(ssddev, 0);
76
- * @page_size_ptr: set to the size of the page containing phys_ptr
50
77
+ * @result: set on translation success,
51
/* Make sure the select pin is high. */
78
* @fi: set to fault info if the translation fails
79
- * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
80
*/
81
static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
82
MMUAccessType access_type, ARMMMUIdx mmu_idx,
83
- bool s1_is_el0, hwaddr *phys_ptr,
84
- MemTxAttrs *txattrs, int *prot,
85
- target_ulong *page_size_ptr,
86
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
87
+ bool s1_is_el0, GetPhysAddrResult *result,
88
+ ARMMMUFaultInfo *fi)
89
{
90
ARMCPU *cpu = env_archcpu(env);
91
/* Read an LPAE long-descriptor translation table. */
92
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
93
if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
94
ns = mmu_idx == ARMMMUIdx_Stage2;
95
xn = extract32(attrs, 11, 2);
96
- *prot = get_S2prot(env, ap, xn, s1_is_el0);
97
+ result->prot = get_S2prot(env, ap, xn, s1_is_el0);
98
} else {
99
ns = extract32(attrs, 3, 1);
100
xn = extract32(attrs, 12, 1);
101
pxn = extract32(attrs, 11, 1);
102
- *prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
103
+ result->prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
104
}
105
106
fault_type = ARMFault_Permission;
107
- if (!(*prot & (1 << access_type))) {
108
+ if (!(result->prot & (1 << access_type))) {
109
goto do_fault;
110
}
111
112
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
113
* the CPU doesn't support TZ or this is a non-secure translation
114
* regime, because the attribute will already be non-secure.
115
*/
116
- txattrs->secure = false;
117
+ result->attrs.secure = false;
118
}
119
/* When in aarch64 mode, and BTI is enabled, remember GP in the IOTLB. */
120
if (aarch64 && guarded && cpu_isar_feature(aa64_bti, cpu)) {
121
- arm_tlb_bti_gp(txattrs) = true;
122
+ arm_tlb_bti_gp(&result->attrs) = true;
123
}
124
125
if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
126
- cacheattrs->is_s2_format = true;
127
- cacheattrs->attrs = extract32(attrs, 0, 4);
128
+ result->cacheattrs.is_s2_format = true;
129
+ result->cacheattrs.attrs = extract32(attrs, 0, 4);
130
} else {
131
/* Index into MAIR registers for cache attributes */
132
uint8_t attrindx = extract32(attrs, 0, 3);
133
uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)];
134
assert(attrindx <= 7);
135
- cacheattrs->is_s2_format = false;
136
- cacheattrs->attrs = extract64(mair, attrindx * 8, 8);
137
+ result->cacheattrs.is_s2_format = false;
138
+ result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8);
139
}
140
141
/*
142
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
143
* that case comes from TCR_ELx, which we extracted earlier.
144
*/
145
if (param.ds) {
146
- cacheattrs->shareability = param.sh;
147
+ result->cacheattrs.shareability = param.sh;
148
} else {
149
- cacheattrs->shareability = extract32(attrs, 6, 2);
150
+ result->cacheattrs.shareability = extract32(attrs, 6, 2);
151
}
152
153
- *phys_ptr = descaddr;
154
- *page_size_ptr = page_size;
155
+ result->phys = descaddr;
156
+ result->page_size = page_size;
157
return false;
158
159
do_fault:
160
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
161
cacheattrs1 = result->cacheattrs;
162
memset(result, 0, sizeof(*result));
163
164
- ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0,
165
- &result->phys, &result->attrs,
166
- &result->prot, &result->page_size,
167
- fi, &result->cacheattrs);
168
+ ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx,
169
+ is_el0, result, fi);
170
fi->s2addr = ipa;
171
172
/* Combine the S1 and S2 perms. */
173
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
174
175
if (regime_using_lpae_format(env, mmu_idx)) {
176
return get_phys_addr_lpae(env, address, access_type, mmu_idx, false,
177
- &result->phys, &result->attrs,
178
- &result->prot, &result->page_size,
179
- fi, &result->cacheattrs);
180
+ result, fi);
181
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
182
return get_phys_addr_v6(env, address, access_type, mmu_idx,
183
&result->phys, &result->attrs,
52
--
184
--
53
2.25.1
185
2.25.1
186
187
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-5-richard.henderson@linaro.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
target/arm/ptw.c | 30 ++++++++++++++----------------
10
1 file changed, 14 insertions(+), 16 deletions(-)
11
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/ptw.c
15
+++ b/target/arm/ptw.c
16
@@ -XXX,XX +XXX,XX @@ do_fault:
17
18
static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
20
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
21
- target_ulong *page_size, ARMMMUFaultInfo *fi)
22
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
23
{
24
ARMCPU *cpu = env_archcpu(env);
25
int level = 1;
26
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
27
phys_addr = (desc & 0xff000000) | (address & 0x00ffffff);
28
phys_addr |= (uint64_t)extract32(desc, 20, 4) << 32;
29
phys_addr |= (uint64_t)extract32(desc, 5, 4) << 36;
30
- *page_size = 0x1000000;
31
+ result->page_size = 0x1000000;
32
} else {
33
/* Section. */
34
phys_addr = (desc & 0xfff00000) | (address & 0x000fffff);
35
- *page_size = 0x100000;
36
+ result->page_size = 0x100000;
37
}
38
ap = ((desc >> 10) & 3) | ((desc >> 13) & 4);
39
xn = desc & (1 << 4);
40
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
41
case 1: /* 64k page. */
42
phys_addr = (desc & 0xffff0000) | (address & 0xffff);
43
xn = desc & (1 << 15);
44
- *page_size = 0x10000;
45
+ result->page_size = 0x10000;
46
break;
47
case 2: case 3: /* 4k page. */
48
phys_addr = (desc & 0xfffff000) | (address & 0xfff);
49
xn = desc & 1;
50
- *page_size = 0x1000;
51
+ result->page_size = 0x1000;
52
break;
53
default:
54
/* Never happens, but compiler isn't smart enough to tell. */
55
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
56
}
57
}
58
if (domain_prot == 3) {
59
- *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
60
+ result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
61
} else {
62
if (pxn && !regime_is_user(env, mmu_idx)) {
63
xn = 1;
64
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
65
fi->type = ARMFault_AccessFlag;
66
goto do_fault;
67
}
68
- *prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1);
69
+ result->prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1);
70
} else {
71
- *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
72
+ result->prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
73
}
74
- if (*prot && !xn) {
75
- *prot |= PAGE_EXEC;
76
+ if (result->prot && !xn) {
77
+ result->prot |= PAGE_EXEC;
78
}
79
- if (!(*prot & (1 << access_type))) {
80
+ if (!(result->prot & (1 << access_type))) {
81
/* Access permission fault. */
82
fi->type = ARMFault_Permission;
83
goto do_fault;
84
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
85
* the CPU doesn't support TZ or this is a non-secure translation
86
* regime, because the attribute will already be non-secure.
87
*/
88
- attrs->secure = false;
89
+ result->attrs.secure = false;
90
}
91
- *phys_ptr = phys_addr;
92
+ result->phys = phys_addr;
93
return false;
94
do_fault:
95
fi->domain = domain;
96
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
97
result, fi);
98
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
99
return get_phys_addr_v6(env, address, access_type, mmu_idx,
100
- &result->phys, &result->attrs,
101
- &result->prot, &result->page_size, fi);
102
+ result, fi);
103
} else {
104
return get_phys_addr_v5(env, address, access_type, mmu_idx,
105
&result->phys, &result->prot,
106
--
107
2.25.1
108
109
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This patch uses the defined fields to describe PWRON STRAPs for
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
better readability.
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
5
Message-id: 20220822152741.1617527-6-richard.henderson@linaro.org
6
Signed-off-by: Hao Wu <wuhaotsh@google.com>
7
Reviewed-by: Patrick Venture <venture@google.com>
8
Message-id: 20220411165842.3912945-3-wuhaotsh@google.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
8
---
12
hw/arm/npcm7xx_boards.c | 24 +++++++++++++++++++-----
9
target/arm/ptw.c | 25 +++++++++++--------------
13
1 file changed, 19 insertions(+), 5 deletions(-)
10
1 file changed, 11 insertions(+), 14 deletions(-)
14
11
15
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/npcm7xx_boards.c
14
--- a/target/arm/ptw.c
18
+++ b/hw/arm/npcm7xx_boards.c
15
+++ b/target/arm/ptw.c
19
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)
20
#include "sysemu/sysemu.h"
17
21
#include "sysemu/block-backend.h"
18
static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
22
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
23
-#define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7
20
- hwaddr *phys_ptr, int *prot,
24
-#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff
21
- target_ulong *page_size,
25
-#define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff
22
- ARMMMUFaultInfo *fi)
26
-#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff
23
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
27
-#define MORI_BMC_POWER_ON_STRAPS 0x00001fff
24
{
28
+#define NPCM7XX_POWER_ON_STRAPS_DEFAULT ( \
25
int level = 1;
29
+ NPCM7XX_PWRON_STRAP_SPI0F18 | \
26
uint32_t table;
30
+ NPCM7XX_PWRON_STRAP_SFAB | \
27
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
31
+ NPCM7XX_PWRON_STRAP_BSPA | \
28
/* 1Mb section. */
32
+ NPCM7XX_PWRON_STRAP_FUP(FUP_NORM_UART2) | \
29
phys_addr = (desc & 0xfff00000) | (address & 0x000fffff);
33
+ NPCM7XX_PWRON_STRAP_SECEN | \
30
ap = (desc >> 10) & 3;
34
+ NPCM7XX_PWRON_STRAP_HIZ | \
31
- *page_size = 1024 * 1024;
35
+ NPCM7XX_PWRON_STRAP_ECC | \
32
+ result->page_size = 1024 * 1024;
36
+ NPCM7XX_PWRON_STRAP_RESERVE1 | \
33
} else {
37
+ NPCM7XX_PWRON_STRAP_J2EN | \
34
/* Lookup l2 entry. */
38
+ NPCM7XX_PWRON_STRAP_CKFRQ(CKFRQ_DEFAULT))
35
if (type == 1) {
39
+
36
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
40
+#define NPCM750_EVB_POWER_ON_STRAPS ( \
37
case 1: /* 64k page. */
41
+ NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_J2EN)
38
phys_addr = (desc & 0xffff0000) | (address & 0xffff);
42
+#define QUANTA_GSJ_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT
39
ap = (desc >> (4 + ((address >> 13) & 6))) & 3;
43
+#define QUANTA_GBS_POWER_ON_STRAPS ( \
40
- *page_size = 0x10000;
44
+ NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_SFAB)
41
+ result->page_size = 0x10000;
45
+#define KUDO_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT
42
break;
46
+#define MORI_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT
43
case 2: /* 4k page. */
47
44
phys_addr = (desc & 0xfffff000) | (address & 0xfff);
48
static const char npcm7xx_default_bootrom[] = "npcm7xx_bootrom.bin";
45
ap = (desc >> (4 + ((address >> 9) & 6))) & 3;
46
- *page_size = 0x1000;
47
+ result->page_size = 0x1000;
48
break;
49
case 3: /* 1k page, or ARMv6/XScale "extended small (4k) page" */
50
if (type == 1) {
51
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
52
if (arm_feature(env, ARM_FEATURE_XSCALE)
53
|| arm_feature(env, ARM_FEATURE_V6)) {
54
phys_addr = (desc & 0xfffff000) | (address & 0xfff);
55
- *page_size = 0x1000;
56
+ result->page_size = 0x1000;
57
} else {
58
/*
59
* UNPREDICTABLE in ARMv5; we choose to take a
60
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
61
}
62
} else {
63
phys_addr = (desc & 0xfffffc00) | (address & 0x3ff);
64
- *page_size = 0x400;
65
+ result->page_size = 0x400;
66
}
67
ap = (desc >> 4) & 3;
68
break;
69
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
70
g_assert_not_reached();
71
}
72
}
73
- *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
74
- *prot |= *prot ? PAGE_EXEC : 0;
75
- if (!(*prot & (1 << access_type))) {
76
+ result->prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
77
+ result->prot |= result->prot ? PAGE_EXEC : 0;
78
+ if (!(result->prot & (1 << access_type))) {
79
/* Access permission fault. */
80
fi->type = ARMFault_Permission;
81
goto do_fault;
82
}
83
- *phys_ptr = phys_addr;
84
+ result->phys = phys_addr;
85
return false;
86
do_fault:
87
fi->domain = domain;
88
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
89
result, fi);
90
} else {
91
return get_phys_addr_v5(env, address, access_type, mmu_idx,
92
- &result->phys, &result->prot,
93
- &result->page_size, fi);
94
+ result, fi);
95
}
96
}
49
97
50
--
98
--
51
2.25.1
99
2.25.1
100
101
diff view generated by jsdifflib
1
Switch the creation of the combiner devices to the new-style
1
From: Richard Henderson <richard.henderson@linaro.org>
2
"embedded in state struct" approach, so we can easily refer
3
to the object elsewhere during realize.
4
2
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-7-richard.henderson@linaro.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220404154658.565020-18-peter.maydell@linaro.org
8
---
8
---
9
include/hw/arm/exynos4210.h | 3 ++
9
target/arm/ptw.c | 24 ++++++++++++------------
10
include/hw/intc/exynos4210_combiner.h | 57 +++++++++++++++++++++++++++
10
1 file changed, 12 insertions(+), 12 deletions(-)
11
hw/arm/exynos4210.c | 20 +++++-----
12
hw/intc/exynos4210_combiner.c | 31 +--------------
13
4 files changed, 72 insertions(+), 39 deletions(-)
14
create mode 100644 include/hw/intc/exynos4210_combiner.h
15
11
16
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
17
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/exynos4210.h
14
--- a/target/arm/ptw.c
19
+++ b/include/hw/arm/exynos4210.h
15
+++ b/target/arm/ptw.c
20
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ do_fault:
21
#include "hw/sysbus.h"
17
22
#include "hw/cpu/a9mpcore.h"
18
static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
23
#include "hw/intc/exynos4210_gic.h"
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
24
+#include "hw/intc/exynos4210_combiner.h"
20
- hwaddr *phys_ptr, int *prot,
25
#include "hw/core/split-irq.h"
21
+ GetPhysAddrResult *result,
26
#include "target/arm/cpu-qom.h"
22
ARMMMUFaultInfo *fi)
27
#include "qom/object.h"
23
{
28
@@ -XXX,XX +XXX,XX @@ struct Exynos4210State {
24
int n;
29
qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS];
25
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
30
A9MPPrivState a9mpcore;
26
31
Exynos4210GicState ext_gic;
27
if (regime_translation_disabled(env, mmu_idx)) {
32
+ Exynos4210CombinerState int_combiner;
28
/* MPU disabled. */
33
+ Exynos4210CombinerState ext_combiner;
29
- *phys_ptr = address;
34
SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS];
30
- *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
35
};
31
+ result->phys = address;
36
32
+ result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
37
diff --git a/include/hw/intc/exynos4210_combiner.h b/include/hw/intc/exynos4210_combiner.h
33
return false;
38
new file mode 100644
39
index XXXXXXX..XXXXXXX
40
--- /dev/null
41
+++ b/include/hw/intc/exynos4210_combiner.h
42
@@ -XXX,XX +XXX,XX @@
43
+/*
44
+ * Samsung exynos4210 Interrupt Combiner
45
+ *
46
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
47
+ * All rights reserved.
48
+ *
49
+ * Evgeny Voevodin <e.voevodin@samsung.com>
50
+ *
51
+ * This program is free software; you can redistribute it and/or modify it
52
+ * under the terms of the GNU General Public License as published by the
53
+ * Free Software Foundation; either version 2 of the License, or (at your
54
+ * option) any later version.
55
+ *
56
+ * This program is distributed in the hope that it will be useful,
57
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
58
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
59
+ * See the GNU General Public License for more details.
60
+ *
61
+ * You should have received a copy of the GNU General Public License along
62
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
63
+ */
64
+
65
+#ifndef HW_INTC_EXYNOS4210_COMBINER
66
+#define HW_INTC_EXYNOS4210_COMBINER
67
+
68
+#include "hw/sysbus.h"
69
+
70
+/*
71
+ * State for each output signal of internal combiner
72
+ */
73
+typedef struct CombinerGroupState {
74
+ uint8_t src_mask; /* 1 - source enabled, 0 - disabled */
75
+ uint8_t src_pending; /* Pending source interrupts before masking */
76
+} CombinerGroupState;
77
+
78
+#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner"
79
+OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER)
80
+
81
+/* Number of groups and total number of interrupts for the internal combiner */
82
+#define IIC_NGRP 64
83
+#define IIC_NIRQ (IIC_NGRP * 8)
84
+#define IIC_REGSET_SIZE 0x41
85
+
86
+struct Exynos4210CombinerState {
87
+ SysBusDevice parent_obj;
88
+
89
+ MemoryRegion iomem;
90
+
91
+ struct CombinerGroupState group[IIC_NGRP];
92
+ uint32_t reg_set[IIC_REGSET_SIZE];
93
+ uint32_t icipsr[2];
94
+ uint32_t external; /* 1 means that this combiner is external */
95
+
96
+ qemu_irq output_irq[IIC_NGRP];
97
+};
98
+
99
+#endif
100
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/hw/arm/exynos4210.c
103
+++ b/hw/arm/exynos4210.c
104
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
105
}
34
}
106
35
107
/* Internal Interrupt Combiner */
36
- *phys_ptr = address;
108
- dev = qdev_new("exynos4210.combiner");
37
+ result->phys = address;
109
- busdev = SYS_BUS_DEVICE(dev);
38
for (n = 7; n >= 0; n--) {
110
- sysbus_realize_and_unref(busdev, &error_fatal);
39
base = env->cp15.c6_region[n];
111
+ busdev = SYS_BUS_DEVICE(&s->int_combiner);
40
if ((base & 1) == 0) {
112
+ sysbus_realize(busdev, &error_fatal);
41
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
113
for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) {
42
fi->level = 1;
114
sysbus_connect_irq(busdev, n,
43
return true;
115
qdev_get_gpio_in(DEVICE(&s->a9mpcore), n));
44
}
45
- *prot = PAGE_READ | PAGE_WRITE;
46
+ result->prot = PAGE_READ | PAGE_WRITE;
47
break;
48
case 2:
49
- *prot = PAGE_READ;
50
+ result->prot = PAGE_READ;
51
if (!is_user) {
52
- *prot |= PAGE_WRITE;
53
+ result->prot |= PAGE_WRITE;
54
}
55
break;
56
case 3:
57
- *prot = PAGE_READ | PAGE_WRITE;
58
+ result->prot = PAGE_READ | PAGE_WRITE;
59
break;
60
case 5:
61
if (is_user) {
62
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
63
fi->level = 1;
64
return true;
65
}
66
- *prot = PAGE_READ;
67
+ result->prot = PAGE_READ;
68
break;
69
case 6:
70
- *prot = PAGE_READ;
71
+ result->prot = PAGE_READ;
72
break;
73
default:
74
/* Bad permission. */
75
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
76
fi->level = 1;
77
return true;
116
}
78
}
117
- exynos4210_combiner_get_gpioin(&s->irqs, dev, 0);
79
- *prot |= PAGE_EXEC;
118
+ exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0);
80
+ result->prot |= PAGE_EXEC;
119
sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR);
81
return false;
120
121
/* External Interrupt Combiner */
122
- dev = qdev_new("exynos4210.combiner");
123
- qdev_prop_set_uint32(dev, "external", 1);
124
- busdev = SYS_BUS_DEVICE(dev);
125
- sysbus_realize_and_unref(busdev, &error_fatal);
126
+ qdev_prop_set_uint32(DEVICE(&s->ext_combiner), "external", 1);
127
+ busdev = SYS_BUS_DEVICE(&s->ext_combiner);
128
+ sysbus_realize(busdev, &error_fatal);
129
for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) {
130
sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n));
131
}
132
- exynos4210_combiner_get_gpioin(&s->irqs, dev, 1);
133
+ exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1);
134
sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR);
135
136
/* Initialize board IRQs. */
137
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj)
138
139
object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV);
140
object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC);
141
+ object_initialize_child(obj, "int-combiner", &s->int_combiner,
142
+ TYPE_EXYNOS4210_COMBINER);
143
+ object_initialize_child(obj, "ext-combiner", &s->ext_combiner,
144
+ TYPE_EXYNOS4210_COMBINER);
145
}
82
}
146
83
147
static void exynos4210_class_init(ObjectClass *klass, void *data)
84
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
148
diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c
85
} else {
149
index XXXXXXX..XXXXXXX 100644
86
/* Pre-v7 MPU */
150
--- a/hw/intc/exynos4210_combiner.c
87
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
151
+++ b/hw/intc/exynos4210_combiner.c
88
- &result->phys, &result->prot, fi);
152
@@ -XXX,XX +XXX,XX @@
89
+ result, fi);
153
#include "hw/sysbus.h"
90
}
154
#include "migration/vmstate.h"
91
qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32
155
#include "qemu/module.h"
92
" mmu_idx %u -> %s (prot %c%c%c)\n",
156
-
157
+#include "hw/intc/exynos4210_combiner.h"
158
#include "hw/arm/exynos4210.h"
159
#include "hw/hw.h"
160
#include "hw/irq.h"
161
@@ -XXX,XX +XXX,XX @@
162
#define DPRINTF(fmt, ...) do {} while (0)
163
#endif
164
165
-#define IIC_NGRP 64 /* Internal Interrupt Combiner
166
- Groups number */
167
-#define IIC_NIRQ (IIC_NGRP * 8)/* Internal Interrupt Combiner
168
- Interrupts number */
169
#define IIC_REGION_SIZE 0x108 /* Size of memory mapped region */
170
-#define IIC_REGSET_SIZE 0x41
171
-
172
-/*
173
- * State for each output signal of internal combiner
174
- */
175
-typedef struct CombinerGroupState {
176
- uint8_t src_mask; /* 1 - source enabled, 0 - disabled */
177
- uint8_t src_pending; /* Pending source interrupts before masking */
178
-} CombinerGroupState;
179
-
180
-#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner"
181
-OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER)
182
-
183
-struct Exynos4210CombinerState {
184
- SysBusDevice parent_obj;
185
-
186
- MemoryRegion iomem;
187
-
188
- struct CombinerGroupState group[IIC_NGRP];
189
- uint32_t reg_set[IIC_REGSET_SIZE];
190
- uint32_t icipsr[2];
191
- uint32_t external; /* 1 means that this combiner is external */
192
-
193
- qemu_irq output_irq[IIC_NGRP];
194
-};
195
196
static const VMStateDescription vmstate_exynos4210_combiner_group_state = {
197
.name = "exynos4210.combiner.groupstate",
198
--
93
--
199
2.25.1
94
2.25.1
95
96
diff view generated by jsdifflib
1
The only time we use the int_combiner_irq[] and ext_combiner_irq[]
1
From: Richard Henderson <richard.henderson@linaro.org>
2
arrays in the Exynos4210Irq struct is during realize of the SoC -- we
3
initialize them with the input IRQs of the combiner devices, and then
4
connect those to outputs of other devices in
5
exynos4210_init_board_irqs(). Now that the combiner objects are
6
easily accessible as s->int_combiner and s->ext_combiner we can make
7
the connections directly from one device to the other without going
8
via these arrays.
9
2
10
Since these are the only two remaining elements of Exynos4210Irq,
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
we can remove that struct entirely.
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-8-richard.henderson@linaro.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
target/arm/ptw.c | 36 +++++++++++++++++-------------------
10
1 file changed, 17 insertions(+), 19 deletions(-)
12
11
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20220404154658.565020-19-peter.maydell@linaro.org
16
---
17
include/hw/arm/exynos4210.h | 6 ------
18
hw/arm/exynos4210.c | 34 ++++++++--------------------------
19
2 files changed, 8 insertions(+), 32 deletions(-)
20
21
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
22
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/exynos4210.h
14
--- a/target/arm/ptw.c
24
+++ b/include/hw/arm/exynos4210.h
15
+++ b/target/arm/ptw.c
25
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
26
*/
17
27
#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38)
18
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
28
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
29
-typedef struct Exynos4210Irq {
20
- hwaddr *phys_ptr, int *prot,
30
- qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
21
- target_ulong *page_size,
31
- qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ];
22
+ GetPhysAddrResult *result,
32
-} Exynos4210Irq;
23
ARMMMUFaultInfo *fi)
33
-
34
struct Exynos4210State {
35
/*< private >*/
36
SysBusDevice parent_obj;
37
/*< public >*/
38
ARMCPU *cpu[EXYNOS4210_NCPUS];
39
- Exynos4210Irq irqs;
40
qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
41
42
MemoryRegion chipid_mem;
43
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/arm/exynos4210.c
46
+++ b/hw/arm/exynos4210.c
47
@@ -XXX,XX +XXX,XX @@ static int mapline_size(const int *mapline)
48
static void exynos4210_init_board_irqs(Exynos4210State *s)
49
{
24
{
50
uint32_t grp, bit, irq_id, n;
25
ARMCPU *cpu = env_archcpu(env);
51
- Exynos4210Irq *is = &s->irqs;
26
int n;
52
DeviceState *extgicdev = DEVICE(&s->ext_gic);
27
bool is_user = regime_is_user(env, mmu_idx);
53
+ DeviceState *intcdev = DEVICE(&s->int_combiner);
28
54
+ DeviceState *extcdev = DEVICE(&s->ext_combiner);
29
- *phys_ptr = address;
55
int splitcount = 0;
30
- *page_size = TARGET_PAGE_SIZE;
56
DeviceState *splitter;
31
- *prot = 0;
57
const int *mapline;
32
+ result->phys = address;
58
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
33
+ result->page_size = TARGET_PAGE_SIZE;
59
splitin = 0;
34
+ result->prot = 0;
60
for (;;) {
35
61
s->irq_table[in] = qdev_get_gpio_in(splitter, 0);
36
if (regime_translation_disabled(env, mmu_idx) ||
62
- qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]);
37
m_is_ppb_region(env, address)) {
63
- qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]);
38
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
64
+ qdev_connect_gpio_out(splitter, splitin,
39
* which always does a direct read using address_space_ldl(), rather
65
+ qdev_get_gpio_in(intcdev, in));
40
* than going via this function, so we don't need to check that here.
66
+ qdev_connect_gpio_out(splitter, splitin + 1,
41
*/
67
+ qdev_get_gpio_in(extcdev, in));
42
- get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
68
splitin += 2;
43
+ get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
69
if (!mapline) {
44
} else { /* MPU enabled */
70
break;
45
for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
71
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
46
/* region search */
72
qdev_realize(splitter, NULL, &error_abort);
47
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
73
splitcount++;
48
if (ranges_overlap(base, rmask,
74
s->irq_table[n] = qdev_get_gpio_in(splitter, 0);
49
address & TARGET_PAGE_MASK,
75
- qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]);
50
TARGET_PAGE_SIZE)) {
76
+ qdev_connect_gpio_out(splitter, 0, qdev_get_gpio_in(intcdev, n));
51
- *page_size = 1;
77
qdev_connect_gpio_out(splitter, 1,
52
+ result->page_size = 1;
78
qdev_get_gpio_in(extgicdev, irq_id - 32));
53
}
79
} else {
54
continue;
80
- s->irq_table[n] = is->int_combiner_irq[n];
55
}
81
+ s->irq_table[n] = qdev_get_gpio_in(intcdev, n);
56
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
57
continue;
58
}
59
if (rsize < TARGET_PAGE_BITS) {
60
- *page_size = 1 << rsize;
61
+ result->page_size = 1 << rsize;
62
}
63
break;
64
}
65
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
66
fi->type = ARMFault_Background;
67
return true;
68
}
69
- get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
70
+ get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
71
} else { /* a MPU hit! */
72
uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3);
73
uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1);
74
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
75
case 5:
76
break; /* no access */
77
case 3:
78
- *prot |= PAGE_WRITE;
79
+ result->prot |= PAGE_WRITE;
80
/* fall through */
81
case 2:
82
case 6:
83
- *prot |= PAGE_READ | PAGE_EXEC;
84
+ result->prot |= PAGE_READ | PAGE_EXEC;
85
break;
86
case 7:
87
/* for v7M, same as 6; for R profile a reserved value */
88
if (arm_feature(env, ARM_FEATURE_M)) {
89
- *prot |= PAGE_READ | PAGE_EXEC;
90
+ result->prot |= PAGE_READ | PAGE_EXEC;
91
break;
92
}
93
/* fall through */
94
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
95
case 1:
96
case 2:
97
case 3:
98
- *prot |= PAGE_WRITE;
99
+ result->prot |= PAGE_WRITE;
100
/* fall through */
101
case 5:
102
case 6:
103
- *prot |= PAGE_READ | PAGE_EXEC;
104
+ result->prot |= PAGE_READ | PAGE_EXEC;
105
break;
106
case 7:
107
/* for v7M, same as 6; for R profile a reserved value */
108
if (arm_feature(env, ARM_FEATURE_M)) {
109
- *prot |= PAGE_READ | PAGE_EXEC;
110
+ result->prot |= PAGE_READ | PAGE_EXEC;
111
break;
112
}
113
/* fall through */
114
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
115
116
/* execute never */
117
if (xn) {
118
- *prot &= ~PAGE_EXEC;
119
+ result->prot &= ~PAGE_EXEC;
120
}
82
}
121
}
83
}
122
}
84
/*
123
85
@@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit)
124
fi->type = ARMFault_Permission;
86
return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit);
125
fi->level = 1;
126
- return !(*prot & (1 << access_type));
127
+ return !(result->prot & (1 << access_type));
87
}
128
}
88
129
89
-/*
130
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
90
- * Get Combiner input GPIO into irqs structure
131
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
91
- */
132
} else if (arm_feature(env, ARM_FEATURE_V7)) {
92
-static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs,
133
/* PMSAv7 */
93
- DeviceState *dev, int ext)
134
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
94
-{
135
- &result->phys, &result->prot,
95
- int n;
136
- &result->page_size, fi);
96
- int max;
137
+ result, fi);
97
- qemu_irq *irq;
138
} else {
98
-
139
/* Pre-v7 MPU */
99
- max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ :
140
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
100
- EXYNOS4210_MAX_INT_COMBINER_IN_IRQ;
101
- irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq;
102
-
103
- for (n = 0; n < max; n++) {
104
- irq[n] = qdev_get_gpio_in(dev, n);
105
- }
106
-}
107
-
108
static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43,
109
0x09, 0x00, 0x00, 0x00 };
110
111
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
112
sysbus_connect_irq(busdev, n,
113
qdev_get_gpio_in(DEVICE(&s->a9mpcore), n));
114
}
115
- exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0);
116
sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR);
117
118
/* External Interrupt Combiner */
119
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
120
for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) {
121
sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n));
122
}
123
- exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1);
124
sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR);
125
126
/* Initialize board IRQs. */
127
--
141
--
128
2.25.1
142
2.25.1
143
144
diff view generated by jsdifflib
1
In exynos4210_init_board_irqs(), use the TYPE_SPLIT_IRQ device
1
From: Richard Henderson <richard.henderson@linaro.org>
2
instead of qemu_irq_split().
3
2
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-9-richard.henderson@linaro.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20220404154658.565020-13-peter.maydell@linaro.org
7
---
8
---
8
include/hw/arm/exynos4210.h | 9 ++++++++
9
target/arm/ptw.c | 28 ++++++++++++++--------------
9
hw/arm/exynos4210.c | 41 +++++++++++++++++++++++++++++--------
10
1 file changed, 14 insertions(+), 14 deletions(-)
10
2 files changed, 42 insertions(+), 8 deletions(-)
11
11
12
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
13
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/arm/exynos4210.h
14
--- a/target/arm/ptw.c
15
+++ b/include/hw/arm/exynos4210.h
15
+++ b/target/arm/ptw.c
16
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
17
#include "hw/sysbus.h"
17
18
#include "hw/cpu/a9mpcore.h"
18
static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
19
#include "hw/intc/exynos4210_gic.h"
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
20
+#include "hw/core/split-irq.h"
20
- hwaddr *phys_ptr, MemTxAttrs *txattrs,
21
#include "target/arm/cpu-qom.h"
21
- int *prot, target_ulong *page_size,
22
#include "qom/object.h"
22
+ GetPhysAddrResult *result,
23
23
ARMMMUFaultInfo *fi)
24
@@ -XXX,XX +XXX,XX @@
24
{
25
25
uint32_t secure = regime_is_secure(env, mmu_idx);
26
#define EXYNOS4210_NUM_DMA 3
26
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
27
27
} else {
28
+/*
28
fi->type = ARMFault_QEMU_SFault;
29
+ * We need one splitter for every external combiner input, plus
29
}
30
+ * one for every non-zero entry in combiner_grp_to_gic_id[].
30
- *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE;
31
+ * We'll assert in exynos4210_init_board_irqs() if this is wrong.
31
- *phys_ptr = address;
32
+ */
32
- *prot = 0;
33
+#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60)
33
+ result->page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE;
34
+
34
+ result->phys = address;
35
typedef struct Exynos4210Irq {
35
+ result->prot = 0;
36
qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
36
return true;
37
qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ];
37
}
38
@@ -XXX,XX +XXX,XX @@ struct Exynos4210State {
39
qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS];
40
A9MPPrivState a9mpcore;
41
Exynos4210GicState ext_gic;
42
+ SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS];
43
};
44
45
#define TYPE_EXYNOS4210_SOC "exynos4210"
46
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/exynos4210.c
49
+++ b/hw/arm/exynos4210.c
50
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
51
uint32_t grp, bit, irq_id, n;
52
Exynos4210Irq *is = &s->irqs;
53
DeviceState *extgicdev = DEVICE(&s->ext_gic);
54
+ int splitcount = 0;
55
+ DeviceState *splitter;
56
57
for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) {
58
irq_id = 0;
59
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
60
/* MCT_G1 is passed to External and GIC */
61
irq_id = EXT_GIC_ID_MCT_G1;
62
}
63
+
64
+ assert(splitcount < EXYNOS4210_NUM_SPLITTERS);
65
+ splitter = DEVICE(&s->splitter[splitcount]);
66
+ qdev_prop_set_uint16(splitter, "num-lines", 2);
67
+ qdev_realize(splitter, NULL, &error_abort);
68
+ splitcount++;
69
+ s->irq_table[n] = qdev_get_gpio_in(splitter, 0);
70
+ qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]);
71
if (irq_id) {
72
- s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
73
- qdev_get_gpio_in(extgicdev,
74
- irq_id - 32));
75
+ qdev_connect_gpio_out(splitter, 1,
76
+ qdev_get_gpio_in(extgicdev, irq_id - 32));
77
} else {
38
} else {
78
- s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
39
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
79
- is->ext_combiner_irq[n]);
40
* might downgrade a secure access to nonsecure.
80
+ qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]);
41
*/
42
if (sattrs.ns) {
43
- txattrs->secure = false;
44
+ result->attrs.secure = false;
45
} else if (!secure) {
46
/*
47
* NS access to S memory must fault.
48
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
49
* for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt().
50
*/
51
fi->type = ARMFault_QEMU_SFault;
52
- *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE;
53
- *phys_ptr = address;
54
- *prot = 0;
55
+ result->page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE;
56
+ result->phys = address;
57
+ result->prot = 0;
58
return true;
59
}
81
}
60
}
82
}
61
}
83
for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) {
62
84
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
63
- ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr,
85
EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit];
64
- txattrs, prot, &mpu_is_subpage, fi, NULL);
86
65
- *page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
87
if (irq_id) {
66
+ ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
88
- s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
67
+ &result->phys, &result->attrs, &result->prot,
89
- qdev_get_gpio_in(extgicdev,
68
+ &mpu_is_subpage, fi, NULL);
90
- irq_id - 32));
69
+ result->page_size =
91
+ assert(splitcount < EXYNOS4210_NUM_SPLITTERS);
70
+ sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
92
+ splitter = DEVICE(&s->splitter[splitcount]);
71
return ret;
93
+ qdev_prop_set_uint16(splitter, "num-lines", 2);
94
+ qdev_realize(splitter, NULL, &error_abort);
95
+ splitcount++;
96
+ s->irq_table[n] = qdev_get_gpio_in(splitter, 0);
97
+ qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]);
98
+ qdev_connect_gpio_out(splitter, 1,
99
+ qdev_get_gpio_in(extgicdev, irq_id - 32));
100
}
101
}
102
+ /*
103
+ * We check this here to avoid a more obscure assert later when
104
+ * qdev_assert_realized_properly() checks that we realized every
105
+ * child object we initialized.
106
+ */
107
+ assert(splitcount == EXYNOS4210_NUM_SPLITTERS);
108
}
72
}
109
73
110
/*
74
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
111
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj)
75
if (arm_feature(env, ARM_FEATURE_V8)) {
112
object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ);
76
/* PMSAv8 */
113
}
77
ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx,
114
78
- &result->phys, &result->attrs,
115
+ for (i = 0; i < ARRAY_SIZE(s->splitter); i++) {
79
- &result->prot, &result->page_size, fi);
116
+ g_autofree char *name = g_strdup_printf("irq-splitter%d", i);
80
+ result, fi);
117
+ object_initialize_child(obj, name, &s->splitter[i], TYPE_SPLIT_IRQ);
81
} else if (arm_feature(env, ARM_FEATURE_V7)) {
118
+ }
82
/* PMSAv7 */
119
+
83
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
120
object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV);
121
object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC);
122
}
123
--
84
--
124
2.25.1
85
2.25.1
86
87
diff view generated by jsdifflib
1
From: Zongyuan Li <zongyuan.li@smartx.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com>
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-10-richard.henderson@linaro.org
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20220324181557.203805-5-zongyuan.li@smartx.com
6
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/811
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
8
---
9
include/hw/irq.h | 5 -----
9
target/arm/internals.h | 11 +++++------
10
hw/core/irq.c | 15 ---------------
10
target/arm/m_helper.c | 16 +++++++---------
11
2 files changed, 20 deletions(-)
11
target/arm/ptw.c | 20 +++++++++-----------
12
3 files changed, 21 insertions(+), 26 deletions(-)
12
13
13
diff --git a/include/hw/irq.h b/include/hw/irq.h
14
diff --git a/target/arm/internals.h b/target/arm/internals.h
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/irq.h
16
--- a/target/arm/internals.h
16
+++ b/include/hw/irq.h
17
+++ b/target/arm/internals.h
17
@@ -XXX,XX +XXX,XX @@ void qemu_free_irq(qemu_irq irq);
18
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
18
/* Returns a new IRQ with opposite polarity. */
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
19
qemu_irq qemu_irq_invert(qemu_irq irq);
20
V8M_SAttributes *sattrs);
20
21
21
-/* Returns a new IRQ which feeds into both the passed IRQs.
22
-bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
22
- * It's probably better to use the TYPE_SPLIT_IRQ device instead.
23
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
23
- */
24
- hwaddr *phys_ptr, MemTxAttrs *txattrs,
24
-qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2);
25
- int *prot, bool *is_subpage,
26
- ARMMMUFaultInfo *fi, uint32_t *mregion);
25
-
27
-
26
/* For internal use in qtest. Similar to qemu_irq_split, but operating
28
/* Cacheability and shareability attributes for a memory access */
27
on an existing vector of qemu_irq. */
29
typedef struct ARMCacheAttrs {
28
void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n);
30
/*
29
diff --git a/hw/core/irq.c b/hw/core/irq.c
31
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
32
GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
33
__attribute__((nonnull));
34
35
+bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
36
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
37
+ GetPhysAddrResult *result, bool *is_subpage,
38
+ ARMMMUFaultInfo *fi, uint32_t *mregion);
39
+
40
void arm_log_exception(CPUState *cs);
41
42
#endif /* !CONFIG_USER_ONLY */
43
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
30
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/core/irq.c
45
--- a/target/arm/m_helper.c
32
+++ b/hw/core/irq.c
46
+++ b/target/arm/m_helper.c
33
@@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_invert(qemu_irq irq)
47
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
34
return qemu_allocate_irq(qemu_notirq, irq, 0);
48
V8M_SAttributes sattrs = {};
49
uint32_t tt_resp;
50
bool r, rw, nsr, nsrw, mrvalid;
51
- int prot;
52
- ARMMMUFaultInfo fi = {};
53
- MemTxAttrs attrs = {};
54
- hwaddr phys_addr;
55
ARMMMUIdx mmu_idx;
56
uint32_t mregion;
57
bool targetpriv;
58
bool targetsec = env->v7m.secure;
59
- bool is_subpage;
60
61
/*
62
* Work out what the security state and privilege level we're
63
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
64
* inspecting the other MPU state.
65
*/
66
if (arm_current_el(env) != 0 || alt) {
67
+ GetPhysAddrResult res = {};
68
+ ARMMMUFaultInfo fi = {};
69
+ bool is_subpage;
70
+
71
/* We can ignore the return value as prot is always set */
72
pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
73
- &phys_addr, &attrs, &prot, &is_subpage,
74
- &fi, &mregion);
75
+ &res, &is_subpage, &fi, &mregion);
76
if (mregion == -1) {
77
mrvalid = false;
78
mregion = 0;
79
} else {
80
mrvalid = true;
81
}
82
- r = prot & PAGE_READ;
83
- rw = prot & PAGE_WRITE;
84
+ r = res.prot & PAGE_READ;
85
+ rw = res.prot & PAGE_WRITE;
86
} else {
87
r = false;
88
rw = false;
89
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
90
index XXXXXXX..XXXXXXX 100644
91
--- a/target/arm/ptw.c
92
+++ b/target/arm/ptw.c
93
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
94
95
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
96
MMUAccessType access_type, ARMMMUIdx mmu_idx,
97
- hwaddr *phys_ptr, MemTxAttrs *txattrs,
98
- int *prot, bool *is_subpage,
99
+ GetPhysAddrResult *result, bool *is_subpage,
100
ARMMMUFaultInfo *fi, uint32_t *mregion)
101
{
102
/*
103
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
104
uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1);
105
106
*is_subpage = false;
107
- *phys_ptr = address;
108
- *prot = 0;
109
+ result->phys = address;
110
+ result->prot = 0;
111
if (mregion) {
112
*mregion = -1;
113
}
114
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
115
116
if (matchregion == -1) {
117
/* hit using the background region */
118
- get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
119
+ get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
120
} else {
121
uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2);
122
uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1);
123
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
124
xn = 1;
125
}
126
127
- *prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
128
- if (*prot && !xn && !(pxn && !is_user)) {
129
- *prot |= PAGE_EXEC;
130
+ result->prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
131
+ if (result->prot && !xn && !(pxn && !is_user)) {
132
+ result->prot |= PAGE_EXEC;
133
}
134
/*
135
* We don't need to look the attribute up in the MAIR0/MAIR1
136
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
137
138
fi->type = ARMFault_Permission;
139
fi->level = 1;
140
- return !(*prot & (1 << access_type));
141
+ return !(result->prot & (1 << access_type));
35
}
142
}
36
143
37
-static void qemu_splitirq(void *opaque, int line, int level)
144
static bool v8m_is_sau_exempt(CPUARMState *env,
38
-{
145
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
39
- struct IRQState **irq = opaque;
146
}
40
- irq[0]->handler(irq[0]->opaque, irq[0]->n, level);
147
41
- irq[1]->handler(irq[1]->opaque, irq[1]->n, level);
148
ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
42
-}
149
- &result->phys, &result->attrs, &result->prot,
43
-
150
- &mpu_is_subpage, fi, NULL);
44
-qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2)
151
+ result, &mpu_is_subpage, fi, NULL);
45
-{
152
result->page_size =
46
- qemu_irq *s = g_new0(qemu_irq, 2);
153
sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
47
- s[0] = irq1;
154
return ret;
48
- s[1] = irq2;
49
- return qemu_allocate_irq(qemu_splitirq, s, 0);
50
-}
51
-
52
void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n)
53
{
54
int i;
55
--
155
--
56
2.25.1
156
2.25.1
157
158
diff view generated by jsdifflib
1
The Exynos4210 SoC device currently uses a custom device
1
From: Richard Henderson <richard.henderson@linaro.org>
2
"exynos4210.irq_gate" to model the OR gate that feeds each CPU's IRQ
3
line. We have a standard TYPE_OR_IRQ device for this now, so use
4
that instead.
5
2
6
(This is a migration compatibility break, but that is OK for this
3
This can be made redundant with result->page_size, by moving the basic
7
machine type.)
4
set of page_size from get_phys_addr_pmsav8. We still need to overwrite
5
page_size when v8m_security_lookup signals a subpage.
8
6
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-11-richard.henderson@linaro.org
9
[PMM: Update a comment that used to refer to is_subpage]
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20220404154658.565020-2-peter.maydell@linaro.org
12
---
12
---
13
include/hw/arm/exynos4210.h | 1 +
13
target/arm/internals.h | 4 ++--
14
hw/arm/exynos4210.c | 31 ++++++++++++++++---------------
14
target/arm/m_helper.c | 3 +--
15
2 files changed, 17 insertions(+), 15 deletions(-)
15
target/arm/ptw.c | 23 ++++++++++++-----------
16
3 files changed, 15 insertions(+), 15 deletions(-)
16
17
17
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/exynos4210.h
20
--- a/target/arm/internals.h
20
+++ b/include/hw/arm/exynos4210.h
21
+++ b/target/arm/internals.h
21
@@ -XXX,XX +XXX,XX @@ struct Exynos4210State {
22
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
22
MemoryRegion bootreg_mem;
23
23
I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER];
24
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
24
qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA];
25
MMUAccessType access_type, ARMMMUIdx mmu_idx,
25
+ qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS];
26
- GetPhysAddrResult *result, bool *is_subpage,
26
};
27
- ARMMMUFaultInfo *fi, uint32_t *mregion);
27
28
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi,
28
#define TYPE_EXYNOS4210_SOC "exynos4210"
29
+ uint32_t *mregion);
29
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
30
31
void arm_log_exception(CPUState *cs);
32
33
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
30
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/exynos4210.c
35
--- a/target/arm/m_helper.c
32
+++ b/hw/arm/exynos4210.c
36
+++ b/target/arm/m_helper.c
33
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
37
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
38
if (arm_current_el(env) != 0 || alt) {
39
GetPhysAddrResult res = {};
40
ARMMMUFaultInfo fi = {};
41
- bool is_subpage;
42
43
/* We can ignore the return value as prot is always set */
44
pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
45
- &res, &is_subpage, &fi, &mregion);
46
+ &res, &fi, &mregion);
47
if (mregion == -1) {
48
mrvalid = false;
49
mregion = 0;
50
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/ptw.c
53
+++ b/target/arm/ptw.c
54
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
55
56
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
57
MMUAccessType access_type, ARMMMUIdx mmu_idx,
58
- GetPhysAddrResult *result, bool *is_subpage,
59
- ARMMMUFaultInfo *fi, uint32_t *mregion)
60
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi,
61
+ uint32_t *mregion)
34
{
62
{
35
Exynos4210State *s = EXYNOS4210_SOC(socdev);
63
/*
36
MemoryRegion *system_mem = get_system_memory();
64
* Perform a PMSAv8 MPU lookup (without also doing the SAU check
37
- qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS];
65
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
38
SysBusDevice *busdev;
66
* mregion is (if not NULL) set to the region number which matched,
39
DeviceState *dev, *uart[4], *pl330[3];
67
* or -1 if no region number is returned (MPU off, address did not
40
int i, n;
68
* hit a region, address hit in multiple regions).
41
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
69
- * We set is_subpage to true if the region hit doesn't cover the
42
70
- * entire TARGET_PAGE the address is within.
43
/* IRQ Gate */
71
+ * If the region hit doesn't cover the entire TARGET_PAGE the address
44
for (i = 0; i < EXYNOS4210_NCPUS; i++) {
72
+ * is within, then we set the result page_size to 1 to force the
45
- dev = qdev_new("exynos4210.irq_gate");
73
+ * memory system to use a subpage.
46
- qdev_prop_set_uint32(dev, "n_in", EXYNOS4210_IRQ_GATE_NINPUTS);
74
*/
47
- sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
75
ARMCPU *cpu = env_archcpu(env);
48
- /* Get IRQ Gate input in gate_irq */
76
bool is_user = regime_is_user(env, mmu_idx);
49
- for (n = 0; n < EXYNOS4210_IRQ_GATE_NINPUTS; n++) {
77
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
50
- gate_irq[i][n] = qdev_get_gpio_in(dev, n);
78
uint32_t addr_page_base = address & TARGET_PAGE_MASK;
51
- }
79
uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1);
52
- busdev = SYS_BUS_DEVICE(dev);
80
53
-
81
- *is_subpage = false;
54
- /* Connect IRQ Gate output to CPU's IRQ line */
82
+ result->page_size = TARGET_PAGE_SIZE;
55
- sysbus_connect_irq(busdev, 0,
83
result->phys = address;
56
- qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ));
84
result->prot = 0;
57
+ DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]);
85
if (mregion) {
58
+ object_property_set_int(OBJECT(orgate), "num-lines",
86
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
59
+ EXYNOS4210_IRQ_GATE_NINPUTS,
87
ranges_overlap(base, limit - base + 1,
60
+ &error_abort);
88
addr_page_base,
61
+ qdev_realize(orgate, NULL, &error_abort);
89
TARGET_PAGE_SIZE)) {
62
+ qdev_connect_gpio_out(orgate, 0,
90
- *is_subpage = true;
63
+ qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ));
91
+ result->page_size = 1;
92
}
93
continue;
94
}
95
96
if (base > addr_page_base || limit < addr_page_limit) {
97
- *is_subpage = true;
98
+ result->page_size = 1;
99
}
100
101
if (matchregion != -1) {
102
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
103
uint32_t secure = regime_is_secure(env, mmu_idx);
104
V8M_SAttributes sattrs = {};
105
bool ret;
106
- bool mpu_is_subpage;
107
108
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
109
v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs);
110
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
64
}
111
}
65
112
66
/* Private memory region and Internal GIC */
113
ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
67
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
114
- result, &mpu_is_subpage, fi, NULL);
68
sysbus_realize_and_unref(busdev, &error_fatal);
115
- result->page_size =
69
sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR);
116
- sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
70
for (n = 0; n < EXYNOS4210_NCPUS; n++) {
117
+ result, fi, NULL);
71
- sysbus_connect_irq(busdev, n, gate_irq[n][0]);
118
+ if (sattrs.subpage) {
72
+ sysbus_connect_irq(busdev, n,
119
+ result->page_size = 1;
73
+ qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0));
74
}
75
for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) {
76
s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n);
77
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
78
/* Map Distributer interface */
79
sysbus_mmio_map(busdev, 1, EXYNOS4210_EXT_GIC_DIST_BASE_ADDR);
80
for (n = 0; n < EXYNOS4210_NCPUS; n++) {
81
- sysbus_connect_irq(busdev, n, gate_irq[n][1]);
82
+ sysbus_connect_irq(busdev, n,
83
+ qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1));
84
}
85
for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) {
86
s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n);
87
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj)
88
object_initialize_child(obj, name, orgate, TYPE_OR_IRQ);
89
g_free(name);
90
}
91
+
92
+ for (i = 0; i < ARRAY_SIZE(s->cpu_irq_orgate); i++) {
93
+ g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i);
94
+ object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ);
95
+ }
120
+ }
121
return ret;
96
}
122
}
97
123
98
static void exynos4210_class_init(ObjectClass *klass, void *data)
99
--
124
--
100
2.25.1
125
2.25.1
diff view generated by jsdifflib
1
Switch the creation of the external GIC to the new-style "embedded in
1
From: Richard Henderson <richard.henderson@linaro.org>
2
state struct" approach, so we can easily refer to the object
3
elsewhere during realize.
4
2
3
Remove the use of regime_is_secure from v8m_security_lookup,
4
passing the new parameter to the lookup instead.
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-12-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220404154658.565020-9-peter.maydell@linaro.org
8
---
11
---
9
include/hw/arm/exynos4210.h | 2 ++
12
target/arm/internals.h | 2 +-
10
include/hw/intc/exynos4210_gic.h | 43 ++++++++++++++++++++++++++++++++
13
target/arm/m_helper.c | 9 ++++++---
11
hw/arm/exynos4210.c | 10 ++++----
14
target/arm/ptw.c | 9 +++++----
12
hw/intc/exynos4210_gic.c | 17 ++-----------
15
3 files changed, 12 insertions(+), 8 deletions(-)
13
MAINTAINERS | 2 +-
14
5 files changed, 53 insertions(+), 21 deletions(-)
15
create mode 100644 include/hw/intc/exynos4210_gic.h
16
16
17
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
17
diff --git a/target/arm/internals.h b/target/arm/internals.h
18
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/exynos4210.h
19
--- a/target/arm/internals.h
20
+++ b/include/hw/arm/exynos4210.h
20
+++ b/target/arm/internals.h
21
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ typedef struct V8M_SAttributes {
22
#include "hw/or-irq.h"
22
23
#include "hw/sysbus.h"
23
void v8m_security_lookup(CPUARMState *env, uint32_t address,
24
#include "hw/cpu/a9mpcore.h"
24
MMUAccessType access_type, ARMMMUIdx mmu_idx,
25
+#include "hw/intc/exynos4210_gic.h"
25
- V8M_SAttributes *sattrs);
26
#include "target/arm/cpu-qom.h"
26
+ bool secure, V8M_SAttributes *sattrs);
27
#include "qom/object.h"
27
28
28
/* Cacheability and shareability attributes for a memory access */
29
@@ -XXX,XX +XXX,XX @@ struct Exynos4210State {
29
typedef struct ARMCacheAttrs {
30
qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA];
30
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
31
qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS];
32
A9MPPrivState a9mpcore;
33
+ Exynos4210GicState ext_gic;
34
};
35
36
#define TYPE_EXYNOS4210_SOC "exynos4210"
37
diff --git a/include/hw/intc/exynos4210_gic.h b/include/hw/intc/exynos4210_gic.h
38
new file mode 100644
39
index XXXXXXX..XXXXXXX
40
--- /dev/null
41
+++ b/include/hw/intc/exynos4210_gic.h
42
@@ -XXX,XX +XXX,XX @@
43
+/*
44
+ * Samsung exynos4210 GIC implementation. Based on hw/arm_gic.c
45
+ *
46
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
47
+ * All rights reserved.
48
+ *
49
+ * Evgeny Voevodin <e.voevodin@samsung.com>
50
+ *
51
+ * This program is free software; you can redistribute it and/or modify it
52
+ * under the terms of the GNU General Public License as published by the
53
+ * Free Software Foundation; either version 2 of the License, or (at your
54
+ * option) any later version.
55
+ *
56
+ * This program is distributed in the hope that it will be useful,
57
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
58
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
59
+ * See the GNU General Public License for more details.
60
+ *
61
+ * You should have received a copy of the GNU General Public License along
62
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
63
+ */
64
+#ifndef HW_INTC_EXYNOS4210_GIC_H
65
+#define HW_INTC_EXYNOS4210_GIC_H
66
+
67
+#include "hw/sysbus.h"
68
+
69
+#define TYPE_EXYNOS4210_GIC "exynos4210.gic"
70
+OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC)
71
+
72
+#define EXYNOS4210_GIC_NCPUS 2
73
+
74
+struct Exynos4210GicState {
75
+ SysBusDevice parent_obj;
76
+
77
+ MemoryRegion cpu_container;
78
+ MemoryRegion dist_container;
79
+ MemoryRegion cpu_alias[EXYNOS4210_GIC_NCPUS];
80
+ MemoryRegion dist_alias[EXYNOS4210_GIC_NCPUS];
81
+ uint32_t num_cpu;
82
+ DeviceState *gic;
83
+};
84
+
85
+#endif
86
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
87
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
88
--- a/hw/arm/exynos4210.c
32
--- a/target/arm/m_helper.c
89
+++ b/hw/arm/exynos4210.c
33
+++ b/target/arm/m_helper.c
90
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
34
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
91
sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL);
35
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
92
36
V8M_SAttributes sattrs = {};
93
/* External GIC */
37
94
- dev = qdev_new("exynos4210.gic");
38
- v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, &sattrs);
95
- qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS);
39
+ v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
96
- busdev = SYS_BUS_DEVICE(dev);
40
+ targets_secure, &sattrs);
97
- sysbus_realize_and_unref(busdev, &error_fatal);
41
if (sattrs.ns) {
98
+ qdev_prop_set_uint32(DEVICE(&s->ext_gic), "num-cpu", EXYNOS4210_NCPUS);
42
attrs.secure = false;
99
+ busdev = SYS_BUS_DEVICE(&s->ext_gic);
43
} else if (!targets_secure) {
100
+ sysbus_realize(busdev, &error_fatal);
44
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
101
/* Map CPU interface */
45
ARMMMUFaultInfo fi = {};
102
sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_GIC_CPU_BASE_ADDR);
46
MemTxResult txres;
103
/* Map Distributer interface */
47
104
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
48
- v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs);
105
qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1));
49
+ v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx,
50
+ regime_is_secure(env, mmu_idx), &sattrs);
51
if (!sattrs.nsc || sattrs.ns) {
52
/*
53
* This must be the second half of the insn, and it straddles a
54
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
106
}
55
}
107
for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) {
56
108
- s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n);
57
if (env->v7m.secure) {
109
+ s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n);
58
- v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, &sattrs);
59
+ v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
60
+ targetsec, &sattrs);
61
nsr = sattrs.ns && r;
62
nsrw = sattrs.ns && rw;
63
} else {
64
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/arm/ptw.c
67
+++ b/target/arm/ptw.c
68
@@ -XXX,XX +XXX,XX @@ static bool v8m_is_sau_exempt(CPUARMState *env,
69
}
70
71
void v8m_security_lookup(CPUARMState *env, uint32_t address,
72
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
73
- V8M_SAttributes *sattrs)
74
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
75
+ bool is_secure, V8M_SAttributes *sattrs)
76
{
77
/*
78
* Look up the security attributes for this address. Compare the
79
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
110
}
80
}
111
81
112
/* Internal Interrupt Combiner */
82
if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) {
113
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj)
83
- sattrs->ns = !regime_is_secure(env, mmu_idx);
84
+ sattrs->ns = !is_secure;
85
return;
114
}
86
}
115
87
116
object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV);
88
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
117
+ object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC);
89
bool ret;
118
}
90
119
91
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
120
static void exynos4210_class_init(ObjectClass *klass, void *data)
92
- v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs);
121
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
93
+ v8m_security_lookup(env, address, access_type, mmu_idx,
122
index XXXXXXX..XXXXXXX 100644
94
+ secure, &sattrs);
123
--- a/hw/intc/exynos4210_gic.c
95
if (access_type == MMU_INST_FETCH) {
124
+++ b/hw/intc/exynos4210_gic.c
96
/*
125
@@ -XXX,XX +XXX,XX @@
97
* Instruction fetches always use the MMU bank and the
126
#include "qemu/module.h"
127
#include "hw/irq.h"
128
#include "hw/qdev-properties.h"
129
+#include "hw/intc/exynos4210_gic.h"
130
#include "hw/arm/exynos4210.h"
131
#include "qom/object.h"
132
133
@@ -XXX,XX +XXX,XX @@
134
#define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100
135
#define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000
136
137
-#define TYPE_EXYNOS4210_GIC "exynos4210.gic"
138
-OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC)
139
-
140
-struct Exynos4210GicState {
141
- SysBusDevice parent_obj;
142
-
143
- MemoryRegion cpu_container;
144
- MemoryRegion dist_container;
145
- MemoryRegion cpu_alias[EXYNOS4210_NCPUS];
146
- MemoryRegion dist_alias[EXYNOS4210_NCPUS];
147
- uint32_t num_cpu;
148
- DeviceState *gic;
149
-};
150
-
151
static void exynos4210_gic_set_irq(void *opaque, int irq, int level)
152
{
153
Exynos4210GicState *s = (Exynos4210GicState *)opaque;
154
@@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp)
155
* enough room for the cpu numbers. gcc 9.2.1 on 32-bit x86
156
* doesn't figure this out, otherwise and gives spurious warnings.
157
*/
158
- assert(n <= EXYNOS4210_NCPUS);
159
+ assert(n <= EXYNOS4210_GIC_NCPUS);
160
for (i = 0; i < n; i++) {
161
/* Map CPU interface per SMP Core */
162
sprintf(cpu_alias_name, "%s%x", cpu_prefix, i);
163
diff --git a/MAINTAINERS b/MAINTAINERS
164
index XXXXXXX..XXXXXXX 100644
165
--- a/MAINTAINERS
166
+++ b/MAINTAINERS
167
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
168
L: qemu-arm@nongnu.org
169
S: Odd Fixes
170
F: hw/*/exynos*
171
-F: include/hw/arm/exynos4210.h
172
+F: include/hw/*/exynos*
173
174
Calxeda Highbank
175
M: Rob Herring <robh@kernel.org>
176
--
98
--
177
2.25.1
99
2.25.1
100
101
diff view generated by jsdifflib
1
In exynos4210_init_board_irqs(), the loop that handles IRQ lines that
1
From: Richard Henderson <richard.henderson@linaro.org>
2
are in a range that applies to the internal combiner only creates a
3
splitter for those interrupts which go to both the internal combiner
4
and to the external GIC, but it does nothing at all for the
5
interrupts which don't go to the external GIC, leaving the
6
irq_table[] array element empty for those. (This will result in
7
those interrupts simply being lost, not in a QEMU crash.)
8
2
9
I don't have a reliable datasheet for this SoC, but since we do wire
3
Remove the use of regime_is_secure from pmsav8_mpu_lookup,
10
up one interrupt line in this category (the HDMI I2C device on
4
passing the new parameter to the lookup instead.
11
interrupt 16,1), this seems like it must be a bug in the existing
12
QEMU code. Fill in the irq_table[] entries where we're not splitting
13
the IRQ to both the internal combiner and the external GIC with the
14
IRQ line of the internal combiner. (That is, these IRQ lines go to
15
just one device, not multiple.)
16
5
17
This bug didn't have any visible guest effects because the only
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
18
implemented device that was affected was the HDMI I2C controller,
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
19
and we never connect any I2C devices to that bus.
8
Message-id: 20220822152741.1617527-13-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/internals.h | 4 ++--
13
target/arm/m_helper.c | 2 +-
14
target/arm/ptw.c | 7 +++----
15
3 files changed, 6 insertions(+), 7 deletions(-)
20
16
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
diff --git a/target/arm/internals.h b/target/arm/internals.h
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Message-id: 20220404154658.565020-14-peter.maydell@linaro.org
24
---
25
hw/arm/exynos4210.c | 2 ++
26
1 file changed, 2 insertions(+)
27
28
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
29
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/exynos4210.c
19
--- a/target/arm/internals.h
31
+++ b/hw/arm/exynos4210.c
20
+++ b/target/arm/internals.h
32
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
21
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
33
qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]);
22
34
qdev_connect_gpio_out(splitter, 1,
23
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
35
qdev_get_gpio_in(extgicdev, irq_id - 32));
24
MMUAccessType access_type, ARMMMUIdx mmu_idx,
36
+ } else {
25
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi,
37
+ s->irq_table[n] = is->int_combiner_irq[n];
26
- uint32_t *mregion);
27
+ bool is_secure, GetPhysAddrResult *result,
28
+ ARMMMUFaultInfo *fi, uint32_t *mregion);
29
30
void arm_log_exception(CPUState *cs);
31
32
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/m_helper.c
35
+++ b/target/arm/m_helper.c
36
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
37
ARMMMUFaultInfo fi = {};
38
39
/* We can ignore the return value as prot is always set */
40
- pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
41
+ pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, targetsec,
42
&res, &fi, &mregion);
43
if (mregion == -1) {
44
mrvalid = false;
45
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/ptw.c
48
+++ b/target/arm/ptw.c
49
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
50
51
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
52
MMUAccessType access_type, ARMMMUIdx mmu_idx,
53
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi,
54
- uint32_t *mregion)
55
+ bool secure, GetPhysAddrResult *result,
56
+ ARMMMUFaultInfo *fi, uint32_t *mregion)
57
{
58
/*
59
* Perform a PMSAv8 MPU lookup (without also doing the SAU check
60
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
61
*/
62
ARMCPU *cpu = env_archcpu(env);
63
bool is_user = regime_is_user(env, mmu_idx);
64
- uint32_t secure = regime_is_secure(env, mmu_idx);
65
int n;
66
int matchregion = -1;
67
bool hit = false;
68
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
38
}
69
}
39
}
70
}
40
/*
71
72
- ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
73
+ ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, secure,
74
result, fi, NULL);
75
if (sattrs.subpage) {
76
result->page_size = 1;
41
--
77
--
42
2.25.1
78
2.25.1
79
80
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Connect the 4 TTC timers on the ZynqMP.
3
Remove the use of regime_is_secure from get_phys_addr_v5,
4
passing the new parameter to the lookup instead.
4
5
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
[PMM: Folded in definition of local is_secure in get_phys_addr(),
8
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
since I dropped the earlier patch that would have provided it]
9
Message-id: 20220331222017.2914409-3-edgar.iglesias@gmail.com
10
Message-id: 20220822152741.1617527-14-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
13
---
12
include/hw/arm/xlnx-zynqmp.h | 4 ++++
14
target/arm/ptw.c | 14 +++++++-------
13
hw/arm/xlnx-zynqmp.c | 22 ++++++++++++++++++++++
15
1 file changed, 7 insertions(+), 7 deletions(-)
14
2 files changed, 26 insertions(+)
15
16
16
diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h
17
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/xlnx-zynqmp.h
19
--- a/target/arm/ptw.c
19
+++ b/include/hw/arm/xlnx-zynqmp.h
20
+++ b/target/arm/ptw.c
20
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)
21
#include "hw/or-irq.h"
22
22
#include "hw/misc/xlnx-zynqmp-apu-ctrl.h"
23
static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
23
#include "hw/misc/xlnx-zynqmp-crf.h"
24
MMUAccessType access_type, ARMMMUIdx mmu_idx,
24
+#include "hw/timer/cadence_ttc.h"
25
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
25
26
+ bool is_secure, GetPhysAddrResult *result,
26
#define TYPE_XLNX_ZYNQMP "xlnx-zynqmp"
27
+ ARMMMUFaultInfo *fi)
27
OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP)
28
{
28
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP)
29
int level = 1;
29
#define XLNX_ZYNQMP_MAX_RAM_SIZE (XLNX_ZYNQMP_MAX_LOW_RAM_SIZE + \
30
uint32_t table;
30
XLNX_ZYNQMP_MAX_HIGH_RAM_SIZE)
31
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
31
32
fi->type = ARMFault_Translation;
32
+#define XLNX_ZYNQMP_NUM_TTC 4
33
goto do_fault;
33
+
34
}
34
/*
35
- desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx),
35
* Unimplemented mmio regions needed to boot some images.
36
- mmu_idx, fi);
36
*/
37
+ desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi);
37
@@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState {
38
if (fi->type != ARMFault_None) {
38
qemu_or_irq qspi_irq_orgate;
39
goto do_fault;
39
XlnxZynqMPAPUCtrl apu_ctrl;
40
}
40
XlnxZynqMPCRF crf;
41
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
41
+ CadenceTTCState ttc[XLNX_ZYNQMP_NUM_TTC];
42
/* Fine pagetable. */
42
43
table = (desc & 0xfffff000) | ((address >> 8) & 0xffc);
43
char *boot_cpu;
44
}
44
ARMCPU *boot_cpu_ptr;
45
- desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx),
45
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
46
- mmu_idx, fi);
46
index XXXXXXX..XXXXXXX 100644
47
+ desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi);
47
--- a/hw/arm/xlnx-zynqmp.c
48
if (fi->type != ARMFault_None) {
48
+++ b/hw/arm/xlnx-zynqmp.c
49
goto do_fault;
49
@@ -XXX,XX +XXX,XX @@
50
}
50
#define APU_ADDR 0xfd5c0000
51
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
51
#define APU_IRQ 153
52
GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
52
53
{
53
+#define TTC0_ADDR 0xFF110000
54
ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx);
54
+#define TTC0_IRQ 36
55
+ bool is_secure = regime_is_secure(env, mmu_idx);
55
+
56
56
#define IPI_ADDR 0xFF300000
57
if (mmu_idx != s1_mmu_idx) {
57
#define IPI_IRQ 64
58
/*
58
59
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
59
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_crf(XlnxZynqMPState *s, qemu_irq *gic)
60
* cannot upgrade an non-secure translation regime's attributes
60
sysbus_connect_irq(sbd, 0, gic[CRF_IRQ]);
61
* to secure.
62
*/
63
- result->attrs.secure = regime_is_secure(env, mmu_idx);
64
+ result->attrs.secure = is_secure;
65
result->attrs.user = regime_is_user(env, mmu_idx);
66
67
/*
68
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
69
result, fi);
70
} else {
71
return get_phys_addr_v5(env, address, access_type, mmu_idx,
72
- result, fi);
73
+ is_secure, result, fi);
74
}
61
}
75
}
62
76
63
+static void xlnx_zynqmp_create_ttc(XlnxZynqMPState *s, qemu_irq *gic)
64
+{
65
+ SysBusDevice *sbd;
66
+ int i, irq;
67
+
68
+ for (i = 0; i < XLNX_ZYNQMP_NUM_TTC; i++) {
69
+ object_initialize_child(OBJECT(s), "ttc[*]", &s->ttc[i],
70
+ TYPE_CADENCE_TTC);
71
+ sbd = SYS_BUS_DEVICE(&s->ttc[i]);
72
+
73
+ sysbus_realize(sbd, &error_fatal);
74
+ sysbus_mmio_map(sbd, 0, TTC0_ADDR + i * 0x10000);
75
+ for (irq = 0; irq < 3; irq++) {
76
+ sysbus_connect_irq(sbd, irq, gic[TTC0_IRQ + i * 3 + irq]);
77
+ }
78
+ }
79
+}
80
+
81
static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s)
82
{
83
static const struct UnimpInfo {
84
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
85
xlnx_zynqmp_create_efuse(s, gic_spi);
86
xlnx_zynqmp_create_apu_ctrl(s, gic_spi);
87
xlnx_zynqmp_create_crf(s, gic_spi);
88
+ xlnx_zynqmp_create_ttc(s, gic_spi);
89
xlnx_zynqmp_create_unimp_mmio(s);
90
91
for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) {
92
--
77
--
93
2.25.1
78
2.25.1
79
80
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Remove the use of regime_is_secure from get_phys_addr_v6,
4
passing the new parameter to the lookup instead.
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-15-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/ptw.c | 11 +++++------
13
1 file changed, 5 insertions(+), 6 deletions(-)
14
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/ptw.c
18
+++ b/target/arm/ptw.c
19
@@ -XXX,XX +XXX,XX @@ do_fault:
20
21
static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
22
MMUAccessType access_type, ARMMMUIdx mmu_idx,
23
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
24
+ bool is_secure, GetPhysAddrResult *result,
25
+ ARMMMUFaultInfo *fi)
26
{
27
ARMCPU *cpu = env_archcpu(env);
28
int level = 1;
29
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
30
fi->type = ARMFault_Translation;
31
goto do_fault;
32
}
33
- desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx),
34
- mmu_idx, fi);
35
+ desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi);
36
if (fi->type != ARMFault_None) {
37
goto do_fault;
38
}
39
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
40
ns = extract32(desc, 3, 1);
41
/* Lookup l2 entry. */
42
table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc);
43
- desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx),
44
- mmu_idx, fi);
45
+ desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi);
46
if (fi->type != ARMFault_None) {
47
goto do_fault;
48
}
49
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
50
result, fi);
51
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
52
return get_phys_addr_v6(env, address, access_type, mmu_idx,
53
- result, fi);
54
+ is_secure, result, fi);
55
} else {
56
return get_phys_addr_v5(env, address, access_type, mmu_idx,
57
is_secure, result, fi);
58
--
59
2.25.1
60
61
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Similar to the Aspeed code in include/misc/aspeed_scu.h, we define
3
Remove the use of regime_is_secure from get_phys_addr_pmsav8.
4
the PWRON STRAP fields in their corresponding module for NPCM7XX.
4
Since we already had a local variable named secure, use that.
5
5
6
Signed-off-by: Hao Wu <wuhaotsh@google.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Patrick Venture <venture@google.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220411165842.3912945-2-wuhaotsh@google.com
8
Message-id: 20220822152741.1617527-16-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
include/hw/misc/npcm7xx_gcr.h | 30 ++++++++++++++++++++++++++++++
12
target/arm/ptw.c | 5 ++---
13
1 file changed, 30 insertions(+)
13
1 file changed, 2 insertions(+), 3 deletions(-)
14
14
15
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/misc/npcm7xx_gcr.h
17
--- a/target/arm/ptw.c
18
+++ b/include/hw/misc/npcm7xx_gcr.h
18
+++ b/target/arm/ptw.c
19
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
20
#include "exec/memory.h"
20
21
#include "hw/sysbus.h"
21
static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
22
22
MMUAccessType access_type, ARMMMUIdx mmu_idx,
23
+/*
23
- GetPhysAddrResult *result,
24
+ * NPCM7XX PWRON STRAP bit fields
24
+ bool secure, GetPhysAddrResult *result,
25
+ * 12: SPI0 powered by VSBV3 at 1.8V
25
ARMMMUFaultInfo *fi)
26
+ * 11: System flash attached to BMC
26
{
27
+ * 10: BSP alternative pins.
27
- uint32_t secure = regime_is_secure(env, mmu_idx);
28
+ * 9:8: Flash UART command route enabled.
28
V8M_SAttributes sattrs = {};
29
+ * 7: Security enabled.
29
bool ret;
30
+ * 6: HI-Z state control.
30
31
+ * 5: ECC disabled.
31
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
32
+ * 4: Reserved
32
if (arm_feature(env, ARM_FEATURE_V8)) {
33
+ * 3: JTAG2 enabled.
33
/* PMSAv8 */
34
+ * 2:0: CPU and DRAM clock frequency.
34
ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx,
35
+ */
35
- result, fi);
36
+#define NPCM7XX_PWRON_STRAP_SPI0F18 BIT(12)
36
+ is_secure, result, fi);
37
+#define NPCM7XX_PWRON_STRAP_SFAB BIT(11)
37
} else if (arm_feature(env, ARM_FEATURE_V7)) {
38
+#define NPCM7XX_PWRON_STRAP_BSPA BIT(10)
38
/* PMSAv7 */
39
+#define NPCM7XX_PWRON_STRAP_FUP(x) ((x) << 8)
39
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
40
+#define FUP_NORM_UART2 3
41
+#define FUP_PROG_UART3 2
42
+#define FUP_PROG_UART2 1
43
+#define FUP_NORM_UART3 0
44
+#define NPCM7XX_PWRON_STRAP_SECEN BIT(7)
45
+#define NPCM7XX_PWRON_STRAP_HIZ BIT(6)
46
+#define NPCM7XX_PWRON_STRAP_ECC BIT(5)
47
+#define NPCM7XX_PWRON_STRAP_RESERVE1 BIT(4)
48
+#define NPCM7XX_PWRON_STRAP_J2EN BIT(3)
49
+#define NPCM7XX_PWRON_STRAP_CKFRQ(x) (x)
50
+#define CKFRQ_SKIPINIT 0x000
51
+#define CKFRQ_DEFAULT 0x111
52
+
53
/*
54
* Number of registers in our device state structure. Don't change this without
55
* incrementing the version_id in the vmstate.
56
--
40
--
57
2.25.1
41
2.25.1
42
43
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Connect the CRL (Clock Reset LPD) to the Versal SoC.
3
Remove the use of regime_is_secure from pmsav7_use_background_region,
4
using the new parameter instead.
4
5
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Frederic Konrad <fkonrad@amd.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
8
Message-id: 20220822152741.1617527-17-richard.henderson@linaro.org
8
Message-id: 20220406174303.2022038-5-edgar.iglesias@xilinx.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
include/hw/arm/xlnx-versal.h | 4 +++
12
target/arm/ptw.c | 10 +++++-----
12
hw/arm/xlnx-versal.c | 54 ++++++++++++++++++++++++++++++++++--
13
1 file changed, 5 insertions(+), 5 deletions(-)
13
2 files changed, 56 insertions(+), 2 deletions(-)
14
14
15
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/xlnx-versal.h
17
--- a/target/arm/ptw.c
18
+++ b/include/hw/arm/xlnx-versal.h
18
+++ b/target/arm/ptw.c
19
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static bool m_is_system_region(CPUARMState *env, uint32_t address)
20
#include "hw/nvram/xlnx-versal-efuse.h"
21
#include "hw/ssi/xlnx-versal-ospi.h"
22
#include "hw/dma/xlnx_csu_dma.h"
23
+#include "hw/misc/xlnx-versal-crl.h"
24
#include "hw/misc/xlnx-versal-pmc-iou-slcr.h"
25
26
#define TYPE_XLNX_VERSAL "xlnx-versal"
27
@@ -XXX,XX +XXX,XX @@ struct Versal {
28
qemu_or_irq irq_orgate;
29
XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM];
30
} xram;
31
+
32
+ XlnxVersalCRL crl;
33
} lpd;
34
35
/* The Platform Management Controller subsystem. */
36
@@ -XXX,XX +XXX,XX @@ struct Versal {
37
#define VERSAL_TIMER_NS_EL1_IRQ 14
38
#define VERSAL_TIMER_NS_EL2_IRQ 10
39
40
+#define VERSAL_CRL_IRQ 10
41
#define VERSAL_UART0_IRQ_0 18
42
#define VERSAL_UART1_IRQ_0 19
43
#define VERSAL_USB0_IRQ_0 22
44
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/arm/xlnx-versal.c
47
+++ b/hw/arm/xlnx-versal.c
48
@@ -XXX,XX +XXX,XX @@ static void versal_create_ospi(Versal *s, qemu_irq *pic)
49
qdev_connect_gpio_out(orgate, 0, pic[VERSAL_OSPI_IRQ]);
50
}
20
}
51
21
52
+static void versal_create_crl(Versal *s, qemu_irq *pic)
22
static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
53
+{
23
- bool is_user)
54
+ SysBusDevice *sbd;
24
+ bool is_secure, bool is_user)
55
+ int i;
25
{
56
+
26
/*
57
+ object_initialize_child(OBJECT(s), "crl", &s->lpd.crl,
27
* Return true if we should use the default memory map as a
58
+ TYPE_XLNX_VERSAL_CRL);
28
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
59
+ sbd = SYS_BUS_DEVICE(&s->lpd.crl);
29
}
60
+
30
61
+ for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) {
31
if (arm_feature(env, ARM_FEATURE_M)) {
62
+ g_autofree gchar *name = g_strdup_printf("cpu_r5[%d]", i);
32
- return env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)]
63
+
33
- & R_V7M_MPU_CTRL_PRIVDEFENA_MASK;
64
+ object_property_set_link(OBJECT(&s->lpd.crl),
34
+ return env->v7m.mpu_ctrl[is_secure] & R_V7M_MPU_CTRL_PRIVDEFENA_MASK;
65
+ name, OBJECT(&s->lpd.rpu.cpu[i]),
35
} else {
66
+ &error_abort);
36
return regime_sctlr(env, mmu_idx) & SCTLR_BR;
67
+ }
37
}
68
+
38
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
69
+ for (i = 0; i < ARRAY_SIZE(s->lpd.iou.gem); i++) {
39
{
70
+ g_autofree gchar *name = g_strdup_printf("gem[%d]", i);
40
ARMCPU *cpu = env_archcpu(env);
71
+
41
int n;
72
+ object_property_set_link(OBJECT(&s->lpd.crl),
42
+ bool secure = regime_is_secure(env, mmu_idx);
73
+ name, OBJECT(&s->lpd.iou.gem[i]),
43
bool is_user = regime_is_user(env, mmu_idx);
74
+ &error_abort);
44
75
+ }
45
result->phys = address;
76
+
46
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
77
+ for (i = 0; i < ARRAY_SIZE(s->lpd.iou.adma); i++) {
47
}
78
+ g_autofree gchar *name = g_strdup_printf("adma[%d]", i);
48
79
+
49
if (n == -1) { /* no hits */
80
+ object_property_set_link(OBJECT(&s->lpd.crl),
50
- if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) {
81
+ name, OBJECT(&s->lpd.iou.adma[i]),
51
+ if (!pmsav7_use_background_region(cpu, mmu_idx, secure, is_user)) {
82
+ &error_abort);
52
/* background fault */
83
+ }
53
fi->type = ARMFault_Background;
84
+
54
return true;
85
+ for (i = 0; i < ARRAY_SIZE(s->lpd.iou.uart); i++) {
55
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
86
+ g_autofree gchar *name = g_strdup_printf("uart[%d]", i);
56
} else if (m_is_ppb_region(env, address)) {
87
+
57
hit = true;
88
+ object_property_set_link(OBJECT(&s->lpd.crl),
58
} else {
89
+ name, OBJECT(&s->lpd.iou.uart[i]),
59
- if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) {
90
+ &error_abort);
60
+ if (pmsav7_use_background_region(cpu, mmu_idx, secure, is_user)) {
91
+ }
61
hit = true;
92
+
62
}
93
+ object_property_set_link(OBJECT(&s->lpd.crl),
94
+ "usb", OBJECT(&s->lpd.iou.usb),
95
+ &error_abort);
96
+
97
+ sysbus_realize(sbd, &error_fatal);
98
+ memory_region_add_subregion(&s->mr_ps, MM_CRL,
99
+ sysbus_mmio_get_region(sbd, 0));
100
+ sysbus_connect_irq(sbd, 0, pic[VERSAL_CRL_IRQ]);
101
+}
102
+
103
/* This takes the board allocated linear DDR memory and creates aliases
104
* for each split DDR range/aperture on the Versal address map.
105
*/
106
@@ -XXX,XX +XXX,XX @@ static void versal_unimp(Versal *s)
107
108
versal_unimp_area(s, "psm", &s->mr_ps,
109
MM_PSM_START, MM_PSM_END - MM_PSM_START);
110
- versal_unimp_area(s, "crl", &s->mr_ps,
111
- MM_CRL, MM_CRL_SIZE);
112
versal_unimp_area(s, "crf", &s->mr_ps,
113
MM_FPD_CRF, MM_FPD_CRF_SIZE);
114
versal_unimp_area(s, "apu", &s->mr_ps,
115
@@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp)
116
versal_create_efuse(s, pic);
117
versal_create_pmc_iou_slcr(s, pic);
118
versal_create_ospi(s, pic);
119
+ versal_create_crl(s, pic);
120
versal_map_ddr(s);
121
versal_unimp(s);
122
63
123
--
64
--
124
2.25.1
65
2.25.1
66
67
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Add a model of the Xilinx Versal CRL.
3
Remove the use of regime_is_secure from get_phys_addr_pmsav7,
4
using the new parameter instead.
4
5
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Frederic Konrad <fkonrad@amd.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
8
Message-id: 20220822152741.1617527-19-richard.henderson@linaro.org
8
Message-id: 20220406174303.2022038-4-edgar.iglesias@xilinx.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++
12
target/arm/ptw.c | 5 ++---
12
hw/misc/xlnx-versal-crl.c | 421 ++++++++++++++++++++++++++++++
13
1 file changed, 2 insertions(+), 3 deletions(-)
13
hw/misc/meson.build | 1 +
14
3 files changed, 657 insertions(+)
15
create mode 100644 include/hw/misc/xlnx-versal-crl.h
16
create mode 100644 hw/misc/xlnx-versal-crl.c
17
14
18
diff --git a/include/hw/misc/xlnx-versal-crl.h b/include/hw/misc/xlnx-versal-crl.h
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
19
new file mode 100644
20
index XXXXXXX..XXXXXXX
21
--- /dev/null
22
+++ b/include/hw/misc/xlnx-versal-crl.h
23
@@ -XXX,XX +XXX,XX @@
24
+/*
25
+ * QEMU model of the Clock-Reset-LPD (CRL).
26
+ *
27
+ * Copyright (c) 2022 Xilinx Inc.
28
+ * SPDX-License-Identifier: GPL-2.0-or-later
29
+ *
30
+ * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com>
31
+ */
32
+#ifndef HW_MISC_XLNX_VERSAL_CRL_H
33
+#define HW_MISC_XLNX_VERSAL_CRL_H
34
+
35
+#include "hw/sysbus.h"
36
+#include "hw/register.h"
37
+#include "target/arm/cpu.h"
38
+
39
+#define TYPE_XLNX_VERSAL_CRL "xlnx,versal-crl"
40
+OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCRL, XLNX_VERSAL_CRL)
41
+
42
+REG32(ERR_CTRL, 0x0)
43
+ FIELD(ERR_CTRL, SLVERR_ENABLE, 0, 1)
44
+REG32(IR_STATUS, 0x4)
45
+ FIELD(IR_STATUS, ADDR_DECODE_ERR, 0, 1)
46
+REG32(IR_MASK, 0x8)
47
+ FIELD(IR_MASK, ADDR_DECODE_ERR, 0, 1)
48
+REG32(IR_ENABLE, 0xc)
49
+ FIELD(IR_ENABLE, ADDR_DECODE_ERR, 0, 1)
50
+REG32(IR_DISABLE, 0x10)
51
+ FIELD(IR_DISABLE, ADDR_DECODE_ERR, 0, 1)
52
+REG32(WPROT, 0x1c)
53
+ FIELD(WPROT, ACTIVE, 0, 1)
54
+REG32(PLL_CLK_OTHER_DMN, 0x20)
55
+ FIELD(PLL_CLK_OTHER_DMN, APLL_BYPASS, 0, 1)
56
+REG32(RPLL_CTRL, 0x40)
57
+ FIELD(RPLL_CTRL, POST_SRC, 24, 3)
58
+ FIELD(RPLL_CTRL, PRE_SRC, 20, 3)
59
+ FIELD(RPLL_CTRL, CLKOUTDIV, 16, 2)
60
+ FIELD(RPLL_CTRL, FBDIV, 8, 8)
61
+ FIELD(RPLL_CTRL, BYPASS, 3, 1)
62
+ FIELD(RPLL_CTRL, RESET, 0, 1)
63
+REG32(RPLL_CFG, 0x44)
64
+ FIELD(RPLL_CFG, LOCK_DLY, 25, 7)
65
+ FIELD(RPLL_CFG, LOCK_CNT, 13, 10)
66
+ FIELD(RPLL_CFG, LFHF, 10, 2)
67
+ FIELD(RPLL_CFG, CP, 5, 4)
68
+ FIELD(RPLL_CFG, RES, 0, 4)
69
+REG32(RPLL_FRAC_CFG, 0x48)
70
+ FIELD(RPLL_FRAC_CFG, ENABLED, 31, 1)
71
+ FIELD(RPLL_FRAC_CFG, SEED, 22, 3)
72
+ FIELD(RPLL_FRAC_CFG, ALGRTHM, 19, 1)
73
+ FIELD(RPLL_FRAC_CFG, ORDER, 18, 1)
74
+ FIELD(RPLL_FRAC_CFG, DATA, 0, 16)
75
+REG32(PLL_STATUS, 0x50)
76
+ FIELD(PLL_STATUS, RPLL_STABLE, 2, 1)
77
+ FIELD(PLL_STATUS, RPLL_LOCK, 0, 1)
78
+REG32(RPLL_TO_XPD_CTRL, 0x100)
79
+ FIELD(RPLL_TO_XPD_CTRL, CLKACT, 25, 1)
80
+ FIELD(RPLL_TO_XPD_CTRL, DIVISOR0, 8, 10)
81
+REG32(LPD_TOP_SWITCH_CTRL, 0x104)
82
+ FIELD(LPD_TOP_SWITCH_CTRL, CLKACT_ADMA, 26, 1)
83
+ FIELD(LPD_TOP_SWITCH_CTRL, CLKACT, 25, 1)
84
+ FIELD(LPD_TOP_SWITCH_CTRL, DIVISOR0, 8, 10)
85
+ FIELD(LPD_TOP_SWITCH_CTRL, SRCSEL, 0, 3)
86
+REG32(LPD_LSBUS_CTRL, 0x108)
87
+ FIELD(LPD_LSBUS_CTRL, CLKACT, 25, 1)
88
+ FIELD(LPD_LSBUS_CTRL, DIVISOR0, 8, 10)
89
+ FIELD(LPD_LSBUS_CTRL, SRCSEL, 0, 3)
90
+REG32(CPU_R5_CTRL, 0x10c)
91
+ FIELD(CPU_R5_CTRL, CLKACT_OCM2, 28, 1)
92
+ FIELD(CPU_R5_CTRL, CLKACT_OCM, 27, 1)
93
+ FIELD(CPU_R5_CTRL, CLKACT_CORE, 26, 1)
94
+ FIELD(CPU_R5_CTRL, CLKACT, 25, 1)
95
+ FIELD(CPU_R5_CTRL, DIVISOR0, 8, 10)
96
+ FIELD(CPU_R5_CTRL, SRCSEL, 0, 3)
97
+REG32(IOU_SWITCH_CTRL, 0x114)
98
+ FIELD(IOU_SWITCH_CTRL, CLKACT, 25, 1)
99
+ FIELD(IOU_SWITCH_CTRL, DIVISOR0, 8, 10)
100
+ FIELD(IOU_SWITCH_CTRL, SRCSEL, 0, 3)
101
+REG32(GEM0_REF_CTRL, 0x118)
102
+ FIELD(GEM0_REF_CTRL, CLKACT_RX, 27, 1)
103
+ FIELD(GEM0_REF_CTRL, CLKACT_TX, 26, 1)
104
+ FIELD(GEM0_REF_CTRL, CLKACT, 25, 1)
105
+ FIELD(GEM0_REF_CTRL, DIVISOR0, 8, 10)
106
+ FIELD(GEM0_REF_CTRL, SRCSEL, 0, 3)
107
+REG32(GEM1_REF_CTRL, 0x11c)
108
+ FIELD(GEM1_REF_CTRL, CLKACT_RX, 27, 1)
109
+ FIELD(GEM1_REF_CTRL, CLKACT_TX, 26, 1)
110
+ FIELD(GEM1_REF_CTRL, CLKACT, 25, 1)
111
+ FIELD(GEM1_REF_CTRL, DIVISOR0, 8, 10)
112
+ FIELD(GEM1_REF_CTRL, SRCSEL, 0, 3)
113
+REG32(GEM_TSU_REF_CTRL, 0x120)
114
+ FIELD(GEM_TSU_REF_CTRL, CLKACT, 25, 1)
115
+ FIELD(GEM_TSU_REF_CTRL, DIVISOR0, 8, 10)
116
+ FIELD(GEM_TSU_REF_CTRL, SRCSEL, 0, 3)
117
+REG32(USB0_BUS_REF_CTRL, 0x124)
118
+ FIELD(USB0_BUS_REF_CTRL, CLKACT, 25, 1)
119
+ FIELD(USB0_BUS_REF_CTRL, DIVISOR0, 8, 10)
120
+ FIELD(USB0_BUS_REF_CTRL, SRCSEL, 0, 3)
121
+REG32(UART0_REF_CTRL, 0x128)
122
+ FIELD(UART0_REF_CTRL, CLKACT, 25, 1)
123
+ FIELD(UART0_REF_CTRL, DIVISOR0, 8, 10)
124
+ FIELD(UART0_REF_CTRL, SRCSEL, 0, 3)
125
+REG32(UART1_REF_CTRL, 0x12c)
126
+ FIELD(UART1_REF_CTRL, CLKACT, 25, 1)
127
+ FIELD(UART1_REF_CTRL, DIVISOR0, 8, 10)
128
+ FIELD(UART1_REF_CTRL, SRCSEL, 0, 3)
129
+REG32(SPI0_REF_CTRL, 0x130)
130
+ FIELD(SPI0_REF_CTRL, CLKACT, 25, 1)
131
+ FIELD(SPI0_REF_CTRL, DIVISOR0, 8, 10)
132
+ FIELD(SPI0_REF_CTRL, SRCSEL, 0, 3)
133
+REG32(SPI1_REF_CTRL, 0x134)
134
+ FIELD(SPI1_REF_CTRL, CLKACT, 25, 1)
135
+ FIELD(SPI1_REF_CTRL, DIVISOR0, 8, 10)
136
+ FIELD(SPI1_REF_CTRL, SRCSEL, 0, 3)
137
+REG32(CAN0_REF_CTRL, 0x138)
138
+ FIELD(CAN0_REF_CTRL, CLKACT, 25, 1)
139
+ FIELD(CAN0_REF_CTRL, DIVISOR0, 8, 10)
140
+ FIELD(CAN0_REF_CTRL, SRCSEL, 0, 3)
141
+REG32(CAN1_REF_CTRL, 0x13c)
142
+ FIELD(CAN1_REF_CTRL, CLKACT, 25, 1)
143
+ FIELD(CAN1_REF_CTRL, DIVISOR0, 8, 10)
144
+ FIELD(CAN1_REF_CTRL, SRCSEL, 0, 3)
145
+REG32(I2C0_REF_CTRL, 0x140)
146
+ FIELD(I2C0_REF_CTRL, CLKACT, 25, 1)
147
+ FIELD(I2C0_REF_CTRL, DIVISOR0, 8, 10)
148
+ FIELD(I2C0_REF_CTRL, SRCSEL, 0, 3)
149
+REG32(I2C1_REF_CTRL, 0x144)
150
+ FIELD(I2C1_REF_CTRL, CLKACT, 25, 1)
151
+ FIELD(I2C1_REF_CTRL, DIVISOR0, 8, 10)
152
+ FIELD(I2C1_REF_CTRL, SRCSEL, 0, 3)
153
+REG32(DBG_LPD_CTRL, 0x148)
154
+ FIELD(DBG_LPD_CTRL, CLKACT, 25, 1)
155
+ FIELD(DBG_LPD_CTRL, DIVISOR0, 8, 10)
156
+ FIELD(DBG_LPD_CTRL, SRCSEL, 0, 3)
157
+REG32(TIMESTAMP_REF_CTRL, 0x14c)
158
+ FIELD(TIMESTAMP_REF_CTRL, CLKACT, 25, 1)
159
+ FIELD(TIMESTAMP_REF_CTRL, DIVISOR0, 8, 10)
160
+ FIELD(TIMESTAMP_REF_CTRL, SRCSEL, 0, 3)
161
+REG32(CRL_SAFETY_CHK, 0x150)
162
+REG32(PSM_REF_CTRL, 0x154)
163
+ FIELD(PSM_REF_CTRL, DIVISOR0, 8, 10)
164
+ FIELD(PSM_REF_CTRL, SRCSEL, 0, 3)
165
+REG32(DBG_TSTMP_CTRL, 0x158)
166
+ FIELD(DBG_TSTMP_CTRL, CLKACT, 25, 1)
167
+ FIELD(DBG_TSTMP_CTRL, DIVISOR0, 8, 10)
168
+ FIELD(DBG_TSTMP_CTRL, SRCSEL, 0, 3)
169
+REG32(CPM_TOPSW_REF_CTRL, 0x15c)
170
+ FIELD(CPM_TOPSW_REF_CTRL, CLKACT, 25, 1)
171
+ FIELD(CPM_TOPSW_REF_CTRL, DIVISOR0, 8, 10)
172
+ FIELD(CPM_TOPSW_REF_CTRL, SRCSEL, 0, 3)
173
+REG32(USB3_DUAL_REF_CTRL, 0x160)
174
+ FIELD(USB3_DUAL_REF_CTRL, CLKACT, 25, 1)
175
+ FIELD(USB3_DUAL_REF_CTRL, DIVISOR0, 8, 10)
176
+ FIELD(USB3_DUAL_REF_CTRL, SRCSEL, 0, 3)
177
+REG32(RST_CPU_R5, 0x300)
178
+ FIELD(RST_CPU_R5, RESET_PGE, 4, 1)
179
+ FIELD(RST_CPU_R5, RESET_AMBA, 2, 1)
180
+ FIELD(RST_CPU_R5, RESET_CPU1, 1, 1)
181
+ FIELD(RST_CPU_R5, RESET_CPU0, 0, 1)
182
+REG32(RST_ADMA, 0x304)
183
+ FIELD(RST_ADMA, RESET, 0, 1)
184
+REG32(RST_GEM0, 0x308)
185
+ FIELD(RST_GEM0, RESET, 0, 1)
186
+REG32(RST_GEM1, 0x30c)
187
+ FIELD(RST_GEM1, RESET, 0, 1)
188
+REG32(RST_SPARE, 0x310)
189
+ FIELD(RST_SPARE, RESET, 0, 1)
190
+REG32(RST_USB0, 0x314)
191
+ FIELD(RST_USB0, RESET, 0, 1)
192
+REG32(RST_UART0, 0x318)
193
+ FIELD(RST_UART0, RESET, 0, 1)
194
+REG32(RST_UART1, 0x31c)
195
+ FIELD(RST_UART1, RESET, 0, 1)
196
+REG32(RST_SPI0, 0x320)
197
+ FIELD(RST_SPI0, RESET, 0, 1)
198
+REG32(RST_SPI1, 0x324)
199
+ FIELD(RST_SPI1, RESET, 0, 1)
200
+REG32(RST_CAN0, 0x328)
201
+ FIELD(RST_CAN0, RESET, 0, 1)
202
+REG32(RST_CAN1, 0x32c)
203
+ FIELD(RST_CAN1, RESET, 0, 1)
204
+REG32(RST_I2C0, 0x330)
205
+ FIELD(RST_I2C0, RESET, 0, 1)
206
+REG32(RST_I2C1, 0x334)
207
+ FIELD(RST_I2C1, RESET, 0, 1)
208
+REG32(RST_DBG_LPD, 0x338)
209
+ FIELD(RST_DBG_LPD, RPU_DBG1_RESET, 5, 1)
210
+ FIELD(RST_DBG_LPD, RPU_DBG0_RESET, 4, 1)
211
+ FIELD(RST_DBG_LPD, RESET_HSDP, 1, 1)
212
+ FIELD(RST_DBG_LPD, RESET, 0, 1)
213
+REG32(RST_GPIO, 0x33c)
214
+ FIELD(RST_GPIO, RESET, 0, 1)
215
+REG32(RST_TTC, 0x344)
216
+ FIELD(RST_TTC, TTC3_RESET, 3, 1)
217
+ FIELD(RST_TTC, TTC2_RESET, 2, 1)
218
+ FIELD(RST_TTC, TTC1_RESET, 1, 1)
219
+ FIELD(RST_TTC, TTC0_RESET, 0, 1)
220
+REG32(RST_TIMESTAMP, 0x348)
221
+ FIELD(RST_TIMESTAMP, RESET, 0, 1)
222
+REG32(RST_SWDT, 0x34c)
223
+ FIELD(RST_SWDT, RESET, 0, 1)
224
+REG32(RST_OCM, 0x350)
225
+ FIELD(RST_OCM, RESET, 0, 1)
226
+REG32(RST_IPI, 0x354)
227
+ FIELD(RST_IPI, RESET, 0, 1)
228
+REG32(RST_SYSMON, 0x358)
229
+ FIELD(RST_SYSMON, SEQ_RST, 1, 1)
230
+ FIELD(RST_SYSMON, CFG_RST, 0, 1)
231
+REG32(RST_FPD, 0x360)
232
+ FIELD(RST_FPD, SRST, 1, 1)
233
+ FIELD(RST_FPD, POR, 0, 1)
234
+REG32(PSM_RST_MODE, 0x370)
235
+ FIELD(PSM_RST_MODE, WAKEUP, 2, 1)
236
+ FIELD(PSM_RST_MODE, RST_MODE, 0, 2)
237
+
238
+#define CRL_R_MAX (R_PSM_RST_MODE + 1)
239
+
240
+#define RPU_MAX_CPU 2
241
+
242
+struct XlnxVersalCRL {
243
+ SysBusDevice parent_obj;
244
+ qemu_irq irq;
245
+
246
+ struct {
247
+ ARMCPU *cpu_r5[RPU_MAX_CPU];
248
+ DeviceState *adma[8];
249
+ DeviceState *uart[2];
250
+ DeviceState *gem[2];
251
+ DeviceState *usb;
252
+ } cfg;
253
+
254
+ RegisterInfoArray *reg_array;
255
+ uint32_t regs[CRL_R_MAX];
256
+ RegisterInfo regs_info[CRL_R_MAX];
257
+};
258
+#endif
259
diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c
260
new file mode 100644
261
index XXXXXXX..XXXXXXX
262
--- /dev/null
263
+++ b/hw/misc/xlnx-versal-crl.c
264
@@ -XXX,XX +XXX,XX @@
265
+/*
266
+ * QEMU model of the Clock-Reset-LPD (CRL).
267
+ *
268
+ * Copyright (c) 2022 Advanced Micro Devices, Inc.
269
+ * SPDX-License-Identifier: GPL-2.0-or-later
270
+ *
271
+ * Written by Edgar E. Iglesias <edgar.iglesias@amd.com>
272
+ */
273
+
274
+#include "qemu/osdep.h"
275
+#include "qapi/error.h"
276
+#include "qemu/log.h"
277
+#include "qemu/bitops.h"
278
+#include "migration/vmstate.h"
279
+#include "hw/qdev-properties.h"
280
+#include "hw/sysbus.h"
281
+#include "hw/irq.h"
282
+#include "hw/register.h"
283
+#include "hw/resettable.h"
284
+
285
+#include "target/arm/arm-powerctl.h"
286
+#include "hw/misc/xlnx-versal-crl.h"
287
+
288
+#ifndef XLNX_VERSAL_CRL_ERR_DEBUG
289
+#define XLNX_VERSAL_CRL_ERR_DEBUG 0
290
+#endif
291
+
292
+static void crl_update_irq(XlnxVersalCRL *s)
293
+{
294
+ bool pending = s->regs[R_IR_STATUS] & ~s->regs[R_IR_MASK];
295
+ qemu_set_irq(s->irq, pending);
296
+}
297
+
298
+static void crl_status_postw(RegisterInfo *reg, uint64_t val64)
299
+{
300
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
301
+ crl_update_irq(s);
302
+}
303
+
304
+static uint64_t crl_enable_prew(RegisterInfo *reg, uint64_t val64)
305
+{
306
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
307
+ uint32_t val = val64;
308
+
309
+ s->regs[R_IR_MASK] &= ~val;
310
+ crl_update_irq(s);
311
+ return 0;
312
+}
313
+
314
+static uint64_t crl_disable_prew(RegisterInfo *reg, uint64_t val64)
315
+{
316
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
317
+ uint32_t val = val64;
318
+
319
+ s->regs[R_IR_MASK] |= val;
320
+ crl_update_irq(s);
321
+ return 0;
322
+}
323
+
324
+static void crl_reset_dev(XlnxVersalCRL *s, DeviceState *dev,
325
+ bool rst_old, bool rst_new)
326
+{
327
+ device_cold_reset(dev);
328
+}
329
+
330
+static void crl_reset_cpu(XlnxVersalCRL *s, ARMCPU *armcpu,
331
+ bool rst_old, bool rst_new)
332
+{
333
+ if (rst_new) {
334
+ arm_set_cpu_off(armcpu->mp_affinity);
335
+ } else {
336
+ arm_set_cpu_on_and_reset(armcpu->mp_affinity);
337
+ }
338
+}
339
+
340
+#define REGFIELD_RESET(type, s, reg, f, new_val, dev) { \
341
+ bool old_f = ARRAY_FIELD_EX32((s)->regs, reg, f); \
342
+ bool new_f = FIELD_EX32(new_val, reg, f); \
343
+ \
344
+ /* Detect edges. */ \
345
+ if (dev && old_f != new_f) { \
346
+ crl_reset_ ## type(s, dev, old_f, new_f); \
347
+ } \
348
+}
349
+
350
+static uint64_t crl_rst_r5_prew(RegisterInfo *reg, uint64_t val64)
351
+{
352
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
353
+
354
+ REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU0, val64, s->cfg.cpu_r5[0]);
355
+ REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU1, val64, s->cfg.cpu_r5[1]);
356
+ return val64;
357
+}
358
+
359
+static uint64_t crl_rst_adma_prew(RegisterInfo *reg, uint64_t val64)
360
+{
361
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
362
+ int i;
363
+
364
+ /* A single register fans out to all ADMA reset inputs. */
365
+ for (i = 0; i < ARRAY_SIZE(s->cfg.adma); i++) {
366
+ REGFIELD_RESET(dev, s, RST_ADMA, RESET, val64, s->cfg.adma[i]);
367
+ }
368
+ return val64;
369
+}
370
+
371
+static uint64_t crl_rst_uart0_prew(RegisterInfo *reg, uint64_t val64)
372
+{
373
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
374
+
375
+ REGFIELD_RESET(dev, s, RST_UART0, RESET, val64, s->cfg.uart[0]);
376
+ return val64;
377
+}
378
+
379
+static uint64_t crl_rst_uart1_prew(RegisterInfo *reg, uint64_t val64)
380
+{
381
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
382
+
383
+ REGFIELD_RESET(dev, s, RST_UART1, RESET, val64, s->cfg.uart[1]);
384
+ return val64;
385
+}
386
+
387
+static uint64_t crl_rst_gem0_prew(RegisterInfo *reg, uint64_t val64)
388
+{
389
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
390
+
391
+ REGFIELD_RESET(dev, s, RST_GEM0, RESET, val64, s->cfg.gem[0]);
392
+ return val64;
393
+}
394
+
395
+static uint64_t crl_rst_gem1_prew(RegisterInfo *reg, uint64_t val64)
396
+{
397
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
398
+
399
+ REGFIELD_RESET(dev, s, RST_GEM1, RESET, val64, s->cfg.gem[1]);
400
+ return val64;
401
+}
402
+
403
+static uint64_t crl_rst_usb_prew(RegisterInfo *reg, uint64_t val64)
404
+{
405
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque);
406
+
407
+ REGFIELD_RESET(dev, s, RST_USB0, RESET, val64, s->cfg.usb);
408
+ return val64;
409
+}
410
+
411
+static const RegisterAccessInfo crl_regs_info[] = {
412
+ { .name = "ERR_CTRL", .addr = A_ERR_CTRL,
413
+ },{ .name = "IR_STATUS", .addr = A_IR_STATUS,
414
+ .w1c = 0x1,
415
+ .post_write = crl_status_postw,
416
+ },{ .name = "IR_MASK", .addr = A_IR_MASK,
417
+ .reset = 0x1,
418
+ .ro = 0x1,
419
+ },{ .name = "IR_ENABLE", .addr = A_IR_ENABLE,
420
+ .pre_write = crl_enable_prew,
421
+ },{ .name = "IR_DISABLE", .addr = A_IR_DISABLE,
422
+ .pre_write = crl_disable_prew,
423
+ },{ .name = "WPROT", .addr = A_WPROT,
424
+ },{ .name = "PLL_CLK_OTHER_DMN", .addr = A_PLL_CLK_OTHER_DMN,
425
+ .reset = 0x1,
426
+ .rsvd = 0xe,
427
+ },{ .name = "RPLL_CTRL", .addr = A_RPLL_CTRL,
428
+ .reset = 0x24809,
429
+ .rsvd = 0xf88c00f6,
430
+ },{ .name = "RPLL_CFG", .addr = A_RPLL_CFG,
431
+ .reset = 0x2000000,
432
+ .rsvd = 0x1801210,
433
+ },{ .name = "RPLL_FRAC_CFG", .addr = A_RPLL_FRAC_CFG,
434
+ .rsvd = 0x7e330000,
435
+ },{ .name = "PLL_STATUS", .addr = A_PLL_STATUS,
436
+ .reset = R_PLL_STATUS_RPLL_STABLE_MASK |
437
+ R_PLL_STATUS_RPLL_LOCK_MASK,
438
+ .rsvd = 0xfa,
439
+ .ro = 0x5,
440
+ },{ .name = "RPLL_TO_XPD_CTRL", .addr = A_RPLL_TO_XPD_CTRL,
441
+ .reset = 0x2000100,
442
+ .rsvd = 0xfdfc00ff,
443
+ },{ .name = "LPD_TOP_SWITCH_CTRL", .addr = A_LPD_TOP_SWITCH_CTRL,
444
+ .reset = 0x6000300,
445
+ .rsvd = 0xf9fc00f8,
446
+ },{ .name = "LPD_LSBUS_CTRL", .addr = A_LPD_LSBUS_CTRL,
447
+ .reset = 0x2000800,
448
+ .rsvd = 0xfdfc00f8,
449
+ },{ .name = "CPU_R5_CTRL", .addr = A_CPU_R5_CTRL,
450
+ .reset = 0xe000300,
451
+ .rsvd = 0xe1fc00f8,
452
+ },{ .name = "IOU_SWITCH_CTRL", .addr = A_IOU_SWITCH_CTRL,
453
+ .reset = 0x2000500,
454
+ .rsvd = 0xfdfc00f8,
455
+ },{ .name = "GEM0_REF_CTRL", .addr = A_GEM0_REF_CTRL,
456
+ .reset = 0xe000a00,
457
+ .rsvd = 0xf1fc00f8,
458
+ },{ .name = "GEM1_REF_CTRL", .addr = A_GEM1_REF_CTRL,
459
+ .reset = 0xe000a00,
460
+ .rsvd = 0xf1fc00f8,
461
+ },{ .name = "GEM_TSU_REF_CTRL", .addr = A_GEM_TSU_REF_CTRL,
462
+ .reset = 0x300,
463
+ .rsvd = 0xfdfc00f8,
464
+ },{ .name = "USB0_BUS_REF_CTRL", .addr = A_USB0_BUS_REF_CTRL,
465
+ .reset = 0x2001900,
466
+ .rsvd = 0xfdfc00f8,
467
+ },{ .name = "UART0_REF_CTRL", .addr = A_UART0_REF_CTRL,
468
+ .reset = 0xc00,
469
+ .rsvd = 0xfdfc00f8,
470
+ },{ .name = "UART1_REF_CTRL", .addr = A_UART1_REF_CTRL,
471
+ .reset = 0xc00,
472
+ .rsvd = 0xfdfc00f8,
473
+ },{ .name = "SPI0_REF_CTRL", .addr = A_SPI0_REF_CTRL,
474
+ .reset = 0x600,
475
+ .rsvd = 0xfdfc00f8,
476
+ },{ .name = "SPI1_REF_CTRL", .addr = A_SPI1_REF_CTRL,
477
+ .reset = 0x600,
478
+ .rsvd = 0xfdfc00f8,
479
+ },{ .name = "CAN0_REF_CTRL", .addr = A_CAN0_REF_CTRL,
480
+ .reset = 0xc00,
481
+ .rsvd = 0xfdfc00f8,
482
+ },{ .name = "CAN1_REF_CTRL", .addr = A_CAN1_REF_CTRL,
483
+ .reset = 0xc00,
484
+ .rsvd = 0xfdfc00f8,
485
+ },{ .name = "I2C0_REF_CTRL", .addr = A_I2C0_REF_CTRL,
486
+ .reset = 0xc00,
487
+ .rsvd = 0xfdfc00f8,
488
+ },{ .name = "I2C1_REF_CTRL", .addr = A_I2C1_REF_CTRL,
489
+ .reset = 0xc00,
490
+ .rsvd = 0xfdfc00f8,
491
+ },{ .name = "DBG_LPD_CTRL", .addr = A_DBG_LPD_CTRL,
492
+ .reset = 0x300,
493
+ .rsvd = 0xfdfc00f8,
494
+ },{ .name = "TIMESTAMP_REF_CTRL", .addr = A_TIMESTAMP_REF_CTRL,
495
+ .reset = 0x2000c00,
496
+ .rsvd = 0xfdfc00f8,
497
+ },{ .name = "CRL_SAFETY_CHK", .addr = A_CRL_SAFETY_CHK,
498
+ },{ .name = "PSM_REF_CTRL", .addr = A_PSM_REF_CTRL,
499
+ .reset = 0xf04,
500
+ .rsvd = 0xfffc00f8,
501
+ },{ .name = "DBG_TSTMP_CTRL", .addr = A_DBG_TSTMP_CTRL,
502
+ .reset = 0x300,
503
+ .rsvd = 0xfdfc00f8,
504
+ },{ .name = "CPM_TOPSW_REF_CTRL", .addr = A_CPM_TOPSW_REF_CTRL,
505
+ .reset = 0x300,
506
+ .rsvd = 0xfdfc00f8,
507
+ },{ .name = "USB3_DUAL_REF_CTRL", .addr = A_USB3_DUAL_REF_CTRL,
508
+ .reset = 0x3c00,
509
+ .rsvd = 0xfdfc00f8,
510
+ },{ .name = "RST_CPU_R5", .addr = A_RST_CPU_R5,
511
+ .reset = 0x17,
512
+ .rsvd = 0x8,
513
+ .pre_write = crl_rst_r5_prew,
514
+ },{ .name = "RST_ADMA", .addr = A_RST_ADMA,
515
+ .reset = 0x1,
516
+ .pre_write = crl_rst_adma_prew,
517
+ },{ .name = "RST_GEM0", .addr = A_RST_GEM0,
518
+ .reset = 0x1,
519
+ .pre_write = crl_rst_gem0_prew,
520
+ },{ .name = "RST_GEM1", .addr = A_RST_GEM1,
521
+ .reset = 0x1,
522
+ .pre_write = crl_rst_gem1_prew,
523
+ },{ .name = "RST_SPARE", .addr = A_RST_SPARE,
524
+ .reset = 0x1,
525
+ },{ .name = "RST_USB0", .addr = A_RST_USB0,
526
+ .reset = 0x1,
527
+ .pre_write = crl_rst_usb_prew,
528
+ },{ .name = "RST_UART0", .addr = A_RST_UART0,
529
+ .reset = 0x1,
530
+ .pre_write = crl_rst_uart0_prew,
531
+ },{ .name = "RST_UART1", .addr = A_RST_UART1,
532
+ .reset = 0x1,
533
+ .pre_write = crl_rst_uart1_prew,
534
+ },{ .name = "RST_SPI0", .addr = A_RST_SPI0,
535
+ .reset = 0x1,
536
+ },{ .name = "RST_SPI1", .addr = A_RST_SPI1,
537
+ .reset = 0x1,
538
+ },{ .name = "RST_CAN0", .addr = A_RST_CAN0,
539
+ .reset = 0x1,
540
+ },{ .name = "RST_CAN1", .addr = A_RST_CAN1,
541
+ .reset = 0x1,
542
+ },{ .name = "RST_I2C0", .addr = A_RST_I2C0,
543
+ .reset = 0x1,
544
+ },{ .name = "RST_I2C1", .addr = A_RST_I2C1,
545
+ .reset = 0x1,
546
+ },{ .name = "RST_DBG_LPD", .addr = A_RST_DBG_LPD,
547
+ .reset = 0x33,
548
+ .rsvd = 0xcc,
549
+ },{ .name = "RST_GPIO", .addr = A_RST_GPIO,
550
+ .reset = 0x1,
551
+ },{ .name = "RST_TTC", .addr = A_RST_TTC,
552
+ .reset = 0xf,
553
+ },{ .name = "RST_TIMESTAMP", .addr = A_RST_TIMESTAMP,
554
+ .reset = 0x1,
555
+ },{ .name = "RST_SWDT", .addr = A_RST_SWDT,
556
+ .reset = 0x1,
557
+ },{ .name = "RST_OCM", .addr = A_RST_OCM,
558
+ },{ .name = "RST_IPI", .addr = A_RST_IPI,
559
+ },{ .name = "RST_FPD", .addr = A_RST_FPD,
560
+ .reset = 0x3,
561
+ },{ .name = "PSM_RST_MODE", .addr = A_PSM_RST_MODE,
562
+ .reset = 0x1,
563
+ .rsvd = 0xf8,
564
+ }
565
+};
566
+
567
+static void crl_reset_enter(Object *obj, ResetType type)
568
+{
569
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj);
570
+ unsigned int i;
571
+
572
+ for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
573
+ register_reset(&s->regs_info[i]);
574
+ }
575
+}
576
+
577
+static void crl_reset_hold(Object *obj)
578
+{
579
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj);
580
+
581
+ crl_update_irq(s);
582
+}
583
+
584
+static const MemoryRegionOps crl_ops = {
585
+ .read = register_read_memory,
586
+ .write = register_write_memory,
587
+ .endianness = DEVICE_LITTLE_ENDIAN,
588
+ .valid = {
589
+ .min_access_size = 4,
590
+ .max_access_size = 4,
591
+ },
592
+};
593
+
594
+static void crl_init(Object *obj)
595
+{
596
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj);
597
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
598
+ int i;
599
+
600
+ s->reg_array =
601
+ register_init_block32(DEVICE(obj), crl_regs_info,
602
+ ARRAY_SIZE(crl_regs_info),
603
+ s->regs_info, s->regs,
604
+ &crl_ops,
605
+ XLNX_VERSAL_CRL_ERR_DEBUG,
606
+ CRL_R_MAX * 4);
607
+ sysbus_init_mmio(sbd, &s->reg_array->mem);
608
+ sysbus_init_irq(sbd, &s->irq);
609
+
610
+ for (i = 0; i < ARRAY_SIZE(s->cfg.cpu_r5); ++i) {
611
+ object_property_add_link(obj, "cpu_r5[*]", TYPE_ARM_CPU,
612
+ (Object **)&s->cfg.cpu_r5[i],
613
+ qdev_prop_allow_set_link_before_realize,
614
+ OBJ_PROP_LINK_STRONG);
615
+ }
616
+
617
+ for (i = 0; i < ARRAY_SIZE(s->cfg.adma); ++i) {
618
+ object_property_add_link(obj, "adma[*]", TYPE_DEVICE,
619
+ (Object **)&s->cfg.adma[i],
620
+ qdev_prop_allow_set_link_before_realize,
621
+ OBJ_PROP_LINK_STRONG);
622
+ }
623
+
624
+ for (i = 0; i < ARRAY_SIZE(s->cfg.uart); ++i) {
625
+ object_property_add_link(obj, "uart[*]", TYPE_DEVICE,
626
+ (Object **)&s->cfg.uart[i],
627
+ qdev_prop_allow_set_link_before_realize,
628
+ OBJ_PROP_LINK_STRONG);
629
+ }
630
+
631
+ for (i = 0; i < ARRAY_SIZE(s->cfg.gem); ++i) {
632
+ object_property_add_link(obj, "gem[*]", TYPE_DEVICE,
633
+ (Object **)&s->cfg.gem[i],
634
+ qdev_prop_allow_set_link_before_realize,
635
+ OBJ_PROP_LINK_STRONG);
636
+ }
637
+
638
+ object_property_add_link(obj, "usb", TYPE_DEVICE,
639
+ (Object **)&s->cfg.gem[i],
640
+ qdev_prop_allow_set_link_before_realize,
641
+ OBJ_PROP_LINK_STRONG);
642
+}
643
+
644
+static void crl_finalize(Object *obj)
645
+{
646
+ XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj);
647
+ register_finalize_block(s->reg_array);
648
+}
649
+
650
+static const VMStateDescription vmstate_crl = {
651
+ .name = TYPE_XLNX_VERSAL_CRL,
652
+ .version_id = 1,
653
+ .minimum_version_id = 1,
654
+ .fields = (VMStateField[]) {
655
+ VMSTATE_UINT32_ARRAY(regs, XlnxVersalCRL, CRL_R_MAX),
656
+ VMSTATE_END_OF_LIST(),
657
+ }
658
+};
659
+
660
+static void crl_class_init(ObjectClass *klass, void *data)
661
+{
662
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
663
+ DeviceClass *dc = DEVICE_CLASS(klass);
664
+
665
+ dc->vmsd = &vmstate_crl;
666
+
667
+ rc->phases.enter = crl_reset_enter;
668
+ rc->phases.hold = crl_reset_hold;
669
+}
670
+
671
+static const TypeInfo crl_info = {
672
+ .name = TYPE_XLNX_VERSAL_CRL,
673
+ .parent = TYPE_SYS_BUS_DEVICE,
674
+ .instance_size = sizeof(XlnxVersalCRL),
675
+ .class_init = crl_class_init,
676
+ .instance_init = crl_init,
677
+ .instance_finalize = crl_finalize,
678
+};
679
+
680
+static void crl_register_types(void)
681
+{
682
+ type_register_static(&crl_info);
683
+}
684
+
685
+type_init(crl_register_types)
686
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
687
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
688
--- a/hw/misc/meson.build
17
--- a/target/arm/ptw.c
689
+++ b/hw/misc/meson.build
18
+++ b/target/arm/ptw.c
690
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c'))
19
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
691
softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c'))
20
692
specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c'))
21
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
693
specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c'))
22
MMUAccessType access_type, ARMMMUIdx mmu_idx,
694
+specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-crl.c'))
23
- GetPhysAddrResult *result,
695
softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files(
24
+ bool secure, GetPhysAddrResult *result,
696
'xlnx-versal-xramc.c',
25
ARMMMUFaultInfo *fi)
697
'xlnx-versal-pmc-iou-slcr.c',
26
{
27
ARMCPU *cpu = env_archcpu(env);
28
int n;
29
- bool secure = regime_is_secure(env, mmu_idx);
30
bool is_user = regime_is_user(env, mmu_idx);
31
32
result->phys = address;
33
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
34
} else if (arm_feature(env, ARM_FEATURE_V7)) {
35
/* PMSAv7 */
36
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
37
- result, fi);
38
+ is_secure, result, fi);
39
} else {
40
/* Pre-v7 MPU */
41
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
698
--
42
--
699
2.25.1
43
2.25.1
44
45
diff view generated by jsdifflib
1
From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Describe that the gic-version influences the maximum number of CPUs.
3
Remove the use of regime_is_secure from get_phys_addr_pmsav5.
4
4
5
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Message-id: 20220413231456.35811-1-heinrich.schuchardt@canonical.com
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
[PMM: minor punctuation tweaks]
7
Message-id: 20220822152741.1617527-21-richard.henderson@linaro.org
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
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
docs/system/arm/virt.rst | 4 ++--
11
target/arm/ptw.c | 4 ++--
12
1 file changed, 2 insertions(+), 2 deletions(-)
12
1 file changed, 2 insertions(+), 2 deletions(-)
13
13
14
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
14
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/system/arm/virt.rst
16
--- a/target/arm/ptw.c
17
+++ b/docs/system/arm/virt.rst
17
+++ b/target/arm/ptw.c
18
@@ -XXX,XX +XXX,XX @@ gic-version
18
@@ -XXX,XX +XXX,XX @@ do_fault:
19
Valid values are:
19
20
20
static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
21
``2``
21
MMUAccessType access_type, ARMMMUIdx mmu_idx,
22
- GICv2
22
- GetPhysAddrResult *result,
23
+ GICv2. Note that this limits the number of CPUs to 8.
23
+ bool is_secure, GetPhysAddrResult *result,
24
``3``
24
ARMMMUFaultInfo *fi)
25
- GICv3
25
{
26
+ GICv3. This allows up to 512 CPUs.
26
int n;
27
``host``
27
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
28
Use the same GIC version the host provides, when using KVM
28
} else {
29
``max``
29
/* Pre-v7 MPU */
30
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
31
- result, fi);
32
+ is_secure, result, fi);
33
}
34
qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32
35
" mmu_idx %u -> %s (prot %c%c%c)\n",
30
--
36
--
31
2.25.1
37
2.25.1
38
39
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
1
From: Keqian Zhu <zhukeqian1@huawei.com>
2
2
3
Add the Cortex-R5Fs of the Versal RPU (Real-time Processing Unit)
3
Setup an ARM virtual machine of machine virt and execute qmp "query-acpi-ospm-status"
4
subsystem.
4
causes segmentation fault with following dumpstack:
5
#1 0x0000aaaaab64235c in qmp_query_acpi_ospm_status (errp=errp@entry=0xfffffffff030) at ../monitor/qmp-cmds.c:312
6
#2 0x0000aaaaabfc4e20 in qmp_marshal_query_acpi_ospm_status (args=<optimized out>, ret=0xffffea4ffe90, errp=0xffffea4ffe88) at qapi/qapi-commands-acpi.c:63
7
#3 0x0000aaaaabff8ba0 in do_qmp_dispatch_bh (opaque=0xffffea4ffe98) at ../qapi/qmp-dispatch.c:128
8
#4 0x0000aaaaac02e594 in aio_bh_call (bh=0xffffe0004d80) at ../util/async.c:150
9
#5 aio_bh_poll (ctx=ctx@entry=0xaaaaad0f6040) at ../util/async.c:178
10
#6 0x0000aaaaac00bd40 in aio_dispatch (ctx=ctx@entry=0xaaaaad0f6040) at ../util/aio-posix.c:421
11
#7 0x0000aaaaac02e010 in aio_ctx_dispatch (source=0xaaaaad0f6040, callback=<optimized out>, user_data=<optimized out>) at ../util/async.c:320
12
#8 0x0000fffff76f6884 in g_main_context_dispatch () at /usr/lib64/libglib-2.0.so.0
13
#9 0x0000aaaaac0452d4 in glib_pollfds_poll () at ../util/main-loop.c:297
14
#10 os_host_main_loop_wait (timeout=0) at ../util/main-loop.c:320
15
#11 main_loop_wait (nonblocking=nonblocking@entry=0) at ../util/main-loop.c:596
16
#12 0x0000aaaaab5c9e50 in qemu_main_loop () at ../softmmu/runstate.c:734
17
#13 0x0000aaaaab185370 in qemu_main (argc=argc@entry=47, argv=argv@entry=0xfffffffff518, envp=envp@entry=0x0) at ../softmmu/main.c:38
18
#14 0x0000aaaaab16f99c in main (argc=47, argv=0xfffffffff518) at ../softmmu/main.c:47
5
19
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
20
Fixes: ebb62075021a ("hw/acpi: Add ACPI Generic Event Device Support")
7
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
21
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
8
Message-id: 20220406174303.2022038-3-edgar.iglesias@xilinx.com
22
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
23
Message-id: 20220816094957.31700-1-zhukeqian1@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
25
---
11
include/hw/arm/xlnx-versal.h | 10 ++++++++++
26
hw/acpi/generic_event_device.c | 8 ++++++++
12
hw/arm/xlnx-versal-virt.c | 6 +++---
27
1 file changed, 8 insertions(+)
13
hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++++++++++
14
3 files changed, 49 insertions(+), 3 deletions(-)
15
28
16
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
29
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
17
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/xlnx-versal.h
31
--- a/hw/acpi/generic_event_device.c
19
+++ b/include/hw/arm/xlnx-versal.h
32
+++ b/hw/acpi/generic_event_device.c
20
@@ -XXX,XX +XXX,XX @@
33
@@ -XXX,XX +XXX,XX @@ static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev,
21
OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL)
22
23
#define XLNX_VERSAL_NR_ACPUS 2
24
+#define XLNX_VERSAL_NR_RCPUS 2
25
#define XLNX_VERSAL_NR_UARTS 2
26
#define XLNX_VERSAL_NR_GEMS 2
27
#define XLNX_VERSAL_NR_ADMAS 8
28
@@ -XXX,XX +XXX,XX @@ struct Versal {
29
VersalUsb2 usb;
30
} iou;
31
32
+ /* Real-time Processing Unit. */
33
+ struct {
34
+ MemoryRegion mr;
35
+ MemoryRegion mr_ps_alias;
36
+
37
+ CPUClusterState cluster;
38
+ ARMCPU cpu[XLNX_VERSAL_NR_RCPUS];
39
+ } rpu;
40
+
41
struct {
42
qemu_or_irq irq_orgate;
43
XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM];
44
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/arm/xlnx-versal-virt.c
47
+++ b/hw/arm/xlnx-versal-virt.c
48
@@ -XXX,XX +XXX,XX @@ static void versal_virt_machine_class_init(ObjectClass *oc, void *data)
49
50
mc->desc = "Xilinx Versal Virtual development board";
51
mc->init = versal_virt_init;
52
- mc->min_cpus = XLNX_VERSAL_NR_ACPUS;
53
- mc->max_cpus = XLNX_VERSAL_NR_ACPUS;
54
- mc->default_cpus = XLNX_VERSAL_NR_ACPUS;
55
+ mc->min_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS;
56
+ mc->max_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS;
57
+ mc->default_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS;
58
mc->no_cdrom = true;
59
mc->default_ram_id = "ddr";
60
}
61
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/arm/xlnx-versal.c
64
+++ b/hw/arm/xlnx-versal.c
65
@@ -XXX,XX +XXX,XX @@
66
#include "hw/sysbus.h"
67
68
#define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")
69
+#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")
70
#define GEM_REVISION 0x40070106
71
72
#define VERSAL_NUM_PMC_APB_IRQS 3
73
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic)
74
}
34
}
75
}
35
}
76
36
77
+static void versal_create_rpu_cpus(Versal *s)
37
+static void acpi_ged_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
78
+{
38
+{
79
+ int i;
39
+ AcpiGedState *s = ACPI_GED(adev);
80
+
40
+
81
+ object_initialize_child(OBJECT(s), "rpu-cluster", &s->lpd.rpu.cluster,
41
+ acpi_memory_ospm_status(&s->memhp_state, list);
82
+ TYPE_CPU_CLUSTER);
83
+ qdev_prop_set_uint32(DEVICE(&s->lpd.rpu.cluster), "cluster-id", 1);
84
+
85
+ for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) {
86
+ Object *obj;
87
+
88
+ object_initialize_child(OBJECT(&s->lpd.rpu.cluster),
89
+ "rpu-cpu[*]", &s->lpd.rpu.cpu[i],
90
+ XLNX_VERSAL_RCPU_TYPE);
91
+ obj = OBJECT(&s->lpd.rpu.cpu[i]);
92
+ object_property_set_bool(obj, "start-powered-off", true,
93
+ &error_abort);
94
+
95
+ object_property_set_int(obj, "mp-affinity", 0x100 | i, &error_abort);
96
+ object_property_set_int(obj, "core-count", ARRAY_SIZE(s->lpd.rpu.cpu),
97
+ &error_abort);
98
+ object_property_set_link(obj, "memory", OBJECT(&s->lpd.rpu.mr),
99
+ &error_abort);
100
+ qdev_realize(DEVICE(obj), NULL, &error_fatal);
101
+ }
102
+
103
+ qdev_realize(DEVICE(&s->lpd.rpu.cluster), NULL, &error_fatal);
104
+}
42
+}
105
+
43
+
106
static void versal_create_uarts(Versal *s, qemu_irq *pic)
44
static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
107
{
45
{
108
int i;
46
AcpiGedState *s = ACPI_GED(adev);
109
@@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp)
47
@@ -XXX,XX +XXX,XX @@ static void acpi_ged_class_init(ObjectClass *class, void *data)
110
48
hc->unplug_request = acpi_ged_unplug_request_cb;
111
versal_create_apu_cpus(s);
49
hc->unplug = acpi_ged_unplug_cb;
112
versal_create_apu_gic(s, pic);
50
113
+ versal_create_rpu_cpus(s);
51
+ adevc->ospm_status = acpi_ged_ospm_status;
114
versal_create_uarts(s, pic);
52
adevc->send_event = acpi_ged_send_event;
115
versal_create_usbs(s, pic);
116
versal_create_gems(s, pic);
117
@@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp)
118
119
memory_region_add_subregion_overlap(&s->mr_ps, MM_OCM, &s->lpd.mr_ocm, 0);
120
memory_region_add_subregion_overlap(&s->fpd.apu.mr, 0, &s->mr_ps, 0);
121
+ memory_region_add_subregion_overlap(&s->lpd.rpu.mr, 0,
122
+ &s->lpd.rpu.mr_ps_alias, 0);
123
}
53
}
124
54
125
static void versal_init(Object *obj)
126
@@ -XXX,XX +XXX,XX @@ static void versal_init(Object *obj)
127
Versal *s = XLNX_VERSAL(obj);
128
129
memory_region_init(&s->fpd.apu.mr, obj, "mr-apu", UINT64_MAX);
130
+ memory_region_init(&s->lpd.rpu.mr, obj, "mr-rpu", UINT64_MAX);
131
memory_region_init(&s->mr_ps, obj, "mr-ps-switch", UINT64_MAX);
132
+ memory_region_init_alias(&s->lpd.rpu.mr_ps_alias, OBJECT(s),
133
+ "mr-rpu-ps-alias", &s->mr_ps, 0, UINT64_MAX);
134
}
135
136
static Property versal_properties[] = {
137
--
55
--
138
2.25.1
56
2.25.1
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
1
From: Lucas Dietrich <ld.adecy@gmail.com>
2
2
3
Break out header file to allow embedding of the the TTC.
3
The LAN9118 allows the guest to specify a level for both the TX and
4
RX FIFOs at which an interrupt will be generated. We implement the
5
RSFL_INT interrupt for the RX FIFO but are missing the handling of
6
the equivalent TSFL_INT for the TX FIFO. Add the missing test to set
7
the interrupt if the TX FIFO has exceeded the guest-specified level.
4
8
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
9
This flag is required for Micrium lan911x ethernet driver to work.
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
11
Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
8
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
12
[PMM: Tweaked commit message and comment]
9
Message-id: 20220331222017.2914409-2-edgar.iglesias@gmail.com
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
15
---
12
include/hw/timer/cadence_ttc.h | 54 ++++++++++++++++++++++++++++++++++
16
hw/net/lan9118.c | 8 ++++++++
13
hw/timer/cadence_ttc.c | 32 ++------------------
17
1 file changed, 8 insertions(+)
14
2 files changed, 56 insertions(+), 30 deletions(-)
15
create mode 100644 include/hw/timer/cadence_ttc.h
16
18
17
diff --git a/include/hw/timer/cadence_ttc.h b/include/hw/timer/cadence_ttc.h
19
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
18
new file mode 100644
20
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX
21
--- a/hw/net/lan9118.c
20
--- /dev/null
22
+++ b/hw/net/lan9118.c
21
+++ b/include/hw/timer/cadence_ttc.h
23
@@ -XXX,XX +XXX,XX @@ static void do_tx_packet(lan9118_state *s)
22
@@ -XXX,XX +XXX,XX @@
24
n = (s->tx_status_fifo_head + s->tx_status_fifo_used) & 511;
23
+/*
25
s->tx_status_fifo[n] = status;
24
+ * Xilinx Zynq cadence TTC model
26
s->tx_status_fifo_used++;
25
+ *
26
+ * Copyright (c) 2011 Xilinx Inc.
27
+ * Copyright (c) 2012 Peter A.G. Crosthwaite (peter.crosthwaite@petalogix.com)
28
+ * Copyright (c) 2012 PetaLogix Pty Ltd.
29
+ * Written By Haibing Ma
30
+ * M. Habib
31
+ *
32
+ * This program is free software; you can redistribute it and/or
33
+ * modify it under the terms of the GNU General Public License
34
+ * as published by the Free Software Foundation; either version
35
+ * 2 of the License, or (at your option) any later version.
36
+ *
37
+ * You should have received a copy of the GNU General Public License along
38
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
39
+ */
40
+#ifndef HW_TIMER_CADENCE_TTC_H
41
+#define HW_TIMER_CADENCE_TTC_H
42
+
27
+
43
+#include "hw/sysbus.h"
28
+ /*
44
+#include "qemu/timer.h"
29
+ * Generate TSFL interrupt if TX FIFO level exceeds the level
45
+
30
+ * specified in the FIFO_INT TX Status Level field.
46
+typedef struct {
31
+ */
47
+ QEMUTimer *timer;
32
+ if (s->tx_status_fifo_used > ((s->fifo_int >> 16) & 0xff)) {
48
+ int freq;
33
+ s->int_sts |= TSFL_INT;
49
+
34
+ }
50
+ uint32_t reg_clock;
35
if (s->tx_status_fifo_used == 512) {
51
+ uint32_t reg_count;
36
s->int_sts |= TSFF_INT;
52
+ uint32_t reg_value;
37
/* TODO: Stop transmission. */
53
+ uint16_t reg_interval;
54
+ uint16_t reg_match[3];
55
+ uint32_t reg_intr;
56
+ uint32_t reg_intr_en;
57
+ uint32_t reg_event_ctrl;
58
+ uint32_t reg_event;
59
+
60
+ uint64_t cpu_time;
61
+ unsigned int cpu_time_valid;
62
+
63
+ qemu_irq irq;
64
+} CadenceTimerState;
65
+
66
+#define TYPE_CADENCE_TTC "cadence_ttc"
67
+OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC)
68
+
69
+struct CadenceTTCState {
70
+ SysBusDevice parent_obj;
71
+
72
+ MemoryRegion iomem;
73
+ CadenceTimerState timer[3];
74
+};
75
+
76
+#endif
77
diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/timer/cadence_ttc.c
80
+++ b/hw/timer/cadence_ttc.c
81
@@ -XXX,XX +XXX,XX @@
82
#include "qemu/timer.h"
83
#include "qom/object.h"
84
85
+#include "hw/timer/cadence_ttc.h"
86
+
87
#ifdef CADENCE_TTC_ERR_DEBUG
88
#define DB_PRINT(...) do { \
89
fprintf(stderr, ": %s: ", __func__); \
90
@@ -XXX,XX +XXX,XX @@
91
#define CLOCK_CTRL_PS_EN 0x00000001
92
#define CLOCK_CTRL_PS_V 0x0000001e
93
94
-typedef struct {
95
- QEMUTimer *timer;
96
- int freq;
97
-
98
- uint32_t reg_clock;
99
- uint32_t reg_count;
100
- uint32_t reg_value;
101
- uint16_t reg_interval;
102
- uint16_t reg_match[3];
103
- uint32_t reg_intr;
104
- uint32_t reg_intr_en;
105
- uint32_t reg_event_ctrl;
106
- uint32_t reg_event;
107
-
108
- uint64_t cpu_time;
109
- unsigned int cpu_time_valid;
110
-
111
- qemu_irq irq;
112
-} CadenceTimerState;
113
-
114
-#define TYPE_CADENCE_TTC "cadence_ttc"
115
-OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC)
116
-
117
-struct CadenceTTCState {
118
- SysBusDevice parent_obj;
119
-
120
- MemoryRegion iomem;
121
- CadenceTimerState timer[3];
122
-};
123
-
124
static void cadence_timer_update(CadenceTimerState *s)
125
{
126
qemu_set_irq(s->irq, !!(s->reg_intr & s->reg_intr_en));
127
--
38
--
128
2.25.1
39
2.25.1
diff view generated by jsdifflib
1
The exynos4210 SoC mostly creates its child devices as if it were
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
board code. This includes the a9mpcore object. Switch that to a
3
new-style "embedded in the state struct" creation, because in the
4
next commit we're going to want to refer to the object again further
5
down in the exynos4210_realize() function.
6
2
3
Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX.
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220819153931.3147384-2-peter.maydell@linaro.org
9
Message-id: 20220404154658.565020-4-peter.maydell@linaro.org
10
---
10
---
11
include/hw/arm/exynos4210.h | 2 ++
11
chardev/baum.c | 11 +++++++----
12
hw/arm/exynos4210.c | 11 ++++++-----
12
1 file changed, 7 insertions(+), 4 deletions(-)
13
2 files changed, 8 insertions(+), 5 deletions(-)
14
13
15
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
14
diff --git a/chardev/baum.c b/chardev/baum.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/exynos4210.h
16
--- a/chardev/baum.c
18
+++ b/include/hw/arm/exynos4210.h
17
+++ b/chardev/baum.c
19
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@
20
19
21
#include "hw/or-irq.h"
20
#define BUF_SIZE 256
22
#include "hw/sysbus.h"
21
23
+#include "hw/cpu/a9mpcore.h"
22
+#define X_MAX 84
24
#include "target/arm/cpu-qom.h"
23
+#define Y_MAX 1
25
#include "qom/object.h"
24
+
26
25
struct BaumChardev {
27
@@ -XXX,XX +XXX,XX @@ struct Exynos4210State {
26
Chardev parent;
28
I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER];
27
29
qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA];
28
@@ -XXX,XX +XXX,XX @@ static int baum_deferred_init(BaumChardev *baum)
30
qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS];
29
brlapi_perror("baum: brlapi__getDisplaySize");
31
+ A9MPPrivState a9mpcore;
30
return 0;
32
};
33
34
#define TYPE_EXYNOS4210_SOC "exynos4210"
35
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/arm/exynos4210.c
38
+++ b/hw/arm/exynos4210.c
39
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
40
}
31
}
41
32
- if (baum->y > 1) {
42
/* Private memory region and Internal GIC */
33
- baum->y = 1;
43
- dev = qdev_new(TYPE_A9MPCORE_PRIV);
34
+ if (baum->y > Y_MAX) {
44
- qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS);
35
+ baum->y = Y_MAX;
45
- busdev = SYS_BUS_DEVICE(dev);
46
- sysbus_realize_and_unref(busdev, &error_fatal);
47
+ qdev_prop_set_uint32(DEVICE(&s->a9mpcore), "num-cpu", EXYNOS4210_NCPUS);
48
+ busdev = SYS_BUS_DEVICE(&s->a9mpcore);
49
+ sysbus_realize(busdev, &error_fatal);
50
sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR);
51
for (n = 0; n < EXYNOS4210_NCPUS; n++) {
52
sysbus_connect_irq(busdev, n,
53
qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0));
54
}
36
}
55
for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) {
37
- if (baum->x > 84) {
56
- s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n);
38
- baum->x = 84;
57
+ s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n);
39
+ if (baum->x > X_MAX) {
40
+ baum->x = X_MAX;
58
}
41
}
59
42
60
/* Cache controller */
43
con = qemu_console_lookup_by_index(0);
61
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj)
62
g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i);
63
object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ);
64
}
65
+
66
+ object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV);
67
}
68
69
static void exynos4210_class_init(ObjectClass *klass, void *data)
70
--
44
--
71
2.25.1
45
2.25.1
46
47
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not
4
a big value, it is actually 84). Instead of having the compiler
5
use variable-length array, declare an array able to hold the
6
maximum 'x * y'.
7
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
10
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20220819153931.3147384-3-peter.maydell@linaro.org
13
---
14
chardev/baum.c | 8 ++++----
15
1 file changed, 4 insertions(+), 4 deletions(-)
16
17
diff --git a/chardev/baum.c b/chardev/baum.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/chardev/baum.c
20
+++ b/chardev/baum.c
21
@@ -XXX,XX +XXX,XX @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
22
switch (req) {
23
case BAUM_REQ_DisplayData:
24
{
25
- uint8_t cells[baum->x * baum->y], c;
26
- uint8_t text[baum->x * baum->y];
27
- uint8_t zero[baum->x * baum->y];
28
+ uint8_t cells[X_MAX * Y_MAX], c;
29
+ uint8_t text[X_MAX * Y_MAX];
30
+ uint8_t zero[X_MAX * Y_MAX];
31
int cursor = BRLAPI_CURSOR_OFF;
32
int i;
33
34
@@ -XXX,XX +XXX,XX @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
35
}
36
timer_del(baum->cellCount_timer);
37
38
- memset(zero, 0, sizeof(zero));
39
+ memset(zero, 0, baum->x * baum->y);
40
41
brlapi_writeArguments_t wa = {
42
.displayNumber = BRLAPI_DISPLAY_DEFAULT,
43
--
44
2.25.1
45
46
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20220819153931.3147384-4-peter.maydell@linaro.org
11
---
12
chardev/baum.c | 3 ++-
13
1 file changed, 2 insertions(+), 1 deletion(-)
14
15
diff --git a/chardev/baum.c b/chardev/baum.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/chardev/baum.c
18
+++ b/chardev/baum.c
19
@@ -XXX,XX +XXX,XX @@ static void baum_chr_accept_input(struct Chardev *chr)
20
static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len)
21
{
22
Chardev *chr = CHARDEV(baum);
23
- uint8_t io_buf[1 + 2 * len], *cur = io_buf;
24
+ g_autofree uint8_t *io_buf = g_malloc(1 + 2 * len);
25
+ uint8_t *cur = io_buf;
26
int room;
27
*cur++ = ESC;
28
while (len--)
29
--
30
2.25.1
31
32
diff view generated by jsdifflib
1
At this point, the function exynos4210_init_board_irqs() splits input
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
IRQ lines to connect them to the input combiner, output combiner and
3
external GIC. The function exynos4210_combiner_get_gpioin() splits
4
some of the combiner input lines further to connect them to multiple
5
different inputs on the combiner.
6
2
7
Because (unlike qemu_irq_split()) the TYPE_SPLIT_IRQ device has a
3
The combined_key[... QIO_CHANNEL_WEBSOCK_GUID_LEN ...] array in
8
configurable number of outputs, we can do all this in one place, by
4
qio_channel_websock_handshake_send_res_ok() expands to a call
9
making exynos4210_init_board_irqs() add extra outputs to the splitter
5
to strlen(QIO_CHANNEL_WEBSOCK_GUID), and the compiler doesn't
10
device when it must be connected to more than one input on each
6
realize the string is const, so consider combined_key[] being
11
combiner.
7
a variable-length array.
12
8
13
We do this with a new data structure, the combinermap, which is an
9
To remove the variable-length array, we provide it a hint to
14
array each of whose elements is a list of the interrupt IDs on the
10
the compiler by using sizeof() - 1 instead of strlen().
15
combiner which must be tied together. As we loop through each
16
interrupt ID, if we find that it is the first one in one of these
17
lists, we configure the splitter device with eonugh extra outputs and
18
wire them up to the other interrupt IDs in the list.
19
11
20
Conveniently, for all the cases where this is necessary, the
12
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
21
lowest-numbered interrupt ID in each group is in the range of the
13
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
22
external combiner, so we only need to code for this in the first of
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
the two loops in exynos4210_init_board_irqs().
15
Message-id: 20220819153931.3147384-5-peter.maydell@linaro.org
16
---
17
io/channel-websock.c | 2 +-
18
1 file changed, 1 insertion(+), 1 deletion(-)
24
19
25
The old code in exynos4210_combiner_get_gpioin() which is being
20
diff --git a/io/channel-websock.c b/io/channel-websock.c
26
deleted here had several problems which don't exist in the new code
27
in its handling of the multi-core timer interrupts:
28
(1) the case labels specified bits 4 ... 8, but bit '8' doesn't
29
exist; these should have been 4 ... 7
30
(2) it used the input irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]
31
multiple times as the input of several different splitters,
32
which isn't allowed
33
(3) in an apparent cut-and-paste error, the cases for all the
34
multi-core timer inputs used "bit + 4" even though the
35
bit range for the case was (intended to be) 4 ... 7, which
36
meant it was looking at non-existent bits 8 ... 11.
37
None of these exist in the new code.
38
39
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
40
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
41
Message-id: 20220404154658.565020-17-peter.maydell@linaro.org
42
---
43
include/hw/arm/exynos4210.h | 6 +-
44
hw/arm/exynos4210.c | 178 +++++++++++++++++++++++-------------
45
2 files changed, 119 insertions(+), 65 deletions(-)
46
47
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
48
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
49
--- a/include/hw/arm/exynos4210.h
22
--- a/io/channel-websock.c
50
+++ b/include/hw/arm/exynos4210.h
23
+++ b/io/channel-websock.c
51
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@
52
25
53
/*
26
#define QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN 24
54
* We need one splitter for every external combiner input, plus
27
#define QIO_CHANNEL_WEBSOCK_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
55
- * one for every non-zero entry in combiner_grp_to_gic_id[].
28
-#define QIO_CHANNEL_WEBSOCK_GUID_LEN strlen(QIO_CHANNEL_WEBSOCK_GUID)
56
+ * one for every non-zero entry in combiner_grp_to_gic_id[],
29
+#define QIO_CHANNEL_WEBSOCK_GUID_LEN (sizeof(QIO_CHANNEL_WEBSOCK_GUID) - 1)
57
+ * minus one for every external combiner ID in second or later
30
58
+ * places in a combinermap[] line.
31
#define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "sec-websocket-protocol"
59
* We'll assert in exynos4210_init_board_irqs() if this is wrong.
32
#define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "sec-websocket-version"
60
*/
61
-#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54)
62
+#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38)
63
64
typedef struct Exynos4210Irq {
65
qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
66
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/hw/arm/exynos4210.c
69
+++ b/hw/arm/exynos4210.c
70
@@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
71
#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \
72
((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq))
73
74
+/*
75
+ * Some interrupt lines go to multiple combiner inputs.
76
+ * This data structure defines those: each array element is
77
+ * a list of combiner inputs which are connected together;
78
+ * the one with the smallest interrupt ID value must be first.
79
+ * As with combiner_grp_to_gic_id[], we rely on (0, 0) not being
80
+ * wired to anything so we can use 0 as a terminator.
81
+ */
82
+#define IRQNO(G, B) EXYNOS4210_COMBINER_GET_IRQ_NUM(G, B)
83
+#define IRQNONE 0
84
+
85
+#define COMBINERMAP_SIZE 16
86
+
87
+static const int combinermap[COMBINERMAP_SIZE][6] = {
88
+ /* MDNIE_LCD1 */
89
+ { IRQNO(0, 4), IRQNO(1, 0), IRQNONE },
90
+ { IRQNO(0, 5), IRQNO(1, 1), IRQNONE },
91
+ { IRQNO(0, 6), IRQNO(1, 2), IRQNONE },
92
+ { IRQNO(0, 7), IRQNO(1, 3), IRQNONE },
93
+ /* TMU */
94
+ { IRQNO(2, 4), IRQNO(3, 4), IRQNONE },
95
+ { IRQNO(2, 5), IRQNO(3, 5), IRQNONE },
96
+ { IRQNO(2, 6), IRQNO(3, 6), IRQNONE },
97
+ { IRQNO(2, 7), IRQNO(3, 7), IRQNONE },
98
+ /* LCD1 */
99
+ { IRQNO(11, 4), IRQNO(12, 0), IRQNONE },
100
+ { IRQNO(11, 5), IRQNO(12, 1), IRQNONE },
101
+ { IRQNO(11, 6), IRQNO(12, 2), IRQNONE },
102
+ { IRQNO(11, 7), IRQNO(12, 3), IRQNONE },
103
+ /* Multi-core timer */
104
+ { IRQNO(1, 4), IRQNO(12, 4), IRQNO(35, 4), IRQNO(51, 4), IRQNO(53, 4), IRQNONE },
105
+ { IRQNO(1, 5), IRQNO(12, 5), IRQNO(35, 5), IRQNO(51, 5), IRQNO(53, 5), IRQNONE },
106
+ { IRQNO(1, 6), IRQNO(12, 6), IRQNO(35, 6), IRQNO(51, 6), IRQNO(53, 6), IRQNONE },
107
+ { IRQNO(1, 7), IRQNO(12, 7), IRQNO(35, 7), IRQNO(51, 7), IRQNO(53, 7), IRQNONE },
108
+};
109
+
110
+#undef IRQNO
111
+
112
+static const int *combinermap_entry(int irq)
113
+{
114
+ /*
115
+ * If the interrupt number passed in is the first entry in some
116
+ * line of the combinermap, return a pointer to that line;
117
+ * otherwise return NULL.
118
+ */
119
+ int i;
120
+ for (i = 0; i < COMBINERMAP_SIZE; i++) {
121
+ if (combinermap[i][0] == irq) {
122
+ return combinermap[i];
123
+ }
124
+ }
125
+ return NULL;
126
+}
127
+
128
+static int mapline_size(const int *mapline)
129
+{
130
+ /* Return number of entries in this mapline in total */
131
+ int i = 0;
132
+
133
+ if (!mapline) {
134
+ /* Not in the map? IRQ goes to exactly one combiner input */
135
+ return 1;
136
+ }
137
+ while (*mapline != IRQNONE) {
138
+ mapline++;
139
+ i++;
140
+ }
141
+ return i;
142
+}
143
+
144
/*
145
* Initialize board IRQs.
146
* These IRQs contain splitted Int/External Combiner and External Gic IRQs.
147
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
148
DeviceState *extgicdev = DEVICE(&s->ext_gic);
149
int splitcount = 0;
150
DeviceState *splitter;
151
+ const int *mapline;
152
+ int numlines, splitin, in;
153
154
for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) {
155
irq_id = 0;
156
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
157
irq_id = EXT_GIC_ID_MCT_G1;
158
}
159
160
+ if (s->irq_table[n]) {
161
+ /*
162
+ * This must be some non-first entry in a combinermap line,
163
+ * and we've already filled it in.
164
+ */
165
+ continue;
166
+ }
167
+ mapline = combinermap_entry(n);
168
+ /*
169
+ * We need to connect the IRQ to multiple inputs on both combiners
170
+ * and possibly also to the external GIC.
171
+ */
172
+ numlines = 2 * mapline_size(mapline);
173
+ if (irq_id) {
174
+ numlines++;
175
+ }
176
assert(splitcount < EXYNOS4210_NUM_SPLITTERS);
177
splitter = DEVICE(&s->splitter[splitcount]);
178
- qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2);
179
+ qdev_prop_set_uint16(splitter, "num-lines", numlines);
180
qdev_realize(splitter, NULL, &error_abort);
181
splitcount++;
182
- s->irq_table[n] = qdev_get_gpio_in(splitter, 0);
183
- qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]);
184
- qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]);
185
+
186
+ in = n;
187
+ splitin = 0;
188
+ for (;;) {
189
+ s->irq_table[in] = qdev_get_gpio_in(splitter, 0);
190
+ qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]);
191
+ qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]);
192
+ splitin += 2;
193
+ if (!mapline) {
194
+ break;
195
+ }
196
+ mapline++;
197
+ in = *mapline;
198
+ if (in == IRQNONE) {
199
+ break;
200
+ }
201
+ }
202
if (irq_id) {
203
- qdev_connect_gpio_out(splitter, 2,
204
+ qdev_connect_gpio_out(splitter, splitin,
205
qdev_get_gpio_in(extgicdev, irq_id - 32));
206
}
207
}
208
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
209
irq_id = combiner_grp_to_gic_id[grp -
210
EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit];
211
212
+ if (s->irq_table[n]) {
213
+ /*
214
+ * This must be some non-first entry in a combinermap line,
215
+ * and we've already filled it in.
216
+ */
217
+ continue;
218
+ }
219
+
220
if (irq_id) {
221
assert(splitcount < EXYNOS4210_NUM_SPLITTERS);
222
splitter = DEVICE(&s->splitter[splitcount]);
223
@@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs,
224
DeviceState *dev, int ext)
225
{
226
int n;
227
- int bit;
228
int max;
229
qemu_irq *irq;
230
231
@@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs,
232
EXYNOS4210_MAX_INT_COMBINER_IN_IRQ;
233
irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq;
234
235
- /*
236
- * Some IRQs of Int/External Combiner are going to two Combiners groups,
237
- * so let split them.
238
- */
239
for (n = 0; n < max; n++) {
240
-
241
- bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n);
242
-
243
- switch (n) {
244
- /* MDNIE_LCD1 INTG1 */
245
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ...
246
- EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3):
247
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
248
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]);
249
- continue;
250
-
251
- /* TMU INTG3 */
252
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4):
253
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
254
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]);
255
- continue;
256
-
257
- /* LCD1 INTG12 */
258
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ...
259
- EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3):
260
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
261
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]);
262
- continue;
263
-
264
- /* Multi-Core Timer INTG12 */
265
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ...
266
- EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8):
267
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
268
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
269
- continue;
270
-
271
- /* Multi-Core Timer INTG35 */
272
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ...
273
- EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8):
274
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
275
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
276
- continue;
277
-
278
- /* Multi-Core Timer INTG51 */
279
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ...
280
- EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8):
281
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
282
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
283
- continue;
284
-
285
- /* Multi-Core Timer INTG53 */
286
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ...
287
- EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8):
288
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
289
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
290
- continue;
291
- }
292
-
293
irq[n] = qdev_get_gpio_in(dev, n);
294
}
295
}
296
--
33
--
297
2.25.1
34
2.25.1
35
36
diff view generated by jsdifflib
1
The only time we use the ext_gic_irq[] array in the Exynos4210Irq
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
struct is during realize of the SoC -- we initialize it with the
3
input IRQs of the external GIC device, and then connect those to
4
outputs of other devices further on in realize (including in the
5
exynos4210_init_board_irqs() function). Now that the ext_gic object
6
is easily accessible as s->ext_gic we can make the connections
7
directly from one device to the other without going via this array.
8
2
3
The compiler isn't clever enough to figure 'min_buf_size'
4
is a constant, so help it by using a definitions instead.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Acked-by: Jason Wang <jasowang@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220819153931.3147384-6-peter.maydell@linaro.org
11
Message-id: 20220404154658.565020-10-peter.maydell@linaro.org
12
---
11
---
13
include/hw/arm/exynos4210.h | 1 -
12
hw/net/e1000e_core.c | 7 ++++---
14
hw/arm/exynos4210.c | 12 ++++++------
13
1 file changed, 4 insertions(+), 3 deletions(-)
15
2 files changed, 6 insertions(+), 7 deletions(-)
16
14
17
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
15
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/exynos4210.h
17
--- a/hw/net/e1000e_core.c
20
+++ b/include/hw/arm/exynos4210.h
18
+++ b/hw/net/e1000e_core.c
21
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ e1000e_rx_fix_l4_csum(E1000ECore *core, struct NetRxPkt *pkt)
22
typedef struct Exynos4210Irq {
23
qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
24
qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ];
25
- qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ];
26
} Exynos4210Irq;
27
28
struct Exynos4210State {
29
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/exynos4210.c
32
+++ b/hw/arm/exynos4210.c
33
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
34
{
35
uint32_t grp, bit, irq_id, n;
36
Exynos4210Irq *is = &s->irqs;
37
+ DeviceState *extgicdev = DEVICE(&s->ext_gic);
38
39
for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) {
40
irq_id = 0;
41
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
42
}
43
if (irq_id) {
44
s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
45
- is->ext_gic_irq[irq_id - 32]);
46
+ qdev_get_gpio_in(extgicdev,
47
+ irq_id - 32));
48
} else {
49
s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
50
is->ext_combiner_irq[n]);
51
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
52
53
if (irq_id) {
54
s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
55
- is->ext_gic_irq[irq_id - 32]);
56
+ qdev_get_gpio_in(extgicdev,
57
+ irq_id - 32));
58
}
59
}
20
}
60
}
21
}
61
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
22
62
sysbus_connect_irq(busdev, n,
23
+/* Min. octets in an ethernet frame sans FCS */
63
qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1));
24
+#define MIN_BUF_SIZE 60
64
}
25
+
65
- for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) {
26
ssize_t
66
- s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n);
27
e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt)
67
- }
28
{
68
29
static const int maximum_ethernet_hdr_len = (14 + 4);
69
/* Internal Interrupt Combiner */
30
- /* Min. octets in an ethernet frame sans FCS */
70
dev = qdev_new("exynos4210.combiner");
31
- static const int min_buf_size = 60;
71
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
32
72
busdev = SYS_BUS_DEVICE(dev);
33
uint32_t n = 0;
73
sysbus_realize_and_unref(busdev, &error_fatal);
34
- uint8_t min_buf[min_buf_size];
74
for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) {
35
+ uint8_t min_buf[MIN_BUF_SIZE];
75
- sysbus_connect_irq(busdev, n, s->irqs.ext_gic_irq[n]);
36
struct iovec min_iov;
76
+ sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n));
37
uint8_t *filter_buf;
77
}
38
size_t size, orig_size;
78
exynos4210_combiner_get_gpioin(&s->irqs, dev, 1);
79
sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR);
80
--
39
--
81
2.25.1
40
2.25.1
41
42
diff view generated by jsdifflib
1
Now we have removed the only use of TYPE_EXYNOS4210_IRQ_GATE we can
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
delete the device entirely.
3
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Acked-by: David Gibson <david@gibson.dropbear.id.au>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 20220404154658.565020-3-peter.maydell@linaro.org
10
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
11
Message-id: 20220819153931.3147384-7-peter.maydell@linaro.org
7
---
12
---
8
hw/intc/exynos4210_gic.c | 107 ---------------------------------------
13
hw/ppc/pnv.c | 4 ++--
9
1 file changed, 107 deletions(-)
14
hw/ppc/spapr.c | 8 ++++----
15
hw/ppc/spapr_pci_nvlink2.c | 2 +-
16
3 files changed, 7 insertions(+), 7 deletions(-)
10
17
11
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
18
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
12
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/intc/exynos4210_gic.c
20
--- a/hw/ppc/pnv.c
14
+++ b/hw/intc/exynos4210_gic.c
21
+++ b/hw/ppc/pnv.c
15
@@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_register_types(void)
22
@@ -XXX,XX +XXX,XX @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt)
23
int smt_threads = CPU_CORE(pc)->nr_threads;
24
CPUPPCState *env = &cpu->env;
25
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);
26
- uint32_t servers_prop[smt_threads];
27
+ g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads);
28
int i;
29
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
30
0xffffffff, 0xffffffff};
31
@@ -XXX,XX +XXX,XX @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt)
32
servers_prop[i] = cpu_to_be32(pc->pir + i);
33
}
34
_FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
35
- servers_prop, sizeof(servers_prop))));
36
+ servers_prop, sizeof(*servers_prop) * smt_threads)));
16
}
37
}
17
38
18
type_init(exynos4210_gic_register_types)
39
static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,
19
-
40
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
20
-/* IRQ OR Gate struct.
41
index XXXXXXX..XXXXXXX 100644
21
- *
42
--- a/hw/ppc/spapr.c
22
- * This device models an OR gate. There are n_in input qdev gpio lines and one
43
+++ b/hw/ppc/spapr.c
23
- * output sysbus IRQ line. The output IRQ level is formed as OR between all
44
@@ -XXX,XX +XXX,XX @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
24
- * gpio inputs.
45
int smt_threads)
25
- */
46
{
26
-
47
int i, ret = 0;
27
-#define TYPE_EXYNOS4210_IRQ_GATE "exynos4210.irq_gate"
48
- uint32_t servers_prop[smt_threads];
28
-OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210IRQGateState, EXYNOS4210_IRQ_GATE)
49
- uint32_t gservers_prop[smt_threads * 2];
29
-
50
+ g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads);
30
-struct Exynos4210IRQGateState {
51
+ g_autofree uint32_t *gservers_prop = g_new(uint32_t, smt_threads * 2);
31
- SysBusDevice parent_obj;
52
int index = spapr_get_vcpu_id(cpu);
32
-
53
33
- uint32_t n_in; /* inputs amount */
54
if (cpu->compat_pvr) {
34
- uint32_t *level; /* input levels */
55
@@ -XXX,XX +XXX,XX @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
35
- qemu_irq out; /* output IRQ */
56
gservers_prop[i*2 + 1] = 0;
36
-};
57
}
37
-
58
ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
38
-static Property exynos4210_irq_gate_properties[] = {
59
- servers_prop, sizeof(servers_prop));
39
- DEFINE_PROP_UINT32("n_in", Exynos4210IRQGateState, n_in, 1),
60
+ servers_prop, sizeof(*servers_prop) * smt_threads);
40
- DEFINE_PROP_END_OF_LIST(),
61
if (ret < 0) {
41
-};
62
return ret;
42
-
63
}
43
-static const VMStateDescription vmstate_exynos4210_irq_gate = {
64
ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s",
44
- .name = "exynos4210.irq_gate",
65
- gservers_prop, sizeof(gservers_prop));
45
- .version_id = 2,
66
+ gservers_prop, sizeof(*gservers_prop) * smt_threads * 2);
46
- .minimum_version_id = 2,
67
47
- .fields = (VMStateField[]) {
68
return ret;
48
- VMSTATE_VBUFFER_UINT32(level, Exynos4210IRQGateState, 1, NULL, n_in),
69
}
49
- VMSTATE_END_OF_LIST()
70
diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c
50
- }
71
index XXXXXXX..XXXXXXX 100644
51
-};
72
--- a/hw/ppc/spapr_pci_nvlink2.c
52
-
73
+++ b/hw/ppc/spapr_pci_nvlink2.c
53
-/* Process a change in IRQ input. */
74
@@ -XXX,XX +XXX,XX @@ void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int offset,
54
-static void exynos4210_irq_gate_handler(void *opaque, int irq, int level)
75
continue;
55
-{
76
}
56
- Exynos4210IRQGateState *s = (Exynos4210IRQGateState *)opaque;
77
if (dev == nvslot->gpdev) {
57
- uint32_t i;
78
- uint32_t npus[nvslot->linknum];
58
-
79
+ g_autofree uint32_t *npus = g_new(uint32_t, nvslot->linknum);
59
- assert(irq < s->n_in);
80
60
-
81
for (j = 0; j < nvslot->linknum; ++j) {
61
- s->level[irq] = level;
82
PCIDevice *npdev = nvslot->links[j].npdev;
62
-
63
- for (i = 0; i < s->n_in; i++) {
64
- if (s->level[i] >= 1) {
65
- qemu_irq_raise(s->out);
66
- return;
67
- }
68
- }
69
-
70
- qemu_irq_lower(s->out);
71
-}
72
-
73
-static void exynos4210_irq_gate_reset(DeviceState *d)
74
-{
75
- Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(d);
76
-
77
- memset(s->level, 0, s->n_in * sizeof(*s->level));
78
-}
79
-
80
-/*
81
- * IRQ Gate initialization.
82
- */
83
-static void exynos4210_irq_gate_init(Object *obj)
84
-{
85
- Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(obj);
86
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
87
-
88
- sysbus_init_irq(sbd, &s->out);
89
-}
90
-
91
-static void exynos4210_irq_gate_realize(DeviceState *dev, Error **errp)
92
-{
93
- Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(dev);
94
-
95
- /* Allocate general purpose input signals and connect a handler to each of
96
- * them */
97
- qdev_init_gpio_in(dev, exynos4210_irq_gate_handler, s->n_in);
98
-
99
- s->level = g_malloc0(s->n_in * sizeof(*s->level));
100
-}
101
-
102
-static void exynos4210_irq_gate_class_init(ObjectClass *klass, void *data)
103
-{
104
- DeviceClass *dc = DEVICE_CLASS(klass);
105
-
106
- dc->reset = exynos4210_irq_gate_reset;
107
- dc->vmsd = &vmstate_exynos4210_irq_gate;
108
- device_class_set_props(dc, exynos4210_irq_gate_properties);
109
- dc->realize = exynos4210_irq_gate_realize;
110
-}
111
-
112
-static const TypeInfo exynos4210_irq_gate_info = {
113
- .name = TYPE_EXYNOS4210_IRQ_GATE,
114
- .parent = TYPE_SYS_BUS_DEVICE,
115
- .instance_size = sizeof(Exynos4210IRQGateState),
116
- .instance_init = exynos4210_irq_gate_init,
117
- .class_init = exynos4210_irq_gate_class_init,
118
-};
119
-
120
-static void exynos4210_irq_gate_register_types(void)
121
-{
122
- type_register_static(&exynos4210_irq_gate_info);
123
-}
124
-
125
-type_init(exynos4210_irq_gate_register_types)
126
--
83
--
127
2.25.1
84
2.25.1
85
86
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Acked-by: David Gibson <david@gibson.dropbear.id.au>
8
Reviewed-by: Greg Kurz <groug@kaod.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20220819153931.3147384-8-peter.maydell@linaro.org
11
---
12
hw/intc/xics.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/xics.c
18
+++ b/hw/intc/xics.c
19
@@ -XXX,XX +XXX,XX @@ static void ics_reset_irq(ICSIRQState *irq)
20
static void ics_reset(DeviceState *dev)
21
{
22
ICSState *ics = ICS(dev);
23
+ g_autofree uint8_t *flags = g_malloc(ics->nr_irqs);
24
int i;
25
- uint8_t flags[ics->nr_irqs];
26
27
for (i = 0; i < ics->nr_irqs; i++) {
28
flags[i] = ics->irqs[i].flags;
29
--
30
2.25.1
31
32
diff view generated by jsdifflib
1
The exynos4210 code currently has two very similar arrays of IRQs:
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
* board_irqs is a field of the Exynos4210Irq struct which is filled
3
Use autofree heap allocation instead of variable-length array on
4
in by exynos4210_init_board_irqs() with the appropriate qemu_irqs
4
the stack. Replace the snprintf() call by g_strdup_printf().
5
for each IRQ the board/SoC can assert
6
* irq_table is a set of qemu_irqs pointed to from the
7
Exynos4210State struct. It's allocated in exynos4210_init_irq,
8
and the only behaviour these irqs have is that they pass on the
9
level to the equivalent board_irqs[] irq
10
5
11
The extra indirection through irq_table is unnecessary, so coalesce
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
these into a single irq_table[] array as a direct field in
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Exynos4210State which exynos4210_init_board_irqs() fills in.
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-9-peter.maydell@linaro.org
10
---
11
hw/i386/multiboot.c | 5 ++---
12
1 file changed, 2 insertions(+), 3 deletions(-)
14
13
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20220404154658.565020-6-peter.maydell@linaro.org
18
---
19
include/hw/arm/exynos4210.h | 8 ++------
20
hw/arm/exynos4210.c | 6 +-----
21
hw/intc/exynos4210_gic.c | 32 ++++++++------------------------
22
3 files changed, 11 insertions(+), 35 deletions(-)
23
24
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
25
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/arm/exynos4210.h
16
--- a/hw/i386/multiboot.c
27
+++ b/include/hw/arm/exynos4210.h
17
+++ b/hw/i386/multiboot.c
28
@@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210Irq {
18
@@ -XXX,XX +XXX,XX @@ int load_multiboot(X86MachineState *x86ms,
29
qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
19
uint8_t *mb_bootinfo_data;
30
qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ];
20
uint32_t cmdline_len;
31
qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ];
21
GList *mods = NULL;
32
- qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
22
+ g_autofree char *kcmdline = NULL;
33
} Exynos4210Irq;
23
34
24
/* Ok, let's see if it is a multiboot image.
35
struct Exynos4210State {
25
The header is 12x32bit long, so the latest entry may be 8192 - 48. */
36
@@ -XXX,XX +XXX,XX @@ struct Exynos4210State {
26
@@ -XXX,XX +XXX,XX @@ int load_multiboot(X86MachineState *x86ms,
37
/*< public >*/
38
ARMCPU *cpu[EXYNOS4210_NCPUS];
39
Exynos4210Irq irqs;
40
- qemu_irq *irq_table;
41
+ qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
42
43
MemoryRegion chipid_mem;
44
MemoryRegion iram_mem;
45
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC)
46
void exynos4210_write_secondary(ARMCPU *cpu,
47
const struct arm_boot_info *info);
48
49
-/* Initialize exynos4210 IRQ subsystem stub */
50
-qemu_irq *exynos4210_init_irq(Exynos4210Irq *env);
51
-
52
/* Initialize board IRQs.
53
* These IRQs contain splitted Int/External Combiner and External Gic IRQs */
54
-void exynos4210_init_board_irqs(Exynos4210Irq *s);
55
+void exynos4210_init_board_irqs(Exynos4210State *s);
56
57
/* Get IRQ number from exynos4210 IRQ subsystem stub.
58
* To identify IRQ source use internal combiner group and bit number
59
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/hw/arm/exynos4210.c
62
+++ b/hw/arm/exynos4210.c
63
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
64
qdev_realize(DEVICE(cpuobj), NULL, &error_fatal);
65
}
27
}
66
28
67
- /*** IRQs ***/
29
/* Commandline support */
68
-
30
- char kcmdline[strlen(kernel_filename) + strlen(kernel_cmdline) + 2];
69
- s->irq_table = exynos4210_init_irq(&s->irqs);
31
- snprintf(kcmdline, sizeof(kcmdline), "%s %s",
70
-
32
- kernel_filename, kernel_cmdline);
71
/* IRQ Gate */
33
+ kcmdline = g_strdup_printf("%s %s", kernel_filename, kernel_cmdline);
72
for (i = 0; i < EXYNOS4210_NCPUS; i++) {
34
stl_p(bootinfo + MBI_CMDLINE, mb_add_cmdline(&mbs, kcmdline));
73
DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]);
35
74
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
36
stl_p(bootinfo + MBI_BOOTLOADER, mb_add_bootloader(&mbs, bootloader_name));
75
sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR);
76
77
/* Initialize board IRQs. */
78
- exynos4210_init_board_irqs(&s->irqs);
79
+ exynos4210_init_board_irqs(s);
80
81
/*** Memory ***/
82
83
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/hw/intc/exynos4210_gic.c
86
+++ b/hw/intc/exynos4210_gic.c
87
@@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
88
#define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100
89
#define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000
90
91
-static void exynos4210_irq_handler(void *opaque, int irq, int level)
92
-{
93
- Exynos4210Irq *s = (Exynos4210Irq *)opaque;
94
-
95
- /* Bypass */
96
- qemu_set_irq(s->board_irqs[irq], level);
97
-}
98
-
99
-/*
100
- * Initialize exynos4210 IRQ subsystem stub.
101
- */
102
-qemu_irq *exynos4210_init_irq(Exynos4210Irq *s)
103
-{
104
- return qemu_allocate_irqs(exynos4210_irq_handler, s,
105
- EXYNOS4210_MAX_INT_COMBINER_IN_IRQ);
106
-}
107
-
108
/*
109
* Initialize board IRQs.
110
* These IRQs contain splitted Int/External Combiner and External Gic IRQs.
111
*/
112
-void exynos4210_init_board_irqs(Exynos4210Irq *s)
113
+void exynos4210_init_board_irqs(Exynos4210State *s)
114
{
115
uint32_t grp, bit, irq_id, n;
116
+ Exynos4210Irq *is = &s->irqs;
117
118
for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) {
119
irq_id = 0;
120
@@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s)
121
irq_id = EXT_GIC_ID_MCT_G1;
122
}
123
if (irq_id) {
124
- s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n],
125
- s->ext_gic_irq[irq_id-32]);
126
+ s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
127
+ is->ext_gic_irq[irq_id - 32]);
128
} else {
129
- s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n],
130
- s->ext_combiner_irq[n]);
131
+ s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
132
+ is->ext_combiner_irq[n]);
133
}
134
}
135
for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) {
136
@@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s)
137
EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit];
138
139
if (irq_id) {
140
- s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n],
141
- s->ext_gic_irq[irq_id-32]);
142
+ s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
143
+ is->ext_gic_irq[irq_id - 32]);
144
}
145
}
146
}
147
--
37
--
148
2.25.1
38
2.25.1
39
40
diff view generated by jsdifflib
1
It's not possible to provide the guest with the Security extensions
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
(TrustZone) when using KVM or HVF, because the hardware
3
virtualization extensions don't permit running EL3 guest code.
4
However, we weren't checking for this combination, with the result
5
that QEMU would assert if you tried it:
6
2
7
$ qemu-system-aarch64 -enable-kvm -machine virt,secure=on -cpu host -display none
3
The compiler isn't clever enough to figure 'width' is a constant,
8
Unexpected error in object_property_find_err() at ../../qom/object.c:1304:
4
so help it by using a definitions instead.
9
qemu-system-aarch64: Property 'host-arm-cpu.secure-memory' not found
10
Aborted
11
5
12
Check for this combination of options and report an error, in the
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
same way we already do for attempts to give a KVM or HVF guest the
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Virtualization or MTE extensions. Now we will report:
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-10-peter.maydell@linaro.org
10
---
11
hw/usb/hcd-ohci.c | 7 ++++---
12
1 file changed, 4 insertions(+), 3 deletions(-)
15
13
16
qemu-system-aarch64: mach-virt: KVM does not support providing Security extensions (TrustZone) to the guest CPU
14
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
17
18
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/961
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Message-id: 20220404155301.566542-1-peter.maydell@linaro.org
22
---
23
hw/arm/virt.c | 7 +++++++
24
1 file changed, 7 insertions(+)
25
26
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
27
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/arm/virt.c
16
--- a/hw/usb/hcd-ohci.c
29
+++ b/hw/arm/virt.c
17
+++ b/hw/usb/hcd-ohci.c
30
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
18
@@ -XXX,XX +XXX,XX @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed)
31
exit(1);
19
return 1;
20
}
21
22
+#define HEX_CHAR_PER_LINE 16
23
+
24
static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
25
{
26
bool print16;
27
bool printall;
28
- const int width = 16;
29
int i;
30
- char tmp[3 * width + 1];
31
+ char tmp[3 * HEX_CHAR_PER_LINE + 1];
32
char *p = tmp;
33
34
print16 = !!trace_event_get_state_backends(TRACE_USB_OHCI_TD_PKT_SHORT);
35
@@ -XXX,XX +XXX,XX @@ static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
32
}
36
}
33
37
34
+ if (vms->secure && (kvm_enabled() || hvf_enabled())) {
38
for (i = 0; ; i++) {
35
+ error_report("mach-virt: %s does not support providing "
39
- if (i && (!(i % width) || (i == len))) {
36
+ "Security extensions (TrustZone) to the guest CPU",
40
+ if (i && (!(i % HEX_CHAR_PER_LINE) || (i == len))) {
37
+ kvm_enabled() ? "KVM" : "HVF");
41
if (!printall) {
38
+ exit(1);
42
trace_usb_ohci_td_pkt_short(msg, tmp);
39
+ }
43
break;
40
+
41
if (vms->virt && (kvm_enabled() || hvf_enabled())) {
42
error_report("mach-virt: %s does not support providing "
43
"Virtualization extensions to the guest CPU",
44
--
44
--
45
2.25.1
45
2.25.1
46
47
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-11-peter.maydell@linaro.org
10
---
11
ui/curses.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/ui/curses.c b/ui/curses.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/ui/curses.c
17
+++ b/ui/curses.c
18
@@ -XXX,XX +XXX,XX @@ static void curses_update(DisplayChangeListener *dcl,
19
int x, int y, int w, int h)
20
{
21
console_ch_t *line;
22
- cchar_t curses_line[width];
23
+ g_autofree cchar_t *curses_line = g_new(cchar_t, width);
24
wchar_t wch[CCHARW_MAX];
25
attr_t attrs;
26
short colors;
27
--
28
2.25.1
29
30
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-12-peter.maydell@linaro.org
10
---
11
tests/unit/test-vmstate.c | 7 +++----
12
1 file changed, 3 insertions(+), 4 deletions(-)
13
14
diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/unit/test-vmstate.c
17
+++ b/tests/unit/test-vmstate.c
18
@@ -XXX,XX +XXX,XX @@ static void save_buffer(const uint8_t *buf, size_t buf_size)
19
static void compare_vmstate(const uint8_t *wire, size_t size)
20
{
21
QEMUFile *f = open_test_file(false);
22
- uint8_t result[size];
23
+ g_autofree uint8_t *result = g_malloc(size);
24
25
/* read back as binary */
26
27
- g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==,
28
- sizeof(result));
29
+ g_assert_cmpint(qemu_get_buffer(f, result, size), ==, size);
30
g_assert(!qemu_file_get_error(f));
31
32
/* Compare that what is on the file is the same that what we
33
expected to be there */
34
- SUCCESS(memcmp(result, wire, sizeof(result)));
35
+ SUCCESS(memcmp(result, wire, size));
36
37
/* Must reach EOF */
38
qemu_get_byte(f);
39
--
40
2.25.1
41
42
diff view generated by jsdifflib
1
The function exynos4210_init_board_irqs() currently lives in
1
Shellcheck correctly reports that we set python_version and never use
2
exynos4210_gic.c, but it isn't really part of the exynos4210.gic
2
it. This is a leftover from commit f9332757898a7: we used to use
3
device -- it is a function that implements (some of) the wiring up of
3
python_version purely to as part of the summary information printed
4
interrupts between the SoC's GIC and combiner components. This means
4
at the end of a configure run, and that commit changed to printing
5
it fits better in exynos4210.c, which is the SoC-level code. Move it
5
the information from meson (which looks up the python version
6
there. Similarly, exynos4210_git_irq() is used almost only in the
6
itself). Remove the unused variable.
7
SoC-level code, so move it too.
8
7
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11
Message-id: 20220404154658.565020-8-peter.maydell@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20220825150703.4074125-2-peter.maydell@linaro.org
12
---
12
---
13
include/hw/arm/exynos4210.h | 4 -
13
configure | 3 ---
14
hw/arm/exynos4210.c | 202 +++++++++++++++++++++++++++++++++++
14
1 file changed, 3 deletions(-)
15
hw/intc/exynos4210_gic.c | 204 ------------------------------------
16
3 files changed, 202 insertions(+), 208 deletions(-)
17
15
18
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
16
diff --git a/configure b/configure
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100755
20
--- a/include/hw/arm/exynos4210.h
18
--- a/configure
21
+++ b/include/hw/arm/exynos4210.h
19
+++ b/configure
22
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC)
20
@@ -XXX,XX +XXX,XX @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
23
void exynos4210_write_secondary(ARMCPU *cpu,
21
"Use --python=/path/to/python to specify a supported Python."
24
const struct arm_boot_info *info);
22
fi
25
23
26
-/* Initialize board IRQs.
24
-# Preserve python version since some functionality is dependent on it
27
- * These IRQs contain splitted Int/External Combiner and External Gic IRQs */
25
-python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
28
-void exynos4210_init_board_irqs(Exynos4210State *s);
29
-
26
-
30
/* Get IRQ number from exynos4210 IRQ subsystem stub.
27
# Suppress writing compiled files
31
* To identify IRQ source use internal combiner group and bit number
28
python="$python -B"
32
* grp - group number
33
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/exynos4210.c
36
+++ b/hw/arm/exynos4210.c
37
@@ -XXX,XX +XXX,XX @@
38
#define EXYNOS4210_PL330_BASE1_ADDR 0x12690000
39
#define EXYNOS4210_PL330_BASE2_ADDR 0x12850000
40
41
+enum ExtGicId {
42
+ EXT_GIC_ID_MDMA_LCD0 = 66,
43
+ EXT_GIC_ID_PDMA0,
44
+ EXT_GIC_ID_PDMA1,
45
+ EXT_GIC_ID_TIMER0,
46
+ EXT_GIC_ID_TIMER1,
47
+ EXT_GIC_ID_TIMER2,
48
+ EXT_GIC_ID_TIMER3,
49
+ EXT_GIC_ID_TIMER4,
50
+ EXT_GIC_ID_MCT_L0,
51
+ EXT_GIC_ID_WDT,
52
+ EXT_GIC_ID_RTC_ALARM,
53
+ EXT_GIC_ID_RTC_TIC,
54
+ EXT_GIC_ID_GPIO_XB,
55
+ EXT_GIC_ID_GPIO_XA,
56
+ EXT_GIC_ID_MCT_L1,
57
+ EXT_GIC_ID_IEM_APC,
58
+ EXT_GIC_ID_IEM_IEC,
59
+ EXT_GIC_ID_NFC,
60
+ EXT_GIC_ID_UART0,
61
+ EXT_GIC_ID_UART1,
62
+ EXT_GIC_ID_UART2,
63
+ EXT_GIC_ID_UART3,
64
+ EXT_GIC_ID_UART4,
65
+ EXT_GIC_ID_MCT_G0,
66
+ EXT_GIC_ID_I2C0,
67
+ EXT_GIC_ID_I2C1,
68
+ EXT_GIC_ID_I2C2,
69
+ EXT_GIC_ID_I2C3,
70
+ EXT_GIC_ID_I2C4,
71
+ EXT_GIC_ID_I2C5,
72
+ EXT_GIC_ID_I2C6,
73
+ EXT_GIC_ID_I2C7,
74
+ EXT_GIC_ID_SPI0,
75
+ EXT_GIC_ID_SPI1,
76
+ EXT_GIC_ID_SPI2,
77
+ EXT_GIC_ID_MCT_G1,
78
+ EXT_GIC_ID_USB_HOST,
79
+ EXT_GIC_ID_USB_DEVICE,
80
+ EXT_GIC_ID_MODEMIF,
81
+ EXT_GIC_ID_HSMMC0,
82
+ EXT_GIC_ID_HSMMC1,
83
+ EXT_GIC_ID_HSMMC2,
84
+ EXT_GIC_ID_HSMMC3,
85
+ EXT_GIC_ID_SDMMC,
86
+ EXT_GIC_ID_MIPI_CSI_4LANE,
87
+ EXT_GIC_ID_MIPI_DSI_4LANE,
88
+ EXT_GIC_ID_MIPI_CSI_2LANE,
89
+ EXT_GIC_ID_MIPI_DSI_2LANE,
90
+ EXT_GIC_ID_ONENAND_AUDI,
91
+ EXT_GIC_ID_ROTATOR,
92
+ EXT_GIC_ID_FIMC0,
93
+ EXT_GIC_ID_FIMC1,
94
+ EXT_GIC_ID_FIMC2,
95
+ EXT_GIC_ID_FIMC3,
96
+ EXT_GIC_ID_JPEG,
97
+ EXT_GIC_ID_2D,
98
+ EXT_GIC_ID_PCIe,
99
+ EXT_GIC_ID_MIXER,
100
+ EXT_GIC_ID_HDMI,
101
+ EXT_GIC_ID_HDMI_I2C,
102
+ EXT_GIC_ID_MFC,
103
+ EXT_GIC_ID_TVENC,
104
+};
105
+
106
+enum ExtInt {
107
+ EXT_GIC_ID_EXTINT0 = 48,
108
+ EXT_GIC_ID_EXTINT1,
109
+ EXT_GIC_ID_EXTINT2,
110
+ EXT_GIC_ID_EXTINT3,
111
+ EXT_GIC_ID_EXTINT4,
112
+ EXT_GIC_ID_EXTINT5,
113
+ EXT_GIC_ID_EXTINT6,
114
+ EXT_GIC_ID_EXTINT7,
115
+ EXT_GIC_ID_EXTINT8,
116
+ EXT_GIC_ID_EXTINT9,
117
+ EXT_GIC_ID_EXTINT10,
118
+ EXT_GIC_ID_EXTINT11,
119
+ EXT_GIC_ID_EXTINT12,
120
+ EXT_GIC_ID_EXTINT13,
121
+ EXT_GIC_ID_EXTINT14,
122
+ EXT_GIC_ID_EXTINT15
123
+};
124
+
125
+/*
126
+ * External GIC sources which are not from External Interrupt Combiner or
127
+ * External Interrupts are starting from EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ,
128
+ * which is INTG16 in Internal Interrupt Combiner.
129
+ */
130
+
131
+static const uint32_t
132
+combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
133
+ /* int combiner groups 16-19 */
134
+ { }, { }, { }, { },
135
+ /* int combiner group 20 */
136
+ { 0, EXT_GIC_ID_MDMA_LCD0 },
137
+ /* int combiner group 21 */
138
+ { EXT_GIC_ID_PDMA0, EXT_GIC_ID_PDMA1 },
139
+ /* int combiner group 22 */
140
+ { EXT_GIC_ID_TIMER0, EXT_GIC_ID_TIMER1, EXT_GIC_ID_TIMER2,
141
+ EXT_GIC_ID_TIMER3, EXT_GIC_ID_TIMER4 },
142
+ /* int combiner group 23 */
143
+ { EXT_GIC_ID_RTC_ALARM, EXT_GIC_ID_RTC_TIC },
144
+ /* int combiner group 24 */
145
+ { EXT_GIC_ID_GPIO_XB, EXT_GIC_ID_GPIO_XA },
146
+ /* int combiner group 25 */
147
+ { EXT_GIC_ID_IEM_APC, EXT_GIC_ID_IEM_IEC },
148
+ /* int combiner group 26 */
149
+ { EXT_GIC_ID_UART0, EXT_GIC_ID_UART1, EXT_GIC_ID_UART2, EXT_GIC_ID_UART3,
150
+ EXT_GIC_ID_UART4 },
151
+ /* int combiner group 27 */
152
+ { EXT_GIC_ID_I2C0, EXT_GIC_ID_I2C1, EXT_GIC_ID_I2C2, EXT_GIC_ID_I2C3,
153
+ EXT_GIC_ID_I2C4, EXT_GIC_ID_I2C5, EXT_GIC_ID_I2C6,
154
+ EXT_GIC_ID_I2C7 },
155
+ /* int combiner group 28 */
156
+ { EXT_GIC_ID_SPI0, EXT_GIC_ID_SPI1, EXT_GIC_ID_SPI2 , EXT_GIC_ID_USB_HOST},
157
+ /* int combiner group 29 */
158
+ { EXT_GIC_ID_HSMMC0, EXT_GIC_ID_HSMMC1, EXT_GIC_ID_HSMMC2,
159
+ EXT_GIC_ID_HSMMC3, EXT_GIC_ID_SDMMC },
160
+ /* int combiner group 30 */
161
+ { EXT_GIC_ID_MIPI_CSI_4LANE, EXT_GIC_ID_MIPI_CSI_2LANE },
162
+ /* int combiner group 31 */
163
+ { EXT_GIC_ID_MIPI_DSI_4LANE, EXT_GIC_ID_MIPI_DSI_2LANE },
164
+ /* int combiner group 32 */
165
+ { EXT_GIC_ID_FIMC0, EXT_GIC_ID_FIMC1 },
166
+ /* int combiner group 33 */
167
+ { EXT_GIC_ID_FIMC2, EXT_GIC_ID_FIMC3 },
168
+ /* int combiner group 34 */
169
+ { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC },
170
+ /* int combiner group 35 */
171
+ { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
172
+ /* int combiner group 36 */
173
+ { EXT_GIC_ID_MIXER },
174
+ /* int combiner group 37 */
175
+ { EXT_GIC_ID_EXTINT4, EXT_GIC_ID_EXTINT5, EXT_GIC_ID_EXTINT6,
176
+ EXT_GIC_ID_EXTINT7 },
177
+ /* groups 38-50 */
178
+ { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { },
179
+ /* int combiner group 51 */
180
+ { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
181
+ /* group 52 */
182
+ { },
183
+ /* int combiner group 53 */
184
+ { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
185
+ /* groups 54-63 */
186
+ { }, { }, { }, { }, { }, { }, { }, { }, { }, { }
187
+};
188
+
189
+/*
190
+ * Initialize board IRQs.
191
+ * These IRQs contain splitted Int/External Combiner and External Gic IRQs.
192
+ */
193
+static void exynos4210_init_board_irqs(Exynos4210State *s)
194
+{
195
+ uint32_t grp, bit, irq_id, n;
196
+ Exynos4210Irq *is = &s->irqs;
197
+
198
+ for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) {
199
+ irq_id = 0;
200
+ if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) ||
201
+ n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) {
202
+ /* MCT_G0 is passed to External GIC */
203
+ irq_id = EXT_GIC_ID_MCT_G0;
204
+ }
205
+ if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) ||
206
+ n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) {
207
+ /* MCT_G1 is passed to External and GIC */
208
+ irq_id = EXT_GIC_ID_MCT_G1;
209
+ }
210
+ if (irq_id) {
211
+ s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
212
+ is->ext_gic_irq[irq_id - 32]);
213
+ } else {
214
+ s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
215
+ is->ext_combiner_irq[n]);
216
+ }
217
+ }
218
+ for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) {
219
+ /* these IDs are passed to Internal Combiner and External GIC */
220
+ grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n);
221
+ bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n);
222
+ irq_id = combiner_grp_to_gic_id[grp -
223
+ EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit];
224
+
225
+ if (irq_id) {
226
+ s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
227
+ is->ext_gic_irq[irq_id - 32]);
228
+ }
229
+ }
230
+}
231
+
232
+/*
233
+ * Get IRQ number from exynos4210 IRQ subsystem stub.
234
+ * To identify IRQ source use internal combiner group and bit number
235
+ * grp - group number
236
+ * bit - bit number inside group
237
+ */
238
+uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit)
239
+{
240
+ return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit);
241
+}
242
+
243
static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43,
244
0x09, 0x00, 0x00, 0x00 };
245
246
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
247
index XXXXXXX..XXXXXXX 100644
248
--- a/hw/intc/exynos4210_gic.c
249
+++ b/hw/intc/exynos4210_gic.c
250
@@ -XXX,XX +XXX,XX @@
251
#include "hw/arm/exynos4210.h"
252
#include "qom/object.h"
253
254
-enum ExtGicId {
255
- EXT_GIC_ID_MDMA_LCD0 = 66,
256
- EXT_GIC_ID_PDMA0,
257
- EXT_GIC_ID_PDMA1,
258
- EXT_GIC_ID_TIMER0,
259
- EXT_GIC_ID_TIMER1,
260
- EXT_GIC_ID_TIMER2,
261
- EXT_GIC_ID_TIMER3,
262
- EXT_GIC_ID_TIMER4,
263
- EXT_GIC_ID_MCT_L0,
264
- EXT_GIC_ID_WDT,
265
- EXT_GIC_ID_RTC_ALARM,
266
- EXT_GIC_ID_RTC_TIC,
267
- EXT_GIC_ID_GPIO_XB,
268
- EXT_GIC_ID_GPIO_XA,
269
- EXT_GIC_ID_MCT_L1,
270
- EXT_GIC_ID_IEM_APC,
271
- EXT_GIC_ID_IEM_IEC,
272
- EXT_GIC_ID_NFC,
273
- EXT_GIC_ID_UART0,
274
- EXT_GIC_ID_UART1,
275
- EXT_GIC_ID_UART2,
276
- EXT_GIC_ID_UART3,
277
- EXT_GIC_ID_UART4,
278
- EXT_GIC_ID_MCT_G0,
279
- EXT_GIC_ID_I2C0,
280
- EXT_GIC_ID_I2C1,
281
- EXT_GIC_ID_I2C2,
282
- EXT_GIC_ID_I2C3,
283
- EXT_GIC_ID_I2C4,
284
- EXT_GIC_ID_I2C5,
285
- EXT_GIC_ID_I2C6,
286
- EXT_GIC_ID_I2C7,
287
- EXT_GIC_ID_SPI0,
288
- EXT_GIC_ID_SPI1,
289
- EXT_GIC_ID_SPI2,
290
- EXT_GIC_ID_MCT_G1,
291
- EXT_GIC_ID_USB_HOST,
292
- EXT_GIC_ID_USB_DEVICE,
293
- EXT_GIC_ID_MODEMIF,
294
- EXT_GIC_ID_HSMMC0,
295
- EXT_GIC_ID_HSMMC1,
296
- EXT_GIC_ID_HSMMC2,
297
- EXT_GIC_ID_HSMMC3,
298
- EXT_GIC_ID_SDMMC,
299
- EXT_GIC_ID_MIPI_CSI_4LANE,
300
- EXT_GIC_ID_MIPI_DSI_4LANE,
301
- EXT_GIC_ID_MIPI_CSI_2LANE,
302
- EXT_GIC_ID_MIPI_DSI_2LANE,
303
- EXT_GIC_ID_ONENAND_AUDI,
304
- EXT_GIC_ID_ROTATOR,
305
- EXT_GIC_ID_FIMC0,
306
- EXT_GIC_ID_FIMC1,
307
- EXT_GIC_ID_FIMC2,
308
- EXT_GIC_ID_FIMC3,
309
- EXT_GIC_ID_JPEG,
310
- EXT_GIC_ID_2D,
311
- EXT_GIC_ID_PCIe,
312
- EXT_GIC_ID_MIXER,
313
- EXT_GIC_ID_HDMI,
314
- EXT_GIC_ID_HDMI_I2C,
315
- EXT_GIC_ID_MFC,
316
- EXT_GIC_ID_TVENC,
317
-};
318
-
319
-enum ExtInt {
320
- EXT_GIC_ID_EXTINT0 = 48,
321
- EXT_GIC_ID_EXTINT1,
322
- EXT_GIC_ID_EXTINT2,
323
- EXT_GIC_ID_EXTINT3,
324
- EXT_GIC_ID_EXTINT4,
325
- EXT_GIC_ID_EXTINT5,
326
- EXT_GIC_ID_EXTINT6,
327
- EXT_GIC_ID_EXTINT7,
328
- EXT_GIC_ID_EXTINT8,
329
- EXT_GIC_ID_EXTINT9,
330
- EXT_GIC_ID_EXTINT10,
331
- EXT_GIC_ID_EXTINT11,
332
- EXT_GIC_ID_EXTINT12,
333
- EXT_GIC_ID_EXTINT13,
334
- EXT_GIC_ID_EXTINT14,
335
- EXT_GIC_ID_EXTINT15
336
-};
337
-
338
-/*
339
- * External GIC sources which are not from External Interrupt Combiner or
340
- * External Interrupts are starting from EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ,
341
- * which is INTG16 in Internal Interrupt Combiner.
342
- */
343
-
344
-static const uint32_t
345
-combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
346
- /* int combiner groups 16-19 */
347
- { }, { }, { }, { },
348
- /* int combiner group 20 */
349
- { 0, EXT_GIC_ID_MDMA_LCD0 },
350
- /* int combiner group 21 */
351
- { EXT_GIC_ID_PDMA0, EXT_GIC_ID_PDMA1 },
352
- /* int combiner group 22 */
353
- { EXT_GIC_ID_TIMER0, EXT_GIC_ID_TIMER1, EXT_GIC_ID_TIMER2,
354
- EXT_GIC_ID_TIMER3, EXT_GIC_ID_TIMER4 },
355
- /* int combiner group 23 */
356
- { EXT_GIC_ID_RTC_ALARM, EXT_GIC_ID_RTC_TIC },
357
- /* int combiner group 24 */
358
- { EXT_GIC_ID_GPIO_XB, EXT_GIC_ID_GPIO_XA },
359
- /* int combiner group 25 */
360
- { EXT_GIC_ID_IEM_APC, EXT_GIC_ID_IEM_IEC },
361
- /* int combiner group 26 */
362
- { EXT_GIC_ID_UART0, EXT_GIC_ID_UART1, EXT_GIC_ID_UART2, EXT_GIC_ID_UART3,
363
- EXT_GIC_ID_UART4 },
364
- /* int combiner group 27 */
365
- { EXT_GIC_ID_I2C0, EXT_GIC_ID_I2C1, EXT_GIC_ID_I2C2, EXT_GIC_ID_I2C3,
366
- EXT_GIC_ID_I2C4, EXT_GIC_ID_I2C5, EXT_GIC_ID_I2C6,
367
- EXT_GIC_ID_I2C7 },
368
- /* int combiner group 28 */
369
- { EXT_GIC_ID_SPI0, EXT_GIC_ID_SPI1, EXT_GIC_ID_SPI2 , EXT_GIC_ID_USB_HOST},
370
- /* int combiner group 29 */
371
- { EXT_GIC_ID_HSMMC0, EXT_GIC_ID_HSMMC1, EXT_GIC_ID_HSMMC2,
372
- EXT_GIC_ID_HSMMC3, EXT_GIC_ID_SDMMC },
373
- /* int combiner group 30 */
374
- { EXT_GIC_ID_MIPI_CSI_4LANE, EXT_GIC_ID_MIPI_CSI_2LANE },
375
- /* int combiner group 31 */
376
- { EXT_GIC_ID_MIPI_DSI_4LANE, EXT_GIC_ID_MIPI_DSI_2LANE },
377
- /* int combiner group 32 */
378
- { EXT_GIC_ID_FIMC0, EXT_GIC_ID_FIMC1 },
379
- /* int combiner group 33 */
380
- { EXT_GIC_ID_FIMC2, EXT_GIC_ID_FIMC3 },
381
- /* int combiner group 34 */
382
- { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC },
383
- /* int combiner group 35 */
384
- { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
385
- /* int combiner group 36 */
386
- { EXT_GIC_ID_MIXER },
387
- /* int combiner group 37 */
388
- { EXT_GIC_ID_EXTINT4, EXT_GIC_ID_EXTINT5, EXT_GIC_ID_EXTINT6,
389
- EXT_GIC_ID_EXTINT7 },
390
- /* groups 38-50 */
391
- { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { },
392
- /* int combiner group 51 */
393
- { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
394
- /* group 52 */
395
- { },
396
- /* int combiner group 53 */
397
- { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
398
- /* groups 54-63 */
399
- { }, { }, { }, { }, { }, { }, { }, { }, { }, { }
400
-};
401
-
402
#define EXYNOS4210_GIC_NIRQ 160
403
404
#define EXYNOS4210_EXT_GIC_CPU_REGION_SIZE 0x10000
405
@@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
406
#define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100
407
#define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000
408
409
-/*
410
- * Initialize board IRQs.
411
- * These IRQs contain splitted Int/External Combiner and External Gic IRQs.
412
- */
413
-void exynos4210_init_board_irqs(Exynos4210State *s)
414
-{
415
- uint32_t grp, bit, irq_id, n;
416
- Exynos4210Irq *is = &s->irqs;
417
-
418
- for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) {
419
- irq_id = 0;
420
- if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) ||
421
- n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) {
422
- /* MCT_G0 is passed to External GIC */
423
- irq_id = EXT_GIC_ID_MCT_G0;
424
- }
425
- if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) ||
426
- n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) {
427
- /* MCT_G1 is passed to External and GIC */
428
- irq_id = EXT_GIC_ID_MCT_G1;
429
- }
430
- if (irq_id) {
431
- s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
432
- is->ext_gic_irq[irq_id - 32]);
433
- } else {
434
- s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
435
- is->ext_combiner_irq[n]);
436
- }
437
- }
438
- for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) {
439
- /* these IDs are passed to Internal Combiner and External GIC */
440
- grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n);
441
- bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n);
442
- irq_id = combiner_grp_to_gic_id[grp -
443
- EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit];
444
-
445
- if (irq_id) {
446
- s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n],
447
- is->ext_gic_irq[irq_id - 32]);
448
- }
449
- }
450
-}
451
-
452
-/*
453
- * Get IRQ number from exynos4210 IRQ subsystem stub.
454
- * To identify IRQ source use internal combiner group and bit number
455
- * grp - group number
456
- * bit - bit number inside group
457
- */
458
-uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit)
459
-{
460
- return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit);
461
-}
462
-
463
-/********* GIC part *********/
464
-
465
#define TYPE_EXYNOS4210_GIC "exynos4210.gic"
466
OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC)
467
29
468
--
30
--
469
2.25.1
31
2.25.1
32
33
diff view generated by jsdifflib
1
The combiner_grp_to_gic_id[] array includes the EXT_GIC_ID_MCT_G0
1
The meson_args variable was added in commit 3b4da13293482134b, but
2
and EXT_GIC_ID_MCT_G1 multiple times. This means that we will
2
was not used in that commit and isn't used today. Delete the
3
connect multiple IRQs up to the same external GIC input, which
3
unnecessary assignment.
4
is not permitted. We do the same thing in the code in
5
exynos4210_init_board_irqs() because the conditionals selecting
6
an irq_id in the first loop match multiple interrupt IDs.
7
8
Overall we do this for interrupt IDs
9
(1, 4), (12, 4), (35, 4), (51, 4), (53, 4) for EXT_GIC_ID_MCT_G0
10
and
11
(1, 5), (12, 5), (35, 5), (51, 5), (53, 5) for EXT_GIC_ID_MCT_G1
12
13
These correspond to the cases for the multi-core timer that we are
14
wiring up to multiple inputs on the combiner in
15
exynos4210_combiner_get_gpioin(). That code already deals with all
16
these interrupt IDs being the same input source, so we don't need to
17
connect the external GIC interrupt for any of them except the first
18
(1, 4) and (1, 5). Remove the array entries and conditionals which
19
were incorrectly causing us to wire up extra lines.
20
21
This bug didn't cause any visible effects, because we only connect
22
up a device to the "primary" ID values (1, 4) and (1, 5), so the
23
extra lines would never be set to a level.
24
4
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
27
Message-id: 20220404154658.565020-16-peter.maydell@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220825150703.4074125-3-peter.maydell@linaro.org
28
---
9
---
29
include/hw/arm/exynos4210.h | 2 +-
10
configure | 1 -
30
hw/arm/exynos4210.c | 12 +++++-------
11
1 file changed, 1 deletion(-)
31
2 files changed, 6 insertions(+), 8 deletions(-)
32
12
33
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
13
diff --git a/configure b/configure
34
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100755
35
--- a/include/hw/arm/exynos4210.h
15
--- a/configure
36
+++ b/include/hw/arm/exynos4210.h
16
+++ b/configure
37
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ pie=""
38
* one for every non-zero entry in combiner_grp_to_gic_id[].
18
coroutine=""
39
* We'll assert in exynos4210_init_board_irqs() if this is wrong.
19
plugins="$default_feature"
40
*/
20
meson=""
41
-#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60)
21
-meson_args=""
42
+#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54)
22
ninja=""
43
23
bindir="bin"
44
typedef struct Exynos4210Irq {
24
skip_meson=no
45
qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
46
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/exynos4210.c
49
+++ b/hw/arm/exynos4210.c
50
@@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
51
/* int combiner group 34 */
52
{ EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC },
53
/* int combiner group 35 */
54
- { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
55
+ { 0, 0, 0, EXT_GIC_ID_MCT_L1 },
56
/* int combiner group 36 */
57
{ EXT_GIC_ID_MIXER },
58
/* int combiner group 37 */
59
@@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
60
/* groups 38-50 */
61
{ }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { },
62
/* int combiner group 51 */
63
- { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
64
+ { EXT_GIC_ID_MCT_L0 },
65
/* group 52 */
66
{ },
67
/* int combiner group 53 */
68
- { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 },
69
+ { EXT_GIC_ID_WDT },
70
/* groups 54-63 */
71
{ }, { }, { }, { }, { }, { }, { }, { }, { }, { }
72
};
73
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
74
75
for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) {
76
irq_id = 0;
77
- if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) ||
78
- n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) {
79
+ if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4)) {
80
/* MCT_G0 is passed to External GIC */
81
irq_id = EXT_GIC_ID_MCT_G0;
82
}
83
- if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) ||
84
- n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) {
85
+ if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5)) {
86
/* MCT_G1 is passed to External and GIC */
87
irq_id = EXT_GIC_ID_MCT_G1;
88
}
89
--
25
--
90
2.25.1
26
2.25.1
27
28
diff view generated by jsdifflib
1
The function exynos4210_combiner_get_gpioin() currently lives in
1
This commit adds quotes in some places which:
2
exynos4210_combiner.c, but it isn't really part of the combiner
2
* are spotted by shellcheck
3
device itself -- it is a function that implements the wiring up of
3
* are obviously incorrect
4
some interrupt sources to multiple combiner inputs. Move it to live
4
* are easy to fix just by adding the quotes
5
with the other SoC-level code in exynos4210.c, along with a few
5
6
macros previously defined in exynos4210.h which are now used only
6
It doesn't attempt fix all of the places shellcheck finds errors,
7
in exynos4210.c.
7
or even all the ones which are easy to fix. It's just a random
8
sampling which is hopefully easy to review and which cuts
9
down the size of the problem for next time somebody wants to
10
try to look at shellcheck errors.
8
11
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11
Message-id: 20220404154658.565020-11-peter.maydell@linaro.org
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20220825150703.4074125-4-peter.maydell@linaro.org
12
---
16
---
13
include/hw/arm/exynos4210.h | 11 -----
17
configure | 64 +++++++++++++++++++++++++++----------------------------
14
hw/arm/exynos4210.c | 82 +++++++++++++++++++++++++++++++++++
18
1 file changed, 32 insertions(+), 32 deletions(-)
15
hw/intc/exynos4210_combiner.c | 77 --------------------------------
19
16
3 files changed, 82 insertions(+), 88 deletions(-)
20
diff --git a/configure b/configure
17
21
index XXXXXXX..XXXXXXX 100755
18
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
22
--- a/configure
19
index XXXXXXX..XXXXXXX 100644
23
+++ b/configure
20
--- a/include/hw/arm/exynos4210.h
24
@@ -XXX,XX +XXX,XX @@ GNUmakefile: ;
21
+++ b/include/hw/arm/exynos4210.h
25
22
@@ -XXX,XX +XXX,XX @@
26
EOF
23
#define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \
27
cd build
24
(EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8)
28
- exec $source_path/configure "$@"
25
29
+ exec "$source_path/configure" "$@"
26
-#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp)*8 + (bit))
30
fi
27
-#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8)
31
28
-#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \
32
# Temporary directory used for files created while
29
- ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq))
33
@@ -XXX,XX +XXX,XX @@ meson_option_build_array() {
30
-
34
printf ']\n'
31
/* IRQs number for external and internal GIC */
32
#define EXYNOS4210_EXT_GIC_NIRQ (160-32)
33
#define EXYNOS4210_INT_GIC_NIRQ 64
34
@@ -XXX,XX +XXX,XX @@ void exynos4210_write_secondary(ARMCPU *cpu,
35
* bit - bit number inside group */
36
uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit);
37
38
-/*
39
- * Get Combiner input GPIO into irqs structure
40
- */
41
-void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev,
42
- int ext);
43
-
44
/*
45
* exynos4210 UART
46
*/
47
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/arm/exynos4210.c
50
+++ b/hw/arm/exynos4210.c
51
@@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
52
{ }, { }, { }, { }, { }, { }, { }, { }, { }, { }
53
};
54
55
+#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp) * 8 + (bit))
56
+#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8)
57
+#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \
58
+ ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq))
59
+
60
/*
61
* Initialize board IRQs.
62
* These IRQs contain splitted Int/External Combiner and External Gic IRQs.
63
@@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit)
64
return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit);
65
}
35
}
66
36
67
+/*
37
-. $source_path/scripts/meson-buildoptions.sh
68
+ * Get Combiner input GPIO into irqs structure
38
+. "$source_path/scripts/meson-buildoptions.sh"
69
+ */
39
70
+static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs,
40
meson_options=
71
+ DeviceState *dev, int ext)
41
meson_option_add() {
72
+{
42
@@ -XXX,XX +XXX,XX @@ for opt do
73
+ int n;
43
case "$opt" in
74
+ int bit;
44
--help|-h) show_help=yes
75
+ int max;
45
;;
76
+ qemu_irq *irq;
46
- --version|-V) exec cat $source_path/VERSION
77
+
47
+ --version|-V) exec cat "$source_path/VERSION"
78
+ max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ :
48
;;
79
+ EXYNOS4210_MAX_INT_COMBINER_IN_IRQ;
49
--prefix=*) prefix="$optarg"
80
+ irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq;
50
;;
81
+
51
@@ -XXX,XX +XXX,XX @@ default_target_list=""
82
+ /*
52
mak_wilds=""
83
+ * Some IRQs of Int/External Combiner are going to two Combiners groups,
53
84
+ * so let split them.
54
if [ "$linux_user" != no ]; then
85
+ */
55
- if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then
86
+ for (n = 0; n < max; n++) {
56
+ if [ "$targetos" = linux ] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then
87
+
57
linux_user=yes
88
+ bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n);
58
elif [ "$linux_user" = yes ]; then
89
+
59
error_exit "linux-user not supported on this architecture"
90
+ switch (n) {
60
@@ -XXX,XX +XXX,XX @@ if [ "$bsd_user" != no ]; then
91
+ /* MDNIE_LCD1 INTG1 */
61
if [ "$bsd_user" = "" ]; then
92
+ case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ...
62
test $targetos = freebsd && bsd_user=yes
93
+ EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3):
63
fi
94
+ irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
64
- if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
95
+ irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]);
65
+ if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
96
+ continue;
66
error_exit "bsd-user not supported on this host OS"
97
+
67
fi
98
+ /* TMU INTG3 */
68
fi
99
+ case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4):
69
@@ -XXX,XX +XXX,XX @@ python="$python -B"
100
+ irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
70
if test -z "$meson"; then
101
+ irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]);
71
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
102
+ continue;
72
meson=meson
103
+
73
- elif test $git_submodules_action != 'ignore' ; then
104
+ /* LCD1 INTG12 */
74
+ elif test "$git_submodules_action" != 'ignore' ; then
105
+ case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ...
75
meson=git
106
+ EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3):
76
elif test -e "${source_path}/meson/meson.py" ; then
107
+ irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
77
meson=internal
108
+ irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]);
78
@@ -XXX,XX +XXX,XX @@ esac
109
+ continue;
79
container="no"
110
+
80
if test $use_containers = "yes"; then
111
+ /* Multi-Core Timer INTG12 */
81
if has "docker" || has "podman"; then
112
+ case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ...
82
- container=$($python $source_path/tests/docker/docker.py probe)
113
+ EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8):
83
+ container=$($python "$source_path"/tests/docker/docker.py probe)
114
+ irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
84
fi
115
+ irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
85
fi
116
+ continue;
86
117
+
87
@@ -XXX,XX +XXX,XX @@ if test "$QEMU_GA_DISTRO" = ""; then
118
+ /* Multi-Core Timer INTG35 */
88
QEMU_GA_DISTRO=Linux
119
+ case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ...
89
fi
120
+ EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8):
90
if test "$QEMU_GA_VERSION" = ""; then
121
+ irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
91
- QEMU_GA_VERSION=$(cat $source_path/VERSION)
122
+ irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
92
+ QEMU_GA_VERSION=$(cat "$source_path"/VERSION)
123
+ continue;
93
fi
124
+
94
125
+ /* Multi-Core Timer INTG51 */
95
126
+ case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ...
96
@@ -XXX,XX +XXX,XX @@ fi
127
+ EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8):
97
for target in $target_list; do
128
+ irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
98
target_dir="$target"
129
+ irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
99
target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
130
+ continue;
100
- mkdir -p $target_dir
131
+
101
+ mkdir -p "$target_dir"
132
+ /* Multi-Core Timer INTG53 */
102
case $target in
133
+ case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ...
103
*-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
134
+ EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8):
104
*) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
135
+ irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
105
@@ -XXX,XX +XXX,XX @@ for target in $target_list; do
136
+ irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
106
config_target_mak=tests/tcg/config-$target.mak
137
+ continue;
107
138
+ }
108
echo "# Automatically generated by configure - do not modify" > $config_target_mak
139
+
109
- echo "TARGET_NAME=$arch" >> $config_target_mak
140
+ irq[n] = qdev_get_gpio_in(dev, n);
110
+ echo "TARGET_NAME=$arch" >> "$config_target_mak"
141
+ }
111
case $target in
142
+}
112
xtensa*-linux-user)
143
+
113
# the toolchain is not complete with headers, only build softmmu tests
144
static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43,
114
continue
145
0x09, 0x00, 0x00, 0x00 };
115
;;
146
116
*-softmmu)
147
diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c
117
- test -f $source_path/tests/tcg/$arch/Makefile.softmmu-target || continue
148
index XXXXXXX..XXXXXXX 100644
118
+ test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue
149
--- a/hw/intc/exynos4210_combiner.c
119
qemu="qemu-system-$arch"
150
+++ b/hw/intc/exynos4210_combiner.c
120
;;
151
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_exynos4210_combiner = {
121
*-linux-user|*-bsd-user)
152
}
122
@@ -XXX,XX +XXX,XX @@ for target in $target_list; do
153
};
123
# compilers is a requirememt for adding a new test that needs a
154
124
# compiler feature.
155
-/*
125
156
- * Get Combiner input GPIO into irqs structure
126
- echo "BUILD_STATIC=$build_static" >> $config_target_mak
157
- */
127
- write_target_makefile >> $config_target_mak
158
-void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev,
128
+ echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
159
- int ext)
129
+ write_target_makefile >> "$config_target_mak"
160
-{
130
case $target in
161
- int n;
131
aarch64-*)
162
- int bit;
132
if do_compiler "$target_cc" $target_cflags \
163
- int max;
133
-march=armv8.1-a+sve -o $TMPE $TMPC; then
164
- qemu_irq *irq;
134
- echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak
165
-
135
+ echo "CROSS_CC_HAS_SVE=y" >> "$config_target_mak"
166
- max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ :
136
fi
167
- EXYNOS4210_MAX_INT_COMBINER_IN_IRQ;
137
if do_compiler "$target_cc" $target_cflags \
168
- irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq;
138
-march=armv8.1-a+sve2 -o $TMPE $TMPC; then
169
-
139
- echo "CROSS_CC_HAS_SVE2=y" >> $config_target_mak
170
- /*
140
+ echo "CROSS_CC_HAS_SVE2=y" >> "$config_target_mak"
171
- * Some IRQs of Int/External Combiner are going to two Combiners groups,
141
fi
172
- * so let split them.
142
if do_compiler "$target_cc" $target_cflags \
173
- */
143
-march=armv8.3-a -o $TMPE $TMPC; then
174
- for (n = 0; n < max; n++) {
144
- echo "CROSS_CC_HAS_ARMV8_3=y" >> $config_target_mak
175
-
145
+ echo "CROSS_CC_HAS_ARMV8_3=y" >> "$config_target_mak"
176
- bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n);
146
fi
177
-
147
if do_compiler "$target_cc" $target_cflags \
178
- switch (n) {
148
-mbranch-protection=standard -o $TMPE $TMPC; then
179
- /* MDNIE_LCD1 INTG1 */
149
- echo "CROSS_CC_HAS_ARMV8_BTI=y" >> $config_target_mak
180
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ...
150
+ echo "CROSS_CC_HAS_ARMV8_BTI=y" >> "$config_target_mak"
181
- EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3):
151
fi
182
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
152
if do_compiler "$target_cc" $target_cflags \
183
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]);
153
-march=armv8.5-a+memtag -o $TMPE $TMPC; then
184
- continue;
154
- echo "CROSS_CC_HAS_ARMV8_MTE=y" >> $config_target_mak
185
-
155
+ echo "CROSS_CC_HAS_ARMV8_MTE=y" >> "$config_target_mak"
186
- /* TMU INTG3 */
156
fi
187
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4):
157
;;
188
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
158
ppc*)
189
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]);
159
if do_compiler "$target_cc" $target_cflags \
190
- continue;
160
-mpower8-vector -o $TMPE $TMPC; then
191
-
161
- echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak
192
- /* LCD1 INTG12 */
162
+ echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> "$config_target_mak"
193
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ...
163
fi
194
- EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3):
164
if do_compiler "$target_cc" $target_cflags \
195
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
165
-mpower10 -o $TMPE $TMPC; then
196
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]);
166
- echo "CROSS_CC_HAS_POWER10=y" >> $config_target_mak
197
- continue;
167
+ echo "CROSS_CC_HAS_POWER10=y" >> "$config_target_mak"
198
-
168
fi
199
- /* Multi-Core Timer INTG12 */
169
;;
200
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ...
170
i386-linux-user)
201
- EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8):
171
if do_compiler "$target_cc" $target_cflags \
202
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
172
-Werror -fno-pie -o $TMPE $TMPC; then
203
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
173
- echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak
204
- continue;
174
+ echo "CROSS_CC_HAS_I386_NOPIE=y" >> "$config_target_mak"
205
-
175
fi
206
- /* Multi-Core Timer INTG35 */
176
;;
207
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ...
177
esac
208
- EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8):
178
elif test -n "$container_image"; then
209
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
179
echo "build-tcg-tests-$target: docker-image-$container_image" >> $makefile
210
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
180
- echo "BUILD_STATIC=y" >> $config_target_mak
211
- continue;
181
- write_container_target_makefile >> $config_target_mak
212
-
182
+ echo "BUILD_STATIC=y" >> "$config_target_mak"
213
- /* Multi-Core Timer INTG51 */
183
+ write_container_target_makefile >> "$config_target_mak"
214
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ...
184
case $target in
215
- EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8):
185
aarch64-*)
216
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
186
- echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak
217
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
187
- echo "CROSS_CC_HAS_SVE2=y" >> $config_target_mak
218
- continue;
188
- echo "CROSS_CC_HAS_ARMV8_3=y" >> $config_target_mak
219
-
189
- echo "CROSS_CC_HAS_ARMV8_BTI=y" >> $config_target_mak
220
- /* Multi-Core Timer INTG53 */
190
- echo "CROSS_CC_HAS_ARMV8_MTE=y" >> $config_target_mak
221
- case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ...
191
+ echo "CROSS_CC_HAS_SVE=y" >> "$config_target_mak"
222
- EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8):
192
+ echo "CROSS_CC_HAS_SVE2=y" >> "$config_target_mak"
223
- irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
193
+ echo "CROSS_CC_HAS_ARMV8_3=y" >> "$config_target_mak"
224
- irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]);
194
+ echo "CROSS_CC_HAS_ARMV8_BTI=y" >> "$config_target_mak"
225
- continue;
195
+ echo "CROSS_CC_HAS_ARMV8_MTE=y" >> "$config_target_mak"
226
- }
196
;;
227
-
197
ppc*)
228
- irq[n] = qdev_get_gpio_in(dev, n);
198
- echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak
229
- }
199
- echo "CROSS_CC_HAS_POWER10=y" >> $config_target_mak
230
-}
200
+ echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> "$config_target_mak"
231
-
201
+ echo "CROSS_CC_HAS_POWER10=y" >> "$config_target_mak"
232
static uint64_t
202
;;
233
exynos4210_combiner_read(void *opaque, hwaddr offset, unsigned size)
203
i386-linux-user)
234
{
204
- echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak
205
+ echo "CROSS_CC_HAS_I386_NOPIE=y" >> "$config_target_mak"
206
;;
207
esac
208
got_cross_cc=yes
209
fi
210
if test $got_cross_cc = yes; then
211
mkdir -p tests/tcg/$target
212
- echo "QEMU=$PWD/$qemu" >> $config_target_mak
213
+ echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
214
echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> $makefile
215
tcg_tests_targets="$tcg_tests_targets $target"
216
fi
235
--
217
--
236
2.25.1
218
2.25.1
219
220
diff view generated by jsdifflib
1
Delete a couple of #defines which are never used.
1
Shellcheck warns that in
2
rm -f */config-devices.mak.d
3
the glob might expand to something with a '-' in it, which would
4
then be misinterpreted as an option to rm. Fix this by adding './'.
2
5
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5
Message-id: 20220404154658.565020-12-peter.maydell@linaro.org
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20220825150703.4074125-5-peter.maydell@linaro.org
6
---
10
---
7
include/hw/arm/exynos4210.h | 4 ----
11
configure | 2 +-
8
1 file changed, 4 deletions(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
9
13
10
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
14
diff --git a/configure b/configure
11
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100755
12
--- a/include/hw/arm/exynos4210.h
16
--- a/configure
13
+++ b/include/hw/arm/exynos4210.h
17
+++ b/configure
14
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ exit 0
15
#define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \
19
fi
16
(EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8)
20
17
21
# Remove old dependency files to make sure that they get properly regenerated
18
-/* IRQs number for external and internal GIC */
22
-rm -f */config-devices.mak.d
19
-#define EXYNOS4210_EXT_GIC_NIRQ (160-32)
23
+rm -f ./*/config-devices.mak.d
20
-#define EXYNOS4210_INT_GIC_NIRQ 64
24
21
-
25
if test -z "$python"
22
#define EXYNOS4210_I2C_NUMBER 9
26
then
23
24
#define EXYNOS4210_NUM_DMA 3
25
--
27
--
26
2.25.1
28
2.25.1
29
30
diff view generated by jsdifflib
1
Fix a missing set of spaces around '-' in the definition of
1
There's only one place in configure where we use `...` to execute a
2
combiner_grp_to_gic_id[]. We're about to move this code, so
2
command and capture the result. Switch to $() to match the rest of
3
fix the style issue first to keep checkpatch happy with the
3
the script. This silences a shellcheck warning.
4
code-motion patch.
5
4
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Message-id: 20220404154658.565020-7-peter.maydell@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220825150703.4074125-6-peter.maydell@linaro.org
9
---
9
---
10
hw/intc/exynos4210_gic.c | 2 +-
10
configure | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
12
13
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
13
diff --git a/configure b/configure
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100755
15
--- a/hw/intc/exynos4210_gic.c
15
--- a/configure
16
+++ b/hw/intc/exynos4210_gic.c
16
+++ b/configure
17
@@ -XXX,XX +XXX,XX @@ enum ExtInt {
17
@@ -XXX,XX +XXX,XX @@ LINKS="$LINKS python"
18
*/
18
LINKS="$LINKS contrib/plugins/Makefile "
19
19
for f in $LINKS ; do
20
static const uint32_t
20
if [ -e "$source_path/$f" ]; then
21
-combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
21
- mkdir -p `dirname ./$f`
22
+combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
22
+ mkdir -p "$(dirname ./"$f")"
23
/* int combiner groups 16-19 */
23
symlink "$source_path/$f" "$f"
24
{ }, { }, { }, { },
24
fi
25
/* int combiner group 20 */
25
done
26
--
26
--
27
2.25.1
27
2.25.1
28
29
diff view generated by jsdifflib
1
The only time we use the int_gic_irq[] array in the Exynos4210Irq
1
Shellcheck warns that we have one place where we run a command and
2
struct is in the exynos4210_realize() function: we initialize it with
2
then check if it failed using $?; this is better written to simply
3
the GPIO inputs of the a9mpcore device, and then a bit later on we
3
check the command in the 'if' statement directly.
4
connect those to the outputs of the internal combiner. Now that the
5
a9mpcore object is easily accessible as s->a9mpcore we can make the
6
connection directly from one device to the other without going via
7
this array.
8
4
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11
Message-id: 20220404154658.565020-5-peter.maydell@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220825150703.4074125-7-peter.maydell@linaro.org
12
---
9
---
13
include/hw/arm/exynos4210.h | 1 -
10
configure | 3 +--
14
hw/arm/exynos4210.c | 6 ++----
11
1 file changed, 1 insertion(+), 2 deletions(-)
15
2 files changed, 2 insertions(+), 5 deletions(-)
16
12
17
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
13
diff --git a/configure b/configure
18
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100755
19
--- a/include/hw/arm/exynos4210.h
15
--- a/configure
20
+++ b/include/hw/arm/exynos4210.h
16
+++ b/configure
21
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ fi
22
typedef struct Exynos4210Irq {
18
# it when configure exits.)
23
qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
19
TMPDIR1="config-temp"
24
qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ];
20
rm -rf "${TMPDIR1}"
25
- qemu_irq int_gic_irq[EXYNOS4210_INT_GIC_NIRQ];
21
-mkdir -p "${TMPDIR1}"
26
qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ];
22
-if [ $? -ne 0 ]; then
27
qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ];
23
+if ! mkdir -p "${TMPDIR1}"; then
28
} Exynos4210Irq;
24
echo "ERROR: failed to create temporary directory"
29
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
25
exit 1
30
index XXXXXXX..XXXXXXX 100644
26
fi
31
--- a/hw/arm/exynos4210.c
32
+++ b/hw/arm/exynos4210.c
33
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
34
sysbus_connect_irq(busdev, n,
35
qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0));
36
}
37
- for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) {
38
- s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n);
39
- }
40
41
/* Cache controller */
42
sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL);
43
@@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
44
busdev = SYS_BUS_DEVICE(dev);
45
sysbus_realize_and_unref(busdev, &error_fatal);
46
for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) {
47
- sysbus_connect_irq(busdev, n, s->irqs.int_gic_irq[n]);
48
+ sysbus_connect_irq(busdev, n,
49
+ qdev_get_gpio_in(DEVICE(&s->a9mpcore), n));
50
}
51
exynos4210_combiner_get_gpioin(&s->irqs, dev, 0);
52
sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR);
53
--
27
--
54
2.25.1
28
2.25.1
29
30
diff view generated by jsdifflib
1
Currently for the interrupts MCT_G0 and MCT_G1 which are
1
We use the non-POSIX 'local' keyword in just two places in configure;
2
the only ones in the input range of the external combiner
2
rewrite to avoid it.
3
and which are also wired to the external GIC, we connect
4
them only to the internal combiner and the external GIC.
5
This seems likely to be a bug, as all other interrupts
6
which are in the input range of both combiners are
7
connected to both combiners. (The fact that the code in
8
exynos4210_combiner_get_gpioin() is also trying to wire
9
up these inputs on both combiners also suggests this.)
10
3
11
Wire these interrupts up to both combiners, like the rest.
4
In do_compiler(), just drop the 'local' keyword. The variable
5
'compiler' is only used elsewhere in the do_compiler_werror()
6
function, which already uses the variable as a normal non-local one.
7
8
In probe_target_compiler(), $try and $t are both local; make them
9
normal variables and use a more obviously distinct variable name
10
for $t.
12
11
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
15
Message-id: 20220404154658.565020-15-peter.maydell@linaro.org
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20220825150703.4074125-8-peter.maydell@linaro.org
16
---
16
---
17
hw/arm/exynos4210.c | 7 +++----
17
configure | 7 +++----
18
1 file changed, 3 insertions(+), 4 deletions(-)
18
1 file changed, 3 insertions(+), 4 deletions(-)
19
19
20
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
20
diff --git a/configure b/configure
21
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100755
22
--- a/hw/arm/exynos4210.c
22
--- a/configure
23
+++ b/hw/arm/exynos4210.c
23
+++ b/configure
24
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s)
24
@@ -XXX,XX +XXX,XX @@ error_exit() {
25
25
do_compiler() {
26
assert(splitcount < EXYNOS4210_NUM_SPLITTERS);
26
# Run the compiler, capturing its output to the log. First argument
27
splitter = DEVICE(&s->splitter[splitcount]);
27
# is compiler binary to execute.
28
- qdev_prop_set_uint16(splitter, "num-lines", 2);
28
- local compiler="$1"
29
+ qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2);
29
+ compiler="$1"
30
qdev_realize(splitter, NULL, &error_abort);
30
shift
31
splitcount++;
31
if test -n "$BASH_VERSION"; then eval '
32
s->irq_table[n] = qdev_get_gpio_in(splitter, 0);
32
echo >>config.log "
33
qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]);
33
@@ -XXX,XX +XXX,XX @@ probe_target_compiler() {
34
+ qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]);
34
: ${container_cross_strip:=${container_cross_prefix}strip}
35
if (irq_id) {
35
done
36
- qdev_connect_gpio_out(splitter, 1,
36
37
+ qdev_connect_gpio_out(splitter, 2,
37
- local t try
38
qdev_get_gpio_in(extgicdev, irq_id - 32));
38
try=cross
39
- } else {
39
case "$target_arch:$cpu" in
40
- qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]);
40
aarch64_be:aarch64 | \
41
}
41
@@ -XXX,XX +XXX,XX @@ probe_target_compiler() {
42
}
42
try='native cross' ;;
43
for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) {
43
esac
44
eval "target_cflags=\${cross_cc_cflags_$target_arch}"
45
- for t in $try; do
46
- case $t in
47
+ for thistry in $try; do
48
+ case $thistry in
49
native)
50
target_cc=$cc
51
target_ccas=$ccas
44
--
52
--
45
2.25.1
53
2.25.1
54
55
diff view generated by jsdifflib