* [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv()
@ 2025-10-30 20:51 Markus Elfring
2025-10-30 21:41 ` David Laight
2025-11-03 5:20 ` Gautam Menghani
0 siblings, 2 replies; 4+ messages in thread
From: Markus Elfring @ 2025-10-30 20:51 UTC (permalink / raw)
To: linuxppc-dev, kvm, Alexander Graf, Christophe Leroy,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin
Cc: LKML, kernel-janitors, Miaoqian Lin
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 30 Oct 2025 21:43:20 +0100
Subject: [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv()
A pointer was assigned to a variable. The same pointer was used for
the destination parameter of a memcpy() call.
This function is documented in the way that the same value is returned.
Thus convert two separate statements into a direct variable assignment for
the return value from a memory copy action.
The source code was transformed by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/powerpc/kvm/powerpc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 2ba057171ebe..ae28447b3e04 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -216,8 +216,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
shared &= PAGE_MASK;
shared |= vcpu->arch.magic_page_pa & 0xf000;
- new_shared = (void*)shared;
- memcpy(new_shared, old_shared, 0x1000);
+ new_shared = memcpy(shared, old_shared, 0x1000);
vcpu->arch.shared = new_shared;
}
#endif
--
2.51.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv()
2025-10-30 20:51 [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv() Markus Elfring
@ 2025-10-30 21:41 ` David Laight
2025-11-03 5:20 ` Gautam Menghani
1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2025-10-30 21:41 UTC (permalink / raw)
To: Markus Elfring
Cc: linuxppc-dev, kvm, Alexander Graf, Christophe Leroy,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin, LKML,
kernel-janitors, Miaoqian Lin
On Thu, 30 Oct 2025 21:51:00 +0100
Markus Elfring <Markus.Elfring@web.de> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 30 Oct 2025 21:43:20 +0100
> Subject: [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv()
>
> A pointer was assigned to a variable. The same pointer was used for
> the destination parameter of a memcpy() call.
> This function is documented in the way that the same value is returned.
> Thus convert two separate statements into a direct variable assignment for
> the return value from a memory copy action.
>
> The source code was transformed by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/powerpc/kvm/powerpc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 2ba057171ebe..ae28447b3e04 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -216,8 +216,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
>
> shared &= PAGE_MASK;
> shared |= vcpu->arch.magic_page_pa & 0xf000;
> - new_shared = (void*)shared;
> - memcpy(new_shared, old_shared, 0x1000);
> + new_shared = memcpy(shared, old_shared, 0x1000);
Did you even try to compile this??
> vcpu->arch.shared = new_shared;
> }
> #endif
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv()
2025-10-30 20:51 [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv() Markus Elfring
2025-10-30 21:41 ` David Laight
@ 2025-11-03 5:20 ` Gautam Menghani
2025-11-03 7:11 ` Markus Elfring
1 sibling, 1 reply; 4+ messages in thread
From: Gautam Menghani @ 2025-11-03 5:20 UTC (permalink / raw)
To: Markus Elfring
Cc: linuxppc-dev, kvm, Alexander Graf, Christophe Leroy,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin, LKML,
kernel-janitors, Miaoqian Lin
On Thu, Oct 30, 2025 at 09:51:00PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 30 Oct 2025 21:43:20 +0100
> Subject: [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv()
>
> A pointer was assigned to a variable. The same pointer was used for
> the destination parameter of a memcpy() call.
> This function is documented in the way that the same value is returned.
> Thus convert two separate statements into a direct variable assignment for
> the return value from a memory copy action.
>
> The source code was transformed by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/powerpc/kvm/powerpc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 2ba057171ebe..ae28447b3e04 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -216,8 +216,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
>
> shared &= PAGE_MASK;
> shared |= vcpu->arch.magic_page_pa & 0xf000;
> - new_shared = (void*)shared;
> - memcpy(new_shared, old_shared, 0x1000);
> + new_shared = memcpy(shared, old_shared, 0x1000);
> vcpu->arch.shared = new_shared;
> }
> #endif
This patch does not compile
In file included from ./include/linux/string.h:382,
from ./arch/powerpc/include/asm/paca.h:16,
from ./arch/powerpc/include/asm/current.h:13,
from ./include/linux/sched.h:12,
from ./include/linux/resume_user_mode.h:6,
from ./include/linux/entry-virt.h:6,
from ./include/linux/kvm_host.h:5,
from arch/powerpc/kvm/powerpc.c:12:
arch/powerpc/kvm/powerpc.c: In function `kvmppc_kvm_pv´:
arch/powerpc/kvm/powerpc.c:219:45: error: passing argument 1 of `__builtin_dynamic_object_size´ makes pointer from integer without a cast [-Wint-conversion]
219 | new_shared = memcpy(shared, old_shared, 0x1000);
| ^~~~~~
| |
| ulong {aka long unsigned int}
Thanks,
Gautam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv()
2025-11-03 5:20 ` Gautam Menghani
@ 2025-11-03 7:11 ` Markus Elfring
0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-11-03 7:11 UTC (permalink / raw)
To: Gautam Menghani, linuxppc-dev, kvm
Cc: Alexander Graf, Christophe Leroy, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, LKML, kernel-janitors,
Miaoqian Lin
>> A pointer was assigned to a variable. The same pointer was used for
>> the destination parameter of a memcpy() call.
>> This function is documented in the way that the same value is returned.
>> Thus convert two separate statements into a direct variable assignment for
>> the return value from a memory copy action.
…>> +++ b/arch/powerpc/kvm/powerpc.c
>> @@ -216,8 +216,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
>>
>> shared &= PAGE_MASK;
>> shared |= vcpu->arch.magic_page_pa & 0xf000;
>> - new_shared = (void*)shared;
>> - memcpy(new_shared, old_shared, 0x1000);
>> + new_shared = memcpy(shared, old_shared, 0x1000);
>> vcpu->arch.shared = new_shared;
>> }
>> #endif
>
> This patch does not compile
…> arch/powerpc/kvm/powerpc.c: In function `kvmppc_kvm_pv´:
> arch/powerpc/kvm/powerpc.c:219:45: error: passing argument 1 of `__builtin_dynamic_object_size´ makes pointer from integer without a cast [-Wint-conversion]
…
Will another subsequent patch variant become relevant for the proposed
source code transformation approach?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-03 7:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-30 20:51 [PATCH] KVM: PPC: Use pointer from memcpy() call for assignment in kvmppc_kvm_pv() Markus Elfring
2025-10-30 21:41 ` David Laight
2025-11-03 5:20 ` Gautam Menghani
2025-11-03 7:11 ` Markus Elfring
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).