From patchwork Wed Jun 19 15:43:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13704203 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 ECDB5C27C53 for ; Wed, 19 Jun 2024 15:46:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29CB08D0081; Wed, 19 Jun 2024 11:46:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 225776B02FA; Wed, 19 Jun 2024 11:46:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECF848D0081; Wed, 19 Jun 2024 11:46:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C18E76B02F9 for ; Wed, 19 Jun 2024 11:46:03 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7C3E31C1892 for ; Wed, 19 Jun 2024 15:46:03 +0000 (UTC) X-FDA: 82248064206.05.A9D0886 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf17.hostedemail.com (Postfix) with ESMTP id 2203E40008 for ; Wed, 19 Jun 2024 15:46:00 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=hrkS6RNO; spf=pass (imf17.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=1718811956; a=rsa-sha256; cv=none; b=6N8fFvWo83Ur+x1hh/rjJNA7qWvZCPTNG+SmzDWwwzkIJYSrjXM0X7O6c+QmPwvSGy4/kJ mQ8hw+VN5pUWW/ZSkZ+d/0Td0g/J3ngOdE9OmyXLOhtk4tym1dfmOCyd4QXQsTcqcZUWoU rOgjazOaKMJQtKLe4TkwDA8Nocnkmfk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=hrkS6RNO; spf=pass (imf17.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=1718811956; 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=fhyNLk4BgDYNJAsfSc8ftWCxz9OlL/4RiKPE6HJFalY=; b=xDGCHX06cZ9Gok60LyqrHBiyyDHfv8SZKAHB7gHgMpmuQcLX9LxCjDw7DSqfEMee4NHJ02 AkusZB/HjQtlPqTNKO9p9eeIaG6ZM87d+sLjG3IH5RYOrK7+CD25wG/7JD6abNwLaW9a7R ScLOL4XcCygeMgJxmxN1sgAFGVe01Yk= 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 45JEwgQL023598; Wed, 19 Jun 2024 15:45:47 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=fhyNLk4BgDYNJ AsfSc8ftWCxz9OlL/4RiKPE6HJFalY=; b=hrkS6RNOPG56OtmskkPkw7yVXYwAT acEMbfC0Soeijihdr5if0GECZ1ST+bS1M1VbsdGDwp510etV1GqX2sIUPiu4fUP4 uboNtL0nRkk9EL8HDoBX2arUaWmCv4e42yeCyA79rrTDwil26m9aJk3utHuE+mq2 VfGqGJQnKBICgmluoafa6R29nP5Q4JzXMai4gnDiMH0fUVjigEIHJ34Y4Wplrt8W jLsdyt/HdLDJGat8R4Okl8r4NoiQp+ax480Y4WYEhiNTpcFsz+H/5Eb9dHaXN81H tsJpvqAWHFxQ/5l/CjOdMuR+Nnu0qqkPiZSIINSpD1pDnYfpF5X26KBPg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yv1jfr5bj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45:47 +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 45JFjkwE005769; Wed, 19 Jun 2024 15:45:46 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yv1jfr5bd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45:46 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45JFN5s7019545; Wed, 19 Jun 2024 15:45:44 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ysnp1e4wf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45:44 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45JFjcse47513874 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jun 2024 15:45:40 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD04E20063; Wed, 19 Jun 2024 15:45:38 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E7592005A; Wed, 19 Jun 2024 15:45:38 +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:38 +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 14/37] kmsan: Use ALIGN_DOWN() in kmsan_get_metadata() Date: Wed, 19 Jun 2024 17:43:49 +0200 Message-ID: <20240619154530.163232-15-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: gIZT5DYHh1rbbpQa0FFDm_E1i5yVi9Yw X-Proofpoint-ORIG-GUID: OHhlw3JqsWTVZx2EL0dqKaWV5MgXhMBa 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: 45c4agwug55pd9k6wcehq6nk5y3npsu1 X-Rspamd-Queue-Id: 2203E40008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718811960-545277 X-HE-Meta: U2FsdGVkX18Yc7bKUZvHhHm8wcBaA2kxd8K8QP9EGn4EXBLfO4EkTyxU+vuEWbOz9jO+KLeAd2gC2KRe7FRB3Xr089LQzZj03sJ0qAn93F6bykcuxDuPxWkefM6QOWx3XBSqUWn1wnoGziF11J1CfsvfUCPF42TWtPY9zoOBaFue3TLOqCarHfw9ZJqBdfHqYjFcXzrBArAEAQvZQH8nSnyzF5GhjFXgnoHJihUj+t6Jg7jUmE7Iz0WtZCJ74CZR+3rhrnEv1QW8M6Rpn2ivBfjgc4feg2Ir1FEbg3xJQ9cyLgmr6+0d2o7hmCRiY0DN2mq+d7zQxD4N9LXj1sYeXzSuVXvLm/Ez5eQsPHSgZpR4V6nNf1rWL1g+j3eAyQg2ch4XRZCdBQuTDLq76EXF0MR2WdgngPDtfDBPS7BPf1adiv3dMAk4MObPbxs+f9Hn7AsOgl6k6u+kzBnAzokx/oMhVzeDoTkLA5TvDUaalOH4ZmFJGCiU0YJjWVrPd/JaTyXIzFXGCNCJXryWsJkzqqvqyU8ho0Nflk6Igu6/YKqqHmR43awFFD7rZT/w7hKOmxRRcR3shGtM0f79GYj/9Dk1pu9nFgJxNEhZ/9DDJPmtN4CGDpjS91nIhWnzSNlvGbS+pyFNCv4YvF2u7eRt69A0wJRmsGsXPKLbkirUpr8NAXvUkUnNAC35owmpuR1VVB8FNjsJRnQrH/IchrYg81XF/vhWMEY3uKqXRy/Gtu2HvBImOkGKzckoZ6PruR3i6p37KQT60kXh+Znl7cIW/J0HnSC0YoWUbvbq8nV21Yi87R92vCGHPT6yJ+TcLKhMo5xHXahX5Wd6uNbU91Dcg+Z+kjzweMM20pTPwAJzVmAzLowVlyfSSOJjFqba3/brDaFFCyc4VAIG3BzU/THoYmFWNACdR/FqAo/9lQ/0/gLATUe7R+DAecJ3ArBTwPd7Bm9GMqZZD9a6BKo50EM GTHvmeVa mWmBlcAFpLpqtOaSFJHOeQXyaDtj11joqzgXSC/W2bv4bRSsRVwe3rzX3mZiCVNmIJt5dICd2GnFQB/gjfPpLY0VXGY1m34T9uoGRifXl9ex0R3Pv8cqG2o3O2qPFyATAGdEoqGX4EGOII3anpIVwkTJ+yz9rTiBpIgmIQDZBsdPAQH/qUakLW4iyII0AwnAz6S1/82oY+TagVV7ZD3bG7Bc1ennJ9y6ulAXSHWiTTX53+8tHwOBw13y0/8BmFySES9xRuZGO3+5ySALXFENOThnYcvIkNZ8z69sbtdpVhwAK+acToDNM9x75xnv9cd2B2DQm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000113, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Improve the readability by replacing the custom aligning logic with ALIGN_DOWN(). Unlike other places where a similar sequence is used, there is no size parameter that needs to be adjusted, so the standard macro fits. Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- mm/kmsan/shadow.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c index 2d57408c78ae..9c58f081d84f 100644 --- a/mm/kmsan/shadow.c +++ b/mm/kmsan/shadow.c @@ -123,14 +123,12 @@ struct shadow_origin_ptr kmsan_get_shadow_origin_ptr(void *address, u64 size, */ void *kmsan_get_metadata(void *address, bool is_origin) { - u64 addr = (u64)address, pad, off; + u64 addr = (u64)address, off; struct page *page; void *ret; - if (is_origin && !IS_ALIGNED(addr, KMSAN_ORIGIN_SIZE)) { - pad = addr % KMSAN_ORIGIN_SIZE; - addr -= pad; - } + if (is_origin) + addr = ALIGN_DOWN(addr, KMSAN_ORIGIN_SIZE); address = (void *)addr; if (kmsan_internal_is_vmalloc_addr(address) || kmsan_internal_is_module_addr(address))