[PATCH v5 7/9] KVM: PPC: selftests: Make nested case on pseries LPARs as resource constrained
From: Ritesh Harjani (IBM)
Date: Tue Sep 22 2026 - 14:32:03 EST
For nested guest case (L1 as pseries LPAR), L0 may fail with -44
(H_NOT_ENOUGH_RESOURCES) during vm or vcpu creation, causing enomem
due to limited resource/quotas.
This adds the necessary arch hooks for the same so that it can survive
hardware_disable_test and kvm_create_max_vcpus test cases.
Reported-by: Anushree Mathur <anushree.mathur@xxxxxxxxxxxxx>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx>
---
.../testing/selftests/kvm/include/powerpc/processor.h | 7 +++++++
tools/testing/selftests/kvm/lib/powerpc/processor.c | 10 ++++++++++
2 files changed, 17 insertions(+)
diff --git a/tools/testing/selftests/kvm/include/powerpc/processor.h b/tools/testing/selftests/kvm/include/powerpc/processor.h
index f0ee21a8e2d4..a46f6828991c 100644
--- a/tools/testing/selftests/kvm/include/powerpc/processor.h
+++ b/tools/testing/selftests/kvm/include/powerpc/processor.h
@@ -6,6 +6,8 @@
#define SELFTEST_KVM_PROCESSOR_H
#include <linux/compiler.h>
+#include <unistd.h>
+
#include "ppc_asm.h"
#include "kvm_util_types.h"
@@ -36,4 +38,9 @@ static inline void cpu_relax(void)
asm volatile("" ::: "memory");
}
+static inline bool is_pseries_lpar(void)
+{
+ return !access("/proc/device-tree/rtas/ibm,hypertas-functions", F_OK);
+}
+
#endif
diff --git a/tools/testing/selftests/kvm/lib/powerpc/processor.c b/tools/testing/selftests/kvm/lib/powerpc/processor.c
index 301455024571..e5d84f6d82f2 100644
--- a/tools/testing/selftests/kvm/lib/powerpc/processor.c
+++ b/tools/testing/selftests/kvm/lib/powerpc/processor.c
@@ -23,6 +23,16 @@ bool kvm_arch_needs_naturally_aligned_page_tables(void)
return true;
}
+/*
+ * For nested guest case (L1 as pseries LPAR), L0 may fail with -44
+ * (H_NOT_ENOUGH_RESOURCES) during vm or vcpu creation, causing enomem
+ * due to limited resource/quotas.
+ */
+bool kvm_arch_vm_create_may_enomem(void)
+{
+ return is_pseries_lpar();
+}
+
static void set_proc_table(struct kvm_vm *vm, int pid, u64 dw0, u64 dw1)
{
u64 *proc_table;
--
2.39.5