Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp237156lqs; Thu, 13 Jun 2024 08:44:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXr8P5Zoz//6S2EujN2aU1N7p7JNPLq19TiEr7PY3NrH3pNq0Yp9y3fJ+ziF4UDPu7FTbkKl0CHWOSdXRhiJr6Yi2w1/o0kJVE9+J3xg== X-Google-Smtp-Source: AGHT+IF5jfkSySTrWDO0vzr1/K74I49Oza7hEMB2TfqZskvg6YrJk7X8cj7Iz5q+P54ljLjTVL+m X-Received: by 2002:a05:6214:3212:b0:6b0:8a90:bda3 with SMTP id 6a1803df08f44-6b1b5c0af85mr56687616d6.59.1718293485128; Thu, 13 Jun 2024 08:44:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718293485; cv=pass; d=google.com; s=arc-20160816; b=fnG+5vxiD/Z0+ciWYnmHgTPDALxYv5r3lf+hfnrNgaoeBrkP5M4gnOhkX/muMhFl62 XvpGGE6QAIXqfEUA/Tgc8vg7Z8QHf0phbzLWVq5/v+4J/+/G0q15x0TkUtRqriBG36tQ /gJO6Y4fiJHoPlsF9D6mYNIKaJeAQr/1yoSGtKjlnMn9p9SAevQ2rfm/Hs2+5Ymeyaeg E5vl0F8vTkR3xf9O6nnzmOIsrizYamOf3NSmGHQzdxBrbeKaEeUwXmhpPb7vqeDU9x4P r3vXNZTlxD/4NQBQ+buctHxGRwpyVc8MtBMO1/jQi7eai8VE4ZDa+L6Kd+kxYLcM/X8T yMWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7LzF+mdGOSfbikK0rRRb7FcZ7CcG1T7oFIQ1dXnxY58=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=d0CDyW2s3tIArOL8xvZIsUs3FFGAXNKa1MMvCB9dq/T6esTCdVVoGQFOZqlKAfN8Gh SOAmNiryVKJXkgC44BWcH6BIaynNapSeGVITzs7iyvlhP5keE/GUzfP8vfqH7beXpGSy 80jTA98wlMaEVHLyBUFFkqwWUTJE+WXcRJEHilbVeHwmWK2BqruS4ubJ1Tdhq46a9ECx KZAxyHpzhHXcU/Z0+O0CQ05DPsuP/E8vvJPnY6SEzz5M+YCf0jhZZs3ChALCtvscD4Ma C8zwcH2RYarSmN/b9PCfVtv0ayLTHLTfdraum1DsK44czXD4bUHpC//nknTV7j8dRndb cHrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=kpM3vAT4; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-213583-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b2a5a16e68si17527936d6.22.2024.06.13.08.44.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 08:44:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213583-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=kpM3vAT4; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-213583-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C755A1C20F1D for ; Thu, 13 Jun 2024 15:44:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0ABD157E6F; Thu, 13 Jun 2024 15:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="kpM3vAT4" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 8C82914B942; Thu, 13 Jun 2024 15:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718293218; cv=none; b=aw+fH88V/PjNpqkoEXBLNGWLX5AwsokvObsEVom6TP6Fs0kQnmKD8Ad5bUM4+gHtRR6//mnI8kGJQ6Q2ikgSBzqool4PnVOjy0pqNe7W8P9ZOmFn+R//ut0DeRS81R6IzzYRGKb+TIv3jNMQk2Pxj0Ah5SoQ9GPoR4zkHoollqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718293218; c=relaxed/simple; bh=3kTbemhwpMfB9YtbUZOglRGtvhOvz39dtgB36tO5TN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dk7iMpOxBG+dmYSvWOXyDhnUvS4fTH9cBj5BI4T5aWmkO5Ialutcz4WIgir4HpKzofyi8mzi3vvN61Tq/n5U33k+uQ63KVLvICV879dJK+vAWIHhgTHKAksJNJqoBdPRfQoZEilRyXD0elvBSSDjnoFDnIQbz6ghXZEgzFpk8Ps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=kpM3vAT4; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45DEKeSI029454; Thu, 13 Jun 2024 15:39:46 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=7LzF+mdGOSfbi kK0rRRb7FcZ7CcG1T7oFIQ1dXnxY58=; b=kpM3vAT4bXVDrS5mSI5qUEzmNa956 9k+Yox589t7V2hPwBLnONF8D10CIK+pniabCuvdUX46pzx7d5J1qKsIbzkdBsacT yrf28vfgieC/2sZF/9W+IR3s9Ptfyycs417HLnx5ZW13OsMIXkwJybkzF41rGeXE iNhY8Aw4o0fB3WJZ4N6T1QvcimrtsBO/VJ5sIwJ3QKExVhG0zBu2pQWjid72ikVA xTaO5gWwDWoFOxZ9NkaljOnIwTSXdsoySD9wqYToIFZkH+3IPCg7zqoH+W1IyFEa WdHsXdK4haZxflkHo3rGgG1iLQnkJ7hgzjUqsZSnNPsiWKsgsDzHFKo8A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yqr0vsy4h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:46 +0000 (GMT) Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45DFdj3A023918; Thu, 13 Jun 2024 15:39:45 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 3yqr0vsy4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:45 +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 45DF7EKD020041; Thu, 13 Jun 2024 15:39:44 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yn34nh0bq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:43 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45DFdbKC56885574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Jun 2024 15:39:40 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2C5020043; Thu, 13 Jun 2024 15:39:37 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6087E2004D; Thu, 13 Jun 2024 15:39:37 +0000 (GMT) Received: from black.boeblingen.de.ibm.com (unknown [9.155.200.166]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 13 Jun 2024 15:39:37 +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 v4 09/35] kmsan: Expose kmsan_get_metadata() Date: Thu, 13 Jun 2024 17:34:11 +0200 Message-ID: <20240613153924.961511-10-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240613153924.961511-1-iii@linux.ibm.com> References: <20240613153924.961511-1-iii@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: DNHr_yy1T_Z01HP8UOfToGMrh2Q-YjYa X-Proofpoint-ORIG-GUID: _fT-888Ew5czqGiJ_jte1hCxiA1X8Tlx 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-13_09,2024-06-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 clxscore=1015 malwarescore=0 mlxscore=0 bulkscore=0 impostorscore=0 mlxlogscore=877 priorityscore=1501 spamscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406130112 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 | 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 { -- 2.45.1