* [PATCH V2] powerpc: Fix oops due to wrong access of lppaca on non virtualized platform
@ 2018-04-02 7:33 Aneesh Kumar K.V
2018-04-02 7:41 ` Nicholas Piggin
2018-04-03 16:03 ` [V2] " Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Aneesh Kumar K.V @ 2018-04-02 7:33 UTC (permalink / raw)
To: benh, paulus, mpe, npiggin; +Cc: linuxppc-dev, 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 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.
Fixes: 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not virtualized")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
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(+)
diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h
index 65d589689f01..7c23ce8a5a4c 100644
--- a/arch/powerpc/include/asm/lppaca.h
+++ b/arch/powerpc/include/asm/lppaca.h
@@ -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);
}
diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
index b9ebc3085fb7..72dc4ddc2972 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -56,6 +56,8 @@
#define vcpu_is_preempted vcpu_is_preempted
static 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
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index f7d96a68ecaa..360e71d455cc 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -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);
--
2.14.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] powerpc: Fix oops due to wrong access of lppaca on non virtualized platform
2018-04-02 7:33 [PATCH V2] powerpc: Fix oops due to wrong access of lppaca on non virtualized platform Aneesh Kumar K.V
@ 2018-04-02 7:41 ` Nicholas Piggin
2018-04-03 16:03 ` [V2] " Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Nicholas Piggin @ 2018-04-02 7:41 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: benh, paulus, mpe, linuxppc-dev
On Mon, 2 Apr 2018 13:03:37 +0530
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> wrote:
> 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.
>
> Fixes: 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not virtualized")
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Thanks, this looks good to me...
> ---
> 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(+)
>
> diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h
> index 65d589689f01..7c23ce8a5a4c 100644
> --- a/arch/powerpc/include/asm/lppaca.h
> +++ b/arch/powerpc/include/asm/lppaca.h
> @@ -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);
> }
>
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.
> diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
> index b9ebc3085fb7..72dc4ddc2972 100644
> --- a/arch/powerpc/include/asm/spinlock.h
> +++ b/arch/powerpc/include/asm/spinlock.h
> @@ -56,6 +56,8 @@
> #define vcpu_is_preempted vcpu_is_preempted
> static 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
> diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
> index f7d96a68ecaa..360e71d455cc 100644
> --- a/arch/powerpc/kernel/time.c
> +++ b/arch/powerpc/kernel/time.c
> @@ -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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [V2] powerpc: Fix oops due to wrong access of lppaca on non virtualized platform
2018-04-02 7:33 [PATCH V2] powerpc: Fix oops due to wrong access of lppaca on non virtualized platform Aneesh Kumar K.V
2018-04-02 7:41 ` Nicholas Piggin
@ 2018-04-03 16:03 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Aneesh Kumar K.V, benh, paulus, npiggin; +Cc: Aneesh Kumar K.V, linuxppc-dev
On Mon, 2018-04-02 at 07:33:37 UTC, "Aneesh Kumar K.V" wrote:
> 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.
>
> Fixes: 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not virtualized")
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/a6201da34ff9366680e97392efd06a
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-03 16:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-02 7:33 [PATCH V2] powerpc: Fix oops due to wrong access of lppaca on non virtualized platform Aneesh Kumar K.V
2018-04-02 7:41 ` Nicholas Piggin
2018-04-03 16:03 ` [V2] " Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.