powerpc: Fix oops due to wrong access of lppaca on non virtualized platform
Subsystems (2)
PATCH v2 1/1 powerpc: Fix oops due to wrong access of lppaca on non virtualized platform
Commit 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not virtualized") removed allocation of lppaca on non virtualized platform. But with CONFIG_PPC_SPLPAR enabled, we do access lppaca non-virtualized platform in some code paths.
Fix this but adding runtime check for virtualized platform.
---
Changes from V1:
* update commit summary
arch/powerpc/include/asm/lppaca.h | 3 +++ arch/powerpc/include/asm/spinlock.h | 2 ++ arch/powerpc/kernel/time.c | 3 +++ 3 files changed, 8 insertions(+)
arch/powerpc/include/asm/lppaca.h +3 -0
@@ -34,6 +34,7 @@#include <linux/threads.h> #include <asm/types.h> #include <asm/mmu.h> +#include <asm/firmware.h> /* * The lppaca is the "virtual processor area" registered with the hypervisor,
@@ -114,6 +115,8 @@ struct lppaca {static inline bool lppaca_shared_proc (struct lppaca *l) { +if (!firmware_has_feature (FW_FEATURE_SPLPAR )) +return false;return !!(l->__old_status &LPPACA_OLD_SHARED_PROC ); }
arch/powerpc/include/asm/spinlock.h +2 -0
@@ -56,6 +56,8 @@#define vcpu_is_preempted vcpu_is_preemptedstatic inline bool vcpu_is_preempted (int cpu) { +if (!firmware_has_feature (FW_FEATURE_SPLPAR )) +return false;return !!(be32_to_cpu (lppaca_of (cpu).yield_count) &1 ); }#endif
arch/powerpc/kernel/time.c +3 -0
@@ -266,6 +266,9 @@ void accumulate_stolen_time(void)static inline u64 calculate_stolen_time (u64 stop_tb) { +if (!firmware_has_feature (FW_FEATURE_SPLPAR )) +return 0 ; +if (get_paca ()->dtl_ridx !=be64_to_cpu (get_lppaca ()->dtl_idx))return scan_dispatch_log (stop_tb);
Signature · 1 line
2.14.3
Nicholas Piggin
reviewerQuoted 10 lines · On Mon, 2 Apr 2018 13:03:37 +0530 "Aneesh Kumar K.V"…
Commit
8e0b634b1327("powerpc/64s: Do not allocate lppaca if we are not virtualized") removed allocation of lppaca on non virtualized platform. But withCONFIG_PPC_SPLPARenabled, we do access lppaca non-virtualized platform in some code paths.Fix this but adding runtime check for virtualized platform.
Fixes 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not virtualized")Signed-off-by Aneesh Kumar K.V <[email protected]>
Thanks, this looks good to me...
Quoted 22 lines
---
Changes from V1:
* update commit summaryarch/powerpc/include/asm/lppaca.h | 3 +++ arch/powerpc/include/asm/spinlock.h | 2 ++ arch/powerpc/kernel/time.c | 3 +++ 3 files changed, 8 insertions(+)arch/powerpc/include/asm/lppaca.h +1
-0@@ -34,6 +34,7 @@#include <linux/threads.h> #include <asm/types.h> #include <asm/mmu.h> +#include <asm/firmware.h> /* * The lppaca is the "virtual processor area" registered with the hypervisor,
arch/powerpc/include/asm/lppaca.h struct lppaca { · line 122
Quoted 8 lines
arch/powerpc/include/asm/lppaca.h +2
-0@@ -114,6 +115,8 @@ struct lppaca {static inline bool lppaca_shared_proc (struct lppaca *l) { +if (!firmware_has_feature (FW_FEATURE_SPLPAR )) +return false;return !!(l->__old_status &LPPACA_OLD_SHARED_PROC ); }
We should eventually clean this up. There's no need to pass in an lppaca here AFAIKS. Is it even per-CPU, does it change dynamically? We could set it up in a FW_FEATURE parameter at boot, which would could make some of these tests cheaper.
Quoted 27 lines
arch/powerpc/include/asm/spinlock.h +2
-0@@ -56,6 +56,8 @@#define vcpu_is_preempted vcpu_is_preemptedstatic inline bool vcpu_is_preempted (int cpu) { +if (!firmware_has_feature (FW_FEATURE_SPLPAR )) +return false;return !!(be32_to_cpu (lppaca_of (cpu).yield_count) &1 ); }#endif arch/powerpc/kernel/time.c +3
-0@@ -266,6 +266,9 @@ void accumulate_stolen_time(void)static inline u64 calculate_stolen_time (u64 stop_tb) { +if (!firmware_has_feature (FW_FEATURE_SPLPAR )) +return 0 ; +if (get_paca ()->dtl_ridx !=be64_to_cpu (get_lppaca ()->dtl_idx))return scan_dispatch_log (stop_tb);
Michael Ellerman
AppliedQuoted 10 lines · Aneesh Kumar K.V
Commit
8e0b634b1327("powerpc/64s: Do not allocate lppaca if we are not virtualized") removed allocation of lppaca on non virtualized platform. But withCONFIG_PPC_SPLPARenabled, we do access lppaca non-virtualized platform in some code paths.Fix this but adding runtime check for virtualized platform.
Fixes 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not virtualized")Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/a6201da34ff9366680e97392efd06a
cheers