1 | First arm pullreq of the 5.1 cycle; mostly bugfixes and some | 1 | target-arm queue: the big stuff here is the final part of |
---|---|---|---|
2 | cleanup patches. The new clock modelling framework is the big | 2 | rth's patches for Cortex-A76 and Neoverse-N1 support; |
3 | thing here. | 3 | also present are Gavin's NUMA series and a few other things. |
4 | 4 | ||
5 | thanks | ||
5 | -- PMM | 6 | -- PMM |
6 | 7 | ||
7 | The following changes since commit 648db19685b7030aa558a4ddbd3a8e53d8c9a062: | 8 | The following changes since commit 554623226f800acf48a2ed568900c1c968ec9a8b: |
8 | 9 | ||
9 | Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2020-04-29' into staging (2020-04-29 15:07:33 +0100) | 10 | Merge tag 'qemu-sparc-20220508' of https://github.com/mcayland/qemu into staging (2022-05-08 17:03:26 -0500) |
10 | 11 | ||
11 | are available in the Git repository at: | 12 | are available in the Git repository at: |
12 | 13 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200430 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220509 |
14 | 15 | ||
15 | for you to fetch changes up to 1267437e593e85498f9105b3bdab796630d2e83f: | 16 | for you to fetch changes up to ae9141d4a3265553503bf07d3574b40f84615a34: |
16 | 17 | ||
17 | hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes (2020-04-30 11:52:29 +0100) | 18 | hw/acpi/aml-build: Use existing CPU topology to build PPTT table (2022-05-09 11:47:55 +0100) |
18 | 19 | ||
19 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
20 | target-arm queue: | 21 | target-arm queue: |
21 | * xlnx-zdma: Fix endianness handling of descriptor loading | 22 | * MAINTAINERS/.mailmap: update email for Leif Lindholm |
22 | * nrf51: Fix last GPIO CNF address | 23 | * hw/arm: add version information to sbsa-ref machine DT |
23 | * gicv3: Use gicr_typer in arm_gicv3_icc_reset | 24 | * Enable new features for -cpu max: |
24 | * msf2: Add EMAC block to SmartFusion2 SoC | 25 | FEAT_Debugv8p2, FEAT_Debugv8p4, FEAT_RAS (minimal version only), |
25 | * New clock modelling framework | 26 | FEAT_IESB, FEAT_CSV2, FEAT_CSV2_2, FEAT_CSV3, FEAT_DGH |
26 | * hw/arm: versal: Setup the ADMA with 128bit bus-width | 27 | * Emulate Cortex-A76 |
27 | * Cadence: gem: fix wraparound in 64bit descriptors | 28 | * Emulate Neoverse-N1 |
28 | * cadence_gem: clear RX control descriptor | 29 | * Fix the virt board default NUMA topology |
29 | * target/arm: Vectorize integer comparison vs zero | ||
30 | * hw/arm/virt: dt: add kaslr-seed property | ||
31 | * hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes | ||
32 | 30 | ||
33 | ---------------------------------------------------------------- | 31 | ---------------------------------------------------------------- |
34 | Cameron Esfahani (1): | 32 | Gavin Shan (6): |
35 | nrf51: Fix last GPIO CNF address | 33 | qapi/machine.json: Add cluster-id |
34 | qtest/numa-test: Specify CPU topology in aarch64_numa_cpu() | ||
35 | hw/arm/virt: Consider SMP configuration in CPU topology | ||
36 | qtest/numa-test: Correct CPU and NUMA association in aarch64_numa_cpu() | ||
37 | hw/arm/virt: Fix CPU's default NUMA node ID | ||
38 | hw/acpi/aml-build: Use existing CPU topology to build PPTT table | ||
36 | 39 | ||
37 | Damien Hedde (7): | 40 | Leif Lindholm (2): |
38 | hw/core/clock-vmstate: define a vmstate entry for clock state | 41 | MAINTAINERS/.mailmap: update email for Leif Lindholm |
39 | qdev: add clock input&output support to devices. | 42 | hw/arm: add versioning to sbsa-ref machine DT |
40 | qdev-clock: introduce an init array to ease the device construction | ||
41 | hw/misc/zynq_slcr: add clock generation for uarts | ||
42 | hw/char/cadence_uart: add clock support | ||
43 | hw/arm/xilinx_zynq: connect uart clocks to slcr | ||
44 | qdev-monitor: print the device's clock with info qtree | ||
45 | 43 | ||
46 | Edgar E. Iglesias (7): | 44 | Richard Henderson (24): |
47 | dma/xlnx-zdma: Fix descriptor loading (MEM) wrt endianness | 45 | target/arm: Handle cpreg registration for missing EL |
48 | dma/xlnx-zdma: Fix descriptor loading (REG) wrt endianness | 46 | target/arm: Drop EL3 no EL2 fallbacks |
49 | hw/arm: versal: Setup the ADMA with 128bit bus-width | 47 | target/arm: Merge zcr reginfo |
50 | device_tree: Allow name wildcards in qemu_fdt_node_path() | 48 | target/arm: Adjust definition of CONTEXTIDR_EL2 |
51 | device_tree: Constify compat in qemu_fdt_node_path() | 49 | target/arm: Move cortex impdef sysregs to cpu_tcg.c |
52 | hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102 | 50 | target/arm: Update qemu-system-arm -cpu max to cortex-a57 |
53 | hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes | 51 | target/arm: Set ID_DFR0.PerfMon for qemu-system-arm -cpu max |
52 | target/arm: Split out aa32_max_features | ||
53 | target/arm: Annotate arm_max_initfn with FEAT identifiers | ||
54 | target/arm: Use field names for manipulating EL2 and EL3 modes | ||
55 | target/arm: Enable FEAT_Debugv8p2 for -cpu max | ||
56 | target/arm: Enable FEAT_Debugv8p4 for -cpu max | ||
57 | target/arm: Add minimal RAS registers | ||
58 | target/arm: Enable SCR and HCR bits for RAS | ||
59 | target/arm: Implement virtual SError exceptions | ||
60 | target/arm: Implement ESB instruction | ||
61 | target/arm: Enable FEAT_RAS for -cpu max | ||
62 | target/arm: Enable FEAT_IESB for -cpu max | ||
63 | target/arm: Enable FEAT_CSV2 for -cpu max | ||
64 | target/arm: Enable FEAT_CSV2_2 for -cpu max | ||
65 | target/arm: Enable FEAT_CSV3 for -cpu max | ||
66 | target/arm: Enable FEAT_DGH for -cpu max | ||
67 | target/arm: Define cortex-a76 | ||
68 | target/arm: Define neoverse-n1 | ||
54 | 69 | ||
55 | Jerome Forissier (2): | 70 | docs/system/arm/emulation.rst | 10 + |
56 | hw/arm/virt: dt: move creation of /secure-chosen to create_fdt() | 71 | docs/system/arm/virt.rst | 2 + |
57 | hw/arm/virt: dt: add kaslr-seed property | 72 | qapi/machine.json | 6 +- |
58 | 73 | target/arm/cpregs.h | 11 + | |
59 | Keqian Zhu (2): | 74 | target/arm/cpu.h | 23 ++ |
60 | bugfix: Use gicr_typer in arm_gicv3_icc_reset | 75 | target/arm/helper.h | 1 + |
61 | Typo: Correct the name of CPU hotplug memory region | 76 | target/arm/internals.h | 16 ++ |
62 | 77 | target/arm/syndrome.h | 5 + | |
63 | Peter Maydell (2): | 78 | target/arm/a32.decode | 16 +- |
64 | hw/core/clock: introduce clock object | 79 | target/arm/t32.decode | 18 +- |
65 | docs/clocks: add device's clock documentation | 80 | hw/acpi/aml-build.c | 111 ++++---- |
66 | 81 | hw/arm/sbsa-ref.c | 16 ++ | |
67 | Philippe Mathieu-Daudé (3): | 82 | hw/arm/virt.c | 21 +- |
68 | target/arm: Restrict the Address Translate write operation to TCG accel | 83 | hw/core/machine-hmp-cmds.c | 4 + |
69 | target/arm/cpu: Use ARRAY_SIZE() to iterate over ARMCPUInfo[] | 84 | hw/core/machine.c | 16 ++ |
70 | target/arm/cpu: Update coding style to make checkpatch.pl happy | 85 | target/arm/cpu.c | 66 ++++- |
71 | 86 | target/arm/cpu64.c | 353 ++++++++++++++----------- | |
72 | Ramon Fried (2): | 87 | target/arm/cpu_tcg.c | 227 +++++++++++----- |
73 | Cadence: gem: fix wraparound in 64bit descriptors | 88 | target/arm/helper.c | 600 +++++++++++++++++++++++++----------------- |
74 | net: cadence_gem: clear RX control descriptor | 89 | target/arm/op_helper.c | 43 +++ |
75 | 90 | target/arm/translate-a64.c | 18 ++ | |
76 | Richard Henderson (1): | 91 | target/arm/translate.c | 23 ++ |
77 | target/arm: Vectorize integer comparison vs zero | 92 | tests/qtest/numa-test.c | 19 +- |
78 | 93 | .mailmap | 3 +- | |
79 | Subbaraya Sundeep (3): | 94 | MAINTAINERS | 2 +- |
80 | hw/net: Add Smartfusion2 emac block | 95 | 25 files changed, 1068 insertions(+), 562 deletions(-) |
81 | msf2: Add EMAC block to SmartFusion2 SoC | ||
82 | tests/boot_linux_console: Add ethernet test to SmartFusion2 | ||
83 | |||
84 | Thomas Huth (1): | ||
85 | target/arm: Make cpu_register() available for other files | ||
86 | |||
87 | hw/core/Makefile.objs | 2 + | ||
88 | hw/net/Makefile.objs | 1 + | ||
89 | tests/Makefile.include | 1 + | ||
90 | include/hw/arm/msf2-soc.h | 2 + | ||
91 | include/hw/char/cadence_uart.h | 1 + | ||
92 | include/hw/clock.h | 225 +++++++++++++ | ||
93 | include/hw/gpio/nrf51_gpio.h | 2 +- | ||
94 | include/hw/net/msf2-emac.h | 53 +++ | ||
95 | include/hw/qdev-clock.h | 159 +++++++++ | ||
96 | include/hw/qdev-core.h | 12 + | ||
97 | include/sysemu/device_tree.h | 5 +- | ||
98 | target/arm/cpu-qom.h | 9 +- | ||
99 | target/arm/helper.h | 27 +- | ||
100 | target/arm/translate.h | 5 + | ||
101 | device_tree.c | 4 +- | ||
102 | hw/acpi/cpu.c | 2 +- | ||
103 | hw/arm/msf2-soc.c | 26 +- | ||
104 | hw/arm/virt.c | 20 +- | ||
105 | hw/arm/xilinx_zynq.c | 57 +++- | ||
106 | hw/arm/xlnx-versal.c | 2 + | ||
107 | hw/arm/xlnx-zcu102.c | 39 ++- | ||
108 | hw/char/cadence_uart.c | 73 +++- | ||
109 | hw/core/clock-vmstate.c | 25 ++ | ||
110 | hw/core/clock.c | 130 ++++++++ | ||
111 | hw/core/qdev-clock.c | 185 +++++++++++ | ||
112 | hw/core/qdev.c | 12 + | ||
113 | hw/dma/xlnx-zdma.c | 25 +- | ||
114 | hw/intc/arm_gicv3_kvm.c | 4 +- | ||
115 | hw/misc/zynq_slcr.c | 172 +++++++++- | ||
116 | hw/net/cadence_gem.c | 16 +- | ||
117 | hw/net/msf2-emac.c | 589 +++++++++++++++++++++++++++++++++ | ||
118 | qdev-monitor.c | 9 + | ||
119 | target/arm/cpu.c | 25 +- | ||
120 | target/arm/cpu64.c | 16 +- | ||
121 | target/arm/helper.c | 17 + | ||
122 | target/arm/neon_helper.c | 24 -- | ||
123 | target/arm/translate-a64.c | 64 +--- | ||
124 | target/arm/translate.c | 256 ++++++++++++-- | ||
125 | target/arm/vec_helper.c | 25 ++ | ||
126 | MAINTAINERS | 2 + | ||
127 | docs/devel/clocks.rst | 391 ++++++++++++++++++++++ | ||
128 | docs/devel/index.rst | 1 + | ||
129 | hw/char/trace-events | 3 + | ||
130 | hw/core/trace-events | 7 + | ||
131 | tests/acceptance/boot_linux_console.py | 15 +- | ||
132 | 45 files changed, 2538 insertions(+), 202 deletions(-) | ||
133 | create mode 100644 include/hw/clock.h | ||
134 | create mode 100644 include/hw/net/msf2-emac.h | ||
135 | create mode 100644 include/hw/qdev-clock.h | ||
136 | create mode 100644 hw/core/clock-vmstate.c | ||
137 | create mode 100644 hw/core/clock.c | ||
138 | create mode 100644 hw/core/qdev-clock.c | ||
139 | create mode 100644 hw/net/msf2-emac.c | ||
140 | create mode 100644 docs/devel/clocks.rst | ||
141 | diff view generated by jsdifflib |
1 | From: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | Modelled Ethernet MAC of Smartfusion2 SoC. | 3 | NUVIA was acquired by Qualcomm in March 2021, but kept functioning on |
4 | Micrel KSZ8051 PHY is present on Emcraft's | 4 | separate infrastructure for a transitional period. We've now switched |
5 | SOM kit hence same PHY is emulated. | 5 | over to contributing as Qualcomm Innovation Center (quicinc), so update |
6 | my email address to reflect this. | ||
6 | 7 | ||
7 | Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 8 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> |
9 | Message-id: 20220505113740.75565-1-quic_llindhol@quicinc.com | ||
10 | Cc: Leif Lindholm <leif@nuviainc.com> | ||
11 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | [Fixed commit message typo] |
10 | Message-id: 1587048891-30493-2-git-send-email-sundeep.lkml@gmail.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 15 | --- |
13 | hw/net/Makefile.objs | 1 + | 16 | .mailmap | 3 ++- |
14 | include/hw/net/msf2-emac.h | 53 ++++ | 17 | MAINTAINERS | 2 +- |
15 | hw/net/msf2-emac.c | 589 +++++++++++++++++++++++++++++++++++++ | 18 | 2 files changed, 3 insertions(+), 2 deletions(-) |
16 | MAINTAINERS | 2 + | ||
17 | 4 files changed, 645 insertions(+) | ||
18 | create mode 100644 include/hw/net/msf2-emac.h | ||
19 | create mode 100644 hw/net/msf2-emac.c | ||
20 | 19 | ||
21 | diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs | 20 | diff --git a/.mailmap b/.mailmap |
22 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/net/Makefile.objs | 22 | --- a/.mailmap |
24 | +++ b/hw/net/Makefile.objs | 23 | +++ b/.mailmap |
25 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_ROCKER) += rocker/rocker.o rocker/rocker_fp.o \ | 24 | @@ -XXX,XX +XXX,XX @@ Greg Kurz <groug@kaod.org> <gkurz@linux.vnet.ibm.com> |
26 | obj-$(call lnot,$(CONFIG_ROCKER)) += rocker/qmp-norocker.o | 25 | Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com> |
27 | 26 | Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn> | |
28 | common-obj-$(CONFIG_CAN_BUS) += can/ | 27 | James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com> |
29 | +common-obj-$(CONFIG_MSF2) += msf2-emac.o | 28 | -Leif Lindholm <leif@nuviainc.com> <leif.lindholm@linaro.org> |
30 | diff --git a/include/hw/net/msf2-emac.h b/include/hw/net/msf2-emac.h | 29 | +Leif Lindholm <quic_llindhol@quicinc.com> <leif.lindholm@linaro.org> |
31 | new file mode 100644 | 30 | +Leif Lindholm <quic_llindhol@quicinc.com> <leif@nuviainc.com> |
32 | index XXXXXXX..XXXXXXX | 31 | Radoslaw Biernacki <rad@semihalf.com> <radoslaw.biernacki@linaro.org> |
33 | --- /dev/null | 32 | Paul Burton <paulburton@kernel.org> <paul.burton@mips.com> |
34 | +++ b/include/hw/net/msf2-emac.h | 33 | Paul Burton <paulburton@kernel.org> <paul.burton@imgtec.com> |
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | +/* | ||
37 | + * QEMU model of the Smartfusion2 Ethernet MAC. | ||
38 | + * | ||
39 | + * Copyright (c) 2020 Subbaraya Sundeep <sundeep.lkml@gmail.com>. | ||
40 | + * | ||
41 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
42 | + * of this software and associated documentation files (the "Software"), to deal | ||
43 | + * in the Software without restriction, including without limitation the rights | ||
44 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
45 | + * copies of the Software, and to permit persons to whom the Software is | ||
46 | + * furnished to do so, subject to the following conditions: | ||
47 | + * | ||
48 | + * The above copyright notice and this permission notice shall be included in | ||
49 | + * all copies or substantial portions of the Software. | ||
50 | + * | ||
51 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
52 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
53 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
54 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
55 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
56 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
57 | + * THE SOFTWARE. | ||
58 | + */ | ||
59 | + | ||
60 | +#include "hw/sysbus.h" | ||
61 | +#include "exec/memory.h" | ||
62 | +#include "net/net.h" | ||
63 | +#include "net/eth.h" | ||
64 | + | ||
65 | +#define TYPE_MSS_EMAC "msf2-emac" | ||
66 | +#define MSS_EMAC(obj) \ | ||
67 | + OBJECT_CHECK(MSF2EmacState, (obj), TYPE_MSS_EMAC) | ||
68 | + | ||
69 | +#define R_MAX (0x1a0 / 4) | ||
70 | +#define PHY_MAX_REGS 32 | ||
71 | + | ||
72 | +typedef struct MSF2EmacState { | ||
73 | + SysBusDevice parent; | ||
74 | + | ||
75 | + MemoryRegion mmio; | ||
76 | + MemoryRegion *dma_mr; | ||
77 | + AddressSpace dma_as; | ||
78 | + | ||
79 | + qemu_irq irq; | ||
80 | + NICState *nic; | ||
81 | + NICConf conf; | ||
82 | + | ||
83 | + uint8_t mac_addr[ETH_ALEN]; | ||
84 | + uint32_t rx_desc; | ||
85 | + uint16_t phy_regs[PHY_MAX_REGS]; | ||
86 | + | ||
87 | + uint32_t regs[R_MAX]; | ||
88 | +} MSF2EmacState; | ||
89 | diff --git a/hw/net/msf2-emac.c b/hw/net/msf2-emac.c | ||
90 | new file mode 100644 | ||
91 | index XXXXXXX..XXXXXXX | ||
92 | --- /dev/null | ||
93 | +++ b/hw/net/msf2-emac.c | ||
94 | @@ -XXX,XX +XXX,XX @@ | ||
95 | +/* | ||
96 | + * QEMU model of the Smartfusion2 Ethernet MAC. | ||
97 | + * | ||
98 | + * Copyright (c) 2020 Subbaraya Sundeep <sundeep.lkml@gmail.com>. | ||
99 | + * | ||
100 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
101 | + * of this software and associated documentation files (the "Software"), to deal | ||
102 | + * in the Software without restriction, including without limitation the rights | ||
103 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
104 | + * copies of the Software, and to permit persons to whom the Software is | ||
105 | + * furnished to do so, subject to the following conditions: | ||
106 | + * | ||
107 | + * The above copyright notice and this permission notice shall be included in | ||
108 | + * all copies or substantial portions of the Software. | ||
109 | + * | ||
110 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
111 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
112 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
113 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
114 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
115 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
116 | + * THE SOFTWARE. | ||
117 | + * | ||
118 | + * Refer to section Ethernet MAC in the document: | ||
119 | + * UG0331: SmartFusion2 Microcontroller Subsystem User Guide | ||
120 | + * Datasheet URL: | ||
121 | + * https://www.microsemi.com/document-portal/cat_view/56661-internal-documents/ | ||
122 | + * 56758-soc?lang=en&limit=20&limitstart=220 | ||
123 | + */ | ||
124 | + | ||
125 | +#include "qemu/osdep.h" | ||
126 | +#include "qemu-common.h" | ||
127 | +#include "qemu/log.h" | ||
128 | +#include "qapi/error.h" | ||
129 | +#include "exec/address-spaces.h" | ||
130 | +#include "hw/registerfields.h" | ||
131 | +#include "hw/net/msf2-emac.h" | ||
132 | +#include "hw/net/mii.h" | ||
133 | +#include "hw/irq.h" | ||
134 | +#include "hw/qdev-properties.h" | ||
135 | +#include "migration/vmstate.h" | ||
136 | + | ||
137 | +REG32(CFG1, 0x0) | ||
138 | + FIELD(CFG1, RESET, 31, 1) | ||
139 | + FIELD(CFG1, RX_EN, 2, 1) | ||
140 | + FIELD(CFG1, TX_EN, 0, 1) | ||
141 | + FIELD(CFG1, LB_EN, 8, 1) | ||
142 | +REG32(CFG2, 0x4) | ||
143 | +REG32(IFG, 0x8) | ||
144 | +REG32(HALF_DUPLEX, 0xc) | ||
145 | +REG32(MAX_FRAME_LENGTH, 0x10) | ||
146 | +REG32(MII_CMD, 0x24) | ||
147 | + FIELD(MII_CMD, READ, 0, 1) | ||
148 | +REG32(MII_ADDR, 0x28) | ||
149 | + FIELD(MII_ADDR, REGADDR, 0, 5) | ||
150 | + FIELD(MII_ADDR, PHYADDR, 8, 5) | ||
151 | +REG32(MII_CTL, 0x2c) | ||
152 | +REG32(MII_STS, 0x30) | ||
153 | +REG32(STA1, 0x40) | ||
154 | +REG32(STA2, 0x44) | ||
155 | +REG32(FIFO_CFG0, 0x48) | ||
156 | +REG32(FIFO_CFG4, 0x58) | ||
157 | + FIELD(FIFO_CFG4, BCAST, 9, 1) | ||
158 | + FIELD(FIFO_CFG4, MCAST, 8, 1) | ||
159 | +REG32(FIFO_CFG5, 0x5C) | ||
160 | + FIELD(FIFO_CFG5, BCAST, 9, 1) | ||
161 | + FIELD(FIFO_CFG5, MCAST, 8, 1) | ||
162 | +REG32(DMA_TX_CTL, 0x180) | ||
163 | + FIELD(DMA_TX_CTL, EN, 0, 1) | ||
164 | +REG32(DMA_TX_DESC, 0x184) | ||
165 | +REG32(DMA_TX_STATUS, 0x188) | ||
166 | + FIELD(DMA_TX_STATUS, PKTCNT, 16, 8) | ||
167 | + FIELD(DMA_TX_STATUS, UNDERRUN, 1, 1) | ||
168 | + FIELD(DMA_TX_STATUS, PKT_SENT, 0, 1) | ||
169 | +REG32(DMA_RX_CTL, 0x18c) | ||
170 | + FIELD(DMA_RX_CTL, EN, 0, 1) | ||
171 | +REG32(DMA_RX_DESC, 0x190) | ||
172 | +REG32(DMA_RX_STATUS, 0x194) | ||
173 | + FIELD(DMA_RX_STATUS, PKTCNT, 16, 8) | ||
174 | + FIELD(DMA_RX_STATUS, OVERFLOW, 2, 1) | ||
175 | + FIELD(DMA_RX_STATUS, PKT_RCVD, 0, 1) | ||
176 | +REG32(DMA_IRQ_MASK, 0x198) | ||
177 | +REG32(DMA_IRQ, 0x19c) | ||
178 | + | ||
179 | +#define EMPTY_MASK (1 << 31) | ||
180 | +#define PKT_SIZE 0x7FF | ||
181 | +#define PHYADDR 0x1 | ||
182 | +#define MAX_PKT_SIZE 2048 | ||
183 | + | ||
184 | +typedef struct { | ||
185 | + uint32_t pktaddr; | ||
186 | + uint32_t pktsize; | ||
187 | + uint32_t next; | ||
188 | +} EmacDesc; | ||
189 | + | ||
190 | +static uint32_t emac_get_isr(MSF2EmacState *s) | ||
191 | +{ | ||
192 | + uint32_t ier = s->regs[R_DMA_IRQ_MASK]; | ||
193 | + uint32_t tx = s->regs[R_DMA_TX_STATUS] & 0xF; | ||
194 | + uint32_t rx = s->regs[R_DMA_RX_STATUS] & 0xF; | ||
195 | + uint32_t isr = (rx << 4) | tx; | ||
196 | + | ||
197 | + s->regs[R_DMA_IRQ] = ier & isr; | ||
198 | + return s->regs[R_DMA_IRQ]; | ||
199 | +} | ||
200 | + | ||
201 | +static void emac_update_irq(MSF2EmacState *s) | ||
202 | +{ | ||
203 | + bool intr = emac_get_isr(s); | ||
204 | + | ||
205 | + qemu_set_irq(s->irq, intr); | ||
206 | +} | ||
207 | + | ||
208 | +static void emac_load_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc) | ||
209 | +{ | ||
210 | + address_space_read(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, d, sizeof *d); | ||
211 | + /* Convert from LE into host endianness. */ | ||
212 | + d->pktaddr = le32_to_cpu(d->pktaddr); | ||
213 | + d->pktsize = le32_to_cpu(d->pktsize); | ||
214 | + d->next = le32_to_cpu(d->next); | ||
215 | +} | ||
216 | + | ||
217 | +static void emac_store_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc) | ||
218 | +{ | ||
219 | + /* Convert from host endianness into LE. */ | ||
220 | + d->pktaddr = cpu_to_le32(d->pktaddr); | ||
221 | + d->pktsize = cpu_to_le32(d->pktsize); | ||
222 | + d->next = cpu_to_le32(d->next); | ||
223 | + | ||
224 | + address_space_write(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, d, sizeof *d); | ||
225 | +} | ||
226 | + | ||
227 | +static void msf2_dma_tx(MSF2EmacState *s) | ||
228 | +{ | ||
229 | + NetClientState *nc = qemu_get_queue(s->nic); | ||
230 | + hwaddr desc = s->regs[R_DMA_TX_DESC]; | ||
231 | + uint8_t buf[MAX_PKT_SIZE]; | ||
232 | + EmacDesc d; | ||
233 | + int size; | ||
234 | + uint8_t pktcnt; | ||
235 | + uint32_t status; | ||
236 | + | ||
237 | + if (!(s->regs[R_CFG1] & R_CFG1_TX_EN_MASK)) { | ||
238 | + return; | ||
239 | + } | ||
240 | + | ||
241 | + while (1) { | ||
242 | + emac_load_desc(s, &d, desc); | ||
243 | + if (d.pktsize & EMPTY_MASK) { | ||
244 | + break; | ||
245 | + } | ||
246 | + size = d.pktsize & PKT_SIZE; | ||
247 | + address_space_read(&s->dma_as, d.pktaddr, MEMTXATTRS_UNSPECIFIED, | ||
248 | + buf, size); | ||
249 | + /* | ||
250 | + * This is very basic way to send packets. Ideally there should be | ||
251 | + * a FIFO and packets should be sent out from FIFO only when | ||
252 | + * R_CFG1 bit 0 is set. | ||
253 | + */ | ||
254 | + if (s->regs[R_CFG1] & R_CFG1_LB_EN_MASK) { | ||
255 | + nc->info->receive(nc, buf, size); | ||
256 | + } else { | ||
257 | + qemu_send_packet(nc, buf, size); | ||
258 | + } | ||
259 | + d.pktsize |= EMPTY_MASK; | ||
260 | + emac_store_desc(s, &d, desc); | ||
261 | + /* update sent packets count */ | ||
262 | + status = s->regs[R_DMA_TX_STATUS]; | ||
263 | + pktcnt = FIELD_EX32(status, DMA_TX_STATUS, PKTCNT); | ||
264 | + pktcnt++; | ||
265 | + s->regs[R_DMA_TX_STATUS] = FIELD_DP32(status, DMA_TX_STATUS, | ||
266 | + PKTCNT, pktcnt); | ||
267 | + s->regs[R_DMA_TX_STATUS] |= R_DMA_TX_STATUS_PKT_SENT_MASK; | ||
268 | + desc = d.next; | ||
269 | + } | ||
270 | + s->regs[R_DMA_TX_STATUS] |= R_DMA_TX_STATUS_UNDERRUN_MASK; | ||
271 | + s->regs[R_DMA_TX_CTL] &= ~R_DMA_TX_CTL_EN_MASK; | ||
272 | +} | ||
273 | + | ||
274 | +static void msf2_phy_update_link(MSF2EmacState *s) | ||
275 | +{ | ||
276 | + /* Autonegotiation status mirrors link status. */ | ||
277 | + if (qemu_get_queue(s->nic)->link_down) { | ||
278 | + s->phy_regs[MII_BMSR] &= ~(MII_BMSR_AN_COMP | | ||
279 | + MII_BMSR_LINK_ST); | ||
280 | + } else { | ||
281 | + s->phy_regs[MII_BMSR] |= (MII_BMSR_AN_COMP | | ||
282 | + MII_BMSR_LINK_ST); | ||
283 | + } | ||
284 | +} | ||
285 | + | ||
286 | +static void msf2_phy_reset(MSF2EmacState *s) | ||
287 | +{ | ||
288 | + memset(&s->phy_regs[0], 0, sizeof(s->phy_regs)); | ||
289 | + s->phy_regs[MII_BMCR] = 0x1140; | ||
290 | + s->phy_regs[MII_BMSR] = 0x7968; | ||
291 | + s->phy_regs[MII_PHYID1] = 0x0022; | ||
292 | + s->phy_regs[MII_PHYID2] = 0x1550; | ||
293 | + s->phy_regs[MII_ANAR] = 0x01E1; | ||
294 | + s->phy_regs[MII_ANLPAR] = 0xCDE1; | ||
295 | + | ||
296 | + msf2_phy_update_link(s); | ||
297 | +} | ||
298 | + | ||
299 | +static void write_to_phy(MSF2EmacState *s) | ||
300 | +{ | ||
301 | + uint8_t reg_addr = s->regs[R_MII_ADDR] & R_MII_ADDR_REGADDR_MASK; | ||
302 | + uint8_t phy_addr = (s->regs[R_MII_ADDR] >> R_MII_ADDR_PHYADDR_SHIFT) & | ||
303 | + R_MII_ADDR_REGADDR_MASK; | ||
304 | + uint16_t data = s->regs[R_MII_CTL] & 0xFFFF; | ||
305 | + | ||
306 | + if (phy_addr != PHYADDR) { | ||
307 | + return; | ||
308 | + } | ||
309 | + | ||
310 | + switch (reg_addr) { | ||
311 | + case MII_BMCR: | ||
312 | + if (data & MII_BMCR_RESET) { | ||
313 | + /* Phy reset */ | ||
314 | + msf2_phy_reset(s); | ||
315 | + data &= ~MII_BMCR_RESET; | ||
316 | + } | ||
317 | + if (data & MII_BMCR_AUTOEN) { | ||
318 | + /* Complete autonegotiation immediately */ | ||
319 | + data &= ~MII_BMCR_AUTOEN; | ||
320 | + s->phy_regs[MII_BMSR] |= MII_BMSR_AN_COMP; | ||
321 | + } | ||
322 | + break; | ||
323 | + } | ||
324 | + | ||
325 | + s->phy_regs[reg_addr] = data; | ||
326 | +} | ||
327 | + | ||
328 | +static uint16_t read_from_phy(MSF2EmacState *s) | ||
329 | +{ | ||
330 | + uint8_t reg_addr = s->regs[R_MII_ADDR] & R_MII_ADDR_REGADDR_MASK; | ||
331 | + uint8_t phy_addr = (s->regs[R_MII_ADDR] >> R_MII_ADDR_PHYADDR_SHIFT) & | ||
332 | + R_MII_ADDR_REGADDR_MASK; | ||
333 | + | ||
334 | + if (phy_addr == PHYADDR) { | ||
335 | + return s->phy_regs[reg_addr]; | ||
336 | + } else { | ||
337 | + return 0xFFFF; | ||
338 | + } | ||
339 | +} | ||
340 | + | ||
341 | +static void msf2_emac_do_reset(MSF2EmacState *s) | ||
342 | +{ | ||
343 | + memset(&s->regs[0], 0, sizeof(s->regs)); | ||
344 | + s->regs[R_CFG1] = 0x80000000; | ||
345 | + s->regs[R_CFG2] = 0x00007000; | ||
346 | + s->regs[R_IFG] = 0x40605060; | ||
347 | + s->regs[R_HALF_DUPLEX] = 0x00A1F037; | ||
348 | + s->regs[R_MAX_FRAME_LENGTH] = 0x00000600; | ||
349 | + s->regs[R_FIFO_CFG5] = 0X3FFFF; | ||
350 | + | ||
351 | + msf2_phy_reset(s); | ||
352 | +} | ||
353 | + | ||
354 | +static uint64_t emac_read(void *opaque, hwaddr addr, unsigned int size) | ||
355 | +{ | ||
356 | + MSF2EmacState *s = opaque; | ||
357 | + uint32_t r = 0; | ||
358 | + | ||
359 | + addr >>= 2; | ||
360 | + | ||
361 | + switch (addr) { | ||
362 | + case R_DMA_IRQ: | ||
363 | + r = emac_get_isr(s); | ||
364 | + break; | ||
365 | + default: | ||
366 | + if (addr >= ARRAY_SIZE(s->regs)) { | ||
367 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
368 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, | ||
369 | + addr * 4); | ||
370 | + return r; | ||
371 | + } | ||
372 | + r = s->regs[addr]; | ||
373 | + break; | ||
374 | + } | ||
375 | + return r; | ||
376 | +} | ||
377 | + | ||
378 | +static void emac_write(void *opaque, hwaddr addr, uint64_t val64, | ||
379 | + unsigned int size) | ||
380 | +{ | ||
381 | + MSF2EmacState *s = opaque; | ||
382 | + uint32_t value = val64; | ||
383 | + uint32_t enreqbits; | ||
384 | + uint8_t pktcnt; | ||
385 | + | ||
386 | + addr >>= 2; | ||
387 | + switch (addr) { | ||
388 | + case R_DMA_TX_CTL: | ||
389 | + s->regs[addr] = value; | ||
390 | + if (value & R_DMA_TX_CTL_EN_MASK) { | ||
391 | + msf2_dma_tx(s); | ||
392 | + } | ||
393 | + break; | ||
394 | + case R_DMA_RX_CTL: | ||
395 | + s->regs[addr] = value; | ||
396 | + if (value & R_DMA_RX_CTL_EN_MASK) { | ||
397 | + s->rx_desc = s->regs[R_DMA_RX_DESC]; | ||
398 | + qemu_flush_queued_packets(qemu_get_queue(s->nic)); | ||
399 | + } | ||
400 | + break; | ||
401 | + case R_CFG1: | ||
402 | + s->regs[addr] = value; | ||
403 | + if (value & R_CFG1_RESET_MASK) { | ||
404 | + msf2_emac_do_reset(s); | ||
405 | + } | ||
406 | + break; | ||
407 | + case R_FIFO_CFG0: | ||
408 | + /* | ||
409 | + * For our implementation, turning on modules is instantaneous, | ||
410 | + * so the states requested via the *ENREQ bits appear in the | ||
411 | + * *ENRPLY bits immediately. Also the reset bits to reset PE-MCXMAC | ||
412 | + * module are not emulated here since it deals with start of frames, | ||
413 | + * inter-packet gap and control frames. | ||
414 | + */ | ||
415 | + enreqbits = extract32(value, 8, 5); | ||
416 | + s->regs[addr] = deposit32(value, 16, 5, enreqbits); | ||
417 | + break; | ||
418 | + case R_DMA_TX_DESC: | ||
419 | + if (value & 0x3) { | ||
420 | + qemu_log_mask(LOG_GUEST_ERROR, "Tx Descriptor address should be" | ||
421 | + " 32 bit aligned\n"); | ||
422 | + } | ||
423 | + /* Ignore [1:0] bits */ | ||
424 | + s->regs[addr] = value & ~3; | ||
425 | + break; | ||
426 | + case R_DMA_RX_DESC: | ||
427 | + if (value & 0x3) { | ||
428 | + qemu_log_mask(LOG_GUEST_ERROR, "Rx Descriptor address should be" | ||
429 | + " 32 bit aligned\n"); | ||
430 | + } | ||
431 | + /* Ignore [1:0] bits */ | ||
432 | + s->regs[addr] = value & ~3; | ||
433 | + break; | ||
434 | + case R_DMA_TX_STATUS: | ||
435 | + if (value & R_DMA_TX_STATUS_UNDERRUN_MASK) { | ||
436 | + s->regs[addr] &= ~R_DMA_TX_STATUS_UNDERRUN_MASK; | ||
437 | + } | ||
438 | + if (value & R_DMA_TX_STATUS_PKT_SENT_MASK) { | ||
439 | + pktcnt = FIELD_EX32(s->regs[addr], DMA_TX_STATUS, PKTCNT); | ||
440 | + pktcnt--; | ||
441 | + s->regs[addr] = FIELD_DP32(s->regs[addr], DMA_TX_STATUS, | ||
442 | + PKTCNT, pktcnt); | ||
443 | + if (pktcnt == 0) { | ||
444 | + s->regs[addr] &= ~R_DMA_TX_STATUS_PKT_SENT_MASK; | ||
445 | + } | ||
446 | + } | ||
447 | + break; | ||
448 | + case R_DMA_RX_STATUS: | ||
449 | + if (value & R_DMA_RX_STATUS_OVERFLOW_MASK) { | ||
450 | + s->regs[addr] &= ~R_DMA_RX_STATUS_OVERFLOW_MASK; | ||
451 | + } | ||
452 | + if (value & R_DMA_RX_STATUS_PKT_RCVD_MASK) { | ||
453 | + pktcnt = FIELD_EX32(s->regs[addr], DMA_RX_STATUS, PKTCNT); | ||
454 | + pktcnt--; | ||
455 | + s->regs[addr] = FIELD_DP32(s->regs[addr], DMA_RX_STATUS, | ||
456 | + PKTCNT, pktcnt); | ||
457 | + if (pktcnt == 0) { | ||
458 | + s->regs[addr] &= ~R_DMA_RX_STATUS_PKT_RCVD_MASK; | ||
459 | + } | ||
460 | + } | ||
461 | + break; | ||
462 | + case R_DMA_IRQ: | ||
463 | + break; | ||
464 | + case R_MII_CMD: | ||
465 | + if (value & R_MII_CMD_READ_MASK) { | ||
466 | + s->regs[R_MII_STS] = read_from_phy(s); | ||
467 | + } | ||
468 | + break; | ||
469 | + case R_MII_CTL: | ||
470 | + s->regs[addr] = value; | ||
471 | + write_to_phy(s); | ||
472 | + break; | ||
473 | + case R_STA1: | ||
474 | + s->regs[addr] = value; | ||
475 | + /* | ||
476 | + * R_STA1 [31:24] : octet 1 of mac address | ||
477 | + * R_STA1 [23:16] : octet 2 of mac address | ||
478 | + * R_STA1 [15:8] : octet 3 of mac address | ||
479 | + * R_STA1 [7:0] : octet 4 of mac address | ||
480 | + */ | ||
481 | + stl_be_p(s->mac_addr, value); | ||
482 | + break; | ||
483 | + case R_STA2: | ||
484 | + s->regs[addr] = value; | ||
485 | + /* | ||
486 | + * R_STA2 [31:24] : octet 5 of mac address | ||
487 | + * R_STA2 [23:16] : octet 6 of mac address | ||
488 | + */ | ||
489 | + stw_be_p(s->mac_addr + 4, value >> 16); | ||
490 | + break; | ||
491 | + default: | ||
492 | + if (addr >= ARRAY_SIZE(s->regs)) { | ||
493 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
494 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, | ||
495 | + addr * 4); | ||
496 | + return; | ||
497 | + } | ||
498 | + s->regs[addr] = value; | ||
499 | + break; | ||
500 | + } | ||
501 | + emac_update_irq(s); | ||
502 | +} | ||
503 | + | ||
504 | +static const MemoryRegionOps emac_ops = { | ||
505 | + .read = emac_read, | ||
506 | + .write = emac_write, | ||
507 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
508 | + .impl = { | ||
509 | + .min_access_size = 4, | ||
510 | + .max_access_size = 4 | ||
511 | + } | ||
512 | +}; | ||
513 | + | ||
514 | +static bool emac_can_rx(NetClientState *nc) | ||
515 | +{ | ||
516 | + MSF2EmacState *s = qemu_get_nic_opaque(nc); | ||
517 | + | ||
518 | + return (s->regs[R_CFG1] & R_CFG1_RX_EN_MASK) && | ||
519 | + (s->regs[R_DMA_RX_CTL] & R_DMA_RX_CTL_EN_MASK); | ||
520 | +} | ||
521 | + | ||
522 | +static bool addr_filter_ok(MSF2EmacState *s, const uint8_t *buf) | ||
523 | +{ | ||
524 | + /* The broadcast MAC address: FF:FF:FF:FF:FF:FF */ | ||
525 | + const uint8_t broadcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, | ||
526 | + 0xFF, 0xFF }; | ||
527 | + bool bcast_en = true; | ||
528 | + bool mcast_en = true; | ||
529 | + | ||
530 | + if (s->regs[R_FIFO_CFG5] & R_FIFO_CFG5_BCAST_MASK) { | ||
531 | + bcast_en = true; /* Broadcast dont care for drop circuitry */ | ||
532 | + } else if (s->regs[R_FIFO_CFG4] & R_FIFO_CFG4_BCAST_MASK) { | ||
533 | + bcast_en = false; | ||
534 | + } | ||
535 | + | ||
536 | + if (s->regs[R_FIFO_CFG5] & R_FIFO_CFG5_MCAST_MASK) { | ||
537 | + mcast_en = true; /* Multicast dont care for drop circuitry */ | ||
538 | + } else if (s->regs[R_FIFO_CFG4] & R_FIFO_CFG4_MCAST_MASK) { | ||
539 | + mcast_en = false; | ||
540 | + } | ||
541 | + | ||
542 | + if (!memcmp(buf, broadcast_addr, sizeof(broadcast_addr))) { | ||
543 | + return bcast_en; | ||
544 | + } | ||
545 | + | ||
546 | + if (buf[0] & 1) { | ||
547 | + return mcast_en; | ||
548 | + } | ||
549 | + | ||
550 | + return !memcmp(buf, s->mac_addr, sizeof(s->mac_addr)); | ||
551 | +} | ||
552 | + | ||
553 | +static ssize_t emac_rx(NetClientState *nc, const uint8_t *buf, size_t size) | ||
554 | +{ | ||
555 | + MSF2EmacState *s = qemu_get_nic_opaque(nc); | ||
556 | + EmacDesc d; | ||
557 | + uint8_t pktcnt; | ||
558 | + uint32_t status; | ||
559 | + | ||
560 | + if (size > (s->regs[R_MAX_FRAME_LENGTH] & 0xFFFF)) { | ||
561 | + return size; | ||
562 | + } | ||
563 | + if (!addr_filter_ok(s, buf)) { | ||
564 | + return size; | ||
565 | + } | ||
566 | + | ||
567 | + emac_load_desc(s, &d, s->rx_desc); | ||
568 | + | ||
569 | + if (d.pktsize & EMPTY_MASK) { | ||
570 | + address_space_write(&s->dma_as, d.pktaddr, MEMTXATTRS_UNSPECIFIED, | ||
571 | + buf, size & PKT_SIZE); | ||
572 | + d.pktsize = size & PKT_SIZE; | ||
573 | + emac_store_desc(s, &d, s->rx_desc); | ||
574 | + /* update received packets count */ | ||
575 | + status = s->regs[R_DMA_RX_STATUS]; | ||
576 | + pktcnt = FIELD_EX32(status, DMA_RX_STATUS, PKTCNT); | ||
577 | + pktcnt++; | ||
578 | + s->regs[R_DMA_RX_STATUS] = FIELD_DP32(status, DMA_RX_STATUS, | ||
579 | + PKTCNT, pktcnt); | ||
580 | + s->regs[R_DMA_RX_STATUS] |= R_DMA_RX_STATUS_PKT_RCVD_MASK; | ||
581 | + s->rx_desc = d.next; | ||
582 | + } else { | ||
583 | + s->regs[R_DMA_RX_CTL] &= ~R_DMA_RX_CTL_EN_MASK; | ||
584 | + s->regs[R_DMA_RX_STATUS] |= R_DMA_RX_STATUS_OVERFLOW_MASK; | ||
585 | + } | ||
586 | + emac_update_irq(s); | ||
587 | + return size; | ||
588 | +} | ||
589 | + | ||
590 | +static void msf2_emac_reset(DeviceState *dev) | ||
591 | +{ | ||
592 | + MSF2EmacState *s = MSS_EMAC(dev); | ||
593 | + | ||
594 | + msf2_emac_do_reset(s); | ||
595 | +} | ||
596 | + | ||
597 | +static void emac_set_link(NetClientState *nc) | ||
598 | +{ | ||
599 | + MSF2EmacState *s = qemu_get_nic_opaque(nc); | ||
600 | + | ||
601 | + msf2_phy_update_link(s); | ||
602 | +} | ||
603 | + | ||
604 | +static NetClientInfo net_msf2_emac_info = { | ||
605 | + .type = NET_CLIENT_DRIVER_NIC, | ||
606 | + .size = sizeof(NICState), | ||
607 | + .can_receive = emac_can_rx, | ||
608 | + .receive = emac_rx, | ||
609 | + .link_status_changed = emac_set_link, | ||
610 | +}; | ||
611 | + | ||
612 | +static void msf2_emac_realize(DeviceState *dev, Error **errp) | ||
613 | +{ | ||
614 | + MSF2EmacState *s = MSS_EMAC(dev); | ||
615 | + | ||
616 | + if (!s->dma_mr) { | ||
617 | + error_setg(errp, "MSS_EMAC 'ahb-bus' link not set"); | ||
618 | + return; | ||
619 | + } | ||
620 | + | ||
621 | + address_space_init(&s->dma_as, s->dma_mr, "emac-ahb"); | ||
622 | + | ||
623 | + qemu_macaddr_default_if_unset(&s->conf.macaddr); | ||
624 | + s->nic = qemu_new_nic(&net_msf2_emac_info, &s->conf, | ||
625 | + object_get_typename(OBJECT(dev)), dev->id, s); | ||
626 | + qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); | ||
627 | +} | ||
628 | + | ||
629 | +static void msf2_emac_init(Object *obj) | ||
630 | +{ | ||
631 | + MSF2EmacState *s = MSS_EMAC(obj); | ||
632 | + | ||
633 | + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | ||
634 | + | ||
635 | + memory_region_init_io(&s->mmio, obj, &emac_ops, s, | ||
636 | + "msf2-emac", R_MAX * 4); | ||
637 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | ||
638 | +} | ||
639 | + | ||
640 | +static Property msf2_emac_properties[] = { | ||
641 | + DEFINE_PROP_LINK("ahb-bus", MSF2EmacState, dma_mr, | ||
642 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
643 | + DEFINE_NIC_PROPERTIES(MSF2EmacState, conf), | ||
644 | + DEFINE_PROP_END_OF_LIST(), | ||
645 | +}; | ||
646 | + | ||
647 | +static const VMStateDescription vmstate_msf2_emac = { | ||
648 | + .name = TYPE_MSS_EMAC, | ||
649 | + .version_id = 1, | ||
650 | + .minimum_version_id = 1, | ||
651 | + .fields = (VMStateField[]) { | ||
652 | + VMSTATE_UINT8_ARRAY(mac_addr, MSF2EmacState, ETH_ALEN), | ||
653 | + VMSTATE_UINT32(rx_desc, MSF2EmacState), | ||
654 | + VMSTATE_UINT16_ARRAY(phy_regs, MSF2EmacState, PHY_MAX_REGS), | ||
655 | + VMSTATE_UINT32_ARRAY(regs, MSF2EmacState, R_MAX), | ||
656 | + VMSTATE_END_OF_LIST() | ||
657 | + } | ||
658 | +}; | ||
659 | + | ||
660 | +static void msf2_emac_class_init(ObjectClass *klass, void *data) | ||
661 | +{ | ||
662 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
663 | + | ||
664 | + dc->realize = msf2_emac_realize; | ||
665 | + dc->reset = msf2_emac_reset; | ||
666 | + dc->vmsd = &vmstate_msf2_emac; | ||
667 | + device_class_set_props(dc, msf2_emac_properties); | ||
668 | +} | ||
669 | + | ||
670 | +static const TypeInfo msf2_emac_info = { | ||
671 | + .name = TYPE_MSS_EMAC, | ||
672 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
673 | + .instance_size = sizeof(MSF2EmacState), | ||
674 | + .instance_init = msf2_emac_init, | ||
675 | + .class_init = msf2_emac_class_init, | ||
676 | +}; | ||
677 | + | ||
678 | +static void msf2_emac_register_types(void) | ||
679 | +{ | ||
680 | + type_register_static(&msf2_emac_info); | ||
681 | +} | ||
682 | + | ||
683 | +type_init(msf2_emac_register_types) | ||
684 | diff --git a/MAINTAINERS b/MAINTAINERS | 34 | diff --git a/MAINTAINERS b/MAINTAINERS |
685 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
686 | --- a/MAINTAINERS | 36 | --- a/MAINTAINERS |
687 | +++ b/MAINTAINERS | 37 | +++ b/MAINTAINERS |
688 | @@ -XXX,XX +XXX,XX @@ F: include/hw/arm/msf2-soc.h | 38 | @@ -XXX,XX +XXX,XX @@ F: include/hw/ssi/imx_spi.h |
689 | F: include/hw/misc/msf2-sysreg.h | 39 | SBSA-REF |
690 | F: include/hw/timer/mss-timer.h | 40 | M: Radoslaw Biernacki <rad@semihalf.com> |
691 | F: include/hw/ssi/mss-spi.h | 41 | M: Peter Maydell <peter.maydell@linaro.org> |
692 | +F: hw/net/msf2-emac.c | 42 | -R: Leif Lindholm <leif@nuviainc.com> |
693 | +F: include/hw/net/msf2-emac.h | 43 | +R: Leif Lindholm <quic_llindhol@quicinc.com> |
694 | 44 | L: qemu-arm@nongnu.org | |
695 | Emcraft M2S-FG484 | 45 | S: Maintained |
696 | M: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 46 | F: hw/arm/sbsa-ref.c |
697 | -- | 47 | -- |
698 | 2.20.1 | 48 | 2.25.1 |
699 | 49 | ||
700 | 50 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add functions to easily handle clocks with devices. | 3 | More gracefully handle cpregs when EL2 and/or EL3 are missing. |
4 | Clock inputs and outputs should be used to handle clock propagation | 4 | If the reg is entirely inaccessible, do not register it at all. |
5 | between devices. | 5 | If the reg is for EL2, and EL3 is present but EL2 is not, |
6 | The API is very similar the GPIO API. | 6 | either discard, squash to res0, const, or keep unchanged. |
7 | 7 | ||
8 | This is based on the original work of Frederic Konrad. | 8 | Per rule RJFFP, mark the 4 aarch32 hypervisor access registers |
9 | 9 | with ARM_CP_EL3_NO_EL2_KEEP, and mark all of the EL2 address | |
10 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | 10 | translation and tlb invalidation "regs" ARM_CP_EL3_NO_EL2_UNDEF. |
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 11 | Mark the 2 virtualization processor id regs ARM_CP_EL3_NO_EL2_C_NZ. |
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 12 | |
13 | Message-id: 20200406135251.157596-4-damien.hedde@greensocs.com | 13 | This will simplify cpreg registration for conditional arm features. |
14 | |||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20220506180242.216785-2-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 19 | --- |
16 | hw/core/Makefile.objs | 2 +- | 20 | target/arm/cpregs.h | 11 +++ |
17 | tests/Makefile.include | 1 + | 21 | target/arm/helper.c | 178 ++++++++++++++++++++++++++++++-------------- |
18 | include/hw/qdev-clock.h | 104 +++++++++++++++++++++++++ | 22 | 2 files changed, 133 insertions(+), 56 deletions(-) |
19 | include/hw/qdev-core.h | 12 +++ | 23 | |
20 | hw/core/qdev-clock.c | 168 ++++++++++++++++++++++++++++++++++++++++ | 24 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
21 | hw/core/qdev.c | 12 +++ | ||
22 | 6 files changed, 298 insertions(+), 1 deletion(-) | ||
23 | create mode 100644 include/hw/qdev-clock.h | ||
24 | create mode 100644 hw/core/qdev-clock.c | ||
25 | |||
26 | diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs | ||
27 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/core/Makefile.objs | 26 | --- a/target/arm/cpregs.h |
29 | +++ b/hw/core/Makefile.objs | 27 | +++ b/target/arm/cpregs.h |
30 | @@ -XXX,XX +XXX,XX @@ common-obj-y += hotplug.o | 28 | @@ -XXX,XX +XXX,XX @@ enum { |
31 | common-obj-y += vmstate-if.o | 29 | ARM_CP_SVE = 1 << 14, |
32 | # irq.o needed for qdev GPIO handling: | 30 | /* Flag: Do not expose in gdb sysreg xml. */ |
33 | common-obj-y += irq.o | 31 | ARM_CP_NO_GDB = 1 << 15, |
34 | -common-obj-y += clock.o | 32 | + /* |
35 | +common-obj-y += clock.o qdev-clock.o | 33 | + * Flags: If EL3 but not EL2... |
36 | 34 | + * - UNDEF: discard the cpreg, | |
37 | common-obj-$(CONFIG_SOFTMMU) += reset.o | 35 | + * - KEEP: retain the cpreg as is, |
38 | common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o | 36 | + * - C_NZ: set const on the cpreg, but retain resetvalue, |
39 | diff --git a/tests/Makefile.include b/tests/Makefile.include | 37 | + * - else: set const on the cpreg, zero resetvalue, aka RES0. |
38 | + * See rule RJFFP in section D1.1.3 of DDI0487H.a. | ||
39 | + */ | ||
40 | + ARM_CP_EL3_NO_EL2_UNDEF = 1 << 16, | ||
41 | + ARM_CP_EL3_NO_EL2_KEEP = 1 << 17, | ||
42 | + ARM_CP_EL3_NO_EL2_C_NZ = 1 << 18, | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/tests/Makefile.include | 48 | --- a/target/arm/helper.c |
42 | +++ b/tests/Makefile.include | 49 | +++ b/target/arm/helper.c |
43 | @@ -XXX,XX +XXX,XX @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ | 50 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
44 | hw/core/fw-path-provider.o \ | 51 | .access = PL1_RW, .readfn = spsel_read, .writefn = spsel_write }, |
45 | hw/core/reset.o \ | 52 | { .name = "FPEXC32_EL2", .state = ARM_CP_STATE_AA64, |
46 | hw/core/vmstate-if.o \ | 53 | .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 3, .opc2 = 0, |
47 | + hw/core/clock.o hw/core/qdev-clock.o \ | 54 | - .access = PL2_RW, .type = ARM_CP_ALIAS | ARM_CP_FPU, |
48 | $(test-qapi-obj-y) | 55 | + .access = PL2_RW, |
49 | tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ | 56 | + .type = ARM_CP_ALIAS | ARM_CP_FPU | ARM_CP_EL3_NO_EL2_KEEP, |
50 | migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \ | 57 | .fieldoffset = offsetof(CPUARMState, vfp.xregs[ARM_VFP_FPEXC]) }, |
51 | diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h | 58 | { .name = "DACR32_EL2", .state = ARM_CP_STATE_AA64, |
52 | new file mode 100644 | 59 | .opc0 = 3, .opc1 = 4, .crn = 3, .crm = 0, .opc2 = 0, |
53 | index XXXXXXX..XXXXXXX | 60 | - .access = PL2_RW, .resetvalue = 0, |
54 | --- /dev/null | 61 | + .access = PL2_RW, .resetvalue = 0, .type = ARM_CP_EL3_NO_EL2_KEEP, |
55 | +++ b/include/hw/qdev-clock.h | 62 | .writefn = dacr_write, .raw_writefn = raw_write, |
56 | @@ -XXX,XX +XXX,XX @@ | 63 | .fieldoffset = offsetof(CPUARMState, cp15.dacr32_el2) }, |
57 | +/* | 64 | { .name = "IFSR32_EL2", .state = ARM_CP_STATE_AA64, |
58 | + * Device's clock input and output | 65 | .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 0, .opc2 = 1, |
59 | + * | 66 | - .access = PL2_RW, .resetvalue = 0, |
60 | + * Copyright GreenSocs 2016-2020 | 67 | + .access = PL2_RW, .resetvalue = 0, .type = ARM_CP_EL3_NO_EL2_KEEP, |
61 | + * | 68 | .fieldoffset = offsetof(CPUARMState, cp15.ifsr32_el2) }, |
62 | + * Authors: | 69 | { .name = "SPSR_IRQ", .state = ARM_CP_STATE_AA64, |
63 | + * Frederic Konrad | 70 | .type = ARM_CP_ALIAS, |
64 | + * Damien Hedde | 71 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { |
65 | + * | 72 | .writefn = tlbimva_hyp_is_write }, |
66 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 73 | { .name = "TLBI_ALLE2", .state = ARM_CP_STATE_AA64, |
67 | + * See the COPYING file in the top-level directory. | 74 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 0, |
68 | + */ | 75 | - .type = ARM_CP_NO_RAW, .access = PL2_W, |
69 | + | 76 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
70 | +#ifndef QDEV_CLOCK_H | 77 | .writefn = tlbi_aa64_alle2_write }, |
71 | +#define QDEV_CLOCK_H | 78 | { .name = "TLBI_VAE2", .state = ARM_CP_STATE_AA64, |
72 | + | 79 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 1, |
73 | +#include "hw/clock.h" | 80 | - .type = ARM_CP_NO_RAW, .access = PL2_W, |
74 | + | 81 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
75 | +/** | 82 | .writefn = tlbi_aa64_vae2_write }, |
76 | + * qdev_init_clock_in: | 83 | { .name = "TLBI_VALE2", .state = ARM_CP_STATE_AA64, |
77 | + * @dev: the device to add an input clock to | 84 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 5, |
78 | + * @name: the name of the clock (can't be NULL). | 85 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
79 | + * @callback: optional callback to be called on update or NULL. | 86 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
80 | + * @opaque: argument for the callback | 87 | .writefn = tlbi_aa64_vae2_write }, |
81 | + * @returns: a pointer to the newly added clock | 88 | { .name = "TLBI_ALLE2IS", .state = ARM_CP_STATE_AA64, |
82 | + * | 89 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 0, |
83 | + * Add an input clock to device @dev as a clock named @name. | 90 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
84 | + * This adds a child<> property. | 91 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
85 | + * The callback will be called with @opaque as opaque parameter. | 92 | .writefn = tlbi_aa64_alle2is_write }, |
86 | + */ | 93 | { .name = "TLBI_VAE2IS", .state = ARM_CP_STATE_AA64, |
87 | +Clock *qdev_init_clock_in(DeviceState *dev, const char *name, | 94 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 1, |
88 | + ClockCallback *callback, void *opaque); | 95 | - .type = ARM_CP_NO_RAW, .access = PL2_W, |
89 | + | 96 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
90 | +/** | 97 | .writefn = tlbi_aa64_vae2is_write }, |
91 | + * qdev_init_clock_out: | 98 | { .name = "TLBI_VALE2IS", .state = ARM_CP_STATE_AA64, |
92 | + * @dev: the device to add an output clock to | 99 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 5, |
93 | + * @name: the name of the clock (can't be NULL). | 100 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
94 | + * @returns: a pointer to the newly added clock | 101 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
95 | + * | 102 | .writefn = tlbi_aa64_vae2is_write }, |
96 | + * Add an output clock to device @dev as a clock named @name. | 103 | #ifndef CONFIG_USER_ONLY |
97 | + * This adds a child<> property. | 104 | /* Unlike the other EL2-related AT operations, these must |
98 | + */ | 105 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { |
99 | +Clock *qdev_init_clock_out(DeviceState *dev, const char *name); | 106 | { .name = "AT_S1E2R", .state = ARM_CP_STATE_AA64, |
100 | + | 107 | .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 0, |
101 | +/** | 108 | .access = PL2_W, .accessfn = at_s1e2_access, |
102 | + * qdev_get_clock_in: | 109 | - .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, .writefn = ats_write64 }, |
103 | + * @dev: the device which has the clock | 110 | + .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF, |
104 | + * @name: the name of the clock (can't be NULL). | 111 | + .writefn = ats_write64 }, |
105 | + * @returns: a pointer to the clock | 112 | { .name = "AT_S1E2W", .state = ARM_CP_STATE_AA64, |
106 | + * | 113 | .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 1, |
107 | + * Get the input clock @name from @dev or NULL if does not exist. | 114 | .access = PL2_W, .accessfn = at_s1e2_access, |
108 | + */ | 115 | - .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, .writefn = ats_write64 }, |
109 | +Clock *qdev_get_clock_in(DeviceState *dev, const char *name); | 116 | + .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF, |
110 | + | 117 | + .writefn = ats_write64 }, |
111 | +/** | 118 | /* The AArch32 ATS1H* operations are CONSTRAINED UNPREDICTABLE |
112 | + * qdev_get_clock_out: | 119 | * if EL2 is not implemented; we choose to UNDEF. Behaviour at EL3 |
113 | + * @dev: the device which has the clock | 120 | * with SCR.NS == 0 outside Monitor mode is UNPREDICTABLE; we choose |
114 | + * @name: the name of the clock (can't be NULL). | 121 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
115 | + * @returns: a pointer to the clock | 122 | { .name = "DBGVCR32_EL2", .state = ARM_CP_STATE_AA64, |
116 | + * | 123 | .opc0 = 2, .opc1 = 4, .crn = 0, .crm = 7, .opc2 = 0, |
117 | + * Get the output clock @name from @dev or NULL if does not exist. | 124 | .access = PL2_RW, .accessfn = access_tda, |
118 | + */ | 125 | - .type = ARM_CP_NOP }, |
119 | +Clock *qdev_get_clock_out(DeviceState *dev, const char *name); | 126 | + .type = ARM_CP_NOP | ARM_CP_EL3_NO_EL2_KEEP }, |
120 | + | 127 | /* Dummy MDCCINT_EL1, since we don't implement the Debug Communications |
121 | +/** | 128 | * Channel but Linux may try to access this register. The 32-bit |
122 | + * qdev_connect_clock_in: | 129 | * alias is DBGDCCINT. |
123 | + * @dev: a device | 130 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { |
124 | + * @name: the name of an input clock in @dev | 131 | .access = PL2_W, .type = ARM_CP_NOP }, |
125 | + * @source: the source clock (an output clock of another device for example) | 132 | { .name = "TLBI_RVAE2IS", .state = ARM_CP_STATE_AA64, |
126 | + * | 133 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 2, .opc2 = 1, |
127 | + * Set the source clock of input clock @name of device @dev to @source. | 134 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
128 | + * @source period update will be propagated to @name clock. | 135 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
129 | + */ | 136 | .writefn = tlbi_aa64_rvae2is_write }, |
130 | +static inline void qdev_connect_clock_in(DeviceState *dev, const char *name, | 137 | { .name = "TLBI_RVALE2IS", .state = ARM_CP_STATE_AA64, |
131 | + Clock *source) | 138 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 2, .opc2 = 5, |
132 | +{ | 139 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
133 | + clock_set_source(qdev_get_clock_in(dev, name), source); | 140 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
134 | +} | 141 | .writefn = tlbi_aa64_rvae2is_write }, |
135 | + | 142 | { .name = "TLBI_RIPAS2E1", .state = ARM_CP_STATE_AA64, |
136 | +/** | 143 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 2, |
137 | + * qdev_alias_clock: | 144 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { |
138 | + * @dev: the device which has the clock | 145 | .access = PL2_W, .type = ARM_CP_NOP }, |
139 | + * @name: the name of the clock in @dev (can't be NULL) | 146 | { .name = "TLBI_RVAE2OS", .state = ARM_CP_STATE_AA64, |
140 | + * @alias_dev: the device to add the clock | 147 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 5, .opc2 = 1, |
141 | + * @alias_name: the name of the clock in @container | 148 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
142 | + * @returns: a pointer to the clock | 149 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
143 | + * | 150 | .writefn = tlbi_aa64_rvae2is_write }, |
144 | + * Add a clock @alias_name in @alias_dev which is an alias of the clock @name | 151 | { .name = "TLBI_RVALE2OS", .state = ARM_CP_STATE_AA64, |
145 | + * in @dev. The direction _in_ or _out_ will the same as the original. | 152 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 5, .opc2 = 5, |
146 | + * An alias clock must not be modified or used by @alias_dev and should | 153 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
147 | + * typically be only only for device composition purpose. | 154 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
148 | + */ | 155 | .writefn = tlbi_aa64_rvae2is_write }, |
149 | +Clock *qdev_alias_clock(DeviceState *dev, const char *name, | 156 | { .name = "TLBI_RVAE2", .state = ARM_CP_STATE_AA64, |
150 | + DeviceState *alias_dev, const char *alias_name); | 157 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 6, .opc2 = 1, |
151 | + | 158 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
152 | +/** | 159 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
153 | + * qdev_finalize_clocklist: | 160 | .writefn = tlbi_aa64_rvae2_write }, |
154 | + * @dev: the device being finalized | 161 | { .name = "TLBI_RVALE2", .state = ARM_CP_STATE_AA64, |
155 | + * | 162 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 6, .opc2 = 5, |
156 | + * Clear the clocklist from @dev. Only used internally in qdev. | 163 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
157 | + */ | 164 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
158 | +void qdev_finalize_clocklist(DeviceState *dev); | 165 | .writefn = tlbi_aa64_rvae2_write }, |
159 | + | 166 | { .name = "TLBI_RVAE3IS", .state = ARM_CP_STATE_AA64, |
160 | +#endif /* QDEV_CLOCK_H */ | 167 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 2, .opc2 = 1, |
161 | diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h | 168 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { |
162 | index XXXXXXX..XXXXXXX 100644 | 169 | .writefn = tlbi_aa64_vae1is_write }, |
163 | --- a/include/hw/qdev-core.h | 170 | { .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64, |
164 | +++ b/include/hw/qdev-core.h | 171 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0, |
165 | @@ -XXX,XX +XXX,XX @@ struct NamedGPIOList { | 172 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
166 | QLIST_ENTRY(NamedGPIOList) node; | 173 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
167 | }; | 174 | .writefn = tlbi_aa64_alle2is_write }, |
168 | 175 | { .name = "TLBI_VAE2OS", .state = ARM_CP_STATE_AA64, | |
169 | +typedef struct Clock Clock; | 176 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 1, |
170 | +typedef struct NamedClockList NamedClockList; | 177 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
171 | + | 178 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
172 | +struct NamedClockList { | 179 | .writefn = tlbi_aa64_vae2is_write }, |
173 | + char *name; | 180 | { .name = "TLBI_ALLE1OS", .state = ARM_CP_STATE_AA64, |
174 | + Clock *clock; | 181 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 4, |
175 | + bool output; | 182 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { |
176 | + bool alias; | 183 | .writefn = tlbi_aa64_alle1is_write }, |
177 | + QLIST_ENTRY(NamedClockList) node; | 184 | { .name = "TLBI_VALE2OS", .state = ARM_CP_STATE_AA64, |
178 | +}; | 185 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 5, |
179 | + | 186 | - .access = PL2_W, .type = ARM_CP_NO_RAW, |
180 | /** | 187 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, |
181 | * DeviceState: | 188 | .writefn = tlbi_aa64_vae2is_write }, |
182 | * @realized: Indicates whether the device has been fully constructed. | 189 | { .name = "TLBI_VMALLS12E1OS", .state = ARM_CP_STATE_AA64, |
183 | @@ -XXX,XX +XXX,XX @@ struct DeviceState { | 190 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 6, |
184 | bool allow_unplug_during_migration; | 191 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
185 | BusState *parent_bus; | 192 | { .name = "VPIDR", .state = ARM_CP_STATE_AA32, |
186 | QLIST_HEAD(, NamedGPIOList) gpios; | 193 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, |
187 | + QLIST_HEAD(, NamedClockList) clocks; | 194 | .access = PL2_RW, .accessfn = access_el3_aa32ns, |
188 | QLIST_HEAD(, BusState) child_bus; | 195 | - .resetvalue = cpu->midr, .type = ARM_CP_ALIAS, |
189 | int num_child_bus; | 196 | + .resetvalue = cpu->midr, |
190 | int instance_id_alias; | 197 | + .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, |
191 | diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c | 198 | .fieldoffset = offsetoflow32(CPUARMState, cp15.vpidr_el2) }, |
192 | new file mode 100644 | 199 | { .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64, |
193 | index XXXXXXX..XXXXXXX | 200 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, |
194 | --- /dev/null | 201 | .access = PL2_RW, .resetvalue = cpu->midr, |
195 | +++ b/hw/core/qdev-clock.c | 202 | + .type = ARM_CP_EL3_NO_EL2_C_NZ, |
196 | @@ -XXX,XX +XXX,XX @@ | 203 | .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, |
197 | +/* | 204 | { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, |
198 | + * Device's clock input and output | 205 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, |
199 | + * | 206 | .access = PL2_RW, .accessfn = access_el3_aa32ns, |
200 | + * Copyright GreenSocs 2016-2020 | 207 | - .resetvalue = vmpidr_def, .type = ARM_CP_ALIAS, |
201 | + * | 208 | + .resetvalue = vmpidr_def, |
202 | + * Authors: | 209 | + .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, |
203 | + * Frederic Konrad | 210 | .fieldoffset = offsetoflow32(CPUARMState, cp15.vmpidr_el2) }, |
204 | + * Damien Hedde | 211 | { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64, |
205 | + * | 212 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, |
206 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 213 | - .access = PL2_RW, |
207 | + * See the COPYING file in the top-level directory. | 214 | - .resetvalue = vmpidr_def, |
208 | + */ | 215 | + .access = PL2_RW, .resetvalue = vmpidr_def, |
209 | + | 216 | + .type = ARM_CP_EL3_NO_EL2_C_NZ, |
210 | +#include "qemu/osdep.h" | 217 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, |
211 | +#include "hw/qdev-clock.h" | 218 | }; |
212 | +#include "hw/qdev-core.h" | 219 | define_arm_cp_regs(cpu, vpidr_regs); |
213 | +#include "qapi/error.h" | 220 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
214 | + | 221 | int crm, int opc1, int opc2, |
215 | +/* | 222 | const char *name) |
216 | + * qdev_init_clocklist: | 223 | { |
217 | + * Add a new clock in a device | 224 | + CPUARMState *env = &cpu->env; |
218 | + */ | 225 | uint32_t key; |
219 | +static NamedClockList *qdev_init_clocklist(DeviceState *dev, const char *name, | 226 | ARMCPRegInfo *r2; |
220 | + bool output, Clock *clk) | 227 | bool is64 = r->type & ARM_CP_64BIT; |
221 | +{ | 228 | bool ns = secstate & ARM_CP_SECSTATE_NS; |
222 | + NamedClockList *ncl; | 229 | int cp = r->cp; |
223 | + | 230 | - bool isbanked; |
231 | size_t name_len; | ||
232 | + bool make_const; | ||
233 | |||
234 | switch (state) { | ||
235 | case ARM_CP_STATE_AA32: | ||
236 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
237 | } | ||
238 | } | ||
239 | |||
224 | + /* | 240 | + /* |
225 | + * Clock must be added before realize() so that we can compute the | 241 | + * Eliminate registers that are not present because the EL is missing. |
226 | + * clock's canonical path during device_realize(). | 242 | + * Doing this here makes it easier to put all registers for a given |
243 | + * feature into the same ARMCPRegInfo array and define them all at once. | ||
227 | + */ | 244 | + */ |
228 | + assert(!dev->realized); | 245 | + make_const = false; |
229 | + | 246 | + if (arm_feature(env, ARM_FEATURE_EL3)) { |
230 | + /* | 247 | + /* |
231 | + * The ncl structure is freed by qdev_finalize_clocklist() which will | 248 | + * An EL2 register without EL2 but with EL3 is (usually) RES0. |
232 | + * be called during @dev's device_finalize(). | 249 | + * See rule RJFFP in section D1.1.3 of DDI0487H.a. |
233 | + */ | 250 | + */ |
234 | + ncl = g_new0(NamedClockList, 1); | 251 | + int min_el = ctz32(r->access) / 2; |
235 | + ncl->name = g_strdup(name); | 252 | + if (min_el == 2 && !arm_feature(env, ARM_FEATURE_EL2)) { |
236 | + ncl->output = output; | 253 | + if (r->type & ARM_CP_EL3_NO_EL2_UNDEF) { |
237 | + ncl->alias = (clk != NULL); | 254 | + return; |
238 | + | 255 | + } |
239 | + /* | 256 | + make_const = !(r->type & ARM_CP_EL3_NO_EL2_KEEP); |
240 | + * Trying to create a clock whose name clashes with some other | ||
241 | + * clock or property is a bug in the caller and we will abort(). | ||
242 | + */ | ||
243 | + if (clk == NULL) { | ||
244 | + clk = CLOCK(object_new(TYPE_CLOCK)); | ||
245 | + object_property_add_child(OBJECT(dev), name, OBJECT(clk), &error_abort); | ||
246 | + if (output) { | ||
247 | + /* | ||
248 | + * Remove object_new()'s initial reference. | ||
249 | + * Note that for inputs, the reference created by object_new() | ||
250 | + * will be deleted in qdev_finalize_clocklist(). | ||
251 | + */ | ||
252 | + object_unref(OBJECT(clk)); | ||
253 | + } | 257 | + } |
254 | + } else { | 258 | + } else { |
255 | + object_property_add_link(OBJECT(dev), name, | 259 | + CPAccessRights max_el = (arm_feature(env, ARM_FEATURE_EL2) |
256 | + object_get_typename(OBJECT(clk)), | 260 | + ? PL2_RW : PL1_RW); |
257 | + (Object **) &ncl->clock, | 261 | + if ((r->access & max_el) == 0) { |
258 | + NULL, OBJ_PROP_LINK_STRONG, &error_abort); | 262 | + return; |
259 | + } | ||
260 | + | ||
261 | + ncl->clock = clk; | ||
262 | + | ||
263 | + QLIST_INSERT_HEAD(&dev->clocks, ncl, node); | ||
264 | + return ncl; | ||
265 | +} | ||
266 | + | ||
267 | +void qdev_finalize_clocklist(DeviceState *dev) | ||
268 | +{ | ||
269 | + /* called by @dev's device_finalize() */ | ||
270 | + NamedClockList *ncl, *ncl_next; | ||
271 | + | ||
272 | + QLIST_FOREACH_SAFE(ncl, &dev->clocks, node, ncl_next) { | ||
273 | + QLIST_REMOVE(ncl, node); | ||
274 | + if (!ncl->output && !ncl->alias) { | ||
275 | + /* | ||
276 | + * We kept a reference on the input clock to ensure it lives up to | ||
277 | + * this point so we can safely remove the callback. | ||
278 | + * It avoids having a callback to a deleted object if ncl->clock | ||
279 | + * is still referenced somewhere else (eg: by a clock output). | ||
280 | + */ | ||
281 | + clock_clear_callback(ncl->clock); | ||
282 | + object_unref(OBJECT(ncl->clock)); | ||
283 | + } | ||
284 | + g_free(ncl->name); | ||
285 | + g_free(ncl); | ||
286 | + } | ||
287 | +} | ||
288 | + | ||
289 | +Clock *qdev_init_clock_out(DeviceState *dev, const char *name) | ||
290 | +{ | ||
291 | + NamedClockList *ncl; | ||
292 | + | ||
293 | + assert(name); | ||
294 | + | ||
295 | + ncl = qdev_init_clocklist(dev, name, true, NULL); | ||
296 | + | ||
297 | + return ncl->clock; | ||
298 | +} | ||
299 | + | ||
300 | +Clock *qdev_init_clock_in(DeviceState *dev, const char *name, | ||
301 | + ClockCallback *callback, void *opaque) | ||
302 | +{ | ||
303 | + NamedClockList *ncl; | ||
304 | + | ||
305 | + assert(name); | ||
306 | + | ||
307 | + ncl = qdev_init_clocklist(dev, name, false, NULL); | ||
308 | + | ||
309 | + if (callback) { | ||
310 | + clock_set_callback(ncl->clock, callback, opaque); | ||
311 | + } | ||
312 | + return ncl->clock; | ||
313 | +} | ||
314 | + | ||
315 | +static NamedClockList *qdev_get_clocklist(DeviceState *dev, const char *name) | ||
316 | +{ | ||
317 | + NamedClockList *ncl; | ||
318 | + | ||
319 | + QLIST_FOREACH(ncl, &dev->clocks, node) { | ||
320 | + if (strcmp(name, ncl->name) == 0) { | ||
321 | + return ncl; | ||
322 | + } | 263 | + } |
323 | + } | 264 | + } |
324 | + | 265 | + |
325 | + return NULL; | 266 | /* Combine cpreg and name into one allocation. */ |
326 | +} | 267 | name_len = strlen(name) + 1; |
327 | + | 268 | r2 = g_malloc(sizeof(*r2) + name_len); |
328 | +Clock *qdev_get_clock_in(DeviceState *dev, const char *name) | 269 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
329 | +{ | 270 | r2->opaque = opaque; |
330 | + NamedClockList *ncl; | 271 | } |
331 | + | 272 | |
332 | + assert(name); | 273 | - isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; |
333 | + | 274 | - if (isbanked) { |
334 | + ncl = qdev_get_clocklist(dev, name); | 275 | + if (make_const) { |
335 | + assert(!ncl->output); | 276 | + /* This should not have been a very special register to begin. */ |
336 | + | 277 | + int old_special = r2->type & ARM_CP_SPECIAL_MASK; |
337 | + return ncl->clock; | 278 | + assert(old_special == 0 || old_special == ARM_CP_NOP); |
338 | +} | 279 | /* |
339 | + | 280 | - * Register is banked (using both entries in array). |
340 | +Clock *qdev_get_clock_out(DeviceState *dev, const char *name) | 281 | - * Overwriting fieldoffset as the array is only used to define |
341 | +{ | 282 | - * banked registers but later only fieldoffset is used. |
342 | + NamedClockList *ncl; | 283 | + * Set the special function to CONST, retaining the other flags. |
343 | + | 284 | + * This is important for e.g. ARM_CP_SVE so that we still |
344 | + assert(name); | 285 | + * take the SVE trap if CPTR_EL3.EZ == 0. |
345 | + | ||
346 | + ncl = qdev_get_clocklist(dev, name); | ||
347 | + assert(ncl->output); | ||
348 | + | ||
349 | + return ncl->clock; | ||
350 | +} | ||
351 | + | ||
352 | +Clock *qdev_alias_clock(DeviceState *dev, const char *name, | ||
353 | + DeviceState *alias_dev, const char *alias_name) | ||
354 | +{ | ||
355 | + NamedClockList *ncl; | ||
356 | + | ||
357 | + assert(name && alias_name); | ||
358 | + | ||
359 | + ncl = qdev_get_clocklist(dev, name); | ||
360 | + | ||
361 | + qdev_init_clocklist(alias_dev, alias_name, ncl->output, ncl->clock); | ||
362 | + | ||
363 | + return ncl->clock; | ||
364 | +} | ||
365 | diff --git a/hw/core/qdev.c b/hw/core/qdev.c | ||
366 | index XXXXXXX..XXXXXXX 100644 | ||
367 | --- a/hw/core/qdev.c | ||
368 | +++ b/hw/core/qdev.c | ||
369 | @@ -XXX,XX +XXX,XX @@ | ||
370 | #include "hw/qdev-properties.h" | ||
371 | #include "hw/boards.h" | ||
372 | #include "hw/sysbus.h" | ||
373 | +#include "hw/qdev-clock.h" | ||
374 | #include "migration/vmstate.h" | ||
375 | #include "trace.h" | ||
376 | |||
377 | @@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp) | ||
378 | DeviceClass *dc = DEVICE_GET_CLASS(dev); | ||
379 | HotplugHandler *hotplug_ctrl; | ||
380 | BusState *bus; | ||
381 | + NamedClockList *ncl; | ||
382 | Error *local_err = NULL; | ||
383 | bool unattached_parent = false; | ||
384 | static int unattached_count; | ||
385 | @@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp) | ||
386 | */ | 286 | */ |
387 | g_free(dev->canonical_path); | 287 | - r2->fieldoffset = r->bank_fieldoffsets[ns]; |
388 | dev->canonical_path = object_get_canonical_path(OBJECT(dev)); | 288 | - } |
389 | + QLIST_FOREACH(ncl, &dev->clocks, node) { | 289 | + r2->type = (r2->type & ~ARM_CP_SPECIAL_MASK) | ARM_CP_CONST; |
390 | + if (ncl->alias) { | 290 | + /* |
391 | + continue; | 291 | + * Usually, these registers become RES0, but there are a few |
392 | + } else { | 292 | + * special cases like VPIDR_EL2 which have a constant non-zero |
393 | + clock_setup_canonical_path(ncl->clock); | 293 | + * value with writes ignored. |
294 | + */ | ||
295 | + if (!(r->type & ARM_CP_EL3_NO_EL2_C_NZ)) { | ||
296 | + r2->resetvalue = 0; | ||
297 | + } | ||
298 | + /* | ||
299 | + * ARM_CP_CONST has precedence, so removing the callbacks and | ||
300 | + * offsets are not strictly necessary, but it is potentially | ||
301 | + * less confusing to debug later. | ||
302 | + */ | ||
303 | + r2->readfn = NULL; | ||
304 | + r2->writefn = NULL; | ||
305 | + r2->raw_readfn = NULL; | ||
306 | + r2->raw_writefn = NULL; | ||
307 | + r2->resetfn = NULL; | ||
308 | + r2->fieldoffset = 0; | ||
309 | + r2->bank_fieldoffsets[0] = 0; | ||
310 | + r2->bank_fieldoffsets[1] = 0; | ||
311 | + } else { | ||
312 | + bool isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; | ||
313 | |||
314 | - if (state == ARM_CP_STATE_AA32) { | ||
315 | if (isbanked) { | ||
316 | /* | ||
317 | - * If the register is banked then we don't need to migrate or | ||
318 | - * reset the 32-bit instance in certain cases: | ||
319 | - * | ||
320 | - * 1) If the register has both 32-bit and 64-bit instances then we | ||
321 | - * can count on the 64-bit instance taking care of the | ||
322 | - * non-secure bank. | ||
323 | - * 2) If ARMv8 is enabled then we can count on a 64-bit version | ||
324 | - * taking care of the secure bank. This requires that separate | ||
325 | - * 32 and 64-bit definitions are provided. | ||
326 | + * Register is banked (using both entries in array). | ||
327 | + * Overwriting fieldoffset as the array is only used to define | ||
328 | + * banked registers but later only fieldoffset is used. | ||
329 | */ | ||
330 | - if ((r->state == ARM_CP_STATE_BOTH && ns) || | ||
331 | - (arm_feature(&cpu->env, ARM_FEATURE_V8) && !ns)) { | ||
332 | + r2->fieldoffset = r->bank_fieldoffsets[ns]; | ||
333 | + } | ||
334 | + if (state == ARM_CP_STATE_AA32) { | ||
335 | + if (isbanked) { | ||
336 | + /* | ||
337 | + * If the register is banked then we don't need to migrate or | ||
338 | + * reset the 32-bit instance in certain cases: | ||
339 | + * | ||
340 | + * 1) If the register has both 32-bit and 64-bit instances | ||
341 | + * then we can count on the 64-bit instance taking care | ||
342 | + * of the non-secure bank. | ||
343 | + * 2) If ARMv8 is enabled then we can count on a 64-bit | ||
344 | + * version taking care of the secure bank. This requires | ||
345 | + * that separate 32 and 64-bit definitions are provided. | ||
346 | + */ | ||
347 | + if ((r->state == ARM_CP_STATE_BOTH && ns) || | ||
348 | + (arm_feature(env, ARM_FEATURE_V8) && !ns)) { | ||
349 | + r2->type |= ARM_CP_ALIAS; | ||
350 | + } | ||
351 | + } else if ((secstate != r->secure) && !ns) { | ||
352 | + /* | ||
353 | + * The register is not banked so we only want to allow | ||
354 | + * migration of the non-secure instance. | ||
355 | + */ | ||
356 | r2->type |= ARM_CP_ALIAS; | ||
357 | } | ||
358 | - } else if ((secstate != r->secure) && !ns) { | ||
359 | - /* | ||
360 | - * The register is not banked so we only want to allow migration | ||
361 | - * of the non-secure instance. | ||
362 | - */ | ||
363 | - r2->type |= ARM_CP_ALIAS; | ||
364 | - } | ||
365 | |||
366 | - if (HOST_BIG_ENDIAN && | ||
367 | - r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { | ||
368 | - r2->fieldoffset += sizeof(uint32_t); | ||
369 | + if (HOST_BIG_ENDIAN && | ||
370 | + r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { | ||
371 | + r2->fieldoffset += sizeof(uint32_t); | ||
394 | + } | 372 | + } |
395 | + } | 373 | } |
396 | |||
397 | if (qdev_get_vmsd(dev)) { | ||
398 | if (vmstate_register_with_alias_id(VMSTATE_IF(dev), | ||
399 | @@ -XXX,XX +XXX,XX @@ static void device_initfn(Object *obj) | ||
400 | dev->allow_unplug_during_migration = false; | ||
401 | |||
402 | QLIST_INIT(&dev->gpios); | ||
403 | + QLIST_INIT(&dev->clocks); | ||
404 | } | ||
405 | |||
406 | static void device_post_init(Object *obj) | ||
407 | @@ -XXX,XX +XXX,XX @@ static void device_finalize(Object *obj) | ||
408 | */ | ||
409 | } | 374 | } |
410 | 375 | ||
411 | + qdev_finalize_clocklist(dev); | 376 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
412 | + | 377 | * multiple times. Special registers (ie NOP/WFI) are |
413 | /* Only send event if the device had been completely realized */ | 378 | * never migratable and not even raw-accessible. |
414 | if (dev->pending_deleted_event) { | 379 | */ |
415 | g_assert(dev->canonical_path); | 380 | - if (r->type & ARM_CP_SPECIAL_MASK) { |
381 | + if (r2->type & ARM_CP_SPECIAL_MASK) { | ||
382 | r2->type |= ARM_CP_NO_RAW; | ||
383 | } | ||
384 | if (((r->crm == CP_ANY) && crm != 0) || | ||
416 | -- | 385 | -- |
417 | 2.20.1 | 386 | 2.25.1 |
418 | |||
419 | diff view generated by jsdifflib |
1 | Add the documentation about the clock inputs and outputs in devices. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This is based on the original work of Frederic Konrad. | 3 | Drop el3_no_el2_cp_reginfo, el3_no_el2_v8_cp_reginfo, and the local |
4 | 4 | vpidr_regs definition, and rely on the squashing to ARM_CP_CONST | |
5 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | 5 | while registering for v8. |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 6 | |
7 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 7 | This is a behavior change for v7 cpus with Security Extensions and |
8 | Message-id: 20200406135251.157596-6-damien.hedde@greensocs.com | 8 | without Virtualization Extensions, in that the virtualization cpregs |
9 | [PMM: Editing pass for minor grammar, style and Sphinx | 9 | are now correctly not present. This would be a migration compatibility |
10 | formatting fixes] | 10 | break, except that we have an existing bug in which migration of 32-bit |
11 | cpus with Security Extensions enabled does not work. | ||
12 | |||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20220506180242.216785-3-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 17 | --- |
14 | docs/devel/clocks.rst | 391 ++++++++++++++++++++++++++++++++++++++++++ | 18 | target/arm/helper.c | 158 ++++---------------------------------------- |
15 | docs/devel/index.rst | 1 + | 19 | 1 file changed, 13 insertions(+), 145 deletions(-) |
16 | 2 files changed, 392 insertions(+) | 20 | |
17 | create mode 100644 docs/devel/clocks.rst | 21 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | 22 | index XXXXXXX..XXXXXXX 100644 | |
19 | diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst | 23 | --- a/target/arm/helper.c |
20 | new file mode 100644 | 24 | +++ b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX | 25 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
22 | --- /dev/null | 26 | .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, |
23 | +++ b/docs/devel/clocks.rst | 27 | }; |
24 | @@ -XXX,XX +XXX,XX @@ | 28 | |
25 | +Modelling a clock tree in QEMU | 29 | -/* Used to describe the behaviour of EL2 regs when EL2 does not exist. */ |
26 | +============================== | 30 | -static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { |
27 | + | 31 | - { .name = "VBAR_EL2", .state = ARM_CP_STATE_BOTH, |
28 | +What are clocks? | 32 | - .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0, |
29 | +---------------- | 33 | - .access = PL2_RW, |
30 | + | 34 | - .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, |
31 | +Clocks are QOM objects developed for the purpose of modelling the | 35 | - { .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH, |
32 | +distribution of clocks in QEMU. | 36 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, |
33 | + | 37 | - .access = PL2_RW, |
34 | +They allow us to model the clock distribution of a platform and detect | 38 | - .type = ARM_CP_CONST, .resetvalue = 0 }, |
35 | +configuration errors in the clock tree such as badly configured PLL, clock | 39 | - { .name = "HACR_EL2", .state = ARM_CP_STATE_BOTH, |
36 | +source selection or disabled clock. | 40 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 7, |
37 | + | 41 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
38 | +The object is *Clock* and its QOM name is ``clock`` (in C code, the macro | 42 | - { .name = "ESR_EL2", .state = ARM_CP_STATE_BOTH, |
39 | +``TYPE_CLOCK``). | 43 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 0, |
40 | + | 44 | - .access = PL2_RW, |
41 | +Clocks are typically used with devices where they are used to model inputs | 45 | - .type = ARM_CP_CONST, .resetvalue = 0 }, |
42 | +and outputs. They are created in a similar way to GPIOs. Inputs and outputs | 46 | - { .name = "CPTR_EL2", .state = ARM_CP_STATE_BOTH, |
43 | +of different devices can be connected together. | 47 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2, |
44 | + | 48 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
45 | +In these cases a Clock object is a child of a Device object, but this | 49 | - { .name = "MAIR_EL2", .state = ARM_CP_STATE_BOTH, |
46 | +is not a requirement. Clocks can be independent of devices. For | 50 | - .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 0, |
47 | +example it is possible to create a clock outside of any device to | 51 | - .access = PL2_RW, .type = ARM_CP_CONST, |
48 | +model the main clock source of a machine. | 52 | - .resetvalue = 0 }, |
49 | + | 53 | - { .name = "HMAIR1", .state = ARM_CP_STATE_AA32, |
50 | +Here is an example of clocks:: | 54 | - .cp = 15, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 1, |
51 | + | 55 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
52 | + +---------+ +----------------------+ +--------------+ | 56 | - { .name = "AMAIR_EL2", .state = ARM_CP_STATE_BOTH, |
53 | + | Clock 1 | | Device B | | Device C | | 57 | - .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 3, .opc2 = 0, |
54 | + | | | +-------+ +-------+ | | +-------+ | | 58 | - .access = PL2_RW, .type = ARM_CP_CONST, |
55 | + | |>>-+-->>|Clock 2| |Clock 3|>>--->>|Clock 6| | | 59 | - .resetvalue = 0 }, |
56 | + +---------+ | | | (in) | | (out) | | | | (in) | | | 60 | - { .name = "HAMAIR1", .state = ARM_CP_STATE_AA32, |
57 | + | | +-------+ +-------+ | | +-------+ | | 61 | - .cp = 15, .opc1 = 4, .crn = 10, .crm = 3, .opc2 = 1, |
58 | + | | +-------+ | +--------------+ | 62 | - .access = PL2_RW, .type = ARM_CP_CONST, |
59 | + | | |Clock 4|>> | 63 | - .resetvalue = 0 }, |
60 | + | | | (out) | | +--------------+ | 64 | - { .name = "AFSR0_EL2", .state = ARM_CP_STATE_BOTH, |
61 | + | | +-------+ | | Device D | | 65 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 1, .opc2 = 0, |
62 | + | | +-------+ | | +-------+ | | 66 | - .access = PL2_RW, .type = ARM_CP_CONST, |
63 | + | | |Clock 5|>>--->>|Clock 7| | | 67 | - .resetvalue = 0 }, |
64 | + | | | (out) | | | | (in) | | | 68 | - { .name = "AFSR1_EL2", .state = ARM_CP_STATE_BOTH, |
65 | + | | +-------+ | | +-------+ | | 69 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 1, .opc2 = 1, |
66 | + | +----------------------+ | | | 70 | - .access = PL2_RW, .type = ARM_CP_CONST, |
67 | + | | +-------+ | | 71 | - .resetvalue = 0 }, |
68 | + +----------------------------->>|Clock 8| | | 72 | - { .name = "TCR_EL2", .state = ARM_CP_STATE_BOTH, |
69 | + | | (in) | | | 73 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 2, |
70 | + | +-------+ | | 74 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
71 | + +--------------+ | 75 | - { .name = "VTCR_EL2", .state = ARM_CP_STATE_BOTH, |
72 | + | 76 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 2, |
73 | +Clocks are defined in the ``include/hw/clock.h`` header and device | 77 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, |
74 | +related functions are defined in the ``include/hw/qdev-clock.h`` | 78 | - .type = ARM_CP_CONST, .resetvalue = 0 }, |
75 | +header. | 79 | - { .name = "VTTBR", .state = ARM_CP_STATE_AA32, |
76 | + | 80 | - .cp = 15, .opc1 = 6, .crm = 2, |
77 | +The clock state | 81 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, |
78 | +--------------- | 82 | - .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, |
79 | + | 83 | - { .name = "VTTBR_EL2", .state = ARM_CP_STATE_AA64, |
80 | +The state of a clock is its period; it is stored as an integer | 84 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 0, |
81 | +representing it in units of 2 :sup:`-32` ns. The special value of 0 is used to | 85 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
82 | +represent the clock being inactive or gated. The clocks do not model | 86 | - { .name = "SCTLR_EL2", .state = ARM_CP_STATE_BOTH, |
83 | +the signal itself (pin toggling) or other properties such as the duty | 87 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 0, |
84 | +cycle. | 88 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
85 | + | 89 | - { .name = "TPIDR_EL2", .state = ARM_CP_STATE_BOTH, |
86 | +All clocks contain this state: outputs as well as inputs. This allows | 90 | - .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 2, |
87 | +the current period of a clock to be fetched at any time. When a clock | 91 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
88 | +is updated, the value is immediately propagated to all connected | 92 | - { .name = "TTBR0_EL2", .state = ARM_CP_STATE_AA64, |
89 | +clocks in the tree. | 93 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0, |
90 | + | 94 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
91 | +To ease interaction with clocks, helpers with a unit suffix are defined for | 95 | - { .name = "HTTBR", .cp = 15, .opc1 = 4, .crm = 2, |
92 | +every clock state setter or getter. The suffixes are: | 96 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, |
93 | + | 97 | - .resetvalue = 0 }, |
94 | +- ``_ns`` for handling periods in nanoseconds | 98 | - { .name = "CNTHCTL_EL2", .state = ARM_CP_STATE_BOTH, |
95 | +- ``_hz`` for handling frequencies in hertz | 99 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 1, .opc2 = 0, |
96 | + | 100 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
97 | +The 0 period value is converted to 0 in hertz and vice versa. 0 always means | 101 | - { .name = "CNTVOFF_EL2", .state = ARM_CP_STATE_AA64, |
98 | +that the clock is disabled. | 102 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 3, |
99 | + | 103 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
100 | +Adding a new clock | 104 | - { .name = "CNTVOFF", .cp = 15, .opc1 = 4, .crm = 14, |
101 | +------------------ | 105 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, |
102 | + | 106 | - .resetvalue = 0 }, |
103 | +Adding clocks to a device must be done during the init method of the Device | 107 | - { .name = "CNTHP_CVAL_EL2", .state = ARM_CP_STATE_AA64, |
104 | +instance. | 108 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 2, |
105 | + | 109 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
106 | +To add an input clock to a device, the function ``qdev_init_clock_in()`` | 110 | - { .name = "CNTHP_CVAL", .cp = 15, .opc1 = 6, .crm = 14, |
107 | +must be used. It takes the name, a callback and an opaque parameter | 111 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, |
108 | +for the callback (this will be explained in a following section). | 112 | - .resetvalue = 0 }, |
109 | +Output is simpler; only the name is required. Typically:: | 113 | - { .name = "CNTHP_TVAL_EL2", .state = ARM_CP_STATE_BOTH, |
110 | + | 114 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 0, |
111 | + qdev_init_clock_in(DEVICE(dev), "clk_in", clk_in_callback, dev); | 115 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
112 | + qdev_init_clock_out(DEVICE(dev), "clk_out"); | 116 | - { .name = "CNTHP_CTL_EL2", .state = ARM_CP_STATE_BOTH, |
113 | + | 117 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 1, |
114 | +Both functions return the created Clock pointer, which should be saved in the | 118 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
115 | +device's state structure for further use. | 119 | - { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH, |
116 | + | 120 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1, |
117 | +These objects will be automatically deleted by the QOM reference mechanism. | 121 | - .access = PL2_RW, .accessfn = access_tda, |
118 | + | 122 | - .type = ARM_CP_CONST, .resetvalue = 0 }, |
119 | +Note that it is possible to create a static array describing clock inputs and | 123 | - { .name = "HPFAR_EL2", .state = ARM_CP_STATE_BOTH, |
120 | +outputs. The function ``qdev_init_clocks()`` must be called with the array as | 124 | - .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4, |
121 | +parameter to initialize the clocks: it has the same behaviour as calling the | 125 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, |
122 | +``qdev_init_clock_in/out()`` for each clock in the array. To ease the array | 126 | - .type = ARM_CP_CONST, .resetvalue = 0 }, |
123 | +construction, some macros are defined in ``include/hw/qdev-clock.h``. | 127 | - { .name = "HSTR_EL2", .state = ARM_CP_STATE_BOTH, |
124 | +As an example, the following creates 2 clocks to a device: one input and one | 128 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, |
125 | +output. | 129 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
126 | + | 130 | - { .name = "FAR_EL2", .state = ARM_CP_STATE_BOTH, |
127 | +.. code-block:: c | 131 | - .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 0, |
128 | + | 132 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
129 | + /* device structure containing pointers to the clock objects */ | 133 | - { .name = "HIFAR", .state = ARM_CP_STATE_AA32, |
130 | + typedef struct MyDeviceState { | 134 | - .type = ARM_CP_CONST, |
131 | + DeviceState parent_obj; | 135 | - .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2, |
132 | + Clock *clk_in; | 136 | - .access = PL2_RW, .resetvalue = 0 }, |
133 | + Clock *clk_out; | 137 | -}; |
134 | + } MyDeviceState; | 138 | - |
139 | -/* Ditto, but for registers which exist in ARMv8 but not v7 */ | ||
140 | -static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | ||
141 | - { .name = "HCR2", .state = ARM_CP_STATE_AA32, | ||
142 | - .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
143 | - .access = PL2_RW, | ||
144 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
145 | -}; | ||
146 | - | ||
147 | static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
148 | { | ||
149 | ARMCPU *cpu = env_archcpu(env); | ||
150 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
151 | define_arm_cp_regs(cpu, v8_idregs); | ||
152 | define_arm_cp_regs(cpu, v8_cp_reginfo); | ||
153 | } | ||
154 | - if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
135 | + | 155 | + |
136 | + /* | 156 | + /* |
137 | + * callback for the input clock (see "Callback on input clock | 157 | + * Register the base EL2 cpregs. |
138 | + * change" section below for more information). | 158 | + * Pre v8, these registers are implemented only as part of the |
159 | + * Virtualization Extensions (EL2 present). Beginning with v8, | ||
160 | + * if EL2 is missing but EL3 is enabled, mostly these become | ||
161 | + * RES0 from EL3, with some specific exceptions. | ||
139 | + */ | 162 | + */ |
140 | + static void clk_in_callback(void *opaque); | 163 | + if (arm_feature(env, ARM_FEATURE_EL2) |
164 | + || (arm_feature(env, ARM_FEATURE_EL3) | ||
165 | + && arm_feature(env, ARM_FEATURE_V8))) { | ||
166 | uint64_t vmpidr_def = mpidr_read_val(env); | ||
167 | ARMCPRegInfo vpidr_regs[] = { | ||
168 | { .name = "VPIDR", .state = ARM_CP_STATE_AA32, | ||
169 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
170 | }; | ||
171 | define_one_arm_cp_reg(cpu, &rvbar); | ||
172 | } | ||
173 | - } else { | ||
174 | - /* If EL2 is missing but higher ELs are enabled, we need to | ||
175 | - * register the no_el2 reginfos. | ||
176 | - */ | ||
177 | - if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
178 | - /* When EL3 exists but not EL2, VPIDR and VMPIDR take the value | ||
179 | - * of MIDR_EL1 and MPIDR_EL1. | ||
180 | - */ | ||
181 | - ARMCPRegInfo vpidr_regs[] = { | ||
182 | - { .name = "VPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
183 | - .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
184 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
185 | - .type = ARM_CP_CONST, .resetvalue = cpu->midr, | ||
186 | - .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, | ||
187 | - { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
188 | - .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
189 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
190 | - .type = ARM_CP_NO_RAW, | ||
191 | - .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, | ||
192 | - }; | ||
193 | - define_arm_cp_regs(cpu, vpidr_regs); | ||
194 | - define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo); | ||
195 | - if (arm_feature(env, ARM_FEATURE_V8)) { | ||
196 | - define_arm_cp_regs(cpu, el3_no_el2_v8_cp_reginfo); | ||
197 | - } | ||
198 | - } | ||
199 | } | ||
141 | + | 200 | + |
142 | + /* | 201 | + /* Register the base EL3 cpregs. */ |
143 | + * static array describing clocks: | 202 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
144 | + * + a clock input named "clk_in", whose pointer is stored in | 203 | define_arm_cp_regs(cpu, el3_cp_reginfo); |
145 | + * the clk_in field of a MyDeviceState structure with callback | 204 | ARMCPRegInfo el3_regs[] = { |
146 | + * clk_in_callback. | ||
147 | + * + a clock output named "clk_out" whose pointer is stored in | ||
148 | + * the clk_out field of a MyDeviceState structure. | ||
149 | + */ | ||
150 | + static const ClockPortInitArray mydev_clocks = { | ||
151 | + QDEV_CLOCK_IN(MyDeviceState, clk_in, clk_in_callback), | ||
152 | + QDEV_CLOCK_OUT(MyDeviceState, clk_out), | ||
153 | + QDEV_CLOCK_END | ||
154 | + }; | ||
155 | + | ||
156 | + /* device initialization function */ | ||
157 | + static void mydev_init(Object *obj) | ||
158 | + { | ||
159 | + /* cast to MyDeviceState */ | ||
160 | + MyDeviceState *mydev = MYDEVICE(obj); | ||
161 | + /* create and fill the pointer fields in the MyDeviceState */ | ||
162 | + qdev_init_clocks(mydev, mydev_clocks); | ||
163 | + [...] | ||
164 | + } | ||
165 | + | ||
166 | +An alternative way to create a clock is to simply call | ||
167 | +``object_new(TYPE_CLOCK)``. In that case the clock will neither be an | ||
168 | +input nor an output of a device. After the whole QOM hierarchy of the | ||
169 | +clock has been set ``clock_setup_canonical_path()`` should be called. | ||
170 | + | ||
171 | +At creation, the period of the clock is 0: the clock is disabled. You can | ||
172 | +change it using ``clock_set_ns()`` or ``clock_set_hz()``. | ||
173 | + | ||
174 | +Note that if you are creating a clock with a fixed period which will never | ||
175 | +change (for example the main clock source of a board), then you'll have | ||
176 | +nothing else to do. This value will be propagated to other clocks when | ||
177 | +connecting the clocks together and devices will fetch the right value during | ||
178 | +the first reset. | ||
179 | + | ||
180 | +Retrieving clocks from a device | ||
181 | +------------------------------- | ||
182 | + | ||
183 | +``qdev_get_clock_in()`` and ``dev_get_clock_out()`` are available to | ||
184 | +get the clock inputs or outputs of a device. For example: | ||
185 | + | ||
186 | +.. code-block:: c | ||
187 | + | ||
188 | + Clock *clk = qdev_get_clock_in(DEVICE(mydev), "clk_in"); | ||
189 | + | ||
190 | +or: | ||
191 | + | ||
192 | +.. code-block:: c | ||
193 | + | ||
194 | + Clock *clk = qdev_get_clock_out(DEVICE(mydev), "clk_out"); | ||
195 | + | ||
196 | +Connecting two clocks together | ||
197 | +------------------------------ | ||
198 | + | ||
199 | +To connect two clocks together, use the ``clock_set_source()`` function. | ||
200 | +Given two clocks ``clk1``, and ``clk2``, ``clock_set_source(clk2, clk1);`` | ||
201 | +configures ``clk2`` to follow the ``clk1`` period changes. Every time ``clk1`` | ||
202 | +is updated, ``clk2`` will be updated too. | ||
203 | + | ||
204 | +When connecting clock between devices, prefer using the | ||
205 | +``qdev_connect_clock_in()`` function to set the source of an input | ||
206 | +device clock. For example, to connect the input clock ``clk2`` of | ||
207 | +``devB`` to the output clock ``clk1`` of ``devA``, do: | ||
208 | + | ||
209 | +.. code-block:: c | ||
210 | + | ||
211 | + qdev_connect_clock_in(devB, "clk2", qdev_get_clock_out(devA, "clk1")) | ||
212 | + | ||
213 | +We used ``qdev_get_clock_out()`` above, but any clock can drive an | ||
214 | +input clock, even another input clock. The following diagram shows | ||
215 | +some examples of connections. Note also that a clock can drive several | ||
216 | +other clocks. | ||
217 | + | ||
218 | +:: | ||
219 | + | ||
220 | + +------------+ +--------------------------------------------------+ | ||
221 | + | Device A | | Device B | | ||
222 | + | | | +---------------------+ | | ||
223 | + | | | | Device C | | | ||
224 | + | +-------+ | | +-------+ | +-------+ +-------+ | +-------+ | | ||
225 | + | |Clock 1|>>-->>|Clock 2|>>+-->>|Clock 3| |Clock 5|>>>>|Clock 6|>> | ||
226 | + | | (out) | | | | (in) | | | | (in) | | (out) | | | (out) | | | ||
227 | + | +-------+ | | +-------+ | | +-------+ +-------+ | +-------+ | | ||
228 | + +------------+ | | +---------------------+ | | ||
229 | + | | | | ||
230 | + | | +--------------+ | | ||
231 | + | | | Device D | | | ||
232 | + | | | +-------+ | | | ||
233 | + | +-->>|Clock 4| | | | ||
234 | + | | | (in) | | | | ||
235 | + | | +-------+ | | | ||
236 | + | +--------------+ | | ||
237 | + +--------------------------------------------------+ | ||
238 | + | ||
239 | +In the above example, when *Clock 1* is updated by *Device A*, three | ||
240 | +clocks get the new clock period value: *Clock 2*, *Clock 3* and *Clock 4*. | ||
241 | + | ||
242 | +It is not possible to disconnect a clock or to change the clock connection | ||
243 | +after it is connected. | ||
244 | + | ||
245 | +Unconnected input clocks | ||
246 | +------------------------ | ||
247 | + | ||
248 | +A newly created input clock is disabled (period of 0). This means the | ||
249 | +clock will be considered as disabled until the period is updated. If | ||
250 | +the clock remains unconnected it will always keep its initial value | ||
251 | +of 0. If this is not the desired behaviour, ``clock_set()``, | ||
252 | +``clock_set_ns()`` or ``clock_set_hz()`` should be called on the Clock | ||
253 | +object during device instance init. For example: | ||
254 | + | ||
255 | +.. code-block:: c | ||
256 | + | ||
257 | + clk = qdev_init_clock_in(DEVICE(dev), "clk-in", clk_in_callback, | ||
258 | + dev); | ||
259 | + /* set initial value to 10ns / 100MHz */ | ||
260 | + clock_set_ns(clk, 10); | ||
261 | + | ||
262 | +Fetching clock frequency/period | ||
263 | +------------------------------- | ||
264 | + | ||
265 | +To get the current state of a clock, use the functions ``clock_get()``, | ||
266 | +``clock_get_ns()`` or ``clock_get_hz()``. | ||
267 | + | ||
268 | +It is also possible to register a callback on clock frequency changes. | ||
269 | +Here is an example: | ||
270 | + | ||
271 | +.. code-block:: c | ||
272 | + | ||
273 | + void clock_callback(void *opaque) { | ||
274 | + MyDeviceState *s = (MyDeviceState *) opaque; | ||
275 | + /* | ||
276 | + * 'opaque' is the argument passed to qdev_init_clock_in(); | ||
277 | + * usually this will be the device state pointer. | ||
278 | + */ | ||
279 | + | ||
280 | + /* do something with the new period */ | ||
281 | + fprintf(stdout, "device new period is %" PRIu64 "ns\n", | ||
282 | + clock_get_ns(dev->my_clk_input)); | ||
283 | + } | ||
284 | + | ||
285 | +Changing a clock period | ||
286 | +----------------------- | ||
287 | + | ||
288 | +A device can change its outputs using the ``clock_update()``, | ||
289 | +``clock_update_ns()`` or ``clock_update_hz()`` function. It will trigger | ||
290 | +updates on every connected input. | ||
291 | + | ||
292 | +For example, let's say that we have an output clock *clkout* and we | ||
293 | +have a pointer to it in the device state because we did the following | ||
294 | +in init phase: | ||
295 | + | ||
296 | +.. code-block:: c | ||
297 | + | ||
298 | + dev->clkout = qdev_init_clock_out(DEVICE(dev), "clkout"); | ||
299 | + | ||
300 | +Then at any time (apart from the cases listed below), it is possible to | ||
301 | +change the clock value by doing: | ||
302 | + | ||
303 | +.. code-block:: c | ||
304 | + | ||
305 | + clock_update_hz(dev->clkout, 1000 * 1000 * 1000); /* 1GHz */ | ||
306 | + | ||
307 | +Because updating a clock may trigger any side effects through | ||
308 | +connected clocks and their callbacks, this operation must be done | ||
309 | +while holding the qemu io lock. | ||
310 | + | ||
311 | +For the same reason, one can update clocks only when it is allowed to have | ||
312 | +side effects on other objects. In consequence, it is forbidden: | ||
313 | + | ||
314 | +* during migration, | ||
315 | +* and in the enter phase of reset. | ||
316 | + | ||
317 | +Note that calling ``clock_update[_ns|_hz]()`` is equivalent to calling | ||
318 | +``clock_set[_ns|_hz]()`` (with the same arguments) then | ||
319 | +``clock_propagate()`` on the clock. Thus, setting the clock value can | ||
320 | +be separated from triggering the side-effects. This is often required | ||
321 | +to factorize code to handle reset and migration in devices. | ||
322 | + | ||
323 | +Aliasing clocks | ||
324 | +--------------- | ||
325 | + | ||
326 | +Sometimes, one needs to forward, or inherit, a clock from another | ||
327 | +device. Typically, when doing device composition, a device might | ||
328 | +expose a sub-device's clock without interfering with it. The function | ||
329 | +``qdev_alias_clock()`` can be used to achieve this behaviour. Note | ||
330 | +that it is possible to expose the clock under a different name. | ||
331 | +``qdev_alias_clock()`` works for both input and output clocks. | ||
332 | + | ||
333 | +For example, if device B is a child of device A, | ||
334 | +``device_a_instance_init()`` may do something like this: | ||
335 | + | ||
336 | +.. code-block:: c | ||
337 | + | ||
338 | + void device_a_instance_init(Object *obj) | ||
339 | + { | ||
340 | + AState *A = DEVICE_A(obj); | ||
341 | + BState *B; | ||
342 | + /* create object B as child of A */ | ||
343 | + [...] | ||
344 | + qdev_alias_clock(B, "clk", A, "b_clk"); | ||
345 | + /* | ||
346 | + * Now A has a clock "b_clk" which is an alias to | ||
347 | + * the clock "clk" of its child B. | ||
348 | + */ | ||
349 | + } | ||
350 | + | ||
351 | +This function does not return any clock object. The new clock has the | ||
352 | +same direction (input or output) as the original one. This function | ||
353 | +only adds a link to the existing clock. In the above example, object B | ||
354 | +remains the only object allowed to use the clock and device A must not | ||
355 | +try to change the clock period or set a callback to the clock. This | ||
356 | +diagram describes the example with an input clock:: | ||
357 | + | ||
358 | + +--------------------------+ | ||
359 | + | Device A | | ||
360 | + | +--------------+ | | ||
361 | + | | Device B | | | ||
362 | + | | +-------+ | | | ||
363 | + >>"b_clk">>>| "clk" | | | | ||
364 | + | (in) | | (in) | | | | ||
365 | + | | +-------+ | | | ||
366 | + | +--------------+ | | ||
367 | + +--------------------------+ | ||
368 | + | ||
369 | +Migration | ||
370 | +--------- | ||
371 | + | ||
372 | +Clock state is not migrated automatically. Every device must handle its | ||
373 | +clock migration. Alias clocks must not be migrated. | ||
374 | + | ||
375 | +To ensure clock states are restored correctly during migration, there | ||
376 | +are two solutions. | ||
377 | + | ||
378 | +Clock states can be migrated by adding an entry into the device | ||
379 | +vmstate description. You should use the ``VMSTATE_CLOCK`` macro for this. | ||
380 | +This is typically used to migrate an input clock state. For example: | ||
381 | + | ||
382 | +.. code-block:: c | ||
383 | + | ||
384 | + MyDeviceState { | ||
385 | + DeviceState parent_obj; | ||
386 | + [...] /* some fields */ | ||
387 | + Clock *clk; | ||
388 | + }; | ||
389 | + | ||
390 | + VMStateDescription my_device_vmstate = { | ||
391 | + .name = "my_device", | ||
392 | + .fields = (VMStateField[]) { | ||
393 | + [...], /* other migrated fields */ | ||
394 | + VMSTATE_CLOCK(clk, MyDeviceState), | ||
395 | + VMSTATE_END_OF_LIST() | ||
396 | + } | ||
397 | + }; | ||
398 | + | ||
399 | +The second solution is to restore the clock state using information already | ||
400 | +at our disposal. This can be used to restore output clock states using the | ||
401 | +device state. The functions ``clock_set[_ns|_hz]()`` can be used during the | ||
402 | +``post_load()`` migration callback. | ||
403 | + | ||
404 | +When adding clock support to an existing device, if you care about | ||
405 | +migration compatibility you will need to be careful, as simply adding | ||
406 | +a ``VMSTATE_CLOCK()`` line will break compatibility. Instead, you can | ||
407 | +put the ``VMSTATE_CLOCK()`` line into a vmstate subsection with a | ||
408 | +suitable ``needed`` function, and use ``clock_set()`` in a | ||
409 | +``pre_load()`` function to set the default value that will be used if | ||
410 | +the source virtual machine in the migration does not send the clock | ||
411 | +state. | ||
412 | + | ||
413 | +Care should be taken not to use ``clock_update[_ns|_hz]()`` or | ||
414 | +``clock_propagate()`` during the whole migration procedure because it | ||
415 | +will trigger side effects to other devices in an unknown state. | ||
416 | diff --git a/docs/devel/index.rst b/docs/devel/index.rst | ||
417 | index XXXXXXX..XXXXXXX 100644 | ||
418 | --- a/docs/devel/index.rst | ||
419 | +++ b/docs/devel/index.rst | ||
420 | @@ -XXX,XX +XXX,XX @@ Contents: | ||
421 | bitops | ||
422 | reset | ||
423 | s390-dasd-ipl | ||
424 | + clocks | ||
425 | -- | 205 | -- |
426 | 2.20.1 | 206 | 2.25.1 |
427 | |||
428 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Fix descriptor loading from memory wrt host endianness. | 3 | Drop zcr_no_el2_reginfo and merge the 3 registers into one array, |
4 | now that ZCR_EL2 can be squashed to RES0 and ZCR_EL3 dropped | ||
5 | while registering. | ||
4 | 6 | ||
5 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 9 | Message-id: 20220506180242.216785-4-richard.henderson@linaro.org |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20200404122718.25111-2-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | hw/dma/xlnx-zdma.c | 11 +++++++---- | 12 | target/arm/helper.c | 55 ++++++++++++++------------------------------- |
13 | 1 file changed, 7 insertions(+), 4 deletions(-) | 13 | 1 file changed, 17 insertions(+), 38 deletions(-) |
14 | 14 | ||
15 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/dma/xlnx-zdma.c | 17 | --- a/target/arm/helper.c |
18 | +++ b/hw/dma/xlnx-zdma.c | 18 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static void zdma_put_regaddr64(XlnxZDMA *s, unsigned int basereg, uint64_t addr) | 19 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
20 | s->regs[basereg + 1] = addr >> 32; | 20 | } |
21 | } | 21 | } |
22 | 22 | ||
23 | -static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf) | 23 | -static const ARMCPRegInfo zcr_el1_reginfo = { |
24 | +static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, | 24 | - .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64, |
25 | + XlnxZDMADescr *descr) | 25 | - .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0, |
26 | { | 26 | - .access = PL1_RW, .type = ARM_CP_SVE, |
27 | /* ZDMA descriptors must be aligned to their own size. */ | 27 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]), |
28 | if (addr % sizeof(XlnxZDMADescr)) { | 28 | - .writefn = zcr_write, .raw_writefn = raw_write |
29 | qemu_log_mask(LOG_GUEST_ERROR, | 29 | -}; |
30 | "zdma: unaligned descriptor at %" PRIx64, | 30 | - |
31 | addr); | 31 | -static const ARMCPRegInfo zcr_el2_reginfo = { |
32 | - memset(buf, 0x0, sizeof(XlnxZDMADescr)); | 32 | - .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, |
33 | + memset(descr, 0x0, sizeof(XlnxZDMADescr)); | 33 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, |
34 | s->error = true; | 34 | - .access = PL2_RW, .type = ARM_CP_SVE, |
35 | return false; | 35 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]), |
36 | - .writefn = zcr_write, .raw_writefn = raw_write | ||
37 | -}; | ||
38 | - | ||
39 | -static const ARMCPRegInfo zcr_no_el2_reginfo = { | ||
40 | - .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | ||
41 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | ||
42 | - .access = PL2_RW, .type = ARM_CP_SVE, | ||
43 | - .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore | ||
44 | -}; | ||
45 | - | ||
46 | -static const ARMCPRegInfo zcr_el3_reginfo = { | ||
47 | - .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64, | ||
48 | - .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0, | ||
49 | - .access = PL3_RW, .type = ARM_CP_SVE, | ||
50 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]), | ||
51 | - .writefn = zcr_write, .raw_writefn = raw_write | ||
52 | +static const ARMCPRegInfo zcr_reginfo[] = { | ||
53 | + { .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64, | ||
54 | + .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0, | ||
55 | + .access = PL1_RW, .type = ARM_CP_SVE, | ||
56 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]), | ||
57 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
58 | + { .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | ||
59 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | ||
60 | + .access = PL2_RW, .type = ARM_CP_SVE, | ||
61 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]), | ||
62 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
63 | + { .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64, | ||
64 | + .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0, | ||
65 | + .access = PL3_RW, .type = ARM_CP_SVE, | ||
66 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]), | ||
67 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
68 | }; | ||
69 | |||
70 | void hw_watchpoint_update(ARMCPU *cpu, int n) | ||
71 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
36 | } | 72 | } |
37 | 73 | ||
38 | - address_space_read(s->dma_as, addr, s->attr, buf, sizeof(XlnxZDMADescr)); | 74 | if (cpu_isar_feature(aa64_sve, cpu)) { |
39 | + descr->addr = address_space_ldq_le(s->dma_as, addr, s->attr, NULL); | 75 | - define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); |
40 | + descr->size = address_space_ldl_le(s->dma_as, addr + 8, s->attr, NULL); | 76 | - if (arm_feature(env, ARM_FEATURE_EL2)) { |
41 | + descr->attr = address_space_ldl_le(s->dma_as, addr + 12, s->attr, NULL); | 77 | - define_one_arm_cp_reg(cpu, &zcr_el2_reginfo); |
42 | return true; | 78 | - } else { |
43 | } | 79 | - define_one_arm_cp_reg(cpu, &zcr_no_el2_reginfo); |
44 | 80 | - } | |
45 | @@ -XXX,XX +XXX,XX @@ static void zdma_update_descr_addr(XlnxZDMA *s, bool type, | 81 | - if (arm_feature(env, ARM_FEATURE_EL3)) { |
46 | } else { | 82 | - define_one_arm_cp_reg(cpu, &zcr_el3_reginfo); |
47 | addr = zdma_get_regaddr64(s, basereg); | 83 | - } |
48 | addr += sizeof(s->dsc_dst); | 84 | + define_arm_cp_regs(cpu, zcr_reginfo); |
49 | - address_space_read(s->dma_as, addr, s->attr, (void *) &next, 8); | ||
50 | + next = address_space_ldq_le(s->dma_as, addr, s->attr, NULL); | ||
51 | } | 85 | } |
52 | 86 | ||
53 | zdma_put_regaddr64(s, basereg, next); | 87 | #ifdef TARGET_AARCH64 |
54 | -- | 88 | -- |
55 | 2.20.1 | 89 | 2.25.1 |
56 | |||
57 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add the connection between the slcr's output clocks and the uarts inputs. | 3 | This register is present for either VHE or Debugv8p2. |
4 | 4 | ||
5 | Also add the main board clock 'ps_clk', which is hard-coded to 33.33MHz | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | (the default frequency). This clock is used to feed the slcr's input | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | clock. | 7 | Message-id: 20220506180242.216785-5-richard.henderson@linaro.org |
8 | |||
9 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
12 | Message-id: 20200406135251.157596-9-damien.hedde@greensocs.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 9 | --- |
15 | hw/arm/xilinx_zynq.c | 57 +++++++++++++++++++++++++++++++++++++------- | 10 | target/arm/helper.c | 15 +++++++++++---- |
16 | 1 file changed, 49 insertions(+), 8 deletions(-) | 11 | 1 file changed, 11 insertions(+), 4 deletions(-) |
17 | 12 | ||
18 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/xilinx_zynq.c | 15 | --- a/target/arm/helper.c |
21 | +++ b/hw/arm/xilinx_zynq.c | 16 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = { |
23 | #include "hw/char/cadence_uart.h" | 18 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
24 | #include "hw/net/cadence_gem.h" | 19 | }; |
25 | #include "hw/cpu/a9mpcore.h" | 20 | |
26 | +#include "hw/qdev-clock.h" | 21 | +static const ARMCPRegInfo contextidr_el2 = { |
27 | +#include "sysemu/reset.h" | 22 | + .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64, |
28 | + | 23 | + .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, |
29 | +#define TYPE_ZYNQ_MACHINE MACHINE_TYPE_NAME("xilinx-zynq-a9") | 24 | + .access = PL2_RW, |
30 | +#define ZYNQ_MACHINE(obj) \ | 25 | + .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) |
31 | + OBJECT_CHECK(ZynqMachineState, (obj), TYPE_ZYNQ_MACHINE) | ||
32 | + | ||
33 | +/* board base frequency: 33.333333 MHz */ | ||
34 | +#define PS_CLK_FREQUENCY (100 * 1000 * 1000 / 3) | ||
35 | |||
36 | #define NUM_SPI_FLASHES 4 | ||
37 | #define NUM_QSPI_FLASHES 2 | ||
38 | @@ -XXX,XX +XXX,XX @@ static const int dma_irqs[8] = { | ||
39 | 0xe3401000 + ARMV7_IMM16(extract32((val), 16, 16)), /* movt r1 ... */ \ | ||
40 | 0xe5801000 + (addr) | ||
41 | |||
42 | +typedef struct ZynqMachineState { | ||
43 | + MachineState parent; | ||
44 | + Clock *ps_clk; | ||
45 | +} ZynqMachineState; | ||
46 | + | ||
47 | static void zynq_write_board_setup(ARMCPU *cpu, | ||
48 | const struct arm_boot_info *info) | ||
49 | { | ||
50 | @@ -XXX,XX +XXX,XX @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq, | ||
51 | |||
52 | static void zynq_init(MachineState *machine) | ||
53 | { | ||
54 | + ZynqMachineState *zynq_machine = ZYNQ_MACHINE(machine); | ||
55 | ARMCPU *cpu; | ||
56 | MemoryRegion *address_space_mem = get_system_memory(); | ||
57 | MemoryRegion *ocm_ram = g_new(MemoryRegion, 1); | ||
58 | - DeviceState *dev; | ||
59 | + DeviceState *dev, *slcr; | ||
60 | SysBusDevice *busdev; | ||
61 | qemu_irq pic[64]; | ||
62 | int n; | ||
63 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | ||
64 | 1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa, | ||
65 | 0); | ||
66 | |||
67 | - dev = qdev_create(NULL, "xilinx,zynq_slcr"); | ||
68 | - qdev_init_nofail(dev); | ||
69 | - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000); | ||
70 | + /* Create slcr, keep a pointer to connect clocks */ | ||
71 | + slcr = qdev_create(NULL, "xilinx,zynq_slcr"); | ||
72 | + qdev_init_nofail(slcr); | ||
73 | + sysbus_mmio_map(SYS_BUS_DEVICE(slcr), 0, 0xF8000000); | ||
74 | + | ||
75 | + /* Create the main clock source, and feed slcr with it */ | ||
76 | + zynq_machine->ps_clk = CLOCK(object_new(TYPE_CLOCK)); | ||
77 | + object_property_add_child(OBJECT(zynq_machine), "ps_clk", | ||
78 | + OBJECT(zynq_machine->ps_clk), &error_abort); | ||
79 | + object_unref(OBJECT(zynq_machine->ps_clk)); | ||
80 | + clock_set_hz(zynq_machine->ps_clk, PS_CLK_FREQUENCY); | ||
81 | + qdev_connect_clock_in(slcr, "ps_clk", zynq_machine->ps_clk); | ||
82 | |||
83 | dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV); | ||
84 | qdev_prop_set_uint32(dev, "num-cpu", 1); | ||
85 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | ||
86 | sysbus_create_simple(TYPE_CHIPIDEA, 0xE0002000, pic[53 - IRQ_OFFSET]); | ||
87 | sysbus_create_simple(TYPE_CHIPIDEA, 0xE0003000, pic[76 - IRQ_OFFSET]); | ||
88 | |||
89 | - cadence_uart_create(0xE0000000, pic[59 - IRQ_OFFSET], serial_hd(0)); | ||
90 | - cadence_uart_create(0xE0001000, pic[82 - IRQ_OFFSET], serial_hd(1)); | ||
91 | + dev = cadence_uart_create(0xE0000000, pic[59 - IRQ_OFFSET], serial_hd(0)); | ||
92 | + qdev_connect_clock_in(dev, "refclk", | ||
93 | + qdev_get_clock_out(slcr, "uart0_ref_clk")); | ||
94 | + dev = cadence_uart_create(0xE0001000, pic[82 - IRQ_OFFSET], serial_hd(1)); | ||
95 | + qdev_connect_clock_in(dev, "refclk", | ||
96 | + qdev_get_clock_out(slcr, "uart1_ref_clk")); | ||
97 | |||
98 | sysbus_create_varargs("cadence_ttc", 0xF8001000, | ||
99 | pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL); | ||
100 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | ||
101 | arm_load_kernel(ARM_CPU(first_cpu), machine, &zynq_binfo); | ||
102 | } | ||
103 | |||
104 | -static void zynq_machine_init(MachineClass *mc) | ||
105 | +static void zynq_machine_class_init(ObjectClass *oc, void *data) | ||
106 | { | ||
107 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
108 | mc->desc = "Xilinx Zynq Platform Baseboard for Cortex-A9"; | ||
109 | mc->init = zynq_init; | ||
110 | mc->max_cpus = 1; | ||
111 | @@ -XXX,XX +XXX,XX @@ static void zynq_machine_init(MachineClass *mc) | ||
112 | mc->default_ram_id = "zynq.ext_ram"; | ||
113 | } | ||
114 | |||
115 | -DEFINE_MACHINE("xilinx-zynq-a9", zynq_machine_init) | ||
116 | +static const TypeInfo zynq_machine_type = { | ||
117 | + .name = TYPE_ZYNQ_MACHINE, | ||
118 | + .parent = TYPE_MACHINE, | ||
119 | + .class_init = zynq_machine_class_init, | ||
120 | + .instance_size = sizeof(ZynqMachineState), | ||
121 | +}; | 26 | +}; |
122 | + | 27 | + |
123 | +static void zynq_machine_register_types(void) | 28 | static const ARMCPRegInfo vhe_reginfo[] = { |
124 | +{ | 29 | - { .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64, |
125 | + type_register_static(&zynq_machine_type); | 30 | - .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, |
126 | +} | 31 | - .access = PL2_RW, |
127 | + | 32 | - .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) }, |
128 | +type_init(zynq_machine_register_types) | 33 | { .name = "TTBR1_EL2", .state = ARM_CP_STATE_AA64, |
34 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 1, | ||
35 | .access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write, | ||
36 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
37 | define_one_arm_cp_reg(cpu, &ssbs_reginfo); | ||
38 | } | ||
39 | |||
40 | + if (cpu_isar_feature(aa64_vh, cpu) || | ||
41 | + cpu_isar_feature(aa64_debugv8p2, cpu)) { | ||
42 | + define_one_arm_cp_reg(cpu, &contextidr_el2); | ||
43 | + } | ||
44 | if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { | ||
45 | define_arm_cp_regs(cpu, vhe_reginfo); | ||
46 | } | ||
129 | -- | 47 | -- |
130 | 2.20.1 | 48 | 2.25.1 |
131 | |||
132 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Disable unsupported FDT firmware nodes if a user passes us | 3 | Previously we were defining some of these in user-only mode, |
4 | a DTB with nodes enabled that the machine cannot support | 4 | but none of them are accessible from user-only, therefore |
5 | due to lack of EL3 or EL2 support. | 5 | define them only in system mode. |
6 | 6 | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | This will shortly be used from cpu_tcg.c also. |
8 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | |
9 | Message-id: 20200423121114.4274-5-edgar.iglesias@gmail.com | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220506180242.216785-6-richard.henderson@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 | hw/arm/xlnx-zcu102.c | 30 ++++++++++++++++++++++++++++++ | 14 | target/arm/internals.h | 6 ++++ |
13 | 1 file changed, 30 insertions(+) | 15 | target/arm/cpu64.c | 64 +++--------------------------------------- |
14 | 16 | target/arm/cpu_tcg.c | 59 ++++++++++++++++++++++++++++++++++++++ | |
15 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c | 17 | 3 files changed, 69 insertions(+), 60 deletions(-) |
18 | |||
19 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/xlnx-zcu102.c | 21 | --- a/target/arm/internals.h |
18 | +++ b/hw/arm/xlnx-zcu102.c | 22 | +++ b/target/arm/internals.h |
23 | @@ -XXX,XX +XXX,XX @@ int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
24 | int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
25 | #endif | ||
26 | |||
27 | +#ifdef CONFIG_USER_ONLY | ||
28 | +static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } | ||
29 | +#else | ||
30 | +void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); | ||
31 | +#endif | ||
32 | + | ||
33 | #endif | ||
34 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/cpu64.c | ||
37 | +++ b/target/arm/cpu64.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | 38 | @@ -XXX,XX +XXX,XX @@ |
20 | #include "qemu/error-report.h" | 39 | #include "hvf_arm.h" |
21 | #include "qemu/log.h" | 40 | #include "qapi/visitor.h" |
22 | #include "sysemu/qtest.h" | 41 | #include "hw/qdev-properties.h" |
23 | +#include "sysemu/device_tree.h" | 42 | -#include "cpregs.h" |
24 | 43 | +#include "internals.h" | |
25 | typedef struct XlnxZCU102 { | 44 | |
26 | MachineState parent_obj; | 45 | |
27 | @@ -XXX,XX +XXX,XX @@ static void zcu102_set_virt(Object *obj, bool value, Error **errp) | 46 | -#ifndef CONFIG_USER_ONLY |
28 | s->virt = value; | 47 | -static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
48 | -{ | ||
49 | - ARMCPU *cpu = env_archcpu(env); | ||
50 | - | ||
51 | - /* Number of cores is in [25:24]; otherwise we RAZ */ | ||
52 | - return (cpu->core_count - 1) << 24; | ||
53 | -} | ||
54 | -#endif | ||
55 | - | ||
56 | -static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | ||
57 | -#ifndef CONFIG_USER_ONLY | ||
58 | - { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
59 | - .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2, | ||
60 | - .access = PL1_RW, .readfn = a57_a53_l2ctlr_read, | ||
61 | - .writefn = arm_cp_write_ignore }, | ||
62 | - { .name = "L2CTLR", | ||
63 | - .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2, | ||
64 | - .access = PL1_RW, .readfn = a57_a53_l2ctlr_read, | ||
65 | - .writefn = arm_cp_write_ignore }, | ||
66 | -#endif | ||
67 | - { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
68 | - .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3, | ||
69 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
70 | - { .name = "L2ECTLR", | ||
71 | - .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3, | ||
72 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
73 | - { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH, | ||
74 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0, | ||
75 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
76 | - { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
77 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0, | ||
78 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | - { .name = "CPUACTLR", | ||
80 | - .cp = 15, .opc1 = 0, .crm = 15, | ||
81 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
82 | - { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
83 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1, | ||
84 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
85 | - { .name = "CPUECTLR", | ||
86 | - .cp = 15, .opc1 = 1, .crm = 15, | ||
87 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
88 | - { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
89 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2, | ||
90 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
91 | - { .name = "CPUMERRSR", | ||
92 | - .cp = 15, .opc1 = 2, .crm = 15, | ||
93 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
94 | - { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
95 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3, | ||
96 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
97 | - { .name = "L2MERRSR", | ||
98 | - .cp = 15, .opc1 = 3, .crm = 15, | ||
99 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
100 | -}; | ||
101 | - | ||
102 | static void aarch64_a57_initfn(Object *obj) | ||
103 | { | ||
104 | ARMCPU *cpu = ARM_CPU(obj); | ||
105 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
106 | cpu->gic_num_lrs = 4; | ||
107 | cpu->gic_vpribits = 5; | ||
108 | cpu->gic_vprebits = 5; | ||
109 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
110 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
29 | } | 111 | } |
30 | 112 | ||
31 | +static void zcu102_modify_dtb(const struct arm_boot_info *binfo, void *fdt) | 113 | static void aarch64_a53_initfn(Object *obj) |
114 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
115 | cpu->gic_num_lrs = 4; | ||
116 | cpu->gic_vpribits = 5; | ||
117 | cpu->gic_vprebits = 5; | ||
118 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
119 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
120 | } | ||
121 | |||
122 | static void aarch64_a72_initfn(Object *obj) | ||
123 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
124 | cpu->gic_num_lrs = 4; | ||
125 | cpu->gic_vpribits = 5; | ||
126 | cpu->gic_vprebits = 5; | ||
127 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
128 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
129 | } | ||
130 | |||
131 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
132 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/target/arm/cpu_tcg.c | ||
135 | +++ b/target/arm/cpu_tcg.c | ||
136 | @@ -XXX,XX +XXX,XX @@ | ||
137 | #endif | ||
138 | #include "cpregs.h" | ||
139 | |||
140 | +#ifndef CONFIG_USER_ONLY | ||
141 | +static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
32 | +{ | 142 | +{ |
33 | + XlnxZCU102 *s = container_of(binfo, XlnxZCU102, binfo); | 143 | + ARMCPU *cpu = env_archcpu(env); |
34 | + bool method_is_hvc; | 144 | + |
35 | + char **node_path; | 145 | + /* Number of cores is in [25:24]; otherwise we RAZ */ |
36 | + const char *r; | 146 | + return (cpu->core_count - 1) << 24; |
37 | + int prop_len; | ||
38 | + int i; | ||
39 | + | ||
40 | + /* If EL3 is enabled, we keep all firmware nodes active. */ | ||
41 | + if (!s->secure) { | ||
42 | + node_path = qemu_fdt_node_path(fdt, NULL, "xlnx,zynqmp-firmware", | ||
43 | + &error_fatal); | ||
44 | + | ||
45 | + for (i = 0; node_path && node_path[i]; i++) { | ||
46 | + r = qemu_fdt_getprop(fdt, node_path[i], "method", &prop_len, NULL); | ||
47 | + method_is_hvc = r && !strcmp("hvc", r); | ||
48 | + | ||
49 | + /* Allow HVC based firmware if EL2 is enabled. */ | ||
50 | + if (method_is_hvc && s->virt) { | ||
51 | + continue; | ||
52 | + } | ||
53 | + qemu_fdt_setprop_string(fdt, node_path[i], "status", "disabled"); | ||
54 | + } | ||
55 | + g_strfreev(node_path); | ||
56 | + } | ||
57 | +} | 147 | +} |
58 | + | 148 | + |
59 | static void xlnx_zcu102_init(MachineState *machine) | 149 | +static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { |
60 | { | 150 | + { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64, |
61 | XlnxZCU102 *s = ZCU102_MACHINE(machine); | 151 | + .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2, |
62 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_init(MachineState *machine) | 152 | + .access = PL1_RW, .readfn = l2ctlr_read, |
63 | 153 | + .writefn = arm_cp_write_ignore }, | |
64 | s->binfo.ram_size = ram_size; | 154 | + { .name = "L2CTLR", |
65 | s->binfo.loader_start = 0; | 155 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2, |
66 | + s->binfo.modify_dtb = zcu102_modify_dtb; | 156 | + .access = PL1_RW, .readfn = l2ctlr_read, |
67 | arm_load_kernel(s->soc.boot_cpu_ptr, machine, &s->binfo); | 157 | + .writefn = arm_cp_write_ignore }, |
68 | } | 158 | + { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64, |
159 | + .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3, | ||
160 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
161 | + { .name = "L2ECTLR", | ||
162 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3, | ||
163 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
164 | + { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH, | ||
165 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0, | ||
166 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
167 | + { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
168 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0, | ||
169 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
170 | + { .name = "CPUACTLR", | ||
171 | + .cp = 15, .opc1 = 0, .crm = 15, | ||
172 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
173 | + { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
174 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1, | ||
175 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
176 | + { .name = "CPUECTLR", | ||
177 | + .cp = 15, .opc1 = 1, .crm = 15, | ||
178 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
179 | + { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
180 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2, | ||
181 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
182 | + { .name = "CPUMERRSR", | ||
183 | + .cp = 15, .opc1 = 2, .crm = 15, | ||
184 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
185 | + { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
186 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3, | ||
187 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
188 | + { .name = "L2MERRSR", | ||
189 | + .cp = 15, .opc1 = 3, .crm = 15, | ||
190 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
191 | +}; | ||
192 | + | ||
193 | +void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) | ||
194 | +{ | ||
195 | + define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
196 | +} | ||
197 | +#endif /* !CONFIG_USER_ONLY */ | ||
198 | + | ||
199 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
200 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
69 | 201 | ||
70 | -- | 202 | -- |
71 | 2.20.1 | 203 | 2.25.1 |
72 | |||
73 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Setup the ADMA with 128bit bus-width. This matters when | 3 | Instead of starting with cortex-a15 and adding v8 features to |
4 | FIXED BURST mode is used. | 4 | a v7 cpu, begin with a v8 cpu stripped of its aarch64 features. |
5 | This fixes the long-standing to-do where we only enabled v8 | ||
6 | features for user-only. | ||
5 | 7 | ||
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 10 | Message-id: 20220506180242.216785-7-richard.henderson@linaro.org |
9 | Message-id: 20200417153800.27399-2-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 12 | --- |
12 | hw/arm/xlnx-versal.c | 2 ++ | 13 | target/arm/cpu_tcg.c | 151 ++++++++++++++++++++++++++----------------- |
13 | 1 file changed, 2 insertions(+) | 14 | 1 file changed, 92 insertions(+), 59 deletions(-) |
14 | 15 | ||
15 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 16 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/xlnx-versal.c | 18 | --- a/target/arm/cpu_tcg.c |
18 | +++ b/hw/arm/xlnx-versal.c | 19 | +++ b/target/arm/cpu_tcg.c |
19 | @@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic) | 20 | @@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data) |
20 | 21 | static void arm_max_initfn(Object *obj) | |
21 | dev = qdev_create(NULL, "xlnx.zdma"); | 22 | { |
22 | s->lpd.iou.adma[i] = SYS_BUS_DEVICE(dev); | 23 | ARMCPU *cpu = ARM_CPU(obj); |
23 | + object_property_set_int(OBJECT(s->lpd.iou.adma[i]), 128, "bus-width", | 24 | + uint32_t t; |
24 | + &error_abort); | 25 | |
25 | object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal); | 26 | - cortex_a15_initfn(obj); |
26 | qdev_init_nofail(dev); | 27 | + /* aarch64_a57_initfn, advertising none of the aarch64 features */ |
28 | + cpu->dtb_compatible = "arm,cortex-a57"; | ||
29 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
30 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
31 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
32 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
33 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
34 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
35 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
36 | + cpu->midr = 0x411fd070; | ||
37 | + cpu->revidr = 0x00000000; | ||
38 | + cpu->reset_fpsid = 0x41034070; | ||
39 | + cpu->isar.mvfr0 = 0x10110222; | ||
40 | + cpu->isar.mvfr1 = 0x12111111; | ||
41 | + cpu->isar.mvfr2 = 0x00000043; | ||
42 | + cpu->ctr = 0x8444c004; | ||
43 | + cpu->reset_sctlr = 0x00c50838; | ||
44 | + cpu->isar.id_pfr0 = 0x00000131; | ||
45 | + cpu->isar.id_pfr1 = 0x00011011; | ||
46 | + cpu->isar.id_dfr0 = 0x03010066; | ||
47 | + cpu->id_afr0 = 0x00000000; | ||
48 | + cpu->isar.id_mmfr0 = 0x10101105; | ||
49 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
50 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
51 | + cpu->isar.id_mmfr3 = 0x02102211; | ||
52 | + cpu->isar.id_isar0 = 0x02101110; | ||
53 | + cpu->isar.id_isar1 = 0x13112111; | ||
54 | + cpu->isar.id_isar2 = 0x21232042; | ||
55 | + cpu->isar.id_isar3 = 0x01112131; | ||
56 | + cpu->isar.id_isar4 = 0x00011142; | ||
57 | + cpu->isar.id_isar5 = 0x00011121; | ||
58 | + cpu->isar.id_isar6 = 0; | ||
59 | + cpu->isar.dbgdidr = 0x3516d000; | ||
60 | + cpu->clidr = 0x0a200023; | ||
61 | + cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | ||
62 | + cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ | ||
63 | + cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ | ||
64 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
65 | |||
66 | - /* old-style VFP short-vector support */ | ||
67 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
68 | + /* Add additional features supported by QEMU */ | ||
69 | + t = cpu->isar.id_isar5; | ||
70 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
71 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
72 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
73 | + t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
74 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
75 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
76 | + cpu->isar.id_isar5 = t; | ||
77 | + | ||
78 | + t = cpu->isar.id_isar6; | ||
79 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
80 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
81 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
82 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
83 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
84 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
85 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
86 | + cpu->isar.id_isar6 = t; | ||
87 | + | ||
88 | + t = cpu->isar.mvfr1; | ||
89 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
90 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
91 | + cpu->isar.mvfr1 = t; | ||
92 | + | ||
93 | + t = cpu->isar.mvfr2; | ||
94 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
95 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
96 | + cpu->isar.mvfr2 = t; | ||
97 | + | ||
98 | + t = cpu->isar.id_mmfr3; | ||
99 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
100 | + cpu->isar.id_mmfr3 = t; | ||
101 | + | ||
102 | + t = cpu->isar.id_mmfr4; | ||
103 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
104 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
105 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
106 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
107 | + cpu->isar.id_mmfr4 = t; | ||
108 | + | ||
109 | + t = cpu->isar.id_pfr0; | ||
110 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
111 | + cpu->isar.id_pfr0 = t; | ||
112 | + | ||
113 | + t = cpu->isar.id_pfr2; | ||
114 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
115 | + cpu->isar.id_pfr2 = t; | ||
116 | |||
117 | #ifdef CONFIG_USER_ONLY | ||
118 | /* | ||
119 | - * We don't set these in system emulation mode for the moment, | ||
120 | - * since we don't correctly set (all of) the ID registers to | ||
121 | - * advertise them. | ||
122 | + * Break with true ARMv8 and add back old-style VFP short-vector support. | ||
123 | + * Only do this for user-mode, where -cpu max is the default, so that | ||
124 | + * older v6 and v7 programs are more likely to work without adjustment. | ||
125 | */ | ||
126 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
127 | - { | ||
128 | - uint32_t t; | ||
129 | - | ||
130 | - t = cpu->isar.id_isar5; | ||
131 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
132 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
133 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
134 | - t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
135 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
136 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
137 | - cpu->isar.id_isar5 = t; | ||
138 | - | ||
139 | - t = cpu->isar.id_isar6; | ||
140 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
141 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
142 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
143 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
144 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
145 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
146 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
147 | - cpu->isar.id_isar6 = t; | ||
148 | - | ||
149 | - t = cpu->isar.mvfr1; | ||
150 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
151 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
152 | - cpu->isar.mvfr1 = t; | ||
153 | - | ||
154 | - t = cpu->isar.mvfr2; | ||
155 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
156 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
157 | - cpu->isar.mvfr2 = t; | ||
158 | - | ||
159 | - t = cpu->isar.id_mmfr3; | ||
160 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
161 | - cpu->isar.id_mmfr3 = t; | ||
162 | - | ||
163 | - t = cpu->isar.id_mmfr4; | ||
164 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
165 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
166 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
167 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
168 | - cpu->isar.id_mmfr4 = t; | ||
169 | - | ||
170 | - t = cpu->isar.id_pfr0; | ||
171 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
172 | - cpu->isar.id_pfr0 = t; | ||
173 | - | ||
174 | - t = cpu->isar.id_pfr2; | ||
175 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
176 | - cpu->isar.id_pfr2 = t; | ||
177 | - } | ||
178 | -#endif /* CONFIG_USER_ONLY */ | ||
179 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
180 | +#endif | ||
181 | } | ||
182 | #endif /* !TARGET_AARCH64 */ | ||
27 | 183 | ||
28 | -- | 184 | -- |
29 | 2.20.1 | 185 | 2.25.1 |
30 | |||
31 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | We set this for qemu-system-aarch64, but failed to do so | ||
4 | for the strictly 32-bit emulation. | ||
5 | |||
6 | Fixes: 3bec78447a9 ("target/arm: Provide ARMv8.4-PMU in '-cpu max'") | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220506180242.216785-8-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu_tcg.c | 4 ++++ | ||
13 | 1 file changed, 4 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu_tcg.c | ||
18 | +++ b/target/arm/cpu_tcg.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
20 | t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
21 | cpu->isar.id_pfr2 = t; | ||
22 | |||
23 | + t = cpu->isar.id_dfr0; | ||
24 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
25 | + cpu->isar.id_dfr0 = t; | ||
26 | + | ||
27 | #ifdef CONFIG_USER_ONLY | ||
28 | /* | ||
29 | * Break with true ARMv8 and add back old-style VFP short-vector support. | ||
30 | -- | ||
31 | 2.25.1 | diff view generated by jsdifflib |
1 | This object may be used to represent a clock inside a clock tree. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | A clock may be connected to another clock so that it receives update, | 3 | Share the code to set AArch32 max features so that we no |
4 | through a callback, whenever the source/parent clock is updated. | 4 | longer have code drift between qemu{-system,}-{arm,aarch64}. |
5 | 5 | ||
6 | Although only the root clock of a clock tree controls the values | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | (represented as periods) of all clocks in tree, each clock holds | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | a local state containing the current value so that it can be fetched | 8 | Message-id: 20220506180242.216785-9-richard.henderson@linaro.org |
9 | independently. It will allows us to fullfill migration requirements | ||
10 | by migrating each clock independently of others. | ||
11 | |||
12 | This is based on the original work of Frederic Konrad. | ||
13 | |||
14 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
17 | Message-id: 20200406135251.157596-2-damien.hedde@greensocs.com | ||
18 | [PMM: Use uint64_t rather than unsigned long long in trace events; | ||
19 | the dtrace backend can't handle the latter] | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 10 | --- |
22 | hw/core/Makefile.objs | 1 + | 11 | target/arm/internals.h | 2 + |
23 | include/hw/clock.h | 216 ++++++++++++++++++++++++++++++++++++++++++ | 12 | target/arm/cpu64.c | 50 +----------------- |
24 | hw/core/clock.c | 130 +++++++++++++++++++++++++ | 13 | target/arm/cpu_tcg.c | 114 ++++++++++++++++++++++------------------- |
25 | hw/core/trace-events | 7 ++ | 14 | 3 files changed, 65 insertions(+), 101 deletions(-) |
26 | 4 files changed, 354 insertions(+) | ||
27 | create mode 100644 include/hw/clock.h | ||
28 | create mode 100644 hw/core/clock.c | ||
29 | 15 | ||
30 | diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
31 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/core/Makefile.objs | 18 | --- a/target/arm/internals.h |
33 | +++ b/hw/core/Makefile.objs | 19 | +++ b/target/arm/internals.h |
34 | @@ -XXX,XX +XXX,XX @@ common-obj-y += hotplug.o | 20 | @@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } |
35 | common-obj-y += vmstate-if.o | 21 | void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); |
36 | # irq.o needed for qdev GPIO handling: | 22 | #endif |
37 | common-obj-y += irq.o | 23 | |
38 | +common-obj-y += clock.o | 24 | +void aa32_max_features(ARMCPU *cpu); |
39 | 25 | + | |
40 | common-obj-$(CONFIG_SOFTMMU) += reset.o | 26 | #endif |
41 | common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o | 27 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
42 | diff --git a/include/hw/clock.h b/include/hw/clock.h | 28 | index XXXXXXX..XXXXXXX 100644 |
43 | new file mode 100644 | 29 | --- a/target/arm/cpu64.c |
44 | index XXXXXXX..XXXXXXX | 30 | +++ b/target/arm/cpu64.c |
45 | --- /dev/null | 31 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
46 | +++ b/include/hw/clock.h | 32 | { |
33 | ARMCPU *cpu = ARM_CPU(obj); | ||
34 | uint64_t t; | ||
35 | - uint32_t u; | ||
36 | |||
37 | if (kvm_enabled() || hvf_enabled()) { | ||
38 | /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ | ||
39 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
40 | t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); | ||
41 | cpu->isar.id_aa64zfr0 = t; | ||
42 | |||
43 | - /* Replicate the same data to the 32-bit id registers. */ | ||
44 | - u = cpu->isar.id_isar5; | ||
45 | - u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */ | ||
46 | - u = FIELD_DP32(u, ID_ISAR5, SHA1, 1); | ||
47 | - u = FIELD_DP32(u, ID_ISAR5, SHA2, 1); | ||
48 | - u = FIELD_DP32(u, ID_ISAR5, CRC32, 1); | ||
49 | - u = FIELD_DP32(u, ID_ISAR5, RDM, 1); | ||
50 | - u = FIELD_DP32(u, ID_ISAR5, VCMA, 1); | ||
51 | - cpu->isar.id_isar5 = u; | ||
52 | - | ||
53 | - u = cpu->isar.id_isar6; | ||
54 | - u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1); | ||
55 | - u = FIELD_DP32(u, ID_ISAR6, DP, 1); | ||
56 | - u = FIELD_DP32(u, ID_ISAR6, FHM, 1); | ||
57 | - u = FIELD_DP32(u, ID_ISAR6, SB, 1); | ||
58 | - u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); | ||
59 | - u = FIELD_DP32(u, ID_ISAR6, BF16, 1); | ||
60 | - u = FIELD_DP32(u, ID_ISAR6, I8MM, 1); | ||
61 | - cpu->isar.id_isar6 = u; | ||
62 | - | ||
63 | - u = cpu->isar.id_pfr0; | ||
64 | - u = FIELD_DP32(u, ID_PFR0, DIT, 1); | ||
65 | - cpu->isar.id_pfr0 = u; | ||
66 | - | ||
67 | - u = cpu->isar.id_pfr2; | ||
68 | - u = FIELD_DP32(u, ID_PFR2, SSBS, 1); | ||
69 | - cpu->isar.id_pfr2 = u; | ||
70 | - | ||
71 | - u = cpu->isar.id_mmfr3; | ||
72 | - u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
73 | - cpu->isar.id_mmfr3 = u; | ||
74 | - | ||
75 | - u = cpu->isar.id_mmfr4; | ||
76 | - u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
77 | - u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
78 | - u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
79 | - u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
80 | - cpu->isar.id_mmfr4 = u; | ||
81 | - | ||
82 | t = cpu->isar.id_aa64dfr0; | ||
83 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
84 | cpu->isar.id_aa64dfr0 = t; | ||
85 | |||
86 | - u = cpu->isar.id_dfr0; | ||
87 | - u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
88 | - cpu->isar.id_dfr0 = u; | ||
89 | - | ||
90 | - u = cpu->isar.mvfr1; | ||
91 | - u = FIELD_DP32(u, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
92 | - u = FIELD_DP32(u, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
93 | - cpu->isar.mvfr1 = u; | ||
94 | + /* Replicate the same data to the 32-bit id registers. */ | ||
95 | + aa32_max_features(cpu); | ||
96 | |||
97 | #ifdef CONFIG_USER_ONLY | ||
98 | /* | ||
99 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/arm/cpu_tcg.c | ||
102 | +++ b/target/arm/cpu_tcg.c | ||
47 | @@ -XXX,XX +XXX,XX @@ | 103 | @@ -XXX,XX +XXX,XX @@ |
48 | +/* | 104 | #endif |
49 | + * Hardware Clocks | 105 | #include "cpregs.h" |
50 | + * | 106 | |
51 | + * Copyright GreenSocs 2016-2020 | 107 | + |
52 | + * | 108 | +/* Share AArch32 -cpu max features with AArch64. */ |
53 | + * Authors: | 109 | +void aa32_max_features(ARMCPU *cpu) |
54 | + * Frederic Konrad | ||
55 | + * Damien Hedde | ||
56 | + * | ||
57 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
58 | + * See the COPYING file in the top-level directory. | ||
59 | + */ | ||
60 | + | ||
61 | +#ifndef QEMU_HW_CLOCK_H | ||
62 | +#define QEMU_HW_CLOCK_H | ||
63 | + | ||
64 | +#include "qom/object.h" | ||
65 | +#include "qemu/queue.h" | ||
66 | + | ||
67 | +#define TYPE_CLOCK "clock" | ||
68 | +#define CLOCK(obj) OBJECT_CHECK(Clock, (obj), TYPE_CLOCK) | ||
69 | + | ||
70 | +typedef void ClockCallback(void *opaque); | ||
71 | + | ||
72 | +/* | ||
73 | + * clock store a value representing the clock's period in 2^-32ns unit. | ||
74 | + * It can represent: | ||
75 | + * + periods from 2^-32ns up to 4seconds | ||
76 | + * + frequency from ~0.25Hz 2e10Ghz | ||
77 | + * Resolution of frequency representation decreases with frequency: | ||
78 | + * + at 100MHz, resolution is ~2mHz | ||
79 | + * + at 1Ghz, resolution is ~0.2Hz | ||
80 | + * + at 10Ghz, resolution is ~20Hz | ||
81 | + */ | ||
82 | +#define CLOCK_SECOND (1000000000llu << 32) | ||
83 | + | ||
84 | +/* | ||
85 | + * macro helpers to convert to hertz / nanosecond | ||
86 | + */ | ||
87 | +#define CLOCK_PERIOD_FROM_NS(ns) ((ns) * (CLOCK_SECOND / 1000000000llu)) | ||
88 | +#define CLOCK_PERIOD_TO_NS(per) ((per) / (CLOCK_SECOND / 1000000000llu)) | ||
89 | +#define CLOCK_PERIOD_FROM_HZ(hz) (((hz) != 0) ? CLOCK_SECOND / (hz) : 0u) | ||
90 | +#define CLOCK_PERIOD_TO_HZ(per) (((per) != 0) ? CLOCK_SECOND / (per) : 0u) | ||
91 | + | ||
92 | +/** | ||
93 | + * Clock: | ||
94 | + * @parent_obj: parent class | ||
95 | + * @period: unsigned integer representing the period of the clock | ||
96 | + * @canonical_path: clock path string cache (used for trace purpose) | ||
97 | + * @callback: called when clock changes | ||
98 | + * @callback_opaque: argument for @callback | ||
99 | + * @source: source (or parent in clock tree) of the clock | ||
100 | + * @children: list of clocks connected to this one (it is their source) | ||
101 | + * @sibling: structure used to form a clock list | ||
102 | + */ | ||
103 | + | ||
104 | +typedef struct Clock Clock; | ||
105 | + | ||
106 | +struct Clock { | ||
107 | + /*< private >*/ | ||
108 | + Object parent_obj; | ||
109 | + | ||
110 | + /* all fields are private and should not be modified directly */ | ||
111 | + | ||
112 | + /* fields */ | ||
113 | + uint64_t period; | ||
114 | + char *canonical_path; | ||
115 | + ClockCallback *callback; | ||
116 | + void *callback_opaque; | ||
117 | + | ||
118 | + /* Clocks are organized in a clock tree */ | ||
119 | + Clock *source; | ||
120 | + QLIST_HEAD(, Clock) children; | ||
121 | + QLIST_ENTRY(Clock) sibling; | ||
122 | +}; | ||
123 | + | ||
124 | +/** | ||
125 | + * clock_setup_canonical_path: | ||
126 | + * @clk: clock | ||
127 | + * | ||
128 | + * compute the canonical path of the clock (used by log messages) | ||
129 | + */ | ||
130 | +void clock_setup_canonical_path(Clock *clk); | ||
131 | + | ||
132 | +/** | ||
133 | + * clock_set_callback: | ||
134 | + * @clk: the clock to register the callback into | ||
135 | + * @cb: the callback function | ||
136 | + * @opaque: the argument to the callback | ||
137 | + * | ||
138 | + * Register a callback called on every clock update. | ||
139 | + */ | ||
140 | +void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque); | ||
141 | + | ||
142 | +/** | ||
143 | + * clock_clear_callback: | ||
144 | + * @clk: the clock to delete the callback from | ||
145 | + * | ||
146 | + * Unregister the callback registered with clock_set_callback. | ||
147 | + */ | ||
148 | +void clock_clear_callback(Clock *clk); | ||
149 | + | ||
150 | +/** | ||
151 | + * clock_set_source: | ||
152 | + * @clk: the clock. | ||
153 | + * @src: the source clock | ||
154 | + * | ||
155 | + * Setup @src as the clock source of @clk. The current @src period | ||
156 | + * value is also copied to @clk and its subtree but no callback is | ||
157 | + * called. | ||
158 | + * Further @src update will be propagated to @clk and its subtree. | ||
159 | + */ | ||
160 | +void clock_set_source(Clock *clk, Clock *src); | ||
161 | + | ||
162 | +/** | ||
163 | + * clock_set: | ||
164 | + * @clk: the clock to initialize. | ||
165 | + * @value: the clock's value, 0 means unclocked | ||
166 | + * | ||
167 | + * Set the local cached period value of @clk to @value. | ||
168 | + */ | ||
169 | +void clock_set(Clock *clk, uint64_t value); | ||
170 | + | ||
171 | +static inline void clock_set_hz(Clock *clk, unsigned hz) | ||
172 | +{ | 110 | +{ |
173 | + clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz)); | 111 | + uint32_t t; |
112 | + | ||
113 | + /* Add additional features supported by QEMU */ | ||
114 | + t = cpu->isar.id_isar5; | ||
115 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
116 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
117 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
118 | + t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
119 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
120 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
121 | + cpu->isar.id_isar5 = t; | ||
122 | + | ||
123 | + t = cpu->isar.id_isar6; | ||
124 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
125 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
126 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
127 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
128 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
129 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
130 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
131 | + cpu->isar.id_isar6 = t; | ||
132 | + | ||
133 | + t = cpu->isar.mvfr1; | ||
134 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
135 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
136 | + cpu->isar.mvfr1 = t; | ||
137 | + | ||
138 | + t = cpu->isar.mvfr2; | ||
139 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
140 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
141 | + cpu->isar.mvfr2 = t; | ||
142 | + | ||
143 | + t = cpu->isar.id_mmfr3; | ||
144 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
145 | + cpu->isar.id_mmfr3 = t; | ||
146 | + | ||
147 | + t = cpu->isar.id_mmfr4; | ||
148 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
149 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
150 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
151 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
152 | + cpu->isar.id_mmfr4 = t; | ||
153 | + | ||
154 | + t = cpu->isar.id_pfr0; | ||
155 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
156 | + cpu->isar.id_pfr0 = t; | ||
157 | + | ||
158 | + t = cpu->isar.id_pfr2; | ||
159 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
160 | + cpu->isar.id_pfr2 = t; | ||
161 | + | ||
162 | + t = cpu->isar.id_dfr0; | ||
163 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
164 | + cpu->isar.id_dfr0 = t; | ||
174 | +} | 165 | +} |
175 | + | 166 | + |
176 | +static inline void clock_set_ns(Clock *clk, unsigned ns) | 167 | #ifndef CONFIG_USER_ONLY |
177 | +{ | 168 | static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
178 | + clock_set(clk, CLOCK_PERIOD_FROM_NS(ns)); | 169 | { |
179 | +} | 170 | @@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data) |
180 | + | 171 | static void arm_max_initfn(Object *obj) |
181 | +/** | 172 | { |
182 | + * clock_propagate: | 173 | ARMCPU *cpu = ARM_CPU(obj); |
183 | + * @clk: the clock | 174 | - uint32_t t; |
184 | + * | 175 | |
185 | + * Propagate the clock period that has been previously configured using | 176 | /* aarch64_a57_initfn, advertising none of the aarch64 features */ |
186 | + * @clock_set(). This will update recursively all connected clocks. | 177 | cpu->dtb_compatible = "arm,cortex-a57"; |
187 | + * It is an error to call this function on a clock which has a source. | 178 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) |
188 | + * Note: this function must not be called during device inititialization | 179 | cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ |
189 | + * or migration. | 180 | define_cortex_a72_a57_a53_cp_reginfo(cpu); |
190 | + */ | 181 | |
191 | +void clock_propagate(Clock *clk); | 182 | - /* Add additional features supported by QEMU */ |
192 | + | 183 | - t = cpu->isar.id_isar5; |
193 | +/** | 184 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); |
194 | + * clock_update: | 185 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); |
195 | + * @clk: the clock to update. | 186 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); |
196 | + * @value: the new clock's value, 0 means unclocked | 187 | - t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); |
197 | + * | 188 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); |
198 | + * Update the @clk to the new @value. All connected clocks will be informed | 189 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); |
199 | + * of this update. This is equivalent to call @clock_set() then | 190 | - cpu->isar.id_isar5 = t; |
200 | + * @clock_propagate(). | 191 | - |
201 | + */ | 192 | - t = cpu->isar.id_isar6; |
202 | +static inline void clock_update(Clock *clk, uint64_t value) | 193 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); |
203 | +{ | 194 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); |
204 | + clock_set(clk, value); | 195 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); |
205 | + clock_propagate(clk); | 196 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); |
206 | +} | 197 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); |
207 | + | 198 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); |
208 | +static inline void clock_update_hz(Clock *clk, unsigned hz) | 199 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); |
209 | +{ | 200 | - cpu->isar.id_isar6 = t; |
210 | + clock_update(clk, CLOCK_PERIOD_FROM_HZ(hz)); | 201 | - |
211 | +} | 202 | - t = cpu->isar.mvfr1; |
212 | + | 203 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ |
213 | +static inline void clock_update_ns(Clock *clk, unsigned ns) | 204 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ |
214 | +{ | 205 | - cpu->isar.mvfr1 = t; |
215 | + clock_update(clk, CLOCK_PERIOD_FROM_NS(ns)); | 206 | - |
216 | +} | 207 | - t = cpu->isar.mvfr2; |
217 | + | 208 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ |
218 | +/** | 209 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ |
219 | + * clock_get: | 210 | - cpu->isar.mvfr2 = t; |
220 | + * @clk: the clk to fetch the clock | 211 | - |
221 | + * | 212 | - t = cpu->isar.id_mmfr3; |
222 | + * @return: the current period. | 213 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ |
223 | + */ | 214 | - cpu->isar.id_mmfr3 = t; |
224 | +static inline uint64_t clock_get(const Clock *clk) | 215 | - |
225 | +{ | 216 | - t = cpu->isar.id_mmfr4; |
226 | + return clk->period; | 217 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ |
227 | +} | 218 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ |
228 | + | 219 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ |
229 | +static inline unsigned clock_get_hz(Clock *clk) | 220 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ |
230 | +{ | 221 | - cpu->isar.id_mmfr4 = t; |
231 | + return CLOCK_PERIOD_TO_HZ(clock_get(clk)); | 222 | - |
232 | +} | 223 | - t = cpu->isar.id_pfr0; |
233 | + | 224 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); |
234 | +static inline unsigned clock_get_ns(Clock *clk) | 225 | - cpu->isar.id_pfr0 = t; |
235 | +{ | 226 | - |
236 | + return CLOCK_PERIOD_TO_NS(clock_get(clk)); | 227 | - t = cpu->isar.id_pfr2; |
237 | +} | 228 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); |
238 | + | 229 | - cpu->isar.id_pfr2 = t; |
239 | +/** | 230 | - |
240 | + * clock_is_enabled: | 231 | - t = cpu->isar.id_dfr0; |
241 | + * @clk: a clock | 232 | - t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ |
242 | + * | 233 | - cpu->isar.id_dfr0 = t; |
243 | + * @return: true if the clock is running. | 234 | + aa32_max_features(cpu); |
244 | + */ | 235 | |
245 | +static inline bool clock_is_enabled(const Clock *clk) | 236 | #ifdef CONFIG_USER_ONLY |
246 | +{ | 237 | /* |
247 | + return clock_get(clk) != 0; | ||
248 | +} | ||
249 | + | ||
250 | +static inline void clock_init(Clock *clk, uint64_t value) | ||
251 | +{ | ||
252 | + clock_set(clk, value); | ||
253 | +} | ||
254 | +static inline void clock_init_hz(Clock *clk, uint64_t value) | ||
255 | +{ | ||
256 | + clock_set_hz(clk, value); | ||
257 | +} | ||
258 | +static inline void clock_init_ns(Clock *clk, uint64_t value) | ||
259 | +{ | ||
260 | + clock_set_ns(clk, value); | ||
261 | +} | ||
262 | + | ||
263 | +#endif /* QEMU_HW_CLOCK_H */ | ||
264 | diff --git a/hw/core/clock.c b/hw/core/clock.c | ||
265 | new file mode 100644 | ||
266 | index XXXXXXX..XXXXXXX | ||
267 | --- /dev/null | ||
268 | +++ b/hw/core/clock.c | ||
269 | @@ -XXX,XX +XXX,XX @@ | ||
270 | +/* | ||
271 | + * Hardware Clocks | ||
272 | + * | ||
273 | + * Copyright GreenSocs 2016-2020 | ||
274 | + * | ||
275 | + * Authors: | ||
276 | + * Frederic Konrad | ||
277 | + * Damien Hedde | ||
278 | + * | ||
279 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
280 | + * See the COPYING file in the top-level directory. | ||
281 | + */ | ||
282 | + | ||
283 | +#include "qemu/osdep.h" | ||
284 | +#include "hw/clock.h" | ||
285 | +#include "trace.h" | ||
286 | + | ||
287 | +#define CLOCK_PATH(_clk) (_clk->canonical_path) | ||
288 | + | ||
289 | +void clock_setup_canonical_path(Clock *clk) | ||
290 | +{ | ||
291 | + g_free(clk->canonical_path); | ||
292 | + clk->canonical_path = object_get_canonical_path(OBJECT(clk)); | ||
293 | +} | ||
294 | + | ||
295 | +void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque) | ||
296 | +{ | ||
297 | + clk->callback = cb; | ||
298 | + clk->callback_opaque = opaque; | ||
299 | +} | ||
300 | + | ||
301 | +void clock_clear_callback(Clock *clk) | ||
302 | +{ | ||
303 | + clock_set_callback(clk, NULL, NULL); | ||
304 | +} | ||
305 | + | ||
306 | +void clock_set(Clock *clk, uint64_t period) | ||
307 | +{ | ||
308 | + trace_clock_set(CLOCK_PATH(clk), CLOCK_PERIOD_TO_NS(clk->period), | ||
309 | + CLOCK_PERIOD_TO_NS(period)); | ||
310 | + clk->period = period; | ||
311 | +} | ||
312 | + | ||
313 | +static void clock_propagate_period(Clock *clk, bool call_callbacks) | ||
314 | +{ | ||
315 | + Clock *child; | ||
316 | + | ||
317 | + QLIST_FOREACH(child, &clk->children, sibling) { | ||
318 | + if (child->period != clk->period) { | ||
319 | + child->period = clk->period; | ||
320 | + trace_clock_update(CLOCK_PATH(child), CLOCK_PATH(clk), | ||
321 | + CLOCK_PERIOD_TO_NS(clk->period), | ||
322 | + call_callbacks); | ||
323 | + if (call_callbacks && child->callback) { | ||
324 | + child->callback(child->callback_opaque); | ||
325 | + } | ||
326 | + clock_propagate_period(child, call_callbacks); | ||
327 | + } | ||
328 | + } | ||
329 | +} | ||
330 | + | ||
331 | +void clock_propagate(Clock *clk) | ||
332 | +{ | ||
333 | + assert(clk->source == NULL); | ||
334 | + trace_clock_propagate(CLOCK_PATH(clk)); | ||
335 | + clock_propagate_period(clk, true); | ||
336 | +} | ||
337 | + | ||
338 | +void clock_set_source(Clock *clk, Clock *src) | ||
339 | +{ | ||
340 | + /* changing clock source is not supported */ | ||
341 | + assert(!clk->source); | ||
342 | + | ||
343 | + trace_clock_set_source(CLOCK_PATH(clk), CLOCK_PATH(src)); | ||
344 | + | ||
345 | + clk->period = src->period; | ||
346 | + QLIST_INSERT_HEAD(&src->children, clk, sibling); | ||
347 | + clk->source = src; | ||
348 | + clock_propagate_period(clk, false); | ||
349 | +} | ||
350 | + | ||
351 | +static void clock_disconnect(Clock *clk) | ||
352 | +{ | ||
353 | + if (clk->source == NULL) { | ||
354 | + return; | ||
355 | + } | ||
356 | + | ||
357 | + trace_clock_disconnect(CLOCK_PATH(clk)); | ||
358 | + | ||
359 | + clk->source = NULL; | ||
360 | + QLIST_REMOVE(clk, sibling); | ||
361 | +} | ||
362 | + | ||
363 | +static void clock_initfn(Object *obj) | ||
364 | +{ | ||
365 | + Clock *clk = CLOCK(obj); | ||
366 | + | ||
367 | + QLIST_INIT(&clk->children); | ||
368 | +} | ||
369 | + | ||
370 | +static void clock_finalizefn(Object *obj) | ||
371 | +{ | ||
372 | + Clock *clk = CLOCK(obj); | ||
373 | + Clock *child, *next; | ||
374 | + | ||
375 | + /* clear our list of children */ | ||
376 | + QLIST_FOREACH_SAFE(child, &clk->children, sibling, next) { | ||
377 | + clock_disconnect(child); | ||
378 | + } | ||
379 | + | ||
380 | + /* remove us from source's children list */ | ||
381 | + clock_disconnect(clk); | ||
382 | + | ||
383 | + g_free(clk->canonical_path); | ||
384 | +} | ||
385 | + | ||
386 | +static const TypeInfo clock_info = { | ||
387 | + .name = TYPE_CLOCK, | ||
388 | + .parent = TYPE_OBJECT, | ||
389 | + .instance_size = sizeof(Clock), | ||
390 | + .instance_init = clock_initfn, | ||
391 | + .instance_finalize = clock_finalizefn, | ||
392 | +}; | ||
393 | + | ||
394 | +static void clock_register_types(void) | ||
395 | +{ | ||
396 | + type_register_static(&clock_info); | ||
397 | +} | ||
398 | + | ||
399 | +type_init(clock_register_types) | ||
400 | diff --git a/hw/core/trace-events b/hw/core/trace-events | ||
401 | index XXXXXXX..XXXXXXX 100644 | ||
402 | --- a/hw/core/trace-events | ||
403 | +++ b/hw/core/trace-events | ||
404 | @@ -XXX,XX +XXX,XX @@ resettable_phase_exit_begin(void *obj, const char *objtype, unsigned count, int | ||
405 | resettable_phase_exit_exec(void *obj, const char *objtype, int has_method) "obj=%p(%s) method=%d" | ||
406 | resettable_phase_exit_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d" | ||
407 | resettable_transitional_function(void *obj, const char *objtype) "obj=%p(%s)" | ||
408 | + | ||
409 | +# clock.c | ||
410 | +clock_set_source(const char *clk, const char *src) "'%s', src='%s'" | ||
411 | +clock_disconnect(const char *clk) "'%s'" | ||
412 | +clock_set(const char *clk, uint64_t old, uint64_t new) "'%s', ns=%"PRIu64"->%"PRIu64 | ||
413 | +clock_propagate(const char *clk) "'%s'" | ||
414 | +clock_update(const char *clk, const char *src, uint64_t val, int cb) "'%s', src='%s', ns=%"PRIu64", cb=%d" | ||
415 | -- | 238 | -- |
416 | 2.20.1 | 239 | 2.25.1 |
417 | |||
418 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Move arm_boot_info into XlnxZCU102. | 3 | Update the legacy feature names to the current names. |
4 | Provide feature names for id changes that were not marked. | ||
5 | Sort the field updates into increasing bitfield order. | ||
4 | 6 | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200423121114.4274-4-edgar.iglesias@gmail.com | 9 | Message-id: 20220506180242.216785-10-richard.henderson@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | hw/arm/xlnx-zcu102.c | 9 +++++---- | 12 | target/arm/cpu64.c | 100 +++++++++++++++++++++---------------------- |
11 | 1 file changed, 5 insertions(+), 4 deletions(-) | 13 | target/arm/cpu_tcg.c | 48 ++++++++++----------- |
14 | 2 files changed, 74 insertions(+), 74 deletions(-) | ||
12 | 15 | ||
13 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c | 16 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/xlnx-zcu102.c | 18 | --- a/target/arm/cpu64.c |
16 | +++ b/hw/arm/xlnx-zcu102.c | 19 | +++ b/target/arm/cpu64.c |
17 | @@ -XXX,XX +XXX,XX @@ typedef struct XlnxZCU102 { | 20 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
18 | 21 | cpu->midr = t; | |
19 | bool secure; | 22 | |
20 | bool virt; | 23 | t = cpu->isar.id_aa64isar0; |
21 | + | 24 | - t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ |
22 | + struct arm_boot_info binfo; | 25 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); |
23 | } XlnxZCU102; | 26 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* SHA512 */ |
24 | 27 | + t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ | |
25 | #define TYPE_ZCU102_MACHINE MACHINE_TYPE_NAME("xlnx-zcu102") | 28 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ |
26 | #define ZCU102_MACHINE(obj) \ | 29 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ |
27 | OBJECT_CHECK(XlnxZCU102, (obj), TYPE_ZCU102_MACHINE) | 30 | t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); |
28 | 31 | - t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); | |
29 | -static struct arm_boot_info xlnx_zcu102_binfo; | 32 | - t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); |
30 | 33 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); | |
31 | static bool zcu102_get_secure(Object *obj, Error **errp) | 34 | - t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); |
32 | { | 35 | - t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); |
33 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_init(MachineState *machine) | 36 | - t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); |
34 | 37 | - t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); | |
35 | /* TODO create and connect IDE devices for ide_drive_get() */ | 38 | - t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* v8.5-CondM */ |
36 | 39 | - t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */ | |
37 | - xlnx_zcu102_binfo.ram_size = ram_size; | 40 | - t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); |
38 | - xlnx_zcu102_binfo.loader_start = 0; | 41 | + t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */ |
39 | - arm_load_kernel(s->soc.boot_cpu_ptr, machine, &xlnx_zcu102_binfo); | 42 | + t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */ |
40 | + s->binfo.ram_size = ram_size; | 43 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */ |
41 | + s->binfo.loader_start = 0; | 44 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); /* FEAT_SM3 */ |
42 | + arm_load_kernel(s->soc.boot_cpu_ptr, machine, &s->binfo); | 45 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); /* FEAT_SM4 */ |
46 | + t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); /* FEAT_DotProd */ | ||
47 | + t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); /* FEAT_FHM */ | ||
48 | + t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* FEAT_FlagM2 */ | ||
49 | + t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */ | ||
50 | + t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); /* FEAT_RNG */ | ||
51 | cpu->isar.id_aa64isar0 = t; | ||
52 | |||
53 | t = cpu->isar.id_aa64isar1; | ||
54 | - t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); | ||
55 | - t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); | ||
56 | - t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | ||
57 | - t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); | ||
58 | - t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); | ||
59 | - t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); | ||
60 | - t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); | ||
61 | - t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* ARMv8.4-RCPC */ | ||
62 | - t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); | ||
63 | + t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */ | ||
64 | + t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */ | ||
65 | + t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); /* FEAT_FCMA */ | ||
66 | + t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* FEAT_LRCPC2 */ | ||
67 | + t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); /* FEAT_FRINTTS */ | ||
68 | + t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */ | ||
69 | + t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */ | ||
70 | + t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */ | ||
71 | + t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */ | ||
72 | cpu->isar.id_aa64isar1 = t; | ||
73 | |||
74 | t = cpu->isar.id_aa64pfr0; | ||
75 | + t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ | ||
76 | + t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ | ||
77 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
78 | - t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); | ||
79 | - t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); | ||
80 | - t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); | ||
81 | - t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); | ||
82 | + t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | ||
83 | + t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | ||
84 | cpu->isar.id_aa64pfr0 = t; | ||
85 | |||
86 | t = cpu->isar.id_aa64pfr1; | ||
87 | - t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); | ||
88 | - t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); | ||
89 | + t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); /* FEAT_BTI */ | ||
90 | + t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); /* FEAT_SSBS2 */ | ||
91 | /* | ||
92 | * Begin with full support for MTE. This will be downgraded to MTE=0 | ||
93 | * during realize if the board provides no tag memory, much like | ||
94 | * we do for EL2 with the virtualization=on property. | ||
95 | */ | ||
96 | - t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); | ||
97 | + t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ | ||
98 | cpu->isar.id_aa64pfr1 = t; | ||
99 | |||
100 | t = cpu->isar.id_aa64mmfr0; | ||
101 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
102 | cpu->isar.id_aa64mmfr0 = t; | ||
103 | |||
104 | t = cpu->isar.id_aa64mmfr1; | ||
105 | - t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ | ||
106 | - t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); | ||
107 | - t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); | ||
108 | - t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ | ||
109 | - t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */ | ||
110 | - t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */ | ||
111 | + t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ | ||
112 | + t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ | ||
113 | + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ | ||
114 | + t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ | ||
115 | + t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* FEAT_PAN2 */ | ||
116 | + t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ | ||
117 | cpu->isar.id_aa64mmfr1 = t; | ||
118 | |||
119 | t = cpu->isar.id_aa64mmfr2; | ||
120 | - t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); | ||
121 | - t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */ | ||
122 | - t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */ | ||
123 | - t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ | ||
124 | - t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
125 | - t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ | ||
126 | + t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */ | ||
127 | + t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */ | ||
128 | + t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ | ||
129 | + t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */ | ||
130 | + t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
131 | + t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ | ||
132 | cpu->isar.id_aa64mmfr2 = t; | ||
133 | |||
134 | t = cpu->isar.id_aa64zfr0; | ||
135 | t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1); | ||
136 | - t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* PMULL */ | ||
137 | - t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); | ||
138 | - t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); | ||
139 | - t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); | ||
140 | - t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); | ||
141 | - t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); | ||
142 | - t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); | ||
143 | - t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); | ||
144 | + t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* FEAT_SVE_PMULL128 */ | ||
145 | + t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); /* FEAT_SVE_BitPerm */ | ||
146 | + t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); /* FEAT_BF16 */ | ||
147 | + t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); /* FEAT_SVE_SHA3 */ | ||
148 | + t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); /* FEAT_SVE_SM4 */ | ||
149 | + t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); /* FEAT_I8MM */ | ||
150 | + t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); /* FEAT_F32MM */ | ||
151 | + t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); /* FEAT_F64MM */ | ||
152 | cpu->isar.id_aa64zfr0 = t; | ||
153 | |||
154 | t = cpu->isar.id_aa64dfr0; | ||
155 | - t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
156 | + t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ | ||
157 | cpu->isar.id_aa64dfr0 = t; | ||
158 | |||
159 | /* Replicate the same data to the 32-bit id registers. */ | ||
160 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
161 | index XXXXXXX..XXXXXXX 100644 | ||
162 | --- a/target/arm/cpu_tcg.c | ||
163 | +++ b/target/arm/cpu_tcg.c | ||
164 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
165 | |||
166 | /* Add additional features supported by QEMU */ | ||
167 | t = cpu->isar.id_isar5; | ||
168 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
169 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
170 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
171 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); /* FEAT_PMULL */ | ||
172 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); /* FEAT_SHA1 */ | ||
173 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); /* FEAT_SHA256 */ | ||
174 | t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
175 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
176 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
177 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); /* FEAT_RDM */ | ||
178 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); /* FEAT_FCMA */ | ||
179 | cpu->isar.id_isar5 = t; | ||
180 | |||
181 | t = cpu->isar.id_isar6; | ||
182 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
183 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
184 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
185 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
186 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
187 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
188 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
189 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); /* FEAT_JSCVT */ | ||
190 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); /* Feat_DotProd */ | ||
191 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); /* FEAT_FHM */ | ||
192 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); /* FEAT_SB */ | ||
193 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); /* FEAT_SPECRES */ | ||
194 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); /* FEAT_AA32BF16 */ | ||
195 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); /* FEAT_AA32I8MM */ | ||
196 | cpu->isar.id_isar6 = t; | ||
197 | |||
198 | t = cpu->isar.mvfr1; | ||
199 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
200 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
201 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* FEAT_FP16 */ | ||
202 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* FEAT_FP16 */ | ||
203 | cpu->isar.mvfr1 = t; | ||
204 | |||
205 | t = cpu->isar.mvfr2; | ||
206 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
207 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
208 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
209 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
210 | cpu->isar.mvfr2 = t; | ||
211 | |||
212 | t = cpu->isar.id_mmfr3; | ||
213 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
214 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* FEAT_PAN2 */ | ||
215 | cpu->isar.id_mmfr3 = t; | ||
216 | |||
217 | t = cpu->isar.id_mmfr4; | ||
218 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
219 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
220 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
221 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
222 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ | ||
223 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
224 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ | ||
225 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX*/ | ||
226 | cpu->isar.id_mmfr4 = t; | ||
227 | |||
228 | t = cpu->isar.id_pfr0; | ||
229 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
230 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ | ||
231 | cpu->isar.id_pfr0 = t; | ||
232 | |||
233 | t = cpu->isar.id_pfr2; | ||
234 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
235 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */ | ||
236 | cpu->isar.id_pfr2 = t; | ||
237 | |||
238 | t = cpu->isar.id_dfr0; | ||
239 | - t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
240 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ | ||
241 | cpu->isar.id_dfr0 = t; | ||
43 | } | 242 | } |
44 | 243 | ||
45 | static void xlnx_zcu102_machine_instance_init(Object *obj) | ||
46 | -- | 244 | -- |
47 | 2.20.1 | 245 | 2.25.1 |
48 | |||
49 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We will move this code in the next commit. Clean it up | 3 | Use FIELD_DP{32,64} to manipulate id_pfr1 and id_aa64pfr0 |
4 | first to avoid checkpatch.pl errors. | 4 | during arm_cpu_realizefn. |
5 | 5 | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200423073358.27155-5-philmd@redhat.com | 8 | Message-id: 20220506180242.216785-11-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 | --- | 10 | --- |
11 | target/arm/cpu.c | 9 ++++++--- | 11 | target/arm/cpu.c | 22 +++++++++++++--------- |
12 | 1 file changed, 6 insertions(+), 3 deletions(-) | 12 | 1 file changed, 13 insertions(+), 9 deletions(-) |
13 | 13 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 16 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/cpu.c | 17 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
19 | CPUARMState *env = &cpu->env; | 19 | */ |
20 | bool ret = false; | 20 | unset_feature(env, ARM_FEATURE_EL3); |
21 | 21 | ||
22 | - /* ARMv7-M interrupt masking works differently than -A or -R. | 22 | - /* Disable the security extension feature bits in the processor feature |
23 | + /* | 23 | - * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. |
24 | + * ARMv7-M interrupt masking works differently than -A or -R. | 24 | + /* |
25 | * There is no FIQ/IRQ distinction. Instead of I and F bits | 25 | + * Disable the security extension feature bits in the processor |
26 | * masking FIQ and IRQ interrupts, an exception is taken only | 26 | + * feature registers as well. |
27 | * if it is higher priority than the current execution priority | 27 | */ |
28 | @@ -XXX,XX +XXX,XX @@ static void arm1026_initfn(Object *obj) | 28 | - cpu->isar.id_pfr1 &= ~0xf0; |
29 | static void arm1136_r2_initfn(Object *obj) | 29 | - cpu->isar.id_aa64pfr0 &= ~0xf000; |
30 | { | 30 | + cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0); |
31 | ARMCPU *cpu = ARM_CPU(obj); | 31 | + cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, |
32 | - /* What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an | 32 | + ID_AA64PFR0, EL3, 0); |
33 | + /* | 33 | } |
34 | + * What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an | 34 | |
35 | * older core than plain "arm1136". In particular this does not | 35 | if (!cpu->has_el2) { |
36 | * have the v6K features. | 36 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
37 | * These ID register values are correct for 1136 but may be wrong | 37 | } |
38 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { | 38 | |
39 | { .name = "arm926", .initfn = arm926_initfn }, | 39 | if (!arm_feature(env, ARM_FEATURE_EL2)) { |
40 | { .name = "arm946", .initfn = arm946_initfn }, | 40 | - /* Disable the hypervisor feature bits in the processor feature |
41 | { .name = "arm1026", .initfn = arm1026_initfn }, | 41 | - * registers if we don't have EL2. These are id_pfr1[15:12] and |
42 | - /* What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an | 42 | - * id_aa64pfr0_el1[11:8]. |
43 | + /* | 43 | + /* |
44 | + * What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an | 44 | + * Disable the hypervisor feature bits in the processor feature |
45 | * older core than plain "arm1136". In particular this does not | 45 | + * registers if we don't have EL2. |
46 | * have the v6K features. | 46 | */ |
47 | */ | 47 | - cpu->isar.id_aa64pfr0 &= ~0xf00; |
48 | - cpu->isar.id_pfr1 &= ~0xf000; | ||
49 | + cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, | ||
50 | + ID_AA64PFR0, EL2, 0); | ||
51 | + cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, | ||
52 | + ID_PFR1, VIRTUALIZATION, 0); | ||
53 | } | ||
54 | |||
55 | #ifndef CONFIG_USER_ONLY | ||
48 | -- | 56 | -- |
49 | 2.20.1 | 57 | 2.25.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Make cpu_register() (renamed to arm_cpu_register()) available | 3 | The only portion of FEAT_Debugv8p2 that is relevant to QEMU |
4 | from internals.h so we can register CPUs also from other files | 4 | is CONTEXTIDR_EL2, which is also conditionally implemented |
5 | in the future. | 5 | with FEAT_VHE. The rest of the debug extension concerns the |
6 | External debug interface, which is outside the scope of QEMU. | ||
6 | 7 | ||
7 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 10 | Message-id: 20220506180242.216785-12-richard.henderson@linaro.org |
10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20200423073358.27155-3-philmd@redhat.com | ||
12 | Message-ID: <20190921150420.30743-2-thuth@redhat.com> | ||
13 | [PMD: Only take cpu_register() from Thomas's patch] | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 12 | --- |
17 | target/arm/cpu-qom.h | 9 ++++++++- | 13 | docs/system/arm/emulation.rst | 1 + |
18 | target/arm/cpu.c | 10 ++-------- | 14 | target/arm/cpu.c | 1 + |
19 | target/arm/cpu64.c | 8 +------- | 15 | target/arm/cpu64.c | 1 + |
20 | 3 files changed, 11 insertions(+), 16 deletions(-) | 16 | target/arm/cpu_tcg.c | 2 ++ |
17 | 4 files changed, 5 insertions(+) | ||
21 | 18 | ||
22 | diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
23 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/cpu-qom.h | 21 | --- a/docs/system/arm/emulation.rst |
25 | +++ b/target/arm/cpu-qom.h | 22 | +++ b/docs/system/arm/emulation.rst |
26 | @@ -XXX,XX +XXX,XX @@ struct arm_boot_info; | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
27 | 24 | - FEAT_BTI (Branch Target Identification) | |
28 | #define TYPE_ARM_MAX_CPU "max-" TYPE_ARM_CPU | 25 | - FEAT_DIT (Data Independent Timing instructions) |
29 | 26 | - FEAT_DPB (DC CVAP instruction) | |
30 | -typedef struct ARMCPUInfo ARMCPUInfo; | 27 | +- FEAT_Debugv8p2 (Debug changes for v8.2) |
31 | +typedef struct ARMCPUInfo { | 28 | - FEAT_DotProd (Advanced SIMD dot product instructions) |
32 | + const char *name; | 29 | - FEAT_FCMA (Floating-point complex number instructions) |
33 | + void (*initfn)(Object *obj); | 30 | - FEAT_FHM (Floating-point half-precision multiplication instructions) |
34 | + void (*class_init)(ObjectClass *oc, void *data); | ||
35 | +} ARMCPUInfo; | ||
36 | + | ||
37 | +void arm_cpu_register(const ARMCPUInfo *info); | ||
38 | +void aarch64_cpu_register(const ARMCPUInfo *info); | ||
39 | |||
40 | /** | ||
41 | * ARMCPUClass: | ||
42 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 31 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
43 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/target/arm/cpu.c | 33 | --- a/target/arm/cpu.c |
45 | +++ b/target/arm/cpu.c | 34 | +++ b/target/arm/cpu.c |
46 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | 35 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
47 | 36 | * feature registers as well. | |
48 | #endif /* !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) */ | 37 | */ |
49 | 38 | cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0); | |
50 | -struct ARMCPUInfo { | 39 | + cpu->isar.id_dfr0 = FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPSDBG, 0); |
51 | - const char *name; | 40 | cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, |
52 | - void (*initfn)(Object *obj); | 41 | ID_AA64PFR0, EL3, 0); |
53 | - void (*class_init)(ObjectClass *oc, void *data); | ||
54 | -}; | ||
55 | - | ||
56 | static const ARMCPUInfo arm_cpus[] = { | ||
57 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
58 | { .name = "arm926", .initfn = arm926_initfn }, | ||
59 | @@ -XXX,XX +XXX,XX @@ static void cpu_register_class_init(ObjectClass *oc, void *data) | ||
60 | acc->info = data; | ||
61 | } | ||
62 | |||
63 | -static void cpu_register(const ARMCPUInfo *info) | ||
64 | +void arm_cpu_register(const ARMCPUInfo *info) | ||
65 | { | ||
66 | TypeInfo type_info = { | ||
67 | .parent = TYPE_ARM_CPU, | ||
68 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_register_types(void) | ||
69 | type_register_static(&idau_interface_type_info); | ||
70 | |||
71 | while (info->name) { | ||
72 | - cpu_register(info); | ||
73 | + arm_cpu_register(info); | ||
74 | info++; | ||
75 | } | 42 | } |
76 | |||
77 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 43 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
78 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
79 | --- a/target/arm/cpu64.c | 45 | --- a/target/arm/cpu64.c |
80 | +++ b/target/arm/cpu64.c | 46 | +++ b/target/arm/cpu64.c |
81 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
82 | cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); | 48 | cpu->isar.id_aa64zfr0 = t; |
49 | |||
50 | t = cpu->isar.id_aa64dfr0; | ||
51 | + t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 8); /* FEAT_Debugv8p2 */ | ||
52 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ | ||
53 | cpu->isar.id_aa64dfr0 = t; | ||
54 | |||
55 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/cpu_tcg.c | ||
58 | +++ b/target/arm/cpu_tcg.c | ||
59 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
60 | cpu->isar.id_pfr2 = t; | ||
61 | |||
62 | t = cpu->isar.id_dfr0; | ||
63 | + t = FIELD_DP32(t, ID_DFR0, COPDBG, 8); /* FEAT_Debugv8p2 */ | ||
64 | + t = FIELD_DP32(t, ID_DFR0, COPSDBG, 8); /* FEAT_Debugv8p2 */ | ||
65 | t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ | ||
66 | cpu->isar.id_dfr0 = t; | ||
83 | } | 67 | } |
84 | |||
85 | -struct ARMCPUInfo { | ||
86 | - const char *name; | ||
87 | - void (*initfn)(Object *obj); | ||
88 | - void (*class_init)(ObjectClass *oc, void *data); | ||
89 | -}; | ||
90 | - | ||
91 | static const ARMCPUInfo aarch64_cpus[] = { | ||
92 | { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, | ||
93 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, | ||
94 | @@ -XXX,XX +XXX,XX @@ static void cpu_register_class_init(ObjectClass *oc, void *data) | ||
95 | acc->info = data; | ||
96 | } | ||
97 | |||
98 | -static void aarch64_cpu_register(const ARMCPUInfo *info) | ||
99 | +void aarch64_cpu_register(const ARMCPUInfo *info) | ||
100 | { | ||
101 | TypeInfo type_info = { | ||
102 | .parent = TYPE_AARCH64_CPU, | ||
103 | -- | 68 | -- |
104 | 2.20.1 | 69 | 2.25.1 |
105 | |||
106 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Make compat in qemu_fdt_node_path() const char *. | 3 | This extension concerns changes to the External Debug interface, |
4 | with Secure and Non-secure access to the debug registers, and all | ||
5 | of it is outside the scope of QEMU. Indicating support for this | ||
6 | is mandatory with FEAT_SEL2, which we do implement. | ||
4 | 7 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
6 | Message-id: 20200423121114.4274-3-edgar.iglesias@gmail.com | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20220506180242.216785-13-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | include/sysemu/device_tree.h | 2 +- | 13 | docs/system/arm/emulation.rst | 1 + |
11 | device_tree.c | 2 +- | 14 | target/arm/cpu64.c | 2 +- |
12 | 2 files changed, 2 insertions(+), 2 deletions(-) | 15 | target/arm/cpu_tcg.c | 4 ++-- |
16 | 3 files changed, 4 insertions(+), 3 deletions(-) | ||
13 | 17 | ||
14 | diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h | 18 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/sysemu/device_tree.h | 20 | --- a/docs/system/arm/emulation.rst |
17 | +++ b/include/sysemu/device_tree.h | 21 | +++ b/docs/system/arm/emulation.rst |
18 | @@ -XXX,XX +XXX,XX @@ void *load_device_tree_from_sysfs(void); | 22 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
19 | * @name may be NULL to wildcard names and only match compatibility | 23 | - FEAT_DIT (Data Independent Timing instructions) |
20 | * strings. | 24 | - FEAT_DPB (DC CVAP instruction) |
21 | */ | 25 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
22 | -char **qemu_fdt_node_path(void *fdt, const char *name, char *compat, | 26 | +- FEAT_Debugv8p4 (Debug changes for v8.4) |
23 | +char **qemu_fdt_node_path(void *fdt, const char *name, const char *compat, | 27 | - FEAT_DotProd (Advanced SIMD dot product instructions) |
24 | Error **errp); | 28 | - FEAT_FCMA (Floating-point complex number instructions) |
25 | 29 | - FEAT_FHM (Floating-point half-precision multiplication instructions) | |
26 | /** | 30 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
27 | diff --git a/device_tree.c b/device_tree.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/device_tree.c | 32 | --- a/target/arm/cpu64.c |
30 | +++ b/device_tree.c | 33 | +++ b/target/arm/cpu64.c |
31 | @@ -XXX,XX +XXX,XX @@ char **qemu_fdt_node_unit_path(void *fdt, const char *name, Error **errp) | 34 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
32 | return path_array; | 35 | cpu->isar.id_aa64zfr0 = t; |
36 | |||
37 | t = cpu->isar.id_aa64dfr0; | ||
38 | - t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 8); /* FEAT_Debugv8p2 */ | ||
39 | + t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */ | ||
40 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ | ||
41 | cpu->isar.id_aa64dfr0 = t; | ||
42 | |||
43 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/cpu_tcg.c | ||
46 | +++ b/target/arm/cpu_tcg.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
48 | cpu->isar.id_pfr2 = t; | ||
49 | |||
50 | t = cpu->isar.id_dfr0; | ||
51 | - t = FIELD_DP32(t, ID_DFR0, COPDBG, 8); /* FEAT_Debugv8p2 */ | ||
52 | - t = FIELD_DP32(t, ID_DFR0, COPSDBG, 8); /* FEAT_Debugv8p2 */ | ||
53 | + t = FIELD_DP32(t, ID_DFR0, COPDBG, 9); /* FEAT_Debugv8p4 */ | ||
54 | + t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */ | ||
55 | t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ | ||
56 | cpu->isar.id_dfr0 = t; | ||
33 | } | 57 | } |
34 | |||
35 | -char **qemu_fdt_node_path(void *fdt, const char *name, char *compat, | ||
36 | +char **qemu_fdt_node_path(void *fdt, const char *name, const char *compat, | ||
37 | Error **errp) | ||
38 | { | ||
39 | int offset, len, ret; | ||
40 | -- | 58 | -- |
41 | 2.20.1 | 59 | 2.25.1 |
42 | |||
43 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add some clocks to zynq_slcr | 3 | Add only the system registers required to implement zero error |
4 | + the main input clock (ps_clk) | 4 | records. This means that all values for ERRSELR are out of range, |
5 | + the reference clock outputs for each uart (uart0 & 1) | 5 | which means that it and all of the indexed error record registers |
6 | need not be implemented. | ||
6 | 7 | ||
7 | This commit also transitional the slcr to multi-phase reset as it is | 8 | Add the EL2 registers required for injecting virtual SError. |
8 | required to initialize the clocks correctly. | ||
9 | 9 | ||
10 | The clock frequencies are computed using the internal pll & uart configuration | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | registers and the input ps_clk frequency. | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | 12 | Message-id: 20220506180242.216785-14-richard.henderson@linaro.org | |
13 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
14 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
15 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Message-id: 20200406135251.157596-7-damien.hedde@greensocs.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 14 | --- |
19 | hw/misc/zynq_slcr.c | 172 ++++++++++++++++++++++++++++++++++++++++++-- | 15 | target/arm/cpu.h | 5 +++ |
20 | 1 file changed, 168 insertions(+), 4 deletions(-) | 16 | target/arm/helper.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ |
17 | 2 files changed, 89 insertions(+) | ||
21 | 18 | ||
22 | diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
23 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/misc/zynq_slcr.c | 21 | --- a/target/arm/cpu.h |
25 | +++ b/hw/misc/zynq_slcr.c | 22 | +++ b/target/arm/cpu.h |
26 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
27 | #include "qemu/log.h" | 24 | uint64_t tfsr_el[4]; /* tfsre0_el1 is index 0. */ |
28 | #include "qemu/module.h" | 25 | uint64_t gcr_el1; |
29 | #include "hw/registerfields.h" | 26 | uint64_t rgsr_el1; |
30 | +#include "hw/qdev-clock.h" | ||
31 | |||
32 | #ifndef ZYNQ_SLCR_ERR_DEBUG | ||
33 | #define ZYNQ_SLCR_ERR_DEBUG 0 | ||
34 | @@ -XXX,XX +XXX,XX @@ REG32(LOCKSTA, 0x00c) | ||
35 | REG32(ARM_PLL_CTRL, 0x100) | ||
36 | REG32(DDR_PLL_CTRL, 0x104) | ||
37 | REG32(IO_PLL_CTRL, 0x108) | ||
38 | +/* fields for [ARM|DDR|IO]_PLL_CTRL registers */ | ||
39 | + FIELD(xxx_PLL_CTRL, PLL_RESET, 0, 1) | ||
40 | + FIELD(xxx_PLL_CTRL, PLL_PWRDWN, 1, 1) | ||
41 | + FIELD(xxx_PLL_CTRL, PLL_BYPASS_QUAL, 3, 1) | ||
42 | + FIELD(xxx_PLL_CTRL, PLL_BYPASS_FORCE, 4, 1) | ||
43 | + FIELD(xxx_PLL_CTRL, PLL_FPDIV, 12, 7) | ||
44 | REG32(PLL_STATUS, 0x10c) | ||
45 | REG32(ARM_PLL_CFG, 0x110) | ||
46 | REG32(DDR_PLL_CFG, 0x114) | ||
47 | @@ -XXX,XX +XXX,XX @@ REG32(SMC_CLK_CTRL, 0x148) | ||
48 | REG32(LQSPI_CLK_CTRL, 0x14c) | ||
49 | REG32(SDIO_CLK_CTRL, 0x150) | ||
50 | REG32(UART_CLK_CTRL, 0x154) | ||
51 | + FIELD(UART_CLK_CTRL, CLKACT0, 0, 1) | ||
52 | + FIELD(UART_CLK_CTRL, CLKACT1, 1, 1) | ||
53 | + FIELD(UART_CLK_CTRL, SRCSEL, 4, 2) | ||
54 | + FIELD(UART_CLK_CTRL, DIVISOR, 8, 6) | ||
55 | REG32(SPI_CLK_CTRL, 0x158) | ||
56 | REG32(CAN_CLK_CTRL, 0x15c) | ||
57 | REG32(CAN_MIOCLK_CTRL, 0x160) | ||
58 | @@ -XXX,XX +XXX,XX @@ typedef struct ZynqSLCRState { | ||
59 | MemoryRegion iomem; | ||
60 | |||
61 | uint32_t regs[ZYNQ_SLCR_NUM_REGS]; | ||
62 | + | 27 | + |
63 | + Clock *ps_clk; | 28 | + /* Minimal RAS registers */ |
64 | + Clock *uart0_ref_clk; | 29 | + uint64_t disr_el1; |
65 | + Clock *uart1_ref_clk; | 30 | + uint64_t vdisr_el2; |
66 | } ZynqSLCRState; | 31 | + uint64_t vsesr_el2; |
67 | 32 | } cp15; | |
68 | -static void zynq_slcr_reset(DeviceState *d) | 33 | |
34 | struct { | ||
35 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/helper.c | ||
38 | +++ b/target/arm/helper.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
40 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
41 | }; | ||
42 | |||
69 | +/* | 43 | +/* |
70 | + * return the output frequency of ARM/DDR/IO pll | 44 | + * Check for traps to RAS registers, which are controlled |
71 | + * using input frequency and PLL_CTRL register | 45 | + * by HCR_EL2.TERR and SCR_EL3.TERR. |
72 | + */ | 46 | + */ |
73 | +static uint64_t zynq_slcr_compute_pll(uint64_t input, uint32_t ctrl_reg) | 47 | +static CPAccessResult access_terr(CPUARMState *env, const ARMCPRegInfo *ri, |
74 | { | 48 | + bool isread) |
75 | - ZynqSLCRState *s = ZYNQ_SLCR(d); | 49 | +{ |
76 | + uint32_t mult = ((ctrl_reg & R_xxx_PLL_CTRL_PLL_FPDIV_MASK) >> | 50 | + int el = arm_current_el(env); |
77 | + R_xxx_PLL_CTRL_PLL_FPDIV_SHIFT); | ||
78 | + | 51 | + |
79 | + /* first, check if pll is bypassed */ | 52 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_TERR)) { |
80 | + if (ctrl_reg & R_xxx_PLL_CTRL_PLL_BYPASS_FORCE_MASK) { | 53 | + return CP_ACCESS_TRAP_EL2; |
81 | + return input; | ||
82 | + } | 54 | + } |
55 | + if (el < 3 && (env->cp15.scr_el3 & SCR_TERR)) { | ||
56 | + return CP_ACCESS_TRAP_EL3; | ||
57 | + } | ||
58 | + return CP_ACCESS_OK; | ||
59 | +} | ||
83 | + | 60 | + |
84 | + /* is pll disabled ? */ | 61 | +static uint64_t disr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
85 | + if (ctrl_reg & (R_xxx_PLL_CTRL_PLL_RESET_MASK | | 62 | +{ |
86 | + R_xxx_PLL_CTRL_PLL_PWRDWN_MASK)) { | 63 | + int el = arm_current_el(env); |
87 | + return 0; | 64 | + |
65 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) { | ||
66 | + return env->cp15.vdisr_el2; | ||
88 | + } | 67 | + } |
68 | + if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) { | ||
69 | + return 0; /* RAZ/WI */ | ||
70 | + } | ||
71 | + return env->cp15.disr_el1; | ||
72 | +} | ||
89 | + | 73 | + |
90 | + /* frequency multiplier -> period division */ | 74 | +static void disr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t val) |
91 | + return input / mult; | 75 | +{ |
76 | + int el = arm_current_el(env); | ||
77 | + | ||
78 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) { | ||
79 | + env->cp15.vdisr_el2 = val; | ||
80 | + return; | ||
81 | + } | ||
82 | + if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) { | ||
83 | + return; /* RAZ/WI */ | ||
84 | + } | ||
85 | + env->cp15.disr_el1 = val; | ||
92 | +} | 86 | +} |
93 | + | 87 | + |
94 | +/* | 88 | +/* |
95 | + * return the output period of a clock given: | 89 | + * Minimal RAS implementation with no Error Records. |
96 | + * + the periods in an array corresponding to input mux selector | 90 | + * Which means that all of the Error Record registers: |
97 | + * + the register xxx_CLK_CTRL value | 91 | + * ERXADDR_EL1 |
98 | + * + enable bit index in ctrl register | 92 | + * ERXCTLR_EL1 |
99 | + * | 93 | + * ERXFR_EL1 |
100 | + * This function makes the assumption that the ctrl_reg value is organized as | 94 | + * ERXMISC0_EL1 |
101 | + * follows: | 95 | + * ERXMISC1_EL1 |
102 | + * + bits[13:8] clock frequency divisor | 96 | + * ERXMISC2_EL1 |
103 | + * + bits[5:4] clock mux selector (index in array) | 97 | + * ERXMISC3_EL1 |
104 | + * + bits[index] clock enable | 98 | + * ERXPFGCDN_EL1 (RASv1p1) |
99 | + * ERXPFGCTL_EL1 (RASv1p1) | ||
100 | + * ERXPFGF_EL1 (RASv1p1) | ||
101 | + * ERXSTATUS_EL1 | ||
102 | + * and | ||
103 | + * ERRSELR_EL1 | ||
104 | + * may generate UNDEFINED, which is the effect we get by not | ||
105 | + * listing them at all. | ||
105 | + */ | 106 | + */ |
106 | +static uint64_t zynq_slcr_compute_clock(const uint64_t periods[], | 107 | +static const ARMCPRegInfo minimal_ras_reginfo[] = { |
107 | + uint32_t ctrl_reg, | 108 | + { .name = "DISR_EL1", .state = ARM_CP_STATE_BOTH, |
108 | + unsigned index) | 109 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 1, .opc2 = 1, |
109 | +{ | 110 | + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.disr_el1), |
110 | + uint32_t srcsel = extract32(ctrl_reg, 4, 2); /* bits [5:4] */ | 111 | + .readfn = disr_read, .writefn = disr_write, .raw_writefn = raw_write }, |
111 | + uint32_t divisor = extract32(ctrl_reg, 8, 6); /* bits [13:8] */ | 112 | + { .name = "ERRIDR_EL1", .state = ARM_CP_STATE_BOTH, |
112 | + | 113 | + .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 3, .opc2 = 0, |
113 | + /* first, check if clock is disabled */ | 114 | + .access = PL1_R, .accessfn = access_terr, |
114 | + if (((ctrl_reg >> index) & 1u) == 0) { | 115 | + .type = ARM_CP_CONST, .resetvalue = 0 }, |
115 | + return 0; | 116 | + { .name = "VDISR_EL2", .state = ARM_CP_STATE_BOTH, |
116 | + } | 117 | + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 1, .opc2 = 1, |
117 | + | 118 | + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vdisr_el2) }, |
118 | + /* | 119 | + { .name = "VSESR_EL2", .state = ARM_CP_STATE_BOTH, |
119 | + * according to the Zynq technical ref. manual UG585 v1.12.2 in | 120 | + .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 3, |
120 | + * Clocks chapter, section 25.10.1 page 705: | 121 | + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vsesr_el2) }, |
121 | + * "The 6-bit divider provides a divide range of 1 to 63" | ||
122 | + * We follow here what is implemented in linux kernel and consider | ||
123 | + * the 0 value as a bypass (no division). | ||
124 | + */ | ||
125 | + /* frequency divisor -> period multiplication */ | ||
126 | + return periods[srcsel] * (divisor ? divisor : 1u); | ||
127 | +} | ||
128 | + | ||
129 | +/* | ||
130 | + * macro helper around zynq_slcr_compute_clock to avoid repeating | ||
131 | + * the register name. | ||
132 | + */ | ||
133 | +#define ZYNQ_COMPUTE_CLK(state, plls, reg, enable_field) \ | ||
134 | + zynq_slcr_compute_clock((plls), (state)->regs[reg], \ | ||
135 | + reg ## _ ## enable_field ## _SHIFT) | ||
136 | + | ||
137 | +/** | ||
138 | + * Compute and set the ouputs clocks periods. | ||
139 | + * But do not propagate them further. Connected clocks | ||
140 | + * will not receive any updates (See zynq_slcr_compute_clocks()) | ||
141 | + */ | ||
142 | +static void zynq_slcr_compute_clocks(ZynqSLCRState *s) | ||
143 | +{ | ||
144 | + uint64_t ps_clk = clock_get(s->ps_clk); | ||
145 | + | ||
146 | + /* consider outputs clocks are disabled while in reset */ | ||
147 | + if (device_is_in_reset(DEVICE(s))) { | ||
148 | + ps_clk = 0; | ||
149 | + } | ||
150 | + | ||
151 | + uint64_t io_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTRL]); | ||
152 | + uint64_t arm_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_CTRL]); | ||
153 | + uint64_t ddr_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_CTRL]); | ||
154 | + | ||
155 | + uint64_t uart_mux[4] = {io_pll, io_pll, arm_pll, ddr_pll}; | ||
156 | + | ||
157 | + /* compute uartX reference clocks */ | ||
158 | + clock_set(s->uart0_ref_clk, | ||
159 | + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0)); | ||
160 | + clock_set(s->uart1_ref_clk, | ||
161 | + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1)); | ||
162 | +} | ||
163 | + | ||
164 | +/** | ||
165 | + * Propagate the outputs clocks. | ||
166 | + * zynq_slcr_compute_clocks() should have been called before | ||
167 | + * to configure them. | ||
168 | + */ | ||
169 | +static void zynq_slcr_propagate_clocks(ZynqSLCRState *s) | ||
170 | +{ | ||
171 | + clock_propagate(s->uart0_ref_clk); | ||
172 | + clock_propagate(s->uart1_ref_clk); | ||
173 | +} | ||
174 | + | ||
175 | +static void zynq_slcr_ps_clk_callback(void *opaque) | ||
176 | +{ | ||
177 | + ZynqSLCRState *s = (ZynqSLCRState *) opaque; | ||
178 | + zynq_slcr_compute_clocks(s); | ||
179 | + zynq_slcr_propagate_clocks(s); | ||
180 | +} | ||
181 | + | ||
182 | +static void zynq_slcr_reset_init(Object *obj, ResetType type) | ||
183 | +{ | ||
184 | + ZynqSLCRState *s = ZYNQ_SLCR(obj); | ||
185 | int i; | ||
186 | |||
187 | DB_PRINT("RESET\n"); | ||
188 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset(DeviceState *d) | ||
189 | s->regs[R_DDRIOB + 12] = 0x00000021; | ||
190 | } | ||
191 | |||
192 | +static void zynq_slcr_reset_hold(Object *obj) | ||
193 | +{ | ||
194 | + ZynqSLCRState *s = ZYNQ_SLCR(obj); | ||
195 | + | ||
196 | + /* will disable all output clocks */ | ||
197 | + zynq_slcr_compute_clocks(s); | ||
198 | + zynq_slcr_propagate_clocks(s); | ||
199 | +} | ||
200 | + | ||
201 | +static void zynq_slcr_reset_exit(Object *obj) | ||
202 | +{ | ||
203 | + ZynqSLCRState *s = ZYNQ_SLCR(obj); | ||
204 | + | ||
205 | + /* will compute output clocks according to ps_clk and registers */ | ||
206 | + zynq_slcr_compute_clocks(s); | ||
207 | + zynq_slcr_propagate_clocks(s); | ||
208 | +} | ||
209 | |||
210 | static bool zynq_slcr_check_offset(hwaddr offset, bool rnw) | ||
211 | { | ||
212 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
213 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
214 | } | ||
215 | break; | ||
216 | + case R_IO_PLL_CTRL: | ||
217 | + case R_ARM_PLL_CTRL: | ||
218 | + case R_DDR_PLL_CTRL: | ||
219 | + case R_UART_CLK_CTRL: | ||
220 | + zynq_slcr_compute_clocks(s); | ||
221 | + zynq_slcr_propagate_clocks(s); | ||
222 | + break; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps slcr_ops = { | ||
227 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
228 | }; | ||
229 | |||
230 | +static const ClockPortInitArray zynq_slcr_clocks = { | ||
231 | + QDEV_CLOCK_IN(ZynqSLCRState, ps_clk, zynq_slcr_ps_clk_callback), | ||
232 | + QDEV_CLOCK_OUT(ZynqSLCRState, uart0_ref_clk), | ||
233 | + QDEV_CLOCK_OUT(ZynqSLCRState, uart1_ref_clk), | ||
234 | + QDEV_CLOCK_END | ||
235 | +}; | 122 | +}; |
236 | + | 123 | + |
237 | static void zynq_slcr_init(Object *obj) | 124 | /* Return the exception level to which exceptions should be taken |
238 | { | 125 | * via SVEAccessTrap. If an exception should be routed through |
239 | ZynqSLCRState *s = ZYNQ_SLCR(obj); | 126 | * AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should |
240 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_init(Object *obj) | 127 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
241 | memory_region_init_io(&s->iomem, obj, &slcr_ops, s, "slcr", | 128 | if (cpu_isar_feature(aa64_ssbs, cpu)) { |
242 | ZYNQ_SLCR_MMIO_SIZE); | 129 | define_one_arm_cp_reg(cpu, &ssbs_reginfo); |
243 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); | ||
244 | + | ||
245 | + qdev_init_clocks(DEVICE(obj), zynq_slcr_clocks); | ||
246 | } | ||
247 | |||
248 | static const VMStateDescription vmstate_zynq_slcr = { | ||
249 | .name = "zynq_slcr", | ||
250 | - .version_id = 2, | ||
251 | + .version_id = 3, | ||
252 | .minimum_version_id = 2, | ||
253 | .fields = (VMStateField[]) { | ||
254 | VMSTATE_UINT32_ARRAY(regs, ZynqSLCRState, ZYNQ_SLCR_NUM_REGS), | ||
255 | + VMSTATE_CLOCK_V(ps_clk, ZynqSLCRState, 3), | ||
256 | VMSTATE_END_OF_LIST() | ||
257 | } | 130 | } |
258 | }; | 131 | + if (cpu_isar_feature(any_ras, cpu)) { |
259 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_zynq_slcr = { | 132 | + define_arm_cp_regs(cpu, minimal_ras_reginfo); |
260 | static void zynq_slcr_class_init(ObjectClass *klass, void *data) | 133 | + } |
261 | { | 134 | |
262 | DeviceClass *dc = DEVICE_CLASS(klass); | 135 | if (cpu_isar_feature(aa64_vh, cpu) || |
263 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | 136 | cpu_isar_feature(aa64_debugv8p2, cpu)) { |
264 | |||
265 | dc->vmsd = &vmstate_zynq_slcr; | ||
266 | - dc->reset = zynq_slcr_reset; | ||
267 | + rc->phases.enter = zynq_slcr_reset_init; | ||
268 | + rc->phases.hold = zynq_slcr_reset_hold; | ||
269 | + rc->phases.exit = zynq_slcr_reset_exit; | ||
270 | } | ||
271 | |||
272 | static const TypeInfo zynq_slcr_info = { | ||
273 | -- | 137 | -- |
274 | 2.20.1 | 138 | 2.25.1 |
275 | |||
276 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Under KVM these registers are written by the hardware. | 3 | Enable writes to the TERR and TEA bits when RAS is enabled. |
4 | Restrict the writefn handlers to TCG to avoid when building | 4 | These bits are otherwise RES0. |
5 | without TCG: | ||
6 | 5 | ||
7 | LINK aarch64-softmmu/qemu-system-aarch64 | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | target/arm/helper.o: In function `do_ats_write': | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | target/arm/helper.c:3524: undefined reference to `raise_exception' | 8 | Message-id: 20220506180242.216785-15-richard.henderson@linaro.org |
10 | |||
11 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Message-id: 20200423073358.27155-2-philmd@redhat.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 10 | --- |
17 | target/arm/helper.c | 17 +++++++++++++++++ | 11 | target/arm/helper.c | 9 +++++++++ |
18 | 1 file changed, 17 insertions(+) | 12 | 1 file changed, 9 insertions(+) |
19 | 13 | ||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 16 | --- a/target/arm/helper.c |
23 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, | 18 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
25 | return CP_ACCESS_OK; | 19 | } |
26 | } | 20 | valid_mask &= ~SCR_NET; |
27 | 21 | ||
28 | +#ifdef CONFIG_TCG | 22 | + if (cpu_isar_feature(aa64_ras, cpu)) { |
29 | static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | 23 | + valid_mask |= SCR_TERR; |
30 | MMUAccessType access_type, ARMMMUIdx mmu_idx) | 24 | + } |
31 | { | 25 | if (cpu_isar_feature(aa64_lor, cpu)) { |
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | 26 | valid_mask |= SCR_TLOR; |
27 | } | ||
28 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
29 | } | ||
30 | } else { | ||
31 | valid_mask &= ~(SCR_RW | SCR_ST); | ||
32 | + if (cpu_isar_feature(aa32_ras, cpu)) { | ||
33 | + valid_mask |= SCR_TERR; | ||
34 | + } | ||
33 | } | 35 | } |
34 | return par64; | 36 | |
35 | } | 37 | if (!arm_feature(env, ARM_FEATURE_EL2)) { |
36 | +#endif /* CONFIG_TCG */ | 38 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) |
37 | 39 | if (cpu_isar_feature(aa64_vh, cpu)) { | |
38 | static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 40 | valid_mask |= HCR_E2H; |
39 | { | 41 | } |
40 | +#ifdef CONFIG_TCG | 42 | + if (cpu_isar_feature(aa64_ras, cpu)) { |
41 | MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; | 43 | + valid_mask |= HCR_TERR | HCR_TEA; |
42 | uint64_t par64; | 44 | + } |
43 | ARMMMUIdx mmu_idx; | 45 | if (cpu_isar_feature(aa64_lor, cpu)) { |
44 | @@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 46 | valid_mask |= HCR_TLOR; |
45 | par64 = do_ats_write(env, value, access_type, mmu_idx); | 47 | } |
46 | |||
47 | A32_BANKED_CURRENT_REG_SET(env, par, par64); | ||
48 | +#else | ||
49 | + /* Handled by hardware accelerator. */ | ||
50 | + g_assert_not_reached(); | ||
51 | +#endif /* CONFIG_TCG */ | ||
52 | } | ||
53 | |||
54 | static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
55 | uint64_t value) | ||
56 | { | ||
57 | +#ifdef CONFIG_TCG | ||
58 | MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
59 | uint64_t par64; | ||
60 | |||
61 | par64 = do_ats_write(env, value, access_type, ARMMMUIdx_E2); | ||
62 | |||
63 | A32_BANKED_CURRENT_REG_SET(env, par, par64); | ||
64 | +#else | ||
65 | + /* Handled by hardware accelerator. */ | ||
66 | + g_assert_not_reached(); | ||
67 | +#endif /* CONFIG_TCG */ | ||
68 | } | ||
69 | |||
70 | static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
71 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
72 | static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, | ||
73 | uint64_t value) | ||
74 | { | ||
75 | +#ifdef CONFIG_TCG | ||
76 | MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
77 | ARMMMUIdx mmu_idx; | ||
78 | int secure = arm_is_secure_below_el3(env); | ||
79 | @@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, | ||
80 | } | ||
81 | |||
82 | env->cp15.par_el[1] = do_ats_write(env, value, access_type, mmu_idx); | ||
83 | +#else | ||
84 | + /* Handled by hardware accelerator. */ | ||
85 | + g_assert_not_reached(); | ||
86 | +#endif /* CONFIG_TCG */ | ||
87 | } | ||
88 | #endif | ||
89 | |||
90 | -- | 48 | -- |
91 | 2.20.1 | 49 | 2.25.1 |
92 | |||
93 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Introduce a function and macro helpers to setup several clocks | 3 | Virtual SError exceptions are raised by setting HCR_EL2.VSE, |
4 | in a device from a static array description. | 4 | and are routed to EL1 just like other virtual exceptions. |
5 | 5 | ||
6 | An element of the array describes the clock (name and direction) as | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | well as the related callback and an optional offset to store the | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | created object pointer in the device state structure. | 8 | Message-id: 20220506180242.216785-16-richard.henderson@linaro.org |
9 | |||
10 | The array must be terminated by a special element QDEV_CLOCK_END. | ||
11 | |||
12 | This is based on the original work of Frederic Konrad. | ||
13 | |||
14 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
17 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
18 | Message-id: 20200406135251.157596-5-damien.hedde@greensocs.com | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 10 | --- |
21 | include/hw/qdev-clock.h | 55 +++++++++++++++++++++++++++++++++++++++++ | 11 | target/arm/cpu.h | 2 ++ |
22 | hw/core/qdev-clock.c | 17 +++++++++++++ | 12 | target/arm/internals.h | 8 ++++++++ |
23 | 2 files changed, 72 insertions(+) | 13 | target/arm/syndrome.h | 5 +++++ |
14 | target/arm/cpu.c | 38 +++++++++++++++++++++++++++++++++++++- | ||
15 | target/arm/helper.c | 40 +++++++++++++++++++++++++++++++++++++++- | ||
16 | 5 files changed, 91 insertions(+), 2 deletions(-) | ||
24 | 17 | ||
25 | diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h | 18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
26 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/qdev-clock.h | 20 | --- a/target/arm/cpu.h |
28 | +++ b/include/hw/qdev-clock.h | 21 | +++ b/target/arm/cpu.h |
29 | @@ -XXX,XX +XXX,XX @@ Clock *qdev_alias_clock(DeviceState *dev, const char *name, | 22 | @@ -XXX,XX +XXX,XX @@ |
23 | #define EXCP_LSERR 21 /* v8M LSERR SecureFault */ | ||
24 | #define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ | ||
25 | #define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ | ||
26 | +#define EXCP_VSERR 24 | ||
27 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | ||
28 | |||
29 | #define ARMV7M_EXCP_RESET 1 | ||
30 | @@ -XXX,XX +XXX,XX @@ enum { | ||
31 | #define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1 | ||
32 | #define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2 | ||
33 | #define CPU_INTERRUPT_VFIQ CPU_INTERRUPT_TGT_EXT_3 | ||
34 | +#define CPU_INTERRUPT_VSERR CPU_INTERRUPT_TGT_INT_0 | ||
35 | |||
36 | /* The usual mapping for an AArch64 system register to its AArch32 | ||
37 | * counterpart is for the 32 bit world to have access to the lower | ||
38 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/internals.h | ||
41 | +++ b/target/arm/internals.h | ||
42 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu); | ||
30 | */ | 43 | */ |
31 | void qdev_finalize_clocklist(DeviceState *dev); | 44 | void arm_cpu_update_vfiq(ARMCPU *cpu); |
32 | 45 | ||
33 | +/** | 46 | +/** |
34 | + * ClockPortInitElem: | 47 | + * arm_cpu_update_vserr: Update CPU_INTERRUPT_VSERR bit |
35 | + * @name: name of the clock (can't be NULL) | 48 | + * |
36 | + * @output: indicates whether the clock is input or output | 49 | + * Update the CPU_INTERRUPT_VSERR bit in cs->interrupt_request, |
37 | + * @callback: for inputs, optional callback to be called on clock's update | 50 | + * following a change to the HCR_EL2.VSE bit. |
38 | + * with device as opaque | ||
39 | + * @offset: optional offset to store the ClockIn or ClockOut pointer in device | ||
40 | + * state structure (0 means unused) | ||
41 | + */ | 51 | + */ |
42 | +struct ClockPortInitElem { | 52 | +void arm_cpu_update_vserr(ARMCPU *cpu); |
43 | + const char *name; | 53 | + |
44 | + bool is_output; | 54 | /** |
45 | + ClockCallback *callback; | 55 | * arm_mmu_idx_el: |
46 | + size_t offset; | 56 | * @env: The cpu environment |
47 | +}; | 57 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h |
48 | + | 58 | index XXXXXXX..XXXXXXX 100644 |
49 | +#define clock_offset_value(devstate, field) \ | 59 | --- a/target/arm/syndrome.h |
50 | + (offsetof(devstate, field) + \ | 60 | +++ b/target/arm/syndrome.h |
51 | + type_check(Clock *, typeof_field(devstate, field))) | 61 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_pcalignment(void) |
52 | + | 62 | return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL; |
53 | +#define QDEV_CLOCK(out_not_in, devstate, field, cb) { \ | 63 | } |
54 | + .name = (stringify(field)), \ | 64 | |
55 | + .is_output = out_not_in, \ | 65 | +static inline uint32_t syn_serror(uint32_t extra) |
56 | + .callback = cb, \ | 66 | +{ |
57 | + .offset = clock_offset_value(devstate, field), \ | 67 | + return (EC_SERROR << ARM_EL_EC_SHIFT) | ARM_EL_IL | extra; |
58 | +} | 68 | +} |
59 | + | 69 | + |
60 | +/** | 70 | #endif /* TARGET_ARM_SYNDROME_H */ |
61 | + * QDEV_CLOCK_(IN|OUT): | 71 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
62 | + * @devstate: structure type. @dev argument of qdev_init_clocks below must be | 72 | index XXXXXXX..XXXXXXX 100644 |
63 | + * a pointer to that same type. | 73 | --- a/target/arm/cpu.c |
64 | + * @field: a field in @_devstate (must be Clock*) | 74 | +++ b/target/arm/cpu.c |
65 | + * @callback: (for input only) callback (or NULL) to be called with the device | 75 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs) |
66 | + * state as argument | 76 | return (cpu->power_state != PSCI_OFF) |
67 | + * | 77 | && cs->interrupt_request & |
68 | + * The name of the clock will be derived from @field | 78 | (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD |
69 | + */ | 79 | - | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ |
70 | +#define QDEV_CLOCK_IN(devstate, field, callback) \ | 80 | + | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR |
71 | + QDEV_CLOCK(false, devstate, field, callback) | 81 | | CPU_INTERRUPT_EXITTB); |
72 | + | 82 | } |
73 | +#define QDEV_CLOCK_OUT(devstate, field) \ | 83 | |
74 | + QDEV_CLOCK(true, devstate, field, NULL) | 84 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, |
75 | + | 85 | return false; |
76 | +#define QDEV_CLOCK_END { .name = NULL } | 86 | } |
77 | + | 87 | return !(env->daif & PSTATE_I); |
78 | +typedef struct ClockPortInitElem ClockPortInitArray[]; | 88 | + case EXCP_VSERR: |
79 | + | 89 | + if (!(hcr_el2 & HCR_AMO) || (hcr_el2 & HCR_TGE)) { |
80 | +/** | 90 | + /* VIRQs are only taken when hypervized. */ |
81 | + * qdev_init_clocks: | 91 | + return false; |
82 | + * @dev: the device to add clocks to | 92 | + } |
83 | + * @clocks: a QDEV_CLOCK_END-terminated array which contains the | 93 | + return !(env->daif & PSTATE_A); |
84 | + * clocks information. | 94 | default: |
85 | + */ | 95 | g_assert_not_reached(); |
86 | +void qdev_init_clocks(DeviceState *dev, const ClockPortInitArray clocks); | 96 | } |
87 | + | 97 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) |
88 | #endif /* QDEV_CLOCK_H */ | 98 | goto found; |
89 | diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c | 99 | } |
90 | index XXXXXXX..XXXXXXX 100644 | 100 | } |
91 | --- a/hw/core/qdev-clock.c | 101 | + if (interrupt_request & CPU_INTERRUPT_VSERR) { |
92 | +++ b/hw/core/qdev-clock.c | 102 | + excp_idx = EXCP_VSERR; |
93 | @@ -XXX,XX +XXX,XX @@ Clock *qdev_init_clock_in(DeviceState *dev, const char *name, | 103 | + target_el = 1; |
94 | return ncl->clock; | 104 | + if (arm_excp_unmasked(cs, excp_idx, target_el, |
95 | } | 105 | + cur_el, secure, hcr_el2)) { |
96 | 106 | + /* Taking a virtual abort clears HCR_EL2.VSE */ | |
97 | +void qdev_init_clocks(DeviceState *dev, const ClockPortInitArray clocks) | 107 | + env->cp15.hcr_el2 &= ~HCR_VSE; |
108 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); | ||
109 | + goto found; | ||
110 | + } | ||
111 | + } | ||
112 | return false; | ||
113 | |||
114 | found: | ||
115 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu) | ||
116 | } | ||
117 | } | ||
118 | |||
119 | +void arm_cpu_update_vserr(ARMCPU *cpu) | ||
98 | +{ | 120 | +{ |
99 | + const struct ClockPortInitElem *elem; | 121 | + /* |
100 | + | 122 | + * Update the interrupt level for VSERR, which is the HCR_EL2.VSE bit. |
101 | + for (elem = &clocks[0]; elem->name != NULL; elem++) { | 123 | + */ |
102 | + Clock **clkp; | 124 | + CPUARMState *env = &cpu->env; |
103 | + /* offset cannot be inside the DeviceState part */ | 125 | + CPUState *cs = CPU(cpu); |
104 | + assert(elem->offset > sizeof(DeviceState)); | 126 | + |
105 | + clkp = (Clock **)(((void *) dev) + elem->offset); | 127 | + bool new_state = env->cp15.hcr_el2 & HCR_VSE; |
106 | + if (elem->is_output) { | 128 | + |
107 | + *clkp = qdev_init_clock_out(dev, elem->name); | 129 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VSERR) != 0)) { |
130 | + if (new_state) { | ||
131 | + cpu_interrupt(cs, CPU_INTERRUPT_VSERR); | ||
108 | + } else { | 132 | + } else { |
109 | + *clkp = qdev_init_clock_in(dev, elem->name, elem->callback, dev); | 133 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); |
110 | + } | 134 | + } |
111 | + } | 135 | + } |
112 | +} | 136 | +} |
113 | + | 137 | + |
114 | static NamedClockList *qdev_get_clocklist(DeviceState *dev, const char *name) | 138 | #ifndef CONFIG_USER_ONLY |
139 | static void arm_cpu_set_irq(void *opaque, int irq, int level) | ||
115 | { | 140 | { |
116 | NamedClockList *ncl; | 141 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
142 | index XXXXXXX..XXXXXXX 100644 | ||
143 | --- a/target/arm/helper.c | ||
144 | +++ b/target/arm/helper.c | ||
145 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
146 | } | ||
147 | } | ||
148 | |||
149 | - /* External aborts are not possible in QEMU so A bit is always clear */ | ||
150 | + if (hcr_el2 & HCR_AMO) { | ||
151 | + if (cs->interrupt_request & CPU_INTERRUPT_VSERR) { | ||
152 | + ret |= CPSR_A; | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | return ret; | ||
157 | } | ||
158 | |||
159 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
160 | g_assert(qemu_mutex_iothread_locked()); | ||
161 | arm_cpu_update_virq(cpu); | ||
162 | arm_cpu_update_vfiq(cpu); | ||
163 | + arm_cpu_update_vserr(cpu); | ||
164 | } | ||
165 | |||
166 | static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
167 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs) | ||
168 | [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
169 | [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
170 | [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", | ||
171 | + [EXCP_VSERR] = "Virtual SERR", | ||
172 | }; | ||
173 | |||
174 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
175 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) | ||
176 | mask = CPSR_A | CPSR_I | CPSR_F; | ||
177 | offset = 4; | ||
178 | break; | ||
179 | + case EXCP_VSERR: | ||
180 | + { | ||
181 | + /* | ||
182 | + * Note that this is reported as a data abort, but the DFAR | ||
183 | + * has an UNKNOWN value. Construct the SError syndrome from | ||
184 | + * AET and ExT fields. | ||
185 | + */ | ||
186 | + ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal, }; | ||
187 | + | ||
188 | + if (extended_addresses_enabled(env)) { | ||
189 | + env->exception.fsr = arm_fi_to_lfsc(&fi); | ||
190 | + } else { | ||
191 | + env->exception.fsr = arm_fi_to_sfsc(&fi); | ||
192 | + } | ||
193 | + env->exception.fsr |= env->cp15.vsesr_el2 & 0xd000; | ||
194 | + A32_BANKED_CURRENT_REG_SET(env, dfsr, env->exception.fsr); | ||
195 | + qemu_log_mask(CPU_LOG_INT, "...with IFSR 0x%x\n", | ||
196 | + env->exception.fsr); | ||
197 | + | ||
198 | + new_mode = ARM_CPU_MODE_ABT; | ||
199 | + addr = 0x10; | ||
200 | + mask = CPSR_A | CPSR_I; | ||
201 | + offset = 8; | ||
202 | + } | ||
203 | + break; | ||
204 | case EXCP_SMC: | ||
205 | new_mode = ARM_CPU_MODE_MON; | ||
206 | addr = 0x08; | ||
207 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
208 | case EXCP_VFIQ: | ||
209 | addr += 0x100; | ||
210 | break; | ||
211 | + case EXCP_VSERR: | ||
212 | + addr += 0x180; | ||
213 | + /* Construct the SError syndrome from IDS and ISS fields. */ | ||
214 | + env->exception.syndrome = syn_serror(env->cp15.vsesr_el2 & 0x1ffffff); | ||
215 | + env->cp15.esr_el[new_el] = env->exception.syndrome; | ||
216 | + break; | ||
217 | default: | ||
218 | cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); | ||
219 | } | ||
117 | -- | 220 | -- |
118 | 2.20.1 | 221 | 2.25.1 |
119 | |||
120 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | These instructions are often used in glibc's string routines. | 3 | Check for and defer any pending virtual SError. |
4 | They were the final uses of the 32-bit at a time neon helpers. | ||
5 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200418162808.4680-1-richard.henderson@linaro.org | 7 | Message-id: 20220506180242.216785-17-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 9 | --- |
11 | target/arm/helper.h | 27 ++-- | 10 | target/arm/helper.h | 1 + |
12 | target/arm/translate.h | 5 + | 11 | target/arm/a32.decode | 16 ++++++++------ |
13 | target/arm/neon_helper.c | 24 ---- | 12 | target/arm/t32.decode | 18 ++++++++-------- |
14 | target/arm/translate-a64.c | 64 +++------- | 13 | target/arm/op_helper.c | 43 ++++++++++++++++++++++++++++++++++++++ |
15 | target/arm/translate.c | 256 +++++++++++++++++++++++++++++++------ | 14 | target/arm/translate-a64.c | 17 +++++++++++++++ |
16 | target/arm/vec_helper.c | 25 ++++ | 15 | target/arm/translate.c | 23 ++++++++++++++++++++ |
17 | 6 files changed, 278 insertions(+), 123 deletions(-) | 16 | 6 files changed, 103 insertions(+), 15 deletions(-) |
18 | 17 | ||
19 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 18 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
20 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.h | 20 | --- a/target/arm/helper.h |
22 | +++ b/target/arm/helper.h | 21 | +++ b/target/arm/helper.h |
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(neon_hsub_u16, i32, i32, i32) | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_1(wfe, void, env) |
24 | DEF_HELPER_2(neon_hsub_s32, s32, s32, s32) | 23 | DEF_HELPER_1(yield, void, env) |
25 | DEF_HELPER_2(neon_hsub_u32, i32, i32, i32) | 24 | DEF_HELPER_1(pre_hvc, void, env) |
26 | 25 | DEF_HELPER_2(pre_smc, void, env, i32) | |
27 | -DEF_HELPER_2(neon_cgt_u8, i32, i32, i32) | 26 | +DEF_HELPER_1(vesb, void, env) |
28 | -DEF_HELPER_2(neon_cgt_s8, i32, i32, i32) | 27 | |
29 | -DEF_HELPER_2(neon_cgt_u16, i32, i32, i32) | 28 | DEF_HELPER_3(cpsr_write, void, env, i32, i32) |
30 | -DEF_HELPER_2(neon_cgt_s16, i32, i32, i32) | 29 | DEF_HELPER_2(cpsr_write_eret, void, env, i32) |
31 | -DEF_HELPER_2(neon_cgt_u32, i32, i32, i32) | 30 | diff --git a/target/arm/a32.decode b/target/arm/a32.decode |
32 | -DEF_HELPER_2(neon_cgt_s32, i32, i32, i32) | 31 | index XXXXXXX..XXXXXXX 100644 |
33 | -DEF_HELPER_2(neon_cge_u8, i32, i32, i32) | 32 | --- a/target/arm/a32.decode |
34 | -DEF_HELPER_2(neon_cge_s8, i32, i32, i32) | 33 | +++ b/target/arm/a32.decode |
35 | -DEF_HELPER_2(neon_cge_u16, i32, i32, i32) | 34 | @@ -XXX,XX +XXX,XX @@ SMULTT .... 0001 0110 .... 0000 .... 1110 .... @rd0mn |
36 | -DEF_HELPER_2(neon_cge_s16, i32, i32, i32) | 35 | |
37 | -DEF_HELPER_2(neon_cge_u32, i32, i32, i32) | 36 | { |
38 | -DEF_HELPER_2(neon_cge_s32, i32, i32, i32) | 37 | { |
39 | - | 38 | - YIELD ---- 0011 0010 0000 1111 ---- 0000 0001 |
40 | DEF_HELPER_2(neon_pmin_u8, i32, i32, i32) | 39 | - WFE ---- 0011 0010 0000 1111 ---- 0000 0010 |
41 | DEF_HELPER_2(neon_pmin_s8, i32, i32, i32) | 40 | - WFI ---- 0011 0010 0000 1111 ---- 0000 0011 |
42 | DEF_HELPER_2(neon_pmin_u16, i32, i32, i32) | 41 | + [ |
43 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(neon_mul_u16, i32, i32, i32) | 42 | + YIELD ---- 0011 0010 0000 1111 ---- 0000 0001 |
44 | DEF_HELPER_2(neon_tst_u8, i32, i32, i32) | 43 | + WFE ---- 0011 0010 0000 1111 ---- 0000 0010 |
45 | DEF_HELPER_2(neon_tst_u16, i32, i32, i32) | 44 | + WFI ---- 0011 0010 0000 1111 ---- 0000 0011 |
46 | DEF_HELPER_2(neon_tst_u32, i32, i32, i32) | 45 | |
47 | -DEF_HELPER_2(neon_ceq_u8, i32, i32, i32) | 46 | - # TODO: Implement SEV, SEVL; may help SMP performance. |
48 | -DEF_HELPER_2(neon_ceq_u16, i32, i32, i32) | 47 | - # SEV ---- 0011 0010 0000 1111 ---- 0000 0100 |
49 | -DEF_HELPER_2(neon_ceq_u32, i32, i32, i32) | 48 | - # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101 |
50 | 49 | + # TODO: Implement SEV, SEVL; may help SMP performance. | |
51 | DEF_HELPER_1(neon_clz_u8, i32, i32) | 50 | + # SEV ---- 0011 0010 0000 1111 ---- 0000 0100 |
52 | DEF_HELPER_1(neon_clz_u16, i32, i32) | 51 | + # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101 |
53 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(frint64_s, TCG_CALL_NO_RWG, f32, f32, ptr) | 52 | + |
54 | DEF_HELPER_FLAGS_2(frint32_d, TCG_CALL_NO_RWG, f64, f64, ptr) | 53 | + ESB ---- 0011 0010 0000 1111 ---- 0001 0000 |
55 | DEF_HELPER_FLAGS_2(frint64_d, TCG_CALL_NO_RWG, f64, f64, ptr) | 54 | + ] |
56 | 55 | ||
57 | +DEF_HELPER_FLAGS_3(gvec_ceq0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 56 | # The canonical nop ends in 00000000, but the whole of the |
58 | +DEF_HELPER_FLAGS_3(gvec_ceq0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 57 | # rest of the space executes as nop if otherwise unsupported. |
59 | +DEF_HELPER_FLAGS_3(gvec_clt0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
60 | +DEF_HELPER_FLAGS_3(gvec_clt0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 59 | index XXXXXXX..XXXXXXX 100644 |
61 | +DEF_HELPER_FLAGS_3(gvec_cle0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 60 | --- a/target/arm/t32.decode |
62 | +DEF_HELPER_FLAGS_3(gvec_cle0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 61 | +++ b/target/arm/t32.decode |
63 | +DEF_HELPER_FLAGS_3(gvec_cgt0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 62 | @@ -XXX,XX +XXX,XX @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 .... @rdm |
64 | +DEF_HELPER_FLAGS_3(gvec_cgt0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 63 | [ |
65 | +DEF_HELPER_FLAGS_3(gvec_cge0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 64 | # Hints, and CPS |
66 | +DEF_HELPER_FLAGS_3(gvec_cge0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 65 | { |
67 | + | 66 | - YIELD 1111 0011 1010 1111 1000 0000 0000 0001 |
68 | DEF_HELPER_FLAGS_4(gvec_sshl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 67 | - WFE 1111 0011 1010 1111 1000 0000 0000 0010 |
69 | DEF_HELPER_FLAGS_4(gvec_sshl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 68 | - WFI 1111 0011 1010 1111 1000 0000 0000 0011 |
70 | DEF_HELPER_FLAGS_4(gvec_ushl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 69 | + [ |
71 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 70 | + YIELD 1111 0011 1010 1111 1000 0000 0000 0001 |
72 | index XXXXXXX..XXXXXXX 100644 | 71 | + WFE 1111 0011 1010 1111 1000 0000 0000 0010 |
73 | --- a/target/arm/translate.h | 72 | + WFI 1111 0011 1010 1111 1000 0000 0000 0011 |
74 | +++ b/target/arm/translate.h | 73 | |
75 | @@ -XXX,XX +XXX,XX @@ static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) | 74 | - # TODO: Implement SEV, SEVL; may help SMP performance. |
76 | uint64_t vfp_expand_imm(int size, uint8_t imm8); | 75 | - # SEV 1111 0011 1010 1111 1000 0000 0000 0100 |
77 | 76 | - # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 | |
78 | /* Vector operations shared between ARM and AArch64. */ | 77 | + # TODO: Implement SEV, SEVL; may help SMP performance. |
79 | +extern const GVecGen2 ceq0_op[4]; | 78 | + # SEV 1111 0011 1010 1111 1000 0000 0000 0100 |
80 | +extern const GVecGen2 clt0_op[4]; | 79 | + # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 |
81 | +extern const GVecGen2 cgt0_op[4]; | 80 | |
82 | +extern const GVecGen2 cle0_op[4]; | 81 | - # For M-profile minimal-RAS ESB can be a NOP, which is the |
83 | +extern const GVecGen2 cge0_op[4]; | 82 | - # default behaviour since it is in the hint space. |
84 | extern const GVecGen3 mla_op[4]; | 83 | - # ESB 1111 0011 1010 1111 1000 0000 0001 0000 |
85 | extern const GVecGen3 mls_op[4]; | 84 | + ESB 1111 0011 1010 1111 1000 0000 0001 0000 |
86 | extern const GVecGen3 cmtst_op[4]; | 85 | + ] |
87 | diff --git a/target/arm/neon_helper.c b/target/arm/neon_helper.c | 86 | |
88 | index XXXXXXX..XXXXXXX 100644 | 87 | # The canonical nop ends in 0000 0000, but the whole rest |
89 | --- a/target/arm/neon_helper.c | 88 | # of the space is "reserved hint, behaves as nop". |
90 | +++ b/target/arm/neon_helper.c | 89 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
91 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_hsub_u32)(uint32_t src1, uint32_t src2) | 90 | index XXXXXXX..XXXXXXX 100644 |
92 | return dest; | 91 | --- a/target/arm/op_helper.c |
92 | +++ b/target/arm/op_helper.c | ||
93 | @@ -XXX,XX +XXX,XX @@ void HELPER(probe_access)(CPUARMState *env, target_ulong ptr, | ||
94 | access_type, mmu_idx, ra); | ||
95 | } | ||
93 | } | 96 | } |
94 | 97 | + | |
95 | -#define NEON_FN(dest, src1, src2) dest = (src1 > src2) ? ~0 : 0 | 98 | +/* |
96 | -NEON_VOP(cgt_s8, neon_s8, 4) | 99 | + * This function corresponds to AArch64.vESBOperation(). |
97 | -NEON_VOP(cgt_u8, neon_u8, 4) | 100 | + * Note that the AArch32 version is not functionally different. |
98 | -NEON_VOP(cgt_s16, neon_s16, 2) | 101 | + */ |
99 | -NEON_VOP(cgt_u16, neon_u16, 2) | 102 | +void HELPER(vesb)(CPUARMState *env) |
100 | -NEON_VOP(cgt_s32, neon_s32, 1) | 103 | +{ |
101 | -NEON_VOP(cgt_u32, neon_u32, 1) | 104 | + /* |
102 | -#undef NEON_FN | 105 | + * The EL2Enabled() check is done inside arm_hcr_el2_eff, |
103 | - | 106 | + * and will return HCR_EL2.VSE == 0, so nothing happens. |
104 | -#define NEON_FN(dest, src1, src2) dest = (src1 >= src2) ? ~0 : 0 | 107 | + */ |
105 | -NEON_VOP(cge_s8, neon_s8, 4) | 108 | + uint64_t hcr = arm_hcr_el2_eff(env); |
106 | -NEON_VOP(cge_u8, neon_u8, 4) | 109 | + bool enabled = !(hcr & HCR_TGE) && (hcr & HCR_AMO); |
107 | -NEON_VOP(cge_s16, neon_s16, 2) | 110 | + bool pending = enabled && (hcr & HCR_VSE); |
108 | -NEON_VOP(cge_u16, neon_u16, 2) | 111 | + bool masked = (env->daif & PSTATE_A); |
109 | -NEON_VOP(cge_s32, neon_s32, 1) | 112 | + |
110 | -NEON_VOP(cge_u32, neon_u32, 1) | 113 | + /* If VSE pending and masked, defer the exception. */ |
111 | -#undef NEON_FN | 114 | + if (pending && masked) { |
112 | - | 115 | + uint32_t syndrome; |
113 | #define NEON_FN(dest, src1, src2) dest = (src1 < src2) ? src1 : src2 | 116 | + |
114 | NEON_POP(pmin_s8, neon_s8, 4) | 117 | + if (arm_el_is_aa64(env, 1)) { |
115 | NEON_POP(pmin_u8, neon_u8, 4) | 118 | + /* Copy across IDS and ISS from VSESR. */ |
116 | @@ -XXX,XX +XXX,XX @@ NEON_VOP(tst_u16, neon_u16, 2) | 119 | + syndrome = env->cp15.vsesr_el2 & 0x1ffffff; |
117 | NEON_VOP(tst_u32, neon_u32, 1) | 120 | + } else { |
118 | #undef NEON_FN | 121 | + ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal }; |
119 | 122 | + | |
120 | -#define NEON_FN(dest, src1, src2) dest = (src1 == src2) ? -1 : 0 | 123 | + if (extended_addresses_enabled(env)) { |
121 | -NEON_VOP(ceq_u8, neon_u8, 4) | 124 | + syndrome = arm_fi_to_lfsc(&fi); |
122 | -NEON_VOP(ceq_u16, neon_u16, 2) | 125 | + } else { |
123 | -NEON_VOP(ceq_u32, neon_u32, 1) | 126 | + syndrome = arm_fi_to_sfsc(&fi); |
124 | -#undef NEON_FN | 127 | + } |
125 | - | 128 | + /* Copy across AET and ExT from VSESR. */ |
126 | /* Count Leading Sign/Zero Bits. */ | 129 | + syndrome |= env->cp15.vsesr_el2 & 0xd000; |
127 | static inline int do_clz8(uint8_t x) | 130 | + } |
128 | { | 131 | + |
132 | + /* Set VDISR_EL2.A along with the syndrome. */ | ||
133 | + env->cp15.vdisr_el2 = syndrome | (1u << 31); | ||
134 | + | ||
135 | + /* Clear pending virtual SError */ | ||
136 | + env->cp15.hcr_el2 &= ~HCR_VSE; | ||
137 | + cpu_reset_interrupt(env_cpu(env), CPU_INTERRUPT_VSERR); | ||
138 | + } | ||
139 | +} | ||
129 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 140 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
130 | index XXXXXXX..XXXXXXX 100644 | 141 | index XXXXXXX..XXXXXXX 100644 |
131 | --- a/target/arm/translate-a64.c | 142 | --- a/target/arm/translate-a64.c |
132 | +++ b/target/arm/translate-a64.c | 143 | +++ b/target/arm/translate-a64.c |
133 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_fn4(DisasContext *s, bool is_q, int rd, int rn, int rm, | 144 | @@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn, |
134 | is_q ? 16 : 8, vec_full_reg_size(s)); | 145 | gen_helper_autib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); |
135 | } | ||
136 | |||
137 | +/* Expand a 2-operand AdvSIMD vector operation using an op descriptor. */ | ||
138 | +static void gen_gvec_op2(DisasContext *s, bool is_q, int rd, | ||
139 | + int rn, const GVecGen2 *gvec_op) | ||
140 | +{ | ||
141 | + tcg_gen_gvec_2(vec_full_reg_offset(s, rd), vec_full_reg_offset(s, rn), | ||
142 | + is_q ? 16 : 8, vec_full_reg_size(s), gvec_op); | ||
143 | +} | ||
144 | + | ||
145 | /* Expand a 2-operand + immediate AdvSIMD vector operation using | ||
146 | * an op descriptor. | ||
147 | */ | ||
148 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | ||
149 | return; | ||
150 | } | 146 | } |
151 | break; | 147 | break; |
152 | + case 0x8: /* CMGT, CMGE */ | 148 | + case 0b10000: /* ESB */ |
153 | + gen_gvec_op2(s, is_q, rd, rn, u ? &cge0_op[size] : &cgt0_op[size]); | 149 | + /* Without RAS, we must implement this as NOP. */ |
154 | + return; | 150 | + if (dc_isar_feature(aa64_ras, s)) { |
155 | + case 0x9: /* CMEQ, CMLE */ | 151 | + /* |
156 | + gen_gvec_op2(s, is_q, rd, rn, u ? &cle0_op[size] : &ceq0_op[size]); | 152 | + * QEMU does not have a source of physical SErrors, |
157 | + return; | 153 | + * so we are only concerned with virtual SErrors. |
158 | + case 0xa: /* CMLT */ | 154 | + * The pseudocode in the ARM for this case is |
159 | + gen_gvec_op2(s, is_q, rd, rn, &clt0_op[size]); | 155 | + * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then |
160 | + return; | 156 | + * AArch64.vESBOperation(); |
161 | case 0xb: | 157 | + * Most of the condition can be evaluated at translation time. |
162 | if (u) { /* ABS, NEG */ | 158 | + * Test for EL2 present, and defer test for SEL2 to runtime. |
163 | gen_gvec_fn2(s, is_q, rd, rn, tcg_gen_gvec_neg, size); | 159 | + */ |
164 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | 160 | + if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) { |
165 | for (pass = 0; pass < (is_q ? 4 : 2); pass++) { | 161 | + gen_helper_vesb(cpu_env); |
166 | TCGv_i32 tcg_op = tcg_temp_new_i32(); | 162 | + } |
167 | TCGv_i32 tcg_res = tcg_temp_new_i32(); | 163 | + } |
168 | - TCGCond cond; | 164 | + break; |
169 | 165 | case 0b11000: /* PACIAZ */ | |
170 | read_vec_element_i32(s, tcg_op, rn, pass, MO_32); | 166 | if (s->pauth_active) { |
171 | 167 | gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], | |
172 | if (size == 2) { | ||
173 | /* Special cases for 32 bit elements */ | ||
174 | switch (opcode) { | ||
175 | - case 0xa: /* CMLT */ | ||
176 | - /* 32 bit integer comparison against zero, result is | ||
177 | - * test ? (2^32 - 1) : 0. We implement via setcond(test) | ||
178 | - * and inverting. | ||
179 | - */ | ||
180 | - cond = TCG_COND_LT; | ||
181 | - do_cmop: | ||
182 | - tcg_gen_setcondi_i32(cond, tcg_res, tcg_op, 0); | ||
183 | - tcg_gen_neg_i32(tcg_res, tcg_res); | ||
184 | - break; | ||
185 | - case 0x8: /* CMGT, CMGE */ | ||
186 | - cond = u ? TCG_COND_GE : TCG_COND_GT; | ||
187 | - goto do_cmop; | ||
188 | - case 0x9: /* CMEQ, CMLE */ | ||
189 | - cond = u ? TCG_COND_LE : TCG_COND_EQ; | ||
190 | - goto do_cmop; | ||
191 | case 0x4: /* CLS */ | ||
192 | if (u) { | ||
193 | tcg_gen_clzi_i32(tcg_res, tcg_op, 32); | ||
194 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | ||
195 | genfn(tcg_res, cpu_env, tcg_op); | ||
196 | break; | ||
197 | } | ||
198 | - case 0x8: /* CMGT, CMGE */ | ||
199 | - case 0x9: /* CMEQ, CMLE */ | ||
200 | - case 0xa: /* CMLT */ | ||
201 | - { | ||
202 | - static NeonGenTwoOpFn * const fns[3][2] = { | ||
203 | - { gen_helper_neon_cgt_s8, gen_helper_neon_cgt_s16 }, | ||
204 | - { gen_helper_neon_cge_s8, gen_helper_neon_cge_s16 }, | ||
205 | - { gen_helper_neon_ceq_u8, gen_helper_neon_ceq_u16 }, | ||
206 | - }; | ||
207 | - NeonGenTwoOpFn *genfn; | ||
208 | - int comp; | ||
209 | - bool reverse; | ||
210 | - TCGv_i32 tcg_zero = tcg_const_i32(0); | ||
211 | - | ||
212 | - /* comp = index into [CMGT, CMGE, CMEQ, CMLE, CMLT] */ | ||
213 | - comp = (opcode - 0x8) * 2 + u; | ||
214 | - /* ...but LE, LT are implemented as reverse GE, GT */ | ||
215 | - reverse = (comp > 2); | ||
216 | - if (reverse) { | ||
217 | - comp = 4 - comp; | ||
218 | - } | ||
219 | - genfn = fns[comp][size]; | ||
220 | - if (reverse) { | ||
221 | - genfn(tcg_res, tcg_zero, tcg_op); | ||
222 | - } else { | ||
223 | - genfn(tcg_res, tcg_op, tcg_zero); | ||
224 | - } | ||
225 | - tcg_temp_free_i32(tcg_zero); | ||
226 | - break; | ||
227 | - } | ||
228 | case 0x4: /* CLS, CLZ */ | ||
229 | if (u) { | ||
230 | if (size == 0) { | ||
231 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 168 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
232 | index XXXXXXX..XXXXXXX 100644 | 169 | index XXXXXXX..XXXXXXX 100644 |
233 | --- a/target/arm/translate.c | 170 | --- a/target/arm/translate.c |
234 | +++ b/target/arm/translate.c | 171 | +++ b/target/arm/translate.c |
235 | @@ -XXX,XX +XXX,XX @@ static int do_v81_helper(DisasContext *s, gen_helper_gvec_3_ptr *fn, | 172 | @@ -XXX,XX +XXX,XX @@ static bool trans_WFI(DisasContext *s, arg_WFI *a) |
236 | return 1; | 173 | return true; |
237 | } | 174 | } |
238 | 175 | ||
239 | +static void gen_ceq0_i32(TCGv_i32 d, TCGv_i32 a) | 176 | +static bool trans_ESB(DisasContext *s, arg_ESB *a) |
240 | +{ | 177 | +{ |
241 | + tcg_gen_setcondi_i32(TCG_COND_EQ, d, a, 0); | 178 | + /* |
242 | + tcg_gen_neg_i32(d, d); | 179 | + * For M-profile, minimal-RAS ESB can be a NOP. |
180 | + * Without RAS, we must implement this as NOP. | ||
181 | + */ | ||
182 | + if (!arm_dc_feature(s, ARM_FEATURE_M) && dc_isar_feature(aa32_ras, s)) { | ||
183 | + /* | ||
184 | + * QEMU does not have a source of physical SErrors, | ||
185 | + * so we are only concerned with virtual SErrors. | ||
186 | + * The pseudocode in the ARM for this case is | ||
187 | + * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then | ||
188 | + * AArch32.vESBOperation(); | ||
189 | + * Most of the condition can be evaluated at translation time. | ||
190 | + * Test for EL2 present, and defer test for SEL2 to runtime. | ||
191 | + */ | ||
192 | + if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) { | ||
193 | + gen_helper_vesb(cpu_env); | ||
194 | + } | ||
195 | + } | ||
196 | + return true; | ||
243 | +} | 197 | +} |
244 | + | 198 | + |
245 | +static void gen_ceq0_i64(TCGv_i64 d, TCGv_i64 a) | 199 | static bool trans_NOP(DisasContext *s, arg_NOP *a) |
246 | +{ | ||
247 | + tcg_gen_setcondi_i64(TCG_COND_EQ, d, a, 0); | ||
248 | + tcg_gen_neg_i64(d, d); | ||
249 | +} | ||
250 | + | ||
251 | +static void gen_ceq0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
252 | +{ | ||
253 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
254 | + tcg_gen_cmp_vec(TCG_COND_EQ, vece, d, a, zero); | ||
255 | + tcg_temp_free_vec(zero); | ||
256 | +} | ||
257 | + | ||
258 | +static const TCGOpcode vecop_list_cmp[] = { | ||
259 | + INDEX_op_cmp_vec, 0 | ||
260 | +}; | ||
261 | + | ||
262 | +const GVecGen2 ceq0_op[4] = { | ||
263 | + { .fno = gen_helper_gvec_ceq0_b, | ||
264 | + .fniv = gen_ceq0_vec, | ||
265 | + .opt_opc = vecop_list_cmp, | ||
266 | + .vece = MO_8 }, | ||
267 | + { .fno = gen_helper_gvec_ceq0_h, | ||
268 | + .fniv = gen_ceq0_vec, | ||
269 | + .opt_opc = vecop_list_cmp, | ||
270 | + .vece = MO_16 }, | ||
271 | + { .fni4 = gen_ceq0_i32, | ||
272 | + .fniv = gen_ceq0_vec, | ||
273 | + .opt_opc = vecop_list_cmp, | ||
274 | + .vece = MO_32 }, | ||
275 | + { .fni8 = gen_ceq0_i64, | ||
276 | + .fniv = gen_ceq0_vec, | ||
277 | + .opt_opc = vecop_list_cmp, | ||
278 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
279 | + .vece = MO_64 }, | ||
280 | +}; | ||
281 | + | ||
282 | +static void gen_cle0_i32(TCGv_i32 d, TCGv_i32 a) | ||
283 | +{ | ||
284 | + tcg_gen_setcondi_i32(TCG_COND_LE, d, a, 0); | ||
285 | + tcg_gen_neg_i32(d, d); | ||
286 | +} | ||
287 | + | ||
288 | +static void gen_cle0_i64(TCGv_i64 d, TCGv_i64 a) | ||
289 | +{ | ||
290 | + tcg_gen_setcondi_i64(TCG_COND_LE, d, a, 0); | ||
291 | + tcg_gen_neg_i64(d, d); | ||
292 | +} | ||
293 | + | ||
294 | +static void gen_cle0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
295 | +{ | ||
296 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
297 | + tcg_gen_cmp_vec(TCG_COND_LE, vece, d, a, zero); | ||
298 | + tcg_temp_free_vec(zero); | ||
299 | +} | ||
300 | + | ||
301 | +const GVecGen2 cle0_op[4] = { | ||
302 | + { .fno = gen_helper_gvec_cle0_b, | ||
303 | + .fniv = gen_cle0_vec, | ||
304 | + .opt_opc = vecop_list_cmp, | ||
305 | + .vece = MO_8 }, | ||
306 | + { .fno = gen_helper_gvec_cle0_h, | ||
307 | + .fniv = gen_cle0_vec, | ||
308 | + .opt_opc = vecop_list_cmp, | ||
309 | + .vece = MO_16 }, | ||
310 | + { .fni4 = gen_cle0_i32, | ||
311 | + .fniv = gen_cle0_vec, | ||
312 | + .opt_opc = vecop_list_cmp, | ||
313 | + .vece = MO_32 }, | ||
314 | + { .fni8 = gen_cle0_i64, | ||
315 | + .fniv = gen_cle0_vec, | ||
316 | + .opt_opc = vecop_list_cmp, | ||
317 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
318 | + .vece = MO_64 }, | ||
319 | +}; | ||
320 | + | ||
321 | +static void gen_cge0_i32(TCGv_i32 d, TCGv_i32 a) | ||
322 | +{ | ||
323 | + tcg_gen_setcondi_i32(TCG_COND_GE, d, a, 0); | ||
324 | + tcg_gen_neg_i32(d, d); | ||
325 | +} | ||
326 | + | ||
327 | +static void gen_cge0_i64(TCGv_i64 d, TCGv_i64 a) | ||
328 | +{ | ||
329 | + tcg_gen_setcondi_i64(TCG_COND_GE, d, a, 0); | ||
330 | + tcg_gen_neg_i64(d, d); | ||
331 | +} | ||
332 | + | ||
333 | +static void gen_cge0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
334 | +{ | ||
335 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
336 | + tcg_gen_cmp_vec(TCG_COND_GE, vece, d, a, zero); | ||
337 | + tcg_temp_free_vec(zero); | ||
338 | +} | ||
339 | + | ||
340 | +const GVecGen2 cge0_op[4] = { | ||
341 | + { .fno = gen_helper_gvec_cge0_b, | ||
342 | + .fniv = gen_cge0_vec, | ||
343 | + .opt_opc = vecop_list_cmp, | ||
344 | + .vece = MO_8 }, | ||
345 | + { .fno = gen_helper_gvec_cge0_h, | ||
346 | + .fniv = gen_cge0_vec, | ||
347 | + .opt_opc = vecop_list_cmp, | ||
348 | + .vece = MO_16 }, | ||
349 | + { .fni4 = gen_cge0_i32, | ||
350 | + .fniv = gen_cge0_vec, | ||
351 | + .opt_opc = vecop_list_cmp, | ||
352 | + .vece = MO_32 }, | ||
353 | + { .fni8 = gen_cge0_i64, | ||
354 | + .fniv = gen_cge0_vec, | ||
355 | + .opt_opc = vecop_list_cmp, | ||
356 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
357 | + .vece = MO_64 }, | ||
358 | +}; | ||
359 | + | ||
360 | +static void gen_clt0_i32(TCGv_i32 d, TCGv_i32 a) | ||
361 | +{ | ||
362 | + tcg_gen_setcondi_i32(TCG_COND_LT, d, a, 0); | ||
363 | + tcg_gen_neg_i32(d, d); | ||
364 | +} | ||
365 | + | ||
366 | +static void gen_clt0_i64(TCGv_i64 d, TCGv_i64 a) | ||
367 | +{ | ||
368 | + tcg_gen_setcondi_i64(TCG_COND_LT, d, a, 0); | ||
369 | + tcg_gen_neg_i64(d, d); | ||
370 | +} | ||
371 | + | ||
372 | +static void gen_clt0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
373 | +{ | ||
374 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
375 | + tcg_gen_cmp_vec(TCG_COND_LT, vece, d, a, zero); | ||
376 | + tcg_temp_free_vec(zero); | ||
377 | +} | ||
378 | + | ||
379 | +const GVecGen2 clt0_op[4] = { | ||
380 | + { .fno = gen_helper_gvec_clt0_b, | ||
381 | + .fniv = gen_clt0_vec, | ||
382 | + .opt_opc = vecop_list_cmp, | ||
383 | + .vece = MO_8 }, | ||
384 | + { .fno = gen_helper_gvec_clt0_h, | ||
385 | + .fniv = gen_clt0_vec, | ||
386 | + .opt_opc = vecop_list_cmp, | ||
387 | + .vece = MO_16 }, | ||
388 | + { .fni4 = gen_clt0_i32, | ||
389 | + .fniv = gen_clt0_vec, | ||
390 | + .opt_opc = vecop_list_cmp, | ||
391 | + .vece = MO_32 }, | ||
392 | + { .fni8 = gen_clt0_i64, | ||
393 | + .fniv = gen_clt0_vec, | ||
394 | + .opt_opc = vecop_list_cmp, | ||
395 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
396 | + .vece = MO_64 }, | ||
397 | +}; | ||
398 | + | ||
399 | +static void gen_cgt0_i32(TCGv_i32 d, TCGv_i32 a) | ||
400 | +{ | ||
401 | + tcg_gen_setcondi_i32(TCG_COND_GT, d, a, 0); | ||
402 | + tcg_gen_neg_i32(d, d); | ||
403 | +} | ||
404 | + | ||
405 | +static void gen_cgt0_i64(TCGv_i64 d, TCGv_i64 a) | ||
406 | +{ | ||
407 | + tcg_gen_setcondi_i64(TCG_COND_GT, d, a, 0); | ||
408 | + tcg_gen_neg_i64(d, d); | ||
409 | +} | ||
410 | + | ||
411 | +static void gen_cgt0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
412 | +{ | ||
413 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
414 | + tcg_gen_cmp_vec(TCG_COND_GT, vece, d, a, zero); | ||
415 | + tcg_temp_free_vec(zero); | ||
416 | +} | ||
417 | + | ||
418 | +const GVecGen2 cgt0_op[4] = { | ||
419 | + { .fno = gen_helper_gvec_cgt0_b, | ||
420 | + .fniv = gen_cgt0_vec, | ||
421 | + .opt_opc = vecop_list_cmp, | ||
422 | + .vece = MO_8 }, | ||
423 | + { .fno = gen_helper_gvec_cgt0_h, | ||
424 | + .fniv = gen_cgt0_vec, | ||
425 | + .opt_opc = vecop_list_cmp, | ||
426 | + .vece = MO_16 }, | ||
427 | + { .fni4 = gen_cgt0_i32, | ||
428 | + .fniv = gen_cgt0_vec, | ||
429 | + .opt_opc = vecop_list_cmp, | ||
430 | + .vece = MO_32 }, | ||
431 | + { .fni8 = gen_cgt0_i64, | ||
432 | + .fniv = gen_cgt0_vec, | ||
433 | + .opt_opc = vecop_list_cmp, | ||
434 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
435 | + .vece = MO_64 }, | ||
436 | +}; | ||
437 | + | ||
438 | static void gen_ssra8_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
439 | { | 200 | { |
440 | tcg_gen_vec_sar8i_i64(a, a, shift); | 201 | return true; |
441 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
442 | tcg_gen_gvec_abs(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
443 | break; | ||
444 | |||
445 | + case NEON_2RM_VCEQ0: | ||
446 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, | ||
447 | + vec_size, &ceq0_op[size]); | ||
448 | + break; | ||
449 | + case NEON_2RM_VCGT0: | ||
450 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, | ||
451 | + vec_size, &cgt0_op[size]); | ||
452 | + break; | ||
453 | + case NEON_2RM_VCLE0: | ||
454 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, | ||
455 | + vec_size, &cle0_op[size]); | ||
456 | + break; | ||
457 | + case NEON_2RM_VCGE0: | ||
458 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, | ||
459 | + vec_size, &cge0_op[size]); | ||
460 | + break; | ||
461 | + case NEON_2RM_VCLT0: | ||
462 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, | ||
463 | + vec_size, &clt0_op[size]); | ||
464 | + break; | ||
465 | + | ||
466 | default: | ||
467 | elementwise: | ||
468 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
469 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
470 | default: abort(); | ||
471 | } | ||
472 | break; | ||
473 | - case NEON_2RM_VCGT0: case NEON_2RM_VCLE0: | ||
474 | - tmp2 = tcg_const_i32(0); | ||
475 | - switch(size) { | ||
476 | - case 0: gen_helper_neon_cgt_s8(tmp, tmp, tmp2); break; | ||
477 | - case 1: gen_helper_neon_cgt_s16(tmp, tmp, tmp2); break; | ||
478 | - case 2: gen_helper_neon_cgt_s32(tmp, tmp, tmp2); break; | ||
479 | - default: abort(); | ||
480 | - } | ||
481 | - tcg_temp_free_i32(tmp2); | ||
482 | - if (op == NEON_2RM_VCLE0) { | ||
483 | - tcg_gen_not_i32(tmp, tmp); | ||
484 | - } | ||
485 | - break; | ||
486 | - case NEON_2RM_VCGE0: case NEON_2RM_VCLT0: | ||
487 | - tmp2 = tcg_const_i32(0); | ||
488 | - switch(size) { | ||
489 | - case 0: gen_helper_neon_cge_s8(tmp, tmp, tmp2); break; | ||
490 | - case 1: gen_helper_neon_cge_s16(tmp, tmp, tmp2); break; | ||
491 | - case 2: gen_helper_neon_cge_s32(tmp, tmp, tmp2); break; | ||
492 | - default: abort(); | ||
493 | - } | ||
494 | - tcg_temp_free_i32(tmp2); | ||
495 | - if (op == NEON_2RM_VCLT0) { | ||
496 | - tcg_gen_not_i32(tmp, tmp); | ||
497 | - } | ||
498 | - break; | ||
499 | - case NEON_2RM_VCEQ0: | ||
500 | - tmp2 = tcg_const_i32(0); | ||
501 | - switch(size) { | ||
502 | - case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break; | ||
503 | - case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break; | ||
504 | - case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break; | ||
505 | - default: abort(); | ||
506 | - } | ||
507 | - tcg_temp_free_i32(tmp2); | ||
508 | - break; | ||
509 | case NEON_2RM_VCGT0_F: | ||
510 | { | ||
511 | TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
512 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
513 | index XXXXXXX..XXXXXXX 100644 | ||
514 | --- a/target/arm/vec_helper.c | ||
515 | +++ b/target/arm/vec_helper.c | ||
516 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve2_pmull_h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
517 | } | ||
518 | } | ||
519 | #endif | ||
520 | + | ||
521 | +#define DO_CMP0(NAME, TYPE, OP) \ | ||
522 | +void HELPER(NAME)(void *vd, void *vn, uint32_t desc) \ | ||
523 | +{ \ | ||
524 | + intptr_t i, opr_sz = simd_oprsz(desc); \ | ||
525 | + for (i = 0; i < opr_sz; i += sizeof(TYPE)) { \ | ||
526 | + TYPE nn = *(TYPE *)(vn + i); \ | ||
527 | + *(TYPE *)(vd + i) = -(nn OP 0); \ | ||
528 | + } \ | ||
529 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); \ | ||
530 | +} | ||
531 | + | ||
532 | +DO_CMP0(gvec_ceq0_b, int8_t, ==) | ||
533 | +DO_CMP0(gvec_clt0_b, int8_t, <) | ||
534 | +DO_CMP0(gvec_cle0_b, int8_t, <=) | ||
535 | +DO_CMP0(gvec_cgt0_b, int8_t, >) | ||
536 | +DO_CMP0(gvec_cge0_b, int8_t, >=) | ||
537 | + | ||
538 | +DO_CMP0(gvec_ceq0_h, int16_t, ==) | ||
539 | +DO_CMP0(gvec_clt0_h, int16_t, <) | ||
540 | +DO_CMP0(gvec_cle0_h, int16_t, <=) | ||
541 | +DO_CMP0(gvec_cgt0_h, int16_t, >) | ||
542 | +DO_CMP0(gvec_cge0_h, int16_t, >=) | ||
543 | + | ||
544 | +#undef DO_CMP0 | ||
545 | -- | 202 | -- |
546 | 2.20.1 | 203 | 2.25.1 |
547 | |||
548 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Allow name wildcards in qemu_fdt_node_path(). This is useful | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | to find all nodes with a given compatibility string. | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | 5 | Message-id: 20220506180242.216785-18-richard.henderson@linaro.org | |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
8 | Message-id: 20200423121114.4274-2-edgar.iglesias@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 7 | --- |
11 | include/sysemu/device_tree.h | 3 +++ | 8 | docs/system/arm/emulation.rst | 1 + |
12 | device_tree.c | 2 +- | 9 | target/arm/cpu64.c | 1 + |
13 | 2 files changed, 4 insertions(+), 1 deletion(-) | 10 | target/arm/cpu_tcg.c | 1 + |
11 | 3 files changed, 3 insertions(+) | ||
14 | 12 | ||
15 | diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h | 13 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/sysemu/device_tree.h | 15 | --- a/docs/system/arm/emulation.rst |
18 | +++ b/include/sysemu/device_tree.h | 16 | +++ b/docs/system/arm/emulation.rst |
19 | @@ -XXX,XX +XXX,XX @@ void *load_device_tree_from_sysfs(void); | 17 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
20 | * NULL. If there is no error but no matching node was found, the | 18 | - FEAT_PMULL (PMULL, PMULL2 instructions) |
21 | * returned array contains a single element equal to NULL. If an error | 19 | - FEAT_PMUv3p1 (PMU Extensions v3.1) |
22 | * was encountered when parsing the blob, the function returns NULL | 20 | - FEAT_PMUv3p4 (PMU Extensions v3.4) |
23 | + * | 21 | +- FEAT_RAS (Reliability, availability, and serviceability) |
24 | + * @name may be NULL to wildcard names and only match compatibility | 22 | - FEAT_RDM (Advanced SIMD rounding double multiply accumulate instructions) |
25 | + * strings. | 23 | - FEAT_RNG (Random number generator) |
26 | */ | 24 | - FEAT_SB (Speculation Barrier) |
27 | char **qemu_fdt_node_path(void *fdt, const char *name, char *compat, | 25 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
28 | Error **errp); | ||
29 | diff --git a/device_tree.c b/device_tree.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/device_tree.c | 27 | --- a/target/arm/cpu64.c |
32 | +++ b/device_tree.c | 28 | +++ b/target/arm/cpu64.c |
33 | @@ -XXX,XX +XXX,XX @@ char **qemu_fdt_node_path(void *fdt, const char *name, char *compat, | 29 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
34 | offset = len; | 30 | t = cpu->isar.id_aa64pfr0; |
35 | break; | 31 | t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ |
36 | } | 32 | t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ |
37 | - if (!strcmp(iter_name, name)) { | 33 | + t = FIELD_DP64(t, ID_AA64PFR0, RAS, 1); /* FEAT_RAS */ |
38 | + if (!name || !strcmp(iter_name, name)) { | 34 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); |
39 | char *path; | 35 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ |
40 | 36 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | |
41 | path = g_malloc(path_len); | 37 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/cpu_tcg.c | ||
40 | +++ b/target/arm/cpu_tcg.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
42 | |||
43 | t = cpu->isar.id_pfr0; | ||
44 | t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ | ||
45 | + t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */ | ||
46 | cpu->isar.id_pfr0 = t; | ||
47 | |||
48 | t = cpu->isar.id_pfr2; | ||
42 | -- | 49 | -- |
43 | 2.20.1 | 50 | 2.25.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | From: Ramon Fried <rfried.dev@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Wraparound of TX descriptor cyclic buffer only updated | 3 | This feature is AArch64 only, and applies to physical SErrors, |
4 | the low 32 bits of the descriptor. | 4 | which QEMU does not implement, thus the feature is a nop. |
5 | Fix that by checking if we're working with 64bit descriptors. | ||
6 | 5 | ||
7 | Signed-off-by: Ramon Fried <rfried.dev@gmail.com> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20200417171736.441607-1-rfried.dev@gmail.com | 8 | Message-id: 20220506180242.216785-19-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | hw/net/cadence_gem.c | 9 ++++++++- | 11 | docs/system/arm/emulation.rst | 1 + |
13 | 1 file changed, 8 insertions(+), 1 deletion(-) | 12 | target/arm/cpu64.c | 1 + |
13 | 2 files changed, 2 insertions(+) | ||
14 | 14 | ||
15 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c | 15 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/net/cadence_gem.c | 17 | --- a/docs/system/arm/emulation.rst |
18 | +++ b/hw/net/cadence_gem.c | 18 | +++ b/docs/system/arm/emulation.rst |
19 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | 19 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
20 | /* read next descriptor */ | 20 | - FEAT_FlagM2 (Enhancements to flag manipulation instructions) |
21 | if (tx_desc_get_wrap(desc)) { | 21 | - FEAT_HPDS (Hierarchical permission disables) |
22 | tx_desc_set_last(desc); | 22 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) |
23 | - packet_desc_addr = s->regs[GEM_TXQBASE]; | 23 | +- FEAT_IESB (Implicit error synchronization event) |
24 | + | 24 | - FEAT_JSCVT (JavaScript conversion instructions) |
25 | + if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) { | 25 | - FEAT_LOR (Limited ordering regions) |
26 | + packet_desc_addr = s->regs[GEM_TBQPH]; | 26 | - FEAT_LPA (Large Physical Address space) |
27 | + packet_desc_addr <<= 32; | 27 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
28 | + } else { | 28 | index XXXXXXX..XXXXXXX 100644 |
29 | + packet_desc_addr = 0; | 29 | --- a/target/arm/cpu64.c |
30 | + } | 30 | +++ b/target/arm/cpu64.c |
31 | + packet_desc_addr |= s->regs[GEM_TXQBASE]; | 31 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
32 | } else { | 32 | t = cpu->isar.id_aa64mmfr2; |
33 | packet_desc_addr += 4 * gem_get_desc_len(s, false); | 33 | t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */ |
34 | } | 34 | t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */ |
35 | + t = FIELD_DP64(t, ID_AA64MMFR2, IESB, 1); /* FEAT_IESB */ | ||
36 | t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ | ||
37 | t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */ | ||
38 | t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
35 | -- | 39 | -- |
36 | 2.20.1 | 40 | 2.25.1 |
37 | |||
38 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This prints the clocks attached to a DeviceState when using | 3 | This extension concerns branch speculation, which TCG does |
4 | "info qtree" monitor command. For every clock, it displays the | 4 | not implement. Thus we can trivially enable this feature. |
5 | direction, the name and if the clock is forwarded. For input clock, | ||
6 | it displays also the frequency. | ||
7 | 5 | ||
8 | This is based on the original work of Frederic Konrad. | ||
9 | |||
10 | Here follows a sample of `info qtree` output on xilinx_zynq machine | ||
11 | after linux boot with only one uart clocked: | ||
12 | > bus: main-system-bus | ||
13 | > type System | ||
14 | > [...] | ||
15 | > dev: cadence_uart, id "" | ||
16 | > gpio-out "sysbus-irq" 1 | ||
17 | > clock-in "refclk" freq_hz=0.000000e+00 | ||
18 | > chardev = "" | ||
19 | > mmio 00000000e0001000/0000000000001000 | ||
20 | > dev: cadence_uart, id "" | ||
21 | > gpio-out "sysbus-irq" 1 | ||
22 | > clock-in "refclk" freq_hz=1.375661e+07 | ||
23 | > chardev = "serial0" | ||
24 | > mmio 00000000e0000000/0000000000001000 | ||
25 | > [...] | ||
26 | > dev: xilinx,zynq_slcr, id "" | ||
27 | > clock-out "uart1_ref_clk" freq_hz=0.000000e+00 | ||
28 | > clock-out "uart0_ref_clk" freq_hz=1.375661e+07 | ||
29 | > clock-in "ps_clk" freq_hz=3.333333e+07 | ||
30 | > mmio 00000000f8000000/0000000000001000 | ||
31 | |||
32 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
33 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
34 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
35 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
36 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | Message-id: 20220506180242.216785-20-richard.henderson@linaro.org |
37 | Message-id: 20200406135251.157596-10-damien.hedde@greensocs.com | ||
38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
39 | --- | 10 | --- |
40 | qdev-monitor.c | 9 +++++++++ | 11 | docs/system/arm/emulation.rst | 1 + |
41 | 1 file changed, 9 insertions(+) | 12 | target/arm/cpu64.c | 1 + |
13 | target/arm/cpu_tcg.c | 1 + | ||
14 | 3 files changed, 3 insertions(+) | ||
42 | 15 | ||
43 | diff --git a/qdev-monitor.c b/qdev-monitor.c | 16 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
44 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/qdev-monitor.c | 18 | --- a/docs/system/arm/emulation.rst |
46 | +++ b/qdev-monitor.c | 19 | +++ b/docs/system/arm/emulation.rst |
47 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
48 | #include "migration/misc.h" | 21 | - FEAT_BBM at level 2 (Translation table break-before-make levels) |
49 | #include "migration/migration.h" | 22 | - FEAT_BF16 (AArch64 BFloat16 instructions) |
50 | #include "qemu/cutils.h" | 23 | - FEAT_BTI (Branch Target Identification) |
51 | +#include "hw/clock.h" | 24 | +- FEAT_CSV2 (Cache speculation variant 2) |
52 | 25 | - FEAT_DIT (Data Independent Timing instructions) | |
53 | /* | 26 | - FEAT_DPB (DC CVAP instruction) |
54 | * Aliases were a bad idea from the start. Let's keep them | 27 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
55 | @@ -XXX,XX +XXX,XX @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent) | 28 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
56 | ObjectClass *class; | 29 | index XXXXXXX..XXXXXXX 100644 |
57 | BusState *child; | 30 | --- a/target/arm/cpu64.c |
58 | NamedGPIOList *ngl; | 31 | +++ b/target/arm/cpu64.c |
59 | + NamedClockList *ncl; | 32 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
60 | 33 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | |
61 | qdev_printf("dev: %s, id \"%s\"\n", object_get_typename(OBJECT(dev)), | 34 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ |
62 | dev->id ? dev->id : ""); | 35 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ |
63 | @@ -XXX,XX +XXX,XX @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent) | 36 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1); /* FEAT_CSV2 */ |
64 | ngl->num_out); | 37 | cpu->isar.id_aa64pfr0 = t; |
65 | } | 38 | |
66 | } | 39 | t = cpu->isar.id_aa64pfr1; |
67 | + QLIST_FOREACH(ncl, &dev->clocks, node) { | 40 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
68 | + qdev_printf("clock-%s%s \"%s\" freq_hz=%e\n", | 41 | index XXXXXXX..XXXXXXX 100644 |
69 | + ncl->output ? "out" : "in", | 42 | --- a/target/arm/cpu_tcg.c |
70 | + ncl->alias ? " (alias)" : "", | 43 | +++ b/target/arm/cpu_tcg.c |
71 | + ncl->name, | 44 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
72 | + CLOCK_PERIOD_TO_HZ(1.0 * clock_get(ncl->clock))); | 45 | cpu->isar.id_mmfr4 = t; |
73 | + } | 46 | |
74 | class = object_get_class(OBJECT(dev)); | 47 | t = cpu->isar.id_pfr0; |
75 | do { | 48 | + t = FIELD_DP32(t, ID_PFR0, CSV2, 2); /* FEAT_CVS2 */ |
76 | qdev_print_props(mon, dev, DEVICE_CLASS(class)->props_, indent); | 49 | t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ |
50 | t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */ | ||
51 | cpu->isar.id_pfr0 = t; | ||
77 | -- | 52 | -- |
78 | 2.20.1 | 53 | 2.25.1 |
79 | |||
80 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | 3 | There is no branch prediction in TCG, therefore there is no |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | need to actually include the context number into the predictor. |
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | Therefore all we need to do is add the state for SCXTNUM_ELx. |
6 | Message-id: 20200423073358.27155-4-philmd@redhat.com | 6 | |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220506180242.216785-21-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 11 | --- |
9 | target/arm/cpu.c | 8 +++----- | 12 | docs/system/arm/emulation.rst | 3 ++ |
10 | target/arm/cpu64.c | 8 +++----- | 13 | target/arm/cpu.h | 16 +++++++++ |
11 | 2 files changed, 6 insertions(+), 10 deletions(-) | 14 | target/arm/cpu.c | 5 +++ |
15 | target/arm/cpu64.c | 3 +- | ||
16 | target/arm/helper.c | 61 ++++++++++++++++++++++++++++++++++- | ||
17 | 5 files changed, 86 insertions(+), 2 deletions(-) | ||
12 | 18 | ||
19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/docs/system/arm/emulation.rst | ||
22 | +++ b/docs/system/arm/emulation.rst | ||
23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | ||
24 | - FEAT_BF16 (AArch64 BFloat16 instructions) | ||
25 | - FEAT_BTI (Branch Target Identification) | ||
26 | - FEAT_CSV2 (Cache speculation variant 2) | ||
27 | +- FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) | ||
28 | +- FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) | ||
29 | +- FEAT_CSV2_2 (Cache speculation variant 2, version 2) | ||
30 | - FEAT_DIT (Data Independent Timing instructions) | ||
31 | - FEAT_DPB (DC CVAP instruction) | ||
32 | - FEAT_Debugv8p2 (Debug changes for v8.2) | ||
33 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/cpu.h | ||
36 | +++ b/target/arm/cpu.h | ||
37 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
38 | ARMPACKey apdb; | ||
39 | ARMPACKey apga; | ||
40 | } keys; | ||
41 | + | ||
42 | + uint64_t scxtnum_el[4]; | ||
43 | #endif | ||
44 | |||
45 | #if defined(CONFIG_USER_ONLY) | ||
46 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
47 | #define SCTLR_WXN (1U << 19) | ||
48 | #define SCTLR_ST (1U << 20) /* up to ??, RAZ in v6 */ | ||
49 | #define SCTLR_UWXN (1U << 20) /* v7 onward, AArch32 only */ | ||
50 | +#define SCTLR_TSCXT (1U << 20) /* FEAT_CSV2_1p2, AArch64 only */ | ||
51 | #define SCTLR_FI (1U << 21) /* up to v7, v8 RES0 */ | ||
52 | #define SCTLR_IESB (1U << 21) /* v8.2-IESB, AArch64 only */ | ||
53 | #define SCTLR_U (1U << 22) /* up to v6, RAO in v7 */ | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) | ||
55 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; | ||
56 | } | ||
57 | |||
58 | +static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id) | ||
59 | +{ | ||
60 | + int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2); | ||
61 | + if (key >= 2) { | ||
62 | + return true; /* FEAT_CSV2_2 */ | ||
63 | + } | ||
64 | + if (key == 1) { | ||
65 | + key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC); | ||
66 | + return key >= 2; /* FEAT_CSV2_1p2 */ | ||
67 | + } | ||
68 | + return false; | ||
69 | +} | ||
70 | + | ||
71 | static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | ||
72 | { | ||
73 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | ||
13 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 74 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
14 | index XXXXXXX..XXXXXXX 100644 | 75 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.c | 76 | --- a/target/arm/cpu.c |
16 | +++ b/target/arm/cpu.c | 77 | +++ b/target/arm/cpu.c |
17 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { | 78 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
18 | { .name = "any", .initfn = arm_max_initfn }, | 79 | */ |
19 | #endif | 80 | env->cp15.gcr_el1 = 0x1ffff; |
20 | #endif | 81 | } |
21 | - { .name = NULL } | 82 | + /* |
22 | }; | 83 | + * Disable access to SCXTNUM_EL0 from CSV2_1p2. |
23 | 84 | + * This is not yet exposed from the Linux kernel in any way. | |
24 | static Property arm_cpu_properties[] = { | 85 | + */ |
25 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo idau_interface_type_info = { | 86 | + env->cp15.sctlr_el[1] |= SCTLR_TSCXT; |
26 | 87 | #else | |
27 | static void arm_cpu_register_types(void) | 88 | /* Reset into the highest available EL */ |
28 | { | 89 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
29 | - const ARMCPUInfo *info = arm_cpus; | ||
30 | + size_t i; | ||
31 | |||
32 | type_register_static(&arm_cpu_type_info); | ||
33 | type_register_static(&idau_interface_type_info); | ||
34 | |||
35 | - while (info->name) { | ||
36 | - arm_cpu_register(info); | ||
37 | - info++; | ||
38 | + for (i = 0; i < ARRAY_SIZE(arm_cpus); ++i) { | ||
39 | + arm_cpu_register(&arm_cpus[i]); | ||
40 | } | ||
41 | |||
42 | #ifdef CONFIG_KVM | ||
43 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 90 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
44 | index XXXXXXX..XXXXXXX 100644 | 91 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/target/arm/cpu64.c | 92 | --- a/target/arm/cpu64.c |
46 | +++ b/target/arm/cpu64.c | 93 | +++ b/target/arm/cpu64.c |
47 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { | 94 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
48 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, | 95 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); |
49 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | 96 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ |
50 | { .name = "max", .initfn = aarch64_max_initfn }, | 97 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ |
51 | - { .name = NULL } | 98 | - t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1); /* FEAT_CSV2 */ |
99 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ | ||
100 | cpu->isar.id_aa64pfr0 = t; | ||
101 | |||
102 | t = cpu->isar.id_aa64pfr1; | ||
103 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
104 | * we do for EL2 with the virtualization=on property. | ||
105 | */ | ||
106 | t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ | ||
107 | + t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ | ||
108 | cpu->isar.id_aa64pfr1 = t; | ||
109 | |||
110 | t = cpu->isar.id_aa64mmfr0; | ||
111 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/arm/helper.c | ||
114 | +++ b/target/arm/helper.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
116 | if (cpu_isar_feature(aa64_mte, cpu)) { | ||
117 | valid_mask |= SCR_ATA; | ||
118 | } | ||
119 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { | ||
120 | + valid_mask |= SCR_ENSCXT; | ||
121 | + } | ||
122 | } else { | ||
123 | valid_mask &= ~(SCR_RW | SCR_ST); | ||
124 | if (cpu_isar_feature(aa32_ras, cpu)) { | ||
125 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
126 | if (cpu_isar_feature(aa64_mte, cpu)) { | ||
127 | valid_mask |= HCR_ATA | HCR_DCT | HCR_TID5; | ||
128 | } | ||
129 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { | ||
130 | + valid_mask |= HCR_ENSCXT; | ||
131 | + } | ||
132 | } | ||
133 | |||
134 | /* Clear RES0 bits. */ | ||
135 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
136 | { K(3, 0, 5, 6, 0), K(3, 4, 5, 6, 0), K(3, 5, 5, 6, 0), | ||
137 | "TFSR_EL1", "TFSR_EL2", "TFSR_EL12", isar_feature_aa64_mte }, | ||
138 | |||
139 | + { K(3, 0, 13, 0, 7), K(3, 4, 13, 0, 7), K(3, 5, 13, 0, 7), | ||
140 | + "SCXTNUM_EL1", "SCXTNUM_EL2", "SCXTNUM_EL12", | ||
141 | + isar_feature_aa64_scxtnum }, | ||
142 | + | ||
143 | /* TODO: ARMv8.2-SPE -- PMSCR_EL2 */ | ||
144 | /* TODO: ARMv8.4-Trace -- TRFCR_EL2 */ | ||
145 | }; | ||
146 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
147 | }, | ||
52 | }; | 148 | }; |
53 | 149 | ||
54 | static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp) | 150 | -#endif |
55 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aarch64_cpu_type_info = { | 151 | +static CPAccessResult access_scxtnum(CPUARMState *env, const ARMCPRegInfo *ri, |
56 | 152 | + bool isread) | |
57 | static void aarch64_cpu_register_types(void) | 153 | +{ |
58 | { | 154 | + uint64_t hcr = arm_hcr_el2_eff(env); |
59 | - const ARMCPUInfo *info = aarch64_cpus; | 155 | + int el = arm_current_el(env); |
60 | + size_t i; | 156 | + |
61 | 157 | + if (el == 0 && !((hcr & HCR_E2H) && (hcr & HCR_TGE))) { | |
62 | type_register_static(&aarch64_cpu_type_info); | 158 | + if (env->cp15.sctlr_el[1] & SCTLR_TSCXT) { |
63 | 159 | + if (hcr & HCR_TGE) { | |
64 | - while (info->name) { | 160 | + return CP_ACCESS_TRAP_EL2; |
65 | - aarch64_cpu_register(info); | 161 | + } |
66 | - info++; | 162 | + return CP_ACCESS_TRAP; |
67 | + for (i = 0; i < ARRAY_SIZE(aarch64_cpus); ++i) { | 163 | + } |
68 | + aarch64_cpu_register(&aarch64_cpus[i]); | 164 | + } else if (el < 2 && (env->cp15.sctlr_el[2] & SCTLR_TSCXT)) { |
165 | + return CP_ACCESS_TRAP_EL2; | ||
166 | + } | ||
167 | + if (el < 2 && arm_is_el2_enabled(env) && !(hcr & HCR_ENSCXT)) { | ||
168 | + return CP_ACCESS_TRAP_EL2; | ||
169 | + } | ||
170 | + if (el < 3 | ||
171 | + && arm_feature(env, ARM_FEATURE_EL3) | ||
172 | + && !(env->cp15.scr_el3 & SCR_ENSCXT)) { | ||
173 | + return CP_ACCESS_TRAP_EL3; | ||
174 | + } | ||
175 | + return CP_ACCESS_OK; | ||
176 | +} | ||
177 | + | ||
178 | +static const ARMCPRegInfo scxtnum_reginfo[] = { | ||
179 | + { .name = "SCXTNUM_EL0", .state = ARM_CP_STATE_AA64, | ||
180 | + .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 7, | ||
181 | + .access = PL0_RW, .accessfn = access_scxtnum, | ||
182 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[0]) }, | ||
183 | + { .name = "SCXTNUM_EL1", .state = ARM_CP_STATE_AA64, | ||
184 | + .opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 7, | ||
185 | + .access = PL1_RW, .accessfn = access_scxtnum, | ||
186 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[1]) }, | ||
187 | + { .name = "SCXTNUM_EL2", .state = ARM_CP_STATE_AA64, | ||
188 | + .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 7, | ||
189 | + .access = PL2_RW, .accessfn = access_scxtnum, | ||
190 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[2]) }, | ||
191 | + { .name = "SCXTNUM_EL3", .state = ARM_CP_STATE_AA64, | ||
192 | + .opc0 = 3, .opc1 = 6, .crn = 13, .crm = 0, .opc2 = 7, | ||
193 | + .access = PL3_RW, | ||
194 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[3]) }, | ||
195 | +}; | ||
196 | +#endif /* TARGET_AARCH64 */ | ||
197 | |||
198 | static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, | ||
199 | bool isread) | ||
200 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
201 | define_arm_cp_regs(cpu, mte_tco_ro_reginfo); | ||
202 | define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo); | ||
69 | } | 203 | } |
70 | } | 204 | + |
71 | 205 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { | |
206 | + define_arm_cp_regs(cpu, scxtnum_reginfo); | ||
207 | + } | ||
208 | #endif | ||
209 | |||
210 | if (cpu_isar_feature(any_predinv, cpu)) { | ||
72 | -- | 211 | -- |
73 | 2.20.1 | 212 | 2.25.1 |
74 | |||
75 | diff view generated by jsdifflib |
1 | From: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | With SmartFusion2 Ethernet MAC model in | 3 | This extension concerns cache speculation, which TCG does |
4 | place this patch adds the same to SoC. | 4 | not implement. Thus we can trivially enable this feature. |
5 | 5 | ||
6 | Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Message-id: 20220506180242.216785-22-richard.henderson@linaro.org |
9 | Message-id: 1587048891-30493-3-git-send-email-sundeep.lkml@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | include/hw/arm/msf2-soc.h | 2 ++ | 11 | docs/system/arm/emulation.rst | 1 + |
13 | hw/arm/msf2-soc.c | 26 ++++++++++++++++++++++++-- | 12 | target/arm/cpu64.c | 1 + |
14 | 2 files changed, 26 insertions(+), 2 deletions(-) | 13 | target/arm/cpu_tcg.c | 1 + |
14 | 3 files changed, 3 insertions(+) | ||
15 | 15 | ||
16 | diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h | 16 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/msf2-soc.h | 18 | --- a/docs/system/arm/emulation.rst |
19 | +++ b/include/hw/arm/msf2-soc.h | 19 | +++ b/docs/system/arm/emulation.rst |
20 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
21 | #include "hw/timer/mss-timer.h" | 21 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) |
22 | #include "hw/misc/msf2-sysreg.h" | 22 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
23 | #include "hw/ssi/mss-spi.h" | 23 | - FEAT_CSV2_2 (Cache speculation variant 2, version 2) |
24 | +#include "hw/net/msf2-emac.h" | 24 | +- FEAT_CSV3 (Cache speculation variant 3) |
25 | 25 | - FEAT_DIT (Data Independent Timing instructions) | |
26 | #define TYPE_MSF2_SOC "msf2-soc" | 26 | - FEAT_DPB (DC CVAP instruction) |
27 | #define MSF2_SOC(obj) OBJECT_CHECK(MSF2State, (obj), TYPE_MSF2_SOC) | 27 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct MSF2State { | 28 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
29 | MSF2SysregState sysreg; | ||
30 | MSSTimerState timer; | ||
31 | MSSSpiState spi[MSF2_NUM_SPIS]; | ||
32 | + MSF2EmacState emac; | ||
33 | } MSF2State; | ||
34 | |||
35 | #endif | ||
36 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/msf2-soc.c | 30 | --- a/target/arm/cpu64.c |
39 | +++ b/hw/arm/msf2-soc.c | 31 | +++ b/target/arm/cpu64.c |
40 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
41 | /* | 33 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ |
42 | * SmartFusion2 SoC emulation. | 34 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ |
43 | * | 35 | t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ |
44 | - * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com> | 36 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */ |
45 | + * Copyright (c) 2017-2020 Subbaraya Sundeep <sundeep.lkml@gmail.com> | 37 | cpu->isar.id_aa64pfr0 = t; |
46 | * | 38 | |
47 | * Permission is hereby granted, free of charge, to any person obtaining a copy | 39 | t = cpu->isar.id_aa64pfr1; |
48 | * of this software and associated documentation files (the "Software"), to deal | 40 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
49 | @@ -XXX,XX +XXX,XX @@ | 41 | index XXXXXXX..XXXXXXX 100644 |
50 | 42 | --- a/target/arm/cpu_tcg.c | |
51 | #define MSF2_TIMER_BASE 0x40004000 | 43 | +++ b/target/arm/cpu_tcg.c |
52 | #define MSF2_SYSREG_BASE 0x40038000 | 44 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
53 | +#define MSF2_EMAC_BASE 0x40041000 | 45 | cpu->isar.id_pfr0 = t; |
54 | 46 | ||
55 | #define ENVM_BASE_ADDRESS 0x60000000 | 47 | t = cpu->isar.id_pfr2; |
56 | 48 | + t = FIELD_DP32(t, ID_PFR2, CSV3, 1); /* FEAT_CSV3 */ | |
57 | #define SRAM_BASE_ADDRESS 0x20000000 | 49 | t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */ |
58 | 50 | cpu->isar.id_pfr2 = t; | |
59 | +#define MSF2_EMAC_IRQ 12 | ||
60 | + | ||
61 | #define MSF2_ENVM_MAX_SIZE (512 * KiB) | ||
62 | |||
63 | /* | ||
64 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_initfn(Object *obj) | ||
65 | sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]), | ||
66 | TYPE_MSS_SPI); | ||
67 | } | ||
68 | + | ||
69 | + sysbus_init_child_obj(obj, "emac", &s->emac, sizeof(s->emac), | ||
70 | + TYPE_MSS_EMAC); | ||
71 | + if (nd_table[0].used) { | ||
72 | + qemu_check_nic_model(&nd_table[0], TYPE_MSS_EMAC); | ||
73 | + qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]); | ||
74 | + } | ||
75 | } | ||
76 | |||
77 | static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
78 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
79 | g_free(bus_name); | ||
80 | } | ||
81 | |||
82 | + dev = DEVICE(&s->emac); | ||
83 | + object_property_set_link(OBJECT(&s->emac), OBJECT(get_system_memory()), | ||
84 | + "ahb-bus", &error_abort); | ||
85 | + object_property_set_bool(OBJECT(&s->emac), true, "realized", &err); | ||
86 | + if (err != NULL) { | ||
87 | + error_propagate(errp, err); | ||
88 | + return; | ||
89 | + } | ||
90 | + busdev = SYS_BUS_DEVICE(dev); | ||
91 | + sysbus_mmio_map(busdev, 0, MSF2_EMAC_BASE); | ||
92 | + sysbus_connect_irq(busdev, 0, | ||
93 | + qdev_get_gpio_in(armv7m, MSF2_EMAC_IRQ)); | ||
94 | + | ||
95 | /* Below devices are not modelled yet. */ | ||
96 | create_unimplemented_device("i2c_0", 0x40002000, 0x1000); | ||
97 | create_unimplemented_device("dma", 0x40003000, 0x1000); | ||
98 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
99 | create_unimplemented_device("can", 0x40015000, 0x1000); | ||
100 | create_unimplemented_device("rtc", 0x40017000, 0x1000); | ||
101 | create_unimplemented_device("apb_config", 0x40020000, 0x10000); | ||
102 | - create_unimplemented_device("emac", 0x40041000, 0x1000); | ||
103 | create_unimplemented_device("usb", 0x40043000, 0x1000); | ||
104 | } | ||
105 | 51 | ||
106 | -- | 52 | -- |
107 | 2.20.1 | 53 | 2.25.1 |
108 | |||
109 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Switch the cadence uart to multi-phase reset and add the | 3 | This extension concerns not merging memory access, which TCG does |
4 | reference clock input. | 4 | not implement. Thus we can trivially enable this feature. |
5 | Add a comment to handle_hint for the DGH instruction, but no code. | ||
5 | 6 | ||
6 | The input clock frequency is added to the migration structure. | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | |
8 | The reference clock controls the baudrate generation. If it disabled, | 9 | Message-id: 20220506180242.216785-23-richard.henderson@linaro.org |
9 | any input characters and events are ignored. | ||
10 | |||
11 | If this clock remains unconnected, the uart behaves as before | ||
12 | (it default to a 50MHz ref clock). | ||
13 | |||
14 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
15 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
16 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
17 | Message-id: 20200406135251.157596-8-damien.hedde@greensocs.com | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 11 | --- |
20 | include/hw/char/cadence_uart.h | 1 + | 12 | docs/system/arm/emulation.rst | 1 + |
21 | hw/char/cadence_uart.c | 73 +++++++++++++++++++++++++++++----- | 13 | target/arm/cpu64.c | 1 + |
22 | hw/char/trace-events | 3 ++ | 14 | target/arm/translate-a64.c | 1 + |
23 | 3 files changed, 67 insertions(+), 10 deletions(-) | 15 | 3 files changed, 3 insertions(+) |
24 | 16 | ||
25 | diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h | 17 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
26 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/char/cadence_uart.h | 19 | --- a/docs/system/arm/emulation.rst |
28 | +++ b/include/hw/char/cadence_uart.h | 20 | +++ b/docs/system/arm/emulation.rst |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 21 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
30 | CharBackend chr; | 22 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
31 | qemu_irq irq; | 23 | - FEAT_CSV2_2 (Cache speculation variant 2, version 2) |
32 | QEMUTimer *fifo_trigger_handle; | 24 | - FEAT_CSV3 (Cache speculation variant 3) |
33 | + Clock *refclk; | 25 | +- FEAT_DGH (Data gathering hint) |
34 | } CadenceUARTState; | 26 | - FEAT_DIT (Data Independent Timing instructions) |
35 | 27 | - FEAT_DPB (DC CVAP instruction) | |
36 | static inline DeviceState *cadence_uart_create(hwaddr addr, | 28 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
37 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c | 29 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
38 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/hw/char/cadence_uart.c | 31 | --- a/target/arm/cpu64.c |
40 | +++ b/hw/char/cadence_uart.c | 32 | +++ b/target/arm/cpu64.c |
41 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
42 | #include "qemu/module.h" | 34 | t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */ |
43 | #include "hw/char/cadence_uart.h" | 35 | t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */ |
44 | #include "hw/irq.h" | 36 | t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */ |
45 | +#include "hw/qdev-clock.h" | 37 | + t = FIELD_DP64(t, ID_AA64ISAR1, DGH, 1); /* FEAT_DGH */ |
46 | +#include "trace.h" | 38 | t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */ |
47 | 39 | cpu->isar.id_aa64isar1 = t; | |
48 | #ifdef CADENCE_UART_ERR_DEBUG | 40 | |
49 | #define DB_PRINT(...) do { \ | 41 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | #define LOCAL_LOOPBACK (0x2 << UART_MR_CHMODE_SH) | ||
52 | #define REMOTE_LOOPBACK (0x3 << UART_MR_CHMODE_SH) | ||
53 | |||
54 | -#define UART_INPUT_CLK 50000000 | ||
55 | +#define UART_DEFAULT_REF_CLK (50 * 1000 * 1000) | ||
56 | |||
57 | #define R_CR (0x00/4) | ||
58 | #define R_MR (0x04/4) | ||
59 | @@ -XXX,XX +XXX,XX @@ static void uart_send_breaks(CadenceUARTState *s) | ||
60 | static void uart_parameters_setup(CadenceUARTState *s) | ||
61 | { | ||
62 | QEMUSerialSetParams ssp; | ||
63 | - unsigned int baud_rate, packet_size; | ||
64 | + unsigned int baud_rate, packet_size, input_clk; | ||
65 | + input_clk = clock_get_hz(s->refclk); | ||
66 | |||
67 | - baud_rate = (s->r[R_MR] & UART_MR_CLKS) ? | ||
68 | - UART_INPUT_CLK / 8 : UART_INPUT_CLK; | ||
69 | + baud_rate = (s->r[R_MR] & UART_MR_CLKS) ? input_clk / 8 : input_clk; | ||
70 | + baud_rate /= (s->r[R_BRGR] * (s->r[R_BDIV] + 1)); | ||
71 | + trace_cadence_uart_baudrate(baud_rate); | ||
72 | + | ||
73 | + ssp.speed = baud_rate; | ||
74 | |||
75 | - ssp.speed = baud_rate / (s->r[R_BRGR] * (s->r[R_BDIV] + 1)); | ||
76 | packet_size = 1; | ||
77 | |||
78 | switch (s->r[R_MR] & UART_MR_PAR) { | ||
79 | @@ -XXX,XX +XXX,XX @@ static void uart_parameters_setup(CadenceUARTState *s) | ||
80 | } | ||
81 | |||
82 | packet_size += ssp.data_bits + ssp.stop_bits; | ||
83 | + if (ssp.speed == 0) { | ||
84 | + /* | ||
85 | + * Avoid division-by-zero below. | ||
86 | + * TODO: find something better | ||
87 | + */ | ||
88 | + ssp.speed = 1; | ||
89 | + } | ||
90 | s->char_tx_time = (NANOSECONDS_PER_SECOND / ssp.speed) * packet_size; | ||
91 | qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp); | ||
92 | } | ||
93 | @@ -XXX,XX +XXX,XX @@ static void uart_receive(void *opaque, const uint8_t *buf, int size) | ||
94 | CadenceUARTState *s = opaque; | ||
95 | uint32_t ch_mode = s->r[R_MR] & UART_MR_CHMODE; | ||
96 | |||
97 | + /* ignore characters when unclocked or in reset */ | ||
98 | + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { | ||
99 | + return; | ||
100 | + } | ||
101 | + | ||
102 | if (ch_mode == NORMAL_MODE || ch_mode == ECHO_MODE) { | ||
103 | uart_write_rx_fifo(opaque, buf, size); | ||
104 | } | ||
105 | @@ -XXX,XX +XXX,XX @@ static void uart_event(void *opaque, QEMUChrEvent event) | ||
106 | CadenceUARTState *s = opaque; | ||
107 | uint8_t buf = '\0'; | ||
108 | |||
109 | + /* ignore characters when unclocked or in reset */ | ||
110 | + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { | ||
111 | + return; | ||
112 | + } | ||
113 | + | ||
114 | if (event == CHR_EVENT_BREAK) { | ||
115 | uart_write_rx_fifo(opaque, &buf, 1); | ||
116 | } | ||
117 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps uart_ops = { | ||
118 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
119 | }; | ||
120 | |||
121 | -static void cadence_uart_reset(DeviceState *dev) | ||
122 | +static void cadence_uart_reset_init(Object *obj, ResetType type) | ||
123 | { | ||
124 | - CadenceUARTState *s = CADENCE_UART(dev); | ||
125 | + CadenceUARTState *s = CADENCE_UART(obj); | ||
126 | |||
127 | s->r[R_CR] = 0x00000128; | ||
128 | s->r[R_IMR] = 0; | ||
129 | @@ -XXX,XX +XXX,XX @@ static void cadence_uart_reset(DeviceState *dev) | ||
130 | s->r[R_BRGR] = 0x0000028B; | ||
131 | s->r[R_BDIV] = 0x0000000F; | ||
132 | s->r[R_TTRIG] = 0x00000020; | ||
133 | +} | ||
134 | + | ||
135 | +static void cadence_uart_reset_hold(Object *obj) | ||
136 | +{ | ||
137 | + CadenceUARTState *s = CADENCE_UART(obj); | ||
138 | |||
139 | uart_rx_reset(s); | ||
140 | uart_tx_reset(s); | ||
141 | @@ -XXX,XX +XXX,XX @@ static void cadence_uart_realize(DeviceState *dev, Error **errp) | ||
142 | uart_event, NULL, s, NULL, true); | ||
143 | } | ||
144 | |||
145 | +static void cadence_uart_refclk_update(void *opaque) | ||
146 | +{ | ||
147 | + CadenceUARTState *s = opaque; | ||
148 | + | ||
149 | + /* recompute uart's speed on clock change */ | ||
150 | + uart_parameters_setup(s); | ||
151 | +} | ||
152 | + | ||
153 | static void cadence_uart_init(Object *obj) | ||
154 | { | ||
155 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
156 | @@ -XXX,XX +XXX,XX @@ static void cadence_uart_init(Object *obj) | ||
157 | sysbus_init_mmio(sbd, &s->iomem); | ||
158 | sysbus_init_irq(sbd, &s->irq); | ||
159 | |||
160 | + s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", | ||
161 | + cadence_uart_refclk_update, s); | ||
162 | + /* initialize the frequency in case the clock remains unconnected */ | ||
163 | + clock_set_hz(s->refclk, UART_DEFAULT_REF_CLK); | ||
164 | + | ||
165 | s->char_tx_time = (NANOSECONDS_PER_SECOND / 9600) * 10; | ||
166 | } | ||
167 | |||
168 | +static int cadence_uart_pre_load(void *opaque) | ||
169 | +{ | ||
170 | + CadenceUARTState *s = opaque; | ||
171 | + | ||
172 | + /* the frequency will be overriden if the refclk field is present */ | ||
173 | + clock_set_hz(s->refclk, UART_DEFAULT_REF_CLK); | ||
174 | + return 0; | ||
175 | +} | ||
176 | + | ||
177 | static int cadence_uart_post_load(void *opaque, int version_id) | ||
178 | { | ||
179 | CadenceUARTState *s = opaque; | ||
180 | @@ -XXX,XX +XXX,XX @@ static int cadence_uart_post_load(void *opaque, int version_id) | ||
181 | |||
182 | static const VMStateDescription vmstate_cadence_uart = { | ||
183 | .name = "cadence_uart", | ||
184 | - .version_id = 2, | ||
185 | + .version_id = 3, | ||
186 | .minimum_version_id = 2, | ||
187 | + .pre_load = cadence_uart_pre_load, | ||
188 | .post_load = cadence_uart_post_load, | ||
189 | .fields = (VMStateField[]) { | ||
190 | VMSTATE_UINT32_ARRAY(r, CadenceUARTState, CADENCE_UART_R_MAX), | ||
191 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_cadence_uart = { | ||
192 | VMSTATE_UINT32(tx_count, CadenceUARTState), | ||
193 | VMSTATE_UINT32(rx_wpos, CadenceUARTState), | ||
194 | VMSTATE_TIMER_PTR(fifo_trigger_handle, CadenceUARTState), | ||
195 | + VMSTATE_CLOCK_V(refclk, CadenceUARTState, 3), | ||
196 | VMSTATE_END_OF_LIST() | ||
197 | - } | ||
198 | + }, | ||
199 | }; | ||
200 | |||
201 | static Property cadence_uart_properties[] = { | ||
202 | @@ -XXX,XX +XXX,XX @@ static Property cadence_uart_properties[] = { | ||
203 | static void cadence_uart_class_init(ObjectClass *klass, void *data) | ||
204 | { | ||
205 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
206 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
207 | |||
208 | dc->realize = cadence_uart_realize; | ||
209 | dc->vmsd = &vmstate_cadence_uart; | ||
210 | - dc->reset = cadence_uart_reset; | ||
211 | + rc->phases.enter = cadence_uart_reset_init; | ||
212 | + rc->phases.hold = cadence_uart_reset_hold; | ||
213 | device_class_set_props(dc, cadence_uart_properties); | ||
214 | } | ||
215 | |||
216 | diff --git a/hw/char/trace-events b/hw/char/trace-events | ||
217 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
218 | --- a/hw/char/trace-events | 43 | --- a/target/arm/translate-a64.c |
219 | +++ b/hw/char/trace-events | 44 | +++ b/target/arm/translate-a64.c |
220 | @@ -XXX,XX +XXX,XX @@ exynos_uart_wo_read(uint32_t channel, const char *name, uint32_t reg) "UART%d: T | 45 | @@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn, |
221 | exynos_uart_rxsize(uint32_t channel, uint32_t size) "UART%d: Rx FIFO size: %d" | 46 | break; |
222 | exynos_uart_channel_error(uint32_t channel) "Wrong UART channel number: %d" | 47 | case 0b00100: /* SEV */ |
223 | exynos_uart_rx_timeout(uint32_t channel, uint32_t stat, uint32_t intsp) "UART%d: Rx timeout stat=0x%x intsp=0x%x" | 48 | case 0b00101: /* SEVL */ |
224 | + | 49 | + case 0b00110: /* DGH */ |
225 | +# hw/char/cadence_uart.c | 50 | /* we treat all as NOP at least for now */ |
226 | +cadence_uart_baudrate(unsigned baudrate) "baudrate %u" | 51 | break; |
52 | case 0b00111: /* XPACLRI */ | ||
227 | -- | 53 | -- |
228 | 2.20.1 | 54 | 2.25.1 |
229 | |||
230 | diff view generated by jsdifflib |
1 | From: Ramon Fried <rfried.dev@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The RX ring descriptors control field is used for setting | 3 | Enable the a76 for virt and sbsa board use. |
4 | SOF and EOF (start of frame and end of frame). | ||
5 | The SOF and EOF weren't cleared from the previous descriptors, | ||
6 | causing inconsistencies in ring buffer. | ||
7 | Fix that by clearing the control field of every descriptors we're | ||
8 | processing. | ||
9 | 4 | ||
10 | Signed-off-by: Ramon Fried <rfried.dev@gmail.com> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 7 | Message-id: 20220506180242.216785-24-richard.henderson@linaro.org |
13 | Message-id: 20200418085145.489726-1-rfried.dev@gmail.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 9 | --- |
16 | hw/net/cadence_gem.c | 7 +++++++ | 10 | docs/system/arm/virt.rst | 1 + |
17 | 1 file changed, 7 insertions(+) | 11 | hw/arm/sbsa-ref.c | 1 + |
12 | hw/arm/virt.c | 1 + | ||
13 | target/arm/cpu64.c | 66 ++++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 69 insertions(+) | ||
18 | 15 | ||
19 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c | 16 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/net/cadence_gem.c | 18 | --- a/docs/system/arm/virt.rst |
22 | +++ b/hw/net/cadence_gem.c | 19 | +++ b/docs/system/arm/virt.rst |
23 | @@ -XXX,XX +XXX,XX @@ static inline void rx_desc_set_sof(uint32_t *desc) | 20 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: |
24 | desc[1] |= DESC_1_RX_SOF; | 21 | - ``cortex-a53`` (64-bit) |
22 | - ``cortex-a57`` (64-bit) | ||
23 | - ``cortex-a72`` (64-bit) | ||
24 | +- ``cortex-a76`` (64-bit) | ||
25 | - ``a64fx`` (64-bit) | ||
26 | - ``host`` (with KVM only) | ||
27 | - ``max`` (same as ``host`` for KVM; best possible emulation with TCG) | ||
28 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/arm/sbsa-ref.c | ||
31 | +++ b/hw/arm/sbsa-ref.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { | ||
33 | static const char * const valid_cpus[] = { | ||
34 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
35 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
36 | + ARM_CPU_TYPE_NAME("cortex-a76"), | ||
37 | ARM_CPU_TYPE_NAME("max"), | ||
38 | }; | ||
39 | |||
40 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/arm/virt.c | ||
43 | +++ b/hw/arm/virt.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { | ||
45 | ARM_CPU_TYPE_NAME("cortex-a53"), | ||
46 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
47 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
48 | + ARM_CPU_TYPE_NAME("cortex-a76"), | ||
49 | ARM_CPU_TYPE_NAME("a64fx"), | ||
50 | ARM_CPU_TYPE_NAME("host"), | ||
51 | ARM_CPU_TYPE_NAME("max"), | ||
52 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/cpu64.c | ||
55 | +++ b/target/arm/cpu64.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
57 | define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
25 | } | 58 | } |
26 | 59 | ||
27 | +static inline void rx_desc_clear_control(uint32_t *desc) | 60 | +static void aarch64_a76_initfn(Object *obj) |
28 | +{ | 61 | +{ |
29 | + desc[1] = 0; | 62 | + ARMCPU *cpu = ARM_CPU(obj); |
63 | + | ||
64 | + cpu->dtb_compatible = "arm,cortex-a76"; | ||
65 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
66 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
67 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
68 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
69 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
70 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
71 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
73 | + | ||
74 | + /* Ordered by B2.4 AArch64 registers by functional group */ | ||
75 | + cpu->clidr = 0x82000023; | ||
76 | + cpu->ctr = 0x8444C004; | ||
77 | + cpu->dcz_blocksize = 4; | ||
78 | + cpu->isar.id_aa64dfr0 = 0x0000000010305408ull; | ||
79 | + cpu->isar.id_aa64isar0 = 0x0000100010211120ull; | ||
80 | + cpu->isar.id_aa64isar1 = 0x0000000000100001ull; | ||
81 | + cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull; | ||
82 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
83 | + cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; | ||
84 | + cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ | ||
85 | + cpu->isar.id_aa64pfr1 = 0x0000000000000010ull; | ||
86 | + cpu->id_afr0 = 0x00000000; | ||
87 | + cpu->isar.id_dfr0 = 0x04010088; | ||
88 | + cpu->isar.id_isar0 = 0x02101110; | ||
89 | + cpu->isar.id_isar1 = 0x13112111; | ||
90 | + cpu->isar.id_isar2 = 0x21232042; | ||
91 | + cpu->isar.id_isar3 = 0x01112131; | ||
92 | + cpu->isar.id_isar4 = 0x00010142; | ||
93 | + cpu->isar.id_isar5 = 0x01011121; | ||
94 | + cpu->isar.id_isar6 = 0x00000010; | ||
95 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
96 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
97 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
98 | + cpu->isar.id_mmfr3 = 0x02122211; | ||
99 | + cpu->isar.id_mmfr4 = 0x00021110; | ||
100 | + cpu->isar.id_pfr0 = 0x10010131; | ||
101 | + cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ | ||
102 | + cpu->isar.id_pfr2 = 0x00000011; | ||
103 | + cpu->midr = 0x414fd0b1; /* r4p1 */ | ||
104 | + cpu->revidr = 0; | ||
105 | + | ||
106 | + /* From B2.18 CCSIDR_EL1 */ | ||
107 | + cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ | ||
108 | + cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ | ||
109 | + cpu->ccsidr[2] = 0x707fe03a; /* 512KB L2 cache */ | ||
110 | + | ||
111 | + /* From B2.93 SCTLR_EL3 */ | ||
112 | + cpu->reset_sctlr = 0x30c50838; | ||
113 | + | ||
114 | + /* From B4.23 ICH_VTR_EL2 */ | ||
115 | + cpu->gic_num_lrs = 4; | ||
116 | + cpu->gic_vpribits = 5; | ||
117 | + cpu->gic_vprebits = 5; | ||
118 | + | ||
119 | + /* From B5.1 AdvSIMD AArch64 register summary */ | ||
120 | + cpu->isar.mvfr0 = 0x10110222; | ||
121 | + cpu->isar.mvfr1 = 0x13211111; | ||
122 | + cpu->isar.mvfr2 = 0x00000043; | ||
30 | +} | 123 | +} |
31 | + | 124 | + |
32 | static inline void rx_desc_set_eof(uint32_t *desc) | 125 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) |
33 | { | 126 | { |
34 | desc[1] |= DESC_1_RX_EOF; | 127 | /* |
35 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | 128 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { |
36 | rxbuf_ptr += MIN(bytes_to_copy, rxbufsize); | 129 | { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, |
37 | bytes_to_copy -= MIN(bytes_to_copy, rxbufsize); | 130 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, |
38 | 131 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | |
39 | + rx_desc_clear_control(s->rx_desc[q]); | 132 | + { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, |
40 | + | 133 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, |
41 | /* Update the descriptor. */ | 134 | { .name = "max", .initfn = aarch64_max_initfn }, |
42 | if (first_desc) { | 135 | #if defined(CONFIG_KVM) || defined(CONFIG_HVF) |
43 | rx_desc_set_sof(s->rx_desc[q]); | ||
44 | -- | 136 | -- |
45 | 2.20.1 | 137 | 2.25.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Fix descriptor loading from registers wrt host endianness. | 3 | Enable the n1 for virt and sbsa board use. |
4 | 4 | ||
5 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 7 | Message-id: 20220506180242.216785-25-richard.henderson@linaro.org |
8 | Message-id: 20200404122718.25111-3-edgar.iglesias@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 9 | --- |
11 | hw/dma/xlnx-zdma.c | 14 ++++++++++---- | 10 | docs/system/arm/virt.rst | 1 + |
12 | 1 file changed, 10 insertions(+), 4 deletions(-) | 11 | hw/arm/sbsa-ref.c | 1 + |
12 | hw/arm/virt.c | 1 + | ||
13 | target/arm/cpu64.c | 66 ++++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 69 insertions(+) | ||
13 | 15 | ||
14 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c | 16 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/dma/xlnx-zdma.c | 18 | --- a/docs/system/arm/virt.rst |
17 | +++ b/hw/dma/xlnx-zdma.c | 19 | +++ b/docs/system/arm/virt.rst |
18 | @@ -XXX,XX +XXX,XX @@ static void zdma_put_regaddr64(XlnxZDMA *s, unsigned int basereg, uint64_t addr) | 20 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: |
19 | s->regs[basereg + 1] = addr >> 32; | 21 | - ``cortex-a76`` (64-bit) |
22 | - ``a64fx`` (64-bit) | ||
23 | - ``host`` (with KVM only) | ||
24 | +- ``neoverse-n1`` (64-bit) | ||
25 | - ``max`` (same as ``host`` for KVM; best possible emulation with TCG) | ||
26 | |||
27 | Note that the default is ``cortex-a15``, so for an AArch64 guest you must | ||
28 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/arm/sbsa-ref.c | ||
31 | +++ b/hw/arm/sbsa-ref.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static const char * const valid_cpus[] = { | ||
33 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
34 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
35 | ARM_CPU_TYPE_NAME("cortex-a76"), | ||
36 | + ARM_CPU_TYPE_NAME("neoverse-n1"), | ||
37 | ARM_CPU_TYPE_NAME("max"), | ||
38 | }; | ||
39 | |||
40 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/arm/virt.c | ||
43 | +++ b/hw/arm/virt.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { | ||
45 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
46 | ARM_CPU_TYPE_NAME("cortex-a76"), | ||
47 | ARM_CPU_TYPE_NAME("a64fx"), | ||
48 | + ARM_CPU_TYPE_NAME("neoverse-n1"), | ||
49 | ARM_CPU_TYPE_NAME("host"), | ||
50 | ARM_CPU_TYPE_NAME("max"), | ||
51 | }; | ||
52 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/cpu64.c | ||
55 | +++ b/target/arm/cpu64.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a76_initfn(Object *obj) | ||
57 | cpu->isar.mvfr2 = 0x00000043; | ||
20 | } | 58 | } |
21 | 59 | ||
22 | +static void zdma_load_descriptor_reg(XlnxZDMA *s, unsigned int reg, | 60 | +static void aarch64_neoverse_n1_initfn(Object *obj) |
23 | + XlnxZDMADescr *descr) | ||
24 | +{ | 61 | +{ |
25 | + descr->addr = zdma_get_regaddr64(s, reg); | 62 | + ARMCPU *cpu = ARM_CPU(obj); |
26 | + descr->size = s->regs[reg + 2]; | 63 | + |
27 | + descr->attr = s->regs[reg + 3]; | 64 | + cpu->dtb_compatible = "arm,neoverse-n1"; |
65 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
66 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
67 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
68 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
69 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
70 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
71 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
73 | + | ||
74 | + /* Ordered by B2.4 AArch64 registers by functional group */ | ||
75 | + cpu->clidr = 0x82000023; | ||
76 | + cpu->ctr = 0x8444c004; | ||
77 | + cpu->dcz_blocksize = 4; | ||
78 | + cpu->isar.id_aa64dfr0 = 0x0000000110305408ull; | ||
79 | + cpu->isar.id_aa64isar0 = 0x0000100010211120ull; | ||
80 | + cpu->isar.id_aa64isar1 = 0x0000000000100001ull; | ||
81 | + cpu->isar.id_aa64mmfr0 = 0x0000000000101125ull; | ||
82 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
83 | + cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; | ||
84 | + cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ | ||
85 | + cpu->isar.id_aa64pfr1 = 0x0000000000000020ull; | ||
86 | + cpu->id_afr0 = 0x00000000; | ||
87 | + cpu->isar.id_dfr0 = 0x04010088; | ||
88 | + cpu->isar.id_isar0 = 0x02101110; | ||
89 | + cpu->isar.id_isar1 = 0x13112111; | ||
90 | + cpu->isar.id_isar2 = 0x21232042; | ||
91 | + cpu->isar.id_isar3 = 0x01112131; | ||
92 | + cpu->isar.id_isar4 = 0x00010142; | ||
93 | + cpu->isar.id_isar5 = 0x01011121; | ||
94 | + cpu->isar.id_isar6 = 0x00000010; | ||
95 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
96 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
97 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
98 | + cpu->isar.id_mmfr3 = 0x02122211; | ||
99 | + cpu->isar.id_mmfr4 = 0x00021110; | ||
100 | + cpu->isar.id_pfr0 = 0x10010131; | ||
101 | + cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ | ||
102 | + cpu->isar.id_pfr2 = 0x00000011; | ||
103 | + cpu->midr = 0x414fd0c1; /* r4p1 */ | ||
104 | + cpu->revidr = 0; | ||
105 | + | ||
106 | + /* From B2.23 CCSIDR_EL1 */ | ||
107 | + cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ | ||
108 | + cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ | ||
109 | + cpu->ccsidr[2] = 0x70ffe03a; /* 1MB L2 cache */ | ||
110 | + | ||
111 | + /* From B2.98 SCTLR_EL3 */ | ||
112 | + cpu->reset_sctlr = 0x30c50838; | ||
113 | + | ||
114 | + /* From B4.23 ICH_VTR_EL2 */ | ||
115 | + cpu->gic_num_lrs = 4; | ||
116 | + cpu->gic_vpribits = 5; | ||
117 | + cpu->gic_vprebits = 5; | ||
118 | + | ||
119 | + /* From B5.1 AdvSIMD AArch64 register summary */ | ||
120 | + cpu->isar.mvfr0 = 0x10110222; | ||
121 | + cpu->isar.mvfr1 = 0x13211111; | ||
122 | + cpu->isar.mvfr2 = 0x00000043; | ||
28 | +} | 123 | +} |
29 | + | 124 | + |
30 | static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, | 125 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) |
31 | XlnxZDMADescr *descr) | ||
32 | { | 126 | { |
33 | @@ -XXX,XX +XXX,XX @@ static void zdma_load_src_descriptor(XlnxZDMA *s) | 127 | /* |
34 | unsigned int ptype = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_CTRL0, POINT_TYPE); | 128 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { |
35 | 129 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | |
36 | if (ptype == PT_REG) { | 130 | { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, |
37 | - memcpy(&s->dsc_src, &s->regs[R_ZDMA_CH_SRC_DSCR_WORD0], | 131 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, |
38 | - sizeof(s->dsc_src)); | 132 | + { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn }, |
39 | + zdma_load_descriptor_reg(s, R_ZDMA_CH_SRC_DSCR_WORD0, &s->dsc_src); | 133 | { .name = "max", .initfn = aarch64_max_initfn }, |
40 | return; | 134 | #if defined(CONFIG_KVM) || defined(CONFIG_HVF) |
41 | } | 135 | { .name = "host", .initfn = aarch64_host_initfn }, |
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static void zdma_load_dst_descriptor(XlnxZDMA *s) | ||
44 | bool dst_type; | ||
45 | |||
46 | if (ptype == PT_REG) { | ||
47 | - memcpy(&s->dsc_dst, &s->regs[R_ZDMA_CH_DST_DSCR_WORD0], | ||
48 | - sizeof(s->dsc_dst)); | ||
49 | + zdma_load_descriptor_reg(s, R_ZDMA_CH_DST_DSCR_WORD0, &s->dsc_dst); | ||
50 | return; | ||
51 | } | ||
52 | |||
53 | -- | 136 | -- |
54 | 2.20.1 | 137 | 2.25.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | From: Keqian Zhu <zhukeqian1@huawei.com> | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | The KVM_VGIC_ATTR macro expect the second parameter as gicr_typer, | 3 | The sbsa-ref machine is continuously evolving. Some of the changes we |
4 | of which high 32bit is constructed by mp_affinity. For most case, | 4 | want to make in the near future, to align with real components (e.g. |
5 | the high 32bit of mp_affinity is zero, so it will always access the | 5 | the GIC-700), will break compatibility for existing firmware. |
6 | ICC_CTLR_EL1 of CPU0. | ||
7 | 6 | ||
8 | Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com> | 7 | Introduce two new properties to the DT generated on machine generation: |
9 | Message-id: 20200413091552.62748-2-zhukeqian1@huawei.com | 8 | - machine-version-major |
9 | To be incremented when a platform change makes the machine | ||
10 | incompatible with existing firmware. | ||
11 | - machine-version-minor | ||
12 | To be incremented when functionality is added to the machine | ||
13 | without causing incompatibility with existing firmware. | ||
14 | to be reset to 0 when machine-version-major is incremented. | ||
15 | |||
16 | This versioning scheme is *neither*: | ||
17 | - A QEMU versioned machine type; a given version of QEMU will emulate | ||
18 | a given version of the platform. | ||
19 | - A reflection of level of SBSA (now SystemReady SR) support provided. | ||
20 | |||
21 | The version will increment on guest-visible functional changes only, | ||
22 | akin to a revision ID register found on a physical platform. | ||
23 | |||
24 | These properties are both introduced with the value 0. | ||
25 | (Hence, a machine where the DT is lacking these nodes is equivalent | ||
26 | to version 0.0.) | ||
27 | |||
28 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
29 | Message-id: 20220505113947.75714-1-quic_llindhol@quicinc.com | ||
30 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
31 | Cc: Radoslaw Biernacki <rad@semihalf.com> | ||
32 | Cc: Cédric Le Goater <clg@kaod.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 33 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 34 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 35 | --- |
13 | hw/intc/arm_gicv3_kvm.c | 4 +--- | 36 | hw/arm/sbsa-ref.c | 14 ++++++++++++++ |
14 | 1 file changed, 1 insertion(+), 3 deletions(-) | 37 | 1 file changed, 14 insertions(+) |
15 | 38 | ||
16 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 39 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
17 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/intc/arm_gicv3_kvm.c | 41 | --- a/hw/arm/sbsa-ref.c |
19 | +++ b/hw/intc/arm_gicv3_kvm.c | 42 | +++ b/hw/arm/sbsa-ref.c |
20 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_get(GICv3State *s) | 43 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) |
21 | 44 | qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); | |
22 | static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) | 45 | qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); |
23 | { | 46 | |
24 | - ARMCPU *cpu; | 47 | + /* |
25 | GICv3State *s; | 48 | + * This versioning scheme is for informing platform fw only. It is neither: |
26 | GICv3CPUState *c; | 49 | + * - A QEMU versioned machine type; a given version of QEMU will emulate |
27 | 50 | + * a given version of the platform. | |
28 | c = (GICv3CPUState *)env->gicv3state; | 51 | + * - A reflection of level of SBSA (now SystemReady SR) support provided. |
29 | s = c->gic; | 52 | + * |
30 | - cpu = ARM_CPU(c->cpu); | 53 | + * machine-version-major: updated when changes breaking fw compatibility |
31 | 54 | + * are introduced. | |
32 | c->icc_pmr_el1 = 0; | 55 | + * machine-version-minor: updated when features are added that don't break |
33 | c->icc_bpr[GICV3_G0] = GIC_MIN_BPR; | 56 | + * fw compatibility. |
34 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) | 57 | + */ |
35 | 58 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0); | |
36 | /* Initialize to actual HW supported configuration */ | 59 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 0); |
37 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS, | 60 | + |
38 | - KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity), | 61 | if (ms->numa_state->have_numa_distance) { |
39 | + KVM_VGIC_ATTR(ICC_CTLR_EL1, c->gicr_typer), | 62 | int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); |
40 | &c->icc_ctlr_el1[GICV3_NS], false, &error_abort); | 63 | uint32_t *matrix = g_malloc0(size); |
41 | |||
42 | c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS]; | ||
43 | -- | 64 | -- |
44 | 2.20.1 | 65 | 2.25.1 |
45 | 66 | ||
46 | 67 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | 3 | This adds cluster-id in CPU instance properties, which will be used |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | by arm/virt machine. Besides, the cluster-id is also verified or |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | dumped in various spots: |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 6 | |
7 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 7 | * hw/core/machine.c::machine_set_cpu_numa_node() to associate |
8 | Message-id: 20200406135251.157596-3-damien.hedde@greensocs.com | 8 | CPU with its NUMA node. |
9 | |||
10 | * hw/core/machine.c::machine_numa_finish_cpu_init() to record | ||
11 | CPU slots with no NUMA mapping set. | ||
12 | |||
13 | * hw/core/machine-hmp-cmds.c::hmp_hotpluggable_cpus() to dump | ||
14 | cluster-id. | ||
15 | |||
16 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
17 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
18 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
19 | Message-id: 20220503140304.855514-2-gshan@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 21 | --- |
11 | hw/core/Makefile.objs | 1 + | 22 | qapi/machine.json | 6 ++++-- |
12 | include/hw/clock.h | 9 +++++++++ | 23 | hw/core/machine-hmp-cmds.c | 4 ++++ |
13 | hw/core/clock-vmstate.c | 25 +++++++++++++++++++++++++ | 24 | hw/core/machine.c | 16 ++++++++++++++++ |
14 | 3 files changed, 35 insertions(+) | 25 | 3 files changed, 24 insertions(+), 2 deletions(-) |
15 | create mode 100644 hw/core/clock-vmstate.c | ||
16 | 26 | ||
17 | diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs | 27 | diff --git a/qapi/machine.json b/qapi/machine.json |
18 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/core/Makefile.objs | 29 | --- a/qapi/machine.json |
20 | +++ b/hw/core/Makefile.objs | 30 | +++ b/qapi/machine.json |
21 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_SOFTMMU) += null-machine.o | 31 | @@ -XXX,XX +XXX,XX @@ |
22 | common-obj-$(CONFIG_SOFTMMU) += loader.o | 32 | # @node-id: NUMA node ID the CPU belongs to |
23 | common-obj-$(CONFIG_SOFTMMU) += machine-hmp-cmds.o | 33 | # @socket-id: socket number within node/board the CPU belongs to |
24 | common-obj-$(CONFIG_SOFTMMU) += numa.o | 34 | # @die-id: die number within socket the CPU belongs to (since 4.1) |
25 | +common-obj-$(CONFIG_SOFTMMU) += clock-vmstate.o | 35 | -# @core-id: core number within die the CPU belongs to |
26 | obj-$(CONFIG_SOFTMMU) += machine-qmp-cmds.o | 36 | +# @cluster-id: cluster number within die the CPU belongs to (since 7.1) |
27 | 37 | +# @core-id: core number within cluster the CPU belongs to | |
28 | common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o | 38 | # @thread-id: thread number within core the CPU belongs to |
29 | diff --git a/include/hw/clock.h b/include/hw/clock.h | 39 | # |
40 | -# Note: currently there are 5 properties that could be present | ||
41 | +# Note: currently there are 6 properties that could be present | ||
42 | # but management should be prepared to pass through other | ||
43 | # properties with device_add command to allow for future | ||
44 | # interface extension. This also requires the filed names to be kept in | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | 'data': { '*node-id': 'int', | ||
47 | '*socket-id': 'int', | ||
48 | '*die-id': 'int', | ||
49 | + '*cluster-id': 'int', | ||
50 | '*core-id': 'int', | ||
51 | '*thread-id': 'int' | ||
52 | } | ||
53 | diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 54 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/include/hw/clock.h | 55 | --- a/hw/core/machine-hmp-cmds.c |
32 | +++ b/include/hw/clock.h | 56 | +++ b/hw/core/machine-hmp-cmds.c |
33 | @@ -XXX,XX +XXX,XX @@ struct Clock { | 57 | @@ -XXX,XX +XXX,XX @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict) |
34 | QLIST_ENTRY(Clock) sibling; | 58 | if (c->has_die_id) { |
35 | }; | 59 | monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id); |
36 | 60 | } | |
37 | +/* | 61 | + if (c->has_cluster_id) { |
38 | + * vmstate description entry to be added in device vmsd. | 62 | + monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n", |
39 | + */ | 63 | + c->cluster_id); |
40 | +extern const VMStateDescription vmstate_clock; | 64 | + } |
41 | +#define VMSTATE_CLOCK(field, state) \ | 65 | if (c->has_core_id) { |
42 | + VMSTATE_CLOCK_V(field, state, 0) | 66 | monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id); |
43 | +#define VMSTATE_CLOCK_V(field, state, version) \ | 67 | } |
44 | + VMSTATE_STRUCT_POINTER_V(field, state, version, vmstate_clock, Clock) | 68 | diff --git a/hw/core/machine.c b/hw/core/machine.c |
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/core/machine.c | ||
71 | +++ b/hw/core/machine.c | ||
72 | @@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine, | ||
73 | return; | ||
74 | } | ||
75 | |||
76 | + if (props->has_cluster_id && !slot->props.has_cluster_id) { | ||
77 | + error_setg(errp, "cluster-id is not supported"); | ||
78 | + return; | ||
79 | + } | ||
45 | + | 80 | + |
46 | /** | 81 | if (props->has_socket_id && !slot->props.has_socket_id) { |
47 | * clock_setup_canonical_path: | 82 | error_setg(errp, "socket-id is not supported"); |
48 | * @clk: clock | 83 | return; |
49 | diff --git a/hw/core/clock-vmstate.c b/hw/core/clock-vmstate.c | 84 | @@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine, |
50 | new file mode 100644 | 85 | continue; |
51 | index XXXXXXX..XXXXXXX | 86 | } |
52 | --- /dev/null | 87 | |
53 | +++ b/hw/core/clock-vmstate.c | 88 | + if (props->has_cluster_id && |
54 | @@ -XXX,XX +XXX,XX @@ | 89 | + props->cluster_id != slot->props.cluster_id) { |
55 | +/* | 90 | + continue; |
56 | + * Clock migration structure | 91 | + } |
57 | + * | ||
58 | + * Copyright GreenSocs 2019-2020 | ||
59 | + * | ||
60 | + * Authors: | ||
61 | + * Damien Hedde | ||
62 | + * | ||
63 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
64 | + * See the COPYING file in the top-level directory. | ||
65 | + */ | ||
66 | + | 92 | + |
67 | +#include "qemu/osdep.h" | 93 | if (props->has_die_id && props->die_id != slot->props.die_id) { |
68 | +#include "migration/vmstate.h" | 94 | continue; |
69 | +#include "hw/clock.h" | 95 | } |
70 | + | 96 | @@ -XXX,XX +XXX,XX @@ static char *cpu_slot_to_string(const CPUArchId *cpu) |
71 | +const VMStateDescription vmstate_clock = { | 97 | } |
72 | + .name = "clock", | 98 | g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id); |
73 | + .version_id = 0, | 99 | } |
74 | + .minimum_version_id = 0, | 100 | + if (cpu->props.has_cluster_id) { |
75 | + .fields = (VMStateField[]) { | 101 | + if (s->len) { |
76 | + VMSTATE_UINT64(period, Clock), | 102 | + g_string_append_printf(s, ", "); |
77 | + VMSTATE_END_OF_LIST() | 103 | + } |
104 | + g_string_append_printf(s, "cluster-id: %"PRId64, cpu->props.cluster_id); | ||
78 | + } | 105 | + } |
79 | +}; | 106 | if (cpu->props.has_core_id) { |
107 | if (s->len) { | ||
108 | g_string_append_printf(s, ", "); | ||
80 | -- | 109 | -- |
81 | 2.20.1 | 110 | 2.25.1 |
82 | |||
83 | diff view generated by jsdifflib |
1 | From: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | In addition to simple serial test this patch uses ping | 3 | The CPU topology isn't enabled on arm/virt machine yet, but we're |
4 | to test the ethernet block modelled in SmartFusion2 SoC. | 4 | going to do it in next patch. After the CPU topology is enabled by |
5 | next patch, "thread-id=1" becomes invalid because the CPU core is | ||
6 | preferred on arm/virt machine. It means these two CPUs have 0/1 | ||
7 | as their core IDs, but their thread IDs are all 0. It will trigger | ||
8 | test failure as the following message indicates: | ||
5 | 9 | ||
6 | Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 10 | [14/21 qemu:qtest+qtest-aarch64 / qtest-aarch64/numa-test ERROR |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 11 | 1.48s killed by signal 6 SIGABRT |
8 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | >>> G_TEST_DBUS_DAEMON=/home/gavin/sandbox/qemu.main/tests/dbus-vmstate-daemon.sh \ |
9 | Message-id: 1587048891-30493-4-git-send-email-sundeep.lkml@gmail.com | 13 | QTEST_QEMU_STORAGE_DAEMON_BINARY=./storage-daemon/qemu-storage-daemon \ |
14 | QTEST_QEMU_BINARY=./qemu-system-aarch64 \ | ||
15 | QTEST_QEMU_IMG=./qemu-img MALLOC_PERTURB_=83 \ | ||
16 | /home/gavin/sandbox/qemu.main/build/tests/qtest/numa-test --tap -k | ||
17 | ―――――――――――――――――――――――――――――――――――――――――――――― | ||
18 | stderr: | ||
19 | qemu-system-aarch64: -numa cpu,node-id=0,thread-id=1: no match found | ||
20 | |||
21 | This fixes the issue by providing comprehensive SMP configurations | ||
22 | in aarch64_numa_cpu(). The SMP configurations aren't used before | ||
23 | the CPU topology is enabled in next patch. | ||
24 | |||
25 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
26 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
27 | Message-id: 20220503140304.855514-3-gshan@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 29 | --- |
12 | tests/acceptance/boot_linux_console.py | 15 ++++++++++----- | 30 | tests/qtest/numa-test.c | 3 ++- |
13 | 1 file changed, 10 insertions(+), 5 deletions(-) | 31 | 1 file changed, 2 insertions(+), 1 deletion(-) |
14 | 32 | ||
15 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 33 | diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c |
16 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/tests/acceptance/boot_linux_console.py | 35 | --- a/tests/qtest/numa-test.c |
18 | +++ b/tests/acceptance/boot_linux_console.py | 36 | +++ b/tests/qtest/numa-test.c |
19 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(Test): | 37 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) |
20 | """ | 38 | QTestState *qts; |
21 | uboot_url = ('https://raw.githubusercontent.com/' | 39 | g_autofree char *cli = NULL; |
22 | 'Subbaraya-Sundeep/qemu-test-binaries/' | 40 | |
23 | - 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/u-boot') | 41 | - cli = make_cli(data, "-machine smp.cpus=2 " |
24 | - uboot_hash = 'abba5d9c24cdd2d49cdc2a8aa92976cf20737eff' | 42 | + cli = make_cli(data, "-machine " |
25 | + 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot') | 43 | + "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 " |
26 | + uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2' | 44 | "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 " |
27 | uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash) | 45 | "-numa cpu,node-id=1,thread-id=0 " |
28 | spi_url = ('https://raw.githubusercontent.com/' | 46 | "-numa cpu,node-id=0,thread-id=1"); |
29 | 'Subbaraya-Sundeep/qemu-test-binaries/' | ||
30 | - 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/spi.bin') | ||
31 | - spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a' | ||
32 | + 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin') | ||
33 | + spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501' | ||
34 | spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash) | ||
35 | |||
36 | self.vm.set_console() | ||
37 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(Test): | ||
38 | '-drive', 'file=' + spi_path + ',if=mtd,format=raw', | ||
39 | '-no-reboot') | ||
40 | self.vm.launch() | ||
41 | - self.wait_for_console_pattern('init started: BusyBox') | ||
42 | + self.wait_for_console_pattern('Enter \'help\' for a list') | ||
43 | + | ||
44 | + exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15', | ||
45 | + 'eth0: link becomes ready') | ||
46 | + exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', | ||
47 | + '3 packets transmitted, 3 packets received, 0% packet loss') | ||
48 | |||
49 | def do_test_arm_raspi2(self, uart_id): | ||
50 | """ | ||
51 | -- | 47 | -- |
52 | 2.20.1 | 48 | 2.25.1 |
53 | 49 | ||
54 | 50 | diff view generated by jsdifflib |
1 | From: Jerome Forissier <jerome@forissier.org> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | The /secure-chosen node is currently used only by create_uart(), but | 3 | Currently, the SMP configuration isn't considered when the CPU |
4 | this will change. Therefore move the creation of this node to | 4 | topology is populated. In this case, it's impossible to provide |
5 | create_fdt(). | 5 | the default CPU-to-NUMA mapping or association based on the socket |
6 | ID of the given CPU. | ||
6 | 7 | ||
7 | Signed-off-by: Jerome Forissier <jerome@forissier.org> | 8 | This takes account of SMP configuration when the CPU topology |
8 | Message-id: 20200420121807.8204-2-jerome@forissier.org | 9 | is populated. The die ID for the given CPU isn't assigned since |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | it's not supported on arm/virt machine. Besides, the used SMP |
11 | configuration in qtest/numa-test/aarch64_numa_cpu() is corrcted | ||
12 | to avoid testing failure | ||
13 | |||
14 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
15 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
16 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
17 | Message-id: 20220503140304.855514-4-gshan@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 19 | --- |
12 | hw/arm/virt.c | 5 ++++- | 20 | hw/arm/virt.c | 15 ++++++++++++++- |
13 | 1 file changed, 4 insertions(+), 1 deletion(-) | 21 | 1 file changed, 14 insertions(+), 1 deletion(-) |
14 | 22 | ||
15 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 23 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
16 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/virt.c | 25 | --- a/hw/arm/virt.c |
18 | +++ b/hw/arm/virt.c | 26 | +++ b/hw/arm/virt.c |
19 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(VirtMachineState *vms) | 27 | @@ -XXX,XX +XXX,XX @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) |
20 | /* /chosen must exist for load_dtb to fill in necessary properties later */ | 28 | int n; |
21 | qemu_fdt_add_subnode(fdt, "/chosen"); | 29 | unsigned int max_cpus = ms->smp.max_cpus; |
22 | 30 | VirtMachineState *vms = VIRT_MACHINE(ms); | |
23 | + if (vms->secure) { | 31 | + MachineClass *mc = MACHINE_GET_CLASS(vms); |
24 | + qemu_fdt_add_subnode(fdt, "/secure-chosen"); | 32 | |
25 | + } | 33 | if (ms->possible_cpus) { |
34 | assert(ms->possible_cpus->len == max_cpus); | ||
35 | @@ -XXX,XX +XXX,XX @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) | ||
36 | ms->possible_cpus->cpus[n].type = ms->cpu_type; | ||
37 | ms->possible_cpus->cpus[n].arch_id = | ||
38 | virt_cpu_mp_affinity(vms, n); | ||
26 | + | 39 | + |
27 | /* Clock node, for the benefit of the UART. The kernel device tree | 40 | + assert(!mc->smp_props.dies_supported); |
28 | * binding documentation claims the PL011 node clock properties are | 41 | + ms->possible_cpus->cpus[n].props.has_socket_id = true; |
29 | * optional but in practice if you omit them the kernel refuses to | 42 | + ms->possible_cpus->cpus[n].props.socket_id = |
30 | @@ -XXX,XX +XXX,XX @@ static void create_uart(const VirtMachineState *vms, int uart, | 43 | + n / (ms->smp.clusters * ms->smp.cores * ms->smp.threads); |
31 | qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled"); | 44 | + ms->possible_cpus->cpus[n].props.has_cluster_id = true; |
32 | qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay"); | 45 | + ms->possible_cpus->cpus[n].props.cluster_id = |
33 | 46 | + (n / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters; | |
34 | - qemu_fdt_add_subnode(vms->fdt, "/secure-chosen"); | 47 | + ms->possible_cpus->cpus[n].props.has_core_id = true; |
35 | qemu_fdt_setprop_string(vms->fdt, "/secure-chosen", "stdout-path", | 48 | + ms->possible_cpus->cpus[n].props.core_id = |
36 | nodename); | 49 | + (n / ms->smp.threads) % ms->smp.cores; |
50 | ms->possible_cpus->cpus[n].props.has_thread_id = true; | ||
51 | - ms->possible_cpus->cpus[n].props.thread_id = n; | ||
52 | + ms->possible_cpus->cpus[n].props.thread_id = | ||
53 | + n % ms->smp.threads; | ||
37 | } | 54 | } |
55 | return ms->possible_cpus; | ||
56 | } | ||
38 | -- | 57 | -- |
39 | 2.20.1 | 58 | 2.25.1 |
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Cameron Esfahani <dirty@apple.com> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | NRF51_GPIO_REG_CNF_END doesn't actually refer to the start of the last | 3 | In aarch64_numa_cpu(), the CPU and NUMA association is something |
4 | valid CNF register: it's referring to the last byte of the last valid | 4 | like below. Two threads in the same core/cluster/socket are |
5 | CNF register. | 5 | associated with two individual NUMA nodes, which is unreal as |
6 | Igor Mammedov mentioned. We don't expect the association to break | ||
7 | NUMA-to-socket boundary, which matches with the real world. | ||
6 | 8 | ||
7 | This hasn't been a problem up to now, as current implementation in | 9 | NUMA-node socket cluster core thread |
8 | memory.c turns an unaligned 4-byte read from 0x77f to a single byte read | 10 | ------------------------------------------ |
9 | and the qtest only looks at the least-significant byte of the register. | 11 | 0 0 0 0 0 |
12 | 1 0 0 0 1 | ||
10 | 13 | ||
11 | But when running with patches which fix unaligned accesses in memory.c, | 14 | This corrects the topology for CPUs and their association with |
12 | the qtest breaks. | 15 | NUMA nodes. After this patch is applied, the CPU and NUMA |
16 | association becomes something like below, which looks real. | ||
17 | Besides, socket/cluster/core/thread IDs are all checked when | ||
18 | the NUMA node IDs are verified. It helps to check if the CPU | ||
19 | topology is properly populated or not. | ||
13 | 20 | ||
14 | Considering NRF51 doesn't support unaligned accesses, the simplest fix | 21 | NUMA-node socket cluster core thread |
15 | is to actually set NRF51_GPIO_REG_CNF_END to the start of the last valid | 22 | ------------------------------------------ |
16 | CNF register: 0x77c. | 23 | 0 1 0 0 0 |
24 | 1 0 0 0 0 | ||
17 | 25 | ||
18 | Now, qtests work with or without the unaligned access patches. | 26 | Suggested-by: Igor Mammedov <imammedo@redhat.com> |
19 | 27 | Signed-off-by: Gavin Shan <gshan@redhat.com> | |
20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 28 | Acked-by: Igor Mammedov <imammedo@redhat.com> |
21 | Tested-by: Cédric Le Goater <clg@kaod.org> | 29 | Message-id: 20220503140304.855514-5-gshan@redhat.com |
22 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
23 | Signed-off-by: Cameron Esfahani <dirty@apple.com> | ||
24 | Message-id: 51b427f06838622da783d38ba56e3630d6d85c60.1586925392.git.dirty@apple.com | ||
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
27 | --- | 31 | --- |
28 | include/hw/gpio/nrf51_gpio.h | 2 +- | 32 | tests/qtest/numa-test.c | 18 ++++++++++++------ |
29 | 1 file changed, 1 insertion(+), 1 deletion(-) | 33 | 1 file changed, 12 insertions(+), 6 deletions(-) |
30 | 34 | ||
31 | diff --git a/include/hw/gpio/nrf51_gpio.h b/include/hw/gpio/nrf51_gpio.h | 35 | diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c |
32 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/hw/gpio/nrf51_gpio.h | 37 | --- a/tests/qtest/numa-test.c |
34 | +++ b/include/hw/gpio/nrf51_gpio.h | 38 | +++ b/tests/qtest/numa-test.c |
35 | @@ -XXX,XX +XXX,XX @@ | 39 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) |
36 | #define NRF51_GPIO_REG_DIRSET 0x518 | 40 | g_autofree char *cli = NULL; |
37 | #define NRF51_GPIO_REG_DIRCLR 0x51C | 41 | |
38 | #define NRF51_GPIO_REG_CNF_START 0x700 | 42 | cli = make_cli(data, "-machine " |
39 | -#define NRF51_GPIO_REG_CNF_END 0x77F | 43 | - "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 " |
40 | +#define NRF51_GPIO_REG_CNF_END 0x77C | 44 | + "smp.cpus=2,smp.sockets=2,smp.clusters=1,smp.cores=1,smp.threads=1 " |
41 | 45 | "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 " | |
42 | #define NRF51_GPIO_PULLDOWN 1 | 46 | - "-numa cpu,node-id=1,thread-id=0 " |
43 | #define NRF51_GPIO_PULLUP 3 | 47 | - "-numa cpu,node-id=0,thread-id=1"); |
48 | + "-numa cpu,node-id=0,socket-id=1,cluster-id=0,core-id=0,thread-id=0 " | ||
49 | + "-numa cpu,node-id=1,socket-id=0,cluster-id=0,core-id=0,thread-id=0"); | ||
50 | qts = qtest_init(cli); | ||
51 | cpus = get_cpus(qts, &resp); | ||
52 | g_assert(cpus); | ||
53 | |||
54 | while ((e = qlist_pop(cpus))) { | ||
55 | QDict *cpu, *props; | ||
56 | - int64_t thread, node; | ||
57 | + int64_t socket, cluster, core, thread, node; | ||
58 | |||
59 | cpu = qobject_to(QDict, e); | ||
60 | g_assert(qdict_haskey(cpu, "props")); | ||
61 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) | ||
62 | |||
63 | g_assert(qdict_haskey(props, "node-id")); | ||
64 | node = qdict_get_int(props, "node-id"); | ||
65 | + g_assert(qdict_haskey(props, "socket-id")); | ||
66 | + socket = qdict_get_int(props, "socket-id"); | ||
67 | + g_assert(qdict_haskey(props, "cluster-id")); | ||
68 | + cluster = qdict_get_int(props, "cluster-id"); | ||
69 | + g_assert(qdict_haskey(props, "core-id")); | ||
70 | + core = qdict_get_int(props, "core-id"); | ||
71 | g_assert(qdict_haskey(props, "thread-id")); | ||
72 | thread = qdict_get_int(props, "thread-id"); | ||
73 | |||
74 | - if (thread == 0) { | ||
75 | + if (socket == 0 && cluster == 0 && core == 0 && thread == 0) { | ||
76 | g_assert_cmpint(node, ==, 1); | ||
77 | - } else if (thread == 1) { | ||
78 | + } else if (socket == 1 && cluster == 0 && core == 0 && thread == 0) { | ||
79 | g_assert_cmpint(node, ==, 0); | ||
80 | } else { | ||
81 | g_assert(false); | ||
44 | -- | 82 | -- |
45 | 2.20.1 | 83 | 2.25.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | From: Jerome Forissier <jerome@forissier.org> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Generate random seeds to be used by the non-secure and/or secure OSes | 3 | When CPU-to-NUMA association isn't explicitly provided by users, |
4 | for ASLR. The seeds are 64-bit random values exported via the DT | 4 | the default one is given by mc->get_default_cpu_node_id(). However, |
5 | properties /chosen/kaslr-seed [1] and /secure-chosen/kaslr-seed, the | 5 | the CPU topology isn't fully considered in the default association |
6 | latter being used by OP-TEE [2]. | 6 | and this causes CPU topology broken warnings on booting Linux guest. |
7 | 7 | ||
8 | [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5bc0c37c97e1 | 8 | For example, the following warning messages are observed when the |
9 | [2] https://github.com/OP-TEE/optee_os/commit/ef262691fe0e | 9 | Linux guest is booted with the following command lines. |
10 | 10 | ||
11 | Signed-off-by: Jerome Forissier <jerome@forissier.org> | 11 | /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ |
12 | Message-id: 20200420121807.8204-3-jerome@forissier.org | 12 | -accel kvm -machine virt,gic-version=host \ |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | -cpu host \ |
14 | -smp 6,sockets=2,cores=3,threads=1 \ | ||
15 | -m 1024M,slots=16,maxmem=64G \ | ||
16 | -object memory-backend-ram,id=mem0,size=128M \ | ||
17 | -object memory-backend-ram,id=mem1,size=128M \ | ||
18 | -object memory-backend-ram,id=mem2,size=128M \ | ||
19 | -object memory-backend-ram,id=mem3,size=128M \ | ||
20 | -object memory-backend-ram,id=mem4,size=128M \ | ||
21 | -object memory-backend-ram,id=mem4,size=384M \ | ||
22 | -numa node,nodeid=0,memdev=mem0 \ | ||
23 | -numa node,nodeid=1,memdev=mem1 \ | ||
24 | -numa node,nodeid=2,memdev=mem2 \ | ||
25 | -numa node,nodeid=3,memdev=mem3 \ | ||
26 | -numa node,nodeid=4,memdev=mem4 \ | ||
27 | -numa node,nodeid=5,memdev=mem5 | ||
28 | : | ||
29 | alternatives: patching kernel code | ||
30 | BUG: arch topology borken | ||
31 | the CLS domain not a subset of the MC domain | ||
32 | <the above error log repeats> | ||
33 | BUG: arch topology borken | ||
34 | the DIE domain not a subset of the NODE domain | ||
35 | |||
36 | With current implementation of mc->get_default_cpu_node_id(), | ||
37 | CPU#0 to CPU#5 are associated with NODE#0 to NODE#5 separately. | ||
38 | That's incorrect because CPU#0/1/2 should be associated with same | ||
39 | NUMA node because they're seated in same socket. | ||
40 | |||
41 | This fixes the issue by considering the socket ID when the default | ||
42 | CPU-to-NUMA association is provided in virt_possible_cpu_arch_ids(). | ||
43 | With this applied, no more CPU topology broken warnings are seen | ||
44 | from the Linux guest. The 6 CPUs are associated with NODE#0/1, but | ||
45 | there are no CPUs associated with NODE#2/3/4/5. | ||
46 | |||
47 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
48 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
49 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
50 | Message-id: 20220503140304.855514-6-gshan@redhat.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 51 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 52 | --- |
16 | hw/arm/virt.c | 15 +++++++++++++++ | 53 | hw/arm/virt.c | 4 +++- |
17 | 1 file changed, 15 insertions(+) | 54 | 1 file changed, 3 insertions(+), 1 deletion(-) |
18 | 55 | ||
19 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 56 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
20 | index XXXXXXX..XXXXXXX 100644 | 57 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/virt.c | 58 | --- a/hw/arm/virt.c |
22 | +++ b/hw/arm/virt.c | 59 | +++ b/hw/arm/virt.c |
23 | @@ -XXX,XX +XXX,XX @@ | 60 | @@ -XXX,XX +XXX,XX @@ virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) |
24 | #include "hw/acpi/generic_event_device.h" | 61 | |
25 | #include "hw/virtio/virtio-iommu.h" | 62 | static int64_t virt_get_default_cpu_node_id(const MachineState *ms, int idx) |
26 | #include "hw/char/pl011.h" | 63 | { |
27 | +#include "qemu/guest-random.h" | 64 | - return idx % ms->numa_state->num_nodes; |
28 | 65 | + int64_t socket_id = ms->possible_cpus->cpus[idx].props.socket_id; | |
29 | #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ | 66 | + |
30 | static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ | 67 | + return socket_id % ms->numa_state->num_nodes; |
31 | @@ -XXX,XX +XXX,XX @@ static bool cpu_type_valid(const char *cpu) | ||
32 | return false; | ||
33 | } | 68 | } |
34 | 69 | ||
35 | +static void create_kaslr_seed(VirtMachineState *vms, const char *node) | 70 | static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) |
36 | +{ | ||
37 | + Error *err = NULL; | ||
38 | + uint64_t seed; | ||
39 | + | ||
40 | + if (qemu_guest_getrandom(&seed, sizeof(seed), &err)) { | ||
41 | + error_free(err); | ||
42 | + return; | ||
43 | + } | ||
44 | + qemu_fdt_setprop_u64(vms->fdt, node, "kaslr-seed", seed); | ||
45 | +} | ||
46 | + | ||
47 | static void create_fdt(VirtMachineState *vms) | ||
48 | { | ||
49 | MachineState *ms = MACHINE(vms); | ||
50 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(VirtMachineState *vms) | ||
51 | |||
52 | /* /chosen must exist for load_dtb to fill in necessary properties later */ | ||
53 | qemu_fdt_add_subnode(fdt, "/chosen"); | ||
54 | + create_kaslr_seed(vms, "/chosen"); | ||
55 | |||
56 | if (vms->secure) { | ||
57 | qemu_fdt_add_subnode(fdt, "/secure-chosen"); | ||
58 | + create_kaslr_seed(vms, "/secure-chosen"); | ||
59 | } | ||
60 | |||
61 | /* Clock node, for the benefit of the UART. The kernel device tree | ||
62 | -- | 71 | -- |
63 | 2.20.1 | 72 | 2.25.1 |
64 | |||
65 | diff view generated by jsdifflib |
1 | From: Keqian Zhu <zhukeqian1@huawei.com> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Replace "acpi-mem-hotplug" with "acpi-cpu-hotplug" | 3 | When the PPTT table is built, the CPU topology is re-calculated, but |
4 | it's unecessary because the CPU topology has been populated in | ||
5 | virt_possible_cpu_arch_ids() on arm/virt machine. | ||
4 | 6 | ||
5 | Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com> | 7 | This reworks build_pptt() to avoid by reusing the existing IDs in |
6 | Message-id: 20200413091552.62748-4-zhukeqian1@huawei.com | 8 | ms->possible_cpus. Currently, the only user of build_pptt() is |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | arm/virt machine. |
10 | |||
11 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
12 | Tested-by: Yanan Wang <wangyanan55@huawei.com> | ||
13 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
14 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
16 | Message-id: 20220503140304.855514-7-gshan@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 18 | --- |
10 | hw/acpi/cpu.c | 2 +- | 19 | hw/acpi/aml-build.c | 111 +++++++++++++++++++------------------------- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 20 | 1 file changed, 48 insertions(+), 63 deletions(-) |
12 | 21 | ||
13 | diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c | 22 | diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c |
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/acpi/cpu.c | 24 | --- a/hw/acpi/aml-build.c |
16 | +++ b/hw/acpi/cpu.c | 25 | +++ b/hw/acpi/aml-build.c |
17 | @@ -XXX,XX +XXX,XX @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, | 26 | @@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, |
18 | state->devs[i].arch_id = id_list->cpus[i].arch_id; | 27 | const char *oem_id, const char *oem_table_id) |
28 | { | ||
29 | MachineClass *mc = MACHINE_GET_CLASS(ms); | ||
30 | - GQueue *list = g_queue_new(); | ||
31 | - guint pptt_start = table_data->len; | ||
32 | - guint parent_offset; | ||
33 | - guint length, i; | ||
34 | - int uid = 0; | ||
35 | - int socket; | ||
36 | + CPUArchIdList *cpus = ms->possible_cpus; | ||
37 | + int64_t socket_id = -1, cluster_id = -1, core_id = -1; | ||
38 | + uint32_t socket_offset = 0, cluster_offset = 0, core_offset = 0; | ||
39 | + uint32_t pptt_start = table_data->len; | ||
40 | + int n; | ||
41 | AcpiTable table = { .sig = "PPTT", .rev = 2, | ||
42 | .oem_id = oem_id, .oem_table_id = oem_table_id }; | ||
43 | |||
44 | acpi_table_begin(&table, table_data); | ||
45 | |||
46 | - for (socket = 0; socket < ms->smp.sockets; socket++) { | ||
47 | - g_queue_push_tail(list, | ||
48 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
49 | - build_processor_hierarchy_node( | ||
50 | - table_data, | ||
51 | - /* | ||
52 | - * Physical package - represents the boundary | ||
53 | - * of a physical package | ||
54 | - */ | ||
55 | - (1 << 0), | ||
56 | - 0, socket, NULL, 0); | ||
57 | - } | ||
58 | - | ||
59 | - if (mc->smp_props.clusters_supported) { | ||
60 | - length = g_queue_get_length(list); | ||
61 | - for (i = 0; i < length; i++) { | ||
62 | - int cluster; | ||
63 | - | ||
64 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | ||
65 | - for (cluster = 0; cluster < ms->smp.clusters; cluster++) { | ||
66 | - g_queue_push_tail(list, | ||
67 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
68 | - build_processor_hierarchy_node( | ||
69 | - table_data, | ||
70 | - (0 << 0), /* not a physical package */ | ||
71 | - parent_offset, cluster, NULL, 0); | ||
72 | - } | ||
73 | + /* | ||
74 | + * This works with the assumption that cpus[n].props.*_id has been | ||
75 | + * sorted from top to down levels in mc->possible_cpu_arch_ids(). | ||
76 | + * Otherwise, the unexpected and duplicated containers will be | ||
77 | + * created. | ||
78 | + */ | ||
79 | + for (n = 0; n < cpus->len; n++) { | ||
80 | + if (cpus->cpus[n].props.socket_id != socket_id) { | ||
81 | + assert(cpus->cpus[n].props.socket_id > socket_id); | ||
82 | + socket_id = cpus->cpus[n].props.socket_id; | ||
83 | + cluster_id = -1; | ||
84 | + core_id = -1; | ||
85 | + socket_offset = table_data->len - pptt_start; | ||
86 | + build_processor_hierarchy_node(table_data, | ||
87 | + (1 << 0), /* Physical package */ | ||
88 | + 0, socket_id, NULL, 0); | ||
89 | } | ||
90 | - } | ||
91 | |||
92 | - length = g_queue_get_length(list); | ||
93 | - for (i = 0; i < length; i++) { | ||
94 | - int core; | ||
95 | - | ||
96 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | ||
97 | - for (core = 0; core < ms->smp.cores; core++) { | ||
98 | - if (ms->smp.threads > 1) { | ||
99 | - g_queue_push_tail(list, | ||
100 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
101 | - build_processor_hierarchy_node( | ||
102 | - table_data, | ||
103 | - (0 << 0), /* not a physical package */ | ||
104 | - parent_offset, core, NULL, 0); | ||
105 | - } else { | ||
106 | - build_processor_hierarchy_node( | ||
107 | - table_data, | ||
108 | - (1 << 1) | /* ACPI Processor ID valid */ | ||
109 | - (1 << 3), /* Node is a Leaf */ | ||
110 | - parent_offset, uid++, NULL, 0); | ||
111 | + if (mc->smp_props.clusters_supported) { | ||
112 | + if (cpus->cpus[n].props.cluster_id != cluster_id) { | ||
113 | + assert(cpus->cpus[n].props.cluster_id > cluster_id); | ||
114 | + cluster_id = cpus->cpus[n].props.cluster_id; | ||
115 | + core_id = -1; | ||
116 | + cluster_offset = table_data->len - pptt_start; | ||
117 | + build_processor_hierarchy_node(table_data, | ||
118 | + (0 << 0), /* Not a physical package */ | ||
119 | + socket_offset, cluster_id, NULL, 0); | ||
120 | } | ||
121 | + } else { | ||
122 | + cluster_offset = socket_offset; | ||
123 | } | ||
124 | - } | ||
125 | |||
126 | - length = g_queue_get_length(list); | ||
127 | - for (i = 0; i < length; i++) { | ||
128 | - int thread; | ||
129 | + if (ms->smp.threads == 1) { | ||
130 | + build_processor_hierarchy_node(table_data, | ||
131 | + (1 << 1) | /* ACPI Processor ID valid */ | ||
132 | + (1 << 3), /* Node is a Leaf */ | ||
133 | + cluster_offset, n, NULL, 0); | ||
134 | + } else { | ||
135 | + if (cpus->cpus[n].props.core_id != core_id) { | ||
136 | + assert(cpus->cpus[n].props.core_id > core_id); | ||
137 | + core_id = cpus->cpus[n].props.core_id; | ||
138 | + core_offset = table_data->len - pptt_start; | ||
139 | + build_processor_hierarchy_node(table_data, | ||
140 | + (0 << 0), /* Not a physical package */ | ||
141 | + cluster_offset, core_id, NULL, 0); | ||
142 | + } | ||
143 | |||
144 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | ||
145 | - for (thread = 0; thread < ms->smp.threads; thread++) { | ||
146 | - build_processor_hierarchy_node( | ||
147 | - table_data, | ||
148 | + build_processor_hierarchy_node(table_data, | ||
149 | (1 << 1) | /* ACPI Processor ID valid */ | ||
150 | (1 << 2) | /* Processor is a Thread */ | ||
151 | (1 << 3), /* Node is a Leaf */ | ||
152 | - parent_offset, uid++, NULL, 0); | ||
153 | + core_offset, n, NULL, 0); | ||
154 | } | ||
19 | } | 155 | } |
20 | memory_region_init_io(&state->ctrl_reg, owner, &cpu_hotplug_ops, state, | 156 | |
21 | - "acpi-mem-hotplug", ACPI_CPU_HOTPLUG_REG_LEN); | 157 | - g_queue_free(list); |
22 | + "acpi-cpu-hotplug", ACPI_CPU_HOTPLUG_REG_LEN); | 158 | acpi_table_end(linker, &table); |
23 | memory_region_add_subregion(as, base_addr, &state->ctrl_reg); | ||
24 | } | 159 | } |
25 | 160 | ||
26 | -- | 161 | -- |
27 | 2.20.1 | 162 | 2.25.1 |
28 | |||
29 | diff view generated by jsdifflib |