From patchwork Fri Jun 21 00:24:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13706570 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 E8748C2BD05 for ; Fri, 21 Jun 2024 00:27:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F38456B0140; Thu, 20 Jun 2024 20:26:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4F4E6B0160; Thu, 20 Jun 2024 20:26:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9E9F6B0140; Thu, 20 Jun 2024 20:26:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A42D76B0125 for ; Thu, 20 Jun 2024 20:26:52 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2C10F806CC for ; Fri, 21 Jun 2024 00:26:52 +0000 (UTC) X-FDA: 82253005464.30.EF12610 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf10.hostedemail.com (Postfix) with ESMTP id EF329C0005 for ; Fri, 21 Jun 2024 00:26:49 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=omgAPtXZ; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf10.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=iii@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718929602; a=rsa-sha256; cv=none; b=6/ZXvxBiFYMZ0E6Or8CxR2YkQfaSeARcx3JHY0Q0CJx0HL7FVsmly3j88pMtQ63a7LI8eV cAurY9aDc2n3UggwFGoCMKWjspMW5/NomVs5/aKQxzQQ6KuHPPKI6GCw/LFFNDdNsJtdbf eqnylyNkhGST2VrEBszZ94EsXqsg5bo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=omgAPtXZ; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf10.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=iii@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718929602; 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=Jg9ruRohxVRU5pl+TsU+/DFApI3oiRhPhGaXlm3lfTSThpSc8MISdn6U0ezHAnmjt0GW3o GylprR7CXiW3vcGkHZnwMHWXVZxTxiZmp4XktHEp+FuyKYnJ1nBcNAZbayApVDQ+giQrlN pU5tYoJOZg63/h4bzEqbej6xfagtp7I= Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45KNwuqu026203; Fri, 21 Jun 2024 00:26:44 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=omgAPtXZa2h+wM2Uz5C2qJvs5wx5Q hXHdc0myeGyh95SHUQqk3gFhzs6od31Zynj67GtVY/MP4+us+8A59m4u+rOSEZqv +5/QW7ONrnSvNZ3i7t+BxsrkFEt3Lgi6BuhScGzwhhA039kLykk/F0Cyf09aHBsJ JEVikiBywlSH3+VBn98+AcAL+UYQ2IEFRC3qsMse0duCDFeRk8YjNo2jOSDh33lV hLOTxWjgwoiFL2nwu6m1/XqKbFssI9WK+RppGnpTuf/jVRjm9jFPPHL4K9dS5B0P IhMOGlgUeBeYcND3kVCOh0J1qCr8oUFkKxbmURIXMw4U4wfx4RrRWPwcA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvxjjr1hr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:44 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45L0QhWV003105; Fri, 21 Jun 2024 00:26:43 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 3yvxjjr1hg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:43 +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 45L0HLif030949; Fri, 21 Jun 2024 00:26:42 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yvrsstn1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:42 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45L0QbQM56361224 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 00:26:39 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F4D02004F; Fri, 21 Jun 2024 00:26:37 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2D0F2004B; Fri, 21 Jun 2024 00:26:35 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.10.44]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jun 2024 00:26:35 +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 v6 14/39] kmsan: Use ALIGN_DOWN() in kmsan_get_metadata() Date: Fri, 21 Jun 2024 02:24:48 +0200 Message-ID: <20240621002616.40684-15-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621002616.40684-1-iii@linux.ibm.com> References: <20240621002616.40684-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5W7KJG6jJlxWPE_in6LwMdbQ8ARjeHya X-Proofpoint-ORIG-GUID: JqP1_YZ35bt2dIEOHFacKgEIXr16xCpW 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-20_09,2024-06-20_04,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 suspectscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406200174 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EF329C0005 X-Stat-Signature: nekrnef5dz1yan7jcpxua4d76q7j5yu7 X-Rspam-User: X-HE-Tag: 1718929609-283361 X-HE-Meta: U2FsdGVkX1+Vt+tq9IYeckO4uHLgtzT+R2Swvqu7IhjdPLCGVmf8Hr7LnmxA/yZZAnjUsBSFL0TtZk3lyhE2oSoIP4aO28BUSdJ4Fity9exZfTSv+gM51uVYA1pxUNyi6i9U38oaVW25BrycQxxvsjHJywhjWqCt85glFVehYS1WDAtjjOUEF4H0RkbiIazeltF2iKCv77Xx8ji/gyn3Rfarwzokx/9mpi5FSnvRt8mmUSd5Q/bIDLaPvot/cpmlJWKPnu+uhL3imYiJIBJW9RXfib9c4QkkkFgKJ6ufvUJbt5pvyYJFs8w5D08nkQ9+tan6RwgsMfJI7upM6uNuMZJN9PmI+SvzmVb1deDP/bM+wUELLSbg9GbipZ+cFiV3NZttsPKF889xtX3pO25P1C9qNROM3mPue9w8EE6Nu2E8AuuzESkCPWU8BIahsIP4BEERt42KSkSCYEpXLRjtMwZIg2wCr1riQZJkXqI5TJsgknT+ki/Jyp0yYo1PWm/m4E9TXZrXBw3fl6lZxbBmIS5wegqk/dwLXoiDzZWXQ7nG5ZHgsqWrx/2OD1ha8FFh6U9S+YBJa7QC5Sd2sT1J7+rMiuuwMgKURRrg1dz1j09shrV31g4c6Tu93mDsQR7nraOiWCWFbXpvrokJwHGlbmbGgcvBNDZqyPj3XxBx4/1qZrlCaUdxoppn9sewbycB1w5D/wxtvyiUaF1j+aEgIc6SjUM9eqnD0RPaq8akS3jTM3UyjwZou4BVL5bqtNQAAlaabDjbLEqNQ4yrYOAsaPknPZIlXRinGzWfmRh7ejhpE3Z2/8A4Zlay1GUq0mvRPlBgSOQybFmm+0tMI1n4xCcyOqV7RToPNByLcY+nHmUriXNmXFSsAXLnuTvOahoEg4giLV02CCYzXK04hO2+c5C5s0YKoXqkpFzraUEiDDh7QeGP8HvRb7n6ZBwrSwXTxYaip2BFwAZnu2LpMKh whiAZBFQ qIb4TvtymND9S3fH9AtAd2tgGgeLzTAeaplD5pHez06fI3F9VskPLyHBo3nQI0XPSHlCQIDXZDShxxPz2Jy8t+xsGrlbYeoCnswexj0CcgoR4QjQaynxHMp6XXa/dM5P8RpuPm1FhzGBgSxjTLQ1niWU5FJsxbp4TEO6bkAhv1+j+VDPSUtaMKim1fiJ0qymqozeqJftjzK3LwU8y/kE8u3IMVhkyCTELO+TNZRP/xFmPXkEVsNPxqd7j76gzk3SpqHx5l2TKYmM2xKaYZDm5abzaiuS2c3sqLMGo0b5d8fI01/nVEgiptS8E6axrYnPM6HXH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, 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))