stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary
@ 2019-11-26 13:48 Lee Jones
  2019-11-26 13:48 ` [PATCH 4.19 2/5] media: siano: Use kmemdup instead of duplicating its function Lee Jones
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Lee Jones @ 2019-11-26 13:48 UTC (permalink / raw)
  To: stable

From: Chester Lin <clin@suse.com>

[ Upstream commit 59f200ef45852141dd45847563bf8e4c11a48f3f ]

adjust_lowmem_bounds() checks every memblocks in order to find the boundary
between lowmem and highmem. However some memblocks could be marked as NOMAP
so they are not used by kernel, which should be skipped while calculating
the boundary.

Signed-off-by: Chester Lin <clin@suse.com>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 arch/arm/mm/mmu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 70e560cf8ca0..d8cbe772f690 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1195,6 +1195,9 @@ void __init adjust_lowmem_bounds(void)
 		phys_addr_t block_start = reg->base;
 		phys_addr_t block_end = reg->base + reg->size;
 
+		if (memblock_is_nomap(reg))
+			continue;
+
 		if (reg->base < vmalloc_limit) {
 			if (block_end > lowmem_limit)
 				/*
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4.19 2/5] media: siano: Use kmemdup instead of duplicating its function
  2019-11-26 13:48 [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones
@ 2019-11-26 13:48 ` Lee Jones
  2019-11-26 13:48 ` [PATCH 4.19 3/5] arm64: fix for bad_mode() handler to always result in panic Lee Jones
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2019-11-26 13:48 UTC (permalink / raw)
  To: stable

From: Wen Yang <wen.yang99@zte.com.cn>

[ Upstream commit 188ba34e2bcfc9a23d301bd78e35bc1d5ad9ae5a ]

kmemdup has implemented the function that kmalloc() + memcpy().
We prefer to kmemdup rather than code opened implementation.

This issue was detected with the help of coccinelle.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
CC: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
CC: linux-kernel@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/media/usb/siano/smsusb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index ec759f43c634..3ab72d653737 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -226,10 +226,9 @@ static int smsusb_sendrequest(void *context, void *buffer, size_t size)
 		return -ENOENT;
 	}
 
-	phdr = kmalloc(size, GFP_KERNEL);
+	phdr = kmemdup(buffer, size, GFP_KERNEL);
 	if (!phdr)
 		return -ENOMEM;
-	memcpy(phdr, buffer, size);
 
 	pr_debug("sending %s(%d) size: %d\n",
 		  smscore_translate_msg(phdr->msg_type), phdr->msg_type,
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4.19 3/5] arm64: fix for bad_mode() handler to always result in panic
  2019-11-26 13:48 [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones
  2019-11-26 13:48 ` [PATCH 4.19 2/5] media: siano: Use kmemdup instead of duplicating its function Lee Jones
@ 2019-11-26 13:48 ` Lee Jones
  2019-11-26 13:48 ` [PATCH 4.19 4/5] cpufreq: Skip cpufreq resume if it's not suspended Lee Jones
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2019-11-26 13:48 UTC (permalink / raw)
  To: stable

From: Hari Vyas <hari.vyas@broadcom.com>

[ Upstream commit 64cd64a02fc8bb23916ee8841ef510f2f1f2540c ]

The bad_mode() handler is called if we encounter an uunknown exception,
with the expectation that the subsequent call to panic() will halt the
system. Unfortunately, if the exception calling bad_mode() is taken from
EL0, then the call to die() can end up killing the current user task and
calling schedule() instead of falling through to panic().

Remove the die() call altogether, since we really want to bring down the
machine in this "impossible" case.

Signed-off-by: Hari Vyas <hari.vyas@broadcom.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 arch/arm64/kernel/traps.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index a4e49e947684..5ae9c86c30d1 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -648,7 +648,6 @@ asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
 		handler[reason], smp_processor_id(), esr,
 		esr_get_class_string(esr));
 
-	die("Oops - bad mode", regs, 0);
 	local_irq_disable();
 	panic("bad mode");
 }
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4.19 4/5] cpufreq: Skip cpufreq resume if it's not suspended
  2019-11-26 13:48 [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones
  2019-11-26 13:48 ` [PATCH 4.19 2/5] media: siano: Use kmemdup instead of duplicating its function Lee Jones
  2019-11-26 13:48 ` [PATCH 4.19 3/5] arm64: fix for bad_mode() handler to always result in panic Lee Jones
@ 2019-11-26 13:48 ` Lee Jones
  2019-11-26 13:48 ` [PATCH 4.19 5/5] ocfs2: remove ocfs2_is_o2cb_active() Lee Jones
  2019-11-26 14:55 ` [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2019-11-26 13:48 UTC (permalink / raw)
  To: stable

From: Bo Yan <byan@nvidia.com>

[ Upstream commit 7815c05f24b49fe6e70505905e3773cd27c17b6c ]

cpufreq_resume can be called even without preceding cpufreq_suspend.
This can happen in following scenario:

    suspend_devices_and_enter
       --> dpm_suspend_start
          --> dpm_prepare
              --> device_prepare : this function errors out
          --> dpm_suspend: this is skipped due to dpm_prepare failure
                           this means cpufreq_suspend is skipped over
       --> goto Recover_platform, due to previous error
       --> goto Resume_devices
       --> dpm_resume_end
           --> dpm_resume
               --> cpufreq_resume

In case schedutil is used as frequency governor, cpufreq_resume will
eventually call sugov_start, which does following:

    memset(sg_cpu, 0, sizeof(*sg_cpu));
    ....

This effectively erases function pointer for frequency update, causing
crash later on. The function pointer would have been set correctly if
subsequent cpufreq_add_update_util_hook runs successfully, but that
function returns earlier because cpufreq_suspend was not called:

    if (WARN_ON(per_cpu(cpufreq_update_util_data, cpu)))
		return;

The fix is to check cpufreq_suspended first, if it's false, that means
cpufreq_suspend was not called in the first place, so do not resume
cpufreq.

Signed-off-by: Bo Yan <byan@nvidia.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
[ rjw: Dropped printing a message ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 4aa3c5331666..52fc08a92bb9 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1673,6 +1673,9 @@ void cpufreq_resume(void)
 	if (!cpufreq_driver)
 		return;
 
+	if (unlikely(!cpufreq_suspended))
+		return;
+
 	cpufreq_suspended = false;
 
 	if (!has_target() && !cpufreq_driver->resume)
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4.19 5/5] ocfs2: remove ocfs2_is_o2cb_active()
  2019-11-26 13:48 [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones
                   ` (2 preceding siblings ...)
  2019-11-26 13:48 ` [PATCH 4.19 4/5] cpufreq: Skip cpufreq resume if it's not suspended Lee Jones
@ 2019-11-26 13:48 ` Lee Jones
  2019-11-26 14:55 ` [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2019-11-26 13:48 UTC (permalink / raw)
  To: stable

From: Gang He <ghe@suse.com>

[ Upstream commit 22ee66ccece0e779fa67c9e7266b926bbc5e903e ]

Remove ocfs2_is_o2cb_active().  We have similar functions to identify
which cluster stack is being used via osb->osb_cluster_stack.

Secondly, the current implementation of ocfs2_is_o2cb_active() is not
totally safe.  Based on the design of stackglue, we need to get
ocfs2_stack_lock before using ocfs2_stack related data structures, and
that active_stack pointer can be NULL in the case of mount failure.

Link: http://lkml.kernel.org/r/1495441079-11708-1-git-send-email-ghe@suse.com
Signed-off-by: Gang He <ghe@suse.com>
Reviewed-by: Joseph Qi <jiangqi903@gmail.com>
Reviewed-by: Eric Ren <zren@suse.com>
Acked-by: Changwei Ge <ge.changwei@h3c.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 fs/ocfs2/dlmglue.c   | 2 +-
 fs/ocfs2/stackglue.c | 6 ------
 fs/ocfs2/stackglue.h | 3 ---
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 5193218f5889..e961015fb484 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3422,7 +3422,7 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
 	 * we can recover correctly from node failure. Otherwise, we may get
 	 * invalid LVB in LKB, but without DLM_SBF_VALNOTVALID being set.
 	 */
-	if (!ocfs2_is_o2cb_active() &&
+	if (ocfs2_userspace_stack(osb) &&
 	    lockres->l_ops->flags & LOCK_TYPE_USES_LVB)
 		lvb = 1;
 
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index d6c350ba25b9..c4b029c43464 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -48,12 +48,6 @@ static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
  */
 static struct ocfs2_stack_plugin *active_stack;
 
-inline int ocfs2_is_o2cb_active(void)
-{
-	return !strcmp(active_stack->sp_name, OCFS2_STACK_PLUGIN_O2CB);
-}
-EXPORT_SYMBOL_GPL(ocfs2_is_o2cb_active);
-
 static struct ocfs2_stack_plugin *ocfs2_stack_lookup(const char *name)
 {
 	struct ocfs2_stack_plugin *p;
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h
index e3036e1790e8..f2dce10fae54 100644
--- a/fs/ocfs2/stackglue.h
+++ b/fs/ocfs2/stackglue.h
@@ -298,9 +298,6 @@ void ocfs2_stack_glue_set_max_proto_version(struct ocfs2_protocol_version *max_p
 int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
 void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
 
-/* In ocfs2_downconvert_lock(), we need to know which stack we are using */
-int ocfs2_is_o2cb_active(void);
-
 extern struct kset *ocfs2_kset;
 
 #endif  /* STACKGLUE_H */
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary
  2019-11-26 13:48 [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones
                   ` (3 preceding siblings ...)
  2019-11-26 13:48 ` [PATCH 4.19 5/5] ocfs2: remove ocfs2_is_o2cb_active() Lee Jones
@ 2019-11-26 14:55 ` Lee Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2019-11-26 14:55 UTC (permalink / raw)
  To: stable

Sorry, guys, copy/paste error.

These 5 patches are headed for 4.14 NOT 4.19.

On Tue, 26 Nov 2019, Lee Jones wrote:

> From: Chester Lin <clin@suse.com>
> 
> [ Upstream commit 59f200ef45852141dd45847563bf8e4c11a48f3f ]
> 
> adjust_lowmem_bounds() checks every memblocks in order to find the boundary
> between lowmem and highmem. However some memblocks could be marked as NOMAP
> so they are not used by kernel, which should be skipped while calculating
> the boundary.
> 
> Signed-off-by: Chester Lin <clin@suse.com>
> Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  arch/arm/mm/mmu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
> index 70e560cf8ca0..d8cbe772f690 100644
> --- a/arch/arm/mm/mmu.c
> +++ b/arch/arm/mm/mmu.c
> @@ -1195,6 +1195,9 @@ void __init adjust_lowmem_bounds(void)
>  		phys_addr_t block_start = reg->base;
>  		phys_addr_t block_end = reg->base + reg->size;
>  
> +		if (memblock_is_nomap(reg))
> +			continue;
> +
>  		if (reg->base < vmalloc_limit) {
>  			if (block_end > lowmem_limit)
>  				/*

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-26 14:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 13:48 [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones
2019-11-26 13:48 ` [PATCH 4.19 2/5] media: siano: Use kmemdup instead of duplicating its function Lee Jones
2019-11-26 13:48 ` [PATCH 4.19 3/5] arm64: fix for bad_mode() handler to always result in panic Lee Jones
2019-11-26 13:48 ` [PATCH 4.19 4/5] cpufreq: Skip cpufreq resume if it's not suspended Lee Jones
2019-11-26 13:48 ` [PATCH 4.19 5/5] ocfs2: remove ocfs2_is_o2cb_active() Lee Jones
2019-11-26 14:55 ` [PATCH 4.19 1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).