From patchwork Wed Nov 15 20:30:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13457288 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 7BBF8C54FB9 for ; Wed, 15 Nov 2023 20:34:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6045480031; Wed, 15 Nov 2023 15:34:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5895180022; Wed, 15 Nov 2023 15:34:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3677480031; Wed, 15 Nov 2023 15:34:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1CF5980022 for ; Wed, 15 Nov 2023 15:34:40 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F24C4160A98 for ; Wed, 15 Nov 2023 20:34:39 +0000 (UTC) X-FDA: 81461341878.28.48B004D Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf04.hostedemail.com (Postfix) with ESMTP id B0A5C40009 for ; Wed, 15 Nov 2023 20:34:37 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=sw+mhheF; spf=pass (imf04.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=1700080477; 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=fibwjw/KiW5HEuIH+IZjTN+t/6WZNSSD23GOexOJS9o=; b=TfBj3B/bnQXUnjVjA5mt7VXF5BSfMyRXGk1iR8mdu2bl1bVfCnE35II+Xcvm9I04l/lIan IzZkyZDI4se4B7QLS18eIeEcKFLfhv/udprDJkDKnQUdt6IVzCH2lcO0oQ41dO9mMlBt3+ DlkzHRdWtSEvn77wshNLZ6QxO74+jgw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=sw+mhheF; spf=pass (imf04.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=1700080477; a=rsa-sha256; cv=none; b=j0n+kZmKag3QQIiMGFpjQwlp+dv+XyAUNIgGflm20IpVigLNpR5XeZikHdXBrQiMbXwLKs vUYtMAFMIHrVFxbQ6BcQpgwFGNAQKI3DvAl2skAbptzazFd1HSP3h7Ds0niBPy2z6b0mTN yVSXtPB6KQClEnVefveSboJkoSGs534= Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFKTffZ023085; Wed, 15 Nov 2023 20:34:31 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=fibwjw/KiW5HEuIH+IZjTN+t/6WZNSSD23GOexOJS9o=; b=sw+mhheFpO546ZVxaJSKrJFRg8AXd4+11Wrj30ovKNZZ9E/Mu7g1CnCfgyHGLs+NYYle XorFNdTZ9SUMCEU8VpsYR1ey0KKHTaDYTG4SN1VBDulH0VKMS3vWqkIIlXo5HgQIBoc8 fOXPZpoe1cy+u+AQSnTgzPXfI9ye9fMcx6rt9RzoVUVVsZ9DfuWabDLTwgs/sBvLXBgh B7/z5ftBKwCTf5kRaAIE/2ZnsRDiiZq20CGcQ4O74RN7x8BzKeesw2LMMuDjMMi5MgAd EcK84wvyaIgl23J/9XJuWY0dVIJwhPZ3HoJrya9pFVQSs4W+JHp19O8QHD2Wl6Sb98w7 Ug== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ud52r847x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:30 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AFKU8lq025130; Wed, 15 Nov 2023 20:34:30 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 3ud52r847e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:30 +0000 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 3AFKIvA5015481; Wed, 15 Nov 2023 20:34:29 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uamxnj0jn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:28 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AFKYPUT20906506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Nov 2023 20:34:25 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B405D20043; Wed, 15 Nov 2023 20:34:25 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6847620040; Wed, 15 Nov 2023 20:34:24 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.179.9.51]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Nov 2023 20:34:24 +0000 (GMT) From: Ilya Leoshkevich To: Alexander Gordeev , Alexander Potapenko , Andrew Morton , Christoph Lameter , David Rientjes , 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 10/32] kmsan: Expose kmsan_get_metadata() Date: Wed, 15 Nov 2023 21:30:42 +0100 Message-ID: <20231115203401.2495875-11-iii@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231115203401.2495875-1-iii@linux.ibm.com> References: <20231115203401.2495875-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: F7flrmLyXJJJAcGqET6C8qzUnTyLkokl X-Proofpoint-ORIG-GUID: g1up5JlfCWsuRUJ_ZeEJ6SY9HrOevKDS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-15_20,2023-11-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=864 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150163 X-Rspamd-Queue-Id: B0A5C40009 X-Rspam-User: X-Stat-Signature: 7jpxczxm7apk8hz7uwuq8u7jiauxbn1x X-Rspamd-Server: rspam01 X-HE-Tag: 1700080477-289350 X-HE-Meta: U2FsdGVkX184wM9JxIrzma8GT4fOp3lH0/9jUVV6jugO5bdvAF8VcgWv7JHI2T/o0G5qQSvwNlCoEaA5McL8QEYyHb5PKsO/oQQerbLrkQH8BgqjYMTR4in9+GUzUSOxM4nSJQ/0yjAEZWsCEc8azB2tWe7AlZL7PK0CMSlJjuh4iMlTuDOaLrF6GOr3ayyfNlT6SCsGFvk/E1KMsQiCEPRiaAVVsmKI+CkKcwQcvimI201a88OvmXr5gy5ZVAa+BaQlIrr5dAICgsb9xkbRjpoYa3s4dXeWMxNPoI9LABgYa68d4UXV4ZQdMMELNKR85VVO0YWcOpce5XCQL76KSY8pXGgu0kzCpJMcWFSEuUHHaWmLEqUrkbfyM01Madr02ropEsa6V6h1S4NcqHd39LdpX8fHTHqlVl4P3qvvXapbwViTFjcqol1cvAGjQFmnWi0NCTUfXjJtbzjSy/i6Q2mYtAEQaLQ9GzE8/s8FelZ20YMST+zi8dru65YI5TIkyOuV83cmej3pIttPn8kQx2zSD7e7GOzGDm8ytdVhTvSxlTFvk8jrmUX5A/jS56ouHRfWZvvNO3NscPnx+UMbIXee+S1GNh2nLNqgNnNWDFkPrU+EavWb4gzEq191m18kiMLXQ9yTvdjbl7BNqauVo9I25SLD8pn+nHTfteUOeNFZL4iCGal+etF/uneziKEiirEoUp88HOv3jrbGqJBQWux4ZzLhGYf651SLh6l1SYjnDfV7Af+zqs/3BY4ZoO9OH/JS5PrlQQc5ZTDMCwhnjZzmWMKMMouDDS8HwWGzB0/W6VPd5H5zRrlD9IyDLaEBzO725OieE676/Cc0LebG3BbB4eR9QQbmLOfWZzx1fC37KOfGY7xi1/hXUSxeNETWyctfQ160KhztWHAYIJlUMQsQUTJCnf3Znh9NENKkPy2jQJ+22OhesRdfw5xiRV83ZSO/e26zSdZd81UdLTT ZWiPJdSG sMQdgOlj0Zmn/UoavCZiUIoszpOytv7P2zEcY2gVj+XlUJdDSox0t6gUuCDHBMWOjYjccgA4zqRV2R42FeHEpXtF/Ulk2ykqzMTf0B9CZlLqKWxoGDRvB5wawclZljpOIvf1bgwQN1VDg0g0GlULM//1osLuOdE0D7x4LJurH1KCyczL91RH/iSVht/L2RFHdURZyPtylLLl1bRI0CuL1xvEmwFaSlyhHeYa8cm6gYnFcJ6DYubQdKvSXEdmTMX2ZPL0tkzAnhwy70hQCRwXMAEBIv0Uz7xZqtEnEdFm26LLkm8w= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Each s390 CPU has lowcore pages associated with it. Each CPU sees its own lowcore at virtual address 0 through a hardware mechanism called prefixing. Additionally, all lowcores are mapped to non-0 virtual addresses stored in the lowcore_ptr[] array. When lowcore is accessed through virtual address 0, one needs to resolve metadata for lowcore_ptr[raw_smp_processor_id()]. Expose kmsan_get_metadata() to make it possible to do this from the arch code. Signed-off-by: Ilya Leoshkevich --- include/linux/kmsan.h | 14 ++++++++++++++ mm/kmsan/instrumentation.c | 1 + mm/kmsan/kmsan.h | 1 - 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/kmsan.h b/include/linux/kmsan.h index e0c23a32cdf0..ff8fd95733fa 100644 --- a/include/linux/kmsan.h +++ b/include/linux/kmsan.h @@ -230,6 +230,15 @@ void kmsan_handle_urb(const struct urb *urb, bool is_out); */ void kmsan_unpoison_entry_regs(const struct pt_regs *regs); +/** + * kmsan_get_metadata() - Return a pointer to KMSAN shadow or origins. + * @addr: kernel address. + * @is_origin: whether to return origins or shadow. + * + * Return NULL if metadata cannot be found. + */ +void *kmsan_get_metadata(void *addr, bool is_origin); + #else static inline void kmsan_init_shadow(void) @@ -329,6 +338,11 @@ static inline void kmsan_unpoison_entry_regs(const struct pt_regs *regs) { } +static inline void *kmsan_get_metadata(void *addr, bool is_origin) +{ + return NULL; +} + #endif #endif /* _LINUX_KMSAN_H */ diff --git a/mm/kmsan/instrumentation.c b/mm/kmsan/instrumentation.c index 8a1bbbc723ab..94b49fac9d8b 100644 --- a/mm/kmsan/instrumentation.c +++ b/mm/kmsan/instrumentation.c @@ -14,6 +14,7 @@ #include "kmsan.h" #include +#include #include #include #include diff --git a/mm/kmsan/kmsan.h b/mm/kmsan/kmsan.h index 3c0476d8b765..2c743911a8c4 100644 --- a/mm/kmsan/kmsan.h +++ b/mm/kmsan/kmsan.h @@ -66,7 +66,6 @@ struct shadow_origin_ptr { struct shadow_origin_ptr kmsan_get_shadow_origin_ptr(void *addr, u64 size, bool store); -void *kmsan_get_metadata(void *addr, bool is_origin); void __init kmsan_init_alloc_meta_for_range(void *start, void *end); enum kmsan_bug_reason {