Re: [PATCH 2/4] printk: store instead of processing cont parts

2020-07-20 Thread Joe Perches
On Mon, 2020-07-20 at 11:30 -0700, Linus Torvalds wrote: > On Sun, Jul 19, 2020 at 6:51 PM Sergey Senozhatsky > wrote: > > Do I get it right, what you are saying is - when we process a PR_CONT > > message the cont buffer should already contain previous non-LOG_NEWLINE > > and non-PR_CONT message,

Re: [PATCH][next] printk: ringbuffer: support dataless records

2020-07-20 Thread Sergey Senozhatsky
On (20/07/20 16:07), John Ogness wrote: > > +/* Determine if a logical position refers to a data-less block. */ > +#define LPOS_DATALESS(lpos) ((lpos) & 1UL) > + [..] > @@ -1402,7 +1396,9 @@ static int prb_read(struct printk_ringbuffer *rb, u64 > seq, > /* Copy text data. If it

Re: [PATCH v3 00/12] ima: Fix rule parsing bugs and extend KEXEC_CMDLINE rule support

2020-07-20 Thread Mimi Zohar
[Cc'ing Sasha] On Thu, 2020-07-09 at 01:18 -0500, Tyler Hicks wrote: > I envision patches 1-7 going to stable. The series is ordered in a way > that has all the fixes up front, followed by cleanups, followed by the > feature patch. The breakdown of patches looks like so: > > Memory leak fixes:

Re: [PATCH 2/4] printk: store instead of processing cont parts

2020-07-20 Thread Linus Torvalds
On Sun, Jul 19, 2020 at 6:51 PM Sergey Senozhatsky wrote: > > Do I get it right, what you are saying is - when we process a PR_CONT > message the cont buffer should already contain previous non-LOG_NEWLINE > and non-PR_CONT message, otherwise it's a bug? No. I'm saying that the code that does

Re: [PATCH 1/4] printk: ringbuffer: support dataless records

2020-07-20 Thread John Ogness
On 2020-07-18, John Ogness wrote: > In order to support storage of continuous lines, dataless records must > be allowed. For example, these are generated with the legal calls: > > pr_info(""); > pr_cont("\n"); > > Currently dataless records are denoted by INVALID_LPOS in order to >

Re: [PATCH][next] printk: ringbuffer: support dataless records

2020-07-20 Thread Marco Elver
dataless records, respectively. > > Fixes: ("printk: use the lockless ringbuffer") > Fixes: https://lkml.kernel.org/r/20200718121053.ga691...@elver.google.com > Signed-off-by: John Ogness > --- > based on next-20200720 > > kernel/printk/printk_ringbuffer.c |

[PATCH][next] printk: ringbuffer: support dataless records

2020-07-20 Thread John Ogness
://lkml.kernel.org/r/20200718121053.ga691...@elver.google.com Signed-off-by: John Ogness --- based on next-20200720 kernel/printk/printk_ringbuffer.c | 58 ++- kernel/printk/printk_ringbuffer.h | 15 2 files changed, 35 insertions(+), 38 deletions(-) diff -

Re: [PATCH v4 03/12] powerpc/kexec_file: add helper functions for getting memory ranges

2020-07-20 Thread Hari Bathini
On 20/07/20 6:21 pm, Hari Bathini wrote: > In kexec case, the kernel to be loaded uses the same memory layout as > the running kernel. So, passing on the DT of the running kernel would > be good enough. > > But in case of kdump, different memory ranges are needed to manage > loading the kdump

[PATCH v4 12/12] ppc64/kexec_file: fix kexec load failure with lack of memory hole

2020-07-20 Thread Hari Bathini
The kexec purgatory has to run in real mode. Only the first memory block maybe accessible in real mode. And, unlike the case with panic kernel, no memory is set aside for regular kexec load. Another thing to note is, the memory for crashkernel is reserved at an offset of 128MB. So, when

[PATCH v4 11/12] ppc64/kexec_file: add appropriate regions for memory reserve map

2020-07-20 Thread Hari Bathini
While initrd, elfcorehdr and backup regions are already added to the reserve map, there are a few missing regions that need to be added to the memory reserve map. Add them here. And now that all the changes to load panic kernel are in place, claim likewise. Signed-off-by: Hari Bathini Tested-by:

[PATCH v4 10/12] ppc64/kexec_file: prepare elfcore header for crashing kernel

2020-07-20 Thread Hari Bathini
Prepare elf headers for the crashing kernel's core file using crash_prepare_elf64_headers() and pass on this info to kdump kernel by updating its command line with elfcorehdr parameter. Also, add elfcorehdr location to reserve map to avoid it from being stomped on while booting. Signed-off-by:

[PATCH v4 08/12] ppc64/kexec_file: setup the stack for purgatory

2020-07-20 Thread Hari Bathini
To avoid any weird errors, the purgatory should run with its own stack. Set one up by adding the stack buffer to .data section of the purgatory. Also, setup opal base & entry values in r8 & r9 registers to help early OPAL debugging. Signed-off-by: Hari Bathini Tested-by: Pingfan Liu

[PATCH v4 09/12] ppc64/kexec_file: setup backup region for kdump kernel

2020-07-20 Thread Hari Bathini
Though kdump kernel boots from loaded address, the first 64K bytes of it is copied down to real 0. So, setup a backup region to copy the first 64K bytes of crashed kernel, in purgatory, before booting into kdump kernel. Also, update reserve map with backup region and crashed kernel's memory to

[PATCH v4 07/12] ppc64/kexec_file: add support to relocate purgatory

2020-07-20 Thread Hari Bathini
Right now purgatory implementation is only minimal. But if purgatory code is to be enhanced to copy memory to the backup region and verify sha256 digest, relocations may have to be applied to the purgatory. So, add support to relocate purgatory in kexec_file_load system call by setting up TOC

[PATCH v4 04/12] ppc64/kexec_file: avoid stomping memory used by special regions

2020-07-20 Thread Hari Bathini
crashkernel region could have an overlap with special memory regions like opal, rtas, tce-table & such. These regions are referred to as exclude memory ranges. Setup this ranges during image probe in order to avoid them while finding the buffer for different kdump segments. Override

[PATCH v4 06/12] ppc64/kexec_file: restrict memory usage of kdump kernel

2020-07-20 Thread Hari Bathini
Kdump kernel, used for capturing the kernel core image, is supposed to use only specific memory regions to avoid corrupting the image to be captured. The regions are crashkernel range - the memory reserved explicitly for kdump kernel, memory used for the tce-table, the OPAL region and RTAS region

[PATCH v4 02/12] powerpc/kexec_file: mark PPC64 specific code

2020-07-20 Thread Hari Bathini
Some of the kexec_file_load code isn't PPC64 specific. Move PPC64 specific code from kexec/file_load.c to kexec/file_load_64.c. Also, rename purgatory/trampoline.S to purgatory/trampoline_64.S in the same spirit. No functional changes. Signed-off-by: Hari Bathini Tested-by: Pingfan Liu

[PATCH v4 05/12] powerpc/drmem: make lmb walk a bit more flexible

2020-07-20 Thread Hari Bathini
Currently, numa & prom are the users of drmem lmb walk code. Loading kdump with kexec_file also needs to walk the drmem LMBs to setup the usable memory ranges for kdump kernel. But there are couple of issues in using the code as is. One, walk_drmem_lmb() code is built into the .init section

[PATCH v4 00/12] ppc64: enable kdump support for kexec_file_load syscall

2020-07-20 Thread Hari Bathini
This patch series enables kdump support for kexec_file_load system call (kexec -s -p) on PPC64. The changes are inspired from kexec-tools code but heavily modified for kernel consumption. The first patch adds a weak arch_kexec_locate_mem_hole() function to override locate memory hole logic

[PATCH v4 03/12] powerpc/kexec_file: add helper functions for getting memory ranges

2020-07-20 Thread Hari Bathini
In kexec case, the kernel to be loaded uses the same memory layout as the running kernel. So, passing on the DT of the running kernel would be good enough. But in case of kdump, different memory ranges are needed to manage loading the kdump kernel, booting into it and exporting the elfcore of the

[PATCH v4 01/12] kexec_file: allow archs to handle special regions while locating memory hole

2020-07-20 Thread Hari Bathini
Some architectures may have special memory regions, within the given memory range, which can't be used for the buffer in a kexec segment. Implement weak arch_kexec_locate_mem_hole() definition which arch code may override, to take care of special regions, while trying to locate a memory hole.

Re: [PATCH v5 4/4] printk: use the lockless ringbuffer

2020-07-20 Thread Marco Elver
On Mon, 20 Jul 2020 at 12:20, John Ogness wrote: > > On 2020-07-18, Marco Elver wrote: > > It seems this causes a regression observed at least with newline-only > > printks. > > [...] > > -- >8 -- > > > > --- a/init/main.c > > +++ b/init/main.c > > @@ -1039,6 +1039,10 @@ asmlinkage

Re: [PATCH v5 4/4] printk: use the lockless ringbuffer

2020-07-20 Thread John Ogness
On 2020-07-18, Marco Elver wrote: > It seems this causes a regression observed at least with newline-only > printks. > [...] > -- >8 -- > > --- a/init/main.c > +++ b/init/main.c > @@ -1039,6 +1039,10 @@ asmlinkage __visible void __init start_kernel(void) > sfi_init_late(); >

Re: [PATCH v5 4/4] printk: use the lockless ringbuffer

2020-07-20 Thread Dmitry Vyukov
On Mon, Jul 20, 2020 at 11:41 AM Marco Elver wrote: > > On Mon, 20 Jul 2020 at 10:41, Sergey Senozhatsky > wrote: > > > > On (20/07/20 08:43), Marco Elver wrote: > > > On Sun, Jul 19, 2020 at 12:43PM +0900, Sergey Senozhatsky wrote: > > > > > > As I said, a number of debugging tools use them to

Re: [PATCH v5 4/4] printk: use the lockless ringbuffer

2020-07-20 Thread Marco Elver
On Mon, 20 Jul 2020 at 10:41, Sergey Senozhatsky wrote: > > On (20/07/20 08:43), Marco Elver wrote: > > On Sun, Jul 19, 2020 at 12:43PM +0900, Sergey Senozhatsky wrote: > > > > As I said, a number of debugging tools use them to format reports to be > > more readable (visually separate title and

Re: [PATCH v5 4/4] printk: use the lockless ringbuffer

2020-07-20 Thread Sergey Senozhatsky
On (20/07/20 08:43), Marco Elver wrote: > On Sun, Jul 19, 2020 at 12:43PM +0900, Sergey Senozhatsky wrote: > > As I said, a number of debugging tools use them to format reports to be > more readable (visually separate title and report body, and separate > parts of the report). Also, such reports

Re: [PATCH v5 4/4] printk: use the lockless ringbuffer

2020-07-20 Thread Sergey Senozhatsky
On (20/07/20 08:43), Marco Elver wrote: [..] > please see a full list of newline-print users below. [..] > $> git grep -En '\<(printk|pr_err|pr_warn|pr_info)\>\("\\n"\)' > arch/alpha/kernel/core_wildfire.c:650:printk("\n"); > arch/alpha/kernel/core_wildfire.c:658:printk("\n"); >

RE: [PATCH 07/13] fs/kernel_read_file: Switch buffer size arg to size_t

2020-07-20 Thread David Laight
From: Kees Cook > Sent: 17 July 2020 18:43 > In preparation for further refactoring of kernel_read_file*(), rename > the "max_size" argument to the more accurate "buf_size", and correct > its type to size_t. Add kerndoc to explain the specifics of how the > arguments will be used. Note that with

Re: [PATCH v5 4/4] printk: use the lockless ringbuffer

2020-07-20 Thread Andy Shevchenko
On Mon, Jul 20, 2020 at 9:45 AM Marco Elver wrote: > On Sun, Jul 19, 2020 at 12:43PM +0900, Sergey Senozhatsky wrote: > > On (20/07/18 14:10), Marco Elver wrote: > > > > > > It seems this causes a regression observed at least with newline-only > > > printks. I noticed this during -next testing

Re: [PATCH v5 4/4] printk: use the lockless ringbuffer

2020-07-20 Thread Marco Elver
On Sun, Jul 19, 2020 at 12:43PM +0900, Sergey Senozhatsky wrote: > Hi Marco, > > On (20/07/18 14:10), Marco Elver wrote: > > > > It seems this causes a regression observed at least with newline-only > > printks. I noticed this during -next testing because various debugging > > tools (K*SAN,