From patchwork Fri Jun 21 11:35:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13707333 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 9785CC27C4F for ; Fri, 21 Jun 2024 11:37:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E25428D0159; Fri, 21 Jun 2024 07:37:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAA4C8D00DB; Fri, 21 Jun 2024 07:37:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD48B8D0159; Fri, 21 Jun 2024 07:37:36 -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 933F78D00DB for ; Fri, 21 Jun 2024 07:37:36 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4DDBD1C1F4C for ; Fri, 21 Jun 2024 11:37:36 +0000 (UTC) X-FDA: 82254695712.09.6DB6EBD Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf29.hostedemail.com (Postfix) with ESMTP id 24E08120017 for ; Fri, 21 Jun 2024 11:37:33 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=fbsMil0j; spf=pass (imf29.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.158.5 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=1718969846; 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=Lus2RQSPSM7ilXLn7l1YCQD25SLYNKHC3cJu5hwIwnE=; b=2RfVeeX4pPDN/9WQAhDyp7uHV3xU7PQWXqJ8ZsrurxlHMcNdb26j7oypoAm4vQ1bewvBm1 OC2TH/02tWtHZiwN3+o8hCMspB5BpBVJR847+BKxXeBiJd7KE/XhF987RUq+gZRnoX8BRn rm2LVz7afnW5cjhZ1VcQH6QpN0SFgY8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=fbsMil0j; spf=pass (imf29.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.158.5 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=1718969846; a=rsa-sha256; cv=none; b=DGFwo1gIYjJK2gHPjsqZZyUHs7QR04fhGbOrwNW+VJQ+pD+CZ4pRwu39nrWRVi02FN+fEu HKjV/qjl8E8l5p9TjAhqKqzjPfRG3iyMNJn3uKV7IlsdB9uOdHfWfBHSOOS0SYdPjqZesu TpZ2tmMabxS0uU9XWj4x7RNxlTFyVaA= Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45L8gL1Y029535; Fri, 21 Jun 2024 11:37:26 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=Lus2RQSPSM7il XLn7l1YCQD25SLYNKHC3cJu5hwIwnE=; b=fbsMil0jBMI/y/i9//oigbamPhNLm xTAC38h662OGad4kCC2Jfc7YJfjRNfK6RnhCYK9pbA3MYqqqPtLCiH6br4lE6g+U hiki9rSBfKW5/tuI3QlEk49cuPL9kZJ0/T/r4AojkUaLtHTxoYe5w8X1vnqI9yH7 Mw30mz7ggQjMOH9kUvam+I+R6SjCuCANtFMGWwujGWMY2OzkcbmZCwrhjQlxyHAd RcvG+eNyHvi7HVc606Ajr8g1z4WQ0ixQdmlYEaf0LMK66zKYrKpIQzw1y2tD4aW4 AxSAFpnG7q7Z3SYxWrlpOwIVzmyfiyjoKNvvDbIxE0OmN5Xji9WxA1+oQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yw5ksrgus-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:26 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45LBbPNI011172; Fri, 21 Jun 2024 11:37:25 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 3yw5ksrgun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:25 +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 45L9ITHD019974; Fri, 21 Jun 2024 11:37:24 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yvrqupvyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:24 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45LBbJ4g48693522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 11:37:21 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC6292004F; Fri, 21 Jun 2024 11:37:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63F6A2004E; Fri, 21 Jun 2024 11:37:18 +0000 (GMT) Received: from black.boeblingen.de.ibm.com (unknown [9.155.200.166]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jun 2024 11:37:18 +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 v7 16/38] kmsan: Expose KMSAN_WARN_ON() Date: Fri, 21 Jun 2024 13:35:00 +0200 Message-ID: <20240621113706.315500-17-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621113706.315500-1-iii@linux.ibm.com> References: <20240621113706.315500-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: KG3-KuwzimdCy9fz-zfFvPuK-LKymJ_g X-Proofpoint-GUID: 72jJRBL-nnrHizPPhKPV3cqq5Hp9wCZ2 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-21_04,2024-06-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 clxscore=1015 mlxscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210084 X-Stat-Signature: xg9dzgasigq6rrr9h5w45ksr3rddgptj X-Rspam-User: X-Rspamd-Queue-Id: 24E08120017 X-Rspamd-Server: rspam02 X-HE-Tag: 1718969853-9054 X-HE-Meta: U2FsdGVkX1/4hK7gBuHNj9Mr0WmTaOA7/JyaFLQEhFFGKjJ1rMjY2e6b2R2zqke7gbxOI2IliX4FGRYlXWxGWe2eLfTuKSyKemKZK+V0LJLyZyIgAz/SZSwUmbvUVJ8jVcSmoh6hF6STQUtJe+zgatHZicKYHKm/8qWwbK/Zojg7hvEq+DgjGiSeu/nOSO3XnFVDd8JisUZ8Lgxw+OftJKn9GpasUBX2mrlj0A6saV6+3srNal06/rTh+Pi7bxEQ/iMu/oaeopGXWeyctJXFlL2q91xmjsHB92R6y48ChxiOQl3irtNrHGngjpQXuv4uWcU8G3RLNdUOhTxmisfcolmWbps3zuvgII5mR2WnxgFL7c3VgAc6kza362FHs5hXkRapY1/Hc/UOka9ytCQS4naUvZrnKRHWTFCeSFLJX6cuyAXcUzmpOhJJ+J5vfvs6bBVM312tum8OfohmM+EIvhne3j91rrq2UWT+Q7HdemRA89NliXvx3VewBNCv9AgKfWSrwV3j25lSh1BLtLWhLX14U6qCq8JlONSs+r4WTv0s/tAfP1xbKYFDtqaUWW6gSM3XlIMoPh74jKMB/oSoSAjvqhDxl30cNy3Y2IOw+MloxfG3iaGdj2SCt39CBCaNPhx11Dbr7xxXBHZucM5wzdJx8yofWJZKx0XgrC1ZVmu+cIm6HUrJaUn6TusIxbOpmxZdPu0wNMxNhMccMev5QP6w9L/hEr4JYW8gpePckpx2F6HoX7diq41d73uRhhYK1W9QqivcGMT1Xu37C2rVtU3WQHUfEQhgBRLGGOv708gep1fvJ4kbiBlsUCQNPdhOlVQu6UcZHZtGKUo3OQOt5thiIoUHjsNnhP5mQ4uIskNCtLI7L3uNQe1rEH/Lf9Q0dIcRHtClFxixWQdfIfd7MaU8wA6A4j7alBLjTkYkobQ4Cuxf/RkiyvYXPJmASoIL722AVvGyOKYkrg/Hlr2 eGB6Jsw4 BGrQAd3Gjh7DclqwkdAAJaaNlx1zZEO2vgwhSSa8f+Cqo7t+BHCT2ZKxxBfl6OJS7unHUIDvumlFuCJeqhab6O4AcKDSQ/745tnL1YXr0ioaaUxv7YITJGuPqBqAAKbhzMvMbao+p+sx3Lu3X067piyMf8JzWrhTpP+Mn5MjkLhOUOdf/txiieJdGzAdHEFbmm0q3v9017AHeu1imboZGx4nyd26EDssHXBdHFUmROQY0SCbQ9gQIKph6kky7U72g0af5Y5FSXywbjpEoiI62tfJqZKq61Jt4mwqE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: KMSAN_WARN_ON() is required for implementing s390-specific KMSAN functions, but right now it's available only to the KMSAN internal functions. Expose it to subsystems through . Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- include/linux/kmsan.h | 25 +++++++++++++++++++++++++ mm/kmsan/kmsan.h | 24 +----------------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/linux/kmsan.h b/include/linux/kmsan.h index 7109644f4c19..2b1432cc16d5 100644 --- a/include/linux/kmsan.h +++ b/include/linux/kmsan.h @@ -268,6 +268,29 @@ static inline void *memset_no_sanitize_memory(void *s, int c, size_t n) return __memset(s, c, n); } +extern bool kmsan_enabled; +extern int panic_on_kmsan; + +/* + * KMSAN performs a lot of consistency checks that are currently enabled by + * default. BUG_ON is normally discouraged in the kernel, unless used for + * debugging, but KMSAN itself is a debugging tool, so it makes little sense to + * recover if something goes wrong. + */ +#define KMSAN_WARN_ON(cond) \ + ({ \ + const bool __cond = WARN_ON(cond); \ + if (unlikely(__cond)) { \ + WRITE_ONCE(kmsan_enabled, false); \ + if (panic_on_kmsan) { \ + /* Can't call panic() here because */ \ + /* of uaccess checks. */ \ + BUG(); \ + } \ + } \ + __cond; \ + }) + #else static inline void kmsan_init_shadow(void) @@ -380,6 +403,8 @@ static inline void *memset_no_sanitize_memory(void *s, int c, size_t n) return memset(s, c, n); } +#define KMSAN_WARN_ON WARN_ON + #endif #endif /* _LINUX_KMSAN_H */ diff --git a/mm/kmsan/kmsan.h b/mm/kmsan/kmsan.h index 34b83c301d57..91a360a31e85 100644 --- a/mm/kmsan/kmsan.h +++ b/mm/kmsan/kmsan.h @@ -11,6 +11,7 @@ #define __MM_KMSAN_KMSAN_H #include +#include #include #include #include @@ -34,29 +35,6 @@ #define KMSAN_META_SHADOW (false) #define KMSAN_META_ORIGIN (true) -extern bool kmsan_enabled; -extern int panic_on_kmsan; - -/* - * KMSAN performs a lot of consistency checks that are currently enabled by - * default. BUG_ON is normally discouraged in the kernel, unless used for - * debugging, but KMSAN itself is a debugging tool, so it makes little sense to - * recover if something goes wrong. - */ -#define KMSAN_WARN_ON(cond) \ - ({ \ - const bool __cond = WARN_ON(cond); \ - if (unlikely(__cond)) { \ - WRITE_ONCE(kmsan_enabled, false); \ - if (panic_on_kmsan) { \ - /* Can't call panic() here because */ \ - /* of uaccess checks. */ \ - BUG(); \ - } \ - } \ - __cond; \ - }) - /* * A pair of metadata pointers to be returned by the instrumentation functions. */