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>,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH] KVM: arm64: Fix misuse of KVM_ARM_VCPU_POWER_OFF bit index
Date: Thu, 22 Jun 2023 17:14:04 +0100 [thread overview]
Message-ID: <d22e2bfaa5056f8789140169e2701b97@kernel.org> (raw)
In-Reply-To: <20230622160922.1925530-1-oliver.upton@linux.dev>
On 2023-06-22 17:09, Oliver Upton wrote:
> KVM_ARM_VCPU_POWER_OFF is as bit index, _not_ a literal bitmask.
> Nonetheless, commit e3c1c0cae31e ("KVM: arm64: Relax invariance
> of KVM_ARM_VCPU_POWER_OFF") started using it that way, meaning that
> powering off a vCPU with the KVM_ARM_VCPU_INIT ioctl is completely
> broken.
>
> Fix it by using a shifted bit for the bitwise operations instead.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Fixes: e3c1c0cae31e ("KVM: arm64: Relax invariance of
> KVM_ARM_VCPU_POWER_OFF")
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> ---
> arch/arm64/kvm/arm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 80ca7ec269dc..7d20bfd77e1c 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -1250,8 +1250,8 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct
> kvm_vcpu *vcpu,
> * reflecting it in the finalized feature set, thus limiting its
> scope
> * to a single KVM_ARM_VCPU_INIT call.
> */
> - if (init->features[0] & KVM_ARM_VCPU_POWER_OFF) {
> - init->features[0] &= ~KVM_ARM_VCPU_POWER_OFF;
> + if (init->features[0] & (1UL << KVM_ARM_VCPU_POWER_OFF)) {
> + init->features[0] &= ~(1UL << KVM_ARM_VCPU_POWER_OFF);
> power_off = true;
> }
Huhuh. Maybe use BIT() instead? Otherwise:
Acked-by: Marc Zyngier <maz@kernel.org>
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2023-06-22 16:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 16:09 [PATCH] KVM: arm64: Fix misuse of KVM_ARM_VCPU_POWER_OFF bit index Oliver Upton
2023-06-22 16:14 ` Marc Zyngier [this message]
2023-06-22 17:17 ` Oliver Upton
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=d22e2bfaa5056f8789140169e2701b97@kernel.org \
--to=maz@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=oliver.upton@linux.dev \
--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