RE: [U-Boot] [RFC PATCH] net: designware: drop compatible altr, socfpga-stmmac

2019-09-03 Thread Alexey Brodkin
Hi Joe,

> -Original Message-
> From: Joe Hershberger 
> Sent: Wednesday, September 4, 2019 1:10 AM
> To: Alexey Brodkin 
> Cc: Ralph Siemsen ; Joseph Hershberger 
> ; u-
> b...@lists.denx.de; linux-snps-arc@lists.infradead.org; Eugeniy Paltsev 
> 
> Subject: Re: [U-Boot] [RFC PATCH] net: designware: drop compatible altr, 
> socfpga-stmmac
> 
> On Tue, Aug 20, 2019 at 3:07 AM Alexey Brodkin
>  wrote:
> >
> > Hi Ralph,
> >
> > > -Original Message-
> > > From: Ralph Siemsen 
> > > Sent: Monday, August 19, 2019 9:43 PM
> > > To: u-b...@lists.denx.de; Joe Hershberger ; 
> > > Alexey Brodkin
> > > ; Vlad Zakharov 
> > > Cc: Ralph Siemsen 
> > > Subject: [RFC PATCH] net: designware: drop compatible altr,socfpga-stmmac
> > >
> > > The same compatible = "altr,socfpga-stmmac" appears in both
> > > drivers/net/designware.c and drivers/net/dwmac_socfgpa.c,
> > > creating ambiguity in which driver will be bound.
> > >
> > > For Intel/Altera SoC devices, dwmac_socfpga.c is the correct driver.
> > > So drop the compatible string from designware.c.
> > >
> > > Signed-off-by: Ralph Siemsen 
> > > ---
> > > This compatible string also appears in: axs10x_mb.dtsi and hsdk.dts.
> > > Maintainers of those boards have been copied, kindly review.
> >
> > Thanks for this clean-up.
> >
> > Speaking about AXS10x board where we do have DW GMAC
> > I cannot recall the reason I chose to use "altr,socfpga-stmmac"
> > for the board here [1] 3 years ago.
> >
> > But given we don't have any special quirks implemented whatever
> > is the most generic DW GMAC compatible string is should be good for us.
> >
> > Joe, could you please suggest if we need to use just "st,stm32-dwmac"
> > or add our own compatible as the ASIC is not from ST obviously but
> > an FPGA with Synopsys ARC SoC?
> 
> I think we should only be using what Linux does, so I'm afraid I have
> to defer to what exists in the DTs there.

In the Linux kernel we use "snps,dwmac", see [1].
But maybe we need to switch to "snps,dwmac-3.70a" even as what we really have 
is 3.73a.

While in U-Boot we don't have either one, the most generic is "st,stm32-dwmac", 
see [2].
So maybe we want to add at least "snps,dwmac".

@Jose Abreu could you please confirm if "snps,dwmac-3.70a" is OK for GMAC IP 
v3.73a?

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arc/boot/dts/axs10x_mb.dtsi#n74
[2] 
https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/net/designware.c#L855

-Alexey
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/3] kbuild, arc: add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC

2019-09-03 Thread Vineet Gupta
On 9/3/19 8:08 AM, Masahiro Yamada wrote:
>> So if you could please split out the Wmaybe-uninitialized change
> I could not understand your request.
>
> I added 'imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED'
> for CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3.
>
> I cannot split it out. Otherwise, you will see false-positive
> maybe-uninitialized warnings.

Sorry I must have overlooked this part. So no issues now !

Thx,
-Vineet

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


test email 3 from webmail

2019-09-03 Thread Vineet Gupta


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


test email 2

2019-09-03 Thread Vineet Gupta


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [U-Boot] [RFC PATCH] net: designware: drop compatible altr, socfpga-stmmac

2019-09-03 Thread Joe Hershberger
On Tue, Aug 20, 2019 at 3:07 AM Alexey Brodkin
 wrote:
>
> Hi Ralph,
>
> > -Original Message-
> > From: Ralph Siemsen 
> > Sent: Monday, August 19, 2019 9:43 PM
> > To: u-b...@lists.denx.de; Joe Hershberger ; Alexey 
> > Brodkin
> > ; Vlad Zakharov 
> > Cc: Ralph Siemsen 
> > Subject: [RFC PATCH] net: designware: drop compatible altr,socfpga-stmmac
> >
> > The same compatible = "altr,socfpga-stmmac" appears in both
> > drivers/net/designware.c and drivers/net/dwmac_socfgpa.c,
> > creating ambiguity in which driver will be bound.
> >
> > For Intel/Altera SoC devices, dwmac_socfpga.c is the correct driver.
> > So drop the compatible string from designware.c.
> >
> > Signed-off-by: Ralph Siemsen 
> > ---
> > This compatible string also appears in: axs10x_mb.dtsi and hsdk.dts.
> > Maintainers of those boards have been copied, kindly review.
>
> Thanks for this clean-up.
>
> Speaking about AXS10x board where we do have DW GMAC
> I cannot recall the reason I chose to use "altr,socfpga-stmmac"
> for the board here [1] 3 years ago.
>
> But given we don't have any special quirks implemented whatever
> is the most generic DW GMAC compatible string is should be good for us.
>
> Joe, could you please suggest if we need to use just "st,stm32-dwmac"
> or add our own compatible as the ASIC is not from ST obviously but
> an FPGA with Synopsys ARC SoC?

I think we should only be using what Linux does, so I'm afraid I have
to defer to what exists in the DTs there.

-Joe

> [1] 
> https://gitlab.denx.de/u-boot/u-boot/commit/fb2dea60e8f355ae00d427db09112a90839c96ec
>
> -Alexey
> ___
> U-Boot mailing list
> u-b...@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH AUTOSEL 4.19 111/167] signal/arc: Use force_sig_fault where appropriate

2019-09-03 Thread Sasha Levin

On Tue, Sep 03, 2019 at 11:49:16AM -0500, Eric W. Biederman wrote:

Sasha Levin  writes:


From: "Eric W. Biederman" 

[ Upstream commit 15773ae938d8d93d982461990bebad6e1d7a1830 ]


To the best of my knowledge this is just a clean up, no changes in
behavior are present.

The only reason I can see to backport this is so that later fixes could
be applied cleanly.

So while I have no objections to this patch being backported I don't see
why you would want to either.


This patch along with the next one came in as a dependency for
a8c715b4dd73c ("ARC: mm: SIGSEGV userspace trying to access kernel
virtual memory").

--
Thanks,
Sasha


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH AUTOSEL 4.19 111/167] signal/arc: Use force_sig_fault where appropriate

2019-09-03 Thread Eric W. Biederman
Sasha Levin  writes:

> From: "Eric W. Biederman" 
>
> [ Upstream commit 15773ae938d8d93d982461990bebad6e1d7a1830 ]

To the best of my knowledge this is just a clean up, no changes in
behavior are present.

The only reason I can see to backport this is so that later fixes could
be applied cleanly.

So while I have no objections to this patch being backported I don't see
why you would want to either.

> Acked-by: Vineet Gupta 
> Signed-off-by: "Eric W. Biederman" 
> Signed-off-by: Sasha Levin 
> ---
>  arch/arc/mm/fault.c | 20 +---
>  1 file changed, 5 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
> index f28db0b112a30..a0366f9dca051 100644
> --- a/arch/arc/mm/fault.c
> +++ b/arch/arc/mm/fault.c
> @@ -66,14 +66,12 @@ void do_page_fault(unsigned long address, struct pt_regs 
> *regs)
>   struct vm_area_struct *vma = NULL;
>   struct task_struct *tsk = current;
>   struct mm_struct *mm = tsk->mm;
> - siginfo_t info;
> + int si_code;
>   int ret;
>   vm_fault_t fault;
>   int write = regs->ecr_cause & ECR_C_PROTV_STORE;  /* ST/EX */
>   unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
>  
> - clear_siginfo();
> -
>   /*
>* We fault-in kernel-space virtual memory on-demand. The
>* 'reference' page table is init_mm.pgd.
> @@ -91,7 +89,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
> *regs)
>   return;
>   }
>  
> - info.si_code = SEGV_MAPERR;
> + si_code = SEGV_MAPERR;
>  
>   /*
>* If we're in an interrupt or have no user
> @@ -119,7 +117,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
> *regs)
>* we can handle it..
>*/
>  good_area:
> - info.si_code = SEGV_ACCERR;
> + si_code = SEGV_ACCERR;
>  
>   /* Handle protection violation, execute on heap or stack */
>  
> @@ -204,11 +202,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
> *regs)
>   /* User mode accesses just cause a SIGSEGV */
>   if (user_mode(regs)) {
>   tsk->thread.fault_address = address;
> - info.si_signo = SIGSEGV;
> - info.si_errno = 0;
> - /* info.si_code has been set above */
> - info.si_addr = (void __user *)address;
> - force_sig_info(SIGSEGV, , tsk);
> + force_sig_fault(SIGSEGV, si_code, (void __user *)address, tsk);
>   return;
>   }
>  
> @@ -243,9 +237,5 @@ void do_page_fault(unsigned long address, struct pt_regs 
> *regs)
>   goto no_context;
>  
>   tsk->thread.fault_address = address;
> - info.si_signo = SIGBUS;
> - info.si_errno = 0;
> - info.si_code = BUS_ADRERR;
> - info.si_addr = (void __user *)address;
> - force_sig_info(SIGBUS, , tsk);
> + force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address, tsk);
>  }

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH AUTOSEL 4.19 113/167] ARC: mm: SIGSEGV userspace trying to access kernel virtual memory

2019-09-03 Thread Sasha Levin
From: Eugeniy Paltsev 

[ Upstream commit a8c715b4dd73c26a81a9cc8dc792aa715d8b4bb2 ]

As of today if userspace process tries to access a kernel virtual addres
(0x7000_ to 0x7_) such that a legit kernel mapping already
exists, that process hangs instead of being killed with SIGSEGV

Fix that by ensuring that do_page_fault() handles kenrel vaddr only if
in kernel mode.

And given this, we can also simplify the code a bit. Now a vmalloc fault
implies kernel mode so its failure (for some reason) can reuse the
@no_context label and we can remove @bad_area_nosemaphore.

Reproduce user test for original problem:

>8-
 #include 
 #include 

 int main(int argc, char *argv[])
 {
volatile uint32_t temp;

temp = *(uint32_t *)(0x7000);
 }
>8-

Cc: 
Signed-off-by: Eugeniy Paltsev 
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/mm/fault.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 535cf18e8bf2c..4e8143de32e70 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -66,7 +66,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
struct vm_area_struct *vma = NULL;
struct task_struct *tsk = current;
struct mm_struct *mm = tsk->mm;
-   int si_code = 0;
+   int si_code = SEGV_MAPERR;
int ret;
vm_fault_t fault;
int write = regs->ecr_cause & ECR_C_PROTV_STORE;  /* ST/EX */
@@ -81,16 +81,14 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
 * only copy the information from the master page table,
 * nothing more.
 */
-   if (address >= VMALLOC_START) {
+   if (address >= VMALLOC_START && !user_mode(regs)) {
ret = handle_kernel_vaddr_fault(address);
if (unlikely(ret))
-   goto bad_area_nosemaphore;
+   goto no_context;
else
return;
}
 
-   si_code = SEGV_MAPERR;
-
/*
 * If we're in an interrupt or have no user
 * context, we must not take the fault..
@@ -198,7 +196,6 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
 bad_area:
up_read(>mmap_sem);
 
-bad_area_nosemaphore:
/* User mode accesses just cause a SIGSEGV */
if (user_mode(regs)) {
tsk->thread.fault_address = address;
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH AUTOSEL 4.19 112/167] ARC: mm: fix uninitialised signal code in do_page_fault

2019-09-03 Thread Sasha Levin
From: Eugeniy Paltsev 

[ Upstream commit 121e38e5acdc8e1e4cdb750fcdcc72f94e420968 ]

Commit 15773ae938d8 ("signal/arc: Use force_sig_fault where
appropriate") introduced undefined behaviour by leaving si_code
unitiailized and leaking random kernel values to user space.

Fixes: 15773ae938d8 ("signal/arc: Use force_sig_fault where appropriate")
Signed-off-by: Eugeniy Paltsev 
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/mm/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index a0366f9dca051..535cf18e8bf2c 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -66,7 +66,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
struct vm_area_struct *vma = NULL;
struct task_struct *tsk = current;
struct mm_struct *mm = tsk->mm;
-   int si_code;
+   int si_code = 0;
int ret;
vm_fault_t fault;
int write = regs->ecr_cause & ECR_C_PROTV_STORE;  /* ST/EX */
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH AUTOSEL 4.19 111/167] signal/arc: Use force_sig_fault where appropriate

2019-09-03 Thread Sasha Levin
From: "Eric W. Biederman" 

[ Upstream commit 15773ae938d8d93d982461990bebad6e1d7a1830 ]

Acked-by: Vineet Gupta 
Signed-off-by: "Eric W. Biederman" 
Signed-off-by: Sasha Levin 
---
 arch/arc/mm/fault.c | 20 +---
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index f28db0b112a30..a0366f9dca051 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -66,14 +66,12 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
struct vm_area_struct *vma = NULL;
struct task_struct *tsk = current;
struct mm_struct *mm = tsk->mm;
-   siginfo_t info;
+   int si_code;
int ret;
vm_fault_t fault;
int write = regs->ecr_cause & ECR_C_PROTV_STORE;  /* ST/EX */
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
 
-   clear_siginfo();
-
/*
 * We fault-in kernel-space virtual memory on-demand. The
 * 'reference' page table is init_mm.pgd.
@@ -91,7 +89,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
return;
}
 
-   info.si_code = SEGV_MAPERR;
+   si_code = SEGV_MAPERR;
 
/*
 * If we're in an interrupt or have no user
@@ -119,7 +117,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
 * we can handle it..
 */
 good_area:
-   info.si_code = SEGV_ACCERR;
+   si_code = SEGV_ACCERR;
 
/* Handle protection violation, execute on heap or stack */
 
@@ -204,11 +202,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
/* User mode accesses just cause a SIGSEGV */
if (user_mode(regs)) {
tsk->thread.fault_address = address;
-   info.si_signo = SIGSEGV;
-   info.si_errno = 0;
-   /* info.si_code has been set above */
-   info.si_addr = (void __user *)address;
-   force_sig_info(SIGSEGV, , tsk);
+   force_sig_fault(SIGSEGV, si_code, (void __user *)address, tsk);
return;
}
 
@@ -243,9 +237,5 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
goto no_context;
 
tsk->thread.fault_address = address;
-   info.si_signo = SIGBUS;
-   info.si_errno = 0;
-   info.si_code = BUS_ADRERR;
-   info.si_addr = (void __user *)address;
-   force_sig_info(SIGBUS, , tsk);
+   force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address, tsk);
 }
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH AUTOSEL 4.19 049/167] ARC: show_regs: lockdep: re-enable preemption

2019-09-03 Thread Sasha Levin
From: Vineet Gupta 

[ Upstream commit f731a8e89f8c78985707c626680f3e24c7a60772 ]

signal handling core calls show_regs() with preemption disabled which
on ARC takes mmap_sem for mm/vma access, causing lockdep splat.

| [ARCLinux]# ./segv-null-ptr
| potentially unexpected fatal signal 11.
| BUG: sleeping function called from invalid context at kernel/fork.c:1011
| in_atomic(): 1, irqs_disabled(): 0, pid: 70, name: segv-null-ptr
| no locks held by segv-null-ptr/70.
| CPU: 0 PID: 70 Comm: segv-null-ptr Not tainted 4.18.0+ #69
|
| Stack Trace:
|  arc_unwind_core+0xcc/0x100
|  ___might_sleep+0x17a/0x190
|  mmput+0x16/0xb8
|  show_regs+0x52/0x310
|  get_signal+0x5ee/0x610
|  do_signal+0x2c/0x218
|  resume_user_mode_begin+0x90/0xd8

Workaround by re-enabling preemption temporarily.

Note that the preemption disabling in core code around show_regs()
was introduced by commit 3a9f84d354ce ("signals, debug: fix BUG: using
smp_processor_id() in preemptible code in print_fatal_signal()")

to silence a differnt lockdep seen on x86 bakc in 2009.

Cc: 
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/kernel/troubleshoot.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index 5c6663321e873..215f515442e03 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -179,6 +179,12 @@ void show_regs(struct pt_regs *regs)
struct task_struct *tsk = current;
struct callee_regs *cregs;
 
+   /*
+* generic code calls us with preemption disabled, but some calls
+* here could sleep, so re-enable to avoid lockdep splat
+*/
+   preempt_enable();
+
print_task_path_n_nm(tsk);
show_regs_print_info(KERN_INFO);
 
@@ -221,6 +227,8 @@ void show_regs(struct pt_regs *regs)
cregs = (struct callee_regs *)current->thread.callee_reg;
if (cregs)
show_callee_regs(cregs);
+
+   preempt_disable();
 }
 
 void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH AUTOSEL 4.19 050/167] ARC: mm: do_page_fault fixes #1: relinquish mmap_sem if signal arrives while handle_mm_fault

2019-09-03 Thread Sasha Levin
From: Vineet Gupta 

[ Upstream commit 4d447455e73b47c43dd35fcc38ed823d3182a474 ]

do_page_fault() forgot to relinquish mmap_sem if a signal came while
handling handle_mm_fault() - due to say a ctl+c or oom etc.
This would later cause a deadlock by acquiring it twice.

This came to light when running libc testsuite tst-tls3-malloc test but
is likely also the cause for prior seen LTP failures. Using lockdep
clearly showed what the issue was.

| # while true; do ./tst-tls3-malloc ; done
| Didn't expect signal from child: got `Segmentation fault'
| ^C
| 
| WARNING: possible recursive locking detected
| 4.17.0+ #25 Not tainted
| 
| tst-tls3-malloc/510 is trying to acquire lock:
| 606c7728 (>mmap_sem){}, at: __might_fault+0x28/0x5c
|
|but task is already holding lock:
|606c7728 (>mmap_sem){}, at: do_page_fault+0x9c/0x2a0
|
| other info that might help us debug this:
|  Possible unsafe locking scenario:
|
|   CPU0
|   
|  lock(>mmap_sem);
|  lock(>mmap_sem);
|
| *** DEADLOCK ***
|


What the change does is not obvious (note to myself)

prior code was

| do_page_fault
|
|   down_read() <-- lock taken
|   handle_mm_fault <-- signal pending as this runs
|   if fatal_signal_pending
|   if VM_FAULT_ERROR
|   up_read
|   if user_mode
|  return   <-- lock still held, this was the BUG

New code

| do_page_fault
|
|   down_read() <-- lock taken
|   handle_mm_fault <-- signal pending as this runs
|   if fatal_signal_pending
|   if VM_FAULT_RETRY
|  return   <-- not same case as above, but still OK since
|   core mm already relinq lock for FAULT_RETRY
|...
|
|   < Now falls through for bug case above >
|
|   up_read()   <-- lock relinquished

Cc: sta...@vger.kernel.org
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/mm/fault.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index db6913094be3c..f28db0b112a30 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -143,12 +143,17 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
 */
fault = handle_mm_fault(vma, address, flags);
 
-   /* If Pagefault was interrupted by SIGKILL, exit page fault "early" */
if (unlikely(fatal_signal_pending(current))) {
-   if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY))
-   up_read(>mmap_sem);
-   if (user_mode(regs))
+
+   /*
+* if fault retry, mmap_sem already relinquished by core mm
+* so OK to return to user mode (with signal handled first)
+*/
+   if (fault & VM_FAULT_RETRY) {
+   if (!user_mode(regs))
+   goto no_context;
return;
+   }
}
 
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


RE: [PATCH] mmc: dw_mmc: fix timeout calculate method

2019-09-03 Thread Alexey Brodkin
H Tom,

[snip]

> > > This is the patch with problem, and here is the link on patchwork:
> > > https://patchwork.ozlabs.org/patch/1146845/
> >
> > Please find my fixes here:
> > https://patchwork.ozlabs.org/patch/1156541/
> > https://patchwork.ozlabs.org/patch/1156617/
> >
> > Tom do we want https://patchwork.ozlabs.org/patch/1146845/ and fixes for it
> > (see 2 items above) to become a part of upcoming v2019.10 release or
> > it will be slated for the next one?
> 
> I think we should aim to get all the fixes in for this release.

Done, see https://lists.denx.de/pipermail/u-boot/2019-September/382628.html

-Alexey
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/3] kbuild, arc: add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC

2019-09-03 Thread Masahiro Yamada
On Sat, Aug 31, 2019 at 1:43 AM Vineet Gupta  wrote:
>
> On 8/20/19 10:09 AM, Masahiro Yamada wrote:
> > arch/arc/Makefile overrides -O2 with -O3. This is the only user of
> > ARCH_CFLAGS. There is no user of ARCH_CPPFLAGS or ARCH_AFLAGS.
> > My plan is to remove ARCH_{CPP,A,C}FLAGS after refactoring the ARC
> > Makefile.
>
> Why, it seems like a good generic facility for arches to over-ride stuff
> (specially adding any toggles at the end of cmdline).
>
> And even if there are no current users, it would be good to have. I 
> understand we
> don't keep code for future, but strictly this is meta-code ;-)

We can re-add it whenever we need it.



> > Currently, ARC has no way to enable -Wmaybe-uninitialized because both
> > -O3 and -Os disable it. Enabling it will be useful for compile-testing.
> > This commit allows allmodconfig (, which defaults to -O2) to enable it.
>
> But this is a separate issue and was done on purpose because of unbearable 
> build
> spew at the time. As an experiment I enabled it in current kernel and at -O3 
> we
> still get the dreaded spew in net/sunrpc/xdr.c and some more in net/ipv4. The 
> spew
> doesn't happen at -O2 and seems not ARC specific as I can see this with ARM 
> -O3
> build with gcc 7.3 (buildroot 2018.08)
>
> | $ make ARCH=arm CROSS_COMPILE=arm-linux- net
> | ..
> | ..
> | ../net/sunrpc/xdr.c: In function ‘xdr_encode_word’:
> | ../net/sunrpc/xdr.c:1199:2: warning: ‘subbuf.tail[0].iov_base’ may be used
> | uninitialized in this function [-Wmaybe-uninitialized]
> |  memcpy(subbuf->tail[0].iov_base, obj, this_len);
> |  ^~~
> | ../net/sunrpc/xdr.c:1205:17: note: ‘subbuf.tail[0].iov_base’ was declared 
> here
> |  struct xdr_buf subbuf;
>
>
> I understand the value of this toggle, but the spew is too much and at times
> obfuscated likely other real issues.
> > Add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y to all the defconfig files
> > in arch/arc/configs/ in order to keep the current config settings.
>
> My first reaction to adding this to all defconfigs was that this was 
> inelegant :
> for lack of better word :-)
>
> But indeed it seems better this way as we can now experiment with -O2 vs. -O3 
> from
> config, rather than hardwiring to -O3.
>
> So if you could please split out the Wmaybe-uninitialized change

I could not understand your request.

I added 'imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED'
for CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3.

I cannot split it out. Otherwise, you will see false-positive
maybe-uninitialized warnings.


> Acked-by: Vineet Gupta 

Thanks.


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 1/1] mm/pgtable/debug: Add test validating architecture page table helpers

2019-09-03 Thread kbuild test robot
Hi Anshuman,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc7 next-20190902]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-debug-Add-tests-for-architecture-exported-page-table-helpers/20190903-162959
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 7.4.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All error/warnings (new ones prefixed by >>):

   In file included from arch/m68k/include/asm/bug.h:32:0,
from include/linux/bug.h:5,
from include/linux/thread_info.h:12,
from include/asm-generic/preempt.h:5,
from ./arch/m68k/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from arch/m68k/include/asm/irqflags.h:6,
from include/linux/irqflags.h:16,
from arch/m68k/include/asm/atomic.h:6,
from include/linux/atomic.h:7,
from include/linux/mm_types_task.h:13,
from include/linux/mm_types.h:5,
from include/linux/hugetlb.h:5,
from mm/arch_pgtable_test.c:14:
   mm/arch_pgtable_test.c: In function 'pmd_clear_tests':
>> arch/m68k/include/asm/page.h:31:22: error: lvalue required as unary '&' 
>> operand
#define pmd_val(x) (()->pmd[0])
 ^
   include/asm-generic/bug.h:124:25: note: in definition of macro 'WARN_ON'
 int __ret_warn_on = !!(condition);\
^
>> arch/m68k/include/asm/motorola_pgtable.h:138:26: note: in expansion of macro 
>> 'pmd_val'
#define pmd_none(pmd)  (!pmd_val(pmd))
 ^~~
>> mm/arch_pgtable_test.c:233:11: note: in expansion of macro 'pmd_none'
 WARN_ON(!pmd_none(READ_ONCE(*pmdp)));
  ^~~~
   mm/arch_pgtable_test.c: In function 'pmd_populate_tests':
>> arch/m68k/include/asm/page.h:31:22: error: lvalue required as unary '&' 
>> operand
#define pmd_val(x) (()->pmd[0])
 ^
   include/asm-generic/bug.h:124:25: note: in definition of macro 'WARN_ON'
 int __ret_warn_on = !!(condition);\
^
   arch/m68k/include/asm/motorola_pgtable.h:139:25: note: in expansion of macro 
'pmd_val'
#define pmd_bad(pmd)  ((pmd_val(pmd) & _DESCTYPE_MASK) != _PAGE_TABLE)
^~~
>> mm/arch_pgtable_test.c:245:10: note: in expansion of macro 'pmd_bad'
 WARN_ON(pmd_bad(READ_ONCE(*pmdp)));
 ^~~

vim +/pmd_none +233 mm/arch_pgtable_test.c

   228  
   229  static void pmd_clear_tests(pmd_t *pmdp)
   230  {
   231  memset(pmdp, RANDOM_NZVALUE, sizeof(pmd_t));
   232  pmd_clear(pmdp);
 > 233  WARN_ON(!pmd_none(READ_ONCE(*pmdp)));
   234  }
   235  
   236  static void pmd_populate_tests(struct mm_struct *mm, pmd_t *pmdp,
   237 pgtable_t pgtable)
   238  {
   239  /*
   240   * This entry points to next level page table page.
   241   * Hence this must not qualify as pmd_bad().
   242   */
   243  pmd_clear(pmdp);
   244  pmd_populate(mm, pmdp, pgtable);
 > 245  WARN_ON(pmd_bad(READ_ONCE(*pmdp)));
   246  }
   247  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 04/26] mips: remove ioremap_cachable

2019-09-03 Thread Paul Burton
Hello,

Christoph Hellwig wrote:
> Just define ioremap_cache directly.

Applied to mips-next.

> commit 60af0d94cc37
> https://git.kernel.org/mips/c/60af0d94cc37
> 
> Signed-off-by: Christoph Hellwig 
> Signed-off-by: Paul Burton 

Thanks,
Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paul.bur...@mips.com to report it. ]

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 1/1] mm/pgtable/debug: Add test validating architecture page table helpers

2019-09-03 Thread Anshuman Khandual
This adds a test module which will validate architecture page table helpers
and accessors regarding compliance with generic MM semantics expectations.
This will help various architectures in validating changes to the existing
page table helpers or addition of new ones.

Test page table and memory pages creating it's entries at various level are
all allocated from system memory with required alignments. If memory pages
with required size and alignment could not be allocated, then all depending
individual tests are skipped.

Cc: Andrew Morton 
Cc: Vlastimil Babka 
Cc: Greg Kroah-Hartman 
Cc: Thomas Gleixner 
Cc: Mike Rapoport 
Cc: Jason Gunthorpe 
Cc: Dan Williams 
Cc: Peter Zijlstra 
Cc: Michal Hocko 
Cc: Mark Rutland 
Cc: Mark Brown 
Cc: Steven Price 
Cc: Ard Biesheuvel 
Cc: Masahiro Yamada 
Cc: Kees Cook 
Cc: Tetsuo Handa 
Cc: Matthew Wilcox 
Cc: Sri Krishna chowdary 
Cc: Dave Hansen 
Cc: Russell King - ARM Linux 
Cc: Michael Ellerman 
Cc: Paul Mackerras 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: "David S. Miller" 
Cc: Vineet Gupta 
Cc: James Hogan 
Cc: Paul Burton 
Cc: Ralf Baechle 
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-m...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-i...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: linux...@vger.kernel.org
Cc: sparcli...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org

Suggested-by: Catalin Marinas 
Signed-off-by: Anshuman Khandual 
---
 mm/Kconfig.debug   |  14 ++
 mm/Makefile|   1 +
 mm/arch_pgtable_test.c | 425 +
 3 files changed, 440 insertions(+)
 create mode 100644 mm/arch_pgtable_test.c

diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
index 327b3ebf23bf..ce9c397f7b07 100644
--- a/mm/Kconfig.debug
+++ b/mm/Kconfig.debug
@@ -117,3 +117,17 @@ config DEBUG_RODATA_TEST
 depends on STRICT_KERNEL_RWX
 ---help---
   This option enables a testcase for the setting rodata read-only.
+
+config DEBUG_ARCH_PGTABLE_TEST
+   bool "Test arch page table helpers for semantics compliance"
+   depends on MMU
+   depends on DEBUG_KERNEL
+   help
+ This options provides a kernel module which can be used to test
+ architecture page table helper functions on various platform in
+ verifying if they comply with expected generic MM semantics. This
+ will help architectures code in making sure that any changes or
+ new additions of these helpers will still conform to generic MM
+ expected semantics.
+
+ If unsure, say N.
diff --git a/mm/Makefile b/mm/Makefile
index d996846697ef..bb572c5aa8c5 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -86,6 +86,7 @@ obj-$(CONFIG_HWPOISON_INJECT) += hwpoison-inject.o
 obj-$(CONFIG_DEBUG_KMEMLEAK) += kmemleak.o
 obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kmemleak-test.o
 obj-$(CONFIG_DEBUG_RODATA_TEST) += rodata_test.o
+obj-$(CONFIG_DEBUG_ARCH_PGTABLE_TEST) += arch_pgtable_test.o
 obj-$(CONFIG_PAGE_OWNER) += page_owner.o
 obj-$(CONFIG_CLEANCACHE) += cleancache.o
 obj-$(CONFIG_MEMORY_ISOLATION) += page_isolation.o
diff --git a/mm/arch_pgtable_test.c b/mm/arch_pgtable_test.c
new file mode 100644
index ..f15be8a73723
--- /dev/null
+++ b/mm/arch_pgtable_test.c
@@ -0,0 +1,425 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * This kernel module validates architecture page table helpers &
+ * accessors and helps in verifying their continued compliance with
+ * generic MM semantics.
+ *
+ * Copyright (C) 2019 ARM Ltd.
+ *
+ * Author: Anshuman Khandual 
+ */
+#define pr_fmt(fmt) "arch_pgtable_test: %s " fmt, __func__
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * Basic operations
+ *
+ * mkold(entry)= An old and not a young entry
+ * mkyoung(entry)  = A young and not an old entry
+ * mkdirty(entry)  = A dirty and not a clean entry
+ * mkclean(entry)  = A clean and not a dirty entry
+ * mkwrite(entry)  = A write and not a write protected entry
+ * wrprotect(entry)= A write protected and not a write entry
+ * pxx_bad(entry)  = A mapped and non-table entry
+ * pxx_same(entry1, entry2)= Both entries hold the exact same value
+ */
+#define VADDR_TEST (PGDIR_SIZE + PUD_SIZE + PMD_SIZE + PAGE_SIZE)
+#define VMA_TEST_FLAGS (VM_READ|VM_WRITE|VM_EXEC)
+#define RANDOM_NZVALUE (0xbe)
+
+static bool pud_aligned;
+static bool pmd_aligned;
+
+extern struct mm_struct *mm_alloc(void);
+
+static void pte_basic_tests(struct page *page, pgprot_t prot)
+{
+   pte_t pte = mk_pte(page, prot);
+
+   WARN_ON(!pte_same(pte, pte));
+   WARN_ON(!pte_young(pte_mkyoung(pte)));
+   WARN_ON(!pte_dirty(pte_mkdirty(pte)));
+   WARN_ON(!pte_write(pte_mkwrite(pte)));
+   

[PATCH 0/1] mm/debug: Add tests for architecture exported page table helpers

2019-09-03 Thread Anshuman Khandual
This series adds a test validation for architecture exported page table
helpers. Patch in the series adds basic transformation tests at various
levels of the page table.

This test was originally suggested by Catalin during arm64 THP migration
RFC discussion earlier. Going forward it can include more specific tests
with respect to various generic MM functions like THP, HugeTLB etc and
platform specific tests.

https://lore.kernel.org/linux-mm/20190628102003.ga56...@arrakis.emea.arm.com/

Questions:

Should alloc_gigantic_page() be made available as an interface for general
use in the kernel. The test module here uses very similar implementation from
HugeTLB to allocate a PUD aligned memory block. Similar for mm_alloc() which
needs to be exported through a header.

Matthew Wilcox had expressed concerns regarding memory allocation for mapped
page table entries at various level. He also suggested using synethetic pfns
which can be derived from virtual address of a known kernel text symbol like
kernel_init(). But as discussed previously, it seems like allocated memory
might still outweigh synthetic pfns. This proposal goes with allocated memory
but if there is a broader agreement with respect to synthetic pfns, will be
happy to rework the test.

Testing:

Build and boot tested on arm64 and x86 platforms. While arm64 clears all
these tests, following errors were reported on x86.

1. WARN_ON(pud_bad(pud)) in pud_populate_tests()
2. WARN_ON(p4d_bad(p4d)) in p4d_populate_tests()

I would really appreciate if folks can help validate this test on other
platforms and report back problems if any. Suggestions, comments and
inputs welcome. Thank you.

Changes in V3:

- Added fallback mechanism for PMD aligned memory allocation failure

Changes in V2:

https://lore.kernel.org/linux-mm/1565335998-22553-1-git-send-email-anshuman.khand...@arm.com/T/#u

- Moved test module and it's config from lib/ to mm/
- Renamed config TEST_ARCH_PGTABLE as DEBUG_ARCH_PGTABLE_TEST
- Renamed file from test_arch_pgtable.c to arch_pgtable_test.c
- Added relevant MODULE_DESCRIPTION() and MODULE_AUTHOR() details
- Dropped loadable module config option
- Basic tests now use memory blocks with required size and alignment
- PUD aligned memory block gets allocated with alloc_contig_range()
- If PUD aligned memory could not be allocated it falls back on PMD aligned
  memory block from page allocator and pud_* tests are skipped
- Clear and populate tests now operate on real in memory page table entries
- Dummy mm_struct gets allocated with mm_alloc()
- Dummy page table entries get allocated with [pud|pmd|pte]_alloc_[map]()
- Simplified [p4d|pgd]_basic_tests(), now has random values in the entries

RFC V1:

https://lore.kernel.org/linux-mm/1564037723-26676-1-git-send-email-anshuman.khand...@arm.com/

Cc: Andrew Morton 
Cc: Vlastimil Babka 
Cc: Greg Kroah-Hartman 
Cc: Thomas Gleixner 
Cc: Mike Rapoport 
Cc: Jason Gunthorpe 
Cc: Dan Williams 
Cc: Peter Zijlstra 
Cc: Michal Hocko 
Cc: Mark Rutland 
Cc: Mark Brown 
Cc: Steven Price 
Cc: Ard Biesheuvel 
Cc: Masahiro Yamada 
Cc: Kees Cook 
Cc: Tetsuo Handa 
Cc: Matthew Wilcox 
Cc: Sri Krishna chowdary 
Cc: Dave Hansen 
Cc: Russell King - ARM Linux 
Cc: Michael Ellerman 
Cc: Paul Mackerras 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: "David S. Miller" 
Cc: Vineet Gupta 
Cc: James Hogan 
Cc: Paul Burton 
Cc: Ralf Baechle 
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-m...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-i...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: linux...@vger.kernel.org
Cc: sparcli...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org

Anshuman Khandual (1):
  mm/pgtable/debug: Add test validating architecture page table helpers

 mm/Kconfig.debug   |  14 ++
 mm/Makefile|   1 +
 mm/arch_pgtable_test.c | 425 +
 3 files changed, 440 insertions(+)
 create mode 100644 mm/arch_pgtable_test.c

-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc