From patchwork Wed Jun 19 15:43:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13704136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06D20C27C53 for ; Wed, 19 Jun 2024 15:46:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1FC46B02E6; Wed, 19 Jun 2024 11:46:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C13666B02E5; Wed, 19 Jun 2024 11:46:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 979DA6B02F6; Wed, 19 Jun 2024 11:46:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5CD946B02E5 for ; Wed, 19 Jun 2024 11:46:00 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 09C0F811B8 for ; Wed, 19 Jun 2024 15:46:00 +0000 (UTC) X-FDA: 82248064080.21.1846E58 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf10.hostedemail.com (Postfix) with ESMTP id AAB64C0015 for ; Wed, 19 Jun 2024 15:45:57 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=I+jieaxF; spf=pass (imf10.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718811953; a=rsa-sha256; cv=none; b=gwG2Oia4pKUGEPEKtKEfwU3aNg0BGsjefgfVxEfFCsx4dPII5xuwUyV7stwNTIZUu8JTf2 5f1cWYfvPSoBG9ZipQMZB6Tknn839EuGlxZSBJ63bLW5cpUm/8CecKrxnG9ga18wwqdIm4 MkkJC5UB9Yzx8RqrS96XM/FAHpPJh7k= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=I+jieaxF; spf=pass (imf10.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718811953; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=erZvlatfvJVe/hx7BkMgZ/7G1oP598/R1HnuL1JF6tI=; b=CWowCwd6EA0mj6pSw9yi3Z1ieXPOPvXTSfSdjxKGzzVlycVzyGlpNU2igPG+QfIBXPafSu 4AbdL9Q/BTUuob24TadtWpb8TuM9T9zDLCukPGg6OpOdCC1GYb01V7w9ckhh2ZbKClFNNS Tgp/qaB67m6as3M8VMWizdv9JSgvZzc= Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45JEwlSk023623; Wed, 19 Jun 2024 15:45:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=erZvlatfvJVe/ hx7BkMgZ/7G1oP598/R1HnuL1JF6tI=; b=I+jieaxFMkgTgdJTGVhtQWzdBbFhq +MgV8bbwb0GO4cjPU056kN4UmjNmVP/xJY69+CziW+rp+eqPPsnZQKFznBqn6fHT b7507V/YE7jBn2THVd7psuTiWVd8z3TkgypCwDORDrt2L6rQjCTHj1IwMQhRo6Q2 5xtl/ZTW1serM1pZvyfmvZrGVxLX1K9jmaQ9BM/IifDrbeRQODoPEjG3lXytfajA fpq718ZOrUuBjCZ948gWPyViszLJQylNh4bNEOZm/rN/1TL69AXqkwb1Hen2/WPX 8CWcBvybPEZ7QEmXoLNTKbRciiGQ5f0yArxLg5taa0USHwBFedmXUqI0A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yv1jfr5bw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45:49 +0000 (GMT) Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45JFjnLw005799; Wed, 19 Jun 2024 15:45:49 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yv1jfr5bq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45:49 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45JE5i63023914; Wed, 19 Jun 2024 15:45:47 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ysp9qdyqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45:47 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45JFjfWA45154602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jun 2024 15:45:44 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7DC52004E; Wed, 19 Jun 2024 15:45:41 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 88D4E20065; Wed, 19 Jun 2024 15:45:41 +0000 (GMT) Received: from black.boeblingen.de.ibm.com (unknown [9.155.200.166]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 19 Jun 2024 15:45:41 +0000 (GMT) From: Ilya Leoshkevich To: Alexander Gordeev , Alexander Potapenko , Andrew Morton , Christoph Lameter , David Rientjes , Heiko Carstens , Joonsoo Kim , Marco Elver , Masami Hiramatsu , Pekka Enberg , Steven Rostedt , Vasily Gorbik , Vlastimil Babka Cc: Christian Borntraeger , Dmitry Vyukov , Hyeonggon Yoo <42.hyeyoo@gmail.com>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Mark Rutland , Roman Gushchin , Sven Schnelle , Ilya Leoshkevich Subject: [PATCH v5 23/37] s390/boot: Add the KMSAN runtime stub Date: Wed, 19 Jun 2024 17:43:58 +0200 Message-ID: <20240619154530.163232-24-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240619154530.163232-1-iii@linux.ibm.com> References: <20240619154530.163232-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: YgmfPE7dzJnFHVsUSCo78DlzIaRJ2Pom X-Proofpoint-ORIG-GUID: PRP7Ai0315YPaTCuzE1hfbsrj0IEqX63 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-19_02,2024-06-19_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 bulkscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406190115 X-Stat-Signature: rk6j161yz6t6jhf1fmite4zoacyxkty7 X-Rspamd-Queue-Id: AAB64C0015 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718811957-269849 X-HE-Meta: U2FsdGVkX1+uspm7YBheTBD2l12NSp5G1Uyz6ZpNcH55mN2CsH02fC4NE4Rs/hape2FVzVj0YUNKNXj1BO6x1+HUQarGXkOTb8AVChg5zdjhfsJ54BiTBSBOM2IbdcfnjHNijJByQGcA8MYEU0I1+Ax/Ht6Ur1Q3Aw5jCcdJkgZTlYk1IhOnjWfTzw6joNu8MI7TcXLq1BsDHCxsqW7xusUJWohfwLtCqD9Q3KeTclPf0CeODgtxCr8N12Qdwz9EV/oa2Z1II/yRSbhnYmxh5RVWyUORll58WkZcjovswOSz3GMb2rBHQARXxDCHTjvFUv5LFT2QIddczVJWH1UAT5hICcUlQgDd+0PHxYBdqYg7qTAn6pI4zMtBAdnUkOPPCQbbep8TLin1lIyyN6gg/l4AJrruMpf4J4OugyzcRD/gQeQANUqgNrpa82TC19Qf93VWYNX+3clK6rdkjXTlMiYKG4yMxs4NxDLrivDz8pgCSnlzkYzimDUuPS8KHhlwTgOQNC5zgVh43blhJYmMDugR6MfeygOi4/s32vfTtT38Ig5qN6O1Qi2gG4qeGVKXct8FEO2S6V1uu9mH9XxoWw4O3SAh1/OT76Bi0x/CCiv5djZ09w0Dn6r0Z0VtS/7x2gzg7w2sR7B+iKc//NNFs0tdUz24L+/cMuuzH4tEBDyxCeM5VOJvECH3N3bJZWgbJj3EivWMzaip+hRMjeZh9xzfkjJHtZt+g/FZZgjhjWVFz2mKVwnhBgn9axrnLEcwm4/jBVcsdD3cLgF+9HBBcYXUuYQhN5ldQ7J3k3MTiJOgtWIimIAqrLEAKNIn4+KoY2vRzPuAE2cULgL/OXIY18afcDUcyHOqlFymWaOaB2/vpZCrIOPL8X4BYFFPI1jqu3WNIcNeymWh6w/OxrJ17d9D2TdYUjEpgziUa1DEY5Q0GNKL6oHhjhpVoObFXcHsrSs+b5MFA4LC7Cid78X YU2076GY 0Ahmf9QRY0aIWzQs9qU1+tZ7Uk7DfzrcKtbCjMGVfk75lO2RwTuiPhn8rpDT6rMVTyHCbJopEGsgRml1CkNxaUbAFhZnhu1EtWdIzozFqHHuFRpa1FbuEnYvL7C8KK/xG2yxXLVC4i7rZLrHJk89yjkUZMUMRi1lXv1XupPqz9Xn1d7WuzJvrxwviwLQJPhU9Ij95Klys3GUjYX1CfFjZkTZYgefpEr93RmnJNgxQcvV6F9jxgi4nCq47pg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: It should be possible to have inline functions in the s390 header files, which call kmsan_unpoison_memory(). The problem is that these header files might be included by the decompressor, which does not contain KMSAN runtime, causing linker errors. Not compiling these calls if __SANITIZE_MEMORY__ is not defined - either by changing kmsan-checks.h or at the call sites - may cause unintended side effects, since calling these functions from an uninstrumented code that is linked into the kernel is valid use case. One might want to explicitly distinguish between the kernel and the decompressor. Checking for a decompressor-specific #define is quite heavy-handed, and will have to be done at all call sites. A more generic approach is to provide a dummy kmsan_unpoison_memory() definition. This produces some runtime overhead, but only when building with CONFIG_KMSAN. The benefit is that it does not disturb the existing KMSAN build logic and call sites don't need to be changed. Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- arch/s390/boot/Makefile | 1 + arch/s390/boot/kmsan.c | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 arch/s390/boot/kmsan.c diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile index 526ed20b9d31..e7658997452b 100644 --- a/arch/s390/boot/Makefile +++ b/arch/s390/boot/Makefile @@ -44,6 +44,7 @@ obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o +obj-$(CONFIG_KMSAN) += kmsan.o obj-all := $(obj-y) piggy.o syms.o targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y) diff --git a/arch/s390/boot/kmsan.c b/arch/s390/boot/kmsan.c new file mode 100644 index 000000000000..e7b3ac48143e --- /dev/null +++ b/arch/s390/boot/kmsan.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +void kmsan_unpoison_memory(const void *address, size_t size) +{ +}