Skip to contentSkip to conversation

s390x: run PV guests with confidential guest enabled

PATCH In review Nico Boehr 3 participants 3 messages Sep 25, 2023

Subsystems (2)
lore
Share & tools
lore

Nico Boehr

author
#0 lore raw

PATCH 1/1 s390x: run PV guests with confidential guest enabled

PV can only handle one page of SCLP read info, hence it can only support a maximum of 247 CPUs.

To make sure we respect these limitations under PV, add a confidential guest device to QEMU when launching a PV guest.

This fixes the topology-2 test failing under PV.

Also refactor the run script a bit to reduce code duplication by moving the check whether we're running a PV guest to a function.

---
 s390x/run | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
s390x/run +17 -2
index dcbf3f036415..e58fa4af9f23 100755
@@ -14,19 +14,34 @@ set_qemu_accelerator || exit $?
 qemu=$(search_qemu_binary) ||
 	exit $?
 
-if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$ACCEL" = "tcg" ]; then
+is_pv() {
+	if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ]; then
+		return 0
+	fi
+	return 1
+}
+
+if is_pv && [ "$ACCEL" = "tcg" ]; then
 	echo "Protected Virtualization isn't supported under TCG"
 	exit 2
 fi
 
-if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$MIGRATION" = "yes" ]; then
+if is_pv && [ "$MIGRATION" = "yes" ]; then
 	echo "Migration isn't supported under Protected Virtualization"
 	exit 2
 fi
 
 M='-machine s390-ccw-virtio'
 M+=",accel=$ACCEL$ACCEL_PROPS"
+
+if is_pv; then
+	M+=",confidential-guest-support=pv0"
+fi
+
 command="$qemu -nodefaults -nographic $M"
+if is_pv; then
+	command+=" -object s390-pv-guest,id=pv0"
+fi
 command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0"
 command+=" -kernel"
 command="$(panic_cmd) $(migration_cmd) $(timeout_cmd) $command"
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Mon, 25 Sep 2023 15:52:45 +0200 Nico Boehr <[email protected]> wrote:

PV can only handle one page of SCLP read info, hence it can only support a maximum of 247 CPUs.

To make sure we respect these limitations under PV, add a confidential guest device to QEMU when launching a PV guest.

Quoted 7 lines

This fixes the topology-2 test failing under PV.

Also refactor the run script a bit to reduce code duplication by moving the check whether we're running a PV guest to a function.

Quoted 45 lines
---
 s390x/run | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
s390x/run +17 -2
index dcbf3f036415..e58fa4af9f23 100755
@@ -14,19 +14,34 @@ set_qemu_accelerator || exit $?
 qemu=$(search_qemu_binary) ||
 	exit $?
 
-if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$ACCEL" = "tcg" ]; then
+is_pv() {
+	if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ]; then
+		return 0
+	fi
+	return 1
+}
+
+if is_pv && [ "$ACCEL" = "tcg" ]; then
 	echo "Protected Virtualization isn't supported under TCG"
 	exit 2
 fi
 
-if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$MIGRATION" = "yes" ]; then
+if is_pv && [ "$MIGRATION" = "yes" ]; then
 	echo "Migration isn't supported under Protected Virtualization"
 	exit 2
 fi
 
 M='-machine s390-ccw-virtio'
 M+=",accel=$ACCEL$ACCEL_PROPS"
+
+if is_pv; then
+	M+=",confidential-guest-support=pv0"
+fi
+
 command="$qemu -nodefaults -nographic $M"
+if is_pv; then
+	command+=" -object s390-pv-guest,id=pv0"
+fi
 command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0"
 command+=" -kernel"
 command="$(panic_cmd) $(migration_cmd) $(timeout_cmd) $command"
Reviewed-by on v1 1/1
#2 lore raw
In reply to Nico Boehr
Quoted 6 lines · Nico Boehr

PV can only handle one page of SCLP read info, hence it can only support a maximum of 247 CPUs.

To make sure we respect these limitations under PV, add a confidential guest device to QEMU when launching a PV guest.

Quoted 7 lines

This fixes the topology-2 test failing under PV.

Also refactor the run script a bit to reduce code duplication by moving the check whether we're running a PV guest to a function.

Quoted 9 lines
---
 s390x/run | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
s390x/run +0 -0
index dcbf3f036415..e58fa4af9f23 100755

s390x/run set_qemu_accelerator || exit $? · line 22

Quoted 10 lines
s390x/run +6 -1
@@ -14,19 +14,34 @@ set_qemu_accelerator || exit $?
 qemu=$(search_qemu_binary) ||
 	exit $?
 
-if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$ACCEL" = "tcg" ]; then
+is_pv() {
+	if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ]; then
+		return 0
+	fi
+	return 1
+}

Could also just do

is_pv() {
        [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ]
}

but it might actually be more readable with the if

Quoted 26 lines
s390x/run +11 -1
+
+if is_pv && [ "$ACCEL" = "tcg" ]; then
 	echo "Protected Virtualization isn't supported under TCG"
 	exit 2
 fi
 
-if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$MIGRATION" = "yes" ]; then
+if is_pv && [ "$MIGRATION" = "yes" ]; then
 	echo "Migration isn't supported under Protected Virtualization"
 	exit 2
 fi
 
 M='-machine s390-ccw-virtio'
 M+=",accel=$ACCEL$ACCEL_PROPS"
+
+if is_pv; then
+	M+=",confidential-guest-support=pv0"
+fi
+
 command="$qemu -nodefaults -nographic $M"
+if is_pv; then
+	command+=" -object s390-pv-guest,id=pv0"
+fi
 command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0"
 command+=" -kernel"
 command="$(panic_cmd) $(migration_cmd) $(timeout_cmd) $command"