KVM: arm64: Fixes for the exposed debug architecture
cover KVM: arm64: Fixes for the exposed debug architecture
I had a conversation with Marc about some of the quirks around the debug architecture on KVM and incorporated some of his suggestions into a series here. Of course, any glaring mistakes/choices made in this series is on me :-)
Anyhow:
KVM's implementation of the debug architecture is a bit deviant as it stands. For one, KVM handles the OS Lock as RAZ/WI, even though the architecture mandates it. Additionally, KVM advertises more than it can actually support: FEAT_DoubleLock is exposed as implemented to the guest, though OSDLR_EL1 is handled as RAZ/WI too.
Only v8.2+ revisions of the debug architecture permit implementations to omit DoubleLock. Fortunately, the delta between v8.0 and v8.2 is entirely focused on external debug, a feature that KVM does not support and likely never will. So, there isn't much of a hurdle to bump KVM's reported DebugVer to v8.2, thereby allowing KVM to omit DoubleLock from ID_AA64DFR0_EL1. Of the remaining bits of external debug visible to the guest, the only additional thing to address is the OSLAR_EL1 issue by simply context switching the host/guest values.
Patch 1 changes the way KVM backs OSLSR_EL1 in the sys reg table. Instead of returning a static value from its handler, stash a copy of it in kvm_cpu_context and return that when read.
Patch 2 makes the material change of allowing a guest to actually toggle the OSLK bit by redirecting writes to OSLAR_EL1.OSLK to OSLSR_EL1.OSLK. When saving context, simply stash the value of OSLSR_EL1. On resume, apply OSLSR_EL1.OSLK to OSLAR_EL1.OSLK.
Finally, Patch 3 raises the KVM debug architecture to v8.2 and exposes FEAT_DoubleLock as NI to the guest. With the changes to OSLAR_EL1 in this series, KVM now does what it says on the tin.
This series applies cleanly to 5.15-rc4, and was (lightly) tested by booting 5.15-rc4 as a kvmtool guest on this kernel.
Oliver Upton (3):
KVM: arm64: Stash OSLSR_EL1 in the cpu context
KVM: arm64: Allow the guest to change the OS Lock status
KVM: arm64: Raise KVM's reported debug architecture to v8.2
arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 5 +++ arch/arm64/kvm/sys_regs.c | 42 ++++++++++++++++------ 3 files changed, 37 insertions(+), 11 deletions(-)
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH 1/3 KVM: arm64: Stash OSLSR_EL1 in the cpu context
An upcoming change to KVM will context switch the OS Lock status between guest/host. Add OSLSR_EL1 to the cpu context and handle guest reads using the stored value.
--- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/sys_regs.c | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-)
arch/arm64/include/asm/kvm_host.h +1 -0
@@ -172,6 +172,7 @@ enum vcpu_sysreg {MDSCR_EL1 ,/* Monitor Debug System Control Register */ MDCCINT_EL1 ,/* Monitor Debug Comms Channel Interrupt Enable Reg */ DISR_EL1 ,/* Deferred Interrupt Status Register */ +OSLSR_EL1 ,/* OS Lock Status Register */ /* Performance Monitors Registers */ PMCR_EL0, /* Control Register */
arch/arm64/kvm/sys_regs.c +6 -7
@@ -291,12 +291,11 @@ static bool trap_oslsr_el1(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r) { -if (p->is_write) { +if (p->is_write)return ignore_write (vcpu, p); - }else { - p->regval = (1 <<3 ); -return true; - } + + p->regval =vcpu_read_sys_reg (vcpu, r->reg); +return true; } static bool trap_dbgauthstatus_el1(struct kvm_vcpu *vcpu,
@@ -1441,7 +1440,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { { SYS_DESC(SYS_MDRAR_EL1), trap_raz_wi }, { SYS_DESC(SYS_OSLAR_EL1), trap_raz_wi }, - { SYS_DESC(SYS_OSLSR_EL1), trap_oslsr_el1 }, + { SYS_DESC(SYS_OSLSR_EL1), trap_oslsr_el1, reset_val, OSLSR_EL1, 0x00000008 }, { SYS_DESC(SYS_OSDLR_EL1), trap_raz_wi }, { SYS_DESC(SYS_DBGPRCR_EL1), trap_raz_wi }, { SYS_DESC(SYS_DBGCLAIMSET_EL1), trap_raz_wi },
@@ -1916,7 +1915,7 @@ static const struct sys_reg_desc cp14_regs[] = { { Op1( 0), CRn( 1), CRm( 0), Op2( 4), trap_raz_wi },DBGBXVR (1 ),/* DBGOSLSR */ - { Op1( 0), CRn( 1), CRm( 1), Op2( 4), trap_oslsr_el1 }, + { Op1( 0), CRn( 1), CRm( 1), Op2( 4), trap_oslsr_el1, NULL, OSLSR_EL1 },DBGBXVR (2 ),DBGBXVR (3 ), /* DBGOSDLR */
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Marc Zyngier
maintainerRe: [PATCH 1/3] KVM: arm64: Stash OSLSR_EL1 in the cpu context
Quoted 16 lines · Oliver Upton
An upcoming change to KVM will context switch the OS Lock status between guest/host. Add
OSLSR_EL1to the cpu context and handle guest reads using the stored value.Signed-off-by Oliver Upton <[email protected]>--- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/sys_regs.c | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-)arch/arm64/include/asm/kvm_host.h +0
-0
arch/arm64/include/asm/kvm_host.h enum vcpu_sysreg { · line 175
Quoted 4 lines
arch/arm64/include/asm/kvm_host.h +1
-0@@ -172,6 +172,7 @@ enum vcpu_sysreg {MDSCR_EL1 ,/* Monitor Debug System Control Register */ MDCCINT_EL1 ,/* Monitor Debug Comms Channel Interrupt Enable Reg */ DISR_EL1 ,/* Deferred Interrupt Status Register */ + OSLSR_EL1, /* OS Lock Status Register */
Please move it one line up, next to the rest of the debug stuff (DISR_EL1 is RAS and not debug).
Quoted 8 lines
arch/arm64/include/asm/kvm_host.h +0
-0/* Performance Monitors Registers */ PMCR_EL0, /* Control Register */arch/arm64/kvm/sys_regs.c +0
-0
arch/arm64/kvm/sys_regs.c static bool trap_oslsr_el1(struct kvm_vcpu *vcpu, · line 295
Quoted 6 lines
arch/arm64/kvm/sys_regs.c +1
-1@@ -291,12 +291,11 @@ static bool trap_oslsr_el1(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r) { -if (p->is_write) { +if (p->is_write)return ignore_write (vcpu, p);
This should be UNDEF (though the HW should catch that, really).
Quoted 20 lines
arch/arm64/kvm/sys_regs.c +4
-5- }else { - p->regval = (1 <<3 ); -return true; - } + + p->regval =vcpu_read_sys_reg (vcpu, r->reg); +return true; } static bool trap_dbgauthstatus_el1(struct kvm_vcpu *vcpu,@@ -1441,7 +1440,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { { SYS_DESC(SYS_MDRAR_EL1), trap_raz_wi }, { SYS_DESC(SYS_OSLAR_EL1), trap_raz_wi }, - { SYS_DESC(SYS_OSLSR_EL1), trap_oslsr_el1 }, + { SYS_DESC(SYS_OSLSR_EL1), trap_oslsr_el1, reset_val, OSLSR_EL1, 0x00000008 }, { SYS_DESC(SYS_OSDLR_EL1), trap_raz_wi }, { SYS_DESC(SYS_DBGPRCR_EL1), trap_raz_wi }, { SYS_DESC(SYS_DBGCLAIMSET_EL1), trap_raz_wi },
arch/arm64/kvm/sys_regs.c static const struct sys_reg_desc cp14_regs[] = { · line 1921
Quoted 8 lines
arch/arm64/kvm/sys_regs.c +1
-1@@ -1916,7 +1915,7 @@ static const struct sys_reg_desc cp14_regs[] = { { Op1( 0), CRn( 1), CRm( 0), Op2( 4), trap_raz_wi },DBGBXVR (1 ),/* DBGOSLSR */ - { Op1( 0), CRn( 1), CRm( 1), Op2( 4), trap_oslsr_el1 }, + { Op1( 0), CRn( 1), CRm( 1), Op2( 4), trap_oslsr_el1, NULL, OSLSR_EL1 },DBGBXVR (2 ),DBGBXVR (3 ), /* DBGOSDLR */
Please update tools/testing/selftests/kvm/aarch64/get-reg-list.c before Andrew catches you red-handed! :D
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
PATCH 2/3 KVM: arm64: Allow the guest to change the OS Lock status
In reply to Oliver UptonKVM diverges from the architecture in the way it handles the OSLAR_EL1 register. While the architecture requires that the register be WO and that the OSLK bit is 1 out of reset, KVM implements the register as RAZ/WI.
Align KVM with the architecture by permitting writes to OSLAR_EL1. Since the register is WO, stash the OS Lock status bit in OSLSR_EL1 and context switch the status between host/guest. Additionally, change the reset value of the OSLK bit to 1.
--- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 5 +++++ arch/arm64/kvm/sys_regs.c | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-)
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +5 -0
@@ -65,6 +65,8 @@ static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt)ctxt_sys_reg (ctxt,SP_EL1 ) =read_sysreg (sp_el1);ctxt_sys_reg (ctxt,ELR_EL1 ) =read_sysreg_el1 (SYS_ELR );ctxt_sys_reg (ctxt,SPSR_EL1 ) =read_sysreg_el1 (SYS_SPSR ); + +ctxt_sys_reg (ctxt,OSLSR_EL1 ) =read_sysreg (oslsr_el1); }static inline void __sysreg_save_el2_return_state (struct kvm_cpu_context *ctxt)
@@ -149,6 +151,9 @@ static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)write_sysreg (ctxt_sys_reg (ctxt,SP_EL1 ), sp_el1);write_sysreg_el1 (ctxt_sys_reg (ctxt,ELR_EL1 ),SYS_ELR );write_sysreg_el1 (ctxt_sys_reg (ctxt,SPSR_EL1 ),SYS_SPSR ); + +/* restore OSLSR_EL1 by writing the OSLK bit to OSLAR_EL1 */ +write_sysreg ((ctxt_sys_reg (ctxt,OSLSR_EL1 ) >>1 ) &1 , oslar_el1); }static inline void __sysreg_restore_el2_return_state (struct kvm_cpu_context *ctxt)
arch/arm64/kvm/sys_regs.c +19 -3
@@ -298,6 +298,22 @@ static bool trap_oslsr_el1(struct kvm_vcpu *vcpu,return true; } +static bool trap_oslar_el1 (struct kvm_vcpu *vcpu, +struct sys_reg_params *p, +const struct sys_reg_desc *r) +{ +u64 oslsr; + +if (!p->is_write) +return read_zero (vcpu, p); + +/* preserve all but the OSLK bit */ + oslsr =vcpu_read_sys_reg (vcpu,OSLSR_EL1 ) & ~0x2ull ; +vcpu_write_sys_reg (vcpu,OSLSR_EL1 , oslsr | ((p->regval &1 ) <<1 )); +return true; +} + +static bool trap_dbgauthstatus_el1 (struct kvm_vcpu *vcpu,struct sys_reg_params *p,const struct sys_reg_desc *r)
@@ -1439,8 +1455,8 @@ static const struct sys_reg_desc sys_reg_descs[] = {DBG_BCR_BVR_WCR_WVR_EL1 (15 ), { SYS_DESC(SYS_MDRAR_EL1), trap_raz_wi }, - { SYS_DESC(SYS_OSLAR_EL1), trap_raz_wi }, - { SYS_DESC(SYS_OSLSR_EL1), trap_oslsr_el1, reset_val, OSLSR_EL1, 0x00000008 }, + { SYS_DESC(SYS_OSLAR_EL1), trap_oslar_el1 }, + { SYS_DESC(SYS_OSLSR_EL1), trap_oslsr_el1, reset_val, OSLSR_EL1, 0x0000000A }, { SYS_DESC(SYS_OSDLR_EL1), trap_raz_wi }, { SYS_DESC(SYS_DBGPRCR_EL1), trap_raz_wi }, { SYS_DESC(SYS_DBGCLAIMSET_EL1), trap_raz_wi },
@@ -1912,7 +1928,7 @@ static const struct sys_reg_desc cp14_regs[] = {DBGBXVR (0 ),/* DBGOSLAR */ - { Op1( 0), CRn( 1), CRm( 0), Op2( 4), trap_raz_wi }, + { Op1( 0), CRn( 1), CRm( 0), Op2( 4), trap_oslar_el1 },DBGBXVR (1 ),/* DBGOSLSR */ { Op1( 0), CRn( 1), CRm( 1), Op2( 4), trap_oslsr_el1, NULL, OSLSR_EL1 },
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Marc Zyngier
maintainerRe: [PATCH 2/3] KVM: arm64: Allow the guest to change the OS Lock status
Hi Oliver,
Quoted 23 lines · Oliver Upton
KVM diverges from the architecture in the way it handles the
OSLAR_EL1register. While the architecture requires that the register be WO and that the OSLK bit is 1 out of reset, KVM implements the register as RAZ/WI.Align KVM with the architecture by permitting writes to
OSLAR_EL1. Since the register is WO, stash the OS Lock status bit inOSLSR_EL1and context switch the status between host/guest. Additionally, change the reset value of the OSLK bit to 1.Suggested-by Marc Zyngier <[email protected]>Signed-off-by Oliver Upton <[email protected]>--- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 5 +++++ arch/arm64/kvm/sys_regs.c | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-)arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +0
-0
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt) · line 69
Quoted 5 lines
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +2
-0@@ -65,6 +65,8 @@ static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt)ctxt_sys_reg (ctxt,SP_EL1 ) =read_sysreg (sp_el1);ctxt_sys_reg (ctxt,ELR_EL1 ) =read_sysreg_el1 (SYS_ELR );ctxt_sys_reg (ctxt,SPSR_EL1 ) =read_sysreg_el1 (SYS_SPSR ); + +ctxt_sys_reg (ctxt,OSLSR_EL1 ) =read_sysreg (oslsr_el1);
Why do we need to save/restore this outside of the debug context? It seems to me that this is only needed if debug has been enabled by the guest (KVM_ARM64_DEBUG_DIRTY being set), as we will have trapped the OSLAR_EL1 access otherwise. I don't think we need to deal with this register outside of this context, as debug exceptions cannot happen otherwise (BRK excepted, of course).
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt) · line 156
Quoted 10 lines
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +3
-0}static inline void __sysreg_save_el2_return_state (struct kvm_cpu_context *ctxt)@@ -149,6 +151,9 @@ static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)write_sysreg (ctxt_sys_reg (ctxt,SP_EL1 ), sp_el1);write_sysreg_el1 (ctxt_sys_reg (ctxt,ELR_EL1 ),SYS_ELR );write_sysreg_el1 (ctxt_sys_reg (ctxt,SPSR_EL1 ),SYS_SPSR ); + +/* restore OSLSR_EL1 by writing the OSLK bit to OSLAR_EL1 */ +write_sysreg ((ctxt_sys_reg (ctxt,OSLSR_EL1 ) >>1 ) &1 , oslar_el1);
Please introduce some eye-pleasing bit definitions ("Here, there, and everywhere", to quote someone famous).
Quoted 9 lines
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +0
-0}static inline void __sysreg_restore_el2_return_state (struct kvm_cpu_context *ctxt)arch/arm64/kvm/sys_regs.c +0
-0@@ -298,6 +298,22 @@ static bool trap_oslsr_el1(struct kvm_vcpu *vcpu,return true;
arch/arm64/kvm/sys_regs.c static bool trap_oslsr_el1(struct kvm_vcpu *vcpu, · line 308
Quoted 10 lines
arch/arm64/kvm/sys_regs.c +8
-0} +static bool trap_oslar_el1 (struct kvm_vcpu *vcpu, +struct sys_reg_params *p, +const struct sys_reg_desc *r) +{ +u64 oslsr; + +if (!p->is_write) +return read_zero (vcpu, p);
This really should be an UNDEF (and it really should UNDEF in HW, but we are being, maybe pointlessly, cautious).
arch/arm64/kvm/sys_regs.c static bool trap_oslsr_el1(struct kvm_vcpu *vcpu, · line 316
Quoted 8 lines
arch/arm64/kvm/sys_regs.c +8
-0+ +/* preserve all but the OSLK bit */ + oslsr =vcpu_read_sys_reg (vcpu,OSLSR_EL1 ) & ~0x2ull ; +vcpu_write_sys_reg (vcpu,OSLSR_EL1 , oslsr | ((p->regval &1 ) <<1 )); +return true; +} + +
Extra newline.
Quoted 15 lines
arch/arm64/kvm/sys_regs.c +2
-2static bool trap_dbgauthstatus_el1 (struct kvm_vcpu *vcpu,struct sys_reg_params *p,const struct sys_reg_desc *r)@@ -1439,8 +1455,8 @@ static const struct sys_reg_desc sys_reg_descs[] = {DBG_BCR_BVR_WCR_WVR_EL1 (15 ), { SYS_DESC(SYS_MDRAR_EL1), trap_raz_wi }, - { SYS_DESC(SYS_OSLAR_EL1), trap_raz_wi }, - { SYS_DESC(SYS_OSLSR_EL1), trap_oslsr_el1, reset_val, OSLSR_EL1, 0x00000008 }, + { SYS_DESC(SYS_OSLAR_EL1), trap_oslar_el1 }, + { SYS_DESC(SYS_OSLSR_EL1), trap_oslsr_el1, reset_val, OSLSR_EL1, 0x0000000A }, { SYS_DESC(SYS_OSDLR_EL1), trap_raz_wi }, { SYS_DESC(SYS_DBGPRCR_EL1), trap_raz_wi }, { SYS_DESC(SYS_DBGCLAIMSET_EL1), trap_raz_wi },
arch/arm64/kvm/sys_regs.c static const struct sys_reg_desc cp14_regs[] = { · line 1934
Quoted 8 lines
arch/arm64/kvm/sys_regs.c +1
-1@@ -1912,7 +1928,7 @@ static const struct sys_reg_desc cp14_regs[] = {DBGBXVR (0 ),/* DBGOSLAR */ - { Op1( 0), CRn( 1), CRm( 0), Op2( 4), trap_raz_wi }, + { Op1( 0), CRn( 1), CRm( 0), Op2( 4), trap_oslar_el1 },DBGBXVR (1 ),/* DBGOSLSR */ { Op1( 0), CRn( 1), CRm( 1), Op2( 4), trap_oslsr_el1, NULL, OSLSR_EL1 },
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
PATCH 3/3 KVM: arm64: Raise KVM's reported debug architecture to v8.2
In reply to Oliver UptonThe additions made to the Debug architecture between v8.0 and v8.2 are only applicable to external debug. KVM does not (and likely will never) support external debug, so KVM can proudly report support for v8.2 to its guests.
Raise the reported Debug architecture to v8.2. Additionally, v8.2 makes FEAT_DoubleLock optional. Even though KVM never supported it in the first place, report DoubleLock as not implemented now as the architecture permits it for v8.2.
--- arch/arm64/kvm/sys_regs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm64/kvm/sys_regs.c +7 -2
@@ -1109,9 +1109,14 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, ARM64_FEATURE_MASK(ID_AA64ISAR1_GPI));break ;case SYS_ID_AA64DFR0_EL1 : -/* Limit debug to ARMv8.0 */ +/* Limit debug to ARMv8.2 */ val &= ~ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ); - val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ),6 ); + val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ),8 ); + +/* Hide DoubleLock from guests */ + val &= ~ARM64_FEATURE_MASK (ID_AA64DFR0_DOUBLELOCK ); + val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DOUBLELOCK ),0xf ); +/* Limit guests to PMUv3 for ARMv8.4 */ val = cpuid_feature_cap_perfmon_field(val, ID_AA64DFR0_PMUVER_SHIFT,
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Marc Zyngier
maintainerRe: [PATCH 3/3] KVM: arm64: Raise KVM's reported debug architecture to v8.2
Quoted 27 lines · Oliver Upton
The additions made to the Debug architecture between v8.0 and v8.2 are only applicable to external debug. KVM does not (and likely will never) support external debug, so KVM can proudly report support for v8.2 to its guests.
Raise the reported Debug architecture to v8.2. Additionally, v8.2 makes
FEAT_DoubleLockoptional. Even though KVM never supported it in the first place, report DoubleLock as not implemented now as the architecture permits it for v8.2.Cc Reiji Watanabe <[email protected]>Cc Ricardo Koller <[email protected]>Suggested-by Marc Zyngier <[email protected]>Signed-off-by Oliver Upton <[email protected]>--- arch/arm64/kvm/sys_regs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)arch/arm64/kvm/sys_regs.c +0
-0@@ -1109,9 +1109,14 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, ARM64_FEATURE_MASK(ID_AA64ISAR1_GPI));break ;case SYS_ID_AA64DFR0_EL1 :
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1119
Quoted 10 lines
arch/arm64/kvm/sys_regs.c +7
-2-/* Limit debug to ARMv8.0 */ +/* Limit debug to ARMv8.2 */ val &= ~ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ); - val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ),6 ); + val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ),8 ); + +/* Hide DoubleLock from guests */ + val &= ~ARM64_FEATURE_MASK (ID_AA64DFR0_DOUBLELOCK ); + val |= FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64DFR0_DOUBLELOCK), 0CF); +
One issue with that is that this will break migration from an older kernel (DFR0 will be different between source and destination).
You'll need a set_user handler and deal with it in a similar way to CSV2/CSV3.
Thanks,
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 3/3] KVM: arm64: Raise KVM's reported debug architecture to v8.2
Hey Marc,
Quoted 3 lines · Marc Zyngier
On Fri, 29 Oct 2021 01:32:02 +0100,
Oliver Upton <[email protected]> wrote:
[...]
Quoted 15 lines
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1119
Quoted 11 lines
case SYS_ID_AA64DFR0_EL1:arch/arm64/kvm/sys_regs.c +7
-2-/* Limit debug to ARMv8.0 */ +/* Limit debug to ARMv8.2 */ val &= ~ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ); - val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ),6 ); + val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ),8 ); + +/* Hide DoubleLock from guests */ + val &= ~ARM64_FEATURE_MASK (ID_AA64DFR0_DOUBLELOCK ); + val |= FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64DFR0_DOUBLELOCK), 0CF); +One issue with that is that this will break migration from an older kernel (DFR0 will be different between source and destination).
Quoted 2 lines
You'll need a
set_userhandler and deal with it in a similar way to CSV2/CSV3.
Yeah, definitely so. In that case, unless we're strongly motivated to expose these changes soon, I'll just punt the ID register changes until Reiji's series [1] lands, as anything I add for a writable DFR0 will invariably be scrapped in favor of his work.
I'll post v2 of this series folding in your feedback (thx for quick review, btw), less this patch.
[1] https://patchwork.kernel.org/project/kvm/cover/[email protected]/
--
Thanks,
Oliver
Marc Zyngier
maintainerRe: [PATCH 3/3] KVM: arm64: Raise KVM's reported debug architecture to v8.2
Quoted 23 lines · Oliver Upton
Hey Marc,
Quoted 3 lines · Marc Zyngier
On Fri, 29 Oct 2021 01:32:02 +0100,
Oliver Upton <[email protected]> wrote:[...]
Quoted 15 lines
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1119
Quoted 11 lines
case SYS_ID_AA64DFR0_EL1:arch/arm64/kvm/sys_regs.c +7
-2-/* Limit debug to ARMv8.0 */ +/* Limit debug to ARMv8.2 */ val &= ~ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ); - val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ),6 ); + val |=FIELD_PREP (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ),8 ); + +/* Hide DoubleLock from guests */ + val &= ~ARM64_FEATURE_MASK (ID_AA64DFR0_DOUBLELOCK ); + val |= FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64DFR0_DOUBLELOCK), 0CF); +One issue with that is that this will break migration from an older kernel (DFR0 will be different between source and destination).
Quoted 7 lines
Quoted 2 lines
You'll need a
set_userhandler and deal with it in a similar way to CSV2/CSV3.Yeah, definitely so. In that case, unless we're strongly motivated to expose these changes soon, I'll just punt the ID register changes until Reiji's series [1] lands, as anything I add for a writable DFR0 will invariably be scrapped in favor of his work.
Yeah, I think that's a sensible thing to do. I need to find the bandwidth to look into these patches...
Quoted 2 lines
I'll post v2 of this series folding in your feedback (thx for quick review, btw), less this patch.
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.