1 | First pullreq for arm of the 4.1 series, since I'm back from | 1 | Hi; here's the latest round of arm patches. I have included also |
---|---|---|---|
2 | holiday now. This is mostly my M-profile FPU series and Philippe's | 2 | my patchset for the RTC devices to avoid keeping time_t and |
3 | devices.h cleanup. I have a pile of other patchsets to work through | 3 | time_t diffs in 32-bit variables. |
4 | in my to-review folder, but 42 patches is definitely quite | ||
5 | big enough to send now... | ||
6 | 4 | ||
7 | thanks | 5 | thanks |
8 | -- PMM | 6 | -- PMM |
9 | 7 | ||
10 | The following changes since commit 413a99a92c13ec408dcf2adaa87918dc81e890c8: | 8 | The following changes since commit 156618d9ea67f2f2e31d9dedd97f2dcccbe6808c: |
11 | 9 | ||
12 | Add Nios II semihosting support. (2019-04-29 16:09:51 +0100) | 10 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2023-08-30 09:20:27 -0400) |
13 | 11 | ||
14 | are available in the Git repository at: | 12 | are available in the Git repository at: |
15 | 13 | ||
16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190429 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230831 |
17 | 15 | ||
18 | for you to fetch changes up to 437cc27ddfded3bbab6afd5ac1761e0e195edba7: | 16 | for you to fetch changes up to e73b8bb8a3e9a162f70e9ffbf922d4fafc96bbfb: |
19 | 17 | ||
20 | hw/devices: Move SMSC 91C111 declaration into a new header (2019-04-29 17:57:21 +0100) | 18 | hw/arm: Set number of MPU regions correctly for an505, an521, an524 (2023-08-31 11:07:02 +0100) |
21 | 19 | ||
22 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
23 | target-arm queue: | 21 | target-arm queue: |
24 | * remove "bag of random stuff" hw/devices.h header | 22 | * Some of the preliminary patches for Cortex-A710 support |
25 | * implement FPU for Cortex-M and enable it for Cortex-M4 and -M33 | 23 | * i.MX7 and i.MX6UL refactoring |
26 | * hw/dma: Compile the bcm2835_dma device as common object | 24 | * Implement SRC device for i.MX7 |
27 | * configure: Remove --source-path option | 25 | * Catch illegal-exception-return from EL3 with bad NSE/NS |
28 | * hw/ssi/xilinx_spips: Avoid variable length array | 26 | * Use 64-bit offsets for holding time_t differences in RTC devices |
29 | * hw/arm/smmuv3: Remove SMMUNotifierNode | 27 | * Model correct number of MPU regions for an505, an521, an524 boards |
30 | 28 | ||
31 | ---------------------------------------------------------------- | 29 | ---------------------------------------------------------------- |
32 | Eric Auger (1): | 30 | Alex Bennée (1): |
33 | hw/arm/smmuv3: Remove SMMUNotifierNode | 31 | target/arm: properly document FEAT_CRC32 |
34 | 32 | ||
35 | Peter Maydell (28): | 33 | Jean-Christophe Dubois (6): |
36 | hw/ssi/xilinx_spips: Avoid variable length array | 34 | Remove i.MX7 IOMUX GPR device from i.MX6UL |
37 | configure: Remove --source-path option | 35 | Refactor i.MX6UL processor code |
38 | target/arm: Make sure M-profile FPSCR RES0 bits are not settable | 36 | Add i.MX6UL missing devices. |
39 | hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers | 37 | Refactor i.MX7 processor code |
40 | target/arm: Implement dummy versions of M-profile FP-related registers | 38 | Add i.MX7 missing TZ devices and memory regions |
41 | target/arm: Disable most VFP sysregs for M-profile | 39 | Add i.MX7 SRC device implementation |
42 | target/arm: Honour M-profile FP enable bits | ||
43 | target/arm: Decode FP instructions for M profile | ||
44 | target/arm: Clear CONTROL_S.SFPA in SG insn if FPU present | ||
45 | target/arm: Handle SFPA and FPCA bits in reads and writes of CONTROL | ||
46 | target/arm/helper: don't return early for STKOF faults during stacking | ||
47 | target/arm: Handle floating point registers in exception entry | ||
48 | target/arm: Implement v7m_update_fpccr() | ||
49 | target/arm: Clear CONTROL.SFPA in BXNS and BLXNS | ||
50 | target/arm: Clean excReturn bits when tail chaining | ||
51 | target/arm: Allow for floating point in callee stack integrity check | ||
52 | target/arm: Handle floating point registers in exception return | ||
53 | target/arm: Move NS TBFLAG from bit 19 to bit 6 | ||
54 | target/arm: Overlap VECSTRIDE and XSCALE_CPAR TB flags | ||
55 | target/arm: Set FPCCR.S when executing M-profile floating point insns | ||
56 | target/arm: Activate M-profile floating point context when FPCCR.ASPEN is set | ||
57 | target/arm: New helper function arm_v7m_mmu_idx_all() | ||
58 | target/arm: New function armv7m_nvic_set_pending_lazyfp() | ||
59 | target/arm: Add lazy-FP-stacking support to v7m_stack_write() | ||
60 | target/arm: Implement M-profile lazy FP state preservation | ||
61 | target/arm: Implement VLSTM for v7M CPUs with an FPU | ||
62 | target/arm: Implement VLLDM for v7M CPUs with an FPU | ||
63 | target/arm: Enable FPU for Cortex-M4 and Cortex-M33 | ||
64 | 40 | ||
65 | Philippe Mathieu-Daudé (13): | 41 | Peter Maydell (8): |
66 | hw/dma: Compile the bcm2835_dma device as common object | 42 | target/arm: Catch illegal-exception-return from EL3 with bad NSE/NS |
67 | hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded string | 43 | hw/rtc/m48t59: Use 64-bit arithmetic in set_alarm() |
68 | hw/arm/nseries: Use TYPE_TMP105 instead of hardcoded string | 44 | hw/rtc/twl92230: Use int64_t for sec_offset and alm_sec |
69 | hw/display/tc6393xb: Remove unused functions | 45 | hw/rtc/aspeed_rtc: Use 64-bit offset for holding time_t difference |
70 | hw/devices: Move TC6393XB declarations into a new header | 46 | rtc: Use time_t for passing and returning time offsets |
71 | hw/devices: Move Blizzard declarations into a new header | 47 | target/arm: Do all "ARM_FEATURE_X implies Y" checks in post_init |
72 | hw/devices: Move CBus declarations into a new header | 48 | hw/arm/armv7m: Add mpu-ns-regions and mpu-s-regions properties |
73 | hw/devices: Move Gamepad declarations into a new header | 49 | hw/arm: Set number of MPU regions correctly for an505, an521, an524 |
74 | hw/devices: Move TI touchscreen declarations into a new header | ||
75 | hw/devices: Move LAN9118 declarations into a new header | ||
76 | hw/net/ne2000-isa: Add guards to the header | ||
77 | hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded string | ||
78 | hw/devices: Move SMSC 91C111 declaration into a new header | ||
79 | 50 | ||
80 | configure | 10 +- | 51 | Richard Henderson (9): |
81 | hw/dma/Makefile.objs | 2 +- | 52 | target/arm: Reduce dcz_blocksize to uint8_t |
82 | include/hw/arm/omap.h | 6 +- | 53 | target/arm: Allow cpu to configure GM blocksize |
83 | include/hw/arm/smmu-common.h | 8 +- | 54 | target/arm: Support more GM blocksizes |
84 | include/hw/devices.h | 62 --- | 55 | target/arm: When tag memory is not present, set MTE=1 |
85 | include/hw/display/blizzard.h | 22 ++ | 56 | target/arm: Introduce make_ccsidr64 |
86 | include/hw/display/tc6393xb.h | 24 ++ | 57 | target/arm: Apply access checks to neoverse-n1 special registers |
87 | include/hw/input/gamepad.h | 19 + | 58 | target/arm: Apply access checks to neoverse-v1 special registers |
88 | include/hw/input/tsc2xxx.h | 36 ++ | 59 | target/arm: Suppress FEAT_TRBE (Trace Buffer Extension) |
89 | include/hw/misc/cbus.h | 32 ++ | 60 | target/arm: Implement FEAT_HPDS2 as a no-op |
90 | include/hw/net/lan9118.h | 21 + | ||
91 | include/hw/net/ne2000-isa.h | 6 + | ||
92 | include/hw/net/smc91c111.h | 19 + | ||
93 | include/qemu/typedefs.h | 1 - | ||
94 | target/arm/cpu.h | 95 ++++- | ||
95 | target/arm/helper.h | 5 + | ||
96 | target/arm/translate.h | 3 + | ||
97 | hw/arm/aspeed.c | 13 +- | ||
98 | hw/arm/exynos4_boards.c | 3 +- | ||
99 | hw/arm/gumstix.c | 2 +- | ||
100 | hw/arm/integratorcp.c | 2 +- | ||
101 | hw/arm/kzm.c | 2 +- | ||
102 | hw/arm/mainstone.c | 2 +- | ||
103 | hw/arm/mps2-tz.c | 3 +- | ||
104 | hw/arm/mps2.c | 2 +- | ||
105 | hw/arm/nseries.c | 7 +- | ||
106 | hw/arm/palm.c | 2 +- | ||
107 | hw/arm/realview.c | 3 +- | ||
108 | hw/arm/smmu-common.c | 6 +- | ||
109 | hw/arm/smmuv3.c | 28 +- | ||
110 | hw/arm/stellaris.c | 2 +- | ||
111 | hw/arm/tosa.c | 2 +- | ||
112 | hw/arm/versatilepb.c | 2 +- | ||
113 | hw/arm/vexpress.c | 2 +- | ||
114 | hw/display/blizzard.c | 2 +- | ||
115 | hw/display/tc6393xb.c | 18 +- | ||
116 | hw/input/stellaris_input.c | 2 +- | ||
117 | hw/input/tsc2005.c | 2 +- | ||
118 | hw/input/tsc210x.c | 4 +- | ||
119 | hw/intc/armv7m_nvic.c | 261 +++++++++++++ | ||
120 | hw/misc/cbus.c | 2 +- | ||
121 | hw/net/lan9118.c | 3 +- | ||
122 | hw/net/smc91c111.c | 2 +- | ||
123 | hw/ssi/xilinx_spips.c | 6 +- | ||
124 | target/arm/cpu.c | 20 + | ||
125 | target/arm/helper.c | 873 +++++++++++++++++++++++++++++++++++++++--- | ||
126 | target/arm/machine.c | 16 + | ||
127 | target/arm/translate.c | 150 +++++++- | ||
128 | target/arm/vfp_helper.c | 8 + | ||
129 | MAINTAINERS | 7 + | ||
130 | 50 files changed, 1595 insertions(+), 235 deletions(-) | ||
131 | delete mode 100644 include/hw/devices.h | ||
132 | create mode 100644 include/hw/display/blizzard.h | ||
133 | create mode 100644 include/hw/display/tc6393xb.h | ||
134 | create mode 100644 include/hw/input/gamepad.h | ||
135 | create mode 100644 include/hw/input/tsc2xxx.h | ||
136 | create mode 100644 include/hw/misc/cbus.h | ||
137 | create mode 100644 include/hw/net/lan9118.h | ||
138 | create mode 100644 include/hw/net/smc91c111.h | ||
139 | 61 | ||
62 | docs/system/arm/emulation.rst | 2 + | ||
63 | include/hw/arm/armsse.h | 5 + | ||
64 | include/hw/arm/armv7m.h | 8 + | ||
65 | include/hw/arm/fsl-imx6ul.h | 158 ++++++++++++++++--- | ||
66 | include/hw/arm/fsl-imx7.h | 338 ++++++++++++++++++++++++++++++----------- | ||
67 | include/hw/misc/imx7_src.h | 66 ++++++++ | ||
68 | include/hw/rtc/aspeed_rtc.h | 2 +- | ||
69 | include/sysemu/rtc.h | 4 +- | ||
70 | target/arm/cpregs.h | 2 + | ||
71 | target/arm/cpu.h | 5 +- | ||
72 | target/arm/internals.h | 6 - | ||
73 | target/arm/tcg/translate.h | 2 + | ||
74 | hw/arm/armsse.c | 16 ++ | ||
75 | hw/arm/armv7m.c | 21 +++ | ||
76 | hw/arm/fsl-imx6ul.c | 174 +++++++++++++-------- | ||
77 | hw/arm/fsl-imx7.c | 201 +++++++++++++++++++----- | ||
78 | hw/arm/mps2-tz.c | 29 ++++ | ||
79 | hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++ | ||
80 | hw/rtc/aspeed_rtc.c | 5 +- | ||
81 | hw/rtc/m48t59.c | 2 +- | ||
82 | hw/rtc/twl92230.c | 4 +- | ||
83 | softmmu/rtc.c | 4 +- | ||
84 | target/arm/cpu.c | 207 ++++++++++++++----------- | ||
85 | target/arm/helper.c | 15 +- | ||
86 | target/arm/tcg/cpu32.c | 2 +- | ||
87 | target/arm/tcg/cpu64.c | 102 +++++++++---- | ||
88 | target/arm/tcg/helper-a64.c | 9 ++ | ||
89 | target/arm/tcg/mte_helper.c | 90 ++++++++--- | ||
90 | target/arm/tcg/translate-a64.c | 5 +- | ||
91 | hw/misc/meson.build | 1 + | ||
92 | hw/misc/trace-events | 4 + | ||
93 | 31 files changed, 1393 insertions(+), 372 deletions(-) | ||
94 | create mode 100644 include/hw/misc/imx7_src.h | ||
95 | create mode 100644 hw/misc/imx7_src.c | ||
96 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
2 | 1 | ||
3 | The SMMUNotifierNode struct is not necessary and brings extra | ||
4 | complexity so let's remove it. We now directly track the SMMUDevices | ||
5 | which have registered IOMMU MR notifiers. | ||
6 | |||
7 | This is inspired from the same transformation on intel-iommu | ||
8 | done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef | ||
9 | ("intel-iommu: remove IntelIOMMUNotifierNode") | ||
10 | |||
11 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
12 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
13 | Message-id: 20190409160219.19026-1-eric.auger@redhat.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/arm/smmu-common.h | 8 ++------ | ||
17 | hw/arm/smmu-common.c | 6 +++--- | ||
18 | hw/arm/smmuv3.c | 28 +++++++--------------------- | ||
19 | 3 files changed, 12 insertions(+), 30 deletions(-) | ||
20 | |||
21 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/arm/smmu-common.h | ||
24 | +++ b/include/hw/arm/smmu-common.h | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUDevice { | ||
26 | AddressSpace as; | ||
27 | uint32_t cfg_cache_hits; | ||
28 | uint32_t cfg_cache_misses; | ||
29 | + QLIST_ENTRY(SMMUDevice) next; | ||
30 | } SMMUDevice; | ||
31 | |||
32 | -typedef struct SMMUNotifierNode { | ||
33 | - SMMUDevice *sdev; | ||
34 | - QLIST_ENTRY(SMMUNotifierNode) next; | ||
35 | -} SMMUNotifierNode; | ||
36 | - | ||
37 | typedef struct SMMUPciBus { | ||
38 | PCIBus *bus; | ||
39 | SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */ | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUState { | ||
41 | GHashTable *iotlb; | ||
42 | SMMUPciBus *smmu_pcibus_by_bus_num[SMMU_PCI_BUS_MAX]; | ||
43 | PCIBus *pci_bus; | ||
44 | - QLIST_HEAD(, SMMUNotifierNode) notifiers_list; | ||
45 | + QLIST_HEAD(, SMMUDevice) devices_with_notifiers; | ||
46 | uint8_t bus_num; | ||
47 | PCIBus *primary_bus; | ||
48 | } SMMUState; | ||
49 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/arm/smmu-common.c | ||
52 | +++ b/hw/arm/smmu-common.c | ||
53 | @@ -XXX,XX +XXX,XX @@ inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) | ||
54 | /* Unmap all notifiers of all mr's */ | ||
55 | void smmu_inv_notifiers_all(SMMUState *s) | ||
56 | { | ||
57 | - SMMUNotifierNode *node; | ||
58 | + SMMUDevice *sdev; | ||
59 | |||
60 | - QLIST_FOREACH(node, &s->notifiers_list, next) { | ||
61 | - smmu_inv_notifiers_mr(&node->sdev->iommu); | ||
62 | + QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) { | ||
63 | + smmu_inv_notifiers_mr(&sdev->iommu); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/hw/arm/smmuv3.c | ||
70 | +++ b/hw/arm/smmuv3.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | ||
72 | /* invalidate an asid/iova tuple in all mr's */ | ||
73 | static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova) | ||
74 | { | ||
75 | - SMMUNotifierNode *node; | ||
76 | + SMMUDevice *sdev; | ||
77 | |||
78 | - QLIST_FOREACH(node, &s->notifiers_list, next) { | ||
79 | - IOMMUMemoryRegion *mr = &node->sdev->iommu; | ||
80 | + QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) { | ||
81 | + IOMMUMemoryRegion *mr = &sdev->iommu; | ||
82 | IOMMUNotifier *n; | ||
83 | |||
84 | trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova); | ||
85 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | ||
86 | SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu); | ||
87 | SMMUv3State *s3 = sdev->smmu; | ||
88 | SMMUState *s = &(s3->smmu_state); | ||
89 | - SMMUNotifierNode *node = NULL; | ||
90 | - SMMUNotifierNode *next_node = NULL; | ||
91 | |||
92 | if (new & IOMMU_NOTIFIER_MAP) { | ||
93 | int bus_num = pci_bus_num(sdev->bus); | ||
94 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | ||
95 | |||
96 | if (old == IOMMU_NOTIFIER_NONE) { | ||
97 | trace_smmuv3_notify_flag_add(iommu->parent_obj.name); | ||
98 | - node = g_malloc0(sizeof(*node)); | ||
99 | - node->sdev = sdev; | ||
100 | - QLIST_INSERT_HEAD(&s->notifiers_list, node, next); | ||
101 | - return; | ||
102 | - } | ||
103 | - | ||
104 | - /* update notifier node with new flags */ | ||
105 | - QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) { | ||
106 | - if (node->sdev == sdev) { | ||
107 | - if (new == IOMMU_NOTIFIER_NONE) { | ||
108 | - trace_smmuv3_notify_flag_del(iommu->parent_obj.name); | ||
109 | - QLIST_REMOVE(node, next); | ||
110 | - g_free(node); | ||
111 | - } | ||
112 | - return; | ||
113 | - } | ||
114 | + QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next); | ||
115 | + } else if (new == IOMMU_NOTIFIER_NONE) { | ||
116 | + trace_smmuv3_notify_flag_del(iommu->parent_obj.name); | ||
117 | + QLIST_REMOVE(sdev, next); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | -- | ||
122 | 2.20.1 | ||
123 | |||
124 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In the stripe8() function we use a variable length array; however | ||
2 | we know that the maximum length required is MAX_NUM_BUSSES. Use | ||
3 | a fixed-length array and an assert instead. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
10 | Message-id: 20190328152635.2794-1-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/ssi/xilinx_spips.c | 6 ++++-- | ||
13 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/ssi/xilinx_spips.c | ||
18 | +++ b/hw/ssi/xilinx_spips.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d) | ||
20 | |||
21 | static inline void stripe8(uint8_t *x, int num, bool dir) | ||
22 | { | ||
23 | - uint8_t r[num]; | ||
24 | - memset(r, 0, sizeof(uint8_t) * num); | ||
25 | + uint8_t r[MAX_NUM_BUSSES]; | ||
26 | int idx[2] = {0, 0}; | ||
27 | int bit[2] = {0, 7}; | ||
28 | int d = dir; | ||
29 | |||
30 | + assert(num <= MAX_NUM_BUSSES); | ||
31 | + memset(r, 0, sizeof(uint8_t) * num); | ||
32 | + | ||
33 | for (idx[0] = 0; idx[0] < num; ++idx[0]) { | ||
34 | for (bit[0] = 7; bit[0] >= 0; bit[0]--) { | ||
35 | r[idx[!d]] |= x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0; | ||
36 | -- | ||
37 | 2.20.1 | ||
38 | |||
39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Normally configure identifies the source path by looking | ||
2 | at the location where the configure script itself exists. | ||
3 | We also provide a --source-path option which lets the user | ||
4 | manually override this. | ||
5 | 1 | ||
6 | There isn't really an obvious use case for the --source-path | ||
7 | option, and in commit 927128222b0a91f56c13a in 2017 we | ||
8 | accidentally added some logic that looks at $source_path | ||
9 | before the command line option that overrides it has been | ||
10 | processed. | ||
11 | |||
12 | The fact that nobody complained suggests that there isn't | ||
13 | any use of this option and we aren't testing it either; | ||
14 | remove it. This allows us to move the "make $source_path | ||
15 | absolute" logic up so that there is no window in the script | ||
16 | where $source_path is set but not yet absolute. | ||
17 | |||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
20 | Message-id: 20190318134019.23729-1-peter.maydell@linaro.org | ||
21 | --- | ||
22 | configure | 10 ++-------- | ||
23 | 1 file changed, 2 insertions(+), 8 deletions(-) | ||
24 | |||
25 | diff --git a/configure b/configure | ||
26 | index XXXXXXX..XXXXXXX 100755 | ||
27 | --- a/configure | ||
28 | +++ b/configure | ||
29 | @@ -XXX,XX +XXX,XX @@ ld_has() { | ||
30 | |||
31 | # default parameters | ||
32 | source_path=$(dirname "$0") | ||
33 | +# make source path absolute | ||
34 | +source_path=$(cd "$source_path"; pwd) | ||
35 | cpu="" | ||
36 | iasl="iasl" | ||
37 | interp_prefix="/usr/gnemul/qemu-%M" | ||
38 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
39 | ;; | ||
40 | --cxx=*) CXX="$optarg" | ||
41 | ;; | ||
42 | - --source-path=*) source_path="$optarg" | ||
43 | - ;; | ||
44 | --cpu=*) cpu="$optarg" | ||
45 | ;; | ||
46 | --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg" | ||
47 | @@ -XXX,XX +XXX,XX @@ if test "$debug_info" = "yes"; then | ||
48 | LDFLAGS="-g $LDFLAGS" | ||
49 | fi | ||
50 | |||
51 | -# make source path absolute | ||
52 | -source_path=$(cd "$source_path"; pwd) | ||
53 | - | ||
54 | # running configure in the source tree? | ||
55 | # we know that's the case if configure is there. | ||
56 | if test -f "./configure"; then | ||
57 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
58 | ;; | ||
59 | --interp-prefix=*) interp_prefix="$optarg" | ||
60 | ;; | ||
61 | - --source-path=*) | ||
62 | - ;; | ||
63 | --cross-prefix=*) | ||
64 | ;; | ||
65 | --cc=*) | ||
66 | @@ -XXX,XX +XXX,XX @@ $(echo Available targets: $default_target_list | \ | ||
67 | --target-list-exclude=LIST exclude a set of targets from the default target-list | ||
68 | |||
69 | Advanced options (experts only): | ||
70 | - --source-path=PATH path of source code [$source_path] | ||
71 | --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix] | ||
72 | --cc=CC use C compiler CC [$cc] | ||
73 | --iasl=IASL use ACPI compiler IASL [$iasl] | ||
74 | -- | ||
75 | 2.20.1 | ||
76 | |||
77 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Enforce that for M-profile various FPSCR bits which are RES0 there | ||
2 | but have defined meanings on A-profile are never settable. This | ||
3 | ensures that M-profile code can't enable the A-profile behaviour | ||
4 | (notably vector length/stride handling) by accident. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190416125744.27770-2-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/vfp_helper.c | 8 ++++++++ | ||
11 | 1 file changed, 8 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/vfp_helper.c | ||
16 | +++ b/target/arm/vfp_helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
18 | val &= ~FPCR_FZ16; | ||
19 | } | ||
20 | |||
21 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
22 | + /* | ||
23 | + * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | ||
24 | + * and also for the trapped-exception-handling bits IxE. | ||
25 | + */ | ||
26 | + val &= 0xf7c0009f; | ||
27 | + } | ||
28 | + | ||
29 | /* | ||
30 | * We don't implement trapped exception handling, so the | ||
31 | * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | ||
32 | -- | ||
33 | 2.20.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For M-profile the MVFR* ID registers are memory mapped, in the | ||
2 | range we implement via the NVIC. Allow them to be read. | ||
3 | (If the CPU has no FPU, these registers are defined to be RAZ.) | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190416125744.27770-3-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/armv7m_nvic.c | 6 ++++++ | ||
10 | 1 file changed, 6 insertions(+) | ||
11 | |||
12 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/intc/armv7m_nvic.c | ||
15 | +++ b/hw/intc/armv7m_nvic.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
17 | return 0; | ||
18 | } | ||
19 | return cpu->env.v7m.sfar; | ||
20 | + case 0xf40: /* MVFR0 */ | ||
21 | + return cpu->isar.mvfr0; | ||
22 | + case 0xf44: /* MVFR1 */ | ||
23 | + return cpu->isar.mvfr1; | ||
24 | + case 0xf48: /* MVFR2 */ | ||
25 | + return cpu->isar.mvfr2; | ||
26 | default: | ||
27 | bad_offset: | ||
28 | qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset); | ||
29 | -- | ||
30 | 2.20.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
1 | In the v7M architecture, if an exception is generated in the process | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | of doing the lazy stacking of FP registers, the handling of | ||
3 | possible escalation to HardFault is treated differently to the normal | ||
4 | approach: it works based on the saved information about exception | ||
5 | readiness that was stored in the FPCCR when the stack frame was | ||
6 | created. Provide a new function armv7m_nvic_set_pending_lazyfp() | ||
7 | which pends exceptions during lazy stacking, and implements | ||
8 | this logic. | ||
9 | 2 | ||
10 | This corresponds to the pseudocode TakePreserveFPException(). | 3 | This value is only 4 bits wide. |
11 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Message-id: 20230811214031.171020-2-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20190416125744.27770-22-peter.maydell@linaro.org | ||
15 | --- | 10 | --- |
16 | target/arm/cpu.h | 12 ++++++ | 11 | target/arm/cpu.h | 3 ++- |
17 | hw/intc/armv7m_nvic.c | 96 +++++++++++++++++++++++++++++++++++++++++++ | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
18 | 2 files changed, 108 insertions(+) | ||
19 | 13 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 16 | --- a/target/arm/cpu.h |
23 | +++ b/target/arm/cpu.h | 17 | +++ b/target/arm/cpu.h |
24 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure); | 18 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
25 | * a different exception). | 19 | bool prop_lpa2; |
26 | */ | 20 | |
27 | void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure); | 21 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ |
28 | +/** | 22 | - uint32_t dcz_blocksize; |
29 | + * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | 23 | + uint8_t dcz_blocksize; |
30 | + * @opaque: the NVIC | ||
31 | + * @irq: the exception number to mark pending | ||
32 | + * @secure: false for non-banked exceptions or for the nonsecure | ||
33 | + * version of a banked exception, true for the secure version of a banked | ||
34 | + * exception. | ||
35 | + * | ||
36 | + * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | ||
37 | + * generated in the course of lazy stacking of FP registers. | ||
38 | + */ | ||
39 | +void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure); | ||
40 | /** | ||
41 | * armv7m_nvic_get_pending_irq_info: return highest priority pending | ||
42 | * exception, and whether it targets Secure state | ||
43 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/intc/armv7m_nvic.c | ||
46 | +++ b/hw/intc/armv7m_nvic.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure) | ||
48 | do_armv7m_nvic_set_pending(opaque, irq, secure, true); | ||
49 | } | ||
50 | |||
51 | +void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) | ||
52 | +{ | ||
53 | + /* | ||
54 | + * Pend an exception during lazy FP stacking. This differs | ||
55 | + * from the usual exception pending because the logic for | ||
56 | + * whether we should escalate depends on the saved context | ||
57 | + * in the FPCCR register, not on the current state of the CPU/NVIC. | ||
58 | + */ | ||
59 | + NVICState *s = (NVICState *)opaque; | ||
60 | + bool banked = exc_is_banked(irq); | ||
61 | + VecInfo *vec; | ||
62 | + bool targets_secure; | ||
63 | + bool escalate = false; | ||
64 | + /* | ||
65 | + * We will only look at bits in fpccr if this is a banked exception | ||
66 | + * (in which case 'secure' tells us whether it is the S or NS version). | ||
67 | + * All the bits for the non-banked exceptions are in fpccr_s. | ||
68 | + */ | ||
69 | + uint32_t fpccr_s = s->cpu->env.v7m.fpccr[M_REG_S]; | ||
70 | + uint32_t fpccr = s->cpu->env.v7m.fpccr[secure]; | ||
71 | + | 24 | + |
72 | + assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); | 25 | uint64_t rvbar_prop; /* Property/input signals. */ |
73 | + assert(!secure || banked); | 26 | |
74 | + | 27 | /* Configurable aspects of GIC cpu interface (which is part of the CPU) */ |
75 | + vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq]; | ||
76 | + | ||
77 | + targets_secure = banked ? secure : exc_targets_secure(s, irq); | ||
78 | + | ||
79 | + switch (irq) { | ||
80 | + case ARMV7M_EXCP_DEBUG: | ||
81 | + if (!(fpccr_s & R_V7M_FPCCR_MONRDY_MASK)) { | ||
82 | + /* Ignore DebugMonitor exception */ | ||
83 | + return; | ||
84 | + } | ||
85 | + break; | ||
86 | + case ARMV7M_EXCP_MEM: | ||
87 | + escalate = !(fpccr & R_V7M_FPCCR_MMRDY_MASK); | ||
88 | + break; | ||
89 | + case ARMV7M_EXCP_USAGE: | ||
90 | + escalate = !(fpccr & R_V7M_FPCCR_UFRDY_MASK); | ||
91 | + break; | ||
92 | + case ARMV7M_EXCP_BUS: | ||
93 | + escalate = !(fpccr_s & R_V7M_FPCCR_BFRDY_MASK); | ||
94 | + break; | ||
95 | + case ARMV7M_EXCP_SECURE: | ||
96 | + escalate = !(fpccr_s & R_V7M_FPCCR_SFRDY_MASK); | ||
97 | + break; | ||
98 | + default: | ||
99 | + g_assert_not_reached(); | ||
100 | + } | ||
101 | + | ||
102 | + if (escalate) { | ||
103 | + /* | ||
104 | + * Escalate to HardFault: faults that initially targeted Secure | ||
105 | + * continue to do so, even if HF normally targets NonSecure. | ||
106 | + */ | ||
107 | + irq = ARMV7M_EXCP_HARD; | ||
108 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) && | ||
109 | + (targets_secure || | ||
110 | + !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))) { | ||
111 | + vec = &s->sec_vectors[irq]; | ||
112 | + } else { | ||
113 | + vec = &s->vectors[irq]; | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | + if (!vec->enabled || | ||
118 | + nvic_exec_prio(s) <= exc_group_prio(s, vec->prio, secure)) { | ||
119 | + if (!(fpccr_s & R_V7M_FPCCR_HFRDY_MASK)) { | ||
120 | + /* | ||
121 | + * We want to escalate to HardFault but the context the | ||
122 | + * FP state belongs to prevents the exception pre-empting. | ||
123 | + */ | ||
124 | + cpu_abort(&s->cpu->parent_obj, | ||
125 | + "Lockup: can't escalate to HardFault during " | ||
126 | + "lazy FP register stacking\n"); | ||
127 | + } | ||
128 | + } | ||
129 | + | ||
130 | + if (escalate) { | ||
131 | + s->cpu->env.v7m.hfsr |= R_V7M_HFSR_FORCED_MASK; | ||
132 | + } | ||
133 | + if (!vec->pending) { | ||
134 | + vec->pending = 1; | ||
135 | + /* | ||
136 | + * We do not call nvic_irq_update(), because we know our caller | ||
137 | + * is going to handle causing us to take the exception by | ||
138 | + * raising EXCP_LAZYFP, so raising the IRQ line would be | ||
139 | + * pointless extra work. We just need to recompute the | ||
140 | + * priorities so that armv7m_nvic_can_take_pending_exception() | ||
141 | + * returns the right answer. | ||
142 | + */ | ||
143 | + nvic_recompute_state(s); | ||
144 | + } | ||
145 | +} | ||
146 | + | ||
147 | /* Make pending IRQ active. */ | ||
148 | void armv7m_nvic_acknowledge_irq(void *opaque) | ||
149 | { | ||
150 | -- | 28 | -- |
151 | 2.20.1 | 29 | 2.34.1 |
152 | 30 | ||
153 | 31 | diff view generated by jsdifflib |
1 | Implement the VLSTM instruction for v7M for the FPU present case. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Previously we hard-coded the blocksize with GMID_EL1_BS. | ||
4 | But the value we choose for -cpu max does not match the | ||
5 | value that cortex-a710 uses. | ||
6 | |||
7 | Mirror the way we handle dcz_blocksize. | ||
8 | |||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20230811214031.171020-3-richard.henderson@linaro.org | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20190416125744.27770-25-peter.maydell@linaro.org | ||
6 | --- | 13 | --- |
7 | target/arm/cpu.h | 2 + | 14 | target/arm/cpu.h | 2 ++ |
8 | target/arm/helper.h | 2 + | 15 | target/arm/internals.h | 6 ----- |
9 | target/arm/helper.c | 84 ++++++++++++++++++++++++++++++++++++++++++ | 16 | target/arm/tcg/translate.h | 2 ++ |
10 | target/arm/translate.c | 15 +++++++- | 17 | target/arm/helper.c | 11 +++++--- |
11 | 4 files changed, 102 insertions(+), 1 deletion(-) | 18 | target/arm/tcg/cpu64.c | 1 + |
19 | target/arm/tcg/mte_helper.c | 46 ++++++++++++++++++++++------------ | ||
20 | target/arm/tcg/translate-a64.c | 5 ++-- | ||
21 | 7 files changed, 45 insertions(+), 28 deletions(-) | ||
12 | 22 | ||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.h | 25 | --- a/target/arm/cpu.h |
16 | +++ b/target/arm/cpu.h | 26 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
18 | #define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */ | 28 | |
19 | #define EXCP_STKOF 19 /* v8M STKOF UsageFault */ | 29 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ |
20 | #define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ | 30 | uint8_t dcz_blocksize; |
21 | +#define EXCP_LSERR 21 /* v8M LSERR SecureFault */ | 31 | + /* GM blocksize, in log_2(words), ie low 4 bits of GMID_EL0 */ |
22 | +#define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ | 32 | + uint8_t gm_blocksize; |
23 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 33 | |
24 | 34 | uint64_t rvbar_prop; /* Property/input signals. */ | |
25 | #define ARMV7M_EXCP_RESET 1 | 35 | |
26 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 36 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
27 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/helper.h | 38 | --- a/target/arm/internals.h |
29 | +++ b/target/arm/helper.h | 39 | +++ b/target/arm/internals.h |
30 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | 40 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs); |
31 | 41 | ||
32 | DEF_HELPER_1(v7m_preserve_fp_state, void, env) | 42 | #endif /* !CONFIG_USER_ONLY */ |
33 | 43 | ||
34 | +DEF_HELPER_2(v7m_vlstm, void, env, i32) | 44 | -/* |
35 | + | 45 | - * The log2 of the words in the tag block, for GMID_EL1.BS. |
36 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | 46 | - * The is the maximum, 256 bytes, which manipulates 64-bits of tags. |
37 | 47 | - */ | |
38 | DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | 48 | -#define GMID_EL1_BS 6 |
49 | - | ||
50 | /* | ||
51 | * SVE predicates are 1/8 the size of SVE vectors, and cannot use | ||
52 | * the same simd_desc() encoding due to restrictions on size. | ||
53 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/tcg/translate.h | ||
56 | +++ b/target/arm/tcg/translate.h | ||
57 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
58 | int8_t btype; | ||
59 | /* A copy of cpu->dcz_blocksize. */ | ||
60 | uint8_t dcz_blocksize; | ||
61 | + /* A copy of cpu->gm_blocksize. */ | ||
62 | + uint8_t gm_blocksize; | ||
63 | /* True if this page is guarded. */ | ||
64 | bool guarded_page; | ||
65 | /* Bottom two bits of XScale c15_cpar coprocessor access control reg */ | ||
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 66 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
40 | index XXXXXXX..XXXXXXX 100644 | 67 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/helper.c | 68 | --- a/target/arm/helper.c |
42 | +++ b/target/arm/helper.c | 69 | +++ b/target/arm/helper.c |
43 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 70 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { |
44 | g_assert_not_reached(); | 71 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 6, |
45 | } | 72 | .access = PL1_RW, .accessfn = access_mte, |
46 | 73 | .fieldoffset = offsetof(CPUARMState, cp15.gcr_el1) }, | |
47 | +void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 74 | - { .name = "GMID_EL1", .state = ARM_CP_STATE_AA64, |
48 | +{ | 75 | - .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4, |
49 | + /* translate.c should never generate calls here in user-only mode */ | 76 | - .access = PL1_R, .accessfn = access_aa64_tid5, |
50 | + g_assert_not_reached(); | 77 | - .type = ARM_CP_CONST, .resetvalue = GMID_EL1_BS }, |
51 | +} | 78 | { .name = "TCO", .state = ARM_CP_STATE_AA64, |
52 | + | 79 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, |
53 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 80 | .type = ARM_CP_NO_RAW, |
54 | { | 81 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
55 | /* The TT instructions can be used by unprivileged code, but in | 82 | * then define only a RAZ/WI version of PSTATE.TCO. |
56 | @@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | 83 | */ |
84 | if (cpu_isar_feature(aa64_mte, cpu)) { | ||
85 | + ARMCPRegInfo gmid_reginfo = { | ||
86 | + .name = "GMID_EL1", .state = ARM_CP_STATE_AA64, | ||
87 | + .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4, | ||
88 | + .access = PL1_R, .accessfn = access_aa64_tid5, | ||
89 | + .type = ARM_CP_CONST, .resetvalue = cpu->gm_blocksize, | ||
90 | + }; | ||
91 | + define_one_arm_cp_reg(cpu, &gmid_reginfo); | ||
92 | define_arm_cp_regs(cpu, mte_reginfo); | ||
93 | define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo); | ||
94 | } else if (cpu_isar_feature(aa64_mte_insn_reg, cpu)) { | ||
95 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/target/arm/tcg/cpu64.c | ||
98 | +++ b/target/arm/tcg/cpu64.c | ||
99 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | ||
100 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
101 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
102 | #endif | ||
103 | + cpu->gm_blocksize = 6; /* 256 bytes */ | ||
104 | |||
105 | cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
106 | cpu->sme_vq.supported = SVE_VQ_POW2_MAP; | ||
107 | diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/tcg/mte_helper.c | ||
110 | +++ b/target/arm/tcg/mte_helper.c | ||
111 | @@ -XXX,XX +XXX,XX @@ void HELPER(st2g_stub)(CPUARMState *env, uint64_t ptr) | ||
57 | } | 112 | } |
58 | } | 113 | } |
59 | 114 | ||
60 | +void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 115 | -#define LDGM_STGM_SIZE (4 << GMID_EL1_BS) |
61 | +{ | 116 | - |
62 | + /* fptr is the value of Rn, the frame pointer we store the FP regs to */ | 117 | uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) |
63 | + bool s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | 118 | { |
64 | + bool lspact = env->v7m.fpccr[s] & R_V7M_FPCCR_LSPACT_MASK; | 119 | int mmu_idx = cpu_mmu_index(env, false); |
65 | + | 120 | uintptr_t ra = GETPC(); |
66 | + assert(env->v7m.secure); | 121 | + int gm_bs = env_archcpu(env)->gm_blocksize; |
67 | + | 122 | + int gm_bs_bytes = 4 << gm_bs; |
68 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | 123 | void *tag_mem; |
69 | + return; | 124 | |
125 | - ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE); | ||
126 | + ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
127 | |||
128 | /* Trap if accessing an invalid page. */ | ||
129 | tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_LOAD, | ||
130 | - LDGM_STGM_SIZE, MMU_DATA_LOAD, | ||
131 | - LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra); | ||
132 | + gm_bs_bytes, MMU_DATA_LOAD, | ||
133 | + gm_bs_bytes / (2 * TAG_GRANULE), ra); | ||
134 | |||
135 | /* The tag is squashed to zero if the page does not support tags. */ | ||
136 | if (!tag_mem) { | ||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | - QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6); | ||
141 | /* | ||
142 | - * We are loading 64-bits worth of tags. The ordering of elements | ||
143 | - * within the word corresponds to a 64-bit little-endian operation. | ||
144 | + * The ordering of elements within the word corresponds to | ||
145 | + * a little-endian operation. | ||
146 | */ | ||
147 | - return ldq_le_p(tag_mem); | ||
148 | + switch (gm_bs) { | ||
149 | + case 6: | ||
150 | + /* 256 bytes -> 16 tags -> 64 result bits */ | ||
151 | + return ldq_le_p(tag_mem); | ||
152 | + default: | ||
153 | + /* cpu configured with unsupported gm blocksize. */ | ||
154 | + g_assert_not_reached(); | ||
70 | + } | 155 | + } |
71 | + | 156 | } |
72 | + /* Check access to the coprocessor is permitted */ | 157 | |
73 | + if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) { | 158 | void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
74 | + raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC()); | 159 | { |
160 | int mmu_idx = cpu_mmu_index(env, false); | ||
161 | uintptr_t ra = GETPC(); | ||
162 | + int gm_bs = env_archcpu(env)->gm_blocksize; | ||
163 | + int gm_bs_bytes = 4 << gm_bs; | ||
164 | void *tag_mem; | ||
165 | |||
166 | - ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE); | ||
167 | + ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
168 | |||
169 | /* Trap if accessing an invalid page. */ | ||
170 | tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_STORE, | ||
171 | - LDGM_STGM_SIZE, MMU_DATA_LOAD, | ||
172 | - LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra); | ||
173 | + gm_bs_bytes, MMU_DATA_LOAD, | ||
174 | + gm_bs_bytes / (2 * TAG_GRANULE), ra); | ||
175 | |||
176 | /* | ||
177 | * Tag store only happens if the page support tags, | ||
178 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | - QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6); | ||
183 | /* | ||
184 | - * We are storing 64-bits worth of tags. The ordering of elements | ||
185 | - * within the word corresponds to a 64-bit little-endian operation. | ||
186 | + * The ordering of elements within the word corresponds to | ||
187 | + * a little-endian operation. | ||
188 | */ | ||
189 | - stq_le_p(tag_mem, val); | ||
190 | + switch (gm_bs) { | ||
191 | + case 6: | ||
192 | + stq_le_p(tag_mem, val); | ||
193 | + break; | ||
194 | + default: | ||
195 | + /* cpu configured with unsupported gm blocksize. */ | ||
196 | + g_assert_not_reached(); | ||
75 | + } | 197 | + } |
76 | + | 198 | } |
77 | + if (lspact) { | 199 | |
78 | + /* LSPACT should not be active when there is active FP state */ | 200 | void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val) |
79 | + raise_exception_ra(env, EXCP_LSERR, 0, 1, GETPC()); | 201 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
80 | + } | 202 | index XXXXXXX..XXXXXXX 100644 |
81 | + | 203 | --- a/target/arm/tcg/translate-a64.c |
82 | + if (fptr & 7) { | 204 | +++ b/target/arm/tcg/translate-a64.c |
83 | + raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC()); | 205 | @@ -XXX,XX +XXX,XX @@ static bool trans_STGM(DisasContext *s, arg_ldst_tag *a) |
84 | + } | 206 | gen_helper_stgm(cpu_env, addr, tcg_rt); |
85 | + | 207 | } else { |
86 | + /* | 208 | MMUAccessType acc = MMU_DATA_STORE; |
87 | + * Note that we do not use v7m_stack_write() here, because the | 209 | - int size = 4 << GMID_EL1_BS; |
88 | + * accesses should not set the FSR bits for stacking errors if they | 210 | + int size = 4 << s->gm_blocksize; |
89 | + * fail. (In pseudocode terms, they are AccType_NORMAL, not AccType_STACK | 211 | |
90 | + * or AccType_LAZYFP). Faults in cpu_stl_data() will throw exceptions | 212 | clean_addr = clean_data_tbi(s, addr); |
91 | + * and longjmp out. | 213 | tcg_gen_andi_i64(clean_addr, clean_addr, -size); |
92 | + */ | 214 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDGM(DisasContext *s, arg_ldst_tag *a) |
93 | + if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) { | 215 | gen_helper_ldgm(tcg_rt, cpu_env, addr); |
94 | + bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK; | 216 | } else { |
95 | + int i; | 217 | MMUAccessType acc = MMU_DATA_LOAD; |
96 | + | 218 | - int size = 4 << GMID_EL1_BS; |
97 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | 219 | + int size = 4 << s->gm_blocksize; |
98 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | 220 | |
99 | + uint32_t faddr = fptr + 4 * i; | 221 | clean_addr = clean_data_tbi(s, addr); |
100 | + uint32_t slo = extract64(dn, 0, 32); | 222 | tcg_gen_andi_i64(clean_addr, clean_addr, -size); |
101 | + uint32_t shi = extract64(dn, 32, 32); | 223 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, |
102 | + | 224 | dc->cp_regs = arm_cpu->cp_regs; |
103 | + if (i >= 16) { | 225 | dc->features = env->features; |
104 | + faddr += 8; /* skip the slot for the FPSCR */ | 226 | dc->dcz_blocksize = arm_cpu->dcz_blocksize; |
105 | + } | 227 | + dc->gm_blocksize = arm_cpu->gm_blocksize; |
106 | + cpu_stl_data(env, faddr, slo); | 228 | |
107 | + cpu_stl_data(env, faddr + 4, shi); | 229 | #ifdef CONFIG_USER_ONLY |
108 | + } | 230 | /* In sve_probe_page, we assume TBI is enabled. */ |
109 | + cpu_stl_data(env, fptr + 0x40, vfp_get_fpscr(env)); | ||
110 | + | ||
111 | + /* | ||
112 | + * If TS is 0 then s0 to s15 and FPSCR are UNKNOWN; we choose to | ||
113 | + * leave them unchanged, matching our choice in v7m_preserve_fp_state. | ||
114 | + */ | ||
115 | + if (ts) { | ||
116 | + for (i = 0; i < 32; i += 2) { | ||
117 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
118 | + } | ||
119 | + vfp_set_fpscr(env, 0); | ||
120 | + } | ||
121 | + } else { | ||
122 | + v7m_update_fpccr(env, fptr, false); | ||
123 | + } | ||
124 | + | ||
125 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | ||
126 | +} | ||
127 | + | ||
128 | static bool v7m_push_stack(ARMCPU *cpu) | ||
129 | { | ||
130 | /* Do the "set up stack frame" part of exception entry, | ||
131 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | ||
132 | [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
133 | [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
134 | [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
135 | + [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
136 | + [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
137 | }; | ||
138 | |||
139 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
140 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
141 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
142 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_STKOF_MASK; | ||
143 | break; | ||
144 | + case EXCP_LSERR: | ||
145 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
146 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | ||
147 | + break; | ||
148 | + case EXCP_UNALIGNED: | ||
149 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
150 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | ||
151 | + break; | ||
152 | case EXCP_SWI: | ||
153 | /* The PC already points to the next instruction. */ | ||
154 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure); | ||
155 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/target/arm/translate.c | ||
158 | +++ b/target/arm/translate.c | ||
159 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
160 | if (!s->v8m_secure || (insn & 0x0040f0ff)) { | ||
161 | goto illegal_op; | ||
162 | } | ||
163 | - /* Just NOP since FP support is not implemented */ | ||
164 | + | ||
165 | + if (arm_dc_feature(s, ARM_FEATURE_VFP)) { | ||
166 | + TCGv_i32 fptr = load_reg(s, rn); | ||
167 | + | ||
168 | + if (extract32(insn, 20, 1)) { | ||
169 | + /* VLLDM */ | ||
170 | + } else { | ||
171 | + gen_helper_v7m_vlstm(cpu_env, fptr); | ||
172 | + } | ||
173 | + tcg_temp_free_i32(fptr); | ||
174 | + | ||
175 | + /* End the TB, because we have updated FP control bits */ | ||
176 | + s->base.is_jmp = DISAS_UPDATE; | ||
177 | + } | ||
178 | break; | ||
179 | } | ||
180 | if (arm_dc_feature(s, ARM_FEATURE_VFP) && | ||
181 | -- | 231 | -- |
182 | 2.20.1 | 232 | 2.34.1 |
183 | |||
184 | diff view generated by jsdifflib |
1 | The M-profile CONTROL register has two bits -- SFPA and FPCA -- | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | which relate to floating-point support, and should be RES0 otherwise. | ||
3 | Handle them correctly in the MSR/MRS register access code. | ||
4 | Neither is banked between security states, so they are stored | ||
5 | in v7m.control[M_REG_S] regardless of current security state. | ||
6 | 2 | ||
3 | Support all of the easy GM block sizes. | ||
4 | Use direct memory operations, since the pointers are aligned. | ||
5 | |||
6 | While BS=2 (16 bytes, 1 tag) is a legal setting, that requires | ||
7 | an atomic store of one nibble. This is not difficult, but there | ||
8 | is also no point in supporting it until required. | ||
9 | |||
10 | Note that cortex-a710 sets GM blocksize to match its cacheline | ||
11 | size of 64 bytes. I expect many implementations will also | ||
12 | match the cacheline, which makes 16 bytes very unlikely. | ||
13 | |||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Message-id: 20230811214031.171020-4-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190416125744.27770-9-peter.maydell@linaro.org | ||
10 | --- | 18 | --- |
11 | target/arm/helper.c | 57 ++++++++++++++++++++++++++++++++++++++------- | 19 | target/arm/cpu.c | 18 +++++++++--- |
12 | 1 file changed, 49 insertions(+), 8 deletions(-) | 20 | target/arm/tcg/mte_helper.c | 56 +++++++++++++++++++++++++++++++------ |
21 | 2 files changed, 62 insertions(+), 12 deletions(-) | ||
13 | 22 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 23 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 25 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/helper.c | 26 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | 27 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
19 | return xpsr_read(env) & mask; | 28 | ID_PFR1, VIRTUALIZATION, 0); |
20 | break; | 29 | } |
21 | case 20: /* CONTROL */ | 30 | |
22 | - return env->v7m.control[env->v7m.secure]; | 31 | + if (cpu_isar_feature(aa64_mte, cpu)) { |
23 | + { | 32 | + /* |
24 | + uint32_t value = env->v7m.control[env->v7m.secure]; | 33 | + * The architectural range of GM blocksize is 2-6, however qemu |
25 | + if (!env->v7m.secure) { | 34 | + * doesn't support blocksize of 2 (see HELPER(ldgm)). |
26 | + /* SFPA is RAZ/WI from NS; FPCA is stored in the M_REG_S bank */ | 35 | + */ |
27 | + value |= env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK; | 36 | + if (tcg_enabled()) { |
37 | + assert(cpu->gm_blocksize >= 3 && cpu->gm_blocksize <= 6); | ||
28 | + } | 38 | + } |
29 | + return value; | 39 | + |
40 | #ifndef CONFIG_USER_ONLY | ||
41 | - if (cpu->tag_memory == NULL && cpu_isar_feature(aa64_mte, cpu)) { | ||
42 | /* | ||
43 | * Disable the MTE feature bits if we do not have tag-memory | ||
44 | * provided by the machine. | ||
45 | */ | ||
46 | - cpu->isar.id_aa64pfr1 = | ||
47 | - FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); | ||
48 | - } | ||
49 | + if (cpu->tag_memory == NULL) { | ||
50 | + cpu->isar.id_aa64pfr1 = | ||
51 | + FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); | ||
52 | + } | ||
53 | #endif | ||
30 | + } | 54 | + } |
31 | case 0x94: /* CONTROL_NS */ | 55 | |
32 | /* We have to handle this here because unprivileged Secure code | 56 | if (tcg_enabled()) { |
33 | * can read the NS CONTROL register. | 57 | /* |
34 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | 58 | diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c |
35 | if (!env->v7m.secure) { | 59 | index XXXXXXX..XXXXXXX 100644 |
36 | return 0; | 60 | --- a/target/arm/tcg/mte_helper.c |
37 | } | 61 | +++ b/target/arm/tcg/mte_helper.c |
38 | - return env->v7m.control[M_REG_NS]; | 62 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) |
39 | + return env->v7m.control[M_REG_NS] | | 63 | int gm_bs = env_archcpu(env)->gm_blocksize; |
40 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK); | 64 | int gm_bs_bytes = 4 << gm_bs; |
65 | void *tag_mem; | ||
66 | + uint64_t ret; | ||
67 | + int shift; | ||
68 | |||
69 | ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
70 | |||
71 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) | ||
72 | |||
73 | /* | ||
74 | * The ordering of elements within the word corresponds to | ||
75 | - * a little-endian operation. | ||
76 | + * a little-endian operation. Computation of shift comes from | ||
77 | + * | ||
78 | + * index = address<LOG2_TAG_GRANULE+3:LOG2_TAG_GRANULE> | ||
79 | + * data<index*4+3:index*4> = tag | ||
80 | + * | ||
81 | + * Because of the alignment of ptr above, BS=6 has shift=0. | ||
82 | + * All memory operations are aligned. Defer support for BS=2, | ||
83 | + * requiring insertion or extraction of a nibble, until we | ||
84 | + * support a cpu that requires it. | ||
85 | */ | ||
86 | switch (gm_bs) { | ||
87 | + case 3: | ||
88 | + /* 32 bytes -> 2 tags -> 8 result bits */ | ||
89 | + ret = *(uint8_t *)tag_mem; | ||
90 | + break; | ||
91 | + case 4: | ||
92 | + /* 64 bytes -> 4 tags -> 16 result bits */ | ||
93 | + ret = cpu_to_le16(*(uint16_t *)tag_mem); | ||
94 | + break; | ||
95 | + case 5: | ||
96 | + /* 128 bytes -> 8 tags -> 32 result bits */ | ||
97 | + ret = cpu_to_le32(*(uint32_t *)tag_mem); | ||
98 | + break; | ||
99 | case 6: | ||
100 | /* 256 bytes -> 16 tags -> 64 result bits */ | ||
101 | - return ldq_le_p(tag_mem); | ||
102 | + return cpu_to_le64(*(uint64_t *)tag_mem); | ||
103 | default: | ||
104 | - /* cpu configured with unsupported gm blocksize. */ | ||
105 | + /* | ||
106 | + * CPU configured with unsupported/invalid gm blocksize. | ||
107 | + * This is detected early in arm_cpu_realizefn. | ||
108 | + */ | ||
109 | g_assert_not_reached(); | ||
41 | } | 110 | } |
42 | 111 | + shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4; | |
43 | if (el == 0) { | 112 | + return ret << shift; |
44 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 113 | } |
45 | */ | 114 | |
46 | uint32_t mask = extract32(maskreg, 8, 4); | 115 | void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
47 | uint32_t reg = extract32(maskreg, 0, 8); | 116 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
48 | + int cur_el = arm_current_el(env); | 117 | int gm_bs = env_archcpu(env)->gm_blocksize; |
49 | 118 | int gm_bs_bytes = 4 << gm_bs; | |
50 | - if (arm_current_el(env) == 0 && reg > 7) { | 119 | void *tag_mem; |
51 | - /* only xPSR sub-fields may be written by unprivileged */ | 120 | + int shift; |
52 | + if (cur_el == 0 && reg > 7 && reg != 20) { | 121 | |
53 | + /* | 122 | ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); |
54 | + * only xPSR sub-fields and CONTROL.SFPA may be written by | 123 | |
55 | + * unprivileged code | 124 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
56 | + */ | ||
57 | return; | 125 | return; |
58 | } | 126 | } |
59 | 127 | ||
60 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 128 | - /* |
61 | env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK; | 129 | - * The ordering of elements within the word corresponds to |
62 | env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK; | 130 | - * a little-endian operation. |
63 | } | 131 | - */ |
64 | + /* | 132 | + /* See LDGM for comments on BS and on shift. */ |
65 | + * SFPA is RAZ/WI from NS. FPCA is RO if NSACR.CP10 == 0, | 133 | + shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4; |
66 | + * RES0 if the FPU is not present, and is stored in the S bank | 134 | + val >>= shift; |
67 | + */ | 135 | switch (gm_bs) { |
68 | + if (arm_feature(env, ARM_FEATURE_VFP) && | 136 | + case 3: |
69 | + extract32(env->v7m.nsacr, 10, 1)) { | 137 | + /* 32 bytes -> 2 tags -> 8 result bits */ |
70 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | 138 | + *(uint8_t *)tag_mem = val; |
71 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK; | 139 | + break; |
72 | + } | 140 | + case 4: |
73 | return; | 141 | + /* 64 bytes -> 4 tags -> 16 result bits */ |
74 | case 0x98: /* SP_NS */ | 142 | + *(uint16_t *)tag_mem = cpu_to_le16(val); |
75 | { | 143 | + break; |
76 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 144 | + case 5: |
77 | env->v7m.faultmask[env->v7m.secure] = val & 1; | 145 | + /* 128 bytes -> 8 tags -> 32 result bits */ |
78 | break; | 146 | + *(uint32_t *)tag_mem = cpu_to_le32(val); |
79 | case 20: /* CONTROL */ | 147 | + break; |
80 | - /* Writing to the SPSEL bit only has an effect if we are in | 148 | case 6: |
81 | + /* | 149 | - stq_le_p(tag_mem, val); |
82 | + * Writing to the SPSEL bit only has an effect if we are in | 150 | + /* 256 bytes -> 16 tags -> 64 result bits */ |
83 | * thread mode; other bits can be updated by any privileged code. | 151 | + *(uint64_t *)tag_mem = cpu_to_le64(val); |
84 | * write_v7m_control_spsel() deals with updating the SPSEL bit in | ||
85 | * env->v7m.control, so we only need update the others. | ||
86 | * For v7M, we must just ignore explicit writes to SPSEL in handler | ||
87 | * mode; for v8M the write is permitted but will have no effect. | ||
88 | + * All these bits are writes-ignored from non-privileged code, | ||
89 | + * except for SFPA. | ||
90 | */ | ||
91 | - if (arm_feature(env, ARM_FEATURE_V8) || | ||
92 | - !arm_v7m_is_handler_mode(env)) { | ||
93 | + if (cur_el > 0 && (arm_feature(env, ARM_FEATURE_V8) || | ||
94 | + !arm_v7m_is_handler_mode(env))) { | ||
95 | write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0); | ||
96 | } | ||
97 | - if (arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
98 | + if (cur_el > 0 && arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
99 | env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK; | ||
100 | env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK; | ||
101 | } | ||
102 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
103 | + /* | ||
104 | + * SFPA is RAZ/WI from NS or if no FPU. | ||
105 | + * FPCA is RO if NSACR.CP10 == 0, RES0 if the FPU is not present. | ||
106 | + * Both are stored in the S bank. | ||
107 | + */ | ||
108 | + if (env->v7m.secure) { | ||
109 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | ||
110 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_SFPA_MASK; | ||
111 | + } | ||
112 | + if (cur_el > 0 && | ||
113 | + (env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_SECURITY) || | ||
114 | + extract32(env->v7m.nsacr, 10, 1))) { | ||
115 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | ||
116 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK; | ||
117 | + } | ||
118 | + } | ||
119 | break; | 152 | break; |
120 | default: | 153 | default: |
121 | bad_reg: | 154 | /* cpu configured with unsupported gm blocksize. */ |
122 | -- | 155 | -- |
123 | 2.20.1 | 156 | 2.34.1 |
124 | |||
125 | diff view generated by jsdifflib |
1 | Enable the FPU by default for the Cortex-M4 and Cortex-M33. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When the cpu support MTE, but the system does not, reduce cpu | ||
4 | support to user instructions at EL0 instead of completely | ||
5 | disabling MTE. If we encounter a cpu implementation which does | ||
6 | something else, we can revisit this setting. | ||
7 | |||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20230811214031.171020-5-richard.henderson@linaro.org | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20190416125744.27770-27-peter.maydell@linaro.org | ||
6 | --- | 12 | --- |
7 | target/arm/cpu.c | 8 ++++++++ | 13 | target/arm/cpu.c | 7 ++++--- |
8 | 1 file changed, 8 insertions(+) | 14 | 1 file changed, 4 insertions(+), 3 deletions(-) |
9 | 15 | ||
10 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 16 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
11 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/cpu.c | 18 | --- a/target/arm/cpu.c |
13 | +++ b/target/arm/cpu.c | 19 | +++ b/target/arm/cpu.c |
14 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | 20 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
15 | set_feature(&cpu->env, ARM_FEATURE_M); | 21 | |
16 | set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 22 | #ifndef CONFIG_USER_ONLY |
17 | set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 23 | /* |
18 | + set_feature(&cpu->env, ARM_FEATURE_VFP4); | 24 | - * Disable the MTE feature bits if we do not have tag-memory |
19 | cpu->midr = 0x410fc240; /* r0p0 */ | 25 | - * provided by the machine. |
20 | cpu->pmsav7_dregion = 8; | 26 | + * If we do not have tag-memory provided by the machine, |
21 | + cpu->isar.mvfr0 = 0x10110021; | 27 | + * reduce MTE support to instructions enabled at EL0. |
22 | + cpu->isar.mvfr1 = 0x11000011; | 28 | + * This matches Cortex-A710 BROADCASTMTE input being LOW. |
23 | + cpu->isar.mvfr2 = 0x00000000; | 29 | */ |
24 | cpu->id_pfr0 = 0x00000030; | 30 | if (cpu->tag_memory == NULL) { |
25 | cpu->id_pfr1 = 0x00000200; | 31 | cpu->isar.id_aa64pfr1 = |
26 | cpu->id_dfr0 = 0x00100000; | 32 | - FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); |
27 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | 33 | + FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 1); |
28 | set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 34 | } |
29 | set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | 35 | #endif |
30 | set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 36 | } |
31 | + set_feature(&cpu->env, ARM_FEATURE_VFP4); | ||
32 | cpu->midr = 0x410fd213; /* r0p3 */ | ||
33 | cpu->pmsav7_dregion = 16; | ||
34 | cpu->sau_sregion = 8; | ||
35 | + cpu->isar.mvfr0 = 0x10110021; | ||
36 | + cpu->isar.mvfr1 = 0x11000011; | ||
37 | + cpu->isar.mvfr2 = 0x00000040; | ||
38 | cpu->id_pfr0 = 0x00000030; | ||
39 | cpu->id_pfr1 = 0x00000210; | ||
40 | cpu->id_dfr0 = 0x00200000; | ||
41 | -- | 37 | -- |
42 | 2.20.1 | 38 | 2.34.1 |
43 | |||
44 | diff view generated by jsdifflib |
1 | Implement the code which updates the FPCCR register on an | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | exception entry where we are going to use lazy FP stacking. | ||
3 | We have to defer to the NVIC to determine whether the | ||
4 | various exceptions are currently ready or not. | ||
5 | 2 | ||
3 | Do not hard-code the constants for Neoverse V1. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20230811214031.171020-6-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20190416125744.27770-12-peter.maydell@linaro.org | ||
8 | --- | 9 | --- |
9 | target/arm/cpu.h | 14 +++++++++ | 10 | target/arm/tcg/cpu64.c | 48 ++++++++++++++++++++++++++++-------------- |
10 | hw/intc/armv7m_nvic.c | 34 ++++++++++++++++++++++ | 11 | 1 file changed, 32 insertions(+), 16 deletions(-) |
11 | target/arm/helper.c | 67 ++++++++++++++++++++++++++++++++++++++++++- | ||
12 | 3 files changed, 114 insertions(+), 1 deletion(-) | ||
13 | 12 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 13 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 15 | --- a/target/arm/tcg/cpu64.c |
17 | +++ b/target/arm/cpu.h | 16 | +++ b/target/arm/tcg/cpu64.c |
18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque); | 17 | @@ -XXX,XX +XXX,XX @@ |
19 | * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | 18 | #include "qemu/module.h" |
20 | */ | 19 | #include "qapi/visitor.h" |
21 | int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure); | 20 | #include "hw/qdev-properties.h" |
22 | +/** | 21 | +#include "qemu/units.h" |
23 | + * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | 22 | #include "internals.h" |
24 | + * @opaque: the NVIC | 23 | #include "cpregs.h" |
25 | + * @irq: the exception number to mark pending | 24 | |
26 | + * @secure: false for non-banked exceptions or for the nonsecure | 25 | +static uint64_t make_ccsidr64(unsigned assoc, unsigned linesize, |
27 | + * version of a banked exception, true for the secure version of a banked | 26 | + unsigned cachesize) |
28 | + * exception. | ||
29 | + * | ||
30 | + * Return whether an exception is "ready", i.e. whether the exception is | ||
31 | + * enabled and is configured at a priority which would allow it to | ||
32 | + * interrupt the current execution priority. This controls whether the | ||
33 | + * RDY bit for it in the FPCCR is set. | ||
34 | + */ | ||
35 | +bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure); | ||
36 | /** | ||
37 | * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
38 | * @opaque: the NVIC | ||
39 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/intc/armv7m_nvic.c | ||
42 | +++ b/hw/intc/armv7m_nvic.c | ||
43 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) | ||
44 | return ret; | ||
45 | } | ||
46 | |||
47 | +bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
48 | +{ | 27 | +{ |
49 | + /* | 28 | + unsigned lg_linesize = ctz32(linesize); |
50 | + * Return whether an exception is "ready", i.e. it is enabled and is | 29 | + unsigned sets; |
51 | + * configured at a priority which would allow it to interrupt the | ||
52 | + * current execution priority. | ||
53 | + * | ||
54 | + * irq and secure have the same semantics as for armv7m_nvic_set_pending(): | ||
55 | + * for non-banked exceptions secure is always false; for banked exceptions | ||
56 | + * it indicates which of the exceptions is required. | ||
57 | + */ | ||
58 | + NVICState *s = (NVICState *)opaque; | ||
59 | + bool banked = exc_is_banked(irq); | ||
60 | + VecInfo *vec; | ||
61 | + int running = nvic_exec_prio(s); | ||
62 | + | ||
63 | + assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); | ||
64 | + assert(!secure || banked); | ||
65 | + | 30 | + |
66 | + /* | 31 | + /* |
67 | + * HardFault is an odd special case: we always check against -1, | 32 | + * The 64-bit CCSIDR_EL1 format is: |
68 | + * even if we're secure and HardFault has priority -3; we never | 33 | + * [55:32] number of sets - 1 |
69 | + * need to check for enabled state. | 34 | + * [23:3] associativity - 1 |
35 | + * [2:0] log2(linesize) - 4 | ||
36 | + * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc | ||
70 | + */ | 37 | + */ |
71 | + if (irq == ARMV7M_EXCP_HARD) { | 38 | + assert(assoc != 0); |
72 | + return running > -1; | 39 | + assert(is_power_of_2(linesize)); |
73 | + } | 40 | + assert(lg_linesize >= 4 && lg_linesize <= 7 + 4); |
74 | + | 41 | + |
75 | + vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq]; | 42 | + /* sets * associativity * linesize == cachesize. */ |
43 | + sets = cachesize / (assoc * linesize); | ||
44 | + assert(cachesize % (assoc * linesize) == 0); | ||
76 | + | 45 | + |
77 | + return vec->enabled && | 46 | + return ((uint64_t)(sets - 1) << 32) |
78 | + exc_group_prio(s, vec->prio, secure) < running; | 47 | + | ((assoc - 1) << 3) |
48 | + | (lg_linesize - 4); | ||
79 | +} | 49 | +} |
80 | + | 50 | + |
81 | /* callback when external interrupt line is changed */ | 51 | static void aarch64_a35_initfn(Object *obj) |
82 | static void set_irq_level(void *opaque, int n, int level) | ||
83 | { | 52 | { |
84 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 53 | ARMCPU *cpu = ARM_CPU(obj); |
85 | index XXXXXXX..XXXXXXX 100644 | 54 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_v1_initfn(Object *obj) |
86 | --- a/target/arm/helper.c | 55 | * The Neoverse-V1 r1p2 TRM lists 32-bit format CCSIDR_EL1 values, |
87 | +++ b/target/arm/helper.c | 56 | * but also says it implements CCIDX, which means they should be |
88 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 57 | * 64-bit format. So we here use values which are based on the textual |
89 | env->thumb = addr & 1; | 58 | - * information in chapter 2 of the TRM (and on the fact that |
90 | } | 59 | - * sets * associativity * linesize == cachesize). |
91 | 60 | - * | |
92 | +static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | 61 | - * The 64-bit CCSIDR_EL1 format is: |
93 | + bool apply_splim) | 62 | - * [55:32] number of sets - 1 |
94 | +{ | 63 | - * [23:3] associativity - 1 |
95 | + /* | 64 | - * [2:0] log2(linesize) - 4 |
96 | + * Like the pseudocode UpdateFPCCR: save state in FPCAR and FPCCR | 65 | - * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc |
97 | + * that we will need later in order to do lazy FP reg stacking. | 66 | - * |
98 | + */ | 67 | - * L1: 4-way set associative 64-byte line size, total size 64K, |
99 | + bool is_secure = env->v7m.secure; | 68 | - * so sets is 256. |
100 | + void *nvic = env->nvic; | 69 | + * information in chapter 2 of the TRM: |
101 | + /* | 70 | * |
102 | + * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits | 71 | + * L1: 4-way set associative 64-byte line size, total size 64K. |
103 | + * are banked and we want to update the bit in the bank for the | 72 | * L2: 8-way set associative, 64 byte line size, either 512K or 1MB. |
104 | + * current security state; and in one case we want to specifically | 73 | - * We pick 1MB, so this has 2048 sets. |
105 | + * update the NS banked version of a bit even if we are secure. | 74 | - * |
106 | + */ | 75 | * L3: No L3 (this matches the CLIDR_EL1 value). |
107 | + uint32_t *fpccr_s = &env->v7m.fpccr[M_REG_S]; | 76 | */ |
108 | + uint32_t *fpccr_ns = &env->v7m.fpccr[M_REG_NS]; | 77 | - cpu->ccsidr[0] = 0x000000ff0000001aull; /* 64KB L1 dcache */ |
109 | + uint32_t *fpccr = &env->v7m.fpccr[is_secure]; | 78 | - cpu->ccsidr[1] = 0x000000ff0000001aull; /* 64KB L1 icache */ |
110 | + bool hfrdy, bfrdy, mmrdy, ns_ufrdy, s_ufrdy, sfrdy, monrdy; | 79 | - cpu->ccsidr[2] = 0x000007ff0000003aull; /* 1MB L2 cache */ |
111 | + | 80 | + cpu->ccsidr[0] = make_ccsidr64(4, 64, 64 * KiB); /* L1 dcache */ |
112 | + env->v7m.fpcar[is_secure] = frameptr & ~0x7; | 81 | + cpu->ccsidr[1] = cpu->ccsidr[0]; /* L1 icache */ |
113 | + | 82 | + cpu->ccsidr[2] = make_ccsidr64(8, 64, 1 * MiB); /* L2 cache */ |
114 | + if (apply_splim && arm_feature(env, ARM_FEATURE_V8)) { | 83 | |
115 | + bool splimviol; | 84 | /* From 3.2.115 SCTLR_EL3 */ |
116 | + uint32_t splim = v7m_sp_limit(env); | 85 | cpu->reset_sctlr = 0x30c50838; |
117 | + bool ign = armv7m_nvic_neg_prio_requested(nvic, is_secure) && | ||
118 | + (env->v7m.ccr[is_secure] & R_V7M_CCR_STKOFHFNMIGN_MASK); | ||
119 | + | ||
120 | + splimviol = !ign && frameptr < splim; | ||
121 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, SPLIMVIOL, splimviol); | ||
122 | + } | ||
123 | + | ||
124 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, LSPACT, 1); | ||
125 | + | ||
126 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, S, is_secure); | ||
127 | + | ||
128 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, USER, arm_current_el(env) == 0); | ||
129 | + | ||
130 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, THREAD, | ||
131 | + !arm_v7m_is_handler_mode(env)); | ||
132 | + | ||
133 | + hfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_HARD, false); | ||
134 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, HFRDY, hfrdy); | ||
135 | + | ||
136 | + bfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_BUS, false); | ||
137 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, BFRDY, bfrdy); | ||
138 | + | ||
139 | + mmrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_MEM, is_secure); | ||
140 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, MMRDY, mmrdy); | ||
141 | + | ||
142 | + ns_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, false); | ||
143 | + *fpccr_ns = FIELD_DP32(*fpccr_ns, V7M_FPCCR, UFRDY, ns_ufrdy); | ||
144 | + | ||
145 | + monrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_DEBUG, false); | ||
146 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, MONRDY, monrdy); | ||
147 | + | ||
148 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
149 | + s_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, true); | ||
150 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, UFRDY, s_ufrdy); | ||
151 | + | ||
152 | + sfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_SECURE, false); | ||
153 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, SFRDY, sfrdy); | ||
154 | + } | ||
155 | +} | ||
156 | + | ||
157 | static bool v7m_push_stack(ARMCPU *cpu) | ||
158 | { | ||
159 | /* Do the "set up stack frame" part of exception entry, | ||
160 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
161 | } | ||
162 | } else { | ||
163 | /* Lazy stacking enabled, save necessary info to stack later */ | ||
164 | - /* TODO : equivalent of UpdateFPCCR() pseudocode */ | ||
165 | + v7m_update_fpccr(env, frameptr + 0x20, true); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | -- | 86 | -- |
170 | 2.20.1 | 87 | 2.34.1 |
171 | |||
172 | diff view generated by jsdifflib |
1 | Add a new helper function which returns the MMU index to use | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | for v7M, where the caller specifies all of the security | ||
3 | state, privilege level and whether the execution priority | ||
4 | is negative, and reimplement the existing | ||
5 | arm_v7m_mmu_idx_for_secstate_and_priv() in terms of it. | ||
6 | 2 | ||
7 | We are going to need this for the lazy-FP-stacking code. | 3 | Access to many of the special registers is enabled or disabled |
4 | by ACTLR_EL[23], which we implement as constant 0, which means | ||
5 | that all writes outside EL3 should trap. | ||
8 | 6 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20230811214031.171020-7-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20190416125744.27770-21-peter.maydell@linaro.org | ||
12 | --- | 11 | --- |
13 | target/arm/cpu.h | 7 +++++++ | 12 | target/arm/cpregs.h | 2 ++ |
14 | target/arm/helper.c | 14 +++++++++++--- | 13 | target/arm/helper.c | 4 ++-- |
15 | 2 files changed, 18 insertions(+), 3 deletions(-) | 14 | target/arm/tcg/cpu64.c | 46 +++++++++++++++++++++++++++++++++--------- |
15 | 3 files changed, 41 insertions(+), 11 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 19 | --- a/target/arm/cpregs.h |
20 | +++ b/target/arm/cpu.h | 20 | +++ b/target/arm/cpregs.h |
21 | @@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) | 21 | @@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } |
22 | } | 22 | void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); |
23 | } | 23 | #endif |
24 | 24 | ||
25 | +/* | 25 | +CPAccessResult access_tvm_trvm(CPUARMState *, const ARMCPRegInfo *, bool); |
26 | + * Return the MMU index for a v7M CPU with all relevant information | ||
27 | + * manually specified. | ||
28 | + */ | ||
29 | +ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
30 | + bool secstate, bool priv, bool negpri); | ||
31 | + | 26 | + |
32 | /* Return the MMU index for a v7M CPU in the specified security and | 27 | #endif /* TARGET_ARM_CPREGS_H */ |
33 | * privilege state. | ||
34 | */ | ||
35 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 28 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
36 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/helper.c | 30 | --- a/target/arm/helper.c |
38 | +++ b/target/arm/helper.c | 31 | +++ b/target/arm/helper.c |
39 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | 32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri, |
40 | return 0; | ||
41 | } | 33 | } |
42 | 34 | ||
43 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | 35 | /* Check for traps from EL1 due to HCR_EL2.TVM and HCR_EL2.TRVM. */ |
44 | - bool secstate, bool priv) | 36 | -static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, |
45 | +ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | 37 | - bool isread) |
46 | + bool secstate, bool priv, bool negpri) | 38 | +CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, |
39 | + bool isread) | ||
47 | { | 40 | { |
48 | ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; | 41 | if (arm_current_el(env) == 1) { |
49 | 42 | uint64_t trap = isread ? HCR_TRVM : HCR_TVM; | |
50 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | 43 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
51 | mmu_idx |= ARM_MMU_IDX_M_PRIV; | 44 | index XXXXXXX..XXXXXXX 100644 |
52 | } | 45 | --- a/target/arm/tcg/cpu64.c |
53 | 46 | +++ b/target/arm/tcg/cpu64.c | |
54 | - if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) { | 47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) |
55 | + if (negpri) { | 48 | /* TODO: Add A64FX specific HPC extension registers */ |
56 | mmu_idx |= ARM_MMU_IDX_M_NEGPRI; | ||
57 | } | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
60 | return mmu_idx; | ||
61 | } | 49 | } |
62 | 50 | ||
63 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | 51 | +static CPAccessResult access_actlr_w(CPUARMState *env, const ARMCPRegInfo *r, |
64 | + bool secstate, bool priv) | 52 | + bool read) |
65 | +{ | 53 | +{ |
66 | + bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); | 54 | + if (!read) { |
55 | + int el = arm_current_el(env); | ||
67 | + | 56 | + |
68 | + return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); | 57 | + /* Because ACTLR_EL2 is constant 0, writes below EL2 trap to EL2. */ |
58 | + if (el < 2 && arm_is_el2_enabled(env)) { | ||
59 | + return CP_ACCESS_TRAP_EL2; | ||
60 | + } | ||
61 | + /* Because ACTLR_EL3 is constant 0, writes below EL3 trap to EL3. */ | ||
62 | + if (el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { | ||
63 | + return CP_ACCESS_TRAP_EL3; | ||
64 | + } | ||
65 | + } | ||
66 | + return CP_ACCESS_OK; | ||
69 | +} | 67 | +} |
70 | + | 68 | + |
71 | /* Return the MMU index for a v7M CPU in the specified security state */ | 69 | static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { |
72 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | 70 | { .name = "ATCR_EL1", .state = ARM_CP_STATE_AA64, |
73 | { | 71 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 7, .opc2 = 0, |
72 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
73 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
74 | + /* Traps and enables are the same as for TCR_EL1. */ | ||
75 | + .accessfn = access_tvm_trvm, .fgt = FGT_TCR_EL1, }, | ||
76 | { .name = "ATCR_EL2", .state = ARM_CP_STATE_AA64, | ||
77 | .opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 0, | ||
78 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | ||
80 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
81 | { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
82 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 0, | ||
83 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
84 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
85 | + .accessfn = access_actlr_w }, | ||
86 | { .name = "CPUACTLR2_EL1", .state = ARM_CP_STATE_AA64, | ||
87 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 1, | ||
88 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
89 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
90 | + .accessfn = access_actlr_w }, | ||
91 | { .name = "CPUACTLR3_EL1", .state = ARM_CP_STATE_AA64, | ||
92 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 2, | ||
93 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
94 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
95 | + .accessfn = access_actlr_w }, | ||
96 | /* | ||
97 | * Report CPUCFR_EL1.SCU as 1, as we do not implement the DSU | ||
98 | * (and in particular its system registers). | ||
99 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | ||
100 | .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 4 }, | ||
101 | { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
102 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 4, | ||
103 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010 }, | ||
104 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010, | ||
105 | + .accessfn = access_actlr_w }, | ||
106 | { .name = "CPUPCR_EL3", .state = ARM_CP_STATE_AA64, | ||
107 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 1, | ||
108 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
109 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | ||
110 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
111 | { .name = "CPUPWRCTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
112 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7, | ||
113 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
114 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
115 | + .accessfn = access_actlr_w }, | ||
116 | { .name = "ERXPFGCDN_EL1", .state = ARM_CP_STATE_AA64, | ||
117 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 2, | ||
118 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
119 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
120 | + .accessfn = access_actlr_w }, | ||
121 | { .name = "ERXPFGCTL_EL1", .state = ARM_CP_STATE_AA64, | ||
122 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 1, | ||
123 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
124 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
125 | + .accessfn = access_actlr_w }, | ||
126 | { .name = "ERXPFGF_EL1", .state = ARM_CP_STATE_AA64, | ||
127 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0, | ||
128 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
129 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
130 | + .accessfn = access_actlr_w }, | ||
131 | }; | ||
132 | |||
133 | static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) | ||
74 | -- | 134 | -- |
75 | 2.20.1 | 135 | 2.34.1 |
76 | |||
77 | 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: Markus Armbruster <armbru@redhat.com> | 3 | There is only one additional EL1 register modeled, which |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | also needs to use access_actlr_w. |
5 | Message-id: 20190412165416.7977-3-philmd@redhat.com | 5 | |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20230811214031.171020-8-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | hw/arm/nseries.c | 3 ++- | 11 | target/arm/tcg/cpu64.c | 3 ++- |
10 | 1 file changed, 2 insertions(+), 1 deletion(-) | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
11 | 13 | ||
12 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | 14 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/nseries.c | 16 | --- a/target/arm/tcg/cpu64.c |
15 | +++ b/hw/arm/nseries.c | 17 | +++ b/target/arm/tcg/cpu64.c |
16 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) |
17 | #include "hw/boards.h" | 19 | static const ARMCPRegInfo neoverse_v1_cp_reginfo[] = { |
18 | #include "hw/i2c/i2c.h" | 20 | { .name = "CPUECTLR2_EL1", .state = ARM_CP_STATE_AA64, |
19 | #include "hw/devices.h" | 21 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 5, |
20 | +#include "hw/misc/tmp105.h" | 22 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
21 | #include "hw/block/flash.h" | 23 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
22 | #include "hw/hw.h" | 24 | + .accessfn = access_actlr_w }, |
23 | #include "hw/bt.h" | 25 | { .name = "CPUPPMCR_EL3", .state = ARM_CP_STATE_AA64, |
24 | @@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s) | 26 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 0, |
25 | qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier); | 27 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
26 | |||
27 | /* Attach a TMP105 PM chip (A0 wired to ground) */ | ||
28 | - dev = i2c_create_slave(i2c, "tmp105", N8X0_TMP105_ADDR); | ||
29 | + dev = i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR); | ||
30 | qdev_connect_gpio_out(dev, 0, tmp_irq); | ||
31 | } | ||
32 | |||
33 | -- | 28 | -- |
34 | 2.20.1 | 29 | 2.34.1 |
35 | |||
36 | diff view generated by jsdifflib |
1 | We are close to running out of TB flags for AArch32; we could | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | start using the cs_base word, but before we do that we can | ||
3 | economise on our usage by sharing the same bits for the VFP | ||
4 | VECSTRIDE field and the XScale XSCALE_CPAR field. This | ||
5 | works because no XScale CPU ever had VFP. | ||
6 | 2 | ||
3 | Like FEAT_TRF (Self-hosted Trace Extension), suppress tracing | ||
4 | external to the cpu, which is out of scope for QEMU. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230811214031.171020-10-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190416125744.27770-18-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/cpu.h | 10 ++++++---- | 11 | target/arm/cpu.c | 3 +++ |
12 | target/arm/cpu.c | 7 +++++++ | 12 | 1 file changed, 3 insertions(+) |
13 | target/arm/helper.c | 6 +++++- | ||
14 | target/arm/translate.c | 9 +++++++-- | ||
15 | 4 files changed, 25 insertions(+), 7 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | ||
22 | FIELD(TBFLAG_A32, THUMB, 0, 1) | ||
23 | FIELD(TBFLAG_A32, VECLEN, 1, 3) | ||
24 | FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) | ||
25 | +/* | ||
26 | + * We store the bottom two bits of the CPAR as TB flags and handle | ||
27 | + * checks on the other bits at runtime. This shares the same bits as | ||
28 | + * VECSTRIDE, which is OK as no XScale CPU has VFP. | ||
29 | + */ | ||
30 | +FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) | ||
31 | /* | ||
32 | * Indicates whether cp register reads and writes by guest code should access | ||
33 | * the secure or nonsecure bank of banked registers; note that this is not | ||
34 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | ||
35 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | ||
36 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | ||
37 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
38 | -/* We store the bottom two bits of the CPAR as TB flags and handle | ||
39 | - * checks on the other bits at runtime | ||
40 | - */ | ||
41 | -FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2) | ||
42 | /* For M profile only, Handler (ie not Thread) mode */ | ||
43 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | ||
44 | /* For M profile only, whether we should generate stack-limit checks */ | ||
45 | 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 |
46 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/cpu.c | 16 | --- a/target/arm/cpu.c |
48 | +++ b/target/arm/cpu.c | 17 | +++ b/target/arm/cpu.c |
49 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
50 | set_feature(env, ARM_FEATURE_THUMB_DSP); | 19 | /* FEAT_SPE (Statistical Profiling Extension) */ |
51 | } | 20 | cpu->isar.id_aa64dfr0 = |
52 | 21 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0); | |
53 | + /* | 22 | + /* FEAT_TRBE (Trace Buffer Extension) */ |
54 | + * We rely on no XScale CPU having VFP so we can use the same bits in the | 23 | + cpu->isar.id_aa64dfr0 = |
55 | + * TB flags field for VECSTRIDE and XSCALE_CPAR. | 24 | + FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEBUFFER, 0); |
56 | + */ | 25 | /* FEAT_TRF (Self-hosted Trace Extension) */ |
57 | + assert(!(arm_feature(env, ARM_FEATURE_VFP) && | 26 | cpu->isar.id_aa64dfr0 = |
58 | + arm_feature(env, ARM_FEATURE_XSCALE))); | 27 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEFILT, 0); |
59 | + | ||
60 | if (arm_feature(env, ARM_FEATURE_V7) && | ||
61 | !arm_feature(env, ARM_FEATURE_M) && | ||
62 | !arm_feature(env, ARM_FEATURE_PMSA)) { | ||
63 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/helper.c | ||
66 | +++ b/target/arm/helper.c | ||
67 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
68 | || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | ||
69 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
70 | } | ||
71 | - flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); | ||
72 | + /* Note that XSCALE_CPAR shares bits with VECSTRIDE */ | ||
73 | + if (arm_feature(env, ARM_FEATURE_XSCALE)) { | ||
74 | + flags = FIELD_DP32(flags, TBFLAG_A32, | ||
75 | + XSCALE_CPAR, env->cp15.c15_cpar); | ||
76 | + } | ||
77 | } | ||
78 | |||
79 | flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); | ||
80 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/translate.c | ||
83 | +++ b/target/arm/translate.c | ||
84 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
85 | dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL); | ||
86 | dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN); | ||
87 | dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN); | ||
88 | - dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE); | ||
89 | - dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR); | ||
90 | + if (arm_feature(env, ARM_FEATURE_XSCALE)) { | ||
91 | + dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR); | ||
92 | + dc->vec_stride = 0; | ||
93 | + } else { | ||
94 | + dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE); | ||
95 | + dc->c15_cpar = 0; | ||
96 | + } | ||
97 | dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_A32, HANDLER); | ||
98 | dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
99 | regime_is_secure(env, dc->mmu_idx); | ||
100 | -- | 28 | -- |
101 | 2.20.1 | 29 | 2.34.1 |
102 | |||
103 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This commit finally deletes "hw/devices.h". | 3 | This feature allows the operating system to set TCR_ELx.HWU* |
4 | to allow the implementation to use the PBHA bits from the | ||
5 | block and page descriptors for for IMPLEMENTATION DEFINED | ||
6 | purposes. Since QEMU has no need to use these bits, we may | ||
7 | simply ignore them. | ||
4 | 8 | ||
5 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20190412165416.7977-13-philmd@redhat.com | 11 | Message-id: 20230811214031.171020-11-richard.henderson@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 13 | --- |
10 | include/hw/devices.h | 11 ----------- | 14 | docs/system/arm/emulation.rst | 1 + |
11 | include/hw/net/smc91c111.h | 19 +++++++++++++++++++ | 15 | target/arm/tcg/cpu32.c | 2 +- |
12 | hw/arm/gumstix.c | 2 +- | 16 | target/arm/tcg/cpu64.c | 2 +- |
13 | hw/arm/integratorcp.c | 2 +- | 17 | 3 files changed, 3 insertions(+), 2 deletions(-) |
14 | hw/arm/mainstone.c | 2 +- | ||
15 | hw/arm/realview.c | 2 +- | ||
16 | hw/arm/versatilepb.c | 2 +- | ||
17 | hw/net/smc91c111.c | 2 +- | ||
18 | 8 files changed, 25 insertions(+), 17 deletions(-) | ||
19 | delete mode 100644 include/hw/devices.h | ||
20 | create mode 100644 include/hw/net/smc91c111.h | ||
21 | 18 | ||
22 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
23 | deleted file mode 100644 | ||
24 | index XXXXXXX..XXXXXXX | ||
25 | --- a/include/hw/devices.h | ||
26 | +++ /dev/null | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | -#ifndef QEMU_DEVICES_H | ||
29 | -#define QEMU_DEVICES_H | ||
30 | - | ||
31 | -/* Devices that have nowhere better to go. */ | ||
32 | - | ||
33 | -#include "hw/hw.h" | ||
34 | - | ||
35 | -/* smc91c111.c */ | ||
36 | -void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
37 | - | ||
38 | -#endif | ||
39 | diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h | ||
40 | new file mode 100644 | ||
41 | index XXXXXXX..XXXXXXX | ||
42 | --- /dev/null | ||
43 | +++ b/include/hw/net/smc91c111.h | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | +/* | ||
46 | + * SMSC 91C111 Ethernet interface emulation | ||
47 | + * | ||
48 | + * Copyright (c) 2005 CodeSourcery, LLC. | ||
49 | + * Written by Paul Brook | ||
50 | + * | ||
51 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
52 | + * See the COPYING file in the top-level directory. | ||
53 | + */ | ||
54 | + | ||
55 | +#ifndef HW_NET_SMC91C111_H | ||
56 | +#define HW_NET_SMC91C111_H | ||
57 | + | ||
58 | +#include "hw/irq.h" | ||
59 | +#include "net/net.h" | ||
60 | + | ||
61 | +void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
62 | + | ||
63 | +#endif | ||
64 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/hw/arm/gumstix.c | 21 | --- a/docs/system/arm/emulation.rst |
67 | +++ b/hw/arm/gumstix.c | 22 | +++ b/docs/system/arm/emulation.rst |
68 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
69 | #include "hw/arm/pxa.h" | 24 | - FEAT_HAFDBS (Hardware management of the access flag and dirty bit state) |
70 | #include "net/net.h" | 25 | - FEAT_HCX (Support for the HCRX_EL2 register) |
71 | #include "hw/block/flash.h" | 26 | - FEAT_HPDS (Hierarchical permission disables) |
72 | -#include "hw/devices.h" | 27 | +- FEAT_HPDS2 (Translation table page-based hardware attributes) |
73 | +#include "hw/net/smc91c111.h" | 28 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) |
74 | #include "hw/boards.h" | 29 | - FEAT_IDST (ID space trap handling) |
75 | #include "exec/address-spaces.h" | 30 | - FEAT_IESB (Implicit error synchronization event) |
76 | #include "sysemu/qtest.h" | 31 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c |
77 | diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
79 | --- a/hw/arm/integratorcp.c | 33 | --- a/target/arm/tcg/cpu32.c |
80 | +++ b/hw/arm/integratorcp.c | 34 | +++ b/target/arm/tcg/cpu32.c |
81 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
82 | #include "qemu-common.h" | 36 | cpu->isar.id_mmfr3 = t; |
83 | #include "cpu.h" | 37 | |
84 | #include "hw/sysbus.h" | 38 | t = cpu->isar.id_mmfr4; |
85 | -#include "hw/devices.h" | 39 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ |
86 | #include "hw/boards.h" | 40 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 2); /* FEAT_HPDS2 */ |
87 | #include "hw/arm/arm.h" | 41 | t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ |
88 | #include "hw/misc/arm_integrator_debug.h" | 42 | t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ |
89 | +#include "hw/net/smc91c111.h" | 43 | t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */ |
90 | #include "net/net.h" | 44 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
91 | #include "exec/address-spaces.h" | ||
92 | #include "sysemu/sysemu.h" | ||
93 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
95 | --- a/hw/arm/mainstone.c | 46 | --- a/target/arm/tcg/cpu64.c |
96 | +++ b/hw/arm/mainstone.c | 47 | +++ b/target/arm/tcg/cpu64.c |
97 | @@ -XXX,XX +XXX,XX @@ | 48 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
98 | #include "hw/arm/pxa.h" | 49 | t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ |
99 | #include "hw/arm/arm.h" | 50 | t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ |
100 | #include "net/net.h" | 51 | t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ |
101 | -#include "hw/devices.h" | 52 | - t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ |
102 | +#include "hw/net/smc91c111.h" | 53 | + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 2); /* FEAT_HPDS2 */ |
103 | #include "hw/boards.h" | 54 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ |
104 | #include "hw/block/flash.h" | 55 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 3); /* FEAT_PAN3 */ |
105 | #include "hw/sysbus.h" | 56 | t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ |
106 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/hw/arm/realview.c | ||
109 | +++ b/hw/arm/realview.c | ||
110 | @@ -XXX,XX +XXX,XX @@ | ||
111 | #include "hw/sysbus.h" | ||
112 | #include "hw/arm/arm.h" | ||
113 | #include "hw/arm/primecell.h" | ||
114 | -#include "hw/devices.h" | ||
115 | #include "hw/net/lan9118.h" | ||
116 | +#include "hw/net/smc91c111.h" | ||
117 | #include "hw/pci/pci.h" | ||
118 | #include "net/net.h" | ||
119 | #include "sysemu/sysemu.h" | ||
120 | diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/hw/arm/versatilepb.c | ||
123 | +++ b/hw/arm/versatilepb.c | ||
124 | @@ -XXX,XX +XXX,XX @@ | ||
125 | #include "cpu.h" | ||
126 | #include "hw/sysbus.h" | ||
127 | #include "hw/arm/arm.h" | ||
128 | -#include "hw/devices.h" | ||
129 | +#include "hw/net/smc91c111.h" | ||
130 | #include "net/net.h" | ||
131 | #include "sysemu/sysemu.h" | ||
132 | #include "hw/pci/pci.h" | ||
133 | diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/hw/net/smc91c111.c | ||
136 | +++ b/hw/net/smc91c111.c | ||
137 | @@ -XXX,XX +XXX,XX @@ | ||
138 | #include "qemu/osdep.h" | ||
139 | #include "hw/sysbus.h" | ||
140 | #include "net/net.h" | ||
141 | -#include "hw/devices.h" | ||
142 | +#include "hw/net/smc91c111.h" | ||
143 | #include "qemu/log.h" | ||
144 | /* For crc32 */ | ||
145 | #include <zlib.h> | ||
146 | -- | 57 | -- |
147 | 2.20.1 | 58 | 2.34.1 |
148 | |||
149 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 3 | This is a mandatory feature for Armv8.1 architectures but we don't |
4 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 4 | state the feature clearly in our emulation list. Also include |
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | FEAT_CRC32 comment in aarch64_max_tcg_initfn for ease of grepping. |
6 | Message-id: 20190412165416.7977-11-philmd@redhat.com | 6 | |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Message-id: 20230824075406.1515566-1-alex.bennee@linaro.org | ||
10 | Cc: qemu-stable@nongnu.org | ||
11 | Message-Id: <20230222110104.3996971-1-alex.bennee@linaro.org> | ||
12 | [PMM: pluralize 'instructions' in docs] | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 14 | --- |
9 | include/hw/net/ne2000-isa.h | 6 ++++++ | 15 | docs/system/arm/emulation.rst | 1 + |
10 | 1 file changed, 6 insertions(+) | 16 | target/arm/tcg/cpu64.c | 2 +- |
17 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
11 | 18 | ||
12 | diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
13 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/net/ne2000-isa.h | 21 | --- a/docs/system/arm/emulation.rst |
15 | +++ b/include/hw/net/ne2000-isa.h | 22 | +++ b/docs/system/arm/emulation.rst |
16 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
17 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | 24 | - FEAT_BBM at level 2 (Translation table break-before-make levels) |
18 | * See the COPYING file in the top-level directory. | 25 | - FEAT_BF16 (AArch64 BFloat16 instructions) |
19 | */ | 26 | - FEAT_BTI (Branch Target Identification) |
20 | + | 27 | +- FEAT_CRC32 (CRC32 instructions) |
21 | +#ifndef HW_NET_NE2K_ISA_H | 28 | - FEAT_CSV2 (Cache speculation variant 2) |
22 | +#define HW_NET_NE2K_ISA_H | 29 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) |
23 | + | 30 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
24 | #include "hw/hw.h" | 31 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
25 | #include "hw/qdev.h" | 32 | index XXXXXXX..XXXXXXX 100644 |
26 | #include "hw/isa/isa.h" | 33 | --- a/target/arm/tcg/cpu64.c |
27 | @@ -XXX,XX +XXX,XX @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq, | 34 | +++ b/target/arm/tcg/cpu64.c |
28 | } | 35 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
29 | return d; | 36 | t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ |
30 | } | 37 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ |
31 | + | 38 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ |
32 | +#endif | 39 | - t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); |
40 | + t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); /* FEAT_CRC32 */ | ||
41 | t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */ | ||
42 | t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */ | ||
43 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */ | ||
33 | -- | 44 | -- |
34 | 2.20.1 | 45 | 2.34.1 |
35 | 46 | ||
36 | 47 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | This device is used by both ARM (BCM2836, for raspi2) and AArch64 | 3 | i.MX7 IOMUX GPR device is not equivalent to i.MX6UL IOMUXC GPR device. |
4 | (BCM2837, for raspi3) targets, and is not CPU-specific. | 4 | In particular, register 22 is not present on i.MX6UL and this is actualy |
5 | Move it to common object, so we build it once for all targets. | 5 | The only register that is really emulated in the i.MX7 IOMUX GPR device. |
6 | 6 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Note: The i.MX6UL code is actually also implementing the IOMUX GPR device |
8 | Message-id: 20190427133028.12874-1-philmd@redhat.com | 8 | as an unimplemented device at the same bus adress and the 2 instantiations |
9 | were actualy colliding. So we go back to the unimplemented device for now. | ||
10 | |||
11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
12 | Message-id: 48681bf51ee97646479bb261bee19abebbc8074e.1692964892.git.jcd@tribudubois.net | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 15 | --- |
12 | hw/dma/Makefile.objs | 2 +- | 16 | include/hw/arm/fsl-imx6ul.h | 2 -- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 17 | hw/arm/fsl-imx6ul.c | 11 ----------- |
18 | 2 files changed, 13 deletions(-) | ||
14 | 19 | ||
15 | diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs | 20 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/dma/Makefile.objs | 22 | --- a/include/hw/arm/fsl-imx6ul.h |
18 | +++ b/hw/dma/Makefile.objs | 23 | +++ b/include/hw/arm/fsl-imx6ul.h |
19 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zdma.o | 24 | @@ -XXX,XX +XXX,XX @@ |
20 | 25 | #include "hw/misc/imx6ul_ccm.h" | |
21 | obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o | 26 | #include "hw/misc/imx6_src.h" |
22 | obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o | 27 | #include "hw/misc/imx7_snvs.h" |
23 | -obj-$(CONFIG_RASPI) += bcm2835_dma.o | 28 | -#include "hw/misc/imx7_gpr.h" |
24 | +common-obj-$(CONFIG_RASPI) += bcm2835_dma.o | 29 | #include "hw/intc/imx_gpcv2.h" |
30 | #include "hw/watchdog/wdt_imx2.h" | ||
31 | #include "hw/gpio/imx_gpio.h" | ||
32 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState { | ||
33 | IMX6SRCState src; | ||
34 | IMX7SNVSState snvs; | ||
35 | IMXGPCv2State gpcv2; | ||
36 | - IMX7GPRState gpr; | ||
37 | IMXSPIState spi[FSL_IMX6UL_NUM_ECSPIS]; | ||
38 | IMXI2CState i2c[FSL_IMX6UL_NUM_I2CS]; | ||
39 | IMXSerialState uart[FSL_IMX6UL_NUM_UARTS]; | ||
40 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/arm/fsl-imx6ul.c | ||
43 | +++ b/hw/arm/fsl-imx6ul.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
45 | */ | ||
46 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
47 | |||
48 | - /* | ||
49 | - * GPR | ||
50 | - */ | ||
51 | - object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR); | ||
52 | - | ||
53 | /* | ||
54 | * GPIOs 1 to 5 | ||
55 | */ | ||
56 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
57 | FSL_IMX6UL_WDOGn_IRQ[i])); | ||
58 | } | ||
59 | |||
60 | - /* | ||
61 | - * GPR | ||
62 | - */ | ||
63 | - sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort); | ||
64 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX6UL_IOMUXC_GPR_ADDR); | ||
65 | - | ||
66 | /* | ||
67 | * SDMA | ||
68 | */ | ||
25 | -- | 69 | -- |
26 | 2.20.1 | 70 | 2.34.1 |
27 | |||
28 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Since uWireSlave is only used in this new header, there is no | 3 | * Add Addr and size definition for most i.MX6UL devices in i.MX6UL header file. |
4 | need to expose it via "qemu/typedefs.h". | 4 | * Use those newly defined named constants whenever possible. |
5 | * Standardize the way we init a familly of unimplemented devices | ||
6 | - SAI | ||
7 | - PWM | ||
8 | - CAN | ||
9 | * Add/rework few comments | ||
5 | 10 | ||
6 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | Message-id: d579043fbd4e4b490370783fda43fc02c8e9be75.1692964892.git.jcd@tribudubois.net |
8 | Message-id: 20190412165416.7977-9-philmd@redhat.com | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 15 | --- |
11 | include/hw/arm/omap.h | 6 +----- | 16 | include/hw/arm/fsl-imx6ul.h | 156 +++++++++++++++++++++++++++++++----- |
12 | include/hw/devices.h | 15 --------------- | 17 | hw/arm/fsl-imx6ul.c | 147 ++++++++++++++++++++++----------- |
13 | include/hw/input/tsc2xxx.h | 36 ++++++++++++++++++++++++++++++++++++ | 18 | 2 files changed, 232 insertions(+), 71 deletions(-) |
14 | include/qemu/typedefs.h | 1 - | ||
15 | hw/arm/nseries.c | 2 +- | ||
16 | hw/arm/palm.c | 2 +- | ||
17 | hw/input/tsc2005.c | 2 +- | ||
18 | hw/input/tsc210x.c | 4 ++-- | ||
19 | MAINTAINERS | 2 ++ | ||
20 | 9 files changed, 44 insertions(+), 26 deletions(-) | ||
21 | create mode 100644 include/hw/input/tsc2xxx.h | ||
22 | 19 | ||
23 | diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h | 20 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
24 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/arm/omap.h | 22 | --- a/include/hw/arm/fsl-imx6ul.h |
26 | +++ b/include/hw/arm/omap.h | 23 | +++ b/include/hw/arm/fsl-imx6ul.h |
27 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
28 | #include "exec/memory.h" | 25 | #include "exec/memory.h" |
29 | # define hw_omap_h "omap.h" | 26 | #include "cpu.h" |
30 | #include "hw/irq.h" | 27 | #include "qom/object.h" |
31 | +#include "hw/input/tsc2xxx.h" | 28 | +#include "qemu/units.h" |
32 | #include "target/arm/cpu-qom.h" | 29 | |
33 | #include "qemu/log.h" | 30 | #define TYPE_FSL_IMX6UL "fsl-imx6ul" |
34 | 31 | OBJECT_DECLARE_SIMPLE_TYPE(FslIMX6ULState, FSL_IMX6UL) | |
35 | @@ -XXX,XX +XXX,XX @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s); | 32 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { |
36 | void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler); | 33 | FSL_IMX6UL_NUM_ADCS = 2, |
37 | void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down); | 34 | FSL_IMX6UL_NUM_USB_PHYS = 2, |
38 | 35 | FSL_IMX6UL_NUM_USBS = 2, | |
39 | -struct uWireSlave { | 36 | + FSL_IMX6UL_NUM_SAIS = 3, |
40 | - uint16_t (*receive)(void *opaque); | 37 | + FSL_IMX6UL_NUM_CANS = 2, |
41 | - void (*send)(void *opaque, uint16_t data); | 38 | + FSL_IMX6UL_NUM_PWMS = 4, |
42 | - void *opaque; | 39 | }; |
43 | -}; | 40 | |
44 | struct omap_uwire_s; | 41 | struct FslIMX6ULState { |
45 | void omap_uwire_attach(struct omap_uwire_s *s, | 42 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState { |
46 | uWireSlave *slave, int chipselect); | 43 | |
47 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 44 | enum FslIMX6ULMemoryMap { |
45 | FSL_IMX6UL_MMDC_ADDR = 0x80000000, | ||
46 | - FSL_IMX6UL_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, | ||
47 | + FSL_IMX6UL_MMDC_SIZE = (2 * GiB), | ||
48 | |||
49 | FSL_IMX6UL_QSPI1_MEM_ADDR = 0x60000000, | ||
50 | - FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, | ||
51 | - FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
52 | - FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
53 | - FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
54 | + FSL_IMX6UL_QSPI1_MEM_SIZE = (256 * MiB), | ||
55 | |||
56 | - /* AIPS-2 */ | ||
57 | + FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, | ||
58 | + FSL_IMX6UL_EIM_ALIAS_SIZE = (128 * MiB), | ||
59 | + | ||
60 | + FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
61 | + FSL_IMX6UL_EIM_CS_SIZE = (128 * MiB), | ||
62 | + | ||
63 | + FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
64 | + FSL_IMX6UL_AES_ENCRYPT_SIZE = (1 * MiB), | ||
65 | + | ||
66 | + FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
67 | + FSL_IMX6UL_QSPI1_RX_SIZE = (32 * MiB), | ||
68 | + | ||
69 | + /* AIPS-2 Begin */ | ||
70 | FSL_IMX6UL_UART6_ADDR = 0x021FC000, | ||
71 | + | ||
72 | FSL_IMX6UL_I2C4_ADDR = 0x021F8000, | ||
73 | + | ||
74 | FSL_IMX6UL_UART5_ADDR = 0x021F4000, | ||
75 | FSL_IMX6UL_UART4_ADDR = 0x021F0000, | ||
76 | FSL_IMX6UL_UART3_ADDR = 0x021EC000, | ||
77 | FSL_IMX6UL_UART2_ADDR = 0x021E8000, | ||
78 | + | ||
79 | FSL_IMX6UL_WDOG3_ADDR = 0x021E4000, | ||
80 | + | ||
81 | FSL_IMX6UL_QSPI_ADDR = 0x021E0000, | ||
82 | + FSL_IMX6UL_QSPI_SIZE = 0x500, | ||
83 | + | ||
84 | FSL_IMX6UL_SYS_CNT_CTRL_ADDR = 0x021DC000, | ||
85 | + FSL_IMX6UL_SYS_CNT_CTRL_SIZE = (16 * KiB), | ||
86 | + | ||
87 | FSL_IMX6UL_SYS_CNT_CMP_ADDR = 0x021D8000, | ||
88 | + FSL_IMX6UL_SYS_CNT_CMP_SIZE = (16 * KiB), | ||
89 | + | ||
90 | FSL_IMX6UL_SYS_CNT_RD_ADDR = 0x021D4000, | ||
91 | + FSL_IMX6UL_SYS_CNT_RD_SIZE = (16 * KiB), | ||
92 | + | ||
93 | FSL_IMX6UL_TZASC_ADDR = 0x021D0000, | ||
94 | + FSL_IMX6UL_TZASC_SIZE = (16 * KiB), | ||
95 | + | ||
96 | FSL_IMX6UL_PXP_ADDR = 0x021CC000, | ||
97 | + FSL_IMX6UL_PXP_SIZE = (16 * KiB), | ||
98 | + | ||
99 | FSL_IMX6UL_LCDIF_ADDR = 0x021C8000, | ||
100 | + FSL_IMX6UL_LCDIF_SIZE = 0x100, | ||
101 | + | ||
102 | FSL_IMX6UL_CSI_ADDR = 0x021C4000, | ||
103 | + FSL_IMX6UL_CSI_SIZE = 0x100, | ||
104 | + | ||
105 | FSL_IMX6UL_CSU_ADDR = 0x021C0000, | ||
106 | + FSL_IMX6UL_CSU_SIZE = (16 * KiB), | ||
107 | + | ||
108 | FSL_IMX6UL_OCOTP_CTRL_ADDR = 0x021BC000, | ||
109 | + FSL_IMX6UL_OCOTP_CTRL_SIZE = (4 * KiB), | ||
110 | + | ||
111 | FSL_IMX6UL_EIM_ADDR = 0x021B8000, | ||
112 | + FSL_IMX6UL_EIM_SIZE = 0x100, | ||
113 | + | ||
114 | FSL_IMX6UL_SIM2_ADDR = 0x021B4000, | ||
115 | + | ||
116 | FSL_IMX6UL_MMDC_CFG_ADDR = 0x021B0000, | ||
117 | + FSL_IMX6UL_MMDC_CFG_SIZE = (4 * KiB), | ||
118 | + | ||
119 | FSL_IMX6UL_ROMCP_ADDR = 0x021AC000, | ||
120 | + FSL_IMX6UL_ROMCP_SIZE = 0x300, | ||
121 | + | ||
122 | FSL_IMX6UL_I2C3_ADDR = 0x021A8000, | ||
123 | FSL_IMX6UL_I2C2_ADDR = 0x021A4000, | ||
124 | FSL_IMX6UL_I2C1_ADDR = 0x021A0000, | ||
125 | + | ||
126 | FSL_IMX6UL_ADC2_ADDR = 0x0219C000, | ||
127 | FSL_IMX6UL_ADC1_ADDR = 0x02198000, | ||
128 | + FSL_IMX6UL_ADCn_SIZE = 0x100, | ||
129 | + | ||
130 | FSL_IMX6UL_USDHC2_ADDR = 0x02194000, | ||
131 | FSL_IMX6UL_USDHC1_ADDR = 0x02190000, | ||
132 | - FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
133 | - FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
134 | - FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
135 | - FSL_IMX6UL_USBO2_USB_ADDR = 0x02184000, | ||
136 | - FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
137 | - FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
138 | - FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
139 | - FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
140 | |||
141 | - /* AIPS-1 */ | ||
142 | + FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
143 | + FSL_IMX6UL_SIMn_SIZE = (16 * KiB), | ||
144 | + | ||
145 | + FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
146 | + | ||
147 | + FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
148 | + FSL_IMX6UL_USBO2_USB1_ADDR = 0x02184000, | ||
149 | + FSL_IMX6UL_USBO2_USB2_ADDR = 0x02184200, | ||
150 | + | ||
151 | + FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
152 | + FSL_IMX6UL_USBO2_PL301_SIZE = (16 * KiB), | ||
153 | + | ||
154 | + FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
155 | + FSL_IMX6UL_AIPS2_CFG_SIZE = 0x100, | ||
156 | + | ||
157 | + FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
158 | + FSL_IMX6UL_CAAM_SIZE = (16 * KiB), | ||
159 | + | ||
160 | + FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
161 | + FSL_IMX6UL_A7MPCORE_DAP_SIZE = (4 * KiB), | ||
162 | + /* AIPS-2 End */ | ||
163 | + | ||
164 | + /* AIPS-1 Begin */ | ||
165 | FSL_IMX6UL_PWM8_ADDR = 0x020FC000, | ||
166 | FSL_IMX6UL_PWM7_ADDR = 0x020F8000, | ||
167 | FSL_IMX6UL_PWM6_ADDR = 0x020F4000, | ||
168 | FSL_IMX6UL_PWM5_ADDR = 0x020F0000, | ||
169 | + | ||
170 | FSL_IMX6UL_SDMA_ADDR = 0x020EC000, | ||
171 | + FSL_IMX6UL_SDMA_SIZE = 0x300, | ||
172 | + | ||
173 | FSL_IMX6UL_GPT2_ADDR = 0x020E8000, | ||
174 | + | ||
175 | FSL_IMX6UL_IOMUXC_GPR_ADDR = 0x020E4000, | ||
176 | + FSL_IMX6UL_IOMUXC_GPR_SIZE = 0x40, | ||
177 | + | ||
178 | FSL_IMX6UL_IOMUXC_ADDR = 0x020E0000, | ||
179 | + FSL_IMX6UL_IOMUXC_SIZE = 0x700, | ||
180 | + | ||
181 | FSL_IMX6UL_GPC_ADDR = 0x020DC000, | ||
182 | + | ||
183 | FSL_IMX6UL_SRC_ADDR = 0x020D8000, | ||
184 | + | ||
185 | FSL_IMX6UL_EPIT2_ADDR = 0x020D4000, | ||
186 | FSL_IMX6UL_EPIT1_ADDR = 0x020D0000, | ||
187 | + | ||
188 | FSL_IMX6UL_SNVS_HP_ADDR = 0x020CC000, | ||
189 | + | ||
190 | FSL_IMX6UL_USBPHY2_ADDR = 0x020CA000, | ||
191 | - FSL_IMX6UL_USBPHY2_SIZE = (4 * 1024), | ||
192 | FSL_IMX6UL_USBPHY1_ADDR = 0x020C9000, | ||
193 | - FSL_IMX6UL_USBPHY1_SIZE = (4 * 1024), | ||
194 | + | ||
195 | FSL_IMX6UL_ANALOG_ADDR = 0x020C8000, | ||
196 | + FSL_IMX6UL_ANALOG_SIZE = 0x300, | ||
197 | + | ||
198 | FSL_IMX6UL_CCM_ADDR = 0x020C4000, | ||
199 | + | ||
200 | FSL_IMX6UL_WDOG2_ADDR = 0x020C0000, | ||
201 | FSL_IMX6UL_WDOG1_ADDR = 0x020BC000, | ||
202 | + | ||
203 | FSL_IMX6UL_KPP_ADDR = 0x020B8000, | ||
204 | + FSL_IMX6UL_KPP_SIZE = 0x10, | ||
205 | + | ||
206 | FSL_IMX6UL_ENET2_ADDR = 0x020B4000, | ||
207 | + | ||
208 | FSL_IMX6UL_SNVS_LP_ADDR = 0x020B0000, | ||
209 | + FSL_IMX6UL_SNVS_LP_SIZE = (16 * KiB), | ||
210 | + | ||
211 | FSL_IMX6UL_GPIO5_ADDR = 0x020AC000, | ||
212 | FSL_IMX6UL_GPIO4_ADDR = 0x020A8000, | ||
213 | FSL_IMX6UL_GPIO3_ADDR = 0x020A4000, | ||
214 | FSL_IMX6UL_GPIO2_ADDR = 0x020A0000, | ||
215 | FSL_IMX6UL_GPIO1_ADDR = 0x0209C000, | ||
216 | + | ||
217 | FSL_IMX6UL_GPT1_ADDR = 0x02098000, | ||
218 | + | ||
219 | FSL_IMX6UL_CAN2_ADDR = 0x02094000, | ||
220 | FSL_IMX6UL_CAN1_ADDR = 0x02090000, | ||
221 | + FSL_IMX6UL_CANn_SIZE = (4 * KiB), | ||
222 | + | ||
223 | FSL_IMX6UL_PWM4_ADDR = 0x0208C000, | ||
224 | FSL_IMX6UL_PWM3_ADDR = 0x02088000, | ||
225 | FSL_IMX6UL_PWM2_ADDR = 0x02084000, | ||
226 | FSL_IMX6UL_PWM1_ADDR = 0x02080000, | ||
227 | + FSL_IMX6UL_PWMn_SIZE = 0x20, | ||
228 | + | ||
229 | FSL_IMX6UL_AIPS1_CFG_ADDR = 0x0207C000, | ||
230 | + FSL_IMX6UL_AIPS1_CFG_SIZE = (16 * KiB), | ||
231 | + | ||
232 | FSL_IMX6UL_BEE_ADDR = 0x02044000, | ||
233 | + FSL_IMX6UL_BEE_SIZE = (16 * KiB), | ||
234 | + | ||
235 | FSL_IMX6UL_TOUCH_CTRL_ADDR = 0x02040000, | ||
236 | + FSL_IMX6UL_TOUCH_CTRL_SIZE = 0x100, | ||
237 | + | ||
238 | FSL_IMX6UL_SPBA_ADDR = 0x0203C000, | ||
239 | + FSL_IMX6UL_SPBA_SIZE = 0x100, | ||
240 | + | ||
241 | FSL_IMX6UL_ASRC_ADDR = 0x02034000, | ||
242 | + FSL_IMX6UL_ASRC_SIZE = 0x100, | ||
243 | + | ||
244 | FSL_IMX6UL_SAI3_ADDR = 0x02030000, | ||
245 | FSL_IMX6UL_SAI2_ADDR = 0x0202C000, | ||
246 | FSL_IMX6UL_SAI1_ADDR = 0x02028000, | ||
247 | + FSL_IMX6UL_SAIn_SIZE = 0x200, | ||
248 | + | ||
249 | FSL_IMX6UL_UART8_ADDR = 0x02024000, | ||
250 | FSL_IMX6UL_UART1_ADDR = 0x02020000, | ||
251 | FSL_IMX6UL_UART7_ADDR = 0x02018000, | ||
252 | + | ||
253 | FSL_IMX6UL_ECSPI4_ADDR = 0x02014000, | ||
254 | FSL_IMX6UL_ECSPI3_ADDR = 0x02010000, | ||
255 | FSL_IMX6UL_ECSPI2_ADDR = 0x0200C000, | ||
256 | FSL_IMX6UL_ECSPI1_ADDR = 0x02008000, | ||
257 | + | ||
258 | FSL_IMX6UL_SPDIF_ADDR = 0x02004000, | ||
259 | + FSL_IMX6UL_SPDIF_SIZE = 0x100, | ||
260 | + /* AIPS-1 End */ | ||
261 | + | ||
262 | + FSL_IMX6UL_BCH_ADDR = 0x01808000, | ||
263 | + FSL_IMX6UL_BCH_SIZE = 0x200, | ||
264 | + | ||
265 | + FSL_IMX6UL_GPMI_ADDR = 0x01806000, | ||
266 | + FSL_IMX6UL_GPMI_SIZE = 0x200, | ||
267 | |||
268 | FSL_IMX6UL_APBH_DMA_ADDR = 0x01804000, | ||
269 | - FSL_IMX6UL_APBH_DMA_SIZE = (32 * 1024), | ||
270 | + FSL_IMX6UL_APBH_DMA_SIZE = (4 * KiB), | ||
271 | |||
272 | FSL_IMX6UL_A7MPCORE_ADDR = 0x00A00000, | ||
273 | |||
274 | FSL_IMX6UL_OCRAM_ALIAS_ADDR = 0x00920000, | ||
275 | - FSL_IMX6UL_OCRAM_ALIAS_SIZE = 0x00060000, | ||
276 | + FSL_IMX6UL_OCRAM_ALIAS_SIZE = (384 * KiB), | ||
277 | + | ||
278 | FSL_IMX6UL_OCRAM_MEM_ADDR = 0x00900000, | ||
279 | - FSL_IMX6UL_OCRAM_MEM_SIZE = 0x00020000, | ||
280 | + FSL_IMX6UL_OCRAM_MEM_SIZE = (128 * KiB), | ||
281 | + | ||
282 | FSL_IMX6UL_CAAM_MEM_ADDR = 0x00100000, | ||
283 | - FSL_IMX6UL_CAAM_MEM_SIZE = 0x00008000, | ||
284 | + FSL_IMX6UL_CAAM_MEM_SIZE = (32 * KiB), | ||
285 | + | ||
286 | FSL_IMX6UL_ROM_ADDR = 0x00000000, | ||
287 | - FSL_IMX6UL_ROM_SIZE = 0x00018000, | ||
288 | + FSL_IMX6UL_ROM_SIZE = (96 * KiB), | ||
289 | }; | ||
290 | |||
291 | enum FslIMX6ULIRQs { | ||
292 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | 293 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/include/hw/devices.h | 294 | --- a/hw/arm/fsl-imx6ul.c |
50 | +++ b/include/hw/devices.h | 295 | +++ b/hw/arm/fsl-imx6ul.c |
51 | @@ -XXX,XX +XXX,XX @@ | 296 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) |
52 | /* Devices that have nowhere better to go. */ | 297 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); |
53 | 298 | ||
54 | #include "hw/hw.h" | 299 | /* |
55 | -#include "ui/console.h" | 300 | - * GPIOs 1 to 5 |
56 | 301 | + * GPIOs | |
57 | /* smc91c111.c */ | 302 | */ |
58 | void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | 303 | for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { |
59 | @@ -XXX,XX +XXX,XX @@ void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | 304 | snprintf(name, NAME_SIZE, "gpio%d", i); |
60 | /* lan9118.c */ | 305 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) |
61 | void lan9118_init(NICInfo *, uint32_t, qemu_irq); | 306 | } |
62 | 307 | ||
63 | -/* tsc210x.c */ | 308 | /* |
64 | -uWireSlave *tsc2102_init(qemu_irq pint); | 309 | - * GPT 1, 2 |
65 | -uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); | 310 | + * GPTs |
66 | -I2SCodec *tsc210x_codec(uWireSlave *chip); | 311 | */ |
67 | -uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); | 312 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { |
68 | -void tsc210x_set_transform(uWireSlave *chip, | 313 | snprintf(name, NAME_SIZE, "gpt%d", i); |
69 | - MouseTransformInfo *info); | 314 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) |
70 | -void tsc210x_key_event(uWireSlave *chip, int key, int down); | 315 | } |
316 | |||
317 | /* | ||
318 | - * EPIT 1, 2 | ||
319 | + * EPITs | ||
320 | */ | ||
321 | for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
322 | snprintf(name, NAME_SIZE, "epit%d", i + 1); | ||
323 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
324 | } | ||
325 | |||
326 | /* | ||
327 | - * eCSPI | ||
328 | + * eCSPIs | ||
329 | */ | ||
330 | for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | ||
331 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | ||
332 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
333 | } | ||
334 | |||
335 | /* | ||
336 | - * I2C | ||
337 | + * I2Cs | ||
338 | */ | ||
339 | for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | ||
340 | snprintf(name, NAME_SIZE, "i2c%d", i + 1); | ||
341 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | - * UART | ||
346 | + * UARTs | ||
347 | */ | ||
348 | for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | ||
349 | snprintf(name, NAME_SIZE, "uart%d", i); | ||
350 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | - * Ethernet | ||
355 | + * Ethernets | ||
356 | */ | ||
357 | for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) { | ||
358 | snprintf(name, NAME_SIZE, "eth%d", i); | ||
359 | object_initialize_child(obj, name, &s->eth[i], TYPE_IMX_ENET); | ||
360 | } | ||
361 | |||
362 | - /* USB */ | ||
363 | + /* | ||
364 | + * USB PHYs | ||
365 | + */ | ||
366 | for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
367 | snprintf(name, NAME_SIZE, "usbphy%d", i); | ||
368 | object_initialize_child(obj, name, &s->usbphy[i], TYPE_IMX_USBPHY); | ||
369 | } | ||
370 | + | ||
371 | + /* | ||
372 | + * USBs | ||
373 | + */ | ||
374 | for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
375 | snprintf(name, NAME_SIZE, "usb%d", i); | ||
376 | object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA); | ||
377 | } | ||
378 | |||
379 | /* | ||
380 | - * SDHCI | ||
381 | + * SDHCIs | ||
382 | */ | ||
383 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
384 | snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
385 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
386 | } | ||
387 | |||
388 | /* | ||
389 | - * Watchdog | ||
390 | + * Watchdogs | ||
391 | */ | ||
392 | for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
393 | snprintf(name, NAME_SIZE, "wdt%d", i); | ||
394 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
395 | * A7MPCORE DAP | ||
396 | */ | ||
397 | create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR, | ||
398 | - 0x100000); | ||
399 | + FSL_IMX6UL_A7MPCORE_DAP_SIZE); | ||
400 | |||
401 | /* | ||
402 | - * GPT 1, 2 | ||
403 | + * GPTs | ||
404 | */ | ||
405 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | ||
406 | static const hwaddr FSL_IMX6UL_GPTn_ADDR[FSL_IMX6UL_NUM_GPTS] = { | ||
407 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
408 | } | ||
409 | |||
410 | /* | ||
411 | - * EPIT 1, 2 | ||
412 | + * EPITs | ||
413 | */ | ||
414 | for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
415 | static const hwaddr FSL_IMX6UL_EPITn_ADDR[FSL_IMX6UL_NUM_EPITS] = { | ||
416 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
417 | } | ||
418 | |||
419 | /* | ||
420 | - * GPIO | ||
421 | + * GPIOs | ||
422 | */ | ||
423 | for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { | ||
424 | static const hwaddr FSL_IMX6UL_GPIOn_ADDR[FSL_IMX6UL_NUM_GPIOS] = { | ||
425 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
426 | } | ||
427 | |||
428 | /* | ||
429 | - * IOMUXC and IOMUXC_GPR | ||
430 | + * IOMUXC | ||
431 | */ | ||
432 | - for (i = 0; i < 1; i++) { | ||
433 | - static const hwaddr FSL_IMX6UL_IOMUXCn_ADDR[FSL_IMX6UL_NUM_IOMUXCS] = { | ||
434 | - FSL_IMX6UL_IOMUXC_ADDR, | ||
435 | - FSL_IMX6UL_IOMUXC_GPR_ADDR, | ||
436 | - }; | ||
71 | - | 437 | - |
72 | -/* tsc2005.c */ | 438 | - snprintf(name, NAME_SIZE, "iomuxc%d", i); |
73 | -void *tsc2005_init(qemu_irq pintdav); | 439 | - create_unimplemented_device(name, FSL_IMX6UL_IOMUXCn_ADDR[i], 0x4000); |
74 | -uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | 440 | - } |
75 | -void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | 441 | + create_unimplemented_device("iomuxc", FSL_IMX6UL_IOMUXC_ADDR, |
76 | - | 442 | + FSL_IMX6UL_IOMUXC_SIZE); |
77 | #endif | 443 | + create_unimplemented_device("iomuxc_gpr", FSL_IMX6UL_IOMUXC_GPR_ADDR, |
78 | diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h | 444 | + FSL_IMX6UL_IOMUXC_GPR_SIZE); |
79 | new file mode 100644 | 445 | |
80 | index XXXXXXX..XXXXXXX | 446 | /* |
81 | --- /dev/null | 447 | * CCM |
82 | +++ b/include/hw/input/tsc2xxx.h | 448 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
83 | @@ -XXX,XX +XXX,XX @@ | 449 | sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort); |
84 | +/* | 450 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX6UL_GPC_ADDR); |
85 | + * TI touchscreen controller | 451 | |
86 | + * | 452 | - /* Initialize all ECSPI */ |
87 | + * Copyright (c) 2006 Andrzej Zaborowski | 453 | + /* |
88 | + * Copyright (C) 2008 Nokia Corporation | 454 | + * ECSPIs |
89 | + * | 455 | + */ |
90 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 456 | for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { |
91 | + * See the COPYING file in the top-level directory. | 457 | static const hwaddr FSL_IMX6UL_SPIn_ADDR[FSL_IMX6UL_NUM_ECSPIS] = { |
92 | + */ | 458 | FSL_IMX6UL_ECSPI1_ADDR, |
93 | + | 459 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
94 | +#ifndef HW_INPUT_TSC2XXX_H | 460 | } |
95 | +#define HW_INPUT_TSC2XXX_H | 461 | |
96 | + | 462 | /* |
97 | +#include "hw/irq.h" | 463 | - * I2C |
98 | +#include "ui/console.h" | 464 | + * I2Cs |
99 | + | 465 | */ |
100 | +typedef struct uWireSlave { | 466 | for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { |
101 | + uint16_t (*receive)(void *opaque); | 467 | static const hwaddr FSL_IMX6UL_I2Cn_ADDR[FSL_IMX6UL_NUM_I2CS] = { |
102 | + void (*send)(void *opaque, uint16_t data); | 468 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
103 | + void *opaque; | 469 | } |
104 | +} uWireSlave; | 470 | |
105 | + | 471 | /* |
106 | +/* tsc210x.c */ | 472 | - * UART |
107 | +uWireSlave *tsc2102_init(qemu_irq pint); | 473 | + * UARTs |
108 | +uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); | 474 | */ |
109 | +I2SCodec *tsc210x_codec(uWireSlave *chip); | 475 | for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { |
110 | +uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); | 476 | static const hwaddr FSL_IMX6UL_UARTn_ADDR[FSL_IMX6UL_NUM_UARTS] = { |
111 | +void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info); | 477 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
112 | +void tsc210x_key_event(uWireSlave *chip, int key, int down); | 478 | } |
113 | + | 479 | |
114 | +/* tsc2005.c */ | 480 | /* |
115 | +void *tsc2005_init(qemu_irq pintdav); | 481 | - * Ethernet |
116 | +uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | 482 | + * Ethernets |
117 | +void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | 483 | * |
118 | + | 484 | * We must use two loops since phy_connected affects the other interface |
119 | +#endif | 485 | * and we have to set all properties before calling sysbus_realize(). |
120 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h | 486 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
121 | index XXXXXXX..XXXXXXX 100644 | 487 | FSL_IMX6UL_ENETn_TIMER_IRQ[i])); |
122 | --- a/include/qemu/typedefs.h | 488 | } |
123 | +++ b/include/qemu/typedefs.h | 489 | |
124 | @@ -XXX,XX +XXX,XX @@ typedef struct RAMBlock RAMBlock; | 490 | - /* USB */ |
125 | typedef struct Range Range; | 491 | + /* |
126 | typedef struct SHPCDevice SHPCDevice; | 492 | + * USB PHYs |
127 | typedef struct SSIBus SSIBus; | 493 | + */ |
128 | -typedef struct uWireSlave uWireSlave; | 494 | for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { |
129 | typedef struct VirtIODevice VirtIODevice; | 495 | + static const hwaddr |
130 | typedef struct Visitor Visitor; | 496 | + FSL_IMX6UL_USB_PHYn_ADDR[FSL_IMX6UL_NUM_USB_PHYS] = { |
131 | typedef void SaveStateHandler(QEMUFile *f, void *opaque); | 497 | + FSL_IMX6UL_USBPHY1_ADDR, |
132 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | 498 | + FSL_IMX6UL_USBPHY2_ADDR, |
133 | index XXXXXXX..XXXXXXX 100644 | 499 | + }; |
134 | --- a/hw/arm/nseries.c | 500 | + |
135 | +++ b/hw/arm/nseries.c | 501 | sysbus_realize(SYS_BUS_DEVICE(&s->usbphy[i]), &error_abort); |
136 | @@ -XXX,XX +XXX,XX @@ | 502 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0, |
137 | #include "ui/console.h" | 503 | - FSL_IMX6UL_USBPHY1_ADDR + i * 0x1000); |
138 | #include "hw/boards.h" | 504 | + FSL_IMX6UL_USB_PHYn_ADDR[i]); |
139 | #include "hw/i2c/i2c.h" | 505 | } |
140 | -#include "hw/devices.h" | 506 | |
141 | #include "hw/display/blizzard.h" | 507 | + /* |
142 | +#include "hw/input/tsc2xxx.h" | 508 | + * USBs |
143 | #include "hw/misc/cbus.h" | 509 | + */ |
144 | #include "hw/misc/tmp105.h" | 510 | for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { |
145 | #include "hw/block/flash.h" | 511 | + static const hwaddr FSL_IMX6UL_USB02_USBn_ADDR[FSL_IMX6UL_NUM_USBS] = { |
146 | diff --git a/hw/arm/palm.c b/hw/arm/palm.c | 512 | + FSL_IMX6UL_USBO2_USB1_ADDR, |
147 | index XXXXXXX..XXXXXXX 100644 | 513 | + FSL_IMX6UL_USBO2_USB2_ADDR, |
148 | --- a/hw/arm/palm.c | 514 | + }; |
149 | +++ b/hw/arm/palm.c | 515 | + |
150 | @@ -XXX,XX +XXX,XX @@ | 516 | static const int FSL_IMX6UL_USBn_IRQ[] = { |
151 | #include "hw/arm/omap.h" | 517 | FSL_IMX6UL_USB1_IRQ, |
152 | #include "hw/boards.h" | 518 | FSL_IMX6UL_USB2_IRQ, |
153 | #include "hw/arm/arm.h" | 519 | }; |
154 | -#include "hw/devices.h" | 520 | + |
155 | +#include "hw/input/tsc2xxx.h" | 521 | sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), &error_abort); |
156 | #include "hw/loader.h" | 522 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, |
157 | #include "exec/address-spaces.h" | 523 | - FSL_IMX6UL_USBO2_USB_ADDR + i * 0x200); |
158 | #include "cpu.h" | 524 | + FSL_IMX6UL_USB02_USBn_ADDR[i]); |
159 | diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c | 525 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, |
160 | index XXXXXXX..XXXXXXX 100644 | 526 | qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
161 | --- a/hw/input/tsc2005.c | 527 | FSL_IMX6UL_USBn_IRQ[i])); |
162 | +++ b/hw/input/tsc2005.c | 528 | } |
163 | @@ -XXX,XX +XXX,XX @@ | 529 | |
164 | #include "hw/hw.h" | 530 | /* |
165 | #include "qemu/timer.h" | 531 | - * USDHC |
166 | #include "ui/console.h" | 532 | + * USDHCs |
167 | -#include "hw/devices.h" | 533 | */ |
168 | +#include "hw/input/tsc2xxx.h" | 534 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { |
169 | #include "trace.h" | 535 | static const hwaddr FSL_IMX6UL_USDHCn_ADDR[FSL_IMX6UL_NUM_USDHCS] = { |
170 | 536 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | |
171 | #define TSC_CUT_RESOLUTION(value, p) ((value) >> (16 - (p ? 12 : 10))) | 537 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6UL_SNVS_HP_ADDR); |
172 | diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c | 538 | |
173 | index XXXXXXX..XXXXXXX 100644 | 539 | /* |
174 | --- a/hw/input/tsc210x.c | 540 | - * Watchdog |
175 | +++ b/hw/input/tsc210x.c | 541 | + * Watchdogs |
176 | @@ -XXX,XX +XXX,XX @@ | 542 | */ |
177 | #include "audio/audio.h" | 543 | for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { |
178 | #include "qemu/timer.h" | 544 | static const hwaddr FSL_IMX6UL_WDOGn_ADDR[FSL_IMX6UL_NUM_WDTS] = { |
179 | #include "ui/console.h" | 545 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
180 | -#include "hw/arm/omap.h" /* For I2SCodec and uWireSlave */ | 546 | FSL_IMX6UL_WDOG2_ADDR, |
181 | -#include "hw/devices.h" | 547 | FSL_IMX6UL_WDOG3_ADDR, |
182 | +#include "hw/arm/omap.h" /* For I2SCodec */ | 548 | }; |
183 | +#include "hw/input/tsc2xxx.h" | 549 | + |
184 | 550 | static const int FSL_IMX6UL_WDOGn_IRQ[FSL_IMX6UL_NUM_WDTS] = { | |
185 | #define TSC_DATA_REGISTERS_PAGE 0x0 | 551 | FSL_IMX6UL_WDOG1_IRQ, |
186 | #define TSC_CONTROL_REGISTERS_PAGE 0x1 | 552 | FSL_IMX6UL_WDOG2_IRQ, |
187 | diff --git a/MAINTAINERS b/MAINTAINERS | 553 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
188 | index XXXXXXX..XXXXXXX 100644 | 554 | /* |
189 | --- a/MAINTAINERS | 555 | * SDMA |
190 | +++ b/MAINTAINERS | 556 | */ |
191 | @@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c | 557 | - create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); |
192 | F: hw/misc/cbus.c | 558 | + create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, |
193 | F: hw/timer/twl92230.c | 559 | + FSL_IMX6UL_SDMA_SIZE); |
194 | F: include/hw/display/blizzard.h | 560 | |
195 | +F: include/hw/input/tsc2xxx.h | 561 | /* |
196 | F: include/hw/misc/cbus.h | 562 | - * SAI (Audio SSI (Synchronous Serial Interface)) |
197 | 563 | + * SAIs (Audio SSI (Synchronous Serial Interface)) | |
198 | Palm | 564 | */ |
199 | @@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org | 565 | - create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000); |
200 | S: Odd Fixes | 566 | - create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000); |
201 | F: hw/arm/palm.c | 567 | - create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000); |
202 | F: hw/input/tsc210x.c | 568 | + for (i = 0; i < FSL_IMX6UL_NUM_SAIS; i++) { |
203 | +F: include/hw/input/tsc2xxx.h | 569 | + static const hwaddr FSL_IMX6UL_SAIn_ADDR[FSL_IMX6UL_NUM_SAIS] = { |
204 | 570 | + FSL_IMX6UL_SAI1_ADDR, | |
205 | Raspberry Pi | 571 | + FSL_IMX6UL_SAI2_ADDR, |
206 | M: Peter Maydell <peter.maydell@linaro.org> | 572 | + FSL_IMX6UL_SAI3_ADDR, |
573 | + }; | ||
574 | + | ||
575 | + snprintf(name, NAME_SIZE, "sai%d", i); | ||
576 | + create_unimplemented_device(name, FSL_IMX6UL_SAIn_ADDR[i], | ||
577 | + FSL_IMX6UL_SAIn_SIZE); | ||
578 | + } | ||
579 | |||
580 | /* | ||
581 | - * PWM | ||
582 | + * PWMs | ||
583 | */ | ||
584 | - create_unimplemented_device("pwm1", FSL_IMX6UL_PWM1_ADDR, 0x4000); | ||
585 | - create_unimplemented_device("pwm2", FSL_IMX6UL_PWM2_ADDR, 0x4000); | ||
586 | - create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); | ||
587 | - create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); | ||
588 | + for (i = 0; i < FSL_IMX6UL_NUM_PWMS; i++) { | ||
589 | + static const hwaddr FSL_IMX6UL_PWMn_ADDR[FSL_IMX6UL_NUM_PWMS] = { | ||
590 | + FSL_IMX6UL_PWM1_ADDR, | ||
591 | + FSL_IMX6UL_PWM2_ADDR, | ||
592 | + FSL_IMX6UL_PWM3_ADDR, | ||
593 | + FSL_IMX6UL_PWM4_ADDR, | ||
594 | + }; | ||
595 | + | ||
596 | + snprintf(name, NAME_SIZE, "pwm%d", i); | ||
597 | + create_unimplemented_device(name, FSL_IMX6UL_PWMn_ADDR[i], | ||
598 | + FSL_IMX6UL_PWMn_SIZE); | ||
599 | + } | ||
600 | |||
601 | /* | ||
602 | * Audio ASRC (asynchronous sample rate converter) | ||
603 | */ | ||
604 | - create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, 0x4000); | ||
605 | + create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, | ||
606 | + FSL_IMX6UL_ASRC_SIZE); | ||
607 | |||
608 | /* | ||
609 | - * CAN | ||
610 | + * CANs | ||
611 | */ | ||
612 | - create_unimplemented_device("can1", FSL_IMX6UL_CAN1_ADDR, 0x4000); | ||
613 | - create_unimplemented_device("can2", FSL_IMX6UL_CAN2_ADDR, 0x4000); | ||
614 | + for (i = 0; i < FSL_IMX6UL_NUM_CANS; i++) { | ||
615 | + static const hwaddr FSL_IMX6UL_CANn_ADDR[FSL_IMX6UL_NUM_CANS] = { | ||
616 | + FSL_IMX6UL_CAN1_ADDR, | ||
617 | + FSL_IMX6UL_CAN2_ADDR, | ||
618 | + }; | ||
619 | + | ||
620 | + snprintf(name, NAME_SIZE, "can%d", i); | ||
621 | + create_unimplemented_device(name, FSL_IMX6UL_CANn_ADDR[i], | ||
622 | + FSL_IMX6UL_CANn_SIZE); | ||
623 | + } | ||
624 | |||
625 | /* | ||
626 | * APHB_DMA | ||
627 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
628 | }; | ||
629 | |||
630 | snprintf(name, NAME_SIZE, "adc%d", i); | ||
631 | - create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], 0x4000); | ||
632 | + create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], | ||
633 | + FSL_IMX6UL_ADCn_SIZE); | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * LCD | ||
638 | */ | ||
639 | - create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, 0x4000); | ||
640 | + create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, | ||
641 | + FSL_IMX6UL_LCDIF_SIZE); | ||
642 | |||
643 | /* | ||
644 | * ROM memory | ||
207 | -- | 645 | -- |
208 | 2.20.1 | 646 | 2.34.1 |
209 | |||
210 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 3 | * Add TZASC as unimplemented device. |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | - Allow bare metal application to access this (unimplemented) device |
5 | Message-id: 20190412165416.7977-10-philmd@redhat.com | 5 | * Add CSU as unimplemented device. |
6 | - Allow bare metal application to access this (unimplemented) device | ||
7 | * Add 4 missing PWM devices | ||
8 | |||
9 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Message-id: 59e4dc56e14eccfefd379275ec19048dff9c10b3.1692964892.git.jcd@tribudubois.net | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 13 | --- |
8 | include/hw/devices.h | 3 --- | 14 | include/hw/arm/fsl-imx6ul.h | 2 +- |
9 | include/hw/net/lan9118.h | 19 +++++++++++++++++++ | 15 | hw/arm/fsl-imx6ul.c | 16 ++++++++++++++++ |
10 | hw/arm/kzm.c | 2 +- | 16 | 2 files changed, 17 insertions(+), 1 deletion(-) |
11 | hw/arm/mps2.c | 2 +- | ||
12 | hw/arm/realview.c | 1 + | ||
13 | hw/arm/vexpress.c | 2 +- | ||
14 | hw/net/lan9118.c | 2 +- | ||
15 | 7 files changed, 24 insertions(+), 7 deletions(-) | ||
16 | create mode 100644 include/hw/net/lan9118.h | ||
17 | 17 | ||
18 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 18 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
19 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/devices.h | 20 | --- a/include/hw/arm/fsl-imx6ul.h |
21 | +++ b/include/hw/devices.h | 21 | +++ b/include/hw/arm/fsl-imx6ul.h |
22 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { |
23 | /* smc91c111.c */ | 23 | FSL_IMX6UL_NUM_USBS = 2, |
24 | void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | 24 | FSL_IMX6UL_NUM_SAIS = 3, |
25 | 25 | FSL_IMX6UL_NUM_CANS = 2, | |
26 | -/* lan9118.c */ | 26 | - FSL_IMX6UL_NUM_PWMS = 4, |
27 | -void lan9118_init(NICInfo *, uint32_t, qemu_irq); | 27 | + FSL_IMX6UL_NUM_PWMS = 8, |
28 | - | 28 | }; |
29 | #endif | 29 | |
30 | diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h | 30 | struct FslIMX6ULState { |
31 | new file mode 100644 | 31 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
32 | index XXXXXXX..XXXXXXX | 32 | index XXXXXXX..XXXXXXX 100644 |
33 | --- /dev/null | 33 | --- a/hw/arm/fsl-imx6ul.c |
34 | +++ b/include/hw/net/lan9118.h | 34 | +++ b/hw/arm/fsl-imx6ul.c |
35 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
36 | +/* | 36 | FSL_IMX6UL_PWM2_ADDR, |
37 | + * SMSC LAN9118 Ethernet interface emulation | 37 | FSL_IMX6UL_PWM3_ADDR, |
38 | + * | 38 | FSL_IMX6UL_PWM4_ADDR, |
39 | + * Copyright (c) 2009 CodeSourcery, LLC. | 39 | + FSL_IMX6UL_PWM5_ADDR, |
40 | + * Written by Paul Brook | 40 | + FSL_IMX6UL_PWM6_ADDR, |
41 | + * | 41 | + FSL_IMX6UL_PWM7_ADDR, |
42 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 42 | + FSL_IMX6UL_PWM8_ADDR, |
43 | + * See the COPYING file in the top-level directory. | 43 | }; |
44 | + */ | 44 | |
45 | snprintf(name, NAME_SIZE, "pwm%d", i); | ||
46 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
47 | create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, | ||
48 | FSL_IMX6UL_LCDIF_SIZE); | ||
49 | |||
50 | + /* | ||
51 | + * CSU | ||
52 | + */ | ||
53 | + create_unimplemented_device("csu", FSL_IMX6UL_CSU_ADDR, | ||
54 | + FSL_IMX6UL_CSU_SIZE); | ||
45 | + | 55 | + |
46 | +#ifndef HW_NET_LAN9118_H | 56 | + /* |
47 | +#define HW_NET_LAN9118_H | 57 | + * TZASC |
58 | + */ | ||
59 | + create_unimplemented_device("tzasc", FSL_IMX6UL_TZASC_ADDR, | ||
60 | + FSL_IMX6UL_TZASC_SIZE); | ||
48 | + | 61 | + |
49 | +#include "hw/irq.h" | 62 | /* |
50 | +#include "net/net.h" | 63 | * ROM memory |
51 | + | 64 | */ |
52 | +void lan9118_init(NICInfo *, uint32_t, qemu_irq); | ||
53 | + | ||
54 | +#endif | ||
55 | diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/hw/arm/kzm.c | ||
58 | +++ b/hw/arm/kzm.c | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | #include "qemu/error-report.h" | ||
61 | #include "exec/address-spaces.h" | ||
62 | #include "net/net.h" | ||
63 | -#include "hw/devices.h" | ||
64 | +#include "hw/net/lan9118.h" | ||
65 | #include "hw/char/serial.h" | ||
66 | #include "sysemu/qtest.h" | ||
67 | |||
68 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/mps2.c | ||
71 | +++ b/hw/arm/mps2.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #include "hw/timer/cmsdk-apb-timer.h" | ||
74 | #include "hw/timer/cmsdk-apb-dualtimer.h" | ||
75 | #include "hw/misc/mps2-scc.h" | ||
76 | -#include "hw/devices.h" | ||
77 | +#include "hw/net/lan9118.h" | ||
78 | #include "net/net.h" | ||
79 | |||
80 | typedef enum MPS2FPGAType { | ||
81 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/arm/realview.c | ||
84 | +++ b/hw/arm/realview.c | ||
85 | @@ -XXX,XX +XXX,XX @@ | ||
86 | #include "hw/arm/arm.h" | ||
87 | #include "hw/arm/primecell.h" | ||
88 | #include "hw/devices.h" | ||
89 | +#include "hw/net/lan9118.h" | ||
90 | #include "hw/pci/pci.h" | ||
91 | #include "net/net.h" | ||
92 | #include "sysemu/sysemu.h" | ||
93 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/hw/arm/vexpress.c | ||
96 | +++ b/hw/arm/vexpress.c | ||
97 | @@ -XXX,XX +XXX,XX @@ | ||
98 | #include "hw/sysbus.h" | ||
99 | #include "hw/arm/arm.h" | ||
100 | #include "hw/arm/primecell.h" | ||
101 | -#include "hw/devices.h" | ||
102 | +#include "hw/net/lan9118.h" | ||
103 | #include "hw/i2c/i2c.h" | ||
104 | #include "net/net.h" | ||
105 | #include "sysemu/sysemu.h" | ||
106 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/hw/net/lan9118.c | ||
109 | +++ b/hw/net/lan9118.c | ||
110 | @@ -XXX,XX +XXX,XX @@ | ||
111 | #include "hw/sysbus.h" | ||
112 | #include "net/net.h" | ||
113 | #include "net/eth.h" | ||
114 | -#include "hw/devices.h" | ||
115 | +#include "hw/net/lan9118.h" | ||
116 | #include "sysemu/sysemu.h" | ||
117 | #include "hw/ptimer.h" | ||
118 | #include "qemu/log.h" | ||
119 | -- | 65 | -- |
120 | 2.20.1 | 66 | 2.34.1 |
121 | 67 | ||
122 | 68 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | No code used the tc6393xb_gpio_in_get() and tc6393xb_gpio_out_set() | 3 | * Add Addr and size definition for all i.MX7 devices in i.MX7 header file. |
4 | functions since their introduction in commit 88d2c950b002. Time to | 4 | * Use those newly defined named constants whenever possible. |
5 | remove them. | 5 | * Standardize the way we init a familly of unimplemented devices |
6 | - SAI | ||
7 | - PWM | ||
8 | - CAN | ||
9 | * Add/rework few comments | ||
6 | 10 | ||
7 | Suggested-by: Markus Armbruster <armbru@redhat.com> | 11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | Message-id: 59e195d33e4d486a8d131392acd46633c8c10ed7.1692964892.git.jcd@tribudubois.net |
9 | Message-id: 20190412165416.7977-4-philmd@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 15 | --- |
13 | include/hw/devices.h | 3 --- | 16 | include/hw/arm/fsl-imx7.h | 330 ++++++++++++++++++++++++++++---------- |
14 | hw/display/tc6393xb.c | 16 ---------------- | 17 | hw/arm/fsl-imx7.c | 130 ++++++++++----- |
15 | 2 files changed, 19 deletions(-) | 18 | 2 files changed, 335 insertions(+), 125 deletions(-) |
16 | 19 | ||
17 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 20 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/devices.h | 22 | --- a/include/hw/arm/fsl-imx7.h |
20 | +++ b/include/hw/devices.h | 23 | +++ b/include/hw/arm/fsl-imx7.h |
21 | @@ -XXX,XX +XXX,XX @@ void retu_key_event(void *retu, int state); | 24 | @@ -XXX,XX +XXX,XX @@ |
22 | typedef struct TC6393xbState TC6393xbState; | 25 | #include "hw/misc/imx7_ccm.h" |
23 | TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | 26 | #include "hw/misc/imx7_snvs.h" |
24 | uint32_t base, qemu_irq irq); | 27 | #include "hw/misc/imx7_gpr.h" |
25 | -void tc6393xb_gpio_out_set(TC6393xbState *s, int line, | 28 | -#include "hw/misc/imx6_src.h" |
26 | - qemu_irq handler); | 29 | #include "hw/watchdog/wdt_imx2.h" |
27 | -qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s); | 30 | #include "hw/gpio/imx_gpio.h" |
28 | qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | 31 | #include "hw/char/imx_serial.h" |
29 | 32 | @@ -XXX,XX +XXX,XX @@ | |
30 | #endif | 33 | #include "hw/usb/chipidea.h" |
31 | diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c | 34 | #include "cpu.h" |
35 | #include "qom/object.h" | ||
36 | +#include "qemu/units.h" | ||
37 | |||
38 | #define TYPE_FSL_IMX7 "fsl-imx7" | ||
39 | OBJECT_DECLARE_SIMPLE_TYPE(FslIMX7State, FSL_IMX7) | ||
40 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7Configuration { | ||
41 | FSL_IMX7_NUM_ECSPIS = 4, | ||
42 | FSL_IMX7_NUM_USBS = 3, | ||
43 | FSL_IMX7_NUM_ADCS = 2, | ||
44 | + FSL_IMX7_NUM_SAIS = 3, | ||
45 | + FSL_IMX7_NUM_CANS = 2, | ||
46 | + FSL_IMX7_NUM_PWMS = 4, | ||
47 | }; | ||
48 | |||
49 | struct FslIMX7State { | ||
50 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { | ||
51 | |||
52 | enum FslIMX7MemoryMap { | ||
53 | FSL_IMX7_MMDC_ADDR = 0x80000000, | ||
54 | - FSL_IMX7_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, | ||
55 | + FSL_IMX7_MMDC_SIZE = (2 * GiB), | ||
56 | |||
57 | - FSL_IMX7_GPIO1_ADDR = 0x30200000, | ||
58 | - FSL_IMX7_GPIO2_ADDR = 0x30210000, | ||
59 | - FSL_IMX7_GPIO3_ADDR = 0x30220000, | ||
60 | - FSL_IMX7_GPIO4_ADDR = 0x30230000, | ||
61 | - FSL_IMX7_GPIO5_ADDR = 0x30240000, | ||
62 | - FSL_IMX7_GPIO6_ADDR = 0x30250000, | ||
63 | - FSL_IMX7_GPIO7_ADDR = 0x30260000, | ||
64 | + FSL_IMX7_QSPI1_MEM_ADDR = 0x60000000, | ||
65 | + FSL_IMX7_QSPI1_MEM_SIZE = (256 * MiB), | ||
66 | |||
67 | - FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000, | ||
68 | + FSL_IMX7_PCIE1_MEM_ADDR = 0x40000000, | ||
69 | + FSL_IMX7_PCIE1_MEM_SIZE = (256 * MiB), | ||
70 | |||
71 | - FSL_IMX7_WDOG1_ADDR = 0x30280000, | ||
72 | - FSL_IMX7_WDOG2_ADDR = 0x30290000, | ||
73 | - FSL_IMX7_WDOG3_ADDR = 0x302A0000, | ||
74 | - FSL_IMX7_WDOG4_ADDR = 0x302B0000, | ||
75 | + FSL_IMX7_QSPI1_RX_BUF_ADDR = 0x34000000, | ||
76 | + FSL_IMX7_QSPI1_RX_BUF_SIZE = (32 * MiB), | ||
77 | |||
78 | - FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000, | ||
79 | + /* PCIe Peripherals */ | ||
80 | + FSL_IMX7_PCIE_REG_ADDR = 0x33800000, | ||
81 | |||
82 | - FSL_IMX7_GPT1_ADDR = 0x302D0000, | ||
83 | - FSL_IMX7_GPT2_ADDR = 0x302E0000, | ||
84 | - FSL_IMX7_GPT3_ADDR = 0x302F0000, | ||
85 | - FSL_IMX7_GPT4_ADDR = 0x30300000, | ||
86 | + /* MMAP Peripherals */ | ||
87 | + FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | ||
88 | + FSL_IMX7_DMA_APBH_SIZE = 0x8000, | ||
89 | |||
90 | - FSL_IMX7_IOMUXC_ADDR = 0x30330000, | ||
91 | - FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000, | ||
92 | - FSL_IMX7_IOMUXCn_SIZE = 0x1000, | ||
93 | + /* GPV configuration */ | ||
94 | + FSL_IMX7_GPV6_ADDR = 0x32600000, | ||
95 | + FSL_IMX7_GPV5_ADDR = 0x32500000, | ||
96 | + FSL_IMX7_GPV4_ADDR = 0x32400000, | ||
97 | + FSL_IMX7_GPV3_ADDR = 0x32300000, | ||
98 | + FSL_IMX7_GPV2_ADDR = 0x32200000, | ||
99 | + FSL_IMX7_GPV1_ADDR = 0x32100000, | ||
100 | + FSL_IMX7_GPV0_ADDR = 0x32000000, | ||
101 | + FSL_IMX7_GPVn_SIZE = (1 * MiB), | ||
102 | |||
103 | - FSL_IMX7_OCOTP_ADDR = 0x30350000, | ||
104 | - FSL_IMX7_OCOTP_SIZE = 0x10000, | ||
105 | + /* Arm Peripherals */ | ||
106 | + FSL_IMX7_A7MPCORE_ADDR = 0x31000000, | ||
107 | |||
108 | - FSL_IMX7_ANALOG_ADDR = 0x30360000, | ||
109 | - FSL_IMX7_SNVS_ADDR = 0x30370000, | ||
110 | - FSL_IMX7_CCM_ADDR = 0x30380000, | ||
111 | + /* AIPS-3 Begin */ | ||
112 | |||
113 | - FSL_IMX7_SRC_ADDR = 0x30390000, | ||
114 | - FSL_IMX7_SRC_SIZE = 0x1000, | ||
115 | + FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
116 | + FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
117 | |||
118 | - FSL_IMX7_ADC1_ADDR = 0x30610000, | ||
119 | - FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
120 | - FSL_IMX7_ADCn_SIZE = 0x1000, | ||
121 | + FSL_IMX7_SDMA_ADDR = 0x30BD0000, | ||
122 | + FSL_IMX7_SDMA_SIZE = (4 * KiB), | ||
123 | |||
124 | - FSL_IMX7_PWM1_ADDR = 0x30660000, | ||
125 | - FSL_IMX7_PWM2_ADDR = 0x30670000, | ||
126 | - FSL_IMX7_PWM3_ADDR = 0x30680000, | ||
127 | - FSL_IMX7_PWM4_ADDR = 0x30690000, | ||
128 | - FSL_IMX7_PWMn_SIZE = 0x10000, | ||
129 | + FSL_IMX7_EIM_ADDR = 0x30BC0000, | ||
130 | + FSL_IMX7_EIM_SIZE = (4 * KiB), | ||
131 | |||
132 | - FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
133 | - FSL_IMX7_PCIE_PHY_SIZE = 0x10000, | ||
134 | + FSL_IMX7_QSPI_ADDR = 0x30BB0000, | ||
135 | + FSL_IMX7_QSPI_SIZE = 0x8000, | ||
136 | |||
137 | - FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
138 | + FSL_IMX7_SIM2_ADDR = 0x30BA0000, | ||
139 | + FSL_IMX7_SIM1_ADDR = 0x30B90000, | ||
140 | + FSL_IMX7_SIMn_SIZE = (4 * KiB), | ||
141 | + | ||
142 | + FSL_IMX7_USDHC3_ADDR = 0x30B60000, | ||
143 | + FSL_IMX7_USDHC2_ADDR = 0x30B50000, | ||
144 | + FSL_IMX7_USDHC1_ADDR = 0x30B40000, | ||
145 | + | ||
146 | + FSL_IMX7_USB3_ADDR = 0x30B30000, | ||
147 | + FSL_IMX7_USBMISC3_ADDR = 0x30B30200, | ||
148 | + FSL_IMX7_USB2_ADDR = 0x30B20000, | ||
149 | + FSL_IMX7_USBMISC2_ADDR = 0x30B20200, | ||
150 | + FSL_IMX7_USB1_ADDR = 0x30B10000, | ||
151 | + FSL_IMX7_USBMISC1_ADDR = 0x30B10200, | ||
152 | + FSL_IMX7_USBMISCn_SIZE = 0x200, | ||
153 | + | ||
154 | + FSL_IMX7_USB_PL301_ADDR = 0x30AD0000, | ||
155 | + FSL_IMX7_USB_PL301_SIZE = (64 * KiB), | ||
156 | + | ||
157 | + FSL_IMX7_SEMAPHORE_HS_ADDR = 0x30AC0000, | ||
158 | + FSL_IMX7_SEMAPHORE_HS_SIZE = (64 * KiB), | ||
159 | + | ||
160 | + FSL_IMX7_MUB_ADDR = 0x30AB0000, | ||
161 | + FSL_IMX7_MUA_ADDR = 0x30AA0000, | ||
162 | + FSL_IMX7_MUn_SIZE = (KiB), | ||
163 | + | ||
164 | + FSL_IMX7_UART7_ADDR = 0x30A90000, | ||
165 | + FSL_IMX7_UART6_ADDR = 0x30A80000, | ||
166 | + FSL_IMX7_UART5_ADDR = 0x30A70000, | ||
167 | + FSL_IMX7_UART4_ADDR = 0x30A60000, | ||
168 | + | ||
169 | + FSL_IMX7_I2C4_ADDR = 0x30A50000, | ||
170 | + FSL_IMX7_I2C3_ADDR = 0x30A40000, | ||
171 | + FSL_IMX7_I2C2_ADDR = 0x30A30000, | ||
172 | + FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
173 | + | ||
174 | + FSL_IMX7_CAN2_ADDR = 0x30A10000, | ||
175 | + FSL_IMX7_CAN1_ADDR = 0x30A00000, | ||
176 | + FSL_IMX7_CANn_SIZE = (4 * KiB), | ||
177 | + | ||
178 | + FSL_IMX7_AIPS3_CONF_ADDR = 0x309F0000, | ||
179 | + FSL_IMX7_AIPS3_CONF_SIZE = (64 * KiB), | ||
180 | |||
181 | FSL_IMX7_CAAM_ADDR = 0x30900000, | ||
182 | - FSL_IMX7_CAAM_SIZE = 0x40000, | ||
183 | + FSL_IMX7_CAAM_SIZE = (256 * KiB), | ||
184 | |||
185 | - FSL_IMX7_CAN1_ADDR = 0x30A00000, | ||
186 | - FSL_IMX7_CAN2_ADDR = 0x30A10000, | ||
187 | - FSL_IMX7_CANn_SIZE = 0x10000, | ||
188 | + FSL_IMX7_SPBA_ADDR = 0x308F0000, | ||
189 | + FSL_IMX7_SPBA_SIZE = (4 * KiB), | ||
190 | |||
191 | - FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
192 | - FSL_IMX7_I2C2_ADDR = 0x30A30000, | ||
193 | - FSL_IMX7_I2C3_ADDR = 0x30A40000, | ||
194 | - FSL_IMX7_I2C4_ADDR = 0x30A50000, | ||
195 | + FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
196 | + FSL_IMX7_SAI2_ADDR = 0x308B0000, | ||
197 | + FSL_IMX7_SAI1_ADDR = 0x308A0000, | ||
198 | + FSL_IMX7_SAIn_SIZE = (4 * KiB), | ||
199 | |||
200 | - FSL_IMX7_ECSPI1_ADDR = 0x30820000, | ||
201 | - FSL_IMX7_ECSPI2_ADDR = 0x30830000, | ||
202 | - FSL_IMX7_ECSPI3_ADDR = 0x30840000, | ||
203 | - FSL_IMX7_ECSPI4_ADDR = 0x30630000, | ||
204 | - | ||
205 | - FSL_IMX7_LCDIF_ADDR = 0x30730000, | ||
206 | - FSL_IMX7_LCDIF_SIZE = 0x1000, | ||
207 | - | ||
208 | - FSL_IMX7_UART1_ADDR = 0x30860000, | ||
209 | + FSL_IMX7_UART3_ADDR = 0x30880000, | ||
210 | /* | ||
211 | * Some versions of the reference manual claim that UART2 is @ | ||
212 | * 0x30870000, but experiments with HW + DT files in upstream | ||
213 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
214 | * actually located @ 0x30890000 | ||
215 | */ | ||
216 | FSL_IMX7_UART2_ADDR = 0x30890000, | ||
217 | - FSL_IMX7_UART3_ADDR = 0x30880000, | ||
218 | - FSL_IMX7_UART4_ADDR = 0x30A60000, | ||
219 | - FSL_IMX7_UART5_ADDR = 0x30A70000, | ||
220 | - FSL_IMX7_UART6_ADDR = 0x30A80000, | ||
221 | - FSL_IMX7_UART7_ADDR = 0x30A90000, | ||
222 | + FSL_IMX7_UART1_ADDR = 0x30860000, | ||
223 | |||
224 | - FSL_IMX7_SAI1_ADDR = 0x308A0000, | ||
225 | - FSL_IMX7_SAI2_ADDR = 0x308B0000, | ||
226 | - FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
227 | - FSL_IMX7_SAIn_SIZE = 0x10000, | ||
228 | + FSL_IMX7_ECSPI3_ADDR = 0x30840000, | ||
229 | + FSL_IMX7_ECSPI2_ADDR = 0x30830000, | ||
230 | + FSL_IMX7_ECSPI1_ADDR = 0x30820000, | ||
231 | + FSL_IMX7_ECSPIn_SIZE = (4 * KiB), | ||
232 | |||
233 | - FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
234 | - FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
235 | + /* AIPS-3 End */ | ||
236 | |||
237 | - FSL_IMX7_USB1_ADDR = 0x30B10000, | ||
238 | - FSL_IMX7_USBMISC1_ADDR = 0x30B10200, | ||
239 | - FSL_IMX7_USB2_ADDR = 0x30B20000, | ||
240 | - FSL_IMX7_USBMISC2_ADDR = 0x30B20200, | ||
241 | - FSL_IMX7_USB3_ADDR = 0x30B30000, | ||
242 | - FSL_IMX7_USBMISC3_ADDR = 0x30B30200, | ||
243 | - FSL_IMX7_USBMISCn_SIZE = 0x200, | ||
244 | + /* AIPS-2 Begin */ | ||
245 | |||
246 | - FSL_IMX7_USDHC1_ADDR = 0x30B40000, | ||
247 | - FSL_IMX7_USDHC2_ADDR = 0x30B50000, | ||
248 | - FSL_IMX7_USDHC3_ADDR = 0x30B60000, | ||
249 | + FSL_IMX7_AXI_DEBUG_MON_ADDR = 0x307E0000, | ||
250 | + FSL_IMX7_AXI_DEBUG_MON_SIZE = (64 * KiB), | ||
251 | |||
252 | - FSL_IMX7_SDMA_ADDR = 0x30BD0000, | ||
253 | - FSL_IMX7_SDMA_SIZE = 0x1000, | ||
254 | + FSL_IMX7_PERFMON2_ADDR = 0x307D0000, | ||
255 | + FSL_IMX7_PERFMON1_ADDR = 0x307C0000, | ||
256 | + FSL_IMX7_PERFMONn_SIZE = (64 * KiB), | ||
257 | + | ||
258 | + FSL_IMX7_DDRC_ADDR = 0x307A0000, | ||
259 | + FSL_IMX7_DDRC_SIZE = (4 * KiB), | ||
260 | + | ||
261 | + FSL_IMX7_DDRC_PHY_ADDR = 0x30790000, | ||
262 | + FSL_IMX7_DDRC_PHY_SIZE = (4 * KiB), | ||
263 | + | ||
264 | + FSL_IMX7_TZASC_ADDR = 0x30780000, | ||
265 | + FSL_IMX7_TZASC_SIZE = (64 * KiB), | ||
266 | + | ||
267 | + FSL_IMX7_MIPI_DSI_ADDR = 0x30760000, | ||
268 | + FSL_IMX7_MIPI_DSI_SIZE = (4 * KiB), | ||
269 | + | ||
270 | + FSL_IMX7_MIPI_CSI_ADDR = 0x30750000, | ||
271 | + FSL_IMX7_MIPI_CSI_SIZE = 0x4000, | ||
272 | + | ||
273 | + FSL_IMX7_LCDIF_ADDR = 0x30730000, | ||
274 | + FSL_IMX7_LCDIF_SIZE = 0x8000, | ||
275 | + | ||
276 | + FSL_IMX7_CSI_ADDR = 0x30710000, | ||
277 | + FSL_IMX7_CSI_SIZE = (4 * KiB), | ||
278 | + | ||
279 | + FSL_IMX7_PXP_ADDR = 0x30700000, | ||
280 | + FSL_IMX7_PXP_SIZE = 0x4000, | ||
281 | + | ||
282 | + FSL_IMX7_EPDC_ADDR = 0x306F0000, | ||
283 | + FSL_IMX7_EPDC_SIZE = (4 * KiB), | ||
284 | + | ||
285 | + FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
286 | + FSL_IMX7_PCIE_PHY_SIZE = (4 * KiB), | ||
287 | + | ||
288 | + FSL_IMX7_SYSCNT_CTRL_ADDR = 0x306C0000, | ||
289 | + FSL_IMX7_SYSCNT_CMP_ADDR = 0x306B0000, | ||
290 | + FSL_IMX7_SYSCNT_RD_ADDR = 0x306A0000, | ||
291 | + | ||
292 | + FSL_IMX7_PWM4_ADDR = 0x30690000, | ||
293 | + FSL_IMX7_PWM3_ADDR = 0x30680000, | ||
294 | + FSL_IMX7_PWM2_ADDR = 0x30670000, | ||
295 | + FSL_IMX7_PWM1_ADDR = 0x30660000, | ||
296 | + FSL_IMX7_PWMn_SIZE = (4 * KiB), | ||
297 | + | ||
298 | + FSL_IMX7_FlEXTIMER2_ADDR = 0x30650000, | ||
299 | + FSL_IMX7_FlEXTIMER1_ADDR = 0x30640000, | ||
300 | + FSL_IMX7_FLEXTIMERn_SIZE = (4 * KiB), | ||
301 | + | ||
302 | + FSL_IMX7_ECSPI4_ADDR = 0x30630000, | ||
303 | + | ||
304 | + FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
305 | + FSL_IMX7_ADC1_ADDR = 0x30610000, | ||
306 | + FSL_IMX7_ADCn_SIZE = (4 * KiB), | ||
307 | + | ||
308 | + FSL_IMX7_AIPS2_CONF_ADDR = 0x305F0000, | ||
309 | + FSL_IMX7_AIPS2_CONF_SIZE = (64 * KiB), | ||
310 | + | ||
311 | + /* AIPS-2 End */ | ||
312 | + | ||
313 | + /* AIPS-1 Begin */ | ||
314 | + | ||
315 | + FSL_IMX7_CSU_ADDR = 0x303E0000, | ||
316 | + FSL_IMX7_CSU_SIZE = (64 * KiB), | ||
317 | + | ||
318 | + FSL_IMX7_RDC_ADDR = 0x303D0000, | ||
319 | + FSL_IMX7_RDC_SIZE = (4 * KiB), | ||
320 | + | ||
321 | + FSL_IMX7_SEMAPHORE2_ADDR = 0x303C0000, | ||
322 | + FSL_IMX7_SEMAPHORE1_ADDR = 0x303B0000, | ||
323 | + FSL_IMX7_SEMAPHOREn_SIZE = (4 * KiB), | ||
324 | + | ||
325 | + FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
326 | + | ||
327 | + FSL_IMX7_SRC_ADDR = 0x30390000, | ||
328 | + FSL_IMX7_SRC_SIZE = (4 * KiB), | ||
329 | + | ||
330 | + FSL_IMX7_CCM_ADDR = 0x30380000, | ||
331 | + | ||
332 | + FSL_IMX7_SNVS_HP_ADDR = 0x30370000, | ||
333 | + | ||
334 | + FSL_IMX7_ANALOG_ADDR = 0x30360000, | ||
335 | + | ||
336 | + FSL_IMX7_OCOTP_ADDR = 0x30350000, | ||
337 | + FSL_IMX7_OCOTP_SIZE = 0x10000, | ||
338 | + | ||
339 | + FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000, | ||
340 | + FSL_IMX7_IOMUXC_GPR_SIZE = (4 * KiB), | ||
341 | + | ||
342 | + FSL_IMX7_IOMUXC_ADDR = 0x30330000, | ||
343 | + FSL_IMX7_IOMUXC_SIZE = (4 * KiB), | ||
344 | + | ||
345 | + FSL_IMX7_KPP_ADDR = 0x30320000, | ||
346 | + FSL_IMX7_KPP_SIZE = (4 * KiB), | ||
347 | + | ||
348 | + FSL_IMX7_ROMCP_ADDR = 0x30310000, | ||
349 | + FSL_IMX7_ROMCP_SIZE = (4 * KiB), | ||
350 | + | ||
351 | + FSL_IMX7_GPT4_ADDR = 0x30300000, | ||
352 | + FSL_IMX7_GPT3_ADDR = 0x302F0000, | ||
353 | + FSL_IMX7_GPT2_ADDR = 0x302E0000, | ||
354 | + FSL_IMX7_GPT1_ADDR = 0x302D0000, | ||
355 | + | ||
356 | + FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000, | ||
357 | + FSL_IMX7_IOMUXC_LPSR_SIZE = (4 * KiB), | ||
358 | + | ||
359 | + FSL_IMX7_WDOG4_ADDR = 0x302B0000, | ||
360 | + FSL_IMX7_WDOG3_ADDR = 0x302A0000, | ||
361 | + FSL_IMX7_WDOG2_ADDR = 0x30290000, | ||
362 | + FSL_IMX7_WDOG1_ADDR = 0x30280000, | ||
363 | + | ||
364 | + FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000, | ||
365 | + | ||
366 | + FSL_IMX7_GPIO7_ADDR = 0x30260000, | ||
367 | + FSL_IMX7_GPIO6_ADDR = 0x30250000, | ||
368 | + FSL_IMX7_GPIO5_ADDR = 0x30240000, | ||
369 | + FSL_IMX7_GPIO4_ADDR = 0x30230000, | ||
370 | + FSL_IMX7_GPIO3_ADDR = 0x30220000, | ||
371 | + FSL_IMX7_GPIO2_ADDR = 0x30210000, | ||
372 | + FSL_IMX7_GPIO1_ADDR = 0x30200000, | ||
373 | + | ||
374 | + FSL_IMX7_AIPS1_CONF_ADDR = 0x301F0000, | ||
375 | + FSL_IMX7_AIPS1_CONF_SIZE = (64 * KiB), | ||
376 | |||
377 | - FSL_IMX7_A7MPCORE_ADDR = 0x31000000, | ||
378 | FSL_IMX7_A7MPCORE_DAP_ADDR = 0x30000000, | ||
379 | + FSL_IMX7_A7MPCORE_DAP_SIZE = (1 * MiB), | ||
380 | |||
381 | - FSL_IMX7_PCIE_REG_ADDR = 0x33800000, | ||
382 | - FSL_IMX7_PCIE_REG_SIZE = 16 * 1024, | ||
383 | + /* AIPS-1 End */ | ||
384 | |||
385 | - FSL_IMX7_GPR_ADDR = 0x30340000, | ||
386 | + FSL_IMX7_EIM_CS0_ADDR = 0x28000000, | ||
387 | + FSL_IMX7_EIM_CS0_SIZE = (128 * MiB), | ||
388 | |||
389 | - FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | ||
390 | - FSL_IMX7_DMA_APBH_SIZE = 0x2000, | ||
391 | + FSL_IMX7_OCRAM_PXP_ADDR = 0x00940000, | ||
392 | + FSL_IMX7_OCRAM_PXP_SIZE = (32 * KiB), | ||
393 | + | ||
394 | + FSL_IMX7_OCRAM_EPDC_ADDR = 0x00920000, | ||
395 | + FSL_IMX7_OCRAM_EPDC_SIZE = (128 * KiB), | ||
396 | + | ||
397 | + FSL_IMX7_OCRAM_MEM_ADDR = 0x00900000, | ||
398 | + FSL_IMX7_OCRAM_MEM_SIZE = (128 * KiB), | ||
399 | + | ||
400 | + FSL_IMX7_TCMU_ADDR = 0x00800000, | ||
401 | + FSL_IMX7_TCMU_SIZE = (32 * KiB), | ||
402 | + | ||
403 | + FSL_IMX7_TCML_ADDR = 0x007F8000, | ||
404 | + FSL_IMX7_TCML_SIZE = (32 * KiB), | ||
405 | + | ||
406 | + FSL_IMX7_OCRAM_S_ADDR = 0x00180000, | ||
407 | + FSL_IMX7_OCRAM_S_SIZE = (32 * KiB), | ||
408 | + | ||
409 | + FSL_IMX7_CAAM_MEM_ADDR = 0x00100000, | ||
410 | + FSL_IMX7_CAAM_MEM_SIZE = (32 * KiB), | ||
411 | + | ||
412 | + FSL_IMX7_ROM_ADDR = 0x00000000, | ||
413 | + FSL_IMX7_ROM_SIZE = (96 * KiB), | ||
414 | }; | ||
415 | |||
416 | enum FslIMX7IRQs { | ||
417 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 418 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/hw/display/tc6393xb.c | 419 | --- a/hw/arm/fsl-imx7.c |
34 | +++ b/hw/display/tc6393xb.c | 420 | +++ b/hw/arm/fsl-imx7.c |
35 | @@ -XXX,XX +XXX,XX @@ struct TC6393xbState { | 421 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) |
36 | blanked : 1; | 422 | char name[NAME_SIZE]; |
37 | }; | 423 | int i; |
38 | 424 | ||
39 | -qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s) | 425 | + /* |
40 | -{ | 426 | + * CPUs |
41 | - return s->gpio_in; | 427 | + */ |
42 | -} | 428 | for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX7_NUM_CPUS); i++) { |
429 | snprintf(name, NAME_SIZE, "cpu%d", i); | ||
430 | object_initialize_child(obj, name, &s->cpu[i], | ||
431 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
432 | TYPE_A15MPCORE_PRIV); | ||
433 | |||
434 | /* | ||
435 | - * GPIOs 1 to 7 | ||
436 | + * GPIOs | ||
437 | */ | ||
438 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { | ||
439 | snprintf(name, NAME_SIZE, "gpio%d", i); | ||
440 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
441 | } | ||
442 | |||
443 | /* | ||
444 | - * GPT1, 2, 3, 4 | ||
445 | + * GPTs | ||
446 | */ | ||
447 | for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) { | ||
448 | snprintf(name, NAME_SIZE, "gpt%d", i); | ||
449 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
450 | */ | ||
451 | object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2); | ||
452 | |||
453 | + /* | ||
454 | + * ECSPIs | ||
455 | + */ | ||
456 | for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) { | ||
457 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | ||
458 | object_initialize_child(obj, name, &s->spi[i], TYPE_IMX_SPI); | ||
459 | } | ||
460 | |||
43 | - | 461 | - |
44 | static void tc6393xb_gpio_set(void *opaque, int line, int level) | 462 | + /* |
45 | { | 463 | + * I2Cs |
46 | // TC6393xbState *s = opaque; | 464 | + */ |
47 | @@ -XXX,XX +XXX,XX @@ static void tc6393xb_gpio_set(void *opaque, int line, int level) | 465 | for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) { |
48 | // FIXME: how does the chip reflect the GPIO input level change? | 466 | snprintf(name, NAME_SIZE, "i2c%d", i + 1); |
467 | object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C); | ||
468 | } | ||
469 | |||
470 | /* | ||
471 | - * UART | ||
472 | + * UARTs | ||
473 | */ | ||
474 | for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) { | ||
475 | snprintf(name, NAME_SIZE, "uart%d", i); | ||
476 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
477 | } | ||
478 | |||
479 | /* | ||
480 | - * Ethernet | ||
481 | + * Ethernets | ||
482 | */ | ||
483 | for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) { | ||
484 | snprintf(name, NAME_SIZE, "eth%d", i); | ||
485 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | - * SDHCI | ||
490 | + * SDHCIs | ||
491 | */ | ||
492 | for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { | ||
493 | snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
494 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
495 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
496 | |||
497 | /* | ||
498 | - * Watchdog | ||
499 | + * Watchdogs | ||
500 | */ | ||
501 | for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) { | ||
502 | snprintf(name, NAME_SIZE, "wdt%d", i); | ||
503 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
504 | */ | ||
505 | object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR); | ||
506 | |||
507 | + /* | ||
508 | + * PCIE | ||
509 | + */ | ||
510 | object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST); | ||
511 | |||
512 | + /* | ||
513 | + * USBs | ||
514 | + */ | ||
515 | for (i = 0; i < FSL_IMX7_NUM_USBS; i++) { | ||
516 | snprintf(name, NAME_SIZE, "usb%d", i); | ||
517 | object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA); | ||
518 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
519 | return; | ||
520 | } | ||
521 | |||
522 | + /* | ||
523 | + * CPUs | ||
524 | + */ | ||
525 | for (i = 0; i < smp_cpus; i++) { | ||
526 | o = OBJECT(&s->cpu[i]); | ||
527 | |||
528 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
529 | * A7MPCORE DAP | ||
530 | */ | ||
531 | create_unimplemented_device("a7mpcore-dap", FSL_IMX7_A7MPCORE_DAP_ADDR, | ||
532 | - 0x100000); | ||
533 | + FSL_IMX7_A7MPCORE_DAP_SIZE); | ||
534 | |||
535 | /* | ||
536 | - * GPT1, 2, 3, 4 | ||
537 | + * GPTs | ||
538 | */ | ||
539 | for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) { | ||
540 | static const hwaddr FSL_IMX7_GPTn_ADDR[FSL_IMX7_NUM_GPTS] = { | ||
541 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
542 | FSL_IMX7_GPTn_IRQ[i])); | ||
543 | } | ||
544 | |||
545 | + /* | ||
546 | + * GPIOs | ||
547 | + */ | ||
548 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { | ||
549 | static const hwaddr FSL_IMX7_GPIOn_ADDR[FSL_IMX7_NUM_GPIOS] = { | ||
550 | FSL_IMX7_GPIO1_ADDR, | ||
551 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
552 | /* | ||
553 | * IOMUXC and IOMUXC_LPSR | ||
554 | */ | ||
555 | - for (i = 0; i < FSL_IMX7_NUM_IOMUXCS; i++) { | ||
556 | - static const hwaddr FSL_IMX7_IOMUXCn_ADDR[FSL_IMX7_NUM_IOMUXCS] = { | ||
557 | - FSL_IMX7_IOMUXC_ADDR, | ||
558 | - FSL_IMX7_IOMUXC_LPSR_ADDR, | ||
559 | - }; | ||
560 | - | ||
561 | - snprintf(name, NAME_SIZE, "iomuxc%d", i); | ||
562 | - create_unimplemented_device(name, FSL_IMX7_IOMUXCn_ADDR[i], | ||
563 | - FSL_IMX7_IOMUXCn_SIZE); | ||
564 | - } | ||
565 | + create_unimplemented_device("iomuxc", FSL_IMX7_IOMUXC_ADDR, | ||
566 | + FSL_IMX7_IOMUXC_SIZE); | ||
567 | + create_unimplemented_device("iomuxc_lspr", FSL_IMX7_IOMUXC_LPSR_ADDR, | ||
568 | + FSL_IMX7_IOMUXC_LPSR_SIZE); | ||
569 | |||
570 | /* | ||
571 | * CCM | ||
572 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
573 | sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort); | ||
574 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX7_GPC_ADDR); | ||
575 | |||
576 | - /* Initialize all ECSPI */ | ||
577 | + /* | ||
578 | + * ECSPIs | ||
579 | + */ | ||
580 | for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) { | ||
581 | static const hwaddr FSL_IMX7_SPIn_ADDR[FSL_IMX7_NUM_ECSPIS] = { | ||
582 | FSL_IMX7_ECSPI1_ADDR, | ||
583 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
584 | FSL_IMX7_SPIn_IRQ[i])); | ||
585 | } | ||
586 | |||
587 | + /* | ||
588 | + * I2Cs | ||
589 | + */ | ||
590 | for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) { | ||
591 | static const hwaddr FSL_IMX7_I2Cn_ADDR[FSL_IMX7_NUM_I2CS] = { | ||
592 | FSL_IMX7_I2C1_ADDR, | ||
593 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
594 | } | ||
595 | |||
596 | /* | ||
597 | - * UART | ||
598 | + * UARTs | ||
599 | */ | ||
600 | for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) { | ||
601 | static const hwaddr FSL_IMX7_UARTn_ADDR[FSL_IMX7_NUM_UARTS] = { | ||
602 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
603 | } | ||
604 | |||
605 | /* | ||
606 | - * Ethernet | ||
607 | + * Ethernets | ||
608 | * | ||
609 | * We must use two loops since phy_connected affects the other interface | ||
610 | * and we have to set all properties before calling sysbus_realize(). | ||
611 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
612 | } | ||
613 | |||
614 | /* | ||
615 | - * USDHC | ||
616 | + * USDHCs | ||
617 | */ | ||
618 | for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { | ||
619 | static const hwaddr FSL_IMX7_USDHCn_ADDR[FSL_IMX7_NUM_USDHCS] = { | ||
620 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
621 | * SNVS | ||
622 | */ | ||
623 | sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort); | ||
624 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_ADDR); | ||
625 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_HP_ADDR); | ||
626 | |||
627 | /* | ||
628 | * SRC | ||
629 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
630 | create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE); | ||
631 | |||
632 | /* | ||
633 | - * Watchdog | ||
634 | + * Watchdogs | ||
635 | */ | ||
636 | for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) { | ||
637 | static const hwaddr FSL_IMX7_WDOGn_ADDR[FSL_IMX7_NUM_WDTS] = { | ||
638 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
639 | create_unimplemented_device("caam", FSL_IMX7_CAAM_ADDR, FSL_IMX7_CAAM_SIZE); | ||
640 | |||
641 | /* | ||
642 | - * PWM | ||
643 | + * PWMs | ||
644 | */ | ||
645 | - create_unimplemented_device("pwm1", FSL_IMX7_PWM1_ADDR, FSL_IMX7_PWMn_SIZE); | ||
646 | - create_unimplemented_device("pwm2", FSL_IMX7_PWM2_ADDR, FSL_IMX7_PWMn_SIZE); | ||
647 | - create_unimplemented_device("pwm3", FSL_IMX7_PWM3_ADDR, FSL_IMX7_PWMn_SIZE); | ||
648 | - create_unimplemented_device("pwm4", FSL_IMX7_PWM4_ADDR, FSL_IMX7_PWMn_SIZE); | ||
649 | + for (i = 0; i < FSL_IMX7_NUM_PWMS; i++) { | ||
650 | + static const hwaddr FSL_IMX7_PWMn_ADDR[FSL_IMX7_NUM_PWMS] = { | ||
651 | + FSL_IMX7_PWM1_ADDR, | ||
652 | + FSL_IMX7_PWM2_ADDR, | ||
653 | + FSL_IMX7_PWM3_ADDR, | ||
654 | + FSL_IMX7_PWM4_ADDR, | ||
655 | + }; | ||
656 | + | ||
657 | + snprintf(name, NAME_SIZE, "pwm%d", i); | ||
658 | + create_unimplemented_device(name, FSL_IMX7_PWMn_ADDR[i], | ||
659 | + FSL_IMX7_PWMn_SIZE); | ||
660 | + } | ||
661 | |||
662 | /* | ||
663 | - * CAN | ||
664 | + * CANs | ||
665 | */ | ||
666 | - create_unimplemented_device("can1", FSL_IMX7_CAN1_ADDR, FSL_IMX7_CANn_SIZE); | ||
667 | - create_unimplemented_device("can2", FSL_IMX7_CAN2_ADDR, FSL_IMX7_CANn_SIZE); | ||
668 | + for (i = 0; i < FSL_IMX7_NUM_CANS; i++) { | ||
669 | + static const hwaddr FSL_IMX7_CANn_ADDR[FSL_IMX7_NUM_CANS] = { | ||
670 | + FSL_IMX7_CAN1_ADDR, | ||
671 | + FSL_IMX7_CAN2_ADDR, | ||
672 | + }; | ||
673 | + | ||
674 | + snprintf(name, NAME_SIZE, "can%d", i); | ||
675 | + create_unimplemented_device(name, FSL_IMX7_CANn_ADDR[i], | ||
676 | + FSL_IMX7_CANn_SIZE); | ||
677 | + } | ||
678 | |||
679 | /* | ||
680 | - * SAI (Audio SSI (Synchronous Serial Interface)) | ||
681 | + * SAIs (Audio SSI (Synchronous Serial Interface)) | ||
682 | */ | ||
683 | - create_unimplemented_device("sai1", FSL_IMX7_SAI1_ADDR, FSL_IMX7_SAIn_SIZE); | ||
684 | - create_unimplemented_device("sai2", FSL_IMX7_SAI2_ADDR, FSL_IMX7_SAIn_SIZE); | ||
685 | - create_unimplemented_device("sai2", FSL_IMX7_SAI3_ADDR, FSL_IMX7_SAIn_SIZE); | ||
686 | + for (i = 0; i < FSL_IMX7_NUM_SAIS; i++) { | ||
687 | + static const hwaddr FSL_IMX7_SAIn_ADDR[FSL_IMX7_NUM_SAIS] = { | ||
688 | + FSL_IMX7_SAI1_ADDR, | ||
689 | + FSL_IMX7_SAI2_ADDR, | ||
690 | + FSL_IMX7_SAI3_ADDR, | ||
691 | + }; | ||
692 | + | ||
693 | + snprintf(name, NAME_SIZE, "sai%d", i); | ||
694 | + create_unimplemented_device(name, FSL_IMX7_SAIn_ADDR[i], | ||
695 | + FSL_IMX7_SAIn_SIZE); | ||
696 | + } | ||
697 | |||
698 | /* | ||
699 | * OCOTP | ||
700 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
701 | create_unimplemented_device("ocotp", FSL_IMX7_OCOTP_ADDR, | ||
702 | FSL_IMX7_OCOTP_SIZE); | ||
703 | |||
704 | + /* | ||
705 | + * GPR | ||
706 | + */ | ||
707 | sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort); | ||
708 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_GPR_ADDR); | ||
709 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_IOMUXC_GPR_ADDR); | ||
710 | |||
711 | + /* | ||
712 | + * PCIE | ||
713 | + */ | ||
714 | sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort); | ||
715 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX7_PCIE_REG_ADDR); | ||
716 | |||
717 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
718 | irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_IRQ); | ||
719 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq); | ||
720 | |||
721 | - | ||
722 | + /* | ||
723 | + * USBs | ||
724 | + */ | ||
725 | for (i = 0; i < FSL_IMX7_NUM_USBS; i++) { | ||
726 | static const hwaddr FSL_IMX7_USBMISCn_ADDR[FSL_IMX7_NUM_USBS] = { | ||
727 | FSL_IMX7_USBMISC1_ADDR, | ||
728 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
729 | */ | ||
730 | create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, | ||
731 | FSL_IMX7_PCIE_PHY_SIZE); | ||
732 | + | ||
49 | } | 733 | } |
50 | 734 | ||
51 | -void tc6393xb_gpio_out_set(TC6393xbState *s, int line, | 735 | static Property fsl_imx7_properties[] = { |
52 | - qemu_irq handler) | ||
53 | -{ | ||
54 | - if (line >= TC6393XB_GPIOS) { | ||
55 | - fprintf(stderr, "TC6393xb: no GPIO pin %d\n", line); | ||
56 | - return; | ||
57 | - } | ||
58 | - | ||
59 | - s->handler[line] = handler; | ||
60 | -} | ||
61 | - | ||
62 | static void tc6393xb_gpio_handler_update(TC6393xbState *s) | ||
63 | { | ||
64 | uint32_t level, diff; | ||
65 | -- | 736 | -- |
66 | 2.20.1 | 737 | 2.34.1 |
67 | |||
68 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 3 | * Add TZASC as unimplemented device. |
4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 4 | - Allow bare metal application to access this (unimplemented) device |
5 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 5 | * Add CSU as unimplemented device. |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | - Allow bare metal application to access this (unimplemented) device |
7 | Message-id: 20190412165416.7977-2-philmd@redhat.com | 7 | * Add various memory segments |
8 | - OCRAM | ||
9 | - OCRAM EPDC | ||
10 | - OCRAM PXP | ||
11 | - OCRAM S | ||
12 | - ROM | ||
13 | - CAAM | ||
14 | |||
15 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
17 | Message-id: f887a3483996ba06d40bd62ffdfb0ecf68621987.1692964892.git.jcd@tribudubois.net | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 19 | --- |
10 | hw/arm/aspeed.c | 13 +++++++++---- | 20 | include/hw/arm/fsl-imx7.h | 7 +++++ |
11 | 1 file changed, 9 insertions(+), 4 deletions(-) | 21 | hw/arm/fsl-imx7.c | 63 +++++++++++++++++++++++++++++++++++++++ |
22 | 2 files changed, 70 insertions(+) | ||
12 | 23 | ||
13 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 24 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
14 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/aspeed.c | 26 | --- a/include/hw/arm/fsl-imx7.h |
16 | +++ b/hw/arm/aspeed.c | 27 | +++ b/include/hw/arm/fsl-imx7.h |
17 | @@ -XXX,XX +XXX,XX @@ | 28 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { |
18 | #include "hw/arm/aspeed_soc.h" | 29 | IMX7GPRState gpr; |
19 | #include "hw/boards.h" | 30 | ChipideaState usb[FSL_IMX7_NUM_USBS]; |
20 | #include "hw/i2c/smbus_eeprom.h" | 31 | DesignwarePCIEHost pcie; |
21 | +#include "hw/misc/pca9552.h" | 32 | + MemoryRegion rom; |
22 | +#include "hw/misc/tmp105.h" | 33 | + MemoryRegion caam; |
23 | #include "qemu/log.h" | 34 | + MemoryRegion ocram; |
24 | #include "sysemu/block-backend.h" | 35 | + MemoryRegion ocram_epdc; |
25 | #include "hw/loader.h" | 36 | + MemoryRegion ocram_pxp; |
26 | @@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) | 37 | + MemoryRegion ocram_s; |
27 | eeprom_buf); | 38 | + |
28 | 39 | uint32_t phy_num[FSL_IMX7_NUM_ETHS]; | |
29 | /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ | 40 | bool phy_connected[FSL_IMX7_NUM_ETHS]; |
30 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d); | 41 | }; |
31 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), | 42 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c |
32 | + TYPE_TMP105, 0x4d); | 43 | index XXXXXXX..XXXXXXX 100644 |
33 | 44 | --- a/hw/arm/fsl-imx7.c | |
34 | /* The AST2500 EVB does not have an RTC. Let's pretend that one is | 45 | +++ b/hw/arm/fsl-imx7.c |
35 | * plugged on the I2C bus header */ | 46 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
36 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | 47 | create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, |
37 | AspeedSoCState *soc = &bmc->soc; | 48 | FSL_IMX7_PCIE_PHY_SIZE); |
38 | uint8_t *eeprom_buf = g_malloc0(8 * 1024); | 49 | |
39 | 50 | + /* | |
40 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); | 51 | + * CSU |
41 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552, | 52 | + */ |
42 | + 0x60); | 53 | + create_unimplemented_device("csu", FSL_IMX7_CSU_ADDR, |
43 | 54 | + FSL_IMX7_CSU_SIZE); | |
44 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c); | 55 | + |
45 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c); | 56 | + /* |
46 | 57 | + * TZASC | |
47 | /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ | 58 | + */ |
48 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a); | 59 | + create_unimplemented_device("tzasc", FSL_IMX7_TZASC_ADDR, |
49 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105, | 60 | + FSL_IMX7_TZASC_SIZE); |
50 | + 0x4a); | 61 | + |
51 | 62 | + /* | |
52 | /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is | 63 | + * OCRAM memory |
53 | * good enough */ | 64 | + */ |
54 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | 65 | + memory_region_init_ram(&s->ocram, NULL, "imx7.ocram", |
55 | 66 | + FSL_IMX7_OCRAM_MEM_SIZE, | |
56 | smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51, | 67 | + &error_abort); |
57 | eeprom_buf); | 68 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_MEM_ADDR, |
58 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552", | 69 | + &s->ocram); |
59 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552, | 70 | + |
60 | 0x60); | 71 | + /* |
72 | + * OCRAM EPDC memory | ||
73 | + */ | ||
74 | + memory_region_init_ram(&s->ocram_epdc, NULL, "imx7.ocram_epdc", | ||
75 | + FSL_IMX7_OCRAM_EPDC_SIZE, | ||
76 | + &error_abort); | ||
77 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_EPDC_ADDR, | ||
78 | + &s->ocram_epdc); | ||
79 | + | ||
80 | + /* | ||
81 | + * OCRAM PXP memory | ||
82 | + */ | ||
83 | + memory_region_init_ram(&s->ocram_pxp, NULL, "imx7.ocram_pxp", | ||
84 | + FSL_IMX7_OCRAM_PXP_SIZE, | ||
85 | + &error_abort); | ||
86 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_PXP_ADDR, | ||
87 | + &s->ocram_pxp); | ||
88 | + | ||
89 | + /* | ||
90 | + * OCRAM_S memory | ||
91 | + */ | ||
92 | + memory_region_init_ram(&s->ocram_s, NULL, "imx7.ocram_s", | ||
93 | + FSL_IMX7_OCRAM_S_SIZE, | ||
94 | + &error_abort); | ||
95 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_S_ADDR, | ||
96 | + &s->ocram_s); | ||
97 | + | ||
98 | + /* | ||
99 | + * ROM memory | ||
100 | + */ | ||
101 | + memory_region_init_rom(&s->rom, OBJECT(dev), "imx7.rom", | ||
102 | + FSL_IMX7_ROM_SIZE, &error_abort); | ||
103 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_ROM_ADDR, | ||
104 | + &s->rom); | ||
105 | + | ||
106 | + /* | ||
107 | + * CAAM memory | ||
108 | + */ | ||
109 | + memory_region_init_rom(&s->caam, OBJECT(dev), "imx7.caam", | ||
110 | + FSL_IMX7_CAAM_MEM_SIZE, &error_abort); | ||
111 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_CAAM_MEM_ADDR, | ||
112 | + &s->caam); | ||
61 | } | 113 | } |
62 | 114 | ||
115 | static Property fsl_imx7_properties[] = { | ||
63 | -- | 116 | -- |
64 | 2.20.1 | 117 | 2.34.1 |
65 | 118 | ||
66 | 119 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 3 | The SRC device is normally used to start the secondary CPU. |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | |
5 | Message-id: 20190412165416.7977-8-philmd@redhat.com | 5 | When running Linux directly, QEMU is emulating a PSCI interface that UBOOT |
6 | is installing at boot time and therefore the fact that the SRC device is | ||
7 | unimplemented is hidden as Qemu respond directly to PSCI requets without | ||
8 | using the SRC device. | ||
9 | |||
10 | But if you try to run a more bare metal application (maybe uboot itself), | ||
11 | then it is not possible to start the secondary CPU as the SRC is an | ||
12 | unimplemented device. | ||
13 | |||
14 | This patch adds the ability to start the secondary CPU through the SRC | ||
15 | device so that you can use this feature in bare metal applications. | ||
16 | |||
17 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Message-id: ce9a0162defd2acee5dc7f8a674743de0cded569.1692964892.git.jcd@tribudubois.net | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 21 | --- |
8 | include/hw/devices.h | 3 --- | 22 | include/hw/arm/fsl-imx7.h | 3 +- |
9 | include/hw/input/gamepad.h | 19 +++++++++++++++++++ | 23 | include/hw/misc/imx7_src.h | 66 +++++++++ |
10 | hw/arm/stellaris.c | 2 +- | 24 | hw/arm/fsl-imx7.c | 8 +- |
11 | hw/input/stellaris_input.c | 2 +- | 25 | hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++++++ |
12 | MAINTAINERS | 1 + | 26 | hw/misc/meson.build | 1 + |
13 | 5 files changed, 22 insertions(+), 5 deletions(-) | 27 | hw/misc/trace-events | 4 + |
14 | create mode 100644 include/hw/input/gamepad.h | 28 | 6 files changed, 356 insertions(+), 2 deletions(-) |
15 | 29 | create mode 100644 include/hw/misc/imx7_src.h | |
16 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 30 | create mode 100644 hw/misc/imx7_src.c |
31 | |||
32 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/devices.h | 34 | --- a/include/hw/arm/fsl-imx7.h |
19 | +++ b/include/hw/devices.h | 35 | +++ b/include/hw/arm/fsl-imx7.h |
20 | @@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav); | 36 | @@ -XXX,XX +XXX,XX @@ |
21 | uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | 37 | #include "hw/misc/imx7_ccm.h" |
22 | void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | 38 | #include "hw/misc/imx7_snvs.h" |
23 | 39 | #include "hw/misc/imx7_gpr.h" | |
24 | -/* stellaris_input.c */ | 40 | +#include "hw/misc/imx7_src.h" |
25 | -void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | 41 | #include "hw/watchdog/wdt_imx2.h" |
26 | - | 42 | #include "hw/gpio/imx_gpio.h" |
27 | #endif | 43 | #include "hw/char/imx_serial.h" |
28 | diff --git a/include/hw/input/gamepad.h b/include/hw/input/gamepad.h | 44 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { |
45 | IMX7CCMState ccm; | ||
46 | IMX7AnalogState analog; | ||
47 | IMX7SNVSState snvs; | ||
48 | + IMX7SRCState src; | ||
49 | IMXGPCv2State gpcv2; | ||
50 | IMXSPIState spi[FSL_IMX7_NUM_ECSPIS]; | ||
51 | IMXI2CState i2c[FSL_IMX7_NUM_I2CS]; | ||
52 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
53 | FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
54 | |||
55 | FSL_IMX7_SRC_ADDR = 0x30390000, | ||
56 | - FSL_IMX7_SRC_SIZE = (4 * KiB), | ||
57 | |||
58 | FSL_IMX7_CCM_ADDR = 0x30380000, | ||
59 | |||
60 | diff --git a/include/hw/misc/imx7_src.h b/include/hw/misc/imx7_src.h | ||
29 | new file mode 100644 | 61 | new file mode 100644 |
30 | index XXXXXXX..XXXXXXX | 62 | index XXXXXXX..XXXXXXX |
31 | --- /dev/null | 63 | --- /dev/null |
32 | +++ b/include/hw/input/gamepad.h | 64 | +++ b/include/hw/misc/imx7_src.h |
33 | @@ -XXX,XX +XXX,XX @@ | 65 | @@ -XXX,XX +XXX,XX @@ |
34 | +/* | 66 | +/* |
35 | + * Gamepad style buttons connected to IRQ/GPIO lines | 67 | + * IMX7 System Reset Controller |
36 | + * | 68 | + * |
37 | + * Copyright (c) 2007 CodeSourcery. | 69 | + * Copyright (C) 2023 Jean-Christophe Dubois <jcd@tribudubois.net> |
38 | + * Written by Paul Brook | ||
39 | + * | 70 | + * |
40 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 71 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
41 | + * See the COPYING file in the top-level directory. | 72 | + * See the COPYING file in the top-level directory. |
42 | + */ | 73 | + */ |
43 | + | 74 | + |
44 | +#ifndef HW_INPUT_GAMEPAD_H | 75 | +#ifndef IMX7_SRC_H |
45 | +#define HW_INPUT_GAMEPAD_H | 76 | +#define IMX7_SRC_H |
46 | + | 77 | + |
47 | +#include "hw/irq.h" | 78 | +#include "hw/sysbus.h" |
48 | + | 79 | +#include "qemu/bitops.h" |
49 | +/* stellaris_input.c */ | 80 | +#include "qom/object.h" |
50 | +void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | 81 | + |
51 | + | 82 | +#define SRC_SCR 0 |
52 | +#endif | 83 | +#define SRC_A7RCR0 1 |
53 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 84 | +#define SRC_A7RCR1 2 |
85 | +#define SRC_M4RCR 3 | ||
86 | +#define SRC_ERCR 5 | ||
87 | +#define SRC_HSICPHY_RCR 7 | ||
88 | +#define SRC_USBOPHY1_RCR 8 | ||
89 | +#define SRC_USBOPHY2_RCR 9 | ||
90 | +#define SRC_MPIPHY_RCR 10 | ||
91 | +#define SRC_PCIEPHY_RCR 11 | ||
92 | +#define SRC_SBMR1 22 | ||
93 | +#define SRC_SRSR 23 | ||
94 | +#define SRC_SISR 26 | ||
95 | +#define SRC_SIMR 27 | ||
96 | +#define SRC_SBMR2 28 | ||
97 | +#define SRC_GPR1 29 | ||
98 | +#define SRC_GPR2 30 | ||
99 | +#define SRC_GPR3 31 | ||
100 | +#define SRC_GPR4 32 | ||
101 | +#define SRC_GPR5 33 | ||
102 | +#define SRC_GPR6 34 | ||
103 | +#define SRC_GPR7 35 | ||
104 | +#define SRC_GPR8 36 | ||
105 | +#define SRC_GPR9 37 | ||
106 | +#define SRC_GPR10 38 | ||
107 | +#define SRC_MAX 39 | ||
108 | + | ||
109 | +/* SRC_A7SCR1 */ | ||
110 | +#define R_CORE1_ENABLE_SHIFT 1 | ||
111 | +#define R_CORE1_ENABLE_LENGTH 1 | ||
112 | +/* SRC_A7SCR0 */ | ||
113 | +#define R_CORE1_RST_SHIFT 5 | ||
114 | +#define R_CORE1_RST_LENGTH 1 | ||
115 | +#define R_CORE0_RST_SHIFT 4 | ||
116 | +#define R_CORE0_RST_LENGTH 1 | ||
117 | + | ||
118 | +#define TYPE_IMX7_SRC "imx7.src" | ||
119 | +OBJECT_DECLARE_SIMPLE_TYPE(IMX7SRCState, IMX7_SRC) | ||
120 | + | ||
121 | +struct IMX7SRCState { | ||
122 | + /* <private> */ | ||
123 | + SysBusDevice parent_obj; | ||
124 | + | ||
125 | + /* <public> */ | ||
126 | + MemoryRegion iomem; | ||
127 | + | ||
128 | + uint32_t regs[SRC_MAX]; | ||
129 | +}; | ||
130 | + | ||
131 | +#endif /* IMX7_SRC_H */ | ||
132 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | 133 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/hw/arm/stellaris.c | 134 | --- a/hw/arm/fsl-imx7.c |
56 | +++ b/hw/arm/stellaris.c | 135 | +++ b/hw/arm/fsl-imx7.c |
136 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
137 | */ | ||
138 | object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2); | ||
139 | |||
140 | + /* | ||
141 | + * SRC | ||
142 | + */ | ||
143 | + object_initialize_child(obj, "src", &s->src, TYPE_IMX7_SRC); | ||
144 | + | ||
145 | /* | ||
146 | * ECSPIs | ||
147 | */ | ||
148 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
149 | /* | ||
150 | * SRC | ||
151 | */ | ||
152 | - create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE); | ||
153 | + sysbus_realize(SYS_BUS_DEVICE(&s->src), &error_abort); | ||
154 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX7_SRC_ADDR); | ||
155 | |||
156 | /* | ||
157 | * Watchdogs | ||
158 | diff --git a/hw/misc/imx7_src.c b/hw/misc/imx7_src.c | ||
159 | new file mode 100644 | ||
160 | index XXXXXXX..XXXXXXX | ||
161 | --- /dev/null | ||
162 | +++ b/hw/misc/imx7_src.c | ||
57 | @@ -XXX,XX +XXX,XX @@ | 163 | @@ -XXX,XX +XXX,XX @@ |
58 | #include "hw/sysbus.h" | 164 | +/* |
59 | #include "hw/ssi/ssi.h" | 165 | + * IMX7 System Reset Controller |
60 | #include "hw/arm/arm.h" | 166 | + * |
61 | -#include "hw/devices.h" | 167 | + * Copyright (c) 2023 Jean-Christophe Dubois <jcd@tribudubois.net> |
62 | #include "qemu/timer.h" | 168 | + * |
63 | #include "hw/i2c/i2c.h" | 169 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
64 | #include "net/net.h" | 170 | + * See the COPYING file in the top-level directory. |
65 | @@ -XXX,XX +XXX,XX @@ | 171 | + * |
66 | #include "sysemu/sysemu.h" | 172 | + */ |
67 | #include "hw/arm/armv7m.h" | 173 | + |
68 | #include "hw/char/pl011.h" | 174 | +#include "qemu/osdep.h" |
69 | +#include "hw/input/gamepad.h" | 175 | +#include "hw/misc/imx7_src.h" |
70 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | 176 | +#include "migration/vmstate.h" |
71 | #include "hw/misc/unimp.h" | 177 | +#include "qemu/bitops.h" |
72 | #include "cpu.h" | 178 | +#include "qemu/log.h" |
73 | diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c | 179 | +#include "qemu/main-loop.h" |
180 | +#include "qemu/module.h" | ||
181 | +#include "target/arm/arm-powerctl.h" | ||
182 | +#include "hw/core/cpu.h" | ||
183 | +#include "hw/registerfields.h" | ||
184 | + | ||
185 | +#include "trace.h" | ||
186 | + | ||
187 | +static const char *imx7_src_reg_name(uint32_t reg) | ||
188 | +{ | ||
189 | + static char unknown[20]; | ||
190 | + | ||
191 | + switch (reg) { | ||
192 | + case SRC_SCR: | ||
193 | + return "SRC_SCR"; | ||
194 | + case SRC_A7RCR0: | ||
195 | + return "SRC_A7RCR0"; | ||
196 | + case SRC_A7RCR1: | ||
197 | + return "SRC_A7RCR1"; | ||
198 | + case SRC_M4RCR: | ||
199 | + return "SRC_M4RCR"; | ||
200 | + case SRC_ERCR: | ||
201 | + return "SRC_ERCR"; | ||
202 | + case SRC_HSICPHY_RCR: | ||
203 | + return "SRC_HSICPHY_RCR"; | ||
204 | + case SRC_USBOPHY1_RCR: | ||
205 | + return "SRC_USBOPHY1_RCR"; | ||
206 | + case SRC_USBOPHY2_RCR: | ||
207 | + return "SRC_USBOPHY2_RCR"; | ||
208 | + case SRC_PCIEPHY_RCR: | ||
209 | + return "SRC_PCIEPHY_RCR"; | ||
210 | + case SRC_SBMR1: | ||
211 | + return "SRC_SBMR1"; | ||
212 | + case SRC_SRSR: | ||
213 | + return "SRC_SRSR"; | ||
214 | + case SRC_SISR: | ||
215 | + return "SRC_SISR"; | ||
216 | + case SRC_SIMR: | ||
217 | + return "SRC_SIMR"; | ||
218 | + case SRC_SBMR2: | ||
219 | + return "SRC_SBMR2"; | ||
220 | + case SRC_GPR1: | ||
221 | + return "SRC_GPR1"; | ||
222 | + case SRC_GPR2: | ||
223 | + return "SRC_GPR2"; | ||
224 | + case SRC_GPR3: | ||
225 | + return "SRC_GPR3"; | ||
226 | + case SRC_GPR4: | ||
227 | + return "SRC_GPR4"; | ||
228 | + case SRC_GPR5: | ||
229 | + return "SRC_GPR5"; | ||
230 | + case SRC_GPR6: | ||
231 | + return "SRC_GPR6"; | ||
232 | + case SRC_GPR7: | ||
233 | + return "SRC_GPR7"; | ||
234 | + case SRC_GPR8: | ||
235 | + return "SRC_GPR8"; | ||
236 | + case SRC_GPR9: | ||
237 | + return "SRC_GPR9"; | ||
238 | + case SRC_GPR10: | ||
239 | + return "SRC_GPR10"; | ||
240 | + default: | ||
241 | + sprintf(unknown, "%u ?", reg); | ||
242 | + return unknown; | ||
243 | + } | ||
244 | +} | ||
245 | + | ||
246 | +static const VMStateDescription vmstate_imx7_src = { | ||
247 | + .name = TYPE_IMX7_SRC, | ||
248 | + .version_id = 1, | ||
249 | + .minimum_version_id = 1, | ||
250 | + .fields = (VMStateField[]) { | ||
251 | + VMSTATE_UINT32_ARRAY(regs, IMX7SRCState, SRC_MAX), | ||
252 | + VMSTATE_END_OF_LIST() | ||
253 | + }, | ||
254 | +}; | ||
255 | + | ||
256 | +static void imx7_src_reset(DeviceState *dev) | ||
257 | +{ | ||
258 | + IMX7SRCState *s = IMX7_SRC(dev); | ||
259 | + | ||
260 | + memset(s->regs, 0, sizeof(s->regs)); | ||
261 | + | ||
262 | + /* Set reset values */ | ||
263 | + s->regs[SRC_SCR] = 0xA0; | ||
264 | + s->regs[SRC_SRSR] = 0x1; | ||
265 | + s->regs[SRC_SIMR] = 0x1F; | ||
266 | +} | ||
267 | + | ||
268 | +static uint64_t imx7_src_read(void *opaque, hwaddr offset, unsigned size) | ||
269 | +{ | ||
270 | + uint32_t value = 0; | ||
271 | + IMX7SRCState *s = (IMX7SRCState *)opaque; | ||
272 | + uint32_t index = offset >> 2; | ||
273 | + | ||
274 | + if (index < SRC_MAX) { | ||
275 | + value = s->regs[index]; | ||
276 | + } else { | ||
277 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
278 | + HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset); | ||
279 | + } | ||
280 | + | ||
281 | + trace_imx7_src_read(imx7_src_reg_name(index), value); | ||
282 | + | ||
283 | + return value; | ||
284 | +} | ||
285 | + | ||
286 | + | ||
287 | +/* | ||
288 | + * The reset is asynchronous so we need to defer clearing the reset | ||
289 | + * bit until the work is completed. | ||
290 | + */ | ||
291 | + | ||
292 | +struct SRCSCRResetInfo { | ||
293 | + IMX7SRCState *s; | ||
294 | + uint32_t reset_bit; | ||
295 | +}; | ||
296 | + | ||
297 | +static void imx7_clear_reset_bit(CPUState *cpu, run_on_cpu_data data) | ||
298 | +{ | ||
299 | + struct SRCSCRResetInfo *ri = data.host_ptr; | ||
300 | + IMX7SRCState *s = ri->s; | ||
301 | + | ||
302 | + assert(qemu_mutex_iothread_locked()); | ||
303 | + | ||
304 | + s->regs[SRC_A7RCR0] = deposit32(s->regs[SRC_A7RCR0], ri->reset_bit, 1, 0); | ||
305 | + | ||
306 | + trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]); | ||
307 | + | ||
308 | + g_free(ri); | ||
309 | +} | ||
310 | + | ||
311 | +static void imx7_defer_clear_reset_bit(uint32_t cpuid, | ||
312 | + IMX7SRCState *s, | ||
313 | + uint32_t reset_shift) | ||
314 | +{ | ||
315 | + struct SRCSCRResetInfo *ri; | ||
316 | + CPUState *cpu = arm_get_cpu_by_id(cpuid); | ||
317 | + | ||
318 | + if (!cpu) { | ||
319 | + return; | ||
320 | + } | ||
321 | + | ||
322 | + ri = g_new(struct SRCSCRResetInfo, 1); | ||
323 | + ri->s = s; | ||
324 | + ri->reset_bit = reset_shift; | ||
325 | + | ||
326 | + async_run_on_cpu(cpu, imx7_clear_reset_bit, RUN_ON_CPU_HOST_PTR(ri)); | ||
327 | +} | ||
328 | + | ||
329 | + | ||
330 | +static void imx7_src_write(void *opaque, hwaddr offset, uint64_t value, | ||
331 | + unsigned size) | ||
332 | +{ | ||
333 | + IMX7SRCState *s = (IMX7SRCState *)opaque; | ||
334 | + uint32_t index = offset >> 2; | ||
335 | + long unsigned int change_mask; | ||
336 | + uint32_t current_value = value; | ||
337 | + | ||
338 | + if (index >= SRC_MAX) { | ||
339 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
340 | + HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset); | ||
341 | + return; | ||
342 | + } | ||
343 | + | ||
344 | + trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]); | ||
345 | + | ||
346 | + change_mask = s->regs[index] ^ (uint32_t)current_value; | ||
347 | + | ||
348 | + switch (index) { | ||
349 | + case SRC_A7RCR0: | ||
350 | + if (FIELD_EX32(change_mask, CORE0, RST)) { | ||
351 | + arm_reset_cpu(0); | ||
352 | + imx7_defer_clear_reset_bit(0, s, R_CORE0_RST_SHIFT); | ||
353 | + } | ||
354 | + if (FIELD_EX32(change_mask, CORE1, RST)) { | ||
355 | + arm_reset_cpu(1); | ||
356 | + imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT); | ||
357 | + } | ||
358 | + s->regs[index] = current_value; | ||
359 | + break; | ||
360 | + case SRC_A7RCR1: | ||
361 | + /* | ||
362 | + * On real hardware when the system reset controller starts a | ||
363 | + * secondary CPU it runs through some boot ROM code which reads | ||
364 | + * the SRC_GPRX registers controlling the start address and branches | ||
365 | + * to it. | ||
366 | + * Here we are taking a short cut and branching directly to the | ||
367 | + * requested address (we don't want to run the boot ROM code inside | ||
368 | + * QEMU) | ||
369 | + */ | ||
370 | + if (FIELD_EX32(change_mask, CORE1, ENABLE)) { | ||
371 | + if (FIELD_EX32(current_value, CORE1, ENABLE)) { | ||
372 | + /* CORE 1 is brought up */ | ||
373 | + arm_set_cpu_on(1, s->regs[SRC_GPR3], s->regs[SRC_GPR4], | ||
374 | + 3, false); | ||
375 | + } else { | ||
376 | + /* CORE 1 is shut down */ | ||
377 | + arm_set_cpu_off(1); | ||
378 | + } | ||
379 | + /* We clear the reset bits as the processor changed state */ | ||
380 | + imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT); | ||
381 | + clear_bit(R_CORE1_RST_SHIFT, &change_mask); | ||
382 | + } | ||
383 | + s->regs[index] = current_value; | ||
384 | + break; | ||
385 | + default: | ||
386 | + s->regs[index] = current_value; | ||
387 | + break; | ||
388 | + } | ||
389 | +} | ||
390 | + | ||
391 | +static const struct MemoryRegionOps imx7_src_ops = { | ||
392 | + .read = imx7_src_read, | ||
393 | + .write = imx7_src_write, | ||
394 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
395 | + .valid = { | ||
396 | + /* | ||
397 | + * Our device would not work correctly if the guest was doing | ||
398 | + * unaligned access. This might not be a limitation on the real | ||
399 | + * device but in practice there is no reason for a guest to access | ||
400 | + * this device unaligned. | ||
401 | + */ | ||
402 | + .min_access_size = 4, | ||
403 | + .max_access_size = 4, | ||
404 | + .unaligned = false, | ||
405 | + }, | ||
406 | +}; | ||
407 | + | ||
408 | +static void imx7_src_realize(DeviceState *dev, Error **errp) | ||
409 | +{ | ||
410 | + IMX7SRCState *s = IMX7_SRC(dev); | ||
411 | + | ||
412 | + memory_region_init_io(&s->iomem, OBJECT(dev), &imx7_src_ops, s, | ||
413 | + TYPE_IMX7_SRC, 0x1000); | ||
414 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
415 | +} | ||
416 | + | ||
417 | +static void imx7_src_class_init(ObjectClass *klass, void *data) | ||
418 | +{ | ||
419 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
420 | + | ||
421 | + dc->realize = imx7_src_realize; | ||
422 | + dc->reset = imx7_src_reset; | ||
423 | + dc->vmsd = &vmstate_imx7_src; | ||
424 | + dc->desc = "i.MX6 System Reset Controller"; | ||
425 | +} | ||
426 | + | ||
427 | +static const TypeInfo imx7_src_info = { | ||
428 | + .name = TYPE_IMX7_SRC, | ||
429 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
430 | + .instance_size = sizeof(IMX7SRCState), | ||
431 | + .class_init = imx7_src_class_init, | ||
432 | +}; | ||
433 | + | ||
434 | +static void imx7_src_register_types(void) | ||
435 | +{ | ||
436 | + type_register_static(&imx7_src_info); | ||
437 | +} | ||
438 | + | ||
439 | +type_init(imx7_src_register_types) | ||
440 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
74 | index XXXXXXX..XXXXXXX 100644 | 441 | index XXXXXXX..XXXXXXX 100644 |
75 | --- a/hw/input/stellaris_input.c | 442 | --- a/hw/misc/meson.build |
76 | +++ b/hw/input/stellaris_input.c | 443 | +++ b/hw/misc/meson.build |
77 | @@ -XXX,XX +XXX,XX @@ | 444 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_IMX', if_true: files( |
78 | */ | 445 | 'imx6_src.c', |
79 | #include "qemu/osdep.h" | 446 | 'imx6ul_ccm.c', |
80 | #include "hw/hw.h" | 447 | 'imx7_ccm.c', |
81 | -#include "hw/devices.h" | 448 | + 'imx7_src.c', |
82 | +#include "hw/input/gamepad.h" | 449 | 'imx7_gpr.c', |
83 | #include "ui/console.h" | 450 | 'imx7_snvs.c', |
84 | 451 | 'imx_ccm.c', | |
85 | typedef struct { | 452 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events |
86 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
87 | index XXXXXXX..XXXXXXX 100644 | 453 | index XXXXXXX..XXXXXXX 100644 |
88 | --- a/MAINTAINERS | 454 | --- a/hw/misc/trace-events |
89 | +++ b/MAINTAINERS | 455 | +++ b/hw/misc/trace-events |
90 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | 456 | @@ -XXX,XX +XXX,XX @@ ccm_clock_freq(uint32_t clock, uint32_t freq) "(Clock = %d) = %d" |
91 | L: qemu-arm@nongnu.org | 457 | ccm_read_reg(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 |
92 | S: Maintained | 458 | ccm_write_reg(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 |
93 | F: hw/*/stellaris* | 459 | |
94 | +F: include/hw/input/gamepad.h | 460 | +# imx7_src.c |
95 | 461 | +imx7_src_read(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 | |
96 | Versatile Express | 462 | +imx7_src_write(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 |
97 | M: Peter Maydell <peter.maydell@linaro.org> | 463 | + |
464 | # iotkit-sysinfo.c | ||
465 | iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
466 | iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
98 | -- | 467 | -- |
99 | 2.20.1 | 468 | 2.34.1 |
100 | |||
101 | diff view generated by jsdifflib |
1 | The M-profile FPCCR.ASPEN bit indicates that automatic floating-point | 1 | The architecture requires (R_TYTWB) that an attempt to return from EL3 |
---|---|---|---|
2 | context preservation is enabled. Before executing any floating-point | 2 | when SCR_EL3.{NSE,NS} are {1,0} is an illegal exception return. (This |
3 | instruction, if FPCCR.ASPEN is set and the CONTROL FPCA/SFPA bits | 3 | enforces that the CPU can't ever be executing below EL3 with the |
4 | indicate that there is no active floating point context then we | 4 | NSE,NS bits indicating an invalid security state.) |
5 | must create a new context (by initializing FPSCR and setting | ||
6 | FPCA/SFPA to indicate that the context is now active). In the | ||
7 | pseudocode this is handled by ExecuteFPCheck(). | ||
8 | 5 | ||
9 | Implement this with a new TB flag which tracks whether we | 6 | We were missing this check; add it. |
10 | need to create a new FP context. | ||
11 | 7 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20190416125744.27770-20-peter.maydell@linaro.org | 10 | Message-id: 20230807150618.101357-1-peter.maydell@linaro.org |
15 | --- | 11 | --- |
16 | target/arm/cpu.h | 2 ++ | 12 | target/arm/tcg/helper-a64.c | 9 +++++++++ |
17 | target/arm/translate.h | 1 + | 13 | 1 file changed, 9 insertions(+) |
18 | target/arm/helper.c | 13 +++++++++++++ | ||
19 | target/arm/translate.c | 29 +++++++++++++++++++++++++++++ | ||
20 | 4 files changed, 45 insertions(+) | ||
21 | 14 | ||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c |
23 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/tcg/helper-a64.c |
25 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/tcg/helper-a64.c |
26 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 19 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) |
27 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 20 | spsr &= ~PSTATE_SS; |
28 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | ||
29 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
30 | +/* For M profile only, set if we must create a new FP context */ | ||
31 | +FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) | ||
32 | /* For M profile only, set if FPCCR.S does not match current security state */ | ||
33 | FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) | ||
34 | /* For M profile only, Handler (ie not Thread) mode */ | ||
35 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/translate.h | ||
38 | +++ b/target/arm/translate.h | ||
39 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
40 | bool v8m_secure; /* true if v8M and we're in Secure mode */ | ||
41 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | ||
42 | bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | ||
43 | + bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */ | ||
44 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | ||
45 | * so that top level loop can generate correct syndrome information. | ||
46 | */ | ||
47 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/helper.c | ||
50 | +++ b/target/arm/helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
52 | flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | ||
53 | } | 21 | } |
54 | 22 | ||
55 | + if (arm_feature(env, ARM_FEATURE_M) && | 23 | + /* |
56 | + (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) && | 24 | + * FEAT_RME forbids return from EL3 with an invalid security state. |
57 | + (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) || | 25 | + * We don't need an explicit check for FEAT_RME here because we enforce |
58 | + (env->v7m.secure && | 26 | + * in scr_write() that you can't set the NSE bit without it. |
59 | + !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) { | 27 | + */ |
60 | + /* | 28 | + if (cur_el == 3 && (env->cp15.scr_el3 & (SCR_NS | SCR_NSE)) == SCR_NSE) { |
61 | + * ASPEN is set, but FPCA/SFPA indicate that there is no active | 29 | + goto illegal_return; |
62 | + * FP context; we must create a new FP context before executing | ||
63 | + * any FP insn. | ||
64 | + */ | ||
65 | + flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); | ||
66 | + } | 30 | + } |
67 | + | 31 | + |
68 | *pflags = flags; | 32 | new_el = el_from_spsr(spsr); |
69 | *cs_base = 0; | 33 | if (new_el == -1) { |
70 | } | 34 | goto illegal_return; |
71 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/translate.c | ||
74 | +++ b/target/arm/translate.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
76 | /* Don't need to do this for any further FP insns in this TB */ | ||
77 | s->v8m_fpccr_s_wrong = false; | ||
78 | } | ||
79 | + | ||
80 | + if (s->v7m_new_fp_ctxt_needed) { | ||
81 | + /* | ||
82 | + * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA | ||
83 | + * and the FPSCR. | ||
84 | + */ | ||
85 | + TCGv_i32 control, fpscr; | ||
86 | + uint32_t bits = R_V7M_CONTROL_FPCA_MASK; | ||
87 | + | ||
88 | + fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]); | ||
89 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
90 | + tcg_temp_free_i32(fpscr); | ||
91 | + /* | ||
92 | + * We don't need to arrange to end the TB, because the only | ||
93 | + * parts of FPSCR which we cache in the TB flags are the VECLEN | ||
94 | + * and VECSTRIDE, and those don't exist for M-profile. | ||
95 | + */ | ||
96 | + | ||
97 | + if (s->v8m_secure) { | ||
98 | + bits |= R_V7M_CONTROL_SFPA_MASK; | ||
99 | + } | ||
100 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
101 | + tcg_gen_ori_i32(control, control, bits); | ||
102 | + store_cpu_field(control, v7m.control[M_REG_S]); | ||
103 | + /* Don't need to do this for any further FP insns in this TB */ | ||
104 | + s->v7m_new_fp_ctxt_needed = false; | ||
105 | + } | ||
106 | } | ||
107 | |||
108 | if (extract32(insn, 28, 4) == 0xf) { | ||
109 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
110 | regime_is_secure(env, dc->mmu_idx); | ||
111 | dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK); | ||
112 | dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | ||
113 | + dc->v7m_new_fp_ctxt_needed = | ||
114 | + FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED); | ||
115 | dc->cp_regs = cpu->cp_regs; | ||
116 | dc->features = env->features; | ||
117 | |||
118 | -- | 35 | -- |
119 | 2.20.1 | 36 | 2.34.1 |
120 | |||
121 | diff view generated by jsdifflib |
1 | Pushing registers to the stack for v7M needs to handle three cases: | 1 | In the m48t59 device we almost always use 64-bit arithmetic when |
---|---|---|---|
2 | * the "normal" case where we pend exceptions | 2 | dealing with time_t deltas. The one exception is in set_alarm(), |
3 | * an "ignore faults" case where we set FSR bits but | 3 | which currently uses a plain 'int' to hold the difference between two |
4 | do not pend exceptions (this is used when we are | 4 | time_t values. Switch to int64_t instead to avoid any possible |
5 | handling some kinds of derived exception on exception entry) | 5 | overflow issues. |
6 | * a "lazy FP stacking" case, where different FSR bits | ||
7 | are set and the exception is pended differently | ||
8 | |||
9 | Implement this by changing the existing flag argument that | ||
10 | tells us whether to ignore faults or not into an enum that | ||
11 | specifies which of the 3 modes we should handle. | ||
12 | 6 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
15 | Message-id: 20190416125744.27770-23-peter.maydell@linaro.org | ||
16 | --- | 9 | --- |
17 | target/arm/helper.c | 118 +++++++++++++++++++++++++++++--------------- | 10 | hw/rtc/m48t59.c | 2 +- |
18 | 1 file changed, 79 insertions(+), 39 deletions(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
19 | 12 | ||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c |
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 15 | --- a/hw/rtc/m48t59.c |
23 | +++ b/target/arm/helper.c | 16 | +++ b/hw/rtc/m48t59.c |
24 | @@ -XXX,XX +XXX,XX @@ static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | 17 | @@ -XXX,XX +XXX,XX @@ static void alarm_cb (void *opaque) |
25 | } | 18 | |
26 | } | 19 | static void set_alarm(M48t59State *NVRAM) |
27 | |||
28 | +/* | ||
29 | + * What kind of stack write are we doing? This affects how exceptions | ||
30 | + * generated during the stacking are treated. | ||
31 | + */ | ||
32 | +typedef enum StackingMode { | ||
33 | + STACK_NORMAL, | ||
34 | + STACK_IGNFAULTS, | ||
35 | + STACK_LAZYFP, | ||
36 | +} StackingMode; | ||
37 | + | ||
38 | static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | ||
39 | - ARMMMUIdx mmu_idx, bool ignfault) | ||
40 | + ARMMMUIdx mmu_idx, StackingMode mode) | ||
41 | { | 20 | { |
42 | CPUState *cs = CPU(cpu); | 21 | - int diff; |
43 | CPUARMState *env = &cpu->env; | 22 | + int64_t diff; |
44 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | 23 | if (NVRAM->alrm_timer != NULL) { |
45 | &attrs, &prot, &page_size, &fi, NULL)) { | 24 | timer_del(NVRAM->alrm_timer); |
46 | /* MPU/SAU lookup failed */ | 25 | diff = qemu_timedate_diff(&NVRAM->alarm) - NVRAM->time_offset; |
47 | if (fi.type == ARMFault_QEMU_SFault) { | ||
48 | - qemu_log_mask(CPU_LOG_INT, | ||
49 | - "...SecureFault with SFSR.AUVIOL during stacking\n"); | ||
50 | - env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK | R_V7M_SFSR_SFARVALID_MASK; | ||
51 | + if (mode == STACK_LAZYFP) { | ||
52 | + qemu_log_mask(CPU_LOG_INT, | ||
53 | + "...SecureFault with SFSR.LSPERR " | ||
54 | + "during lazy stacking\n"); | ||
55 | + env->v7m.sfsr |= R_V7M_SFSR_LSPERR_MASK; | ||
56 | + } else { | ||
57 | + qemu_log_mask(CPU_LOG_INT, | ||
58 | + "...SecureFault with SFSR.AUVIOL " | ||
59 | + "during stacking\n"); | ||
60 | + env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK; | ||
61 | + } | ||
62 | + env->v7m.sfsr |= R_V7M_SFSR_SFARVALID_MASK; | ||
63 | env->v7m.sfar = addr; | ||
64 | exc = ARMV7M_EXCP_SECURE; | ||
65 | exc_secure = false; | ||
66 | } else { | ||
67 | - qemu_log_mask(CPU_LOG_INT, "...MemManageFault with CFSR.MSTKERR\n"); | ||
68 | - env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK; | ||
69 | + if (mode == STACK_LAZYFP) { | ||
70 | + qemu_log_mask(CPU_LOG_INT, | ||
71 | + "...MemManageFault with CFSR.MLSPERR\n"); | ||
72 | + env->v7m.cfsr[secure] |= R_V7M_CFSR_MLSPERR_MASK; | ||
73 | + } else { | ||
74 | + qemu_log_mask(CPU_LOG_INT, | ||
75 | + "...MemManageFault with CFSR.MSTKERR\n"); | ||
76 | + env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK; | ||
77 | + } | ||
78 | exc = ARMV7M_EXCP_MEM; | ||
79 | exc_secure = secure; | ||
80 | } | ||
81 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | ||
82 | attrs, &txres); | ||
83 | if (txres != MEMTX_OK) { | ||
84 | /* BusFault trying to write the data */ | ||
85 | - qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n"); | ||
86 | - env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK; | ||
87 | + if (mode == STACK_LAZYFP) { | ||
88 | + qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.LSPERR\n"); | ||
89 | + env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_LSPERR_MASK; | ||
90 | + } else { | ||
91 | + qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n"); | ||
92 | + env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK; | ||
93 | + } | ||
94 | exc = ARMV7M_EXCP_BUS; | ||
95 | exc_secure = false; | ||
96 | goto pend_fault; | ||
97 | @@ -XXX,XX +XXX,XX @@ pend_fault: | ||
98 | * later if we have two derived exceptions. | ||
99 | * The only case when we must not pend the exception but instead | ||
100 | * throw it away is if we are doing the push of the callee registers | ||
101 | - * and we've already generated a derived exception. Even in this | ||
102 | - * case we will still update the fault status registers. | ||
103 | + * and we've already generated a derived exception (this is indicated | ||
104 | + * by the caller passing STACK_IGNFAULTS). Even in this case we will | ||
105 | + * still update the fault status registers. | ||
106 | */ | ||
107 | - if (!ignfault) { | ||
108 | + switch (mode) { | ||
109 | + case STACK_NORMAL: | ||
110 | armv7m_nvic_set_pending_derived(env->nvic, exc, exc_secure); | ||
111 | + break; | ||
112 | + case STACK_LAZYFP: | ||
113 | + armv7m_nvic_set_pending_lazyfp(env->nvic, exc, exc_secure); | ||
114 | + break; | ||
115 | + case STACK_IGNFAULTS: | ||
116 | + break; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
121 | uint32_t limit; | ||
122 | bool want_psp; | ||
123 | uint32_t sig; | ||
124 | + StackingMode smode = ignore_faults ? STACK_IGNFAULTS : STACK_NORMAL; | ||
125 | |||
126 | if (dotailchain) { | ||
127 | bool mode = lr & R_V7M_EXCRET_MODE_MASK; | ||
128 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
129 | */ | ||
130 | sig = v7m_integrity_sig(env, lr); | ||
131 | stacked_ok = | ||
132 | - v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) && | ||
133 | - v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, | ||
134 | - ignore_faults) && | ||
135 | - v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, | ||
136 | - ignore_faults) && | ||
137 | - v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, | ||
138 | - ignore_faults) && | ||
139 | - v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, | ||
140 | - ignore_faults) && | ||
141 | - v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, | ||
142 | - ignore_faults) && | ||
143 | - v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, | ||
144 | - ignore_faults) && | ||
145 | - v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, | ||
146 | - ignore_faults) && | ||
147 | - v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, | ||
148 | - ignore_faults); | ||
149 | + v7m_stack_write(cpu, frameptr, sig, mmu_idx, smode) && | ||
150 | + v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, smode) && | ||
151 | + v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, smode) && | ||
152 | + v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, smode) && | ||
153 | + v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, smode) && | ||
154 | + v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, smode) && | ||
155 | + v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, smode) && | ||
156 | + v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, smode) && | ||
157 | + v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, smode); | ||
158 | |||
159 | /* Update SP regardless of whether any of the stack accesses failed. */ | ||
160 | *frame_sp_p = frameptr; | ||
161 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
162 | * if it has higher priority). | ||
163 | */ | ||
164 | stacked_ok = stacked_ok && | ||
165 | - v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) && | ||
166 | - v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) && | ||
167 | - v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) && | ||
168 | - v7m_stack_write(cpu, frameptr + 12, env->regs[3], mmu_idx, false) && | ||
169 | - v7m_stack_write(cpu, frameptr + 16, env->regs[12], mmu_idx, false) && | ||
170 | - v7m_stack_write(cpu, frameptr + 20, env->regs[14], mmu_idx, false) && | ||
171 | - v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | ||
172 | - v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | ||
173 | + v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, STACK_NORMAL) && | ||
174 | + v7m_stack_write(cpu, frameptr + 4, env->regs[1], | ||
175 | + mmu_idx, STACK_NORMAL) && | ||
176 | + v7m_stack_write(cpu, frameptr + 8, env->regs[2], | ||
177 | + mmu_idx, STACK_NORMAL) && | ||
178 | + v7m_stack_write(cpu, frameptr + 12, env->regs[3], | ||
179 | + mmu_idx, STACK_NORMAL) && | ||
180 | + v7m_stack_write(cpu, frameptr + 16, env->regs[12], | ||
181 | + mmu_idx, STACK_NORMAL) && | ||
182 | + v7m_stack_write(cpu, frameptr + 20, env->regs[14], | ||
183 | + mmu_idx, STACK_NORMAL) && | ||
184 | + v7m_stack_write(cpu, frameptr + 24, env->regs[15], | ||
185 | + mmu_idx, STACK_NORMAL) && | ||
186 | + v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, STACK_NORMAL); | ||
187 | |||
188 | if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) { | ||
189 | /* FPU is active, try to save its registers */ | ||
190 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
191 | faddr += 8; /* skip the slot for the FPSCR */ | ||
192 | } | ||
193 | stacked_ok = stacked_ok && | ||
194 | - v7m_stack_write(cpu, faddr, slo, mmu_idx, false) && | ||
195 | - v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false); | ||
196 | + v7m_stack_write(cpu, faddr, slo, | ||
197 | + mmu_idx, STACK_NORMAL) && | ||
198 | + v7m_stack_write(cpu, faddr + 4, shi, | ||
199 | + mmu_idx, STACK_NORMAL); | ||
200 | } | ||
201 | stacked_ok = stacked_ok && | ||
202 | v7m_stack_write(cpu, frameptr + 0x60, | ||
203 | - vfp_get_fpscr(env), mmu_idx, false); | ||
204 | + vfp_get_fpscr(env), mmu_idx, STACK_NORMAL); | ||
205 | if (cpacr_pass) { | ||
206 | for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | ||
207 | *aa32_vfp_dreg(env, i / 2) = 0; | ||
208 | -- | 26 | -- |
209 | 2.20.1 | 27 | 2.34.1 |
210 | 28 | ||
211 | 29 | diff view generated by jsdifflib |
1 | Implement the VLLDM instruction for v7M for the FPU present cas. | 1 | In the twl92230 device, use int64_t for the two state fields |
---|---|---|---|
2 | sec_offset and alm_sec, because we set these to values that | ||
3 | are either time_t or differences between two time_t values. | ||
4 | |||
5 | These fields aren't saved in vmstate anywhere, so we can | ||
6 | safely widen them. | ||
2 | 7 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | Message-id: 20190416125744.27770-26-peter.maydell@linaro.org | ||
6 | --- | 10 | --- |
7 | target/arm/helper.h | 1 + | 11 | hw/rtc/twl92230.c | 4 ++-- |
8 | target/arm/helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++ | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
9 | target/arm/translate.c | 2 +- | ||
10 | 3 files changed, 56 insertions(+), 1 deletion(-) | ||
11 | 13 | ||
12 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 14 | diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.h | 16 | --- a/hw/rtc/twl92230.c |
15 | +++ b/target/arm/helper.h | 17 | +++ b/hw/rtc/twl92230.c |
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | 18 | @@ -XXX,XX +XXX,XX @@ struct MenelausState { |
17 | DEF_HELPER_1(v7m_preserve_fp_state, void, env) | 19 | struct tm tm; |
18 | 20 | struct tm new; | |
19 | DEF_HELPER_2(v7m_vlstm, void, env, i32) | 21 | struct tm alm; |
20 | +DEF_HELPER_2(v7m_vlldm, void, env, i32) | 22 | - int sec_offset; |
21 | 23 | - int alm_sec; | |
22 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | 24 | + int64_t sec_offset; |
23 | 25 | + int64_t alm_sec; | |
24 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 26 | int next_comp; |
25 | index XXXXXXX..XXXXXXX 100644 | 27 | } rtc; |
26 | --- a/target/arm/helper.c | 28 | uint16_t rtc_next_vmstate; |
27 | +++ b/target/arm/helper.c | ||
28 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | ||
29 | g_assert_not_reached(); | ||
30 | } | ||
31 | |||
32 | +void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | ||
33 | +{ | ||
34 | + /* translate.c should never generate calls here in user-only mode */ | ||
35 | + g_assert_not_reached(); | ||
36 | +} | ||
37 | + | ||
38 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
39 | { | ||
40 | /* The TT instructions can be used by unprivileged code, but in | ||
41 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | ||
42 | env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | ||
43 | } | ||
44 | |||
45 | +void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | ||
46 | +{ | ||
47 | + /* fptr is the value of Rn, the frame pointer we load the FP regs from */ | ||
48 | + assert(env->v7m.secure); | ||
49 | + | ||
50 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | ||
51 | + return; | ||
52 | + } | ||
53 | + | ||
54 | + /* Check access to the coprocessor is permitted */ | ||
55 | + if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) { | ||
56 | + raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC()); | ||
57 | + } | ||
58 | + | ||
59 | + if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) { | ||
60 | + /* State in FP is still valid */ | ||
61 | + env->v7m.fpccr[M_REG_S] &= ~R_V7M_FPCCR_LSPACT_MASK; | ||
62 | + } else { | ||
63 | + bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK; | ||
64 | + int i; | ||
65 | + uint32_t fpscr; | ||
66 | + | ||
67 | + if (fptr & 7) { | ||
68 | + raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC()); | ||
69 | + } | ||
70 | + | ||
71 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | ||
72 | + uint32_t slo, shi; | ||
73 | + uint64_t dn; | ||
74 | + uint32_t faddr = fptr + 4 * i; | ||
75 | + | ||
76 | + if (i >= 16) { | ||
77 | + faddr += 8; /* skip the slot for the FPSCR */ | ||
78 | + } | ||
79 | + | ||
80 | + slo = cpu_ldl_data(env, faddr); | ||
81 | + shi = cpu_ldl_data(env, faddr + 4); | ||
82 | + | ||
83 | + dn = (uint64_t) shi << 32 | slo; | ||
84 | + *aa32_vfp_dreg(env, i / 2) = dn; | ||
85 | + } | ||
86 | + fpscr = cpu_ldl_data(env, fptr + 0x40); | ||
87 | + vfp_set_fpscr(env, fpscr); | ||
88 | + } | ||
89 | + | ||
90 | + env->v7m.control[M_REG_S] |= R_V7M_CONTROL_FPCA_MASK; | ||
91 | +} | ||
92 | + | ||
93 | static bool v7m_push_stack(ARMCPU *cpu) | ||
94 | { | ||
95 | /* Do the "set up stack frame" part of exception entry, | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
101 | TCGv_i32 fptr = load_reg(s, rn); | ||
102 | |||
103 | if (extract32(insn, 20, 1)) { | ||
104 | - /* VLLDM */ | ||
105 | + gen_helper_v7m_vlldm(cpu_env, fptr); | ||
106 | } else { | ||
107 | gen_helper_v7m_vlstm(cpu_env, fptr); | ||
108 | } | ||
109 | -- | 29 | -- |
110 | 2.20.1 | 30 | 2.34.1 |
111 | 31 | ||
112 | 32 | diff view generated by jsdifflib |
1 | The M-profile floating point support has three associated config | 1 | In the aspeed_rtc device we store a difference between two time_t |
---|---|---|---|
2 | registers: FPCAR, FPCCR and FPDSCR. It also makes the registers | 2 | values in an 'int'. This is not really correct when time_t could |
3 | CPACR and NSACR have behaviour other than reads-as-zero. | 3 | be 64 bits. Enlarge the field to 'int64_t'. |
4 | Add support for all of these as simple reads-as-written registers. | ||
5 | We will hook up actual functionality later. | ||
6 | 4 | ||
7 | The main complexity here is handling the FPCCR register, which | 5 | This is a migration compatibility break for the aspeed boards. |
8 | has a mix of banked and unbanked bits. | 6 | While we are changing the vmstate, remove the accidental |
9 | 7 | duplicate of the offset field. | |
10 | Note that we don't share storage with the A-profile | ||
11 | cpu->cp15.nsacr and cpu->cp15.cpacr_el1, though the behaviour | ||
12 | is quite similar, for two reasons: | ||
13 | * the M profile CPACR is banked between security states | ||
14 | * it preserves the invariant that M profile uses no state | ||
15 | inside the cp15 substruct | ||
16 | 8 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
19 | Message-id: 20190416125744.27770-4-peter.maydell@linaro.org | ||
20 | --- | 11 | --- |
21 | target/arm/cpu.h | 34 ++++++++++++ | 12 | include/hw/rtc/aspeed_rtc.h | 2 +- |
22 | hw/intc/armv7m_nvic.c | 125 ++++++++++++++++++++++++++++++++++++++++++ | 13 | hw/rtc/aspeed_rtc.c | 5 ++--- |
23 | target/arm/cpu.c | 5 ++ | 14 | 2 files changed, 3 insertions(+), 4 deletions(-) |
24 | target/arm/machine.c | 16 ++++++ | ||
25 | 4 files changed, 180 insertions(+) | ||
26 | 15 | ||
27 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/include/hw/rtc/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h |
28 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/cpu.h | 18 | --- a/include/hw/rtc/aspeed_rtc.h |
30 | +++ b/target/arm/cpu.h | 19 | +++ b/include/hw/rtc/aspeed_rtc.h |
31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 20 | @@ -XXX,XX +XXX,XX @@ struct AspeedRtcState { |
32 | uint32_t scr[M_REG_NUM_BANKS]; | 21 | qemu_irq irq; |
33 | uint32_t msplim[M_REG_NUM_BANKS]; | 22 | |
34 | uint32_t psplim[M_REG_NUM_BANKS]; | 23 | uint32_t reg[0x18]; |
35 | + uint32_t fpcar[M_REG_NUM_BANKS]; | 24 | - int offset; |
36 | + uint32_t fpccr[M_REG_NUM_BANKS]; | 25 | + int64_t offset; |
37 | + uint32_t fpdscr[M_REG_NUM_BANKS]; | 26 | |
38 | + uint32_t cpacr[M_REG_NUM_BANKS]; | 27 | }; |
39 | + uint32_t nsacr; | 28 | |
40 | } v7m; | 29 | diff --git a/hw/rtc/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c |
41 | |||
42 | /* Information associated with an exception about to be taken: | ||
43 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_CSSELR, LEVEL, 1, 3) | ||
44 | */ | ||
45 | FIELD(V7M_CSSELR, INDEX, 0, 4) | ||
46 | |||
47 | +/* v7M FPCCR bits */ | ||
48 | +FIELD(V7M_FPCCR, LSPACT, 0, 1) | ||
49 | +FIELD(V7M_FPCCR, USER, 1, 1) | ||
50 | +FIELD(V7M_FPCCR, S, 2, 1) | ||
51 | +FIELD(V7M_FPCCR, THREAD, 3, 1) | ||
52 | +FIELD(V7M_FPCCR, HFRDY, 4, 1) | ||
53 | +FIELD(V7M_FPCCR, MMRDY, 5, 1) | ||
54 | +FIELD(V7M_FPCCR, BFRDY, 6, 1) | ||
55 | +FIELD(V7M_FPCCR, SFRDY, 7, 1) | ||
56 | +FIELD(V7M_FPCCR, MONRDY, 8, 1) | ||
57 | +FIELD(V7M_FPCCR, SPLIMVIOL, 9, 1) | ||
58 | +FIELD(V7M_FPCCR, UFRDY, 10, 1) | ||
59 | +FIELD(V7M_FPCCR, RES0, 11, 15) | ||
60 | +FIELD(V7M_FPCCR, TS, 26, 1) | ||
61 | +FIELD(V7M_FPCCR, CLRONRETS, 27, 1) | ||
62 | +FIELD(V7M_FPCCR, CLRONRET, 28, 1) | ||
63 | +FIELD(V7M_FPCCR, LSPENS, 29, 1) | ||
64 | +FIELD(V7M_FPCCR, LSPEN, 30, 1) | ||
65 | +FIELD(V7M_FPCCR, ASPEN, 31, 1) | ||
66 | +/* These bits are banked. Others are non-banked and live in the M_REG_S bank */ | ||
67 | +#define R_V7M_FPCCR_BANKED_MASK \ | ||
68 | + (R_V7M_FPCCR_LSPACT_MASK | \ | ||
69 | + R_V7M_FPCCR_USER_MASK | \ | ||
70 | + R_V7M_FPCCR_THREAD_MASK | \ | ||
71 | + R_V7M_FPCCR_MMRDY_MASK | \ | ||
72 | + R_V7M_FPCCR_SPLIMVIOL_MASK | \ | ||
73 | + R_V7M_FPCCR_UFRDY_MASK | \ | ||
74 | + R_V7M_FPCCR_ASPEN_MASK) | ||
75 | + | ||
76 | /* | ||
77 | * System register ID fields. | ||
78 | */ | ||
79 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
81 | --- a/hw/intc/armv7m_nvic.c | 31 | --- a/hw/rtc/aspeed_rtc.c |
82 | +++ b/hw/intc/armv7m_nvic.c | 32 | +++ b/hw/rtc/aspeed_rtc.c |
83 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 33 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_rtc_ops = { |
84 | } | 34 | |
85 | case 0xd84: /* CSSELR */ | 35 | static const VMStateDescription vmstate_aspeed_rtc = { |
86 | return cpu->env.v7m.csselr[attrs.secure]; | 36 | .name = TYPE_ASPEED_RTC, |
87 | + case 0xd88: /* CPACR */ | 37 | - .version_id = 1, |
88 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 38 | + .version_id = 2, |
89 | + return 0; | 39 | .fields = (VMStateField[]) { |
90 | + } | 40 | VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), |
91 | + return cpu->env.v7m.cpacr[attrs.secure]; | 41 | - VMSTATE_INT32(offset, AspeedRtcState), |
92 | + case 0xd8c: /* NSACR */ | 42 | - VMSTATE_INT32(offset, AspeedRtcState), |
93 | + if (!attrs.secure || !arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 43 | + VMSTATE_INT64(offset, AspeedRtcState), |
94 | + return 0; | 44 | VMSTATE_END_OF_LIST() |
95 | + } | ||
96 | + return cpu->env.v7m.nsacr; | ||
97 | /* TODO: Implement debug registers. */ | ||
98 | case 0xd90: /* MPU_TYPE */ | ||
99 | /* Unified MPU; if the MPU is not present this value is zero */ | ||
100 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
101 | return 0; | ||
102 | } | ||
103 | return cpu->env.v7m.sfar; | ||
104 | + case 0xf34: /* FPCCR */ | ||
105 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
106 | + return 0; | ||
107 | + } | ||
108 | + if (attrs.secure) { | ||
109 | + return cpu->env.v7m.fpccr[M_REG_S]; | ||
110 | + } else { | ||
111 | + /* | ||
112 | + * NS can read LSPEN, CLRONRET and MONRDY. It can read | ||
113 | + * BFRDY and HFRDY if AIRCR.BFHFNMINS != 0; | ||
114 | + * other non-banked bits RAZ. | ||
115 | + * TODO: MONRDY should RAZ/WI if DEMCR.SDME is set. | ||
116 | + */ | ||
117 | + uint32_t value = cpu->env.v7m.fpccr[M_REG_S]; | ||
118 | + uint32_t mask = R_V7M_FPCCR_LSPEN_MASK | | ||
119 | + R_V7M_FPCCR_CLRONRET_MASK | | ||
120 | + R_V7M_FPCCR_MONRDY_MASK; | ||
121 | + | ||
122 | + if (s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) { | ||
123 | + mask |= R_V7M_FPCCR_BFRDY_MASK | R_V7M_FPCCR_HFRDY_MASK; | ||
124 | + } | ||
125 | + | ||
126 | + value &= mask; | ||
127 | + | ||
128 | + value |= cpu->env.v7m.fpccr[M_REG_NS]; | ||
129 | + return value; | ||
130 | + } | ||
131 | + case 0xf38: /* FPCAR */ | ||
132 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
133 | + return 0; | ||
134 | + } | ||
135 | + return cpu->env.v7m.fpcar[attrs.secure]; | ||
136 | + case 0xf3c: /* FPDSCR */ | ||
137 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
138 | + return 0; | ||
139 | + } | ||
140 | + return cpu->env.v7m.fpdscr[attrs.secure]; | ||
141 | case 0xf40: /* MVFR0 */ | ||
142 | return cpu->isar.mvfr0; | ||
143 | case 0xf44: /* MVFR1 */ | ||
144 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
145 | cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK; | ||
146 | } | ||
147 | break; | ||
148 | + case 0xd88: /* CPACR */ | ||
149 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
150 | + /* We implement only the Floating Point extension's CP10/CP11 */ | ||
151 | + cpu->env.v7m.cpacr[attrs.secure] = value & (0xf << 20); | ||
152 | + } | ||
153 | + break; | ||
154 | + case 0xd8c: /* NSACR */ | ||
155 | + if (attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
156 | + /* We implement only the Floating Point extension's CP10/CP11 */ | ||
157 | + cpu->env.v7m.nsacr = value & (3 << 10); | ||
158 | + } | ||
159 | + break; | ||
160 | case 0xd90: /* MPU_TYPE */ | ||
161 | return; /* RO */ | ||
162 | case 0xd94: /* MPU_CTRL */ | ||
163 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
164 | } | ||
165 | break; | ||
166 | } | ||
167 | + case 0xf34: /* FPCCR */ | ||
168 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
169 | + /* Not all bits here are banked. */ | ||
170 | + uint32_t fpccr_s; | ||
171 | + | ||
172 | + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { | ||
173 | + /* Don't allow setting of bits not present in v7M */ | ||
174 | + value &= (R_V7M_FPCCR_LSPACT_MASK | | ||
175 | + R_V7M_FPCCR_USER_MASK | | ||
176 | + R_V7M_FPCCR_THREAD_MASK | | ||
177 | + R_V7M_FPCCR_HFRDY_MASK | | ||
178 | + R_V7M_FPCCR_MMRDY_MASK | | ||
179 | + R_V7M_FPCCR_BFRDY_MASK | | ||
180 | + R_V7M_FPCCR_MONRDY_MASK | | ||
181 | + R_V7M_FPCCR_LSPEN_MASK | | ||
182 | + R_V7M_FPCCR_ASPEN_MASK); | ||
183 | + } | ||
184 | + value &= ~R_V7M_FPCCR_RES0_MASK; | ||
185 | + | ||
186 | + if (!attrs.secure) { | ||
187 | + /* Some non-banked bits are configurably writable by NS */ | ||
188 | + fpccr_s = cpu->env.v7m.fpccr[M_REG_S]; | ||
189 | + if (!(fpccr_s & R_V7M_FPCCR_LSPENS_MASK)) { | ||
190 | + uint32_t lspen = FIELD_EX32(value, V7M_FPCCR, LSPEN); | ||
191 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, LSPEN, lspen); | ||
192 | + } | ||
193 | + if (!(fpccr_s & R_V7M_FPCCR_CLRONRETS_MASK)) { | ||
194 | + uint32_t cor = FIELD_EX32(value, V7M_FPCCR, CLRONRET); | ||
195 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, CLRONRET, cor); | ||
196 | + } | ||
197 | + if ((s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
198 | + uint32_t hfrdy = FIELD_EX32(value, V7M_FPCCR, HFRDY); | ||
199 | + uint32_t bfrdy = FIELD_EX32(value, V7M_FPCCR, BFRDY); | ||
200 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, HFRDY, hfrdy); | ||
201 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, BFRDY, bfrdy); | ||
202 | + } | ||
203 | + /* TODO MONRDY should RAZ/WI if DEMCR.SDME is set */ | ||
204 | + { | ||
205 | + uint32_t monrdy = FIELD_EX32(value, V7M_FPCCR, MONRDY); | ||
206 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, MONRDY, monrdy); | ||
207 | + } | ||
208 | + | ||
209 | + /* | ||
210 | + * All other non-banked bits are RAZ/WI from NS; write | ||
211 | + * just the banked bits to fpccr[M_REG_NS]. | ||
212 | + */ | ||
213 | + value &= R_V7M_FPCCR_BANKED_MASK; | ||
214 | + cpu->env.v7m.fpccr[M_REG_NS] = value; | ||
215 | + } else { | ||
216 | + fpccr_s = value; | ||
217 | + } | ||
218 | + cpu->env.v7m.fpccr[M_REG_S] = fpccr_s; | ||
219 | + } | ||
220 | + break; | ||
221 | + case 0xf38: /* FPCAR */ | ||
222 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
223 | + value &= ~7; | ||
224 | + cpu->env.v7m.fpcar[attrs.secure] = value; | ||
225 | + } | ||
226 | + break; | ||
227 | + case 0xf3c: /* FPDSCR */ | ||
228 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
229 | + value &= 0x07c00000; | ||
230 | + cpu->env.v7m.fpdscr[attrs.secure] = value; | ||
231 | + } | ||
232 | + break; | ||
233 | case 0xf50: /* ICIALLU */ | ||
234 | case 0xf58: /* ICIMVAU */ | ||
235 | case 0xf5c: /* DCIMVAC */ | ||
236 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
237 | index XXXXXXX..XXXXXXX 100644 | ||
238 | --- a/target/arm/cpu.c | ||
239 | +++ b/target/arm/cpu.c | ||
240 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
241 | env->v7m.ccr[M_REG_S] |= R_V7M_CCR_UNALIGN_TRP_MASK; | ||
242 | } | ||
243 | |||
244 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
245 | + env->v7m.fpccr[M_REG_NS] = R_V7M_FPCCR_ASPEN_MASK; | ||
246 | + env->v7m.fpccr[M_REG_S] = R_V7M_FPCCR_ASPEN_MASK | | ||
247 | + R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK; | ||
248 | + } | ||
249 | /* Unlike A/R profile, M profile defines the reset LR value */ | ||
250 | env->regs[14] = 0xffffffff; | ||
251 | |||
252 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
253 | index XXXXXXX..XXXXXXX 100644 | ||
254 | --- a/target/arm/machine.c | ||
255 | +++ b/target/arm/machine.c | ||
256 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_v8m = { | ||
257 | } | ||
258 | }; | ||
259 | |||
260 | +static const VMStateDescription vmstate_m_fp = { | ||
261 | + .name = "cpu/m/fp", | ||
262 | + .version_id = 1, | ||
263 | + .minimum_version_id = 1, | ||
264 | + .needed = vfp_needed, | ||
265 | + .fields = (VMStateField[]) { | ||
266 | + VMSTATE_UINT32_ARRAY(env.v7m.fpcar, ARMCPU, M_REG_NUM_BANKS), | ||
267 | + VMSTATE_UINT32_ARRAY(env.v7m.fpccr, ARMCPU, M_REG_NUM_BANKS), | ||
268 | + VMSTATE_UINT32_ARRAY(env.v7m.fpdscr, ARMCPU, M_REG_NUM_BANKS), | ||
269 | + VMSTATE_UINT32_ARRAY(env.v7m.cpacr, ARMCPU, M_REG_NUM_BANKS), | ||
270 | + VMSTATE_UINT32(env.v7m.nsacr, ARMCPU), | ||
271 | + VMSTATE_END_OF_LIST() | ||
272 | + } | ||
273 | +}; | ||
274 | + | ||
275 | static const VMStateDescription vmstate_m = { | ||
276 | .name = "cpu/m", | ||
277 | .version_id = 4, | ||
278 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | ||
279 | &vmstate_m_scr, | ||
280 | &vmstate_m_other_sp, | ||
281 | &vmstate_m_v8m, | ||
282 | + &vmstate_m_fp, | ||
283 | NULL | ||
284 | } | 45 | } |
285 | }; | 46 | }; |
286 | -- | 47 | -- |
287 | 2.20.1 | 48 | 2.34.1 |
288 | 49 | ||
289 | 50 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The only "system register" that M-profile floating point exposes | ||
2 | via the VMRS/VMRS instructions is FPSCR, and it does not have | ||
3 | the odd special case for rd==15. Add a check to ensure we only | ||
4 | expose FPSCR. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190416125744.27770-5-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate.c | 19 +++++++++++++++++-- | ||
11 | 1 file changed, 17 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/translate.c | ||
16 | +++ b/target/arm/translate.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
18 | } | ||
19 | } | ||
20 | } else { /* !dp */ | ||
21 | + bool is_sysreg; | ||
22 | + | ||
23 | if ((insn & 0x6f) != 0x00) | ||
24 | return 1; | ||
25 | rn = VFP_SREG_N(insn); | ||
26 | + | ||
27 | + is_sysreg = extract32(insn, 21, 1); | ||
28 | + | ||
29 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
30 | + /* | ||
31 | + * The only M-profile VFP vmrs/vmsr sysreg is FPSCR. | ||
32 | + * Writes to R15 are UNPREDICTABLE; we choose to undef. | ||
33 | + */ | ||
34 | + if (is_sysreg && (rd == 15 || (rn >> 1) != ARM_VFP_FPSCR)) { | ||
35 | + return 1; | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | if (insn & ARM_CP_RW_BIT) { | ||
40 | /* vfp->arm */ | ||
41 | - if (insn & (1 << 21)) { | ||
42 | + if (is_sysreg) { | ||
43 | /* system register */ | ||
44 | rn >>= 1; | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
47 | } | ||
48 | } else { | ||
49 | /* arm->vfp */ | ||
50 | - if (insn & (1 << 21)) { | ||
51 | + if (is_sysreg) { | ||
52 | rn >>= 1; | ||
53 | /* system register */ | ||
54 | switch (rn) { | ||
55 | -- | ||
56 | 2.20.1 | ||
57 | |||
58 | diff view generated by jsdifflib |
1 | The M-profile architecture floating point system supports | 1 | The functions qemu_get_timedate() and qemu_timedate_diff() take |
---|---|---|---|
2 | lazy FP state preservation, where FP registers are not | 2 | and return a time offset as an integer. Coverity points out that |
3 | pushed to the stack when an exception occurs but are instead | 3 | means that when an RTC device implementation holds an offset |
4 | only saved if and when the first FP instruction in the exception | 4 | as a time_t, as the m48t59 does, the time_t will get truncated. |
5 | handler is executed. Implement this in QEMU, corresponding | 5 | (CID 1507157, 1517772). |
6 | to the check of LSPACT in the pseudocode ExecuteFPCheck(). | 6 | |
7 | The functions work with time_t internally, so make them use that type | ||
8 | in their APIs. | ||
9 | |||
10 | Note that this won't help any Y2038 issues where either the device | ||
11 | model itself is keeping the offset in a 32-bit integer, or where the | ||
12 | hardware under emulation has Y2038 or other rollover problems. If we | ||
13 | missed any cases of the former then hopefully Coverity will warn us | ||
14 | about them since after this patch we'd be truncating a time_t in | ||
15 | assignments from qemu_timedate_diff().) | ||
7 | 16 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Message-id: 20190416125744.27770-24-peter.maydell@linaro.org | ||
11 | --- | 19 | --- |
12 | target/arm/cpu.h | 3 ++ | 20 | include/sysemu/rtc.h | 4 ++-- |
13 | target/arm/helper.h | 2 + | 21 | softmmu/rtc.c | 4 ++-- |
14 | target/arm/translate.h | 1 + | 22 | 2 files changed, 4 insertions(+), 4 deletions(-) |
15 | target/arm/helper.c | 112 +++++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate.c | 22 ++++++++ | ||
17 | 5 files changed, 140 insertions(+) | ||
18 | 23 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 24 | diff --git a/include/sysemu/rtc.h b/include/sysemu/rtc.h |
20 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 26 | --- a/include/sysemu/rtc.h |
22 | +++ b/target/arm/cpu.h | 27 | +++ b/include/sysemu/rtc.h |
23 | @@ -XXX,XX +XXX,XX @@ | 28 | @@ -XXX,XX +XXX,XX @@ |
24 | #define EXCP_NOCP 17 /* v7M NOCP UsageFault */ | 29 | * The behaviour of the clock whose value this function returns will |
25 | #define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */ | 30 | * depend on the -rtc command line option passed by the user. |
26 | #define EXCP_STKOF 19 /* v8M STKOF UsageFault */ | 31 | */ |
27 | +#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ | 32 | -void qemu_get_timedate(struct tm *tm, int offset); |
28 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 33 | +void qemu_get_timedate(struct tm *tm, time_t offset); |
29 | 34 | ||
30 | #define ARMV7M_EXCP_RESET 1 | 35 | /** |
31 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 36 | * qemu_timedate_diff: Return difference between a struct tm and the RTC |
32 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 37 | @@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset); |
33 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 38 | * a timestamp one hour further ahead than the current RTC time |
34 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 39 | * then this function will return 3600. |
35 | +/* For M profile only, set if FPCCR.LSPACT is set */ | 40 | */ |
36 | +FIELD(TBFLAG_A32, LSPACT, 18, 1) | 41 | -int qemu_timedate_diff(struct tm *tm); |
37 | /* For M profile only, set if we must create a new FP context */ | 42 | +time_t qemu_timedate_diff(struct tm *tm); |
38 | FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) | 43 | |
39 | /* For M profile only, set if FPCCR.S does not match current security state */ | 44 | #endif |
40 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 45 | diff --git a/softmmu/rtc.c b/softmmu/rtc.c |
41 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/target/arm/helper.h | 47 | --- a/softmmu/rtc.c |
43 | +++ b/target/arm/helper.h | 48 | +++ b/softmmu/rtc.c |
44 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v7m_blxns, void, env, i32) | 49 | @@ -XXX,XX +XXX,XX @@ static time_t qemu_ref_timedate(QEMUClockType clock) |
45 | 50 | return value; | |
46 | DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | ||
47 | |||
48 | +DEF_HELPER_1(v7m_preserve_fp_state, void, env) | ||
49 | + | ||
50 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | ||
51 | |||
52 | DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | ||
53 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/translate.h | ||
56 | +++ b/target/arm/translate.h | ||
57 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
58 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | ||
59 | bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | ||
60 | bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */ | ||
61 | + bool v7m_lspact; /* FPCCR.LSPACT set */ | ||
62 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | ||
63 | * so that top level loop can generate correct syndrome information. | ||
64 | */ | ||
65 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/helper.c | ||
68 | +++ b/target/arm/helper.c | ||
69 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
70 | g_assert_not_reached(); | ||
71 | } | 51 | } |
72 | 52 | ||
73 | +void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 53 | -void qemu_get_timedate(struct tm *tm, int offset) |
74 | +{ | 54 | +void qemu_get_timedate(struct tm *tm, time_t offset) |
75 | + /* translate.c should never generate calls here in user-only mode */ | ||
76 | + g_assert_not_reached(); | ||
77 | +} | ||
78 | + | ||
79 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
80 | { | 55 | { |
81 | /* The TT instructions can be used by unprivileged code, but in | 56 | time_t ti = qemu_ref_timedate(rtc_clock); |
82 | @@ -XXX,XX +XXX,XX @@ pend_fault: | 57 | |
83 | return false; | 58 | @@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset) |
59 | } | ||
84 | } | 60 | } |
85 | 61 | ||
86 | +void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 62 | -int qemu_timedate_diff(struct tm *tm) |
87 | +{ | 63 | +time_t qemu_timedate_diff(struct tm *tm) |
88 | + /* | 64 | { |
89 | + * Preserve FP state (because LSPACT was set and we are about | 65 | time_t seconds; |
90 | + * to execute an FP instruction). This corresponds to the | ||
91 | + * PreserveFPState() pseudocode. | ||
92 | + * We may throw an exception if the stacking fails. | ||
93 | + */ | ||
94 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
95 | + bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
96 | + bool negpri = !(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_HFRDY_MASK); | ||
97 | + bool is_priv = !(env->v7m.fpccr[is_secure] & R_V7M_FPCCR_USER_MASK); | ||
98 | + bool splimviol = env->v7m.fpccr[is_secure] & R_V7M_FPCCR_SPLIMVIOL_MASK; | ||
99 | + uint32_t fpcar = env->v7m.fpcar[is_secure]; | ||
100 | + bool stacked_ok = true; | ||
101 | + bool ts = is_secure && (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK); | ||
102 | + bool take_exception; | ||
103 | + | ||
104 | + /* Take the iothread lock as we are going to touch the NVIC */ | ||
105 | + qemu_mutex_lock_iothread(); | ||
106 | + | ||
107 | + /* Check the background context had access to the FPU */ | ||
108 | + if (!v7m_cpacr_pass(env, is_secure, is_priv)) { | ||
109 | + armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, is_secure); | ||
110 | + env->v7m.cfsr[is_secure] |= R_V7M_CFSR_NOCP_MASK; | ||
111 | + stacked_ok = false; | ||
112 | + } else if (!is_secure && !extract32(env->v7m.nsacr, 10, 1)) { | ||
113 | + armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S); | ||
114 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK; | ||
115 | + stacked_ok = false; | ||
116 | + } | ||
117 | + | ||
118 | + if (!splimviol && stacked_ok) { | ||
119 | + /* We only stack if the stack limit wasn't violated */ | ||
120 | + int i; | ||
121 | + ARMMMUIdx mmu_idx; | ||
122 | + | ||
123 | + mmu_idx = arm_v7m_mmu_idx_all(env, is_secure, is_priv, negpri); | ||
124 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | ||
125 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | ||
126 | + uint32_t faddr = fpcar + 4 * i; | ||
127 | + uint32_t slo = extract64(dn, 0, 32); | ||
128 | + uint32_t shi = extract64(dn, 32, 32); | ||
129 | + | ||
130 | + if (i >= 16) { | ||
131 | + faddr += 8; /* skip the slot for the FPSCR */ | ||
132 | + } | ||
133 | + stacked_ok = stacked_ok && | ||
134 | + v7m_stack_write(cpu, faddr, slo, mmu_idx, STACK_LAZYFP) && | ||
135 | + v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, STACK_LAZYFP); | ||
136 | + } | ||
137 | + | ||
138 | + stacked_ok = stacked_ok && | ||
139 | + v7m_stack_write(cpu, fpcar + 0x40, | ||
140 | + vfp_get_fpscr(env), mmu_idx, STACK_LAZYFP); | ||
141 | + } | ||
142 | + | ||
143 | + /* | ||
144 | + * We definitely pended an exception, but it's possible that it | ||
145 | + * might not be able to be taken now. If its priority permits us | ||
146 | + * to take it now, then we must not update the LSPACT or FP regs, | ||
147 | + * but instead jump out to take the exception immediately. | ||
148 | + * If it's just pending and won't be taken until the current | ||
149 | + * handler exits, then we do update LSPACT and the FP regs. | ||
150 | + */ | ||
151 | + take_exception = !stacked_ok && | ||
152 | + armv7m_nvic_can_take_pending_exception(env->nvic); | ||
153 | + | ||
154 | + qemu_mutex_unlock_iothread(); | ||
155 | + | ||
156 | + if (take_exception) { | ||
157 | + raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC()); | ||
158 | + } | ||
159 | + | ||
160 | + env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK; | ||
161 | + | ||
162 | + if (ts) { | ||
163 | + /* Clear s0 to s31 and the FPSCR */ | ||
164 | + int i; | ||
165 | + | ||
166 | + for (i = 0; i < 32; i += 2) { | ||
167 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
168 | + } | ||
169 | + vfp_set_fpscr(env, 0); | ||
170 | + } | ||
171 | + /* | ||
172 | + * Otherwise s0 to s15 and FPSCR are UNKNOWN; we choose to leave them | ||
173 | + * unchanged. | ||
174 | + */ | ||
175 | +} | ||
176 | + | ||
177 | /* Write to v7M CONTROL.SPSEL bit for the specified security bank. | ||
178 | * This may change the current stack pointer between Main and Process | ||
179 | * stack pointers if it is done for the CONTROL register for the current | ||
180 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | ||
181 | [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
182 | [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
183 | [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
184 | + [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
185 | }; | ||
186 | |||
187 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
188 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
189 | return; | ||
190 | } | ||
191 | break; | ||
192 | + case EXCP_LAZYFP: | ||
193 | + /* | ||
194 | + * We already pended the specific exception in the NVIC in the | ||
195 | + * v7m_preserve_fp_state() helper function. | ||
196 | + */ | ||
197 | + break; | ||
198 | default: | ||
199 | cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); | ||
200 | return; /* Never happens. Keep compiler happy. */ | ||
201 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
202 | flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); | ||
203 | } | ||
204 | |||
205 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
206 | + bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
207 | + | ||
208 | + if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) { | ||
209 | + flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); | ||
210 | + } | ||
211 | + } | ||
212 | + | ||
213 | *pflags = flags; | ||
214 | *cs_base = 0; | ||
215 | } | ||
216 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
217 | index XXXXXXX..XXXXXXX 100644 | ||
218 | --- a/target/arm/translate.c | ||
219 | +++ b/target/arm/translate.c | ||
220 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
221 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
222 | /* Handle M-profile lazy FP state mechanics */ | ||
223 | |||
224 | + /* Trigger lazy-state preservation if necessary */ | ||
225 | + if (s->v7m_lspact) { | ||
226 | + /* | ||
227 | + * Lazy state saving affects external memory and also the NVIC, | ||
228 | + * so we must mark it as an IO operation for icount. | ||
229 | + */ | ||
230 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
231 | + gen_io_start(); | ||
232 | + } | ||
233 | + gen_helper_v7m_preserve_fp_state(cpu_env); | ||
234 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
235 | + gen_io_end(); | ||
236 | + } | ||
237 | + /* | ||
238 | + * If the preserve_fp_state helper doesn't throw an exception | ||
239 | + * then it will clear LSPACT; we don't need to repeat this for | ||
240 | + * any further FP insns in this TB. | ||
241 | + */ | ||
242 | + s->v7m_lspact = false; | ||
243 | + } | ||
244 | + | ||
245 | /* Update ownership of FP context: set FPCCR.S to match current state */ | ||
246 | if (s->v8m_fpccr_s_wrong) { | ||
247 | TCGv_i32 tmp; | ||
248 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
249 | dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | ||
250 | dc->v7m_new_fp_ctxt_needed = | ||
251 | FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED); | ||
252 | + dc->v7m_lspact = FIELD_EX32(tb_flags, TBFLAG_A32, LSPACT); | ||
253 | dc->cp_regs = cpu->cp_regs; | ||
254 | dc->features = env->features; | ||
255 | 66 | ||
256 | -- | 67 | -- |
257 | 2.20.1 | 68 | 2.34.1 |
258 | 69 | ||
259 | 70 | diff view generated by jsdifflib |
1 | Like AArch64, M-profile floating point has no FPEXC enable | 1 | Where architecturally one ARM_FEATURE_X flag implies another |
---|---|---|---|
2 | bit to gate floating point; so always set the VFPEN TB flag. | 2 | ARM_FEATURE_Y, we allow the CPU init function to only set X, and then |
3 | 3 | set Y for it. Currently we do this in two places -- we set a few | |
4 | M-profile also has CPACR and NSACR similar to A-profile; | 4 | flags in arm_cpu_post_init() because we need them to decide which |
5 | they behave slightly differently: | 5 | properties to create on the CPU object, and then we do the rest in |
6 | * the CPACR is banked between Secure and Non-Secure | 6 | arm_cpu_realizefn(). However, this is fragile, because it's easy to |
7 | * if the NSACR forces a trap then this is taken to | 7 | add a new property and not notice that this means that an X-implies-Y |
8 | the Secure state, not the Non-Secure state | 8 | check now has to move from realize to post-init. |
9 | 9 | ||
10 | Honour the CPACR and NSACR settings. The NSACR handling | 10 | As a specific example, the pmsav7-dregion property is conditional |
11 | requires us to borrow the exception.target_el field | 11 | on ARM_FEATURE_PMSA && ARM_FEATURE_V7, which means it won't appear |
12 | (usually meaningless for M profile) to distinguish the | 12 | on the Cortex-M33 and -M55, because they set ARM_FEATURE_V8 and |
13 | NOCP UsageFault taken to Secure state from the more | 13 | rely on V8-implies-V7, which doesn't happen until the realizefn. |
14 | usual fault taken to the current security state. | 14 | |
15 | Move all of these X-implies-Y checks into a new function, which | ||
16 | we call at the top of arm_cpu_post_init(), so the feature bits | ||
17 | are available at that point. | ||
18 | |||
19 | This does now give us the reverse issue, that if there's a feature | ||
20 | bit which is enabled or disabled by the setting of a property then | ||
21 | then X-implies-Y features that are dependent on that property need to | ||
22 | be in realize, not in this new function. But the only one of those | ||
23 | is the "EL3 implies VBAR" which is already in the right place, so | ||
24 | putting things this way round seems better to me. | ||
15 | 25 | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-id: 20190416125744.27770-6-peter.maydell@linaro.org | 28 | Message-id: 20230724174335.2150499-2-peter.maydell@linaro.org |
19 | --- | 29 | --- |
20 | target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++--- | 30 | target/arm/cpu.c | 179 +++++++++++++++++++++++++---------------------- |
21 | target/arm/translate.c | 10 ++++++-- | 31 | 1 file changed, 97 insertions(+), 82 deletions(-) |
22 | 2 files changed, 60 insertions(+), 5 deletions(-) | 32 | |
23 | 33 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | |
24 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/helper.c | 35 | --- a/target/arm/cpu.c |
27 | +++ b/target/arm/helper.c | 36 | +++ b/target/arm/cpu.c |
28 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | 37 | @@ -XXX,XX +XXX,XX @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) |
29 | return target_el; | 38 | NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; |
30 | } | 39 | } |
31 | 40 | ||
32 | +/* | 41 | +static void arm_cpu_propagate_feature_implications(ARMCPU *cpu) |
33 | + * Return true if the v7M CPACR permits access to the FPU for the specified | ||
34 | + * security state and privilege level. | ||
35 | + */ | ||
36 | +static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | ||
37 | +{ | 42 | +{ |
38 | + switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { | 43 | + CPUARMState *env = &cpu->env; |
39 | + case 0: | 44 | + bool no_aa32 = false; |
40 | + case 2: /* UNPREDICTABLE: we treat like 0 */ | 45 | + |
41 | + return false; | 46 | + /* |
42 | + case 1: | 47 | + * Some features automatically imply others: set the feature |
43 | + return is_priv; | 48 | + * bits explicitly for these cases. |
44 | + case 3: | 49 | + */ |
45 | + return true; | 50 | + |
46 | + default: | 51 | + if (arm_feature(env, ARM_FEATURE_M)) { |
47 | + g_assert_not_reached(); | 52 | + set_feature(env, ARM_FEATURE_PMSA); |
53 | + } | ||
54 | + | ||
55 | + if (arm_feature(env, ARM_FEATURE_V8)) { | ||
56 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
57 | + set_feature(env, ARM_FEATURE_V7); | ||
58 | + } else { | ||
59 | + set_feature(env, ARM_FEATURE_V7VE); | ||
60 | + } | ||
61 | + } | ||
62 | + | ||
63 | + /* | ||
64 | + * There exist AArch64 cpus without AArch32 support. When KVM | ||
65 | + * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. | ||
66 | + * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. | ||
67 | + * As a general principle, we also do not make ID register | ||
68 | + * consistency checks anywhere unless using TCG, because only | ||
69 | + * for TCG would a consistency-check failure be a QEMU bug. | ||
70 | + */ | ||
71 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
72 | + no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); | ||
73 | + } | ||
74 | + | ||
75 | + if (arm_feature(env, ARM_FEATURE_V7VE)) { | ||
76 | + /* | ||
77 | + * v7 Virtualization Extensions. In real hardware this implies | ||
78 | + * EL2 and also the presence of the Security Extensions. | ||
79 | + * For QEMU, for backwards-compatibility we implement some | ||
80 | + * CPUs or CPU configs which have no actual EL2 or EL3 but do | ||
81 | + * include the various other features that V7VE implies. | ||
82 | + * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | ||
83 | + * Security Extensions is ARM_FEATURE_EL3. | ||
84 | + */ | ||
85 | + assert(!tcg_enabled() || no_aa32 || | ||
86 | + cpu_isar_feature(aa32_arm_div, cpu)); | ||
87 | + set_feature(env, ARM_FEATURE_LPAE); | ||
88 | + set_feature(env, ARM_FEATURE_V7); | ||
89 | + } | ||
90 | + if (arm_feature(env, ARM_FEATURE_V7)) { | ||
91 | + set_feature(env, ARM_FEATURE_VAPA); | ||
92 | + set_feature(env, ARM_FEATURE_THUMB2); | ||
93 | + set_feature(env, ARM_FEATURE_MPIDR); | ||
94 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
95 | + set_feature(env, ARM_FEATURE_V6K); | ||
96 | + } else { | ||
97 | + set_feature(env, ARM_FEATURE_V6); | ||
98 | + } | ||
99 | + | ||
100 | + /* | ||
101 | + * Always define VBAR for V7 CPUs even if it doesn't exist in | ||
102 | + * non-EL3 configs. This is needed by some legacy boards. | ||
103 | + */ | ||
104 | + set_feature(env, ARM_FEATURE_VBAR); | ||
105 | + } | ||
106 | + if (arm_feature(env, ARM_FEATURE_V6K)) { | ||
107 | + set_feature(env, ARM_FEATURE_V6); | ||
108 | + set_feature(env, ARM_FEATURE_MVFR); | ||
109 | + } | ||
110 | + if (arm_feature(env, ARM_FEATURE_V6)) { | ||
111 | + set_feature(env, ARM_FEATURE_V5); | ||
112 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
113 | + assert(!tcg_enabled() || no_aa32 || | ||
114 | + cpu_isar_feature(aa32_jazelle, cpu)); | ||
115 | + set_feature(env, ARM_FEATURE_AUXCR); | ||
116 | + } | ||
117 | + } | ||
118 | + if (arm_feature(env, ARM_FEATURE_V5)) { | ||
119 | + set_feature(env, ARM_FEATURE_V4T); | ||
120 | + } | ||
121 | + if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
122 | + set_feature(env, ARM_FEATURE_V7MP); | ||
123 | + } | ||
124 | + if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | ||
125 | + set_feature(env, ARM_FEATURE_CBAR); | ||
126 | + } | ||
127 | + if (arm_feature(env, ARM_FEATURE_THUMB2) && | ||
128 | + !arm_feature(env, ARM_FEATURE_M)) { | ||
129 | + set_feature(env, ARM_FEATURE_THUMB_DSP); | ||
48 | + } | 130 | + } |
49 | +} | 131 | +} |
50 | + | 132 | + |
51 | static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | 133 | void arm_cpu_post_init(Object *obj) |
52 | ARMMMUIdx mmu_idx, bool ignfault) | ||
53 | { | 134 | { |
54 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 135 | ARMCPU *cpu = ARM_CPU(obj); |
55 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK; | 136 | |
56 | break; | 137 | - /* M profile implies PMSA. We have to do this here rather than |
57 | case EXCP_NOCP: | 138 | - * in realize with the other feature-implication checks because |
58 | - armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | 139 | - * we look at the PMSA bit to see if we should add some properties. |
59 | - env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; | 140 | + /* |
60 | + { | 141 | + * Some features imply others. Figure this out now, because we |
61 | + /* | 142 | + * are going to look at the feature bits in deciding which |
62 | + * NOCP might be directed to something other than the current | 143 | + * properties to add. |
63 | + * security state if this fault is because of NSACR; we indicate | 144 | */ |
64 | + * the target security state using exception.target_el. | 145 | - if (arm_feature(&cpu->env, ARM_FEATURE_M)) { |
65 | + */ | 146 | - set_feature(&cpu->env, ARM_FEATURE_PMSA); |
66 | + int target_secstate; | 147 | - } |
67 | + | 148 | + arm_cpu_propagate_feature_implications(cpu); |
68 | + if (env->exception.target_el == 3) { | 149 | |
69 | + target_secstate = M_REG_S; | 150 | if (arm_feature(&cpu->env, ARM_FEATURE_CBAR) || |
70 | + } else { | 151 | arm_feature(&cpu->env, ARM_FEATURE_CBAR_RO)) { |
71 | + target_secstate = env->v7m.secure; | 152 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
72 | + } | 153 | CPUARMState *env = &cpu->env; |
73 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, target_secstate); | 154 | int pagebits; |
74 | + env->v7m.cfsr[target_secstate] |= R_V7M_CFSR_NOCP_MASK; | 155 | Error *local_err = NULL; |
75 | break; | 156 | - bool no_aa32 = false; |
76 | + } | 157 | |
77 | case EXCP_INVSTATE: | 158 | /* Use pc-relative instructions in system-mode */ |
78 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | 159 | #ifndef CONFIG_USER_ONLY |
79 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK; | 160 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
80 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | 161 | cpu->isar.id_isar3 = u; |
81 | return 0; | ||
82 | } | 162 | } |
83 | 163 | ||
84 | + if (arm_feature(env, ARM_FEATURE_M)) { | 164 | - /* Some features automatically imply others: */ |
85 | + /* CPACR can cause a NOCP UsageFault taken to current security state */ | 165 | - if (arm_feature(env, ARM_FEATURE_V8)) { |
86 | + if (!v7m_cpacr_pass(env, env->v7m.secure, cur_el != 0)) { | 166 | - if (arm_feature(env, ARM_FEATURE_M)) { |
87 | + return 1; | 167 | - set_feature(env, ARM_FEATURE_V7); |
88 | + } | 168 | - } else { |
89 | + | 169 | - set_feature(env, ARM_FEATURE_V7VE); |
90 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY) && !env->v7m.secure) { | 170 | - } |
91 | + if (!extract32(env->v7m.nsacr, 10, 1)) { | 171 | - } |
92 | + /* FP insns cause a NOCP UsageFault taken to Secure */ | 172 | - |
93 | + return 3; | 173 | - /* |
94 | + } | 174 | - * There exist AArch64 cpus without AArch32 support. When KVM |
95 | + } | 175 | - * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. |
96 | + | 176 | - * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. |
97 | + return 0; | 177 | - * As a general principle, we also do not make ID register |
98 | + } | 178 | - * consistency checks anywhere unless using TCG, because only |
99 | + | 179 | - * for TCG would a consistency-check failure be a QEMU bug. |
100 | /* The CPACR controls traps to EL1, or PL1 if we're 32 bit: | 180 | - */ |
101 | * 0, 2 : trap EL0 and EL1/PL1 accesses | 181 | - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
102 | * 1 : trap only EL0 accesses | 182 | - no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); |
103 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 183 | - } |
104 | flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); | 184 | - |
105 | flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); | 185 | - if (arm_feature(env, ARM_FEATURE_V7VE)) { |
106 | if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) | 186 | - /* v7 Virtualization Extensions. In real hardware this implies |
107 | - || arm_el_is_aa64(env, 1)) { | 187 | - * EL2 and also the presence of the Security Extensions. |
108 | + || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | 188 | - * For QEMU, for backwards-compatibility we implement some |
109 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | 189 | - * CPUs or CPU configs which have no actual EL2 or EL3 but do |
110 | } | 190 | - * include the various other features that V7VE implies. |
111 | flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); | 191 | - * Presence of EL2 itself is ARM_FEATURE_EL2, and of the |
112 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 192 | - * Security Extensions is ARM_FEATURE_EL3. |
113 | index XXXXXXX..XXXXXXX 100644 | 193 | - */ |
114 | --- a/target/arm/translate.c | 194 | - assert(!tcg_enabled() || no_aa32 || |
115 | +++ b/target/arm/translate.c | 195 | - cpu_isar_feature(aa32_arm_div, cpu)); |
116 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 196 | - set_feature(env, ARM_FEATURE_LPAE); |
117 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | 197 | - set_feature(env, ARM_FEATURE_V7); |
118 | */ | 198 | - } |
119 | if (s->fp_excp_el) { | 199 | - if (arm_feature(env, ARM_FEATURE_V7)) { |
120 | - gen_exception_insn(s, 4, EXCP_UDEF, | 200 | - set_feature(env, ARM_FEATURE_VAPA); |
121 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | 201 | - set_feature(env, ARM_FEATURE_THUMB2); |
122 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | 202 | - set_feature(env, ARM_FEATURE_MPIDR); |
123 | + gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | 203 | - if (!arm_feature(env, ARM_FEATURE_M)) { |
124 | + s->fp_excp_el); | 204 | - set_feature(env, ARM_FEATURE_V6K); |
125 | + } else { | 205 | - } else { |
126 | + gen_exception_insn(s, 4, EXCP_UDEF, | 206 | - set_feature(env, ARM_FEATURE_V6); |
127 | + syn_fp_access_trap(1, 0xe, false), | 207 | - } |
128 | + s->fp_excp_el); | 208 | - |
129 | + } | 209 | - /* Always define VBAR for V7 CPUs even if it doesn't exist in |
130 | return 0; | 210 | - * non-EL3 configs. This is needed by some legacy boards. |
131 | } | 211 | - */ |
132 | 212 | - set_feature(env, ARM_FEATURE_VBAR); | |
213 | - } | ||
214 | - if (arm_feature(env, ARM_FEATURE_V6K)) { | ||
215 | - set_feature(env, ARM_FEATURE_V6); | ||
216 | - set_feature(env, ARM_FEATURE_MVFR); | ||
217 | - } | ||
218 | - if (arm_feature(env, ARM_FEATURE_V6)) { | ||
219 | - set_feature(env, ARM_FEATURE_V5); | ||
220 | - if (!arm_feature(env, ARM_FEATURE_M)) { | ||
221 | - assert(!tcg_enabled() || no_aa32 || | ||
222 | - cpu_isar_feature(aa32_jazelle, cpu)); | ||
223 | - set_feature(env, ARM_FEATURE_AUXCR); | ||
224 | - } | ||
225 | - } | ||
226 | - if (arm_feature(env, ARM_FEATURE_V5)) { | ||
227 | - set_feature(env, ARM_FEATURE_V4T); | ||
228 | - } | ||
229 | - if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
230 | - set_feature(env, ARM_FEATURE_V7MP); | ||
231 | - } | ||
232 | - if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | ||
233 | - set_feature(env, ARM_FEATURE_CBAR); | ||
234 | - } | ||
235 | - if (arm_feature(env, ARM_FEATURE_THUMB2) && | ||
236 | - !arm_feature(env, ARM_FEATURE_M)) { | ||
237 | - set_feature(env, ARM_FEATURE_THUMB_DSP); | ||
238 | - } | ||
239 | |||
240 | /* | ||
241 | * We rely on no XScale CPU having VFP so we can use the same bits in the | ||
133 | -- | 242 | -- |
134 | 2.20.1 | 243 | 2.34.1 |
135 | |||
136 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Correct the decode of the M-profile "coprocessor and | ||
2 | floating-point instructions" space: | ||
3 | * op0 == 0b11 is always unallocated | ||
4 | * if the CPU has an FPU then all insns with op1 == 0b101 | ||
5 | are floating point and go to disas_vfp_insn() | ||
6 | 1 | ||
7 | For the moment we leave VLLDM and VLSTM as NOPs; in | ||
8 | a later commit we will fill in the proper implementation | ||
9 | for the case where an FPU is present. | ||
10 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20190416125744.27770-7-peter.maydell@linaro.org | ||
14 | --- | ||
15 | target/arm/translate.c | 26 ++++++++++++++++++++++---- | ||
16 | 1 file changed, 22 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/translate.c | ||
21 | +++ b/target/arm/translate.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
23 | case 6: case 7: case 14: case 15: | ||
24 | /* Coprocessor. */ | ||
25 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
26 | - /* We don't currently implement M profile FP support, | ||
27 | - * so this entire space should give a NOCP fault, with | ||
28 | - * the exception of the v8M VLLDM and VLSTM insns, which | ||
29 | - * must be NOPs in Secure state and UNDEF in Nonsecure state. | ||
30 | + /* 0b111x_11xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx */ | ||
31 | + if (extract32(insn, 24, 2) == 3) { | ||
32 | + goto illegal_op; /* op0 = 0b11 : unallocated */ | ||
33 | + } | ||
34 | + | ||
35 | + /* | ||
36 | + * Decode VLLDM and VLSTM first: these are nonstandard because: | ||
37 | + * * if there is no FPU then these insns must NOP in | ||
38 | + * Secure state and UNDEF in Nonsecure state | ||
39 | + * * if there is an FPU then these insns do not have | ||
40 | + * the usual behaviour that disas_vfp_insn() provides of | ||
41 | + * being controlled by CPACR/NSACR enable bits or the | ||
42 | + * lazy-stacking logic. | ||
43 | */ | ||
44 | if (arm_dc_feature(s, ARM_FEATURE_V8) && | ||
45 | (insn & 0xffa00f00) == 0xec200a00) { | ||
46 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
47 | /* Just NOP since FP support is not implemented */ | ||
48 | break; | ||
49 | } | ||
50 | + if (arm_dc_feature(s, ARM_FEATURE_VFP) && | ||
51 | + ((insn >> 8) & 0xe) == 10) { | ||
52 | + /* FP, and the CPU supports it */ | ||
53 | + if (disas_vfp_insn(s, insn)) { | ||
54 | + goto illegal_op; | ||
55 | + } | ||
56 | + break; | ||
57 | + } | ||
58 | + | ||
59 | /* All other insns: NOCP */ | ||
60 | gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
61 | default_exception_el(s)); | ||
62 | -- | ||
63 | 2.20.1 | ||
64 | |||
65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If the floating point extension is present, then the SG instruction | ||
2 | must clear the CONTROL_S.SFPA bit. Implement this. | ||
3 | 1 | ||
4 | (On a no-FPU system the bit will always be zero, so we don't need | ||
5 | to make the clearing of the bit conditional on ARM_FEATURE_VFP.) | ||
6 | |||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190416125744.27770-8-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/helper.c | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper.c | ||
17 | +++ b/target/arm/helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
19 | qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32 | ||
20 | ", executing it\n", env->regs[15]); | ||
21 | env->regs[14] &= ~1; | ||
22 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | ||
23 | switch_v7m_security_state(env, true); | ||
24 | xpsr_write(env, 0, XPSR_IT); | ||
25 | env->regs[15] += 4; | ||
26 | -- | ||
27 | 2.20.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Currently the code in v7m_push_stack() which detects a violation | ||
2 | of the v8M stack limit simply returns early if it does so. This | ||
3 | is OK for the current integer-only code, but won't work for the | ||
4 | floating point handling we're about to add. We need to continue | ||
5 | executing the rest of the function so that we check for other | ||
6 | exceptions like not having permission to use the FPU and so | ||
7 | that we correctly set the FPCCR state if we are doing lazy | ||
8 | stacking. Refactor to avoid the early return. | ||
9 | 1 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20190416125744.27770-10-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/arm/helper.c | 23 ++++++++++++++++++----- | ||
15 | 1 file changed, 18 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper.c | ||
20 | +++ b/target/arm/helper.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
22 | * should ignore further stack faults trying to process | ||
23 | * that derived exception.) | ||
24 | */ | ||
25 | - bool stacked_ok; | ||
26 | + bool stacked_ok = true, limitviol = false; | ||
27 | CPUARMState *env = &cpu->env; | ||
28 | uint32_t xpsr = xpsr_read(env); | ||
29 | uint32_t frameptr = env->regs[13]; | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
31 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | ||
32 | env->v7m.secure); | ||
33 | env->regs[13] = limit; | ||
34 | - return true; | ||
35 | + /* | ||
36 | + * We won't try to perform any further memory accesses but | ||
37 | + * we must continue through the following code to check for | ||
38 | + * permission faults during FPU state preservation, and we | ||
39 | + * must update FPCCR if lazy stacking is enabled. | ||
40 | + */ | ||
41 | + limitviol = true; | ||
42 | + stacked_ok = false; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
47 | * (which may be taken in preference to the one we started with | ||
48 | * if it has higher priority). | ||
49 | */ | ||
50 | - stacked_ok = | ||
51 | + stacked_ok = stacked_ok && | ||
52 | v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) && | ||
53 | v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) && | ||
54 | v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) && | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
56 | v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | ||
57 | v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | ||
58 | |||
59 | - /* Update SP regardless of whether any of the stack accesses failed. */ | ||
60 | - env->regs[13] = frameptr; | ||
61 | + /* | ||
62 | + * If we broke a stack limit then SP was already updated earlier; | ||
63 | + * otherwise we update SP regardless of whether any of the stack | ||
64 | + * accesses failed or we took some other kind of fault. | ||
65 | + */ | ||
66 | + if (!limitviol) { | ||
67 | + env->regs[13] = frameptr; | ||
68 | + } | ||
69 | |||
70 | return !stacked_ok; | ||
71 | } | ||
72 | -- | ||
73 | 2.20.1 | ||
74 | |||
75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Handle floating point registers in exception entry. | ||
2 | This corresponds to the FP-specific parts of the pseudocode | ||
3 | functions ActivateException() and PushStack(). | ||
4 | 1 | ||
5 | We defer the code corresponding to UpdateFPCCR() to a later patch. | ||
6 | |||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190416125744.27770-11-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/helper.c | 98 +++++++++++++++++++++++++++++++++++++++++++-- | ||
12 | 1 file changed, 95 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper.c | ||
17 | +++ b/target/arm/helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
19 | switch_v7m_security_state(env, targets_secure); | ||
20 | write_v7m_control_spsel(env, 0); | ||
21 | arm_clear_exclusive(env); | ||
22 | + /* Clear SFPA and FPCA (has no effect if no FPU) */ | ||
23 | + env->v7m.control[M_REG_S] &= | ||
24 | + ~(R_V7M_CONTROL_FPCA_MASK | R_V7M_CONTROL_SFPA_MASK); | ||
25 | /* Clear IT bits */ | ||
26 | env->condexec_bits = 0; | ||
27 | env->regs[14] = lr; | ||
28 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
29 | uint32_t xpsr = xpsr_read(env); | ||
30 | uint32_t frameptr = env->regs[13]; | ||
31 | ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
32 | + uint32_t framesize; | ||
33 | + bool nsacr_cp10 = extract32(env->v7m.nsacr, 10, 1); | ||
34 | + | ||
35 | + if ((env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) && | ||
36 | + (env->v7m.secure || nsacr_cp10)) { | ||
37 | + if (env->v7m.secure && | ||
38 | + env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK) { | ||
39 | + framesize = 0xa8; | ||
40 | + } else { | ||
41 | + framesize = 0x68; | ||
42 | + } | ||
43 | + } else { | ||
44 | + framesize = 0x20; | ||
45 | + } | ||
46 | |||
47 | /* Align stack pointer if the guest wants that */ | ||
48 | if ((frameptr & 4) && | ||
49 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
50 | xpsr |= XPSR_SPREALIGN; | ||
51 | } | ||
52 | |||
53 | - frameptr -= 0x20; | ||
54 | + xpsr &= ~XPSR_SFPA; | ||
55 | + if (env->v7m.secure && | ||
56 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | ||
57 | + xpsr |= XPSR_SFPA; | ||
58 | + } | ||
59 | + | ||
60 | + frameptr -= framesize; | ||
61 | |||
62 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
63 | uint32_t limit = v7m_sp_limit(env); | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
65 | v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | ||
66 | v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | ||
67 | |||
68 | + if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) { | ||
69 | + /* FPU is active, try to save its registers */ | ||
70 | + bool fpccr_s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
71 | + bool lspact = env->v7m.fpccr[fpccr_s] & R_V7M_FPCCR_LSPACT_MASK; | ||
72 | + | ||
73 | + if (lspact && arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
74 | + qemu_log_mask(CPU_LOG_INT, | ||
75 | + "...SecureFault because LSPACT and FPCA both set\n"); | ||
76 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | ||
77 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
78 | + } else if (!env->v7m.secure && !nsacr_cp10) { | ||
79 | + qemu_log_mask(CPU_LOG_INT, | ||
80 | + "...Secure UsageFault with CFSR.NOCP because " | ||
81 | + "NSACR.CP10 prevents stacking FP regs\n"); | ||
82 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S); | ||
83 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK; | ||
84 | + } else { | ||
85 | + if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) { | ||
86 | + /* Lazy stacking disabled, save registers now */ | ||
87 | + int i; | ||
88 | + bool cpacr_pass = v7m_cpacr_pass(env, env->v7m.secure, | ||
89 | + arm_current_el(env) != 0); | ||
90 | + | ||
91 | + if (stacked_ok && !cpacr_pass) { | ||
92 | + /* | ||
93 | + * Take UsageFault if CPACR forbids access. The pseudocode | ||
94 | + * here does a full CheckCPEnabled() but we know the NSACR | ||
95 | + * check can never fail as we have already handled that. | ||
96 | + */ | ||
97 | + qemu_log_mask(CPU_LOG_INT, | ||
98 | + "...UsageFault with CFSR.NOCP because " | ||
99 | + "CPACR.CP10 prevents stacking FP regs\n"); | ||
100 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | ||
101 | + env->v7m.secure); | ||
102 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; | ||
103 | + stacked_ok = false; | ||
104 | + } | ||
105 | + | ||
106 | + for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | ||
107 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | ||
108 | + uint32_t faddr = frameptr + 0x20 + 4 * i; | ||
109 | + uint32_t slo = extract64(dn, 0, 32); | ||
110 | + uint32_t shi = extract64(dn, 32, 32); | ||
111 | + | ||
112 | + if (i >= 16) { | ||
113 | + faddr += 8; /* skip the slot for the FPSCR */ | ||
114 | + } | ||
115 | + stacked_ok = stacked_ok && | ||
116 | + v7m_stack_write(cpu, faddr, slo, mmu_idx, false) && | ||
117 | + v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false); | ||
118 | + } | ||
119 | + stacked_ok = stacked_ok && | ||
120 | + v7m_stack_write(cpu, frameptr + 0x60, | ||
121 | + vfp_get_fpscr(env), mmu_idx, false); | ||
122 | + if (cpacr_pass) { | ||
123 | + for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | ||
124 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
125 | + } | ||
126 | + vfp_set_fpscr(env, 0); | ||
127 | + } | ||
128 | + } else { | ||
129 | + /* Lazy stacking enabled, save necessary info to stack later */ | ||
130 | + /* TODO : equivalent of UpdateFPCCR() pseudocode */ | ||
131 | + } | ||
132 | + } | ||
133 | + } | ||
134 | + | ||
135 | /* | ||
136 | * If we broke a stack limit then SP was already updated earlier; | ||
137 | * otherwise we update SP regardless of whether any of the stack | ||
138 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
139 | |||
140 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
141 | lr = R_V7M_EXCRET_RES1_MASK | | ||
142 | - R_V7M_EXCRET_DCRS_MASK | | ||
143 | - R_V7M_EXCRET_FTYPE_MASK; | ||
144 | + R_V7M_EXCRET_DCRS_MASK; | ||
145 | /* The S bit indicates whether we should return to Secure | ||
146 | * or NonSecure (ie our current state). | ||
147 | * The ES bit indicates whether we're taking this exception | ||
148 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
149 | if (env->v7m.secure) { | ||
150 | lr |= R_V7M_EXCRET_S_MASK; | ||
151 | } | ||
152 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) { | ||
153 | + lr |= R_V7M_EXCRET_FTYPE_MASK; | ||
154 | + } | ||
155 | } else { | ||
156 | lr = R_V7M_EXCRET_RES1_MASK | | ||
157 | R_V7M_EXCRET_S_MASK | | ||
158 | -- | ||
159 | 2.20.1 | ||
160 | |||
161 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For v8M floating point support, transitions from Secure | ||
2 | to Non-secure state via BLNS and BLXNS must clear the | ||
3 | CONTROL.SFPA bit. (This corresponds to the pseudocode | ||
4 | BranchToNS() function.) | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190416125744.27770-13-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/helper.c | 4 ++++ | ||
11 | 1 file changed, 4 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper.c | ||
16 | +++ b/target/arm/helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
18 | /* translate.c should have made BXNS UNDEF unless we're secure */ | ||
19 | assert(env->v7m.secure); | ||
20 | |||
21 | + if (!(dest & 1)) { | ||
22 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | ||
23 | + } | ||
24 | switch_v7m_security_state(env, dest & 1); | ||
25 | env->thumb = 1; | ||
26 | env->regs[15] = dest & ~1; | ||
27 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
28 | */ | ||
29 | write_v7m_exception(env, 1); | ||
30 | } | ||
31 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | ||
32 | switch_v7m_security_state(env, 0); | ||
33 | env->thumb = 1; | ||
34 | env->regs[15] = dest; | ||
35 | -- | ||
36 | 2.20.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The TailChain() pseudocode specifies that a tail chaining | ||
2 | exception should sanitize the excReturn all-ones bits and | ||
3 | (if there is no FPU) the excReturn FType bits; we weren't | ||
4 | doing this. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190416125744.27770-14-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/helper.c | 8 ++++++++ | ||
11 | 1 file changed, 8 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper.c | ||
16 | +++ b/target/arm/helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
18 | qemu_log_mask(CPU_LOG_INT, "...taking pending %s exception %d\n", | ||
19 | targets_secure ? "secure" : "nonsecure", exc); | ||
20 | |||
21 | + if (dotailchain) { | ||
22 | + /* Sanitize LR FType and PREFIX bits */ | ||
23 | + if (!arm_feature(env, ARM_FEATURE_VFP)) { | ||
24 | + lr |= R_V7M_EXCRET_FTYPE_MASK; | ||
25 | + } | ||
26 | + lr = deposit32(lr, 24, 8, 0xff); | ||
27 | + } | ||
28 | + | ||
29 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
30 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
31 | (lr & R_V7M_EXCRET_S_MASK)) { | ||
32 | -- | ||
33 | 2.20.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The magic value pushed onto the callee stack as an integrity | ||
2 | check is different if floating point is present. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20190416125744.27770-15-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper.c | 22 +++++++++++++++++++--- | ||
9 | 1 file changed, 19 insertions(+), 3 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/helper.c | ||
14 | +++ b/target/arm/helper.c | ||
15 | @@ -XXX,XX +XXX,XX @@ load_fail: | ||
16 | return false; | ||
17 | } | ||
18 | |||
19 | +static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr) | ||
20 | +{ | ||
21 | + /* | ||
22 | + * Return the integrity signature value for the callee-saves | ||
23 | + * stack frame section. @lr is the exception return payload/LR value | ||
24 | + * whose FType bit forms bit 0 of the signature if FP is present. | ||
25 | + */ | ||
26 | + uint32_t sig = 0xfefa125a; | ||
27 | + | ||
28 | + if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) { | ||
29 | + sig |= 1; | ||
30 | + } | ||
31 | + return sig; | ||
32 | +} | ||
33 | + | ||
34 | static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
35 | bool ignore_faults) | ||
36 | { | ||
37 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
38 | bool stacked_ok; | ||
39 | uint32_t limit; | ||
40 | bool want_psp; | ||
41 | + uint32_t sig; | ||
42 | |||
43 | if (dotailchain) { | ||
44 | bool mode = lr & R_V7M_EXCRET_MODE_MASK; | ||
45 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
46 | /* Write as much of the stack frame as we can. A write failure may | ||
47 | * cause us to pend a derived exception. | ||
48 | */ | ||
49 | + sig = v7m_integrity_sig(env, lr); | ||
50 | stacked_ok = | ||
51 | - v7m_stack_write(cpu, frameptr, 0xfefa125b, mmu_idx, ignore_faults) && | ||
52 | + v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) && | ||
53 | v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, | ||
54 | ignore_faults) && | ||
55 | v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, | ||
56 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
57 | if (return_to_secure && | ||
58 | ((excret & R_V7M_EXCRET_ES_MASK) == 0 || | ||
59 | (excret & R_V7M_EXCRET_DCRS_MASK) == 0)) { | ||
60 | - uint32_t expected_sig = 0xfefa125b; | ||
61 | uint32_t actual_sig; | ||
62 | |||
63 | pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx); | ||
64 | |||
65 | - if (pop_ok && expected_sig != actual_sig) { | ||
66 | + if (pop_ok && v7m_integrity_sig(env, excret) != actual_sig) { | ||
67 | /* Take a SecureFault on the current stack */ | ||
68 | env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK; | ||
69 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
70 | -- | ||
71 | 2.20.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Handle floating point registers in exception return. | ||
2 | This corresponds to pseudocode functions ValidateExceptionReturn(), | ||
3 | ExceptionReturn(), PopStack() and ConsumeExcStackFrame(). | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190416125744.27770-16-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/helper.c | 142 +++++++++++++++++++++++++++++++++++++++++++- | ||
10 | 1 file changed, 141 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper.c | ||
15 | +++ b/target/arm/helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
17 | bool rettobase = false; | ||
18 | bool exc_secure = false; | ||
19 | bool return_to_secure; | ||
20 | + bool ftype; | ||
21 | + bool restore_s16_s31; | ||
22 | |||
23 | /* If we're not in Handler mode then jumps to magic exception-exit | ||
24 | * addresses don't have magic behaviour. However for the v8M | ||
25 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
26 | excret); | ||
27 | } | ||
28 | |||
29 | + ftype = excret & R_V7M_EXCRET_FTYPE_MASK; | ||
30 | + | ||
31 | + if (!arm_feature(env, ARM_FEATURE_VFP) && !ftype) { | ||
32 | + qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero FTYPE in exception " | ||
33 | + "exit PC value 0x%" PRIx32 " is UNPREDICTABLE " | ||
34 | + "if FPU not present\n", | ||
35 | + excret); | ||
36 | + ftype = true; | ||
37 | + } | ||
38 | + | ||
39 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
40 | /* EXC_RETURN.ES validation check (R_SMFL). We must do this before | ||
41 | * we pick which FAULTMASK to clear. | ||
42 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
43 | */ | ||
44 | write_v7m_control_spsel_for_secstate(env, return_to_sp_process, exc_secure); | ||
45 | |||
46 | + /* | ||
47 | + * Clear scratch FP values left in caller saved registers; this | ||
48 | + * must happen before any kind of tail chaining. | ||
49 | + */ | ||
50 | + if ((env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_CLRONRET_MASK) && | ||
51 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) { | ||
52 | + if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) { | ||
53 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | ||
54 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
55 | + qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing " | ||
56 | + "stackframe: error during lazy state deactivation\n"); | ||
57 | + v7m_exception_taken(cpu, excret, true, false); | ||
58 | + return; | ||
59 | + } else { | ||
60 | + /* Clear s0..s15 and FPSCR */ | ||
61 | + int i; | ||
62 | + | ||
63 | + for (i = 0; i < 16; i += 2) { | ||
64 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
65 | + } | ||
66 | + vfp_set_fpscr(env, 0); | ||
67 | + } | ||
68 | + } | ||
69 | + | ||
70 | if (sfault) { | ||
71 | env->v7m.sfsr |= R_V7M_SFSR_INVER_MASK; | ||
72 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
73 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
74 | } | ||
75 | } | ||
76 | |||
77 | + if (!ftype) { | ||
78 | + /* FP present and we need to handle it */ | ||
79 | + if (!return_to_secure && | ||
80 | + (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK)) { | ||
81 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
82 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | ||
83 | + qemu_log_mask(CPU_LOG_INT, | ||
84 | + "...taking SecureFault on existing stackframe: " | ||
85 | + "Secure LSPACT set but exception return is " | ||
86 | + "not to secure state\n"); | ||
87 | + v7m_exception_taken(cpu, excret, true, false); | ||
88 | + return; | ||
89 | + } | ||
90 | + | ||
91 | + restore_s16_s31 = return_to_secure && | ||
92 | + (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK); | ||
93 | + | ||
94 | + if (env->v7m.fpccr[return_to_secure] & R_V7M_FPCCR_LSPACT_MASK) { | ||
95 | + /* State in FPU is still valid, just clear LSPACT */ | ||
96 | + env->v7m.fpccr[return_to_secure] &= ~R_V7M_FPCCR_LSPACT_MASK; | ||
97 | + } else { | ||
98 | + int i; | ||
99 | + uint32_t fpscr; | ||
100 | + bool cpacr_pass, nsacr_pass; | ||
101 | + | ||
102 | + cpacr_pass = v7m_cpacr_pass(env, return_to_secure, | ||
103 | + return_to_priv); | ||
104 | + nsacr_pass = return_to_secure || | ||
105 | + extract32(env->v7m.nsacr, 10, 1); | ||
106 | + | ||
107 | + if (!cpacr_pass) { | ||
108 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | ||
109 | + return_to_secure); | ||
110 | + env->v7m.cfsr[return_to_secure] |= R_V7M_CFSR_NOCP_MASK; | ||
111 | + qemu_log_mask(CPU_LOG_INT, | ||
112 | + "...taking UsageFault on existing " | ||
113 | + "stackframe: CPACR.CP10 prevents unstacking " | ||
114 | + "FP regs\n"); | ||
115 | + v7m_exception_taken(cpu, excret, true, false); | ||
116 | + return; | ||
117 | + } else if (!nsacr_pass) { | ||
118 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true); | ||
119 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_INVPC_MASK; | ||
120 | + qemu_log_mask(CPU_LOG_INT, | ||
121 | + "...taking Secure UsageFault on existing " | ||
122 | + "stackframe: NSACR.CP10 prevents unstacking " | ||
123 | + "FP regs\n"); | ||
124 | + v7m_exception_taken(cpu, excret, true, false); | ||
125 | + return; | ||
126 | + } | ||
127 | + | ||
128 | + for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) { | ||
129 | + uint32_t slo, shi; | ||
130 | + uint64_t dn; | ||
131 | + uint32_t faddr = frameptr + 0x20 + 4 * i; | ||
132 | + | ||
133 | + if (i >= 16) { | ||
134 | + faddr += 8; /* Skip the slot for the FPSCR */ | ||
135 | + } | ||
136 | + | ||
137 | + pop_ok = pop_ok && | ||
138 | + v7m_stack_read(cpu, &slo, faddr, mmu_idx) && | ||
139 | + v7m_stack_read(cpu, &shi, faddr + 4, mmu_idx); | ||
140 | + | ||
141 | + if (!pop_ok) { | ||
142 | + break; | ||
143 | + } | ||
144 | + | ||
145 | + dn = (uint64_t)shi << 32 | slo; | ||
146 | + *aa32_vfp_dreg(env, i / 2) = dn; | ||
147 | + } | ||
148 | + pop_ok = pop_ok && | ||
149 | + v7m_stack_read(cpu, &fpscr, frameptr + 0x60, mmu_idx); | ||
150 | + if (pop_ok) { | ||
151 | + vfp_set_fpscr(env, fpscr); | ||
152 | + } | ||
153 | + if (!pop_ok) { | ||
154 | + /* | ||
155 | + * These regs are 0 if security extension present; | ||
156 | + * otherwise merely UNKNOWN. We zero always. | ||
157 | + */ | ||
158 | + for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) { | ||
159 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
160 | + } | ||
161 | + vfp_set_fpscr(env, 0); | ||
162 | + } | ||
163 | + } | ||
164 | + } | ||
165 | + env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S], | ||
166 | + V7M_CONTROL, FPCA, !ftype); | ||
167 | + | ||
168 | /* Commit to consuming the stack frame */ | ||
169 | frameptr += 0x20; | ||
170 | + if (!ftype) { | ||
171 | + frameptr += 0x48; | ||
172 | + if (restore_s16_s31) { | ||
173 | + frameptr += 0x40; | ||
174 | + } | ||
175 | + } | ||
176 | /* Undo stack alignment (the SPREALIGN bit indicates that the original | ||
177 | * pre-exception SP was not 8-aligned and we added a padding word to | ||
178 | * align it, so we undo this by ORing in the bit that increases it | ||
179 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
180 | *frame_sp_p = frameptr; | ||
181 | } | ||
182 | /* This xpsr_write() will invalidate frame_sp_p as it may switch stack */ | ||
183 | - xpsr_write(env, xpsr, ~XPSR_SPREALIGN); | ||
184 | + xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA)); | ||
185 | + | ||
186 | + if (env->v7m.secure) { | ||
187 | + bool sfpa = xpsr & XPSR_SFPA; | ||
188 | + | ||
189 | + env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S], | ||
190 | + V7M_CONTROL, SFPA, sfpa); | ||
191 | + } | ||
192 | |||
193 | /* The restored xPSR exception field will be zero if we're | ||
194 | * resuming in Thread mode. If that doesn't match what the | ||
195 | -- | ||
196 | 2.20.1 | ||
197 | |||
198 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Move the NS TBFLAG down from bit 19 to bit 6, which has not | ||
2 | been used since commit c1e3781090b9d36c60 in 2015, when we | ||
3 | started passing the entire MMU index in the TB flags rather | ||
4 | than just a 'privilege level' bit. | ||
5 | 1 | ||
6 | This rearrangement is not strictly necessary, but means that | ||
7 | we can put M-profile-only bits next to each other rather | ||
8 | than scattered across the flag word. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20190416125744.27770-17-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/arm/cpu.h | 11 ++++++----- | ||
15 | 1 file changed, 6 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | ||
22 | FIELD(TBFLAG_A32, THUMB, 0, 1) | ||
23 | FIELD(TBFLAG_A32, VECLEN, 1, 3) | ||
24 | FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) | ||
25 | +/* | ||
26 | + * Indicates whether cp register reads and writes by guest code should access | ||
27 | + * the secure or nonsecure bank of banked registers; note that this is not | ||
28 | + * the same thing as the current security state of the processor! | ||
29 | + */ | ||
30 | +FIELD(TBFLAG_A32, NS, 6, 1) | ||
31 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | ||
32 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | ||
33 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
34 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
35 | * checks on the other bits at runtime | ||
36 | */ | ||
37 | FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2) | ||
38 | -/* Indicates whether cp register reads and writes by guest code should access | ||
39 | - * the secure or nonsecure bank of banked registers; note that this is not | ||
40 | - * the same thing as the current security state of the processor! | ||
41 | - */ | ||
42 | -FIELD(TBFLAG_A32, NS, 19, 1) | ||
43 | /* For M profile only, Handler (ie not Thread) mode */ | ||
44 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | ||
45 | /* For M profile only, whether we should generate stack-limit checks */ | ||
46 | -- | ||
47 | 2.20.1 | ||
48 | |||
49 | diff view generated by jsdifflib |
1 | The M-profile FPCCR.S bit indicates the security status of | 1 | M-profile CPUs generally allow configuration of the number of MPU |
---|---|---|---|
2 | the floating point context. In the pseudocode ExecuteFPCheck() | 2 | regions that they have. We don't currently model this, so our |
3 | function it is unconditionally set to match the current | 3 | implementations of some of the board models provide CPUs with the |
4 | security state whenever a floating point instruction is | 4 | wrong number of regions. RTOSes like Zephyr that hardcode the |
5 | executed. | 5 | expected number of regions may therefore not run on the model if they |
6 | are set up to run on real hardware. | ||
6 | 7 | ||
7 | Implement this by adding a new TB flag which tracks whether | 8 | Add properties mpu-ns-regions and mpu-s-regions to the ARMV7M object, |
8 | FPCCR.S is different from the current security state, so | 9 | matching the ability of hardware to configure the number of Secure |
9 | that we only need to emit the code to update it in the | 10 | and NonSecure regions separately. Our actual CPU implementation |
10 | less-common case when it is not already set correctly. | 11 | doesn't currently support that, and it happens that none of the MPS |
12 | boards we model set the number of regions differently for Secure vs | ||
13 | NonSecure, so we provide an interface to the boards and SoCs that | ||
14 | won't need to change if we ever do add that functionality in future, | ||
15 | but make it an error to configure the two properties to different | ||
16 | values. | ||
11 | 17 | ||
12 | Note that we will add the handling for the other work done | 18 | (The property name on the CPU is the somewhat misnamed-for-M-profile |
13 | by ExecuteFPCheck() in later commits. | 19 | "pmsav7-dregion", so we don't follow that naming convention for |
20 | the properties here. The TRM doesn't say what the CPU configuration | ||
21 | variable names are, so we pick something, and follow the lowercase | ||
22 | convention we already have for properties here.) | ||
14 | 23 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 25 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
17 | Message-id: 20190416125744.27770-19-peter.maydell@linaro.org | 26 | Message-id: 20230724174335.2150499-3-peter.maydell@linaro.org |
18 | --- | 27 | --- |
19 | target/arm/cpu.h | 2 ++ | 28 | include/hw/arm/armv7m.h | 8 ++++++++ |
20 | target/arm/translate.h | 1 + | 29 | hw/arm/armv7m.c | 21 +++++++++++++++++++++ |
21 | target/arm/helper.c | 5 +++++ | 30 | 2 files changed, 29 insertions(+) |
22 | target/arm/translate.c | 20 ++++++++++++++++++++ | ||
23 | 4 files changed, 28 insertions(+) | ||
24 | 31 | ||
25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 32 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h |
26 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/cpu.h | 34 | --- a/include/hw/arm/armv7m.h |
28 | +++ b/target/arm/cpu.h | 35 | +++ b/include/hw/arm/armv7m.h |
29 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 36 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M) |
30 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 37 | * + Property "vfp": enable VFP (forwarded to CPU object) |
31 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 38 | * + Property "dsp": enable DSP (forwarded to CPU object) |
32 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 39 | * + Property "enable-bitband": expose bitbanded IO |
33 | +/* For M profile only, set if FPCCR.S does not match current security state */ | 40 | + * + Property "mpu-ns-regions": number of Non-Secure MPU regions (forwarded |
34 | +FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) | 41 | + * to CPU object pmsav7-dregion property; default is whatever the default |
35 | /* For M profile only, Handler (ie not Thread) mode */ | 42 | + * for the CPU is) |
36 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | 43 | + * + Property "mpu-s-regions": number of Secure MPU regions (default is |
37 | /* For M profile only, whether we should generate stack-limit checks */ | 44 | + * whatever the default for the CPU is; must currently be set to the same |
38 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 45 | + * value as mpu-ns-regions if the CPU implements the Security Extension) |
46 | * + Clock input "refclk" is the external reference clock for the systick timers | ||
47 | * + Clock input "cpuclk" is the main CPU clock | ||
48 | */ | ||
49 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { | ||
50 | Object *idau; | ||
51 | uint32_t init_svtor; | ||
52 | uint32_t init_nsvtor; | ||
53 | + uint32_t mpu_ns_regions; | ||
54 | + uint32_t mpu_s_regions; | ||
55 | bool enable_bitband; | ||
56 | bool start_powered_off; | ||
57 | bool vfp; | ||
58 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/target/arm/translate.h | 60 | --- a/hw/arm/armv7m.c |
41 | +++ b/target/arm/translate.h | 61 | +++ b/hw/arm/armv7m.c |
42 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 62 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) |
43 | bool v7m_handler_mode; | ||
44 | bool v8m_secure; /* true if v8M and we're in Secure mode */ | ||
45 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | ||
46 | + bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | ||
47 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | ||
48 | * so that top level loop can generate correct syndrome information. | ||
49 | */ | ||
50 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/helper.c | ||
53 | +++ b/target/arm/helper.c | ||
54 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
55 | flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1); | ||
56 | } | ||
57 | |||
58 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
59 | + FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { | ||
60 | + flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | ||
61 | + } | ||
62 | + | ||
63 | *pflags = flags; | ||
64 | *cs_base = 0; | ||
65 | } | ||
66 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/translate.c | ||
69 | +++ b/target/arm/translate.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
71 | } | 63 | } |
72 | } | 64 | } |
73 | 65 | ||
74 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | 66 | + /* |
75 | + /* Handle M-profile lazy FP state mechanics */ | 67 | + * Real M-profile hardware can be configured with a different number of |
76 | + | 68 | + * MPU regions for Secure vs NonSecure. QEMU's CPU implementation doesn't |
77 | + /* Update ownership of FP context: set FPCCR.S to match current state */ | 69 | + * support that yet, so catch attempts to select that. |
78 | + if (s->v8m_fpccr_s_wrong) { | 70 | + */ |
79 | + TCGv_i32 tmp; | 71 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) && |
80 | + | 72 | + s->mpu_ns_regions != s->mpu_s_regions) { |
81 | + tmp = load_cpu_field(v7m.fpccr[M_REG_S]); | 73 | + error_setg(errp, |
82 | + if (s->v8m_secure) { | 74 | + "mpu-ns-regions and mpu-s-regions properties must have the same value"); |
83 | + tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK); | 75 | + return; |
84 | + } else { | 76 | + } |
85 | + tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK); | 77 | + if (s->mpu_ns_regions != UINT_MAX && |
86 | + } | 78 | + object_property_find(OBJECT(s->cpu), "pmsav7-dregion")) { |
87 | + store_cpu_field(tmp, v7m.fpccr[M_REG_S]); | 79 | + if (!object_property_set_uint(OBJECT(s->cpu), "pmsav7-dregion", |
88 | + /* Don't need to do this for any further FP insns in this TB */ | 80 | + s->mpu_ns_regions, errp)) { |
89 | + s->v8m_fpccr_s_wrong = false; | 81 | + return; |
90 | + } | 82 | + } |
91 | + } | 83 | + } |
92 | + | 84 | + |
93 | if (extract32(insn, 28, 4) == 0xf) { | 85 | /* |
94 | /* | 86 | * Tell the CPU where the NVIC is; it will fail realize if it doesn't |
95 | * Encodings with T=1 (Thumb) or unconditional (ARM): | 87 | * have one. Similarly, tell the NVIC where its CPU is. |
96 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 88 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { |
97 | dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) && | 89 | false), |
98 | regime_is_secure(env, dc->mmu_idx); | 90 | DEFINE_PROP_BOOL("vfp", ARMv7MState, vfp, true), |
99 | dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK); | 91 | DEFINE_PROP_BOOL("dsp", ARMv7MState, dsp, true), |
100 | + dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | 92 | + DEFINE_PROP_UINT32("mpu-ns-regions", ARMv7MState, mpu_ns_regions, UINT_MAX), |
101 | dc->cp_regs = cpu->cp_regs; | 93 | + DEFINE_PROP_UINT32("mpu-s-regions", ARMv7MState, mpu_s_regions, UINT_MAX), |
102 | dc->features = env->features; | 94 | DEFINE_PROP_END_OF_LIST(), |
95 | }; | ||
103 | 96 | ||
104 | -- | 97 | -- |
105 | 2.20.1 | 98 | 2.34.1 |
106 | 99 | ||
107 | 100 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Message-id: 20190412165416.7977-5-philmd@redhat.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/devices.h | 6 ------ | ||
9 | include/hw/display/tc6393xb.h | 24 ++++++++++++++++++++++++ | ||
10 | hw/arm/tosa.c | 2 +- | ||
11 | hw/display/tc6393xb.c | 2 +- | ||
12 | MAINTAINERS | 1 + | ||
13 | 5 files changed, 27 insertions(+), 8 deletions(-) | ||
14 | create mode 100644 include/hw/display/tc6393xb.h | ||
15 | |||
16 | diff --git a/include/hw/devices.h b/include/hw/devices.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/devices.h | ||
19 | +++ b/include/hw/devices.h | ||
20 | @@ -XXX,XX +XXX,XX @@ void *tahvo_init(qemu_irq irq, int betty); | ||
21 | |||
22 | void retu_key_event(void *retu, int state); | ||
23 | |||
24 | -/* tc6393xb.c */ | ||
25 | -typedef struct TC6393xbState TC6393xbState; | ||
26 | -TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | ||
27 | - uint32_t base, qemu_irq irq); | ||
28 | -qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | ||
29 | - | ||
30 | #endif | ||
31 | diff --git a/include/hw/display/tc6393xb.h b/include/hw/display/tc6393xb.h | ||
32 | new file mode 100644 | ||
33 | index XXXXXXX..XXXXXXX | ||
34 | --- /dev/null | ||
35 | +++ b/include/hw/display/tc6393xb.h | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | +/* | ||
38 | + * Toshiba TC6393XB I/O Controller. | ||
39 | + * Found in Sharp Zaurus SL-6000 (tosa) or some | ||
40 | + * Toshiba e-Series PDAs. | ||
41 | + * | ||
42 | + * Copyright (c) 2007 Hervé Poussineau | ||
43 | + * | ||
44 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
45 | + * See the COPYING file in the top-level directory. | ||
46 | + */ | ||
47 | + | ||
48 | +#ifndef HW_DISPLAY_TC6393XB_H | ||
49 | +#define HW_DISPLAY_TC6393XB_H | ||
50 | + | ||
51 | +#include "exec/memory.h" | ||
52 | +#include "hw/irq.h" | ||
53 | + | ||
54 | +typedef struct TC6393xbState TC6393xbState; | ||
55 | + | ||
56 | +TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | ||
57 | + uint32_t base, qemu_irq irq); | ||
58 | +qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | ||
59 | + | ||
60 | +#endif | ||
61 | diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/hw/arm/tosa.c | ||
64 | +++ b/hw/arm/tosa.c | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | #include "hw/hw.h" | ||
67 | #include "hw/arm/pxa.h" | ||
68 | #include "hw/arm/arm.h" | ||
69 | -#include "hw/devices.h" | ||
70 | #include "hw/arm/sharpsl.h" | ||
71 | #include "hw/pcmcia.h" | ||
72 | #include "hw/boards.h" | ||
73 | +#include "hw/display/tc6393xb.h" | ||
74 | #include "hw/i2c/i2c.h" | ||
75 | #include "hw/ssi/ssi.h" | ||
76 | #include "hw/sysbus.h" | ||
77 | diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/display/tc6393xb.c | ||
80 | +++ b/hw/display/tc6393xb.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qapi/error.h" | ||
83 | #include "qemu/host-utils.h" | ||
84 | #include "hw/hw.h" | ||
85 | -#include "hw/devices.h" | ||
86 | +#include "hw/display/tc6393xb.h" | ||
87 | #include "hw/block/flash.h" | ||
88 | #include "ui/console.h" | ||
89 | #include "ui/pixel_ops.h" | ||
90 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/MAINTAINERS | ||
93 | +++ b/MAINTAINERS | ||
94 | @@ -XXX,XX +XXX,XX @@ F: hw/misc/mst_fpga.c | ||
95 | F: hw/misc/max111x.c | ||
96 | F: include/hw/arm/pxa.h | ||
97 | F: include/hw/arm/sharpsl.h | ||
98 | +F: include/hw/display/tc6393xb.h | ||
99 | |||
100 | SABRELITE / i.MX6 | ||
101 | M: Peter Maydell <peter.maydell@linaro.org> | ||
102 | -- | ||
103 | 2.20.1 | ||
104 | |||
105 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Add an entries the Blizzard device in MAINTAINERS. | ||
4 | |||
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
6 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190412165416.7977-6-philmd@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/devices.h | 7 ------- | ||
12 | include/hw/display/blizzard.h | 22 ++++++++++++++++++++++ | ||
13 | hw/arm/nseries.c | 1 + | ||
14 | hw/display/blizzard.c | 2 +- | ||
15 | MAINTAINERS | 2 ++ | ||
16 | 5 files changed, 26 insertions(+), 8 deletions(-) | ||
17 | create mode 100644 include/hw/display/blizzard.h | ||
18 | |||
19 | diff --git a/include/hw/devices.h b/include/hw/devices.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/hw/devices.h | ||
22 | +++ b/include/hw/devices.h | ||
23 | @@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | ||
24 | /* stellaris_input.c */ | ||
25 | void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | ||
26 | |||
27 | -/* blizzard.c */ | ||
28 | -void *s1d13745_init(qemu_irq gpio_int); | ||
29 | -void s1d13745_write(void *opaque, int dc, uint16_t value); | ||
30 | -void s1d13745_write_block(void *opaque, int dc, | ||
31 | - void *buf, size_t len, int pitch); | ||
32 | -uint16_t s1d13745_read(void *opaque, int dc); | ||
33 | - | ||
34 | /* cbus.c */ | ||
35 | typedef struct { | ||
36 | qemu_irq clk; | ||
37 | diff --git a/include/hw/display/blizzard.h b/include/hw/display/blizzard.h | ||
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | --- /dev/null | ||
41 | +++ b/include/hw/display/blizzard.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | +/* | ||
44 | + * Epson S1D13744/S1D13745 (Blizzard/Hailstorm/Tornado) LCD/TV controller. | ||
45 | + * | ||
46 | + * Copyright (C) 2008 Nokia Corporation | ||
47 | + * Written by Andrzej Zaborowski | ||
48 | + * | ||
49 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
50 | + * See the COPYING file in the top-level directory. | ||
51 | + */ | ||
52 | + | ||
53 | +#ifndef HW_DISPLAY_BLIZZARD_H | ||
54 | +#define HW_DISPLAY_BLIZZARD_H | ||
55 | + | ||
56 | +#include "hw/irq.h" | ||
57 | + | ||
58 | +void *s1d13745_init(qemu_irq gpio_int); | ||
59 | +void s1d13745_write(void *opaque, int dc, uint16_t value); | ||
60 | +void s1d13745_write_block(void *opaque, int dc, | ||
61 | + void *buf, size_t len, int pitch); | ||
62 | +uint16_t s1d13745_read(void *opaque, int dc); | ||
63 | + | ||
64 | +#endif | ||
65 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/hw/arm/nseries.c | ||
68 | +++ b/hw/arm/nseries.c | ||
69 | @@ -XXX,XX +XXX,XX @@ | ||
70 | #include "hw/boards.h" | ||
71 | #include "hw/i2c/i2c.h" | ||
72 | #include "hw/devices.h" | ||
73 | +#include "hw/display/blizzard.h" | ||
74 | #include "hw/misc/tmp105.h" | ||
75 | #include "hw/block/flash.h" | ||
76 | #include "hw/hw.h" | ||
77 | diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/display/blizzard.c | ||
80 | +++ b/hw/display/blizzard.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qemu/osdep.h" | ||
83 | #include "qemu-common.h" | ||
84 | #include "ui/console.h" | ||
85 | -#include "hw/devices.h" | ||
86 | +#include "hw/display/blizzard.h" | ||
87 | #include "ui/pixel_ops.h" | ||
88 | |||
89 | typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int); | ||
90 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/MAINTAINERS | ||
93 | +++ b/MAINTAINERS | ||
94 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
95 | L: qemu-arm@nongnu.org | ||
96 | S: Odd Fixes | ||
97 | F: hw/arm/nseries.c | ||
98 | +F: hw/display/blizzard.c | ||
99 | F: hw/input/lm832x.c | ||
100 | F: hw/input/tsc2005.c | ||
101 | F: hw/misc/cbus.c | ||
102 | F: hw/timer/twl92230.c | ||
103 | +F: include/hw/display/blizzard.h | ||
104 | |||
105 | Palm | ||
106 | M: Andrzej Zaborowski <balrogg@gmail.com> | ||
107 | -- | ||
108 | 2.20.1 | ||
109 | |||
110 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
4 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Message-id: 20190412165416.7977-7-philmd@redhat.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | include/hw/devices.h | 14 -------------- | ||
10 | include/hw/misc/cbus.h | 32 ++++++++++++++++++++++++++++++++ | ||
11 | hw/arm/nseries.c | 1 + | ||
12 | hw/misc/cbus.c | 2 +- | ||
13 | MAINTAINERS | 1 + | ||
14 | 5 files changed, 35 insertions(+), 15 deletions(-) | ||
15 | create mode 100644 include/hw/misc/cbus.h | ||
16 | |||
17 | diff --git a/include/hw/devices.h b/include/hw/devices.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/devices.h | ||
20 | +++ b/include/hw/devices.h | ||
21 | @@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | ||
22 | /* stellaris_input.c */ | ||
23 | void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | ||
24 | |||
25 | -/* cbus.c */ | ||
26 | -typedef struct { | ||
27 | - qemu_irq clk; | ||
28 | - qemu_irq dat; | ||
29 | - qemu_irq sel; | ||
30 | -} CBus; | ||
31 | -CBus *cbus_init(qemu_irq dat_out); | ||
32 | -void cbus_attach(CBus *bus, void *slave_opaque); | ||
33 | - | ||
34 | -void *retu_init(qemu_irq irq, int vilma); | ||
35 | -void *tahvo_init(qemu_irq irq, int betty); | ||
36 | - | ||
37 | -void retu_key_event(void *retu, int state); | ||
38 | - | ||
39 | #endif | ||
40 | diff --git a/include/hw/misc/cbus.h b/include/hw/misc/cbus.h | ||
41 | new file mode 100644 | ||
42 | index XXXXXXX..XXXXXXX | ||
43 | --- /dev/null | ||
44 | +++ b/include/hw/misc/cbus.h | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | +/* | ||
47 | + * CBUS three-pin bus and the Retu / Betty / Tahvo / Vilma / Avilma / | ||
48 | + * Hinku / Vinku / Ahne / Pihi chips used in various Nokia platforms. | ||
49 | + * Based on reverse-engineering of a linux driver. | ||
50 | + * | ||
51 | + * Copyright (C) 2008 Nokia Corporation | ||
52 | + * Written by Andrzej Zaborowski | ||
53 | + * | ||
54 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
55 | + * See the COPYING file in the top-level directory. | ||
56 | + */ | ||
57 | + | ||
58 | +#ifndef HW_MISC_CBUS_H | ||
59 | +#define HW_MISC_CBUS_H | ||
60 | + | ||
61 | +#include "hw/irq.h" | ||
62 | + | ||
63 | +typedef struct { | ||
64 | + qemu_irq clk; | ||
65 | + qemu_irq dat; | ||
66 | + qemu_irq sel; | ||
67 | +} CBus; | ||
68 | + | ||
69 | +CBus *cbus_init(qemu_irq dat_out); | ||
70 | +void cbus_attach(CBus *bus, void *slave_opaque); | ||
71 | + | ||
72 | +void *retu_init(qemu_irq irq, int vilma); | ||
73 | +void *tahvo_init(qemu_irq irq, int betty); | ||
74 | + | ||
75 | +void retu_key_event(void *retu, int state); | ||
76 | + | ||
77 | +#endif | ||
78 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/hw/arm/nseries.c | ||
81 | +++ b/hw/arm/nseries.c | ||
82 | @@ -XXX,XX +XXX,XX @@ | ||
83 | #include "hw/i2c/i2c.h" | ||
84 | #include "hw/devices.h" | ||
85 | #include "hw/display/blizzard.h" | ||
86 | +#include "hw/misc/cbus.h" | ||
87 | #include "hw/misc/tmp105.h" | ||
88 | #include "hw/block/flash.h" | ||
89 | #include "hw/hw.h" | ||
90 | diff --git a/hw/misc/cbus.c b/hw/misc/cbus.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/hw/misc/cbus.c | ||
93 | +++ b/hw/misc/cbus.c | ||
94 | @@ -XXX,XX +XXX,XX @@ | ||
95 | #include "qemu/osdep.h" | ||
96 | #include "hw/hw.h" | ||
97 | #include "hw/irq.h" | ||
98 | -#include "hw/devices.h" | ||
99 | +#include "hw/misc/cbus.h" | ||
100 | #include "sysemu/sysemu.h" | ||
101 | |||
102 | //#define DEBUG | ||
103 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/MAINTAINERS | ||
106 | +++ b/MAINTAINERS | ||
107 | @@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c | ||
108 | F: hw/misc/cbus.c | ||
109 | F: hw/timer/twl92230.c | ||
110 | F: include/hw/display/blizzard.h | ||
111 | +F: include/hw/misc/cbus.h | ||
112 | |||
113 | Palm | ||
114 | M: Andrzej Zaborowski <balrogg@gmail.com> | ||
115 | -- | ||
116 | 2.20.1 | ||
117 | |||
118 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | The IoTKit, SSE200 and SSE300 all default to 8 MPU regions. The |
---|---|---|---|
2 | 2 | MPS2/MPS3 FPGA images don't override these except in the case of | |
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 3 | AN547, which uses 16 MPU regions. |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | |
5 | Message-id: 20190412165416.7977-12-philmd@redhat.com | 5 | Define properties on the ARMSSE object for the MPU regions (using the |
6 | same names as the documented RTL configuration settings, and | ||
7 | following the pattern we already have for this device of using | ||
8 | all-caps names as the RTL does), and set them in the board code. | ||
9 | |||
10 | We don't actually need to override the default except on AN547, | ||
11 | but it's simpler code to have the board code set them always | ||
12 | rather than tracking which board subtypes want to set them to | ||
13 | a non-default value separately from what that value is. | ||
14 | |||
15 | Tho overall effect is that for mps2-an505, mps2-an521 and mps3-an524 | ||
16 | we now correctly use 8 MPU regions, while mps3-an547 stays at its | ||
17 | current 16 regions. | ||
18 | |||
19 | It's possible some guest code wrongly depended on the previous | ||
20 | incorrectly modeled number of memory regions. (Such guest code | ||
21 | should ideally check the number of regions via the MPU_TYPE | ||
22 | register.) The old behaviour can be obtained with additional | ||
23 | -global arguments to QEMU: | ||
24 | |||
25 | For mps2-an521 and mps2-an524: | ||
26 | -global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 -global sse-200.CPU1_MPU_NS=16 -global sse-200.CPU1_MPU_S=16 | ||
27 | |||
28 | For mps2-an505: | ||
29 | -global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 | ||
30 | |||
31 | NB that the way the implementation allows this use of -global | ||
32 | is slightly fragile: if the board code explicitly sets the | ||
33 | properties on the sse-200 object, this overrides the -global | ||
34 | command line option. So we rely on: | ||
35 | - the boards that need fixing all happen to use the SSE defaults | ||
36 | - we can write the board code to only set the property if it | ||
37 | is different from the default, rather than having all boards | ||
38 | explicitly set the property | ||
39 | - the board that does need to use a non-default value happens | ||
40 | to need to set it to the same value (16) we previously used | ||
41 | This works, but there are some kinds of refactoring of the | ||
42 | mps2-tz.c code that would break the support for -global here. | ||
43 | |||
44 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1772 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 45 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
46 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
47 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
48 | Message-id: 20230724174335.2150499-4-peter.maydell@linaro.org | ||
7 | --- | 49 | --- |
8 | include/hw/net/lan9118.h | 2 ++ | 50 | include/hw/arm/armsse.h | 5 +++++ |
9 | hw/arm/exynos4_boards.c | 3 ++- | 51 | hw/arm/armsse.c | 16 ++++++++++++++++ |
10 | hw/arm/mps2-tz.c | 3 ++- | 52 | hw/arm/mps2-tz.c | 29 +++++++++++++++++++++++++++++ |
11 | hw/net/lan9118.c | 1 - | 53 | 3 files changed, 50 insertions(+) |
12 | 4 files changed, 6 insertions(+), 3 deletions(-) | 54 | |
13 | 55 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h | |
14 | diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/net/lan9118.h | 57 | --- a/include/hw/arm/armsse.h |
17 | +++ b/include/hw/net/lan9118.h | 58 | +++ b/include/hw/arm/armsse.h |
18 | @@ -XXX,XX +XXX,XX @@ | 59 | @@ -XXX,XX +XXX,XX @@ |
19 | #include "hw/irq.h" | 60 | * (matching the hardware) is that for CPU0 in an IoTKit and CPU1 in an |
20 | #include "net/net.h" | 61 | * SSE-200 both are present; CPU0 in an SSE-200 has neither. |
21 | 62 | * Since the IoTKit has only one CPU, it does not have the CPU1_* properties. | |
22 | +#define TYPE_LAN9118 "lan9118" | 63 | + * + QOM properties "CPU0_MPU_NS", "CPU0_MPU_S", "CPU1_MPU_NS" and "CPU1_MPU_S" |
23 | + | 64 | + * which set the number of MPU regions on the CPUs. If there is only one |
24 | void lan9118_init(NICInfo *, uint32_t, qemu_irq); | 65 | + * CPU the CPU1 properties are not present. |
25 | 66 | * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, | |
26 | #endif | 67 | * which are wired to its NVIC lines 32 .. n+32 |
27 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c | 68 | * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for |
69 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { | ||
70 | uint32_t exp_numirq; | ||
71 | uint32_t sram_addr_width; | ||
72 | uint32_t init_svtor; | ||
73 | + uint32_t cpu_mpu_ns[SSE_MAX_CPUS]; | ||
74 | + uint32_t cpu_mpu_s[SSE_MAX_CPUS]; | ||
75 | bool cpu_fpu[SSE_MAX_CPUS]; | ||
76 | bool cpu_dsp[SSE_MAX_CPUS]; | ||
77 | }; | ||
78 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | 79 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/hw/arm/exynos4_boards.c | 80 | --- a/hw/arm/armsse.c |
30 | +++ b/hw/arm/exynos4_boards.c | 81 | +++ b/hw/arm/armsse.c |
31 | @@ -XXX,XX +XXX,XX @@ | 82 | @@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = { |
32 | #include "hw/arm/arm.h" | 83 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), |
33 | #include "exec/address-spaces.h" | 84 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), |
34 | #include "hw/arm/exynos4210.h" | 85 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), |
35 | +#include "hw/net/lan9118.h" | 86 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), |
36 | #include "hw/boards.h" | 87 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), |
37 | 88 | DEFINE_PROP_END_OF_LIST() | |
38 | #undef DEBUG | 89 | }; |
39 | @@ -XXX,XX +XXX,XX @@ static void lan9215_init(uint32_t base, qemu_irq irq) | 90 | |
40 | /* This should be a 9215 but the 9118 is close enough */ | 91 | @@ -XXX,XX +XXX,XX @@ static Property sse200_properties[] = { |
41 | if (nd_table[0].used) { | 92 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], false), |
42 | qemu_check_nic_model(&nd_table[0], "lan9118"); | 93 | DEFINE_PROP_BOOL("CPU1_FPU", ARMSSE, cpu_fpu[1], true), |
43 | - dev = qdev_create(NULL, "lan9118"); | 94 | DEFINE_PROP_BOOL("CPU1_DSP", ARMSSE, cpu_dsp[1], true), |
44 | + dev = qdev_create(NULL, TYPE_LAN9118); | 95 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), |
45 | qdev_set_nic_properties(dev, &nd_table[0]); | 96 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), |
46 | qdev_prop_set_uint32(dev, "mode_16bit", 1); | 97 | + DEFINE_PROP_UINT32("CPU1_MPU_NS", ARMSSE, cpu_mpu_ns[1], 8), |
47 | qdev_init_nofail(dev); | 98 | + DEFINE_PROP_UINT32("CPU1_MPU_S", ARMSSE, cpu_mpu_s[1], 8), |
99 | DEFINE_PROP_END_OF_LIST() | ||
100 | }; | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ static Property sse300_properties[] = { | ||
103 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
104 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
105 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), | ||
106 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | ||
107 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | ||
108 | DEFINE_PROP_END_OF_LIST() | ||
109 | }; | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
112 | return; | ||
113 | } | ||
114 | } | ||
115 | + if (!object_property_set_uint(cpuobj, "mpu-ns-regions", | ||
116 | + s->cpu_mpu_ns[i], errp)) { | ||
117 | + return; | ||
118 | + } | ||
119 | + if (!object_property_set_uint(cpuobj, "mpu-s-regions", | ||
120 | + s->cpu_mpu_s[i], errp)) { | ||
121 | + return; | ||
122 | + } | ||
123 | |||
124 | if (i > 0) { | ||
125 | memory_region_add_subregion_overlap(&s->cpu_container[i], 0, | ||
48 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 126 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c |
49 | index XXXXXXX..XXXXXXX 100644 | 127 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/hw/arm/mps2-tz.c | 128 | --- a/hw/arm/mps2-tz.c |
51 | +++ b/hw/arm/mps2-tz.c | 129 | +++ b/hw/arm/mps2-tz.c |
52 | @@ -XXX,XX +XXX,XX @@ | 130 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { |
53 | #include "hw/arm/armsse.h" | 131 | int uart_overflow_irq; /* number of the combined UART overflow IRQ */ |
54 | #include "hw/dma/pl080.h" | 132 | uint32_t init_svtor; /* init-svtor setting for SSE */ |
55 | #include "hw/ssi/pl022.h" | 133 | uint32_t sram_addr_width; /* SRAM_ADDR_WIDTH setting for SSE */ |
56 | +#include "hw/net/lan9118.h" | 134 | + uint32_t cpu0_mpu_ns; /* CPU0_MPU_NS setting for SSE */ |
57 | #include "net/net.h" | 135 | + uint32_t cpu0_mpu_s; /* CPU0_MPU_S setting for SSE */ |
58 | #include "hw/core/split-irq.h" | 136 | + uint32_t cpu1_mpu_ns; /* CPU1_MPU_NS setting for SSE */ |
59 | 137 | + uint32_t cpu1_mpu_s; /* CPU1_MPU_S setting for SSE */ | |
60 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | 138 | const RAMInfo *raminfo; |
61 | * except that it doesn't support the checksum-offload feature. | 139 | const char *armsse_type; |
62 | */ | 140 | uint32_t boot_ram_size; /* size of ram at address 0; 0 == find in raminfo */ |
63 | qemu_check_nic_model(nd, "lan9118"); | 141 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) |
64 | - mms->lan9118 = qdev_create(NULL, "lan9118"); | 142 | #define MPS3_DDR_SIZE (2 * GiB) |
65 | + mms->lan9118 = qdev_create(NULL, TYPE_LAN9118); | 143 | #endif |
66 | qdev_set_nic_properties(mms->lan9118, nd); | 144 | |
67 | qdev_init_nofail(mms->lan9118); | 145 | +/* For cpu{0,1}_mpu_{ns,s}, means "leave at SSE's default value" */ |
68 | 146 | +#define MPU_REGION_DEFAULT UINT32_MAX | |
69 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c | 147 | + |
70 | index XXXXXXX..XXXXXXX 100644 | 148 | static const uint32_t an505_oscclk[] = { |
71 | --- a/hw/net/lan9118.c | 149 | 40000000, |
72 | +++ b/hw/net/lan9118.c | 150 | 24580000, |
73 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118_packet = { | 151 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
74 | } | 152 | OBJECT(system_memory), &error_abort); |
75 | }; | 153 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", mmc->numirq); |
76 | 154 | qdev_prop_set_uint32(iotkitdev, "init-svtor", mmc->init_svtor); | |
77 | -#define TYPE_LAN9118 "lan9118" | 155 | + if (mmc->cpu0_mpu_ns != MPU_REGION_DEFAULT) { |
78 | #define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118) | 156 | + qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_NS", mmc->cpu0_mpu_ns); |
79 | 157 | + } | |
80 | typedef struct { | 158 | + if (mmc->cpu0_mpu_s != MPU_REGION_DEFAULT) { |
159 | + qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_S", mmc->cpu0_mpu_s); | ||
160 | + } | ||
161 | + if (object_property_find(OBJECT(iotkitdev), "CPU1_MPU_NS")) { | ||
162 | + if (mmc->cpu1_mpu_ns != MPU_REGION_DEFAULT) { | ||
163 | + qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_NS", mmc->cpu1_mpu_ns); | ||
164 | + } | ||
165 | + if (mmc->cpu1_mpu_s != MPU_REGION_DEFAULT) { | ||
166 | + qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_S", mmc->cpu1_mpu_s); | ||
167 | + } | ||
168 | + } | ||
169 | qdev_prop_set_uint32(iotkitdev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | ||
170 | qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); | ||
171 | qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); | ||
172 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_class_init(ObjectClass *oc, void *data) | ||
173 | { | ||
174 | MachineClass *mc = MACHINE_CLASS(oc); | ||
175 | IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(oc); | ||
176 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_CLASS(oc); | ||
177 | |||
178 | mc->init = mps2tz_common_init; | ||
179 | mc->reset = mps2_machine_reset; | ||
180 | iic->check = mps2_tz_idau_check; | ||
181 | + | ||
182 | + /* Most machines leave these at the SSE defaults */ | ||
183 | + mmc->cpu0_mpu_ns = MPU_REGION_DEFAULT; | ||
184 | + mmc->cpu0_mpu_s = MPU_REGION_DEFAULT; | ||
185 | + mmc->cpu1_mpu_ns = MPU_REGION_DEFAULT; | ||
186 | + mmc->cpu1_mpu_s = MPU_REGION_DEFAULT; | ||
187 | } | ||
188 | |||
189 | static void mps2tz_set_default_ram_info(MPS2TZMachineClass *mmc) | ||
190 | @@ -XXX,XX +XXX,XX @@ static void mps3tz_an547_class_init(ObjectClass *oc, void *data) | ||
191 | mmc->numirq = 96; | ||
192 | mmc->uart_overflow_irq = 48; | ||
193 | mmc->init_svtor = 0x00000000; | ||
194 | + mmc->cpu0_mpu_s = mmc->cpu0_mpu_ns = 16; | ||
195 | mmc->sram_addr_width = 21; | ||
196 | mmc->raminfo = an547_raminfo; | ||
197 | mmc->armsse_type = TYPE_SSE300; | ||
81 | -- | 198 | -- |
82 | 2.20.1 | 199 | 2.34.1 |
83 | 200 | ||
84 | 201 | diff view generated by jsdifflib |