From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10C7B5661 for ; Thu, 20 Jun 2024 00:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718845156; cv=none; b=jWpkTrcAt4qweMA1T2cjwGSGDImRd6sM67wubQEtgH2yTY1Xu/lMvCrfCUWR2Ag//QPvY9Q2Tjm2kgsASEptuG3FAJO25+SUV2TxOQnI19SRd/WM1TNcU8WZ5DHarU8KKTgA786E7ca9BrSYQxfBldxrvjLZt4viZpFAERG38Cs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718845156; c=relaxed/simple; bh=C/tDCL/BL96OaeWnf6dLoXGIKp/vo28vXFC9YcfbgRM=; h=Date:To:From:Subject:Message-Id; b=tUSSgxhvW6Xai4YEoDviUIJ8EuC0tT1keqLsifdFWr3KV7HdYJlDCzf1QU/Ed1zspJFwnRoYs640Cozcr4mDIPxLUrAv+euUadXuAyB9+lGpK6Rvcrr7BG/sYmSVwVN0/v5UpoopPiO7yXdltSPyldV+Q2jdVCyAcFvwnBX9xf8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=R2FpjN/h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="R2FpjN/h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA440C2BBFC; Thu, 20 Jun 2024 00:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1718845155; bh=C/tDCL/BL96OaeWnf6dLoXGIKp/vo28vXFC9YcfbgRM=; h=Date:To:From:Subject:From; b=R2FpjN/hgtZvta/YIRTkhFiw1SgbkeVbL/LO4cVsv0vei5U8N2X28Z6xBnKP90uQn BFovVN7H7S5AGS7kJrAysS4iFBdZppyxNWRPrXJpaqnPmoIikW8n5Uk6yfkP+XO67Y q6h4UU4CzNZu9Wt4zTAq0lSHyuI6ykoT6Qn+O+s8= Date: Wed, 19 Jun 2024 17:59:15 -0700 To: mm-commits@vger.kernel.org,vbabka@suse.cz,svens@linux.ibm.com,rostedt@goodmis.org,roman.gushchin@linux.dev,rientjes@google.com,penberg@kernel.org,mhiramat@kernel.org,mark.rutland@arm.com,kasan-dev@googlegroups.com,iamjoonsoo.kim@lge.com,hca@linux.ibm.com,gor@linux.ibm.com,glider@google.com,elver@google.com,dvyukov@google.com,cl@linux.com,borntraeger@linux.ibm.com,agordeev@linux.ibm.com,42.hyeyoo@gmail.com,iii@linux.ibm.com,akpm@linux-foundation.org From: Andrew Morton Subject: + s390-mm-define-kmsan-metadata-for-vmalloc-and-modules.patch added to mm-unstable branch Message-Id: <20240620005915.DA440C2BBFC@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: s390/mm: define KMSAN metadata for vmalloc and modules has been added to the -mm mm-unstable branch. Its filename is s390-mm-define-kmsan-metadata-for-vmalloc-and-modules.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/s390-mm-define-kmsan-metadata-for-vmalloc-and-modules.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Ilya Leoshkevich Subject: s390/mm: define KMSAN metadata for vmalloc and modules Date: Wed, 19 Jun 2024 17:44:05 +0200 The pages for the KMSAN metadata associated with most kernel mappings are taken from memblock by the common code. However, vmalloc and module metadata needs to be defined by the architectures. Be a little bit more careful than x86: allocate exactly MODULES_LEN for the module shadow and origins, and then take 2/3 of vmalloc for the vmalloc shadow and origins. This ensures that users passing small vmalloc= values on the command line do not cause module metadata collisions. Link: https://lkml.kernel.org/r/20240619154530.163232-31-iii@linux.ibm.com Signed-off-by: Ilya Leoshkevich Reviewed-by: Alexander Potapenko Acked-by: Alexander Gordeev Acked-by: Heiko Carstens Cc: Christian Borntraeger Cc: Christoph Lameter Cc: David Rientjes Cc: Dmitry Vyukov Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Joonsoo Kim Cc: Cc: Marco Elver Cc: Mark Rutland Cc: Masami Hiramatsu (Google) Cc: Pekka Enberg Cc: Roman Gushchin Cc: Steven Rostedt (Google) Cc: Sven Schnelle Cc: Vasily Gorbik Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- arch/s390/boot/startup.c | 7 +++++++ arch/s390/include/asm/pgtable.h | 8 ++++++++ 2 files changed, 15 insertions(+) --- a/arch/s390/boot/startup.c~s390-mm-define-kmsan-metadata-for-vmalloc-and-modules +++ a/arch/s390/boot/startup.c @@ -301,11 +301,18 @@ static unsigned long setup_kernel_memory MODULES_END = round_down(kernel_start, _SEGMENT_SIZE); MODULES_VADDR = MODULES_END - MODULES_LEN; VMALLOC_END = MODULES_VADDR; + if (IS_ENABLED(CONFIG_KMSAN)) + VMALLOC_END -= MODULES_LEN * 2; /* allow vmalloc area to occupy up to about 1/2 of the rest virtual space left */ vsize = (VMALLOC_END - FIXMAP_SIZE) / 2; vsize = round_down(vsize, _SEGMENT_SIZE); vmalloc_size = min(vmalloc_size, vsize); + if (IS_ENABLED(CONFIG_KMSAN)) { + /* take 2/3 of vmalloc area for KMSAN shadow and origins */ + vmalloc_size = round_down(vmalloc_size / 3, _SEGMENT_SIZE); + VMALLOC_END -= vmalloc_size * 2; + } VMALLOC_START = VMALLOC_END - vmalloc_size; __memcpy_real_area = round_down(VMALLOC_START - MEMCPY_REAL_SIZE, PAGE_SIZE); --- a/arch/s390/include/asm/pgtable.h~s390-mm-define-kmsan-metadata-for-vmalloc-and-modules +++ a/arch/s390/include/asm/pgtable.h @@ -107,6 +107,14 @@ static inline int is_module_addr(void *a return 1; } +#ifdef CONFIG_KMSAN +#define KMSAN_VMALLOC_SIZE (VMALLOC_END - VMALLOC_START) +#define KMSAN_VMALLOC_SHADOW_START VMALLOC_END +#define KMSAN_VMALLOC_ORIGIN_START (KMSAN_VMALLOC_SHADOW_START + KMSAN_VMALLOC_SIZE) +#define KMSAN_MODULES_SHADOW_START (KMSAN_VMALLOC_ORIGIN_START + KMSAN_VMALLOC_SIZE) +#define KMSAN_MODULES_ORIGIN_START (KMSAN_MODULES_SHADOW_START + MODULES_LEN) +#endif + #ifdef CONFIG_RANDOMIZE_BASE #define KASLR_LEN (1UL << 31) #else _ Patches currently in -mm which might be from iii@linux.ibm.com are ftrace-unpoison-ftrace_regs-in-ftrace_ops_list_func.patch kmsan-make-the-tests-compatible-with-kmsanpanic=1.patch kmsan-disable-kmsan-when-deferred_struct_page_init-is-enabled.patch kmsan-increase-the-maximum-store-size-to-4096.patch kmsan-fix-is_bad_asm_addr-on-arches-with-overlapping-address-spaces.patch kmsan-fix-kmsan_copy_to_user-on-arches-with-overlapping-address-spaces.patch kmsan-remove-a-useless-assignment-from-kmsan_vmap_pages_range_noflush.patch kmsan-remove-an-x86-specific-include-from-kmsanh.patch kmsan-expose-kmsan_get_metadata.patch kmsan-export-panic_on_kmsan.patch kmsan-allow-disabling-kmsan-checks-for-the-current-task.patch kmsan-introduce-memset_no_sanitize_memory.patch kmsan-support-slab_poison.patch kmsan-use-align_down-in-kmsan_get_metadata.patch kmsan-do-not-round-up-pg_data_t-size.patch mm-slub-let-kmsan-access-metadata.patch mm-slub-disable-kmsan-when-checking-the-padding-bytes.patch mm-kfence-disable-kmsan-when-checking-the-canary.patch lib-zlib-unpoison-dfltcc-output-buffers.patch kmsan-accept-ranges-starting-with-0-on-s390.patch s390-boot-turn-off-kmsan.patch s390-use-a-larger-stack-for-kmsan.patch s390-boot-add-the-kmsan-runtime-stub.patch s390-checksum-add-a-kmsan-check.patch s390-cpacf-unpoison-the-results-of-cpacf_trng.patch s390-cpumf-unpoison-stcctm-output-buffer.patch s390-diag-unpoison-diag224-output-buffer.patch s390-ftrace-unpoison-ftrace_regs-in-kprobe_ftrace_handler.patch s390-irqflags-do-not-instrument-arch_local_irq_-with-kmsan.patch s390-mm-define-kmsan-metadata-for-vmalloc-and-modules.patch s390-string-add-kmsan-support.patch s390-traps-unpoison-the-kernel_stack_overflows-pt_regs.patch s390-uaccess-add-kmsan-support-to-put_user-and-get_user.patch s390-uaccess-add-the-missing-linux-instrumentedh-include.patch s390-unwind-disable-kmsan-checks.patch s390-kmsan-implement-the-architecture-specific-functions.patch kmsan-enable-on-s390.patch