From patchwork Fri Jun 21 11:34:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13707329 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 48A31C27C4F for ; Fri, 21 Jun 2024 11:37:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A9E46B0127; Fri, 21 Jun 2024 07:37:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F10308D0155; Fri, 21 Jun 2024 07:37:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4CA96B011F; Fri, 21 Jun 2024 07:37:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2A7FE6B0115 for ; Fri, 21 Jun 2024 07:37:31 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BE9C940D04 for ; Fri, 21 Jun 2024 11:37:30 +0000 (UTC) X-FDA: 82254695460.22.F32B100 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf30.hostedemail.com (Postfix) with ESMTP id 8958080002 for ; Fri, 21 Jun 2024 11:37:28 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=NwRG9w7a; spf=pass (imf30.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=1718969838; 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=9fryXD6fg7ZWH/K5Ic2hWhXvK+X7HFTa6K6lMBwUrkw=; b=xxlplX2nP0GOnaEjtJAF5WxmcJnZOBynAAD2Dyb4YxvOCCWV6rNyptav7bz51EoRr9Ki1H ESOry5ZVSezhkK1TrOFH3dqak/A4okAebnNzZaeI/o8g0yRxlnUSi3AX+8mw5xCqUjeAz5 NUMaVpx4fV5i5lZbk3NbGuyAtnn1Qug= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718969838; a=rsa-sha256; cv=none; b=A97N26QtywxZc+tKH+rp4ATQHZ9xJIamtnuGpqscZmEyGxnoDHctuycMeZLjylBDTJGRFp 7ujYtVbCqNH5IEP0fXDKYfaVVjMJCQJdYvuvtKZWRjeLWqC1yAIIbgvo8V+3TIi74CBxQD K1dpPgP+f20gHMiy1mCkkRx7OWoZ3KA= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=NwRG9w7a; spf=pass (imf30.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 Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45LATGSV018103; Fri, 21 Jun 2024 11:37:22 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=9fryXD6fg7ZWH /K5Ic2hWhXvK+X7HFTa6K6lMBwUrkw=; b=NwRG9w7aTDvCiDT1NR1MHIAJ2Wfko aTv2JwPOkeFIYtaDQfOQsmy8qMM8+vf83Zlve0tAG6GV7JLTUHSFD3d0SECrDV3z EZQvyzSp9+WL6v/AbnJX1v8t1fV8m482DVRnGx3nM30AKL0Pmn/gkkU25dGU3Ngf NBnOmUuk8zC1oIJA9h6ANNI2zLKe0ONkLM3rNvc1FW71aSldcS8RXOu8vzqlzWP5 lXuhS8CDBMnjyUq1/ixJ91xRrcpcBcwLuCwzTimBeTMehs4/GDj4aQrIQWGIVYef SrO2drN51NwtisNtPoXHsOYha4x88C5h/IGob2WA+JiybVHtTkJUSpLqQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yw7t5045t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:22 +0000 (GMT) Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45LBbLLw017458; Fri, 21 Jun 2024 11:37:21 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yw7t5045q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:21 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45L99jFH031338; Fri, 21 Jun 2024 11:37:20 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yvrrq6vfk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:20 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45LBbEHR56754514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 11:37:16 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D48E2004B; Fri, 21 Jun 2024 11:37:14 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0868B20067; Fri, 21 Jun 2024 11:37:14 +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:13 +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 09/38] kmsan: Expose kmsan_get_metadata() Date: Fri, 21 Jun 2024 13:34:53 +0200 Message-ID: <20240621113706.315500-10-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: 2d2yzejn_5N3eie6A5aHac-WohbQjPgg X-Proofpoint-GUID: LxBKq5auC44MABsbauNQFbMiBqpPPcNl 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 lowpriorityscore=0 malwarescore=0 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 mlxlogscore=884 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210084 X-Stat-Signature: 8fasu1zw7jkg97r6n1oft3174bn91g75 X-Rspamd-Queue-Id: 8958080002 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1718969848-139416 X-HE-Meta: U2FsdGVkX1/xjxU3+tbzs8rjwFjUQ/t781M4zwk1zsGxOimoOCs/dm7P3dLFpw3gEg22o4os5bAmz4/fEpHFCPQej6RcmOP3Tj2H5g0FoRoE8kVIdgpKTjRq295kZcA1MCeZpzgGAfxIa1gUk0fpR8QgjRZMNGO4F0zZtql+XeA7ZBP2mpJOFiYATsUDaI9svnVdlB5zaVP62a3MFzNP04Z5SxZpv83c9piugpLw70cKIaOnqZZMxDBAOywcR2tVbHpS6TY/3V3wmHvTiboyurOhaQqFNWDSIB/fNDvRUtX/opswPuoFUdSARKHl3/v/Q8csWPvZHq1kloCyORXEloiw/oap8jAZwgZ2lqWP39jKNT2+2DTGTGI9xC6yqndvweKCX/Sj6mWfjlKVttBgxcJp3MZpuISy9OwAB3l3hYWQ0Q9Z5LHbHp/+CZhn+MWc9mRwneajSOEY2ZTD22gJwJaqFuAY6AkbXPxdfB6VgTTvRL65ZeZt2vJxDESdhi4D4n+IDY27QeCikudw+W3rRLwOH8olb9m4ldbaGSZjkNt6PsMlY/UNVAZHf+5QLhpd7yWozpnRRL+6K3X6oYT0aEpxOKYhzWCXZM8fxmVa0V5JhG/TYSFx96C3Yy/yKb/2HEBMnQBWYskXA+slymxKdafCSdOz8n62azhthX/qGRVATwPf5NybFllHl5Vm35Z6vvu+DHlvYRG6lej/5KFAiZMZS9EILjiYXzjbtjcXM3bufTOdcXUoWupd8O+ppQNxvox57OnsSFmjRpoe5birtmPOwDTKa5iSZxfR3JjvHOwp7Cy6i9EPEa4x9BgbhPBNrjI209C/mbaBKRkLYmIUpCnzEX2EV+PGmYy8c2myEMXbNmY3qEKwSKRsKU1J2YD2m4/5OxoOrY8Naq5taNqxgvmAmoEKohYG12LmjDNH3TGvutoW3CXdHmJx9lybFlFt2Q3hquvfLEvRo+iucKJ L4hct6Na mZsPb4Vs/p5PQPmCF8KaZq+RcHeEiWItNFBnGNQIowCDSCrrOLQJ1hjm1BZ3XPBOdYNIZ/C4E7pd3D8vThx5V48UY6Iryoz2TsZtEjVefbeRX8oiia568XkOQTad+o93YjkZ/rVs+hVzs0z53ltETuSzGt3teG2nhDz5M3CruuxZT6vv3w0Z2ecCoMezJfvktrRded93rPQR9u6H5EQZFNpzHoqm6pCyvpmxk/WYtvTLle+g7wraNIqE4EADXuQS3D0uHLWXb3YE+7+6AVl7iCXPlEJHkpGKlZff1TgQAq+Fzc64x9a7tknug+vocNNHP6lXE 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. Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- include/linux/kmsan.h | 9 +++++++++ mm/kmsan/instrumentation.c | 1 + mm/kmsan/kmsan.h | 1 - 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/kmsan.h b/include/linux/kmsan.h index e0c23a32cdf0..fe6c2212bdb1 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) 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 adf443bcffe8..34b83c301d57 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 {