KVM: arm64: Handle MTE Set/Way CMOs
Marc Zyngier
maintainercover KVM: arm64: Handle MTE Set/Way CMOs
When the MTE support was added, it seens the handling of MTE Set/Way was ommited, meaning that the guest will get an UNDEF if it tries to do something that is quite stupid, but still allowed by the architecture...
Found by inspection while writting the trap support for NV.
Marc Zyngier (2):
arm64: Add missing Set/Way CMO encodings
KVM: arm64: Handle trap of tagged Set/Way CMOs
arch/arm64/include/asm/sysreg.h | 6 ++++++ arch/arm64/kvm/sys_regs.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+)
Signature · 1 line
2.34.1
Marc Zyngier
maintainerPATCH 1/2 arm64: Add missing Set/Way CMO encodings
Add the missing Set/Way CMOs that apply to tagged memory.
--- arch/arm64/include/asm/sysreg.h | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/include/asm/sysreg.h +6 -0
@@ -115,8 +115,14 @@#define SB_BARRIER_INSN __SYS_BARRIER_INSN(0, 7, 31)#define SYS_DC_ISW sys_insn(1, 0, 7, 6, 2) +#define SYS_DC_IGSW sys_insn(1, 0, 7, 6, 4) +#define SYS_DC_IGDSW sys_insn(1, 0, 7, 6, 6)#define SYS_DC_CSW sys_insn(1, 0, 7, 10, 2) +#define SYS_DC_CGSW sys_insn(1, 0, 7, 10, 4) +#define SYS_DC_CGDSW sys_insn(1, 0, 7, 10, 6)#define SYS_DC_CISW sys_insn(1, 0, 7, 14, 2) +#define SYS_DC_CIGSW sys_insn(1, 0, 7, 14, 4) +#define SYS_DC_CIGDSW sys_insn(1, 0, 7, 14, 6)/* * Automatically generated definitions for system registers, the
Signature · 1 line
2.34.1
Re: [PATCH 1/2] arm64: Add missing Set/Way CMO encodings
Quoted 6 lines · Marc Zyngier
Add the missing Set/Way CMOs that apply to tagged memory.
Signed-off-by Marc Zyngier <[email protected]>--- arch/arm64/include/asm/sysreg.h | 6 ++++++ 1 file changed, 6 insertions(+)
Marc Zyngier
maintainerPATCH 2/2 KVM: arm64: Handle trap of tagged Set/Way CMOs
In reply to Marc ZyngierWe appear to have missed the Set/Way CMOs when adding MTE support. Not that we really expect anyone to use them, but you never know what stupidity some people can come up with...
Treat these mostly like we deal with the classic S/W CMOs, only with an additional check that MTE really is enabled.
--- arch/arm64/kvm/sys_regs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm64/kvm/sys_regs.c +19 -0
@@ -211,6 +211,19 @@ static bool access_dcsw(struct kvm_vcpu *vcpu,return true; } +static bool access_dcgsw (struct kvm_vcpu *vcpu, +struct sys_reg_params *p, +const struct sys_reg_desc *r) +{ +if (!kvm_has_mte (vcpu->kvm)) { +kvm_inject_undefined (vcpu); +return false; + } + +/* Treat MTE S/W ops as we treat the classic ones: with contempt */ +return access_dcsw (vcpu, p, r); +} +static void get_access_mask (const struct sys_reg_desc *r,u64 *mask,u64 *shift) {switch (r->aarch32_map) {
@@ -1756,8 +1769,14 @@ static bool access_spsr(struct kvm_vcpu *vcpu,*/ static const struct sys_reg_desc sys_reg_descs[] = { {SYS_DESC (SYS_DC_ISW ), access_dcsw }, + {SYS_DESC (SYS_DC_IGSW ), access_dcgsw }, + {SYS_DESC (SYS_DC_IGDSW ), access_dcgsw }, {SYS_DESC (SYS_DC_CSW ), access_dcsw }, + {SYS_DESC (SYS_DC_CGSW ), access_dcgsw }, + {SYS_DESC (SYS_DC_CGDSW ), access_dcgsw }, {SYS_DESC (SYS_DC_CISW ), access_dcsw }, + {SYS_DESC (SYS_DC_CIGSW ), access_dcgsw }, + {SYS_DESC (SYS_DC_CIGDSW ), access_dcgsw },DBG_BCR_BVR_WCR_WVR_EL1 (0 ),DBG_BCR_BVR_WCR_WVR_EL1 (1 ),
Signature · 1 line
2.34.1
Re: [PATCH 2/2] KVM: arm64: Handle trap of tagged Set/Way CMOs
Quoted 11 lines · Marc Zyngier
We appear to have missed the Set/Way CMOs when adding MTE support. Not that we really expect anyone to use them, but you never know what stupidity some people can come up with...
Treat these mostly like we deal with the classic S/W CMOs, only with an additional check that MTE really is enabled.
Signed-off-by Marc Zyngier <[email protected]>--- arch/arm64/kvm/sys_regs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Quoted 4 lines · Marc Zyngier
When the MTE support was added, it seens the handling of MTE Set/Way was ommited, meaning that the guest will get an UNDEF if it tries to do something that is quite stupid, but still allowed by the architecture...
Sorry about that, as you say it's quite a stupid thing for a guest to attempt and it hadn't occurred to me when implementing KVM support.
Both patches:
Thanks,
Steve
Quoted 11 lines
Found by inspection while writting the trap support for NV.
Marc Zyngier (2):
arm64: Add missing Set/Way CMO encodings
KVM: arm64: Handle trap of tagged Set/Way CMOsarch/arm64/include/asm/sysreg.h | 6 ++++++ arch/arm64/kvm/sys_regs.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+)
Quoted 10 lines · Marc Zyngier
When the MTE support was added, it seens the handling of MTE Set/Way was ommited, meaning that the guest will get an UNDEF if it tries to do something that is quite stupid, but still allowed by the architecture...
Found by inspection while writting the trap support for NV.
Marc Zyngier (2):
arm64: Add missing Set/Way CMO encodings
KVM: arm64: Handle trap of tagged Set/Way CMOs
For the series:
Signature · 2 lines
Thanks, Oliver
Quoted 8 lines · Marc Zyngier
When the MTE support was added, it seens the handling of MTE Set/Way was ommited, meaning that the guest will get an UNDEF if it tries to do something that is quite stupid, but still allowed by the architecture...
Found by inspection while writting the trap support for NV.
[...]
Applied to fixes, thanks!
[1/2] arm64: Add missing Set/Way CMO encodings
commit: 8d0f019e4c4f2ee2de81efd9bf1c27e9fb3c0460
[2/2] KVM: arm64: Handle trap of tagged Set/Way CMOs
commit: d282fa3c5ccb7a0029c418f358143689553b6447Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.