Skip to contentSkip to conversation

KVM: selftests: Undef musl's PAGE_SIZE on x86 to avoid type differences

PATCH In review Sean Christopherson 1 participant 2 messages Nov 10 – Nov 13

Subsystems (3)
lore
Share & tools
lore

Sean Christopherson

author maintainer
#0 lore raw

PATCH v2 1/1 KVM: selftests: Undef musl's PAGE_SIZE on x86 to avoid type differences

Before defining PAGE_SIZE in x86's processor.h, explicitly include the system's limits.h and #undef PAGE_SIZE to workaround a conflict when using musl where musl defines PAGE_SIZE as a signed 32-bit value, but KVM expects it to be (and effectively requires it to be) an unsigned 64-bit value.

---

v2:
- Limit the hackery to KVM x86 selftests.
- Ensure limits.h is included before PAGE_SIZE can get defined by processor.h

v1: https://lore.kernel.org/all/[email protected]

 tools/testing/selftests/kvm/include/x86/processor.h | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/testing/selftests/kvm/include/x86/processor.h +8 -0
index 5898a277a2e0..65fda03ea893 100644
@@ -6,6 +6,14 @@
 #ifndef SELFTEST_KVM_PROCESSOR_H
 #define SELFTEST_KVM_PROCESSOR_H
 
+/*
+ * Explicitly include the system's limit.h and undefine PAGE_SIZE to workaround
+ * an incompatibility where musl defines PAGE_SIZE as a signed integer, whereas
+ * KVM selftests expect it to be a 64-bit unsigned value.
+ */
+#include <limits.h>
+#undef PAGE_SIZE
+
 #include <assert.h>
 #include <stdint.h>
 #include <syscall.h>

base-commit: cf7fa575900051e489f95944c65f432ea706ed73

Signature · 1 line
2.56.0.542.g3ef89b7020-goog
author maintainer
#1 lore raw
Quoted 4 lines · Sean Christopherson

Before defining PAGE_SIZE in x86's processor.h, explicitly include the system's limits.h and #undef PAGE_SIZE to workaround a conflict when using musl where musl defines PAGE_SIZE as a signed 32-bit value, but KVM expects it to be (and effectively requires it to be) an unsigned 64-bit value.

Applied to kvm-x86 selftests, thanks!

[1/1] KVM: selftests: Undef musl's PAGE_SIZE on x86 to avoid type differences

      https://github.com/kvm-x86/linux/commit/3efa3f8b6eb6

--
https://github.com/kvm-x86/linux/tree/next