[PATCH] fs/ntfs: remove unused varible attr_len

2020-11-07 Thread Alex Shi
This varible isn't used anymore, remove it to skip W=1 warning:
fs/ntfs/inode.c:2350:6: warning: variable ‘attr_len’ set but not used
[-Wunused-but-set-variable]

Signed-off-by: Alex Shi 
Cc: Anton Altaparmakov  
Cc: linux-ntfs-...@lists.sourceforge.net 
Cc: linux-kernel@vger.kernel.org 
---
 fs/ntfs/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index caf563981532..d3127ea201ec 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2347,7 +2347,6 @@ int ntfs_truncate(struct inode *vi)
ATTR_RECORD *a;
const char *te = "  Leaving file length out of sync with i_size.";
int err, mp_size, size_change, alloc_change;
-   u32 attr_len;
 
ntfs_debug("Entering for inode 0x%lx.", vi->i_ino);
BUG_ON(NInoAttr(ni));
@@ -2721,7 +2720,7 @@ int ntfs_truncate(struct inode *vi)
 * this cannot fail since we are making the attribute smaller thus by
 * definition there is enough space to do so.
 */
-   attr_len = le32_to_cpu(a->length);
+   le32_to_cpu(a->length);
err = ntfs_attr_record_resize(m, a, mp_size +
le16_to_cpu(a->data.non_resident.mapping_pairs_offset));
BUG_ON(err);
-- 
1.8.3.1



Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread John Hubbard

On 11/7/20 11:35 PM, Song Bao Hua (Barry Song) wrote:

Or do you want this ?

(Code B)
diff --git a/mm/Kconfig b/mm/Kconfig
index 01b0ae0cd9d3..a7ff0d31afd5 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -836,6 +836,7 @@ config PERCPU_STATS

  config GUP_TEST
 bool "Enable infrastructure for get_user_pages()-related unit tests"
+   depends on DEBUG_FS
 help
   Provides /sys/kernel/debug/gup_test, which in turn provides a way
   to make ioctl calls that can launch kernel-based unit tests for
@@ -853,6 +854,9 @@ config GUP_TEST

   See tools/testing/selftests/vm/gup_test.c

+comment "GUP_TEST needs to have DEBUG_FS enabled"
+   depends on !GUP_TEST && !DEBUG_FS
+
  config GUP_GET_PTE_LOW_HIGH
 bool



The above, please. It's your original patch, plus a way to display something
if the "depends on" is not met.




To be honest, I am not a big fan of both of code A and B. I think "depends on" 
has
clearly said everything the redundant comment wants to say.


It's not really just a "comment", in the sense of commenting the Kconfig 
sources.
It actually has an effect, which is that it displays something in "make 
menuconfig".
So it's not redundant, because it provides that output *instead* of hiding the
option entirely, when !DEBUG_FS.

Try it out, it's nice.




   │ Symbol: GUP_TEST [=]
   │ Type  : bool
   │ Defined at mm/Kconfig:837
   │   Prompt: Enable infrastructure for get_user_pages()-related unit tests
   │   Depends on: DEBUG_FS [=n]
   │   Location:
   │ (1) -> Memory Management option

Menuconfig shows GUP_TEST depends on DEBUG_FS and right now DEBUG_FS is
"n". so it is impossible to enable GUP_TEST.

"comment" is a good thing, but it is more likely to be used for a menu or a 
group
of configurations to extend a bundle of things.

On the other hand, If this particular case needs this comment, so do countless
other configurations in hundreds of Kconfig files.


Well, maybe, yes.

I personally find it quite difficult, having options appear and disappear on me,
in this system. If they all had this "comment" behavior by default, to show up
as a placeholder, I think it would be a better user experience.


thanks,
--
John Hubbard
NVIDIA


Re: About regression caused by commit aea6cb99703e ("regulator: resolve supply after creating regulator")

2020-11-07 Thread Qu Wenruo
Also add Rockchip and device tree mail lists to the CC, just in case we
need to update the device tree for RK808.

On 2020/11/8 下午3:35, Qu Wenruo wrote:
> Hi Michał,
> 
> Recently when testing v5.10-rc2, I found my RK3399 boards failed to boot
> from NVME.
> 
> It turns out that, commit aea6cb99703e ("regulator: resolve supply after
> creating regulator") seems to be the cause.
> 
> In RK3399 board, vpcie1v8 and vpcie0v9 of the pcie controller is
> provided by RK808 regulator.
> With that commit, now RK808 regulator fails to register:
> 
> [1.402500] rk808-regulator rk808-regulator: there is no dvs0 gpio
> [1.403104] rk808-regulator rk808-regulator: there is no dvs1 gpio
> [1.419856] rk808 0-001b: failed to register 12 regulator
> [1.422801] rk808-regulator: probe of rk808-regulator failed with
> error -22
> 
> Since voltages from rk808 are not proper registered, then it prevents
> the rockchip PCIE controller to find its voltage provider:
> 
> [1.855276] rockchip_pcie_probe: parse_host_dt err=-517
> 
> 
> I currently tested with that commit reverted, then the RK808 works again.
> 
> Is this a known regression? Or the RK808 device tree is out of spec?
> 
> It would help a lot to fix the problem before the regression makes all
> RK3399 boards to lose their ability to initialize PCIE controller.
> 
> 
> BTW I didn't find that patch submitted to mail lists like
> linux-arm-kernel. I doubt if that commit really got enough testing from
> arm community, especially considering that currently ARM is the biggest
> user of device-tree and regulators.
> 
> Maybe it's a good idea to also submit such patches to arm related mail
> lists next time?
> 
> Thanks,
> Qu
> 



[PATCH] fs/ntfs: remove unused varibles

2020-11-07 Thread Alex Shi
We actually don't use these varibles, so remove them to avoid gcc warning:
fs/ntfs/file.c:326:14: warning: variable ‘base_ni’ set but not used
[-Wunused-but-set-variable]
fs/ntfs/logfile.c:481:21: warning: variable ‘log_page_mask’ set but not
used [-Wunused-but-set-variable]

Signed-off-by: Alex Shi 
Cc: Anton Altaparmakov  
Cc: linux-ntfs-...@lists.sourceforge.net 
Cc: linux-kernel@vger.kernel.org 
---
 fs/ntfs/file.c| 5 +
 fs/ntfs/logfile.c | 3 +--
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index f42967b738eb..e5aab265dff1 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -323,7 +323,7 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb 
*iocb,
unsigned long flags;
struct file *file = iocb->ki_filp;
struct inode *vi = file_inode(file);
-   ntfs_inode *base_ni, *ni = NTFS_I(vi);
+   ntfs_inode *ni = NTFS_I(vi);
ntfs_volume *vol = ni->vol;
 
ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, pos "
@@ -365,9 +365,6 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb 
*iocb,
err = -EOPNOTSUPP;
goto out;
}
-   base_ni = ni;
-   if (NInoAttr(ni))
-   base_ni = ni->ext.base_ntfs_ino;
err = file_remove_privs(file);
if (unlikely(err))
goto out;
diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
index a0c40f1be7ac..bc1bf217b38e 100644
--- a/fs/ntfs/logfile.c
+++ b/fs/ntfs/logfile.c
@@ -478,7 +478,7 @@ bool ntfs_check_logfile(struct inode *log_vi, 
RESTART_PAGE_HEADER **rp)
u8 *kaddr = NULL;
RESTART_PAGE_HEADER *rstr1_ph = NULL;
RESTART_PAGE_HEADER *rstr2_ph = NULL;
-   int log_page_size, log_page_mask, err;
+   int log_page_size, err;
bool logfile_is_empty = true;
u8 log_page_bits;
 
@@ -501,7 +501,6 @@ bool ntfs_check_logfile(struct inode *log_vi, 
RESTART_PAGE_HEADER **rp)
log_page_size = DefaultLogPageSize;
else
log_page_size = PAGE_SIZE;
-   log_page_mask = log_page_size - 1;
/*
 * Use ntfs_ffs() instead of ffs() to enable the compiler to
 * optimize log_page_size and log_page_bits into constants.
-- 
1.8.3.1



RE: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread Song Bao Hua (Barry Song)


> -Original Message-
> From: John Hubbard [mailto:jhubb...@nvidia.com]
> Sent: Sunday, November 8, 2020 5:56 PM
> To: Randy Dunlap ; Song Bao Hua (Barry Song)
> ; a...@linux-foundation.org;
> linux...@kvack.org; linux-kernel@vger.kernel.org
> Cc: Linuxarm ; Ralph Campbell
> ; John Garry 
> Subject: Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on
> DEBUG_FS
> 
> On 11/7/20 8:11 PM, Randy Dunlap wrote:
> ...
> > Look at kconfig-language.rst instead.
> 
> aha, yes.
> 
> >
> > One thing that could be done (and is done in a few places for other reasons)
> is to add
> > a Kconfig comment if DEBUG_FS is not enabled:
> >
> > comment "GUP_TEST needs to have DEBUG_FS enabled"
> > depends on !GUP_TEST && !DEBUG_FS
> >
> 
> Sweet--I just applied that here, and it does exactly what I wanted: puts a 
> nice
> clear
> message on the "make menuconfig" screen. No more hidden item. Brilliant!
> 
> Let's go with that, shall we?

Do you want this

(Code A)

diff --git a/mm/Kconfig b/mm/Kconfig
index 01b0ae0cd9d3..d80839d1fad8 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -853,6 +853,9 @@ config GUP_TEST

  See tools/testing/selftests/vm/gup_test.c

+comment "GUP_TEST needs to have DEBUG_FS enabled"
+   depends on !GUP_TEST && !DEBUG_FS
+
 config GUP_GET_PTE_LOW_HIGH
bool

Or do you want this ?

(Code B)
diff --git a/mm/Kconfig b/mm/Kconfig
index 01b0ae0cd9d3..a7ff0d31afd5 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -836,6 +836,7 @@ config PERCPU_STATS

 config GUP_TEST
bool "Enable infrastructure for get_user_pages()-related unit tests"
+   depends on DEBUG_FS
help
  Provides /sys/kernel/debug/gup_test, which in turn provides a way
  to make ioctl calls that can launch kernel-based unit tests for
@@ -853,6 +854,9 @@ config GUP_TEST

  See tools/testing/selftests/vm/gup_test.c

+comment "GUP_TEST needs to have DEBUG_FS enabled"
+   depends on !GUP_TEST && !DEBUG_FS
+
 config GUP_GET_PTE_LOW_HIGH
bool

To be honest, I am not a big fan of both of code A and B. I think "depends on" 
has
clearly said everything the redundant comment wants to say.

  │ Symbol: GUP_TEST [=]
  │ Type  : bool
  │ Defined at mm/Kconfig:837
  │   Prompt: Enable infrastructure for get_user_pages()-related unit tests
  │   Depends on: DEBUG_FS [=n]
  │   Location:
  │ (1) -> Memory Management option

Menuconfig shows GUP_TEST depends on DEBUG_FS and right now DEBUG_FS is
"n". so it is impossible to enable GUP_TEST.

"comment" is a good thing, but it is more likely to be used for a menu or a 
group
of configurations to extend a bundle of things.

On the other hand, If this particular case needs this comment, so do countless
other configurations in hundreds of Kconfig files.

My favorite order is
1. depends on
2. select
3. depends on + comment(code B)
4. comment only(code A)

I won't accept 4, but it seems we can't get agreement on 1 which is my 
favorite. 
So if you want either one of 2 and 3, I am happy to send v2 for that. So which 
one
is your favorite? 2 or 3?

> 
> thanks,
> --
> John Hubbard
> NVIDIA

Thanks
Barry


About regression caused by commit aea6cb99703e ("regulator: resolve supply after creating regulator")

2020-11-07 Thread Qu Wenruo
Hi Michał,

Recently when testing v5.10-rc2, I found my RK3399 boards failed to boot
from NVME.

It turns out that, commit aea6cb99703e ("regulator: resolve supply after
creating regulator") seems to be the cause.

In RK3399 board, vpcie1v8 and vpcie0v9 of the pcie controller is
provided by RK808 regulator.
With that commit, now RK808 regulator fails to register:

[1.402500] rk808-regulator rk808-regulator: there is no dvs0 gpio
[1.403104] rk808-regulator rk808-regulator: there is no dvs1 gpio
[1.419856] rk808 0-001b: failed to register 12 regulator
[1.422801] rk808-regulator: probe of rk808-regulator failed with
error -22

Since voltages from rk808 are not proper registered, then it prevents
the rockchip PCIE controller to find its voltage provider:

[1.855276] rockchip_pcie_probe: parse_host_dt err=-517


I currently tested with that commit reverted, then the RK808 works again.

Is this a known regression? Or the RK808 device tree is out of spec?

It would help a lot to fix the problem before the regression makes all
RK3399 boards to lose their ability to initialize PCIE controller.


BTW I didn't find that patch submitted to mail lists like
linux-arm-kernel. I doubt if that commit really got enough testing from
arm community, especially considering that currently ARM is the biggest
user of device-tree and regulators.

Maybe it's a good idea to also submit such patches to arm related mail
lists next time?

Thanks,
Qu



Re: [PATCH] netfilter: conntrack: fix -Wformat

2020-11-07 Thread Lukas Bulwahn


On Sat, 7 Nov 2020, Joe Perches wrote:

> On Fri, 2020-11-06 at 23:55 -0800, Nick Desaulniers wrote:
> > Clang is more aggressive about -Wformat warnings when the format flag
> > specifies a type smaller than the parameter. Fixes 8 instances of:
> > 
> > warning: format specifies type 'unsigned short' but the argument has
> > type 'int' [-Wformat]
> 
> Likely clang's -Wformat message is still bogus.
> Wasn't that going to be fixed?
> 
> Integer promotions are already done on these types to int anyway.
> Didn't we have this discussion last year?
> 
> https://lore.kernel.org/lkml/CAKwvOd=mqzj2pAZEUsW-M_62xn4pijpCJmP=b1h_-web0ne...@mail.gmail.com/
> https://lore.kernel.org/lkml/CAHk-=wgoxnmsj8GEVFJSvTwdnWm8wVJthefNk2n6+4TC=20...@mail.gmail.com/
> https://lore.kernel.org/lkml/a68114afb134b8633905f5a25ae7c4e6799ce8f1.ca...@perches.com/
> 
> Look at commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use
> of unnecessary %h[xudi] and %hh[xudi]")
> 
> The "h" and "hh" things should never be used. The only reason for them
> being used if if you have an "int", but you want to print it out as a
> "char" (and honestly, that is a really bad reason, you'd be better off
> just using a proper cast to make the code more obvious).
>

Joe, would this be a good rule to check for in checkpatch?

Can Dwaipayan or Aditya give it a try to create a suitable patch to add 
such a rule?

Dwaipayan, Aditya, if Joe thinks it is worth a rule, it is "first come, 
first serve" for you to take that task. 

Lukas

> So if what you have a "char" (or unsigned char) you should always just
> print it out as an "int", knowing that the compiler already did the
> proper type conversion.
> 
> > diff --git a/net/netfilter/nf_conntrack_standalone.c 
> > b/net/netfilter/nf_conntrack_standalone.c
> []
> > @@ -50,38 +50,38 @@ print_tuple(struct seq_file *s, const struct 
> > nf_conntrack_tuple *tuple,
> >  
> > 
> >     switch (l4proto->l4proto) {
> >     case IPPROTO_ICMP:
> > -   seq_printf(s, "type=%u code=%u id=%u ",
> > +   seq_printf(s, "type=%u code=%u id=%hu ",
> 
> etc...
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clang-built-linux+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/clang-built-linux/4910042649a4f3ab22fac93191b8c1fa0a2e17c3.camel%40perches.com.
> 

[PATCH v5 5/5] arch, mm: make kernel_page_present() always available

2020-11-07 Thread Mike Rapoport
From: Mike Rapoport 

For architectures that enable ARCH_HAS_SET_MEMORY having the ability to
verify that a page is mapped in the kernel direct map can be useful
regardless of hibernation.

Add RISC-V implementation of kernel_page_present(), update its forward
declarations and stubs to be a part of set_memory API and remove ugly
ifdefery in inlcude/linux/mm.h around current declarations of
kernel_page_present().

Signed-off-by: Mike Rapoport 
Acked-by: Kirill A. Shutemov 
---
 arch/arm64/include/asm/cacheflush.h |  1 +
 arch/arm64/mm/pageattr.c|  4 +---
 arch/riscv/include/asm/set_memory.h |  1 +
 arch/riscv/mm/pageattr.c| 29 +
 arch/x86/include/asm/set_memory.h   |  1 +
 arch/x86/mm/pat/set_memory.c|  4 +---
 include/linux/mm.h  |  7 ---
 include/linux/set_memory.h  |  5 +
 8 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/arch/arm64/include/asm/cacheflush.h 
b/arch/arm64/include/asm/cacheflush.h
index 9384fd8fc13c..45217f21f1fe 100644
--- a/arch/arm64/include/asm/cacheflush.h
+++ b/arch/arm64/include/asm/cacheflush.h
@@ -140,6 +140,7 @@ int set_memory_valid(unsigned long addr, int numpages, int 
enable);
 
 int set_direct_map_invalid_noflush(struct page *page);
 int set_direct_map_default_noflush(struct page *page);
+bool kernel_page_present(struct page *page);
 
 #include 
 
diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
index 439325532be1..92eccaf595c8 100644
--- a/arch/arm64/mm/pageattr.c
+++ b/arch/arm64/mm/pageattr.c
@@ -186,8 +186,8 @@ void __kernel_map_pages(struct page *page, int numpages, 
int enable)
 
set_memory_valid((unsigned long)page_address(page), numpages, enable);
 }
+#endif /* CONFIG_DEBUG_PAGEALLOC */
 
-#ifdef CONFIG_HIBERNATION
 /*
  * This function is used to determine if a linear map page has been marked as
  * not-valid. Walk the page table and check the PTE_VALID bit. This is based
@@ -234,5 +234,3 @@ bool kernel_page_present(struct page *page)
ptep = pte_offset_kernel(pmdp, addr);
return pte_valid(READ_ONCE(*ptep));
 }
-#endif /* CONFIG_HIBERNATION */
-#endif /* CONFIG_DEBUG_PAGEALLOC */
diff --git a/arch/riscv/include/asm/set_memory.h 
b/arch/riscv/include/asm/set_memory.h
index 4c5bae7ca01c..d690b08dff2a 100644
--- a/arch/riscv/include/asm/set_memory.h
+++ b/arch/riscv/include/asm/set_memory.h
@@ -24,6 +24,7 @@ static inline int set_memory_nx(unsigned long addr, int 
numpages) { return 0; }
 
 int set_direct_map_invalid_noflush(struct page *page);
 int set_direct_map_default_noflush(struct page *page);
+bool kernel_page_present(struct page *page);
 
 #endif /* __ASSEMBLY__ */
 
diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c
index 321b09d2e2ea..87ba5a68bbb8 100644
--- a/arch/riscv/mm/pageattr.c
+++ b/arch/riscv/mm/pageattr.c
@@ -198,3 +198,32 @@ void __kernel_map_pages(struct page *page, int numpages, 
int enable)
 __pgprot(0), __pgprot(_PAGE_PRESENT));
 }
 #endif
+
+bool kernel_page_present(struct page *page)
+{
+   unsigned long addr = (unsigned long)page_address(page);
+   pgd_t *pgd;
+   pud_t *pud;
+   p4d_t *p4d;
+   pmd_t *pmd;
+   pte_t *pte;
+
+   pgd = pgd_offset_k(addr);
+   if (!pgd_present(*pgd))
+   return false;
+
+   p4d = p4d_offset(pgd, addr);
+   if (!p4d_present(*p4d))
+   return false;
+
+   pud = pud_offset(p4d, addr);
+   if (!pud_present(*pud))
+   return false;
+
+   pmd = pmd_offset(pud, addr);
+   if (!pmd_present(*pmd))
+   return false;
+
+   pte = pte_offset_kernel(pmd, addr);
+   return pte_present(*pte);
+}
diff --git a/arch/x86/include/asm/set_memory.h 
b/arch/x86/include/asm/set_memory.h
index 5948218f35c5..4352f08bfbb5 100644
--- a/arch/x86/include/asm/set_memory.h
+++ b/arch/x86/include/asm/set_memory.h
@@ -82,6 +82,7 @@ int set_pages_rw(struct page *page, int numpages);
 
 int set_direct_map_invalid_noflush(struct page *page);
 int set_direct_map_default_noflush(struct page *page);
+bool kernel_page_present(struct page *page);
 
 extern int kernel_set_to_readonly;
 
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index bc9be96b777f..16f878c26667 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -2226,8 +2226,8 @@ void __kernel_map_pages(struct page *page, int numpages, 
int enable)
 
arch_flush_lazy_mmu_mode();
 }
+#endif /* CONFIG_DEBUG_PAGEALLOC */
 
-#ifdef CONFIG_HIBERNATION
 bool kernel_page_present(struct page *page)
 {
unsigned int level;
@@ -2239,8 +2239,6 @@ bool kernel_page_present(struct page *page)
pte = lookup_address((unsigned long)page_address(page), );
return (pte_val(*pte) & _PAGE_PRESENT);
 }
-#endif /* CONFIG_HIBERNATION */
-#endif /* CONFIG_DEBUG_PAGEALLOC */
 
 int __init kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long 

[PATCH v5 3/5] PM: hibernate: make direct map manipulations more explicit

2020-11-07 Thread Mike Rapoport
From: Mike Rapoport 

When DEBUG_PAGEALLOC or ARCH_HAS_SET_DIRECT_MAP is enabled a page may be
not present in the direct map and has to be explicitly mapped before it
could be copied.

Introduce hibernate_map_page() and hibernation_unmap_page() that will
explicitly use set_direct_map_{default,invalid}_noflush() for
ARCH_HAS_SET_DIRECT_MAP case and debug_pagealloc_{map,unmap}_pages() for
DEBUG_PAGEALLOC case.

The remapping of the pages in safe_copy_page() presumes that it only
changes protection bits in an existing PTE and so it is safe to ignore
return value of set_direct_map_{default,invalid}_noflush().

Still, add a pr_warn() so that future changes in set_memory APIs will not
silently break hibernation.

Signed-off-by: Mike Rapoport 
Acked-by: Rafael J. Wysocki 
Reviewed-by: David Hildenbrand 
Acked-by: Kirill A. Shutemov 
Acked-by: Vlastimil Babka 
---
 include/linux/mm.h  | 12 
 kernel/power/snapshot.c | 38 --
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index bb8c70178f4e..e198b938f5c5 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2927,16 +2927,6 @@ static inline bool debug_pagealloc_enabled_static(void)
 #if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_ARCH_HAS_SET_DIRECT_MAP)
 extern void __kernel_map_pages(struct page *page, int numpages, int enable);
 
-/*
- * When called in DEBUG_PAGEALLOC context, the call should most likely be
- * guarded by debug_pagealloc_enabled() or debug_pagealloc_enabled_static()
- */
-static inline void
-kernel_map_pages(struct page *page, int numpages, int enable)
-{
-   __kernel_map_pages(page, numpages, enable);
-}
-
 static inline void debug_pagealloc_map_pages(struct page *page, int numpages)
 {
if (debug_pagealloc_enabled_static())
@@ -2953,8 +2943,6 @@ static inline void debug_pagealloc_unmap_pages(struct 
page *page, int numpages)
 extern bool kernel_page_present(struct page *page);
 #endif /* CONFIG_HIBERNATION */
 #else  /* CONFIG_DEBUG_PAGEALLOC || CONFIG_ARCH_HAS_SET_DIRECT_MAP */
-static inline void
-kernel_map_pages(struct page *page, int numpages, int enable) {}
 static inline void debug_pagealloc_map_pages(struct page *page, int numpages) 
{}
 static inline void debug_pagealloc_unmap_pages(struct page *page, int 
numpages) {}
 #ifdef CONFIG_HIBERNATION
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 46b1804c1ddf..d848377dd8dc 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -76,6 +76,40 @@ static inline void hibernate_restore_protect_page(void 
*page_address) {}
 static inline void hibernate_restore_unprotect_page(void *page_address) {}
 #endif /* CONFIG_STRICT_KERNEL_RWX  && CONFIG_ARCH_HAS_SET_MEMORY */
 
+
+/*
+ * The calls to set_direct_map_*() should not fail because remapping a page
+ * here means that we only update protection bits in an existing PTE.
+ * It is still worth to have a warning here if something changes and this
+ * will no longer be the case.
+ */
+static inline void hibernate_map_page(struct page *page)
+{
+   if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) {
+   int ret = set_direct_map_default_noflush(page);
+
+   if (ret)
+   pr_warn_once("Failed to remap page\n");
+   } else {
+   debug_pagealloc_map_pages(page, 1);
+   }
+}
+
+static inline void hibernate_unmap_page(struct page *page)
+{
+   if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) {
+   unsigned long addr = (unsigned long)page_address(page);
+   int ret  = set_direct_map_invalid_noflush(page);
+
+   if (ret)
+   pr_warn_once("Failed to remap page\n");
+
+   flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
+   } else {
+   debug_pagealloc_unmap_pages(page, 1);
+   }
+}
+
 static int swsusp_page_is_free(struct page *);
 static void swsusp_set_page_forbidden(struct page *);
 static void swsusp_unset_page_forbidden(struct page *);
@@ -1355,9 +1389,9 @@ static void safe_copy_page(void *dst, struct page *s_page)
if (kernel_page_present(s_page)) {
do_copy_page(dst, page_address(s_page));
} else {
-   kernel_map_pages(s_page, 1, 1);
+   hibernate_map_page(s_page);
do_copy_page(dst, page_address(s_page));
-   kernel_map_pages(s_page, 1, 0);
+   hibernate_unmap_page(s_page);
}
 }
 
-- 
2.28.0



[PATCH v5 4/5] arch, mm: restore dependency of __kernel_map_pages() on DEBUG_PAGEALLOC

2020-11-07 Thread Mike Rapoport
From: Mike Rapoport 

The design of DEBUG_PAGEALLOC presumes that __kernel_map_pages() must never
fail. With this assumption is wouldn't be safe to allow general usage of
this function.

Moreover, some architectures that implement __kernel_map_pages() have this
function guarded by #ifdef DEBUG_PAGEALLOC and some refuse to map/unmap
pages when page allocation debugging is disabled at runtime.

As all the users of __kernel_map_pages() were converted to use
debug_pagealloc_map_pages() it is safe to make it available only when
DEBUG_PAGEALLOC is set.

Signed-off-by: Mike Rapoport 
Acked-by: David Hildenbrand 
Acked-by: Kirill A. Shutemov 
---
 arch/Kconfig |  3 +++
 arch/arm64/Kconfig   |  4 +---
 arch/arm64/mm/pageattr.c |  8 ++--
 arch/powerpc/Kconfig |  5 +
 arch/riscv/Kconfig   |  4 +---
 arch/riscv/include/asm/pgtable.h |  2 --
 arch/riscv/mm/pageattr.c |  2 ++
 arch/s390/Kconfig|  4 +---
 arch/sparc/Kconfig   |  4 +---
 arch/x86/Kconfig |  4 +---
 arch/x86/mm/pat/set_memory.c |  2 ++
 include/linux/mm.h   | 10 +++---
 12 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 56b6ccc0e32d..56d4752b6db6 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1028,6 +1028,9 @@ config HAVE_STATIC_CALL_INLINE
bool
depends on HAVE_STATIC_CALL
 
+config ARCH_SUPPORTS_DEBUG_PAGEALLOC
+   bool
+
 source "kernel/gcov/Kconfig"
 
 source "scripts/gcc-plugins/Kconfig"
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1d466addb078..a932810cfd90 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -71,6 +71,7 @@ config ARM64
select ARCH_USE_QUEUED_RWLOCKS
select ARCH_USE_QUEUED_SPINLOCKS
select ARCH_USE_SYM_ANNOTATIONS
+   select ARCH_SUPPORTS_DEBUG_PAGEALLOC
select ARCH_SUPPORTS_MEMORY_FAILURE
select ARCH_SUPPORTS_SHADOW_CALL_STACK if CC_HAVE_SHADOW_CALL_STACK
select ARCH_SUPPORTS_ATOMIC_RMW
@@ -1025,9 +1026,6 @@ config HOLES_IN_ZONE
 
 source "kernel/Kconfig.hz"
 
-config ARCH_SUPPORTS_DEBUG_PAGEALLOC
-   def_bool y
-
 config ARCH_SPARSEMEM_ENABLE
def_bool y
select SPARSEMEM_VMEMMAP_ENABLE
diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
index 1b94f5b82654..439325532be1 100644
--- a/arch/arm64/mm/pageattr.c
+++ b/arch/arm64/mm/pageattr.c
@@ -155,7 +155,7 @@ int set_direct_map_invalid_noflush(struct page *page)
.clear_mask = __pgprot(PTE_VALID),
};
 
-   if (!rodata_full)
+   if (!debug_pagealloc_enabled() && !rodata_full)
return 0;
 
return apply_to_page_range(_mm,
@@ -170,7 +170,7 @@ int set_direct_map_default_noflush(struct page *page)
.clear_mask = __pgprot(PTE_RDONLY),
};
 
-   if (!rodata_full)
+   if (!debug_pagealloc_enabled() && !rodata_full)
return 0;
 
return apply_to_page_range(_mm,
@@ -178,6 +178,7 @@ int set_direct_map_default_noflush(struct page *page)
   PAGE_SIZE, change_page_range, );
 }
 
+#ifdef CONFIG_DEBUG_PAGEALLOC
 void __kernel_map_pages(struct page *page, int numpages, int enable)
 {
if (!debug_pagealloc_enabled() && !rodata_full)
@@ -186,6 +187,7 @@ void __kernel_map_pages(struct page *page, int numpages, 
int enable)
set_memory_valid((unsigned long)page_address(page), numpages, enable);
 }
 
+#ifdef CONFIG_HIBERNATION
 /*
  * This function is used to determine if a linear map page has been marked as
  * not-valid. Walk the page table and check the PTE_VALID bit. This is based
@@ -232,3 +234,5 @@ bool kernel_page_present(struct page *page)
ptep = pte_offset_kernel(pmdp, addr);
return pte_valid(READ_ONCE(*ptep));
 }
+#endif /* CONFIG_HIBERNATION */
+#endif /* CONFIG_DEBUG_PAGEALLOC */
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e9f13fe08492..ad8a83f3ddca 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -146,6 +146,7 @@ config PPC
select ARCH_MIGHT_HAVE_PC_SERIO
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_SUPPORTS_ATOMIC_RMW
+   select ARCH_SUPPORTS_DEBUG_PAGEALLOCif PPC32 || PPC_BOOK3S_64
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_CMPXCHG_LOCKREF if PPC64
select ARCH_USE_QUEUED_RWLOCKS  if PPC_QUEUED_SPINLOCKS
@@ -355,10 +356,6 @@ config PPC_OF_PLATFORM_PCI
depends on PCI
depends on PPC64 # not supported on 32 bits yet
 
-config ARCH_SUPPORTS_DEBUG_PAGEALLOC
-   depends on PPC32 || PPC_BOOK3S_64
-   def_bool y
-
 config ARCH_SUPPORTS_UPROBES
def_bool y
 
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 44377fd7860e..9283c6f9ae2a 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -14,6 +14,7 @@ config RISCV
def_bool y
   

[PATCH v5 2/5] slab: debug: split slab_kernel_map() to map and unmap variants

2020-11-07 Thread Mike Rapoport
From: Mike Rapoport 

Instead of using slab_kernel_map() with 'map' parameter to remap pages when
DEBUG_PAGEALLOC is enabled, use dedicated helpers slab_kernel_map() and
slab_kernel_unmap().

Signed-off-by: Mike Rapoport 
---
 mm/slab.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 07317386e150..0719421d69f7 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1428,17 +1428,21 @@ static bool is_debug_pagealloc_cache(struct kmem_cache 
*cachep)
return false;
 }
 
-static void slab_kernel_map(struct kmem_cache *cachep, void *objp, int map)
+static void slab_kernel_map(struct kmem_cache *cachep, void *objp)
 {
if (!is_debug_pagealloc_cache(cachep))
return;
 
-   if (map)
-   debug_pagealloc_map_pages(virt_to_page(objp),
- cachep->size / PAGE_SIZE);
-   else
-   debug_pagealloc_unmap_pages(virt_to_page(objp),
-   cachep->size / PAGE_SIZE);
+   debug_pagealloc_map_pages(virt_to_page(objp), cachep->size / PAGE_SIZE);
+}
+
+static void slab_kernel_unmap(struct kmem_cache *cachep, void *objp)
+{
+   if (!is_debug_pagealloc_cache(cachep))
+   return;
+
+   debug_pagealloc_unmap_pages(virt_to_page(objp),
+   cachep->size / PAGE_SIZE);
 }
 
 static void poison_obj(struct kmem_cache *cachep, void *addr, unsigned char 
val)
@@ -1585,7 +1589,7 @@ static void slab_destroy_debugcheck(struct kmem_cache 
*cachep,
 
if (cachep->flags & SLAB_POISON) {
check_poison_obj(cachep, objp);
-   slab_kernel_map(cachep, objp, 1);
+   slab_kernel_map(cachep, objp);
}
if (cachep->flags & SLAB_RED_ZONE) {
if (*dbg_redzone1(cachep, objp) != RED_INACTIVE)
@@ -2360,7 +2364,7 @@ static void cache_init_objs_debug(struct kmem_cache 
*cachep, struct page *page)
/* need to poison the objs? */
if (cachep->flags & SLAB_POISON) {
poison_obj(cachep, objp, POISON_FREE);
-   slab_kernel_map(cachep, objp, 0);
+   slab_kernel_unmap(cachep, objp);
}
}
 #endif
@@ -2728,7 +2732,7 @@ static void *cache_free_debugcheck(struct kmem_cache 
*cachep, void *objp,
 
if (cachep->flags & SLAB_POISON) {
poison_obj(cachep, objp, POISON_FREE);
-   slab_kernel_map(cachep, objp, 0);
+   slab_kernel_unmap(cachep, objp);
}
return objp;
 }
@@ -2993,7 +2997,7 @@ static void *cache_alloc_debugcheck_after(struct 
kmem_cache *cachep,
return objp;
if (cachep->flags & SLAB_POISON) {
check_poison_obj(cachep, objp);
-   slab_kernel_map(cachep, objp, 1);
+   slab_kernel_map(cachep, objp);
poison_obj(cachep, objp, POISON_INUSE);
}
if (cachep->flags & SLAB_STORE_USER)
-- 
2.28.0



[PATCH v5 0/5] arch, mm: improve robustness of direct map manipulation

2020-11-07 Thread Mike Rapoport
From: Mike Rapoport 

Hi,

During recent discussion about KVM protected memory, David raised a concern
about usage of __kernel_map_pages() outside of DEBUG_PAGEALLOC scope [1].

Indeed, for architectures that define CONFIG_ARCH_HAS_SET_DIRECT_MAP it is
possible that __kernel_map_pages() would fail, but since this function is
void, the failure will go unnoticed.

Moreover, there's lack of consistency of __kernel_map_pages() semantics
across architectures as some guard this function with
#ifdef DEBUG_PAGEALLOC, some refuse to update the direct map if page
allocation debugging is disabled at run time and some allow modifying the
direct map regardless of DEBUG_PAGEALLOC settings.

This set straightens this out by restoring dependency of
__kernel_map_pages() on DEBUG_PAGEALLOC and updating the call sites
accordingly. 

Since currently the only user of __kernel_map_pages() outside
DEBUG_PAGEALLOC is hibernation, it is updated to make direct map accesses
there more explicit.

[1] https://lore.kernel.org/lkml/2759b4bf-e1e3-d006-7d86-78a403482...@redhat.com

v5 changes:
* use pairs of _map()/_unmap() functions instead of _map(..., int enable) as
  Vlastimil suggested

v4 changes:
* s/WARN_ON/pr_warn_once/ per David and Kirill
* rebase on v5.10-rc2
* add Acked/Reviewed tags
https://lore.kernel.org/lkml/20201103162057.22916-1-r...@kernel.org

v3 changes:
* update arm64 changes to avoid regression, per Rick's comments
* fix bisectability
https://lore.kernel.org/lkml/20201101170815.9795-1-r...@kernel.org

v2 changes:
* Rephrase patch 2 changelog to better describe the change intentions and
implications
* Move removal of kernel_map_pages() from patch 1 to patch 2, per David
https://lore.kernel.org/lkml/20201029161902.19272-1-r...@kernel.org

v1:
https://lore.kernel.org/lkml/20201025101555.3057-1-r...@kernel.org

Mike Rapoport (5):
  mm: introduce debug_pagealloc_{map,unmap}_pages() helpers
  slab: debug: split slab_kernel_map() to map and unmap variants
  PM: hibernate: make direct map manipulations more explicit
  arch, mm: restore dependency of __kernel_map_pages() on DEBUG_PAGEALLOC
  arch, mm: make kernel_page_present() always available

 arch/Kconfig|  3 +++
 arch/arm64/Kconfig  |  4 +--
 arch/arm64/include/asm/cacheflush.h |  1 +
 arch/arm64/mm/pageattr.c|  6 +++--
 arch/powerpc/Kconfig|  5 +---
 arch/riscv/Kconfig  |  4 +--
 arch/riscv/include/asm/pgtable.h|  2 --
 arch/riscv/include/asm/set_memory.h |  1 +
 arch/riscv/mm/pageattr.c| 31 ++
 arch/s390/Kconfig   |  4 +--
 arch/sparc/Kconfig  |  4 +--
 arch/x86/Kconfig|  4 +--
 arch/x86/include/asm/set_memory.h   |  1 +
 arch/x86/mm/pat/set_memory.c|  4 +--
 include/linux/mm.h  | 40 ++---
 include/linux/set_memory.h  |  5 
 kernel/power/snapshot.c | 38 +--
 mm/memory_hotplug.c |  3 +--
 mm/page_alloc.c |  6 ++---
 mm/slab.c   | 26 ++-
 20 files changed, 127 insertions(+), 65 deletions(-)

-- 
2.28.0



[PATCH v5 1/5] mm: introduce debug_pagealloc_{map,unmap}_pages() helpers

2020-11-07 Thread Mike Rapoport
From: Mike Rapoport 

When CONFIG_DEBUG_PAGEALLOC is enabled, it unmaps pages from the kernel
direct mapping after free_pages(). The pages than need to be mapped back
before they could be used. Theese mapping operations use
__kernel_map_pages() guarded with with debug_pagealloc_enabled().

The only place that calls __kernel_map_pages() without checking whether
DEBUG_PAGEALLOC is enabled is the hibernation code that presumes
availability of this function when ARCH_HAS_SET_DIRECT_MAP is set.
Still, on arm64, __kernel_map_pages() will bail out when DEBUG_PAGEALLOC is
not enabled but set_direct_map_invalid_noflush() may render some pages not
present in the direct map and hibernation code won't be able to save such
pages.

To make page allocation debugging and hibernation interaction more robust,
the dependency on DEBUG_PAGEALLOC or ARCH_HAS_SET_DIRECT_MAP has to be made
more explicit.

Start with combining the guard condition and the call to
__kernel_map_pages() into debug_pagealloc_map_pages() and
debug_pagealloc_unmap_pages() functions to emphasize that
__kernel_map_pages() should not be called without DEBUG_PAGEALLOC and use
these new functions to map/unmap pages when page allocation debugging is
enabled.

Signed-off-by: Mike Rapoport 
Reviewed-by: David Hildenbrand 
Acked-by: Kirill A. Shutemov 
Acked-by: Vlastimil Babka 
---
 include/linux/mm.h  | 15 +++
 mm/memory_hotplug.c |  3 +--
 mm/page_alloc.c |  6 ++
 mm/slab.c   | 16 +++-
 4 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index ef360fe70aaf..bb8c70178f4e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2936,12 +2936,27 @@ kernel_map_pages(struct page *page, int numpages, int 
enable)
 {
__kernel_map_pages(page, numpages, enable);
 }
+
+static inline void debug_pagealloc_map_pages(struct page *page, int numpages)
+{
+   if (debug_pagealloc_enabled_static())
+   __kernel_map_pages(page, numpages, 1);
+}
+
+static inline void debug_pagealloc_unmap_pages(struct page *page, int numpages)
+{
+   if (debug_pagealloc_enabled_static())
+   __kernel_map_pages(page, numpages, 0);
+}
+
 #ifdef CONFIG_HIBERNATION
 extern bool kernel_page_present(struct page *page);
 #endif /* CONFIG_HIBERNATION */
 #else  /* CONFIG_DEBUG_PAGEALLOC || CONFIG_ARCH_HAS_SET_DIRECT_MAP */
 static inline void
 kernel_map_pages(struct page *page, int numpages, int enable) {}
+static inline void debug_pagealloc_map_pages(struct page *page, int numpages) 
{}
+static inline void debug_pagealloc_unmap_pages(struct page *page, int 
numpages) {}
 #ifdef CONFIG_HIBERNATION
 static inline bool kernel_page_present(struct page *page) { return true; }
 #endif /* CONFIG_HIBERNATION */
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index b44d4c7ba73b..f18f86ba2a68 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -614,8 +614,7 @@ void generic_online_page(struct page *page, unsigned int 
order)
 * so we should map it first. This is better than introducing a special
 * case in page freeing fast path.
 */
-   if (debug_pagealloc_enabled_static())
-   kernel_map_pages(page, 1 << order, 1);
+   debug_pagealloc_map_pages(page, 1 << order);
__free_pages_core(page, order);
totalram_pages_add(1UL << order);
 #ifdef CONFIG_HIGHMEM
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 23f5066bd4a5..db1bf70458d0 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1272,8 +1272,7 @@ static __always_inline bool free_pages_prepare(struct 
page *page,
 */
arch_free_page(page, order);
 
-   if (debug_pagealloc_enabled_static())
-   kernel_map_pages(page, 1 << order, 0);
+   debug_pagealloc_unmap_pages(page, 1 << order);
 
kasan_free_nondeferred_pages(page, order);
 
@@ -2270,8 +2269,7 @@ inline void post_alloc_hook(struct page *page, unsigned 
int order,
set_page_refcounted(page);
 
arch_alloc_page(page, order);
-   if (debug_pagealloc_enabled_static())
-   kernel_map_pages(page, 1 << order, 1);
+   debug_pagealloc_map_pages(page, 1 << order);
kasan_alloc_pages(page, order);
kernel_poison_pages(page, 1 << order, 1);
set_page_owner(page, order, gfp_flags);
diff --git a/mm/slab.c b/mm/slab.c
index b1113561b98b..07317386e150 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1428,21 +1428,19 @@ static bool is_debug_pagealloc_cache(struct kmem_cache 
*cachep)
return false;
 }
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
 static void slab_kernel_map(struct kmem_cache *cachep, void *objp, int map)
 {
if (!is_debug_pagealloc_cache(cachep))
return;
 
-   kernel_map_pages(virt_to_page(objp), cachep->size / PAGE_SIZE, map);
+   if (map)
+   debug_pagealloc_map_pages(virt_to_page(objp),
+ cachep->size / PAGE_SIZE);
+   

[PATCH] x86/tlb: remove unused varible 'cpu'

2020-11-07 Thread Alex Shi
It's not used, we could remove it to avoid a W1 warning:
arch/x86/mm/tlb.c:318:6: warning: variable ‘cpu’ set but not used
[-Wunused-but-set-variable]

Signed-off-by: Alex Shi 
Cc: Dave Hansen  
Cc: Andy Lutomirski  
Cc: x...@kernel.org 
Cc: "H. Peter Anvin"  
Cc: linux-kernel@vger.kernel.org 
---
 arch/x86/mm/tlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 88e9ad5142e4..be2e9080ca79 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -315,7 +315,7 @@ void leave_mm(int cpu)
 
 int enable_l1d_flush_for_task(struct task_struct *tsk)
 {
-   int cpu, ret = 0, i;
+   int ret = 0, i;
 
/*
 * Do not enable L1D_FLUSH_OUT if
@@ -328,7 +328,7 @@ int enable_l1d_flush_for_task(struct task_struct *tsk)
!static_cpu_has(X86_FEATURE_FLUSH_L1D))
return -EINVAL;
 
-   cpu = get_cpu();
+   get_cpu();
 
for_each_cpu(i, >cpus_mask) {
if (cpu_data(i).smt_active == true) {
-- 
1.8.3.1



Re: [PATCH] mm/zsmalloc: include sparsemem.h for MAX_PHYSMEM_BITS

2020-11-07 Thread Mike Rapoport
On Sat, Nov 07, 2020 at 04:22:06PM +0100, Stefan Agner wrote:
> Most architectures define MAX_PHYSMEM_BITS in asm/sparsemem.h and don't
> include it in asm/pgtable.h. Include asm/sparsemem.h directly to get
> the MAX_PHYSMEM_BITS define on all architectures.
> 
> This fixes a crash when accessing zram on 32-bit ARM platform with LPAE and
> more than 4GB of memory:
>   Unable to handle kernel NULL pointer dereference at virtual address 
>   pgd = a27bd01c
>   [] *pgd=236a0003, *pmd=1ffa64003
>   Internal error: Oops: 207 [#1] SMP ARM
>   Modules linked in: mdio_bcm_unimac(+) brcmfmac cfg80211 brcmutil 
> raspberrypi_hwmon hci_uart crc32_arm_ce bcm2711_thermal phy_generic genet
>   CPU: 0 PID: 123 Comm: mkfs.ext4 Not tainted 5.9.6 #1
>   Hardware name: BCM2711
>   PC is at zs_map_object+0x94/0x338
>   LR is at zram_bvec_rw.constprop.0+0x330/0xa64
>   pc : []lr : []psr: 6013
>   sp : e376bbe0  ip :   fp : c1e2921c
>   r10: 0002  r9 : c1dda730  r8 : 
>   r7 : e8ff7a00  r6 :   r5 : 02f9ffa0  r4 : e371
>   r3 : 000fdffe  r2 : c1e0ce80  r1 : ebf979a0  r0 : 
>   Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
>   Control: 30c5383d  Table: 235c2a80  DAC: fffd
>   Process mkfs.ext4 (pid: 123, stack limit = 0x495a22e6)
>   Stack: (0xe376bbe0 to 0xe376c000)
>   ...
>   [] (zs_map_object) from [] 
> (zram_bvec_rw.constprop.0+0x330/0xa64)
>   [] (zram_bvec_rw.constprop.0) from [] 
> (zram_submit_bio+0x1a4/0x40c)
>   [] (zram_submit_bio) from [] 
> (submit_bio_noacct+0xd0/0x3c8)
>   [] (submit_bio_noacct) from [] (submit_bio+0x4c/0x190)
>   [] (submit_bio) from [] (submit_bh_wbc+0x188/0x1b8)
>   [] (submit_bh_wbc) from [] 
> (__block_write_full_page+0x340/0x5e4)
>   [] (__block_write_full_page) from [] 
> (block_write_full_page+0x128/0x170)
>   [] (block_write_full_page) from [] 
> (__writepage+0x14/0x68)
>   [] (__writepage) from [] (write_cache_pages+0x1bc/0x494)
>   [] (write_cache_pages) from [] 
> (generic_writepages+0x58/0x8c)
>   [] (generic_writepages) from [] 
> (do_writepages+0x48/0xec)
>   [] (do_writepages) from [] 
> (__filemap_fdatawrite_range+0xf0/0x128)
>   [] (__filemap_fdatawrite_range) from [] 
> (file_write_and_wait_range+0x48/0x98)
>   [] (file_write_and_wait_range) from [] 
> (blkdev_fsync+0x1c/0x44)
>   [] (blkdev_fsync) from [] (do_fsync+0x3c/0x70)
>   [] (do_fsync) from [] (__sys_trace_return+0x0/0x2c)
>   Exception stack(0xe376bfa8 to 0xe376bff0)
>   bfa0:   0003d2e0 b6f7b6f0 0003 00046e40 1000 
> 
>   bfc0: 0003d2e0 b6f7b6f0  0076   befcbb20 
> befcbb28
>   bfe0: b6f4e060 befcbad8 b6f23e0c b6dc4a80
>   Code: e5927000 e0050391 e0871005 e5918018 (e5983000)
> 
> Fixes: 61989a80fb3a ("staging: zsmalloc: zsmalloc memory allocation library")
> Signed-off-by: Stefan Agner 
> ---
>  mm/zsmalloc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index c36fdff9a371..260bd48aacd0 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -40,6 +40,7 @@
>  #include 
>  #include 
>  #include 
> +#include 

asm/sparsemem.h is not available on some architectures.
It's better to use linux/mmzone.h instead.

>  #include 
>  #include 
>  #include 
> -- 
> 2.29.1
> 
> 

-- 
Sincerely yours,
Mike.


[PATCH] security/smack: remove unused varible 'rc'

2020-11-07 Thread Alex Shi
This varible isn't used and can be removed to avoid a gcc warning:
security/smack/smack_lsm.c:3873:6: warning: variable ‘rc’ set but not
used [-Wunused-but-set-variable]

Signed-off-by: Alex Shi 
Cc: Casey Schaufler  
Cc: James Morris  
Cc: "Serge E. Hallyn"  
Cc: linux-security-mod...@vger.kernel.org 
Cc: linux-kernel@vger.kernel.org 
---
 security/smack/smack_lsm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 5c90b9fa4d40..9994fcfafd70 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -3870,7 +3870,6 @@ static struct smack_known *smack_from_netlbl(struct sock 
*sk, u16 family,
struct netlbl_lsm_secattr secattr;
struct socket_smack *ssp = NULL;
struct smack_known *skp = NULL;
-   int rc;
 
netlbl_secattr_init();
 
@@ -3880,7 +3879,7 @@ static struct smack_known *smack_from_netlbl(struct sock 
*sk, u16 family,
if (netlbl_skbuff_getattr(skb, family, ) == 0) {
skp = smack_from_secattr(, ssp);
if (secattr.flags & NETLBL_SECATTR_CACHEABLE)
-   rc = netlbl_cache_add(skb, family, >smk_netlabel);
+   netlbl_cache_add(skb, family, >smk_netlabel);
}
 
netlbl_secattr_destroy();
-- 
1.8.3.1



[PATCH] s390/qeth: remove useless if/else

2020-11-07 Thread xiakaixu1987
From: Kaixu Xia 

Fix the following coccinelle report:

./drivers/s390/net/qeth_l3_main.c:107:2-4: WARNING: possible condition with no 
effect (if == else)

Both branches are the same, so remove them.

Reported-by: Tosk Robot 
Signed-off-by: Kaixu Xia 
---
 drivers/s390/net/qeth_l3_main.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index b1c1d2510d55..264b6c782382 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -104,10 +104,7 @@ static bool qeth_l3_is_addr_covered_by_ipato(struct 
qeth_card *card,
qeth_l3_convert_addr_to_bits(ipatoe->addr, ipatoe_bits,
  (ipatoe->proto == QETH_PROT_IPV4) ?
  4 : 16);
-   if (addr->proto == QETH_PROT_IPV4)
-   rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
-   else
-   rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
+   rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
if (rc)
break;
}
-- 
2.20.0



mmotm 2020-11-07-21-40 uploaded

2020-11-07 Thread akpm
The mm-of-the-moment snapshot 2020-11-07-21-40 has been uploaded to

   https://www.ozlabs.org/~akpm/mmotm/

mmotm-readme.txt says

README for mm-of-the-moment:

https://www.ozlabs.org/~akpm/mmotm/

This is a snapshot of my -mm patch queue.  Uploaded at random hopefully
more than once a week.

You will need quilt to apply these patches to the latest Linus release (5.x
or 5.x-rcY).  The series file is in broken-out.tar.gz and is duplicated in
https://ozlabs.org/~akpm/mmotm/series

The file broken-out.tar.gz contains two datestamp files: .DATE and
.DATE--mm-dd-hh-mm-ss.  Both contain the string -mm-dd-hh-mm-ss,
followed by the base kernel version against which this patch series is to
be applied.

This tree is partially included in linux-next.  To see which patches are
included in linux-next, consult the `series' file.  Only the patches
within the #NEXT_PATCHES_START/#NEXT_PATCHES_END markers are included in
linux-next.


A full copy of the full kernel tree with the linux-next and mmotm patches
already applied is available through git within an hour of the mmotm
release.  Individual mmotm releases are tagged.  The master branch always
points to the latest release, so it's constantly rebasing.

https://github.com/hnaz/linux-mm

The directory https://www.ozlabs.org/~akpm/mmots/ (mm-of-the-second)
contains daily snapshots of the -mm tree.  It is updated more frequently
than mmotm, and is untested.

A git copy of this tree is also available at

https://github.com/hnaz/linux-mm



This mmotm tree contains the following patches against 5.10-rc2:
(patches marked "*" will be included in linux-next)

  origin.patch
* mm-compaction-count-pages-and-stop-correctly-during-page-isolation.patch
* 
mm-compaction-stop-isolation-if-too-many-pages-are-isolated-and-we-have-pages-to-migrate.patch
* mm-vmscan-fix-nr_isolated_file-corruption-on-64-bit.patch
* mailmap-fix-entry-for-dmitry-baryshkov-eremin-solenikov.patch
* mm-slub-fix-panic-in-slab_alloc_node.patch
* mm-gup-use-unpin_user_pages-in-__gup_longterm_locked.patch
* compilerh-fix-barrier_data-on-clang.patch
* compilerh-fix-barrier_data-on-clang-fix.patch
* revert-kernel-rebootc-convert-simple_strtoul-to-kstrtoint.patch
* reboot-fix-overflow-parsing-reboot-cpu-number.patch
* mm-fix-phys_to_target_node-and-memory_add_physaddr_to_nid-exports.patch
* mm-fix-phys_to_target_node-and-memory_add_physaddr_to_nid-exports-v4.patch
* mm-fix-readahead_page_batch-for-retry-entries.patch
* mm-filemap-add-static-for-function-__add_to_page_cache_locked.patch
* kernel-watchdog-fix-watchdog_allowed_mask-not-used-warning.patch
* mm-memcontrol-fix-missing-wakeup-polling-thread.patch
* hugetlbfs-fix-anon-huge-page-migration-race.patch
* mm-zsmalloc-include-sparsememh-for-max_physmem_bits.patch
* panic-dont-dump-stack-twice-on-warn.patch
* proc-kpageflags-prevent-an-integer-overflow-in-stable_page_flags.patch
* proc-kpageflags-do-not-use-uninitialized-struct-pages.patch
* kthread-add-kthread_work-tracepoints.patch
* kthread_worker-document-cpu-hotplug-handling.patch
* kthread_worker-document-cpu-hotplug-handling-fix.patch
* uapi-move-constants-from-linux-kernelh-to-linux-consth.patch
* fs-ocfs2-remove-unneeded-break.patch
* ocfs2-ratelimit-the-max-lookup-times-reached-notice.patch
* ocfs2-clear-links-count-in-ocfs2_mknod-if-an-error-occurs.patch
* ocfs2-fix-ocfs2-corrupt-when-iputting-an-inode.patch
* ramfs-support-o_tmpfile.patch
* kernel-watchdog-flush-all-printk-nmi-buffers-when-hardlockup-detected.patch
  mm.patch
* mmslab_common-use-list_for_each_entry-in-dump_unreclaimable_slab.patch
* mm-slub-use-kmem_cache_debug_flags-in-deactivate_slab.patch
* device-dax-kmem-use-struct_size.patch
* mm-fix-page_owner-initializing-issue-for-arm32.patch
* fs-break-generic_file_buffered_read-up-into-multiple-functions.patch
* fs-generic_file_buffered_read-now-uses-find_get_pages_contig.patch
* mm-msync-exit-early-when-the-flags-is-an-ms_async-and-start-vm_start.patch
* mm-gup_benchmark-rename-to-mm-gup_test.patch
* selftests-vm-use-a-common-gup_testh.patch
* selftests-vm-rename-run_vmtests-run_vmtestssh.patch
* selftests-vm-minor-cleanup-makefile-and-gup_testc.patch
* selftests-vm-only-some-gup_test-items-are-really-benchmarks.patch
* selftests-vm-gup_test-introduce-the-dump_pages-sub-test.patch
* selftests-vm-run_vmtestssh-update-and-clean-up-gup_test-invocation.patch
* selftests-vm-hmm-tests-remove-the-libhugetlbfs-dependency.patch
* selftests-vm-2x-speedup-for-run_vmtestssh.patch
* mm-gup_benchmark-mark-gup_benchmark_init-as-__init-function.patch
* mm-gup_benchmark-gup_benchmark-depends-on-debug_fs.patch
* mm-handle-zone-device-pages-in-release_pages.patch
* 
mm-swapfilec-use-helper-function-swap_count-in-add_swap_count_continuation.patch
* mm-swap_state-skip-meaningless-swap-cache-readahead-when-ra_infowin-==-0.patch
* 
mm-swap_state-skip-meaningless-swap-cache-readahead-when-ra_infowin-==-0-fix.patch
* mm-swapfilec-remove-unnecessary-out-label-in-__swap_duplicate.patch
* 

Re: [PATCH net-next] net: dlci: Deprecate the DLCI driver (aka the Frame Relay layer)

2020-11-07 Thread Xie He
On Sat, Oct 31, 2020 at 3:04 PM Jakub Kicinski  wrote:
>
> On Sat, 31 Oct 2020 22:41:30 +0100 Arnd Bergmann wrote:
> >
> > I think it can just go in the bin directly.
>
> Ack, fine by me.
>
> > I actually submitted a couple of patches to clean up drivers/net/wan
> > last year but didn't follow up with a new version after we decided
> > that x.25 is still needed, see
> > https://lore.kernel.org/netdev/20191209151256.2497534-1-a...@arndb.de/
> >
> > I can resubmit if you like.
>
> Let's just leave it at DLCI/SDLA for now, we can revisit once Dave
> is back :)

Hi Arnd,

Can you resubmit your patch to delete the DLCI / SDLA drivers? I
really want them to be deleted. Thank you so much!


[PATCH 06/19] elf/vdso: Reuse arch_setup_additional_pages() parameters

2020-11-07 Thread Dmitry Safonov
Both parameters of arch_setup_additional_pages() are currently unused.
commit fc5243d98ac2 ("[S390] arch_setup_additional_pages arguments")
tried to introduce useful arguments, but they still are not used.

Remove old parameters and introduce sysinfo_ehdr argument that will be
used to return vdso address to put as AT_SYSINFO_EHDR tag in auxiliary
vector. The reason to do it is that many architecture have vDSO pointer
saved in their mm->context with the only purpose to use it later
in ARCH_DLINFO. That's the macro for elf loader to setup sysinfo_ehdr
tag.

Return sysinfo_ehdr address that will be later used by ARCH_DLINFO as
an argument. That will allow to drop vDSO pointer from mm.context
and any code responsible to track vDSO position on platforms that
don't use vDSO as a landing in userspace (arm/s390/sparc).

Cc: Albert Ou 
Cc: "David S. Miller" 
Cc: Palmer Dabbelt 
Cc: Paul Walmsley 
Cc: linux-fsde...@vger.kernel.org
Signed-off-by: Dmitry Safonov 
---
 arch/arm/include/asm/vdso.h|  6 --
 arch/arm/kernel/process.c  |  4 ++--
 arch/arm/kernel/vdso.c | 10 +++---
 arch/arm64/kernel/vdso.c   | 17 
 arch/csky/kernel/vdso.c|  3 ++-
 arch/hexagon/kernel/vdso.c |  3 ++-
 arch/mips/kernel/vdso.c|  3 ++-
 arch/nds32/kernel/vdso.c   |  3 ++-
 arch/nios2/mm/init.c   |  2 +-
 arch/powerpc/kernel/vdso.c |  3 ++-
 arch/riscv/kernel/vdso.c   |  9 +
 arch/s390/kernel/vdso.c|  3 ++-
 arch/sh/kernel/vsyscall/vsyscall.c |  3 ++-
 arch/sparc/vdso/vma.c  | 15 +++---
 arch/x86/entry/vdso/vma.c  | 32 +-
 arch/x86/um/vdso/vma.c |  2 +-
 fs/binfmt_elf.c|  3 ++-
 fs/binfmt_elf_fdpic.c  |  3 ++-
 include/linux/elf.h| 17 +++-
 19 files changed, 84 insertions(+), 57 deletions(-)

diff --git a/arch/arm/include/asm/vdso.h b/arch/arm/include/asm/vdso.h
index 5b85889f82ee..6b2b3b1fe833 100644
--- a/arch/arm/include/asm/vdso.h
+++ b/arch/arm/include/asm/vdso.h
@@ -10,13 +10,15 @@ struct mm_struct;
 
 #ifdef CONFIG_VDSO
 
-void arm_install_vdso(struct mm_struct *mm, unsigned long addr);
+void arm_install_vdso(struct mm_struct *mm, unsigned long addr,
+ unsigned long *sysinfo_ehdr);
 
 extern unsigned int vdso_total_pages;
 
 #else /* CONFIG_VDSO */
 
-static inline void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
+static inline void arm_install_vdso(struct mm_struct *mm, unsigned long addr,
+   unsigned long *sysinfo_ehdr)
 {
 }
 
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index d0220da1d1b1..0e90cba8ac7a 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -389,7 +389,7 @@ static const struct vm_special_mapping sigpage_mapping = {
.mremap = sigpage_mremap,
 };
 
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
 {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
@@ -430,7 +430,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, 
int uses_interp)
 * to be fatal to the process, so no error check needed
 * here.
 */
-   arm_install_vdso(mm, addr + PAGE_SIZE);
+   arm_install_vdso(mm, addr + PAGE_SIZE, sysinfo_ehdr);
 
  up_fail:
mmap_write_unlock(mm);
diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index 3408269d19c7..710e5ca99a53 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -233,7 +233,8 @@ static int install_vvar(struct mm_struct *mm, unsigned long 
addr)
 }
 
 /* assumes mmap_lock is write-locked */
-void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
+void arm_install_vdso(struct mm_struct *mm, unsigned long addr,
+ unsigned long *sysinfo_ehdr)
 {
struct vm_area_struct *vma;
unsigned long len;
@@ -254,7 +255,10 @@ void arm_install_vdso(struct mm_struct *mm, unsigned long 
addr)
VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
_text_mapping);
 
-   if (!IS_ERR(vma))
-   mm->context.vdso = addr;
+   if (IS_ERR(vma))
+   return;
+
+   mm->context.vdso = addr;
+   *sysinfo_ehdr = addr;
 }
 
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 1b710deb84d6..666338724a07 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -213,8 +213,7 @@ static vm_fault_t vvar_fault(const struct 
vm_special_mapping *sm,
 
 static int __setup_additional_pages(enum vdso_abi abi,
struct mm_struct *mm,
-   struct linux_binprm *bprm,
-   int uses_interp)
+   unsigned long 

[PATCH 19/19] mips/vdso: Migrate to user_landing

2020-11-07 Thread Dmitry Safonov
Generic way to track the land vma area.
As a bonus, after unmapping sigpage, kernel won't try to land on its
previous position.

Cc: Thomas Bogendoerfer 
Cc: linux-m...@vger.kernel.org
Signed-off-by: Dmitry Safonov 
---
 arch/mips/Kconfig |  1 +
 arch/mips/kernel/signal.c | 11 +++
 arch/mips/kernel/vdso.c   |  2 +-
 arch/mips/vdso/genvdso.c  |  8 
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5e696ab80df4..eedb1683ec8e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -10,6 +10,7 @@ config MIPS
select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAS_UBSAN_SANITIZE_ALL
+   select ARCH_HAS_USER_LANDING
select ARCH_SUPPORTS_UPROBES
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_CMPXCHG_LOCKREF if 64BIT
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index f1e985109da0..eb79272d3cc2 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -806,11 +806,13 @@ struct mips_abi mips_abi = {
 
 static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
 {
+   unsigned long land = (unsigned long)current->mm->user_landing;
sigset_t *oldset = sigmask_to_save();
-   int ret;
+   int ret = 1;
struct mips_abi *abi = current->thread.abi;
-   void *vdso = current->mm->context.vdso;
 
+   if (land == UNMAPPED_USER_LANDING)
+   goto err;
/*
 * If we were emulating a delay slot instruction, exit that frame such
 * that addresses in the sigframe are as expected for userland and we
@@ -843,12 +845,13 @@ static void handle_signal(struct ksignal *ksig, struct 
pt_regs *regs)
rseq_signal_deliver(ksig, regs);
 
if (sig_uses_siginfo(>ka, abi))
-   ret = abi->setup_rt_frame(vdso + abi->vdso->off_rt_sigreturn,
+   ret = abi->setup_rt_frame(land + abi->vdso->off_rt_sigreturn,
  ksig, regs, oldset);
else
-   ret = abi->setup_frame(vdso + abi->vdso->off_sigreturn,
+   ret = abi->setup_frame(land + abi->vdso->off_sigreturn,
   ksig, regs, oldset);
 
+err:
signal_setup_done(ret, ksig, 0);
 }
 
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index a4a321252df6..5523ba25ab3d 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -183,7 +183,7 @@ int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
goto out;
}
 
-   mm->context.vdso = (void *)vdso_addr;
+   mm->user_landing = (void __user *)vdso_addr;
*sysinfo_ehdr = vdso_addr;
ret = 0;
 
diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c
index 0303d30cde03..8f581a2c8578 100644
--- a/arch/mips/vdso/genvdso.c
+++ b/arch/mips/vdso/genvdso.c
@@ -259,13 +259,6 @@ int main(int argc, char **argv)
fprintf(out_file, "#include \n");
fprintf(out_file, "#include \n");
fprintf(out_file, "#include \n");
-   fprintf(out_file, "static void vdso_mremap(\n");
-   fprintf(out_file, " const struct vm_special_mapping *sm,\n");
-   fprintf(out_file, " struct vm_area_struct *new_vma)\n");
-   fprintf(out_file, "{\n");
-   fprintf(out_file, " current->mm->context.vdso =\n");
-   fprintf(out_file, " (void *)(new_vma->vm_start);\n");
-   fprintf(out_file, "}\n");
 
/* Write out the stripped VDSO data. */
fprintf(out_file,
@@ -290,7 +283,6 @@ int main(int argc, char **argv)
fprintf(out_file, "\t.mapping = {\n");
fprintf(out_file, "\t\t.name = \"[vdso]\",\n");
fprintf(out_file, "\t\t.pages = vdso_pages,\n");
-   fprintf(out_file, "\t\t.mremap = vdso_mremap,\n");
fprintf(out_file, "\t},\n");
 
/* Calculate and write symbol offsets to  */
-- 
2.28.0



[PATCH 17/19] arm64/vdso: Migrate compat signals to user_landing

2020-11-07 Thread Dmitry Safonov
Generic way to track the land vma area.
As a bonus, after unmapping sigpage, kernel won't try to land on its
previous position.

Signed-off-by: Dmitry Safonov 
---
 arch/arm64/Kconfig   |  1 +
 arch/arm64/kernel/signal32.c | 17 -
 arch/arm64/kernel/vdso.c |  2 +-
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7111cf335ede..56505e396253 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -38,6 +38,7 @@ config ARM64
select ARCH_HAS_SYSCALL_WRAPPER
select ARCH_HAS_TEARDOWN_DMA_OPS if IOMMU_SUPPORT
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+   select ARCH_HAS_USER_LANDING
select ARCH_HAVE_ELF_PROT
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select ARCH_INLINE_READ_LOCK if !PREEMPTION
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index 2f507f565c48..61d583c73be3 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal32.c
@@ -315,7 +315,7 @@ static void __user *compat_get_sigframe(struct ksignal 
*ksig,
return frame;
 }
 
-static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
+static int compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
compat_ulong_t __user *rc, void __user *frame,
int usig)
 {
@@ -342,13 +342,16 @@ static void compat_setup_return(struct pt_regs *regs, 
struct k_sigaction *ka,
retcode = ptr_to_compat(ka->sa.sa_restorer);
} else {
/* Set up sigreturn pointer */
+   unsigned long land = (unsigned long)current->mm->user_landing;
unsigned int idx = thumb << 1;
 
if (ka->sa.sa_flags & SA_SIGINFO)
idx += 3;
 
-   retcode = (unsigned long)current->mm->context.sigpage +
- (idx << 2) + thumb;
+   if (land == UNMAPPED_USER_LANDING)
+   return 1;
+
+   retcode = land + (idx << 2) + thumb;
}
 
regs->regs[0]   = usig;
@@ -356,6 +359,8 @@ static void compat_setup_return(struct pt_regs *regs, 
struct k_sigaction *ka,
regs->compat_lr = retcode;
regs->pc= handler;
regs->pstate= spsr;
+
+   return 0;
 }
 
 static int compat_setup_sigframe(struct compat_sigframe __user *sf,
@@ -425,7 +430,8 @@ int compat_setup_rt_frame(int usig, struct ksignal *ksig,
err |= compat_setup_sigframe(>sig, regs, set);
 
if (err == 0) {
-   compat_setup_return(regs, >ka, frame->sig.retcode, frame, 
usig);
+   err = compat_setup_return(regs, >ka,
+ frame->sig.retcode, frame, usig);
regs->regs[1] = (compat_ulong_t)(unsigned long)>info;
regs->regs[2] = (compat_ulong_t)(unsigned long)>sig.uc;
}
@@ -448,7 +454,8 @@ int compat_setup_frame(int usig, struct ksignal *ksig, 
sigset_t *set,
 
err |= compat_setup_sigframe(frame, regs, set);
if (err == 0)
-   compat_setup_return(regs, >ka, frame->retcode, frame, 
usig);
+   err = compat_setup_return(regs, >ka,
+ frame->retcode, frame, usig);
 
return err;
 }
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 91c1b7c716b7..08e8f1d56d92 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -394,7 +394,7 @@ static int aarch32_sigreturn_setup(struct mm_struct *mm)
if (IS_ERR(ret))
goto out;
 
-   mm->context.sigpage = (void *)addr;
+   mm->user_landing = (void __user *)addr;
 
 out:
return PTR_ERR_OR_ZERO(ret);
-- 
2.28.0



[PATCH 14/19] mm: Add user_landing in mm_struct

2020-11-07 Thread Dmitry Safonov
Instead of having every architecture to define vdso_base/vdso_addr etc,
provide a generic mechanism to track landing in userspace.
It'll minimize per-architecture difference, the number of callbacks to
provide.

Originally, it started from thread [1] where the need for .close()
callback on vm_special_mapping was pointed, this generic code besides
removing duplicated .mremap() callbacks provides a cheaper way to
support munmap() on vdso mappings without introducing .close() callbacks
for every architecture (with would bring even more code duplication).

[1]: 
https://lore.kernel.org/linux-arch/cajwjo6zanqykshbq+3b+fi_vt80mtrzev5yreqawx-l8j8x...@mail.gmail.com/
Cc: Thomas Bogendoerfer 
Cc: linux-m...@vger.kernel.org
Signed-off-by: Dmitry Safonov 
---
 arch/x86/kernel/cpu/resctrl/pseudo_lock.c |  3 ++-
 fs/aio.c  |  3 ++-
 include/linux/mm.h|  3 ++-
 include/linux/mm_types.h  | 10 ++
 mm/Kconfig|  3 +++
 mm/mmap.c | 19 ++-
 mm/mremap.c   |  2 +-
 7 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c 
b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
index e916646adc69..786c97203bf6 100644
--- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
+++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
@@ -1458,7 +1458,8 @@ static int pseudo_lock_dev_release(struct inode *inode, 
struct file *filp)
return 0;
 }
 
-static int pseudo_lock_dev_mremap(struct vm_area_struct *area, unsigned long 
flags)
+static int pseudo_lock_dev_mremap(struct vm_area_struct *old_vma,
+   struct vm_area_struct *new_vma, unsigned long flags)
 {
/* Not supported */
return -EINVAL;
diff --git a/fs/aio.c b/fs/aio.c
index d1dad4cd860f..2695dc9ed46f 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -324,7 +324,8 @@ static void aio_free_ring(struct kioctx *ctx)
}
 }
 
-static int aio_ring_mremap(struct vm_area_struct *vma, unsigned long flags)
+static int aio_ring_mremap(struct vm_area_struct *old_vma,
+  struct vm_area_struct *vma, unsigned long flags)
 {
struct file *file = vma->vm_file;
struct mm_struct *mm = vma->vm_mm;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 427911d2c83e..4b0f97a289b3 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -559,7 +559,8 @@ struct vm_operations_struct {
void (*close)(struct vm_area_struct * area);
/* Called any time before splitting to check if it's allowed */
int (*may_split)(struct vm_area_struct *area, unsigned long addr);
-   int (*mremap)(struct vm_area_struct *area, unsigned long flags);
+   int (*mremap)(struct vm_area_struct *old_vma,
+   struct vm_area_struct *new_vma, unsigned long flags);
vm_fault_t (*fault)(struct vm_fault *vmf);
vm_fault_t (*huge_fault)(struct vm_fault *vmf,
enum page_entry_size pe_size);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index b035caff6abe..f888257e973a 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -488,6 +488,16 @@ struct mm_struct {
 
/* Architecture-specific MM context */
mm_context_t context;
+#ifdef CONFIG_ARCH_HAS_USER_LANDING
+   /*
+* Address of special mapping VMA to land after processing
+* a signal. Reads are unprotected: if a thread unmaps or
+* mremaps the mapping while another thread is processing
+* a signal, it can segfault while landing.
+*/
+   void __user *user_landing;
+#endif
+#define UNMAPPED_USER_LANDING TASK_SIZE_MAX
 
unsigned long flags; /* Must use atomic bitops to access */
 
diff --git a/mm/Kconfig b/mm/Kconfig
index 01b0ae0cd9d3..d43b61a21be8 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -883,4 +883,7 @@ config ARCH_HAS_HUGEPD
 config MAPPING_DIRTY_HELPERS
 bool
 
+config ARCH_HAS_USER_LANDING
+   bool
+
 endmenu
diff --git a/mm/mmap.c b/mm/mmap.c
index 2376f3972f13..8a17ffdedacb 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3410,11 +3410,25 @@ void vm_stat_account(struct mm_struct *mm, vm_flags_t 
flags, long npages)
 
 static vm_fault_t special_mapping_fault(struct vm_fault *vmf);
 
+static void update_user_landing(struct vm_area_struct *old_vma,
+   unsigned long new_addr)
+{
+#ifdef CONFIG_ARCH_HAS_USER_LANDING
+   struct mm_struct *mm = old_vma->vm_mm;
+
+   if (WARN_ON_ONCE(!mm))
+   return;
+   if (old_vma->vm_start == (unsigned long)mm->user_landing)
+   mm->user_landing = (void __user *)new_addr;
+#endif
+}
+
 /*
  * Having a close hook prevents vma merging regardless of flags.
  */
 static void special_mapping_close(struct vm_area_struct *vma)
 {
+   

[PATCH 11/19] mm/mmap: Make vm_special_mapping::mremap return void

2020-11-07 Thread Dmitry Safonov
Previously .mremap() callback needed (int) return to provide way to
restrict resizing of a special mapping. Now it's restricted by
providing .may_split = special_mapping_split.

Removing (int) return simplifies further changes to
special_mapping_mremap() as it won't need save ret code from the
callback. Also, it removes needless `return 0` from callbacks.

Signed-off-by: Dmitry Safonov 
---
 arch/arm/kernel/process.c | 3 +--
 arch/arm64/kernel/vdso.c  | 4 +---
 arch/mips/vdso/genvdso.c  | 3 +--
 arch/x86/entry/vdso/vma.c | 4 +---
 include/linux/mm_types.h  | 2 +-
 mm/mmap.c | 2 +-
 6 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 0e90cba8ac7a..5f4eced738f5 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -376,11 +376,10 @@ static unsigned long sigpage_addr(const struct mm_struct 
*mm,
 static struct page *signal_page;
 extern struct page *get_signal_page(void);
 
-static int sigpage_mremap(const struct vm_special_mapping *sm,
+static void sigpage_mremap(const struct vm_special_mapping *sm,
struct vm_area_struct *new_vma)
 {
current->mm->context.sigpage = new_vma->vm_start;
-   return 0;
 }
 
 static const struct vm_special_mapping sigpage_mapping = {
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 666338724a07..91c1b7c716b7 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -78,12 +78,10 @@ static union {
 } vdso_data_store __page_aligned_data;
 struct vdso_data *vdso_data = vdso_data_store.data;
 
-static int vdso_mremap(const struct vm_special_mapping *sm,
+static void vdso_mremap(const struct vm_special_mapping *sm,
struct vm_area_struct *new_vma)
 {
current->mm->context.vdso = (void *)new_vma->vm_start;
-
-   return 0;
 }
 
 static int __vdso_init(enum vdso_abi abi)
diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c
index 09e30eb4be86..0303d30cde03 100644
--- a/arch/mips/vdso/genvdso.c
+++ b/arch/mips/vdso/genvdso.c
@@ -259,13 +259,12 @@ int main(int argc, char **argv)
fprintf(out_file, "#include \n");
fprintf(out_file, "#include \n");
fprintf(out_file, "#include \n");
-   fprintf(out_file, "static int vdso_mremap(\n");
+   fprintf(out_file, "static void vdso_mremap(\n");
fprintf(out_file, " const struct vm_special_mapping *sm,\n");
fprintf(out_file, " struct vm_area_struct *new_vma)\n");
fprintf(out_file, "{\n");
fprintf(out_file, " current->mm->context.vdso =\n");
fprintf(out_file, " (void *)(new_vma->vm_start);\n");
-   fprintf(out_file, " return 0;\n");
fprintf(out_file, "}\n");
 
/* Write out the stripped VDSO data. */
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 5b9020742e66..65780a0164e3 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -86,15 +86,13 @@ static void vdso_fix_landing(const struct vdso_image *image,
 #endif
 }
 
-static int vdso_mremap(const struct vm_special_mapping *sm,
+static void vdso_mremap(const struct vm_special_mapping *sm,
struct vm_area_struct *new_vma)
 {
const struct vdso_image *image = current->mm->context.vdso_image;
 
vdso_fix_landing(image, new_vma);
current->mm->context.vdso = (void __user *)new_vma->vm_start;
-
-   return 0;
 }
 
 #ifdef CONFIG_TIME_NS
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 6a6b078b9d6a..b035caff6abe 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -772,7 +772,7 @@ struct vm_special_mapping {
struct vm_area_struct *vma,
struct vm_fault *vmf);
 
-   int (*mremap)(const struct vm_special_mapping *sm,
+   void (*mremap)(const struct vm_special_mapping *sm,
 struct vm_area_struct *new_vma);
 };
 
diff --git a/mm/mmap.c b/mm/mmap.c
index 61f72b09d990..2376f3972f13 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3434,7 +3434,7 @@ static int special_mapping_mremap(struct vm_area_struct 
*new_vma,
return -EFAULT;
 
if (sm->mremap)
-   return sm->mremap(sm, new_vma);
+   sm->mremap(sm, new_vma);
 
return 0;
 }
-- 
2.28.0



[PATCH 16/19] arm/vdso: Migrate to user_landing

2020-11-07 Thread Dmitry Safonov
Generic way to track the land vma area.
As a bonus, after unmapping sigpage, kernel won't try to land on its
previous position.

Signed-off-by: Dmitry Safonov 
---
 arch/arm/Kconfig  | 1 +
 arch/arm/kernel/process.c | 9 +
 arch/arm/kernel/signal.c  | 6 +-
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bece41f3b3b9..c161d7313911 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -24,6 +24,7 @@ config ARM
select ARCH_HAS_SYNC_DMA_FOR_CPU if SWIOTLB
select ARCH_HAS_TEARDOWN_DMA_OPS if MMU
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+   select ARCH_HAS_USER_LANDING
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_HAS_GCOV_PROFILE_ALL
select ARCH_KEEP_MEMBLOCK
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 5f4eced738f5..ac08241e5cf8 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -376,16 +376,9 @@ static unsigned long sigpage_addr(const struct mm_struct 
*mm,
 static struct page *signal_page;
 extern struct page *get_signal_page(void);
 
-static void sigpage_mremap(const struct vm_special_mapping *sm,
-   struct vm_area_struct *new_vma)
-{
-   current->mm->context.sigpage = new_vma->vm_start;
-}
-
 static const struct vm_special_mapping sigpage_mapping = {
.name = "[sigpage]",
.pages = _page,
-   .mremap = sigpage_mremap,
 };
 
 int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
@@ -423,7 +416,7 @@ int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
goto up_fail;
}
 
-   mm->context.sigpage = addr;
+   mm->user_landing = (void __user *)addr;
 
/* Unlike the sigpage, failure to install the vdso is unlikely
 * to be fatal to the process, so no error check needed
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 9d2e916121be..270b17a9dc0f 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -451,13 +451,17 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
 #ifdef CONFIG_MMU
if (cpsr & MODE32_BIT) {
struct mm_struct *mm = current->mm;
+   unsigned long land = (unsigned long)mm->user_landing;
+
+   if (land == UNMAPPED_USER_LANDING)
+   return 1;
 
/*
 * 32-bit code can use the signal return page
 * except when the MPU has protected the vectors
 * page from PL0
 */
-   retcode = mm->context.sigpage + signal_return_offset +
+   retcode = land + signal_return_offset +
  (idx << 2) + thumb;
} else
 #endif
-- 
2.28.0



[PATCH 07/19] elf: Use sysinfo_ehdr in ARCH_DLINFO()

2020-11-07 Thread Dmitry Safonov
Instead mm->context.vdso use the pointer provided by elf loader.
That allows to drop the pointer on arm/s390/sparc.

Cc: Christian Borntraeger 
Cc: Heiko Carstens 
Cc: Vasily Gorbik 
Cc: linux-s...@vger.kernel.org
Cc: "David S. Miller" 
Cc: sparcli...@vger.kernel.org
Signed-off-by: Dmitry Safonov 
---
 arch/alpha/include/asm/elf.h|  2 +-
 arch/arm/include/asm/elf.h  |  5 ++---
 arch/arm64/include/asm/elf.h| 18 +-
 arch/ia64/include/asm/elf.h |  2 +-
 arch/mips/include/asm/elf.h |  5 ++---
 arch/nds32/include/asm/elf.h|  5 ++---
 arch/powerpc/include/asm/elf.h  |  4 ++--
 arch/riscv/include/asm/elf.h|  5 ++---
 arch/s390/include/asm/elf.h |  5 ++---
 arch/sh/include/asm/elf.h   | 10 +-
 arch/sparc/include/asm/elf_64.h |  5 ++---
 arch/x86/include/asm/elf.h  | 33 ++---
 arch/x86/um/asm/elf.h   |  4 ++--
 fs/binfmt_elf.c |  6 +++---
 fs/binfmt_elf_fdpic.c   | 11 ++-
 15 files changed, 51 insertions(+), 69 deletions(-)

diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
index 8049997fa372..701e820f28f0 100644
--- a/arch/alpha/include/asm/elf.h
+++ b/arch/alpha/include/asm/elf.h
@@ -155,7 +155,7 @@ extern int alpha_l2_cacheshape;
 extern int alpha_l3_cacheshape;
 
 /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
-#define ARCH_DLINFO\
+#define ARCH_DLINFO(sysinfo_ehdr)  \
   do { \
 NEW_AUX_ENT(AT_L1I_CACHESHAPE, alpha_l1i_cacheshape);  \
 NEW_AUX_ENT(AT_L1D_CACHESHAPE, alpha_l1d_cacheshape);  \
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 1f4b91a17a91..7bb07056242f 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -133,10 +133,9 @@ extern void elf_set_personality(const struct elf32_hdr *);
 #define SET_PERSONALITY(ex)elf_set_personality(&(ex))
 
 #ifdef CONFIG_VDSO
-#define ARCH_DLINFO\
+#define ARCH_DLINFO(sysinfo_ehdr)  \
 do {   \
-   NEW_AUX_ENT(AT_SYSINFO_EHDR,\
-   (elf_addr_t)current->mm->context.vdso); \
+   NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
 } while (0)
 #endif
 
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index a81953bcc1cf..e62818967a69 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -165,10 +165,9 @@ typedef struct user_fpsimd_state elf_fpregset_t;
 })
 
 /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
-#define ARCH_DLINFO\
+#define ARCH_DLINFO(sysinfo_ehdr)  \
 do {   \
-   NEW_AUX_ENT(AT_SYSINFO_EHDR,\
-   (elf_addr_t)current->mm->context.vdso); \
+   NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
\
/*  \
 * Should always be nonzero unless there's a kernel bug.\
@@ -223,19 +222,12 @@ typedef compat_elf_greg_t 
compat_elf_gregset_t[COMPAT_ELF_NGREG];
set_thread_flag(TIF_32BIT); \
  })
 #ifdef CONFIG_COMPAT_VDSO
-#define COMPAT_ARCH_DLINFO \
+#define COMPAT_ARCH_DLINFO(sysinfo_ehdr)   \
 do {   \
-   /*  \
-* Note that we use Elf64_Off instead of elf_addr_t because \
-* elf_addr_t in compat is defined as Elf32_Addr and casting\
-* current->mm->context.vdso to it triggers a cast warning of   \
-* cast from pointer to integer of different size.  \
-*/ \
-   NEW_AUX_ENT(AT_SYSINFO_EHDR,\
-   (Elf64_Off)current->mm->context.vdso);  \
+   NEW_AUX_ENT(AT_SYSINFO_EHDR, sysinfo_ehdr); \
 } while (0)
 #else
-#define COMPAT_ARCH_DLINFO
+#define COMPAT_ARCH_DLINFO(sysinfo_ehdr)
 #endif
 
 #endif /* CONFIG_COMPAT */
diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
index 6629301a2620..a257e5abddce 100644
--- a/arch/ia64/include/asm/elf.h
+++ b/arch/ia64/include/asm/elf.h
@@ -208,7 +208,7 @@ struct task_struct;
 #define GATE_EHDR  ((const struct elfhdr *) GATE_ADDR)
 

[PATCH 09/19] s390/vdso: Remove vdso_base pointer from mm->context

2020-11-07 Thread Dmitry Safonov
Not used any more.

Cc: Christian Borntraeger 
Cc: Heiko Carstens 
Cc: Vasily Gorbik 
Cc: linux-s...@vger.kernel.org
Signed-off-by: Dmitry Safonov 
---
 arch/s390/include/asm/mmu.h |  1 -
 arch/s390/kernel/vdso.c | 10 --
 2 files changed, 11 deletions(-)

diff --git a/arch/s390/include/asm/mmu.h b/arch/s390/include/asm/mmu.h
index e12ff0f29d1a..095d0596f700 100644
--- a/arch/s390/include/asm/mmu.h
+++ b/arch/s390/include/asm/mmu.h
@@ -15,7 +15,6 @@ typedef struct {
unsigned long gmap_asce;
unsigned long asce;
unsigned long asce_limit;
-   unsigned long vdso_base;
/* The mmu context belongs to a secure guest. */
atomic_t is_protected;
/*
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index 810b72f8985c..3f07711a07c1 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -58,18 +58,9 @@ static vm_fault_t vdso_fault(const struct vm_special_mapping 
*sm,
return 0;
 }
 
-static int vdso_mremap(const struct vm_special_mapping *sm,
-  struct vm_area_struct *vma)
-{
-   current->mm->context.vdso_base = vma->vm_start;
-
-   return 0;
-}
-
 static const struct vm_special_mapping vdso_mapping = {
.name = "[vdso]",
.fault = vdso_fault,
-   .mremap = vdso_mremap,
 };
 
 static int __init vdso_setup(char *str)
@@ -204,7 +195,6 @@ int arch_setup_additional_pages(unsigned long *sysinfo_ehdr)
goto out_up;
}
 
-   current->mm->context.vdso_base = vdso_base;
*sysinfo_ehdr = vdso_base;
rc = 0;
 
-- 
2.28.0



[PATCH 12/19] x86/signal: Land on >retcode when vdso isn't mapped

2020-11-07 Thread Dmitry Safonov
Since commit 9fbbd4dd17d0 ("x86: Don't require the vDSO for handling
a.out signals") after processing 32-bit signal if there is no vdso
mapped frame->retcode is used as a landing.
Do the same for rt ia32 signals.

This shouldn't be mistaken for encouragement for running binaries with
executable stack, rather something to do in hopefully very rare
situation with disabled or unmapped vdso and absent SA_RESTORER.
For non-executable stack it'll segfault on attempt to land, rather than
land on a random address where vdso was previously mapped.
For programs with executable stack it'll just do the same for rt signals
as for non-rt.

Discouraging users to run with executable stack is done separately in
commit 47a2ebb7f505 ("execve: warn if process starts with executable
stack").

Signed-off-by: Dmitry Safonov 
---
 arch/x86/ia32/ia32_signal.c | 12 +++-
 arch/x86/kernel/signal.c| 23 ++-
 2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 81cf22398cd1..ea3db15b57bf 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -270,8 +270,8 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
unsafe_put_user(set->sig[1], >extramask[0], Efault);
unsafe_put_user(ptr_to_compat(restorer), >pretcode, Efault);
/*
-* These are actually not used anymore, but left because some
-* gdb versions depend on them as a marker.
+* This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
+* gdb uses it as a signature to notice signal handler stack frames.
 */
unsafe_put_user(*((u64 *)), (u64 __user *)frame->retcode, Efault);
user_access_end();
@@ -336,14 +336,16 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
 
if (ksig->ka.sa.sa_flags & SA_RESTORER)
restorer = ksig->ka.sa.sa_restorer;
-   else
+   else if (current->mm->context.vdso)
restorer = current->mm->context.vdso +
vdso_image_32.sym___kernel_rt_sigreturn;
+   else
+   restorer = >retcode;
unsafe_put_user(ptr_to_compat(restorer), >pretcode, Efault);
 
/*
-* Not actually used anymore, but left because some gdb
-* versions need it.
+* This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
+* gdb uses it as a signature to notice signal handler stack frames.
 */
unsafe_put_user(*((u64 *)), (u64 __user *)frame->retcode, Efault);
unsafe_put_sigcontext32(>uc.uc_mcontext, fp, regs, set, Efault);
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index ea794a083c44..372ec09dc4ac 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -317,23 +317,20 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t 
*set,
unsafe_put_user(sig, >sig, Efault);
unsafe_put_sigcontext(>sc, fp, regs, set, Efault);
unsafe_put_user(set->sig[1], >extramask[0], Efault);
-   if (current->mm->context.vdso)
+   if (ksig->ka.sa.sa_flags & SA_RESTORER)
+   restorer = ksig->ka.sa.sa_restorer;
+   else if (current->mm->context.vdso)
restorer = current->mm->context.vdso +
vdso_image_32.sym___kernel_sigreturn;
else
restorer = >retcode;
-   if (ksig->ka.sa.sa_flags & SA_RESTORER)
-   restorer = ksig->ka.sa.sa_restorer;
 
/* Set up to return from userspace.  */
unsafe_put_user(restorer, >pretcode, Efault);
 
/*
 * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
-*
-* WE DO NOT USE IT ANY MORE! It's only left here for historical
-* reasons and because gdb uses it as a signature to notice
-* signal handler stack frames.
+* gdb uses it as a signature to notice signal handler stack frames.
 */
unsafe_put_user(*((u64 *)), (u64 *)frame->retcode, Efault);
user_access_end();
@@ -382,18 +379,18 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
unsafe_save_altstack(>uc.uc_stack, regs->sp, Efault);
 
/* Set up to return from userspace.  */
-   restorer = current->mm->context.vdso +
-   vdso_image_32.sym___kernel_rt_sigreturn;
if (ksig->ka.sa.sa_flags & SA_RESTORER)
restorer = ksig->ka.sa.sa_restorer;
+   else if (current->mm->context.vdso)
+   restorer = current->mm->context.vdso +
+   vdso_image_32.sym___kernel_rt_sigreturn;
+   else
+   restorer = >retcode;
unsafe_put_user(restorer, >pretcode, Efault);
 
/*
 * This is movl $__NR_rt_sigreturn, %ax ; int $0x80
-*
-* WE DO NOT USE IT ANY MORE! It's only left here for historical
-* reasons and because gdb uses it as a signature to notice
-* signal handler stack frames.
+  

[PATCH 15/19] x86/vdso: Migrate to user_landing

2020-11-07 Thread Dmitry Safonov
Generic way to track the land vma area.
As a bonus, after unmapping vdso, kernel won't try to land on its
previous position.

Signed-off-by: Dmitry Safonov 
---
 arch/x86/Kconfig| 1 +
 arch/x86/entry/common.c | 3 ++-
 arch/x86/entry/vdso/vma.c   | 9 -
 arch/x86/ia32/ia32_signal.c | 4 ++--
 arch/x86/include/asm/mmu.h  | 1 -
 arch/x86/include/asm/vdso.h | 2 +-
 arch/x86/kernel/signal.c| 4 ++--
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index b068f949d2e4..2449844ef0e9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -84,6 +84,7 @@ config X86
select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
select ARCH_HAS_SYSCALL_WRAPPER
select ARCH_HAS_UBSAN_SANITIZE_ALL
+   select ARCH_HAS_USER_LANDING
select ARCH_HAS_DEBUG_WX
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 1be1bdbe55d4..1a3f795af331 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -151,9 +151,10 @@ __visible noinstr long do_fast_syscall_32(struct pt_regs 
*regs)
 * Called using the internal vDSO SYSENTER/SYSCALL32 calling
 * convention.  Adjust regs so it looks like we entered using int80.
 */
-   landing_pad = (unsigned long)current->mm->context.vdso +
+   landing_pad = (unsigned long)current->mm->user_landing +
vdso_image_32.sym_int80_landing_pad;
 
+
/*
 * SYSENTER loses EIP, and even SYSCALL32 needs us to skip forward
 * so that 'regs->ip -= 2' lands back on an int $0x80 instruction.
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 65780a0164e3..2c426997a7a4 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -77,7 +77,7 @@ static void vdso_fix_landing(const struct vdso_image *image,
struct pt_regs *regs = current_pt_regs();
unsigned long vdso_land = image->sym_int80_landing_pad;
unsigned long old_land_addr = vdso_land +
-   (unsigned long)current->mm->context.vdso;
+   (unsigned long)current->mm->user_landing;
 
/* Fixing userspace landing - look at do_fast_syscall_32 */
if (regs->ip == old_land_addr)
@@ -92,7 +92,6 @@ static void vdso_mremap(const struct vm_special_mapping *sm,
const struct vdso_image *image = current->mm->context.vdso_image;
 
vdso_fix_landing(image, new_vma);
-   current->mm->context.vdso = (void __user *)new_vma->vm_start;
 }
 
 #ifdef CONFIG_TIME_NS
@@ -287,7 +286,7 @@ static int map_vdso(const struct vdso_image *image, 
unsigned long addr,
ret = PTR_ERR(vma);
do_munmap(mm, text_start, image->size, NULL);
} else {
-   current->mm->context.vdso = (void __user *)text_start;
+   current->mm->user_landing = (void __user *)text_start;
current->mm->context.vdso_image = image;
*sysinfo_ehdr = text_start;
}
@@ -362,8 +361,8 @@ int map_vdso_once(const struct vdso_image *image, unsigned 
long addr)
 * Check if we have already mapped vdso blob - fail to prevent
 * abusing from userspace install_speciall_mapping, which may
 * not do accounting and rlimit right.
-* We could search vma near context.vdso, but it's a slowpath,
-* so let's explicitly check all VMAs to be completely sure.
+* It's a slowpath, let's explicitly check all VMAs to be
+* completely sure.
 */
for (vma = mm->mmap; vma; vma = vma->vm_next) {
if (vma_is_special_mapping(vma, _mapping) ||
diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index f87ed1d53938..fb84c0fcdc4e 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -256,7 +256,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
} else {
/* Return stub is in 32bit vsyscall page */
if (current_has_vdso_image_32())
-   restorer = current->mm->context.vdso +
+   restorer = current->mm->user_landing +
vdso_image_32.sym___kernel_sigreturn;
else
restorer = >retcode;
@@ -337,7 +337,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
if (ksig->ka.sa.sa_flags & SA_RESTORER)
restorer = ksig->ka.sa.sa_restorer;
else if (current_has_vdso_image_32())
-   restorer = current->mm->context.vdso +
+   restorer = current->mm->user_landing +
vdso_image_32.sym___kernel_rt_sigreturn;
else
restorer = >retcode;
diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
index 

[PATCH 10/19] sparc/vdso: Remove vdso pointer from mm->context

2020-11-07 Thread Dmitry Safonov
Not used any more.

Cc: "David S. Miller" 
Cc: sparcli...@vger.kernel.org
Signed-off-by: Dmitry Safonov 
---
 arch/sparc/include/asm/mmu_64.h | 1 -
 arch/sparc/vdso/vma.c   | 5 +
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/sparc/include/asm/mmu_64.h b/arch/sparc/include/asm/mmu_64.h
index 7e2704c770e9..8e7892890d14 100644
--- a/arch/sparc/include/asm/mmu_64.h
+++ b/arch/sparc/include/asm/mmu_64.h
@@ -111,7 +111,6 @@ typedef struct {
unsigned long   thp_pte_count;
struct tsb_config   tsb_block[MM_NUM_TSBS];
struct hv_tsb_descr tsb_descr[MM_NUM_TSBS];
-   void*vdso;
booladi;
tag_storage_desc_t  *tag_store;
spinlock_t  tag_lock;
diff --git a/arch/sparc/vdso/vma.c b/arch/sparc/vdso/vma.c
index bf9195fe9bcc..255e052223ca 100644
--- a/arch/sparc/vdso/vma.c
+++ b/arch/sparc/vdso/vma.c
@@ -389,7 +389,6 @@ static int map_vdso(const struct vdso_image *image,
}
 
text_start = addr - image->sym_vvar_start;
-   current->mm->context.vdso = (void __user *)text_start;
 
/*
 * MAYWRITE to allow gdb to COW and set breakpoints
@@ -418,9 +417,7 @@ static int map_vdso(const struct vdso_image *image,
}
 
 up_fail:
-   if (ret)
-   current->mm->context.vdso = NULL;
-   else
+   if (!ret)
*sysinfo_ehdr = text_start;
 
mmap_write_unlock(mm);
-- 
2.28.0



[PATCH 08/19] arm/vdso: Remove vdso pointer from mm->context

2020-11-07 Thread Dmitry Safonov
Not used any more.

Signed-off-by: Dmitry Safonov 
---
 arch/arm/include/asm/mmu.h |  3 ---
 arch/arm/kernel/vdso.c | 12 
 2 files changed, 15 deletions(-)

diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 1592a4264488..2397b0a19f59 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -12,9 +12,6 @@ typedef struct {
 #endif
unsigned intvmalloc_seq;
unsigned long   sigpage;
-#ifdef CONFIG_VDSO
-   unsigned long   vdso;
-#endif
 #ifdef CONFIG_BINFMT_ELF_FDPIC
unsigned long   exec_fdpic_loadmap;
unsigned long   interp_fdpic_loadmap;
diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index 710e5ca99a53..4b39c7d8f525 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -47,17 +47,8 @@ static const struct vm_special_mapping vdso_data_mapping = {
.pages = _data_page,
 };
 
-static int vdso_mremap(const struct vm_special_mapping *sm,
-   struct vm_area_struct *new_vma)
-{
-   current->mm->context.vdso = new_vma->vm_start;
-
-   return 0;
-}
-
 static struct vm_special_mapping vdso_text_mapping __ro_after_init = {
.name = "[vdso]",
-   .mremap = vdso_mremap,
 };
 
 struct elfinfo {
@@ -239,8 +230,6 @@ void arm_install_vdso(struct mm_struct *mm, unsigned long 
addr,
struct vm_area_struct *vma;
unsigned long len;
 
-   mm->context.vdso = 0;
-
if (vdso_text_pagelist == NULL)
return;
 
@@ -258,7 +247,6 @@ void arm_install_vdso(struct mm_struct *mm, unsigned long 
addr,
if (IS_ERR(vma))
return;
 
-   mm->context.vdso = addr;
*sysinfo_ehdr = addr;
 }
 
-- 
2.28.0



[PATCH 18/19] arm64/vdso: Migrate native signals to user_landing

2020-11-07 Thread Dmitry Safonov
Generic way to track the land vma area.
As a bonus, after unmapping vdso, kernel won't try to land on its
previous position.

Signed-off-by: Dmitry Safonov 
---
 arch/arm64/kernel/signal.c | 10 +++---
 arch/arm64/kernel/vdso.c   | 13 +++--
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index bec6ef69704f..4c1dfbc1aed3 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -723,9 +723,10 @@ static int get_sigframe(struct rt_sigframe_user_layout 
*user,
return 0;
 }
 
-static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
+static int setup_return(struct pt_regs *regs, struct k_sigaction *ka,
 struct rt_sigframe_user_layout *user, int usig)
 {
+   unsigned long land = (unsigned long)current->mm->user_landing;
__sigrestore_t sigtramp;
 
regs->regs[0] = usig;
@@ -754,10 +755,13 @@ static void setup_return(struct pt_regs *regs, struct 
k_sigaction *ka,
 
if (ka->sa.sa_flags & SA_RESTORER)
sigtramp = ka->sa.sa_restorer;
+   else if (land != UNMAPPED_USER_LANDING)
+   sigtramp = VDSO_SYMBOL(land, sigtramp);
else
-   sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp);
+   return 1;
 
regs->regs[30] = (unsigned long)sigtramp;
+   return 0;
 }
 
 static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
@@ -780,7 +784,7 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, 
sigset_t *set,
err |= __save_altstack(>uc.uc_stack, regs->sp);
err |= setup_sigframe(, regs, set);
if (err == 0) {
-   setup_return(regs, >ka, , usig);
+   err = setup_return(regs, >ka, , usig);
if (ksig->ka.sa.sa_flags & SA_SIGINFO) {
err |= copy_siginfo_to_user(>info, >info);
regs->regs[1] = (unsigned long)>info;
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 08e8f1d56d92..d710fcd7141c 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -78,12 +78,6 @@ static union {
 } vdso_data_store __page_aligned_data;
 struct vdso_data *vdso_data = vdso_data_store.data;
 
-static void vdso_mremap(const struct vm_special_mapping *sm,
-   struct vm_area_struct *new_vma)
-{
-   current->mm->context.vdso = (void *)new_vma->vm_start;
-}
-
 static int __vdso_init(enum vdso_abi abi)
 {
int i;
@@ -239,7 +233,6 @@ static int __setup_additional_pages(enum vdso_abi abi,
gp_flags = VM_ARM64_BTI;
 
vdso_base += VVAR_NR_PAGES * PAGE_SIZE;
-   mm->context.vdso = (void *)vdso_base;
ret = _install_special_mapping(mm, vdso_base, vdso_text_len,
   VM_READ|VM_EXEC|gp_flags|
   VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
@@ -247,12 +240,14 @@ static int __setup_additional_pages(enum vdso_abi abi,
if (IS_ERR(ret))
goto up_fail;
 
+   /* 32-bit ABI is to land on sigpage, 64-bit on vdso */
+   if (abi == VDSO_ABI_AA64)
+   mm->user_landing = (void __user *)vdso_base;
*sysinfo_ehdr = vdso_base;
 
return 0;
 
 up_fail:
-   mm->context.vdso = NULL;
return PTR_ERR(ret);
 }
 
@@ -285,7 +280,6 @@ static struct vm_special_mapping aarch32_vdso_maps[] = {
},
[AA32_MAP_VDSO] = {
.name = "[vdso]",
-   .mremap = vdso_mremap,
},
 };
 
@@ -431,7 +425,6 @@ static struct vm_special_mapping aarch64_vdso_maps[] 
__ro_after_init = {
},
[AA64_MAP_VDSO] = {
.name   = "[vdso]",
-   .mremap = vdso_mremap,
},
 };
 
-- 
2.28.0



[PATCH 13/19] x86/signal: Check if vdso_image_32 is mapped before trying to land on it

2020-11-07 Thread Dmitry Safonov
Provide current_has_vdso_image_32() helper and check it apriory landing
attempt on vdso vma.
The helper is a macro, not a static inline funciton to avoid
linux/sched/task_stack.h inclusion in asm/vdso.h.

Signed-off-by: Dmitry Safonov 
---
 arch/x86/entry/common.c | 7 ++-
 arch/x86/ia32/ia32_signal.c | 4 ++--
 arch/x86/include/asm/vdso.h | 4 
 arch/x86/kernel/signal.c| 4 ++--
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 870efeec8bda..1be1bdbe55d4 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -142,11 +142,16 @@ static noinstr bool __do_fast_syscall_32(struct pt_regs 
*regs)
 /* Returns 0 to return using IRET or 1 to return using SYSEXIT/SYSRETL. */
 __visible noinstr long do_fast_syscall_32(struct pt_regs *regs)
 {
+   unsigned long landing_pad;
+
+   if (!current_has_vdso_image_32())
+   force_sigsegv(SIGSEGV);
+
/*
 * Called using the internal vDSO SYSENTER/SYSCALL32 calling
 * convention.  Adjust regs so it looks like we entered using int80.
 */
-   unsigned long landing_pad = (unsigned long)current->mm->context.vdso +
+   landing_pad = (unsigned long)current->mm->context.vdso +
vdso_image_32.sym_int80_landing_pad;
 
/*
diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index ea3db15b57bf..f87ed1d53938 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -255,7 +255,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
restorer = ksig->ka.sa.sa_restorer;
} else {
/* Return stub is in 32bit vsyscall page */
-   if (current->mm->context.vdso)
+   if (current_has_vdso_image_32())
restorer = current->mm->context.vdso +
vdso_image_32.sym___kernel_sigreturn;
else
@@ -336,7 +336,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
 
if (ksig->ka.sa.sa_flags & SA_RESTORER)
restorer = ksig->ka.sa.sa_restorer;
-   else if (current->mm->context.vdso)
+   else if (current_has_vdso_image_32())
restorer = current->mm->context.vdso +
vdso_image_32.sym___kernel_rt_sigreturn;
else
diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index bbcdc7b8f963..a19e0a7bae2d 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -39,6 +39,10 @@ extern const struct vdso_image vdso_image_x32;
 
 #if defined CONFIG_X86_32 || defined CONFIG_COMPAT
 extern const struct vdso_image vdso_image_32;
+
+#define current_has_vdso_image_32()\
+   likely(current->mm->context.vdso_image == _image_32 && \
+   !!current->mm->context.vdso)
 #endif
 
 extern void __init init_vdso_image(const struct vdso_image *image);
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 372ec09dc4ac..6fed2e523e0a 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -319,7 +319,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
unsafe_put_user(set->sig[1], >extramask[0], Efault);
if (ksig->ka.sa.sa_flags & SA_RESTORER)
restorer = ksig->ka.sa.sa_restorer;
-   else if (current->mm->context.vdso)
+   else if (current_has_vdso_image_32())
restorer = current->mm->context.vdso +
vdso_image_32.sym___kernel_sigreturn;
else
@@ -381,7 +381,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
/* Set up to return from userspace.  */
if (ksig->ka.sa.sa_flags & SA_RESTORER)
restorer = ksig->ka.sa.sa_restorer;
-   else if (current->mm->context.vdso)
+   else if (current_has_vdso_image_32())
restorer = current->mm->context.vdso +
vdso_image_32.sym___kernel_rt_sigreturn;
else
-- 
2.28.0



[PATCH 02/19] elf: Move arch_setup_additional_pages() to generic elf.h

2020-11-07 Thread Dmitry Safonov
Ifdef the function in the header, not in the code.
Following kernel style, move it to Kconfig.
All it makes it easier to follow when the option is enabled/disabled.
Remove re-definition from compat_binfmt_elf, as it's always defined
under compat_arch_setup_additional_pages (to be reworked).

Signed-off-by: Dmitry Safonov 
---
 arch/arm/Kconfig|  1 +
 arch/arm/include/asm/elf.h  |  5 -
 arch/arm64/Kconfig  |  1 +
 arch/arm64/include/asm/elf.h|  6 +-
 arch/csky/Kconfig   |  1 +
 arch/csky/include/asm/elf.h |  4 
 arch/hexagon/Kconfig|  1 +
 arch/hexagon/include/asm/elf.h  |  6 --
 arch/mips/Kconfig   |  1 +
 arch/mips/include/asm/elf.h |  5 -
 arch/nds32/Kconfig  |  1 +
 arch/nds32/include/asm/elf.h|  3 ---
 arch/nios2/Kconfig  |  1 +
 arch/nios2/include/asm/elf.h|  4 
 arch/powerpc/Kconfig|  1 +
 arch/powerpc/include/asm/elf.h  |  5 -
 arch/riscv/Kconfig  |  1 +
 arch/riscv/include/asm/elf.h|  5 -
 arch/s390/Kconfig   |  1 +
 arch/s390/include/asm/elf.h |  5 -
 arch/sh/Kconfig |  1 +
 arch/sh/include/asm/elf.h   |  6 --
 arch/sparc/Kconfig  |  1 +
 arch/sparc/include/asm/elf_64.h |  6 --
 arch/x86/Kconfig|  1 +
 arch/x86/include/asm/elf.h  |  4 
 arch/x86/um/asm/elf.h   |  5 -
 fs/Kconfig.binfmt   |  3 +++
 fs/binfmt_elf.c |  2 --
 fs/binfmt_elf_fdpic.c   |  3 +--
 fs/compat_binfmt_elf.c  |  2 --
 include/linux/elf.h | 12 
 32 files changed, 30 insertions(+), 74 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fb700e471332..bece41f3b3b9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -15,6 +15,7 @@ config ARM
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
select ARCH_HAS_PHYS_TO_DMA
+   select ARCH_HAS_SETUP_ADDITIONAL_PAGES if MMU
select ARCH_HAS_SETUP_DMA_OPS
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 61941f369861..1f4b91a17a91 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -132,7 +132,6 @@ extern int arm_elf_read_implies_exec(int);
 extern void elf_set_personality(const struct elf32_hdr *);
 #define SET_PERSONALITY(ex)elf_set_personality(&(ex))
 
-#ifdef CONFIG_MMU
 #ifdef CONFIG_VDSO
 #define ARCH_DLINFO\
 do {   \
@@ -140,9 +139,5 @@ do {
\
(elf_addr_t)current->mm->context.vdso); \
 } while (0)
 #endif
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-struct linux_binprm;
-int arch_setup_additional_pages(struct linux_binprm *, int);
-#endif
 
 #endif
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index d1b81221c6a9..7111cf335ede 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -26,6 +26,7 @@ config ARM64
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
select ARCH_HAS_PTE_DEVMAP
select ARCH_HAS_PTE_SPECIAL
+   select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_SETUP_DMA_OPS
select ARCH_HAS_SET_DIRECT_MAP
select ARCH_HAS_SET_MEMORY
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 8d1c8dcb87fd..d1073ffa7f24 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -181,11 +181,6 @@ do {   
\
NEW_AUX_ENT(AT_IGNORE, 0);  \
 } while (0)
 
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
-  int uses_interp);
-
 /* 1GB of VA */
 #ifdef CONFIG_COMPAT
 #define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \
@@ -242,6 +237,7 @@ do {
\
 #else
 #define COMPAT_ARCH_DLINFO
 #endif
+struct linux_binprm;
 extern int aarch32_setup_additional_pages(struct linux_binprm *bprm,
  int uses_interp);
 #define compat_arch_setup_additional_pages \
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 8fec85ab5da6..00e7b063f6ca 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -4,6 +4,7 @@ config CSKY
select ARCH_32BIT_OFF_T
select ARCH_HAS_DMA_PREP_COHERENT
select ARCH_HAS_GCOV_PROFILE_ALL
+   select ARCH_HAS_SETUP_ADDITIONAL_PAGES
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select 

[PATCH 03/19] arm64: Use in_compat_task() in arch_setup_additional_pages()

2020-11-07 Thread Dmitry Safonov
Instead of providing compat_arch_setup_additional_pages(), check if the
task is compatible from personality, which is set earlier in
load_elf_binary(). That will align code with powerpc and sparc, also
it'll allow to completely remove compat_arch_setyp_addtional_pages()
macro after doing the same for x86, simiplifying the binfmt code
in the end.

Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Dmitry Safonov 
---
 arch/arm64/include/asm/elf.h |  5 -
 arch/arm64/kernel/vdso.c | 21 ++---
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index d1073ffa7f24..a81953bcc1cf 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -237,11 +237,6 @@ do {   
\
 #else
 #define COMPAT_ARCH_DLINFO
 #endif
-struct linux_binprm;
-extern int aarch32_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-#define compat_arch_setup_additional_pages \
-   aarch32_setup_additional_pages
 
 #endif /* CONFIG_COMPAT */
 
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index cee5d04ea9ad..1b710deb84d6 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -401,29 +401,24 @@ static int aarch32_sigreturn_setup(struct mm_struct *mm)
return PTR_ERR_OR_ZERO(ret);
 }
 
-int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+static int aarch32_setup_additional_pages(struct linux_binprm *bprm,
+ int uses_interp)
 {
struct mm_struct *mm = current->mm;
int ret;
 
-   if (mmap_write_lock_killable(mm))
-   return -EINTR;
-
ret = aarch32_kuser_helpers_setup(mm);
if (ret)
-   goto out;
+   return ret;
 
if (IS_ENABLED(CONFIG_COMPAT_VDSO)) {
ret = __setup_additional_pages(VDSO_ABI_AA32, mm, bprm,
   uses_interp);
if (ret)
-   goto out;
+   return ret;
}
 
-   ret = aarch32_sigreturn_setup(mm);
-out:
-   mmap_write_unlock(mm);
-   return ret;
+   return aarch32_sigreturn_setup(mm);
 }
 #endif /* CONFIG_COMPAT */
 
@@ -460,7 +455,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, 
int uses_interp)
if (mmap_write_lock_killable(mm))
return -EINTR;
 
-   ret = __setup_additional_pages(VDSO_ABI_AA64, mm, bprm, uses_interp);
+   if (is_compat_task())
+   ret = aarch32_setup_additional_pages(bprm, uses_interp);
+   else
+   ret = __setup_additional_pages(VDSO_ABI_AA64, mm, bprm, 
uses_interp);
+
mmap_write_unlock(mm);
 
return ret;
-- 
2.28.0



[PATCH 05/19] elf: Remove compat_arch_setup_additional_pages()

2020-11-07 Thread Dmitry Safonov
Now that all users rely on detecting bitness of new-born task checking
personality, remove compat_arch_setup_additional_pages() macro,
simplifying the code.

Signed-off-by: Dmitry Safonov 
---
 fs/compat_binfmt_elf.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
index 3606dd3a32f5..da8ee4d6e451 100644
--- a/fs/compat_binfmt_elf.c
+++ b/fs/compat_binfmt_elf.c
@@ -115,11 +115,6 @@
 #define START_THREAD   COMPAT_START_THREAD
 #endif
 
-#ifdef compat_arch_setup_additional_pages
-#undef arch_setup_additional_pages
-#definearch_setup_additional_pages compat_arch_setup_additional_pages
-#endif
-
 #ifdef compat_elf_read_implies_exec
 #undef elf_read_implies_exec
 #defineelf_read_implies_exec compat_elf_read_implies_exec
-- 
2.28.0



[PATCH 00/19] Add generic user_landing tracking

2020-11-07 Thread Dmitry Safonov
Started from discussion [1], where was noted that currently a couple of
architectures support mremap() for vdso/sigpage, but not munmap().
If an application maps something on the ex-place of vdso/sigpage,
later after processing signal it will land there (good luck!)

Patches set is based on linux-next (next-20201106) and it depends on
changes in x86/cleanups (those reclaim TIF_IA32/TIF_X32) and also
on my changes in akpm (fixing several mremap() issues).

Logically, the patches set divides on:
- patch   1: cleanup for patches in x86/cleanups
- patches  2-11: cleanups for arch_setup_additional_pages()
- patches 12-13: x86 signal changes for unmapped vdso
- patches 14-19: provide generic user_landing in mm_struct

In the end, besides cleanups, it's now more predictable what happens for
applications with unmapped vdso on architectures those support .mremap()
for vdso/sigpage.

I'm aware of only one user that unmaps vdso - Valgrind [2].
(there possibly are more, but this one is "special", it unmaps vdso, but
 not vvar, which confuses CRIU [Checkpoint Restore In Userspace], that's
 why I'm aware of it)

Patches as a .git branch:
https://github.com/0x7f454c46/linux/tree/setup_additional_pages

[1]: 
https://lore.kernel.org/linux-arch/cajwjo6zanqykshbq+3b+fi_vt80mtrzev5yreqawx-l8j8x...@mail.gmail.com/
[2]: https://github.com/checkpoint-restore/criu/issues/488

Cc: Alexander Viro 
Cc: Andrew Morton 
Cc: Andy Lutomirski 
Cc: Arnd Bergmann 
Cc: Borislav Petkov 
Cc: Catalin Marinas 
Cc: Christophe Leroy 
Cc: Guo Ren 
Cc: "H. Peter Anvin" 
Cc: Ingo Molnar 
Cc: Oleg Nesterov 
Cc: Russell King 
Cc: Thomas Bogendoerfer 
Cc: Thomas Gleixner 
Cc: Vincenzo Frascino 
Cc: Will Deacon 
Cc: x...@kernel.org

Dmitry Safonov (19):
  x86/elf: Check in_x32_syscall() in compat_arch_setup_additional_pages()
  elf: Move arch_setup_additional_pages() to generic elf.h
  arm64: Use in_compat_task() in arch_setup_additional_pages()
  x86: Remove compat_arch_setup_additional_pages()
  elf: Remove compat_arch_setup_additional_pages()
  elf/vdso: Reuse arch_setup_additional_pages() parameters
  elf: Use sysinfo_ehdr in ARCH_DLINFO()
  arm/vdso: Remove vdso pointer from mm->context
  s390/vdso: Remove vdso_base pointer from mm->context
  sparc/vdso: Remove vdso pointer from mm->context
  mm/mmap: Make vm_special_mapping::mremap return void
  x86/signal: Land on >retcode when vdso isn't mapped
  x86/signal: Check if vdso_image_32 is mapped before trying to land on it
  mm: Add user_landing in mm_struct
  x86/vdso: Migrate to user_landing
  arm/vdso: Migrate to user_landing
  arm64/vdso: Migrate compat signals to user_landing
  arm64/vdso: Migrate native signals to user_landing
  mips/vdso: Migrate to user_landing

 arch/alpha/include/asm/elf.h  |  2 +-
 arch/arm/Kconfig  |  2 +
 arch/arm/include/asm/elf.h| 10 +---
 arch/arm/include/asm/mmu.h|  3 -
 arch/arm/include/asm/vdso.h   |  6 +-
 arch/arm/kernel/process.c | 14 +
 arch/arm/kernel/signal.c  |  6 +-
 arch/arm/kernel/vdso.c| 20 ++-
 arch/arm64/Kconfig|  2 +
 arch/arm64/include/asm/elf.h  | 27 ++---
 arch/arm64/kernel/signal.c| 10 +++-
 arch/arm64/kernel/signal32.c  | 17 --
 arch/arm64/kernel/vdso.c  | 47 ++-
 arch/csky/Kconfig |  1 +
 arch/csky/include/asm/elf.h   |  4 --
 arch/csky/kernel/vdso.c   |  3 +-
 arch/hexagon/Kconfig  |  1 +
 arch/hexagon/include/asm/elf.h|  6 --
 arch/hexagon/kernel/vdso.c|  3 +-
 arch/ia64/include/asm/elf.h   |  2 +-
 arch/mips/Kconfig |  2 +
 arch/mips/include/asm/elf.h   | 10 +---
 arch/mips/kernel/signal.c | 11 ++--
 arch/mips/kernel/vdso.c   |  5 +-
 arch/mips/vdso/genvdso.c  |  9 ---
 arch/nds32/Kconfig|  1 +
 arch/nds32/include/asm/elf.h  |  8 +--
 arch/nds32/kernel/vdso.c  |  3 +-
 arch/nios2/Kconfig|  1 +
 arch/nios2/include/asm/elf.h  |  4 --
 arch/nios2/mm/init.c  |  2 +-
 arch/powerpc/Kconfig  |  1 +
 arch/powerpc/include/asm/elf.h|  9 +--
 arch/powerpc/kernel/vdso.c|  3 +-
 arch/riscv/Kconfig|  1 +
 arch/riscv/include/asm/elf.h  | 10 +---
 arch/riscv/kernel/vdso.c  |  9 +--
 arch/s390/Kconfig |  1 +
 arch/s390/include/asm/elf.h   | 10 +---
 arch/s390/include/asm/mmu.h   |  1 -
 arch/s390/kernel/vdso.c   | 13 +---
 arch/sh/Kconfig   |  1 +
 arch/sh/include/asm/elf.h | 16 ++---
 arch/sh/kernel/vsyscall/vsyscall.c  

[PATCH 04/19] x86: Remove compat_arch_setup_additional_pages()

2020-11-07 Thread Dmitry Safonov
The same as for x32 task, detect ia32 task by in_ia32_syscall().
It's valid as new-execed task is pretending to be in a syscall of
relevant bitness/ABI, see the comment near in_32bit_syscall().

Removing compat_arch_setup_additional_pages() provides single point of
entry - arch_setup_additional_pages(), makes ifdeffery easier to read,
aligns the code with powerpc and sparc (mips also has single vdso setup
function, but instead of taking bitness from mm.context, takes vdso
image pointer there).
Together with arm64 code align to use in_compat_task(), it makes
possible to remove compat_arch_setup_additional_pages() macro
re-definition from compat elf code (another redefined marco less).

Cc: x...@kernel.org
Signed-off-by: Dmitry Safonov 
---
 arch/x86/entry/vdso/vma.c  | 41 +++---
 arch/x86/include/asm/elf.h |  5 -
 2 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 4eea508e9b10..aace862ed9a1 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -376,48 +376,49 @@ int map_vdso_once(const struct vdso_image *image, 
unsigned long addr)
 }
 
 #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
-static int load_vdso32(void)
+static int load_vdso_ia32(void)
 {
if (vdso32_enabled != 1)  /* Other values all mean "disabled" */
return 0;
 
return map_vdso(_image_32, 0);
 }
+#else
+static int load_vdso_ia32(void)
+{
+   WARN_ON_ONCE(1);
+   return -ENODATA;
+}
 #endif
 
 #ifdef CONFIG_X86_64
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+static int load_vdso_64(void)
 {
if (!vdso64_enabled)
return 0;
 
-   return map_vdso_randomized(_image_64);
-}
-
-#ifdef CONFIG_COMPAT
-int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
-  int uses_interp)
-{
 #ifdef CONFIG_X86_X32_ABI
-   if (in_x32_syscall()) {
-   if (!vdso64_enabled)
-   return 0;
+   if (in_x32_syscall())
return map_vdso_randomized(_image_x32);
-   }
 #endif
-#ifdef CONFIG_IA32_EMULATION
-   return load_vdso32();
+
+   return map_vdso_randomized(_image_64);
+}
 #else
-   return 0;
-#endif
+static int load_vdso_64(void)
+{
+   WARN_ON_ONCE(1);
+   return -ENODATA;
 }
 #endif
-#else
+
 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
 {
-   return load_vdso32();
+   if (in_ia32_syscall())
+   return load_vdso_ia32();
+
+   return load_vdso_64();
 }
-#endif
 
 #ifdef CONFIG_X86_64
 static __init int vdso_setup(char *s)
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index d00b723eea2d..51a08f6b18e5 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -377,11 +377,6 @@ else   
\
((unsigned long)current->mm->context.vdso + \
 vdso_image_32.sym___kernel_vsyscall)
 
-struct linux_binprm;
-extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-#define compat_arch_setup_additional_pages compat_arch_setup_additional_pages
-
 /* Do not change the values. See get_align_mask() */
 enum align_flags {
ALIGN_VA_32 = BIT(0),
-- 
2.28.0



[PATCH 01/19] x86/elf: Check in_x32_syscall() in compat_arch_setup_additional_pages()

2020-11-07 Thread Dmitry Safonov
Partly revert commit 3316ec8ccd34 ("x86/elf: Use e_machine to check for
x32/ia32 in setup_additional_pages()") and commit 9a29a671902c ("elf:
Expose ELF header on arch_setup_additional_pages()".
Both patches did a good thing: removed usage of TIF_X32, but with
a price of additional macros ARCH_SETUP_ADDITIONAL_PAGES() and ifdeffs.

Instead, use in_x32_syscall() - the first thing load_elf_binary() does
after parsing and checking new ELF binary. It's done that early which
also allows to use it in mmap() code straight away, which needs it
to know which mmap_base to use (see arch_pick_mmap_layout()).
Add comments that describe how it works.

Cc: x...@kernel.org
Signed-off-by: Dmitry Safonov 
---
 arch/x86/entry/vdso/vma.c |  4 ++--
 arch/x86/include/asm/compat.h |  6 ++
 arch/x86/include/asm/elf.h|  6 ++
 fs/binfmt_elf.c   | 10 +++---
 fs/compat_binfmt_elf.c| 11 +++
 include/linux/elf.h   |  5 -
 6 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 44de75b21fab..4eea508e9b10 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -396,10 +396,10 @@ int arch_setup_additional_pages(struct linux_binprm 
*bprm, int uses_interp)
 
 #ifdef CONFIG_COMPAT
 int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
-  int uses_interp, bool x32)
+  int uses_interp)
 {
 #ifdef CONFIG_X86_X32_ABI
-   if (x32) {
+   if (in_x32_syscall()) {
if (!vdso64_enabled)
return 0;
return map_vdso_randomized(_image_x32);
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index f145e3326c6d..4489bd60640b 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -197,6 +197,12 @@ static inline bool in_x32_syscall(void)
return false;
 }
 
+/*
+ * Valid all time on the context of process that performs a syscall.
+ * Just born process has __X32_SYSCALL_BIT or TS_COMPAT set very
+ * early in load_binary() on setting personality and flags.
+ * See also set_personality_ia32().
+ */
 static inline bool in_32bit_syscall(void)
 {
return in_ia32_syscall() || in_x32_syscall();
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 44a9b9940535..109697a19eb1 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -383,10 +383,8 @@ struct linux_binprm;
 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
   int uses_interp);
 extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp, bool x32);
-#define COMPAT_ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter)  \
-   compat_arch_setup_additional_pages(bprm, interpreter,   \
-  (ex->e_machine == EM_X86_64))
+ int uses_interp);
+#define compat_arch_setup_additional_pages compat_arch_setup_additional_pages
 
 /* Do not change the values. See get_align_mask() */
 enum align_flags {
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index ac0b5fc30ea6..3de72c0e0406 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -999,8 +999,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
if (retval)
goto out_free_dentry;
 
-   /* Do this immediately, since STACK_TOP as used in setup_arg_pages
-  may depend on the personality.  */
+   /*
+* Do this immediately, since STACK_TOP as used in setup_arg_pages
+* may depend on the personality. At this moment we start
+* pretending that we are in a context of compat syscall for
+* compatible applications on x86, in_compat_syscall() starts working.
+*/
SET_PERSONALITY2(*elf_ex, _state);
if (elf_read_implies_exec(*elf_ex, executable_stack))
current->personality |= READ_IMPLIES_EXEC;
@@ -1246,7 +1250,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
set_binfmt(_format);
 
 #ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES
-   retval = ARCH_SETUP_ADDITIONAL_PAGES(bprm, elf_ex, !!interpreter);
+   retval = arch_setup_additional_pages(bprm, !!interpreter);
if (retval < 0)
goto out;
 #endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */
diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
index 2c557229696a..12b991368f0a 100644
--- a/fs/compat_binfmt_elf.c
+++ b/fs/compat_binfmt_elf.c
@@ -115,16 +115,11 @@
 #define START_THREAD   COMPAT_START_THREAD
 #endif
 
-#ifdef compat_arch_setup_additional_pages
-#define COMPAT_ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \
-   compat_arch_setup_additional_pages(bprm, interpreter)
-#endif
-
-#ifdef COMPAT_ARCH_SETUP_ADDITIONAL_PAGES
+#ifdef 

Re: [PATCH 1/2] tomoyo: Convert get_user_pages*() to pin_user_pages*()

2020-11-07 Thread John Hubbard

On 11/7/20 8:12 PM, Tetsuo Handa wrote:

On 2020/11/08 11:17, John Hubbard wrote:

Excuse me, but Documentation/core-api/pin_user_pages.rst says
"CASE 5: Pinning in order to _write_ to the data within the page"
while tomoyo_dump_page() is for "_read_ the data within the page".
Do we want to convert to pin_user_pages_remote() or lock_page() ?



Sorry, I missed the direction here, was too focused on the Case 5
aspect. Yes. Case 5 (which, again, I think we're about to re-document)
is only about *writing* to data within the page.

So in this case, where it is just reading from the page, I think it's
already from a gup vs pup point of view.

btw, it's not clear to me whether the current code is susceptible to any
sort of problem involving something writing to the page while it
is being dumped (I am curious). But changing from gup to pup wouldn't
fix that, if it were a problem. It a separate question from this patch.


The "struct page" tomoyo_dump_page() accesses is argv/envp arguments passed
to execve() syscall. Therefore, these pages are not visible from threads
except current thread, and thus there is no possibility that these pages
are modified by other threads while current thread is reading.



Perfect. So since I accidentally left out the word "correct" above (I meant
to write, "it's already correct"), let me be extra clear: Souptick, we
should just drop this patch.

thanks,
--
John Hubbard
NVIDIA


Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread John Hubbard

On 11/7/20 8:11 PM, Randy Dunlap wrote:
...

Look at kconfig-language.rst instead.


aha, yes.



One thing that could be done (and is done in a few places for other reasons) is 
to add
a Kconfig comment if DEBUG_FS is not enabled:

comment "GUP_TEST needs to have DEBUG_FS enabled"
depends on !GUP_TEST && !DEBUG_FS



Sweet--I just applied that here, and it does exactly what I wanted: puts a nice 
clear
message on the "make menuconfig" screen. No more hidden item. Brilliant!

Let's go with that, shall we?

thanks,
--
John Hubbard
NVIDIA


Re: [PATCH] mm/zsmalloc: include sparsemem.h for MAX_PHYSMEM_BITS

2020-11-07 Thread Florian Fainelli



On 11/7/2020 5:16 PM, Stefan Agner wrote:
> On 2020-11-08 01:56, Andrew Morton wrote:
>> On Sat,  7 Nov 2020 16:22:06 +0100 Stefan Agner  wrote:
>>
>>> Most architectures define MAX_PHYSMEM_BITS in asm/sparsemem.h and don't
>>> include it in asm/pgtable.h. Include asm/sparsemem.h directly to get
>>> the MAX_PHYSMEM_BITS define on all architectures.
>>>
>>> This fixes a crash when accessing zram on 32-bit ARM platform with LPAE and
>>> more than 4GB of memory:
>>>   Unable to handle kernel NULL pointer dereference at virtual address 
>>> 
>>
>> Mysterious.  Presumably without this include, some compilation unit is
>> picking up the wrong value of MAX_PHYSMEM_BITS?  But I couldn't
>> actually see where/how this occurs.  Can you please explain further?
> 
> Not sure if I got that right, but from what I understand if
> MAX_PHYSMEM_BITS is not set in mm/zsmalloc.c it will set
> MAX_PHYSMEM_BITS to BITS_PER_LONG. And this is 32-bit, too short when
> LPAE is in use...

You should probably include this in your commit message since that is
describing the bug and then your fix makes complete sense.
-- 
Florian


Re: [PATCH 0/8] simplify ep_poll

2020-11-07 Thread Soheil Hassas Yeganeh
On Sat, Nov 7, 2020 at 8:43 PM Andrew Morton  wrote:
>
> On Fri,  6 Nov 2020 18:16:27 -0500 Soheil Hassas Yeganeh 
>  wrote:
>
> > From: Soheil Hassas Yeganeh 
> >
> > This patch series is a follow up based on the suggestions and feedback by 
> > Linus:
> > https://lkml.kernel.org/r/CAHk-=wizk=oxuyqpbo8ms41w2pag1kniuv5wdd5qwl-gq1k...@mail.gmail.com
>
> Al Viro has been playing in here as well - see the below, from
> linux-next.
>
> I think I'll leave it to you folks to sort this out, please.

Thank you Andrew for pointing that out!  Sorry that I didn't notice Al
Viro's nice clean ups.

The changes are all orthogonal and apply cleanly except "epoll: pull
fatal signal checks into ep_send_events()".   The conflict is trivial
and the following patch should cleanly apply to linux-next/master (I
didn't move the initialization of `res = 0` after the new branch to
keep it simple).

FWIW, I also stress-tested the patch series applied on top of
linux-next/master for a couple of hours.

Could you please let me know whether I should send a V2 of the patch
series for linux-next? Thanks!

Subject: [PATCH linux-next] epoll: pull fatal signal checks into
ep_send_events()

To simplify the code, pull in checking the fatal signals into
ep_send_events().  ep_send_events() is called only from ep_poll().

Note that, previously, we were always checking fatal events, but
it is checked only if eavail is true.  This should be fine because
the goal of that check is to quickly return from epoll_wait() when
there is a pending fatal signal.

Suggested-by: Willem de Bruijn 
Signed-off-by: Soheil Hassas Yeganeh 
Reviewed-by: Eric Dumazet 
Reviewed-by: Willem de Bruijn 
Reviewed-by: Khazhismel Kumykov 
Change-Id: I68bbaf02db564e64815bcd8ed3c1cd272cfe832f
---
 fs/eventpoll.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 06fb0de4bcc7..42f6bfc5f24e 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1625,6 +1625,14 @@ static int ep_send_events(struct eventpoll *ep,
poll_table pt;
int res = 0;

+   /*
+* Always short-circuit for fatal signals to allow threads to make a
+* timely exit without the chance of finding more events available and
+* fetching repeatedly.
+*/
+   if (fatal_signal_pending(current))
+   return -EINTR;
+
init_poll_funcptr(, NULL);

mutex_lock(>mtx);
@@ -1846,15 +1854,6 @@ static int ep_poll(struct eventpoll *ep, struct
epoll_event __user *events,
}

 send_events:
-   if (fatal_signal_pending(current)) {
-   /*
-* Always short-circuit for fatal signals to allow
-* threads to make a timely exit without the chance of
-* finding more events available and fetching
-* repeatedly.
-*/
-   return -EINTR;
-   }
/*
 * Try to transfer events to user space. In case we get 0 events and
 * there's still timeout left over, we go trying again in search of

--
2.29.2.222.g5d2a92d10f8-goog




> commit 57804b1cc4616780c72a2d0930d1bd0d5bd3ed4c
> Author: Al Viro 
> AuthorDate: Mon Aug 31 13:41:30 2020 -0400
> Commit: Al Viro 
> CommitDate: Sun Oct 25 20:02:01 2020 -0400
>
> lift locking/unlocking ep->mtx out of ep_{start,done}_scan()
>
> get rid of depth/ep_locked arguments there and document
> the kludge in ep_item_poll() that has lead to ep_locked existence in
> the first place
>
> Signed-off-by: Al Viro 
>
> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> index ac996b959e94..f9c567af1f5f 100644
> --- a/fs/eventpoll.c
> +++ b/fs/eventpoll.c
> @@ -554,20 +554,13 @@ static inline void ep_pm_stay_awake_rcu(struct epitem 
> *epi)
> rcu_read_unlock();
>  }
>
> -static void ep_start_scan(struct eventpoll *ep,
> - int depth, bool ep_locked,
> - struct list_head *txlist)
> -{
> -   lockdep_assert_irqs_enabled();
> -
> -   /*
> -* We need to lock this because we could be hit by
> -* eventpoll_release_file() and epoll_ctl().
> -*/
> -
> -   if (!ep_locked)
> -   mutex_lock_nested(>mtx, depth);
>
> +/*
> + * ep->mutex needs to be held because we could be hit by
> + * eventpoll_release_file() and epoll_ctl().
> + */
> +static void ep_start_scan(struct eventpoll *ep, struct list_head *txlist)
> +{
> /*
>  * Steal the ready list, and re-init the original one to the
>  * empty list. Also, set ep->ovflist to NULL so that events
> @@ -576,6 +569,7 @@ static void ep_start_scan(struct eventpoll *ep,
>  * because we want the "sproc" callback to be able to do it
>  * in a lockless way.
>  */
> +   lockdep_assert_irqs_enabled();
> write_lock_irq(>lock);
> list_splice_init(>rdllist, txlist);
> WRITE_ONCE(ep->ovflist, NULL);
> @@ -583,7 +577,6 @@ static void 

RE: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread Song Bao Hua (Barry Song)


> -Original Message-
> From: Randy Dunlap [mailto:rdun...@infradead.org]
> Sent: Sunday, November 8, 2020 5:12 PM
> To: John Hubbard ; Song Bao Hua (Barry Song)
> ; a...@linux-foundation.org;
> linux...@kvack.org; linux-kernel@vger.kernel.org
> Cc: Linuxarm ; Ralph Campbell
> ; John Garry 
> Subject: Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on
> DEBUG_FS
> 
> On 11/7/20 7:22 PM, John Hubbard wrote:
> > On 11/7/20 7:14 PM, John Hubbard wrote:
> >> On 11/7/20 6:58 PM, Song Bao Hua (Barry Song) wrote:
>  On 11/7/20 2:20 PM, Randy Dunlap wrote:
> > On 11/7/20 11:16 AM, John Hubbard wrote:
> >> On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:
>  From: John Hubbard [mailto:jhubb...@nvidia.com]
> >> ...
>  But if you really disagree, then I'd go with, just drop the patch 
>  entirely,
> because
>  it doesn't really make things better as written...IMHO anyway. :)
> >>>
> >>> Just imagine a case, we don't enable DEBUG_FS but we enable GUP_TEST,
> we will
> >>> get an image with totally useless code section since GUP_TEST depends on
> debugfs
> >>> entry to perform any useful functionality.
> >>>
> >>
> >> Looking at the choices, from the user's (usually kernel developer's)
> experience:
> >>
> >> a) The user enables GUP_TEST, then boots up, runs, and is briefly surprised
> by a
> >> runtime failure. But it's a very quick diagnosis: "open: No such file or
> directory",
> >> when trying to make that ioctl call. The path indicates that it's a debug 
> >> fs
> path,
> >> so the solution is pretty clear, at least for the main audience.
> >>
> >> b) The other choice: the user *never even sees* GUP_TEST as a choice. This
> especially
> >> bothers me because sometimes you find things by poking around in the
> menu, although
> >> of course "you should already know about it"...but there's a lot to 
> >> "already
> know"
> >> in a large kernel.
> >>
> >>  From a user experience, it's way better to simply see what you want, and
> select it
> >> in the menu. Or, at least get some prompt that you need to pre-select
> something else.
> >>
> >
> > ...and again, this is all fallout from Kconfig. I might be missing some 
> > advanced
> > feature, because it seems surprising to only be allowed to choose between
> > missing dependencies (which this patch would correct), or a poorer user
> experience
> > (which I argue that this patch would also provide).
> >
> > Ideally, we'd just set up the dependencies, and then have some options for
> > visibility, but I'm not aware of any way to do that...and after a quick peek
> > at Documentation/kbuild/kconfig-macro-language.rst it looks pretty bare
> bones.
> 
> Look at kconfig-language.rst instead.
> 
> One thing that could be done (and is done in a few places for other reasons) 
> is
> to add
> a Kconfig comment if DEBUG_FS is not enabled:
> 
> comment "GUP_TEST needs to have DEBUG_FS enabled"
>   depends on !GUP_TEST && !DEBUG_FS
> 
> e.g. drivers/hid/usbhid/Kconfig:
> 
> comment "Input core support is needed for USB HID input layer or HIDBP
> support"
>   depends on USB_HID && INPUT=n


This is interesting.
Thanks for sharing this. I've never realized we can do this kind of comments.
What I have been always doing is simply reading the status from menuconfig.
For example, to use IIO_CONSUMERS_PER_TRIGGER, I search it in menuconfig
by "/", I get:

Symbol: IIO_CONSUMERS_PER_TRIGGER [=]
  │ Type  : integer
  │ Defined at drivers/iio/Kconfig:41
  │   Prompt: Maximum number of consumers per trigger
  │   Depends on: IIO [=n] && IIO_TRIGGER [=n]
  │   Location:
  │ -> Device Drivers
  │ (1)   -> Industrial I/O support (IIO [=n])
  │ -> Enable triggered sampling support (IIO_TRIGGER [=n])
  │

The menuconfig tells me it depends on IIO and IIO_TRIGGER. But both of
them are "n". so the next step, I am going to make IIO and IIO_TRIGGER
"y".


> 
> 
> --
> ~Randy

Thanks
Barry



[PATCH 1/4] x86/cpufeatures: Enumerate #DB for bus lock detection

2020-11-07 Thread Fenghua Yu
A bus lock is acquired either through split locked access to
writeback (WB) memory or by using locks to uncacheable (UC) memory
(e.g. direct device assignment). This is typically >1000 cycles slower
than an atomic operation within a cache line. It also disrupts performance
on other cores.

Some CPUs have ability to notify the kernel by an #DB trap after a user
instruction acquires a bus lock and is executed. This allows the kernel
to enforce user application throttling or mitigations.

The CPU feature flag to be shown in /proc/cpuinfo will be "bus_lock_detect".

Signed-off-by: Fenghua Yu 
Reviewed-by: Tony Luck 
---
 arch/x86/include/asm/cpufeatures.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/cpufeatures.h 
b/arch/x86/include/asm/cpufeatures.h
index dad350d42ecf..f375d9cb8123 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -352,6 +352,7 @@
 #define X86_FEATURE_AVX512_VPOPCNTDQ   (16*32+14) /* POPCNT for vectors of 
DW/QW */
 #define X86_FEATURE_LA57   (16*32+16) /* 5-level page tables */
 #define X86_FEATURE_RDPID  (16*32+22) /* RDPID instruction */
+#define X86_FEATURE_BUS_LOCK_DETECT(16*32+24) /* Bus Lock detect */
 #define X86_FEATURE_CLDEMOTE   (16*32+25) /* CLDEMOTE instruction */
 #define X86_FEATURE_MOVDIRI(16*32+27) /* MOVDIRI instruction */
 #define X86_FEATURE_MOVDIR64B  (16*32+28) /* MOVDIR64B instruction */
-- 
2.29.2



[PATCH 3/4] x86/bus_lock: Set rate limit for bus lock

2020-11-07 Thread Fenghua Yu
To enforce user application throttling or mitigations, extend the
existing split lock detect kernel parameter:
split_lock_detect=ratelimit:N

It limits bus lock rate to N per second for non-root users.

Signed-off-by: Fenghua Yu 
Reviewed-by: Tony Luck 
---
 arch/x86/kernel/cpu/intel.c | 37 -
 include/linux/sched/user.h  |  4 +++-
 kernel/user.c   |  7 +++
 3 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 4c8a22c36798..9d33fc9295ea 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -10,6 +10,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -40,6 +43,7 @@ enum split_lock_detect_state {
sld_off = 0,
sld_warn,
sld_fatal,
+   sld_ratelimit,
 };
 
 /*
@@ -998,13 +1002,25 @@ static const struct {
{ "off",sld_off   },
{ "warn",   sld_warn  },
{ "fatal",  sld_fatal },
+   { "ratelimit:", sld_ratelimit },
 };
 
 static inline bool match_option(const char *arg, int arglen, const char *opt)
 {
-   int len = strlen(opt);
 
-   return len == arglen && !strncmp(arg, opt, len);
+   int len = strlen(opt), ratelimit;
+
+   if (strncmp(arg, opt, len))
+   return false;
+
+   if (sscanf(arg, "ratelimit:%d", ) == 1 && ratelimit > 0 &&
+   ratelimit_bl <= HZ / 2) {
+   ratelimit_bl = ratelimit;
+
+   return true;
+   }
+
+   return len == arglen;
 }
 
 static bool split_lock_verify_msr(bool on)
@@ -1085,10 +1101,10 @@ static void sld_update_msr(bool on)
 static void split_lock_init(void)
 {
/*
-* If supported, #DB for bus lock will handle warn
+* If supported, #DB for bus lock will handle warn or ratelimit
 * and #AC for split lock is disabled.
 */
-   if (bld && sld_state == sld_warn) {
+   if ((bld && sld_state == sld_warn) || sld_state == sld_ratelimit) {
split_lock_verify_msr(false);
return;
}
@@ -1149,7 +1165,8 @@ static void bus_lock_init(void)
 
 bool handle_user_split_lock(struct pt_regs *regs, long error_code)
 {
-   if ((regs->flags & X86_EFLAGS_AC) || !sld || sld_state == sld_fatal)
+   if ((regs->flags & X86_EFLAGS_AC) || !sld || sld_state == sld_fatal ||
+   sld_state == sld_ratelimit)
return false;
split_lock_warn(regs->ip);
return true;
@@ -1162,6 +1179,11 @@ void handle_bus_lock(struct pt_regs *regs)
 
pr_warn_ratelimited("#DB: %s/%d took a bus_lock trap at address: 
0x%lx\n",
current->comm, current->pid, regs->ip);
+
+   if (sld_state == sld_ratelimit) {
+   while (!__ratelimit(_current_user()->ratelimit_bl))
+   msleep(1000 / ratelimit_bl);
+   }
 }
 
 /*
@@ -1256,6 +1278,11 @@ static void sld_state_show(void)
else
pr_info("#DB: sending SIGBUS on user-space 
bus_locks\n");
break;
+
+   case sld_ratelimit:
+   if (bld)
+   pr_info("#DB: setting rate limit to %d/sec per user on 
non-root user-space bus_locks\n", ratelimit_bl);
+   break;
}
 }
 
diff --git a/include/linux/sched/user.h b/include/linux/sched/user.h
index a8ec3b6093fc..79f95002a123 100644
--- a/include/linux/sched/user.h
+++ b/include/linux/sched/user.h
@@ -40,8 +40,9 @@ struct user_struct {
atomic_t nr_watches;/* The number of watches this user currently 
has */
 #endif
 
-   /* Miscellaneous per-user rate limit */
+   /* Miscellaneous per-user rate limits */
struct ratelimit_state ratelimit;
+   struct ratelimit_state ratelimit_bl;
 };
 
 extern int uids_sysfs_init(void);
@@ -51,6 +52,7 @@ extern struct user_struct *find_user(kuid_t);
 extern struct user_struct root_user;
 #define INIT_USER (_user)
 
+extern int ratelimit_bl;
 
 /* per-UID process charging. */
 extern struct user_struct * alloc_uid(kuid_t);
diff --git a/kernel/user.c b/kernel/user.c
index b1635d94a1f2..8fc19706bc91 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -103,6 +103,7 @@ struct user_struct root_user = {
.locked_shm = 0,
.uid= GLOBAL_ROOT_UID,
.ratelimit  = RATELIMIT_STATE_INIT(root_user.ratelimit, 0, 0),
+   .ratelimit_bl   = RATELIMIT_STATE_INIT(root_user.ratelimit_bl, 0, 0),
 };
 
 /*
@@ -172,6 +173,9 @@ void free_uid(struct user_struct *up)
free_user(up, flags);
 }
 
+/* Architectures (e.g. X86) may set this for rate-limited bus locks. */
+int ratelimit_bl;
+
 struct user_struct *alloc_uid(kuid_t uid)
 {
struct hlist_head *hashent = uidhashentry(uid);
@@ -190,6 +194,9 @@ struct user_struct *alloc_uid(kuid_t uid)
refcount_set(>__count, 1);

[PATCH 0/4] x86/bus_lock: Enable bus lock detection

2020-11-07 Thread Fenghua Yu
A bus lock [1] is acquired either through split locked access to
writeback (WB) memory or by using locks to uncacheable (UC) memory
(e.g. direct device assignment). This is typically >1000 cycles slower
than an atomic operation within a cache line. It also disrupts performance
on other cores.

Although split lock can be detected by #AC trap, the trap is triggered
before the instruction acquires bus lock. This makes it difficult to
mitigate bus lock (e.g. throttle the user application).

Some CPUs have ability to notify the kernel by an #DB trap after a user
instruction acquires a bus lock and is executed. This allows the kernel
to enforce user application throttling or mitigations.

#DB for bus lock detect fixes issues in #AC for split lock detect:
1) It's architectural ... just need to look at one CPUID bit to know it
   exists
2) The IA32_DEBUGCTL MSR, which reports bus lock in #DB, is per-thread.
   So each process or guest can have different behavior.
3) It has support for VMM/guests (new VMEXIT codes, etc).

Hardware only generates #DB for bus lock detect when CPL>0 to avoid
nested #DB from multiple bus locks while the first #DB is being handled.

Use the existing kernel command line option "split_lock_detect=" to handle
#DB for bus lock:

split_lock_detect=
#AC for split lock  #DB for bus lock

off Do nothing  Do nothing

warnKernel OOPs Warn once per task and
Warn once per task and  and continues to run.
disable future checking When both features are
supported, warn in #DB

fatal   Kernel OOPs Send SIGBUS to user
Send SIGBUS to user
When both features are
supported, fatal in #AC.

ratelimit:N Do nothing  Limit bus lock rate to
N per second in the
current non-root user.

Default split_lock_detect is "warn".

[1] Intel Instruction Set Extension Chapter 8: 
https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf

Change Log:
- Check bus lock bit by its positive polarity (Xiaoyao).
- Fix a few wording issues in the documentation (Randy).
[RFC v3 can be found at: https://lore.kernel.org/patchwork/cover/1329943/]

RFC v3:
- Remove DR6_RESERVED change (PeterZ).
- Simplify the documentation (Randy).

RFC v2:
- Architecture changed based on feedback from Thomas and PeterZ. #DB is
  no longer generated for bus lock in ring0.
- Split the one single patch into four patches.
[RFC v1 can be found at: 
https://lore.kernel.org/lkml/1595021700-68460-1-git-send-email-fenghua...@intel.com/]

Fenghua Yu (4):
  x86/cpufeatures: Enumerate #DB for bus lock detection
  x86/bus_lock: Handle warn and fatal in #DB for bus lock
  x86/bus_lock: Set rate limit for bus lock
  Documentation/admin-guide: Change doc for split_lock_detect parameter

 .../admin-guide/kernel-parameters.txt |  30 +++-
 arch/x86/include/asm/cpu.h|   9 +-
 arch/x86/include/asm/cpufeatures.h|   1 +
 arch/x86/include/asm/msr-index.h  |   1 +
 arch/x86/include/uapi/asm/debugreg.h  |   1 +
 arch/x86/kernel/cpu/common.c  |   2 +-
 arch/x86/kernel/cpu/intel.c   | 152 +++---
 arch/x86/kernel/traps.c   |   7 +
 include/linux/sched/user.h|   4 +-
 kernel/user.c |   7 +
 10 files changed, 182 insertions(+), 32 deletions(-)

-- 
2.29.2



[PATCH 4/4] Documentation/admin-guide: Change doc for split_lock_detect parameter

2020-11-07 Thread Fenghua Yu
Since #DB for bus lock detect changes the split_lock_detect parameter,
update the documentation for the changes.

Signed-off-by: Fenghua Yu 
Reviewed-by: Tony Luck 
---
Change Log:
- Fix a few wording issues (Randy).

RFC v2:
- Simplify the documentation (Randy).

 .../admin-guide/kernel-parameters.txt | 30 +++
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 526d65d8573a..215e119f6ca7 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5044,27 +5044,45 @@
spia_peddr=
 
split_lock_detect=
-   [X86] Enable split lock detection
+   [X86] Enable split lock detection or bus lock detection
 
When enabled (and if hardware support is present), 
atomic
instructions that access data across cache line
-   boundaries will result in an alignment check exception.
+   boundaries will result in an alignment check exception
+   for split lock detection or a debug exception for
+   bus lock detection.
 
off - not enabled
 
-   warn- the kernel will emit rate limited warnings
+   warn- the kernel will emit rate-limited warnings
  about applications triggering the #AC
- exception. This mode is the default on CPUs
- that supports split lock detection.
+ exception or the #DB exception. This mode is
+ the default on CPUs that support split lock
+ detection or bus lock detection. Default
+ behavior is by #DB if both features are
+ enabled in hardware.
 
fatal   - the kernel will send SIGBUS to applications
- that trigger the #AC exception.
+ that trigger the #AC exception or the #DB
+ exception. Default behavior is by #AC
+ if both features are enabled in hardware.
+
+   ratelimit:N -
+ Set rate limit to N bus locks per second
+ for bus lock detection. 0 < N <= HZ/2 and
+ N is approximate. Only applied to non-root
+ users.
+
+ N/A for split lock detection.
 
If an #AC exception is hit in the kernel or in
firmware (i.e. not while executing in user mode)
the kernel will oops in either "warn" or "fatal"
mode.
 
+   #DB exception for bus lock is triggered only when
+   CPL > 0.
+
srbds=  [X86,INTEL]
Control the Special Register Buffer Data Sampling
(SRBDS) mitigation.
-- 
2.29.2



[PATCH 2/4] x86/bus_lock: Handle warn and fatal in #DB for bus lock

2020-11-07 Thread Fenghua Yu
#DB for bus lock is enabled by bus lock detection bit 2 in DEBUGCTL MSR
while #AC for split lock is enabled by split lock detection bit 29 in
TEST_CTRL MSR.

Delivery of #DB for bus lock in userspace clears DR6[11]. To avoid
confusion in identifying #DB, #DB handler sets the bit to 1 before
returning to the interrupted task.

Use the existing kernel command line option "split_lock_detect=" to handle
#DB for bus lock:

split_lock_detect=
#AC for split lock  #DB for bus lock

off Do nothing  Do nothing

warnKernel OOPs Warn once per task and
Warn once per task and  and continues to run.
disable future checking When both features are
supported, warn in #DB

fatal   Kernel OOPs Send SIGBUS to user
Send SIGBUS to user
When both features are
supported, fatal in #AC.

Default option is "warn".

Hardware only generates #DB for bus lock detect when CPL>0 to avoid
nested #DB from multiple bus locks while the first #DB is being handled.
So no need to handle #DB for bus lock detected in the kernel.

Signed-off-by: Fenghua Yu 
Reviewed-by: Tony Luck 
---
Change Log:
- Check bus lock bit by its positive polarity (Xiaoyao).

RFC v3:
- Remove DR6_RESERVED change (PeterZ).

 arch/x86/include/asm/cpu.h   |   9 +-
 arch/x86/include/asm/msr-index.h |   1 +
 arch/x86/include/uapi/asm/debugreg.h |   1 +
 arch/x86/kernel/cpu/common.c |   2 +-
 arch/x86/kernel/cpu/intel.c  | 121 ++-
 arch/x86/kernel/traps.c  |   7 ++
 6 files changed, 118 insertions(+), 23 deletions(-)

diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index da78ccbd493b..c16b9bab502f 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -41,12 +41,13 @@ unsigned int x86_family(unsigned int sig);
 unsigned int x86_model(unsigned int sig);
 unsigned int x86_stepping(unsigned int sig);
 #ifdef CONFIG_CPU_SUP_INTEL
-extern void __init cpu_set_core_cap_bits(struct cpuinfo_x86 *c);
+extern void __init sld_setup(struct cpuinfo_x86 *c);
 extern void switch_to_sld(unsigned long tifn);
 extern bool handle_user_split_lock(struct pt_regs *regs, long error_code);
 extern bool handle_guest_split_lock(unsigned long ip);
+extern void handle_bus_lock(struct pt_regs *regs);
 #else
-static inline void __init cpu_set_core_cap_bits(struct cpuinfo_x86 *c) {}
+static inline void __init sld_setup(struct cpuinfo_x86 *c) {}
 static inline void switch_to_sld(unsigned long tifn) {}
 static inline bool handle_user_split_lock(struct pt_regs *regs, long 
error_code)
 {
@@ -57,6 +58,10 @@ static inline bool handle_guest_split_lock(unsigned long ip)
 {
return false;
 }
+
+static inline void handle_bus_lock(struct pt_regs *regs)
+{
+}
 #endif
 #ifdef CONFIG_IA32_FEAT_CTL
 void init_ia32_feat_ctl(struct cpuinfo_x86 *c);
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 972a34d93505..62f7534e0855 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -264,6 +264,7 @@
 #define DEBUGCTLMSR_LBR(1UL <<  0) /* last branch 
recording */
 #define DEBUGCTLMSR_BTF_SHIFT  1
 #define DEBUGCTLMSR_BTF(1UL <<  1) /* single-step on 
branches */
+#define DEBUGCTLMSR_BUS_LOCK_DETECT(1UL <<  2) /* Bus lock detect */
 #define DEBUGCTLMSR_TR (1UL <<  6)
 #define DEBUGCTLMSR_BTS(1UL <<  7)
 #define DEBUGCTLMSR_BTINT  (1UL <<  8)
diff --git a/arch/x86/include/uapi/asm/debugreg.h 
b/arch/x86/include/uapi/asm/debugreg.h
index d95d080b30e3..0007ba077c0c 100644
--- a/arch/x86/include/uapi/asm/debugreg.h
+++ b/arch/x86/include/uapi/asm/debugreg.h
@@ -24,6 +24,7 @@
 #define DR_TRAP3   (0x8)   /* db3 */
 #define DR_TRAP_BITS   (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)
 
+#define DR_BUS_LOCK(0x800) /* bus_lock */
 #define DR_STEP(0x4000)/* single-step */
 #define DR_SWITCH  (0x8000)/* task switch */
 
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 35ad8480c464..92705ac301ec 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1327,7 +1327,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 
*c)
 
cpu_set_bug_bits(c);
 
-   cpu_set_core_cap_bits(c);
+   sld_setup(c);
 
fpu__init_system(c);
 
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 59a1e3ce3f14..4c8a22c36798 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -43,12 +43,16 @@ enum split_lock_detect_state {
 };
 
 /*
- * Default to sld_off because most systems do not support split lock detection
- * split_lock_setup() 

Re: [PATCH v2] lan743x: correctly handle chips with internal PHY

2020-11-07 Thread Andrew Lunn
On Fri, Nov 06, 2020 at 08:43:24AM -0500, Sven Van Asbroeck wrote:
> From: Sven Van Asbroeck 
> 
> Commit 6f197fb63850 ("lan743x: Added fixed link and RGMII support")
> assumes that chips with an internal PHY will never have a devicetree
> entry. This is incorrect: even for these chips, a devicetree entry
> can be useful e.g. to pass the mac address from bootloader to chip:
> 
>  {
> status = "okay";
> 
> host@0 {
> reg = <0 0 0 0 0>;
> 
> #address-cells = <3>;
> #size-cells = <2>;
> 
> lan7430: ethernet@0 {
> /* LAN7430 with internal PHY */
> compatible = "microchip,lan743x";
> status = "okay";
> reg = <0 0 0 0 0>;
> /* filled in by bootloader */
> local-mac-address = [00 00 00 00 00 00];
> };
> };
> };
> 
> If a devicetree entry is present, the driver will not attach the chip
> to its internal phy, and the chip will be non-operational.
> 
> Fix by tweaking the phy connection algorithm:
> - first try to connect to a phy specified in the devicetree
>   (could be 'real' phy, or just a 'fixed-link')
> - if that doesn't succeed, try to connect to an internal phy, even
>   if the chip has a devnode
> 
> Tested on a LAN7430 with internal PHY. I cannot test a device using
> fixed-link, as I do not have access to one.
> 
> Fixes: 6f197fb63850 ("lan743x: Added fixed link and RGMII support")
> Tested-by: Sven Van Asbroeck  # lan7430
> Signed-off-by: Sven Van Asbroeck 
> ---
> 
> v1 -> v2:
> Andrew Lunn: keep patch minimal and correct, so keep open-coded version
> of of_phy_get_and_connect().

Hi Sven

Why is it required to remove adapter->phy_mode? It is not clear to me
what this change has to do with not looking for an internal PHY.

> @@ -1063,6 +1065,7 @@ static int lan743x_phy_open(struct lan743x_adapter 
> *adapter)
>  
>   phy_start(phydev);
>   phy_start_aneg(phydev);
> + phy_attached_info(phydev);

This also has nothing to do with the problem you are fixing. It is a
sensible thing to do, but it should be a separate patch, and target
net-next, since it is not a fix.

  Andrew


Re: [PATCH 1/2] tomoyo: Convert get_user_pages*() to pin_user_pages*()

2020-11-07 Thread Tetsuo Handa
On 2020/11/08 11:17, John Hubbard wrote:
>> Excuse me, but Documentation/core-api/pin_user_pages.rst says
>> "CASE 5: Pinning in order to _write_ to the data within the page"
>> while tomoyo_dump_page() is for "_read_ the data within the page".
>> Do we want to convert to pin_user_pages_remote() or lock_page() ?
>>
> 
> Sorry, I missed the direction here, was too focused on the Case 5
> aspect. Yes. Case 5 (which, again, I think we're about to re-document)
> is only about *writing* to data within the page.
> 
> So in this case, where it is just reading from the page, I think it's
> already from a gup vs pup point of view.
> 
> btw, it's not clear to me whether the current code is susceptible to any
> sort of problem involving something writing to the page while it
> is being dumped (I am curious). But changing from gup to pup wouldn't
> fix that, if it were a problem. It a separate question from this patch.

The "struct page" tomoyo_dump_page() accesses is argv/envp arguments passed
to execve() syscall. Therefore, these pages are not visible from threads
except current thread, and thus there is no possibility that these pages
are modified by other threads while current thread is reading.


Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread Randy Dunlap
On 11/7/20 7:22 PM, John Hubbard wrote:
> On 11/7/20 7:14 PM, John Hubbard wrote:
>> On 11/7/20 6:58 PM, Song Bao Hua (Barry Song) wrote:
 On 11/7/20 2:20 PM, Randy Dunlap wrote:
> On 11/7/20 11:16 AM, John Hubbard wrote:
>> On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:
 From: John Hubbard [mailto:jhubb...@nvidia.com]
>> ...
 But if you really disagree, then I'd go with, just drop the patch 
 entirely, because
 it doesn't really make things better as written...IMHO anyway. :)
>>>
>>> Just imagine a case, we don't enable DEBUG_FS but we enable GUP_TEST, we 
>>> will
>>> get an image with totally useless code section since GUP_TEST depends on 
>>> debugfs
>>> entry to perform any useful functionality.
>>>
>>
>> Looking at the choices, from the user's (usually kernel developer's) 
>> experience:
>>
>> a) The user enables GUP_TEST, then boots up, runs, and is briefly surprised 
>> by a
>> runtime failure. But it's a very quick diagnosis: "open: No such file or 
>> directory",
>> when trying to make that ioctl call. The path indicates that it's a debug fs 
>> path,
>> so the solution is pretty clear, at least for the main audience.
>>
>> b) The other choice: the user *never even sees* GUP_TEST as a choice. This 
>> especially
>> bothers me because sometimes you find things by poking around in the menu, 
>> although
>> of course "you should already know about it"...but there's a lot to "already 
>> know"
>> in a large kernel.
>>
>>  From a user experience, it's way better to simply see what you want, and 
>> select it
>> in the menu. Or, at least get some prompt that you need to pre-select 
>> something else.
>>
> 
> ...and again, this is all fallout from Kconfig. I might be missing some 
> advanced
> feature, because it seems surprising to only be allowed to choose between
> missing dependencies (which this patch would correct), or a poorer user 
> experience
> (which I argue that this patch would also provide).
> 
> Ideally, we'd just set up the dependencies, and then have some options for
> visibility, but I'm not aware of any way to do that...and after a quick peek
> at Documentation/kbuild/kconfig-macro-language.rst it looks pretty bare bones.

Look at kconfig-language.rst instead.

One thing that could be done (and is done in a few places for other reasons) is 
to add
a Kconfig comment if DEBUG_FS is not enabled:

comment "GUP_TEST needs to have DEBUG_FS enabled"
depends on !GUP_TEST && !DEBUG_FS

e.g. drivers/hid/usbhid/Kconfig:

comment "Input core support is needed for USB HID input layer or HIDBP support"
depends on USB_HID && INPUT=n


-- 
~Randy



RE: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread Song Bao Hua (Barry Song)


> -Original Message-
> From: John Hubbard [mailto:jhubb...@nvidia.com]
> Sent: Sunday, November 8, 2020 4:14 PM
> To: Song Bao Hua (Barry Song) ; Randy Dunlap
> ; a...@linux-foundation.org; linux...@kvack.org;
> linux-kernel@vger.kernel.org
> Cc: Linuxarm ; Ralph Campbell
> ; John Garry 
> Subject: Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on
> DEBUG_FS
> 
> On 11/7/20 6:58 PM, Song Bao Hua (Barry Song) wrote:
> >> On 11/7/20 2:20 PM, Randy Dunlap wrote:
> >>> On 11/7/20 11:16 AM, John Hubbard wrote:
>  On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:
> >> From: John Hubbard [mailto:jhubb...@nvidia.com]
>  ...
> >> But if you really disagree, then I'd go with, just drop the patch entirely,
> because
> >> it doesn't really make things better as written...IMHO anyway. :)
> >
> > Just imagine a case, we don't enable DEBUG_FS but we enable GUP_TEST, we
> will
> > get an image with totally useless code section since GUP_TEST depends on
> debugfs
> > entry to perform any useful functionality.
> >
> 
> Looking at the choices, from the user's (usually kernel developer's) 
> experience:
> 
> a) The user enables GUP_TEST, then boots up, runs, and is briefly surprised 
> by a
> runtime failure. But it's a very quick diagnosis: "open: No such file or
> directory",
> when trying to make that ioctl call. The path indicates that it's a debug fs 
> path,
> so the solution is pretty clear, at least for the main audience.

users could have these two different stories:
Story A:
users want to use GUP_TEST, so they simply enable GUP_TEST, build a kernel
and run the test. Then they get failed at runtime but the kernel build has no
any issue.

Then they have to read the code, and figure out DEBUG_FS is a must-have, then
they enable DEBUG_FS afterwards. After that, they re-build kernel and re-test.

Users might have wasted one hour on it.

Story B:
if we put "depends on", users want to use GUP_TEST, then they try to
enable "GUP_TEST", but they couldn't enable it at all since DEBUG_FS is
not enabled.

And they use "/" to search GUP_TEST, menuconfig will show "GUP_TEST"
depend on "DEBUG_FS", they will enable DEBUG_FS to get GUP_TEST
enabled.

For story B, users only spend one minute in menuconfig :-)

> 
> b) The other choice: the user *never even sees* GUP_TEST as a choice. This
> especially
> bothers me because sometimes you find things by poking around in the menu,
> although
> of course "you should already know about it"...but there's a lot to "already
> know"
> in a large kernel.
> 
>  From a user experience, it's way better to simply see what you want, and
> select it
> in the menu. Or, at least get some prompt that you need to pre-select
> something else.
> 

If we type "/" to search GUP_TEST, menuconfig will show it depends on
DEBUG_FS and show the status of DEBUG_FS Y or N. Wouldn't it has been
a prompt?

> 
> > The difference between "depends on" and "select" for this case is like:
> > depends on: if we want to use GUP_TEST, we have to enable DEBUG_FS first;
> > select: if we enable GUP_TEST, Kconfig will enable DEBUG_FS automatically.
> >
> > To me, I am 60% inclined to "depends on" as I think "DEBUG_FS" is more
> > of a pre-condition of GUP_TEST than an internal part of GUP_TEST. So people
> > should realize the pre-condition must be met before using GUP_TEST and
> 
> 
> Right, but first of course they must read every single line of the test code
> carefully. And while it is true the you often *do* end up reading most or
> all of the test code, there are situations in which you don't need to. We'd
> be taking away some of those situations. :)
> 

An careless engineer like me often ignore some dependency even after I have
read code carefully. "depends on" will enforce me to resolve the dependency
during build stage and save me much time :-)

> 
> > they must manually enable it if they haven't. That's why I think this patch 
> > is
> > making things better.
> >
> 
> ...which makes things a little bit worse.

For this case, I am also happy with "select" as it also resolves the problem of
story A. Just kconfig documentation says "select" should be used with care.

> 
> 
> thanks,
> --
> John Hubbard
> NVIDIA

Thanks
Barry



Re: [PATCH v2] Add-driver-for-STMicroelectronics-PM6764-Voltage-Regulator

2020-11-07 Thread Guenter Roeck
On 11/5/20 11:04 PM, Charles wrote:
> Add the pmbus driver for the STMicroelectronics pm6764 voltage regulator.
> 
> the output voltage use the MFR_READ_VOUT 0xD4
> vout value returned is linear11
> 
> Signed-off-by: Charles Hsu 

I don't find this patch in hwmon patchwork. Please remember
to cc linux-hw...@vger.kernel.org.

The subject line needs to be fixed to something like

hwmon: Add driver for STMicroelectronics PM6764 Voltage Regulator

(hwmon tag and no dashes).

> ---
> v2:
>  - fix formatting.
>  - remove pmbus_do_remove.
>  - Change from .probe to .probe_new. 
> v1:
>  - Initial patchset.
> ---
>  drivers/hwmon/pmbus/Kconfig|  9 
>  drivers/hwmon/pmbus/Makefile   |  1 +
>  drivers/hwmon/pmbus/pm6764tr.c | 79 ++

Documentation (Documentation/hwmon/pm6764tr.rst) is missing.

>  3 files changed, 89 insertions(+)
>  create mode 100644 drivers/hwmon/pmbus/pm6764tr.c
> 
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index a25faf69fce3..9c846facce9f 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -220,6 +220,15 @@ config SENSORS_MP2975
> This driver can also be built as a module. If so, the module will
> be called mp2975.
>  
> +config SENSORS_PM6764TR
> + tristate "ST PM6764TR"
> + help
> +   If you say yes here you get hardware monitoring support for ST
> +   PM6764TR.
> +
> +   This driver can also be built as a module. If so, the module will
> +   be called pm6764tr.
> +
>  config SENSORS_PXE1610
>   tristate "Infineon PXE1610"
>   help
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index 4c97ad0bd791..31ebdef5d4a6 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -25,6 +25,7 @@ obj-$(CONFIG_SENSORS_MAX31785)  += max31785.o
>  obj-$(CONFIG_SENSORS_MAX34440)   += max34440.o
>  obj-$(CONFIG_SENSORS_MAX8688)+= max8688.o
>  obj-$(CONFIG_SENSORS_MP2975) += mp2975.o
> +obj-$(CONFIG_SENSORS_PM6764TR)   += pm6764tr.o
>  obj-$(CONFIG_SENSORS_PXE1610)+= pxe1610.o
>  obj-$(CONFIG_SENSORS_TPS40422)   += tps40422.o
>  obj-$(CONFIG_SENSORS_TPS53679)   += tps53679.o
> diff --git a/drivers/hwmon/pmbus/pm6764tr.c b/drivers/hwmon/pmbus/pm6764tr.c
> new file mode 100644
> index ..590435f8e69e
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/pm6764tr.c
> @@ -0,0 +1,79 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Hardware monitoring driver for Renesas Digital Multiphase Voltage 
> Regulators
> + *

Renesas ? Is this a cut-and-paste error ?

> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "pmbus.h"

This should be the last include file (local includes always come last).

> +#include 
> +#include 
> +
> +#define PM6764TR_PMBUS_READ_VOUT 0xD4
> +
> +static int pm6764tr_read_word_data(struct i2c_client *client, int page, int 
> reg)
> +{
> + int ret;
> +
> + switch (reg) {
> + case PMBUS_VIRT_READ_VMON:
> + ret = pmbus_read_word_data(client, page, 
> PM6764TR_PMBUS_READ_VOUT);
> + break;
> + default:
> + ret = -ENODATA;
> + break;
> + }
> + return ret;
> +}
> +
> +static struct pmbus_driver_info pm6764tr_info = {
> + .pages = 1,
> + .format[PSC_VOLTAGE_IN] = linear,
> + .format[PSC_VOLTAGE_OUT] = vid,
> + .format[PSC_TEMPERATURE] = linear,
> + .format[PSC_CURRENT_OUT] = linear,
> + .format[PSC_POWER] = linear,
> + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |  PMBUS_HAVE_PIN |
> + PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT | PMBUS_HAVE_VMON |
> + PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_VOUT |
> + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
> + .read_word_data = pm6764tr_read_word_data,
> +};
> +
> +static int pm6764tr_probe(struct i2c_client *client,
> +   const struct i2c_device_id *id)
> +{
> + return pmbus_do_probe(client, id, _info);
> +}
> +
> +static const struct i2c_device_id pm6764tr_id[] = {
> + {"pm6764tr", 0},
> + {}
> +};
> +MODULE_DEVICE_TABLE(i2c, pm6764tr_id);
> +
> +static const struct of_device_id pm6764tr_of_match[] = {
> + {.compatible = "pm6764tr"},
> + {}
> +};
> +
> +/* This is the driver that will be inserted */
> +static struct i2c_driver pm6764tr_driver = {
> + .driver = {
> +.name = "pm6764tr",
> +.of_match_table = of_match_ptr(pm6764tr_of_match),
> +},
> + .probe_new = pm6764tr_probe,
> + .id_table = pm6764tr_id,
> +};
> +
> +module_i2c_driver(pm6764tr_driver);
> +
> +MODULE_AUTHOR("Charles Hsu");
> +MODULE_DESCRIPTION("PMBus driver for  ST PM6764TR");
> +MODULE_LICENSE("GPL");
> -- 
> 2.25.1
> 



Re: [PATCH][next] hwmon: corsair-psu: fix unintentional sign extension issue

2020-11-07 Thread Guenter Roeck
On Thu, Nov 05, 2020 at 11:50:19AM +, Colin King wrote:
> From: Colin Ian King 
> 
> The shifting of the u8 integer data[3] by 24 bits to the left will
> be promoted to a 32 bit signed int and then sign-extended to a
> long. In the event that the top bit of data[3] is set then all
> then all the upper 32 bits of a 64 bit long end up as also being
> set because of the sign-extension. Fix this by casting data[3] to
> a long before the shift.
> 
> Addresses-Coverity: ("Unintended sign extension")
> Fixes: ce15cd2cee8b ("hwmon: add Corsair PSU HID controller driver")
> Signed-off-by: Colin Ian King 

I wasn't sure if I am going to get another version of this patch.
Either case, I applied this now.

Guenter

> ---
>  drivers/hwmon/corsair-psu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c
> index e92d0376e7ac..5d19a888231a 100644
> --- a/drivers/hwmon/corsair-psu.c
> +++ b/drivers/hwmon/corsair-psu.c
> @@ -241,7 +241,7 @@ static int corsairpsu_get_value(struct corsairpsu_data 
> *priv, u8 cmd, u8 rail, l
>* the LINEAR11 conversion are the watts values which are about 1200 
> for the strongest psu
>* supported (HX1200i)
>*/
> - tmp = (data[3] << 24) + (data[2] << 16) + (data[1] << 8) + data[0];
> + tmp = ((long)data[3] << 24) + (data[2] << 16) + (data[1] << 8) + 
> data[0];
>   switch (cmd) {
>   case PSU_CMD_IN_VOLTS:
>   case PSU_CMD_IN_AMPS:


Re: [v2 PATCH] dt-bindings: display: mediatek: convert the dpi bindings to yaml

2020-11-07 Thread Chun-Kuang Hu
Hi, Jitao:

Rob Herring  於 2020年9月24日 週四 上午4:15寫道:
>
> On Thu, 17 Sep 2020 15:33:05 +0800, Jitao Shi wrote:
> > Convert display/mediatek/mediatek,dpi.txt to 
> > display/mediatek/mediatek,dpi.yaml
> > and remove the old text bindings.
> >
> > Signed-off-by: Jitao Shi 
> > ---
> >  .../bindings/display/mediatek/mediatek,dpi.txt | 42 --
> >  .../bindings/display/mediatek/mediatek,dpi.yaml| 97 
> > ++
> >  2 files changed, 97 insertions(+), 42 deletions(-)
> >  delete mode 100644 
> > Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml
> >
>
> Reviewed-by: Rob Herring 
> __

Applied to mediatek-drm-next [1], thanks.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

_
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread John Hubbard

On 11/7/20 7:14 PM, John Hubbard wrote:

On 11/7/20 6:58 PM, Song Bao Hua (Barry Song) wrote:

On 11/7/20 2:20 PM, Randy Dunlap wrote:

On 11/7/20 11:16 AM, John Hubbard wrote:

On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:

From: John Hubbard [mailto:jhubb...@nvidia.com]

...

But if you really disagree, then I'd go with, just drop the patch entirely, 
because
it doesn't really make things better as written...IMHO anyway. :)


Just imagine a case, we don't enable DEBUG_FS but we enable GUP_TEST, we will
get an image with totally useless code section since GUP_TEST depends on debugfs
entry to perform any useful functionality.



Looking at the choices, from the user's (usually kernel developer's) experience:

a) The user enables GUP_TEST, then boots up, runs, and is briefly surprised by a
runtime failure. But it's a very quick diagnosis: "open: No such file or 
directory",
when trying to make that ioctl call. The path indicates that it's a debug fs 
path,
so the solution is pretty clear, at least for the main audience.

b) The other choice: the user *never even sees* GUP_TEST as a choice. This 
especially
bothers me because sometimes you find things by poking around in the menu, 
although
of course "you should already know about it"...but there's a lot to "already 
know"
in a large kernel.

 From a user experience, it's way better to simply see what you want, and 
select it
in the menu. Or, at least get some prompt that you need to pre-select something 
else.



...and again, this is all fallout from Kconfig. I might be missing some advanced
feature, because it seems surprising to only be allowed to choose between
missing dependencies (which this patch would correct), or a poorer user 
experience
(which I argue that this patch would also provide).

Ideally, we'd just set up the dependencies, and then have some options for
visibility, but I'm not aware of any way to do that...and after a quick peek
at Documentation/kbuild/kconfig-macro-language.rst it looks pretty bare bones.

thanks,
--
John Hubbard
NVIDIA


Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread John Hubbard

On 11/7/20 6:58 PM, Song Bao Hua (Barry Song) wrote:

On 11/7/20 2:20 PM, Randy Dunlap wrote:

On 11/7/20 11:16 AM, John Hubbard wrote:

On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:

From: John Hubbard [mailto:jhubb...@nvidia.com]

...

But if you really disagree, then I'd go with, just drop the patch entirely, 
because
it doesn't really make things better as written...IMHO anyway. :)


Just imagine a case, we don't enable DEBUG_FS but we enable GUP_TEST, we will
get an image with totally useless code section since GUP_TEST depends on debugfs
entry to perform any useful functionality.



Looking at the choices, from the user's (usually kernel developer's) experience:

a) The user enables GUP_TEST, then boots up, runs, and is briefly surprised by a
runtime failure. But it's a very quick diagnosis: "open: No such file or 
directory",
when trying to make that ioctl call. The path indicates that it's a debug fs 
path,
so the solution is pretty clear, at least for the main audience.

b) The other choice: the user *never even sees* GUP_TEST as a choice. This 
especially
bothers me because sometimes you find things by poking around in the menu, 
although
of course "you should already know about it"...but there's a lot to "already 
know"
in a large kernel.

From a user experience, it's way better to simply see what you want, and select 
it
in the menu. Or, at least get some prompt that you need to pre-select something 
else.



The difference between "depends on" and "select" for this case is like:
depends on: if we want to use GUP_TEST, we have to enable DEBUG_FS first;
select: if we enable GUP_TEST, Kconfig will enable DEBUG_FS automatically.

To me, I am 60% inclined to "depends on" as I think "DEBUG_FS" is more
of a pre-condition of GUP_TEST than an internal part of GUP_TEST. So people
should realize the pre-condition must be met before using GUP_TEST and



Right, but first of course they must read every single line of the test code
carefully. And while it is true the you often *do* end up reading most or
all of the test code, there are situations in which you don't need to. We'd
be taking away some of those situations. :)



they must manually enable it if they haven't. That's why I think this patch is
making things better.



...which makes things a little bit worse.


thanks,
--
John Hubbard
NVIDIA


Re: [PATCH 3/3] MAINTAINERS: add files for Mediatek DRM drivers

2020-11-07 Thread Chun-Kuang Hu
+ Vinod:

Hi, Chunfeng:

Chun-Kuang Hu  於 2020年10月29日 週四 下午11:28寫道:
>
> Mediatek MIPI DSI phy driver is moved from drivers/gpu/drm/mediatek to
> drivers/phy/mediatek, so add the new folder to the Mediatek DRM drivers'
> information.

Would you like this patch? If so, you could give an acked-by tag on
this patch, so I could applied the whole series into my tree.

Regards,
Chun-Kuang.

>
> Signed-off-by: Chun-Kuang Hu 
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e73636b75f29..14f5018c01b6 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5867,6 +5867,7 @@ S:Supported
>  F: Documentation/devicetree/bindings/display/mediatek/
>  F: drivers/gpu/drm/mediatek/
>  F: drivers/phy/mediatek/phy-mtk-hdmi*
> +F: drivers/phy/mediatek/phy-mtk-mipi*
>
>  DRM DRIVERS FOR NVIDIA TEGRA
>  M: Thierry Reding 
> --
> 2.17.1
>


RE: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread Song Bao Hua (Barry Song)


> -Original Message-
> From: John Hubbard [mailto:jhubb...@nvidia.com]
> Sent: Sunday, November 8, 2020 1:03 PM
> To: Randy Dunlap ; Song Bao Hua (Barry Song)
> ; a...@linux-foundation.org;
> linux...@kvack.org; linux-kernel@vger.kernel.org
> Cc: Linuxarm ; Ralph Campbell
> ; John Garry 
> Subject: Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on
> DEBUG_FS
> 
> On 11/7/20 2:20 PM, Randy Dunlap wrote:
> > On 11/7/20 11:16 AM, John Hubbard wrote:
> >> On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:
>  -Original Message-
>  From: John Hubbard [mailto:jhubb...@nvidia.com]
> >> ...
> >     config GUP_BENCHMARK
> >     bool "Enable infrastructure for get_user_pages() and related
> calls
>  benchmarking"
> > +    depends on DEBUG_FS
> 
> 
>  I think "select DEBUG_FS" is better here. "depends on" has the obnoxious
>  behavior of hiding the choice from you, if the dependencies aren't 
>  already
> met.
>  Whereas what the developer *really* wants is a no-nonsense activation of
> the
>  choice: "enable GUP_BENCHMARK and the debug fs that it requires".
> 
> >>>
> >>> To some extent, I agree with you. But I still think here it is better to 
> >>> use
> "depends on".
> >>> According to
> >>> https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt
> >>>
> >>>  select should be used with care. select will force
> >>>  a symbol to a value without visiting the dependencies.
> >>>  By abusing select you are able to select a symbol FOO even
> >>>  if FOO depends on BAR that is not set.
> >>>  In general use select only for non-visible symbols
> >>>  (no prompts anywhere) and for symbols with no dependencies.
> >>>  That will limit the usefulness but on the other hand avoid
> >>>  the illegal configurations all over.
> >>>
> >>> On the other hand, in kernel there are 78 "depends on DEBUG_FS" and
> >>> only 14 "select DEBUG_FS".
> >>>
> >>
> >> You're not looking at the best statistics. Go look at what *already* 
> >> selects
> >> DEBUG_FS, and you'll find about 50 items.
> >
> > Sorry, I'm not following you. I see the same 14 "select DEBUG_FS" as Barry.
> 
> I ran make menuconfig, and looked at it. Because I want to see the true end
> result,
> and I didn't trust my grep use, given that the system has interlocking
> dependencies,
> and I think one select could end up activating others (yes?).
> 
> And sure enough, there are 42 items listed, here they are, cleaned up so that
> there
> is one per line:
> 
> ZSMALLOC_STAT [=n]
> ZSMALLOC [=m]
> BCACHE_CLOSURES_DEBUG [=n]
> MD [=y]
> BCACHE [=n]
> DVB_C8SECTPFE [=n]
> MEDIA_SUPPORT [=m]
> MEDIA_PLATFORM_SUPPORT [=y]
> DVB_PLATFORM_DRIVERS [=n]
> PINCT
> DRM_I915_DEBUG [=n]
> HAS_IOMEM [=y]
> EXPERT [=y]
> DRM_I915 [=m]
> EDAC_DEBUG [=n]
> EDAC [=y]
> SUNRPC_DEBUG [=n]
> NETWORK_FILESYSTEMS [=y]
> SUNRPC [=m]
> SYSCTL [=y]
> PAGE_OWNER [=n]
> DEBUG_KERNEL [=y]
> STACKTRACE_SUPPORT [=y]
> DEBUG_KMEMLEAK [=n]
> DEBUG_KERNEL [=y]
> HAVE_DEBUG_KMEMLEAK [=y]
> BLK_DEV_IO_TRACE [=n]
> TRACING_SUPPORT [=y]
> FTRACE [=y]
> SYSFS [=y]
> BLOCK [=y]
> PUNIT_ATOM_DEBUG [=n]
> PCI [=y]
> NOTIFIER_ERROR_INJECTION [=n]
> DEBUG_KERNEL [=y]
> FAIL_FUTEX [=n]
> FAULT_INJECTION [=n]
> FUTEX [=y]
> KCOV [=n]
> ARCH_HAS_KCOV [=y]
> CC_HAS_SANCOV_TRACE_PC [=y]
> GCC_PLUGINS
> 
> 
> >
> > In general we don't want any one large "feature" (or subsystem) to be
> enabled
> > by one driver. If someone has gone to the trouble to disable DEBUG_FS (or
> whatever),
> > then a different Kconfig symbol shouldn't undo that.
> >
> 
> I agree with the "in general" point, yes. And my complaint is really 80% due 
> to
> the
> very unhappy situation with Kconfig, where we seem to get a choice between
> *hiding*
> a feature, or forcing a dependency break. What we really want is a way to
> indicate
> a dependency that doesn't hide entire features, unless we want that. (Maybe I
> should
> attempt to get into the implementation, although I suspect it's harder than I
> realize.)
> 
> But the other 20% of my complaint is, given what we have, I think the
> appropriate
> adaptation for GUP_BENCHMARK's relationship to DEBUG_FS *in particular*, is:
> select.
> 
> And 42 other committers have chosen the same thing, for their relationship to
> DEBUG_FS. I'm in good company.
> 
> But if you really disagree, then I'd go with, just drop the patch entirely, 
> because
> it doesn't really make things better as written...IMHO anyway. :)

Just imagine a case, we don't enable DEBUG_FS but we enable GUP_TEST, we will
get an image with totally useless code section since GUP_TEST depends on debugfs
entry to perform any useful functionality.

The difference between "depends on" and "select" for this case is like:
depends on: if we want to use GUP_TEST, we have to enable DEBUG_FS first;
select: if we enable GUP_TEST, Kconfig will enable DEBUG_FS automatically.

To me, I am 60% inclined to "depends on" as I 

Re: [PATCH] drm/mediatek: Optimize functions which do not need to return

2020-11-07 Thread Chun-Kuang Hu
Hi, Bernard:

Chun-Kuang Hu  於 2020年10月17日 週六 上午10:50寫道:
>
> Bernard Zhao  於 2020年10月13日 週二 下午4:55寫道:
> >
> > Function mtk_hdmi_aud_set_input always return 0, no need to
> > keep the return value. Functions mtk_hdmi_aud_enable_packet &
> > mtk_hdmi_aud_on_off_hw_ncts are the same, these two functions
> > just call next functions. Maybe it`s a bit better to just call
> > the inner function.
>
> Reviewed-by: Chun-Kuang Hu 
>

Applied to mediatek-drm-next [1], thanks.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

> >
> > Signed-off-by: Bernard Zhao 
> > ---
> >  drivers/gpu/drm/mediatek/mtk_hdmi.c | 27 +++
> >  1 file changed, 7 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c 
> > b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> > index a97725680d4e..f1d987df0550 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> > @@ -870,19 +870,8 @@ static void mtk_hdmi_video_set_display_mode(struct 
> > mtk_hdmi *hdmi,
> > mtk_hdmi_hw_msic_setting(hdmi, mode);
> >  }
> >
> > -static int mtk_hdmi_aud_enable_packet(struct mtk_hdmi *hdmi, bool enable)
> > -{
> > -   mtk_hdmi_hw_send_aud_packet(hdmi, enable);
> > -   return 0;
> > -}
> >
> > -static int mtk_hdmi_aud_on_off_hw_ncts(struct mtk_hdmi *hdmi, bool on)
> > -{
> > -   mtk_hdmi_hw_ncts_enable(hdmi, on);
> > -   return 0;
> > -}
> > -
> > -static int mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi)
> > +static void mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi)
> >  {
> > enum hdmi_aud_channel_type chan_type;
> > u8 chan_count;
> > @@ -912,8 +901,6 @@ static int mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi)
> > chan_count = mtk_hdmi_aud_get_chnl_count(chan_type);
> > mtk_hdmi_hw_aud_set_i2s_chan_num(hdmi, chan_type, chan_count);
> > mtk_hdmi_hw_aud_set_input_type(hdmi, 
> > hdmi->aud_param.aud_input_type);
> > -
> > -   return 0;
> >  }
> >
> >  static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,
> > @@ -921,7 +908,7 @@ static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,
> >  {
> > unsigned int sample_rate = hdmi->aud_param.codec_params.sample_rate;
> >
> > -   mtk_hdmi_aud_on_off_hw_ncts(hdmi, false);
> > +   mtk_hdmi_hw_ncts_enable(hdmi, false);
> > mtk_hdmi_hw_aud_src_disable(hdmi);
> > mtk_hdmi_clear_bits(hdmi, GRL_CFG2, CFG2_ACLK_INV);
> >
> > @@ -959,7 +946,7 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi 
> > *hdmi,
> >   struct drm_display_mode *display_mode)
> >  {
> > mtk_hdmi_hw_aud_mute(hdmi);
> > -   mtk_hdmi_aud_enable_packet(hdmi, false);
> > +   mtk_hdmi_hw_send_aud_packet(hdmi, false);
> >
> > mtk_hdmi_aud_set_input(hdmi);
> > mtk_hdmi_aud_set_src(hdmi, display_mode);
> > @@ -968,8 +955,8 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi 
> > *hdmi,
> >
> > usleep_range(50, 100);
> >
> > -   mtk_hdmi_aud_on_off_hw_ncts(hdmi, true);
> > -   mtk_hdmi_aud_enable_packet(hdmi, true);
> > +   mtk_hdmi_hw_ncts_enable(hdmi, true);
> > +   mtk_hdmi_hw_send_aud_packet(hdmi, true);
> > mtk_hdmi_hw_aud_unmute(hdmi);
> > return 0;
> >  }
> > @@ -1097,13 +1084,13 @@ static int mtk_hdmi_output_init(struct mtk_hdmi 
> > *hdmi)
> >
> >  static void mtk_hdmi_audio_enable(struct mtk_hdmi *hdmi)
> >  {
> > -   mtk_hdmi_aud_enable_packet(hdmi, true);
> > +   mtk_hdmi_hw_send_aud_packet(hdmi, true);
> > hdmi->audio_enable = true;
> >  }
> >
> >  static void mtk_hdmi_audio_disable(struct mtk_hdmi *hdmi)
> >  {
> > -   mtk_hdmi_aud_enable_packet(hdmi, false);
> > +   mtk_hdmi_hw_send_aud_packet(hdmi, false);
> > hdmi->audio_enable = false;
> >  }
> >
> > --
> > 2.28.0
> >


[PATCH] arm64: dts: imx: Fix imx8mm-kontron-n801x-s.dtb target

2020-11-07 Thread Nathan Chancellor
$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux- \
INSTALL_DTBS_PATH=rootfs distclean defconfig dtbs dtbs_install
...
make[3]: *** No rule to make target
'rootfs/freescale/imx8mm-kontron-n801x-s.dts', needed by
'__dtbs_install'
...

It should be .dtb, not .dts.

Fixes: 8668d8b2e67f ("arm64: dts: Add the Kontron i.MX8M Mini SoMs and 
baseboards")
Signed-off-by: Nathan Chancellor 
---
 arch/arm64/boot/dts/freescale/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/Makefile 
b/arch/arm64/boot/dts/freescale/Makefile
index 876bf484bbe6..6f0777ee6cd6 100644
--- a/arch/arm64/boot/dts/freescale/Makefile
+++ b/arch/arm64/boot/dts/freescale/Makefile
@@ -32,7 +32,7 @@ dtb-$(CONFIG_ARCH_LAYERSCAPE) += fsl-lx2162a-qds.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mm-beacon-kit.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mm-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mm-ddr4-evk.dtb
-dtb-$(CONFIG_ARCH_MXC) += imx8mm-kontron-n801x-s.dts
+dtb-$(CONFIG_ARCH_MXC) += imx8mm-kontron-n801x-s.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mm-var-som-symphony.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mn-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mn-ddr4-evk.dtb

base-commit: 39fabe22e0f8c00334882ceac1dc70ffbd7f4871
-- 
2.29.2



Re: [PATCH 1/2] tomoyo: Convert get_user_pages*() to pin_user_pages*()

2020-11-07 Thread John Hubbard

On 11/7/20 5:13 PM, Tetsuo Handa wrote:

On 2020/11/08 4:17, John Hubbard wrote:

On 11/7/20 1:04 AM, John Hubbard wrote:

On 11/7/20 12:24 AM, Souptick Joarder wrote:

In 2019, we introduced pin_user_pages*() and now we are converting
get_user_pages*() to the new API as appropriate. [1] & [2] could
be referred for more information. This is case 5 as per document [1].


It turns out that Case 5 can be implemented via a better pattern, as long
as we're just dealing with a page at a time, briefly:

lock_page()
write to page's data
unlock_page()

...which neatly synchronizes with writeback and other fs activities.


Ahem, I left out a key step: set_page_dirty()!

lock_page()
write to page's data
set_page_dirty()
unlock_page()



Excuse me, but Documentation/core-api/pin_user_pages.rst says
"CASE 5: Pinning in order to _write_ to the data within the page"
while tomoyo_dump_page() is for "_read_ the data within the page".
Do we want to convert to pin_user_pages_remote() or lock_page() ?



Sorry, I missed the direction here, was too focused on the Case 5
aspect. Yes. Case 5 (which, again, I think we're about to re-document)
is only about *writing* to data within the page.

So in this case, where it is just reading from the page, I think it's
already from a gup vs pup point of view.

btw, it's not clear to me whether the current code is susceptible to any
sort of problem involving something writing to the page while it
is being dumped (I am curious). But changing from gup to pup wouldn't
fix that, if it were a problem. It a separate question from this patch.

(Souptick, if you're interested, the Case 5 documentation change and
callsite retrofit is all yours if you want it. Otherwise it's on
my list.)

thanks,
--
John Hubbard
NVIDIA


Re: [PATCH v2 4/5] drm/mediatek: add DDP support for MT8167

2020-11-07 Thread Chun-Kuang Hu
Hi, Fabien:

Chun-Kuang Hu  於 2020年10月23日 週五 下午11:45寫道:
>
> Hi, Fabien:
>
> Fabien Parent  於 2020年10月23日 週五 下午9:31寫道:
> >
> > Add DDP support for MT8167 SoC.
>
> Reviewed-by: Chun-Kuang Hu 

For this patch, applied to mediatek-drm-next [1], thanks.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

>
> > Signed-off-by: Fabien Parent 
> > ---
> >
> > Changelog:
> >
> > V2: don't set DDP_MUTEX_SOF_DSI{1,2,3} since they are not available on 
> > MT8167
> >
> >  drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 47 ++
> >  1 file changed, 47 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c 
> > b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> > index 014c1bbe1df2..1f99db6b1a42 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> > @@ -25,6 +25,19 @@
> >
> >  #define INT_MUTEX  BIT(1)
> >
> > +#define MT8167_MUTEX_MOD_DISP_PWM  1
> > +#define MT8167_MUTEX_MOD_DISP_OVL0 6
> > +#define MT8167_MUTEX_MOD_DISP_OVL1 7
> > +#define MT8167_MUTEX_MOD_DISP_RDMA08
> > +#define MT8167_MUTEX_MOD_DISP_RDMA19
> > +#define MT8167_MUTEX_MOD_DISP_WDMA010
> > +#define MT8167_MUTEX_MOD_DISP_CCORR11
> > +#define MT8167_MUTEX_MOD_DISP_COLOR12
> > +#define MT8167_MUTEX_MOD_DISP_AAL  13
> > +#define MT8167_MUTEX_MOD_DISP_GAMMA14
> > +#define MT8167_MUTEX_MOD_DISP_DITHER   15
> > +#define MT8167_MUTEX_MOD_DISP_UFOE 16
> > +
> >  #define MT8173_MUTEX_MOD_DISP_OVL0 11
> >  #define MT8173_MUTEX_MOD_DISP_OVL1 12
> >  #define MT8173_MUTEX_MOD_DISP_RDMA013
> > @@ -73,6 +86,8 @@
> >  #define MUTEX_SOF_DPI1 4
> >  #define MUTEX_SOF_DSI2 5
> >  #define MUTEX_SOF_DSI3 6
> > +#define MT8167_MUTEX_SOF_DPI0  2
> > +#define MT8167_MUTEX_SOF_DPI1  3
> >
> >
> >  struct mtk_disp_mutex {
> > @@ -135,6 +150,21 @@ static const unsigned int 
> > mt2712_mutex_mod[DDP_COMPONENT_ID_MAX] = {
> > [DDP_COMPONENT_WDMA1] = MT2712_MUTEX_MOD_DISP_WDMA1,
> >  };
> >
> > +static const unsigned int mt8167_mutex_mod[DDP_COMPONENT_ID_MAX] = {
> > +   [DDP_COMPONENT_AAL0] = MT8167_MUTEX_MOD_DISP_AAL,
> > +   [DDP_COMPONENT_CCORR] = MT8167_MUTEX_MOD_DISP_CCORR,
> > +   [DDP_COMPONENT_COLOR0] = MT8167_MUTEX_MOD_DISP_COLOR,
> > +   [DDP_COMPONENT_DITHER] = MT8167_MUTEX_MOD_DISP_DITHER,
> > +   [DDP_COMPONENT_GAMMA] = MT8167_MUTEX_MOD_DISP_GAMMA,
> > +   [DDP_COMPONENT_OVL0] = MT8167_MUTEX_MOD_DISP_OVL0,
> > +   [DDP_COMPONENT_OVL1] = MT8167_MUTEX_MOD_DISP_OVL1,
> > +   [DDP_COMPONENT_PWM0] = MT8167_MUTEX_MOD_DISP_PWM,
> > +   [DDP_COMPONENT_RDMA0] = MT8167_MUTEX_MOD_DISP_RDMA0,
> > +   [DDP_COMPONENT_RDMA1] = MT8167_MUTEX_MOD_DISP_RDMA1,
> > +   [DDP_COMPONENT_UFOE] = MT8167_MUTEX_MOD_DISP_UFOE,
> > +   [DDP_COMPONENT_WDMA0] = MT8167_MUTEX_MOD_DISP_WDMA0,
> > +};
> > +
> >  static const unsigned int mt8173_mutex_mod[DDP_COMPONENT_ID_MAX] = {
> > [DDP_COMPONENT_AAL0] = MT8173_MUTEX_MOD_DISP_AAL,
> > [DDP_COMPONENT_COLOR0] = MT8173_MUTEX_MOD_DISP_COLOR0,
> > @@ -163,6 +193,13 @@ static const unsigned int 
> > mt2712_mutex_sof[DDP_MUTEX_SOF_DSI3 + 1] = {
> > [DDP_MUTEX_SOF_DSI3] = MUTEX_SOF_DSI3,
> >  };
> >
> > +static const unsigned int mt8167_mutex_sof[DDP_MUTEX_SOF_DSI3 + 1] = {
> > +   [DDP_MUTEX_SOF_SINGLE_MODE] = MUTEX_SOF_SINGLE_MODE,
> > +   [DDP_MUTEX_SOF_DSI0] = MUTEX_SOF_DSI0,
> > +   [DDP_MUTEX_SOF_DPI0] = MT8167_MUTEX_SOF_DPI0,
> > +   [DDP_MUTEX_SOF_DPI1] = MT8167_MUTEX_SOF_DPI1,
> > +};
> > +
> >  static const struct mtk_ddp_data mt2701_ddp_driver_data = {
> > .mutex_mod = mt2701_mutex_mod,
> > .mutex_sof = mt2712_mutex_sof,
> > @@ -177,6 +214,14 @@ static const struct mtk_ddp_data 
> > mt2712_ddp_driver_data = {
> > .mutex_sof_reg = MT2701_DISP_MUTEX0_SOF0,
> >  };
> >
> > +static const struct mtk_ddp_data mt8167_ddp_driver_data = {
> > +   .mutex_mod = mt8167_mutex_mod,
> > +   .mutex_sof = mt8167_mutex_sof,
> > +   .mutex_mod_reg = MT2701_DISP_MUTEX0_MOD0,
> > +   .mutex_sof_reg = MT2701_DISP_MUTEX0_SOF0,
> > +   .no_clk = true,
> > +};
> > +
> >  static const struct mtk_ddp_data mt8173_ddp_driver_data = {
> > .mutex_mod = mt8173_mutex_mod,
> > .mutex_sof = mt2712_mutex_sof,
> > @@ -400,6 +445,8 @@ static const struct of_device_id ddp_driver_dt_match[] 
> > = {
> >   .data = _ddp_driver_data},
> > { .compatible = "mediatek,mt2712-disp-mutex",
> >   .data = _ddp_driver_data},
> > +   { .compatible = "mediatek,mt8167-disp-mutex",
> > + .data = _ddp_driver_data},
> > { .compatible = "mediatek,mt8173-disp-mutex",
> >   .data = 

Re: [PATCH v2 3/5] drm/mediatek: add disp-color MT8167 support

2020-11-07 Thread Chun-Kuang Hu
Hi, Fabien:

Fabien Parent  於 2020年10月23日 週五 下午9:31寫道:
>
> Add support for disp-color on MT8167 SoC.

For this patch, applied to mediatek-drm-next [1], thanks.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

>
> Signed-off-by: Fabien Parent 
> Reviewed-by: Chun-Kuang Hu 
> ---
>
> Changelog:
>
> V2: No change
>
>  drivers/gpu/drm/mediatek/mtk_disp_color.c | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_color.c 
> b/drivers/gpu/drm/mediatek/mtk_disp_color.c
> index 3ae9c810845b..a1227cefbf31 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_color.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_color.c
> @@ -16,6 +16,7 @@
>
>  #define DISP_COLOR_CFG_MAIN0x0400
>  #define DISP_COLOR_START_MT27010x0f00
> +#define DISP_COLOR_START_MT81670x0400
>  #define DISP_COLOR_START_MT81730x0c00
>  #define DISP_COLOR_START(comp) ((comp)->data->color_offset)
>  #define DISP_COLOR_WIDTH(comp) (DISP_COLOR_START(comp) + 
> 0x50)
> @@ -148,6 +149,10 @@ static const struct mtk_disp_color_data 
> mt2701_color_driver_data = {
> .color_offset = DISP_COLOR_START_MT2701,
>  };
>
> +static const struct mtk_disp_color_data mt8167_color_driver_data = {
> +   .color_offset = DISP_COLOR_START_MT8167,
> +};
> +
>  static const struct mtk_disp_color_data mt8173_color_driver_data = {
> .color_offset = DISP_COLOR_START_MT8173,
>  };
> @@ -155,6 +160,8 @@ static const struct mtk_disp_color_data 
> mt8173_color_driver_data = {
>  static const struct of_device_id mtk_disp_color_driver_dt_match[] = {
> { .compatible = "mediatek,mt2701-disp-color",
>   .data = _color_driver_data},
> +   { .compatible = "mediatek,mt8167-disp-color",
> + .data = _color_driver_data},
> { .compatible = "mediatek,mt8173-disp-color",
>   .data = _color_driver_data},
> {},
> --
> 2.28.0
>


Re: [PATCH v2 1/5] dt-bindings: display: mediatek: disp: add documentation for MT8167 SoC

2020-11-07 Thread Chun-Kuang Hu
Hi, Fabien:

Rob Herring  於 2020年10月30日 週五 下午11:49寫道:
>
> On Fri, 23 Oct 2020 15:31:26 +0200, Fabien Parent wrote:
> > Add binding documentation for the MT8167 SoC

For this patch, applied to mediatek-drm-next [1], thanks.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

> >
> > Signed-off-by: Fabien Parent 
> > Reviewed-by: Chun-Kuang Hu 
> > ---
> >
> > Changelog:
> >
> > V2: No change
> >
> >  .../devicetree/bindings/display/mediatek/mediatek,disp.txt| 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
>
> Acked-by: Rob Herring 


Re: [PATCH 0/8] simplify ep_poll

2020-11-07 Thread Andrew Morton
On Fri,  6 Nov 2020 18:16:27 -0500 Soheil Hassas Yeganeh 
 wrote:

> From: Soheil Hassas Yeganeh 
> 
> This patch series is a follow up based on the suggestions and feedback by 
> Linus:
> https://lkml.kernel.org/r/CAHk-=wizk=oxuyqpbo8ms41w2pag1kniuv5wdd5qwl-gq1k...@mail.gmail.com

Al Viro has been playing in here as well - see the below, from
linux-next.

I think I'll leave it to you folks to sort this out, please.


commit 57804b1cc4616780c72a2d0930d1bd0d5bd3ed4c
Author: Al Viro 
AuthorDate: Mon Aug 31 13:41:30 2020 -0400
Commit: Al Viro 
CommitDate: Sun Oct 25 20:02:01 2020 -0400

lift locking/unlocking ep->mtx out of ep_{start,done}_scan()

get rid of depth/ep_locked arguments there and document
the kludge in ep_item_poll() that has lead to ep_locked existence in
the first place

Signed-off-by: Al Viro 

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ac996b959e94..f9c567af1f5f 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -554,20 +554,13 @@ static inline void ep_pm_stay_awake_rcu(struct epitem 
*epi)
rcu_read_unlock();
 }
 
-static void ep_start_scan(struct eventpoll *ep,
- int depth, bool ep_locked,
- struct list_head *txlist)
-{
-   lockdep_assert_irqs_enabled();
-
-   /*
-* We need to lock this because we could be hit by
-* eventpoll_release_file() and epoll_ctl().
-*/
-
-   if (!ep_locked)
-   mutex_lock_nested(>mtx, depth);
 
+/*
+ * ep->mutex needs to be held because we could be hit by
+ * eventpoll_release_file() and epoll_ctl().
+ */
+static void ep_start_scan(struct eventpoll *ep, struct list_head *txlist)
+{
/*
 * Steal the ready list, and re-init the original one to the
 * empty list. Also, set ep->ovflist to NULL so that events
@@ -576,6 +569,7 @@ static void ep_start_scan(struct eventpoll *ep,
 * because we want the "sproc" callback to be able to do it
 * in a lockless way.
 */
+   lockdep_assert_irqs_enabled();
write_lock_irq(>lock);
list_splice_init(>rdllist, txlist);
WRITE_ONCE(ep->ovflist, NULL);
@@ -583,7 +577,6 @@ static void ep_start_scan(struct eventpoll *ep,
 }
 
 static void ep_done_scan(struct eventpoll *ep,
-int depth, bool ep_locked,
 struct list_head *txlist)
 {
struct epitem *epi, *nepi;
@@ -624,9 +617,6 @@ static void ep_done_scan(struct eventpoll *ep,
list_splice(txlist, >rdllist);
__pm_relax(ep->ws);
write_unlock_irq(>lock);
-
-   if (!ep_locked)
-   mutex_unlock(>mtx);
 }
 
 static void epi_rcu_free(struct rcu_head *head)
@@ -763,11 +753,16 @@ static __poll_t ep_item_poll(const struct epitem *epi, 
poll_table *pt,
 
ep = epi->ffd.file->private_data;
poll_wait(epi->ffd.file, >poll_wait, pt);
-   locked = pt && (pt->_qproc == ep_ptable_queue_proc);
 
-   ep_start_scan(ep, depth, locked, );
+   // kludge: ep_insert() calls us with ep->mtx already locked
+   locked = pt && (pt->_qproc == ep_ptable_queue_proc);
+   if (!locked)
+   mutex_lock_nested(>mtx, depth);
+   ep_start_scan(ep, );
res = ep_read_events_proc(ep, , depth + 1);
-   ep_done_scan(ep, depth, locked, );
+   ep_done_scan(ep, );
+   if (!locked)
+   mutex_unlock(>mtx);
return res & epi->event.events;
 }
 
@@ -809,9 +804,11 @@ static __poll_t ep_eventpoll_poll(struct file *file, 
poll_table *wait)
 * Proceed to find out if wanted events are really available inside
 * the ready list.
 */
-   ep_start_scan(ep, 0, false, );
+   mutex_lock(>mtx);
+   ep_start_scan(ep, );
res = ep_read_events_proc(ep, , 1);
-   ep_done_scan(ep, 0, false, );
+   ep_done_scan(ep, );
+   mutex_unlock(>mtx);
return res;
 }
 
@@ -1573,15 +1570,13 @@ static int ep_send_events(struct eventpoll *ep,
 
init_poll_funcptr(, NULL);
 
-   ep_start_scan(ep, 0, false, );
+   mutex_lock(>mtx);
+   ep_start_scan(ep, );
 
/*
 * We can loop without lock because we are passed a task private list.
-* Items cannot vanish during the loop because ep_scan_ready_list() is
-* holding "mtx" during this call.
+* Items cannot vanish during the loop we are holding ep->mtx.
 */
-   lockdep_assert_held(>mtx);
-
list_for_each_entry_safe(epi, tmp, , rdllink) {
struct wakeup_source *ws;
__poll_t revents;
@@ -1609,9 +1604,8 @@ static int ep_send_events(struct eventpoll *ep,
 
/*
 * If the event mask intersect the caller-requested one,
-* deliver the event to userspace. Again, ep_scan_ready_list()
-* is holding ep->mtx, so no operations coming from userspace
-* can change the item.
+* deliver the 

[PATCH v2] HID: sony: support for ghlive ps3/wii u dongles

2020-11-07 Thread Pascal Giard
This commit adds support for the Guitar Hero Live PS3 and Wii U dongles.

These dongles require a "magic" USB control message [1] to be sent
approximately every 10 seconds otherwise the dongle will not report
events where the strumbar is hit while a fret is being held.

Also, inspired by a patch sent on linux-input by Sanjay Govind [2], the
accelerometer is mapped to ABS_RY for tilt.

Interestingly, the Wii U and PS3 dongles share the same VID and PID.

[1] https://github.com/ghlre/GHLtarUtility/
[2] https://marc.info/?l=linux-input=157242835928542=2

Signed-off-by: Pascal Giard 
---
differences from v1:
* Patches hid-sony instead of creating a new driver
* Changed memory allocation scheme in case of fail
---
 drivers/hid/Kconfig|   1 +
 drivers/hid/hid-ids.h  |   3 ++
 drivers/hid/hid-sony.c | 115 +
 3 files changed, 119 insertions(+)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 34f07371716d..e2df2ae112a5 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -897,6 +897,7 @@ config HID_SONY
  * Buzz controllers
  * Sony PS3 Blue-ray Disk Remote Control (Bluetooth)
  * Logitech Harmony adapter for Sony Playstation 3 (Bluetooth)
+ * Guitar Hero Live PS3 and Wii U guitar dongles
 
 config SONY_FF
bool "Sony PS2/3/4 accessories force feedback support" 
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 1c71a1aa76b2..e3a3942079cf 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -1060,6 +1060,9 @@
 #define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002
 #define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER0x1000
 
+#define USB_VENDOR_ID_SONY_GHLIVE  0x12ba
+#define USB_DEVICE_ID_SONY_PS3WIIU_GHLIVE_DONGLE   0x074b
+
 #define USB_VENDOR_ID_SINO_LITE0x1345
 #define USB_DEVICE_ID_SINO_LITE_CONTROLLER 0x3008
 
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 4c6ed6ef31f1..700bea6239f6 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -11,6 +11,7 @@
  *  Copyright (c) 2013 Colin Leitner 
  *  Copyright (c) 2014-2016 Frank Praznik 
  *  Copyright (c) 2018 Todd Kelner
+ *  Copyright (c) 2020 Pascal Giard 
  */
 
 /*
@@ -35,6 +36,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include "hid-ids.h"
@@ -56,6 +59,8 @@
 #define NSG_MR5U_REMOTE_BTBIT(14)
 #define NSG_MR7U_REMOTE_BTBIT(15)
 #define SHANWAN_GAMEPAD   BIT(16)
+#define GHL_GUITAR_PS3WIIUBIT(17)
+#define GHL_GUITAR_CONTROLLER BIT(18)
 
 #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
 #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT)
@@ -79,6 +84,17 @@
 #define NSG_MRXU_MAX_X 1667
 #define NSG_MRXU_MAX_Y 1868
 
+#define GHL_GUITAR_POKE_INTERVAL 10 /* In seconds */
+#define GHL_GUITAR_TILT_USAGE 44
+
+/* Magic value and data taken from GHLtarUtility:
+ * https://github.com/ghlre/GHLtarUtility/blob/master/PS3Guitar.cs
+ * Note: The Wii U and PS3 dongles happen to share the same!
+ */
+static const u16 ghl_ps3wiiu_magic_value = 0x201;
+static const char ghl_ps3wiiu_magic_data[] = {
+   0x02, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00
+};
 
 /* PS/3 Motion controller */
 static u8 motion_rdesc[] = {
@@ -578,6 +594,10 @@ struct sony_sc {
enum ds4_dongle_state ds4_dongle_state;
/* DS4 calibration data */
struct ds4_calibration_data ds4_calib_data[6];
+   /* GH Live */
+   struct timer_list ghl_poke_timer;
+   struct usb_ctrlrequest *ghl_cr;
+   u8 *ghl_databuf;
 };
 
 static void sony_set_leds(struct sony_sc *sc);
@@ -601,6 +621,87 @@ static inline void sony_schedule_work(struct sony_sc *sc,
}
 }
 
+static void ghl_magic_poke_cb(struct urb *urb)
+{
+   if (urb) {
+   /* Free sc->ghl_cr and sc->ghl_databuf allocated in
+* ghl_magic_poke()
+*/
+   kfree(urb->setup_packet);
+   kfree(urb->transfer_buffer);
+   }
+}
+
+static void ghl_magic_poke(struct timer_list *t)
+{
+   struct sony_sc *sc = from_timer(sc, t, ghl_poke_timer);
+
+   int ret;
+   unsigned int pipe;
+   struct urb *urb;
+   struct usb_device *usbdev = to_usb_device(sc->hdev->dev.parent->parent);
+   const u16 poke_size =
+   ARRAY_SIZE(ghl_ps3wiiu_magic_data);
+
+   pipe = usb_sndctrlpipe(usbdev, 0);
+
+   if (!sc->ghl_cr) {
+   sc->ghl_cr = kzalloc(sizeof(*sc->ghl_cr), GFP_ATOMIC);
+   if (!sc->ghl_cr)
+   goto resched;
+   }
+
+   if (!sc->ghl_databuf) {
+   sc->ghl_databuf = kzalloc(poke_size, GFP_ATOMIC);
+   if (!sc->ghl_databuf)
+   goto resched;
+   }
+
+   urb = usb_alloc_urb(0, GFP_ATOMIC);
+   if (!urb)
+   goto resched;
+
+   if (sc->quirks & 

[PATCH] MAINTAINERS: Fix 'W:' prefix in Invensense IMU entry

2020-11-07 Thread Jonathan Neuschäfer
The colon is missing, which can confuse scripts/parse-maintainers.pl.

Signed-off-by: Jonathan Neuschäfer 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e73636b75f29d..80defad325f31 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9160,7 +9160,7 @@ INVENSENSE ICM-426xx IMU DRIVER
 M: Jean-Baptiste Maneyrol 
 L: linux-...@vger.kernel.org
 S: Maintained
-W  https://invensense.tdk.com/
+W: https://invensense.tdk.com/
 F: Documentation/devicetree/bindings/iio/imu/invensense,icm42600.yaml
 F: drivers/iio/imu/inv_icm42600/

--
2.28.0



Re: [PATCH] mm/zsmalloc: include sparsemem.h for MAX_PHYSMEM_BITS

2020-11-07 Thread Stefan Agner
On 2020-11-08 01:56, Andrew Morton wrote:
> On Sat,  7 Nov 2020 16:22:06 +0100 Stefan Agner  wrote:
> 
>> Most architectures define MAX_PHYSMEM_BITS in asm/sparsemem.h and don't
>> include it in asm/pgtable.h. Include asm/sparsemem.h directly to get
>> the MAX_PHYSMEM_BITS define on all architectures.
>>
>> This fixes a crash when accessing zram on 32-bit ARM platform with LPAE and
>> more than 4GB of memory:
>>   Unable to handle kernel NULL pointer dereference at virtual address 
>> 
> 
> Mysterious.  Presumably without this include, some compilation unit is
> picking up the wrong value of MAX_PHYSMEM_BITS?  But I couldn't
> actually see where/how this occurs.  Can you please explain further?

Not sure if I got that right, but from what I understand if
MAX_PHYSMEM_BITS is not set in mm/zsmalloc.c it will set
MAX_PHYSMEM_BITS to BITS_PER_LONG. And this is 32-bit, too short when
LPAE is in use...

--
Stefan


Re: [PATCH 1/2] tomoyo: Convert get_user_pages*() to pin_user_pages*()

2020-11-07 Thread Tetsuo Handa
On 2020/11/08 4:17, John Hubbard wrote:
> On 11/7/20 1:04 AM, John Hubbard wrote:
>> On 11/7/20 12:24 AM, Souptick Joarder wrote:
>>> In 2019, we introduced pin_user_pages*() and now we are converting
>>> get_user_pages*() to the new API as appropriate. [1] & [2] could
>>> be referred for more information. This is case 5 as per document [1].
>>
>> It turns out that Case 5 can be implemented via a better pattern, as long
>> as we're just dealing with a page at a time, briefly:
>>
>> lock_page()
>> write to page's data
>> unlock_page()
>>
>> ...which neatly synchronizes with writeback and other fs activities.
> 
> Ahem, I left out a key step: set_page_dirty()!
> 
> lock_page()
> write to page's data
> set_page_dirty()
> unlock_page()
> 

Excuse me, but Documentation/core-api/pin_user_pages.rst says 
"CASE 5: Pinning in order to _write_ to the data within the page"
while tomoyo_dump_page() is for "_read_ the data within the page".
Do we want to convert to pin_user_pages_remote() or lock_page() ?


[PATCH v2] net: atlantic: Remove unnecessary conversion to bool

2020-11-07 Thread xiakaixu1987
From: Kaixu Xia 

The '!=' expression itself is bool, no need to convert it to bool.
Fix the following coccicheck warning:

./drivers/net/ethernet/aquantia/atlantic/aq_nic.c:1477:34-39: WARNING: 
conversion to bool not needed here

Reported-by: Tosk Robot 
Signed-off-by: Kaixu Xia 
---
 drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c 
b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index bf5e0e9bd0e2..6c049864dac0 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -1474,7 +1474,7 @@ int aq_nic_setup_tc_mqprio(struct aq_nic_s *self, u32 
tcs, u8 *prio_tc_map)
for (i = 0; i < sizeof(cfg->prio_tc_map); i++)
cfg->prio_tc_map[i] = cfg->tcs * i / 8;
 
-   cfg->is_qos = (tcs != 0 ? true : false);
+   cfg->is_qos = !!tcs;
cfg->is_ptp = (cfg->tcs <= AQ_HW_PTP_TC);
if (!cfg->is_ptp)
netdev_warn(self->ndev, "%s\n",
-- 
2.20.0



[PATCH net] net: udp: fix Fast/frag0 UDP GRO

2020-11-07 Thread Alexander Lobakin
While testing UDP GSO fraglists forwarding through driver that uses
Fast GRO (via napi_gro_frags()), I was observing lots of out-of-order
iperf packets:

[ ID] Interval   Transfer Bitrate Jitter
[SUM]  0.0-40.0 sec  12106 datagrams received out-of-order

Simple switch to napi_gro_receive() any other method without frag0
shortcut completely resolved them.

I've found that UDP GRO uses udp_hdr(skb) in its .gro_receive()
callback. While it's probably OK for non-frag0 paths (when all
headers or even the entire frame are already in skb->data), this
inline points to junk when using Fast GRO (napi_gro_frags() or
napi_gro_receive() with only Ethernet header in skb->data and all
the rest in shinfo->frags) and breaks GRO packet compilation and
the packet flow itself.
To support both modes, skb_gro_header_fast() + skb_gro_header_slow()
are typically used. UDP even has an inline helper that makes use of
them, udp_gro_udphdr(). Use that instead of troublemaking udp_hdr()
to get rid of the out-of-order delivers.

Present since the introduction of plain UDP GRO in 5.0-rc1.

Fixes: e20cf8d3f1f7 ("udp: implement GRO for plain UDP sockets.")
Signed-off-by: Alexander Lobakin 
---
 net/ipv4/udp_offload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index e67a66fbf27b..13740e9fe6ec 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -366,7 +366,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff 
*skb,
 static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
   struct sk_buff *skb)
 {
-   struct udphdr *uh = udp_hdr(skb);
+   struct udphdr *uh = udp_gro_udphdr(skb);
struct sk_buff *pp = NULL;
struct udphdr *uh2;
struct sk_buff *p;
-- 
2.29.2




Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread John Hubbard

On 11/7/20 4:24 PM, Randy Dunlap wrote:

On 11/7/20 4:03 PM, John Hubbard wrote:

On 11/7/20 2:20 PM, Randy Dunlap wrote:

On 11/7/20 11:16 AM, John Hubbard wrote:

On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:

...

OK, thanks, I see how you get that list now.

JFTR, those are not 42 independent users of DEBUG_FS. There are lots of &
and a few ||s in that list.



You are right, and that means that I have to withdraw my earlier claim that
"42 committers" made such a decision.



xconfig shows this for DEBUG_FS: (13 selects for x86_64 allmodconfig)



...maybe only 13 committers and dependency chain, then. :)


thanks,
--
John Hubbard
NVIDIA


[PATCH v2] net: ipv4: remove redundant initialization in inet_rtm_deladdr

2020-11-07 Thread Menglong Dong
The initialization for 'err' with '-EINVAL' is redundant and
can be removed, as it is updated soon.

Changes since v1:
- Remove redundant empty line

Signed-off-by: Menglong Dong 
---
 net/ipv4/devinet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 123a6d39438f..43e04382c593 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -650,8 +650,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct 
nlmsghdr *nlh,
struct in_device *in_dev;
struct ifaddrmsg *ifm;
struct in_ifaddr *ifa;
-
-   int err = -EINVAL;
+   int err;
 
ASSERT_RTNL();
 
-- 
2.29.2



[PATCH v3] applesmc: Re-work SMC comms

2020-11-07 Thread Brad Campbell
G'day Henrik,

I noticed you'd also loosened up the requirement for SMC_STATUS_BUSY in 
read_smc(). I assume
that causes problems on the early Macbook. This is revised on the one sent 
earlier.
If you could test this on your Air1,1 it'd be appreciated.


Commit fff2d0f701e6 ("hwmon: (applesmc) avoid overlong udelay()") introduced
an issue whereby communication with the SMC became unreliable with write
errors like :

[  120.378614] applesmc: send_byte(0x00, 0x0300) fail: 0x40
[  120.378621] applesmc: LKSB: write data fail
[  120.512782] applesmc: send_byte(0x00, 0x0300) fail: 0x40
[  120.512787] applesmc: LKSB: write data fail

The original code appeared to be timing sensitive and was not reliable with
the timing changes in the aforementioned commit.

This patch re-factors the SMC communication to remove the timing 
dependencies and restore function with the changes previously committed.

Tested on : MacbookAir6,2 MacBookPro11,1 iMac12,2

Fixes: fff2d0f701e6 ("hwmon: (applesmc) avoid overlong udelay()")
Reported-by: Andreas Kemnade 
Tested-by: Andreas Kemnade  # MacBookAir6,2
Acked-by: Arnd Bergmann 
Signed-off-by: Brad Campbell 
Signed-off-by: Henrik Rydberg 

---
Changelog : 
v1 : Inital attempt
v2 : Address logic and coding style
v3 : Removed some debug hangover. Added tested-by. Modifications for 
MacBookAir1,1

diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index a18887990f4a..3e968abb37aa 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* data port used by Apple SMC */
 #define APPLESMC_DATA_PORT 0x300
@@ -42,6 +43,11 @@
 
 #define APPLESMC_MAX_DATA_LENGTH 32
 
+/* Apple SMC status bits */
+#define SMC_STATUS_AWAITING_DATA  BIT(0) /* SMC has data waiting */
+#define SMC_STATUS_IB_CLOSED  BIT(1) /* Will ignore any input */
+#define SMC_STATUS_BUSY   BIT(2) /* Command in progress */
+
 /* wait up to 128 ms for a status change. */
 #define APPLESMC_MIN_WAIT  0x0010
 #define APPLESMC_RETRY_WAIT0x0100
@@ -151,65 +157,73 @@ static unsigned int key_at_index;
 static struct workqueue_struct *applesmc_led_wq;
 
 /*
- * wait_read - Wait for a byte to appear on SMC port. Callers must
- * hold applesmc_lock.
+ * Wait for specific status bits with a mask on the SMC
+ * Used before and after writes, and before reads
  */
-static int wait_read(void)
+
+static int wait_status(u8 val, u8 mask)
 {
unsigned long end = jiffies + (APPLESMC_MAX_WAIT * HZ) / USEC_PER_SEC;
u8 status;
int us;
 
+   udelay(APPLESMC_MIN_WAIT);
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
-   usleep_range(us, us * 16);
status = inb(APPLESMC_CMD_PORT);
-   /* read: wait for smc to settle */
-   if (status & 0x01)
+   if ((status & mask) == val)
return 0;
/* timeout: give up */
if (time_after(jiffies, end))
break;
+   usleep_range(us, us * 16);
}
-
-   pr_warn("wait_read() fail: 0x%02x\n", status);
return -EIO;
 }
 
 /*
- * send_byte - Write to SMC port, retrying when necessary. Callers
+ * send_byte_data - Write to SMC data port. Callers
  * must hold applesmc_lock.
+ * Parameter skip must be true on the last write of any
+ * command or it'll time out.
  */
-static int send_byte(u8 cmd, u16 port)
+
+static int send_byte_data(u8 cmd, u16 port, bool skip)
 {
-   u8 status;
-   int us;
-   unsigned long end = jiffies + (APPLESMC_MAX_WAIT * HZ) / USEC_PER_SEC;
+   int ret;
 
+   ret = wait_status(SMC_STATUS_BUSY, SMC_STATUS_BUSY | 
SMC_STATUS_IB_CLOSED);
+   if (ret)
+   return ret;
outb(cmd, port);
-   for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
-   usleep_range(us, us * 16);
-   status = inb(APPLESMC_CMD_PORT);
-   /* write: wait for smc to settle */
-   if (status & 0x02)
-   continue;
-   /* ready: cmd accepted, return */
-   if (status & 0x04)
-   return 0;
-   /* timeout: give up */
-   if (time_after(jiffies, end))
-   break;
-   /* busy: long wait and resend */
-   udelay(APPLESMC_RETRY_WAIT);
-   outb(cmd, port);
-   }
+   return wait_status(skip ? 0 : SMC_STATUS_BUSY, SMC_STATUS_BUSY);
+}
 
-   pr_warn("send_byte(0x%02x, 0x%04x) fail: 0x%02x\n", cmd, port, status);
-   return -EIO;
+static int send_byte(u8 cmd, u16 port)
+{
+   return send_byte_data(cmd, port, false);
 }
 
+/*
+ * send_command - Write a command to the SMC. Callers must hold applesmc_lock.
+ * If SMC is in undefined state, any new command write resets the state 
machine.
+ */
+
 static int send_command(u8 cmd)
 {
-   return send_byte(cmd, 

Re: [PATCH] scsi: core: fix -Wformat

2020-11-07 Thread Nathan Chancellor
On Sat, Nov 07, 2020 at 12:11:32AM -0800, Nick Desaulniers wrote:
> Clang is more aggressive about -Wformat warnings when the format flag
> specifies a type smaller than the parameter. Turns out, struct
> Scsi_Host's member can_queue is actually an int. Fixes:
> 
> warning: format specifies type 'short' but the argument has type 'int'
> [-Wformat]
> shost_rd_attr(can_queue, "%hd\n");
> ^
>   %d
> Link: https://github.com/ClangBuiltLinux/linux/issues/378
> Signed-off-by: Nick Desaulniers 

Reviewed-by: Nathan Chancellor 

> ---
>  drivers/scsi/scsi_sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index d6e344fa33ad..b6378c8ca783 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -370,7 +370,7 @@ static DEVICE_ATTR(eh_deadline, S_IRUGO | S_IWUSR, 
> show_shost_eh_deadline, store
>  
>  shost_rd_attr(unique_id, "%u\n");
>  shost_rd_attr(cmd_per_lun, "%hd\n");
> -shost_rd_attr(can_queue, "%hd\n");
> +shost_rd_attr(can_queue, "%d\n");
>  shost_rd_attr(sg_tablesize, "%hu\n");
>  shost_rd_attr(sg_prot_tablesize, "%hu\n");
>  shost_rd_attr(unchecked_isa_dma, "%d\n");
> -- 
> 2.29.2.222.g5d2a92d10f8-goog
> 


Re: [PATCH] mm/zsmalloc: include sparsemem.h for MAX_PHYSMEM_BITS

2020-11-07 Thread Andrew Morton
On Sat,  7 Nov 2020 16:22:06 +0100 Stefan Agner  wrote:

> Most architectures define MAX_PHYSMEM_BITS in asm/sparsemem.h and don't
> include it in asm/pgtable.h. Include asm/sparsemem.h directly to get
> the MAX_PHYSMEM_BITS define on all architectures.
> 
> This fixes a crash when accessing zram on 32-bit ARM platform with LPAE and
> more than 4GB of memory:
>   Unable to handle kernel NULL pointer dereference at virtual address 

Mysterious.  Presumably without this include, some compilation unit is
picking up the wrong value of MAX_PHYSMEM_BITS?  But I couldn't
actually see where/how this occurs.  Can you please explain further?



[PATCH v2 net] ethtool: netlink: add missing netdev_features_change() call

2020-11-07 Thread Alexander Lobakin
After updating userspace Ethtool from 5.7 to 5.9, I noticed that
NETDEV_FEAT_CHANGE is no more raised when changing netdev features
through Ethtool.
That's because the old Ethtool ioctl interface always calls
netdev_features_change() at the end of user request processing to
inform the kernel that our netdevice has some features changed, but
the new Netlink interface does not. Instead, it just notifies itself
with ETHTOOL_MSG_FEATURES_NTF.
Replace this ethtool_notify() call with netdev_features_change(), so
the kernel will be aware of any features changes, just like in case
with the ioctl interface. This does not omit Ethtool notifications,
as Ethtool itself listens to NETDEV_FEAT_CHANGE and drops
ETHTOOL_MSG_FEATURES_NTF on it
(net/ethtool/netlink.c:ethnl_netdev_event()).

>From v1 [1]:
- dropped extra new line as advised by Jakub;
- no functional changes.

[1] 
https://lore.kernel.org/netdev/alzxq2o5uutvhcfngoiggj8vj3kgo5yiwanqjh0...@cp3-web-009.plabs.ch

Fixes: 0980bfcd6954 ("ethtool: set netdev features with FEATURES_SET request")
Signed-off-by: Alexander Lobakin 
---
 net/ethtool/features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ethtool/features.c b/net/ethtool/features.c
index 8ee4cdbd6b82..1c9f4df273bd 100644
--- a/net/ethtool/features.c
+++ b/net/ethtool/features.c
@@ -280,7 +280,7 @@ int ethnl_set_features(struct sk_buff *skb, struct 
genl_info *info)
  active_diff_mask, compact);
}
if (mod)
-   ethtool_notify(dev, ETHTOOL_MSG_FEATURES_NTF, NULL);
+   netdev_features_change(dev);
 
 out_rtnl:
rtnl_unlock();
-- 
2.29.2




Re: [PATCH] net: ipv4: remove redundant initialization in inet_rtm_deladdr

2020-11-07 Thread Menglong Dong
Dear Jakub,

On Sun, Nov 8, 2020 at 7:48 AM Jakub Kicinski  wrote:
>
> On Fri,  6 Nov 2020 01:42:37 -0500 menglong8.d...@gmail.com wrote:
> > From: Menglong Dong 
> >
> > The initialization for 'err' with '-EINVAL' is redundant and
> > can be removed, as it is updated soon.
> >
> > Signed-off-by: Menglong Dong 
>
> How many changes like this are there in the kernel right now?
>
> I'm afraid that if there are too many it's not worth the effort.
>
> Also - what tool do you use to find those, we need to make sure new
> instances don't get into the tree.
>

I didn't use any tools. Maybe some general tools, such as kw,
coverity, coccicheck,
are able to find these changes(as far as I know, they can).

In fact, I find these changes by my eyes. I believe 'err' is the most
likely victim
and checked every usage of it in 'net' directory. Here are all the
changes I found,
and I think there won't be too many.

Cheers,
Menglong Dong


[PATCH] docs: filesystems: Reduce ext2.rst to one top-level heading

2020-11-07 Thread Jonathan Neuschäfer
This prevents the other headings like "Options" and "Specification" from
leaking out and being listed separately in the table of contents.

Signed-off-by: Jonathan Neuschäfer 
---
 Documentation/filesystems/ext2.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/filesystems/ext2.rst 
b/Documentation/filesystems/ext2.rst
index d83dbbb162e20..c2fce22cfd035 100644
--- a/Documentation/filesystems/ext2.rst
+++ b/Documentation/filesystems/ext2.rst
@@ -1,6 +1,7 @@
 .. SPDX-License-Identifier: GPL-2.0


+==
 The Second Extended Filesystem
 ==

--
2.28.0



Re: [PATCH] arm64: dts: rockchip: Reorder LED triggers from mmc devices on rk3399-roc-pc.

2020-11-07 Thread Heiko Stuebner
On Wed, 4 Nov 2020 20:29:31 +0100, Markus Reichl wrote:
> After patch [1] SD-card becomes mmc1 and eMMC becomes mmc2.
> Correct trigger of LEDs accordingly.
> 
> [1]
> https://patchwork.kernel.org/patch/11881427

Applied, thanks!

[1/1] arm64: dts: rockchip: Reorder LED triggers from mmc devices on 
rk3399-roc-pc.
  commit: 7327c8b98e2e14c47021eea14d1ab268086a6408

Best regards,
-- 
Heiko Stuebner 


Re: [PATCH] arm64: dts: rockchip: add adc joystick to Odroid Go Advance

2020-11-07 Thread Heiko Stuebner
Am Sonntag, 8. November 2020, 01:31:19 CET schrieb Heiko Stuebner:
> On Sat, 4 Jul 2020 00:14:13 +0200, Heiko Stuebner wrote:
> > Add the now usable adc-joystick node that describes the analog
> > joystick connected to two saradc channels from the rk3326 soc.
> 
> Applied, thanks!
> 
> [1/1] arm64: dts: rockchip: add adc joystick to Odroid Go Advance
>   commit: c20e6dd9a953d62f14399dabf457dce61dd5611f

forgot to add, I fixed the things Johans commented on when applying

> 
> Best regards,
> 






Re: [PATCH] dt-bindings: arm: rockchip: Add Kobol Helios64

2020-11-07 Thread Heiko Stuebner
On Mon, 2 Nov 2020 16:06:58 +0100, Uwe Kleine-König wrote:
> Document the new board by Kobol introduced recently in
> rockchip/rk3399-kobol-helios64.dts.

Applied, thanks!

[1/1] dt-bindings: arm: rockchip: Add Kobol Helios64
  commit: 62dbf80fc581a8eed7288ed7aca24446054eb616

Best regards,
-- 
Heiko Stuebner 


Re: [PATCH] arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399 boards.

2020-11-07 Thread Heiko Stuebner
On Wed, 4 Nov 2020 17:23:55 +0100, Markus Reichl wrote:
> Recently introduced async probe on mmc devices can shuffle block IDs.
> Pin them to fixed values to ease booting in environments where UUIDs
> are not practical. Use newly introduced aliases for mmcblk devices from [1].
> 
> [1]
> https://patchwork.kernel.org/patch/11747669/

Applied, thanks!

[1/1] arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399 
boards.
  commit: 0011c6d182774fc781fb9e115ebe8baa356029ae

Best regards,
-- 
Heiko Stuebner 


Re: [PATCH] arm64: dts: rockchip: add adc joystick to Odroid Go Advance

2020-11-07 Thread Heiko Stuebner
On Sat, 4 Jul 2020 00:14:13 +0200, Heiko Stuebner wrote:
> Add the now usable adc-joystick node that describes the analog
> joystick connected to two saradc channels from the rk3326 soc.

Applied, thanks!

[1/1] arm64: dts: rockchip: add adc joystick to Odroid Go Advance
  commit: c20e6dd9a953d62f14399dabf457dce61dd5611f

Best regards,
-- 
Heiko Stuebner 


[PATCH v4.19] tools: perf: Fix build error in v4.19.y

2020-11-07 Thread Guenter Roeck
perf may fail to build in v4.19.y with the following error.

util/evsel.c: In function ‘perf_evsel__exit’:
util/util.h:25:28: error:
passing argument 1 of ‘free’ discards ‘const’ qualifier from pointer 
target type

This is observed (at least) with gcc v6.5.0. The underlying problem is
the following statement.
zfree(>pmu_name);
evsel->pmu_name is decared 'const *'. zfree in turn is defined as
#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
and thus passes the const * to free(). The problem is not seen
in the upstream kernel since zfree() has been rewritten there.

The problem has been introduced into v4.19.y with the backport of upstream
commit d4953f7ef1a2 (perf parse-events: Fix 3 use after frees found with
clang ASAN).

One possible fix of this problem would be to not declare pmu_name
as const. This patch chooses to typecast the parameter of zfree()
to void *, following the guidance from the upstream kernel which
does the same since commit 7f7c536f23e6a ("tools lib: Adopt
zalloc()/zfree() from tools/perf")

Fixes: a0100a363098 ("perf parse-events: Fix 3 use after frees found with clang 
ASAN")
Signed-off-by: Guenter Roeck 
---
This patch only applies to v4.19.y and has no upstream equivalent.

 tools/perf/util/util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index dc58254a2b69..8c01b2cfdb1a 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -22,7 +22,7 @@ static inline void *zalloc(size_t size)
return calloc(1, size);
 }
 
-#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
+#define zfree(ptr) ({ free((void *)*ptr); *ptr = NULL; })
 
 struct dirent;
 struct nsinfo;
-- 
2.17.1



Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread Randy Dunlap
On 11/7/20 4:03 PM, John Hubbard wrote:
> On 11/7/20 2:20 PM, Randy Dunlap wrote:
>> On 11/7/20 11:16 AM, John Hubbard wrote:
>>> On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:
> -Original Message-
> From: John Hubbard [mailto:jhubb...@nvidia.com]
>>> ...
>>     config GUP_BENCHMARK
>>     bool "Enable infrastructure for get_user_pages() and related 
>> calls
> benchmarking"
>> +    depends on DEBUG_FS
>
>
> I think "select DEBUG_FS" is better here. "depends on" has the obnoxious
> behavior of hiding the choice from you, if the dependencies aren't 
> already met.
> Whereas what the developer *really* wants is a no-nonsense activation of 
> the
> choice: "enable GUP_BENCHMARK and the debug fs that it requires".
>

 To some extent, I agree with you. But I still think here it is better to 
 use "depends on".
 According to
 https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt

  select should be used with care. select will force
  a symbol to a value without visiting the dependencies.
  By abusing select you are able to select a symbol FOO even
  if FOO depends on BAR that is not set.
  In general use select only for non-visible symbols
  (no prompts anywhere) and for symbols with no dependencies.
  That will limit the usefulness but on the other hand avoid
  the illegal configurations all over.

 On the other hand, in kernel there are 78 "depends on DEBUG_FS" and
 only 14 "select DEBUG_FS".

>>>
>>> You're not looking at the best statistics. Go look at what *already* selects
>>> DEBUG_FS, and you'll find about 50 items.
>>
>> Sorry, I'm not following you. I see the same 14 "select DEBUG_FS" as Barry.
> 
> I ran make menuconfig, and looked at it. Because I want to see the true end 
> result,
> and I didn't trust my grep use, given that the system has interlocking 
> dependencies,
> and I think one select could end up activating others (yes?).
> 
> And sure enough, there are 42 items listed, here they are, cleaned up so that 
> there
> is one per line:
> 
> ZSMALLOC_STAT [=n]
> ZSMALLOC [=m]
> BCACHE_CLOSURES_DEBUG [=n]
> MD [=y]
> BCACHE [=n]
> DVB_C8SECTPFE [=n]
> MEDIA_SUPPORT [=m]
> MEDIA_PLATFORM_SUPPORT [=y]
> DVB_PLATFORM_DRIVERS [=n]
> PINCT
> DRM_I915_DEBUG [=n]
> HAS_IOMEM [=y]
> EXPERT [=y]
> DRM_I915 [=m]
> EDAC_DEBUG [=n]
> EDAC [=y]
> SUNRPC_DEBUG [=n]
> NETWORK_FILESYSTEMS [=y]
> SUNRPC [=m]
> SYSCTL [=y]
> PAGE_OWNER [=n]
> DEBUG_KERNEL [=y]
> STACKTRACE_SUPPORT [=y]
> DEBUG_KMEMLEAK [=n]
> DEBUG_KERNEL [=y]
> HAVE_DEBUG_KMEMLEAK [=y]
> BLK_DEV_IO_TRACE [=n]
> TRACING_SUPPORT [=y]
> FTRACE [=y]
> SYSFS [=y]
> BLOCK [=y]
> PUNIT_ATOM_DEBUG [=n]
> PCI [=y]
> NOTIFIER_ERROR_INJECTION [=n]
> DEBUG_KERNEL [=y]
> FAIL_FUTEX [=n]
> FAULT_INJECTION [=n]
> FUTEX [=y]
> KCOV [=n]
> ARCH_HAS_KCOV [=y]
> CC_HAS_SANCOV_TRACE_PC [=y]
> GCC_PLUGINS
> 

OK, thanks, I see how you get that list now.

JFTR, those are not 42 independent users of DEBUG_FS. There are lots of &
and a few ||s in that list.


xconfig shows this for DEBUG_FS: (13 selects for x86_64 allmodconfig)

Selected by [y]:
- PAGE_OWNER [=y] && DEBUG_KERNEL [=y] && STACKTRACE_SUPPORT [=y]
- DEBUG_KMEMLEAK [=y] && DEBUG_KERNEL [=y] && HAVE_DEBUG_KMEMLEAK [=y]
- BLK_DEV_IO_TRACE [=y] && TRACING_SUPPORT [=y] && FTRACE [=y] && SYSFS [=y] && 
BLOCK [=y]
- FAIL_FUTEX [=y] && FAULT_INJECTION [=y] && FUTEX [=y]
- KCOV [=y] && ARCH_HAS_KCOV [=y] && (CC_HAS_SANCOV_TRACE_PC [=y] || 
GCC_PLUGINS [=n])
Selected by [m]:
- ZSMALLOC_STAT [=y] && ZSMALLOC [=m]
- BCACHE_CLOSURES_DEBUG [=y] && MD [=y] && BCACHE [=m]
- DVB_C8SECTPFE [=m] && MEDIA_SUPPORT [=m] && MEDIA_PLATFORM_SUPPORT [=y] && 
DVB_PLATFORM_DRIVERS [=y] && PINCTRL [=y] && DVB_CORE [=m] && I2C [=y] && 
(ARCH_STI || ARCH_MULTIPLATFORM || COMPILE_TEST [=y])
- DRM_I915_DEBUG [=y] && HAS_IOMEM [=y] && EXPERT [=y] && DRM_I915 [=m]
- EDAC_DEBUG [=y] && EDAC [=m]
- SUNRPC_DEBUG [=y] && NETWORK_FILESYSTEMS [=y] && SUNRPC [=m] && SYSCTL [=y]
- PUNIT_ATOM_DEBUG [=m] && PCI [=y]
- NOTIFIER_ERROR_INJECTION [=m] && DEBUG_KERNEL [=y]

Some other $ARCH could be more...

>>
>> In general we don't want any one large "feature" (or subsystem) to be enabled
>> by one driver. If someone has gone to the trouble to disable DEBUG_FS (or 
>> whatever),
>> then a different Kconfig symbol shouldn't undo that.
>>
> 
> I agree with the "in general" point, yes. And my complaint is really 80% due 
> to the
> very unhappy situation with Kconfig, where we seem to get a choice between 
> *hiding*
> a feature, or forcing a dependency break. What we really want is a way to 
> indicate
> a dependency that doesn't hide entire features, unless we want that. (Maybe I 
> should
> attempt to get into the implementation, although I suspect it's harder than I
> realize.)
> 
> But the other 20% of my complaint is, given what we have, I think the 

Re: [PATCH net-next 1/1] stmmac: intel: change all EHL/TGL to auto detect phy addr

2020-11-07 Thread patchwork-bot+netdevbpf
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Fri,  6 Nov 2020 17:43:41 +0800 you wrote:
> From: Voon Weifeng 
> 
> Set all EHL/TGL phy_addr to -1 so that the driver will automatically
> detect it at run-time by probing all the possible 32 addresses.
> 
> Signed-off-by: Voon Weifeng 
> Signed-off-by: Wong Vee Khee 
> 
> [...]

Here is the summary with links:
  - [net-next,1/1] stmmac: intel: change all EHL/TGL to auto detect phy addr
https://git.kernel.org/netdev/net-next/c/bff6f1db91e3

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




Re: [PATCH] applesmc: Re-work SMC comms v2

2020-11-07 Thread Brad Campbell
On 8/11/20 5:31 am, Henrik Rydberg wrote:
> On 2020-11-06 21:02, Henrik Rydberg wrote:
>>> So as it stands, it does not work at all. I will continue to check another 
>>> machine, and see if I can get something working.
>>
>> On the MacBookAir3,1 the situation is somewhat better.
>>
>> The first three tree positions result in zero failures and 10 reads per 
>> second. The fourth yields zero failues and 11 reads per second, within the 
>> margin of similarity.
>>
>> So, the patch appears to have no apparent effect on the 3,1 series.
>>
>> Now onto fixing the 1,1 behavior.
> 
> Hi again,
> 
> This patch, v3, works for me, on both MBA1,1 and MBA3,1. Both machines yields 
> 25 reads per second.
> 
> It turns out that the origin code has a case that was not carried over to the 
> v2 patch; the command byte needs to be resent upon the wrong status code. I 
> added that back. Also, there seems to be a basic response time that needs to 
> be respected, so I added back a small fixed delay after each write operation. 
> I also took the liberty to reduce the number of status reads, and clean up 
> error handling. Checkpatch is happy with this version.
> 
> The code obviously needs to be retested on the other machines, but the logic 
> still follows what you wrote, Brad, and I have also checked it against the 
> VirtualSMC code. It appears to make sense, so hopefully there wont be 
> additional issues.
> 
> Thanks,
> Henrik
> 

G'day Henrik,

Which kernel was this based on? It won't apply to my 5.9 tree.

I assume the sprinkling of udelay(APPLESMC_MIN_WAIT) means the SMC is
slow in getting its status register set up. Could we instead just put
a single one of those up-front in wait_status?

Any chance you could try this one? I've added a retry to send_command and 
added a single global APPLESMC_MIN_WAIT before each status read.

>From looking at your modified send_command, it appears the trigger for a 
retry is sending a command and the SMC doing absolutely nothing. This
should do the same thing.

Interestingly enough, by adding the udelay to wait_status on my machine I've
gone from 24 reads/s to 50 reads/s.

I've left out the remainder of the cleanups. Once we get a minimally working
patch I was going to look at a few cleanups, and I have some patches pending
to allow writing to the SMC from userspace (for setting BCLM and BFCL mainly)


diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index a18887990f4a..2190de78b5f5 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* data port used by Apple SMC */
 #define APPLESMC_DATA_PORT 0x300
@@ -42,6 +43,11 @@
 
 #define APPLESMC_MAX_DATA_LENGTH 32
 
+/* Apple SMC status bits */
+#define SMC_STATUS_AWAITING_DATA  BIT(0) /* SMC has data waiting */
+#define SMC_STATUS_IB_CLOSED  BIT(1) /* Will ignore any input */
+#define SMC_STATUS_BUSY   BIT(2) /* Command in progress */
+
 /* wait up to 128 ms for a status change. */
 #define APPLESMC_MIN_WAIT  0x0010
 #define APPLESMC_RETRY_WAIT0x0100
@@ -151,65 +157,73 @@ static unsigned int key_at_index;
 static struct workqueue_struct *applesmc_led_wq;
 
 /*
- * wait_read - Wait for a byte to appear on SMC port. Callers must
- * hold applesmc_lock.
+ * Wait for specific status bits with a mask on the SMC
+ * Used before and after writes, and before reads
  */
-static int wait_read(void)
+
+static int wait_status(u8 val, u8 mask)
 {
unsigned long end = jiffies + (APPLESMC_MAX_WAIT * HZ) / USEC_PER_SEC;
u8 status;
int us;
 
+   udelay(APPLESMC_MIN_WAIT);
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
-   usleep_range(us, us * 16);
status = inb(APPLESMC_CMD_PORT);
-   /* read: wait for smc to settle */
-   if (status & 0x01)
+   if ((status & mask) == val)
return 0;
/* timeout: give up */
if (time_after(jiffies, end))
break;
+   usleep_range(us, us * 16);
}
-
-   pr_warn("wait_read() fail: 0x%02x\n", status);
return -EIO;
 }
 
 /*
- * send_byte - Write to SMC port, retrying when necessary. Callers
+ * send_byte_data - Write to SMC data port. Callers
  * must hold applesmc_lock.
+ * Parameter skip must be true on the last write of any
+ * command or it'll time out.
  */
-static int send_byte(u8 cmd, u16 port)
+
+static int send_byte_data(u8 cmd, u16 port, bool skip)
 {
-   u8 status;
-   int us;
-   unsigned long end = jiffies + (APPLESMC_MAX_WAIT * HZ) / USEC_PER_SEC;
+   int ret;
 
+   ret = wait_status(SMC_STATUS_BUSY, SMC_STATUS_BUSY | 
SMC_STATUS_IB_CLOSED);
+   if (ret)
+   return ret;
outb(cmd, port);
-   for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
-   usleep_range(us, us * 16);
-   status = 

Re: [RFC net-next 00/28] ndo_ioctl rework

2020-11-07 Thread Jakub Kicinski
On Fri,  6 Nov 2020 23:17:15 +0100 Arnd Bergmann wrote:
> Any suggestions on how to proceed? I think the ndo_siocdevprivate
> change is the most interesting here, and I would like to get
> that merged.

Splitting out / eliminating ioctl pass-thry in general seems like 
a nice clean up. How did you get the ndo_eth_ioctl patch done, was 
it manual work?

> For the wireless drivers, removing the old drivers
> instead of just the dead code might be an alternative, depending
> on whether anyone thinks there might still be users.

Dunno if you want to dig into removal with a series like this, 
anything using ioctls will be pretty old (with the exception 
of what you separated into ndo_eth_ioctl). You may get bogged 
down.


Re: [PATCH] mm/gup_benchmark: GUP_BENCHMARK depends on DEBUG_FS

2020-11-07 Thread John Hubbard

On 11/7/20 2:20 PM, Randy Dunlap wrote:

On 11/7/20 11:16 AM, John Hubbard wrote:

On 11/7/20 11:05 AM, Song Bao Hua (Barry Song) wrote:

-Original Message-
From: John Hubbard [mailto:jhubb...@nvidia.com]

...

    config GUP_BENCHMARK
    bool "Enable infrastructure for get_user_pages() and related calls

benchmarking"

+    depends on DEBUG_FS



I think "select DEBUG_FS" is better here. "depends on" has the obnoxious
behavior of hiding the choice from you, if the dependencies aren't already met.
Whereas what the developer *really* wants is a no-nonsense activation of the
choice: "enable GUP_BENCHMARK and the debug fs that it requires".



To some extent, I agree with you. But I still think here it is better to use 
"depends on".
According to
https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt

 select should be used with care. select will force
 a symbol to a value without visiting the dependencies.
 By abusing select you are able to select a symbol FOO even
 if FOO depends on BAR that is not set.
 In general use select only for non-visible symbols
 (no prompts anywhere) and for symbols with no dependencies.
 That will limit the usefulness but on the other hand avoid
 the illegal configurations all over.

On the other hand, in kernel there are 78 "depends on DEBUG_FS" and
only 14 "select DEBUG_FS".



You're not looking at the best statistics. Go look at what *already* selects
DEBUG_FS, and you'll find about 50 items.


Sorry, I'm not following you. I see the same 14 "select DEBUG_FS" as Barry.


I ran make menuconfig, and looked at it. Because I want to see the true end 
result,
and I didn't trust my grep use, given that the system has interlocking 
dependencies,
and I think one select could end up activating others (yes?).

And sure enough, there are 42 items listed, here they are, cleaned up so that 
there
is one per line:

ZSMALLOC_STAT [=n]
ZSMALLOC [=m]
BCACHE_CLOSURES_DEBUG [=n]
MD [=y]
BCACHE [=n]
DVB_C8SECTPFE [=n]
MEDIA_SUPPORT [=m]
MEDIA_PLATFORM_SUPPORT [=y]
DVB_PLATFORM_DRIVERS [=n]
PINCT
DRM_I915_DEBUG [=n]
HAS_IOMEM [=y]
EXPERT [=y]
DRM_I915 [=m]
EDAC_DEBUG [=n]
EDAC [=y]
SUNRPC_DEBUG [=n]
NETWORK_FILESYSTEMS [=y]
SUNRPC [=m]
SYSCTL [=y]
PAGE_OWNER [=n]
DEBUG_KERNEL [=y]
STACKTRACE_SUPPORT [=y]
DEBUG_KMEMLEAK [=n]
DEBUG_KERNEL [=y]
HAVE_DEBUG_KMEMLEAK [=y]
BLK_DEV_IO_TRACE [=n]
TRACING_SUPPORT [=y]
FTRACE [=y]
SYSFS [=y]
BLOCK [=y]
PUNIT_ATOM_DEBUG [=n]
PCI [=y]
NOTIFIER_ERROR_INJECTION [=n]
DEBUG_KERNEL [=y]
FAIL_FUTEX [=n]
FAULT_INJECTION [=n]
FUTEX [=y]
KCOV [=n]
ARCH_HAS_KCOV [=y]
CC_HAS_SANCOV_TRACE_PC [=y]
GCC_PLUGINS




In general we don't want any one large "feature" (or subsystem) to be enabled
by one driver. If someone has gone to the trouble to disable DEBUG_FS (or 
whatever),
then a different Kconfig symbol shouldn't undo that.



I agree with the "in general" point, yes. And my complaint is really 80% due to 
the
very unhappy situation with Kconfig, where we seem to get a choice between 
*hiding*
a feature, or forcing a dependency break. What we really want is a way to 
indicate
a dependency that doesn't hide entire features, unless we want that. (Maybe I 
should
attempt to get into the implementation, although I suspect it's harder than I
realize.)

But the other 20% of my complaint is, given what we have, I think the 
appropriate
adaptation for GUP_BENCHMARK's relationship to DEBUG_FS *in particular*, is: 
select.

And 42 other committers have chosen the same thing, for their relationship to
DEBUG_FS. I'm in good company.

But if you really disagree, then I'd go with, just drop the patch entirely, 
because
it doesn't really make things better as written...IMHO anyway. :)

thanks,
--
John Hubbard
NVIDIA


Re: [PATCH] net: usb: fix spelling typo in cdc_ncm.c

2020-11-07 Thread patchwork-bot+netdevbpf
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Fri,  6 Nov 2020 15:50:25 +0800 you wrote:
> Actually, withing should be within.
> 
> Signed-off-by: Wang Qing 
> ---
>  drivers/net/usb/cdc_ncm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - net: usb: fix spelling typo in cdc_ncm.c
https://git.kernel.org/netdev/net-next/c/ef9ac2091180

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




Re: [PATCH] net: core: fix spelling typo in flow_dissector.c

2020-11-07 Thread patchwork-bot+netdevbpf
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Fri,  6 Nov 2020 16:11:49 +0800 you wrote:
> withing should be within.
> 
> Signed-off-by: Wang Qing 
> ---
>  net/core/flow_dissector.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - net: core: fix spelling typo in flow_dissector.c
https://git.kernel.org/netdev/net-next/c/75a5fb0cdbb7

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




Re: [PATCH net-next 00/13] net: ipa: constrain GSI interrupts

2020-11-07 Thread patchwork-bot+netdevbpf
Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Thu,  5 Nov 2020 12:13:54 -0600 you wrote:
> The goal of this series is to more tightly control when GSI
> interrupts are enabled.  This is a long-ish series, so I'll
> describe it in parts.
> 
> The first patch is actually unrelated...  I forgot to include
> it in my previous series (which exposed the GSI layer to the
> IPA version).  It is a trivial comments-only update patch.
> 
> [...]

Here is the summary with links:
  - [net-next,01/13] net: ipa: refer to IPA versions, not GSI
https://git.kernel.org/netdev/net-next/c/4a04d65c964e
  - [net-next,02/13] net: ipa: request GSI IRQ later
https://git.kernel.org/netdev/net-next/c/0b8d67610845
  - [net-next,03/13] net: ipa: rename gsi->event_enable_bitmap
https://git.kernel.org/netdev/net-next/c/a054539db196
  - [net-next,04/13] net: ipa: define GSI interrupt types with an enum
https://git.kernel.org/netdev/net-next/c/f9b28804ab50
  - [net-next,05/13] net: ipa: disable all GSI interrupt types initially
https://git.kernel.org/netdev/net-next/c/97eb94c8c790
  - [net-next,06/13] net: ipa: cache last-saved GSI IRQ enabled type
https://git.kernel.org/netdev/net-next/c/3ca97ffd984c
  - [net-next,07/13] net: ipa: only enable GSI channel control IRQs when needed
https://git.kernel.org/netdev/net-next/c/b054d4f9eb4b
  - [net-next,08/13] net: ipa: only enable GSI event control IRQs when needed
https://git.kernel.org/netdev/net-next/c/b4175f8731f7
  - [net-next,09/13] net: ipa: only enable generic command completion IRQ when 
needed
https://git.kernel.org/netdev/net-next/c/d6c9e3f506ae
  - [net-next,10/13] net: ipa: only enable GSI IEOB IRQs when needed
https://git.kernel.org/netdev/net-next/c/06c8632833c2
  - [net-next,11/13] net: ipa: explicitly disallow inter-EE interrupts
https://git.kernel.org/netdev/net-next/c/46f748ccaf01
  - [net-next,12/13] net: ipa: only enable GSI general IRQs when needed
https://git.kernel.org/netdev/net-next/c/352f26a886d8
  - [net-next,13/13] net: ipa: pass a value to gsi_irq_type_update()
https://git.kernel.org/netdev/net-next/c/8194be79fbbc

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




Re: [PATCH] net: ipv4: remove redundant initialization in inet_rtm_deladdr

2020-11-07 Thread Jakub Kicinski
On Fri,  6 Nov 2020 01:42:37 -0500 menglong8.d...@gmail.com wrote:
> From: Menglong Dong 
> 
> The initialization for 'err' with '-EINVAL' is redundant and
> can be removed, as it is updated soon.
> 
> Signed-off-by: Menglong Dong 

How many changes like this are there in the kernel right now?

I'm afraid that if there are too many it's not worth the effort.

Also - what tool do you use to find those, we need to make sure new
instances don't get into the tree.

> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index 123a6d3..847cb18 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -651,7 +651,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct 
> nlmsghdr *nlh,
>   struct ifaddrmsg *ifm;
>   struct in_ifaddr *ifa;
>  

You can remove this empty line while at it.

> - int err = -EINVAL;
> + int err;
>  
>   ASSERT_RTNL();
>  



Re: [PATCH] net: atlantic: Remove unnecessary conversion to bool

2020-11-07 Thread Jakub Kicinski
On Fri,  6 Nov 2020 10:57:59 +0800 xiakaixu1...@gmail.com wrote:
> - cfg->is_qos = (tcs != 0 ? true : false);
> + cfg->is_qos = (tcs != 0);

!!tcs


[PATCH 2/2] remoteproc: stm32: Constify st_rproc_ops

2020-11-07 Thread Rikard Falkeborn
The only usage of st_rproc_ops is to pass its address to rproc_alloc()
which accepts a const pointer. Make it const to allow the compiler to
put it in read-only memory.

Signed-off-by: Rikard Falkeborn 
---
 drivers/remoteproc/stm32_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index d2414cc1d90d..a180aeae9675 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -541,7 +541,7 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid)
}
 }
 
-static struct rproc_ops st_rproc_ops = {
+static const struct rproc_ops st_rproc_ops = {
.start  = stm32_rproc_start,
.stop   = stm32_rproc_stop,
.attach = stm32_rproc_attach,
-- 
2.29.2



[PATCH 0/2] remoteproc: Constify static struct rproc_ops

2020-11-07 Thread Rikard Falkeborn
Constify two static struct rproc_ops which are never modified. These two
changes makes all static instances of rproc_ops in the kernel const.

Rikard Falkeborn (2):
  remoteproc: ingenic: Constify ingenic_rproc_ops
  remoteproc: stm32: Constify st_rproc_ops

 drivers/remoteproc/ingenic_rproc.c | 2 +-
 drivers/remoteproc/stm32_rproc.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.29.2



[PATCH 1/2] remoteproc: ingenic: Constify ingenic_rproc_ops

2020-11-07 Thread Rikard Falkeborn
The only usage of ingenic_rproc_ops is to pass its address to
devm_rproc_alloc(), which accepts a const pointer. Make it const to
allow the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn 
---
 drivers/remoteproc/ingenic_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/ingenic_rproc.c 
b/drivers/remoteproc/ingenic_rproc.c
index 1c2b21a5d178..26e19e6143b7 100644
--- a/drivers/remoteproc/ingenic_rproc.c
+++ b/drivers/remoteproc/ingenic_rproc.c
@@ -135,7 +135,7 @@ static void *ingenic_rproc_da_to_va(struct rproc *rproc, 
u64 da, size_t len)
return (__force void *)va;
 }
 
-static struct rproc_ops ingenic_rproc_ops = {
+static const struct rproc_ops ingenic_rproc_ops = {
.prepare = ingenic_rproc_prepare,
.unprepare = ingenic_rproc_unprepare,
.start = ingenic_rproc_start,
-- 
2.29.2



  1   2   3   4   >