Skip to content

Commit 03bd646

Browse files
author
Marc Zyngier
committed
KVM: arm64: vgic-v3: Add support for ICC_SGI0R_EL1 and ICC_ASGI1R_EL1 accesses
In order to generate Group0 SGIs, let's add some decoding logic to access_gic_sgi(), and pass the generating group accordingly. Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent 6249f2a commit 03bd646

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

arch/arm64/include/asm/sysreg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@
314314
#define SYS_ICC_DIR_EL1 sys_reg(3, 0, 12, 11, 1)
315315
#define SYS_ICC_RPR_EL1 sys_reg(3, 0, 12, 11, 3)
316316
#define SYS_ICC_SGI1R_EL1 sys_reg(3, 0, 12, 11, 5)
317+
#define SYS_ICC_ASGI1R_EL1 sys_reg(3, 0, 12, 11, 6)
318+
#define SYS_ICC_SGI0R_EL1 sys_reg(3, 0, 12, 11, 7)
317319
#define SYS_ICC_IAR1_EL1 sys_reg(3, 0, 12, 12, 0)
318320
#define SYS_ICC_EOIR1_EL1 sys_reg(3, 0, 12, 12, 1)
319321
#define SYS_ICC_HPPIR1_EL1 sys_reg(3, 0, 12, 12, 2)

arch/arm64/kvm/sys_regs.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,43 @@ static bool access_gic_sgi(struct kvm_vcpu *vcpu,
252252
struct sys_reg_params *p,
253253
const struct sys_reg_desc *r)
254254
{
255+
bool g1;
256+
255257
if (!p->is_write)
256258
return read_from_write_only(vcpu, p, r);
257259

258-
vgic_v3_dispatch_sgi(vcpu, p->regval, true);
260+
/*
261+
* In a system where GICD_CTLR.DS=1, a ICC_SGI0R_EL1 access generates
262+
* Group0 SGIs only, while ICC_SGI1R_EL1 can generate either group,
263+
* depending on the SGI configuration. ICC_ASGI1R_EL1 is effectively
264+
* equivalent to ICC_SGI0R_EL1, as there is no "alternative" secure
265+
* group.
266+
*/
267+
if (p->is_aarch32) {
268+
switch (p->Op1) {
269+
default: /* Keep GCC quiet */
270+
case 0: /* ICC_SGI1R */
271+
g1 = true;
272+
break;
273+
case 1: /* ICC_ASGI1R */
274+
case 2: /* ICC_SGI0R */
275+
g1 = false;
276+
break;
277+
}
278+
} else {
279+
switch (p->Op2) {
280+
default: /* Keep GCC quiet */
281+
case 5: /* ICC_SGI1R_EL1 */
282+
g1 = true;
283+
break;
284+
case 6: /* ICC_ASGI1R_EL1 */
285+
case 7: /* ICC_SGI0R_EL1 */
286+
g1 = false;
287+
break;
288+
}
289+
}
290+
291+
vgic_v3_dispatch_sgi(vcpu, p->regval, g1);
259292

260293
return true;
261294
}
@@ -1312,6 +1345,8 @@ static const struct sys_reg_desc sys_reg_descs[] = {
13121345
{ SYS_DESC(SYS_ICC_DIR_EL1), read_from_write_only },
13131346
{ SYS_DESC(SYS_ICC_RPR_EL1), write_to_read_only },
13141347
{ SYS_DESC(SYS_ICC_SGI1R_EL1), access_gic_sgi },
1348+
{ SYS_DESC(SYS_ICC_ASGI1R_EL1), access_gic_sgi },
1349+
{ SYS_DESC(SYS_ICC_SGI0R_EL1), access_gic_sgi },
13151350
{ SYS_DESC(SYS_ICC_IAR1_EL1), write_to_read_only },
13161351
{ SYS_DESC(SYS_ICC_EOIR1_EL1), read_from_write_only },
13171352
{ SYS_DESC(SYS_ICC_HPPIR1_EL1), write_to_read_only },
@@ -1744,8 +1779,10 @@ static const struct sys_reg_desc cp15_regs[] = {
17441779
static const struct sys_reg_desc cp15_64_regs[] = {
17451780
{ Op1( 0), CRn( 0), CRm( 2), Op2( 0), access_vm_reg, NULL, c2_TTBR0 },
17461781
{ Op1( 0), CRn( 0), CRm( 9), Op2( 0), access_pmu_evcntr },
1747-
{ Op1( 0), CRn( 0), CRm(12), Op2( 0), access_gic_sgi },
1782+
{ Op1( 0), CRn( 0), CRm(12), Op2( 0), access_gic_sgi }, /* ICC_SGI1R */
17481783
{ Op1( 1), CRn( 0), CRm( 2), Op2( 0), access_vm_reg, NULL, c2_TTBR1 },
1784+
{ Op1( 1), CRn( 0), CRm(12), Op2( 0), access_gic_sgi }, /* ICC_ASGI1R */
1785+
{ Op1( 2), CRn( 0), CRm(12), Op2( 0), access_gic_sgi }, /* ICC_SGI0R */
17491786
{ Op1( 2), CRn( 0), CRm(14), Op2( 0), access_cntp_cval },
17501787
};
17511788

0 commit comments

Comments
 (0)