Blob Blame History Raw
From 02a31caea9355acca56dc348f932ae4f5a888991 Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Fri, 14 Sep 2018 16:01:36 +0200
Subject: [PATCH 2/3] powerpc: KABI add aux_ptr to hole in paca_struct to
 extend it with additional members.

References: bsc#1094244
Patch-mainline: no, kabi

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 arch/powerpc/include/asm/paca.h   | 13 +++++++++++++
 arch/powerpc/kernel/asm-offsets.c |  2 +-
 arch/powerpc/kernel/paca.c        | 21 ++++++++++++++++++++-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 6b4d68937b7d..723812dbff21 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -53,6 +53,15 @@ extern unsigned int debug_smp_processor_id(void); /* from linux/smp.h */
 struct task_struct;
 
 /*
+ * This is pointed to by paca->aux_ptr, for the purpose of extending the paca
+ * structure without kABI breakage.
+ */
+#ifdef CONFIG_PPC_BOOK3S_64
+struct paca_aux_struct {
+};
+#endif
+
+/*
  * Defines the layout of the paca.
  *
  * This structure is not directly accessed by firmware or the service
@@ -239,6 +248,10 @@ struct paca_struct {
 #endif
 #endif
 #ifdef CONFIG_PPC_BOOK3S_64
+#ifndef __GENKSYMS__
+	/* add pointer to extra paca members into a hole */
+	struct paca_aux_struct * aux_ptr;
+#endif
 	/*
 	 * rfi fallback flush must be in its own cacheline to prevent
 	 * other paca data leaking into the L1d
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 2029b2d95edc..a8adfadf9b9b 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -241,7 +241,7 @@ int main(void)
 	OFFSET(PACA_RFI_FLUSH_FALLBACK_AREA, paca_struct, rfi_flush_fallback_area);
 	OFFSET(PACA_EXRFI, paca_struct, exrfi);
 	OFFSET(PACA_L1D_FLUSH_SIZE, paca_struct, l1d_flush_size);
-
+	OFFSET(PACA_AUX_PTR, paca_struct, aux_ptr);
 #endif
 	OFFSET(PACAHWCPUID, paca_struct, hw_cpu_id);
 	OFFSET(PACAKEXECSTATE, paca_struct, kexec_state);
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index a847d99ede24..75f338023ce6 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -146,6 +146,15 @@ static void __init allocate_slb_shadows(int nr_cpus, int limit) { }
 struct paca_struct *paca;
 EXPORT_SYMBOL(paca);
 
+#ifdef CONFIG_PPC_BOOK3S_64
+/*
+ * Auxiliary structure that can be used to basically add fields to the
+ * paca without changing its size (for kABI purposes). Upstream code should
+ * have these fields directly in the paca.
+ */
+static struct paca_aux_struct * __initdata paca_aux;
+#endif /* CONFIG_PPC_BOOK3S_64 */
+
 void __init initialise_paca(struct paca_struct *new_paca, int cpu)
 {
 #ifdef CONFIG_PPC_BOOK3S
@@ -165,6 +174,7 @@ void __init initialise_paca(struct paca_struct *new_paca, int cpu)
 	new_paca->data_offset = 0xfeeeeeeeeeeeeeeeULL;
 #ifdef CONFIG_PPC_BOOK3S_64
 	new_paca->slb_shadow_ptr = init_slb_shadow(cpu);
+	new_paca->aux_ptr = &paca_aux[cpu];
 #endif
 
 #ifdef CONFIG_PPC_BOOK3E
@@ -195,6 +205,7 @@ void setup_paca(struct paca_struct *new_paca)
 }
 
 static int __initdata paca_size;
+static int __initdata paca_aux_size;
 
 void __init allocate_pacas(void)
 {
@@ -216,8 +227,16 @@ void __init allocate_pacas(void)
 	paca = __va(memblock_alloc_base(paca_size, PAGE_SIZE, limit));
 	memset(paca, 0, paca_size);
 
+#ifdef CONFIG_PPC_BOOK3S_64
+	paca_aux_size = PAGE_ALIGN(sizeof(struct paca_aux_struct) * nr_cpu_ids);
+	if (paca_aux_size) {
+		paca_aux = __va(memblock_alloc_base(paca_aux_size, PAGE_SIZE, limit));
+		memset(paca_aux, 0, paca_aux_size);
+	}
+#endif
+
 	printk(KERN_DEBUG "Allocated %u bytes for %u pacas at %p\n",
-		paca_size, nr_cpu_ids, paca);
+		paca_size + paca_aux_size, nr_cpu_ids, paca);
 
 	allocate_lppacas(nr_cpu_ids, limit);
 
-- 
2.13.7