Skip to content

Commit 980c41f

Browse files
shamiali2008Marc Zyngier
authored andcommitted
KVM: arm64: Make the exposed feature bits in AA64DFR0_EL1 writable from userspace
KVM exposes the OS double lock feature bit to Guests but returns RAZ/WI on Guest OSDLR_EL1 access. This breaks Guest migration between systems where this feature differ. Add support to make this feature writable from userspace by setting the mask bit. While at it, set the mask bits for the exposed WRPs(Number of Watchpoints) as well. Also update the selftest to cover these fields. However we still can't make BRPs and CTX_CMPs fields writable, because as per ARM ARM DDI 0487K.a, section D2.8.3 Breakpoint types and linking of breakpoints, highest numbered breakpoints(BRPs) must be context aware breakpoints(CTX_CMPs). KVM does not trap + emulate the breakpoint registers, and as such cannot support a layout that misaligns with the underlying hardware. Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Shameer Kolothum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 7c626ce commit 980c41f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,21 @@ static const struct sys_reg_desc sys_reg_descs[] = {
23762376
.get_user = get_id_reg,
23772377
.set_user = set_id_aa64dfr0_el1,
23782378
.reset = read_sanitised_id_aa64dfr0_el1,
2379-
.val = ID_AA64DFR0_EL1_PMUVer_MASK |
2379+
/*
2380+
* Prior to FEAT_Debugv8.9, the architecture defines context-aware
2381+
* breakpoints (CTX_CMPs) as the highest numbered breakpoints (BRPs).
2382+
* KVM does not trap + emulate the breakpoint registers, and as such
2383+
* cannot support a layout that misaligns with the underlying hardware.
2384+
* While it may be possible to describe a subset that aligns with
2385+
* hardware, just prevent changes to BRPs and CTX_CMPs altogether for
2386+
* simplicity.
2387+
*
2388+
* See DDI0487K.a, section D2.8.3 Breakpoint types and linking
2389+
* of breakpoints for more details.
2390+
*/
2391+
.val = ID_AA64DFR0_EL1_DoubleLock_MASK |
2392+
ID_AA64DFR0_EL1_WRPs_MASK |
2393+
ID_AA64DFR0_EL1_PMUVer_MASK |
23802394
ID_AA64DFR0_EL1_DebugVer_MASK, },
23812395
ID_SANITISED(ID_AA64DFR1_EL1),
23822396
ID_UNALLOCATED(5,2),

tools/testing/selftests/kvm/aarch64/set_id_regs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ struct test_feature_reg {
6868
}
6969

7070
static const struct reg_ftr_bits ftr_id_aa64dfr0_el1[] = {
71+
S_REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64DFR0_EL1, DoubleLock, 0),
72+
REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64DFR0_EL1, WRPs, 0),
7173
S_REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64DFR0_EL1, PMUVer, 0),
7274
REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64DFR0_EL1, DebugVer, ID_AA64DFR0_EL1_DebugVer_IMP),
7375
REG_FTR_END,

0 commit comments

Comments
 (0)