All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx
@ 2023-04-04 11:36 Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 01/14] .gitignore: ignore `s390x/comm.key` file Nico Boehr
                   ` (13 more replies)
  0 siblings, 14 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda

Hi Paolo and/or Thomas,

so, here's the second try of the first pull request from me :)

v2:
---
* pick up a new version of Nina's spec_ex series to fix clang compiler issue and
  missing barrier.

Changes in this pull request:

* Marc contributed a series with a few fixes. Most importantly, it generates
  linker scripts for s390x with the assembler, permitting the use of defines in
  linker scripts.
  It is worth noting that it also touches lib/linux/const.h to check for
  __ASSEMBLY__ and __ASSEMBLER__.
* Nina contributed quite a few tests for misalignments in various instructions.
  As well as tests for execute-type instructions. Note that a few of her tests
  will require recent QEMUs under TCG. Upstream fixes are available [1, 2].
* Thomas contributed a test for vSIE on s390x, where the g3 clock might
  sometimes we wrong after reboot. A kernel patch is required[3].
* And, finally, the patch where I get the honor to work as maintainer.

MERGE: https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/merge_requests/42

PIPELINE: https://gitlab.com/Nico-Boehr/kvm-unit-tests/-/pipelines/827521196

PULL: https://gitlab.com/Nico-Boehr/kvm-unit-tests.git s390x-2023-03

[1] https://lists.gnu.org/archive/html/qemu-devel/2023-03/msg04860.html
[2] https://lists.gnu.org/archive/html/qemu-devel/2023-03/msg04896.html
[3] https://lore.kernel.org/kvm/20221123090833.292938-1-thuth@redhat.com/

The following changes since commit 5b5d27da2973b20ec29b18df4d749fb2190458af:

  memory: Skip tests for instructions that are absent (2023-04-03 18:44:24 +0200)

are available in the Git repository at:

  https://gitlab.com/Nico-Boehr/kvm-unit-tests.git s390x-2023-03

for you to fetch changes up to 215923b163742f167dd118664af638389e5ada59:

  s390x: sie: Test whether the epoch extension field is working as expected (2023-04-04 13:10:33 +0200)

----------------------------------------------------------------
Janosch Frank (1):
  MAINTAINERS: Add Nico as s390x Maintainer and make Thomas reviewer

Marc Hartmayer (7):
  .gitignore: ignore `s390x/comm.key` file
  s390x/Makefile: simplify `%.hdr` target rules
  s390x/Makefile: fix `*.gbin` target dependencies
  s390x/Makefile: refactor CPPFLAGS
  s390x: use preprocessor for linker script generation
  s390x: define a macro for the stack frame size
  lib/linux/const.h: test for `__ASSEMBLER__` as well

Nina Schoetterl-Glausch (5):
  s390x/spec_ex: Use PSW macro
  s390x/spec_ex: Add test introducing odd address into PSW
  s390x/spec_ex: Add test of EXECUTE with odd target address
  s390x: Add tests for execute-type instructions
  s390x: spec_ex: Add test for misaligned load

Thomas Huth (1):
  s390x: sie: Test whether the epoch extension field is working as
    expected

 MAINTAINERS                                 |   3 +-
 s390x/Makefile                              |  28 +--
 lib/linux/const.h                           |   2 +-
 lib/s390x/asm-offsets.c                     |   1 +
 s390x/cstart64.S                            |   2 +-
 s390x/{flat.lds => flat.lds.S}              |   4 +-
 s390x/macros.S                              |   4 +-
 s390x/snippets/asm/{flat.lds => flat.lds.S} |   0
 s390x/snippets/c/{flat.lds => flat.lds.S}   |   6 +-
 s390x/ex.c                                  | 188 ++++++++++++++++++++
 s390x/gs.c                                  |  38 ++--
 s390x/sie.c                                 |  28 +++
 s390x/spec_ex.c                             | 106 +++++++++--
 s390x/unittests.cfg                         |   3 +
 .gitignore                                  |   2 +
 .gitlab-ci.yml                              |   1 +
 16 files changed, 370 insertions(+), 46 deletions(-)
 rename s390x/{flat.lds => flat.lds.S} (93%)
 rename s390x/snippets/asm/{flat.lds => flat.lds.S} (100%)
 rename s390x/snippets/c/{flat.lds => flat.lds.S} (88%)
 create mode 100644 s390x/ex.c

-- 
2.39.2


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 01/14] .gitignore: ignore `s390x/comm.key` file
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 02/14] s390x/Makefile: simplify `%.hdr` target rules Nico Boehr
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda, Marc Hartmayer

From: Marc Hartmayer <mhartmay@linux.ibm.com>

Ignore the Secure Execution Customer Communication Key file.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20230307091051.13945-2-mhartmay@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 33529b6..601822d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,5 +28,6 @@ cscope.*
 /s390x/*.bin
 /s390x/snippets/*/*.gbin
 /efi-tests/*
+/s390x/comm.key
 /s390x/snippets/*/*.hdr
 /s390x/snippets/*/*.*obj
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 02/14] s390x/Makefile: simplify `%.hdr` target rules
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 01/14] .gitignore: ignore `s390x/comm.key` file Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 03/14] s390x/Makefile: fix `*.gbin` target dependencies Nico Boehr
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda, Marc Hartmayer

From: Marc Hartmayer <mhartmay@linux.ibm.com>

Merge the two Makefile target rules `$(SNIPPET_DIR)/asm/%.hdr` and
`$(SNIPPET_DIR)/c/%.hdr` into one target rule.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20230307091051.13945-3-mhartmay@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/s390x/Makefile b/s390x/Makefile
index 97a6161..660ff06 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -145,10 +145,7 @@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS)
 	$(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@
 	truncate -s '%4096' $@
 
-$(SNIPPET_DIR)/asm/%.hdr: $(SNIPPET_DIR)/asm/%.gbin $(HOST_KEY_DOCUMENT)
-	$(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@
-
-$(SNIPPET_DIR)/c/%.hdr: $(SNIPPET_DIR)/c/%.gbin $(HOST_KEY_DOCUMENT)
+%.hdr: %.gbin $(HOST_KEY_DOCUMENT)
 	$(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@
 
 .SECONDARY:
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 03/14] s390x/Makefile: fix `*.gbin` target dependencies
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 01/14] .gitignore: ignore `s390x/comm.key` file Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 02/14] s390x/Makefile: simplify `%.hdr` target rules Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 04/14] s390x/Makefile: refactor CPPFLAGS Nico Boehr
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda, Marc Hartmayer

From: Marc Hartmayer <mhartmay@linux.ibm.com>

If the linker scripts change, then the .gbin binaries must be rebuilt.
While at it, replace `$(SRCDIR)/s390x/snippets` with `$(SNIPPET_DIR)`
for these Makefile rules.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20230307091051.13945-4-mhartmay@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/s390x/Makefile b/s390x/Makefile
index 660ff06..71e6563 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -135,13 +135,13 @@ $(SNIPPET_DIR)/asm/%.o: $(SNIPPET_DIR)/asm/%.S $(asm-offsets)
 $(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets)
 	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
 
-$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o
-	$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/snippets/asm/flat.lds $<
+$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds
+	$(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/asm/flat.lds $<
 	$(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@
 	truncate -s '%4096' $@
 
-$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS)
-	$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/snippets/c/flat.lds $< $(snippet_lib) $(FLATLIBS)
+$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds
+	$(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $< $(snippet_lib) $(FLATLIBS)
 	$(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@
 	truncate -s '%4096' $@
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 04/14] s390x/Makefile: refactor CPPFLAGS
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (2 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 03/14] s390x/Makefile: fix `*.gbin` target dependencies Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 05/14] s390x: use preprocessor for linker script generation Nico Boehr
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda, Marc Hartmayer

From: Marc Hartmayer <mhartmay@linux.ibm.com>

This change makes it easier to reuse them. While at it, add a comment
why the `lib` include path is required.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Tested-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20230331082709.35955-1-mhartmay@linux.ibm.com
[ nrb: remove trailing whitespace after INCLUDE_PATH ]
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/s390x/Makefile b/s390x/Makefile
index 71e6563..50171f3 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -63,9 +63,14 @@ test_cases: $(tests)
 test_cases_binary: $(tests_binary)
 test_cases_pv: $(tests_pv_binary)
 
+INCLUDE_PATHS = $(SRCDIR)/lib $(SRCDIR)/lib/s390x
+# Include generated header files (e.g. in case of out-of-source builds)
+INCLUDE_PATHS += lib
+CPPFLAGS = $(addprefix -I,$(INCLUDE_PATHS))
+
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
-CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/s390x -I lib
+CFLAGS += $(CPPFLAGS)
 CFLAGS += -O2
 CFLAGS += -march=zEC12
 CFLAGS += -mbackchain
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 05/14] s390x: use preprocessor for linker script generation
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (3 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 04/14] s390x/Makefile: refactor CPPFLAGS Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 06/14] s390x: define a macro for the stack frame size Nico Boehr
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones
  Cc: kvm, frankja, imbrenda, Marc Hartmayer, Nina Schoetterl-Glausch

From: Marc Hartmayer <mhartmay@linux.ibm.com>

The old `.lds` scripts are being renamed to `.lds.S` and the actual
`.lds` scripts are being generated by the assembler preprocessor. This
change allows us to use constants defined by macros in the `.lds.S`
files.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20230307091051.13945-6-mhartmay@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/Makefile                              | 7 +++++--
 s390x/{flat.lds => flat.lds.S}              | 0
 s390x/snippets/asm/{flat.lds => flat.lds.S} | 0
 s390x/snippets/c/{flat.lds => flat.lds.S}   | 0
 .gitignore                                  | 1 +
 5 files changed, 6 insertions(+), 2 deletions(-)
 rename s390x/{flat.lds => flat.lds.S} (100%)
 rename s390x/snippets/asm/{flat.lds => flat.lds.S} (100%)
 rename s390x/snippets/c/{flat.lds => flat.lds.S} (100%)

diff --git a/s390x/Makefile b/s390x/Makefile
index 50171f3..6732b48 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -78,7 +78,7 @@ CFLAGS += -fno-delete-null-pointer-checks
 LDFLAGS += -nostdlib -Wl,--build-id=none
 
 # We want to keep intermediate files
-.PRECIOUS: %.o
+.PRECIOUS: %.o %.lds
 
 asm-offsets = lib/$(ARCH)/asm-offsets.h
 include $(SRCDIR)/scripts/asm-offsets.mak
@@ -161,6 +161,9 @@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPP
 %.hdr.obj: %.hdr
 	$(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@
 
+lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@
+%.lds: %.lds.S
+	$(CPP) $(lds-autodepend-flags) $(CPPFLAGS) -P -C -o $@ $<
 
 .SECONDEXPANSION:
 %.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o
@@ -213,7 +216,7 @@ $(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets)
 
 
 arch_clean: asm_offsets_clean
-	$(RM) $(TEST_DIR)/*.{o,elf,bin} $(SNIPPET_DIR)/*/*.{o,elf,*bin,*obj,hdr} $(SNIPPET_DIR)/asm/.*.d $(TEST_DIR)/.*.d lib/s390x/.*.d $(comm-key)
+	$(RM) $(TEST_DIR)/*.{o,elf,bin,lds} $(SNIPPET_DIR)/*/*.{o,elf,*bin,*obj,hdr,lds} $(SNIPPET_DIR)/asm/.*.d $(TEST_DIR)/.*.d lib/s390x/.*.d $(comm-key)
 
 generated-files = $(asm-offsets)
 $(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files)
diff --git a/s390x/flat.lds b/s390x/flat.lds.S
similarity index 100%
rename from s390x/flat.lds
rename to s390x/flat.lds.S
diff --git a/s390x/snippets/asm/flat.lds b/s390x/snippets/asm/flat.lds.S
similarity index 100%
rename from s390x/snippets/asm/flat.lds
rename to s390x/snippets/asm/flat.lds.S
diff --git a/s390x/snippets/c/flat.lds b/s390x/snippets/c/flat.lds.S
similarity index 100%
rename from s390x/snippets/c/flat.lds
rename to s390x/snippets/c/flat.lds.S
diff --git a/.gitignore b/.gitignore
index 601822d..29f352c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@ cscope.*
 /s390x/comm.key
 /s390x/snippets/*/*.hdr
 /s390x/snippets/*/*.*obj
+/s390x/**/*.lds
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 06/14] s390x: define a macro for the stack frame size
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (4 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 05/14] s390x: use preprocessor for linker script generation Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 07/14] lib/linux/const.h: test for `__ASSEMBLER__` as well Nico Boehr
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones
  Cc: kvm, frankja, imbrenda, Marc Hartmayer, Nina Schoetterl-Glausch

From: Marc Hartmayer <mhartmay@linux.ibm.com>

Define and use a macro for the stack frame size. While at it, fix
whitespace in the `gs_handler_asm` block.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20230307091051.13945-7-mhartmay@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/Makefile              |  2 +-
 lib/s390x/asm-offsets.c     |  1 +
 s390x/cstart64.S            |  2 +-
 s390x/flat.lds.S            |  4 +++-
 s390x/macros.S              |  4 ++--
 s390x/snippets/c/flat.lds.S |  6 ++++--
 s390x/gs.c                  | 38 +++++++++++++++++++++----------------
 7 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/s390x/Makefile b/s390x/Makefile
index 6732b48..ab146eb 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -162,7 +162,7 @@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPP
 	$(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@
 
 lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@
-%.lds: %.lds.S
+%.lds: %.lds.S $(asm-offsets)
 	$(CPP) $(lds-autodepend-flags) $(CPPFLAGS) -P -C -o $@ $<
 
 .SECONDEXPANSION:
diff --git a/lib/s390x/asm-offsets.c b/lib/s390x/asm-offsets.c
index f612f32..188dd2e 100644
--- a/lib/s390x/asm-offsets.c
+++ b/lib/s390x/asm-offsets.c
@@ -87,6 +87,7 @@ int main(void)
 	OFFSET(STACK_FRAME_INT_GRS0, stack_frame_int, grs0);
 	OFFSET(STACK_FRAME_INT_GRS1, stack_frame_int, grs1);
 	DEFINE(STACK_FRAME_INT_SIZE, sizeof(struct stack_frame_int));
+	DEFINE(STACK_FRAME_SIZE, sizeof(struct stack_frame));
 
 	return 0;
 }
diff --git a/s390x/cstart64.S b/s390x/cstart64.S
index 6f83da2..468ace3 100644
--- a/s390x/cstart64.S
+++ b/s390x/cstart64.S
@@ -38,7 +38,7 @@ start:
 	/* setup stack */
 	larl	%r15, stackptr
 	/* Clear first stack frame */
-	xc      0(160,%r15), 0(%r15)
+	xc      0(STACK_FRAME_SIZE,%r15), 0(%r15)
 	/* setup initial PSW mask + control registers*/
 	larl	%r1, initial_psw
 	lpswe	0(%r1)
diff --git a/s390x/flat.lds.S b/s390x/flat.lds.S
index 952f6cd..0cb7e38 100644
--- a/s390x/flat.lds.S
+++ b/s390x/flat.lds.S
@@ -1,3 +1,5 @@
+#include <asm/asm-offsets.h>
+
 SECTIONS
 {
 	.lowcore : {
@@ -44,6 +46,6 @@ SECTIONS
 	/*
 	 * stackptr set with initial stack frame preallocated
 	 */
-	stackptr = . - 160;
+	stackptr = . - STACK_FRAME_SIZE;
 	stacktop = .;
 }
diff --git a/s390x/macros.S b/s390x/macros.S
index 13cff29..e2a56a3 100644
--- a/s390x/macros.S
+++ b/s390x/macros.S
@@ -21,14 +21,14 @@
 	/* Save the stack address in GR2 which is the first function argument */
 	lgr     %r2, %r15
 	/* Allocate stack space for called C function, as specified in s390 ELF ABI */
-	slgfi   %r15, 160
+	slgfi   %r15, STACK_FRAME_SIZE
 	/*
 	 * Save the address of the interrupt stack into the back chain
 	 * of the called function.
 	 */
 	stg     %r2, STACK_FRAME_INT_BACKCHAIN(%r15)
 	brasl	%r14, \c_func
-	algfi   %r15, 160
+	algfi   %r15, STACK_FRAME_SIZE
 	RESTORE_REGS_STACK
 	lpswe	\old_psw
 	.endm
diff --git a/s390x/snippets/c/flat.lds.S b/s390x/snippets/c/flat.lds.S
index 9e5eb66..468b5f1 100644
--- a/s390x/snippets/c/flat.lds.S
+++ b/s390x/snippets/c/flat.lds.S
@@ -1,3 +1,5 @@
+#include <asm/asm-offsets.h>
+
 SECTIONS
 {
 	.lowcore : {
@@ -18,9 +20,9 @@ SECTIONS
 	. = 0x4000;
 	/*
 	 * The stack grows down from 0x4000 to 0x2000, we pre-allocoate
-	 * a frame via the -160.
+	 * a frame via the -STACK_FRAME_SIZE.
 	 */
-	stackptr = . - 160;
+	stackptr = . - STACK_FRAME_SIZE;
 	stacktop = .;
 	/* Start text 0x4000 */
 	.text : {
diff --git a/s390x/gs.c b/s390x/gs.c
index 4993eb8..9ae893e 100644
--- a/s390x/gs.c
+++ b/s390x/gs.c
@@ -9,6 +9,7 @@
  *    Janosch Frank <frankja@linux.ibm.com>
  */
 #include <libcflat.h>
+#include <asm/asm-offsets.h>
 #include <asm/page.h>
 #include <asm/facility.h>
 #include <asm/interrupt.h>
@@ -35,22 +36,27 @@ static inline unsigned long load_guarded(unsigned long *p)
 
 /* guarded-storage event handler and finally it calls gs_handler */
 extern void gs_handler_asm(void);
-	asm(".globl gs_handler_asm\n"
-	    "gs_handler_asm:\n"
-	    "	    lgr	    %r14,%r15\n" 		/* Save current stack address in r14 */
-	    "	    aghi    %r15,-320\n" 		/* Allocate stack frame */
-	    "	    stmg    %r0,%r13,192(%r15)\n" 	/* Store regs to save area */
-	    "	    stg	    %r14,312(%r15)\n"
-	    "	    la	    %r2,160(%r15)\n" 		/* Store gscb address in this_cb */
-	    "	    .insn   rxy,0xe30000000049,0,160(%r15)\n" /* stgsc */
-	    "	    lg	    %r14,24(%r2)\n" 		/* Get GSEPLA from GSCB*/
-	    "	    lg	    %r14,40(%r14)\n" 		/* Get GSERA from GSEPL*/
-	    "	    stg	    %r14,304(%r15)\n" 		/* Store GSERA in r14 of reg save area */
-	    "	    brasl   %r14,gs_handler\n" 		/* Jump to gs_handler */
-	    "	    lmg	    %r0,%r15,192(%r15)\n" 	/* Restore regs */
-	    "	    aghi    %r14, 6\n" 			/* Add lgg instr len to GSERA */
-	    "	    br	    %r14\n" 			/* Jump to next instruction after lgg */
-	    "	    .size gs_handler_asm,.-gs_handler_asm\n");
+	asm (          ".macro	STGSC	args:vararg\n"
+		"	.insn	rxy,0xe30000000049,\\args\n"
+		"	.endm\n"
+		"	.globl	gs_handler_asm\n"
+		"gs_handler_asm:\n"
+		"	lgr	%r14,%r15\n"				/* Save current stack address in r14 */
+		".Lgs_handler_frame = 16*8+32+" xstr(STACK_FRAME_SIZE) "\n"
+		"	aghi	%r15,-(.Lgs_handler_frame)\n"		/* Allocate stack frame */
+		"	stmg	%r0,%r13,192(%r15)\n"			/* Store regs to save area */
+		"	stg	%r14,312(%r15)\n"
+		"	la	%r2," xstr(STACK_FRAME_SIZE) "(%r15)\n"	/* Store gscb address in this_cb */
+		"	STGSC	%r0," xstr(STACK_FRAME_SIZE) "(%r15)\n"
+		"	lg	%r14,24(%r2)\n"				/* Get GSEPLA from GSCB*/
+		"	lg	%r14,40(%r14)\n"			/* Get GSERA from GSEPL*/
+		"	stg	%r14,304(%r15)\n"			/* Store GSERA in r14 of reg save area */
+		"	brasl	%r14,gs_handler\n"			/* Jump to gs_handler */
+		"	lmg	%r0,%r15,192(%r15)\n"			/* Restore regs */
+		"	aghi	%r14, 6\n"				/* Add lgg instr len to GSERA */
+		"	br	%r14\n"					/* Jump to next instruction after lgg */
+		".size gs_handler_asm,.-gs_handler_asm\n"
+	);
 
 void gs_handler(struct gs_cb *this_cb)
 {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 07/14] lib/linux/const.h: test for `__ASSEMBLER__` as well
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (5 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 06/14] s390x: define a macro for the stack frame size Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 08/14] s390x/spec_ex: Use PSW macro Nico Boehr
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda, Marc Hartmayer

From: Marc Hartmayer <mhartmay@linux.ibm.com>

On s390x we're using the preprocessor for generating our linker scripts
out of assembly files. The macro `__ASSEMBLER__` is defined with value 1
when preprocessing assembly language using gcc. [1] Therefore, let's
check for the macro `__ASSEMBLER__` in `lib/linux/const.h` as well. Thus
we can use macros that makes use of the `_AC` or `_AT` macro in the
"linker scripts".

[1] https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20230307091051.13945-8-mhartmay@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 lib/linux/const.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/linux/const.h b/lib/linux/const.h
index c872bfd..be114dc 100644
--- a/lib/linux/const.h
+++ b/lib/linux/const.h
@@ -12,7 +12,7 @@
  * leave it unchanged in asm.
  */
 
-#ifdef __ASSEMBLY__
+#if defined(__ASSEMBLY__) || defined(__ASSEMBLER__)
 #define _AC(X,Y)	X
 #define _AT(T,X)	X
 #else
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 08/14] s390x/spec_ex: Use PSW macro
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (6 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 07/14] lib/linux/const.h: test for `__ASSEMBLER__` as well Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 09/14] s390x/spec_ex: Add test introducing odd address into PSW Nico Boehr
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones
  Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch

From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

Replace explicit psw definition by PSW macro.
No functional change intended.

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20230404085454.2709061-2-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/spec_ex.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c
index 42ecaed..2adc599 100644
--- a/s390x/spec_ex.c
+++ b/s390x/spec_ex.c
@@ -105,10 +105,7 @@ static int check_invalid_psw(void)
 /* For normal PSWs bit 12 has to be 0 to be a valid PSW*/
 static int psw_bit_12_is_1(void)
 {
-	struct psw invalid = {
-		.mask = BIT(63 - 12),
-		.addr = 0x00000000deadbeee
-	};
+	struct psw invalid = PSW(BIT(63 - 12), 0x00000000deadbeee);
 
 	expect_invalid_psw(invalid);
 	load_psw(invalid);
@@ -118,10 +115,7 @@ static int psw_bit_12_is_1(void)
 /* A short PSW needs to have bit 12 set to be valid. */
 static int short_psw_bit_12_is_0(void)
 {
-	struct psw invalid = {
-		.mask = BIT(63 - 12),
-		.addr = 0x00000000deadbeee
-	};
+	struct psw invalid = PSW(BIT(63 - 12), 0x00000000deadbeee);
 	struct short_psw short_invalid = {
 		.mask = 0x0,
 		.addr = 0xdeadbeee
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 09/14] s390x/spec_ex: Add test introducing odd address into PSW
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (7 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 08/14] s390x/spec_ex: Use PSW macro Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 10/14] s390x/spec_ex: Add test of EXECUTE with odd target address Nico Boehr
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones
  Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch

From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

Instructions on s390 must be halfword aligned.
Introducing an odd instruction address into the PSW leads to a
specification exception when attempting to execute the instruction at
the odd address.
Add a test for this.

Acked-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Tested-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20230404085454.2709061-3-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/spec_ex.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c
index 2adc599..494d94c 100644
--- a/s390x/spec_ex.c
+++ b/s390x/spec_ex.c
@@ -88,12 +88,23 @@ static void expect_invalid_psw(struct psw psw)
 	invalid_psw_expected = true;
 }
 
+static void clear_invalid_psw(void)
+{
+	expected_psw = PSW(0, 0);
+	invalid_psw_expected = false;
+}
+
 static int check_invalid_psw(void)
 {
 	/* Since the fixup sets this to false we check for false here. */
 	if (!invalid_psw_expected) {
+		/*
+		 * Early exception recognition: pgm_int_id == 0.
+		 * Late exception recognition: psw address has been
+		 *	incremented by pgm_int_id (unpredictable value)
+		 */
 		if (expected_psw.mask == invalid_psw.mask &&
-		    expected_psw.addr == invalid_psw.addr)
+		    expected_psw.addr == invalid_psw.addr - lowcore.pgm_int_id)
 			return 0;
 		report_fail("Wrong invalid PSW");
 	} else {
@@ -112,6 +123,42 @@ static int psw_bit_12_is_1(void)
 	return check_invalid_psw();
 }
 
+extern char misaligned_code_pre[];
+asm (  ".balign	2\n"
+"misaligned_code_pre:\n"
+"	. = . + 1\n"
+"	larl	%r0,0\n"
+"	br	%r1\n"
+);
+
+static int psw_odd_address(void)
+{
+	struct psw odd = PSW_WITH_CUR_MASK(((uint64_t)&misaligned_code_pre) + 1);
+	uint64_t executed_addr;
+
+	expect_invalid_psw(odd);
+	fixup_psw.mask = extract_psw_mask();
+	asm volatile ( "xgr	%%r0,%%r0\n"
+		"	larl	%%r1,0f\n"
+		"	stg	%%r1,%[fixup_addr]\n"
+		"	lpswe	%[odd_psw]\n"
+		"0:	lr	%[executed_addr],%%r0\n"
+	: [fixup_addr] "=&T" (fixup_psw.addr),
+	  [executed_addr] "=d" (executed_addr)
+	: [odd_psw] "Q" (odd)
+	: "cc", "%r0", "%r1", "memory" /* Compiler barrier like in load_psw */
+	);
+
+	if (!executed_addr) {
+		return check_invalid_psw();
+	} else {
+		assert(executed_addr == odd.addr);
+		clear_invalid_psw();
+		report_fail("did not execute unaligned instructions");
+		return 1;
+	}
+}
+
 /* A short PSW needs to have bit 12 set to be valid. */
 static int short_psw_bit_12_is_0(void)
 {
@@ -170,6 +217,7 @@ struct spec_ex_trigger {
 static const struct spec_ex_trigger spec_ex_triggers[] = {
 	{ "psw_bit_12_is_1", &psw_bit_12_is_1, false, &fixup_invalid_psw },
 	{ "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, false, &fixup_invalid_psw },
+	{ "psw_odd_address", &psw_odd_address, false, &fixup_invalid_psw },
 	{ "bad_alignment", &bad_alignment, true, NULL },
 	{ "not_even", &not_even, true, NULL },
 	{ NULL, NULL, false, NULL },
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 10/14] s390x/spec_ex: Add test of EXECUTE with odd target address
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (8 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 09/14] s390x/spec_ex: Add test introducing odd address into PSW Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions Nico Boehr
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones
  Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch

From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

The EXECUTE instruction executes the instruction at the given target
address. This address must be halfword aligned, otherwise a
specification exception occurs.
Add a test for this.

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20230404085454.2709061-4-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/spec_ex.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c
index 494d94c..e5f7b12 100644
--- a/s390x/spec_ex.c
+++ b/s390x/spec_ex.c
@@ -177,6 +177,30 @@ static int short_psw_bit_12_is_0(void)
 	return 0;
 }
 
+static int odd_ex_target(void)
+{
+	uint64_t pre_target_addr;
+	int to = 0, from = 0x0dd;
+
+	asm volatile ( ".pushsection .text.ex_odd\n"
+		"	.balign	2\n"
+		"pre_odd_ex_target%=:\n"
+		"	. = . + 1\n"
+		"	lr	%[to],%[from]\n"
+		"	.popsection\n"
+
+		"	larl	%[pre_target_addr],pre_odd_ex_target%=\n"
+		"	ex	0,1(%[pre_target_addr])\n"
+		: [pre_target_addr] "=&a" (pre_target_addr),
+		  [to] "+d" (to)
+		: [from] "d" (from)
+	);
+
+	assert((pre_target_addr + 1) & 1);
+	report(to != from, "did not perform ex with odd target");
+	return 0;
+}
+
 static int bad_alignment(void)
 {
 	uint32_t words[5] __attribute__((aligned(16)));
@@ -218,6 +242,7 @@ static const struct spec_ex_trigger spec_ex_triggers[] = {
 	{ "psw_bit_12_is_1", &psw_bit_12_is_1, false, &fixup_invalid_psw },
 	{ "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, false, &fixup_invalid_psw },
 	{ "psw_odd_address", &psw_odd_address, false, &fixup_invalid_psw },
+	{ "odd_ex_target", &odd_ex_target, true, NULL },
 	{ "bad_alignment", &bad_alignment, true, NULL },
 	{ "not_even", &not_even, true, NULL },
 	{ NULL, NULL, false, NULL },
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (9 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 10/14] s390x/spec_ex: Add test of EXECUTE with odd target address Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 14:15   ` Thomas Huth
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 12/14] s390x: spec_ex: Add test for misaligned load Nico Boehr
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones
  Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch

From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

Test the instruction address used by targets of an execute instruction.
When the target instruction calculates a relative address, the result is
relative to the target instruction, not the execute instruction.

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20230317112339.774659-1-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/Makefile      |   1 +
 s390x/ex.c          | 188 ++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |   3 +
 .gitlab-ci.yml      |   1 +
 4 files changed, 193 insertions(+)
 create mode 100644 s390x/ex.c

diff --git a/s390x/Makefile b/s390x/Makefile
index ab146eb..a80db53 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -39,6 +39,7 @@ tests += $(TEST_DIR)/panic-loop-extint.elf
 tests += $(TEST_DIR)/panic-loop-pgm.elf
 tests += $(TEST_DIR)/migration-sck.elf
 tests += $(TEST_DIR)/exittime.elf
+tests += $(TEST_DIR)/ex.elf
 
 pv-tests += $(TEST_DIR)/pv-diags.elf
 
diff --git a/s390x/ex.c b/s390x/ex.c
new file mode 100644
index 0000000..dbd8030
--- /dev/null
+++ b/s390x/ex.c
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright IBM Corp. 2023
+ *
+ * Test EXECUTE (RELATIVE LONG).
+ * These instructions execute a target instruction. The target instruction is formed
+ * by reading an instruction from memory and optionally modifying some of its bits.
+ * The execution of the target instruction is the same as if it was executed
+ * normally as part of the instruction sequence, except for the instruction
+ * address and the instruction-length code.
+ */
+
+#include <libcflat.h>
+
+/*
+ * Accesses to the operand of execute-type instructions are instruction fetches.
+ * Minimum alignment is two, since the relative offset is specified by number of halfwords.
+ */
+asm (  ".pushsection .text.exrl_targets,\"x\"\n"
+"	.balign	2\n"
+"	.popsection\n"
+);
+
+/*
+ * BRANCH AND SAVE, register register variant.
+ * Saves the next instruction address (address from PSW + length of instruction)
+ * to the first register. No branch is taken in this test, because 0 is
+ * specified as target.
+ * BASR does *not* perform a relative address calculation with an intermediate.
+ */
+static void test_basr(void)
+{
+	uint64_t ret_addr, after_ex;
+
+	report_prefix_push("BASR");
+	asm volatile ( ".pushsection .text.exrl_targets\n"
+		"0:	basr	%[ret_addr],0\n"
+		"	.popsection\n"
+
+		"	larl	%[after_ex],1f\n"
+		"	exrl	0,0b\n"
+		"1:\n"
+		: [ret_addr] "=d" (ret_addr),
+		  [after_ex] "=d" (after_ex)
+	);
+
+	report(ret_addr == after_ex, "return address after EX");
+	report_prefix_pop();
+}
+
+/*
+ * BRANCH RELATIVE AND SAVE.
+ * According to PoP (Branch-Address Generation), the address calculated relative
+ * to the instruction address is relative to BRAS when it is the target of an
+ * execute-type instruction, not relative to the execute-type instruction.
+ */
+static void test_bras(void)
+{
+	uint64_t after_target, ret_addr, after_ex, branch_addr;
+
+	report_prefix_push("BRAS");
+	asm volatile ( ".pushsection .text.exrl_targets\n"
+		"0:	bras	%[ret_addr],1f\n"
+		"	nopr	%%r7\n"
+		"1:	larl	%[branch_addr],0\n"
+		"	j	4f\n"
+		"	.popsection\n"
+
+		"	larl	%[after_target],1b\n"
+		"	larl	%[after_ex],3f\n"
+		"2:	exrl	0,0b\n"
+/*
+ * In case the address calculation is correct, we jump by the relative offset 1b-0b from 0b to 1b.
+ * In case the address calculation is relative to the exrl (i.e. a test failure),
+ * put a valid instruction at the same relative offset from the exrl, so the test continues in a
+ * controlled manner.
+ */
+		"3:	larl	%[branch_addr],0\n"
+		"4:\n"
+
+		"	.if (1b - 0b) != (3b - 2b)\n"
+		"	.error	\"right and wrong target must have same offset\"\n"
+		"	.endif\n"
+		: [after_target] "=d" (after_target),
+		  [ret_addr] "=d" (ret_addr),
+		  [after_ex] "=d" (after_ex),
+		  [branch_addr] "=d" (branch_addr)
+	);
+
+	report(after_target == branch_addr, "address calculated relative to BRAS");
+	report(ret_addr == after_ex, "return address after EX");
+	report_prefix_pop();
+}
+
+/*
+ * LOAD ADDRESS RELATIVE LONG.
+ * If it is the target of an execute-type instruction, the address is relative
+ * to the LARL.
+ */
+static void test_larl(void)
+{
+	uint64_t target, addr;
+
+	report_prefix_push("LARL");
+	asm volatile ( ".pushsection .text.exrl_targets\n"
+		"0:	larl	%[addr],0\n"
+		"	.popsection\n"
+
+		"	larl	%[target],0b\n"
+		"	exrl	0,0b\n"
+		: [target] "=d" (target),
+		  [addr] "=d" (addr)
+	);
+
+	report(target == addr, "address calculated relative to LARL");
+	report_prefix_pop();
+}
+
+/* LOAD LOGICAL RELATIVE LONG.
+ * If it is the target of an execute-type instruction, the address is relative
+ * to the LLGFRL.
+ */
+static void test_llgfrl(void)
+{
+	uint64_t target, value;
+
+	report_prefix_push("LLGFRL");
+	asm volatile ( ".pushsection .text.exrl_targets\n"
+		"	.balign	4\n"
+		 //operand of llgfrl must be word aligned
+		"0:	llgfrl	%[value],0\n"
+		"	.popsection\n"
+
+		"	llgfrl	%[target],0b\n"
+		//align (pad with nop), in case the wrong operand is used
+		"	.balignw 4,0x0707\n"
+		"	exrl	0,0b\n"
+		: [target] "=d" (target),
+		  [value] "=d" (value)
+	);
+
+	report(target == value, "loaded correct value");
+	report_prefix_pop();
+}
+
+/*
+ * COMPARE RELATIVE LONG
+ * If it is the target of an execute-type instruction, the address is relative
+ * to the CRL.
+ */
+static void test_crl(void)
+{
+	uint32_t program_mask, cc, crl_word;
+
+	report_prefix_push("CRL");
+	asm volatile ( ".pushsection .text.exrl_targets\n"
+		 //operand of crl must be word aligned
+		 "	.balign	4\n"
+		"0:	crl	%[crl_word],0\n"
+		"	.popsection\n"
+
+		"	lrl	%[crl_word],0b\n"
+		//align (pad with nop), in case the wrong operand is used
+		"	.balignw 4,0x0707\n"
+		"	exrl	0,0b\n"
+		"	ipm	%[program_mask]\n"
+		: [program_mask] "=d" (program_mask),
+		  [crl_word] "=d" (crl_word)
+		:: "cc"
+	);
+
+	cc = program_mask >> 28;
+	report(!cc, "operand compared to is relative to CRL");
+	report_prefix_pop();
+}
+
+int main(int argc, char **argv)
+{
+	report_prefix_push("ex");
+	test_basr();
+	test_bras();
+	test_larl();
+	test_llgfrl();
+	test_crl();
+	report_prefix_pop();
+
+	return report_summary();
+}
diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
index d97eb5e..b61faf0 100644
--- a/s390x/unittests.cfg
+++ b/s390x/unittests.cfg
@@ -215,3 +215,6 @@ file = migration-skey.elf
 smp = 2
 groups = migration
 extra_params = -append '--parallel'
+
+[execute]
+file = ex.elf
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ad7949c..a999f64 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -275,6 +275,7 @@ s390x-kvm:
   - ACCEL=kvm ./run_tests.sh
       selftest-setup intercept emulator sieve sthyi diag10 diag308 pfmf
       cmm vector gs iep cpumodel diag288 stsi sclp-1g sclp-3g css skrf sie
+      execute
       | tee results.txt
   - grep -q PASS results.txt && ! grep -q FAIL results.txt
  only:
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 12/14] s390x: spec_ex: Add test for misaligned load
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (10 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 13/14] MAINTAINERS: Add Nico as s390x Maintainer and make Thomas reviewer Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 14/14] s390x: sie: Test whether the epoch extension field is working as expected Nico Boehr
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones
  Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch

From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

The operand of LOAD RELATIVE LONG must be word aligned, otherwise a
specification exception occurs. Test that this exception occurs.

Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20230301132638.3336040-1-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/spec_ex.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c
index e5f7b12..e3dd85d 100644
--- a/s390x/spec_ex.c
+++ b/s390x/spec_ex.c
@@ -201,7 +201,7 @@ static int odd_ex_target(void)
 	return 0;
 }
 
-static int bad_alignment(void)
+static int bad_alignment_lqp(void)
 {
 	uint32_t words[5] __attribute__((aligned(16)));
 	uint32_t (*bad_aligned)[4] = (uint32_t (*)[4])&words[1];
@@ -214,6 +214,22 @@ static int bad_alignment(void)
 	return 0;
 }
 
+static int bad_alignment_lrl(void)
+{
+	uint64_t r;
+
+	asm volatile ( ".pushsection .rodata\n"
+		"	.balign	4\n"
+		"	. = . + 2\n"
+		"0:	.fill	4\n"
+		"	.popsection\n"
+
+		"	lrl	%0,0b\n"
+		: "=d" (r)
+	);
+	return 0;
+}
+
 static int not_even(void)
 {
 	uint64_t quad[2] __attribute__((aligned(16))) = {0};
@@ -243,7 +259,8 @@ static const struct spec_ex_trigger spec_ex_triggers[] = {
 	{ "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, false, &fixup_invalid_psw },
 	{ "psw_odd_address", &psw_odd_address, false, &fixup_invalid_psw },
 	{ "odd_ex_target", &odd_ex_target, true, NULL },
-	{ "bad_alignment", &bad_alignment, true, NULL },
+	{ "bad_alignment_lqp", &bad_alignment_lqp, true, NULL },
+	{ "bad_alignment_lrl", &bad_alignment_lrl, true, NULL },
 	{ "not_even", &not_even, true, NULL },
 	{ NULL, NULL, false, NULL },
 };
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 13/14] MAINTAINERS: Add Nico as s390x Maintainer and make Thomas reviewer
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (11 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 12/14] s390x: spec_ex: Add test for misaligned load Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 14/14] s390x: sie: Test whether the epoch extension field is working as expected Nico Boehr
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda

From: Janosch Frank <frankja@linux.ibm.com>

The circle of life continues as we bring in Nico as a s390x
maintainer. Thomas moves from the maintainer position to reviewer but
he's a general maintainer of the project anyway.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Acked-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20230322113400.1123378-1-frankja@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 649de50..bd1761d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -85,11 +85,12 @@ F: lib/powerpc/
 F: lib/ppc64/
 
 S390X
-M: Thomas Huth <thuth@redhat.com>
 M: Janosch Frank <frankja@linux.ibm.com>
 M: Claudio Imbrenda <imbrenda@linux.ibm.com>
+M: Nico Böhr <nrb@linux.ibm.com>
 S: Supported
 R: David Hildenbrand <david@redhat.com>
+R: Thomas Huth <thuth@redhat.com>
 L: kvm@vger.kernel.org
 L: linux-s390@vger.kernel.org
 F: s390x/
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [kvm-unit-tests GIT PULL v2 14/14] s390x: sie: Test whether the epoch extension field is working as expected
  2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
                   ` (12 preceding siblings ...)
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 13/14] MAINTAINERS: Add Nico as s390x Maintainer and make Thomas reviewer Nico Boehr
@ 2023-04-04 11:36 ` Nico Boehr
  13 siblings, 0 replies; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 11:36 UTC (permalink / raw)
  To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda

From: Thomas Huth <thuth@redhat.com>

We recently discovered a bug with the time management in nested scenarios
which got fixed by kernel commit "KVM: s390: vsie: Fix the initialization
of the epoch extension (epdx) field". This adds a simple test for this
bug so that it is easier to determine whether the host kernel of a machine
has already been fixed or not.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20221208170502.17984-1-thuth@redhat.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 s390x/sie.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/s390x/sie.c b/s390x/sie.c
index 87575b2..cd3cea1 100644
--- a/s390x/sie.c
+++ b/s390x/sie.c
@@ -58,6 +58,33 @@ static void test_diags(void)
 	}
 }
 
+static void test_epoch_ext(void)
+{
+	u32 instr[] = {
+		0xb2780000,	/* STCKE 0 */
+		0x83000044	/* DIAG 0x44 to intercept */
+	};
+
+	if (!test_facility(139)) {
+		report_skip("epdx: Multiple Epoch Facility is not available");
+		return;
+	}
+
+	guest[0] = 0x00;
+	memcpy(guest_instr, instr, sizeof(instr));
+
+	vm.sblk->gpsw.addr = PAGE_SIZE * 2;
+	vm.sblk->gpsw.mask = PSW_MASK_64;
+
+	vm.sblk->ecd |= ECD_MEF;
+	vm.sblk->epdx = 0x47;	/* Setting the epoch extension here ... */
+
+	sie(&vm);
+
+	/* ... should result in the same epoch extension here: */
+	report(guest[0] == 0x47, "epdx: different epoch is visible in the guest");
+}
+
 static void setup_guest(void)
 {
 	setup_vm();
@@ -80,6 +107,7 @@ int main(void)
 
 	setup_guest();
 	test_diags();
+	test_epoch_ext();
 	sie_guest_destroy(&vm);
 
 done:
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions
  2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions Nico Boehr
@ 2023-04-04 14:15   ` Thomas Huth
  2023-04-04 14:54     ` Nina Schoetterl-Glausch
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas Huth @ 2023-04-04 14:15 UTC (permalink / raw)
  To: Nico Boehr, pbonzini, andrew.jones, Nina Schoetterl-Glausch
  Cc: kvm, frankja, imbrenda

On 04/04/2023 13.36, Nico Boehr wrote:
> From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> 
> Test the instruction address used by targets of an execute instruction.
> When the target instruction calculates a relative address, the result is
> relative to the target instruction, not the execute instruction.
> 
> Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> Link: https://lore.kernel.org/r/20230317112339.774659-1-nsg@linux.ibm.com
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> ---
>   s390x/Makefile      |   1 +
>   s390x/ex.c          | 188 ++++++++++++++++++++++++++++++++++++++++++++
>   s390x/unittests.cfg |   3 +
>   .gitlab-ci.yml      |   1 +
>   4 files changed, 193 insertions(+)
>   create mode 100644 s390x/ex.c
> 
> diff --git a/s390x/Makefile b/s390x/Makefile
> index ab146eb..a80db53 100644
> --- a/s390x/Makefile
> +++ b/s390x/Makefile
> @@ -39,6 +39,7 @@ tests += $(TEST_DIR)/panic-loop-extint.elf
>   tests += $(TEST_DIR)/panic-loop-pgm.elf
>   tests += $(TEST_DIR)/migration-sck.elf
>   tests += $(TEST_DIR)/exittime.elf
> +tests += $(TEST_DIR)/ex.elf
>   
>   pv-tests += $(TEST_DIR)/pv-diags.elf
>   
> diff --git a/s390x/ex.c b/s390x/ex.c
> new file mode 100644
> index 0000000..dbd8030
> --- /dev/null
> +++ b/s390x/ex.c
> @@ -0,0 +1,188 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright IBM Corp. 2023
> + *
> + * Test EXECUTE (RELATIVE LONG).
> + * These instructions execute a target instruction. The target instruction is formed
> + * by reading an instruction from memory and optionally modifying some of its bits.
> + * The execution of the target instruction is the same as if it was executed
> + * normally as part of the instruction sequence, except for the instruction
> + * address and the instruction-length code.
> + */
> +
> +#include <libcflat.h>
> +
> +/*
> + * Accesses to the operand of execute-type instructions are instruction fetches.
> + * Minimum alignment is two, since the relative offset is specified by number of halfwords.
> + */
> +asm (  ".pushsection .text.exrl_targets,\"x\"\n"
> +"	.balign	2\n"
> +"	.popsection\n"
> +);
> +
> +/*
> + * BRANCH AND SAVE, register register variant.
> + * Saves the next instruction address (address from PSW + length of instruction)
> + * to the first register. No branch is taken in this test, because 0 is
> + * specified as target.
> + * BASR does *not* perform a relative address calculation with an intermediate.
> + */
> +static void test_basr(void)
> +{
> +	uint64_t ret_addr, after_ex;
> +
> +	report_prefix_push("BASR");
> +	asm volatile ( ".pushsection .text.exrl_targets\n"
> +		"0:	basr	%[ret_addr],0\n"
> +		"	.popsection\n"
> +
> +		"	larl	%[after_ex],1f\n"
> +		"	exrl	0,0b\n"
> +		"1:\n"
> +		: [ret_addr] "=d" (ret_addr),
> +		  [after_ex] "=d" (after_ex)
> +	);
> +
> +	report(ret_addr == after_ex, "return address after EX");
> +	report_prefix_pop();
> +}
> +
> +/*
> + * BRANCH RELATIVE AND SAVE.
> + * According to PoP (Branch-Address Generation), the address calculated relative
> + * to the instruction address is relative to BRAS when it is the target of an
> + * execute-type instruction, not relative to the execute-type instruction.
> + */
> +static void test_bras(void)
> +{
> +	uint64_t after_target, ret_addr, after_ex, branch_addr;
> +
> +	report_prefix_push("BRAS");
> +	asm volatile ( ".pushsection .text.exrl_targets\n"
> +		"0:	bras	%[ret_addr],1f\n"
> +		"	nopr	%%r7\n"
> +		"1:	larl	%[branch_addr],0\n"
> +		"	j	4f\n"
> +		"	.popsection\n"
> +
> +		"	larl	%[after_target],1b\n"
> +		"	larl	%[after_ex],3f\n"
> +		"2:	exrl	0,0b\n"
> +/*
> + * In case the address calculation is correct, we jump by the relative offset 1b-0b from 0b to 1b.
> + * In case the address calculation is relative to the exrl (i.e. a test failure),
> + * put a valid instruction at the same relative offset from the exrl, so the test continues in a
> + * controlled manner.
> + */
> +		"3:	larl	%[branch_addr],0\n"
> +		"4:\n"
> +
> +		"	.if (1b - 0b) != (3b - 2b)\n"
> +		"	.error	\"right and wrong target must have same offset\"\n"
> +		"	.endif\n"

FWIW, this is failing with Clang 15 for me:

s390x/ex.c:81:4: error: expected absolute expression
                 "       .if (1b - 0b) != (3b - 2b)\n"
                  ^
<inline asm>:12:6: note: instantiated into assembly here
         .if (1b - 0b) != (3b - 2b)
             ^
s390x/ex.c:82:4: error: right and wrong target must have same offset
                 "       .error  \"right and wrong target must have same 
offset\"\n"
                  ^
<inline asm>:13:2: note: instantiated into assembly here
         .error  "right and wrong target must have same offset"
         ^
2 errors generated.

Any easy ways to fix this?

  Thomas


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions
  2023-04-04 14:15   ` Thomas Huth
@ 2023-04-04 14:54     ` Nina Schoetterl-Glausch
  2023-04-04 15:05       ` Thomas Huth
  0 siblings, 1 reply; 22+ messages in thread
From: Nina Schoetterl-Glausch @ 2023-04-04 14:54 UTC (permalink / raw)
  To: Thomas Huth, Nico Boehr, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda

On Tue, 2023-04-04 at 16:15 +0200, Thomas Huth wrote:
> On 04/04/2023 13.36, Nico Boehr wrote:
> > From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> > 
> > Test the instruction address used by targets of an execute instruction.
> > When the target instruction calculates a relative address, the result is
> > relative to the target instruction, not the execute instruction.
> > 
> > Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
> > Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> > Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > Link: https://lore.kernel.org/r/20230317112339.774659-1-nsg@linux.ibm.com
> > Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> > ---
> >   s390x/Makefile      |   1 +
> >   s390x/ex.c          | 188 ++++++++++++++++++++++++++++++++++++++++++++
> >   s390x/unittests.cfg |   3 +
> >   .gitlab-ci.yml      |   1 +
> >   4 files changed, 193 insertions(+)
> >   create mode 100644 s390x/ex.c
> > 
> > diff --git a/s390x/Makefile b/s390x/Makefile
> > index ab146eb..a80db53 100644
> > --- a/s390x/Makefile
> > +++ b/s390x/Makefile
> > @@ -39,6 +39,7 @@ tests += $(TEST_DIR)/panic-loop-extint.elf
> >   tests += $(TEST_DIR)/panic-loop-pgm.elf
> >   tests += $(TEST_DIR)/migration-sck.elf
> >   tests += $(TEST_DIR)/exittime.elf
> > +tests += $(TEST_DIR)/ex.elf
> >   
> >   pv-tests += $(TEST_DIR)/pv-diags.elf
> >   
> > diff --git a/s390x/ex.c b/s390x/ex.c
> > new file mode 100644
> > index 0000000..dbd8030
> > --- /dev/null
> > +++ b/s390x/ex.c
> > @@ -0,0 +1,188 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright IBM Corp. 2023
> > + *
> > + * Test EXECUTE (RELATIVE LONG).
> > + * These instructions execute a target instruction. The target instruction is formed
> > + * by reading an instruction from memory and optionally modifying some of its bits.
> > + * The execution of the target instruction is the same as if it was executed
> > + * normally as part of the instruction sequence, except for the instruction
> > + * address and the instruction-length code.
> > + */
> > +
> > +#include <libcflat.h>
> > +
> > +/*
> > + * Accesses to the operand of execute-type instructions are instruction fetches.
> > + * Minimum alignment is two, since the relative offset is specified by number of halfwords.
> > + */
> > +asm (  ".pushsection .text.exrl_targets,\"x\"\n"
> > +"	.balign	2\n"
> > +"	.popsection\n"
> > +);
> > +
> > +/*
> > + * BRANCH AND SAVE, register register variant.
> > + * Saves the next instruction address (address from PSW + length of instruction)
> > + * to the first register. No branch is taken in this test, because 0 is
> > + * specified as target.
> > + * BASR does *not* perform a relative address calculation with an intermediate.
> > + */
> > +static void test_basr(void)
> > +{
> > +	uint64_t ret_addr, after_ex;
> > +
> > +	report_prefix_push("BASR");
> > +	asm volatile ( ".pushsection .text.exrl_targets\n"
> > +		"0:	basr	%[ret_addr],0\n"
> > +		"	.popsection\n"
> > +
> > +		"	larl	%[after_ex],1f\n"
> > +		"	exrl	0,0b\n"
> > +		"1:\n"
> > +		: [ret_addr] "=d" (ret_addr),
> > +		  [after_ex] "=d" (after_ex)
> > +	);
> > +
> > +	report(ret_addr == after_ex, "return address after EX");
> > +	report_prefix_pop();
> > +}
> > +
> > +/*
> > + * BRANCH RELATIVE AND SAVE.
> > + * According to PoP (Branch-Address Generation), the address calculated relative
> > + * to the instruction address is relative to BRAS when it is the target of an
> > + * execute-type instruction, not relative to the execute-type instruction.
> > + */
> > +static void test_bras(void)
> > +{
> > +	uint64_t after_target, ret_addr, after_ex, branch_addr;
> > +
> > +	report_prefix_push("BRAS");
> > +	asm volatile ( ".pushsection .text.exrl_targets\n"
> > +		"0:	bras	%[ret_addr],1f\n"
> > +		"	nopr	%%r7\n"
> > +		"1:	larl	%[branch_addr],0\n"
> > +		"	j	4f\n"
> > +		"	.popsection\n"
> > +
> > +		"	larl	%[after_target],1b\n"
> > +		"	larl	%[after_ex],3f\n"
> > +		"2:	exrl	0,0b\n"
> > +/*
> > + * In case the address calculation is correct, we jump by the relative offset 1b-0b from 0b to 1b.
> > + * In case the address calculation is relative to the exrl (i.e. a test failure),
> > + * put a valid instruction at the same relative offset from the exrl, so the test continues in a
> > + * controlled manner.
> > + */
> > +		"3:	larl	%[branch_addr],0\n"
> > +		"4:\n"
> > +
> > +		"	.if (1b - 0b) != (3b - 2b)\n"
> > +		"	.error	\"right and wrong target must have same offset\"\n"
> > +		"	.endif\n"
> 
> FWIW, this is failing with Clang 15 for me:
> 
> s390x/ex.c:81:4: error: expected absolute expression
>                  "       .if (1b - 0b) != (3b - 2b)\n"
>                   ^
> <inline asm>:12:6: note: instantiated into assembly here
>          .if (1b - 0b) != (3b - 2b)

Seems gcc is smarter here than clang.

>              ^
> s390x/ex.c:82:4: error: right and wrong target must have same offset
>                  "       .error  \"right and wrong target must have same 
> offset\"\n"
>                   ^
> <inline asm>:13:2: note: instantiated into assembly here
>          .error  "right and wrong target must have same offset"
>          ^
> 2 errors generated.
> 
> Any easy ways to fix this?

Just deleting that .if block would work, it's basically only a static assert.
What do you think?
Other than that I can't think of anything.

> 
>   Thomas
> 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions
  2023-04-04 14:54     ` Nina Schoetterl-Glausch
@ 2023-04-04 15:05       ` Thomas Huth
  2023-04-04 15:33         ` Nina Schoetterl-Glausch
  2023-04-04 17:12         ` Nico Boehr
  0 siblings, 2 replies; 22+ messages in thread
From: Thomas Huth @ 2023-04-04 15:05 UTC (permalink / raw)
  To: Nina Schoetterl-Glausch, Nico Boehr, pbonzini, andrew.jones
  Cc: kvm, frankja, imbrenda

On 04/04/2023 16.54, Nina Schoetterl-Glausch wrote:
> On Tue, 2023-04-04 at 16:15 +0200, Thomas Huth wrote:
>> On 04/04/2023 13.36, Nico Boehr wrote:
>>> From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
>>>
>>> Test the instruction address used by targets of an execute instruction.
>>> When the target instruction calculates a relative address, the result is
>>> relative to the target instruction, not the execute instruction.
>>>
>>> Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
>>> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
>>> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
>>> Link: https://lore.kernel.org/r/20230317112339.774659-1-nsg@linux.ibm.com
>>> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
>>> ---
>>>    s390x/Makefile      |   1 +
>>>    s390x/ex.c          | 188 ++++++++++++++++++++++++++++++++++++++++++++
>>>    s390x/unittests.cfg |   3 +
>>>    .gitlab-ci.yml      |   1 +
>>>    4 files changed, 193 insertions(+)
>>>    create mode 100644 s390x/ex.c
>>>
>>> diff --git a/s390x/Makefile b/s390x/Makefile
>>> index ab146eb..a80db53 100644
>>> --- a/s390x/Makefile
>>> +++ b/s390x/Makefile
>>> @@ -39,6 +39,7 @@ tests += $(TEST_DIR)/panic-loop-extint.elf
>>>    tests += $(TEST_DIR)/panic-loop-pgm.elf
>>>    tests += $(TEST_DIR)/migration-sck.elf
>>>    tests += $(TEST_DIR)/exittime.elf
>>> +tests += $(TEST_DIR)/ex.elf
>>>    
>>>    pv-tests += $(TEST_DIR)/pv-diags.elf
>>>    
>>> diff --git a/s390x/ex.c b/s390x/ex.c
>>> new file mode 100644
>>> index 0000000..dbd8030
>>> --- /dev/null
>>> +++ b/s390x/ex.c
>>> @@ -0,0 +1,188 @@
>>> +// SPDX-License-Identifier: GPL-2.0-only
>>> +/*
>>> + * Copyright IBM Corp. 2023
>>> + *
>>> + * Test EXECUTE (RELATIVE LONG).
>>> + * These instructions execute a target instruction. The target instruction is formed
>>> + * by reading an instruction from memory and optionally modifying some of its bits.
>>> + * The execution of the target instruction is the same as if it was executed
>>> + * normally as part of the instruction sequence, except for the instruction
>>> + * address and the instruction-length code.
>>> + */
>>> +
>>> +#include <libcflat.h>
>>> +
>>> +/*
>>> + * Accesses to the operand of execute-type instructions are instruction fetches.
>>> + * Minimum alignment is two, since the relative offset is specified by number of halfwords.
>>> + */
>>> +asm (  ".pushsection .text.exrl_targets,\"x\"\n"
>>> +"	.balign	2\n"
>>> +"	.popsection\n"
>>> +);
>>> +
>>> +/*
>>> + * BRANCH AND SAVE, register register variant.
>>> + * Saves the next instruction address (address from PSW + length of instruction)
>>> + * to the first register. No branch is taken in this test, because 0 is
>>> + * specified as target.
>>> + * BASR does *not* perform a relative address calculation with an intermediate.
>>> + */
>>> +static void test_basr(void)
>>> +{
>>> +	uint64_t ret_addr, after_ex;
>>> +
>>> +	report_prefix_push("BASR");
>>> +	asm volatile ( ".pushsection .text.exrl_targets\n"
>>> +		"0:	basr	%[ret_addr],0\n"
>>> +		"	.popsection\n"
>>> +
>>> +		"	larl	%[after_ex],1f\n"
>>> +		"	exrl	0,0b\n"
>>> +		"1:\n"
>>> +		: [ret_addr] "=d" (ret_addr),
>>> +		  [after_ex] "=d" (after_ex)
>>> +	);
>>> +
>>> +	report(ret_addr == after_ex, "return address after EX");
>>> +	report_prefix_pop();
>>> +}
>>> +
>>> +/*
>>> + * BRANCH RELATIVE AND SAVE.
>>> + * According to PoP (Branch-Address Generation), the address calculated relative
>>> + * to the instruction address is relative to BRAS when it is the target of an
>>> + * execute-type instruction, not relative to the execute-type instruction.
>>> + */
>>> +static void test_bras(void)
>>> +{
>>> +	uint64_t after_target, ret_addr, after_ex, branch_addr;
>>> +
>>> +	report_prefix_push("BRAS");
>>> +	asm volatile ( ".pushsection .text.exrl_targets\n"
>>> +		"0:	bras	%[ret_addr],1f\n"
>>> +		"	nopr	%%r7\n"
>>> +		"1:	larl	%[branch_addr],0\n"
>>> +		"	j	4f\n"
>>> +		"	.popsection\n"
>>> +
>>> +		"	larl	%[after_target],1b\n"
>>> +		"	larl	%[after_ex],3f\n"
>>> +		"2:	exrl	0,0b\n"
>>> +/*
>>> + * In case the address calculation is correct, we jump by the relative offset 1b-0b from 0b to 1b.
>>> + * In case the address calculation is relative to the exrl (i.e. a test failure),
>>> + * put a valid instruction at the same relative offset from the exrl, so the test continues in a
>>> + * controlled manner.
>>> + */
>>> +		"3:	larl	%[branch_addr],0\n"
>>> +		"4:\n"
>>> +
>>> +		"	.if (1b - 0b) != (3b - 2b)\n"
>>> +		"	.error	\"right and wrong target must have same offset\"\n"
>>> +		"	.endif\n"
>>
>> FWIW, this is failing with Clang 15 for me:
>>
>> s390x/ex.c:81:4: error: expected absolute expression
>>                   "       .if (1b - 0b) != (3b - 2b)\n"
>>                    ^
>> <inline asm>:12:6: note: instantiated into assembly here
>>           .if (1b - 0b) != (3b - 2b)
> 
> Seems gcc is smarter here than clang.

Yeah, the assembler from clang is quite a bit behind on s390x ... in the 
past I was only able to compile the k-u-t with Clang when using the 
"-no-integrated-as" option ... but at least in the most recent version it 
seems to have caught up now enough to be very close to compile it with the 
built-in assembler, so it would be great to get this problem here fixed 
somehow, too...

> Just deleting that .if block would work, it's basically only a static assert.
> What do you think?
> Other than that I can't think of anything.

Yes, either delete it ... or maybe you could return the two values (1b - 0b) 
and (3b - 2b) as output from the asm statement and do an assert() in C instead?

  Thomas


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions
  2023-04-04 15:05       ` Thomas Huth
@ 2023-04-04 15:33         ` Nina Schoetterl-Glausch
  2023-04-04 17:12         ` Nico Boehr
  1 sibling, 0 replies; 22+ messages in thread
From: Nina Schoetterl-Glausch @ 2023-04-04 15:33 UTC (permalink / raw)
  To: Thomas Huth, Nico Boehr, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda

On Tue, 2023-04-04 at 17:05 +0200, Thomas Huth wrote:
> On 04/04/2023 16.54, Nina Schoetterl-Glausch wrote:
> > On Tue, 2023-04-04 at 16:15 +0200, Thomas Huth wrote:
> > > On 04/04/2023 13.36, Nico Boehr wrote:
> > > > From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> > > > 
> > > > Test the instruction address used by targets of an execute instruction.
> > > > When the target instruction calculates a relative address, the result is
> > > > relative to the target instruction, not the execute instruction.
> > > > 
> > > > Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
> > > > Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> > > > Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > > > Link: https://lore.kernel.org/r/20230317112339.774659-1-nsg@linux.ibm.com
> > > > Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> > > > ---
> > > >    s390x/Makefile      |   1 +
> > > >    s390x/ex.c          | 188 ++++++++++++++++++++++++++++++++++++++++++++
> > > >    s390x/unittests.cfg |   3 +
> > > >    .gitlab-ci.yml      |   1 +
> > > >    4 files changed, 193 insertions(+)
> > > >    create mode 100644 s390x/ex.c
> > > > 
> > > > diff --git a/s390x/Makefile b/s390x/Makefile
> > > > index ab146eb..a80db53 100644
> > > > --- a/s390x/Makefile
> > > > +++ b/s390x/Makefile
> > > > @@ -39,6 +39,7 @@ tests += $(TEST_DIR)/panic-loop-extint.elf
> > > >    tests += $(TEST_DIR)/panic-loop-pgm.elf
> > > >    tests += $(TEST_DIR)/migration-sck.elf
> > > >    tests += $(TEST_DIR)/exittime.elf
> > > > +tests += $(TEST_DIR)/ex.elf
> > > >    
> > > >    pv-tests += $(TEST_DIR)/pv-diags.elf
> > > >    
> > > > diff --git a/s390x/ex.c b/s390x/ex.c
> > > > new file mode 100644
> > > > index 0000000..dbd8030
> > > > --- /dev/null
> > > > +++ b/s390x/ex.c
> > > > @@ -0,0 +1,188 @@
> > > > +// SPDX-License-Identifier: GPL-2.0-only
> > > > +/*
> > > > + * Copyright IBM Corp. 2023
> > > > + *
> > > > + * Test EXECUTE (RELATIVE LONG).
> > > > + * These instructions execute a target instruction. The target instruction is formed
> > > > + * by reading an instruction from memory and optionally modifying some of its bits.
> > > > + * The execution of the target instruction is the same as if it was executed
> > > > + * normally as part of the instruction sequence, except for the instruction
> > > > + * address and the instruction-length code.
> > > > + */
> > > > +
> > > > +#include <libcflat.h>
> > > > +
> > > > +/*
> > > > + * Accesses to the operand of execute-type instructions are instruction fetches.
> > > > + * Minimum alignment is two, since the relative offset is specified by number of halfwords.
> > > > + */
> > > > +asm (  ".pushsection .text.exrl_targets,\"x\"\n"
> > > > +"	.balign	2\n"
> > > > +"	.popsection\n"
> > > > +);
> > > > +
> > > > +/*
> > > > + * BRANCH AND SAVE, register register variant.
> > > > + * Saves the next instruction address (address from PSW + length of instruction)
> > > > + * to the first register. No branch is taken in this test, because 0 is
> > > > + * specified as target.
> > > > + * BASR does *not* perform a relative address calculation with an intermediate.
> > > > + */
> > > > +static void test_basr(void)
> > > > +{
> > > > +	uint64_t ret_addr, after_ex;
> > > > +
> > > > +	report_prefix_push("BASR");
> > > > +	asm volatile ( ".pushsection .text.exrl_targets\n"
> > > > +		"0:	basr	%[ret_addr],0\n"
> > > > +		"	.popsection\n"
> > > > +
> > > > +		"	larl	%[after_ex],1f\n"
> > > > +		"	exrl	0,0b\n"
> > > > +		"1:\n"
> > > > +		: [ret_addr] "=d" (ret_addr),
> > > > +		  [after_ex] "=d" (after_ex)
> > > > +	);
> > > > +
> > > > +	report(ret_addr == after_ex, "return address after EX");
> > > > +	report_prefix_pop();
> > > > +}
> > > > +
> > > > +/*
> > > > + * BRANCH RELATIVE AND SAVE.
> > > > + * According to PoP (Branch-Address Generation), the address calculated relative
> > > > + * to the instruction address is relative to BRAS when it is the target of an
> > > > + * execute-type instruction, not relative to the execute-type instruction.
> > > > + */
> > > > +static void test_bras(void)
> > > > +{
> > > > +	uint64_t after_target, ret_addr, after_ex, branch_addr;
> > > > +
> > > > +	report_prefix_push("BRAS");
> > > > +	asm volatile ( ".pushsection .text.exrl_targets\n"
> > > > +		"0:	bras	%[ret_addr],1f\n"
> > > > +		"	nopr	%%r7\n"
> > > > +		"1:	larl	%[branch_addr],0\n"
> > > > +		"	j	4f\n"
> > > > +		"	.popsection\n"
> > > > +
> > > > +		"	larl	%[after_target],1b\n"
> > > > +		"	larl	%[after_ex],3f\n"
> > > > +		"2:	exrl	0,0b\n"
> > > > +/*
> > > > + * In case the address calculation is correct, we jump by the relative offset 1b-0b from 0b to 1b.
> > > > + * In case the address calculation is relative to the exrl (i.e. a test failure),
> > > > + * put a valid instruction at the same relative offset from the exrl, so the test continues in a
> > > > + * controlled manner.
> > > > + */
> > > > +		"3:	larl	%[branch_addr],0\n"
> > > > +		"4:\n"
> > > > +
> > > > +		"	.if (1b - 0b) != (3b - 2b)\n"
> > > > +		"	.error	\"right and wrong target must have same offset\"\n"
> > > > +		"	.endif\n"
> > > 
> > > FWIW, this is failing with Clang 15 for me:
> > > 
> > > s390x/ex.c:81:4: error: expected absolute expression
> > >                   "       .if (1b - 0b) != (3b - 2b)\n"
> > >                    ^
> > > <inline asm>:12:6: note: instantiated into assembly here
> > >           .if (1b - 0b) != (3b - 2b)
> > 
> > Seems gcc is smarter here than clang.
> 
> Yeah, the assembler from clang is quite a bit behind on s390x ... in the 
> past I was only able to compile the k-u-t with Clang when using the 
> "-no-integrated-as" option ... but at least in the most recent version it 
> seems to have caught up now enough to be very close to compile it with the 
> built-in assembler, so it would be great to get this problem here fixed 
> somehow, too...
> 
> > Just deleting that .if block would work, it's basically only a static assert.
> > What do you think?
> > Other than that I can't think of anything.
> 
> Yes, either delete it ... or maybe you could return the two values (1b - 0b) 
> and (3b - 2b) as output from the asm statement and do an assert() in C instead?

No, that's too late, it'd crash before if the invariant doesn't hold.
Could do a runtime check in asm but I don't think it's worth it. So lets go for deletion.

Do you wan't to fix it up when pulling or do you want a new version and pull request?
> 
>   Thomas
> 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions
  2023-04-04 15:05       ` Thomas Huth
  2023-04-04 15:33         ` Nina Schoetterl-Glausch
@ 2023-04-04 17:12         ` Nico Boehr
  2023-04-04 18:06           ` Nina Schoetterl-Glausch
  1 sibling, 1 reply; 22+ messages in thread
From: Nico Boehr @ 2023-04-04 17:12 UTC (permalink / raw)
  To: Nina Schoetterl-Glausch, Thomas Huth, andrew.jones, pbonzini
  Cc: kvm, frankja, imbrenda

Quoting Thomas Huth (2023-04-04 17:05:02)
[...]
> >> FWIW, this is failing with Clang 15 for me:
> >>
> >> s390x/ex.c:81:4: error: expected absolute expression
> >>                   "       .if (1b - 0b) != (3b - 2b)\n"
> >>                    ^
> >> <inline asm>:12:6: note: instantiated into assembly here
> >>           .if (1b - 0b) != (3b - 2b)
> > 
> > Seems gcc is smarter here than clang.
> 
> Yeah, the assembler from clang is quite a bit behind on s390x ... in the 
> past I was only able to compile the k-u-t with Clang when using the 
> "-no-integrated-as" option ... but at least in the most recent version it 
> seems to have caught up now enough to be very close to compile it with the 
> built-in assembler, so it would be great to get this problem here fixed 
> somehow, too...

Bringing up another option: Can we maybe guard this section from Clang so we still have the assertion when compiling with GCC?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions
  2023-04-04 17:12         ` Nico Boehr
@ 2023-04-04 18:06           ` Nina Schoetterl-Glausch
  2023-04-05  8:05             ` Thomas Huth
  0 siblings, 1 reply; 22+ messages in thread
From: Nina Schoetterl-Glausch @ 2023-04-04 18:06 UTC (permalink / raw)
  To: Nico Boehr, Thomas Huth, andrew.jones, pbonzini; +Cc: kvm, frankja, imbrenda

On Tue, 2023-04-04 at 19:12 +0200, Nico Boehr wrote:
> Quoting Thomas Huth (2023-04-04 17:05:02)
> [...]
> > > > FWIW, this is failing with Clang 15 for me:
> > > > 
> > > > s390x/ex.c:81:4: error: expected absolute expression
> > > >                   "       .if (1b - 0b) != (3b - 2b)\n"
> > > >                    ^
> > > > <inline asm>:12:6: note: instantiated into assembly here
> > > >           .if (1b - 0b) != (3b - 2b)
> > > 
> > > Seems gcc is smarter here than clang.
> > 
> > Yeah, the assembler from clang is quite a bit behind on s390x ... in the 
> > past I was only able to compile the k-u-t with Clang when using the 
> > "-no-integrated-as" option ... but at least in the most recent version it 
> > seems to have caught up now enough to be very close to compile it with the 
> > built-in assembler, so it would be great to get this problem here fixed 
> > somehow, too...
> 
> Bringing up another option: Can we maybe guard this section from Clang so we still have the assertion when compiling with GCC?

I considered this, but only from the asm, where I don't think it's possible.
But putting #ifndef __clang__ around it works. Until you compile with gcc and assemble with clang.
Not something we need to care about IMO.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions
  2023-04-04 18:06           ` Nina Schoetterl-Glausch
@ 2023-04-05  8:05             ` Thomas Huth
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Huth @ 2023-04-05  8:05 UTC (permalink / raw)
  To: Nina Schoetterl-Glausch, Nico Boehr, andrew.jones, pbonzini
  Cc: kvm, frankja, imbrenda

On 04/04/2023 20.06, Nina Schoetterl-Glausch wrote:
> On Tue, 2023-04-04 at 19:12 +0200, Nico Boehr wrote:
>> Quoting Thomas Huth (2023-04-04 17:05:02)
>> [...]
>>>>> FWIW, this is failing with Clang 15 for me:
>>>>>
>>>>> s390x/ex.c:81:4: error: expected absolute expression
>>>>>                    "       .if (1b - 0b) != (3b - 2b)\n"
>>>>>                     ^
>>>>> <inline asm>:12:6: note: instantiated into assembly here
>>>>>            .if (1b - 0b) != (3b - 2b)
>>>>
>>>> Seems gcc is smarter here than clang.
>>>
>>> Yeah, the assembler from clang is quite a bit behind on s390x ... in the
>>> past I was only able to compile the k-u-t with Clang when using the
>>> "-no-integrated-as" option ... but at least in the most recent version it
>>> seems to have caught up now enough to be very close to compile it with the
>>> built-in assembler, so it would be great to get this problem here fixed
>>> somehow, too...
>>
>> Bringing up another option: Can we maybe guard this section from Clang so we still have the assertion when compiling with GCC?
> 
> I considered this, but only from the asm, where I don't think it's possible.
> But putting #ifndef __clang__ around it works. Until you compile with gcc and assemble with clang.
> Not something we need to care about IMO.

Right. So if the #ifndef works, let's go with that! Nico, could you fix it 
up in the pull request?

  Thanks,
   Thomas


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-04-05  8:06 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-04 11:36 [kvm-unit-tests GIT PULL v2 00/14] s390x: new maintainer, refactor linker scripts, tests for misalignments, execute-type instructions and vSIE epdx Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 01/14] .gitignore: ignore `s390x/comm.key` file Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 02/14] s390x/Makefile: simplify `%.hdr` target rules Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 03/14] s390x/Makefile: fix `*.gbin` target dependencies Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 04/14] s390x/Makefile: refactor CPPFLAGS Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 05/14] s390x: use preprocessor for linker script generation Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 06/14] s390x: define a macro for the stack frame size Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 07/14] lib/linux/const.h: test for `__ASSEMBLER__` as well Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 08/14] s390x/spec_ex: Use PSW macro Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 09/14] s390x/spec_ex: Add test introducing odd address into PSW Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 10/14] s390x/spec_ex: Add test of EXECUTE with odd target address Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 11/14] s390x: Add tests for execute-type instructions Nico Boehr
2023-04-04 14:15   ` Thomas Huth
2023-04-04 14:54     ` Nina Schoetterl-Glausch
2023-04-04 15:05       ` Thomas Huth
2023-04-04 15:33         ` Nina Schoetterl-Glausch
2023-04-04 17:12         ` Nico Boehr
2023-04-04 18:06           ` Nina Schoetterl-Glausch
2023-04-05  8:05             ` Thomas Huth
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 12/14] s390x: spec_ex: Add test for misaligned load Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 13/14] MAINTAINERS: Add Nico as s390x Maintainer and make Thomas reviewer Nico Boehr
2023-04-04 11:36 ` [kvm-unit-tests GIT PULL v2 14/14] s390x: sie: Test whether the epoch extension field is working as expected Nico Boehr

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.