1 | Hi; some minor changes for 6.2, which I think can be classified | 1 | Some small arm bug fixes for rc3. |
---|---|---|---|
2 | as bug fixes and are OK for this point in the release cycle. | ||
3 | (Wouldn't be the end of the world if they slipped to 7.0.) | ||
4 | 2 | ||
5 | -- PMM | 3 | -- PMM |
6 | 4 | ||
7 | The following changes since commit 42f6c9179be4401974dd3a75ee72defd16b5092d: | 5 | The following changes since commit 9b617b1bb4056e60b39be4c33be20c10928a6a5c: |
8 | 6 | ||
9 | Merge tag 'pull-ppc-20211112' of https://github.com/legoater/qemu into staging (2021-11-12 12:28:25 +0100) | 7 | Merge tag 'trivial-branch-for-7.0-pull-request' of https://gitlab.com/laurent_vivier/qemu into staging (2022-04-01 10:23:27 +0100) |
10 | 8 | ||
11 | are available in the Git repository at: | 9 | are available in the Git repository at: |
12 | 10 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20211115-1 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220401 |
14 | 12 | ||
15 | for you to fetch changes up to 1adf528ec3bdf62ea3b580b7ad562534a3676ff5: | 13 | for you to fetch changes up to a5b1e1ab662aa6dc42d5a913080fccbb8bf82e9b: |
16 | 14 | ||
17 | hw/rtc/pl031: Send RTC_CHANGE QMP event (2021-11-15 18:53:00 +0000) | 15 | target/arm: Don't use DISAS_NORETURN in STXP !HAVE_CMPXCHG128 codegen (2022-04-01 15:35:49 +0100) |
18 | 16 | ||
19 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
20 | target-arm queue: | 18 | target-arm queue: |
21 | * Support multiple redistributor regions for TCG GICv3 | 19 | * target/arm: Fix some bugs in secure EL2 handling |
22 | * Send RTC_CHANGE QMP event from pl031 | 20 | * target/arm: Fix assert when !HAVE_CMPXCHG128 |
21 | * MAINTAINERS: change Fred Konrad's email address | ||
23 | 22 | ||
24 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
25 | Eric Auger (1): | 24 | Frederic Konrad (1): |
26 | hw/rtc/pl031: Send RTC_CHANGE QMP event | 25 | MAINTAINERS: change Fred Konrad's email address |
27 | 26 | ||
28 | Peter Maydell (3): | 27 | Idan Horowitz (4): |
29 | hw/intc/arm_gicv3: Move checking of redist-region-count to arm_gicv3_common_realize | 28 | target/arm: Fix MTE access checks for disabled SEL2 |
30 | hw/intc/arm_gicv3: Set GICR_TYPER.Last correctly when nb_redist_regions > 1 | 29 | target/arm: Check VSTCR.SW when assigning the stage 2 output PA space |
31 | hw/intc/arm_gicv3: Support multiple redistributor regions | 30 | target/arm: Take VSTCR.SW, VTCR.NSW into account in final stage 2 walk |
31 | target/arm: Determine final stage 2 output PA space based on original IPA | ||
32 | 32 | ||
33 | include/hw/intc/arm_gicv3_common.h | 14 ++++++++-- | 33 | Peter Maydell (1): |
34 | hw/intc/arm_gicv3.c | 12 +------- | 34 | target/arm: Don't use DISAS_NORETURN in STXP !HAVE_CMPXCHG128 codegen |
35 | hw/intc/arm_gicv3_common.c | 56 ++++++++++++++++++++++++-------------- | ||
36 | hw/intc/arm_gicv3_kvm.c | 10 ++----- | ||
37 | hw/intc/arm_gicv3_redist.c | 40 +++++++++++++++------------ | ||
38 | hw/rtc/pl031.c | 10 ++++++- | ||
39 | hw/rtc/meson.build | 2 +- | ||
40 | 7 files changed, 83 insertions(+), 61 deletions(-) | ||
41 | 35 | ||
36 | target/arm/internals.h | 2 +- | ||
37 | target/arm/helper.c | 18 +++++++++++++++--- | ||
38 | target/arm/translate-a64.c | 7 ++++++- | ||
39 | .mailmap | 3 ++- | ||
40 | MAINTAINERS | 2 +- | ||
41 | 5 files changed, 25 insertions(+), 7 deletions(-) | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Idan Horowitz <idan.horowitz@gmail.com> | ||
1 | 2 | ||
3 | While not mentioned anywhere in the actual specification text, the | ||
4 | HCR_EL2.ATA bit is treated as '1' when EL2 is disabled at the current | ||
5 | security state. This can be observed in the psuedo-code implementation | ||
6 | of AArch64.AllocationTagAccessIsEnabled(). | ||
7 | |||
8 | Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20220328173107.311267-1-idan.horowitz@gmail.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/internals.h | 2 +- | ||
14 | target/arm/helper.c | 2 +- | ||
15 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/internals.h | ||
20 | +++ b/target/arm/internals.h | ||
21 | @@ -XXX,XX +XXX,XX @@ static inline bool allocation_tag_access_enabled(CPUARMState *env, int el, | ||
22 | && !(env->cp15.scr_el3 & SCR_ATA)) { | ||
23 | return false; | ||
24 | } | ||
25 | - if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { | ||
26 | + if (el < 2 && arm_is_el2_enabled(env)) { | ||
27 | uint64_t hcr = arm_hcr_el2_eff(env); | ||
28 | if (!(hcr & HCR_ATA) && (!(hcr & HCR_E2H) || !(hcr & HCR_TGE))) { | ||
29 | return false; | ||
30 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/helper.c | ||
33 | +++ b/target/arm/helper.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_mte(CPUARMState *env, const ARMCPRegInfo *ri, | ||
35 | { | ||
36 | int el = arm_current_el(env); | ||
37 | |||
38 | - if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { | ||
39 | + if (el < 2 && arm_is_el2_enabled(env)) { | ||
40 | uint64_t hcr = arm_hcr_el2_eff(env); | ||
41 | if (!(hcr & HCR_ATA) && (!(hcr & HCR_E2H) || !(hcr & HCR_TGE))) { | ||
42 | return CP_ACCESS_TRAP_EL2; | ||
43 | -- | ||
44 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Idan Horowitz <idan.horowitz@gmail.com> | ||
1 | 2 | ||
3 | As per the AArch64.SS2OutputPASpace() psuedo-code in the ARMv8 ARM when the | ||
4 | PA space of the IPA is non secure, the output PA space is secure if and only | ||
5 | if all of the bits VTCR.<NSW, NSA>, VSTCR.<SW, SA> are not set. | ||
6 | |||
7 | Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220327093427.1548629-2-idan.horowitz@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper.c | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper.c | ||
18 | +++ b/target/arm/helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
20 | } else { | ||
21 | attrs->secure = | ||
22 | !((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_NSW)) | ||
23 | - || (env->cp15.vstcr_el2.raw_tcr & VSTCR_SA)); | ||
24 | + || (env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW))); | ||
25 | } | ||
26 | } | ||
27 | return 0; | ||
28 | -- | ||
29 | 2.25.1 | diff view generated by jsdifflib |
1 | Our GICv3 QOM interface includes an array property | 1 | From: Idan Horowitz <idan.horowitz@gmail.com> |
---|---|---|---|
2 | redist-region-count which allows board models to specify that the | ||
3 | registributor registers are not in a single contiguous range, but | ||
4 | split into multiple pieces. We implemented this for KVM, but | ||
5 | currently the TCG GICv3 model insists that there is only one region. | ||
6 | You can see the limit being hit with a setup like: | ||
7 | qemu-system-aarch64 -machine virt,gic-version=3 -smp 124 | ||
8 | 2 | ||
9 | Add support for split regions to the TCG GICv3. To do this we switch | 3 | As per the AArch64.SS2InitialTTWState() psuedo-code in the ARMv8 ARM the |
10 | from allocating a simple array of MemoryRegions to an array of | 4 | initial PA space used for stage 2 table walks is assigned based on the SW |
11 | GICv3RedistRegion structs so that we can use the GICv3RedistRegion as | 5 | and NSW bits of the VSTCR and VTCR registers. |
12 | the opaque pointer in the MemoryRegion read/write callbacks. Each | 6 | This was already implemented for the recursive stage 2 page table walks |
13 | GICv3RedistRegion contains the MemoryRegion, a backpointer allowing | 7 | in S1_ptw_translate(), but was missing for the final stage 2 walk. |
14 | the read/write callback to get hold of the GICv3State, and an index | ||
15 | which allows us to calculate which CPU's redistributor is being | ||
16 | accessed. | ||
17 | 8 | ||
18 | Note that arm_gicv3_kvm always passes in NULL as the ops argument | 9 | Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com> |
19 | to gicv3_init_irqs_and_mmio(), so the only MemoryRegion read/write | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
20 | callbacks we need to update to handle this new scheme are the | 11 | Message-id: 20220327093427.1548629-3-idan.horowitz@gmail.com |
21 | gicv3_redist_read/write functions used by the emulated GICv3. | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | ||
14 | target/arm/helper.c | 10 ++++++++++ | ||
15 | 1 file changed, 10 insertions(+) | ||
22 | 16 | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
24 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
25 | --- | ||
26 | include/hw/intc/arm_gicv3_common.h | 12 ++++++++- | ||
27 | hw/intc/arm_gicv3.c | 6 ----- | ||
28 | hw/intc/arm_gicv3_common.c | 15 ++++++++--- | ||
29 | hw/intc/arm_gicv3_kvm.c | 4 +-- | ||
30 | hw/intc/arm_gicv3_redist.c | 40 ++++++++++++++++-------------- | ||
31 | 5 files changed, 46 insertions(+), 31 deletions(-) | ||
32 | |||
33 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/include/hw/intc/arm_gicv3_common.h | 19 | --- a/target/arm/helper.c |
36 | +++ b/include/hw/intc/arm_gicv3_common.h | 20 | +++ b/target/arm/helper.c |
37 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | 21 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, |
38 | bool seenbetter; | 22 | return ret; |
39 | }; | 23 | } |
40 | 24 | ||
41 | +/* | 25 | + if (arm_is_secure_below_el3(env)) { |
42 | + * The redistributor pages might be split into more than one region | 26 | + if (attrs->secure) { |
43 | + * on some machine types if there are many CPUs. | 27 | + attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); |
44 | + */ | 28 | + } else { |
45 | +typedef struct GICv3RedistRegion { | 29 | + attrs->secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); |
46 | + GICv3State *gic; | 30 | + } |
47 | + MemoryRegion iomem; | 31 | + } else { |
48 | + uint32_t cpuidx; /* index of first CPU this region covers */ | 32 | + assert(!attrs->secure); |
49 | +} GICv3RedistRegion; | 33 | + } |
50 | + | 34 | + |
51 | struct GICv3State { | 35 | s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; |
52 | /*< private >*/ | 36 | is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0; |
53 | SysBusDevice parent_obj; | ||
54 | /*< public >*/ | ||
55 | |||
56 | MemoryRegion iomem_dist; /* Distributor */ | ||
57 | - MemoryRegion *iomem_redist; /* Redistributor Regions */ | ||
58 | + GICv3RedistRegion *redist_regions; /* Redistributor Regions */ | ||
59 | uint32_t *redist_region_count; /* redistributor count within each region */ | ||
60 | uint32_t nb_redist_regions; /* number of redist regions */ | ||
61 | |||
62 | diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/intc/arm_gicv3.c | ||
65 | +++ b/hw/intc/arm_gicv3.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static void arm_gic_realize(DeviceState *dev, Error **errp) | ||
67 | return; | ||
68 | } | ||
69 | |||
70 | - if (s->nb_redist_regions != 1) { | ||
71 | - error_setg(errp, "VGICv3 redist region number(%d) not equal to 1", | ||
72 | - s->nb_redist_regions); | ||
73 | - return; | ||
74 | - } | ||
75 | - | ||
76 | gicv3_init_irqs_and_mmio(s, gicv3_set_irq, gic_ops); | ||
77 | |||
78 | gicv3_init_cpuif(s); | ||
79 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/intc/arm_gicv3_common.c | ||
82 | +++ b/hw/intc/arm_gicv3_common.c | ||
83 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, | ||
84 | { | ||
85 | SysBusDevice *sbd = SYS_BUS_DEVICE(s); | ||
86 | int i; | ||
87 | + int cpuidx; | ||
88 | |||
89 | /* For the GIC, also expose incoming GPIO lines for PPIs for each CPU. | ||
90 | * GPIO array layout is thus: | ||
91 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, | ||
92 | "gicv3_dist", 0x10000); | ||
93 | sysbus_init_mmio(sbd, &s->iomem_dist); | ||
94 | |||
95 | - s->iomem_redist = g_new0(MemoryRegion, s->nb_redist_regions); | ||
96 | + s->redist_regions = g_new0(GICv3RedistRegion, s->nb_redist_regions); | ||
97 | + cpuidx = 0; | ||
98 | for (i = 0; i < s->nb_redist_regions; i++) { | ||
99 | char *name = g_strdup_printf("gicv3_redist_region[%d]", i); | ||
100 | + GICv3RedistRegion *region = &s->redist_regions[i]; | ||
101 | |||
102 | - memory_region_init_io(&s->iomem_redist[i], OBJECT(s), | ||
103 | - ops ? &ops[1] : NULL, s, name, | ||
104 | + region->gic = s; | ||
105 | + region->cpuidx = cpuidx; | ||
106 | + cpuidx += s->redist_region_count[i]; | ||
107 | + | ||
108 | + memory_region_init_io(®ion->iomem, OBJECT(s), | ||
109 | + ops ? &ops[1] : NULL, region, name, | ||
110 | s->redist_region_count[i] * GICV3_REDIST_SIZE); | ||
111 | - sysbus_init_mmio(sbd, &s->iomem_redist[i]); | ||
112 | + sysbus_init_mmio(sbd, ®ion->iomem); | ||
113 | g_free(name); | ||
114 | } | ||
115 | } | ||
116 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/hw/intc/arm_gicv3_kvm.c | ||
119 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
121 | KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd, 0); | ||
122 | |||
123 | if (!multiple_redist_region_allowed) { | ||
124 | - kvm_arm_register_device(&s->iomem_redist[0], -1, | ||
125 | + kvm_arm_register_device(&s->redist_regions[0].iomem, -1, | ||
126 | KVM_DEV_ARM_VGIC_GRP_ADDR, | ||
127 | KVM_VGIC_V3_ADDR_TYPE_REDIST, s->dev_fd, 0); | ||
128 | } else { | ||
129 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
130 | uint64_t addr_ormask = | ||
131 | i | ((uint64_t)s->redist_region_count[i] << 52); | ||
132 | |||
133 | - kvm_arm_register_device(&s->iomem_redist[i], -1, | ||
134 | + kvm_arm_register_device(&s->redist_regions[i].iomem, -1, | ||
135 | KVM_DEV_ARM_VGIC_GRP_ADDR, | ||
136 | KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION, | ||
137 | s->dev_fd, addr_ormask); | ||
138 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
139 | index XXXXXXX..XXXXXXX 100644 | ||
140 | --- a/hw/intc/arm_gicv3_redist.c | ||
141 | +++ b/hw/intc/arm_gicv3_redist.c | ||
142 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writell(GICv3CPUState *cs, hwaddr offset, | ||
143 | MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
144 | unsigned size, MemTxAttrs attrs) | ||
145 | { | ||
146 | - GICv3State *s = opaque; | ||
147 | + GICv3RedistRegion *region = opaque; | ||
148 | + GICv3State *s = region->gic; | ||
149 | GICv3CPUState *cs; | ||
150 | MemTxResult r; | ||
151 | int cpuidx; | ||
152 | |||
153 | assert((offset & (size - 1)) == 0); | ||
154 | |||
155 | - /* This region covers all the redistributor pages; there are | ||
156 | - * (for GICv3) two 64K pages per CPU. At the moment they are | ||
157 | - * all contiguous (ie in this one region), though we might later | ||
158 | - * want to allow splitting of redistributor pages into several | ||
159 | - * blocks so we can support more CPUs. | ||
160 | + /* | ||
161 | + * There are (for GICv3) two 64K redistributor pages per CPU. | ||
162 | + * In some cases the redistributor pages for all CPUs are not | ||
163 | + * contiguous (eg on the virt board they are split into two | ||
164 | + * parts if there are too many CPUs to all fit in the same place | ||
165 | + * in the memory map); if so then the GIC has multiple MemoryRegions | ||
166 | + * for the redistributors. | ||
167 | */ | ||
168 | - cpuidx = offset / 0x20000; | ||
169 | - offset %= 0x20000; | ||
170 | - assert(cpuidx < s->num_cpu); | ||
171 | + cpuidx = region->cpuidx + offset / GICV3_REDIST_SIZE; | ||
172 | + offset %= GICV3_REDIST_SIZE; | ||
173 | |||
174 | cs = &s->cpu[cpuidx]; | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
177 | MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, | ||
178 | unsigned size, MemTxAttrs attrs) | ||
179 | { | ||
180 | - GICv3State *s = opaque; | ||
181 | + GICv3RedistRegion *region = opaque; | ||
182 | + GICv3State *s = region->gic; | ||
183 | GICv3CPUState *cs; | ||
184 | MemTxResult r; | ||
185 | int cpuidx; | ||
186 | |||
187 | assert((offset & (size - 1)) == 0); | ||
188 | |||
189 | - /* This region covers all the redistributor pages; there are | ||
190 | - * (for GICv3) two 64K pages per CPU. At the moment they are | ||
191 | - * all contiguous (ie in this one region), though we might later | ||
192 | - * want to allow splitting of redistributor pages into several | ||
193 | - * blocks so we can support more CPUs. | ||
194 | + /* | ||
195 | + * There are (for GICv3) two 64K redistributor pages per CPU. | ||
196 | + * In some cases the redistributor pages for all CPUs are not | ||
197 | + * contiguous (eg on the virt board they are split into two | ||
198 | + * parts if there are too many CPUs to all fit in the same place | ||
199 | + * in the memory map); if so then the GIC has multiple MemoryRegions | ||
200 | + * for the redistributors. | ||
201 | */ | ||
202 | - cpuidx = offset / 0x20000; | ||
203 | - offset %= 0x20000; | ||
204 | - assert(cpuidx < s->num_cpu); | ||
205 | + cpuidx = region->cpuidx + offset / GICV3_REDIST_SIZE; | ||
206 | + offset %= GICV3_REDIST_SIZE; | ||
207 | |||
208 | cs = &s->cpu[cpuidx]; | ||
209 | 37 | ||
210 | -- | 38 | -- |
211 | 2.25.1 | 39 | 2.25.1 |
212 | |||
213 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Idan Horowitz <idan.horowitz@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | The PL031 currently is not able to report guest RTC change to the QMP | 3 | As per the AArch64.S2Walk() pseudo-code in the ARMv8 ARM, the final |
4 | monitor as opposed to mc146818 or spapr RTCs. This patch adds the call | 4 | decision as to the output address's PA space based on the SA/SW/NSA/NSW |
5 | to qapi_event_send_rtc_change() when the Load Register is written. The | 5 | bits needs to take the input IPA's PA space into account, and not the |
6 | value which is reported corresponds to the difference between the guest | 6 | PA space of the result of the stage 2 walk itself. |
7 | reference time and the reference time kept in softmmu/rtc.c. | ||
8 | 7 | ||
9 | For instance adding 20s to the guest RTC value will report 20. Adding | 8 | Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com> |
10 | an extra 20s to the guest RTC value will report 20 + 20 = 40. | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | 10 | Message-id: 20220327093427.1548629-4-idan.horowitz@gmail.com | |
12 | The inclusion of qapi/qapi-types-misc-target.h in hw/rtl/pl031.c | 11 | [PMM: fixed commit message typo] |
13 | require to compile the PL031 with specific_ss.add() to avoid | ||
14 | ./qapi/qapi-types-misc-target.h:18:13: error: attempt to use poisoned | ||
15 | "TARGET_<ARCH>". | ||
16 | |||
17 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Message-id: 20210920122535.269988-1-eric.auger@redhat.com | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 13 | --- |
22 | hw/rtc/pl031.c | 10 +++++++++- | 14 | target/arm/helper.c | 8 +++++--- |
23 | hw/rtc/meson.build | 2 +- | 15 | 1 file changed, 5 insertions(+), 3 deletions(-) |
24 | 2 files changed, 10 insertions(+), 2 deletions(-) | ||
25 | 16 | ||
26 | diff --git a/hw/rtc/pl031.c b/hw/rtc/pl031.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
27 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/rtc/pl031.c | 19 | --- a/target/arm/helper.c |
29 | +++ b/hw/rtc/pl031.c | 20 | +++ b/target/arm/helper.c |
30 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, |
31 | #include "qemu/log.h" | 22 | hwaddr ipa; |
32 | #include "qemu/module.h" | 23 | int s2_prot; |
33 | #include "trace.h" | 24 | int ret; |
34 | +#include "qapi/qapi-events-misc-target.h" | 25 | + bool ipa_secure; |
35 | 26 | ARMCacheAttrs cacheattrs2 = {}; | |
36 | #define RTC_DR 0x00 /* Data read register */ | 27 | ARMMMUIdx s2_mmu_idx; |
37 | #define RTC_MR 0x04 /* Match register */ | 28 | bool is_el0; |
38 | @@ -XXX,XX +XXX,XX @@ static void pl031_write(void * opaque, hwaddr offset, | 29 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, |
39 | trace_pl031_write(offset, value); | 30 | return ret; |
40 | 31 | } | |
41 | switch (offset) { | 32 | |
42 | - case RTC_LR: | 33 | + ipa_secure = attrs->secure; |
43 | + case RTC_LR: { | 34 | if (arm_is_secure_below_el3(env)) { |
44 | + struct tm tm; | 35 | - if (attrs->secure) { |
45 | + | 36 | + if (ipa_secure) { |
46 | s->tick_offset += value - pl031_get_count(s); | 37 | attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); |
47 | + | 38 | } else { |
48 | + qemu_get_timedate(&tm, s->tick_offset); | 39 | attrs->secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); |
49 | + qapi_event_send_rtc_change(qemu_timedate_diff(&tm)); | 40 | } |
50 | + | 41 | } else { |
51 | pl031_set_alarm(s); | 42 | - assert(!attrs->secure); |
52 | break; | 43 | + assert(!ipa_secure); |
53 | + } | 44 | } |
54 | case RTC_MR: | 45 | |
55 | s->mr = value; | 46 | s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; |
56 | pl031_set_alarm(s); | 47 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, |
57 | diff --git a/hw/rtc/meson.build b/hw/rtc/meson.build | 48 | |
58 | index XXXXXXX..XXXXXXX 100644 | 49 | /* Check if IPA translates to secure or non-secure PA space. */ |
59 | --- a/hw/rtc/meson.build | 50 | if (arm_is_secure_below_el3(env)) { |
60 | +++ b/hw/rtc/meson.build | 51 | - if (attrs->secure) { |
61 | @@ -XXX,XX +XXX,XX @@ | 52 | + if (ipa_secure) { |
62 | softmmu_ss.add(when: 'CONFIG_DS1338', if_true: files('ds1338.c')) | 53 | attrs->secure = |
63 | softmmu_ss.add(when: 'CONFIG_M41T80', if_true: files('m41t80.c')) | 54 | !(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW)); |
64 | softmmu_ss.add(when: 'CONFIG_M48T59', if_true: files('m48t59.c')) | 55 | } else { |
65 | -softmmu_ss.add(when: 'CONFIG_PL031', if_true: files('pl031.c')) | ||
66 | +specific_ss.add(when: 'CONFIG_PL031', if_true: files('pl031.c')) | ||
67 | softmmu_ss.add(when: 'CONFIG_TWL92230', if_true: files('twl92230.c')) | ||
68 | softmmu_ss.add(when: ['CONFIG_ISA_BUS', 'CONFIG_M48T59'], if_true: files('m48t59-isa.c')) | ||
69 | softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP', if_true: files('xlnx-zynqmp-rtc.c')) | ||
70 | -- | 56 | -- |
71 | 2.25.1 | 57 | 2.25.1 |
72 | |||
73 | diff view generated by jsdifflib |
1 | The 'Last' bit in the GICR_TYPER GICv3 redistributor register is | 1 | From: Frederic Konrad <konrad@adacore.com> |
---|---|---|---|
2 | supposed to be set to 1 if this is the last redistributor in a series | ||
3 | of contiguous redistributor pages. Currently we set Last only for | ||
4 | the redistributor for CPU (num_cpu - 1). This only works if there is | ||
5 | a single redistributor region; if there are multiple redistributor | ||
6 | regions then we need to set the Last bit for the last redistributor | ||
7 | in each region. | ||
8 | 2 | ||
9 | This doesn't cause any problems currently because only the KVM GICv3 | 3 | frederic.konrad@adacore.com and konrad@adacore.com will stop working starting |
10 | supports multiple redistributor regions, and it ignores the value in | 4 | 2022-04-01. |
11 | GICv3State::gicr_typer. But we need to fix this before we can enable | ||
12 | support for multiple regions in the emulated GICv3. | ||
13 | 5 | ||
6 | Use my personal email instead. | ||
7 | |||
8 | Signed-off-by: Frederic Konrad <frederic.konrad@adacore.com> | ||
9 | Reviewed-by: Fabien Chouteau <chouteau@adacore.com <clg@kaod.org>> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 1648643217-15811-1-git-send-email-frederic.konrad@adacore.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | 13 | --- |
17 | hw/intc/arm_gicv3_common.c | 17 ++++++++++++----- | 14 | .mailmap | 3 ++- |
18 | 1 file changed, 12 insertions(+), 5 deletions(-) | 15 | MAINTAINERS | 2 +- |
16 | 2 files changed, 3 insertions(+), 2 deletions(-) | ||
19 | 17 | ||
20 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | 18 | diff --git a/.mailmap b/.mailmap |
21 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/intc/arm_gicv3_common.c | 20 | --- a/.mailmap |
23 | +++ b/hw/intc/arm_gicv3_common.c | 21 | +++ b/.mailmap |
24 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, | 22 | @@ -XXX,XX +XXX,XX @@ Alexander Graf <agraf@csgraf.de> <agraf@suse.de> |
25 | static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | 23 | Anthony Liguori <anthony@codemonkey.ws> Anthony Liguori <aliguori@us.ibm.com> |
26 | { | 24 | Christian Borntraeger <borntraeger@linux.ibm.com> <borntraeger@de.ibm.com> |
27 | GICv3State *s = ARM_GICV3_COMMON(dev); | 25 | Filip Bozuta <filip.bozuta@syrmia.com> <filip.bozuta@rt-rk.com.com> |
28 | - int i, rdist_capacity; | 26 | -Frederic Konrad <konrad@adacore.com> <fred.konrad@greensocs.com> |
29 | + int i, rdist_capacity, cpuidx; | 27 | +Frederic Konrad <konrad.frederic@yahoo.fr> <fred.konrad@greensocs.com> |
30 | 28 | +Frederic Konrad <konrad.frederic@yahoo.fr> <konrad@adacore.com> | |
31 | /* revision property is actually reserved and currently used only in order | 29 | Greg Kurz <groug@kaod.org> <gkurz@linux.vnet.ibm.com> |
32 | * to keep the interface compatible with GICv2 code, avoiding extra | 30 | Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com> |
33 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | 31 | Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn> |
34 | for (i = 0; i < s->num_cpu; i++) { | 32 | diff --git a/MAINTAINERS b/MAINTAINERS |
35 | CPUState *cpu = qemu_get_cpu(i); | 33 | index XXXXXXX..XXXXXXX 100644 |
36 | uint64_t cpu_affid; | 34 | --- a/MAINTAINERS |
37 | - int last; | 35 | +++ b/MAINTAINERS |
38 | 36 | @@ -XXX,XX +XXX,XX @@ F: include/hw/rtc/sun4v-rtc.h | |
39 | s->cpu[i].cpu = cpu; | 37 | |
40 | s->cpu[i].gic = s; | 38 | Leon3 |
41 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | 39 | M: Fabien Chouteau <chouteau@adacore.com> |
42 | * PLPIS == 0 (physical LPIs not supported) | 40 | -M: KONRAD Frederic <frederic.konrad@adacore.com> |
43 | */ | 41 | +M: Frederic Konrad <konrad.frederic@yahoo.fr> |
44 | cpu_affid = object_property_get_uint(OBJECT(cpu), "mp-affinity", NULL); | 42 | S: Maintained |
45 | - last = (i == s->num_cpu - 1); | 43 | F: hw/sparc/leon3.c |
46 | 44 | F: hw/*/grlib* | |
47 | /* The CPU mp-affinity property is in MPIDR register format; squash | ||
48 | * the affinity bytes into 32 bits as the GICR_TYPER has them. | ||
49 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | ||
50 | (cpu_affid & 0xFFFFFF); | ||
51 | s->cpu[i].gicr_typer = (cpu_affid << 32) | | ||
52 | (1 << 24) | | ||
53 | - (i << 8) | | ||
54 | - (last << 4); | ||
55 | + (i << 8); | ||
56 | |||
57 | if (s->lpi_enable) { | ||
58 | s->cpu[i].gicr_typer |= GICR_TYPER_PLPIS; | ||
59 | } | ||
60 | } | ||
61 | + | ||
62 | + /* | ||
63 | + * Now go through and set GICR_TYPER.Last for the final | ||
64 | + * redistributor in each region. | ||
65 | + */ | ||
66 | + cpuidx = 0; | ||
67 | + for (i = 0; i < s->nb_redist_regions; i++) { | ||
68 | + cpuidx += s->redist_region_count[i]; | ||
69 | + s->cpu[cpuidx - 1].gicr_typer |= GICR_TYPER_LAST; | ||
70 | + } | ||
71 | } | ||
72 | |||
73 | static void arm_gicv3_finalize(Object *obj) | ||
74 | -- | 45 | -- |
75 | 2.25.1 | 46 | 2.25.1 |
76 | 47 | ||
77 | 48 | diff view generated by jsdifflib |
1 | The GICv3 devices have an array property redist-region-count. | 1 | In gen_store_exclusive(), if the host does not have a cmpxchg128 |
---|---|---|---|
2 | Currently we check this for errors (bad values) in | 2 | primitive then we generate bad code for STXP for storing two 64-bit |
3 | gicv3_init_irqs_and_mmio(), just before we use it. Move this error | 3 | values. We generate a call to the exit_atomic helper, which never |
4 | checking to the arm_gicv3_common_realize() function, where we | 4 | returns, and set is_jmp to DISAS_NORETURN. However, this is |
5 | sanity-check all of the other base-class properties. (This will | 5 | forgetting that we have already emitted a brcond that jumps over this |
6 | always be before gicv3_init_irqs_and_mmio() is called, because | 6 | call for the case where we don't hold the exclusive. The effect is |
7 | that function is called in the subclass realize methods, after | 7 | that we don't generate any code to end the TB for the |
8 | they have called the parent-class realize.) | 8 | exclusive-not-held execution path, which falls into the "exit with |
9 | TB_EXIT_REQUESTED" code that gen_tb_end() emits. This then causes an | ||
10 | assert at runtime when cpu_loop_exec_tb() sees an EXIT_REQUESTED TB | ||
11 | return that wasn't for an interrupt or icount. | ||
9 | 12 | ||
10 | The motivation for this refactor is: | 13 | In particular, you can hit this case when using the clang sanitizers |
11 | * we would like to use the redist_region_count[] values in | 14 | and trying to run the xlnx-versal-virt acceptance test in 'make |
12 | arm_gicv3_common_realize() in a subsequent patch, so we need | 15 | check-acceptance'. This bug was masked until commit 848126d11e93ff |
13 | to have already done the sanity-checking first | 16 | ("meson: move int128 checks from configure") because we used to set |
14 | * this removes the only use of the Error** argument to | 17 | CONFIG_CMPXCHG128=1 and avoid the buggy codepath, but after that we |
15 | gicv3_init_irqs_and_mmio(), so we can remove some error-handling | 18 | do not. |
16 | boilerplate | ||
17 | 19 | ||
20 | Fix the bug by not setting is_jmp. The code after the exit_atomic | ||
21 | call up to the fail_label is dead, but TCG is smart enough to | ||
22 | eliminate it. We do need to set 'tmp' to some valid value, though | ||
23 | (in the same way the exit_atomic-using code in tcg/tcg-op.c does). | ||
24 | |||
25 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/953 | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
28 | Message-id: 20220331150858.96348-1-peter.maydell@linaro.org | ||
20 | --- | 29 | --- |
21 | include/hw/intc/arm_gicv3_common.h | 2 +- | 30 | target/arm/translate-a64.c | 7 ++++++- |
22 | hw/intc/arm_gicv3.c | 6 +----- | 31 | 1 file changed, 6 insertions(+), 1 deletion(-) |
23 | hw/intc/arm_gicv3_common.c | 26 +++++++++++++------------- | ||
24 | hw/intc/arm_gicv3_kvm.c | 6 +----- | ||
25 | 4 files changed, 16 insertions(+), 24 deletions(-) | ||
26 | 32 | ||
27 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | 33 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
28 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/include/hw/intc/arm_gicv3_common.h | 35 | --- a/target/arm/translate-a64.c |
30 | +++ b/include/hw/intc/arm_gicv3_common.h | 36 | +++ b/target/arm/translate-a64.c |
31 | @@ -XXX,XX +XXX,XX @@ struct ARMGICv3CommonClass { | 37 | @@ -XXX,XX +XXX,XX @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, |
32 | }; | 38 | } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { |
33 | 39 | if (!HAVE_CMPXCHG128) { | |
34 | void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, | 40 | gen_helper_exit_atomic(cpu_env); |
35 | - const MemoryRegionOps *ops, Error **errp); | 41 | - s->base.is_jmp = DISAS_NORETURN; |
36 | + const MemoryRegionOps *ops); | 42 | + /* |
37 | 43 | + * Produce a result so we have a well-formed opcode | |
38 | #endif | 44 | + * stream when the following (dead) code uses 'tmp'. |
39 | diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c | 45 | + * TCG will remove the dead ops for us. |
40 | index XXXXXXX..XXXXXXX 100644 | 46 | + */ |
41 | --- a/hw/intc/arm_gicv3.c | 47 | + tcg_gen_movi_i64(tmp, 0); |
42 | +++ b/hw/intc/arm_gicv3.c | 48 | } else if (s->be_data == MO_LE) { |
43 | @@ -XXX,XX +XXX,XX @@ static void arm_gic_realize(DeviceState *dev, Error **errp) | 49 | gen_helper_paired_cmpxchg64_le_parallel(tmp, cpu_env, |
44 | return; | 50 | cpu_exclusive_addr, |
45 | } | ||
46 | |||
47 | - gicv3_init_irqs_and_mmio(s, gicv3_set_irq, gic_ops, &local_err); | ||
48 | - if (local_err) { | ||
49 | - error_propagate(errp, local_err); | ||
50 | - return; | ||
51 | - } | ||
52 | + gicv3_init_irqs_and_mmio(s, gicv3_set_irq, gic_ops); | ||
53 | |||
54 | gicv3_init_cpuif(s); | ||
55 | } | ||
56 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/intc/arm_gicv3_common.c | ||
59 | +++ b/hw/intc/arm_gicv3_common.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3 = { | ||
61 | }; | ||
62 | |||
63 | void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, | ||
64 | - const MemoryRegionOps *ops, Error **errp) | ||
65 | + const MemoryRegionOps *ops) | ||
66 | { | ||
67 | SysBusDevice *sbd = SYS_BUS_DEVICE(s); | ||
68 | - int rdist_capacity = 0; | ||
69 | int i; | ||
70 | |||
71 | - for (i = 0; i < s->nb_redist_regions; i++) { | ||
72 | - rdist_capacity += s->redist_region_count[i]; | ||
73 | - } | ||
74 | - if (rdist_capacity < s->num_cpu) { | ||
75 | - error_setg(errp, "Capacity of the redist regions(%d) " | ||
76 | - "is less than number of vcpus(%d)", | ||
77 | - rdist_capacity, s->num_cpu); | ||
78 | - return; | ||
79 | - } | ||
80 | - | ||
81 | /* For the GIC, also expose incoming GPIO lines for PPIs for each CPU. | ||
82 | * GPIO array layout is thus: | ||
83 | * [0..N-1] spi | ||
84 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, | ||
85 | static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | ||
86 | { | ||
87 | GICv3State *s = ARM_GICV3_COMMON(dev); | ||
88 | - int i; | ||
89 | + int i, rdist_capacity; | ||
90 | |||
91 | /* revision property is actually reserved and currently used only in order | ||
92 | * to keep the interface compatible with GICv2 code, avoiding extra | ||
93 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | ||
94 | return; | ||
95 | } | ||
96 | |||
97 | + rdist_capacity = 0; | ||
98 | + for (i = 0; i < s->nb_redist_regions; i++) { | ||
99 | + rdist_capacity += s->redist_region_count[i]; | ||
100 | + } | ||
101 | + if (rdist_capacity < s->num_cpu) { | ||
102 | + error_setg(errp, "Capacity of the redist regions(%d) " | ||
103 | + "is less than number of vcpus(%d)", | ||
104 | + rdist_capacity, s->num_cpu); | ||
105 | + return; | ||
106 | + } | ||
107 | + | ||
108 | s->cpu = g_new0(GICv3CPUState, s->num_cpu); | ||
109 | |||
110 | for (i = 0; i < s->num_cpu; i++) { | ||
111 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/hw/intc/arm_gicv3_kvm.c | ||
114 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
116 | return; | ||
117 | } | ||
118 | |||
119 | - gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL, &local_err); | ||
120 | - if (local_err) { | ||
121 | - error_propagate(errp, local_err); | ||
122 | - return; | ||
123 | - } | ||
124 | + gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL); | ||
125 | |||
126 | for (i = 0; i < s->num_cpu; i++) { | ||
127 | ARMCPU *cpu = ARM_CPU(qemu_get_cpu(i)); | ||
128 | -- | 51 | -- |
129 | 2.25.1 | 52 | 2.25.1 |
130 | |||
131 | diff view generated by jsdifflib |