Re: [PATCH 3/3] KVM: arm64: Raise KVM's reported debug architecture to v8.2

Marc Zyngier
2021-10-29T11:31:27Z

On Fri, 29 Oct 2021 01:32:02 +0100,
Oliver Upton <oupton@google.com> wrote:
>
> 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_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.
>
> Cc: Reiji Watanabe <reijiw@google.com>
> Cc: Ricardo Koller <ricarkol@google.com>
> Suggested-by: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Oliver Upton <oupton@google.com>
> ---
> arch/arm64/kvm/sys_regs.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 0840ae081290..f56ee5830d18 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -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), 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.

--
Without deviation from the norm, progress is not possible.