Re: [RFC PATCH v2 1/3] selftests/x86: Fixed Makefile for SGX selftest
On 7/11/2019 8:19 PM, Jarkko Sakkinen wrote: On Tue, Apr 23, 2019 at 11:26:21PM -0700, Cedric Xing wrote: The original x86/sgx/Makefile doesn't work when 'x86/sgx' is specified as the test target. This patch fixes that problem, along with minor changes to the dependencies between 'x86' and 'x86/sgx' in selftests/x86/Makefile. Signed-off-by: Cedric Xing --- tools/testing/selftests/x86/Makefile | 12 +++ tools/testing/selftests/x86/sgx/Makefile | 45 +--- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile index 4fc9a42f56ea..1294c5f5b6ca 100644 --- a/tools/testing/selftests/x86/Makefile +++ b/tools/testing/selftests/x86/Makefile @@ -70,11 +70,11 @@ all_32: $(BINARIES_32) all_64: $(BINARIES_64) -all_64: $(SUBDIRS_64) - @for DIR in $(SUBDIRS_64); do \ - BUILD_TARGET=$(OUTPUT)/$$DIR; \ - mkdir $$BUILD_TARGET -p; \ - make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ +all_64: | $(SUBDIRS_64) + @for DIR in $|; do \ + BUILD_TARGET=$(OUTPUT)/$$DIR; \ + mkdir $$BUILD_TARGET -p; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ This is not fix for anything. It is change in semantics. This diff should be isolated to its own commit as you are changing something outside of SGX scope. I have removed all changes to x86/Makefile from v4. The current x86/Makefile only builds but cannot run sgx selftest. I don't see it as an urgent issue though. done EXTRA_CLEAN := $(BINARIES_32) $(BINARIES_64) @@ -90,7 +90,7 @@ ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01) all: warn_32bit_failure warn_32bit_failure: - @echo "Warning: you seem to have a broken 32-bit build" 2>&1; \ + @echo "Warning: you seem to have a broken 32-bit build" 2>&1; \ Please clean this up. echo "environment. This will reduce test coverage of 64-bit" 2>&1; \ echo "kernels. If you are using a Debian-like distribution," 2>&1; \ echo "try:"; 2>&1; \ diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile index 1fd6f2708e81..3af15d7c8644 100644 --- a/tools/testing/selftests/x86/sgx/Makefile +++ b/tools/testing/selftests/x86/sgx/Makefile @@ -2,47 +2,34 @@ top_srcdir = ../../../../.. include ../../lib.mk -HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) -fPIC -ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \ +ifeq ($(shell $(CC) -dumpmachine | cut --delimiter=- -f1),x86_64) +all: all_64 +endif + +HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) +ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIE \ -fno-stack-protector -mrdrnd $(INCLUDES) TEST_CUSTOM_PROGS := $(OUTPUT)/test_sgx all_64: $(TEST_CUSTOM_PROGS) -$(TEST_CUSTOM_PROGS): $(OUTPUT)/main.o $(OUTPUT)/sgx_call.o \ - $(OUTPUT)/encl_piggy.o +$(TEST_CUSTOM_PROGS): main.c sgx_call.S $(OUTPUT)/encl_piggy.o $(CC) $(HOST_CFLAGS) -o $@ $^ -$(OUTPUT)/main.o: main.c - $(CC) $(HOST_CFLAGS) -c $< -o $@ - -$(OUTPUT)/sgx_call.o: sgx_call.S - $(CC) $(HOST_CFLAGS) -c $< -o $@ - -$(OUTPUT)/encl_piggy.o: $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss - $(CC) $(HOST_CFLAGS) -c encl_piggy.S -o $@ +$(OUTPUT)/encl_piggy.o: encl_piggy.S $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss + $(CC) $(HOST_CFLAGS) -I$(OUTPUT) -c $< -o $@ -$(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf $(OUTPUT)/sgxsign +$(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf objcopy --remove-section=.got.plt -O binary $< $@ -$(OUTPUT)/encl.elf: $(OUTPUT)/encl.o $(OUTPUT)/encl_bootstrap.o - $(CC) $(ENCL_CFLAGS) -T encl.lds -o $@ $^ +$(OUTPUT)/encl.elf: encl.lds encl.c encl_bootstrap.S + $(CC) $(ENCL_CFLAGS) -T $^ -o $@ -$(OUTPUT)/encl.o: encl.c - $(CC) $(ENCL_CFLAGS) -c $< -o $@ - -$(OUTPUT)/encl_bootstrap.o: encl_bootstrap.S - $(CC) $(ENCL_CFLAGS) -c $< -o $@ - -$(OUTPUT)/encl.ss: $(OUTPUT)/encl.bin $(OUTPUT)/sgxsign - $(OUTPUT)/sgxsign signing_key.pem $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss +$(OUTPUT)/encl.ss: $(OUTPUT)/sgxsign signing_key.pem $(OUTPUT)/encl.bin + $^ $@ $(OUTPUT)/sgxsign: sgxsign.c $(CC) -o $@ $< -lcrypto -EXTRA_CLEAN := $(OUTPUT)/sgx-selftest $(OUTPUT)/sgx-selftest.o \ - $(OUTPUT)/sgx_call.o $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss \ - $(OUTPUT)/encl.elf $(OUTPUT)/encl.o $(OUTPUT)/encl_bootstrap.o \ - $(OUTPUT)/sgxsign - -.PHONY: clean +EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(addprefix $(OUTPUT)/,\ + encl.elf encl.bin encl.ss encl_piggy.o sgxsign) -- 2.17.1 What are all these changes to the makefile? I don't see mention of them in the commit message. Added description to the commit message i
[RFC PATCH v4 3/3] selftests/x86/sgx: Augment SGX selftest to test vDSO API
This patch augments SGX selftest with two new tests. The first test exercises the newly added callback interface, by marking the whole enclave range as PROT_READ, then calling mprotect() upon #PFs to add necessary PTE permissions per PFEC (#PF Error Code) until the enclave finishes. This test also serves as an example to demonstrate the callback interface. The second test single-steps through __vdso_sgx_enter_enclave() to make sure the call stack can be unwound at every instruction within that vDSO API. Its purpose is to validate the hand-crafted CFI directives in the assembly. Besides the new tests, this patch also fixes minor problems in the Makefile, such as: * appended "--build-id=none" to ld command line to suppress the ".note.gnu.build-id section discarded" linker warning. * removed "--remove-section=.got.plt" from objcopy command line as that section would never exist in statically linked (enclave) images. Signed-off-by: Cedric Xing --- tools/testing/selftests/x86/sgx/Makefile | 6 +- tools/testing/selftests/x86/sgx/main.c | 344 ++--- tools/testing/selftests/x86/sgx/sgx_call.S | 40 ++- 3 files changed, 343 insertions(+), 47 deletions(-) diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile index 3af15d7c8644..31f937e220c4 100644 --- a/tools/testing/selftests/x86/sgx/Makefile +++ b/tools/testing/selftests/x86/sgx/Makefile @@ -14,16 +14,16 @@ TEST_CUSTOM_PROGS := $(OUTPUT)/test_sgx all_64: $(TEST_CUSTOM_PROGS) $(TEST_CUSTOM_PROGS): main.c sgx_call.S $(OUTPUT)/encl_piggy.o - $(CC) $(HOST_CFLAGS) -o $@ $^ + $(CC) $(HOST_CFLAGS) -o $@ $^ -lunwind -ldl -Wl,--defsym,__image_base=0 -pie $(OUTPUT)/encl_piggy.o: encl_piggy.S $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss $(CC) $(HOST_CFLAGS) -I$(OUTPUT) -c $< -o $@ $(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf - objcopy --remove-section=.got.plt -O binary $< $@ + objcopy -O binary $< $@ $(OUTPUT)/encl.elf: encl.lds encl.c encl_bootstrap.S - $(CC) $(ENCL_CFLAGS) -T $^ -o $@ + $(CC) $(ENCL_CFLAGS) -T $^ -o $@ -Wl,--build-id=none $(OUTPUT)/encl.ss: $(OUTPUT)/sgxsign signing_key.pem $(OUTPUT)/encl.bin $^ $@ diff --git a/tools/testing/selftests/x86/sgx/main.c b/tools/testing/selftests/x86/sgx/main.c index e2265f841fb0..e47d6c32623f 100644 --- a/tools/testing/selftests/x86/sgx/main.c +++ b/tools/testing/selftests/x86/sgx/main.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) // Copyright(c) 2016-18 Intel Corporation. +#define _GNU_SOURCE #include #include #include @@ -9,16 +10,31 @@ #include #include #include +#include #include #include #include -#include +#include +#include +#include + +#define UNW_LOCAL_ONLY +#include + #include "encl_piggy.h" #include "defines.h" #include "../../../../../arch/x86/kernel/cpu/sgx/arch.h" #include "../../../../../arch/x86/include/uapi/asm/sgx.h" -static const uint64_t MAGIC = 0x1122334455667788ULL; +#define _Q(x) __Q(x) +#define __Q(x) #x +#define ERRLN "Line " _Q(__LINE__) + +#define X86_EFLAGS_TF (1ul << 8) + +extern char __image_base[]; +size_t eenter; +static size_t vdso_base; struct vdso_symtab { Elf64_Sym *elf_symtab; @@ -26,20 +42,11 @@ struct vdso_symtab { Elf64_Word *elf_hashtab; }; -static void *vdso_get_base_addr(char *envp[]) +static void vdso_init(void) { - Elf64_auxv_t *auxv; - int i; - - for (i = 0; envp[i]; i++); - auxv = (Elf64_auxv_t *)&envp[i + 1]; - - for (i = 0; auxv[i].a_type != AT_NULL; i++) { - if (auxv[i].a_type == AT_SYSINFO_EHDR) - return (void *)auxv[i].a_un.a_val; - } - - return NULL; + vdso_base = getauxval(AT_SYSINFO_EHDR); + if (!vdso_base) + exit(1); } static Elf64_Dyn *vdso_get_dyntab(void *addr) @@ -66,8 +73,9 @@ static void *vdso_get_dyn(void *addr, Elf64_Dyn *dyntab, Elf64_Sxword tag) return NULL; } -static bool vdso_get_symtab(void *addr, struct vdso_symtab *symtab) +static bool vdso_get_symtab(struct vdso_symtab *symtab) { + void *addr = (void *)vdso_base; Elf64_Dyn *dyntab = vdso_get_dyntab(addr); symtab->elf_symtab = vdso_get_dyn(addr, dyntab, DT_SYMTAB); @@ -138,7 +146,7 @@ static bool encl_create(int dev_fd, unsigned long bin_size, base = mmap(NULL, secs->size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_SHARED, dev_fd, 0); if (base == MAP_FAILED) { - perror("mmap"); + perror(ERRLN); return false; } @@ -224,35 +232,292 @@ static bool encl_load(struct sgx_secs *secs, unsigned long bin_size) return false; } -void sgx_call(void *rdi, void *rsi, void *tcs, - struct sgx_enclave_exception *exception, - void *eenter); +int sgx_call(void *rdi, void *rsi, long rdx, void *rcx, void *r8, void *r9, +void *t
[RFC PATCH v4 1/3] selftests/x86/sgx: Fix Makefile for SGX selftest
The original x86/sgx/Makefile didn't work when "x86/sgx" was specified as the test target, nor did it work with "run_tests" as the make target. Yet another problem was that it breaks 32-bit only build. This patch fixes those problems, along with adjustments to compiler/linker options and simplifications to the build rules. Signed-off-by: Cedric Xing --- tools/testing/selftests/x86/sgx/Makefile | 45 +--- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile index 1fd6f2708e81..3af15d7c8644 100644 --- a/tools/testing/selftests/x86/sgx/Makefile +++ b/tools/testing/selftests/x86/sgx/Makefile @@ -2,47 +2,34 @@ top_srcdir = ../../../../.. include ../../lib.mk -HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) -fPIC -ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \ +ifeq ($(shell $(CC) -dumpmachine | cut --delimiter=- -f1),x86_64) +all: all_64 +endif + +HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) +ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIE \ -fno-stack-protector -mrdrnd $(INCLUDES) TEST_CUSTOM_PROGS := $(OUTPUT)/test_sgx all_64: $(TEST_CUSTOM_PROGS) -$(TEST_CUSTOM_PROGS): $(OUTPUT)/main.o $(OUTPUT)/sgx_call.o \ - $(OUTPUT)/encl_piggy.o +$(TEST_CUSTOM_PROGS): main.c sgx_call.S $(OUTPUT)/encl_piggy.o $(CC) $(HOST_CFLAGS) -o $@ $^ -$(OUTPUT)/main.o: main.c - $(CC) $(HOST_CFLAGS) -c $< -o $@ - -$(OUTPUT)/sgx_call.o: sgx_call.S - $(CC) $(HOST_CFLAGS) -c $< -o $@ - -$(OUTPUT)/encl_piggy.o: $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss - $(CC) $(HOST_CFLAGS) -c encl_piggy.S -o $@ +$(OUTPUT)/encl_piggy.o: encl_piggy.S $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss + $(CC) $(HOST_CFLAGS) -I$(OUTPUT) -c $< -o $@ -$(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf $(OUTPUT)/sgxsign +$(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf objcopy --remove-section=.got.plt -O binary $< $@ -$(OUTPUT)/encl.elf: $(OUTPUT)/encl.o $(OUTPUT)/encl_bootstrap.o - $(CC) $(ENCL_CFLAGS) -T encl.lds -o $@ $^ +$(OUTPUT)/encl.elf: encl.lds encl.c encl_bootstrap.S + $(CC) $(ENCL_CFLAGS) -T $^ -o $@ -$(OUTPUT)/encl.o: encl.c - $(CC) $(ENCL_CFLAGS) -c $< -o $@ - -$(OUTPUT)/encl_bootstrap.o: encl_bootstrap.S - $(CC) $(ENCL_CFLAGS) -c $< -o $@ - -$(OUTPUT)/encl.ss: $(OUTPUT)/encl.bin $(OUTPUT)/sgxsign - $(OUTPUT)/sgxsign signing_key.pem $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss +$(OUTPUT)/encl.ss: $(OUTPUT)/sgxsign signing_key.pem $(OUTPUT)/encl.bin + $^ $@ $(OUTPUT)/sgxsign: sgxsign.c $(CC) -o $@ $< -lcrypto -EXTRA_CLEAN := $(OUTPUT)/sgx-selftest $(OUTPUT)/sgx-selftest.o \ - $(OUTPUT)/sgx_call.o $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss \ - $(OUTPUT)/encl.elf $(OUTPUT)/encl.o $(OUTPUT)/encl_bootstrap.o \ - $(OUTPUT)/sgxsign - -.PHONY: clean +EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(addprefix $(OUTPUT)/,\ + encl.elf encl.bin encl.ss encl_piggy.o sgxsign) -- 2.17.1
[RFC PATCH v4 0/3] x86/sgx: Amend vDSO API to allow enclave/host parameter passing on untrusted stack
This patchset is based upon, and can be applied cleanly on SGX1 patch v20 (https://lkml.org/lkml/2019/4/17/344) by Jarkko Sakkinen. The current proposed __vdso_sgx_enter_enclave() requires enclaves to preserve %rsp, which prohibits enclaves from allocating space on the untrusted stack. However, there are existing enclaves (e.g. those built with current Intel SGX SDK libraries) relying on the untrusted stack for passing parameters to untrusted functions (aka. o-calls), which requires allocating space on the untrusted stack by enclaves. After all, passing data via untrusted stack is very easy to implement (by enclaves), with essentially no overhead, therefore is very suitable for exchanging data in small amounts, so could be desirable by future SGX applications as well. This patchset introduces a new ABI for __vdso_sgx_enter_enclave() to anchor its stack frame on %rbp (instead of %rsp), so as to allow enclaves to "push" onto the untrusted stack by decrementing the untrusted %rsp. And in order to service o-calls and to preserve the untrusted stack upon exceptions, the new vDSO API takes one more optional parameter - "callback", which if supplied, will be invoked on all enclave exits (including normal and asynchronous exits). Ample details regarding the new ABI have been documented as comments inside the source code located in arch/x86/entry/vsgx_enter_enclave.S Please note that there was a lengthy discussion on what is the "best" approach for passing parameters for trusted/untrusted calls. Unfortunately there's no single "best" approach that fits all use cases, hence this new ABI has been designed intentionally to accommodate varieties. Therefore, to those not interested in using the untrusted stack, whatever worked with the old ABI proposed by Sean will continue to work with this new ABI. The SGX selftest has been augmented by two new tests. One exercises the new callback interface, and serves as a simple example to showcase how to use it; while the other validates the hand-crafted CFI directives in __vdso_sgx_enter_enclave() by single-stepping through it and unwinding call stack at every instruction. Changelog: · This is version 4 of this patch series with the following changes. - Removed unrelated cosmetic changes. - Rewrote and reformatted comments in arch/x86/entry/vdso/vsgx_enter_enclave.S to follow kernel-doc conventions. New comments now can be converted to nice looking man pages. - Fixed minor issues in the unwinding selftest and now it can run to completion successfully with Sean's fix in vDSO fixup code (https://patchwork.kernel.org/patch/11040801/). Comments have also been added to describe the tests done. · v3 - https://patchwork.kernel.org/cover/11039263/ · v2 - https://patchwork.kernel.org/cover/10914161/ · v1 - https://patchwork.kernel.org/cover/10911615/ Cedric Xing (3): selftests/x86/sgx: Fix Makefile for SGX selftest x86/vdso: Modify __vdso_sgx_enter_enclave() to allow parameter passing on untrusted stack selftests/x86/sgx: Augment SGX selftest to test vDSO API arch/x86/entry/vdso/vsgx_enter_enclave.S | 310 ++- arch/x86/include/uapi/asm/sgx.h| 14 +- tools/testing/selftests/x86/sgx/Makefile | 49 ++- tools/testing/selftests/x86/sgx/main.c | 344 ++--- tools/testing/selftests/x86/sgx/sgx_call.S | 40 ++- 5 files changed, 600 insertions(+), 157 deletions(-) -- 2.17.1
[RFC PATCH v4 2/3] x86/vdso: Modify __vdso_sgx_enter_enclave() to allow parameter passing on untrusted stack
The previous __vdso_sgx_enter_enclave() requires enclaves to preserve %rsp, which prohibits enclaves from allocating and passing parameters for untrusted function calls (aka. o-calls) on the untrusted stack. This patch addresses the problem above by introducing a new ABI that preserves %rbp instead of %rsp. Then __vdso_sgx_enter_enclave() can anchor its frame using %rbp so that enclaves are allowed to allocate space on the untrusted stack by decrementing %rsp. Please note that the stack space allocated in such way will be part of __vdso_sgx_enter_enclave()'s frame so will be freed after __vdso_sgx_enter_enclave() returns. Therefore, __vdso_sgx_enter_enclave() has been revised to take a callback function as an optional parameter, which if supplied, will be invoked upon enclave exits (both AEX (Asynchronous Enclave eXit) and normal exits), with the value of %rsp left off by the enclave as a parameter to the callback. Here's the summary of API/ABI changes in this patch. More details could be found in arch/x86/entry/vdso/vsgx_enter_enclave.S. * 'struct sgx_enclave_exception' is renamed to 'struct sgx_enclave_exinfo' because it is filled upon both AEX (i.e. exceptions) and normal enclave exits. * __vdso_sgx_enter_enclave() anchors its frame using %rbp (instead of %rsp in the previous implementation). * __vdso_sgx_enter_enclave() takes one more parameter - a callback function to be invoked upon enclave exits. This callback is optional, and if not supplied, will cause __vdso_sgx_enter_enclave() to return upon enclave exits (same behavior as previous implementation). * The callback function is given as a parameter the value of %rsp at enclave exit to address data "pushed" by the enclave. A positive value returned by the callback will be treated as an ENCLU leaf for re-entering the enclave, while a zero or negative value will be passed through as the return value of __vdso_sgx_enter_enclave() to its caller. It's also safe to leave callback by longjmp() or by throwing a C++ exception. Signed-off-by: Cedric Xing --- arch/x86/entry/vdso/vsgx_enter_enclave.S | 310 +-- arch/x86/include/uapi/asm/sgx.h | 14 +- 2 files changed, 242 insertions(+), 82 deletions(-) diff --git a/arch/x86/entry/vdso/vsgx_enter_enclave.S b/arch/x86/entry/vdso/vsgx_enter_enclave.S index fe0bf6671d6d..a96542ba6945 100644 --- a/arch/x86/entry/vdso/vsgx_enter_enclave.S +++ b/arch/x86/entry/vdso/vsgx_enter_enclave.S @@ -6,96 +6,256 @@ #include "extable.h" -#define EX_LEAF0*8 -#define EX_TRAPNR 0*8+4 -#define EX_ERROR_CODE 0*8+6 -#define EX_ADDRESS 1*8 +#define EX_LEAF 0*8 +#define EX_TRAPNR 0*8+4 +#define EX_ERROR_CODE 0*8+6 +#define EX_ADDRESS 1*8 .code64 .section .text, "ax" #ifdef SGX_KERNEL_DOC /** - * __vdso_sgx_enter_enclave() - Enter an SGX enclave + * typedef sgx_ex_callback - Callback function for __vdso_sgx_enter_enclave() * - * @leaf: **IN \%eax** - ENCLU leaf, must be EENTER or ERESUME - * @tcs: **IN \%rbx** - TCS, must be non-NULL - * @ex_info: **IN \%rcx** - Optional 'struct sgx_enclave_exception' pointer + * @rdi:value of %%rdi register at enclave exit + * @rsi:value of %%rsi register at enclave exit + * @rdx:value of %%rdx register at enclave exit + * @exinfo: pointer to a sgx_enclave_exinfo structure, which was passed to + * __vdso_sgx_enter_enclave() as input + * @r8: value of %%r8 register at enclave exit + * @r9: value of %%r9 register at enclave exit + * @tcs:TCS used by __vdso_sgx_enter_enclave() to enter the enclave, + * could be used to re-enter the + * enclave + * @ursp: value of %%rsp register at enclave exit + * + * This is the callback function to be invoked upon enclave exits, including + * normal exits (as result of EEXIT), and asynchronous exits (AEX) due to + * exceptions occurred at EENTER or within the enclave. + * + * This callback is expected to follow x86_64 ABI. * * Return: - * **OUT \%eax** - - * %0 on a clean entry/exit to/from the enclave, %-EINVAL if ENCLU leaf is - * not allowed or if TCS is NULL, %-EFAULT if ENCLU or the enclave faults - * - * **Important!** __vdso_sgx_enter_enclave() is **NOT** compliant with the - * x86-64 ABI, i.e. cannot be called from standard C code. As noted above, - * input parameters must be passed via ``%eax``, ``%rbx`` and ``%rcx``, with - * the return value passed via ``%eax``. All registers except ``%rsp`` must - * be treated as volatile from the caller's perspective, including but not - * limited to GPRs, EFLAGS.DF, MXCSR, FCW, etc... Conversely, the enclave - * being run **must** preserve the untrusted ``%rsp`` and stack. + * + * EENTER(2) - causes __vdso_sgx_enter_enclave() to issue ENCLU[EENTER] on the + * same TCS. All GPRs left off by this callback function will be passed through + * back to the enclave, except %%rax, %%rbx and %%rcx, which are clobbered by + * ENCLU[E
Re: [PATCH] kernel/printk: prevent deadlock at calling kmsg_dump from NMI context
On Sat, Jul 13, 2019 at 9:10 AM Sergey Senozhatsky wrote: > > On (07/12/19 17:54), Konstantin Khlebnikov wrote: > > Function kmsg_dump could be invoked from NMI context intentionally or > > accidentally because it is called at various oops/panic paths. > > Kernel message dumpers are not ready to work in NMI context right now. > > They could deadlock on lockbuf_lock or break internal structures. > > Hmm. > printk()-s from NMI go through per-CPU printk_safe/nmi - a bunch of > lockless buffers which is supposed to deal with printk() deadlocks, > including NMI printk()-s. > > include/linux/hardirq.h > > #define nmi_enter() > ... > printk_nmi_enter(); > ... > > #define nmi_exit() > ... > printk_nmi_exit(); > ... > > So we are not really supposed to deadlock. Yep printk() can deal with NMI, but kmsg_dump() is a different beast. It reads printk buffer and saves content into persistent storage like ACPI ERST. > > -ss
[GIT] Sparc
Just a few small changes: 1) Fix console naming inconsistency with hypervisor consoles, from John Paul Adrian Glaubitz 2) Fix userland compilation due to use of u_int, from Masahiro Yamada. Please pull, thanks a lot. The following changes since commit 30d1d92a888d03681b927c76a35181b4eed7071f: Merge tag 'nds32-for-linux-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/greentime/linux (2019-06-03 10:23:41 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git for you to fetch changes up to 61daf52c4ddd433924687850fa04ed85c0d806dd: sparc64: Add missing newline at end of file (2019-07-09 14:53:57 -0700) Geert Uytterhoeven (1): sparc64: Add missing newline at end of file John Paul Adrian Glaubitz (1): sunhv: Fix device naming inconsistency between sunhv_console and sunhv_reg Krzysztof Kozlowski (1): sparc: configs: Remove useless UEVENT_HELPER_PATH Masahiro Yamada (1): sparc: fix unknown type name u_int in uapi header Thomas Huth (1): sparc: Remove redundant copy of the LGPL-2.0 arch/sparc/configs/sparc32_defconfig | 1 - arch/sparc/configs/sparc64_defconfig | 1 - arch/sparc/include/uapi/asm/openpromio.h | 3 +- arch/sparc/lib/COPYING.LIB | 481 - arch/sparc/lib/NG4clear_page.S | 2 +- drivers/tty/serial/sunhv.c | 2 +- 6 files changed, 3 insertions(+), 487 deletions(-) delete mode 100644 arch/sparc/lib/COPYING.LIB
[GIT] Ide
Please pull to get this small cleanup. Thanks. The following changes since commit 54dee406374ce8adb352c48e175176247cb8db7c: Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux (2019-05-22 08:36:16 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide.git for you to fetch changes up to 13990cf8a180cc070f0b1266140e799db8754289: ide: use BIT() macro for defining bit-flags (2019-07-09 14:52:14 -0700) Amol Surati (1): ide: use BIT() macro for defining bit-flags include/linux/ide.h | 272 +- 1 file changed, 136 insertions(+), 136 deletions(-)
[GIT] Networking
1) Fix excessive stack usage in cxgb4, from Arnd Bergmann. 2) Missing skb queue lock init in tipc, from Chris Packham. 3) Fix some regressions in ipv6 flow label handling, from Eric Dumazet. 4) Elide flow dissection of local packets in FIB rules, from Petar Penkov. 5) Fix TLS support build failure in mlx5, from Tariq Toukab. Please pull, thanks a lot. The following changes since commit a131c2bf165684315f606fdd88cf80be22ba32f3: Merge tag 'acpi-5.3-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm (2019-07-11 11:17:09 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git for you to fetch changes up to 25a09ce79639a8775244808c17282c491cff89cf: ppp: mppe: Revert "ppp: mppe: Add softdep to arc4" (2019-07-12 22:58:49 -0700) Arnd Bergmann (2): davinci_cpdma: don't cast dma_addr_t to pointer cxgb4: reduce kernel stack usage in cudbg_collect_mem_region() Aya Levin (3): net/mlx5e: Fix return value from timeout recover function net/mlx5e: Fix error flow in tx reporter diagnose net/mlx5e: IPoIB, Add error path in mlx5_rdma_setup_rn Chris Packham (1): tipc: ensure head->lock is initialised Christian Lamparter (1): net: dsa: qca8k: replace legacy gpio include Cong Wang (1): hsr: switch ->dellink() to ->ndo_uninit() David S. Miller (4): Merge branch 'mlx5-build-fixes' Merge tag 'mlx5-fixes-2019-07-11' of git://git.kernel.org/.../saeed/linux Merge branch 'net/rds-fixes' of git://git.kernel.org/.../ssantosh/linux Merge branch 'nfp-flower-bugs' Denis Efremov (1): net: phy: make exported variables non-static Eli Britstein (1): net/mlx5e: Fix port tunnel GRE entropy control Eric Biggers (1): ppp: mppe: Revert "ppp: mppe: Add softdep to arc4" Eric Dumazet (3): ipv6: tcp: fix flowlabels reflection for RST packets ipv6: fix potential crash in ip6_datagram_dst_update() ipv6: fix static key imbalance in fl_create() Gerd Rausch (3): Revert "RDS: IB: split the mr registration and invalidation path" rds: Accept peer connection reject messages due to incompatible version rds: Return proper "tos" value to user-space Jiangfeng Xiao (1): net: hisilicon: Use devm_platform_ioremap_resource Joe Perches (2): net: ethernet: mediatek: Fix misuses of GENMASK macro net: stmmac: Fix misuses of GENMASK macro John Hurley (2): nfp: flower: fix ethernet check on match fields nfp: flower: ensure ip protocol is specified for L4 matches Maor Gottlieb (1): net/mlx5: E-Switch, Fix default encap mode Nathan Chancellor (1): net/mlx5e: Convert single case statement switch statements into if statements Petar Penkov (1): net: fib_rules: do not flow dissect local packets Roman Mashak (1): tc-tests: updated skbedit tests Saeed Mahameed (3): net/mlx5e: Rx, Fix checksum calculation for new hardware net/mlx5e: Fix unused variable warning when CONFIG_MLX5_ESWITCH is off net/mlx5: E-Switch, Reduce ingress acl modify metadata stack usage Santosh Shilimkar (2): rds: fix reordering with composite message notification rds: avoid version downgrade to legitimate newer peer connections Taehee Yoo (1): net: openvswitch: do not update max_headroom if new headroom is equal to old headroom Tariq Toukan (1): net/mlx5e: Fix compilation error in TLS code Vlad Buslov (2): net: sched: Fix NULL-pointer dereference in tc_indr_block_ing_cmd() net/mlx5e: Provide cb_list pointer when setting up tc block on rep yangxingwu (1): ipv6: Use ipv6_authlen for len drivers/net/dsa/qca8k.c | 2 +- drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 19 ++--- drivers/net/ethernet/hisilicon/hip04_eth.c | 7 +--- drivers/net/ethernet/hisilicon/hisi_femac.c | 7 +--- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c| 7 +--- drivers/net/ethernet/hisilicon/hns_mdio.c| 4 +- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- drivers/net/ethernet/mediatek/mtk_sgmii.c| 2 +- drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c | 10 ++--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c | 34 +--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c| 8 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 5 ++- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 7 +++- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c|
Re: [PATCH] kernel/printk: prevent deadlock at calling kmsg_dump from NMI context
On (07/12/19 17:54), Konstantin Khlebnikov wrote: > Function kmsg_dump could be invoked from NMI context intentionally or > accidentally because it is called at various oops/panic paths. > Kernel message dumpers are not ready to work in NMI context right now. > They could deadlock on lockbuf_lock or break internal structures. Hmm. printk()-s from NMI go through per-CPU printk_safe/nmi - a bunch of lockless buffers which is supposed to deal with printk() deadlocks, including NMI printk()-s. include/linux/hardirq.h #define nmi_enter() ... printk_nmi_enter(); ... #define nmi_exit() ... printk_nmi_exit(); ... So we are not really supposed to deadlock. -ss
Re: [PATCH] kbuild: add --hash-style= and --build-id unconditionally
On Sat, Jul 13, 2019 at 01:01:10PM +0900, Masahiro Yamada wrote: > As commit 1e0221374e30 ("mips: vdso: drop unnecessary cc-ldoption") > explained, these flags are supported by the minimal required version > of binutils. > > Signed-off-by: Masahiro Yamada Also supported by ld.lld; I tested both arm and x86, the build ID shows up fine. Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor
[PATCH v2 05/13] powerpc/pseries: Add and use LPPACA_SIZE constant
Helps document what the hard-coded number means. Also take the opportunity to fix an #endif comment. Suggested-by: Alexey Kardashevskiy Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/kernel/paca.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 9cc91d03ab62..854105db5cff 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -56,6 +56,8 @@ static void *__init alloc_paca_data(unsigned long size, unsigned long align, #ifdef CONFIG_PPC_PSERIES +#define LPPACA_SIZE 0x400 + /* * See asm/lppaca.h for more detail. * @@ -69,7 +71,7 @@ static inline void init_lppaca(struct lppaca *lppaca) *lppaca = (struct lppaca) { .desc = cpu_to_be32(0xd397d781),/* "LpPa" */ - .size = cpu_to_be16(0x400), + .size = cpu_to_be16(LPPACA_SIZE), .fpregs_in_use = 1, .slb_count = cpu_to_be16(64), .vmxregs_in_use = 0, @@ -79,19 +81,18 @@ static inline void init_lppaca(struct lppaca *lppaca) static struct lppaca * __init new_lppaca(int cpu, unsigned long limit) { struct lppaca *lp; - size_t size = 0x400; - BUILD_BUG_ON(size < sizeof(struct lppaca)); + BUILD_BUG_ON(sizeof(struct lppaca) > LPPACA_SIZE); if (early_cpu_has_feature(CPU_FTR_HVMODE)) return NULL; - lp = alloc_paca_data(size, 0x400, limit, cpu); + lp = alloc_paca_data(LPPACA_SIZE, 0x400, limit, cpu); init_lppaca(lp); return lp; } -#endif /* CONFIG_PPC_BOOK3S */ +#endif /* CONFIG_PPC_PSERIES */ #ifdef CONFIG_PPC_BOOK3S_64
[PATCH v2 09/13] powerpc/pseries/svm: Export guest SVM status to user space via sysfs
From: Ryan Grimm User space might want to know it's running in a secure VM. It can't do a mfmsr because mfmsr is a privileged instruction. The solution here is to create a cpu attribute: /sys/devices/system/cpu/svm which will read 0 or 1 based on the S bit of the guest's CPU 0. Signed-off-by: Ryan Grimm Reviewed-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/kernel/sysfs.c | 29 + 1 file changed, 29 insertions(+) diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index e2147d7c9e72..f7100ab77d29 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "cacheinfo.h" #include "setup.h" @@ -715,6 +716,32 @@ static struct device_attribute pa6t_attrs[] = { #endif /* HAS_PPC_PMC_PA6T */ #endif /* HAS_PPC_PMC_CLASSIC */ +#ifdef CONFIG_PPC_SVM +static void get_svm(void *val) +{ + u32 *value = val; + + *value = is_secure_guest(); +} + +static ssize_t show_svm(struct device *dev, struct device_attribute *attr, char *buf) +{ + u32 val; + smp_call_function_single(0, get_svm, &val, 1); + return sprintf(buf, "%u\n", val); +} +static DEVICE_ATTR(svm, 0444, show_svm, NULL); + +static void create_svm_file(void) +{ + device_create_file(cpu_subsys.dev_root, &dev_attr_svm); +} +#else +static void create_svm_file(void) +{ +} +#endif /* CONFIG_PPC_SVM */ + static int register_cpu_online(unsigned int cpu) { struct cpu *c = &per_cpu(cpu_devices, cpu); @@ -1058,6 +1085,8 @@ static int __init topology_init(void) sysfs_create_dscr_default(); #endif /* CONFIG_PPC64 */ + create_svm_file(); + return 0; } subsys_initcall(topology_init);
[PATCH v2 13/13] powerpc/configs: Enable secure guest support in pseries and ppc64 defconfigs
From: Ryan Grimm Enables running as a secure guest in platforms with an Ultravisor. Signed-off-by: Ryan Grimm Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/configs/ppc64_defconfig | 1 + arch/powerpc/configs/pseries_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig index c63b019ba753..0b04c5ca9e13 100644 --- a/arch/powerpc/configs/ppc64_defconfig +++ b/arch/powerpc/configs/ppc64_defconfig @@ -31,6 +31,7 @@ CONFIG_DTL=y CONFIG_SCANLOG=m CONFIG_PPC_SMLPAR=y CONFIG_IBMEBUS=y +CONFIG_PPC_SVM=y CONFIG_PPC_MAPLE=y CONFIG_PPC_PASEMI=y CONFIG_PPC_PASEMI_IOMMU=y diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig index 38abc9c1770a..26126b4d4de3 100644 --- a/arch/powerpc/configs/pseries_defconfig +++ b/arch/powerpc/configs/pseries_defconfig @@ -42,6 +42,7 @@ CONFIG_DTL=y CONFIG_SCANLOG=m CONFIG_PPC_SMLPAR=y CONFIG_IBMEBUS=y +CONFIG_PPC_SVM=y # CONFIG_PPC_PMAC is not set CONFIG_RTAS_FLASH=m CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
[PATCH v2 12/13] powerpc/pseries/svm: Force SWIOTLB for secure guests
From: Anshuman Khandual SWIOTLB checks range of incoming CPU addresses to be bounced and sees if the device can access it through its DMA window without requiring bouncing. In such cases it just chooses to skip bouncing. But for cases like secure guests on powerpc platform all addresses need to be bounced into the shared pool of memory because the host cannot access it otherwise. Hence the need to do the bouncing is not related to device's DMA window and use of bounce buffers is forced by setting swiotlb_force. Also, connect the shared memory conversion functions into the ARCH_HAS_MEM_ENCRYPT hooks and call swiotlb_update_mem_attributes() to convert SWIOTLB's memory pool to shared memory. Signed-off-by: Anshuman Khandual [ bauerman: Use ARCH_HAS_MEM_ENCRYPT hooks to share swiotlb memory pool. ] Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/mem_encrypt.h | 26 +++ arch/powerpc/platforms/pseries/Kconfig | 3 ++ arch/powerpc/platforms/pseries/svm.c | 45 ++ 3 files changed, 74 insertions(+) diff --git a/arch/powerpc/include/asm/mem_encrypt.h b/arch/powerpc/include/asm/mem_encrypt.h new file mode 100644 index ..d8d5a7fcf298 --- /dev/null +++ b/arch/powerpc/include/asm/mem_encrypt.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * SVM helper functions + * + * Copyright 2019 IBM Corporation + */ + +#ifndef _ASM_POWERPC_MEM_ENCRYPT_H +#define _ASM_POWERPC_MEM_ENCRYPT_H + +#include + +static inline bool mem_encrypt_active(void) +{ + return is_secure_guest(); +} + +static inline bool force_dma_unencrypted(struct device *dev) +{ + return is_secure_guest(); +} + +int set_memory_encrypted(unsigned long addr, int numpages); +int set_memory_decrypted(unsigned long addr, int numpages); + +#endif /* _ASM_POWERPC_MEM_ENCRYPT_H */ diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index d09deb05bb66..9e35cf73 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -149,6 +149,9 @@ config PAPR_SCM config PPC_SVM bool "Secure virtual machine (SVM) support for POWER" depends on PPC_PSERIES + select SWIOTLB + select ARCH_HAS_MEM_ENCRYPT + select ARCH_HAS_FORCE_DMA_UNENCRYPTED help There are certain POWER platforms which support secure guests using the Protected Execution Facility, with the help of an Ultravisor diff --git a/arch/powerpc/platforms/pseries/svm.c b/arch/powerpc/platforms/pseries/svm.c index c508196f7c83..618622d636d5 100644 --- a/arch/powerpc/platforms/pseries/svm.c +++ b/arch/powerpc/platforms/pseries/svm.c @@ -7,8 +7,53 @@ */ #include +#include +#include +#include #include +static int __init init_svm(void) +{ + if (!is_secure_guest()) + return 0; + + /* Don't release the SWIOTLB buffer. */ + ppc_swiotlb_enable = 1; + + /* +* Since the guest memory is inaccessible to the host, devices always +* need to use the SWIOTLB buffer for DMA even if dma_capable() says +* otherwise. +*/ + swiotlb_force = SWIOTLB_FORCE; + + /* Share the SWIOTLB buffer with the host. */ + swiotlb_update_mem_attributes(); + + return 0; +} +machine_early_initcall(pseries, init_svm); + +int set_memory_encrypted(unsigned long addr, int numpages) +{ + if (!PAGE_ALIGNED(addr)) + return -EINVAL; + + uv_unshare_page(PHYS_PFN(__pa(addr)), numpages); + + return 0; +} + +int set_memory_decrypted(unsigned long addr, int numpages) +{ + if (!PAGE_ALIGNED(addr)) + return -EINVAL; + + uv_share_page(PHYS_PFN(__pa(addr)), numpages); + + return 0; +} + /* There's one dispatch log per CPU. */ #define NR_DTL_PAGE (DISPATCH_LOG_BYTES * CONFIG_NR_CPUS / PAGE_SIZE)
Re: [PATCH v2] printk: Do not lose last line in kmsg buffer dump
On (07/12/19 15:11), Petr Mladek wrote: > > Looks correct to me as well. > > > > Reviewed-by: Sergey Senozhatsky > > The patch has been committed into printk.git, branch for-5.3-fixes. > > I am still a bit undecided whether to send pull request the following > week or wait for 5.4. On one hand, it is very old bug (since 3.5). > On the other hand, I think that it was not reported/fixed earlier > only because it was hard to notice. And loosing the very last message > is quite pity. My call would be - let's wait till next merge window. -ss
[PATCH v2 11/13] powerpc/pseries/iommu: Don't use dma_iommu_ops on secure guests
Secure guest memory is inacessible to devices so regular DMA isn't possible. In that case set devices' dma_map_ops to NULL so that the generic DMA code path will use SWIOTLB and DMA to bounce buffers. Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/platforms/pseries/iommu.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 03bbb299320e..7d9550edb700 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -50,6 +50,7 @@ #include #include #include +#include #include "pseries.h" @@ -1332,7 +1333,10 @@ void iommu_init_early_pSeries(void) of_reconfig_notifier_register(&iommu_reconfig_nb); register_memory_notifier(&iommu_mem_nb); - set_pci_dma_ops(&dma_iommu_ops); + if (is_secure_guest()) + set_pci_dma_ops(NULL); + else + set_pci_dma_ops(&dma_iommu_ops); } static int __init disable_multitce(char *str)
[PATCH v2 07/13] powerpc/pseries/svm: Use shared memory for Debug Trace Log (DTL)
From: Anshuman Khandual Secure guests need to share the DTL buffers with the hypervisor. To that end, use a kmem_cache constructor which converts the underlying buddy allocated SLUB cache pages into shared memory. Signed-off-by: Anshuman Khandual Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/svm.h | 5 arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/setup.c | 5 +++- arch/powerpc/platforms/pseries/svm.c| 40 + 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/svm.h b/arch/powerpc/include/asm/svm.h index fef3740f46a6..f253116c31fc 100644 --- a/arch/powerpc/include/asm/svm.h +++ b/arch/powerpc/include/asm/svm.h @@ -15,6 +15,9 @@ static inline bool is_secure_guest(void) return mfmsr() & MSR_S; } +void dtl_cache_ctor(void *addr); +#define get_dtl_cache_ctor() (is_secure_guest() ? dtl_cache_ctor : NULL) + #else /* CONFIG_PPC_SVM */ static inline bool is_secure_guest(void) @@ -22,5 +25,7 @@ static inline bool is_secure_guest(void) return false; } +#define get_dtl_cache_ctor() NULL + #endif /* CONFIG_PPC_SVM */ #endif /* _ASM_POWERPC_SVM_H */ diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index ab3d59aeacca..a420ef4c9d8e 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_IBMVIO) += vio.o obj-$(CONFIG_IBMEBUS) += ibmebus.o obj-$(CONFIG_PAPR_SCM) += papr_scm.o obj-$(CONFIG_PPC_SPLPAR) += vphn.o +obj-$(CONFIG_PPC_SVM) += svm.o ifdef CONFIG_PPC_PSERIES obj-$(CONFIG_SUSPEND) += suspend.o diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index cb418d2bb1ac..3009b5bd11d2 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -73,6 +73,7 @@ #include #include #include +#include #include "pseries.h" #include "../../../../drivers/pci/pci.h" @@ -301,8 +302,10 @@ static inline int alloc_dispatch_logs(void) static int alloc_dispatch_log_kmem_cache(void) { + void (*ctor)(void *) = get_dtl_cache_ctor(); + dtl_cache = kmem_cache_create("dtl", DISPATCH_LOG_BYTES, - DISPATCH_LOG_BYTES, 0, NULL); + DISPATCH_LOG_BYTES, 0, ctor); if (!dtl_cache) { pr_warn("Failed to create dispatch trace log buffer cache\n"); pr_warn("Stolen time statistics will be unreliable\n"); diff --git a/arch/powerpc/platforms/pseries/svm.c b/arch/powerpc/platforms/pseries/svm.c new file mode 100644 index ..c508196f7c83 --- /dev/null +++ b/arch/powerpc/platforms/pseries/svm.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Secure VM platform + * + * Copyright 2019 IBM Corporation + * Author: Anshuman Khandual + */ + +#include +#include + +/* There's one dispatch log per CPU. */ +#define NR_DTL_PAGE (DISPATCH_LOG_BYTES * CONFIG_NR_CPUS / PAGE_SIZE) + +static struct page *dtl_page_store[NR_DTL_PAGE]; +static long dtl_nr_pages; + +static bool is_dtl_page_shared(struct page *page) +{ + long i; + + for (i = 0; i < dtl_nr_pages; i++) + if (dtl_page_store[i] == page) + return true; + + return false; +} + +void dtl_cache_ctor(void *addr) +{ + unsigned long pfn = PHYS_PFN(__pa(addr)); + struct page *page = pfn_to_page(pfn); + + if (!is_dtl_page_shared(page)) { + dtl_page_store[dtl_nr_pages] = page; + dtl_nr_pages++; + WARN_ON(dtl_nr_pages >= NR_DTL_PAGE); + uv_share_page(pfn, 1); + } +}
[PATCH v2 08/13] powerpc/pseries/svm: Unshare all pages before kexecing a new kernel
From: Ram Pai A new kernel deserves a clean slate. Any pages shared with the hypervisor is unshared before invoking the new kernel. However there are exceptions. If the new kernel is invoked to dump the current kernel, or if there is a explicit request to preserve the state of the current kernel, unsharing of pages is skipped. NOTE: While testing crashkernel, make sure at least 256M is reserved for crashkernel. Otherwise SWIOTLB allocation will fail and crash kernel will fail to boot. Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/ultravisor-api.h | 1 + arch/powerpc/include/asm/ultravisor.h | 6 ++ arch/powerpc/kernel/machine_kexec_64.c| 8 3 files changed, 15 insertions(+) diff --git a/arch/powerpc/include/asm/ultravisor-api.h b/arch/powerpc/include/asm/ultravisor-api.h index c7513bbadf57..ab4f756cb91c 100644 --- a/arch/powerpc/include/asm/ultravisor-api.h +++ b/arch/powerpc/include/asm/ultravisor-api.h @@ -29,5 +29,6 @@ #define UV_UNSHARE_PAGE0xF134 #define UV_PAGE_INVAL 0xF138 #define UV_SVM_TERMINATE 0xF13C +#define UV_UNSHARE_ALL_PAGES 0xF140 #endif /* _ASM_POWERPC_ULTRAVISOR_API_H */ diff --git a/arch/powerpc/include/asm/ultravisor.h b/arch/powerpc/include/asm/ultravisor.h index f7418b663a0e..80d4beaf61b8 100644 --- a/arch/powerpc/include/asm/ultravisor.h +++ b/arch/powerpc/include/asm/ultravisor.h @@ -106,6 +106,12 @@ static inline int uv_unshare_page(u64 pfn, u64 npages) return ucall(UV_UNSHARE_PAGE, retbuf, pfn, npages); } +static inline int uv_unshare_all_pages(void) +{ + unsigned long retbuf[UCALL_BUFSIZE]; + + return ucall(UV_UNSHARE_ALL_PAGES, retbuf); +} #endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_ULTRAVISOR_H */ diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c index 75692c327ba0..b3d87d32e8f7 100644 --- a/arch/powerpc/kernel/machine_kexec_64.c +++ b/arch/powerpc/kernel/machine_kexec_64.c @@ -31,6 +31,7 @@ #include #include #include +#include int default_machine_kexec_prepare(struct kimage *image) { @@ -329,6 +330,13 @@ void default_machine_kexec(struct kimage *image) #ifdef CONFIG_PPC_PSERIES kexec_paca.lppaca_ptr = NULL; #endif + + if (is_secure_guest() && !(image->preserve_context || + image->type == KEXEC_TYPE_CRASH)) { + uv_unshare_all_pages(); + printk("kexec: Unshared all shared pages.\n"); + } + paca_ptrs[kexec_paca.paca_index] = &kexec_paca; setup_paca(&kexec_paca);
[PATCH v2 10/13] powerpc/pseries/svm: Disable doorbells in SVM guests
From: Sukadev Bhattiprolu Normally, the HV emulates some instructions like MSGSNDP, MSGCLRP from a KVM guest. To emulate the instructions, it must first read the instruction from the guest's memory and decode its parameters. However for a secure guest (aka SVM), the page containing the instruction is in secure memory and the HV cannot access directly. It would need the Ultravisor (UV) to facilitate accessing the instruction and parameters but the UV currently does not have the support for such accesses. Until the UV has such support, disable doorbells in SVMs. This might incur a performance hit but that is yet to be quantified. With this patch applied (needed only in SVMs not needed for HV) we are able to launch SVM guests with multi-core support. Eg: qemu -smp sockets=2,cores=2,threads=2. Fix suggested by Benjamin Herrenschmidt. Thanks to input from Paul Mackerras, Ram Pai and Michael Anderson. Signed-off-by: Sukadev Bhattiprolu Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/platforms/pseries/smp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c index 3df46123cce3..95a5c24a1544 100644 --- a/arch/powerpc/platforms/pseries/smp.c +++ b/arch/powerpc/platforms/pseries/smp.c @@ -45,6 +45,7 @@ #include #include #include +#include #include "pseries.h" #include "offline_states.h" @@ -225,7 +226,7 @@ static __init void pSeries_smp_probe_xics(void) { xics_smp_probe(); - if (cpu_has_feature(CPU_FTR_DBELL)) + if (cpu_has_feature(CPU_FTR_DBELL) && !is_secure_guest()) smp_ops->cause_ipi = smp_pseries_cause_ipi; else smp_ops->cause_ipi = icp_ops->cause_ipi;
[PATCH v2 04/13] powerpc/pseries/svm: Add helpers for UV_SHARE_PAGE and UV_UNSHARE_PAGE
From: Ram Pai These functions are used when the guest wants to grant the hypervisor access to certain pages. Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/ultravisor-api.h | 2 ++ arch/powerpc/include/asm/ultravisor.h | 15 +++ 2 files changed, 17 insertions(+) diff --git a/arch/powerpc/include/asm/ultravisor-api.h b/arch/powerpc/include/asm/ultravisor-api.h index fe9a0d8d7673..c7513bbadf57 100644 --- a/arch/powerpc/include/asm/ultravisor-api.h +++ b/arch/powerpc/include/asm/ultravisor-api.h @@ -25,6 +25,8 @@ #define UV_UNREGISTER_MEM_SLOT 0xF124 #define UV_PAGE_IN 0xF128 #define UV_PAGE_OUT0xF12C +#define UV_SHARE_PAGE 0xF130 +#define UV_UNSHARE_PAGE0xF134 #define UV_PAGE_INVAL 0xF138 #define UV_SVM_TERMINATE 0xF13C diff --git a/arch/powerpc/include/asm/ultravisor.h b/arch/powerpc/include/asm/ultravisor.h index f5dc5af739b8..f7418b663a0e 100644 --- a/arch/powerpc/include/asm/ultravisor.h +++ b/arch/powerpc/include/asm/ultravisor.h @@ -91,6 +91,21 @@ static inline int uv_svm_terminate(u64 lpid) return ucall(UV_SVM_TERMINATE, retbuf, lpid); } + +static inline int uv_share_page(u64 pfn, u64 npages) +{ + unsigned long retbuf[UCALL_BUFSIZE]; + + return ucall(UV_SHARE_PAGE, retbuf, pfn, npages); +} + +static inline int uv_unshare_page(u64 pfn, u64 npages) +{ + unsigned long retbuf[UCALL_BUFSIZE]; + + return ucall(UV_UNSHARE_PAGE, retbuf, pfn, npages); +} + #endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_ULTRAVISOR_H */
[PATCH v2 06/13] powerpc/pseries/svm: Use shared memory for LPPACA structures
From: Anshuman Khandual LPPACA structures need to be shared with the host. Hence they need to be in shared memory. Instead of allocating individual chunks of memory for a given structure from memblock, a contiguous chunk of memory is allocated and then converted into shared memory. Subsequent allocation requests will come from the contiguous chunk which will be always shared memory for all structures. While we are able to use a kmem_cache constructor for the Debug Trace Log, LPPACAs are allocated very early in the boot process (before SLUB is available) so we need to use a simpler scheme here. Introduce helper is_svm_platform() which uses the S bit of the MSR to tell whether we're running as a secure guest. Signed-off-by: Anshuman Khandual Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/svm.h | 26 arch/powerpc/kernel/paca.c | 43 +- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/svm.h b/arch/powerpc/include/asm/svm.h new file mode 100644 index ..fef3740f46a6 --- /dev/null +++ b/arch/powerpc/include/asm/svm.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * SVM helper functions + * + * Copyright 2019 Anshuman Khandual, IBM Corporation. + */ + +#ifndef _ASM_POWERPC_SVM_H +#define _ASM_POWERPC_SVM_H + +#ifdef CONFIG_PPC_SVM + +static inline bool is_secure_guest(void) +{ + return mfmsr() & MSR_S; +} + +#else /* CONFIG_PPC_SVM */ + +static inline bool is_secure_guest(void) +{ + return false; +} + +#endif /* CONFIG_PPC_SVM */ +#endif /* _ASM_POWERPC_SVM_H */ diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 854105db5cff..a9622f4b45bb 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "setup.h" @@ -58,6 +60,41 @@ static void *__init alloc_paca_data(unsigned long size, unsigned long align, #define LPPACA_SIZE 0x400 +static void *__init alloc_shared_lppaca(unsigned long size, unsigned long align, + unsigned long limit, int cpu) +{ + size_t shared_lppaca_total_size = PAGE_ALIGN(nr_cpu_ids * LPPACA_SIZE); + static unsigned long shared_lppaca_size; + static void *shared_lppaca; + void *ptr; + + if (!shared_lppaca) { + memblock_set_bottom_up(true); + + shared_lppaca = + memblock_alloc_try_nid(shared_lppaca_total_size, + PAGE_SIZE, MEMBLOCK_LOW_LIMIT, + limit, NUMA_NO_NODE); + if (!shared_lppaca) + panic("cannot allocate shared data"); + + memblock_set_bottom_up(false); + uv_share_page(PHYS_PFN(__pa(shared_lppaca)), + shared_lppaca_total_size >> PAGE_SHIFT); + } + + ptr = shared_lppaca + shared_lppaca_size; + shared_lppaca_size += size; + + /* +* This is very early in boot, so no harm done if the kernel crashes at +* this point. +*/ + BUG_ON(shared_lppaca_size >= shared_lppaca_total_size); + + return ptr; +} + /* * See asm/lppaca.h for more detail. * @@ -87,7 +124,11 @@ static struct lppaca * __init new_lppaca(int cpu, unsigned long limit) if (early_cpu_has_feature(CPU_FTR_HVMODE)) return NULL; - lp = alloc_paca_data(LPPACA_SIZE, 0x400, limit, cpu); + if (is_secure_guest()) + lp = alloc_shared_lppaca(LPPACA_SIZE, 0x400, limit, cpu); + else + lp = alloc_paca_data(LPPACA_SIZE, 0x400, limit, cpu); + init_lppaca(lp); return lp;
[PATCH v2 03/13] powerpc/prom_init: Add the ESM call to prom_init
From: Ram Pai Make the Enter-Secure-Mode (ESM) ultravisor call to switch the VM to secure mode. Add "svm=" command line option to turn on switching to secure mode. Signed-off-by: Ram Pai [ andmike: Generate an RTAS os-term hcall when the ESM ucall fails. ] Signed-off-by: Michael Anderson [ bauerman: Cleaned up the code a bit. ] Signed-off-by: Thiago Jung Bauermann --- .../admin-guide/kernel-parameters.txt | 5 + arch/powerpc/include/asm/ultravisor-api.h | 1 + arch/powerpc/kernel/prom_init.c | 99 +++ 3 files changed, 105 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 7b15abf7db21..c611891b5992 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4585,6 +4585,11 @@ /sys/power/pm_test). Only available when CONFIG_PM_DEBUG is set. Default value is 5. + svm=[PPC] + Format: { on | off | y | n | 1 | 0 } + This parameter controls use of the Protected + Execution Facility on pSeries. + swapaccount=[0|1] [KNL] Enable accounting of swap in memory resource controller if no parameter or 1 is given or disable diff --git a/arch/powerpc/include/asm/ultravisor-api.h b/arch/powerpc/include/asm/ultravisor-api.h index c8180427fa01..fe9a0d8d7673 100644 --- a/arch/powerpc/include/asm/ultravisor-api.h +++ b/arch/powerpc/include/asm/ultravisor-api.h @@ -19,6 +19,7 @@ /* opcodes */ #define UV_WRITE_PATE 0xF104 +#define UV_ESM 0xF110 #define UV_RETURN 0xF11C #define UV_REGISTER_MEM_SLOT 0xF120 #define UV_UNREGISTER_MEM_SLOT 0xF124 diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index a3fb90bb5a39..6389a992451b 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -44,6 +44,7 @@ #include #include #include +#include #include @@ -175,6 +176,10 @@ static bool __prombss prom_radix_disable; static bool __prombss prom_xive_disable; #endif +#ifdef CONFIG_PPC_SVM +static bool __prombss prom_svm_enable; +#endif + struct platform_support { bool hash_mmu; bool radix_mmu; @@ -816,6 +821,17 @@ static void __init early_cmdline_parse(void) prom_debug("XIVE disabled from cmdline\n"); } #endif /* CONFIG_PPC_PSERIES */ + +#ifdef CONFIG_PPC_SVM + opt = prom_strstr(prom_cmd_line, "svm="); + if (opt) { + bool val; + + opt += sizeof("svm=") - 1; + if (!prom_strtobool(opt, &val)) + prom_svm_enable = val; + } +#endif /* CONFIG_PPC_SVM */ } #ifdef CONFIG_PPC_PSERIES @@ -1716,6 +1732,43 @@ static void __init prom_close_stdin(void) } } +#ifdef CONFIG_PPC_SVM +static int prom_rtas_hcall(uint64_t args) +{ + register uint64_t arg1 asm("r3") = H_RTAS; + register uint64_t arg2 asm("r4") = args; + + asm volatile("sc 1\n" : "=r" (arg1) : + "r" (arg1), + "r" (arg2) :); + return arg1; +} + +static struct rtas_args __prombss os_term_args; + +static void __init prom_rtas_os_term(char *str) +{ + phandle rtas_node; + __be32 val; + u32 token; + + prom_debug("%s: start...\n", __func__); + rtas_node = call_prom("finddevice", 1, 1, ADDR("/rtas")); + prom_debug("rtas_node: %x\n", rtas_node); + if (!PHANDLE_VALID(rtas_node)) + return; + + val = 0; + prom_getprop(rtas_node, "ibm,os-term", &val, sizeof(val)); + token = be32_to_cpu(val); + prom_debug("ibm,os-term: %x\n", token); + if (token == 0) + prom_panic("Could not get token for ibm,os-term\n"); + os_term_args.token = cpu_to_be32(token); + prom_rtas_hcall((uint64_t)&os_term_args); +} +#endif /* CONFIG_PPC_SVM */ + /* * Allocate room for and instantiate RTAS */ @@ -3172,6 +3225,49 @@ static void unreloc_toc(void) #endif #endif +#ifdef CONFIG_PPC_SVM +/* + * Perform the Enter Secure Mode ultracall. + */ +static int enter_secure_mode(unsigned long kbase, unsigned long fdt) +{ + register uint64_t func asm("r3") = UV_ESM; + register uint64_t arg1 asm("r4") = (uint64_t)kbase; + register uint64_t arg2 asm("r5") = (uint64_t)fdt; + + asm volatile("sc 2\n" +: "=r"(func) +: "0"(func), "r"(arg1), "r"(arg2) +:); + + return (int)func; +} + +/* + * Call the Ultravisor to transfer us to secure memory if we have an ESM blob. + */ +static void setup_secure_guest(unsigned long kbase, unsigned long fdt) +{ + int ret; + + if (!prom_svm_enable) + return; + +
[RFC PATCH v2 02/13] powerpc: Add support for adding an ESM blob to the zImage wrapper
From: Benjamin Herrenschmidt For secure VMs, the signing tool will create a ticket called the "ESM blob" for the Enter Secure Mode ultravisor call with the signatures of the kernel and initrd among other things. This adds support to the wrapper script for adding that blob via the "-e" option to the zImage.pseries. It also adds code to the zImage wrapper itself to retrieve and if necessary relocate the blob, and pass its address to Linux via the device-tree, to be later consumed by prom_init. Signed-off-by: Benjamin Herrenschmidt [ bauerman: Minor adjustments to some comments. ] Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/boot/main.c | 41 ++ arch/powerpc/boot/ops.h| 2 ++ arch/powerpc/boot/wrapper | 24 +--- arch/powerpc/boot/zImage.lds.S | 8 +++ 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index 78aaf4ffd7ab..ca612efd3e81 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -150,6 +150,46 @@ static struct addr_range prep_initrd(struct addr_range vmlinux, void *chosen, return (struct addr_range){(void *)initrd_addr, initrd_size}; } +#ifdef __powerpc64__ +static void prep_esm_blob(struct addr_range vmlinux, void *chosen) +{ + unsigned long esm_blob_addr, esm_blob_size; + + /* Do we have an ESM (Enter Secure Mode) blob? */ + if (_esm_blob_end <= _esm_blob_start) + return; + + printf("Attached ESM blob at 0x%p-0x%p\n\r", + _esm_blob_start, _esm_blob_end); + esm_blob_addr = (unsigned long)_esm_blob_start; + esm_blob_size = _esm_blob_end - _esm_blob_start; + + /* +* If the ESM blob is too low it will be clobbered when the +* kernel relocates to its final location. In this case, +* allocate a safer place and move it. +*/ + if (esm_blob_addr < vmlinux.size) { + void *old_addr = (void *)esm_blob_addr; + + printf("Allocating 0x%lx bytes for esm_blob ...\n\r", + esm_blob_size); + esm_blob_addr = (unsigned long)malloc(esm_blob_size); + if (!esm_blob_addr) + fatal("Can't allocate memory for ESM blob !\n\r"); + printf("Relocating ESM blob 0x%lx <- 0x%p (0x%lx bytes)\n\r", + esm_blob_addr, old_addr, esm_blob_size); + memmove((void *)esm_blob_addr, old_addr, esm_blob_size); + } + + /* Tell the kernel ESM blob address via device tree. */ + setprop_val(chosen, "linux,esm-blob-start", (u32)(esm_blob_addr)); + setprop_val(chosen, "linux,esm-blob-end", (u32)(esm_blob_addr + esm_blob_size)); +} +#else +static inline void prep_esm_blob(struct addr_range vmlinux, void *chosen) { } +#endif + /* A buffer that may be edited by tools operating on a zImage binary so as to * edit the command line passed to vmlinux (by setting /chosen/bootargs). * The buffer is put in it's own section so that tools may locate it easier. @@ -218,6 +258,7 @@ void start(void) vmlinux = prep_kernel(); initrd = prep_initrd(vmlinux, chosen, loader_info.initrd_addr, loader_info.initrd_size); + prep_esm_blob(vmlinux, chosen); prep_cmdline(chosen); printf("Finalizing device tree..."); diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h index cd043726ed88..e0606766480f 100644 --- a/arch/powerpc/boot/ops.h +++ b/arch/powerpc/boot/ops.h @@ -251,6 +251,8 @@ extern char _initrd_start[]; extern char _initrd_end[]; extern char _dtb_start[]; extern char _dtb_end[]; +extern char _esm_blob_start[]; +extern char _esm_blob_end[]; static inline __attribute__((const)) int __ilog2_u32(u32 n) diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 4ed18d63d892..ddb62b5b5b7a 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -14,6 +14,7 @@ # -i initrdspecify initrd file # -d devtree specify device-tree blob # -s tree.dts specify device-tree source file (needs dtc installed) +# -e esm_blob specify ESM blob for secure images # -c cache $kernel.strip.gz (use if present & newer, else make) # -C prefixspecify command prefix for cross-building tools # (strip, objcopy, ld) @@ -38,6 +39,7 @@ platform=of initrd= dtb= dts= +esm_blob= cacheit= binary= compression=.gz @@ -61,9 +63,9 @@ tmpdir=. usage() { echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2 -echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2 -echo ' [-D datadir] [-W workingdir] [-Z (gz|xz|none)]' >&2 -echo ' [--no-compression] [vmlinux]' >&2 +echo ' [-d devtree] [-s tree.dts] [-e esm_blob]' >&2 +echo ' [-c] [-C cross-prefix] [-D datadir] [-W workingdir]' >&2 +echo ' [-Z (gz|xz|none)] [--no-com
[PATCH v2 00/13] Secure Virtual Machine Enablement
Hello, The main change in this version was to rebase on top of cleanup series I just posted: https://lore.kernel.org/linuxppc-dev/20190713044554.28719-1-bauer...@linux.ibm.com/ In addition to the patches above, this patch series applies on top of v4 of Claudio Carvalho's "kvmppc: Paravirtualize KVM to support ultravisor" series: https://lore.kernel.org/linuxppc-dev/20190628200825.31049-1-cclau...@linux.ibm.com/ I only actually need the following two patches from his series: [PATCH v4 1/8] KVM: PPC: Ultravisor: Introduce the MSR_S bit [PATCH v4 3/8] KVM: PPC: Ultravisor: Add generic ultravisor call handler Everything is available in branch ultravisor-secure-vm at this repo: https://github.com/bauermann/linux.git Original cover letter below, and changelog at the bottom: This series enables Secure Virtual Machines (SVMs) on powerpc. SVMs use the Protected Execution Facility (PEF) and request to be migrated to secure memory during prom_init() so by default all of their memory is inaccessible to the hypervisor. There is an Ultravisor call that the VM can use to request certain pages to be made accessible to (or shared with) the hypervisor. The objective of these patches is to have the guest perform this request for buffers that need to be accessed by the hypervisor such as the LPPACAs, the SWIOTLB memory and the Debug Trace Log. Patch 2 ("powerpc: Add support for adding an ESM blob to the zImage wrapper") is posted as RFC because we are still finalizing the details on how the ESM blob will be passed along with the kernel. All other patches are (hopefully) in upstreamable shape and don't depend on this patch. Unfortunately this series still doesn't enable the use of virtio devices in the secure guest. This support depends on a discussion that is currently ongoing with the virtio community: https://lore.kernel.org/linuxppc-dev/87womn8inf.fsf@morokweng.localdomain/ I was able to test it using Claudio's patches in the host kernel, booting normally using an initramfs for the root filesystem. This is the command used to start up the guest with QEMU 4.0: qemu-system-ppc64 \ -nodefaults \ -cpu host \ -machine pseries,accel=kvm,kvm-type=HV,cap-htm=off,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken \ -display none \ -serial mon:stdio \ -smp 1 \ -m 4G \ -kernel /root/bauermann/vmlinux \ -initrd /root/bauermann/fs_small.cpio \ -append 'debug' Changelog Since v1: - Patch "powerpc/pseries: Introduce option to build secure virtual machines" - Dropped redundant "default n" from CONFIG_PPC_SVM. Suggested by Christoph Hellwig. - Patch "powerpc: Add support for adding an ESM blob to the zImage wrapper" - Renamed prom_rtas_os_term_hcall() to prom_rtas_hcall(). Suggested by Alexey Kardashevskiy. - In prom_rtas_hcall(), changed prom_printf() calls to prom_debug(), and use H_RTAS constant instead of raw value. - Changed enter_secure_mode() to new ABI passing ucall number in r3. Also changed it to accept kbase argument instead of ESM blob address. - Changed setup_secure_guest() to only make the ESM ultracall if svm=1 was passed on the kernel command line. - Patch "powerpc/pseries/svm: Unshare all pages before kexecing a new kernel" - New patch from Ram Pai. - Patch "powerpc/pseries/svm: Force SWIOTLB for secure guests" - No need to define sme_me_mask, sme_active() and sev_active() anymore. - Add definitions for mem_encrypt_active() and force_dma_unencrypted(). - Select ARCH_HAS_FORCE_DMA_UNENCRYPTED in CONFIG_PPC_SVM. Since the RFC from August: - Patch "powerpc/pseries: Introduce option to build secure virtual machines" - New patch. - Patch "powerpc: Add support for adding an ESM blob to the zImage wrapper" - Patch from Benjamin Herrenschmidt, first posted here: https://lore.kernel.org/linuxppc-dev/20180531043417.25073-1-b...@kernel.crashing.org/ - Made minor adjustments to some comments. Code is unchanged. - Patch "powerpc/prom_init: Add the ESM call to prom_init" - New patch from Ram Pai and Michael Anderson. - Patch "powerpc/pseries/svm: Add helpers for UV_SHARE_PAGE and UV_UNSHARE_PAGE" - New patch from Ram Pai. - Patch "powerpc/pseries: Add and use LPPACA_SIZE constant" - Moved LPPACA_SIZE macro inside the CONFIG_PPC_PSERIES #ifdef. - Put sizeof() operand left of comparison operator in BUILD_BUG_ON() macro to appease a checkpatch warning. - Patch "powerpc/pseries/svm: Use shared memory for LPPACA structures" - Moved definition of is_secure_guest() helper to this patch. - Changed shared_lppaca and shared_lppaca_size from globals to static variables inside alloc_shared_lppaca(). - Changed shared_lppaca to hold virtual address instead of physi
[PATCH v2 01/13] powerpc/pseries: Introduce option to build secure virtual machines
Introduce CONFIG_PPC_SVM to control support for secure guests and include Ultravisor-related helpers when it is selected Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/ultravisor.h | 2 +- arch/powerpc/kernel/Makefile | 4 +++- arch/powerpc/platforms/pseries/Kconfig | 11 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/ultravisor.h b/arch/powerpc/include/asm/ultravisor.h index a5e4516c8ddb..f5dc5af739b8 100644 --- a/arch/powerpc/include/asm/ultravisor.h +++ b/arch/powerpc/include/asm/ultravisor.h @@ -28,7 +28,7 @@ extern int early_init_dt_scan_ultravisor(unsigned long node, const char *uname, * This call supports up to 6 arguments and 4 return arguments. Use * UCALL_BUFSIZE to size the return argument buffer. */ -#if defined(CONFIG_PPC_POWERNV) +#if defined(CONFIG_PPC_POWERNV) || defined(CONFIG_PPC_SVM) long ucall(unsigned long opcode, unsigned long *retbuf, ...); #else static long ucall(unsigned long opcode, unsigned long *retbuf, ...) diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 929f79d3e6a9..ea671f03eba2 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -155,7 +155,9 @@ endif obj-$(CONFIG_EPAPR_PARAVIRT) += epapr_paravirt.o epapr_hcalls.o obj-$(CONFIG_KVM_GUEST)+= kvm.o kvm_emul.o -obj-$(CONFIG_PPC_POWERNV) += ultravisor.o ucall.o +ifneq ($(CONFIG_PPC_POWERNV)$(CONFIG_PPC_SVM),) +obj-y += ultravisor.o ucall.o +endif # Disable GCOV, KCOV & sanitizers in odd or sensitive code GCOV_PROFILE_prom_init.o := n diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index f7b484f3..d09deb05bb66 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -145,3 +145,14 @@ config PAPR_SCM tristate "Support for the PAPR Storage Class Memory interface" help Enable access to hypervisor provided storage class memory. + +config PPC_SVM + bool "Secure virtual machine (SVM) support for POWER" + depends on PPC_PSERIES + help +There are certain POWER platforms which support secure guests using +the Protected Execution Facility, with the help of an Ultravisor +executing below the hypervisor layer. This enables support for +those guests. + +If unsure, say "N".
Re: [PATCH V5 11/18] clk: tegra210: Add support for Tegra210 clocks
On 6/29/19 8:10 AM, Dmitry Osipenko wrote: 28.06.2019 5:12, Sowjanya Komatineni пишет: This patch adds system suspend and resume support for Tegra210 clocks. All the CAR controller settings are lost on suspend when core power goes off. This patch has implementation for saving and restoring all the PLLs and clocks context during system suspend and resume to have the clocks back to same state for normal operation. Acked-by: Thierry Reding Signed-off-by: Sowjanya Komatineni --- drivers/clk/tegra/clk-tegra210.c | 115 ++- drivers/clk/tegra/clk.c | 14 + drivers/clk/tegra/clk.h | 1 + 3 files changed, 127 insertions(+), 3 deletions(-) diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c index 1c08c53482a5..1b839544e086 100644 --- a/drivers/clk/tegra/clk-tegra210.c +++ b/drivers/clk/tegra/clk-tegra210.c @@ -9,10 +9,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -20,6 +22,7 @@ #include #include "clk.h" +#include "clk-dfll.h" #include "clk-id.h" /* @@ -225,6 +228,7 @@ #define CLK_RST_CONTROLLER_RST_DEV_Y_SET 0x2a8 #define CLK_RST_CONTROLLER_RST_DEV_Y_CLR 0x2ac +#define CPU_SOFTRST_CTRL 0x380 #define LVL2_CLK_GATE_OVRA 0xf8 #define LVL2_CLK_GATE_OVRC 0x3a0 @@ -2820,6 +2824,7 @@ static int tegra210_enable_pllu(void) struct tegra_clk_pll_freq_table *fentry; struct tegra_clk_pll pllu; u32 reg; + int ret; for (fentry = pll_u_freq_table; fentry->input_rate; fentry++) { if (fentry->input_rate == pll_ref_freq) @@ -2847,10 +2852,10 @@ static int tegra210_enable_pllu(void) fence_udelay(1, clk_base); reg |= PLL_ENABLE; writel(reg, clk_base + PLLU_BASE); + fence_udelay(1, clk_base); - readl_relaxed_poll_timeout_atomic(clk_base + PLLU_BASE, reg, - reg & PLL_BASE_LOCK, 2, 1000); - if (!(reg & PLL_BASE_LOCK)) { + ret = tegra210_wait_for_mask(&pllu, PLLU_BASE, PLL_BASE_LOCK); + if (ret) { pr_err("Timed out waiting for PLL_U to lock\n"); return -ETIMEDOUT; } @@ -3283,6 +3288,103 @@ static void tegra210_disable_cpu_clock(u32 cpu) } #ifdef CONFIG_PM_SLEEP +static u32 cpu_softrst_ctx[3]; +static struct platform_device *dfll_pdev; +#define car_readl(_base, _off) readl_relaxed(clk_base + (_base) + ((_off) * 4)) +#define car_writel(_val, _base, _off) \ + writel_relaxed(_val, clk_base + (_base) + ((_off) * 4)) + +static int tegra210_clk_suspend(void) +{ + unsigned int i; + struct device_node *node; + + tegra_cclkg_burst_policy_save_context(); + + if (!dfll_pdev) { + node = of_find_compatible_node(NULL, NULL, + "nvidia,tegra210-dfll"); + if (node) + dfll_pdev = of_find_device_by_node(node); + + of_node_put(node); + if (!dfll_pdev) + pr_err("dfll node not found. no suspend for dfll\n"); + } + + if (dfll_pdev) + tegra_dfll_suspend(dfll_pdev); + + /* Enable PLLP_OUT_CPU after dfll suspend */ + tegra_clk_set_pllp_out_cpu(true); + + tegra_sclk_cclklp_burst_policy_save_context(); + + clk_save_context(); + + for (i = 0; i < ARRAY_SIZE(cpu_softrst_ctx); i++) + cpu_softrst_ctx[i] = car_readl(CPU_SOFTRST_CTRL, i); + + return 0; +} + +static void tegra210_clk_resume(void) +{ + unsigned int i; + struct clk_hw *parent; + struct clk *clk; + + /* +* clk_restore_context restores clocks as per the clock tree. +* +* dfllCPU_out is first in the clock tree to get restored and it +* involves programming DFLL controller along with restoring CPUG +* clock burst policy. +* +* DFLL programming needs dfll_ref and dfll_soc peripheral clocks +* to be restores which are part ofthe peripheral clocks. +* So, peripheral clocks restore should happen prior to dfll clock +* restore. +*/ + + tegra_clk_osc_resume(clk_base); + for (i = 0; i < ARRAY_SIZE(cpu_softrst_ctx); i++) + car_writel(cpu_softrst_ctx[i], CPU_SOFTRST_CTRL, i); + + /* restore all plls and peripheral clocks */ + tegra210_init_pllu(); + clk_restore_context(); + + fence_udelay(5, clk_base); + + /* resume SCLK and CPULP clocks */ + tegra_sclk_cpulp_burst_policy_restore_context(); + + /* +* restore CPUG clocks: +* - enable DFLL in open loop mode +* - switch CPUG to DFLL clock source +* - close DFLL loop +* - sync PLLX state +*/ + if (dfll_pdev) + tegra_dfll_resume(dfll_pdev, false); + +
Re: [PATCH V5 02/18] pinctrl: tegra: Add suspend and resume support
On 6/29/19 8:46 AM, Dmitry Osipenko wrote: 28.06.2019 5:12, Sowjanya Komatineni пишет: This patch adds support for Tegra pinctrl driver suspend and resume. During suspend, context of all pinctrl registers are stored and on resume they are all restored to have all the pinmux and pad configuration for normal operation. Acked-by: Thierry Reding Signed-off-by: Sowjanya Komatineni --- drivers/pinctrl/tegra/pinctrl-tegra.c| 52 drivers/pinctrl/tegra/pinctrl-tegra.h| 3 ++ drivers/pinctrl/tegra/pinctrl-tegra210.c | 1 + 3 files changed, 56 insertions(+) diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c index 34596b246578..e7c0a1011cba 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra.c @@ -621,6 +621,43 @@ static void tegra_pinctrl_clear_parked_bits(struct tegra_pmx *pmx) } } +static int tegra_pinctrl_suspend(struct device *dev) +{ + struct tegra_pmx *pmx = dev_get_drvdata(dev); + u32 *backup_regs = pmx->backup_regs; + u32 *regs; + unsigned int i, j; + + for (i = 0; i < pmx->nbanks; i++) { + regs = pmx->regs[i]; + for (j = 0; j < pmx->reg_bank_size[i] / 4; j++) + *backup_regs++ = readl(regs++); + } + + return pinctrl_force_sleep(pmx->pctl); +} + +static int tegra_pinctrl_resume(struct device *dev) +{ + struct tegra_pmx *pmx = dev_get_drvdata(dev); + u32 *backup_regs = pmx->backup_regs; + u32 *regs; + unsigned int i, j; + + for (i = 0; i < pmx->nbanks; i++) { + regs = pmx->regs[i]; + for (j = 0; j < pmx->reg_bank_size[i] / 4; j++) + writel(*backup_regs++, regs++); + } + + return 0; +} + +const struct dev_pm_ops tegra_pinctrl_pm = { + .suspend = &tegra_pinctrl_suspend, + .resume = &tegra_pinctrl_resume +}; Hm, so this are the generic platform-driver suspend-resume OPS here, which is very nice! But.. shouldn't pinctrl be resumed before the CLK driver (which is syscore_ops in this version of the series)? .. Given that "clock" function may need to be selected for some of the pins. selection of clock functions on some Tegra pins through corresponding pinmux (like extperiph clks) can happen after clock driver resume as well where clock source is restored to state during suspend before selecting clock function on that pin.
Re: [PATCH V5 02/18] pinctrl: tegra: Add suspend and resume support
On 7/4/19 3:40 AM, Dmitry Osipenko wrote: 04.07.2019 10:31, Linus Walleij пишет: On Sat, Jun 29, 2019 at 5:58 PM Dmitry Osipenko wrote: Oh, also what about GPIO-pinctrl suspend resume ordering .. is it okay that pinctrl will be resumed after GPIO? Shouldn't a proper pin-muxing be selected at first? Thierry sent some initial patches about this I think. We need to use device links for this to work properly so he adds support for linking the pinctrl and GPIO devices through the ranges. For links between pin control handles and their consumers, see also: 036f394dd77f pinctrl: Enable device link creation for pin control c6045b4e3cad pinctrl: stmfx: enable links creations 489b64d66325 pinctrl: stm32: Add links to consumers I am using STM32 as guinea pig for this, consider adding links also from the Tegra pinctrl. I might simply make these pinctrl consumer to producer links default because I think it makes a lot sense. IIUC, currently the plan is to resume pinctrl *after* GPIO for Tegra210 [1]. But this contradicts to what was traditionally done for older Tegras where pinctrl was always resumed first and apparently it won't work well for the GPIO ranges as well. I think this and the other patchsets related to suspend-resume still need some more thought. [1] https://patchwork.kernel.org/patch/11012077/ Park bit was introduced from Tegra210 onwards and during suspend/resume, requirement of gpio restore prior to pinctrl restore is not required for prior Tegra210. Also currently pinctrl suspend/resume implementation for prior Tegra210 is not yet upstreamed but having gpio restore prior to pinmux during suspend/resume should not cause any issue for prior tegra's as well as gpio resume restores pins back to same gpio config as they were during suspend entry.
Re: list corruption in deferred_split_scan()
On 7/12/19 12:12 PM, Yang Shi wrote: On 7/11/19 2:07 PM, Qian Cai wrote: On Wed, 2019-07-10 at 17:16 -0700, Yang Shi wrote: Hi Qian, Thanks for reporting the issue. But, I can't reproduce it on my machine. Could you please share more details about your test? How often did you run into this problem? I can almost reproduce it every time on a HPE ProLiant DL385 Gen10 server. Here is some more information. # cat .config https://raw.githubusercontent.com/cailca/linux-mm/master/x86.config I tried your kernel config, but I still can't reproduce it. My compiler doesn't have retpoline support, so CONFIG_RETPOLINE is disabled in my test, but I don't think this would make any difference for this case. According to the bug call trace in the earlier email, it looks deferred _split_scan lost race with put_compound_page. The put_compound_page would call free_transhuge_page() which delete the page from the deferred split queue, but it may still appear on the deferred list due to some reason. Would you please try the below patch? diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b7f709d..66bd9db 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2765,7 +2765,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) if (!mapcount && page_ref_freeze(head, 1 + extra_pins)) { if (!list_empty(page_deferred_list(head))) { ds_queue->split_queue_len--; - list_del(page_deferred_list(head)); + list_del_init(page_deferred_list(head)); This line should not be changed. Please just apply the below part. } if (mapping) __dec_node_page_state(page, NR_SHMEM_THPS); @@ -2814,7 +2814,7 @@ void free_transhuge_page(struct page *page) spin_lock_irqsave(&ds_queue->split_queue_lock, flags); if (!list_empty(page_deferred_list(page))) { ds_queue->split_queue_len--; - list_del(page_deferred_list(page)); + list_del_init(page_deferred_list(page)); } spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags); free_compound_page(page); # numactl -H available: 8 nodes (0-7) node 0 cpus: 0 1 2 3 4 5 6 7 64 65 66 67 68 69 70 71 node 0 size: 19984 MB node 0 free: 7251 MB node 1 cpus: 8 9 10 11 12 13 14 15 72 73 74 75 76 77 78 79 node 1 size: 0 MB node 1 free: 0 MB node 2 cpus: 16 17 18 19 20 21 22 23 80 81 82 83 84 85 86 87 node 2 size: 0 MB node 2 free: 0 MB node 3 cpus: 24 25 26 27 28 29 30 31 88 89 90 91 92 93 94 95 node 3 size: 0 MB node 3 free: 0 MB node 4 cpus: 32 33 34 35 36 37 38 39 96 97 98 99 100 101 102 103 node 4 size: 31524 MB node 4 free: 25165 MB node 5 cpus: 40 41 42 43 44 45 46 47 104 105 106 107 108 109 110 111 node 5 size: 0 MB node 5 free: 0 MB node 6 cpus: 48 49 50 51 52 53 54 55 112 113 114 115 116 117 118 119 node 6 size: 0 MB node 6 free: 0 MB node 7 cpus: 56 57 58 59 60 61 62 63 120 121 122 123 124 125 126 127 node 7 size: 0 MB node 7 free: 0 MB node distances: node 0 1 2 3 4 5 6 7 0: 10 16 16 16 32 32 32 32 1: 16 10 16 16 32 32 32 32 2: 16 16 10 16 32 32 32 32 3: 16 16 16 10 32 32 32 32 4: 32 32 32 32 10 16 16 16 5: 32 32 32 32 16 10 16 16 6: 32 32 32 32 16 16 10 16 7: 32 32 32 32 16 16 16 10 # lscpu Architecture:x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 128 On-line CPU(s) list: 0-127 Thread(s) per core: 2 Core(s) per socket: 32 Socket(s): 2 NUMA node(s):8 Vendor ID: AuthenticAMD CPU family: 23 Model: 1 Model name: AMD EPYC 7601 32-Core Processor Stepping:2 CPU MHz: 2713.551 BogoMIPS:4391.39 Virtualization: AMD-V L1d cache: 32K L1i cache: 64K L2 cache:512K L3 cache:8192K NUMA node0 CPU(s): 0-7,64-71 NUMA node1 CPU(s): 8-15,72-79 NUMA node2 CPU(s): 16-23,80-87 NUMA node3 CPU(s): 24-31,88-95 NUMA node4 CPU(s): 32-39,96-103 NUMA node5 CPU(s): 40-47,104-111 NUMA node6 CPU(s): 48-55,112-119 NUMA node7 CPU(s): 56-63,120-127 Another possible lead is that without reverting the those commits below, kdump kernel would always also crash in shrink_slab_memcg() at this line, map = rcu_dereference_protected(memcg->nodeinfo[nid]->shrinker_map, true); This looks a little bit weird. It seems nodeinfo[nid] is NULL? I didn't think of where nodeinfo was freed but memcg was still online. Maybe a check is needed: diff --git a/mm/vmscan.c b/mm/vmscan.c index a0301ed..bacda49 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -602,6 +602,9 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, if (!mem_cgroup_online(memcg)) return 0; + if (!memcg->nodeinfo[nid]) + return 0; + if
[GIT PULL] Please pull powerpc/linux.git powerpc-5.3-1 tag
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Linus, Please pull powerpc updates for 5.3. A bit of a small batch for us, just due to me not getting the time to review things. Only one conflict that I'm aware of, in our pgtable.h, resolution is simply to take both sides. cheers The following changes since commit cd6c84d8f0cdc911df435bb075ba22ce3c605b07: Linux 5.2-rc2 (2019-05-26 16:49:19 -0700) are available in the git repository at: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-5.3-1 for you to fetch changes up to f5a9e488d62360c91c5770bd55a0b40e419a71ce: powerpc/powernv/idle: Fix restore of SPRN_LDBAR for POWER9 stop state. (2019-07-12 22:25:26 +1000) - -- powerpc updates for 5.3 Notable changes: - Removal of the NPU DMA code, used by the out-of-tree Nvidia driver, as well as some other functions only used by drivers that haven't (yet?) made it upstream. - A fix for a bug in our handling of hardware watchpoints (eg. perf record -e mem: ...) which could lead to register corruption and kernel crashes. - Enable HAVE_ARCH_HUGE_VMAP, which allows us to use large pages for vmalloc when using the Radix MMU. - A large but incremental rewrite of our exception handling code to use gas macros rather than multiple levels of nested CPP macros. And the usual small fixes, cleanups and improvements. Thanks to: Alastair D'Silva, Alexey Kardashevskiy, Andreas Schwab, Aneesh Kumar K.V, Anju T Sudhakar, Anton Blanchard, Arnd Bergmann, Athira Rajeev, Cédric Le Goater, Christian Lamparter, Christophe Leroy, Christophe Lombard, Christoph Hellwig, Daniel Axtens, Denis Efremov, Enrico Weigelt, Frederic Barrat, Gautham R. Shenoy, Geert Uytterhoeven, Geliang Tang, Gen Zhang, Greg Kroah-Hartman, Greg Kurz, Gustavo Romero, Krzysztof Kozlowski, Madhavan Srinivasan, Masahiro Yamada, Mathieu Malaterre, Michael Neuling, Nathan Lynch, Naveen N. Rao, Nicholas Piggin, Nishad Kamdar, Oliver O'Halloran, Qian Cai, Ravi Bangoria, Sachin Sant, Sam Bobroff, Satheesh Rajendran, Segher Boessenkool, Shaokun Zhang, Shawn Anastasio, Stewart Smith, Suraj Jitindar Singh, Thiago Jung Bauermann, YueHaibing. - -- Alastair D'Silva (1): ocxl: Update for AFU descriptor template version 1.1 Alexey Kardashevskiy (5): powerpc/pci/of: Fix OF flags parsing for 64bit BARs powerpc/pseries/dma: Allow SWIOTLB powerpc/pseries/dma: Enable SWIOTLB powerpc/pci/of: Parse unassigned resources powerpc/powernv: Fix stale iommu table base after VFIO Andreas Schwab (1): powerpc/mm/32s: fix condition that is always true Aneesh Kumar K.V (16): powerpc/mm: Remove unused variable declaration powerpc/mm/hash/4k: Don't use 64K page size for vmemmap with 4K pagesize powerpc/mm/radix: Use the right page size for vmemmap mapping powerpc/mm/drconf: Use NUMA_NO_NODE on failures instead of node 0 powerpc/mm: Fix node look up with numa=off boot powerpc/mm: Consolidate numa_enable check and min_common_depth check powerpc/mm/nvdimm: Add an informative message if we fail to allocate altmap block powerpc/pseries/scm: Mark the region volatile if cache flush not required powerpc/nvdimm: Add support for multibyte read/write for metadata powerpc/pseries/scm: Use a specific endian format for storing uuid from the device tree powerpc/book3s: Use config independent helpers for page table walk powerpc/mm: pmd_devmap implies pmd_large(). powerpc/mm: Remove radix dependency on HugeTLB page powerpc/mm: Handle page table allocation failures powerpc/mm/hugetlb: Fix kernel crash if we fail to allocate page table caches powerpc/mm/hugetlb: Don't enable HugeTLB if we don't have a page table cache Anju T Sudhakar (1): powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units. Anton Blanchard (1): powerpc/configs: Disable latencytop Athira Rajeev (1): powerpc/powernv/idle: Fix restore of SPRN_LDBAR for POWER9 stop state. Christian Lamparter (1): powerpc/4xx/uic: clear pending interrupt after irq type/pol change Christoph Hellwig (5): powerpc/powernv: remove the unused pnv_pci_set_p2p function powerpc/powernv: remove the unused tunneling exports powerpc/powernv: remove unused NPU DMA code powerpc/powernv: remove the unused vas_win_paste_addr and vas_win_id functions powerpc: remove device_to_mask() Christophe Leroy (25): powerpc/lib: fix redundant inclusion of quad.o powerpc/lib: only build ldstfp.o when CONFIG_PPC_FPU is set powerpc/64: mark start_here_multiplatform as __ref powerpc/32s: fix suspend/resume when IBATs 4-7 are used powerpc/ftrace: Enable C Version of recordmcount powerpc: slightly improve cache helpers
[GIT PULL] percpu changes for v5.3-rc1
Hi Linus, This pull request includes changes to let percpu_ref release the backing percpu memory earlier after it has been switched to atomic in cases where the percpu ref is not revived. This will help recycle percpu memory earlier in cases where the refcounts are pinned for prolonged periods of time. Thanks, Dennis The following changes since commit e93c9c99a629c61837d5a7fc2120cd2b6c70dbdd: Linux 5.1 (2019-05-05 17:42:58 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu.git for-5.3 for you to fetch changes up to 7d9ab9b6adffd9c474c1274acb5f6208f9a09cf3: percpu_ref: release percpu memory early without PERCPU_REF_ALLOW_REINIT (2019-05-09 10:51:06 -0700) Roman Gushchin (4): percpu_ref: introduce PERCPU_REF_ALLOW_REINIT flag io_uring: initialize percpu refcounters using PERCU_REF_ALLOW_REINIT md: initialize percpu refcounters using PERCU_REF_ALLOW_REINIT percpu_ref: release percpu memory early without PERCPU_REF_ALLOW_REINIT drivers/md/md.c | 3 ++- fs/io_uring.c | 3 ++- include/linux/percpu-refcount.h | 10 +- lib/percpu-refcount.c | 13 +++-- 4 files changed, 24 insertions(+), 5 deletions(-)
[PATCH v2 1/4] fs/posix_acl: apply umask if superblock disables ACL support
The function posix_acl_create() applies the umask only if the inode has no ACL (= NULL) or if ACLs are not supported by the filesystem driver (= -EOPNOTSUPP). However, this happens only after after the IS_POSIXACL() check succeeeded. If the superblock doesn't enable ACL support, umask will never be applied. A filesystem which has no ACL support will of course not enable SB_POSIXACL, rendering the umask-applying code path unreachable. This fixes a bug which causes the umask to be ignored with O_TMPFILE on tmpfs: https://github.com/MusicPlayerDaemon/MPD/issues/558 https://bugs.gentoo.org/show_bug.cgi?id=686142#c3 https://bugzilla.kernel.org/show_bug.cgi?id=203625 Signed-off-by: Max Kellermann Cc: sta...@vger.kernel.org --- fs/posix_acl.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 84ad1c90d535..4071c66f234a 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -589,9 +589,14 @@ posix_acl_create(struct inode *dir, umode_t *mode, *acl = NULL; *default_acl = NULL; - if (S_ISLNK(*mode) || !IS_POSIXACL(dir)) + if (S_ISLNK(*mode)) return 0; + if (!IS_POSIXACL(dir)) { + *mode &= ~current_umask(); + return 0; + } + p = get_acl(dir, ACL_TYPE_DEFAULT); if (!p || p == ERR_PTR(-EOPNOTSUPP)) { *mode &= ~current_umask(); -- 2.20.1
[PATCH v2 4/4] nfs/super: check NFS_CAP_ACLS instead of the NFS version
This sets MS_POSIXACL only if ACL support is really enabled, instead of always setting MS_POSIXACL if the NFS protocol version theoretically supports ACL. The code comment says "We will [apply the umask] ourselves", but that happens in posix_acl_create() only if the kernel has POSIX ACL support. Without it, posix_acl_create() is an empty dummy function. So let's not pretend we will apply the umask if we can already know that we will never. This fixes a problem where the umask is always ignored in the NFS client when compiled without CONFIG_FS_POSIX_ACL. This is a 4 year old regression caused by commit 013cdf1088d723 which itself was not completely wrong, but failed to consider all the side effects by misdesigned VFS code. Signed-off-by: Max Kellermann Cc: sta...@vger.kernel.org --- fs/nfs/super.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index f88ddac2dcdf..886ad89af676 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -2353,11 +2353,14 @@ void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info) if (data && data->bsize) sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits); - if (server->nfs_client->rpc_ops->version != 2) { + if (NFS_SB(sb)->caps & NFS_CAP_ACLS) { /* The VFS shouldn't apply the umask to mode bits. We will do * so ourselves when necessary. */ sb->s_flags |= SB_POSIXACL; + } + + if (server->nfs_client->rpc_ops->version != 2) { sb->s_time_gran = 1; sb->s_export_op = &nfs_export_ops; } @@ -2383,7 +2386,7 @@ static void nfs_clone_super(struct super_block *sb, sb->s_time_gran = 1; sb->s_export_op = old_sb->s_export_op; - if (server->nfs_client->rpc_ops->version != 2) { + if (NFS_SB(sb)->caps & NFS_CAP_ACLS) { /* The VFS shouldn't apply the umask to mode bits. We will do * so ourselves when necessary. */ -- 2.20.1
[PATCH v2 2/4] fs/ext4/acl: apply umask if ACL support is disabled
The function ext4_init_acl() calls posix_acl_create() which is responsible for applying the umask. But without CONFIG_EXT4_FS_POSIX_ACL, ext4_init_acl() is an empty inline function, and nobody applies the umask. This fixes a bug which causes the umask to be ignored with O_TMPFILE on ext4: https://github.com/MusicPlayerDaemon/MPD/issues/558 https://bugs.gentoo.org/show_bug.cgi?id=686142#c3 https://bugzilla.kernel.org/show_bug.cgi?id=203625 Signed-off-by: Max Kellermann Cc: sta...@vger.kernel.org --- fs/ext4/acl.h | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h index 9b63f5416a2f..7f3b25b3fa6d 100644 --- a/fs/ext4/acl.h +++ b/fs/ext4/acl.h @@ -67,6 +67,11 @@ extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); static inline int ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir) { + /* usually, the umask is applied by posix_acl_create(), but if + ext4 ACL support is disabled at compile time, we need to do + it here, because posix_acl_create() will never be called */ + inode->i_mode &= ~current_umask(); + return 0; } #endif /* CONFIG_EXT4_FS_POSIX_ACL */ -- 2.20.1
[PATCH v2 3/4] linux/fs.h: fix umask on NFS with CONFIG_FS_POSIX_ACL=n
Make IS_POSIXACL() return false if POSIX ACL support is disabled and ignore SB_POSIXACL/MS_POSIXACL. Never skip applying the umask in namei.c and never bother to do any ACL specific checks if the filesystem falsely indicates it has ACLs enabled when the feature is completely disabled in the kernel. This fixes a problem where the umask is always ignored in the NFS client when compiled without CONFIG_FS_POSIX_ACL. This is a 4 year old regression caused by commit 013cdf1088d723 which itself was not completely wrong, but failed to consider all the side effects by misdesigned VFS code. Prior to that commit, there were two places where the umask could be applied, for example when creating a directory: 1. in the VFS layer in SYSCALL_DEFINE3(mkdirat), but only if !IS_POSIXACL() 2. again (unconditionally) in nfs3_proc_mkdir() The first one does not apply, because even without CONFIG_FS_POSIX_ACL, the NFS client sets MS_POSIXACL in nfs_fill_super(). After that commit, (2.) was replaced by: 2b. in posix_acl_create(), called by nfs3_proc_mkdir() There's one branch in posix_acl_create() which applies the umask; however, without CONFIG_FS_POSIX_ACL, posix_acl_create() is an empty dummy function which does not apply the umask. The approach chosen by this patch is to make IS_POSIXACL() always return false when POSIX ACL support is disabled, so the umask always gets applied by the VFS layer. This is consistent with the (regular) behavior of posix_acl_create(): that function returns early if IS_POSIXACL() is false, before applying the umask. Therefore, posix_acl_create() is responsible for applying the umask if there is ACL support enabled in the file system (SB_POSIXACL), and the VFS layer is responsible for all other cases (no SB_POSIXACL or no CONFIG_FS_POSIX_ACL). Signed-off-by: Max Kellermann Cc: sta...@vger.kernel.org --- include/linux/fs.h | 5 + 1 file changed, 5 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index f7fdfe93e25d..5e9f3aa7ba26 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1993,7 +1993,12 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA) #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) #define IS_IMMUTABLE(inode)((inode)->i_flags & S_IMMUTABLE) + +#ifdef CONFIG_FS_POSIX_ACL #define IS_POSIXACL(inode) __IS_FLG(inode, SB_POSIXACL) +#else +#define IS_POSIXACL(inode) 0 +#endif #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD) #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) -- 2.20.1
Re: [GIT PULL] xfs: new features for 5.3
On Fri, Jul 12, 2019 at 05:27:15PM -0700, Linus Torvalds wrote: > On Fri, Jul 12, 2019 at 11:02 AM Darrick J. Wong wrote: > > > > The branch merges cleanly against this morning's HEAD and survived an > > overnight run of xfstests. The merge was completely straightforward, so > > please let me know if you run into anything weird. > > Hmm. I don't know what you merged against, but it got a (fairly > trivial) conflict for me due to > > 79d08f89bb1b ("block: fix .bi_size overflow") > > from the block merge (from Tuesday) touching a line next to one changed by > > a24737359667 ("xfs: simplify xfs_chain_bio") > > from this pull. > > So it wasn't an entirely clean merge for me. > > Was it a complex merge conflict? No. I'm just confused by the "merges > cleanly against this morning's HEAD", which makes me wonder what you > tried to merge against.. Doh, it turns out I was merging against the same HEAD as my last two pull requests because I forgot to re-pull. Sorry about that. It's been too long of a week. :/ --D > Linus
[PATCH] kbuild: add --hash-style= and --build-id unconditionally
As commit 1e0221374e30 ("mips: vdso: drop unnecessary cc-ldoption") explained, these flags are supported by the minimal required version of binutils. Signed-off-by: Masahiro Yamada --- Makefile | 6 ++ arch/arm/vdso/Makefile| 3 +-- arch/arm64/kernel/vdso32/Makefile | 4 ++-- arch/sparc/vdso/Makefile | 3 +-- arch/x86/entry/vdso/Makefile | 5 ++--- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 2c5d00ba537e..969182105dbd 100644 --- a/Makefile +++ b/Makefile @@ -900,10 +900,8 @@ KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS) KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS) -# Use --build-id when available. -LDFLAGS_BUILD_ID := $(call ld-option, --build-id) -KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) -LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) +KBUILD_LDFLAGS_MODULE += --build-id +LDFLAGS_vmlinux += --build-id ifeq ($(CONFIG_STRIP_ASM_SYMS),y) LDFLAGS_vmlinux+= $(call ld-option, -X,) diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile index ca85df247775..87b7769214e0 100644 --- a/arch/arm/vdso/Makefile +++ b/arch/arm/vdso/Makefile @@ -13,8 +13,7 @@ ccflags-y += -DDISABLE_BRANCH_PROFILING ldflags-$(CONFIG_CPU_ENDIAN_BE8) := --be8 ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ -z max-page-size=4096 -nostdlib -shared $(ldflags-y) \ - $(call ld-option, --hash-style=sysv) \ - $(call ld-option, --build-id) \ + --hash-style=sysv --build-id \ -T obj-$(CONFIG_VDSO) += vdso.o diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile index 288c14d30b45..60a4c6239712 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -96,8 +96,8 @@ VDSO_LDFLAGS := $(VDSO_CPPFLAGS) VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 VDSO_LDFLAGS += -nostdlib -shared -mfloat-abi=soft -VDSO_LDFLAGS += $(call cc32-ldoption,-Wl$(comma)--hash-style=sysv) -VDSO_LDFLAGS += $(call cc32-ldoption,-Wl$(comma)--build-id) +VDSO_LDFLAGS += -Wl,--hash-style=sysv +VDSO_LDFLAGS += -Wl,--build-id VDSO_LDFLAGS += $(call cc32-ldoption,-fuse-ld=bfd) diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile index 5a9e4e1f9f81..324a23947585 100644 --- a/arch/sparc/vdso/Makefile +++ b/arch/sparc/vdso/Makefile @@ -115,8 +115,7 @@ quiet_cmd_vdso = VDSO$@ -T $(filter %.lds,$^) $(filter %.o,$^) && \ sh $(srctree)/$(src)/checkundef.sh '$(OBJDUMP)' '$@' -VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ - $(call ld-option, --build-id) -Bsymbolic +VDSO_LDFLAGS = -shared --hash-style=both --build-id -Bsymbolic GCOV_PROFILE := n # diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 39106111be86..4c234a18638a 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -179,9 +179,8 @@ quiet_cmd_vdso = VDSO$@ -T $(filter %.lds,$^) $(filter %.o,$^) && \ sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' -VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ - $(call ld-option, --build-id) $(call ld-option, --eh-frame-hdr) \ - -Bsymbolic +VDSO_LDFLAGS = -shared --hash-style=both --build-id \ + $(call ld-option, --eh-frame-hdr) -Bsymbolic GCOV_PROFILE := n # -- 2.17.1
[PATCH v4 7/8] dt-bindings: arm: sunxi: add binding for Lichee Zero Plus core board
The Lichee Zero Plus is a core board made by Sipeed, with a microUSB connector on it, TF slot or WSON8 SD chip, optional eMMC or SPI Flash. It has a gold finger connector for expansion, and UART is available from reserved pins w/ 2.54mm pitch. The board can use either SoChip S3 or Allwinner V3L SoCs. Add the device tree binding of the basic version of the core board -- w/o eMMC or SPI Flash, w/ TF slot or WSON8 SD, and use S3 SoC. Signed-off-by: Icenowy Zheng --- No changes since v3. Patch introduced in v2. Documentation/devicetree/bindings/arm/sunxi.yaml | 5 + 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/sunxi.yaml b/Documentation/devicetree/bindings/arm/sunxi.yaml index 000a00d12d6a..48c126a7a848 100644 --- a/Documentation/devicetree/bindings/arm/sunxi.yaml +++ b/Documentation/devicetree/bindings/arm/sunxi.yaml @@ -353,6 +353,11 @@ properties: - const: licheepi,licheepi-zero - const: allwinner,sun8i-v3s + - description: Lichee Zero Plus (with S3, without eMMC/SPI Flash) +items: + - const: sipeed,lichee-zero-plus + - const: allwinner,sun8i-s3 + - description: Linksprite PCDuino items: - const: linksprite,a10-pcduino -- 2.21.0
[PATCH v4 8/8] ARM: dts: sun8i: s3: add devicetree for Lichee zero plus w/ S3
Lichee zero plus is a core board made by Sipeed, which includes on-board TF slot or SMT SD NAND, and optional SPI NOR or eMMC, a UART debug header, a microUSB slot and a gold finger connector for expansion. It can use either Sochip S3 or Allwinner S3L SoC. Add the basic device tree for the core board, w/o optional onboard storage, and with S3 SoC. Signed-off-by: Icenowy Zheng --- No changes in v4. Changes in v3: - Drop common regulator DTSI usage and added vcc3v3 regulator. arch/arm/boot/dts/Makefile| 1 + .../boot/dts/sun8i-s3-lichee-zero-plus.dts| 8 .../dts/sun8i-s3-s3l-lichee-zero-plus.dtsi| 46 +++ 3 files changed, 55 insertions(+) create mode 100644 arch/arm/boot/dts/sun8i-s3-lichee-zero-plus.dts create mode 100644 arch/arm/boot/dts/sun8i-s3-s3l-lichee-zero-plus.dtsi diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 9159fa2cea90..e320460a952b 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -1114,6 +1114,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \ sun8i-r16-nintendo-super-nes-classic.dtb \ sun8i-r16-parrot.dtb \ sun8i-r40-bananapi-m2-ultra.dtb \ + sun8i-s3-lichee-zero-plus.dtb \ sun8i-t3-cqa3t-bv3.dtb \ sun8i-v3s-licheepi-zero.dtb \ sun8i-v3s-licheepi-zero-dock.dtb \ diff --git a/arch/arm/boot/dts/sun8i-s3-lichee-zero-plus.dts b/arch/arm/boot/dts/sun8i-s3-lichee-zero-plus.dts new file mode 100644 index ..7d2f6b145190 --- /dev/null +++ b/arch/arm/boot/dts/sun8i-s3-lichee-zero-plus.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2019 Icenowy Zheng + */ + +/dts-v1/; +#include "sun8i-s3.dtsi" +#include "sun8i-s3-s3l-lichee-zero-plus.dtsi" diff --git a/arch/arm/boot/dts/sun8i-s3-s3l-lichee-zero-plus.dtsi b/arch/arm/boot/dts/sun8i-s3-s3l-lichee-zero-plus.dtsi new file mode 100644 index ..2677d319fb29 --- /dev/null +++ b/arch/arm/boot/dts/sun8i-s3-s3l-lichee-zero-plus.dtsi @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2019 Icenowy Zheng + */ + +#include + +/ { + aliases { + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + reg_vcc3v3: vcc3v3 { + compatible = "regulator-fixed"; + regulator-name = "vcc3v3"; + regulator-min-microvolt = <330>; + regulator-max-microvolt = <330>; + }; +}; + +&mmc0 { + broken-cd; + bus-width = <4>; + vmmc-supply = <®_vcc3v3>; + status = "okay"; +}; + +&uart0 { + pinctrl-0 = <&uart0_pb_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&usb_otg { + dr_mode = "otg"; + status = "okay"; +}; + +&usbphy { + usb0_id_det-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; + status = "okay"; +}; -- 2.21.0
[PATCH v4 6/8] ARM: sunxi: dts: s3/s3l/v3: add DTSI files for S3/S3L/V3 SoCs
The Allwinner S3/S3L/V3 SoCs all share the same die with the V3s SoC, but with more GPIO wired out of the package. Add DTSI files for these SoCs. The DTSI file for V3 just replaces the pinctrl compatible string, and the S3/S3L DTSI files just include the V3 DTSI file. Signed-off-by: Icenowy Zheng --- No changes since v2. arch/arm/boot/dts/sun8i-s3.dtsi | 6 ++ arch/arm/boot/dts/sun8i-s3l.dtsi | 6 ++ arch/arm/boot/dts/sun8i-v3.dtsi | 14 ++ 3 files changed, 26 insertions(+) create mode 100644 arch/arm/boot/dts/sun8i-s3.dtsi create mode 100644 arch/arm/boot/dts/sun8i-s3l.dtsi create mode 100644 arch/arm/boot/dts/sun8i-v3.dtsi diff --git a/arch/arm/boot/dts/sun8i-s3.dtsi b/arch/arm/boot/dts/sun8i-s3.dtsi new file mode 100644 index ..0f41a25ecb30 --- /dev/null +++ b/arch/arm/boot/dts/sun8i-s3.dtsi @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2019 Icenowy Zheng + */ + +#include "sun8i-v3.dtsi" diff --git a/arch/arm/boot/dts/sun8i-s3l.dtsi b/arch/arm/boot/dts/sun8i-s3l.dtsi new file mode 100644 index ..0f41a25ecb30 --- /dev/null +++ b/arch/arm/boot/dts/sun8i-s3l.dtsi @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2019 Icenowy Zheng + */ + +#include "sun8i-v3.dtsi" diff --git a/arch/arm/boot/dts/sun8i-v3.dtsi b/arch/arm/boot/dts/sun8i-v3.dtsi new file mode 100644 index ..6ae8645ade50 --- /dev/null +++ b/arch/arm/boot/dts/sun8i-v3.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2019 Icenowy Zheng + */ + +#include "sun8i-v3s.dtsi" + +&ccu { + compatible = "allwinner,sun8i-v3-ccu"; +}; + +&pio { + compatible = "allwinner,sun8i-v3-pinctrl"; +}; -- 2.21.0
[PATCH 0/2] ASoC: samsung: odroid: fix err handling of odroid_audio_probe
We developed a coccinelle SmPL to detect sound/soc/samsung/odroid.c and found some use-after-free problems. This patch series fixes those problems. Wen Yang (2): ASoC: samsung: odroid: fix an use-after-free issue for codec ASoC: samsung: odroid: fix a double-free issue for cpu_dai sound/soc/samsung/odroid.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) Cc: Krzysztof Kozlowski Cc: Sangbeom Kim Cc: Sylwester Nawrocki Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-de...@alsa-project.org Cc: linux-kernel@vger.kernel.org -- 2.9.5
[PATCH v4 5/8] clk: sunxi-ng: v3s: add Allwinner V3 support
Allwinner V3 has the same main die with V3s, but with more pins wired. There's a I2S bus on V3 that is not available on V3s. Add the V3-only peripheral's clocks and reset to the V3s CCU driver, bound to a new V3 compatible string. The driver name is not changed because it's part of the device tree binding (the header file name). Signed-off-by: Icenowy Zheng --- Changes in v4: - Add the missing MMC2 clock slices. No changes in v3/v2. drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 228 +- drivers/clk/sunxi-ng/ccu-sun8i-v3s.h | 2 +- include/dt-bindings/clock/sun8i-v3s-ccu.h | 4 + include/dt-bindings/reset/sun8i-v3s-ccu.h | 3 + 4 files changed, 234 insertions(+), 3 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c index 9c88015d4419..32854dec3753 100644 --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c @@ -235,6 +235,8 @@ static SUNXI_CCU_GATE(bus_codec_clk,"bus-codec", "apb1", 0x068, BIT(0), 0); static SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1", 0x068, BIT(5), 0); +static SUNXI_CCU_GATE(bus_i2s0_clk,"bus-i2s0", "apb1", + 0x068, BIT(12), 0); static SUNXI_CCU_GATE(bus_i2c0_clk,"bus-i2c0", "apb2", 0x06c, BIT(0), 0); @@ -306,6 +308,11 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0, BIT(31), /* gate */ 0); +static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x", + "pll-audio-2x", "pll-audio" }; +static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents, + 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT); + static SUNXI_CCU_GATE(usb_phy0_clk,"usb-phy0", "osc24M", 0x0cc, BIT(8), 0); static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0","osc24M", @@ -443,6 +450,80 @@ static const struct clk_hw *clk_parent_pll_audio[] = { &pll_audio_base_clk.common.hw }; +static struct ccu_common *sun8i_v3_ccu_clks[] = { + &pll_cpu_clk.common, + &pll_audio_base_clk.common, + &pll_video_clk.common, + &pll_ve_clk.common, + &pll_ddr0_clk.common, + &pll_periph0_clk.common, + &pll_isp_clk.common, + &pll_periph1_clk.common, + &pll_ddr1_clk.common, + &cpu_clk.common, + &axi_clk.common, + &ahb1_clk.common, + &apb1_clk.common, + &apb2_clk.common, + &ahb2_clk.common, + &bus_ce_clk.common, + &bus_dma_clk.common, + &bus_mmc0_clk.common, + &bus_mmc1_clk.common, + &bus_mmc2_clk.common, + &bus_dram_clk.common, + &bus_emac_clk.common, + &bus_hstimer_clk.common, + &bus_spi0_clk.common, + &bus_otg_clk.common, + &bus_ehci0_clk.common, + &bus_ohci0_clk.common, + &bus_ve_clk.common, + &bus_tcon0_clk.common, + &bus_csi_clk.common, + &bus_de_clk.common, + &bus_codec_clk.common, + &bus_pio_clk.common, + &bus_i2s0_clk.common, + &bus_i2c0_clk.common, + &bus_i2c1_clk.common, + &bus_uart0_clk.common, + &bus_uart1_clk.common, + &bus_uart2_clk.common, + &bus_ephy_clk.common, + &bus_dbg_clk.common, + &mmc0_clk.common, + &mmc0_sample_clk.common, + &mmc0_output_clk.common, + &mmc1_clk.common, + &mmc1_sample_clk.common, + &mmc1_output_clk.common, + &mmc2_clk.common, + &mmc2_sample_clk.common, + &mmc2_output_clk.common, + &ce_clk.common, + &spi0_clk.common, + &i2s0_clk.common, + &usb_phy0_clk.common, + &usb_ohci0_clk.common, + &dram_clk.common, + &dram_ve_clk.common, + &dram_csi_clk.common, + &dram_ohci_clk.common, + &dram_ehci_clk.common, + &de_clk.common, + &tcon_clk.common, + &csi_misc_clk.common, + &csi0_mclk_clk.common, + &csi1_sclk_clk.common, + &csi1_mclk_clk.common, + &ve_clk.common, + &ac_dig_clk.common, + &avs_clk.common, + &mbus_clk.common, + &mipi_csi_clk.common, +}; + /* We hardcode the divider to 4 for now */ static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio", clk_parent_pll_audio, @@ -540,6 +621,88 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = { .num= CLK_NUMBER, }; +static struct clk_hw_onecell_data sun8i_v3_hw_clks = { + .hws= { + [CLK_PLL_CPU] = &pll_cpu_clk.common.hw, + [CLK_PLL_AUDIO_BASE]= &pll_audio_base_clk.common.hw, + [CLK_PLL_AUDIO] = &pll_audio_clk.hw, + [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw, + [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw, + [CLK_PL
[PATCH 2/2] ASoC: samsung: odroid: fix a double-free issue for cpu_dai
The cpu_dai variable is still being used after the of_node_put() call, which may result in double-free: of_node_put(cpu_dai);---> released here ret = devm_snd_soc_register_card(dev, card); if (ret < 0) { ... goto err_put_clk_i2s;--> jump to err_put_clk_i2s ... err_put_clk_i2s: clk_put(priv->clk_i2s_bus); err_put_sclk: clk_put(priv->sclk_i2s); err_put_cpu_dai: of_node_put(cpu_dai);--> double-free here Fixes: d832d2b246c5 ("ASoC: samsung: odroid: Fix of_node refcount unbalance") Signed-off-by: Wen Yang Cc: Krzysztof Kozlowski Cc: Sangbeom Kim Cc: Sylwester Nawrocki Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-de...@alsa-project.org Cc: linux-kernel@vger.kernel.org --- sound/soc/samsung/odroid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index 64ebe89..f0f5fa9 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -308,7 +308,6 @@ static int odroid_audio_probe(struct platform_device *pdev) ret = PTR_ERR(priv->clk_i2s_bus); goto err_put_sclk; } - of_node_put(cpu_dai); ret = devm_snd_soc_register_card(dev, card); if (ret < 0) { @@ -316,6 +315,7 @@ static int odroid_audio_probe(struct platform_device *pdev) goto err_put_clk_i2s; } + of_node_put(cpu_dai); of_node_put(codec); return 0; -- 2.9.5
[PATCH 1/2] ASoC: samsung: odroid: fix an use-after-free issue for codec
The codec variable is still being used after the of_node_put() call, which may result in use-after-free. Fixes: bc3cf17b575a ("ASoC: samsung: odroid: Add support for secondary CPU DAI") Signed-off-by: Wen Yang Cc: Krzysztof Kozlowski Cc: Sangbeom Kim Cc: Sylwester Nawrocki Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-de...@alsa-project.org Cc: linux-kernel@vger.kernel.org --- sound/soc/samsung/odroid.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index dfb6e46..64ebe89 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -284,9 +284,8 @@ static int odroid_audio_probe(struct platform_device *pdev) } of_node_put(cpu); - of_node_put(codec); if (ret < 0) - return ret; + goto err_put_node; ret = snd_soc_of_get_dai_link_codecs(dev, codec, codec_link); if (ret < 0) @@ -317,6 +316,7 @@ static int odroid_audio_probe(struct platform_device *pdev) goto err_put_clk_i2s; } + of_node_put(codec); return 0; err_put_clk_i2s: @@ -326,6 +326,8 @@ static int odroid_audio_probe(struct platform_device *pdev) err_put_cpu_dai: of_node_put(cpu_dai); snd_soc_of_put_dai_link_codecs(codec_link); +err_put_node: + of_node_put(codec); return ret; } -- 2.9.5
[PATCH v4 2/8] clk: sunxi-ng: v3s: add the missing PLL_DDR1
The user manual of V3/V3s/S3 declares a PLL_DDR1, however it's forgot when developing the V3s CCU driver. Add back the missing PLL_DDR1. Fixes: d0f11d14b0bc ("clk: sunxi-ng: add support for V3s CCU") Signed-off-by: Icenowy Zheng --- No changes since v1. drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 19 +++ drivers/clk/sunxi-ng/ccu-sun8i-v3s.h | 6 -- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c index 9b3939fc7faa..4eb68243e310 100644 --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c @@ -77,7 +77,7 @@ static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve", BIT(28),/* lock */ 0); -static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr_clk, "pll-ddr", +static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0", "osc24M", 0x020, 8, 5, /* N */ 4, 2, /* K */ @@ -116,6 +116,14 @@ static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_clk, "pll-periph1", 2, /* post-div */ 0); +static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1", + "osc24M", 0x04c, + 8, 7,/* N */ + 0, 2,/* M */ + BIT(31), /* gate */ + BIT(28), /* lock */ + 0); + static const char * const cpu_parents[] = { "osc32k", "osc24M", "pll-cpu", "pll-cpu" }; static SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents, @@ -303,7 +311,8 @@ static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0","osc24M", 0x0cc, BIT(16), 0); -static const char * const dram_parents[] = { "pll-ddr", "pll-periph0-2x" }; +static const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1", +"pll-periph0-2x" }; static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents, 0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL); @@ -363,10 +372,11 @@ static struct ccu_common *sun8i_v3s_ccu_clks[] = { &pll_audio_base_clk.common, &pll_video_clk.common, &pll_ve_clk.common, - &pll_ddr_clk.common, + &pll_ddr0_clk.common, &pll_periph0_clk.common, &pll_isp_clk.common, &pll_periph1_clk.common, + &pll_ddr1_clk.common, &cpu_clk.common, &axi_clk.common, &ahb1_clk.common, @@ -460,11 +470,12 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = { [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, [CLK_PLL_VIDEO] = &pll_video_clk.common.hw, [CLK_PLL_VE]= &pll_ve_clk.common.hw, - [CLK_PLL_DDR] = &pll_ddr_clk.common.hw, + [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw, [CLK_PLL_PERIPH0_2X]= &pll_periph0_2x_clk.hw, [CLK_PLL_ISP] = &pll_isp_clk.common.hw, [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw, + [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, [CLK_CPU] = &cpu_clk.common.hw, [CLK_AXI] = &axi_clk.common.hw, [CLK_AHB1] = &ahb1_clk.common.hw, diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.h b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.h index fbc1da8b4520..10af324bd6b1 100644 --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.h +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.h @@ -20,7 +20,7 @@ #define CLK_PLL_AUDIO_8X 5 #define CLK_PLL_VIDEO 6 #define CLK_PLL_VE 7 -#define CLK_PLL_DDR8 +#define CLK_PLL_DDR0 8 #define CLK_PLL_PERIPH09 #define CLK_PLL_PERIPH0_2X 10 #define CLK_PLL_ISP11 @@ -49,6 +49,8 @@ /* And the GPU module clock is exported */ -#define CLK_NUMBER (CLK_MIPI_CSI + 1) +#define CLK_PLL_DDR1 74 + +#define CLK_NUMBER (CLK_PLL_DDR1 + 1) #endif /* _CCU_SUN8I_H3_H_ */ -- 2.21.0
[PATCH v4 4/8] clk: sunxi-ng: v3s: add missing clock slices for MMC2 module clocks
The MMC2 clock slices are currently not defined in V3s CCU driver, which makes MMC2 not working. Fix this issue. Fixes: d0f11d14b0bc ("clk: sunxi-ng: add support for V3s CCU") Signed-off-by: Icenowy Zheng --- New patch in v4. drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c index 4eb68243e310..9c88015d4419 100644 --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c @@ -513,6 +513,9 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = { [CLK_MMC1] = &mmc1_clk.common.hw, [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw, [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw, + [CLK_MMC2] = &mmc1_clk.common.hw, + [CLK_MMC2_SAMPLE] = &mmc1_sample_clk.common.hw, + [CLK_MMC2_OUTPUT] = &mmc1_output_clk.common.hw, [CLK_CE]= &ce_clk.common.hw, [CLK_SPI0] = &spi0_clk.common.hw, [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, -- 2.21.0
[PATCH v4 3/8] dt-bindings: clk: sunxi-ccu: add compatible string for V3 CCU
Despite Allwinner V3 and V3s shares the same die, one peripheral (I2S) is only available on V3, and thus the clocks is not declared for V3s CCU. Add a V3 CCU compatible string to the binding to prepare for a CCU driver that provide I2S clock on V3, but not on V3s. Signed-off-by: Icenowy Zheng Reviewed-by: Rob Herring --- No changes since v3. Changes in v2: - Adapt to YAML binding document in linux-next. .../devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml b/Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml index c935405458fe..1bde87fc94c5 100644 --- a/Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml +++ b/Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml @@ -31,6 +31,7 @@ properties: - allwinner,sun8i-h3-ccu - allwinner,sun8i-h3-r-ccu - allwinner,sun8i-r40-ccu + - allwinner,sun8i-v3-ccu - allwinner,sun8i-v3s-ccu - allwinner,sun9i-a80-ccu - allwinner,sun50i-a64-ccu -- 2.21.0
[PATCH v4 1/8] pinctrl: sunxi: v3s: introduce support for V3
Introduce the GPIO pins that is only available on V3 (not on V3s) to the V3s pinctrl driver. Signed-off-by: Icenowy Zheng --- Changes in v4: - Removed bogus alignment change. Changes in v3: - Fixed code alignment. - Fixed LVDS function number. Changes in v2: - Dropped the driver rename patch and apply the changes directly on V3s driver. drivers/pinctrl/sunxi/pinctrl-sun8i-v3s.c | 265 +- drivers/pinctrl/sunxi/pinctrl-sunxi.h | 2 + 2 files changed, 262 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-v3s.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-v3s.c index 6704ce8e5e3d..ca85438e379a 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sun8i-v3s.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-v3s.c @@ -1,5 +1,5 @@ /* - * Allwinner V3s SoCs pinctrl driver. + * Allwinner V3/V3s SoCs pinctrl driver. * * Copyright (C) 2016 Icenowy Zheng * @@ -77,6 +77,30 @@ static const struct sunxi_desc_pin sun8i_v3s_pins[] = { SUNXI_FUNCTION(0x2, "i2c1"), /* SCK */ SUNXI_FUNCTION(0x3, "uart0"), /* RX */ SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 9)), /* PB_EINT9 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(B, 10), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "jtag"), /* MS */ + SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 10)), /* PB_EINT10 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(B, 11), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "jtag"), /* CK */ + SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 11)), /* PB_EINT11 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(B, 12), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "jtag"), /* DO */ + SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 12)), /* PB_EINT12 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(B, 13), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "jtag"), /* DI */ + SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 13)), /* PB_EINT13 */ /* Hole */ SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 0), SUNXI_FUNCTION(0x0, "gpio_in"), @@ -98,6 +122,180 @@ static const struct sunxi_desc_pin sun8i_v3s_pins[] = { SUNXI_FUNCTION(0x1, "gpio_out"), SUNXI_FUNCTION(0x2, "mmc2"), /* D0 */ SUNXI_FUNCTION(0x3, "spi0")), /* MOSI */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(C, 4), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "mmc2")), /* D1 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(C, 5), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "mmc2")), /* D2 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(C, 6), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "mmc2")), /* D3 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(C, 7), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "mmc2")), /* D4 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(C, 8), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "mmc2")), /* D5 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(C, 9), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "mmc2")), /* D6 */ + SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(C, 10), + PINCTRL_SUN8I_V3, + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x2, "mmc2")),
[PATCH v4 0/8] Support for Allwinner V3/S3L and Sochip S3
This patchset tries to add support for Allwinner V3/S3L and Sochip S3. Allwinner V3/V3s/S3L and Sochip S3 share the same die, but with different package. V3 is BGA w/o co-packaged DDR, V3s is QFP w/ DDR2, S3L is BGA w/ DDR2 and S3 is BGA w/ DDR3. (S3 and S3L is compatible for pinout, but because of different DDR, DDR voltage is different between the two variants). Because of the pin count of V3s is restricted due to the package, some pins are not bound on V3s, but they're bound on V3/S3/S3L. Currently the kernel is only prepared for the features available on V3s. This patchset adds the features missing on V3s for using them on V3/S3/S3L, and add bindings for V3/S3/S3L. It also adds a S3 SoM by Sipeed, called Lichee Zero Plus. Icenowy Zheng (8): pinctrl: sunxi: v3s: introduce support for V3 clk: sunxi-ng: v3s: add the missing PLL_DDR1 dt-bindings: clk: sunxi-ccu: add compatible string for V3 CCU clk: sunxi-ng: v3s: add missing clock slices for MMC2 module clocks clk: sunxi-ng: v3s: add Allwinner V3 support ARM: sunxi: dts: s3/s3l/v3: add DTSI files for S3/S3L/V3 SoCs dt-bindings: arm: sunxi: add binding for Lichee Zero Plus core board ARM: dts: sun8i: s3: add devicetree for Lichee zero plus w/ S3 .../devicetree/bindings/arm/sunxi.yaml| 5 + .../clock/allwinner,sun4i-a10-ccu.yaml| 1 + arch/arm/boot/dts/Makefile| 1 + .../boot/dts/sun8i-s3-lichee-zero-plus.dts| 8 + .../dts/sun8i-s3-s3l-lichee-zero-plus.dtsi| 46 +++ arch/arm/boot/dts/sun8i-s3.dtsi | 6 + arch/arm/boot/dts/sun8i-s3l.dtsi | 6 + arch/arm/boot/dts/sun8i-v3.dtsi | 14 + drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 250 - drivers/clk/sunxi-ng/ccu-sun8i-v3s.h | 6 +- drivers/pinctrl/sunxi/pinctrl-sun8i-v3s.c | 265 +- drivers/pinctrl/sunxi/pinctrl-sunxi.h | 2 + include/dt-bindings/clock/sun8i-v3s-ccu.h | 4 + include/dt-bindings/reset/sun8i-v3s-ccu.h | 3 + 14 files changed, 604 insertions(+), 13 deletions(-) create mode 100644 arch/arm/boot/dts/sun8i-s3-lichee-zero-plus.dts create mode 100644 arch/arm/boot/dts/sun8i-s3-s3l-lichee-zero-plus.dtsi create mode 100644 arch/arm/boot/dts/sun8i-s3.dtsi create mode 100644 arch/arm/boot/dts/sun8i-s3l.dtsi create mode 100644 arch/arm/boot/dts/sun8i-v3.dtsi -- 2.21.0
FRESH & NEW EMAIL LEADS TOOLS, RDP,EMAILS, SPYWARES, SMTP, MAILER, CVV
DEAR CUSTOMERS We are happy to inform you about our new SMTP SERVER today I would like to introduce you to a page that provides services for UNLIMITED SENDER We offer all the services that you desire now? 15x Domain Inbox SMTP please check http://www.cybergatesltd.net/index.php?route=product/product&product_id=458 Unlimited SMTP (Cheap and Inbox) Unlimited PHP Mailer (Cheap and Inbox) Unlimited WebMail Sever ( Cheap And Inbox) RDP With AMS 4.3 (Warranty Full Time and On Sales) Email Leads (New and Fresh) Unlimited Cpanel Hosting (Use For Scampage, botnet,etc...) VPN Linux Root Hacking Tools zeus trojan Hacking ScamPage CVV, BANK LOGINS, DATING SITES LOGIN SPYWARES ETC Top Services http://www.cybergatesltd.net To impress the customers, so we decided to discout price all products with 10% discount code: http://www.cybergatesltd.net You can see more Sale OFF 10% All Product How can I enter discount code? We also have 100 RDP WITH AMS program discounts to customers Click here to Order Now, be quick, limited http://www.cybergatesltd.net/index.php?route=product/category&path=93 Why is trusted by our customers? We always provide the best service for our customers, we guarantee customers will be happy to have what they want, the first priority is to treat our customers as god How to Order? Payment Method? We accept payment Via PerfectMoney We will try to accept multiple payment gateways to serve customers better Deliver We Delivered Via Email Within 0-2 hour You have any questions Other? Click here for see more // http://www.cybergatesltd.net/index.php?route=product/category&path=59 Are you ready to experience? READY TO GET STARTED? With us, you will not be disappointed, currently on the market there are many scam sites, selling quality goods, come to us, we will show you, Our service is best Customer Care Services Thank you for choosing cyber gates Store! chat with the admin for more information Perfect Money payments will be accepted using our LIVE CHAT payment processor. skype( skytunnel1 chat ( rs...@yahoo.com www.cybergatesltd.net
[PATCH] powerpc: remove meaningless KBUILD_ARFLAGS addition
The KBUILD_ARFLAGS addition in arch/powerpc/Makefile has never worked in a useful way because it is always overridden by the following code in the top Makefile: # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D) The code in the top Makefile was added in 2011, by commit 40df759e2b9e ("kbuild: Fix build with binutils <= 2.19"). The KBUILD_ARFLAGS addition for ppc has always been dead code from the beginning. Nobody has reported a problem since 43c9127d94d6 ("powerpc: Add option to use thin archives"), so this code was unneeded. Signed-off-by: Masahiro Yamada --- arch/powerpc/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index c345b79414a9..46ed198a3aa3 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -112,7 +112,6 @@ ifeq ($(HAS_BIARCH),y) KBUILD_CFLAGS += -m$(BITS) KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS) KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION) -KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) endif cflags-$(CONFIG_STACKPROTECTOR)+= -mstack-protector-guard=tls -- 2.17.1
Re: [PATCH 5.2 00/61] 5.2.1-stable review
On Fri, 12 Jul 2019 at 18:04, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 5.2.1 release. > There are 61 patches in this series, all will be posted as a response > to this one. If anyone has any issues with these being applied, please > let me know. > > Responses should be made by Sun 14 Jul 2019 12:14:36 PM UTC. > Anything received after that time might be too late. > > The whole patch series can be found in one patch at: > > https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.1-rc1.gz > or in the git tree and branch at: > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git > linux-5.2.y > and the diffstat can be found below. > > thanks, > > greg k-h > Results from Linaro’s test farm. No regressions on arm64, arm, x86_64, and i386. Summary kernel: 5.2.1-rc1 git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git git branch: linux-5.2.y git commit: 61731e8fe278d37915a743554d370bc33a2037cb git describe: v5.2-62-g61731e8fe278 Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-5.2-oe/build/v5.2-62-g61731e8fe278 No regressions (compared to build v5.2) No fixes (compared to build v5.2) Ran 22507 total tests in the following environments and test suites. Environments -- - dragonboard-410c - hi6220-hikey - i386 - juno-r2 - qemu_arm - qemu_arm64 - qemu_i386 - qemu_x86_64 - x15 - x86 Test Suites --- * build * install-android-platform-tools-r2600 * kselftest * libgpiod * libhugetlbfs * ltp-cap_bounds-tests * ltp-commands-tests * ltp-containers-tests * ltp-cpuhotplug-tests * ltp-cve-tests * ltp-dio-tests * ltp-fcntl-locktests-tests * ltp-filecaps-tests * ltp-fs_bind-tests * ltp-fs_perms_simple-tests * ltp-fsx-tests * ltp-hugetlb-tests * ltp-io-tests * ltp-ipc-tests * ltp-math-tests * ltp-mm-tests * ltp-nptl-tests * ltp-pty-tests * ltp-sched-tests * ltp-securebits-tests * ltp-syscalls-tests * ltp-timers-tests * network-basic-tests * perf * spectre-meltdown-checker-test * v4l2-compliance * ltp-fs-tests * ltp-open-posix-tests * kvm-unit-tests * kselftest-vsyscall-mode-native * kselftest-vsyscall-mode-none -- Linaro LKFT https://lkft.linaro.org
Re: [PATCH 5.1 000/138] 5.1.18-stable review
On Fri, 12 Jul 2019 at 17:56, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 5.1.18 release. > There are 138 patches in this series, all will be posted as a response > to this one. If anyone has any issues with these being applied, please > let me know. > > Responses should be made by Sun 14 Jul 2019 12:14:36 PM UTC. > Anything received after that time might be too late. > > The whole patch series can be found in one patch at: > > https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.1.18-rc1.gz > or in the git tree and branch at: > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git > linux-5.1.y > and the diffstat can be found below. > > thanks, > > greg k-h Results from Linaro’s test farm. No regressions on arm64, arm, x86_64, and i386. Summary kernel: 5.1.18-rc2 git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git git branch: linux-5.1.y git commit: de182b90f76d9beac11a216bcdbe52542014de24 git describe: v5.1.17-137-gde182b90f76d Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-5.1-oe/build/v5.1.17-137-gde182b90f76d No regressions (compared to build v5.1.17) No fixes (compared to build v5.1.17) Ran 22803 total tests in the following environments and test suites. Environments -- - dragonboard-410c - hi6220-hikey - i386 - juno-r2 - qemu_arm - qemu_arm64 - qemu_i386 - qemu_x86_64 - x15 - x86 Test Suites --- * build * install-android-platform-tools-r2600 * kselftest * libgpiod * libhugetlbfs * ltp-cap_bounds-tests * ltp-commands-tests * ltp-containers-tests * ltp-cpuhotplug-tests * ltp-cve-tests * ltp-dio-tests * ltp-fcntl-locktests-tests * ltp-filecaps-tests * ltp-fs-tests * ltp-fs_bind-tests * ltp-fs_perms_simple-tests * ltp-fsx-tests * ltp-hugetlb-tests * ltp-io-tests * ltp-ipc-tests * ltp-math-tests * ltp-mm-tests * ltp-nptl-tests * ltp-pty-tests * ltp-sched-tests * ltp-securebits-tests * ltp-syscalls-tests * ltp-timers-tests * network-basic-tests * perf * spectre-meltdown-checker-test * v4l2-compliance * ltp-open-posix-tests * kvm-unit-tests * kselftest-vsyscall-mode-native * kselftest-vsyscall-mode-none -- Linaro LKFT https://lkft.linaro.org
Re: [PATCH 4.19 00/91] 4.19.59-stable review
On Fri, 12 Jul 2019 at 17:52, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 4.19.59 release. > There are 91 patches in this series, all will be posted as a response > to this one. If anyone has any issues with these being applied, please > let me know. > > Responses should be made by Sun 14 Jul 2019 12:14:36 PM UTC. > Anything received after that time might be too late. > > The whole patch series can be found in one patch at: > > https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.59-rc1.gz > or in the git tree and branch at: > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git > linux-4.19.y > and the diffstat can be found below. > > thanks, > > greg k-h > Results from Linaro’s test farm. No regressions on arm64, arm, x86_64, and i386. Summary kernel: 4.19.59-rc1 git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git git branch: linux-4.19.y git commit: d66f8e7f112fefe0c1d2a0f77da022a56ccde6dc git describe: v4.19.58-92-gd66f8e7f112f Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.19-oe/build/v4.19.58-92-gd66f8e7f112f No regressions (compared to build v4.19.58) No fixes (compared to build v4.19.58) Ran 25278 total tests in the following environments and test suites. Environments -- - dragonboard-410c - arm64 - hi6220-hikey - arm64 - i386 - juno-r2 - arm64 - qemu_arm - qemu_arm64 - qemu_i386 - qemu_x86_64 - x15 - arm - x86_64 Test Suites --- * build * install-android-platform-tools-r2600 * kselftest * libgpiod * libhugetlbfs * ltp-cap_bounds-tests * ltp-commands-tests * ltp-containers-tests * ltp-cpuhotplug-tests * ltp-cve-tests * ltp-dio-tests * ltp-fcntl-locktests-tests * ltp-filecaps-tests * ltp-fs_bind-tests * ltp-fs_perms_simple-tests * ltp-fsx-tests * ltp-hugetlb-tests * ltp-io-tests * ltp-ipc-tests * ltp-math-tests * ltp-mm-tests * ltp-nptl-tests * ltp-pty-tests * ltp-sched-tests * ltp-securebits-tests * ltp-syscalls-tests * ltp-timers-tests * perf * spectre-meltdown-checker-test * v4l2-compliance * ltp-fs-tests * network-basic-tests * ltp-open-posix-tests * kvm-unit-tests * kselftest-vsyscall-mode-native * kselftest-vsyscall-mode-none -- Linaro LKFT https://lkft.linaro.org
Re: [RFC PATCH] bug: always show source-tree-relative paths in WARN()/BUG()
On Thu, Jul 11, 2019 at 6:50 PM Masahiro Yamada wrote: > GCC 8 added this flag. > So, it will be eventually all solved in the GCC world. Ack. > Clang has not supported it yet... That's what it appeared like. I've bugged our Clang-loving toolchain folks to see if we can get parity. > Trimming absolute path at run-time > is no help for reducing the kernel image. Sure, but that's not my stated goal. It would indeed be nicer though. I guess if no one else speaks up with a favorable word toward my RFC, I'll just see what I can do on the toolchain side. Thanks for the help, Brian
Re: [PATCH 5.1 000/138] 5.1.18-stable review
On Fri, Jul 12, 2019 at 02:17:44PM +0200, Greg Kroah-Hartman wrote: > This is the start of the stable review cycle for the 5.1.18 release. > There are 138 patches in this series, all will be posted as a response > to this one. If anyone has any issues with these being applied, please > let me know. > > Responses should be made by Sun 14 Jul 2019 12:14:36 PM UTC. > Anything received after that time might be too late. > > The whole patch series can be found in one patch at: > > https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.1.18-rc1.gz > or in the git tree and branch at: > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git > linux-5.1.y > and the diffstat can be found below. > > thanks, > > greg k-h > > - Hello, Compiled and booted fine. No regressions on x86_64. THX, Jiunn
Re: [Question] Should direct reclaim time be bounded?
On 7/11/19 10:47 PM, Hillf Danton wrote: > > On Thu, 11 Jul 2019 02:42:56 +0800 Mike Kravetz wrote: >> >> It is quite easy to hit the condition where: >> nr_reclaimed == 0 && nr_scanned == 0 is true, but we skip the previous test >> > Then skipping check of __GFP_RETRY_MAYFAIL makes no sense in your case. > It is restored in respin below. > >> and the compaction check: >> sc->nr_reclaimed < pages_for_compaction && >> inactive_lru_pages > pages_for_compaction >> is true, so we return true before the below check of costly_fg_reclaim >> > This check is placed after COMPACT_SUCCESS; the latter is used to > replace sc->nr_reclaimed < pages_for_compaction. > > And dryrun detection is added based on the result of last round of > shrinking of inactive pages, particularly when their number is large > enough. > Thanks Hillf. This change does appear to eliminate the issue with stalls by should_continue_reclaim returning true too often. I need to think some more about exactly what is impacted with the change. With this change, the problem moves to compaction with should_compact_retry returning true too often. It is the same behavior seem when I simply removed the __GFP_RETRY_MAYFAIL special casing in should_continue_reclaim. At Mel's suggestion I removed the compaction_zonelist_suitable() call from should_compact_retry. This eliminated the compaction stalls. Thanks Mel. With both changes, stalls appear to be eliminated. This is promising. I'll try to refine these approaches and continue testing. -- Mike Kravetz > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2571,18 +2571,6 @@ static inline bool should_continue_reclaim(struct > pglist_data *pgdat, > return false; > } > > - /* > - * If we have not reclaimed enough pages for compaction and the > - * inactive lists are large enough, continue reclaiming > - */ > - pages_for_compaction = compact_gap(sc->order); > - inactive_lru_pages = node_page_state(pgdat, NR_INACTIVE_FILE); > - if (get_nr_swap_pages() > 0) > - inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON); > - if (sc->nr_reclaimed < pages_for_compaction && > - inactive_lru_pages > pages_for_compaction) > - return true; > - > /* If compaction would go ahead or the allocation would succeed, stop */ > for (z = 0; z <= sc->reclaim_idx; z++) { > struct zone *zone = &pgdat->node_zones[z]; > @@ -2598,7 +2586,21 @@ static inline bool should_continue_reclaim(struct > pglist_data *pgdat, > ; > } > } > - return true; > + > + /* > + * If we have not reclaimed enough pages for compaction and the > + * inactive lists are large enough, continue reclaiming > + */ > + pages_for_compaction = compact_gap(sc->order); > + inactive_lru_pages = node_page_state(pgdat, NR_INACTIVE_FILE); > + if (get_nr_swap_pages() > 0) > + inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON); > + > + return inactive_lru_pages > pages_for_compaction && > + /* > + * avoid dryrun with plenty of inactive pages > + */ > + nr_scanned && nr_reclaimed; > } > > static bool pgdat_memcg_congested(pg_data_t *pgdat, struct mem_cgroup *memcg) > -- >
Re: [HELP REQUESTED from the community] Was: Staging status of speakup
On Fri, Jul 12, 2019 at 11:23:19AM +0200, Samuel Thibault wrote: > Hello, > > To readers of the linux-speakup: could you help on this so we can get > Speakup in mainline? Neither Okash or I completely know what user > consequences the files in /sys/accessibility/speakup/ have, so could > people give brief explanations for each file (something like 3-6 lines > of explanation)? I have a recollection of documenting most of this on the speakup list in response to a similar query a number of years ago. Unfortunately, the speakup mailing list archives aren't easily searchable, and I don't have a local copy of that mail. Kirk, doing grep with a few of the file names in /sys/accessibility/speakup against the list's mbox file archive should find that message if it's in fact there. If you can please find it, and post the date when it was sent, we can provide a URL to that thread as a starting point. If my recollection is wrong, and such a message isn't in the archives, I'll write up what I know about. Greg -- web site: http://www.gregn.net gpg public key: http://www.gregn.net/pubkey.asc skype: gregn1 (authorization required, add me to your contacts list first) If we haven't been in touch before, e-mail me before adding me to your contacts. -- Free domains: http://www.eu.org/ or mail dns-mana...@eu.org
LPC 2019 Networking Track CFP (reminder)
This is a call for proposals for the 3 day networking track at the Linux Plumbers Conference in Lisbon, which will be happening on September 9th-11th, 2019. We are seeking talks of 40 minutes in length (including Q & A), optionally accompanied by papers of 2 to 10 pages in length. The papers, while not required, are very strongly encouraged by the committee. The submitters intention to provide a paper will be taken into consideration as a criteria when deciding which proposals to accept. Any kind of advanced networking-related topic will be considered. Please submit your proposals on the LPC website at: https://www.linuxplumbersconf.org/event/4/abstracts/#submit-abstract And be sure to select "Networking Summit Track" in the Track pulldown menu. Proposals must be submitted by August 2nd, and submitters will be notified of acceptance by August 9th. Final slides and papers (as PDF) are due on September 2nd. Looking forward to seeing you all in Lisbon in September!
Re: [PATCH] be2net: fix adapter->big_page_size miscaculation
From: Qian Cai Date: Fri, 12 Jul 2019 20:27:09 -0400 > Actually, GCC would consider it a const with -O2 optimized level because it > found that it was never modified and it does not understand it is a module > parameter. Considering the following code. > > # cat const.c > #include > > static int a = 1; > > int main(void) > { > if (__builtin_constant_p(a)) > printf("a is a const.\n"); > > return 0; > } > > # gcc -O2 const.c -o const That's not a complete test case, and with a proper test case that shows the externalization of the address of &a done by the module parameter macros, gcc should not make this optimization or we should define the module parameter macros in a way that makes this properly clear to the compiler. It makes no sense to hack around this locally in drivers and other modules. Thank you.
Re: [GIT PULL] dlm updates for 5.3 (second try)
The pull request you sent on Fri, 12 Jul 2019 10:18:44 -0500: > git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm.git dlm-5.3 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/964a4eacef67503a1154f7e0a75f52fbdce52022 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] 9p updates for 5.3
The pull request you sent on Fri, 12 Jul 2019 10:04:46 +0200: > git://github.com/martinetd/linux tags/9p-for-5.3 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/23bbbf5c1fb3ddf104c2ddbda4cc24ebe53a3453 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] 9p updates for 5.3
On Fri, Jul 12, 2019 at 1:08 AM Dominique Martinet wrote: > > Just noticed this typo in version number here, should I make a new tag > with the correct text? No need, The important part is the signature itself, the typo will be embedded in the merge commit (as part of the merge signature) but not really matter. Nobody will ever really see that - even when asking to see the signature with "--show-signature", it only verifies the pgp signing, and doesn't show your typo. (But just FYI: your shame is forever visible to future generations if you do git cat-file commit 23bbbf5c1fb3ddf104c2ddbda4cc24ebe53a3453 and start looking at the details ;^). Linus
Re: [GIT PULL] xfs: new features for 5.3
The pull request you sent on Fri, 12 Jul 2019 11:02:05 -0700: > git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git tags/xfs-5.3-merge-12 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/4ce9d181ebe53abbca5f450b8a2984b8c3a38f26 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] vfs: standardize parameter checking for SETFLAGS/FSSETXATTR ioctls
The pull request you sent on Thu, 11 Jul 2019 07:18:25 -0700: > git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git > tags/vfs-fix-ioctl-checking-3 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/5010fe9f095414b959fd6fda63986dc90fd0c419 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] xfs: new features for 5.3
On Fri, Jul 12, 2019 at 11:02 AM Darrick J. Wong wrote: > > The branch merges cleanly against this morning's HEAD and survived an > overnight run of xfstests. The merge was completely straightforward, so > please let me know if you run into anything weird. Hmm. I don't know what you merged against, but it got a (fairly trivial) conflict for me due to 79d08f89bb1b ("block: fix .bi_size overflow") from the block merge (from Tuesday) touching a line next to one changed by a24737359667 ("xfs: simplify xfs_chain_bio") from this pull. So it wasn't an entirely clean merge for me. Was it a complex merge conflict? No. I'm just confused by the "merges cleanly against this morning's HEAD", which makes me wonder what you tried to merge against.. Linus
Re: [PATCH] be2net: fix adapter->big_page_size miscaculation
> On Jul 12, 2019, at 6:46 PM, David Miller wrote: > > From: Qian Cai > Date: Fri, 12 Jul 2019 15:23:21 -0400 > >> The commit d66acc39c7ce ("bitops: Optimise get_order()") introduced a >> problem for the be2net driver as "rx_frag_size" could be a module >> parameter that can be changed while loading the module. > > Why is this a problem? Well, for example, if rx_frag_size was set to 8096 when loading the module, the kernel has already used the default value 2048 during compilation time. > >> That commit checks __builtin_constant_p() first in get_order() which >> cause "adapter->big_page_size" to be assigned a value based on the >> the default "rx_frag_size" value at the compilation time. It also >> generate a compilation warning, > > rx_frag_size is not a constant, therefore the __builtin_constant_p() > test should not pass. > > This explanation doesn't seem valid. Actually, GCC would consider it a const with -O2 optimized level because it found that it was never modified and it does not understand it is a module parameter. Considering the following code. # cat const.c #include static int a = 1; int main(void) { if (__builtin_constant_p(a)) printf("a is a const.\n"); return 0; } # gcc -O2 const.c -o const # ./const a is a const.
Re: [PATCH v5 01/12] S.A.R.A.: add documentation
On Sat, 6 Jul 2019, Salvatore Mesoraca wrote: > Adding documentation for S.A.R.A. LSM. It would be good if you could add an operational overview to help people understand how it works in practice, e.g. setting policies for binaries via sara-xattr and global config via saractl (IIUC). It's difficult to understand if you have to visit several links to piece things together. > +S.A.R.A.'s Submodules > += > + > +WX Protection > +- > +WX Protection aims to improve user-space programs security by applying: > + > +- `W^X enforcement`_ > +- `W!->X (once writable never executable) mprotect restriction`_ > +- `Executable MMAP prevention`_ > + > +All of the above features can be enabled or disabled both system wide > +or on a per executable basis through the use of configuration files managed > by > +`saractl` [2]_. How complete is the WX protection provided by this module? How does it compare with other implementations (such as PaX's restricted mprotect). > +Parts of WX Protection are inspired by some of the features available in PaX. Some critical aspects are copied (e.g. trampoline emulation), so it's more than just inspired. Could you include more information in the description about what's been ported from PaX to SARA? -- James Morris
Re: [PATCH] [net-next] cxgb4: reduce kernel stack usage in cudbg_collect_mem_region()
On Fri, 2019-07-12 at 15:36 -0700, David Miller wrote: > From: Arnd Bergmann > Date: Fri, 12 Jul 2019 11:06:33 +0200 > > > The cudbg_collect_mem_region() and cudbg_read_fw_mem() both use several > > hundred kilobytes of kernel stack space. Several hundred 'kilo' bytes? I hope not.
[PATCH v5 07/11] of/platform: Sanity check DT bindings before creating device links
If a common DT binding is pointing to a child DT node of a particular parent DT node, don't add device links for such DT references. This is because, by definition, a child node can't be a functional dependency for the parent node. Signed-off-by: Saravana Kannan --- drivers/of/platform.c | 17 + 1 file changed, 17 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index dba962a0ee50..98414ba53b1f 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -512,6 +512,19 @@ int of_platform_default_populate(struct device_node *root, } EXPORT_SYMBOL_GPL(of_platform_default_populate); +bool of_link_is_valid(struct device_node *con, struct device_node *sup) +{ + of_node_get(sup); + while (sup) { + if (sup == con) { + of_node_put(sup); + return false; + } + sup = of_get_next_parent(sup); + } + return true; +} + static int of_link_binding(struct device *dev, const char *binding, const char *cell) { @@ -522,6 +535,10 @@ static int of_link_binding(struct device *dev, while (!of_parse_phandle_with_args(dev->of_node, binding, cell, i, &sup_args)) { + if (!of_link_is_valid(dev->of_node, sup_args.np)) { + of_node_put(sup_args.np); + continue; + } i++; sup_dev = of_find_device_by_node(sup_args.np); of_node_put(sup_args.np); -- 2.22.0.510.g264f2c817a-goog
[PATCH v5 09/11] of/platform: Create device links for all child-supplier depencencies
A parent device can have child devices that it adds when it probes. But this probing of the parent device can happen way after kernel init is done -- for example, when the parent device's driver is loaded as a module. In such cases, if the child devices depend on a supplier in the system, we need to make sure the supplier gets the sync_state() callback only after these child devices are added and probed. To achieve this, when creating device links for a device by looking at its DT node, don't just look at DT references at the top node level. Look at DT references in all the descendant nodes too and create device links from the ancestor device to all these supplier devices. This way, when the parent device probes and adds child devices, the child devices can then create their own device links to the suppliers and further delay the supplier's sync_state() callback to after the child devices are probed. Example: In this illustration, -> denotes DT references and indentation represents child status. Device node A Device node B -> D Device node C -> B, D Device node D Assume all these devices have their drivers loaded as modules. Without this patch, this is the sequence of events: 1. D is added. 2. A is added. 3. Device D probes. 4. Device D gets its sync_state() callback. 5. Device B and C might malfunction because their resources got altered/turned off before they can make active requests for them. With this patch, this is the sequence of events: 1. D is added. 2. A is added and creates device links to D. 3. Device link from A to B is not added because A is a parent of B. 4. Device D probes. 5. Device D does not get it's sync_state() callback because consumer A hasn't probed yet. 5. Device A probes. 5. a. Devices B and C are added. 5. b. Device links from B and C to D are added. 5. c. Device A's probe completes. 6. Device D does not get it's sync_state() callback because consumer A has probed but consumers B and C haven't probed yet. 7. Device B and C probe. 8. Device D gets it's sync_state() callback because all its consumers have probed. 9. None of the devices malfunction. Signed-off-by: Saravana Kannan --- drivers/of/platform.c | 29 - 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index cf8625abe30c..6523d07ef2d7 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -525,7 +525,7 @@ bool of_link_is_valid(struct device_node *con, struct device_node *sup) return true; } -static int of_link_binding(struct device *dev, +static int of_link_binding(struct device *dev, struct device_node *con_np, const char *binding, const char *cell) { struct of_phandle_args sup_args; @@ -534,7 +534,7 @@ static int of_link_binding(struct device *dev, unsigned int i = 0, links = 0; u32 dl_flags = DL_FLAG_AUTOPROBE_CONSUMER; - while (!of_parse_phandle_with_args(dev->of_node, binding, cell, i, + while (!of_parse_phandle_with_args(con_np, binding, cell, i, &sup_args)) { sup_np = sup_args.np; /* @@ -579,26 +579,37 @@ static const char * const link_bindings[] = { "interconnects", "#interconnect-cells", }; -static int of_link_to_suppliers(struct device *dev) +static int __of_link_to_suppliers(struct device *dev, + struct device_node *con_np) { unsigned int i = 0; bool done = true; - - if (!of_devlink) - return 0; - if (unlikely(!dev->of_node)) - return 0; + struct device_node *child; for (i = 0; i < ARRAY_SIZE(link_bindings) / 2; i++) - if (of_link_binding(dev, link_bindings[i * 2], + if (of_link_binding(dev, con_np, link_bindings[i * 2], link_bindings[i * 2 + 1])) done = false; + for_each_child_of_node(con_np, child) + if (__of_link_to_suppliers(dev, child)) + done = false; + if (!done) return -ENODEV; return 0; } +static int of_link_to_suppliers(struct device *dev) +{ + if (!of_devlink) + return 0; + if (unlikely(!dev->of_node)) + return 0; + + return __of_link_to_suppliers(dev, dev->of_node); +} + #ifndef CONFIG_PPC static const struct of_device_id reserved_mem_matches[] = { { .compatible = "qcom,rmtfs-mem" }, -- 2.22.0.510.g264f2c817a-goog
[PATCH v5 11/11] of/platform: Don't create device links default busses
Default busses also have devices created for them. But there's no point in creating device links for them. It's especially wasteful as it'll cause the traversal of the entire device tree and also spend a lot of time checking and figuring out that creating those links isn't allowed. So check for default busses and skip trying to create device links for them. Signed-off-by: Saravana Kannan --- drivers/of/platform.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 9f3b7e1801bc..b02dbaa01bfe 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -593,6 +593,9 @@ static int __of_link_to_suppliers(struct device *dev, struct property *p; unsigned int len, reg_len; + if (of_match_node(of_default_bus_match_table, con_np)) + return 0; + for (i = 0; i < ARRAY_SIZE(link_bindings) / 2; i++) if (of_link_binding(dev, con_np, link_bindings[i * 2], link_bindings[i * 2 + 1])) -- 2.22.0.510.g264f2c817a-goog
[PATCH v5 03/11] driver core: Add sync_state driver/bus callback
This sync_state driver/bus callback is called once all the consumers of a supplier have probed successfully. This allows the supplier device's driver/bus to sync the supplier device's state to the software state with the guarantee that all the consumers are actively managing the resources provided by the supplier device. To maintain backwards compatibility and ease transition from existing frameworks and resource cleanup schemes, late_initcall_sync is the earliest when the sync_state callback might be called. There is no upper bound on the time by which the sync_state callback has to be called. This is because if a consumer device never probes, the supplier has to maintain its resources in the state left by the bootloader. For example, if the bootloader leaves the display backlight at a fixed voltage and the backlight driver is never probed, you don't want the backlight to ever be turned off after boot up. Signed-off-by: Saravana Kannan --- drivers/base/core.c| 39 +++ drivers/of/platform.c | 9 + include/linux/device.h | 19 +++ 3 files changed, 67 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 0705926d362f..8b8b812d26f1 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -46,6 +46,7 @@ early_param("sysfs.deprecated", sysfs_deprecated_setup); /* Device links support. */ static LIST_HEAD(wait_for_suppliers); static DEFINE_MUTEX(wfs_lock); +static bool supplier_sync_state_enabled; #ifdef CONFIG_SRCU static DEFINE_MUTEX(device_links_lock); @@ -614,6 +615,41 @@ int device_links_check_suppliers(struct device *dev) return ret; } +static void __device_links_supplier_sync_state(struct device *dev) +{ + struct device_link *link; + + if (dev->state_synced) + return; + + list_for_each_entry(link, &dev->links.consumers, s_node) { + if (link->flags & DL_FLAG_STATELESS) + continue; + if (link->status != DL_STATE_ACTIVE) + return; + } + + if (dev->bus->sync_state) + dev->bus->sync_state(dev); + else if (dev->driver && dev->driver->sync_state) + dev->driver->sync_state(dev); + + dev->state_synced = true; +} + +int device_links_supplier_sync_state(struct device *dev, void *data) +{ + device_links_write_lock(); + __device_links_supplier_sync_state(dev); + device_links_write_unlock(); + return 0; +} + +void device_links_supplier_sync_state_enable(void) +{ + supplier_sync_state_enabled = true; +} + /** * device_links_driver_bound - Update device links after probing its driver. * @dev: Device to update the links for. @@ -658,6 +694,9 @@ void device_links_driver_bound(struct device *dev) WARN_ON(link->status != DL_STATE_CONSUMER_PROBE); WRITE_ONCE(link->status, DL_STATE_ACTIVE); + + if (supplier_sync_state_enabled) + __device_links_supplier_sync_state(link->supplier); } dev->links.status = DL_DEV_DRIVER_BOUND; diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 0930f9f89571..4d12d6658999 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -601,6 +601,15 @@ static int __init of_platform_default_populate_init(void) return 0; } arch_initcall_sync(of_platform_default_populate_init); + +static int __init of_platform_sync_state_init(void) +{ + device_links_supplier_sync_state_enable(); + bus_for_each_dev(&platform_bus_type, NULL, NULL, +device_links_supplier_sync_state); + return 0; +} +late_initcall_sync(of_platform_sync_state_init); #endif int of_platform_device_destroy(struct device *dev, void *data) diff --git a/include/linux/device.h b/include/linux/device.h index 7f8ae7e5fc6b..4a0db34ae650 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -84,6 +84,13 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); * in the future. * @probe: Called when a new device or driver add to this bus, and callback * the specific driver's probe to initial the matched device. + * @sync_state:Called to sync device state to software state after all the + * state tracking consumers linked to this device (present at + * the time of late_initcall) have successfully bound to a + * driver. If the device has no consumers, this function will + * be called at late_initcall_sync level. If the device has + * consumers that are never bound to a driver, this function + * will never get called until they do. * @remove:Called when a device removed from this bus. * @shutdown: Called at shut-down time to quiesce the device. * @@ -128,6 +135,7 @@ struct bus_type { int (*uevent)(struct device *dev, struct kobj_ueven
[PATCH v5 10/11] of/platform: Add functional dependency link from DT regulator bindings
Similar to creating functional dependency links from clock and interconnect DT bindings, also create functional dependency links from regulator DT bindings. Signed-off-by: Saravana Kannan --- drivers/of/platform.c | 83 ++- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 6523d07ef2d7..9f3b7e1801bc 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -525,46 +525,50 @@ bool of_link_is_valid(struct device_node *con, struct device_node *sup) return true; } -static int of_link_binding(struct device *dev, struct device_node *con_np, - const char *binding, const char *cell) +static int of_link_to_phandle(struct device *dev, struct device_node *sup_np) { - struct of_phandle_args sup_args; - struct device_node *sup_np; struct platform_device *sup_dev; - unsigned int i = 0, links = 0; u32 dl_flags = DL_FLAG_AUTOPROBE_CONSUMER; + int ret = 0; - while (!of_parse_phandle_with_args(con_np, binding, cell, i, - &sup_args)) { - sup_np = sup_args.np; - /* -* Since we are trying to create device links, we need to find -* the actual device node that owns this supplier phandle. -* Often times it's the same node, but sometimes it can be one -* of the parents. So walk up the parent till you find a -* device. -*/ - while (sup_np && !of_find_property(sup_np, "compatible", NULL)) - sup_np = of_get_next_parent(sup_np); - if (!sup_np) - continue; + /* +* Since we are trying to create device links, we need to find +* the actual device node that owns this supplier phandle. +* Often times it's the same node, but sometimes it can be one +* of the parents. So walk up the parent till you find a +* device. +*/ + while (sup_np && !of_find_property(sup_np, "compatible", NULL)) + sup_np = of_get_next_parent(sup_np); + if (!sup_np) + return 0; - if (!of_link_is_valid(dev->of_node, sup_np)) { - of_node_put(sup_np); - continue; - } - i++; - sup_dev = of_find_device_by_node(sup_np); + if (!of_link_is_valid(dev->of_node, sup_np)) { of_node_put(sup_np); - if (!sup_dev) - continue; - if (device_link_add(dev, &sup_dev->dev, dl_flags)) - links++; - put_device(&sup_dev->dev); + return 0; } - if (links < i) + sup_dev = of_find_device_by_node(sup_np); + of_node_put(sup_np); + if (!sup_dev) return -ENODEV; - return 0; + if (!device_link_add(dev, &sup_dev->dev, dl_flags)) + ret = -ENODEV; + put_device(&sup_dev->dev); + return ret; +} + +static int of_link_binding(struct device *dev, struct device_node *con_np, + const char *binding, const char *cell) +{ + struct of_phandle_args sup_args; + unsigned int i = 0; + bool done = true; + + while (!of_parse_phandle_with_args(con_np, binding, cell, i++, + &sup_args)) + if (of_link_to_phandle(dev, sup_args.np)) + done = false; + return done ? 0 : -ENODEV; } static bool of_devlink; @@ -579,18 +583,33 @@ static const char * const link_bindings[] = { "interconnects", "#interconnect-cells", }; +#define REG_SUFFIX "-supply" static int __of_link_to_suppliers(struct device *dev, struct device_node *con_np) { unsigned int i = 0; bool done = true; struct device_node *child; + struct property *p; + unsigned int len, reg_len; for (i = 0; i < ARRAY_SIZE(link_bindings) / 2; i++) if (of_link_binding(dev, con_np, link_bindings[i * 2], link_bindings[i * 2 + 1])) done = false; + reg_len = strlen(REG_SUFFIX); + for_each_property_of_node(con_np, p) { + len = strlen(p->name); + if (len <= reg_len) + continue; + if (strcmp(p->name + len - reg_len, REG_SUFFIX)) + continue; + if (of_link_to_phandle(dev, + of_parse_phandle(con_np, p->name, 0))) + done = false; + } + for_each_child_of_node(con_np, child) if (__of_link_to_suppliers(dev, child)) done = false; -- 2.22.0.510.g264f2c817a
[PATCH v5 05/11] driver core: Add APIs to pause/resume sync state callbacks
When multiple devices are added after kernel init, some suppliers could be added before their consumer devices get added. In these instances, the supplier devices could get their sync_state callback called right after they probe because the consumers haven't had a chance to create device links to the suppliers. This change adds APIs to pause/resume sync state callbacks so that when multiple devices are added, their sync_state callback evaluation can be postponed to happen after all of them are added. Signed-off-by: Saravana Kannan --- drivers/base/core.c| 40 +--- drivers/of/platform.c | 5 ++--- include/linux/device.h | 6 -- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index dce97b5f3536..b03e679faea4 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -46,7 +46,8 @@ early_param("sysfs.deprecated", sysfs_deprecated_setup); /* Device links support. */ static LIST_HEAD(wait_for_suppliers); static DEFINE_MUTEX(wfs_lock); -static bool supplier_sync_state_enabled; +static LIST_HEAD(deferred_sync); +static unsigned int supplier_sync_state_disabled; #ifdef CONFIG_SRCU static DEFINE_MUTEX(device_links_lock); @@ -657,17 +658,38 @@ static void __device_links_supplier_sync_state(struct device *dev) dev->state_synced = true; } -int device_links_supplier_sync_state(struct device *dev, void *data) +void device_links_supplier_sync_state_pause(void) { device_links_write_lock(); - __device_links_supplier_sync_state(dev); + supplier_sync_state_disabled++; device_links_write_unlock(); - return 0; } -void device_links_supplier_sync_state_enable(void) +void device_links_supplier_sync_state_resume(void) { - supplier_sync_state_enabled = true; + struct device *dev, *tmp; + + device_links_write_lock(); + if (!supplier_sync_state_disabled) { + WARN(true, "Unmatched sync_state pause/resume!"); + goto out; + } + supplier_sync_state_disabled--; + if (supplier_sync_state_disabled) + goto out; + + list_for_each_entry_safe(dev, tmp, &deferred_sync, links.defer_sync) { + __device_links_supplier_sync_state(dev); + list_del_init(&dev->links.defer_sync); + } +out: + device_links_write_unlock(); +} + +static void __device_links_supplier_defer_sync(struct device *sup) +{ + if (list_empty(&sup->links.defer_sync)) + list_add_tail(&sup->links.defer_sync, &deferred_sync); } /** @@ -715,7 +737,9 @@ void device_links_driver_bound(struct device *dev) WARN_ON(link->status != DL_STATE_CONSUMER_PROBE); WRITE_ONCE(link->status, DL_STATE_ACTIVE); - if (supplier_sync_state_enabled) + if (supplier_sync_state_disabled) + __device_links_supplier_defer_sync(link->supplier); + else __device_links_supplier_sync_state(link->supplier); } @@ -826,6 +850,7 @@ void device_links_driver_cleanup(struct device *dev) WRITE_ONCE(link->status, DL_STATE_DORMANT); } + list_del_init(&dev->links.defer_sync); __device_links_no_driver(dev); device_links_write_unlock(); @@ -1797,6 +1822,7 @@ void device_initialize(struct device *dev) INIT_LIST_HEAD(&dev->links.consumers); INIT_LIST_HEAD(&dev->links.suppliers); INIT_LIST_HEAD(&dev->links.needs_suppliers); + INIT_LIST_HEAD(&dev->links.defer_sync); dev->links.status = DL_DEV_NO_DRIVER; } EXPORT_SYMBOL_GPL(device_initialize); diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 4d12d6658999..56b718f09929 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -581,6 +581,7 @@ static int __init of_platform_default_populate_init(void) return -ENODEV; platform_bus_type.add_links = of_link_to_suppliers; + device_links_supplier_sync_state_pause(); /* * Handle certain compatibles explicitly, since we don't want to create * platform_devices for every node in /reserved-memory with a @@ -604,9 +605,7 @@ arch_initcall_sync(of_platform_default_populate_init); static int __init of_platform_sync_state_init(void) { - device_links_supplier_sync_state_enable(); - bus_for_each_dev(&platform_bus_type, NULL, NULL, -device_links_supplier_sync_state); + device_links_supplier_sync_state_resume(); return 0; } late_initcall_sync(of_platform_sync_state_init); diff --git a/include/linux/device.h b/include/linux/device.h index d3c9e70052d8..0ea28cb8c77e 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -926,12 +926,14 @@ enum dl_dev_state { * @suppliers: List of links to supplier devices. * @consumers: List of links to consumer devices. * @needs_suppliers
[PATCH v5 04/11] driver core: Add edit_links() callback for drivers
The driver core/bus adding dependencies by default makes sure that suppliers don't sync the hardware state with software state before all the consumers have their drivers loaded (if they are modules) and are probed. However, when the bus incorrectly adds dependencies that it shouldn't have added, the devices might never probe. For example, if device-C is a consumer of device-S and they have phandles to each other in DT, the following could happen: 1. Device-S get added first. 2. The bus add_links() callback will (incorrectly) try to link it as a consumer of device-C. 3. Since device-C isn't present, device-S will be put in "waiting-for-supplier" list. 4. Device-C gets added next. 5. All devices in "waiting-for-supplier" list are retried for linking. 6. Device-S gets linked as consumer to Device-C. 7. The bus add_links() callback will (correctly) try to link it as a consumer of device-S. 8. This isn't allowed because it would create a cyclic device links. So neither devices will get probed since the supplier is dependent on a consumer that'll never probe (because it can't get resources from the supplier). Without this patch, things stay in this broken state. However, with this patch, the execution will continue like this: 9. Device-C's driver is loaded. 10. Device-C's driver removes Device-S as a consumer of Device-C. 11. Device-C's driver adds Device-C as a consumer of Device-S. 12. Device-S probes. 13. Device-S sync_state() isn't called because Device-C hasn't probed yet. 14. Device-C probes. 15. Device-S's sync_state() callback is called. Signed-off-by: Saravana Kannan --- drivers/base/core.c| 24 ++-- drivers/base/dd.c | 29 + include/linux/device.h | 18 ++ 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 8b8b812d26f1..dce97b5f3536 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -423,6 +423,19 @@ static void device_link_wait_for_supplier(struct device *consumer) mutex_unlock(&wfs_lock); } +/** + * device_link_remove_from_wfs - Unmark device as waiting for supplier + * @consumer: Consumer device + * + * Unmark the consumer device as waiting for suppliers to become available. + */ +void device_link_remove_from_wfs(struct device *consumer) +{ + mutex_lock(&wfs_lock); + list_del_init(&consumer->links.needs_suppliers); + mutex_unlock(&wfs_lock); +} + /** * device_link_check_waiting_consumers - Try to unmark waiting consumers * @@ -440,12 +453,19 @@ static void device_link_wait_for_supplier(struct device *consumer) static void device_link_check_waiting_consumers(void) { struct device *dev, *tmp; + int ret; mutex_lock(&wfs_lock); list_for_each_entry_safe(dev, tmp, &wait_for_suppliers, -links.needs_suppliers) - if (!dev->bus->add_links(dev)) +links.needs_suppliers) { + ret = 0; + if (dev->has_edit_links) + ret = driver_edit_links(dev); + else if (dev->bus->add_links) + ret = dev->bus->add_links(dev); + if (!ret) list_del_init(&dev->links.needs_suppliers); + } mutex_unlock(&wfs_lock); } diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 0df9b4461766..842fc7b704f9 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -659,6 +659,12 @@ int driver_probe_device(struct device_driver *drv, struct device *dev) pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); + if (drv->edit_links) { + if (drv->edit_links(dev)) + dev->has_edit_links = true; + else + device_link_remove_from_wfs(dev); + } pm_runtime_get_suppliers(dev); if (dev->parent) pm_runtime_get_sync(dev->parent); @@ -747,6 +753,29 @@ struct device_attach_data { bool have_async; }; +static int __driver_edit_links(struct device_driver *drv, void *data) +{ + struct device *dev = data; + + if (!drv->edit_links) + return 0; + + if (driver_match_device(drv, dev) <= 0) + return 0; + + return drv->edit_links(dev); +} + +int driver_edit_links(struct device *dev) +{ + int ret; + + device_lock(dev); + ret = bus_for_each_drv(dev->bus, NULL, dev, __driver_edit_links); + device_unlock(dev); + return ret; +} + static int __device_attach_driver(struct device_driver *drv, void *_data) { struct device_attach_data *data = _data; diff --git a/include/linux/device.h b/include/linux/device.h index 4a0db34ae650..d3c9e70052d8 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -262,6 +262,20 @@ e
Re: [PATCH 4.19 00/91] 4.19.59-stable review
stable-rc/linux-4.19.y boot: 122 boots: 4 failed, 117 passed with 1 offline (v4.19.58-92-gd66f8e7f112f) Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.19.y/kernel/v4.19.58-92-gd66f8e7f112f/ Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.19.y/kernel/v4.19.58-92-gd66f8e7f112f/ Tree: stable-rc Branch: linux-4.19.y Git Describe: v4.19.58-92-gd66f8e7f112f Git Commit: d66f8e7f112fefe0c1d2a0f77da022a56ccde6dc Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git Tested: 70 unique boards, 27 SoC families, 17 builds out of 206 Boot Regressions Detected: arm64: defconfig: gcc-8: meson-gxbb-nanopi-k2: lab-baylibre: new failure (last pass: v4.19.58) Boot Failures Detected: arm: multi_v7_defconfig: gcc-8: sun7i-a20-bananapi: 1 failed lab sunxi_defconfig: gcc-8: sun7i-a20-bananapi: 1 failed lab arm64: defconfig: gcc-8: meson-gxbb-nanopi-k2: 1 failed lab arc: hsdk_defconfig: gcc-8: hsdk: 1 failed lab Offline Platforms: arm64: defconfig: gcc-8 meson-gxl-s905d-p230: 1 offline lab --- For more info write to
[PATCH v5 00/11] Solve postboot supplier cleanup and optimize probe ordering
Add device-links to track functional dependencies between devices after they are created (but before they are probed) by looking at their common DT bindings like clocks, interconnects, etc. Having functional dependencies automatically added before the devices are probed, provides the following benefits: - Optimizes device probe order and avoids the useless work of attempting probes of devices that will not probe successfully (because their suppliers aren't present or haven't probed yet). For example, in a commonly available mobile SoC, registering just one consumer device's driver at an initcall level earlier than the supplier device's driver causes 11 failed probe attempts before the consumer device probes successfully. This was with a kernel with all the drivers statically compiled in. This problem gets a lot worse if all the drivers are loaded as modules without direct symbol dependencies. - Supplier devices like clock providers, interconnect providers, etc need to keep the resources they provide active and at a particular state(s) during boot up even if their current set of consumers don't request the resource to be active. This is because the rest of the consumers might not have probed yet and turning off the resource before all the consumers have probed could lead to a hang or undesired user experience. Some frameworks (Eg: regulator) handle this today by turning off "unused" resources at late_initcall_sync and hoping all the devices have probed by then. This is not a valid assumption for systems with loadable modules. Other frameworks (Eg: clock) just don't handle this due to the lack of a clear signal for when they can turn off resources. This leads to downstream hacks to handle cases like this that can easily be solved in the upstream kernel. By linking devices before they are probed, we give suppliers a clear count of the number of dependent consumers. Once all of the consumers are active, the suppliers can turn off the unused resources without making assumptions about the number of consumers. By default we just add device-links to track "driver presence" (probe succeeded) of the supplier device. If any other functionality provided by device-links are needed, it is left to the consumer/supplier devices to change the link when they probe. v1 -> v2: - Drop patch to speed up of_find_device_by_node() - Drop depends-on property and use existing bindings v2 -> v3: - Refactor the code to have driver core initiate the linking of devs - Have driver core link consumers to supplier before it's probed - Add support for drivers to edit the device links before probing v3 -> v4 - Tested edit_links() on system with cyclic dependency. Works. - Added some checks to make sure device link isn't attempted from parent device node to child device node. - Added way to pause/resume sync_state callbacks across of_platform_populate(). - Recursively parse DT node to create device links from parent to suppliers of parent and all child nodes. v4 -> v5 - Fixed copy-pasta bugs with linked list handling - Walk up the phandle reference till I find an actual device (needed for regulators to work) - Added support for linking devices from regulator DT bindings - Tested the whole series again to make sure cyclic dependencies are broken with edit_links() and regulator links are created properly. I could probably squash some of the patches, but leaving them like this because I think it's easier to understand this way. I've also not updated this patch series to handle the new patch [1] from Rafael. Will do that once this patch series is close to being Acked. [1] - https://lore.kernel.org/lkml/3121545.4lOhFoIcdQ@kreacher/ -Saravana Saravana Kannan (11): driver core: Add support for linking devices during device addition of/platform: Add functional dependency link from DT bindings driver core: Add sync_state driver/bus callback driver core: Add edit_links() callback for drivers driver core: Add APIs to pause/resume sync state callbacks of/platform: Pause/resume sync state in of_platform_populate() of/platform: Sanity check DT bindings before creating device links of/platform: Make sure supplier DT node is device when creating device links of/platform: Create device links for all child-supplier depencencies of/platform: Add functional dependency link from DT regulator bindings of/platform: Don't create device links default busses .../admin-guide/kernel-parameters.txt | 5 + drivers/base/core.c | 168 ++ drivers/base/dd.c | 29 +++ drivers/of/platform.c | 132 ++ include/linux/device.h| 47 + 5 files changed, 381 insertions(+) -- 2.22.0.510.g264f2c817a-goog
[PATCH v5 01/11] driver core: Add support for linking devices during device addition
When devices are added, the bus might want to create device links to track functional dependencies between supplier and consumer devices. This tracking of supplier-consumer relationship allows optimizing device probe order and tracking whether all consumers of a supplier are active. The add_links bus callback is added to support this. However, when consumer devices are added, they might not have a supplier device to link to despite needing mandatory resources/functionality from one or more suppliers. A waiting_for_suppliers list is created to track such consumers and retry linking them when new devices get added. Signed-off-by: Saravana Kannan --- drivers/base/core.c| 83 ++ include/linux/device.h | 8 2 files changed, 91 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index fd7511e04e62..0705926d362f 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -44,6 +44,8 @@ early_param("sysfs.deprecated", sysfs_deprecated_setup); #endif /* Device links support. */ +static LIST_HEAD(wait_for_suppliers); +static DEFINE_MUTEX(wfs_lock); #ifdef CONFIG_SRCU static DEFINE_MUTEX(device_links_lock); @@ -401,6 +403,51 @@ struct device_link *device_link_add(struct device *consumer, } EXPORT_SYMBOL_GPL(device_link_add); +/** + * device_link_wait_for_supplier - Mark device as waiting for supplier + * @consumer: Consumer device + * + * Marks the consumer device as waiting for suppliers to become available. The + * consumer device will never be probed until it's unmarked as waiting for + * suppliers. The caller is responsible for adding the link to the supplier + * once the supplier device is present. + * + * This function is NOT meant to be called from the probe function of the + * consumer but rather from code that creates/adds the consumer device. + */ +static void device_link_wait_for_supplier(struct device *consumer) +{ + mutex_lock(&wfs_lock); + list_add_tail(&consumer->links.needs_suppliers, &wait_for_suppliers); + mutex_unlock(&wfs_lock); +} + +/** + * device_link_check_waiting_consumers - Try to unmark waiting consumers + * + * Loops through all consumers waiting on suppliers and tries to add all their + * supplier links. If that succeeds, the consumer device is unmarked as waiting + * for suppliers. Otherwise, they are left marked as waiting on suppliers, + * + * The add_links bus callback is expected to return 0 if it has found and added + * all the supplier links for the consumer device. It should return an error if + * it isn't able to do so. + * + * The caller of device_link_wait_for_supplier() is expected to call this once + * it's aware of potential suppliers becoming available. + */ +static void device_link_check_waiting_consumers(void) +{ + struct device *dev, *tmp; + + mutex_lock(&wfs_lock); + list_for_each_entry_safe(dev, tmp, &wait_for_suppliers, +links.needs_suppliers) + if (!dev->bus->add_links(dev)) + list_del_init(&dev->links.needs_suppliers); + mutex_unlock(&wfs_lock); +} + static void device_link_free(struct device_link *link) { while (refcount_dec_not_one(&link->rpm_active)) @@ -535,6 +582,19 @@ int device_links_check_suppliers(struct device *dev) struct device_link *link; int ret = 0; + /* +* If a device is waiting for one or more suppliers (in +* wait_for_suppliers list), it is not ready to probe yet. So just +* return -EPROBE_DEFER without having to check the links with existing +* suppliers. +*/ + mutex_lock(&wfs_lock); + if (!list_empty(&dev->links.needs_suppliers)) { + mutex_unlock(&wfs_lock); + return -EPROBE_DEFER; + } + mutex_unlock(&wfs_lock); + device_links_write_lock(); list_for_each_entry(link, &dev->links.suppliers, c_node) { @@ -812,6 +872,10 @@ static void device_links_purge(struct device *dev) { struct device_link *link, *ln; + mutex_lock(&wfs_lock); + list_del(&dev->links.needs_suppliers); + mutex_unlock(&wfs_lock); + /* * Delete all of the remaining links from this device to any other * devices (either consumers or suppliers). @@ -1673,6 +1737,7 @@ void device_initialize(struct device *dev) #endif INIT_LIST_HEAD(&dev->links.consumers); INIT_LIST_HEAD(&dev->links.suppliers); + INIT_LIST_HEAD(&dev->links.needs_suppliers); dev->links.status = DL_DEV_NO_DRIVER; } EXPORT_SYMBOL_GPL(device_initialize); @@ -2108,6 +2173,24 @@ int device_add(struct device *dev) BUS_NOTIFY_ADD_DEVICE, dev); kobject_uevent(&dev->kobj, KOBJ_ADD); + + /* +* Check if any of the other devices (consumers) have been waiting for +* this device (supplier) to be added so that they can create a device +
[PATCH v5 06/11] of/platform: Pause/resume sync state in of_platform_populate()
When multiple child devices are populated using of_platform_populate() after kernel init, there could be supplier-consumer dependencies between the child devices. Wait for all the devices to be added and linked before calling sync_state() on all the suppliers. Signed-off-by: Saravana Kannan --- drivers/of/platform.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 56b718f09929..dba962a0ee50 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -486,6 +486,7 @@ int of_platform_populate(struct device_node *root, pr_debug("%s()\n", __func__); pr_debug(" starting at: %pOF\n", root); + device_links_supplier_sync_state_pause(); for_each_child_of_node(root, child) { rc = of_platform_bus_create(child, matches, lookup, parent, true); if (rc) { @@ -493,6 +494,8 @@ int of_platform_populate(struct device_node *root, break; } } + device_links_supplier_sync_state_resume(); + of_node_set_flag(root, OF_POPULATED_BUS); of_node_put(root); -- 2.22.0.510.g264f2c817a-goog
[PATCH v5 08/11] of/platform: Make sure supplier DT node is device when creating device links
While most phandle references in common bindings point to the supplier device node, there are also common bindings where the phandle can pointing to a child node of the supplier device node. Therefore, when trying to find the supplier device that corresponds to a supplier phandle, we need to make sure we are using the supplier's device node. Otherwise, we'll never find the supplier device. Signed-off-by: Saravana Kannan --- drivers/of/platform.c | 22 ++ 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 98414ba53b1f..cf8625abe30c 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -529,19 +529,33 @@ static int of_link_binding(struct device *dev, const char *binding, const char *cell) { struct of_phandle_args sup_args; + struct device_node *sup_np; struct platform_device *sup_dev; unsigned int i = 0, links = 0; u32 dl_flags = DL_FLAG_AUTOPROBE_CONSUMER; while (!of_parse_phandle_with_args(dev->of_node, binding, cell, i, &sup_args)) { - if (!of_link_is_valid(dev->of_node, sup_args.np)) { - of_node_put(sup_args.np); + sup_np = sup_args.np; + /* +* Since we are trying to create device links, we need to find +* the actual device node that owns this supplier phandle. +* Often times it's the same node, but sometimes it can be one +* of the parents. So walk up the parent till you find a +* device. +*/ + while (sup_np && !of_find_property(sup_np, "compatible", NULL)) + sup_np = of_get_next_parent(sup_np); + if (!sup_np) + continue; + + if (!of_link_is_valid(dev->of_node, sup_np)) { + of_node_put(sup_np); continue; } i++; - sup_dev = of_find_device_by_node(sup_args.np); - of_node_put(sup_args.np); + sup_dev = of_find_device_by_node(sup_np); + of_node_put(sup_np); if (!sup_dev) continue; if (device_link_add(dev, &sup_dev->dev, dl_flags)) -- 2.22.0.510.g264f2c817a-goog
Re: [PATCH v5 03/12] S.A.R.A.: cred blob management
On Sat, 6 Jul 2019, Salvatore Mesoraca wrote: > Creation of the S.A.R.A. cred blob management "API". > In order to allow S.A.R.A. to be stackable with other LSMs, it doesn't use > the "security" field of struct cred, instead it uses an ad hoc field named > security_sara. > This solution is probably not acceptable for upstream, so this part will > be modified as soon as the LSM stackable cred blob management will be > available. This description is out of date wrt cred blob sharing. > + if (sara_data_init()) { > + pr_crit("impossible to initialize creds.\n"); > + goto error; > + } > + > +int __init sara_data_init(void) > +{ > + security_add_hooks(data_hooks, ARRAY_SIZE(data_hooks), "sara"); > + return 0; > +} This can't fail so make it return void and simplify the caller. -- James Morris
Re: [PATCH v1 1/6] rcu: Add support for consolidated-RCU reader checking
On Fri, Jul 12, 2019 at 03:40:40PM -0400, Joel Fernandes wrote: > On Fri, Jul 12, 2019 at 10:46:30AM -0700, Paul E. McKenney wrote: > > On Fri, Jul 12, 2019 at 01:06:31PM -0400, Joel Fernandes wrote: > > > On Fri, Jul 12, 2019 at 09:45:31AM -0700, Paul E. McKenney wrote: > > > > On Fri, Jul 12, 2019 at 11:10:51AM -0400, Joel Fernandes wrote: > > > > > On Fri, Jul 12, 2019 at 01:11:25PM +0200, Peter Zijlstra wrote: > > > > > > On Thu, Jul 11, 2019 at 07:43:56PM -0400, Joel Fernandes (Google) > > > > > > wrote: > > > > > > > +int rcu_read_lock_any_held(void) > > > > > > > +{ > > > > > > > + int lockdep_opinion = 0; > > > > > > > + > > > > > > > + if (!debug_lockdep_rcu_enabled()) > > > > > > > + return 1; > > > > > > > + if (!rcu_is_watching()) > > > > > > > + return 0; > > > > > > > + if (!rcu_lockdep_current_cpu_online()) > > > > > > > + return 0; > > > > > > > + > > > > > > > + /* Preemptible RCU flavor */ > > > > > > > + if (lock_is_held(&rcu_lock_map)) > > > > > > > > > > > > you forgot debug_locks here. > > > > > > > > > > Actually, it turns out debug_locks checking is not even needed. If > > > > > debug_locks == 0, then debug_lockdep_rcu_enabled() returns 0 and we > > > > > would not > > > > > get to this point. > > > > > > > > > > > > + return 1; > > > > > > > + > > > > > > > + /* BH flavor */ > > > > > > > + if (in_softirq() || irqs_disabled()) > > > > > > > > > > > > I'm not sure I'd put irqs_disabled() under BH, also this entire > > > > > > condition is superfluous, see below. > > > > > > > > > > > > > + return 1; > > > > > > > + > > > > > > > + /* Sched flavor */ > > > > > > > + if (debug_locks) > > > > > > > + lockdep_opinion = lock_is_held(&rcu_sched_lock_map); > > > > > > > + return lockdep_opinion || !preemptible(); > > > > > > > > > > > > that !preemptible() turns into: > > > > > > > > > > > > !(preempt_count()==0 && !irqs_disabled()) > > > > > > > > > > > > which is: > > > > > > > > > > > > preempt_count() != 0 || irqs_disabled() > > > > > > > > > > > > and already includes irqs_disabled() and in_softirq(). > > > > > > > > > > > > > +} > > > > > > > > > > > > So maybe something lke: > > > > > > > > > > > > if (debug_locks && (lock_is_held(&rcu_lock_map) || > > > > > > lock_is_held(&rcu_sched_lock_map))) > > > > > > return true; > > > > > > > > > > Agreed, I will do it this way (without the debug_locks) like: > > > > > > > > > > ---8<--- > > > > > > > > > > diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c > > > > > index ba861d1716d3..339aebc330db 100644 > > > > > --- a/kernel/rcu/update.c > > > > > +++ b/kernel/rcu/update.c > > > > > @@ -296,27 +296,15 @@ EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held); > > > > > > > > > > int rcu_read_lock_any_held(void) > > > > > { > > > > > - int lockdep_opinion = 0; > > > > > - > > > > > if (!debug_lockdep_rcu_enabled()) > > > > > return 1; > > > > > if (!rcu_is_watching()) > > > > > return 0; > > > > > if (!rcu_lockdep_current_cpu_online()) > > > > > return 0; > > > > > - > > > > > - /* Preemptible RCU flavor */ > > > > > - if (lock_is_held(&rcu_lock_map)) > > > > > - return 1; > > > > > - > > > > > - /* BH flavor */ > > > > > - if (in_softirq() || irqs_disabled()) > > > > > - return 1; > > > > > - > > > > > - /* Sched flavor */ > > > > > - if (debug_locks) > > > > > - lockdep_opinion = lock_is_held(&rcu_sched_lock_map); > > > > > - return lockdep_opinion || !preemptible(); > > > > > + if (lock_is_held(&rcu_lock_map) || > > > > > lock_is_held(&rcu_sched_lock_map)) > > > > > > > > OK, I will bite... Why not also lock_is_held(&rcu_bh_lock_map)? > > > > > > Hmm, I was borrowing the strategy from rcu_read_lock_bh_held() which does > > > not > > > check for a lock held in this map. > > > > > > Honestly, even lock_is_held(&rcu_sched_lock_map) seems unnecessary per-se > > > since !preemptible() will catch that? rcu_read_lock_sched() disables > > > preemption already, so lockdep's opinion of the matter seems redundant > > > there. > > > > Good point! At least as long as the lockdep splats list RCU-bh among > > the locks held, which they did last I checked. > > > > Of course, you could make the same argument for getting rid of > > rcu_sched_lock_map. Does it make sense to have the one without > > the other? > > It probably makes it inconsistent in the least. I will add the check for > the rcu_bh_lock_map in a separate patch, if that's Ok with you - since I also > want to update the rcu_read_lock_bh_held() logic in the same patch. > > That rcu_read_lock_bh_held() could also just return !preemptible as Peter > suggested for the bh case. Although that seems reasonable, please check the call sites. > > > Sorry I already sent out patches again before seeing your comment but I > > > can > >
[PATCH] scatterlist: Don't allocate sg lists using __get_free_page
From: Sultan Alsawaf Allocating pages with __get_free_page is slower than going through the slab allocator to grab free pages out from a pool. These are the results from running the code at the bottom of this message: [1.278602] speedtest: __get_free_page: 9 us [1.278606] speedtest: kmalloc: 4 us [1.278609] speedtest: kmem_cache_alloc: 4 us [1.278611] speedtest: vmalloc: 13 us kmalloc and kmem_cache_alloc (which is what kmalloc uses for common sizes behind the scenes) are the fastest choices. Use kmalloc to speed up sg list allocation. This is the code used to produce the above measurements: #include #include #include static int speedtest(void *data) { static const struct sched_param sched_max_rt_prio = { .sched_priority = MAX_RT_PRIO - 1 }; volatile s64 ctotal = 0, gtotal = 0, ktotal = 0, vtotal = 0; struct kmem_cache *page_pool; int i, j, trials = 1000; volatile ktime_t start; void *ptr[100]; sched_setscheduler_nocheck(current, SCHED_FIFO, &sched_max_rt_prio); page_pool = kmem_cache_create("pages", PAGE_SIZE, PAGE_SIZE, SLAB_PANIC, NULL); for (i = 0; i < trials; i++) { start = ktime_get(); for (j = 0; j < ARRAY_SIZE(ptr); j++) while (!(ptr[j] = kmem_cache_alloc(page_pool, GFP_KERNEL))); ctotal += ktime_us_delta(ktime_get(), start); for (j = 0; j < ARRAY_SIZE(ptr); j++) kmem_cache_free(page_pool, ptr[j]); start = ktime_get(); for (j = 0; j < ARRAY_SIZE(ptr); j++) while (!(ptr[j] = (void *)__get_free_page(GFP_KERNEL))); gtotal += ktime_us_delta(ktime_get(), start); for (j = 0; j < ARRAY_SIZE(ptr); j++) free_page((unsigned long)ptr[j]); start = ktime_get(); for (j = 0; j < ARRAY_SIZE(ptr); j++) while (!(ptr[j] = kmalloc(PAGE_SIZE, GFP_KERNEL))); ktotal += ktime_us_delta(ktime_get(), start); for (j = 0; j < ARRAY_SIZE(ptr); j++) kfree(ptr[j]); start = ktime_get(); *ptr = vmalloc(ARRAY_SIZE(ptr) * PAGE_SIZE); vtotal += ktime_us_delta(ktime_get(), start); vfree(*ptr); } kmem_cache_destroy(page_pool); printk("%s: __get_free_page: %lld us\n", __func__, gtotal / trials); printk("%s: kmalloc: %lld us\n", __func__, ktotal / trials); printk("%s: kmem_cache_alloc: %lld us\n", __func__, ctotal / trials); printk("%s: vmalloc: %lld us\n", __func__, vtotal / trials); complete(data); return 0; } static int __init start_test(void) { DECLARE_COMPLETION_ONSTACK(done); BUG_ON(IS_ERR(kthread_run(speedtest, &done, "malloc_test"))); wait_for_completion(&done); return 0; } late_initcall(start_test); Signed-off-by: Sultan Alsawaf --- lib/scatterlist.c | 23 ++- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/lib/scatterlist.c b/lib/scatterlist.c index c2cf2c311b7d..d3093e8f8978 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -148,31 +148,12 @@ EXPORT_SYMBOL(sg_init_one); */ static struct scatterlist *sg_kmalloc(unsigned int nents, gfp_t gfp_mask) { - if (nents == SG_MAX_SINGLE_ALLOC) { - /* -* Kmemleak doesn't track page allocations as they are not -* commonly used (in a raw form) for kernel data structures. -* As we chain together a list of pages and then a normal -* kmalloc (tracked by kmemleak), in order to for that last -* allocation not to become decoupled (and thus a -* false-positive) we need to inform kmemleak of all the -* intermediate allocations. -*/ - void *ptr = (void *) __get_free_page(gfp_mask); - kmemleak_alloc(ptr, PAGE_SIZE, 1, gfp_mask); - return ptr; - } else - return kmalloc_array(nents, sizeof(struct scatterlist), -gfp_mask); + return kmalloc_array(nents, sizeof(struct scatterlist), gfp_mask); } static void sg_kfree(struct scatterlist *sg, unsigned int nents) { - if (nents == SG_MAX_SINGLE_ALLOC) { - kmemleak_free(sg); - free_page((unsigned long) sg); - } else - kfree(sg); + kfree(sg); } /** -- 2.22.0
Re: [GIT PULL] Kselftest update for Linux 5.3-rc1
The pull request you sent on Fri, 12 Jul 2019 12:07:27 -0600: > git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest > tags/linux-kselftest-5.3-rc1 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/8487d8229990e6eacaf1c854a113c9d16b7b596c Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] asm-generic: remove ptrace.h
The pull request you sent on Fri, 12 Jul 2019 23:04:31 +0200: > git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git > tags/asm-generic-5.3 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/5f26f1143678d0fed8115afdcc0de99ee7cc9675 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] dma-mapping updates for 5.3
The pull request you sent on Thu, 11 Jul 2019 15:56:54 +0200: > git://git.infradead.org/users/hch/dma-mapping.git tags/dma-mapping-5.3 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/9e3a25dc992dd9f3170fb643bdd95da5ca9c5576 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] hyper-v patches for 5.3
The pull request you sent on Thu, 11 Jul 2019 14:32:18 -0400: > https://lore.kernel.org/lkml/20190709195358.25af2...@canb.auug.org.au/ . has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/16c97650a56abdd067f7da079007b7e00b307083 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL 1/2] Kbuild updates for v5.3-rc1
The pull request you sent on Sat, 13 Jul 2019 02:50:05 +0900: > git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git > tags/kbuild-v5.3 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/39ceda5ce1b002e30563fcb8ad1bb5ac8e4d59ee Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL 2/2] Kconfig updates for v5.3-rc1
The pull request you sent on Sat, 13 Jul 2019 02:54:42 +0900: > git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git > tags/kconfig-v5.3 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/106f1466e7e7057ec6f4dc9516c13ea8cb9dffa0 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] First batch of KVM changes for Linux 5.3
The pull request you sent on Fri, 12 Jul 2019 19:44:24 +0200: > https://git.kernel.org/pub/scm/virt/kvm/kvm.git tags/for-linus has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/39d7530d7494b4e47ba1856e741f513dafd17e3d Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] s390 patches for the 5.3 merge window #2
The pull request you sent on Fri, 12 Jul 2019 16:39:34 +0200: > git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.3-2 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/aabfea8dc91cf5b220d2ed85e8f6395a9b140371 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [PATCH] mm: sparse: Skip no-map regions in memblocks_present
On Fri, Jul 12, 2019 at 10:51:31AM +0200, KarimAllah Ahmed wrote: >Do not mark regions that are marked with nomap to be present, otherwise >these memblock cause unnecessarily allocation of metadata. > >Cc: Andrew Morton >Cc: Pavel Tatashin >Cc: Oscar Salvador >Cc: Michal Hocko >Cc: Mike Rapoport >Cc: Baoquan He >Cc: Qian Cai >Cc: Wei Yang >Cc: Logan Gunthorpe >Cc: linux...@kvack.org >Cc: linux-kernel@vger.kernel.org >Signed-off-by: KarimAllah Ahmed >--- > mm/sparse.c | 4 > 1 file changed, 4 insertions(+) > >diff --git a/mm/sparse.c b/mm/sparse.c >index fd13166..33810b6 100644 >--- a/mm/sparse.c >+++ b/mm/sparse.c >@@ -256,6 +256,10 @@ void __init memblocks_present(void) > struct memblock_region *reg; > > for_each_memblock(memory, reg) { >+ >+ if (memblock_is_nomap(reg)) >+ continue; >+ > memory_present(memblock_get_region_node(reg), > memblock_region_memory_base_pfn(reg), > memblock_region_memory_end_pfn(reg)); The logic looks good, while I am not sure this would take effect. Since the metadata is SECTION size aligned while memblock is not. If I am correct, on arm64, we mark nomap memblock in map_mem() memblock_mark_nomap(kernel_start, kernel_end - kernel_start); And kernel text area is less than 40M, if I am right. This means memblocks_present would still mark the section present. Would you mind showing how much memory range it is marked nomap? >-- >2.7.4 -- Wei Yang Help you, Help me
Re: [PATCH] nvmet-file: fix nvmet_file_flush() always returning an error
Looks good, Reviewed-by: Sagi Grimberg
Re: BUG: MAX_STACK_TRACE_ENTRIES too low! (2)
On 7/12/19 1:55 AM, Peter Zijlstra wrote: On Thu, Jul 11, 2019 at 11:53:12AM -0700, Bart Van Assche wrote: On 7/10/19 3:09 PM, Peter Zijlstra wrote: One thing I mentioned when Thomas did the unwinder API changes was trying to move lockdep over to something like stackdepot. We can't directly use stackdepot as is, because it uses locks and memory allocation, but we could maybe add a lower level API to it and use that under the graph_lock() on static storage or something. Otherwise we'll have to (re)implement something like it. I've not looked at it in detail. Hi Peter, Is something like the untested patch below perhaps what you had in mind? Most excellent, yes! Now I suppose the $64000 question is if it actually reduces the amount of storage we use for stack traces.. Seems to boot just fine.. :-) Hi Peter, On my setup after some time the space occupied by stack traces stabilizes to the following: # grep stack /proc/lockdep_stats stack-trace entries:169456 [max: 524288] number of stack traces:9073 number of stack hash chains: 6980 I think these numbers show that there are some but not too many hash collisions (the code for the hash statistics was added after I e-mailed my patch). Bart.
Re: [PATCH] be2net: fix adapter->big_page_size miscaculation
From: Qian Cai Date: Fri, 12 Jul 2019 15:23:21 -0400 > The commit d66acc39c7ce ("bitops: Optimise get_order()") introduced a > problem for the be2net driver as "rx_frag_size" could be a module > parameter that can be changed while loading the module. Why is this a problem? > That commit checks __builtin_constant_p() first in get_order() which > cause "adapter->big_page_size" to be assigned a value based on the > the default "rx_frag_size" value at the compilation time. It also > generate a compilation warning, rx_frag_size is not a constant, therefore the __builtin_constant_p() test should not pass. This explanation doesn't seem valid.
[PATCH] x86/process: Delete useless check for dead process with LDT
At release_thread(), ->mm is NULL; and it is fine for the former mm to still have an LDT. Delete this check in process_64.c, similar to commit 2684927c6b93 ("[PATCH] x86: Deprecate useless bug"), which did the same in process_32.c. Signed-off-by: Jann Horn --- arch/x86/kernel/process_64.c | 12 +--- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 250e4c4ac6d9..af64519b2695 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -143,17 +143,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode) void release_thread(struct task_struct *dead_task) { - if (dead_task->mm) { -#ifdef CONFIG_MODIFY_LDT_SYSCALL - if (dead_task->mm->context.ldt) { - pr_warn("WARNING: dead process %s still has LDT? <%p/%d>\n", - dead_task->comm, - dead_task->mm->context.ldt->entries, - dead_task->mm->context.ldt->nr_entries); - BUG(); - } -#endif - } + WARN_ON(dead_task->mm); } enum which_selector { -- 2.22.0.510.g264f2c817a-goog
[PATCH] nvmet-file: fix nvmet_file_flush() always returning an error
errno_to_nvme_status() doesn't take into account the case when errno=0, all other use cases only call it if there is actually an error. Presently, nvmet_file_flush() always returns a call to errno_to_nvme_status() so, even if it is successful, it will return NVME_SC_INTERNAL. This bug was found while trying to get the existing blktests to pass. Fixes: c6aa3542e010 ("nvmet: add error log support for file backend") Signed-off-by: Logan Gunthorpe Cc: Chaitanya Kulkarni --- drivers/nvme/target/io-cmd-file.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c index 05453f5d1448..fec17c66b8cd 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -261,7 +261,13 @@ static void nvmet_file_execute_rw(struct nvmet_req *req) u16 nvmet_file_flush(struct nvmet_req *req) { - return errno_to_nvme_status(req, vfs_fsync(req->ns->file, 1)); + int ret; + + ret = vfs_fsync(req->ns->file, 1); + if (ret) + return errno_to_nvme_status(req, ret); + + return NVME_SC_SUCCESS; } static void nvmet_file_flush_work(struct work_struct *w) -- 2.20.1
Re: [PATCH] net: hisilicon: Use devm_platform_ioremap_resource
From: Jiangfeng Xiao Date: Fri, 12 Jul 2019 21:16:24 +0800 > Use devm_platform_ioremap_resource instead of > devm_ioremap_resource. Make the code simpler. > > Signed-off-by: Jiangfeng Xiao Applied.