target/i386: Make sure that vsyscall's tb->size != 0
PATCH v2 2/2 tests/tcg/x86_64: add vsyscall smoke test
In reply to Ilya LeoshkevichHaving a small test will prevent trivial regressions in the future.
--- tests/tcg/x86_64/Makefile.target | 6 +++++- tests/tcg/x86_64/vsyscall.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/x86_64/vsyscall.c
tests/tcg/x86_64/Makefile.target +5 -1
@@ -3,14 +3,18 @@ # x86_64 tests - included from tests/tcg/Makefile.target # # Currently we only build test-x86_64 and test-i386-ssse3 from -# $(SRC)/tests/tcg/i386/ +# $(SRC_PATH)/tests/tcg/i386/ # include $(SRC_PATH)/tests/tcg/i386/Makefile.target +X86_64_TESTS += vsyscall TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64 QEMU_OPTS += -cpu max test-x86_64: LDFLAGS+=-lm -lc test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) + +vsyscall: $(SRC_PATH)/tests/tcg/x86_64/vsyscall.c + $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
tests/tcg/x86_64/vsyscall.c new file +12 -0
@@ -0,0 +1,12 @@ +#include <stdio.h> +#include <time.h> + +#define VSYSCALL_PAGE 0xffffffffff600000 +#define TIME_OFFSET 0x400 +typedef time_t (*time_func )(time_t *); + +int main (void ) +{ +printf ("%ld\n" , ((time_func)(VSYSCALL_PAGE +TIME_OFFSET ))(NULL )); +return 0 ; +}
Signature · 1 line
2.31.1
PATCH v2 1/2 target/i386: Make sure that vsyscall's tb->size != 0
In reply to Ilya Leoshkevichtb_gen_code() assumes that tb->size must never be zero, otherwise it may produce spurious exceptions. For x86_64 this may happen when creating a translation block for the vsyscall page.
Fix by pretending that vsyscall translation blocks have at least one instruction.
--- target/i386/tcg/translate.c | 1 + 1 file changed, 1 insertion(+)
target/i386/tcg/translate.c +1 -0
@@ -8572,6 +8572,7 @@ static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)*/ if ((dc->base.pc_next &TARGET_PAGE_MASK ) ==TARGET_VSYSCALL_PAGE ) {gen_exception (dc,EXCP_VSYSCALL , dc->base.pc_next); + dc->base.pc_next = dc->pc +1 ;return ; }#endif
Signature · 1 line
2.31.1
v2 cover target/i386: Make sure that vsyscall's tb->size != 0
This series for the s390-next tree fixes [1]. Patch 1 is the fix, patch 2 is the new test to avoid similar regressions in the future.
[1] https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg02962.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg03219.html
v1 -> v2: Fixed a problem with compiling the new test on centos7. `make
docker-all-tests` does not spot any other issues with the updated patch (it does fail though: a number of iotests have problems, there is a build problem with musl, etc, but this all happens without the patch too).
Ilya Leoshkevich (2):
target/i386: Make sure that vsyscall's tb->size != 0 tests/tcg/x86_64: add vsyscall smoke test
target/i386/tcg/translate.c | 1 + tests/tcg/x86_64/Makefile.target | 6 +++++- tests/tcg/x86_64/vsyscall.c | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/x86_64/vsyscall.c
Signature · 1 line
2.31.1
Quoted 16 lines · On Wed, 19 May 2021 06:57:36 +0200 Ilya Leoshkevich <[email protected]> wrote:
This series for the s390-next tree fixes [1]. Patch 1 is the fix, patch 2 is the new test to avoid similar regressions in the future.
[1] https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg02962.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg03219.html
v1 -> v2: Fixed a problem with compiling the new test on centos7. `make
docker-all-tests` does not spot any other issues with the updated patch (it does fail though: a number of iotests have problems, there is a build problem with musl, etc, but this all happens without the patch too).Ilya Leoshkevich (2):
target/i386: Make sure that vsyscall'stb->size!= 0 tests/tcg/x86_64: add vsyscall smoke test
Quoted 6 lines
target/i386/tcg/translate.c | 1 + tests/tcg/x86_64/Makefile.target | 6 +++++- tests/tcg/x86_64/vsyscall.c | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/x86_64/vsyscall.c
Passes my tests and CI now.
Can I get an ack on patch 2? :)
Re: [PATCH v2 2/2] tests/tcg/x86_64: add vsyscall smoke test
In reply to Ilya LeoshkevichQuoted 8 lines · Ilya Leoshkevich
Having a small test will prevent trivial regressions in the future.
Signed-off-by Ilya Leoshkevich<[email protected]>--- tests/tcg/x86_64/Makefile.target | 6 +++++- tests/tcg/x86_64/vsyscall.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)create mode 100644
tests/tcg/x86_64/vsyscall.c
r~
Quoted 16 lines · On Wed, 19 May 2021 06:57:36 +0200 Ilya Leoshkevich <[email protected]> wrote:
This series for the s390-next tree fixes [1]. Patch 1 is the fix, patch 2 is the new test to avoid similar regressions in the future.
[1] https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg02962.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg03219.html
v1 -> v2: Fixed a problem with compiling the new test on centos7. `make
docker-all-tests` does not spot any other issues with the updated patch (it does fail though: a number of iotests have problems, there is a build problem with musl, etc, but this all happens without the patch too).Ilya Leoshkevich (2):
target/i386: Make sure that vsyscall'stb->size!= 0 tests/tcg/x86_64: add vsyscall smoke test
Quoted 6 lines
target/i386/tcg/translate.c | 1 + tests/tcg/x86_64/Makefile.target | 6 +++++- tests/tcg/x86_64/vsyscall.c | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/x86_64/vsyscall.c
Thanks, queued to s390-next.