diff options
| -rw-r--r-- | arch/arm64/include/asm/kvm_emulate.h | 3 | ||||
| -rw-r--r-- | arch/arm64/kvm/sys_regs.c | 15 |
2 files changed, 17 insertions, 1 deletions
diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index 9acccb1e3746..d3842791e1c4 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h | |||
| @@ -78,7 +78,8 @@ static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu) | |||
| 78 | if (!vcpu_el1_is_32bit(vcpu)) | 78 | if (!vcpu_el1_is_32bit(vcpu)) |
| 79 | vcpu->arch.hcr_el2 |= HCR_TID3; | 79 | vcpu->arch.hcr_el2 |= HCR_TID3; |
| 80 | 80 | ||
| 81 | if (cpus_have_const_cap(ARM64_MISMATCHED_CACHE_TYPE)) | 81 | if (cpus_have_const_cap(ARM64_MISMATCHED_CACHE_TYPE) || |
| 82 | vcpu_el1_is_32bit(vcpu)) | ||
| 82 | vcpu->arch.hcr_el2 |= HCR_TID2; | 83 | vcpu->arch.hcr_el2 |= HCR_TID2; |
| 83 | } | 84 | } |
| 84 | 85 | ||
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 45a07cfc57ed..81a342679e60 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c | |||
| @@ -1186,6 +1186,21 @@ static bool access_ccsidr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, | |||
| 1186 | 1186 | ||
| 1187 | csselr = vcpu_read_sys_reg(vcpu, CSSELR_EL1); | 1187 | csselr = vcpu_read_sys_reg(vcpu, CSSELR_EL1); |
| 1188 | p->regval = get_ccsidr(csselr); | 1188 | p->regval = get_ccsidr(csselr); |
| 1189 | |||
| 1190 | /* | ||
| 1191 | * Guests should not be doing cache operations by set/way at all, and | ||
| 1192 | * for this reason, we trap them and attempt to infer the intent, so | ||
| 1193 | * that we can flush the entire guest's address space at the appropriate | ||
| 1194 | * time. | ||
| 1195 | * To prevent this trapping from causing performance problems, let's | ||
| 1196 | * expose the geometry of all data and unified caches (which are | ||
| 1197 | * guaranteed to be PIPT and thus non-aliasing) as 1 set and 1 way. | ||
| 1198 | * [If guests should attempt to infer aliasing properties from the | ||
| 1199 | * geometry (which is not permitted by the architecture), they would | ||
| 1200 | * only do so for virtually indexed caches.] | ||
| 1201 | */ | ||
| 1202 | if (!(csselr & 1)) // data or unified cache | ||
| 1203 | p->regval &= ~GENMASK(27, 3); | ||
| 1189 | return true; | 1204 | return true; |
| 1190 | } | 1205 | } |
| 1191 | 1206 | ||
