Skip to content

Commit 0cb8aae

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: nv: Add handling of outer-shareable TLBI operations
Our handling of outer-shareable TLBIs is pretty basic: we just map them to the existing inner-shareable ones, because we really don't have anything else. The only significant change is that we can now advertise FEAT_TLBIOS support if the host supports it. Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 809b2e6 commit 0cb8aae

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

arch/arm64/kvm/hyp/vhe/tlb.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ void __kvm_flush_vm_context(void)
226226
*
227227
* - a TLBI targeting EL2 S1 is remapped to EL1 S1
228228
* - a non-shareable TLBI is upgraded to being inner-shareable
229+
* - an outer-shareable TLBI is also mapped to inner-shareable
229230
*/
230231
int __kvm_tlbi_s1e2(struct kvm_s2_mmu *mmu, u64 va, u64 sys_encoding)
231232
{
@@ -245,32 +246,41 @@ int __kvm_tlbi_s1e2(struct kvm_s2_mmu *mmu, u64 va, u64 sys_encoding)
245246
switch (sys_encoding) {
246247
case OP_TLBI_ALLE2:
247248
case OP_TLBI_ALLE2IS:
249+
case OP_TLBI_ALLE2OS:
248250
case OP_TLBI_VMALLE1:
249251
case OP_TLBI_VMALLE1IS:
252+
case OP_TLBI_VMALLE1OS:
250253
__tlbi(vmalle1is);
251254
break;
252255
case OP_TLBI_VAE2:
253256
case OP_TLBI_VAE2IS:
257+
case OP_TLBI_VAE2OS:
254258
case OP_TLBI_VAE1:
255259
case OP_TLBI_VAE1IS:
260+
case OP_TLBI_VAE1OS:
256261
__tlbi(vae1is, va);
257262
break;
258263
case OP_TLBI_VALE2:
259264
case OP_TLBI_VALE2IS:
265+
case OP_TLBI_VALE2OS:
260266
case OP_TLBI_VALE1:
261267
case OP_TLBI_VALE1IS:
268+
case OP_TLBI_VALE1OS:
262269
__tlbi(vale1is, va);
263270
break;
264271
case OP_TLBI_ASIDE1:
265272
case OP_TLBI_ASIDE1IS:
273+
case OP_TLBI_ASIDE1OS:
266274
__tlbi(aside1is, va);
267275
break;
268276
case OP_TLBI_VAAE1:
269277
case OP_TLBI_VAAE1IS:
278+
case OP_TLBI_VAAE1OS:
270279
__tlbi(vaae1is, va);
271280
break;
272281
case OP_TLBI_VAALE1:
273282
case OP_TLBI_VAALE1IS:
283+
case OP_TLBI_VAALE1OS:
274284
__tlbi(vaale1is, va);
275285
break;
276286
default:

arch/arm64/kvm/nested.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,12 @@ static u64 limit_nv_id_reg(u32 id, u64 val)
805805

806806
switch (id) {
807807
case SYS_ID_AA64ISAR0_EL1:
808-
/* Support everything but TME, O.S. and Range TLBIs */
808+
/* Support everything but TME and Range TLBIs */
809+
tmp = FIELD_GET(NV_FTR(ISAR0, TLB), val);
810+
tmp = min(tmp, ID_AA64ISAR0_EL1_TLB_OS);
809811
val &= ~(NV_FTR(ISAR0, TLB) |
810812
NV_FTR(ISAR0, TME));
813+
val |= FIELD_PREP(NV_FTR(ISAR0, TLB), tmp);
811814
break;
812815

813816
case SYS_ID_AA64ISAR1_EL1:

arch/arm64/kvm/sys_regs.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,13 @@ static struct sys_reg_desc sys_insn_descs[] = {
29592959
{ SYS_DESC(SYS_DC_CIGSW), access_dcgsw },
29602960
{ SYS_DESC(SYS_DC_CIGDSW), access_dcgsw },
29612961

2962+
SYS_INSN(TLBI_VMALLE1OS, handle_tlbi_el1),
2963+
SYS_INSN(TLBI_VAE1OS, handle_tlbi_el1),
2964+
SYS_INSN(TLBI_ASIDE1OS, handle_tlbi_el1),
2965+
SYS_INSN(TLBI_VAAE1OS, handle_tlbi_el1),
2966+
SYS_INSN(TLBI_VALE1OS, handle_tlbi_el1),
2967+
SYS_INSN(TLBI_VAALE1OS, handle_tlbi_el1),
2968+
29622969
SYS_INSN(TLBI_VMALLE1IS, handle_tlbi_el1),
29632970
SYS_INSN(TLBI_VAE1IS, handle_tlbi_el1),
29642971
SYS_INSN(TLBI_ASIDE1IS, handle_tlbi_el1),
@@ -2975,9 +2982,17 @@ static struct sys_reg_desc sys_insn_descs[] = {
29752982
SYS_INSN(TLBI_IPAS2E1IS, handle_ipas2e1is),
29762983
SYS_INSN(TLBI_IPAS2LE1IS, handle_ipas2e1is),
29772984

2985+
SYS_INSN(TLBI_ALLE2OS, trap_undef),
2986+
SYS_INSN(TLBI_VAE2OS, trap_undef),
2987+
SYS_INSN(TLBI_ALLE1OS, handle_alle1is),
2988+
SYS_INSN(TLBI_VALE2OS, trap_undef),
2989+
SYS_INSN(TLBI_VMALLS12E1OS, handle_vmalls12e1is),
2990+
29782991
SYS_INSN(TLBI_ALLE1IS, handle_alle1is),
29792992
SYS_INSN(TLBI_VMALLS12E1IS, handle_vmalls12e1is),
2993+
SYS_INSN(TLBI_IPAS2E1OS, handle_ipas2e1is),
29802994
SYS_INSN(TLBI_IPAS2E1, handle_ipas2e1is),
2995+
SYS_INSN(TLBI_IPAS2LE1OS, handle_ipas2e1is),
29812996
SYS_INSN(TLBI_IPAS2LE1, handle_ipas2e1is),
29822997
SYS_INSN(TLBI_ALLE1, handle_alle1is),
29832998
SYS_INSN(TLBI_VMALLS12E1, handle_vmalls12e1is),

0 commit comments

Comments
 (0)