KVM: arm64: Advertise selected DebugVer in DBGDIDR.Version
authorOliver Upton <oliver.upton@linux.dev>
Wed, 4 Oct 2023 17:03:17 +0000 (17:03 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Wed, 4 Oct 2023 17:10:15 +0000 (17:10 +0000)
Much like we do for other fields, extract the Debug architecture version
from the ID register to populate the corresponding field in DBGDIDR.
Rewrite the existing sysreg field extractors to use SYS_FIELD_GET() for
consistency.

Suggested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/sys_regs.c

index b73f9ff0899b9291ad9bbf4ea37ab61d22e8ca21..34f578d110a98cc6f450ecf4df465e4ed6a6b2a5 100644 (file)
@@ -2447,12 +2447,13 @@ static bool trap_dbgdidr(struct kvm_vcpu *vcpu,
        } else {
                u64 dfr = IDREG(vcpu->kvm, SYS_ID_AA64DFR0_EL1);
                u64 pfr = IDREG(vcpu->kvm, SYS_ID_AA64PFR0_EL1);
-               u32 el3 = !!cpuid_feature_extract_unsigned_field(pfr, ID_AA64PFR0_EL1_EL3_SHIFT);
+               u32 el3 = !!SYS_FIELD_GET(ID_AA64PFR0_EL1, EL3, pfr);
 
-               p->regval = ((((dfr >> ID_AA64DFR0_EL1_WRPs_SHIFT) & 0xf) << 28) |
-                            (((dfr >> ID_AA64DFR0_EL1_BRPs_SHIFT) & 0xf) << 24) |
-                            (((dfr >> ID_AA64DFR0_EL1_CTX_CMPs_SHIFT) & 0xf) << 20)
-                            | (6 << 16) | (1 << 15) | (el3 << 14) | (el3 << 12));
+               p->regval = ((SYS_FIELD_GET(ID_AA64DFR0_EL1, WRPs, dfr) << 28) |
+                            (SYS_FIELD_GET(ID_AA64DFR0_EL1, BRPs, dfr) << 24) |
+                            (SYS_FIELD_GET(ID_AA64DFR0_EL1, CTX_CMPs, dfr) << 20) |
+                            (SYS_FIELD_GET(ID_AA64DFR0_EL1, DebugVer, dfr) << 16) |
+                            (1 << 15) | (el3 << 14) | (el3 << 12));
                return true;
        }
 }