[PATCH mm 12/13] mm: delete mmap_write_trylock() and vma_try_start_write()

2023-07-11 Thread Hugh Dickins
mmap_write_trylock() and vma_try_start_write() were added just for khugepaged, but now it has no use for them: delete. Signed-off-by: Hugh Dickins --- This is the version which applies to mm-unstable or linux-next. include/linux/mm.h| 17 - include/linux/mmap_lock.h |

[PATCH v3 13/13] mm/pgtable: notes on pte_offset_map[_lock]()

2023-07-11 Thread Hugh Dickins
Add a block of comments on pte_offset_map_lock(), pte_offset_map() and pte_offset_map_nolock() to mm/pgtable-generic.c, to help explain them. Signed-off-by: Hugh Dickins --- mm/pgtable-generic.c | 44 1 file changed, 44 insertions(+) diff --git

[PATCH v2] powerpc:platforms:Fix an NULL vs IS_ERR() bug for debugfs_create_dir()

2023-07-11 Thread Wang Ming
The debugfs_create_dir() function returns error pointers. It never returns NULL. Most incorrect error checks were fixed, but the one in scom_debug_init() was forgotten, the other one in scom_debug_init_one() was also forgotten. Fix the remaining error check. Signed-off-by: Wang Ming Fixes:

[PATCH v3 12/13] mm: delete mmap_write_trylock() and vma_try_start_write()

2023-07-11 Thread Hugh Dickins
mmap_write_trylock() and vma_try_start_write() were added just for khugepaged, but now it has no use for them: delete. Signed-off-by: Hugh Dickins --- include/linux/mm.h| 17 - include/linux/mmap_lock.h | 10 -- 2 files changed, 27 deletions(-) diff --git

[PATCH v3 11/13] mm/khugepaged: delete khugepaged_collapse_pte_mapped_thps()

2023-07-11 Thread Hugh Dickins
Now that retract_page_tables() can retract page tables reliably, without depending on trylocks, delete all the apparatus for khugepaged to try again later: khugepaged_collapse_pte_mapped_thps() etc; and free up the per-mm memory which was set aside for that in the khugepaged_mm_slot. But one part

[PATCH v3 10/13] mm/khugepaged: collapse_pte_mapped_thp() with mmap_read_lock()

2023-07-11 Thread Hugh Dickins
Bring collapse_and_free_pmd() back into collapse_pte_mapped_thp(). It does need mmap_read_lock(), but it does not need mmap_write_lock(), nor vma_start_write() nor i_mmap lock nor anon_vma lock. All racing paths are relying on pte_offset_map_lock() and pmd_lock(), so use those. Follow the

[PATCH v3 09/13] mm/khugepaged: retract_page_tables() without mmap or vma lock

2023-07-11 Thread Hugh Dickins
Simplify shmem and file THP collapse's retract_page_tables(), and relax its locking: to improve its success rate and to lessen impact on others. Instead of its MADV_COLLAPSE case doing set_huge_pmd() at target_addr of target_mm, leave that part of the work to madvise_collapse() calling

[PATCH v3 08/13] mm/pgtable: add pte_free_defer() for pgtable as page

2023-07-11 Thread Hugh Dickins
Add the generic pte_free_defer(), to call pte_free() via call_rcu(). pte_free_defer() will be called inside khugepaged's retract_page_tables() loop, where allocating extra memory cannot be relied upon. This version suits all those architectures which use an unfragmented page for one page table

[PATCH v3 07/13] s390: add pte_free_defer() for pgtables sharing page

2023-07-11 Thread Hugh Dickins
Add s390-specific pte_free_defer(), to free table page via call_rcu(). pte_free_defer() will be called inside khugepaged's retract_page_tables() loop, where allocating extra memory cannot be relied upon. This precedes the generic version to avoid build breakage from incompatible pgtable_t. This

[PATCH v3 06/13] sparc: add pte_free_defer() for pte_t *pgtable_t

2023-07-11 Thread Hugh Dickins
Add sparc-specific pte_free_defer(), to call pte_free() via call_rcu(). pte_free_defer() will be called inside khugepaged's retract_page_tables() loop, where allocating extra memory cannot be relied upon. This precedes the generic version to avoid build breakage from incompatible pgtable_t.

[PATCH v3 05/13] powerpc: add pte_free_defer() for pgtables sharing page

2023-07-11 Thread Hugh Dickins
Add powerpc-specific pte_free_defer(), to free table page via call_rcu(). pte_free_defer() will be called inside khugepaged's retract_page_tables() loop, where allocating extra memory cannot be relied upon. This precedes the generic version to avoid build breakage from incompatible pgtable_t.

[PATCH v3 04/13] powerpc: assert_pte_locked() use pte_offset_map_nolock()

2023-07-11 Thread Hugh Dickins
Instead of pte_lockptr(), use the recently added pte_offset_map_nolock() in assert_pte_locked(). BUG if pte_offset_map_nolock() fails: this is stricter than the previous implementation, which skipped when pmd_none() (with a comment on khugepaged collapse transitions): but wouldn't we want to

[PATCH v3 03/13] arm: adjust_pte() use pte_offset_map_nolock()

2023-07-11 Thread Hugh Dickins
Instead of pte_lockptr(), use the recently added pte_offset_map_nolock() in adjust_pte(): because it gives the not-locked ptl for precisely that pte, which the caller can then safely lock; whereas pte_lockptr() is not so tightly coupled, because it dereferences the pmd pointer again.

[PATCH v3 02/13] mm/pgtable: add PAE safety to __pte_offset_map()

2023-07-11 Thread Hugh Dickins
There is a faint risk that __pte_offset_map(), on a 32-bit architecture with a 64-bit pmd_t e.g. x86-32 with CONFIG_X86_PAE=y, would succeed on a pmdval assembled from a pmd_low and a pmd_high which never belonged together: their combination not pointing to a page table at all, perhaps not even a

[PATCH v3 01/13] mm/pgtable: add rcu_read_lock() and rcu_read_unlock()s

2023-07-11 Thread Hugh Dickins
Before putting them to use (several commits later), add rcu_read_lock() to pte_offset_map(), and rcu_read_unlock() to pte_unmap(). Make this a separate commit, since it risks exposing imbalances: prior commits have fixed all the known imbalances, but we may find some have been missed.

[PATCH v3 00/13] mm: free retracted page table by RCU

2023-07-11 Thread Hugh Dickins
Here is v3 of the series of patches to mm (and a few architectures), based on v6.5-rc1 which includes the preceding two series (thank you!): in which khugepaged takes advantage of pte_offset_map[_lock]() allowing for pmd transitions. Differences from v1 and v2 are noted patch by patch below.

Re: [PATCH net-next v3 0/8] net: freescale: Convert to platform remove callback returning void

2023-07-11 Thread patchwork-bot+netdevbpf
Hello: This series was applied to netdev/net-next.git (main) by Jakub Kicinski : On Mon, 10 Jul 2023 09:19:38 +0200 you wrote: > Hello, > > v2 of this series was sent in June[1], code changes since then only affect > patch #1 where the dev_err invocation was adapted to emit the error code of >

Re: [PATCH v3 4/7] mm/hotplug: Allow pageblock alignment via altmap reservation

2023-07-11 Thread Aneesh Kumar K V
On 7/11/23 10:49 PM, David Hildenbrand wrote: > On 11.07.23 06:48, Aneesh Kumar K.V wrote: >> Add a new kconfig option that can be selected if we want to allow >> pageblock alignment by reserving pages in the vmemmap altmap area. >> This implies we will be reserving some pages for every

Re: [PATCH] soc: fsl: qe: Replace all non-returning strlcpy with strscpy

2023-07-11 Thread Azeem Shaikh
> Sorry for the late response. But I found some old discussions with the > conclusion to be not converting old users. Has this been changed later on? > https://lwn.net/Articles/659214/ > @Kees Cook what's your advice here?

Re: [PATCH v7 3/8] KVM: Make __kvm_follow_pfn not imply FOLL_GET

2023-07-11 Thread Sean Christopherson
On Tue, Jul 11, 2023, Zhi Wang wrote: > On Thu, 6 Jul 2023 15:49:39 +0900 > David Stevens wrote: > > > On Wed, Jul 5, 2023 at 10:19___PM Zhi Wang wrote: > > > > > > On Tue, 4 Jul 2023 16:50:48 +0900 > > > David Stevens wrote: > > > If yes, do we have to use FOLL_GET to resolve GFN associated

Re: [PATCH v2 1/2] powerpc/tpm: Create linux,sml-base/size as big endian

2023-07-11 Thread Jarkko Sakkinen
On Tue, 2023-07-11 at 08:47 -0400, Stefan Berger wrote: > > On 7/10/23 17:23, Jarkko Sakkinen wrote: > > On Thu, 2023-06-15 at 22:37 +1000, Michael Ellerman wrote: > > > There's code in prom_instantiate_sml() to do a "SML handover" (Stored > > > Measurement Log) from OF to Linux, before Linux

Re: [PATCH v2 10/10] docs: ABI: sysfs-bus-event_source-devices-hv_gpci: Document affinity_domain_via_partition sysfs interface file

2023-07-11 Thread Randy Dunlap
Hi, Same correction comments as in the other 4 patches (not repeated here). On 7/10/23 02:27, Kajol Jain wrote: > Add details of the new hv-gpci interface file called > "affinity_domain_via_partition" in the ABI documentation. > > Signed-off-by: Kajol Jain > --- >

Re: [PATCH v2 08/10] docs: ABI: sysfs-bus-event_source-devices-hv_gpci: Document affinity_domain_via_domain sysfs interface file

2023-07-11 Thread Randy Dunlap
Hi, On 7/10/23 02:27, Kajol Jain wrote: > Add details of the new hv-gpci interface file called > "affinity_domain_via_domain" in the ABI documentation. > > Signed-off-by: Kajol Jain > --- > .../sysfs-bus-event_source-devices-hv_gpci| 32 +++ > 1 file changed, 32

Re: [PATCH v2 06/10] docs: ABI: sysfs-bus-event_source-devices-hv_gpci: Document affinity_domain_via_virtual_processor sysfs interface file

2023-07-11 Thread Randy Dunlap
Hi-- On 7/10/23 02:27, Kajol Jain wrote: > Add details of the new hv-gpci interface file called > "affinity_domain_via_virtual_processor" in the ABI documentation. > > Signed-off-by: Kajol Jain > --- > .../sysfs-bus-event_source-devices-hv_gpci| 32 +++ > 1 file changed, 32

Re: [PATCH v2 04/10] docs: ABI: sysfs-bus-event_source-devices-hv_gpci: Document processor_config sysfs interface file

2023-07-11 Thread Randy Dunlap
Hi-- On 7/10/23 02:27, Kajol Jain wrote: > Add details of the new hv-gpci interface file called > "processor_config" in the ABI documentation. > > Signed-off-by: Kajol Jain > --- > .../sysfs-bus-event_source-devices-hv_gpci| 32 +++ > 1 file changed, 32 insertions(+) > >

Re: [PATCH v2 02/10] docs: ABI: sysfs-bus-event_source-devices-hv_gpci: Document processor_bus_topology sysfs interface file

2023-07-11 Thread Randy Dunlap
Hi-- On 7/10/23 02:27, Kajol Jain wrote: > Add details of the new hv-gpci interface file called > "processor_bus_topology" in the ABI documentation. > > Signed-off-by: Kajol Jain > --- > .../sysfs-bus-event_source-devices-hv_gpci| 32 +++ > 1 file changed, 32 insertions(+)

Re: [PATCH v3 2/5] fs: Add fchmodat4()

2023-07-11 Thread Alexey Gladkov
On Tue, Jul 11, 2023 at 04:01:03PM +0200, Christian Brauner wrote: > On Tue, Jul 11, 2023 at 02:51:01PM +0200, Alexey Gladkov wrote: > > On Tue, Jul 11, 2023 at 01:52:01PM +0200, Christian Brauner wrote: > > > On Tue, Jul 11, 2023 at 01:42:19PM +0200, Arnd Bergmann wrote: > > > > On Tue, Jul 11,

Re: [PATCH v3 0/5] Add a new fchmodat4() syscall

2023-07-11 Thread Christian Brauner
On Tue, Jul 11, 2023 at 02:24:51PM +0200, Florian Weimer wrote: > * Alexey Gladkov: > > > This patch set adds fchmodat4(), a new syscall. The actual > > implementation is super simple: essentially it's just the same as > > fchmodat(), but LOOKUP_FOLLOW is conditionally set based on the flags. > >

Re: [PATCH v3 2/5] fs: Add fchmodat4()

2023-07-11 Thread Christian Brauner
On Tue, Jul 11, 2023 at 02:51:01PM +0200, Alexey Gladkov wrote: > On Tue, Jul 11, 2023 at 01:52:01PM +0200, Christian Brauner wrote: > > On Tue, Jul 11, 2023 at 01:42:19PM +0200, Arnd Bergmann wrote: > > > On Tue, Jul 11, 2023, at 13:25, Alexey Gladkov wrote: > > > > From: Palmer Dabbelt > > > >

Re: [PATCH v3 5/5] selftests: add fchmodat4(2) selftest

2023-07-11 Thread Alexey Gladkov
On Tue, Jul 11, 2023 at 02:10:58PM +0200, Florian Weimer wrote: > * Alexey Gladkov: > > > The test marks as skipped if a syscall with the AT_SYMLINK_NOFOLLOW flag > > fails. This is because not all filesystems support changing the mode > > bits of symlinks properly. These filesystems return an

Re: [PATCH v3 2/5] fs: Add fchmodat4()

2023-07-11 Thread Alexey Gladkov
On Tue, Jul 11, 2023 at 01:52:01PM +0200, Christian Brauner wrote: > On Tue, Jul 11, 2023 at 01:42:19PM +0200, Arnd Bergmann wrote: > > On Tue, Jul 11, 2023, at 13:25, Alexey Gladkov wrote: > > > From: Palmer Dabbelt > > > > > > On the userspace side fchmodat(3) is implemented as a wrapper > > >

Re: [PATCH v3 2/5] fs: Add fchmodat4()

2023-07-11 Thread Alexey Gladkov
On Tue, Jul 11, 2023 at 01:28:04PM +0100, Matthew Wilcox wrote: > On Tue, Jul 11, 2023 at 01:25:43PM +0200, Alexey Gladkov wrote: > > -static int do_fchmodat(int dfd, const char __user *filename, umode_t mode) > > +static int do_fchmodat4(int dfd, const char __user *filename, umode_t > > mode,

Re: [PATCH v7 2/8] KVM: Introduce __kvm_follow_pfn function

2023-07-11 Thread Zhi Wang
On Wed, 5 Jul 2023 18:08:17 +0900 David Stevens wrote: > On Wed, Jul 5, 2023 at 5:47___PM Zhi Wang wrote: > > > > On Tue, 4 Jul 2023 16:50:47 +0900 > > David Stevens wrote: > > > > > From: David Stevens > > > > > > Introduce __kvm_follow_pfn, which will replace __gfn_to_pfn_memslot. > > >

Re: (subset) [PATCH v4 0/5] Add a new fchmodat2() syscall

2023-07-11 Thread Christian Brauner
On Tue, 11 Jul 2023 18:16:02 +0200, Alexey Gladkov wrote: > In glibc, the fchmodat(3) function has a flags argument according to the > POSIX specification [1], but kernel syscalls has no such argument. > Therefore, libc implementations do workarounds using /proc. However, > this requires procfs to

Re: [PATCH v7 3/8] KVM: Make __kvm_follow_pfn not imply FOLL_GET

2023-07-11 Thread Zhi Wang
On Thu, 6 Jul 2023 15:49:39 +0900 David Stevens wrote: > On Wed, Jul 5, 2023 at 10:19___PM Zhi Wang wrote: > > > > On Tue, 4 Jul 2023 16:50:48 +0900 > > David Stevens wrote: > > > > > From: David Stevens > > > > > > Make it so that __kvm_follow_pfn does not imply FOLL_GET. This allows > >

Re: [PATCH v4 4/5] tools headers UAPI: Sync files changed by new fchmodat2 syscall

2023-07-11 Thread Alexey Gladkov
On Tue, Jul 11, 2023 at 10:19:35AM -0700, Namhyung Kim wrote: > Hello, > > On Tue, Jul 11, 2023 at 9:18 AM Alexey Gladkov wrote: > > > > From: Palmer Dabbelt > > > > That add support for this new syscall in tools such as 'perf trace'. > > > > Signed-off-by: Palmer Dabbelt > > Signed-off-by:

Re: [PATCH v4 4/5] tools headers UAPI: Sync files changed by new fchmodat2 syscall

2023-07-11 Thread Namhyung Kim
Hello, On Tue, Jul 11, 2023 at 9:18 AM Alexey Gladkov wrote: > > From: Palmer Dabbelt > > That add support for this new syscall in tools such as 'perf trace'. > > Signed-off-by: Palmer Dabbelt > Signed-off-by: Alexey Gladkov > --- > tools/include/uapi/asm-generic/unistd.h | 5

Re: [PATCH v3 4/7] mm/hotplug: Allow pageblock alignment via altmap reservation

2023-07-11 Thread David Hildenbrand
On 11.07.23 06:48, Aneesh Kumar K.V wrote: Add a new kconfig option that can be selected if we want to allow pageblock alignment by reserving pages in the vmemmap altmap area. This implies we will be reserving some pages for every memoryblock This also allows the memmap on memory feature to be

Re: [PATCH v4 00/33] Per-VMA locks

2023-07-11 Thread Leon Romanovsky
On Tue, Jul 11, 2023 at 09:35:13AM -0700, Suren Baghdasaryan wrote: > On Tue, Jul 11, 2023 at 4:09 AM Leon Romanovsky wrote: > > > > On Tue, Jul 11, 2023 at 02:01:41PM +0300, Leon Romanovsky wrote: > > > On Tue, Jul 11, 2023 at 12:39:34PM +0200, Vlastimil Babka wrote: > > > > On 7/11/23 12:35,

Re: [PATCH v4 2/5] fs: Add fchmodat2()

2023-07-11 Thread Christian Brauner
On Tue, Jul 11, 2023 at 06:16:04PM +0200, Alexey Gladkov wrote: > On the userspace side fchmodat(3) is implemented as a wrapper > function which implements the POSIX-specified interface. This > interface differs from the underlying kernel system call, which does not > have a flags argument. Most

Re: [PATCH v4 00/33] Per-VMA locks

2023-07-11 Thread Suren Baghdasaryan
On Tue, Jul 11, 2023 at 4:09 AM Leon Romanovsky wrote: > > On Tue, Jul 11, 2023 at 02:01:41PM +0300, Leon Romanovsky wrote: > > On Tue, Jul 11, 2023 at 12:39:34PM +0200, Vlastimil Babka wrote: > > > On 7/11/23 12:35, Leon Romanovsky wrote: > > > > > > > > On Mon, Feb 27, 2023 at 09:35:59AM -0800,

[PATCH v4 4/5] tools headers UAPI: Sync files changed by new fchmodat2 syscall

2023-07-11 Thread Alexey Gladkov
From: Palmer Dabbelt That add support for this new syscall in tools such as 'perf trace'. Signed-off-by: Palmer Dabbelt Signed-off-by: Alexey Gladkov --- tools/include/uapi/asm-generic/unistd.h | 5 - tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 2 ++

Re: [PATCH v4 3/5] arch: Register fchmodat2, usually as syscall 452

2023-07-11 Thread Arnd Bergmann
On Tue, Jul 11, 2023, at 18:16, Alexey Gladkov wrote: > From: Palmer Dabbelt > > This registers the new fchmodat2 syscall in most places as nuber 452, > with alpha being the exception where it's 562. I found all these sites > by grepping for fspick, which I assume has found me everything. > >

[PATCH v4 5/5] selftests: Add fchmodat2 selftest

2023-07-11 Thread Alexey Gladkov
The test marks as skipped if a syscall with the AT_SYMLINK_NOFOLLOW flag fails. This is because not all filesystems support changing the mode bits of symlinks properly. These filesystems return an error but change the mode bits: newfstatat(4, "regfile", {st_mode=S_IFREG|0640, st_size=0, ...},

[PATCH v4 3/5] arch: Register fchmodat2, usually as syscall 452

2023-07-11 Thread Alexey Gladkov
From: Palmer Dabbelt This registers the new fchmodat2 syscall in most places as nuber 452, with alpha being the exception where it's 562. I found all these sites by grepping for fspick, which I assume has found me everything. Signed-off-by: Palmer Dabbelt Signed-off-by: Alexey Gladkov ---

[PATCH v4 2/5] fs: Add fchmodat2()

2023-07-11 Thread Alexey Gladkov
On the userspace side fchmodat(3) is implemented as a wrapper function which implements the POSIX-specified interface. This interface differs from the underlying kernel system call, which does not have a flags argument. Most implementations require procfs [1][2]. There doesn't appear to be a good

[PATCH v4 1/5] Non-functional cleanup of a "__user * filename"

2023-07-11 Thread Alexey Gladkov
From: Palmer Dabbelt The next patch defines a very similar interface, which I copied from this definition. Since I'm touching it anyway I don't see any reason not to just go fix this one up. Signed-off-by: Palmer Dabbelt Acked-by: Arnd Bergmann --- include/linux/syscalls.h | 2 +- 1 file

[PATCH v4 0/5] Add a new fchmodat2() syscall

2023-07-11 Thread Alexey Gladkov
In glibc, the fchmodat(3) function has a flags argument according to the POSIX specification [1], but kernel syscalls has no such argument. Therefore, libc implementations do workarounds using /proc. However, this requires procfs to be mounted and accessible. This patch set adds fchmodat2(), a

[PATCH v4 15/15] powerpc: Implement UACCESS validation on PPC32

2023-07-11 Thread Christophe Leroy
In order to implement UACCESS validation, objtool support for powerpc needs to be enhanced to decode more instructions. It also requires implementation of switch tables finding. On PPC32 it is similar to x86, switch tables are anonymous in .rodata, the difference is that the value is relative to

[PATCH v4 08/15] objtool: Track general purpose register used for switch table base

2023-07-11 Thread Christophe Leroy
A function can contain nested switch tables using different registers as base address. In order to avoid failure in tracking those switch tables, the register containing the base address needs to be taken into account. To do so, add a 5 bits field in struct instruction that will hold the ID of

[PATCH v4 14/15] powerpc/bug: Annotate reachable after warning trap

2023-07-11 Thread Christophe Leroy
This commit is copied from commit bfb1a7c91fb7 ("x86/bug: Merge annotate_reachable() into _BUG_FLAGS() asm") 'twi 31,0,0' is a BUG instruction, which is by default a dead end. But the same instruction is used for WARNINGs and the execution resumes with the following instruction. Mark it

[PATCH v4 07/15] objtool: Merge mark_func_jump_tables() and add_func_jump_tables()

2023-07-11 Thread Christophe Leroy
Those two functions loop over the instructions of a function. Merge the two loops in order to ease enhancement of table end in a following patch. Signed-off-by: Christophe Leroy --- tools/objtool/check.c | 22 ++ 1 file changed, 6 insertions(+), 16 deletions(-) diff --git

[PATCH v4 04/15] objtool: Fix JUMP_ENTRY_SIZE for bi-arch like powerpc

2023-07-11 Thread Christophe Leroy
struct jump_entry { s32 code; s32 target; long key; }; It means that the size of the third argument depends on whether we are building a 32 bits or 64 bits kernel. Therefore JUMP_ENTRY_SIZE must depend on elf_class_addrsize(elf).

[PATCH v4 02/15] objtool: Move back misplaced comment

2023-07-11 Thread Christophe Leroy
A comment was introduced by commit 113d4bc90483 ("objtool: Fix clang switch table edge case") and wrongly moved by commit d871f7b5a6a2 ("objtool: Refactor jump table code to support other architectures") without the piece of code added with the comment in the original commit. Fixes: d871f7b5a6a2

[PATCH v4 06/15] objtool: Add support for relative switch tables

2023-07-11 Thread Christophe Leroy
On powerpc, switch tables are relative, than means the address of the table is added to the value of the entry in order to get the pointed address: (r10 is the table address, r4 the index in the table) lis r10,0 <== Load r10 with upper part of .rodata address

[PATCH v4 12/15] objtool: Add support for more complex UACCESS control

2023-07-11 Thread Christophe Leroy
On x86, UACCESS is controlled by two instructions: STAC and CLAC. STAC instruction enables UACCESS while CLAC disables UACCESS. This is simple enough for objtool to locate UACCESS enable and disable. But on powerpc it is a bit more complex, the same instruction is used for enabling and disabling

[PATCH v4 11/15] objtool: .rodata.cst{2/4/8/16} are not switch tables

2023-07-11 Thread Christophe Leroy
Exclude sections named .rodata.cst2 .rodata.cst4 .rodata.cst8 .rodata.cst16 as they won't contain switch tables. Signed-off-by: Christophe Leroy --- tools/objtool/check.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c

[PATCH v4 10/15] objtool: When looking for switch tables also follow conditional and dynamic jumps

2023-07-11 Thread Christophe Leroy
When walking backward to find the base address of a switch table, also take into account conditionnal branches and dynamic jumps from a previous switch table. To avoid mis-routing, break when stumbling on a function return. Signed-off-by: Christophe Leroy --- tools/objtool/check.c | 8 ++--

[PATCH v4 05/15] objtool: Add INSN_RETURN_CONDITIONAL

2023-07-11 Thread Christophe Leroy
Most functions have an unconditional return at the end, like this one: : 0: 81 22 04 d0 lwz r9,1232(r2) 4: 38 60 00 00 li r3,0 8: 2c 09 00 00 cmpwi r9,0 c: 4d 82 00 20 beqlr <== Conditional

[PATCH v4 13/15] objtool: Prepare noreturns.h for more architectures

2023-07-11 Thread Christophe Leroy
noreturns.h is a mix of x86 specific functions and more generic core functions. In preparation of inclusion of powerpc, split x86 functions out of noreturns.h into arch/noreturns.h Signed-off-by: Christophe Leroy --- .../objtool/arch/x86/include/arch/noreturns.h | 20 +++

Re: [PATCH v3 3/7] mm/hotplug: Allow architecture to override memmap on memory support check

2023-07-11 Thread David Hildenbrand
On 11.07.23 18:07, Aneesh Kumar K V wrote: On 7/11/23 4:06 PM, David Hildenbrand wrote: On 11.07.23 06:48, Aneesh Kumar K.V wrote: Some architectures would want different restrictions. Hence add an architecture-specific override. Both the PMD_SIZE check and pageblock alignment check are moved

[PATCH v4 09/15] objtool: Find end of switch table directly

2023-07-11 Thread Christophe Leroy
At the time being, the end of a switch table can only be known once the start of the following switch table has ben located. This is a problem when switch tables are nested because until the first switch table is properly added, the second one cannot be located as a the backward walk will abut on

[PATCH v4 03/15] objtool: Allow an architecture to disable objtool on ASM files

2023-07-11 Thread Christophe Leroy
Supporting objtool on ASM files requires quite an effort. Features like UACCESS validation don't require ASM files validation. In order to allow architectures to enable objtool validation without spending unnecessary effort on cleaning up ASM files, provide an option to disable objtool

[PATCH v4 01/15] Revert "powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto"

2023-07-11 Thread Christophe Leroy
This reverts commit 1e688dd2a3d6759d416616ff07afc4bb836c4213. That commit aimed at optimising the code around generation of WARN_ON/BUG_ON but this leads to a lot of dead code erroneously generated by GCC. That dead code becomes a problem when we start using objtool validation because objtool

[PATCH v4 00/15] powerpc/objtool: uaccess validation for PPC32 (v4)

2023-07-11 Thread Christophe Leroy
This series adds UACCESS validation for PPC32. It includes a dozen of changes to objtool core. It applies on top of series "Cleanup/Optimise KUAP (v3)" https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=363368=* It is almost mature, performs code analysis for all PPC32. In this

Re: [PATCH v3 3/7] mm/hotplug: Allow architecture to override memmap on memory support check

2023-07-11 Thread Aneesh Kumar K V
On 7/11/23 4:06 PM, David Hildenbrand wrote: > On 11.07.23 06:48, Aneesh Kumar K.V wrote: >> Some architectures would want different restrictions. Hence add an >> architecture-specific override. >> >> Both the PMD_SIZE check and pageblock alignment check are moved there. >> >> Signed-off-by:

Re: [PATCH 00/17] fbdev: Remove FBINFO_DEFAULT and FBINFO_FLAG_DEFAULT flags

2023-07-11 Thread Geert Uytterhoeven
Hi Helge, On Tue, Jul 11, 2023 at 5:26 PM Helge Deller wrote: > On 7/11/23 16:47, Sam Ravnborg wrote: > > On Tue, Jul 11, 2023 at 08:24:40AM +0200, Thomas Zimmermann wrote: > >> Am 10.07.23 um 19:19 schrieb Sam Ravnborg: > >>> On Mon, Jul 10, 2023 at 02:50:04PM +0200, Thomas Zimmermann wrote: >

[PATCH v3 8/9] powerpc/kuap: KUAP enabling/disabling functions must be __always_inline

2023-07-11 Thread Christophe Leroy
Objtool reports following warnings: arch/powerpc/kernel/signal_32.o: warning: objtool: __prevent_user_access.constprop.0+0x4 (.text+0x4): redundant UACCESS disable arch/powerpc/kernel/signal_32.o: warning: objtool: user_access_begin+0x2c (.text+0x4c): return with UACCESS enabled

[PATCH v3 9/9] powerpc/kuap: Use ASM feature fixups instead of static branches

2023-07-11 Thread Christophe Leroy
To avoid a useless nop on top of every uaccess enable/disable and make life easier for objtool, replace static branches by ASM feature fixups that will nop KUAP enabling instructions out in the unlikely case KUAP is disabled at boottime. Leave it as is on book3s/64 for now, it will be handled

[PATCH v3 5/9] powerpc/kuap: MMU_FTR_BOOK3S_KUAP becomes MMU_FTR_KUAP

2023-07-11 Thread Christophe Leroy
In order to reuse MMU_FTR_BOOK3S_KUAP for other targets than BOOK3S, rename it MMU_FTR_KUAP. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/64/hash-pkey.h | 2 +- arch/powerpc/include/asm/book3s/64/kup.h | 18 +- arch/powerpc/include/asm/mmu.h

[PATCH v3 7/9] powerpc/kuap: Simplify KUAP lock/unlock on BOOK3S/32

2023-07-11 Thread Christophe Leroy
On book3s/32 KUAP is performed at segment level. At the moment, when enabling userspace access, only current segment is modified. Then if a write is performed on another user segment, a fault is taken and all other user segments get enabled for userspace access. This then require special attention

[PATCH v3 6/9] powerpc/kuap: Use MMU_FTR_KUAP on all and refactor disabling kuap

2023-07-11 Thread Christophe Leroy
All but book3s/64 use a static branch key for disabling kuap. book3s/64 uses an mmu feature. Refactor all targets to use MMU_FTR_KUAP like book3s/64. For PPC32 that implies updating mmu features fixups once KUAP has been initialised. Signed-off-by: Christophe Leroy ---

[PATCH v3 1/9] powerpc/kuap: Avoid unnecessary reads of MD_AP

2023-07-11 Thread Christophe Leroy
A disassembly of interrupt_exit_kernel_prepare() shows a useless read of MD_AP register. This is shown by r9 being re-used immediately without doing anything with the value read. c000e0e0: 60 00 00 00 nop c000e0e4: ===> 7d 3a c2 a6 mfmd_ap r9< c000e0e8: 7d 20 00

[PATCH v3 4/9] powerpc/features: Add capability to update mmu features later

2023-07-11 Thread Christophe Leroy
On powerpc32, features fixup is performed very early and that's too early to read the cmdline and take into account 'nosmap' parameter. On the other hand, no userspace access is performed that early and KUAP feature fixup can be performed later. Add a function to update mmu features. The

[PATCH v3 2/9] powerpc/kuap: Avoid useless jump_label on empty function

2023-07-11 Thread Christophe Leroy
Disassembly of interrupt_enter_prepare() shows a pointless nop before the mftb c000abf0 : c000abf0: 81 23 00 84 lwz r9,132(r3) c000abf4: 71 29 40 00 andi. r9,r9,16384 c000abf8: 41 82 00 28 beq-c000ac20 c000abfc: ===> 60 00 00 00 nop <

[PATCH v3 3/9] powerpc/kuap: Fold kuep_is_disabled() into its only user

2023-07-11 Thread Christophe Leroy
kuep_is_disabled() was introduced by commit 91bb30822a2e ("powerpc/32s: Refactor update of user segment registers") but then all users but one were removed by commit 526d4a4c77ae ("powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly"). Fold kuep_is_disabled() into init_new_context() which

[PATCH v3 0/9] Cleanup/Optimise KUAP (v3)

2023-07-11 Thread Christophe Leroy
This series is cleaning up a bit KUAP in preparation of using objtool to validate UACCESS. There are two main changes in this series: 1/ Simplification of KUAP on book3s/32 2/ Using ASM features on 32 bits and booke as suggested by Nic. Those changes will be required for objtool UACCESS

Re: [PATCH v3 2/7] mm/hotplug: Allow memmap on memory hotplug request to fallback

2023-07-11 Thread Aneesh Kumar K V
On 7/11/23 3:53 PM, David Hildenbrand wrote: >> -bool mhp_supports_memmap_on_memory(unsigned long size) >> +static bool mhp_supports_memmap_on_memory(unsigned long size) >>   { >>   unsigned long nr_vmemmap_pages = size / PAGE_SIZE; >>   unsigned long vmemmap_size = nr_vmemmap_pages *

Re: [PATCH v3 5/7] powerpc/book3s64/memhotplug: Enable memmap on memory for radix

2023-07-11 Thread Aneesh Kumar K V
On 7/11/23 9:14 PM, David Hildenbrand wrote: > On 11.07.23 17:40, Aneesh Kumar K V wrote: >> On 7/11/23 8:56 PM, David Hildenbrand wrote: >>> On 11.07.23 06:48, Aneesh Kumar K.V wrote: Radix vmemmap mapping can map things correctly at the PMD level or PTE level based on different device

Re: [PATCH v3 5/7] powerpc/book3s64/memhotplug: Enable memmap on memory for radix

2023-07-11 Thread David Hildenbrand
On 11.07.23 17:40, Aneesh Kumar K V wrote: On 7/11/23 8:56 PM, David Hildenbrand wrote: On 11.07.23 06:48, Aneesh Kumar K.V wrote: Radix vmemmap mapping can map things correctly at the PMD level or PTE level based on different device boundary checks. Hence we skip the restrictions w.r.t

Re: [PATCH v3 5/7] powerpc/book3s64/memhotplug: Enable memmap on memory for radix

2023-07-11 Thread Aneesh Kumar K V
On 7/11/23 8:56 PM, David Hildenbrand wrote: > On 11.07.23 06:48, Aneesh Kumar K.V wrote: >> Radix vmemmap mapping can map things correctly at the PMD level or PTE >> level based on different device boundary checks. Hence we skip the >> restrictions w.r.t vmemmap size to be multiple of PMD_SIZE.

Re: [PATCH 00/17] fbdev: Remove FBINFO_DEFAULT and FBINFO_FLAG_DEFAULT flags

2023-07-11 Thread Helge Deller
On 7/11/23 16:47, Sam Ravnborg wrote: Hi Thomas, On Tue, Jul 11, 2023 at 08:24:40AM +0200, Thomas Zimmermann wrote: Hi Sam Am 10.07.23 um 19:19 schrieb Sam Ravnborg: Hi Thomas, On Mon, Jul 10, 2023 at 02:50:04PM +0200, Thomas Zimmermann wrote: Remove the unused flags FBINFO_DEFAULT and

Re: [PATCH v3 5/7] powerpc/book3s64/memhotplug: Enable memmap on memory for radix

2023-07-11 Thread David Hildenbrand
On 11.07.23 06:48, Aneesh Kumar K.V wrote: Radix vmemmap mapping can map things correctly at the PMD level or PTE level based on different device boundary checks. Hence we skip the restrictions w.r.t vmemmap size to be multiple of PMD_SIZE. This also makes the feature widely useful because to

Re: [PATCH 00/17] fbdev: Remove FBINFO_DEFAULT and FBINFO_FLAG_DEFAULT flags

2023-07-11 Thread Sam Ravnborg
Hi Thomas, On Tue, Jul 11, 2023 at 08:24:40AM +0200, Thomas Zimmermann wrote: > Hi Sam > > Am 10.07.23 um 19:19 schrieb Sam Ravnborg: > > Hi Thomas, > > > > On Mon, Jul 10, 2023 at 02:50:04PM +0200, Thomas Zimmermann wrote: > > > Remove the unused flags FBINFO_DEFAULT and FBINFO_FLAG_DEFAULT

[PATCH v2] powerpc/512x: lpbfifo: Convert to platform remove callback returning void

2023-07-11 Thread Uwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve

[PATCH] powerpc/512x: lpbfifo: Convert to platform remove callback returning void

2023-07-11 Thread Uwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve

Re: [PATCH v2 1/2] powerpc/tpm: Create linux,sml-base/size as big endian

2023-07-11 Thread Stefan Berger
On 7/10/23 17:23, Jarkko Sakkinen wrote: On Thu, 2023-06-15 at 22:37 +1000, Michael Ellerman wrote: There's code in prom_instantiate_sml() to do a "SML handover" (Stored Measurement Log) from OF to Linux, before Linux shuts down Open Firmware. This involves creating a buffer to hold the

Re: [PATCH v3 2/5] fs: Add fchmodat4()

2023-07-11 Thread Matthew Wilcox
On Tue, Jul 11, 2023 at 01:25:43PM +0200, Alexey Gladkov wrote: > -static int do_fchmodat(int dfd, const char __user *filename, umode_t mode) > +static int do_fchmodat4(int dfd, const char __user *filename, umode_t mode, > int lookup_flags) This function can still be called do_fchmodat(); we

Re: [PATCH v3 0/5] Add a new fchmodat4() syscall

2023-07-11 Thread Florian Weimer
* Alexey Gladkov: > This patch set adds fchmodat4(), a new syscall. The actual > implementation is super simple: essentially it's just the same as > fchmodat(), but LOOKUP_FOLLOW is conditionally set based on the flags. > I've attempted to make this match "man 2 fchmodat" as closely as >

Re: [PATCH v3 5/5] selftests: add fchmodat4(2) selftest

2023-07-11 Thread Florian Weimer
* Alexey Gladkov: > The test marks as skipped if a syscall with the AT_SYMLINK_NOFOLLOW flag > fails. This is because not all filesystems support changing the mode > bits of symlinks properly. These filesystems return an error but change > the mode bits: > > newfstatat(4, "regfile",

Re: [PATCH v3 2/5] fs: Add fchmodat4()

2023-07-11 Thread Christian Brauner
On Tue, Jul 11, 2023 at 01:42:19PM +0200, Arnd Bergmann wrote: > On Tue, Jul 11, 2023, at 13:25, Alexey Gladkov wrote: > > From: Palmer Dabbelt > > > > On the userspace side fchmodat(3) is implemented as a wrapper > > function which implements the POSIX-specified interface. This > > interface

Re: [PATCH v3 2/5] fs: Add fchmodat4()

2023-07-11 Thread Arnd Bergmann
On Tue, Jul 11, 2023, at 13:25, Alexey Gladkov wrote: > From: Palmer Dabbelt > > On the userspace side fchmodat(3) is implemented as a wrapper > function which implements the POSIX-specified interface. This > interface differs from the underlying kernel system call, which does not > have a flags

Re: [PATCH v3 1/5] Non-functional cleanup of a "__user * filename"

2023-07-11 Thread Arnd Bergmann
On Tue, Jul 11, 2023, at 13:25, Alexey Gladkov wrote: > From: Palmer Dabbelt > > The next patch defines a very similar interface, which I copied from > this definition. Since I'm touching it anyway I don't see any reason > not to just go fix this one up. > > Signed-off-by: Palmer Dabbelt

Re: [PATCH v3 3/5] arch: Register fchmodat4, usually as syscall 451

2023-07-11 Thread Arnd Bergmann
On Tue, Jul 11, 2023, at 13:25, Alexey Gladkov wrote: > From: Palmer Dabbelt > > This registers the new fchmodat4 syscall in most places as nuber 451, > with alpha being the exception where it's 561. I found all these sites > by grepping for fspick, which I assume has found me everything. > >

[PATCH v3 5/5] selftests: add fchmodat4(2) selftest

2023-07-11 Thread Alexey Gladkov
The test marks as skipped if a syscall with the AT_SYMLINK_NOFOLLOW flag fails. This is because not all filesystems support changing the mode bits of symlinks properly. These filesystems return an error but change the mode bits: newfstatat(4, "regfile", {st_mode=S_IFREG|0640, st_size=0, ...},

[PATCH v3 4/5] tools headers UAPI: Sync files changed by new fchmodat4 syscall

2023-07-11 Thread Alexey Gladkov
From: Palmer Dabbelt That add support for this new syscall in tools such as 'perf trace'. Signed-off-by: Palmer Dabbelt Signed-off-by: Alexey Gladkov --- tools/include/uapi/asm-generic/unistd.h | 5 - tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 1 +

[PATCH v3 1/5] Non-functional cleanup of a "__user * filename"

2023-07-11 Thread Alexey Gladkov
From: Palmer Dabbelt The next patch defines a very similar interface, which I copied from this definition. Since I'm touching it anyway I don't see any reason not to just go fix this one up. Signed-off-by: Palmer Dabbelt --- include/linux/syscalls.h | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v3 2/5] fs: Add fchmodat4()

2023-07-11 Thread Alexey Gladkov
From: Palmer Dabbelt On the userspace side fchmodat(3) is implemented as a wrapper function which implements the POSIX-specified interface. This interface differs from the underlying kernel system call, which does not have a flags argument. Most implementations require procfs [1][2]. There

[PATCH v3 3/5] arch: Register fchmodat4, usually as syscall 451

2023-07-11 Thread Alexey Gladkov
From: Palmer Dabbelt This registers the new fchmodat4 syscall in most places as nuber 451, with alpha being the exception where it's 561. I found all these sites by grepping for fspick, which I assume has found me everything. Signed-off-by: Palmer Dabbelt Signed-off-by: Alexey Gladkov ---

[PATCH v3 0/5] Add a new fchmodat4() syscall

2023-07-11 Thread Alexey Gladkov
This patch set adds fchmodat4(), a new syscall. The actual implementation is super simple: essentially it's just the same as fchmodat(), but LOOKUP_FOLLOW is conditionally set based on the flags. I've attempted to make this match "man 2 fchmodat" as closely as possible, which says EINVAL is

  1   2   >