RE: [PATCH kernel] KVM: PPC: Book3S: Suppress warnings when allocating too big memory slots

2021-09-02 Thread David Laight
... > > This is from my deep Windows past :) > > > > https://docs.microsoft.com/en-us/windows/win32/stg/coding-style-conventions > > =D How interesting! And according to that link 'sz' means "Zero terminated > String". Imagine the confusion.. haha Is that document responsible for some of the

RE: [PATCH] powerpc/32: Don't use lmw/stmw for saving/restoring non volatile regs

2021-08-25 Thread David Laight
From: Segher Boessenkool > Sent: 24 August 2021 16:28 > > On Tue, Aug 24, 2021 at 08:16:00AM -0500, Segher Boessenkool wrote: > > On Tue, Aug 24, 2021 at 07:54:22AM +0200, Christophe Leroy wrote: > > > >On mpccore both lmw and stmw are only N+1 btw. But the serialization > > > >might cost

RE: [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull()

2021-05-27 Thread David Laight
From: Chen Huang > Sent: 26 May 2021 10:20 > > The simple_strtoull() function is deprecated in some situation, since > it does not check for the range overflow, use kstrtoull() instead. > ... > - target_bytes = simple_strtoull(buf, , 0) * 1024; > + ret = kstrtoull(buf, 0, _bytes); > +

RE: [PATCH v1 12/12] powerpc: Replace PPC_INST_NOP by PPC_RAW_NOP()

2021-05-20 Thread David Laight
From: Christophe Leroy > Sent: 20 May 2021 11:23 > > On the road to removing all PPC_INST_xx defines in > asm/ppc-opcodes.h, change PPC_INST_NOP to PPC_RAW_NOP(). ... > @@ -475,7 +474,7 @@ > #define PPC_RAW_ADD_DOT(t, a, b) (PPC_INST_ADD | ___PPC_RT(t) | > ___PPC_RA(a) | ___PPC_RB(b) | 0x1)

RE: [PATCH] Raise the minimum GCC version to 5.2

2021-05-03 Thread David Laight
From: Arnd Bergmann > Sent: 03 May 2021 10:25 ... > One scenario that I've seen previously is where user space and > kernel are built together as a source based distribution (OE, buildroot, > openwrt, ...), and the compiler is picked to match the original sources > of the user space because that

RE: [PATCH] powerpc: Initialize local variable fdt to NULL in elf64_load()

2021-04-23 Thread David Laight
From: Michael Ellerman > Sent: 23 April 2021 14:51 ... > > (Does anyone - and by anyone I mean any large distro - compile with > > local variables inited by the compiler?) > > This is where I say, "yes, Android" and you say "ugh no I meant a real > distro", and I say "well ...". > > But yeah

RE: [PATCH] powerpc: Initialize local variable fdt to NULL in elf64_load()

2021-04-22 Thread David Laight
From: Daniel Axtens > Sent: 22 April 2021 03:21 > > > Hi Lakshmi, > > > >> On 4/15/21 12:14 PM, Lakshmi Ramasubramanian wrote: > >> > >> Sorry - missed copying device-tree and powerpc mailing lists. > >> > >>> There are a few "goto out;" statements before the local variable "fdt" > >>> is

RE: [PATCH 1/2] mm: Fix struct page layout on 32-bit systems

2021-04-21 Thread David Laight
From: Arnd Bergmann > Sent: 20 April 2021 22:20 > > On Tue, Apr 20, 2021 at 11:14 PM Vineet Gupta > wrote: > > On 4/20/21 12:07 AM, Arnd Bergmann wrote: > > > > > > > which means that half the 32-bit architectures do this. This may > > > cause more problems when arc and/or microblaze want to

RE: [PATCH 1/2] mm: Fix struct page layout on 32-bit systems

2021-04-20 Thread David Laight
From: Geert Uytterhoeven > Sent: 20 April 2021 08:40 > > Hi Willy, > > On Sat, Apr 17, 2021 at 4:49 AM Matthew Wilcox wrote: > > Replacement patch to fix compiler warning. > > > > 32-bit architectures which expect 8-byte alignment for 8-byte integers > > and need 64-bit DMA addresses (arc, arm,

RE: [PATCH 1/2] mm: Fix struct page layout on 32-bit systems

2021-04-17 Thread David Laight
From: Matthew Wilcox > Sent: 17 April 2021 03:45 > > Replacement patch to fix compiler warning. ... > static inline dma_addr_t page_pool_get_dma_addr(struct page *page) > { > - return page->dma_addr; > + dma_addr_t ret = page->dma_addr[0]; > + if (sizeof(dma_addr_t) >

RE: [PATCH 2/2] mm: Indicate pfmemalloc pages in compound_head

2021-04-17 Thread David Laight
From: Matthew Wilcox (Oracle) > Sent: 17 April 2021 00:07 > > The net page_pool wants to use a magic value to identify page pool pages. > The best place to put it is in the first word where it can be clearly a > non-pointer value. That means shifting dma_addr up to alias with ->index, > which

RE: Bogus struct page layout on 32-bit

2021-04-17 Thread David Laight
From: Grygorii Strashko > Sent: 16 April 2021 10:27 ... > Sry, for delayed reply. > > The TI platforms am3/4/5 (cpsw) and Keystone 2 (netcp) can do only 32bit DMA > even in case of LPAE > (dma-ranges are used). > Originally, as I remember, CONFIG_ARCH_DMA_ADDR_T_64BIT has not been selected >

RE: [PATCH 1/1] mm: Fix struct page layout on 32-bit systems

2021-04-17 Thread David Laight
From: Matthew Wilcox > Sent: 16 April 2021 16:28 > > On Thu, Apr 15, 2021 at 08:08:32PM +0200, Jesper Dangaard Brouer wrote: > > See below patch. Where I swap32 the dma address to satisfy > > page->compound having bit zero cleared. (It is the simplest fix I could > > come up with). > > I think

RE: [PATCH 1/1] mm: Fix struct page layout on 32-bit systems

2021-04-16 Thread David Laight
From: Matthew Wilcox > Sent: 15 April 2021 23:22 > > On Thu, Apr 15, 2021 at 09:11:56PM +0000, David Laight wrote: > > Isn't it possible to move the field down one long? > > This might require an explicit zero - but this is not a common > > code path - th

RE: [PATCH 1/1] mm: Fix struct page layout on 32-bit systems

2021-04-15 Thread David Laight
From: Matthew Wilcox > Sent: 15 April 2021 19:22 > > On Thu, Apr 15, 2021 at 08:08:32PM +0200, Jesper Dangaard Brouer wrote: > > +static inline > > +dma_addr_t page_pool_dma_addr_read(dma_addr_t dma_addr) > > +{ > > + /* Workaround for storing 64-bit DMA-addr on 32-bit machines in struct > > +

RE: [PATCH 1/1] mm: Fix struct page layout on 32-bit systems

2021-04-14 Thread David Laight
From: Matthew Wilcox > Sent: 14 April 2021 22:36 > > On Wed, Apr 14, 2021 at 09:13:22PM +0200, Jesper Dangaard Brouer wrote: > > (If others want to reproduce). First I could not reproduce on ARM32. > > Then I found out that enabling CONFIG_XEN on ARCH=arm was needed to > > cause the issue by

RE: [PATCH 1/1] mm: Fix struct page layout on 32-bit systems

2021-04-14 Thread David Laight
> Doing this fixes it: > > +++ b/include/linux/types.h > @@ -140,7 +140,7 @@ typedef u64 blkcnt_t; > * so they don't care about the size of the actual bus addresses. > */ > #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT > -typedef u64 dma_addr_t; > +typedef u64 __attribute__((aligned(sizeof(void *

RE: [PATCH v1 1/2] powerpc/bitops: Use immediate operand when possible

2021-04-14 Thread David Laight
From: Segher Boessenkool > Sent: 14 April 2021 16:19 ... > > Could the kernel use GCC builtin atomic functions instead ? > > > > https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html > > Certainly that should work fine for the simpler cases that the atomic > operations are meant to

RE: [PATCH 1/1] mm: Fix struct page layout on 32-bit systems

2021-04-13 Thread David Laight
From: Matthew Wilcox > Sent: 12 April 2021 19:24 > > On Sun, Apr 11, 2021 at 11:43:07AM +0200, Jesper Dangaard Brouer wrote: > > Could you explain your intent here? > > I worry about @index. > > > > As I mentioned in other thread[1] netstack use page_is_pfmemalloc() > > (code copy-pasted below

RE: [PATCH 5/5] compat: consolidate the compat_flock{,64} definition

2021-04-12 Thread David Laight
From: Arnd Bergmann > Sent: 12 April 2021 12:26 > > On Mon, Apr 12, 2021 at 12:54 PM David Laight wrote: > > From: David Laight > Sent: 12 April 2021 10:37 > > ... > > > I'm guessing that compat_pid_t is 16 bits? > > > So the native 32bit v

RE: [PATCH 5/5] compat: consolidate the compat_flock{,64} definition

2021-04-12 Thread David Laight
From: David Laight > Sent: 12 April 2021 10:37 ... > I'm guessing that compat_pid_t is 16 bits? > So the native 32bit version has an unnamed 2 byte structure pad. > The 'packed' removes this pad from the compat structure. > > AFAICT (apart from mips) the __ARCH_COMPAT_FLOCK_PA

RE: consolidate the flock uapi definitions

2021-04-12 Thread David Laight
From: Arnd Bergmann > Sent: 12 April 2021 11:04 > > On Mon, Apr 12, 2021 at 10:55 AM Christoph Hellwig wrote: > > > > Hi all, > > > > currently we deal with the slight differents in the various architecture > > variants of the flock and flock64 stuctures in a very cruft way. This > > series

RE: [PATCH 5/5] compat: consolidate the compat_flock{,64} definition

2021-04-12 Thread David Laight
From: Christoph Hellwig > Sent: 12 April 2021 09:56 > > Provide a single common definition for the compat_flock and > compat_flock64 structures using the same tricks as for the native > variants. An extra define is added for the packing required on x86. > ... > /* > - * IA32 uses 4 byte

RE: Bogus struct page layout on 32-bit

2021-04-10 Thread David Laight
From: Matthew Wilcox > Sent: 10 April 2021 03:43 > On Sat, Apr 10, 2021 at 06:45:35AM +0800, kernel test robot wrote: > > >> include/linux/mm_types.h:274:1: error: static_assert failed due to > > >> requirement > '__builtin_offsetof(struct page, lru) == __builtin_offsetof(struct folio, > lru)'

RE: [PATCH 3/4] exec: simplify the compat syscall handling

2021-03-26 Thread David Laight
From: Al Viro > Sent: 26 March 2021 16:12 > > On Fri, Mar 26, 2021 at 03:38:30PM +0100, Christoph Hellwig wrote: > > > +static const char __user * > > +get_user_arg_ptr(const char __user *const __user *argv, int nr) > > { > > + if (in_compat_syscall()) { > > + const compat_uptr_t

RE: [PATCH] powerpc/vdso32: Add missing _restgpr_31_x to fix build failure

2021-03-16 Thread David Laight
From: Segher Boessenkool > Sent: 16 March 2021 00:00 ... > > Although you may need to disable loop unrolling (often dubious at best) > > and either force or disable some function inlining. > > The cases where GCC does loop unrolling at -O2 always help quite a lot. > Or, do you have a

RE: [PATCH] powerpc/vdso32: Add missing _restgpr_31_x to fix build failure

2021-03-15 Thread David Laight
From: Rasmus Villemoes > Sent: 15 March 2021 16:24 > > On 12/03/2021 03.29, Segher Boessenkool wrote: > > Hi! > > > > On Tue, Mar 09, 2021 at 06:19:30AM +, Christophe Leroy wrote: > >> With some defconfig including CONFIG_CC_OPTIMIZE_FOR_SIZE, > >> (for instance mvme5100_defconfig and

RE: Errant readings on LM81 with T2080 SoC

2021-03-15 Thread David Laight
From: Chris Packham > Sent: 14 March 2021 21:26 > > On 12/03/21 10:25 pm, David Laight wrote: > > From: Linuxppc-dev Guenter Roeck > >> Sent: 11 March 2021 21:35 > >> > >> On 3/11/21 1:17 PM, Chris Packham wrote: > >>> On 11/03/21 9:18 pm, Wo

RE: Errant readings on LM81 with T2080 SoC

2021-03-12 Thread David Laight
From: Linuxppc-dev Guenter Roeck > Sent: 11 March 2021 21:35 > > On 3/11/21 1:17 PM, Chris Packham wrote: > > > > On 11/03/21 9:18 pm, Wolfram Sang wrote: > >>> Bummer. What is really weird is that you see clock stretching under > >>> CPU load. Normally clock stretching is triggered by the

RE: [PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer

2021-02-09 Thread David Laight
From: Christophe Leroy > Sent: 09 February 2021 17:04 > > Le 09/02/2021 à 15:31, David Laight a écrit : > > From: Segher Boessenkool > >> Sent: 09 February 2021 13:51 > >> > >> On Tue, Feb 09, 2021 at 12:36:20PM +1000, Nicholas Piggin wrote: > >&g

RE: [PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer

2021-02-09 Thread David Laight
From: Segher Boessenkool > Sent: 09 February 2021 13:51 > > On Tue, Feb 09, 2021 at 12:36:20PM +1000, Nicholas Piggin wrote: > > What if you did this? > > > +static inline struct task_struct *get_current(void) > > +{ > > + register struct task_struct *task asm ("r2"); > > + > > + return

RE: [PATCH v2 1/3] powerpc: sstep: Fix load and update emulation

2021-02-04 Thread David Laight
From: Segher Boessenkool > Sent: 03 February 2021 21:18 ... > Power9 does: > > Load with Update Instructions (RA = 0) > EA is placed into R0. Does that change the value of 0? Rather reminds me of some 1960s era systems that had the small integers at fixed (global) addresses. FORTRAN always

RE: [PATCH v4 02/10] powerpc/signal: Add unsafe_copy_{vsx, fpr}_from_user()

2021-02-01 Thread David Laight
From: Christopher M. Riedl > Sent: 01 February 2021 16:55 ... > > > > > + int i; > > > > > \ > > > > > + > > > > > \ > > > > > + unsafe_copy_from_user(buf, __f,

RE: [PATCH v4 02/10] powerpc/signal: Add unsafe_copy_{vsx, fpr}_from_user()

2021-02-01 Thread David Laight
From: Christopher M. Riedl > Sent: 01 February 2021 15:56 > > On Thu Jan 28, 2021 at 4:38 AM CST, David Laight wrote: > > From: Christopher M. Riedl > > > Sent: 28 January 2021 04:04 > > > > > > Reuse the "safe" implementation from signal.c exce

RE: [PATCH v4 02/10] powerpc/signal: Add unsafe_copy_{vsx, fpr}_from_user()

2021-01-28 Thread David Laight
From: Christopher M. Riedl > Sent: 28 January 2021 04:04 > > Reuse the "safe" implementation from signal.c except for calling > unsafe_copy_from_user() to copy into a local buffer. > > Signed-off-by: Christopher M. Riedl > --- > arch/powerpc/kernel/signal.h | 33

RE: [PATCH v4 11/23] powerpc/syscall: Rename syscall_64.c into syscall.c

2021-01-26 Thread David Laight
From: Nicholas Piggin > Sent: 26 January 2021 10:21 > > Excerpts from Christophe Leroy's message of January 26, 2021 12:48 am: > > syscall_64.c will be reused almost as is for PPC32. > > > > Rename it syscall.c > > Could you rename it to interrupt.c instead? A system call is an > interrupt, and

RE: [PATCH v10 11/12] mm/vmalloc: Hugepage vmalloc mappings

2021-01-25 Thread David Laight
From: Christophe Leroy > Sent: 25 January 2021 09:15 > > Le 24/01/2021 à 09:22, Nicholas Piggin a écrit : > > Support huge page vmalloc mappings. Config option HAVE_ARCH_HUGE_VMALLOC > > enables support on architectures that define HAVE_ARCH_HUGE_VMAP and > > supports PMD sized vmap mappings. > >

RE: [PATCH 02/13] module: add a module_loaded helper

2021-01-21 Thread David Laight
> > On Thu, Jan 21, 2021 at 11:00:20AM +0100, Christophe Leroy wrote: > > > +bool module_loaded(const char *name); > > > > Maybe module_is_loaded() would be a better name. > > Fine with me. It does look like both callers aren't 'unsafe'. But it is a bit strange returning a stale value. It did

RE: [PATCH 02/13] module: add a module_loaded helper

2021-01-21 Thread David Laight
From: Christophe Leroy > Sent: 21 January 2021 10:00 > > Le 21/01/2021 à 08:49, Christoph Hellwig a écrit : > > Add a helper that takes modules_mutex and uses find_module to check if a > > given module is loaded. This provides a better abstraction for the two > > callers, and allows to unexport

RE: [PATCH 2/2] powerpc/44x: Remove STDBINUTILS kconfig option

2021-01-20 Thread David Laight
From: Christophe Leroy > Sent: 20 January 2021 07:49 > > STDBINUTILS is just a toggle to allow 256k page size > to appear in the possible page sizes list for the 44x. > > Make 256k page size appear all the time with an > explicit warning on binutils, and remove this unneccessary > STDBINUTILS

RE: [PATCH] Adds a new ioctl32 syscall for backwards compatibility layers

2021-01-16 Thread David Laight
... > He's already doing the system call emulation for all the system > calls other than ioctl in user space though. In my experience, > there are actually fairly few ioctl commands that are different > between architectures -- most of them have no misaligned > or architecture-defined struct

RE: [PATCH] Adds a new ioctl32 syscall for backwards compatibility layers

2021-01-16 Thread David Laight
From: sonicadvan...@gmail.com > Sent: 15 January 2021 07:03 > Problem presented: > A backwards compatibility layer that allows running x86-64 and x86 > processes inside of an AArch64 process. > - CPU is emulated > - Syscall interface is mostly passthrough > - Some syscalls require patching

RE: [PATCH 05/11] iov_iter: merge the compat case into rw_copy_check_uvector

2021-01-08 Thread David Laight
From: Christoph Hellwig > Sent: 21 September 2020 15:34 > > Stop duplicating the iovec verify code, and instead add add a > __import_iovec helper that does the whole verify and import, but takes > a bool compat to decided on the native or compat layout. This also > ends up massively simplifying

RE: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2021-01-01 Thread David Laight
From: Andy Lutomirski > Sent: 29 December 2020 00:36 ... > I mean that the mapping from the name "sync_core" to its semantics is > x86 only. The string "sync_core" appears in the kernel only in > arch/x86, membarrier code, membarrier docs, and a single SGI driver > that is x86-only. Sure, the

RE: [PATCH] powerpc:Don't print raw EIP/LR hex values in dump_stack() and show_regs()

2020-12-21 Thread David Laight
From: Segher Boessenkool > Sent: 21 December 2020 16:32 > > On Mon, Dec 21, 2020 at 04:17:21PM +0100, Christophe Leroy wrote: > > Le 21/12/2020 à 04:27, Xiaoming Ni a écrit : > > >Since the commit 2b0e86cc5de6 ("powerpc/fsl_booke/32: implement KASLR > > >infrastructure"), the powerpc system is

RE: [PATCH] net: ethernet: fs-enet: remove casting dma_alloc_coherent

2020-12-11 Thread David Laight
From: Christophe Leroy > Sent: 11 December 2020 15:22 > > Le 11/12/2020 à 09:52, Xu Wang a écrit : > > Remove casting the values returned by dma_alloc_coherent. > > Can you explain more in the commit log ? > > As far as I can see, dma_alloc_coherent() doesn't return __iomem, and > ring_base

RE: [PATCH] net: ethernet: fs-enet: remove casting dma_alloc_coherent

2020-12-11 Thread David Laight
From: Christophe Leroy > Sent: 11 December 2020 16:43 > > Le 11/12/2020 à 17:07, David Laight a écrit : > > From: Christophe Leroy > >> Sent: 11 December 2020 15:22 > >> > >> Le 11/12/2020 à 09:52, Xu Wang a écrit : > >>> Remove casting the va

RE: [PATCH v6 4/5] PCI: vmd: Update type of the __iomem pointers

2020-11-30 Thread David Laight
From: Krzysztof Wilczynski > Sent: 29 November 2020 23:08 > > Use "void __iomem" instead "char __iomem" pointer type when working with > the accessor functions (with names like readb() or writel(), etc.) to > better match a given accessor function signature where commonly the > address pointing

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-11-02 Thread David Laight
From: 'Greg KH' > Sent: 02 November 2020 13:52 > > On Mon, Nov 02, 2020 at 09:06:38AM +0000, David Laight wrote: > > From: 'Greg KH' > > > Sent: 23 October 2020 15:47 > > > > > > On Fri, Oct 23, 2020 at 02:39:24PM +, David Laight wrote: > >

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-11-02 Thread David Laight
From: 'Greg KH' > Sent: 23 October 2020 15:47 > > On Fri, Oct 23, 2020 at 02:39:24PM +0000, David Laight wrote: > > From: David Hildenbrand > > > Sent: 23 October 2020 15:33 > > ... > > > I just checked against upstream code generated by clang 10 and it >

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-24 Thread David Laight
From: Segher Boessenkool > Sent: 24 October 2020 18:29 > > On Fri, Oct 23, 2020 at 09:28:59PM +0000, David Laight wrote: > > From: Segher Boessenkool > > > Sent: 23 October 2020 19:27 > > > On Fri, Oct 23, 2020 at 06:58:57PM +0100, Al Viro wrote: > > >

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-23 Thread David Laight
From: Segher Boessenkool > Sent: 23 October 2020 19:27 > > On Fri, Oct 23, 2020 at 06:58:57PM +0100, Al Viro wrote: > > On Fri, Oct 23, 2020 at 03:09:30PM +0200, David Hildenbrand wrote: > > > > > Now, I am not a compiler expert, but as I already cited, at least on > > > x86-64 clang expects that

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-23 Thread David Laight
From: David Hildenbrand > Sent: 23 October 2020 15:33 ... > I just checked against upstream code generated by clang 10 and it > properly discards the upper 32bit via a mov w23 w2. > > So at least clang 10 indeed properly assumes we could have garbage and > masks it off. > > Maybe the issue is

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-23 Thread David Laight
From: Arnd Bergmann > Sent: 23 October 2020 14:23 > > On Fri, Oct 23, 2020 at 2:46 PM David Laight wrote: > > > > From: Greg KH > > > Sent: 22 October 2020 14:51 > > > > I've rammed the code into godbolt. > > > > https://godbolt.org/z

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-23 Thread David Laight
From: Greg KH > Sent: 22 October 2020 14:51 I've rammed the code into godbolt. https://godbolt.org/z/9v5PPW Definitely a clang bug. Search for [wx]24 in the clang output. nr_segs comes in as w2 and the initial bound checks are done on w2. w24 is loaded from w2 - I don't believe this changes

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: Al Viro > Sent: 22 October 2020 20:25 > > On Thu, Oct 22, 2020 at 12:04:52PM -0700, Nick Desaulniers wrote: > > > Passing an `unsigned long` as an `unsigned int` does no such > > narrowing: https://godbolt.org/z/TvfMxe (same vice-versa, just tail > > calls, no masking instructions). > > So

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: Nick Desaulniers > Sent: 22 October 2020 20:05 > ... > Passing an `unsigned long` as an `unsigned int` does no such > narrowing: https://godbolt.org/z/TvfMxe (same vice-versa, just tail > calls, no masking instructions). Right but is the called function going to use 32bit ops and/or mask

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: Matthew Wilcox > Sent: 22 October 2020 17:41 > > On Thu, Oct 22, 2020 at 04:35:17PM +0000, David Laight wrote: > > Wait... > > readv(2) defines: > > ssize_t readv(int fd, const struct iovec *iov, int iovcnt); > > It doesn't really matter what the

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: Christoph Hellwig > Sent: 22 October 2020 14:24 > > On Thu, Oct 22, 2020 at 11:36:40AM +0200, David Hildenbrand wrote: > > My thinking: if the compiler that calls import_iovec() has garbage in > > the upper 32 bit > > > > a) gcc will zero it out and not rely on it being zero. > > b) clang

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: Greg KH > Sent: 22 October 2020 15:40 > > On Thu, Oct 22, 2020 at 04:28:20PM +0200, Arnd Bergmann wrote: ... > > Can you attach the iov_iter.s files from the broken build, plus the > > one with 'noinline' for comparison? Maybe something can be seen > > in there. > > I don't know how to

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: David Hildenbrand > Sent: 22 October 2020 10:25 ... > ... especially because I recall that clang and gcc behave slightly > differently: > > https://github.com/hjl-tools/x86-psABI/issues/2 > > "Function args are different: narrow types are sign or zero extended to > 32 bits, depending on

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: David Hildenbrand > Sent: 22 October 2020 10:19 > > On 22.10.20 11:01, Greg KH wrote: > > On Thu, Oct 22, 2020 at 10:48:59AM +0200, David Hildenbrand wrote: > >> On 22.10.20 10:40, David Laight wrote: > >>> From: David Hildenbrand > >>>> Se

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: Greg KH > Sent: 22 October 2020 10:02 ... > I'm running some more tests, trying to narrow things down as just adding > a "noinline" to the function that got moved here doesn't work on Linus's > tree at the moment because the function was split into multiple > functions. I was going to look

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
From: David Hildenbrand > Sent: 22 October 2020 09:49 ... > >>> But, this looks now to be a compiler bug. I'm using the latest version > >>> of clang and if I put "noinline" at the front of the function, > >>> everything works. > >> > >> Well, the compiler can do more invasive optimizations when

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-22 Thread David Laight
:39AM +0200, Christoph Hellwig wrote: > >>>> From: David Laight > >>>> > >>>> This lets the compiler inline it into import_iovec() generating > >>>> much better code. > >>>> > &

RE: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c"

2020-10-21 Thread David Laight
From: Greg KH > Sent: 21 October 2020 17:13 > > On Fri, Sep 25, 2020 at 06:51:39AM +0200, Christoph Hellwig wrote: > > From: David Laight > > > > This lets the compiler inline it into import_iovec() generating > > much better code. > > > >

RE: [PATCH 5/9] fs: remove various compat readv/writev helpers

2020-09-23 Thread David Laight
From: Arnd Bergmann > Sent: 23 September 2020 19:46 ... > Regardless of that, another advantage of having the SYSCALL_DECLAREx() > would be the ability to include that header file from elsewhere with a > different > macro definition to create a machine-readable version of the interface when >

RE: [PATCH 3/9] iov_iter: refactor rw_copy_check_uvector and import_iovec

2020-09-23 Thread David Laight
From: Al Viro > Sent: 23 September 2020 15:17 > > On Wed, Sep 23, 2020 at 08:05:41AM +0200, Christoph Hellwig wrote: > > > +struct iovec *iovec_from_user(const struct iovec __user *uvec, > > + unsigned long nr_segs, unsigned long fast_segs, > > Hmm... For fast_segs unsigned long had

RE: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()

2020-09-21 Thread David Laight
From: Al Viro > Sent: 21 September 2020 16:30 > > On Mon, Sep 21, 2020 at 03:21:35PM +0000, David Laight wrote: > > > You really don't want to be looping through the array twice. > > Profiles, please. I did some profiling of send() v sendmsg() much earlier in th

RE: [PATCH 04/11] iov_iter: explicitly check for CHECK_IOVEC_ONLY in rw_copy_check_uvector

2020-09-21 Thread David Laight
From: Al Viro > Sent: 21 September 2020 16:11 > On Mon, Sep 21, 2020 at 03:05:32PM +, David Laight wrote: > > > I've actually no idea: > > 1) Why there is an access_ok() check here. > >It will be repeated by the user copy functions. > > Early sanity c

RE: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()

2020-09-21 Thread David Laight
From: Al Viro > Sent: 21 September 2020 16:02 > > On Mon, Sep 21, 2020 at 04:34:25PM +0200, Christoph Hellwig wrote: > > From: David Laight > > > > This is the only direct call of rw_copy_check_uvector(). Removing it > > will allow rw_copy_check_uvector(

RE: [PATCH 04/11] iov_iter: explicitly check for CHECK_IOVEC_ONLY in rw_copy_check_uvector

2020-09-21 Thread David Laight
From: Christoph Hellwig > Sent: 21 September 2020 15:34 > > Explicitly check for the magic value insted of implicitly relying on > its numeric representation. Also drop the rather pointless unlikely > annotation. > > Signed-off-by: Christoph Hellwig > --- > lib/iov_iter.c | 5 ++--- > 1 file

RE: let import_iovec deal with compat_iovecs as well

2020-09-21 Thread David Laight
> On Sat, Sep 19, 2020 at 02:24:10PM +0000, David Laight wrote: > > I thought about that change while writing my import_iovec() => > > iovec_import() > > patch - and thought that the io_uring code would (as usual) cause grief. > > > > Christoph - did you see

RE: [PATCH 1/9] kernel: add a PF_FORCE_COMPAT flag

2020-09-20 Thread David Laight
From: Arnd Bergmann > Sent: 20 September 2020 21:49 > > On Sun, Sep 20, 2020 at 9:28 PM Andy Lutomirski wrote: > > On Sun, Sep 20, 2020 at 12:23 PM Matthew Wilcox wrote: > > > > > > On Sun, Sep 20, 2020 at 08:10:31PM +0100, Al Viro wrote: > > > > IMO it's much saner to mark those and refuse to

RE: [PATCH 1/9] kernel: add a PF_FORCE_COMPAT flag

2020-09-19 Thread David Laight
From: Al Viro > Sent: 18 September 2020 14:58 > > On Fri, Sep 18, 2020 at 03:44:06PM +0200, Christoph Hellwig wrote: > > On Fri, Sep 18, 2020 at 02:40:12PM +0100, Al Viro wrote: > > > > /* Vector 0x110 is LINUX_32BIT_SYSCALL_TRAP */ > > > > - return

RE: let import_iovec deal with compat_iovecs as well

2020-09-19 Thread David Laight
From: Christoph Hellwig > Sent: 18 September 2020 13:45 > > this series changes import_iovec to transparently deal with comat iovec > structures, and then cleanups up a lot of code dupliation. But to get > there it first has to fix the pre-existing bug that io_uring compat > contexts don't

RE: [PATCH] powerpc: Select HAVE_FUTEX_CMPXCHG

2020-09-19 Thread David Laight
From: Samuel Holland > Sent: 19 September 2020 04:20 > > On powerpc, access_ok() succeeds for the NULL pointer. This breaks the > dynamic check in futex_detect_cmpxchg(), which expects -EFAULT. As a > result, robust futex operations are not functional on powerpc. access_ok(NULL, sane_count) will

RE: remove the last set_fs() in common code, and remove it for x86 and powerpc v3

2020-09-10 Thread David Laight
> -Original Message- > From: Segher Boessenkool > Sent: 10 September 2020 16:21 > To: David Laight > Cc: 'Christophe Leroy' ; 'Linus Torvalds' > foundation.org>; linux-arch ; Kees Cook > ; the > arch/x86 maintainers ; Nick Desaulniers > ; Linux

RE: remove the last set_fs() in common code, and remove it for x86 and powerpc v3

2020-09-10 Thread David Laight
From: David Laight > Sent: 10 September 2020 10:26 ... > > > I had an 'interesting' idea. > > > > > > Can you use a local asm register variable as an input and output to > > > an 'asm volatile goto' statement? > > > > > > Well you can

RE: remove the last set_fs() in common code, and remove it for x86 and powerpc v3

2020-09-10 Thread David Laight
From: Christophe Leroy > Sent: 10 September 2020 09:14 > > Le 10/09/2020 à 10:04, David Laight a écrit : > > From: Linus Torvalds > >> Sent: 09 September 2020 22:34 > >> On Wed, Sep 9, 2020 at 11:42 AM Segher Boessenkool > >> wrote: > >>>

RE: remove the last set_fs() in common code, and remove it for x86 and powerpc v3

2020-09-10 Thread David Laight
From: Linus Torvalds > Sent: 09 September 2020 22:34 > On Wed, Sep 9, 2020 at 11:42 AM Segher Boessenkool > wrote: > > > > It will not work like this in GCC, no. The LLVM people know about that. > > I do not know why they insist on pushing this, being incompatible and > > everything. > > Umm.

RE: remove the last set_fs() in common code, and remove it for x86 and powerpc v3

2020-09-05 Thread David Laight
From: Christophe Leroy > Sent: 05 September 2020 08:16 > > Le 04/09/2020 à 23:01, David Laight a écrit : > > From: Alexey Dobriyan > >> Sent: 04 September 2020 18:58 ... > > What is this strange %fs register you are talking about. > > Figure 2-4 only has CS,

RE: remove the last set_fs() in common code, and remove it for x86 and powerpc v3

2020-09-04 Thread David Laight
From: Alexey Dobriyan > Sent: 04 September 2020 18:58 > > On Fri, Sep 04, 2020 at 08:00:24AM +0200, Ingo Molnar wrote: > > * Christoph Hellwig wrote: > > > this series removes the last set_fs() used to force a kernel address > > > space for the uaccess code in the kernel read/write/splice code,

RE: [PATCH 12/14] x86: remove address space overrides using set_fs()

2020-09-04 Thread David Laight
From: Linus Torvalds > Sent: 04 September 2020 00:26 > > On Thu, Sep 3, 2020 at 2:30 PM David Laight wrote: > > > > A non-canonical (is that the right term) address between the highest > > valid user address and the lowest valid kernel address (7ffe to fffe?) >

RE: [PATCH 12/14] x86: remove address space overrides using set_fs()

2020-09-03 Thread David Laight
From: Christoph Hellwig > Sent: 03 September 2020 15:23 > > Stop providing the possibility to override the address space using > set_fs() now that there is no need for that any more. To properly > handle the TASK_SIZE_MAX checking for 4 vs 5-level page tables on > x86 a new alternative is

RE: [PATCH 10/10] powerpc: remove address space overrides using set_fs()

2020-09-02 Thread David Laight
From: Christophe Leroy > Sent: 02 September 2020 15:13 > > > Le 02/09/2020 à 15:51, David Laight a écrit : > > From: Christophe Leroy > >> Sent: 02 September 2020 14:25 > >> Le 02/09/2020 à 15:13, David Laight a écrit : > >>> From: Christ

RE: [PATCH 10/10] powerpc: remove address space overrides using set_fs()

2020-09-02 Thread David Laight
From: Christophe Leroy > Sent: 02 September 2020 14:25 > Le 02/09/2020 à 15:13, David Laight a écrit : > > From: Christoph Hellwig > >> Sent: 02 September 2020 13:37 > >> > >> On Wed, Sep 02, 2020 at 08:15:12AM +0200, Christophe Leroy wrote: > >>>

RE: [PATCH 10/10] powerpc: remove address space overrides using set_fs()

2020-09-02 Thread David Laight
From: Christoph Hellwig > Sent: 02 September 2020 13:37 > > On Wed, Sep 02, 2020 at 08:15:12AM +0200, Christophe Leroy wrote: > >> - return 0; > >> - return (size == 0 || size - 1 <= seg.seg - addr); > >> + if (addr >= TASK_SIZE_MAX) > >> + return false; > >> + if (size == 0)

RE: [PATCH 01/10] fs: don't allow kernel reads and writes without iter ops

2020-08-27 Thread David Laight
From: Christoph Hellwig > Sent: 27 August 2020 16:00 > > Don't allow calling ->read or ->write with set_fs as a preparation for > killing off set_fs. All the instances that we use kernel_read/write on > are using the iter ops already. > > If a file has both the regular ->read/->write methods

RE: Re:Re: [PATCH] powerpc: Fix a bug in __div64_32 if divisor is zero

2020-08-24 Thread David Laight
From: Guohua Zhong > Sent: 24 August 2020 14:26 > > >> >In generic version in lib/math/div64.c, there is no checking of 'base' > >> >either. > >> >Do we really want to add this check in the powerpc version only ? > >> > >> >The only user of __div64_32() is do_div() in > >>

RE: [PATCH 09/11] x86: remove address space overrides using set_fs()

2020-08-17 Thread David Laight
From: Christoph Hellwig > Sent: 17 August 2020 08:32 > > Stop providing the possibility to override the address space using > set_fs() now that there is no need for that any more. To properly > handle the TASK_SIZE_MAX checking for 4 vs 5-level page tables on > x86 a new alternative is

RE: [PATCH v2] selftests/powerpc: Fix pkey syscall redefinitions

2020-08-03 Thread David Laight
> > +#undef SYS_pkey_mprotect > > #define SYS_pkey_mprotect 386 > > We shouldn't undef them. > > They should obviously never change, but if the system headers already > have a definition then we should use that, so I think it should be: > > #ifndef SYS_pkey_mprotect > #define

RE: [RFC PATCH 00/35] Move all PCIBIOS* definitions into arch/x86

2020-07-16 Thread David Laight
From: Bjorn Helgaas > Sent: 15 July 2020 23:02 > > On Wed, Jul 15, 2020 at 02:24:21PM +0000, David Laight wrote: > > From: Arnd Bergmann > > > Sent: 15 July 2020 07:47 > > > On Wed, Jul 15, 2020 at 1:46 AM Bjorn Helgaas wrote: > > > > &

RE: [RFC PATCH 00/35] Move all PCIBIOS* definitions into arch/x86

2020-07-16 Thread David Laight
From: Benjamin Herrenschmidt > Sent: 15 July 2020 23:49 > On Wed, 2020-07-15 at 17:12 -0500, Bjorn Helgaas wrote: > > > I've 'played' with PCIe error handling - without much success. > > > What might be useful is for a driver that has just read ~0u to > > > be able to ask 'has there been an error

RE: [RFC PATCH 00/35] Move all PCIBIOS* definitions into arch/x86

2020-07-15 Thread David Laight
From: Oliver O'Halloran > Sent: 15 July 2020 05:19 > > On Wed, Jul 15, 2020 at 8:03 AM Arnd Bergmann wrote: ... > > - config space accesses are very rare compared to memory > > space access and on the hardware side the error handling > > would be similar, but readl/writel don't return

RE: [RFC PATCH 00/35] Move all PCIBIOS* definitions into arch/x86

2020-07-15 Thread David Laight
From: Arnd Bergmann > Sent: 15 July 2020 07:47 > On Wed, Jul 15, 2020 at 1:46 AM Bjorn Helgaas wrote: > > So something like: > > > > void pci_read_config_word(struct pci_dev *dev, int where, u16 *val) > > > > and where we used to return anything non-zero, we just set *val = ~0 > > instead? I

RE: [PATCH v2 1/3] module: Rename module_alloc() to text_alloc() and move to kernel proper

2020-07-15 Thread David Laight
From: Jarkko Sakkinen > Sent: 14 July 2020 17:31 .. > There is one arch (nios2), which uses a regular kzalloc(). This means > that both text_alloc() and text_memfree() need to be weaks symbols and > nios2 needs to have overriding text.c to do its thing. That could be handled by an arch-specific

RE: [PATCH] x86: Fix early boot crash on gcc-10, next try

2020-04-27 Thread David Laight
From: Borislav Petkov > Sent: 25 April 2020 18:53 ... > IOW, something like this (ontop) which takes care of the xen case too. > If it needs to be used by all arches, then I'll split the patch: . > - asm (""); > + prevent_tail_call_optimization(); > } One obvious implementation would be

RE: [musl] Powerpc Linux 'scv' system call ABI proposal take 2

2020-04-21 Thread David Laight
From: Nicholas Piggin > Sent: 20 April 2020 02:10 ... > >> Yes, but does it really matter to optimize this specific usage case > >> for size? glibc, for instance, tries to leverage the syscall mechanism > >> by adding some complex pre-processor asm directives. It optimizes > >> the syscall code

RE: [musl] Powerpc Linux 'scv' system call ABI proposal take 2

2020-04-21 Thread David Laight
From: Adhemerval Zanella > Sent: 21 April 2020 16:01 > > On 21/04/2020 11:39, Rich Felker wrote: > > On Tue, Apr 21, 2020 at 12:28:25PM +0000, David Laight wrote: > >> From: Nicholas Piggin > >>> Sent: 20 April 2020 02:10 > >> ... > >>>&g

<    1   2   3   4   5   6   >