diff mbox series

[kvm-unit-tests,v4,1/2] s390x: sclp: consider monoprocessor on read_info error

Message ID 20230530125243.18883-2-pmorel@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Fixing infinite loop on SCLP READ SCP INFO error | expand

Commit Message

Pierre Morel May 30, 2023, 12:52 p.m. UTC
A test would hang if an abort happens before SCLP Read SCP
Information has completed.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/sclp.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Nico Boehr May 31, 2023, 6:20 a.m. UTC | #1
Quoting Pierre Morel (2023-05-30 14:52:42)
> A test would hang if an abort happens before SCLP Read SCP
> Information has completed.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>

Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
diff mbox series

Patch

diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
index acdc8a9..34a31da 100644
--- a/lib/s390x/sclp.c
+++ b/lib/s390x/sclp.c
@@ -119,8 +119,15 @@  void sclp_read_info(void)
 
 int sclp_get_cpu_num(void)
 {
-	assert(read_info);
-	return read_info->entries_cpu;
+	if (read_info)
+		return read_info->entries_cpu;
+	/*
+	 * If we fail here and read_info has not being set,
+	 * it means we failed early and we try to abort the test.
+	 * We need to return at least one CPU, and obviously we have
+	 * at least one, for the smp_teardown to correctly work.
+	 */
+	return 1;
 }
 
 CPUEntry *sclp_get_cpu_entries(void)