From 53c6b52438ea29241c8a75a4c4cb5de99313022f Mon Sep 17 00:00:00 2001 From: Hesham Almatary Date: Fri, 13 Jan 2017 11:53:25 +1100 Subject: [PATCH] SMP: Abstract architecture/platform independent parts of smp.h and ipi.h This commit is a re-arrangement of SMP directory structure to make it easier for other architectures/platforms (in general) and ARM (in particular) to add SMP support. * new include/smp directory to act as a centralised container of "shared" architecture-independent SMP headers. This makes it clearer what's needed for other architecture/platform to support SMP. * Each platform can define its own unique ipi.[h|c] that make sense, since ipi implementation is SoC/platform dependent. --- .../arch/arm/arch/32/mode/model/statedata.h | 2 +- include/arch/arm/arch/kernel/ipi.h | 15 ----- include/arch/arm/arch/smp/ipi.h | 13 ++++ include/arch/x86/arch/32/mode/kernel/ipi.h | 2 +- include/arch/x86/arch/32/mode/kernel/tlb.h | 2 +- .../arch/x86/arch/32/mode/model/statedata.h | 2 +- include/arch/x86/arch/64/mode/kernel/ipi.h | 2 +- include/arch/x86/arch/64/mode/kernel/tlb.h | 2 +- .../arch/x86/arch/64/mode/model/statedata.h | 2 +- include/arch/x86/arch/kernel/lock.h | 2 +- include/arch/x86/arch/kernel/tlb.h | 2 +- include/arch/x86/arch/smp/ipi.h | 34 ++++++++++ include/arch/x86/arch/smp/ipi_inline.h | 65 +++++++++++++++++++ include/model/statedata.h | 2 +- include/{arch/x86/arch/kernel => smp}/ipi.h | 65 ++----------------- include/{model => smp}/smp.h | 6 +- src/arch/x86/kernel/ipi.c | 4 +- src/arch/x86/kernel/lock.c | 2 +- src/object/interrupt.c | 2 +- 19 files changed, 133 insertions(+), 93 deletions(-) delete mode 100644 include/arch/arm/arch/kernel/ipi.h create mode 100644 include/arch/arm/arch/smp/ipi.h create mode 100644 include/arch/x86/arch/smp/ipi.h create mode 100644 include/arch/x86/arch/smp/ipi_inline.h rename include/{arch/x86/arch/kernel => smp}/ipi.h (66%) rename include/{model => smp}/smp.h (94%) diff --git a/include/arch/arm/arch/32/mode/model/statedata.h b/include/arch/arm/arch/32/mode/model/statedata.h index 5f0ccab6f..b6a791cd9 100644 --- a/include/arch/arm/arch/32/mode/model/statedata.h +++ b/include/arch/arm/arch/32/mode/model/statedata.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include #ifdef CONFIG_IPC_BUF_GLOBALS_FRAME extern word_t armKSGlobalsFrame[BIT(ARMSmallPageBits) / sizeof(word_t)] VISIBLE; diff --git a/include/arch/arm/arch/kernel/ipi.h b/include/arch/arm/arch/kernel/ipi.h deleted file mode 100644 index 585861c19..000000000 --- a/include/arch/arm/arch/kernel/ipi.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2016, Data61 - * Commonwealth Scientific and Industrial Research Organisation (CSIRO) - * ABN 41 687 119 230. - * - * This software may be distributed and modified according to the terms of - * the GNU General Public License version 2. Note that NO WARRANTY is provided. - * See "LICENSE_GPLv2.txt" for details. - * - * @TAG(D61_GPL) - */ - -#pragma once - -/* placeholder for future arm multicore implementation */ diff --git a/include/arch/arm/arch/smp/ipi.h b/include/arch/arm/arch/smp/ipi.h new file mode 100644 index 000000000..154421dfb --- /dev/null +++ b/include/arch/arm/arch/smp/ipi.h @@ -0,0 +1,13 @@ +/* +* Copyright 2016, Data61 +* Commonwealth Scientific and Industrial Research Organisation (CSIRO) +* ABN 41 687 119 230. +* +* This software may be distributed and modified according to the terms of +* the GNU General Public License version 2. Note that NO WARRANTY is provided. +* See "LICENSE_GPLv2.txt" for details. +* +* @TAG(D61_GPL) +*/ +/* Placeholder for future ARM shared ipi.h */ +#pragma once diff --git a/include/arch/x86/arch/32/mode/kernel/ipi.h b/include/arch/x86/arch/32/mode/kernel/ipi.h index f510900da..9eaaad34d 100644 --- a/include/arch/x86/arch/32/mode/kernel/ipi.h +++ b/include/arch/x86/arch/32/mode/kernel/ipi.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include #if CONFIG_MAX_NUM_NODES > 1 diff --git a/include/arch/x86/arch/32/mode/kernel/tlb.h b/include/arch/x86/arch/32/mode/kernel/tlb.h index a79305739..a794229da 100644 --- a/include/arch/x86/arch/32/mode/kernel/tlb.h +++ b/include/arch/x86/arch/32/mode/kernel/tlb.h @@ -13,7 +13,7 @@ #ifndef __MODE_KERNEL_TLB_H #define __MODE_KERNEL_TLB_H -#include +#include #include static inline void invalidateTLBEntry(vptr_t vptr, word_t mask) diff --git a/include/arch/x86/arch/32/mode/model/statedata.h b/include/arch/x86/arch/32/mode/model/statedata.h index 4e5455626..b6cbd94d6 100644 --- a/include/arch/x86/arch/32/mode/model/statedata.h +++ b/include/arch/x86/arch/32/mode/model/statedata.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include extern pdpte_t ia32KSGlobalPDPT[BIT(PDPT_INDEX_BITS)]; extern pde_t ia32KSGlobalPD[BIT(PD_INDEX_BITS + PDPT_INDEX_BITS)]; diff --git a/include/arch/x86/arch/64/mode/kernel/ipi.h b/include/arch/x86/arch/64/mode/kernel/ipi.h index 30c6584f8..8ce09898d 100644 --- a/include/arch/x86/arch/64/mode/kernel/ipi.h +++ b/include/arch/x86/arch/64/mode/kernel/ipi.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include #if CONFIG_MAX_NUM_NODES > 1 diff --git a/include/arch/x86/arch/64/mode/kernel/tlb.h b/include/arch/x86/arch/64/mode/kernel/tlb.h index edaed7bd9..f66c3eb3a 100644 --- a/include/arch/x86/arch/64/mode/kernel/tlb.h +++ b/include/arch/x86/arch/64/mode/kernel/tlb.h @@ -13,7 +13,7 @@ #ifndef __MODE_KERNEL_TLB_H #define __MODE_KERNEL_TLB_H -#include +#include #include #include #include diff --git a/include/arch/x86/arch/64/mode/model/statedata.h b/include/arch/x86/arch/64/mode/model/statedata.h index 5828c76e0..35bc8d43b 100644 --- a/include/arch/x86/arch/64/mode/model/statedata.h +++ b/include/arch/x86/arch/64/mode/model/statedata.h @@ -15,7 +15,7 @@ #include #include -#include +#include extern pml4e_t x64KSGlobalPML4[BIT(PML4_INDEX_BITS)]; extern pdpte_t x64KSGlobalPDPT[BIT(PDPT_INDEX_BITS)]; diff --git a/include/arch/x86/arch/kernel/lock.h b/include/arch/x86/arch/kernel/lock.h index adb3a7147..1e6c32b53 100644 --- a/include/arch/x86/arch/kernel/lock.h +++ b/include/arch/x86/arch/kernel/lock.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #if CONFIG_MAX_NUM_NODES > 1 diff --git a/include/arch/x86/arch/kernel/tlb.h b/include/arch/x86/arch/kernel/tlb.h index 57e4c2e21..bd112d450 100644 --- a/include/arch/x86/arch/kernel/tlb.h +++ b/include/arch/x86/arch/kernel/tlb.h @@ -13,7 +13,7 @@ #ifndef __ARCH_KERNEL_TLB_H #define __ARCH_KERNEL_TLB_H -#include +#include static inline void invalidatePageStructureCacheASID(paddr_t root, asid_t asid, word_t mask) { diff --git a/include/arch/x86/arch/smp/ipi.h b/include/arch/x86/arch/smp/ipi.h new file mode 100644 index 000000000..4d72bc016 --- /dev/null +++ b/include/arch/x86/arch/smp/ipi.h @@ -0,0 +1,34 @@ +/* + * Copyright 2016, Data61 + * Commonwealth Scientific and Industrial Research Organisation (CSIRO) + * ABN 41 687 119 230. + * + * This software may be distributed and modified according to the terms of + * the GNU General Public License version 2. Note that NO WARRANTY is provided. + * See "LICENSE_GPLv2.txt" for details. + * + * @TAG(D61_GPL) + */ + +#ifndef __ARCH_KERNEL_IPI_H +#define __ARCH_KERNEL_IPI_H + +#include + +#if CONFIG_MAX_NUM_NODES > 1 +typedef enum { + IpiRemoteCall_Stall, +#ifdef CONFIG_VTX + IpiRemoteCall_ClearCurrentVCPU, + IpiRemoteCall_VMCheckBoundNotification, +#endif + IpiRemoteCall_InvalidatePageStructureCacheASID, + IpiRemoteCall_InvalidateTranslationSingle, + IpiRemoteCall_InvalidateTranslationSingleASID, + IpiRemoteCall_InvalidateTranslationAll, + IpiRemoteCall_switchFpuOwner, + IpiNumArchRemoteCall +} IpiRemoteCall_t; + +#endif /* CONFIG_MAX_NUM_NODES > 1 */ +#endif /* __ARCH_KERNEL_IPI_H */ diff --git a/include/arch/x86/arch/smp/ipi_inline.h b/include/arch/x86/arch/smp/ipi_inline.h new file mode 100644 index 000000000..f14d8d58a --- /dev/null +++ b/include/arch/x86/arch/smp/ipi_inline.h @@ -0,0 +1,65 @@ +/* +* Copyright 2016, Data61 +* Commonwealth Scientific and Industrial Research Organisation (CSIRO) +* ABN 41 687 119 230. +* +* This software may be distributed and modified according to the terms of +* the GNU General Public License version 2. Note that NO WARRANTY is provided. +* See "LICENSE_GPLv2.txt" for details. +* +* @TAG(D61_GPL) +*/ + +#ifndef __ARCH_KERNEL_IPI_INLINE_H +#define __ARCH_KERNEL_IPI_INLINE_H + +#include +#include + +#if CONFIG_MAX_NUM_NODES > 1 +static inline void doRemoteStall(word_t cpu) +{ + doRemoteOp0Arg(IpiRemoteCall_Stall, cpu); +} + +static inline void doRemoteswitchFpuOwner(user_fpu_state_t *new_owner, word_t cpu) +{ + doRemoteOp1Arg(IpiRemoteCall_switchFpuOwner, (word_t)new_owner, cpu); +} + +static inline void doRemoteInvalidatePageStructureCacheASID(paddr_t root, asid_t asid, word_t mask) +{ + doRemoteMaskOp2Arg(IpiRemoteCall_InvalidatePageStructureCacheASID, root, asid, mask); +} + +static inline void doRemoteInvalidateTranslationSingle(vptr_t vptr, word_t mask) +{ + doRemoteMaskOp1Arg(IpiRemoteCall_InvalidateTranslationSingle, vptr, mask); +} + +static inline void doRemoteInvalidateTranslationSingleASID(vptr_t vptr, asid_t asid, word_t mask) +{ + doRemoteMaskOp2Arg(IpiRemoteCall_InvalidateTranslationSingleASID, vptr, asid, mask); +} + +static inline void doRemoteInvalidateTranslationAll(word_t mask) +{ + doRemoteMaskOp0Arg(IpiRemoteCall_InvalidateTranslationAll, mask); +} + +#ifdef CONFIG_VTX +static inline void +doRemoteClearCurrentVCPU(word_t cpu) +{ + doRemoteOp0Arg(IpiRemoteCall_ClearCurrentVCPU, cpu); +} + +static inline void +doRemoteVMCheckBoundNotification(word_t cpu) +{ + doRemoteOp0Arg(IpiRemoteCall_VMCheckBoundNotification, cpu); +} +#endif + +#endif /* CONFIG_MAX_NUM_NODES > 1 */ +#endif /* __ARCH_KERNEL_IPI_INLINE_H */ diff --git a/include/model/statedata.h b/include/model/statedata.h index c39fde17e..47d3068dc 100644 --- a/include/model/statedata.h +++ b/include/model/statedata.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #define NUM_READY_QUEUES (CONFIG_NUM_DOMAINS * CONFIG_NUM_PRIORITIES) diff --git a/include/arch/x86/arch/kernel/ipi.h b/include/smp/ipi.h similarity index 66% rename from include/arch/x86/arch/kernel/ipi.h rename to include/smp/ipi.h index 239379b4c..02164c7a0 100644 --- a/include/arch/x86/arch/kernel/ipi.h +++ b/include/smp/ipi.h @@ -10,32 +10,19 @@ * @TAG(D61_GPL) */ -#ifndef __ARCH_KERNEL_IPI_H -#define __ARCH_KERNEL_IPI_H +#ifndef __IPI_H +#define __IPI_H #include #include #include +#include #if CONFIG_MAX_NUM_NODES > 1 #define MAX_IPI_ARGS 3 /* Maximum number of parameters to remote function */ void Arch_handleIPI(irq_t irq); -typedef enum { - IpiRemoteCall_Stall, -#ifdef CONFIG_VTX - IpiRemoteCall_ClearCurrentVCPU, - IpiRemoteCall_VMCheckBoundNotification, -#endif - IpiRemoteCall_InvalidatePageStructureCacheASID, - IpiRemoteCall_InvalidateTranslationSingle, - IpiRemoteCall_InvalidateTranslationSingleASID, - IpiRemoteCall_InvalidateTranslationAll, - IpiRemoteCall_switchFpuOwner, - IpiNumArchRemoteCall -} IpiRemoteCall_t; - /* * Run a synchronous function on all cores specified by mask. Return when target cores * have all executed the function. Caller must hold the lock. @@ -131,49 +118,5 @@ static void inline doReschedule(word_t cpu) } } -static void inline doRemoteStall(word_t cpu) -{ - doRemoteOp0Arg(IpiRemoteCall_Stall, cpu); -} - -static void inline doRemoteswitchFpuOwner(user_fpu_state_t *new_owner, word_t cpu) -{ - doRemoteOp1Arg(IpiRemoteCall_switchFpuOwner, (word_t)new_owner, cpu); -} - -static void inline doRemoteInvalidatePageStructureCacheASID(paddr_t root, asid_t asid, word_t mask) -{ - doRemoteMaskOp2Arg(IpiRemoteCall_InvalidatePageStructureCacheASID, root, asid, mask); -} - -static void inline doRemoteInvalidateTranslationSingle(vptr_t vptr, word_t mask) -{ - doRemoteMaskOp1Arg(IpiRemoteCall_InvalidateTranslationSingle, vptr, mask); -} - -static void inline doRemoteInvalidateTranslationSingleASID(vptr_t vptr, asid_t asid, word_t mask) -{ - doRemoteMaskOp2Arg(IpiRemoteCall_InvalidateTranslationSingleASID, vptr, asid, mask); -} - -static void inline doRemoteInvalidateTranslationAll(word_t mask) -{ - doRemoteMaskOp0Arg(IpiRemoteCall_InvalidateTranslationAll, mask); -} - -#ifdef CONFIG_VTX -static inline void -doRemoteClearCurrentVCPU(word_t cpu) -{ - doRemoteOp0Arg(IpiRemoteCall_ClearCurrentVCPU, cpu); -} - -static inline void -doRemoteVMCheckBoundNotification(word_t cpu) -{ - doRemoteOp0Arg(IpiRemoteCall_VMCheckBoundNotification, cpu); -} -#endif - #endif /* CONFIG_MAX_NUM_NODES */ -#endif /* __ARCH_KERNEL_IPI_H */ +#endif /* __IPI_H */ diff --git a/include/model/smp.h b/include/smp/smp.h similarity index 94% rename from include/model/smp.h rename to include/smp/smp.h index 7cfbf3f80..be0a2e916 100644 --- a/include/model/smp.h +++ b/include/smp/smp.h @@ -10,8 +10,8 @@ * @TAG(D61_GPL) */ -#ifndef __MODEL_SMP_H_ -#define __MODEL_SMP_H_ +#ifndef __SMP_H_ +#define __SMP_H_ #include @@ -42,4 +42,4 @@ #endif /* CONFIG_MAX_NUM_NODES */ -#endif /* __MODEL_SMP_H_ */ +#endif /* __SMP_H_ */ diff --git a/src/arch/x86/kernel/ipi.c b/src/arch/x86/kernel/ipi.c index 1435899d0..b206b8bc2 100644 --- a/src/arch/x86/kernel/ipi.c +++ b/src/arch/x86/kernel/ipi.c @@ -12,9 +12,9 @@ #include #include -#include #include -#include +#include +#include #if CONFIG_MAX_NUM_NODES > 1 diff --git a/src/arch/x86/kernel/lock.c b/src/arch/x86/kernel/lock.c index 044791159..0a2beb0cd 100644 --- a/src/arch/x86/kernel/lock.c +++ b/src/arch/x86/kernel/lock.c @@ -11,7 +11,7 @@ */ #include -#include +#include #include #if CONFIG_MAX_NUM_NODES > 1 diff --git a/src/object/interrupt.c b/src/object/interrupt.c index 775cdf9d3..b467a256c 100644 --- a/src/object/interrupt.c +++ b/src/object/interrupt.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include exception_t decodeIRQControlInvocation(word_t invLabel, word_t length,