Re: [PATCH 1/2] KVM: selftests: Make rseq compatible with glibc-2.35

From: Gavin Shan
Date: Wed Aug 10 2022 - 19:35:53 EST


Hi Paolo and Mathieu,

On 8/10/22 10:19 PM, Paolo Bonzini wrote:
On 8/10/22 14:17, Mathieu Desnoyers wrote:
Indeed, this hack seems to be a good approach to immediately fix things without
moving around all source files and headers. In the longer term, I'd prefer Sean's
proposal to move rseq.c to tools/lib/ (and to move rseq headers to tools/include/rseq/).
This can be done in a follow up phase though. I'll put a note on my todo list
for after I come back from vacation.

Great, Gavin, are you going to repost using librseq?


It seems you've merged v2. I will post additional patches to
use tools/lib/librseq.so, depending on what Mathieu will have.

Mathieu, Please let me know if there are anything I can help.

Yeah, rseq_test should reuse librseq code.  The simplest way,
if slightly hackish, is to do something like

diff --git a/tools/testing/selftests/kvm/Makefile
b/tools/testing/selftests/kvm/Makefile
index 690b499c3471..6c192b0ec304 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -37,6 +37,7 @@ ifeq ($(ARCH),riscv)
     UNAME_M := riscv
 endif

 LIBKVM += lib/assert.c
 LIBKVM += lib/elf.c
 LIBKVM += lib/guest_modes.c
@@ -198,7 +199,7 @@ endif
 CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
     -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
     -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
-    -I$(<D) -Iinclude/$(UNAME_M) -I.. $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
+    -I$(<D) -Iinclude/$(UNAME_M) -I.. $(EXTRA_CFLAGS) $(KHDR_INCLUDES) -I../rseq

 no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
         $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie)


and just #include "../rseq/rseq.c" in rseq_test.c.

Thanks,
Gavin