* [PATCH] KVM: selftests: Make rseq compatible with versions prior to glibc-2.30
@ 2022-09-07 15:55 Liam Merwick
2022-09-07 16:00 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Liam Merwick @ 2022-09-07 15:55 UTC (permalink / raw)
To: kvm, linux-kselftest
Cc: liam.merwick, pbonzini, gshan, oliver.upton, andrew.jones, seanjc
The fix for commit e923b0537d28 ("KVM: selftests: Fix target thread to be migrated in rseq_test")
added a call to gettid() which was only added to glibc-2.30 and fails to
compile with older glibc versions.
rseq_test.c: In function 'main':
rseq_test.c:230:33: warning: implicit declaration of function 'gettid'; did you mean 'getgid'? [-Wimplicit-function-declaration]
(void *)(unsigned long)gettid());
^~~~~~
getgid
Switch the call to syscall(SYS_gettid) which was the original advice in the
gettid(2) NOTES section and which works with both new and older glibc versions.
Fixes: e923b0537d28 ("KVM: selftests: Fix target thread to be migrated in rseq_test")
Cc: stable@vger.kernel.org # v5.15
Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
---
Verified with glibc-2.28 and glibc-2.34 and ensured test case from e923b0537d28 still passes.
tools/testing/selftests/kvm/rseq_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
index fac248a43666..6f88da7e60be 100644
--- a/tools/testing/selftests/kvm/rseq_test.c
+++ b/tools/testing/selftests/kvm/rseq_test.c
@@ -227,7 +227,7 @@ int main(int argc, char *argv[])
ucall_init(vm, NULL);
pthread_create(&migration_thread, NULL, migration_worker,
- (void *)(unsigned long)gettid());
+ (void *)(unsigned long)syscall(SYS_gettid));
for (i = 0; !done; i++) {
vcpu_run(vcpu);
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] KVM: selftests: Make rseq compatible with versions prior to glibc-2.30
2022-09-07 15:55 [PATCH] KVM: selftests: Make rseq compatible with versions prior to glibc-2.30 Liam Merwick
@ 2022-09-07 16:00 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2022-09-07 16:00 UTC (permalink / raw)
To: Liam Merwick
Cc: kvm, linux-kselftest, pbonzini, gshan, oliver.upton, andrew.jones
On Wed, Sep 07, 2022, Liam Merwick wrote:
> The fix for commit e923b0537d28 ("KVM: selftests: Fix target thread to be migrated in rseq_test")
> added a call to gettid() which was only added to glibc-2.30 and fails to
> compile with older glibc versions.
>
> rseq_test.c: In function 'main':
> rseq_test.c:230:33: warning: implicit declaration of function 'gettid'; did you mean 'getgid'? [-Wimplicit-function-declaration]
> (void *)(unsigned long)gettid());
> ^~~~~~
> getgid
>
> Switch the call to syscall(SYS_gettid) which was the original advice in the
> gettid(2) NOTES section and which works with both new and older glibc versions.
>
> Fixes: e923b0537d28 ("KVM: selftests: Fix target thread to be migrated in rseq_test")
> Cc: stable@vger.kernel.org # v5.15
> Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
> ---
>
> Verified with glibc-2.28 and glibc-2.34 and ensured test case from e923b0537d28 still passes.
>
> tools/testing/selftests/kvm/rseq_test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
> index fac248a43666..6f88da7e60be 100644
> --- a/tools/testing/selftests/kvm/rseq_test.c
> +++ b/tools/testing/selftests/kvm/rseq_test.c
> @@ -227,7 +227,7 @@ int main(int argc, char *argv[])
> ucall_init(vm, NULL);
>
> pthread_create(&migration_thread, NULL, migration_worker,
> - (void *)(unsigned long)gettid());
> + (void *)(unsigned long)syscall(SYS_gettid));
This exact fix was already posted[*], but we rat-holed a bit on coming up with an
elegant solution and the patch never got applied. I'll poke that thread to see if
Paolo wants to take it for 6.0.
[*] https://lore.kernel.org/all/20220802071240.84626-1-cloudliang@tencent.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-07 16:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-07 15:55 [PATCH] KVM: selftests: Make rseq compatible with versions prior to glibc-2.30 Liam Merwick
2022-09-07 16:00 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox