Skip to contentSkip to conversation

s390x: Add Protected VM support

RFC Superseded Marc Hartmayer 3 participants 20 messages Aug 12, 2020 – Aug 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover s390x: Add Protected VM support

Add support for Protected Virtual Machine (PVM) tests. For starting a PVM guest we must be able to generate a PVM image by using the genprotimg tool from the s390-tools collection. This requires the ability to pass a machine-specific host-key document, so the option --host-key-document is added to the configure script.

Sorry it took so long to send the second version :/

For everybody's convenience there is a branch:
https://gitlab.com/mhartmay/kvm-unit-tests/-/tree/test_alternative

Changelog:
RFC v1 -> RFC v2:
+ Remove pv_support option (Janosch, David)
+ Add some preliminary patches:
- move "testname guard"
- add support for architecture dependent functions
+ Add support for specifying a parmline file for the PV image generation. This is necessary for the selftest because the kernel cmdline set on the QEMU command line is ignored for PV guests

Marc Hartmayer (4):
common.bash: run cmd only if a test case was found
scripts: add support for architecture dependent functions run_tests/mkstandalone: add arch dependent function to
for_each_unittest
s390x: add Protected VM support

 README.md               |  3 ++-
 configure               |  8 ++++++++
 run_tests.sh            |  5 +----
 s390x/Makefile          | 17 +++++++++++++++--
 s390x/selftest.parmfile |  1 +
 s390x/unittests.cfg     |  1 +
 scripts/common.bash     | 26 ++++++++++++++++++++++++--
 scripts/mkstandalone.sh |  6 +-----
 scripts/s390x/func.bash | 18 ++++++++++++++++++
 9 files changed, 71 insertions(+), 14 deletions(-)
 create mode 100644 s390x/selftest.parmfile
 create mode 100644 scripts/s390x/func.bash
Signature · 1 line
2.25.4
#1 lore raw

RFC v2 1/4 common.bash: run `cmd` only if a test case was found

It's only useful to run cmd in for_each_unittest if a test case was found. This change allows us to remove the guards from the functions run_task and mkstandalone.

---
 run_tests.sh            | 3 ---
 scripts/common.bash     | 8 ++++++--
 scripts/mkstandalone.sh | 4 ----
 3 files changed, 6 insertions(+), 9 deletions(-)
run_tests.sh +0 -3
index 01e36dcfa06e..24aba9cc3a98 100755
@@ -126,9 +126,6 @@ RUNTIME_log_stdout () {
 function run_task()
 {
 	local testname="$1"
-	if [ -z "$testname" ]; then
-		return
-	fi
 
 	while (( $(jobs | wc -l) == $unittest_run_queues )); do
 		# wait for any background test to finish
scripts/common.bash +6 -2
index 9a6ebbd7f287..96655c9ffd1f 100644
@@ -17,7 +17,9 @@ function for_each_unittest()
 
 	while read -r -u $fd line; do
 		if [[ "$line" =~ ^\[(.*)\]$ ]]; then
-			"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+			if [ -n "${testname}" ]; then
+				"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+			fi
 			testname=${BASH_REMATCH[1]}
 			smp=1
 			kernel=""
@@ -45,6 +47,8 @@ function for_each_unittest()
 			timeout=${BASH_REMATCH[1]}
 		fi
 	done
-	"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+	if [ -n "${testname}" ]; then
+		"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+	fi
 	exec {fd}<&-
 }
scripts/mkstandalone.sh +0 -4
index 9d506cc95072..cefdec30cb33 100755
@@ -83,10 +83,6 @@ function mkstandalone()
 {
 	local testname="$1"
 
-	if [ -z "$testname" ]; then
-		return
-	fi
-
 	if [ -n "$one_testname" ] && [ "$testname" != "$one_testname" ]; then
 		return
 	fi
Signature · 1 line
2.25.4
Reviewed-by on v2 1/4
#2 lore raw

Re: [kvm-unit-tests RFC v2 1/4] common.bash: run `cmd` only if a test case was found

Quoted 11 lines · Marc Hartmayer

It's only useful to run cmd in for_each_unittest if a test case was found. This change allows us to remove the guards from the functions run_task and mkstandalone.

---
 run_tests.sh            | 3 ---
 scripts/common.bash     | 8 ++++++--
 scripts/mkstandalone.sh | 4 ----
 3 files changed, 6 insertions(+), 9 deletions(-)
#3 lore raw

Re: [kvm-unit-tests RFC v2 1/4] common.bash: run `cmd` only if a test case was found

Quoted 13 lines · Andrew Jones
Quoted 11 lines · Marc Hartmayer

It's only useful to run cmd in for_each_unittest if a test case was found. This change allows us to remove the guards from the functions run_task and mkstandalone.

---
 run_tests.sh            | 3 ---
 scripts/common.bash     | 8 ++++++--
 scripts/mkstandalone.sh | 4 ----
 3 files changed, 6 insertions(+), 9 deletions(-)
Quoted 2 lines

Thanks.

Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#4 lore raw

RFC v2 2/4 scripts: add support for architecture dependent functions

In reply to Marc Hartmayer

This is necessary to keep architecture dependent code separate from common code.

---
 README.md           | 3 ++-
 scripts/common.bash | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
README.md +2 -1
index 48be206c6db1..24d4bdaaee0d 100644
@@ -134,7 +134,8 @@ all unit tests.
 ## Directory structure
 
     .:                  configure script, top-level Makefile, and run_tests.sh
-    ./scripts:          helper scripts for building and running tests
+    ./scripts:          general architecture neutral helper scripts for building and running tests
+    ./scripts/<ARCH>:   architecture dependent helper scripts for building and running tests
     ./lib:              general architecture neutral services for the tests
     ./lib/<ARCH>:       architecture dependent services for the tests
     ./<ARCH>:           the sources of the tests and the created objects/images
scripts/common.bash +5 -0
index 96655c9ffd1f..f9c15fd304bd 100644
@@ -52,3 +52,8 @@ function for_each_unittest()
 	fi
 	exec {fd}<&-
 }
+
+ARCH_FUNC=scripts/${ARCH}/func.bash
+if [ -f "${ARCH_FUNC}" ]; then
+	source "${ARCH_FUNC}"
+fi
Signature · 1 line
2.25.4
#5 lore raw

Re: [kvm-unit-tests RFC v2 2/4] scripts: add support for architecture dependent functions

Quoted 28 lines · Marc Hartmayer

This is necessary to keep architecture dependent code separate from common code.

---
 README.md           | 3 ++-
 scripts/common.bash | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
README.md +2 -1
index 48be206c6db1..24d4bdaaee0d 100644
@@ -134,7 +134,8 @@ all unit tests.
 ## Directory structure
 
     .:                  configure script, top-level Makefile, and run_tests.sh
-    ./scripts:          helper scripts for building and running tests
+    ./scripts:          general architecture neutral helper scripts for building and running tests
+    ./scripts/<ARCH>:   architecture dependent helper scripts for building and running tests
     ./lib:              general architecture neutral services for the tests
     ./lib/<ARCH>:       architecture dependent services for the tests
     ./<ARCH>:           the sources of the tests and the created objects/images
scripts/common.bash +0 -0
index 96655c9ffd1f..f9c15fd304bd 100644

scripts/common.bash function for_each_unittest() · line 56

Quoted 5 lines
scripts/common.bash +2 -0
@@ -52,3 +52,8 @@ function for_each_unittest()
 	fi
 	exec {fd}<&-
 }
+
+ARCH_FUNC=scripts/${ARCH}/func.bash

The use of ${ARCH} adds a dependency on config.mak. It works now because in the two places we source common.bash we source config.mak first, but I'd prefer we make that dependency explicit. We could probably just source it again from this file.

Thanks,
drew

Quoted 6 lines
scripts/common.bash +3 -0
+if [ -f "${ARCH_FUNC}" ]; then
+	source "${ARCH_FUNC}"
+fi
Signature · 1 line
2.25.4
#6 lore raw

Re: [kvm-unit-tests RFC v2 2/4] scripts: add support for architecture dependent functions

Quoted 29 lines · Andrew Jones
Quoted 28 lines · Marc Hartmayer

This is necessary to keep architecture dependent code separate from common code.

---
 README.md           | 3 ++-
 scripts/common.bash | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
README.md +2 -1
index 48be206c6db1..24d4bdaaee0d 100644
@@ -134,7 +134,8 @@ all unit tests.
 ## Directory structure
 
     .:                  configure script, top-level Makefile, and run_tests.sh
-    ./scripts:          helper scripts for building and running tests
+    ./scripts:          general architecture neutral helper scripts for building and running tests
+    ./scripts/<ARCH>:   architecture dependent helper scripts for building and running tests
     ./lib:              general architecture neutral services for the tests
     ./lib/<ARCH>:       architecture dependent services for the tests
     ./<ARCH>:           the sources of the tests and the created objects/images
scripts/common.bash +0 -0
index 96655c9ffd1f..f9c15fd304bd 100644
@@ -52,3 +52,8 @@ function for_each_unittest()
Quoted 8 lines

scripts/common.bash function for_each_unittest() · line 56

Quoted 5 lines
scripts/common.bash +2 -0
 	fi
 	exec {fd}<&-
 }
+
+ARCH_FUNC=scripts/${ARCH}/func.bash

The use of ${ARCH} adds a dependency on config.mak. It works now because in the two places we source common.bash we source config.mak first

Yep, I know.

Quoted 2 lines

, but
I'd prefer we make that dependency explicit.

Okay.

Quoted 2 lines

We could probably just
source it again from this file.

Another option is to pass ${ARCH} as an argument when we source scripts/runtime.bash

=> source scripts/runtime.bash "${ARCH}"

Which one do you prefer?

Quoted 11 lines

Thanks,
drew

Quoted 6 lines
scripts/common.bash +3 -0
+if [ -f "${ARCH_FUNC}" ]; then
+	source "${ARCH_FUNC}"
+fi
Signature · 1 line
2.25.4
Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#7 lore raw

Re: [kvm-unit-tests RFC v2 2/4] scripts: add support for architecture dependent functions

Quoted 49 lines · Marc Hartmayer
Quoted 29 lines · Andrew Jones
Quoted 28 lines · Marc Hartmayer

This is necessary to keep architecture dependent code separate from common code.

---
 README.md           | 3 ++-
 scripts/common.bash | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
README.md +2 -1
index 48be206c6db1..24d4bdaaee0d 100644
@@ -134,7 +134,8 @@ all unit tests.
 ## Directory structure
 
     .:                  configure script, top-level Makefile, and run_tests.sh
-    ./scripts:          helper scripts for building and running tests
+    ./scripts:          general architecture neutral helper scripts for building and running tests
+    ./scripts/<ARCH>:   architecture dependent helper scripts for building and running tests
     ./lib:              general architecture neutral services for the tests
     ./lib/<ARCH>:       architecture dependent services for the tests
     ./<ARCH>:           the sources of the tests and the created objects/images
scripts/common.bash +0 -0
index 96655c9ffd1f..f9c15fd304bd 100644
@@ -52,3 +52,8 @@ function for_each_unittest()
Quoted 8 lines

scripts/common.bash function for_each_unittest() · line 56

Quoted 5 lines
scripts/common.bash +2 -0
 	fi
 	exec {fd}<&-
 }
+
+ARCH_FUNC=scripts/${ARCH}/func.bash

The use of ${ARCH} adds a dependency on config.mak. It works now because in the two places we source common.bash we source config.mak first

Yep, I know.

Quoted 2 lines

, but
I'd prefer we make that dependency explicit.

Okay.

Quoted 2 lines

We could probably just
source it again from this file.

Quoted 6 lines

Another option is to pass ${ARCH} as an argument when we source scripts/runtime.bash

=> source scripts/runtime.bash "${ARCH}"

Which one do you prefer?

The first one. There's a chance that the arch helper functions will need more than $ARCH from config.mak. Of course that means we have a dependency on config.mak from the arch helper file too. We can just add a comment in common.bash about the order of sourcing though, as common.bash should be the only file sourcing the arch helper file.

Thanks,
drew

Quoted 22 lines
Quoted 12 lines

Thanks,
drew

Quoted 6 lines
scripts/common.bash +3 -0
+if [ -f "${ARCH_FUNC}" ]; then
+	source "${ARCH_FUNC}"
+fi
Signature · 1 line
2.25.4
Signature · 8 lines
Kind regards / Beste Gr��e
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Gesch�ftsf�hrung: Dirk Wittkopp
Sitz der Gesellschaft: B�blingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#8 lore raw

Re: [kvm-unit-tests RFC v2 2/4] scripts: add support for architecture dependent functions

Quoted 55 lines · Andrew Jones
Quoted 54 lines · Marc Hartmayer
Quoted 29 lines · Andrew Jones
Quoted 28 lines · Marc Hartmayer

This is necessary to keep architecture dependent code separate from common code.

---
 README.md           | 3 ++-
 scripts/common.bash | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
README.md +2 -1
index 48be206c6db1..24d4bdaaee0d 100644
@@ -134,7 +134,8 @@ all unit tests.
 ## Directory structure
 
     .:                  configure script, top-level Makefile, and run_tests.sh
-    ./scripts:          helper scripts for building and running tests
+    ./scripts:          general architecture neutral helper scripts for building and running tests
+    ./scripts/<ARCH>:   architecture dependent helper scripts for building and running tests
     ./lib:              general architecture neutral services for the tests
     ./lib/<ARCH>:       architecture dependent services for the tests
     ./<ARCH>:           the sources of the tests and the created objects/images
scripts/common.bash +0 -0
index 96655c9ffd1f..f9c15fd304bd 100644
@@ -52,3 +52,8 @@ function for_each_unittest()
Quoted 8 lines

scripts/common.bash function for_each_unittest() · line 56

Quoted 5 lines
scripts/common.bash +2 -0
 	fi
 	exec {fd}<&-
 }
+
+ARCH_FUNC=scripts/${ARCH}/func.bash

The use of ${ARCH} adds a dependency on config.mak. It works now because in the two places we source common.bash we source config.mak first

Yep, I know.

Quoted 2 lines

, but
I'd prefer we make that dependency explicit.

Okay.

Quoted 2 lines

We could probably just
source it again from this file.

Another option is to pass ${ARCH} as an argument when we source scripts/runtime.bash

=> source scripts/runtime.bash "${ARCH}"

Quoted 8 lines
Quoted 1 line

Which one do you prefer?

The first one. There's a chance that the arch helper functions will need more than $ARCH from config.mak. Of course that means we have a dependency on config.mak from the arch helper file too. We can just add a comment in common.bash about the order of sourcing though, as common.bash should be the only file sourcing the arch helper file.

Will add it. Thanks!

Quoted 27 lines

Thanks,
drew

Quoted 22 lines
Quoted 12 lines

Thanks,
drew

Quoted 6 lines
scripts/common.bash +3 -0
+if [ -f "${ARCH_FUNC}" ]; then
+	source "${ARCH_FUNC}"
+fi
Signature · 1 line
2.25.4
Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#9 lore raw

RFC v2 3/4 run_tests/mkstandalone: add arch dependent function to `for_each_unittest`

In reply to Marc Hartmayer

This allows us, for example, to auto generate a new test case based on an existing test case.

---
 run_tests.sh            |  2 +-
 scripts/common.bash     | 13 +++++++++++++
 scripts/mkstandalone.sh |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)
run_tests.sh +1 -1
index 24aba9cc3a98..23658392c488 100755
@@ -160,7 +160,7 @@ trap "wait; exit 130" SIGINT
    # preserve stdout so that process_test_output output can write TAP to it
    exec 3>&1
    test "$tap_output" == "yes" && exec > /dev/null
-   for_each_unittest $config run_task
+   for_each_unittest $config run_task arch_cmd
 ) | postprocess_suite_output
 
 # wait until all tasks finish
scripts/common.bash +13 -0
index f9c15fd304bd..62931a40b79a 100644
@@ -1,8 +1,15 @@
+function arch_cmd()
+{
+	# Dummy function, can be overwritten by architecture dependent
+	# code
+	return
+}
 
 function for_each_unittest()
 {
 	local unittests="$1"
 	local cmd="$2"
+	local arch_cmd="${3-}"
 	local testname
 	local smp
 	local kernel
@@ -19,6 +26,9 @@ function for_each_unittest()
 		if [[ "$line" =~ ^\[(.*)\]$ ]]; then
 			if [ -n "${testname}" ]; then
 				"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+				if [ "${arch_cmd}" ]; then
+					"${arch_cmd}" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+				fi
 			fi
 			testname=${BASH_REMATCH[1]}
 			smp=1
@@ -49,6 +59,9 @@ function for_each_unittest()
 	done
 	if [ -n "${testname}" ]; then
 		"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+		if [ "${arch_cmd}" ]; then
+			"${arch_cmd}" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+		fi
 	fi
 	exec {fd}<&-
 }
scripts/mkstandalone.sh +1 -1
index cefdec30cb33..3b18c0cf090b 100755
@@ -128,4 +128,4 @@ fi
 
 mkdir -p tests
 
-for_each_unittest $cfg mkstandalone
+for_each_unittest $cfg mkstandalone arch_cmd
Signature · 1 line
2.25.4
#10 lore raw

Re: [kvm-unit-tests RFC v2 3/4] run_tests/mkstandalone: add arch dependent function to `for_each_unittest`

Quoted 15 lines · Marc Hartmayer

This allows us, for example, to auto generate a new test case based on an existing test case.

---
 run_tests.sh            |  2 +-
 scripts/common.bash     | 13 +++++++++++++
 scripts/mkstandalone.sh |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)
run_tests.sh +0 -0
index 24aba9cc3a98..23658392c488 100755

run_tests.sh trap "wait; exit 130" SIGINT · line 163

Quoted 5 lines
run_tests.sh +1 -1
@@ -160,7 +160,7 @@ trap "wait; exit 130" SIGINT
    # preserve stdout so that process_test_output output can write TAP to it
    exec 3>&1
    test "$tap_output" == "yes" && exec > /dev/null
-   for_each_unittest $config run_task
+   for_each_unittest $config run_task arch_cmd

Let's just require that arch cmd hook be specified by the "$arch_cmd" variable. Then we don't need to pass it to for_each_unittest.

Quoted 8 lines
run_tests.sh +0 -0
 ) | postprocess_suite_output
 
 # wait until all tasks finish
scripts/common.bash +0 -0
index f9c15fd304bd..62931a40b79a 100644

scripts/common.bash line 6

Quoted 6 lines
scripts/common.bash +6 -0
@@ -1,8 +1,15 @@
+function arch_cmd()
+{
+	# Dummy function, can be overwritten by architecture dependent
+	# code
+	return
+}

This dummy function appears unused and can be dropped.

Quoted 10 lines
scripts/common.bash +1 -0
 function for_each_unittest()
 {
 	local unittests="$1"
 	local cmd="$2"
+	local arch_cmd="${3-}"
 	local testname
 	local smp
 	local kernel

scripts/common.bash function for_each_unittest() · line 31

Quoted 6 lines
scripts/common.bash +3 -0
@@ -19,6 +26,9 @@ function for_each_unittest()
 		if [[ "$line" =~ ^\[(.*)\]$ ]]; then
 			if [ -n "${testname}" ]; then
 				"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+				if [ "${arch_cmd}" ]; then
+					"${arch_cmd}" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+				fi

Rather than assuming we should run both $cmd ... and $arch_cmd $cmd ..., let's just run $arch_cmd $cmd ..., when it exists. If $arch_cmd wants to run $cmd ... first, then it can do so itself.

Quoted 26 lines
scripts/common.bash +3 -0
 			fi
 			testname=${BASH_REMATCH[1]}
 			smp=1
@@ -49,6 +59,9 @@ function for_each_unittest()
 	done
 	if [ -n "${testname}" ]; then
 		"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+		if [ "${arch_cmd}" ]; then
+			"${arch_cmd}" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+		fi
 	fi
 	exec {fd}<&-
 }
scripts/mkstandalone.sh +1 -1
index cefdec30cb33..3b18c0cf090b 100755
@@ -128,4 +128,4 @@ fi
 
 mkdir -p tests
 
-for_each_unittest $cfg mkstandalone
+for_each_unittest $cfg mkstandalone arch_cmd
Signature · 1 line
2.25.4

In summary, I think this patch should just be

scripts/common.bash +2 -2
index 9a6ebbd7f287..b409b0529ea6 100644
@@ -17,7 +17,7 @@ function for_each_unittest()
 
        while read -r -u $fd line; do
                if [[ "$line" =~ ^\[(.*)\]$ ]]; then
-                       "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+                       "$arch_cmd" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
                        testname=${BASH_REMATCH[1]}
                        smp=1
                        kernel=""
@@ -45,6 +45,6 @@ function for_each_unittest()
                        timeout=${BASH_REMATCH[1]}
                fi
        done
-       "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+       "$arch_cmd" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
        exec {fd}<&-
 }

Thanks,
drew

#11 lore raw

Re: [kvm-unit-tests RFC v2 3/4] run_tests/mkstandalone: add arch dependent function to `for_each_unittest`

Quoted 11 lines · Andrew Jones
Quoted 10 lines · Marc Hartmayer

This allows us, for example, to auto generate a new test case based on an existing test case.

---
 run_tests.sh            |  2 +-
 scripts/common.bash     | 13 +++++++++++++
 scripts/mkstandalone.sh |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)
Quoted 13 lines

run_tests.sh trap "wait; exit 130" SIGINT · line 163

Quoted 10 lines
run_tests.sh +1 -1
index 24aba9cc3a98..23658392c488 100755
@@ -160,7 +160,7 @@ trap "wait; exit 130" SIGINT
    # preserve stdout so that process_test_output output can write TAP to it
    exec 3>&1
    test "$tap_output" == "yes" && exec > /dev/null
-   for_each_unittest $config run_task
+   for_each_unittest $config run_task arch_cmd

Let's just require that arch cmd hook be specified by the "$arch_cmd" variable. Then we don't need to pass it to for_each_unittest.

Where is it then specified?

Quoted 17 lines
Quoted 9 lines
run_tests.sh +0 -0
 ) | postprocess_suite_output
 
 # wait until all tasks finish
scripts/common.bash +0 -0
index f9c15fd304bd..62931a40b79a 100644

scripts/common.bash line 6

Quoted 6 lines
scripts/common.bash +6 -0
@@ -1,8 +1,15 @@
+function arch_cmd()
+{
+	# Dummy function, can be overwritten by architecture dependent
+	# code
+	return
+}

This dummy function appears unused and can be dropped.

So what is then used if the function is not defined by the architecture specific code?

Quoted 13 lines
Quoted 13 lines
scripts/common.bash +1 -0
 function for_each_unittest()
 {
 	local unittests="$1"
 	local cmd="$2"
+	local arch_cmd="${3-}"
 	local testname
 	local smp
 	local kernel
@@ -19,6 +26,9 @@ function for_each_unittest()
 		if [[ "$line" =~ ^\[(.*)\]$ ]]; then
 			if [ -n "${testname}" ]; then
Quoted 8 lines

scripts/common.bash function for_each_unittest() · line 31

Quoted 4 lines
scripts/common.bash +3 -0
 				"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+				if [ "${arch_cmd}" ]; then
+					"${arch_cmd}" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+				fi

Rather than assuming we should run both $cmd ... and $arch_cmd $cmd ..., let's just run $arch_cmd $cmd ..., when it exists. If $arch_cmd wants to run $cmd ... first, then it can do so itself.

Yep, makes sense.

Quoted 35 lines
Quoted 27 lines
scripts/common.bash +3 -0
 			fi
 			testname=${BASH_REMATCH[1]}
 			smp=1
@@ -49,6 +59,9 @@ function for_each_unittest()
 	done
 	if [ -n "${testname}" ]; then
 		"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+		if [ "${arch_cmd}" ]; then
+			"${arch_cmd}" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+		fi
 	fi
 	exec {fd}<&-
 }
scripts/mkstandalone.sh +1 -1
index cefdec30cb33..3b18c0cf090b 100755
@@ -128,4 +128,4 @@ fi
 
 mkdir -p tests
 
-for_each_unittest $cfg mkstandalone
+for_each_unittest $cfg mkstandalone arch_cmd
Signature · 1 line
2.25.4

In summary, I think this patch should just be

scripts/common.bash +0 -0
index 9a6ebbd7f287..b409b0529ea6 100644

scripts/common.bash function for_each_unittest() · line 20

Quoted 5 lines
scripts/common.bash +1 -1
@@ -17,7 +17,7 @@ function for_each_unittest()
 
        while read -r -u $fd line; do
                if [[ "$line" =~ ^\[(.*)\]$ ]]; then
-                       "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+                       "$arch_cmd" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"

If we remove the $arch_cmd variable we can directly use:

arch_cmd "$cmd" …

Quoted 16 lines
scripts/common.bash +1 -1
                        testname=${BASH_REMATCH[1]}
                        smp=1
                        kernel=""
@@ -45,6 +45,6 @@ function for_each_unittest()
                        timeout=${BASH_REMATCH[1]}
                fi
        done
-       "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+       "$arch_cmd" "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
        exec {fd}<&-
 }

Thanks,
drew

Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#12 lore raw

Re: [kvm-unit-tests RFC v2 3/4] run_tests/mkstandalone: add arch dependent function to `for_each_unittest`

Quoted 26 lines · Marc Hartmayer
Quoted 11 lines · Andrew Jones
Quoted 10 lines · Marc Hartmayer

This allows us, for example, to auto generate a new test case based on an existing test case.

---
 run_tests.sh            |  2 +-
 scripts/common.bash     | 13 +++++++++++++
 scripts/mkstandalone.sh |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)
Quoted 13 lines

run_tests.sh trap "wait; exit 130" SIGINT · line 163

Quoted 10 lines
run_tests.sh +1 -1
index 24aba9cc3a98..23658392c488 100755
@@ -160,7 +160,7 @@ trap "wait; exit 130" SIGINT
    # preserve stdout so that process_test_output output can write TAP to it
    exec 3>&1
    test "$tap_output" == "yes" && exec > /dev/null
-   for_each_unittest $config run_task
+   for_each_unittest $config run_task arch_cmd

Let's just require that arch cmd hook be specified by the "$arch_cmd" variable. Then we don't need to pass it to for_each_unittest.

Quoted 1 line

Where is it then specified?

Just using it that way in the source is enough. We should probably call it $ARCH_CMD to indicate that it's a special variable. Also, we could return it from a $(arch_cmd) function, which is how $(migration_cmd) and $(timeout_cmd) work.

Quoted 19 lines
Quoted 4 lines
Quoted 4 lines
run_tests.sh +0 -0
 ) | postprocess_suite_output
 
Quoted 14 lines

scripts/common.bash line 6

Quoted 12 lines
run_tests.sh +0 -0
 # wait until all tasks finish
scripts/common.bash +6 -0
index f9c15fd304bd..62931a40b79a 100644
@@ -1,8 +1,15 @@
+function arch_cmd()
+{
+	# Dummy function, can be overwritten by architecture dependent
+	# code
+	return
+}

This dummy function appears unused and can be dropped.

Quoted 2 lines

So what is then used if the function is not defined by the architecture specific code?

Nothing, which works fine

 $ arch_cmd=
 $ $arch_cmd echo foo   # just do 'echo foo'

However, with what I wrote above, we now need a common arch_cmd function. Something like

arch_cmd()
{
[ "$ARCH_CMD" ] && return "$ARCH_CMD"
}

Which would allow us to write

$(arch_cmd) $cmd ...

That does the same thing as above, but it now follows the pattern of migration_cmd and timeout_cmd.

Thanks,
drew

#13 lore raw

Re: [kvm-unit-tests RFC v2 3/4] run_tests/mkstandalone: add arch dependent function to `for_each_unittest`

Quoted 27 lines · Andrew Jones
Quoted 26 lines · Marc Hartmayer
Quoted 24 lines · Andrew Jones
Quoted 15 lines · Marc Hartmayer

This allows us, for example, to auto generate a new test case based on an existing test case.

---
 run_tests.sh            |  2 +-
 scripts/common.bash     | 13 +++++++++++++
 scripts/mkstandalone.sh |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)
run_tests.sh +0 -0
index 24aba9cc3a98..23658392c488 100755

run_tests.sh trap "wait; exit 130" SIGINT · line 163

Quoted 5 lines
run_tests.sh +1 -1
@@ -160,7 +160,7 @@ trap "wait; exit 130" SIGINT
    # preserve stdout so that process_test_output output can write TAP to it
    exec 3>&1
    test "$tap_output" == "yes" && exec > /dev/null
-   for_each_unittest $config run_task
+   for_each_unittest $config run_task arch_cmd

Let's just require that arch cmd hook be specified by the "$arch_cmd" variable. Then we don't need to pass it to for_each_unittest.

Quoted 6 lines
Quoted 1 line

Where is it then specified?

Just using it that way in the source is enough. We should probably call it $ARCH_CMD to indicate that it's a special variable. Also, we could return it from a $(arch_cmd) function, which is how $(migration_cmd) and $(timeout_cmd) work.

My first approach was different…

First we source the (common) functions that could be overridden by architecture dependent code, and then source the architecture dependent code. But I’m not sure which approach is cleaner - if you prefer your proposed solution with the global variables I can change it.

Thanks for the feedback!

[…snip]

Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#14 lore raw

Re: [kvm-unit-tests RFC v2 3/4] run_tests/mkstandalone: add arch dependent function to `for_each_unittest`

Quoted 35 lines · Marc Hartmayer
Quoted 27 lines · Andrew Jones
Quoted 26 lines · Marc Hartmayer
Quoted 24 lines · Andrew Jones
Quoted 15 lines · Marc Hartmayer

This allows us, for example, to auto generate a new test case based on an existing test case.

---
 run_tests.sh            |  2 +-
 scripts/common.bash     | 13 +++++++++++++
 scripts/mkstandalone.sh |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)
run_tests.sh +0 -0
index 24aba9cc3a98..23658392c488 100755

run_tests.sh trap "wait; exit 130" SIGINT · line 163

Quoted 5 lines
run_tests.sh +1 -1
@@ -160,7 +160,7 @@ trap "wait; exit 130" SIGINT
    # preserve stdout so that process_test_output output can write TAP to it
    exec 3>&1
    test "$tap_output" == "yes" && exec > /dev/null
-   for_each_unittest $config run_task
+   for_each_unittest $config run_task arch_cmd

Let's just require that arch cmd hook be specified by the "$arch_cmd" variable. Then we don't need to pass it to for_each_unittest.

Quoted 6 lines
Quoted 1 line

Where is it then specified?

Just using it that way in the source is enough. We should probably call it $ARCH_CMD to indicate that it's a special variable. Also, we could return it from a $(arch_cmd) function, which is how $(migration_cmd) and $(timeout_cmd) work.

Quoted 6 lines

My first approach was different…

First we source the (common) functions that could be overridden by architecture dependent code, and then source the architecture dependent code. But I’m not sure which approach is cleaner - if you prefer your proposed solution with the global variables I can change it.

I prefer my proposed solution. It's not necessary to provide and source an arch-neutral function that will never do anything. And, it will never do anything, because the function is supposed to be arch-specific. If an arch doesn't implement the function, then we don't need to call anything at all.

Thanks,
drew

Quoted 15 lines

Thanks for the feedback!

[…snip]

Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#15 lore raw

RFC v2 4/4 s390x: add Protected VM support

In reply to Marc Hartmayer

Add support for Protected Virtual Machine (PVM) tests. For starting a PVM guest we must be able to generate a PVM image by using the genprotimg tool from the s390-tools collection. This requires the ability to pass a machine-specific host-key document, so the option --host-key-document is added to the configure script.

---
 configure               |  8 ++++++++
 s390x/Makefile          | 17 +++++++++++++++--
 s390x/selftest.parmfile |  1 +
 s390x/unittests.cfg     |  1 +
 scripts/s390x/func.bash | 18 ++++++++++++++++++
 5 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 s390x/selftest.parmfile
 create mode 100644 scripts/s390x/func.bash
configure +8 -0
index f9d030fd2f03..aa528af72534 100755
@@ -18,6 +18,7 @@ u32_long=
 vmm="qemu"
 errata_force=0
 erratatxt="$srcdir/errata.txt"
+host_key_document=
 
 usage() {
     cat <<-EOF
@@ -40,6 +41,8 @@ usage() {
 	                           no environ is provided by the user (enabled by default)
 	    --erratatxt=FILE       specify a file to use instead of errata.txt. Use
 	                           '--erratatxt=' to ensure no file is used.
+	    --host-key-document=HOST_KEY_DOCUMENT
+	                           host-key-document to use (s390x only)
 EOF
     exit 1
 }
@@ -92,6 +95,9 @@ while [[ "$1" = -* ]]; do
 	    erratatxt=
 	    [ "$arg" ] && erratatxt=$(eval realpath "$arg")
 	    ;;
+	--host-key-document)
+	    host_key_document="$arg"
+	    ;;
 	--help)
 	    usage
 	    ;;
@@ -205,6 +211,8 @@ PRETTY_PRINT_STACKS=$pretty_print_stacks
 ENVIRON_DEFAULT=$environ_default
 ERRATATXT=$erratatxt
 U32_LONG_FMT=$u32_long
+GENPROTIMG=${GENPROTIMG-genprotimg}
+HOST_KEY_DOCUMENT=$host_key_document
 EOF
 
 cat <<EOF > lib/config.h
s390x/Makefile +15 -2
index 0f54bf43bfb7..cd4e270952ec 100644
@@ -18,12 +18,19 @@ tests += $(TEST_DIR)/skrf.elf
 tests += $(TEST_DIR)/smp.elf
 tests += $(TEST_DIR)/sclp.elf
 tests += $(TEST_DIR)/css.elf
-tests_binary = $(patsubst %.elf,%.bin,$(tests))
 
-all: directories test_cases test_cases_binary
+tests_binary = $(patsubst %.elf,%.bin,$(tests))
+ifneq ($(HOST_KEY_DOCUMENT),)
+tests_pv_binary = $(patsubst %.bin,%.pv.bin,$(tests_binary))
+else
+tests_pv_binary =
+endif
+
+all: directories test_cases test_cases_binary test_cases_pv
 
 test_cases: $(tests)
 test_cases_binary: $(tests_binary)
+test_cases_pv: $(tests_pv_binary)
 
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
@@ -72,6 +79,12 @@ FLATLIBS = $(libcflat)
 %.bin: %.elf
 	$(OBJCOPY) -O binary  $< $@
 
+%selftest.pv.bin: %selftest.bin $(HOST_KEY_DOCUMENT) $(patsubst %.pv.bin,%.parmfile,$@)
+	$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --parmfile $(patsubst %.pv.bin,%.parmfile,$@) --no-verify --image $< -o $@
+
+%.pv.bin: %.bin $(HOST_KEY_DOCUMENT)
+	$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify --image $< -o $@
+
 arch_clean: asm_offsets_clean
 	$(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d lib/s390x/.*.d
 
s390x/selftest.parmfile new file +1 -0
new file mode 100644
index 000000000000..5613931aa5c6
@@ -0,0 +1 @@
+test 123
\ No newline at end of file
s390x/unittests.cfg +1 -0
index 0f156afbe741..12f6fb613995 100644
@@ -21,6 +21,7 @@
 [selftest-setup]
 file = selftest.elf
 groups = selftest
+# please keep the kernel cmdline in sync with $(TEST_DIR)/selftest.parmfile
 extra_params = -append 'test 123'
 
 [intercept]
scripts/s390x/func.bash new file +18 -0
new file mode 100644
index 000000000000..5c682cb47f73
@@ -0,0 +1,18 @@
+# Run Protected VM test
+function arch_cmd()
+{
+	local cmd=$1
+	local testname=$2
+	local groups=$3
+	local smp=$4
+	local kernel=$5
+	local opts=$6
+	local arch=$7
+	local check=$8
+	local accel=$9
+	local timeout=${10}
+
+	kernel=${kernel%.elf}.pv.bin
+	# do not run PV test cases by default
+	"$cmd" "${testname}_PV" "$groups pv nodefault" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+}
Signature · 1 line
2.25.4
#16 lore raw

Re: [kvm-unit-tests RFC v2 4/4] s390x: add Protected VM support

Quoted 30 lines · On Wed, 12 Aug 2020 11:27:05 +0200 Marc Hartmayer <[email protected]>…

Add support for Protected Virtual Machine (PVM) tests. For starting a PVM guest we must be able to generate a PVM image by using the genprotimg tool from the s390-tools collection. This requires the ability to pass a machine-specific host-key document, so the option --host-key-document is added to the configure script.

---
 configure               |  8 ++++++++
 s390x/Makefile          | 17 +++++++++++++++--
 s390x/selftest.parmfile |  1 +
 s390x/unittests.cfg     |  1 +
 scripts/s390x/func.bash | 18 ++++++++++++++++++
 5 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 s390x/selftest.parmfile
 create mode 100644 scripts/s390x/func.bash
configure +1 -0
index f9d030fd2f03..aa528af72534 100755
@@ -18,6 +18,7 @@ u32_long=
 vmm="qemu"
 errata_force=0
 erratatxt="$srcdir/errata.txt"
+host_key_document=
 
 usage() {
     cat <<-EOF

configure usage() { · line 45

Quoted 5 lines
configure +2 -0
@@ -40,6 +41,8 @@ usage() {
 	                           no environ is provided by the user (enabled by default)
 	    --erratatxt=FILE       specify a file to use instead of errata.txt. Use
 	                           '--erratatxt=' to ensure no file is used.
+	    --host-key-document=HOST_KEY_DOCUMENT
+	                           host-key-document to use (s390x only)

Maybe a bit more verbose? If I see only this option, I have no idea what it is used for and where to get it.

Quoted 67 lines
configure +5 -0
 EOF
     exit 1
 }
@@ -92,6 +95,9 @@ while [[ "$1" = -* ]]; do
 	    erratatxt=
 	    [ "$arg" ] && erratatxt=$(eval realpath "$arg")
 	    ;;
+	--host-key-document)
+	    host_key_document="$arg"
+	    ;;
 	--help)
 	    usage
 	    ;;
@@ -205,6 +211,8 @@ PRETTY_PRINT_STACKS=$pretty_print_stacks
 ENVIRON_DEFAULT=$environ_default
 ERRATATXT=$erratatxt
 U32_LONG_FMT=$u32_long
+GENPROTIMG=${GENPROTIMG-genprotimg}
+HOST_KEY_DOCUMENT=$host_key_document
 EOF
 
 cat <<EOF > lib/config.h
s390x/Makefile +15 -2
index 0f54bf43bfb7..cd4e270952ec 100644
@@ -18,12 +18,19 @@ tests += $(TEST_DIR)/skrf.elf
 tests += $(TEST_DIR)/smp.elf
 tests += $(TEST_DIR)/sclp.elf
 tests += $(TEST_DIR)/css.elf
-tests_binary = $(patsubst %.elf,%.bin,$(tests))
 
-all: directories test_cases test_cases_binary
+tests_binary = $(patsubst %.elf,%.bin,$(tests))
+ifneq ($(HOST_KEY_DOCUMENT),)
+tests_pv_binary = $(patsubst %.bin,%.pv.bin,$(tests_binary))
+else
+tests_pv_binary =
+endif
+
+all: directories test_cases test_cases_binary test_cases_pv
 
 test_cases: $(tests)
 test_cases_binary: $(tests_binary)
+test_cases_pv: $(tests_pv_binary)
 
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
@@ -72,6 +79,12 @@ FLATLIBS = $(libcflat)
 %.bin: %.elf
 	$(OBJCOPY) -O binary  $< $@
 
+%selftest.pv.bin: %selftest.bin $(HOST_KEY_DOCUMENT) $(patsubst %.pv.bin,%.parmfile,$@)
+	$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --parmfile $(patsubst %.pv.bin,%.parmfile,$@) --no-verify --image $< -o $@
+
+%.pv.bin: %.bin $(HOST_KEY_DOCUMENT)
+	$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify --image $< -o $@
+
 arch_clean: asm_offsets_clean
 	$(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d lib/s390x/.*.d
 
s390x/selftest.parmfile new file +0 -0
new file mode 100644
index 000000000000..5613931aa5c6

s390x/selftest.parmfile line 1

Quoted 2 lines
s390x/selftest.parmfile new file +1 -0
@@ -0,0 +1 @@
+test 123
\ No newline at end of file

Maybe add one? :)

Quoted 25 lines
s390x/unittests.cfg +1 -0
index 0f156afbe741..12f6fb613995 100644
@@ -21,6 +21,7 @@
 [selftest-setup]
 file = selftest.elf
 groups = selftest
+# please keep the kernel cmdline in sync with $(TEST_DIR)/selftest.parmfile
 extra_params = -append 'test 123'
 
 [intercept]
scripts/s390x/func.bash new file +7 -0
new file mode 100644
index 000000000000..5c682cb47f73
@@ -0,0 +1,18 @@
+# Run Protected VM test
+function arch_cmd()
+{
+	local cmd=$1
+	local testname=$2
+	local groups=$3
+	local smp=$4

scripts/s390x/func.bash line 17

Quoted 10 lines
scripts/s390x/func.bash new file +10 -0
+	local kernel=$5
+	local opts=$6
+	local arch=$7
+	local check=$8
+	local accel=$9
+	local timeout=${10}
+
+	kernel=${kernel%.elf}.pv.bin
+	# do not run PV test cases by default
+	"$cmd" "${testname}_PV" "$groups pv nodefault" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"

If we don't run this test, can we maybe print some informative message like "PV tests not run; specify --host-key-document to enable" or so? (At whichever point that makes the most sense.)

Quoted 1 line
scripts/s390x/func.bash new file +1 -0
+}
#17 lore raw

Re: [kvm-unit-tests RFC v2 4/4] s390x: add Protected VM support

Quoted 30 lines · Cornelia Huck
Quoted 27 lines · On Wed, 12 Aug 2020 11:27:05 +0200 Marc Hartmayer <[email protected]>…

Add support for Protected Virtual Machine (PVM) tests. For starting a PVM guest we must be able to generate a PVM image by using the genprotimg tool from the s390-tools collection. This requires the ability to pass a machine-specific host-key document, so the option --host-key-document is added to the configure script.

---
 configure               |  8 ++++++++
 s390x/Makefile          | 17 +++++++++++++++--
 s390x/selftest.parmfile |  1 +
 s390x/unittests.cfg     |  1 +
 scripts/s390x/func.bash | 18 ++++++++++++++++++
 5 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 s390x/selftest.parmfile
 create mode 100644 scripts/s390x/func.bash
configure +1 -0
index f9d030fd2f03..aa528af72534 100755
@@ -18,6 +18,7 @@ u32_long=
 vmm="qemu"
 errata_force=0
 erratatxt="$srcdir/errata.txt"
+host_key_document=
 
Quoted 11 lines

configure usage() { · line 45

Quoted 8 lines
configure +2 -0
 usage() {
     cat <<-EOF
@@ -40,6 +41,8 @@ usage() {
 	                           no environ is provided by the user (enabled by default)
 	    --erratatxt=FILE       specify a file to use instead of errata.txt. Use
 	                           '--erratatxt=' to ensure no file is used.
+	    --host-key-document=HOST_KEY_DOCUMENT
+	                           host-key-document to use (s390x only)

Maybe a bit more verbose? If I see only this option, I have no idea what it is used for and where to get it.

“Specifies the machine-specific host-key document required to create a PVM image using the genprotimg tool from the s390-tools collection (s390x only)”

Better?

Quoted 62 lines
Quoted 62 lines
configure +5 -0
 EOF
     exit 1
 }
@@ -92,6 +95,9 @@ while [[ "$1" = -* ]]; do
 	    erratatxt=
 	    [ "$arg" ] && erratatxt=$(eval realpath "$arg")
 	    ;;
+	--host-key-document)
+	    host_key_document="$arg"
+	    ;;
 	--help)
 	    usage
 	    ;;
@@ -205,6 +211,8 @@ PRETTY_PRINT_STACKS=$pretty_print_stacks
 ENVIRON_DEFAULT=$environ_default
 ERRATATXT=$erratatxt
 U32_LONG_FMT=$u32_long
+GENPROTIMG=${GENPROTIMG-genprotimg}
+HOST_KEY_DOCUMENT=$host_key_document
 EOF
 
 cat <<EOF > lib/config.h
s390x/Makefile +15 -2
index 0f54bf43bfb7..cd4e270952ec 100644
@@ -18,12 +18,19 @@ tests += $(TEST_DIR)/skrf.elf
 tests += $(TEST_DIR)/smp.elf
 tests += $(TEST_DIR)/sclp.elf
 tests += $(TEST_DIR)/css.elf
-tests_binary = $(patsubst %.elf,%.bin,$(tests))
 
-all: directories test_cases test_cases_binary
+tests_binary = $(patsubst %.elf,%.bin,$(tests))
+ifneq ($(HOST_KEY_DOCUMENT),)
+tests_pv_binary = $(patsubst %.bin,%.pv.bin,$(tests_binary))
+else
+tests_pv_binary =
+endif
+
+all: directories test_cases test_cases_binary test_cases_pv
 
 test_cases: $(tests)
 test_cases_binary: $(tests_binary)
+test_cases_pv: $(tests_pv_binary)
 
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
@@ -72,6 +79,12 @@ FLATLIBS = $(libcflat)
 %.bin: %.elf
 	$(OBJCOPY) -O binary  $< $@
 
+%selftest.pv.bin: %selftest.bin $(HOST_KEY_DOCUMENT) $(patsubst %.pv.bin,%.parmfile,$@)
+	$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --parmfile $(patsubst %.pv.bin,%.parmfile,$@) --no-verify --image $< -o $@
+
+%.pv.bin: %.bin $(HOST_KEY_DOCUMENT)
+	$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify --image $< -o $@
+
 arch_clean: asm_offsets_clean
 	$(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d lib/s390x/.*.d
 
Quoted 10 lines

s390x/selftest.parmfile line 1

Quoted 8 lines
s390x/selftest.parmfile new file +1 -0
new file mode 100644
index 000000000000..5613931aa5c6
@@ -0,0 +1 @@
+test 123
\ No newline at end of file

Maybe add one? :)

No, this’s intended, otherwise the test case fails.

Quoted 32 lines
Quoted 32 lines
s390x/unittests.cfg +1 -0
index 0f156afbe741..12f6fb613995 100644
@@ -21,6 +21,7 @@
 [selftest-setup]
 file = selftest.elf
 groups = selftest
+# please keep the kernel cmdline in sync with $(TEST_DIR)/selftest.parmfile
 extra_params = -append 'test 123'
 
 [intercept]
scripts/s390x/func.bash new file +13 -0
new file mode 100644
index 000000000000..5c682cb47f73
@@ -0,0 +1,18 @@
+# Run Protected VM test
+function arch_cmd()
+{
+	local cmd=$1
+	local testname=$2
+	local groups=$3
+	local smp=$4
+	local kernel=$5
+	local opts=$6
+	local arch=$7
+	local check=$8
+	local accel=$9
+	local timeout=${10}
Quoted 8 lines

scripts/s390x/func.bash line 17

Quoted 4 lines
scripts/s390x/func.bash new file +4 -0
+
+	kernel=${kernel%.elf}.pv.bin
+	# do not run PV test cases by default
+	"$cmd" "${testname}_PV" "$groups pv nodefault" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"

If we don't run this test, can we maybe print some informative message like "PV tests not run; specify --host-key-document to enable" or so? (At whichever point that makes the most sense.)

Currently, the output looks like this:

$ ./run_tests.sh    
PASS selftest-setup (14 tests)
SKIP selftest-setup_PV (test marked as manual run only)
PASS intercept (20 tests)
SKIP intercept_PV (test marked as manual run only)
…

And if you’re trying to run the PV tests without specifying the host-key document it results in:

$ ./run_tests.sh -a
PASS selftest-setup (14 tests)
FAIL selftest-setup_PV 
PASS intercept (20 tests)
FAIL intercept_PV 
…

But if you like I can return a hint that the PVM image was not generated. Should the PV test case then be skipped?

Quoted 3 lines
Quoted 2 lines
scripts/s390x/func.bash new file +1 -0
+}
Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#18 lore raw

Re: [kvm-unit-tests RFC v2 4/4] s390x: add Protected VM support

Quoted 43 lines · On Thu, 13 Aug 2020 15:08:51 +0200 Marc Hartmayer <[email protected]>…
Quoted 30 lines · Cornelia Huck
Quoted 27 lines · On Wed, 12 Aug 2020 11:27:05 +0200 Marc Hartmayer <[email protected]>…

Add support for Protected Virtual Machine (PVM) tests. For starting a PVM guest we must be able to generate a PVM image by using the genprotimg tool from the s390-tools collection. This requires the ability to pass a machine-specific host-key document, so the option --host-key-document is added to the configure script.

---
 configure               |  8 ++++++++
 s390x/Makefile          | 17 +++++++++++++++--
 s390x/selftest.parmfile |  1 +
 s390x/unittests.cfg     |  1 +
 scripts/s390x/func.bash | 18 ++++++++++++++++++
 5 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 s390x/selftest.parmfile
 create mode 100644 scripts/s390x/func.bash
configure +1 -0
index f9d030fd2f03..aa528af72534 100755
@@ -18,6 +18,7 @@ u32_long=
 vmm="qemu"
 errata_force=0
 erratatxt="$srcdir/errata.txt"
+host_key_document=
 
Quoted 11 lines

configure usage() { · line 45

Quoted 8 lines
configure +2 -0
 usage() {
     cat <<-EOF
@@ -40,6 +41,8 @@ usage() {
 	                           no environ is provided by the user (enabled by default)
 	    --erratatxt=FILE       specify a file to use instead of errata.txt. Use
 	                           '--erratatxt=' to ensure no file is used.
+	    --host-key-document=HOST_KEY_DOCUMENT
+	                           host-key-document to use (s390x only)  

Maybe a bit more verbose? If I see only this option, I have no idea what it is used for and where to get it.

Quoted 5 lines

“Specifies the machine-specific host-key document required to create a PVM image using the genprotimg tool from the s390-tools collection (s390x only)”

Better?

"specify the machine-specific host-key document for creating a PVM image with 'genprotimg' (s390x only)"

I think you can figure out where to get genprotimg if you actually know that you want it ;)

(...)

Quoted 47 lines
Quoted 19 lines
Quoted 19 lines
scripts/s390x/func.bash new file +13 -0
new file mode 100644
index 000000000000..5c682cb47f73
@@ -0,0 +1,18 @@
+# Run Protected VM test
+function arch_cmd()
+{
+	local cmd=$1
+	local testname=$2
+	local groups=$3
+	local smp=$4
+	local kernel=$5
+	local opts=$6
+	local arch=$7
+	local check=$8
+	local accel=$9
+	local timeout=${10}
Quoted 8 lines

scripts/s390x/func.bash line 17

Quoted 4 lines
scripts/s390x/func.bash new file +4 -0
+
+	kernel=${kernel%.elf}.pv.bin
+	# do not run PV test cases by default
+	"$cmd" "${testname}_PV" "$groups pv nodefault" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"  

If we don't run this test, can we maybe print some informative message like "PV tests not run; specify --host-key-document to enable" or so? (At whichever point that makes the most sense.)

Currently, the output looks like this:

$ ./run_tests.sh    
PASS selftest-setup (14 tests)
SKIP selftest-setup_PV (test marked as manual run only)
PASS intercept (20 tests)
SKIP intercept_PV (test marked as manual run only)
…

And if you’re trying to run the PV tests without specifying the host-key document it results in:

$ ./run_tests.sh -a
PASS selftest-setup (14 tests)
FAIL selftest-setup_PV 
PASS intercept (20 tests)
FAIL intercept_PV 
…
Quoted 2 lines

But if you like I can return a hint that the PVM image was not generated. Should the PV test case then be skipped?

Yes, I was expecting something like

SKIP selftest-setup_PV (no host-key document specified) SKIP intercept_PV (no host-key document specified)

so that you get a hint what you may want to set up.

#19 lore raw

Re: [kvm-unit-tests RFC v2 4/4] s390x: add Protected VM support

Quoted 110 lines · Cornelia Huck
Quoted 43 lines · On Thu, 13 Aug 2020 15:08:51 +0200 Marc Hartmayer <[email protected]>…
Quoted 30 lines · Cornelia Huck
Quoted 27 lines · On Wed, 12 Aug 2020 11:27:05 +0200 Marc Hartmayer <[email protected]>…

Add support for Protected Virtual Machine (PVM) tests. For starting a PVM guest we must be able to generate a PVM image by using the genprotimg tool from the s390-tools collection. This requires the ability to pass a machine-specific host-key document, so the option --host-key-document is added to the configure script.

---
 configure               |  8 ++++++++
 s390x/Makefile          | 17 +++++++++++++++--
 s390x/selftest.parmfile |  1 +
 s390x/unittests.cfg     |  1 +
 scripts/s390x/func.bash | 18 ++++++++++++++++++
 5 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 s390x/selftest.parmfile
 create mode 100644 scripts/s390x/func.bash
configure +1 -0
index f9d030fd2f03..aa528af72534 100755
@@ -18,6 +18,7 @@ u32_long=
 vmm="qemu"
 errata_force=0
 erratatxt="$srcdir/errata.txt"
+host_key_document=
 
Quoted 11 lines

configure usage() { · line 45

Quoted 8 lines
configure +2 -0
 usage() {
     cat <<-EOF
@@ -40,6 +41,8 @@ usage() {
 	                           no environ is provided by the user (enabled by default)
 	    --erratatxt=FILE       specify a file to use instead of errata.txt. Use
 	                           '--erratatxt=' to ensure no file is used.
+	    --host-key-document=HOST_KEY_DOCUMENT
+	                           host-key-document to use (s390x only)  

Maybe a bit more verbose? If I see only this option, I have no idea what it is used for and where to get it.

Quoted 5 lines

“Specifies the machine-specific host-key document required to create a PVM image using the genprotimg tool from the s390-tools collection (s390x only)”

Better?

"specify the machine-specific host-key document for creating a PVM image with 'genprotimg' (s390x only)"

I think you can figure out where to get genprotimg if you actually know that you want it ;)

(...)

Quoted 47 lines
Quoted 19 lines
Quoted 19 lines
scripts/s390x/func.bash new file +13 -0
new file mode 100644
index 000000000000..5c682cb47f73
@@ -0,0 +1,18 @@
+# Run Protected VM test
+function arch_cmd()
+{
+	local cmd=$1
+	local testname=$2
+	local groups=$3
+	local smp=$4
+	local kernel=$5
+	local opts=$6
+	local arch=$7
+	local check=$8
+	local accel=$9
+	local timeout=${10}
Quoted 8 lines

scripts/s390x/func.bash line 17

Quoted 4 lines
scripts/s390x/func.bash new file +4 -0
+
+	kernel=${kernel%.elf}.pv.bin
+	# do not run PV test cases by default
+	"$cmd" "${testname}_PV" "$groups pv nodefault" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"  

If we don't run this test, can we maybe print some informative message like "PV tests not run; specify --host-key-document to enable" or so? (At whichever point that makes the most sense.)

Currently, the output looks like this:

$ ./run_tests.sh    
PASS selftest-setup (14 tests)
SKIP selftest-setup_PV (test marked as manual run only)
PASS intercept (20 tests)
SKIP intercept_PV (test marked as manual run only)
…

And if you’re trying to run the PV tests without specifying the host-key document it results in:

$ ./run_tests.sh -a
PASS selftest-setup (14 tests)
FAIL selftest-setup_PV 
PASS intercept (20 tests)
FAIL intercept_PV 
…
Quoted 2 lines

But if you like I can return a hint that the PVM image was not generated. Should the PV test case then be skipped?

Quoted 6 lines

Yes, I was expecting something like

SKIP selftest-setup_PV (no host-key document specified) SKIP intercept_PV (no host-key document specified)

so that you get a hint what you may want to set up.

Okay, I’ll add this and remove the marker that PV tests aren’t executed by default. Because when someone builds the PV images, he will most likely want to run the PV test cases as well.

Quoted 1 line
Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294