From: Marc Zyngier <maz@kernel.org>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: kvmarm@lists.linux.dev, James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Jing Zhang <jingzhangos@google.com>,
Reiji Watanabe <reijiw@google.com>
Subject: Re: [PATCH] KVM: arm64: Reject attempts to set invalid debug arch version
Date: Mon, 26 Jun 2023 10:23:24 +0100 [thread overview]
Message-ID: <86jzvqbmr7.wl-maz@kernel.org> (raw)
In-Reply-To: <20230623205232.2837077-1-oliver.upton@linux.dev>
On Fri, 23 Jun 2023 21:52:32 +0100,
Oliver Upton <oliver.upton@linux.dev> wrote:
>
> The debug architecture is mandatory in ARMv8, so KVM should not allow
> userspace to configure a vCPU with less than that. Of course, this isn't
> handled elegantly by the generic ID register plumbing, as the respective
> ID register fields have a nonzero starting value.
>
> Add an explicit check for debug versions less than v8 of the
> architecture.
>
> Fixes: c118cead07a7 ("KVM: arm64: Use generic sanitisation for ID_(AA64)DFR0_EL1")
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> ---
> arch/arm64/kvm/sys_regs.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 1a13bab1a06c..5b25053a8e04 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -1482,6 +1482,7 @@ static int set_id_aa64dfr0_el1(struct kvm_vcpu *vcpu,
> const struct sys_reg_desc *rd,
> u64 val)
> {
> + u8 debugver = SYS_FIELD_GET(ID_AA64DFR0_EL1, DebugVer, val);
> u8 pmuver = SYS_FIELD_GET(ID_AA64DFR0_EL1, PMUVer, val);
>
> /*
> @@ -1501,6 +1502,13 @@ static int set_id_aa64dfr0_el1(struct kvm_vcpu *vcpu,
> if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF)
> val &= ~ID_AA64DFR0_EL1_PMUVer_MASK;
>
> + /*
> + * ID_AA64DFR0_EL1.DebugVer is one of those awkward fields with a
> + * nonzero minimum safe value.
> + */
> + if (debugver < ID_AA64DFR0_EL1_DebugVer_IMP)
> + return -EINVAL;
> +
Why isn't that caught by the check at the end of arm64_check_features
which says that for RO fields, the only safe value is the sanitised
version?
Am I missing something obvious (full disclosure, I've had a single
coffee at this time of the day...)?
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2023-06-26 9:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 20:52 [PATCH] KVM: arm64: Reject attempts to set invalid debug arch version Oliver Upton
2023-06-26 9:23 ` Marc Zyngier [this message]
2023-06-26 16:25 ` Oliver Upton
2023-06-29 1:12 ` Jitindar Singh, Suraj
2023-06-29 2:58 ` Oliver Upton
2023-06-29 20:52 ` Jitindar Singh, Suraj
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86jzvqbmr7.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=james.morse@arm.com \
--cc=jingzhangos@google.com \
--cc=kvmarm@lists.linux.dev \
--cc=oliver.upton@linux.dev \
--cc=reijiw@google.com \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox