* [PATCH] KVM: arm64: Fix the return value of smp_call_function_single()
@ 2021-01-18 9:31 Yejune Deng
2021-01-18 11:18 ` Marc Zyngier
0 siblings, 1 reply; 2+ messages in thread
From: Yejune Deng @ 2021-01-18 9:31 UTC (permalink / raw)
To: maz, james.morse, julien.thierry.kdev, suzuki.poulose,
catalin.marinas, will
Cc: linux-arm-kernel, kvmarm, linux-kernel, yejune.deng
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;
--
2.29.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: arm64: Fix the return value of smp_call_function_single()
2021-01-18 9:31 [PATCH] KVM: arm64: Fix the return value of smp_call_function_single() Yejune Deng
@ 2021-01-18 11:18 ` Marc Zyngier
0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2021-01-18 11:18 UTC (permalink / raw)
To: Yejune Deng
Cc: james.morse, julien.thierry.kdev, suzuki.poulose,
catalin.marinas, will, linux-arm-kernel, kvmarm, linux-kernel
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...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-18 11:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 9:31 [PATCH] KVM: arm64: Fix the return value of smp_call_function_single() Yejune Deng
2021-01-18 11:18 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).