From: Marc Zyngier <maz@kernel.org>
To: Yejune Deng <yejune.deng@gmail.com>
Cc: catalin.marinas@arm.com, linux-kernel@vger.kernel.org,
will@kernel.org, kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] KVM: arm64: Fix the return value of smp_call_function_single()
Date: Mon, 18 Jan 2021 11:18:20 +0000 [thread overview]
Message-ID: <af2ea1ad8df12907fa24eb4bf44c6e99@kernel.org> (raw)
In-Reply-To: <20210118093137.3383-1-yejune.deng@gmail.com>
On 2021-01-18 09:31, Yejune Deng wrote:
> In smp_call_function_single(), the 3rd parameter isn't the return value
> and it's always positive. But it may return a negative value. So the
> 'ret' is should be the return value of the smp_call_function_single().
>
> In check_kvm_target_cpu(), 'phys_target' is more readable than 'ret'.
>
> Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> ---
> arch/arm64/kvm/arm.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 04c44853b103..5fa5c04106de 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -1815,9 +1815,9 @@ static int init_hyp_mode(void)
> return err;
> }
>
> -static void check_kvm_target_cpu(void *ret)
> +static void check_kvm_target_cpu(void *phys_target)
> {
> - *(int *)ret = kvm_target_cpu();
> + *(int *)phys_target = kvm_target_cpu();
> }
>
> struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long
> mpidr)
> @@ -1879,7 +1879,7 @@ void kvm_arch_irq_bypass_start(struct
> irq_bypass_consumer *cons)
> int kvm_arch_init(void *opaque)
> {
> int err;
> - int ret, cpu;
> + int ret, cpu, phys_target;
> bool in_hyp_mode;
>
> if (!is_hyp_mode_available()) {
> @@ -1900,7 +1900,7 @@ int kvm_arch_init(void *opaque)
> "Only trusted guests should be used on this system.\n");
>
> for_each_online_cpu(cpu) {
> - smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
> + ret = smp_call_function_single(cpu, check_kvm_target_cpu,
> &phys_target, 1);
> if (ret < 0) {
> kvm_err("Error, CPU %d not supported!\n", cpu);
> return -ENODEV;
That's not the purpose of this code. We check the target CPU
for so that we can decide to *fail* the KVM init if there is
a CPU we do not support (we definitely used to do that with
32bit), and the error message clearly states this.
So if you want to handle a cross-call failure, please do that.
But don't change the existing semantics of this code.
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Yejune Deng <yejune.deng@gmail.com>
Cc: suzuki.poulose@arm.com, catalin.marinas@arm.com,
linux-kernel@vger.kernel.org, james.morse@arm.com,
julien.thierry.kdev@gmail.com, will@kernel.org,
kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] KVM: arm64: Fix the return value of smp_call_function_single()
Date: Mon, 18 Jan 2021 11:18:20 +0000 [thread overview]
Message-ID: <af2ea1ad8df12907fa24eb4bf44c6e99@kernel.org> (raw)
In-Reply-To: <20210118093137.3383-1-yejune.deng@gmail.com>
On 2021-01-18 09:31, Yejune Deng wrote:
> In smp_call_function_single(), the 3rd parameter isn't the return value
> and it's always positive. But it may return a negative value. So the
> 'ret' is should be the return value of the smp_call_function_single().
>
> In check_kvm_target_cpu(), 'phys_target' is more readable than 'ret'.
>
> Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> ---
> arch/arm64/kvm/arm.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 04c44853b103..5fa5c04106de 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -1815,9 +1815,9 @@ static int init_hyp_mode(void)
> return err;
> }
>
> -static void check_kvm_target_cpu(void *ret)
> +static void check_kvm_target_cpu(void *phys_target)
> {
> - *(int *)ret = kvm_target_cpu();
> + *(int *)phys_target = kvm_target_cpu();
> }
>
> struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long
> mpidr)
> @@ -1879,7 +1879,7 @@ void kvm_arch_irq_bypass_start(struct
> irq_bypass_consumer *cons)
> int kvm_arch_init(void *opaque)
> {
> int err;
> - int ret, cpu;
> + int ret, cpu, phys_target;
> bool in_hyp_mode;
>
> if (!is_hyp_mode_available()) {
> @@ -1900,7 +1900,7 @@ int kvm_arch_init(void *opaque)
> "Only trusted guests should be used on this system.\n");
>
> for_each_online_cpu(cpu) {
> - smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
> + ret = smp_call_function_single(cpu, check_kvm_target_cpu,
> &phys_target, 1);
> if (ret < 0) {
> kvm_err("Error, CPU %d not supported!\n", cpu);
> return -ENODEV;
That's not the purpose of this code. We check the target CPU
for so that we can decide to *fail* the KVM init if there is
a CPU we do not support (we definitely used to do that with
32bit), and the error message clearly states this.
So if you want to handle a cross-call failure, please do that.
But don't change the existing semantics of this code.
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Yejune Deng <yejune.deng@gmail.com>
Cc: james.morse@arm.com, julien.thierry.kdev@gmail.com,
suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org,
linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: Fix the return value of smp_call_function_single()
Date: Mon, 18 Jan 2021 11:18:20 +0000 [thread overview]
Message-ID: <af2ea1ad8df12907fa24eb4bf44c6e99@kernel.org> (raw)
In-Reply-To: <20210118093137.3383-1-yejune.deng@gmail.com>
On 2021-01-18 09:31, Yejune Deng wrote:
> In smp_call_function_single(), the 3rd parameter isn't the return value
> and it's always positive. But it may return a negative value. So the
> 'ret' is should be the return value of the smp_call_function_single().
>
> In check_kvm_target_cpu(), 'phys_target' is more readable than 'ret'.
>
> Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> ---
> arch/arm64/kvm/arm.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 04c44853b103..5fa5c04106de 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -1815,9 +1815,9 @@ static int init_hyp_mode(void)
> return err;
> }
>
> -static void check_kvm_target_cpu(void *ret)
> +static void check_kvm_target_cpu(void *phys_target)
> {
> - *(int *)ret = kvm_target_cpu();
> + *(int *)phys_target = kvm_target_cpu();
> }
>
> struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long
> mpidr)
> @@ -1879,7 +1879,7 @@ void kvm_arch_irq_bypass_start(struct
> irq_bypass_consumer *cons)
> int kvm_arch_init(void *opaque)
> {
> int err;
> - int ret, cpu;
> + int ret, cpu, phys_target;
> bool in_hyp_mode;
>
> if (!is_hyp_mode_available()) {
> @@ -1900,7 +1900,7 @@ int kvm_arch_init(void *opaque)
> "Only trusted guests should be used on this system.\n");
>
> for_each_online_cpu(cpu) {
> - smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
> + ret = smp_call_function_single(cpu, check_kvm_target_cpu,
> &phys_target, 1);
> if (ret < 0) {
> kvm_err("Error, CPU %d not supported!\n", cpu);
> return -ENODEV;
That's not the purpose of this code. We check the target CPU
for so that we can decide to *fail* the KVM init if there is
a CPU we do not support (we definitely used to do that with
32bit), and the error message clearly states this.
So if you want to handle a cross-call failure, please do that.
But don't change the existing semantics of this code.
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2021-01-18 11:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 9:31 [PATCH] KVM: arm64: Fix the return value of smp_call_function_single() Yejune Deng
2021-01-18 9:31 ` Yejune Deng
2021-01-18 9:31 ` Yejune Deng
2021-01-18 11:18 ` Marc Zyngier [this message]
2021-01-18 11:18 ` Marc Zyngier
2021-01-18 11:18 ` Marc Zyngier
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=af2ea1ad8df12907fa24eb4bf44c6e99@kernel.org \
--to=maz@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=will@kernel.org \
--cc=yejune.deng@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.