[kvm-unit-tests PATCH v5 09/29] powerpc: Fix interrupt stack alignment

Nicholas Piggin npiggin at gmail.com
Sun Dec 17 00:42:36 AEDT 2023


ppc64 requires the stack to be 16-byte aligned but the interrupt
stack frame has 8-byte aligned size. Add padding to fix.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 lib/powerpc/setup.c    | 3 +++
 lib/ppc64/asm/ptrace.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
index 1be4c030..d98f66fa 100644
--- a/lib/powerpc/setup.c
+++ b/lib/powerpc/setup.c
@@ -18,6 +18,7 @@
 #include <argv.h>
 #include <asm/setup.h>
 #include <asm/page.h>
+#include <asm/ptrace.h>
 #include <asm/hcall.h>
 #include "io.h"
 
@@ -195,6 +196,8 @@ void setup(const void *fdt)
 		freemem += initrd_size;
 	}
 
+	assert(STACK_INT_FRAME_SIZE % 16 == 0);
+
 	/* call init functions */
 	cpu_init();
 
diff --git a/lib/ppc64/asm/ptrace.h b/lib/ppc64/asm/ptrace.h
index 076c9d9c..12de7499 100644
--- a/lib/ppc64/asm/ptrace.h
+++ b/lib/ppc64/asm/ptrace.h
@@ -14,6 +14,7 @@ struct pt_regs {
 	unsigned long xer;
 	unsigned long ccr;
 	unsigned long trap;
+	unsigned long _pad; /* stack must be 16-byte aligned */
 };
 
 #define STACK_INT_FRAME_SIZE    (sizeof(struct pt_regs) + \
-- 
2.42.0



More information about the Linuxppc-dev mailing list