Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp698990rdf; Tue, 21 Nov 2023 14:04:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGALWKAgtVw5iuF3/3wh3lJIH4Ju2qWPC6qCX7Vl+QXnIWH2RH4Vy8Vv3+sgYOK2Iy807WX X-Received: by 2002:a17:90b:3b52:b0:262:f449:4497 with SMTP id ot18-20020a17090b3b5200b00262f4494497mr622611pjb.2.1700604273120; Tue, 21 Nov 2023 14:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700604273; cv=none; d=google.com; s=arc-20160816; b=pVwzOH1C0smJEX/Tf8ujmIWf0JgwG8ByI8zyrdy+ZKS7rjxq6LFePNnnb/dAuQjFxp RDMf0IIC4epGAMW3kEv5MqhfMJ4zQLj3OpBS4AbQuGzI2rxp1FNvhG3JKiG0xZ60TXql 2zLbaudT44koDsWOobhP42/mKSOhSn25FCsuI3i0mli0hN7h48NhqGONiFDD3EEXcLea r3cjyXzRxtp8FVZOOiY4cllMMmrfdsKWSVx18SGhMvW6aoCf/zbe6RnXkfwqr9JFlHX1 7ABXrqqCT5WSC6Llwu0dFSEB+PLcBt2TWIPGwbeOgHaG9QqVP7tFxUGj6NhR0KQSMyyx jCUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QnHpD2/5G8nBf7RYxex7ZCPkjJMh3IfDIUDgzy28hLk=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=RBksmpqcYAepcC2zulmLLBO0b2ssbM/rFcIcoi2+GlsXWWmsq62HONlTzaeGxdo1bA Exnp3hT+pKD34rcJSCy5a9Zz/RLvxW0ReGl2JXxkr3CQAybxSWywmstBSEZpuOyCVeAF KFDwkcGq6sBOf5CepCdl4HaAzU4+J/JbCxcgXD5DXQYPnXT+21Db/9KRC9uRo1DqS20T ZMniovtGQtGlvRm1Nd6TgpdmLnPXvOdZsLKVes965rzAjnmswqKcTwNxtQQl7GCgHBGz cdXkmT4j4uo/xbuliVFqkCcg3f+wjGokHPO1JdbTylJYPobB/xNI5rqQPWQUm7ZMmhmj 9Cag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=KOLMzVoP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id by40-20020a056a0205a800b005b834096959si11923725pgb.851.2023.11.21.14.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 14:04:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=KOLMzVoP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 244D88022718; Tue, 21 Nov 2023 14:04:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229582AbjKUWDU (ORCPT + 99 others); Tue, 21 Nov 2023 17:03:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjKUWDN (ORCPT ); Tue, 21 Nov 2023 17:03:13 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F48E10F7; Tue, 21 Nov 2023 14:03:01 -0800 (PST) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALL79FR001860; Tue, 21 Nov 2023 22:02:37 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=QnHpD2/5G8nBf7RYxex7ZCPkjJMh3IfDIUDgzy28hLk=; b=KOLMzVoPdxMpKE/B5PsK8VLy9LhPrARqMDSbblL3jQMXMy2j/yM7yZ9rFSsPwE+IJ0oS joYURlN4eIuAVEThUDhbChMbf4/5JLTL5kCghwaFOyI8b49qr8288xWLh8NGmqPPj9Sm D52A7r0KRp1xBs+YmABGPOjLHcBbXTiKbjlsFuhl3XXozpMvTVY2KYEs5tKl906dSbhk rlcgp2RQBtCEvtIr4wJQfTCeGy/kZadzn7cKtTLZKhCfoeHxFHn6WEpQ2laeIGvXAt6c gZckQOQZdSzwZ10tFvtw3DQOm6VVGSS4QBMIfVo9yO4qKba59zv5uvJXIq2vvhIDYP7P yw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uh46a1a4y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:02:36 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3ALLgHKi029220; Tue, 21 Nov 2023 22:02:36 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 3uh46a1a42-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:02:36 +0000 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 3ALLnSZD004663; Tue, 21 Nov 2023 22:02:34 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf7yykvh6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:02:34 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3ALM2V2l14942770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Nov 2023 22:02:31 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8906F20065; Tue, 21 Nov 2023 22:02:31 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21D2C2005A; Tue, 21 Nov 2023 22:02:30 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.179.23.98]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Nov 2023 22:02:30 +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 v2 15/33] kmsan: Use ALIGN_DOWN() in kmsan_get_metadata() Date: Tue, 21 Nov 2023 23:01:09 +0100 Message-ID: <20231121220155.1217090-16-iii@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231121220155.1217090-1-iii@linux.ibm.com> References: <20231121220155.1217090-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2TCo5LFGLjvBe_FNuSOp8ISqSS6rfXb4 X-Proofpoint-GUID: PizVCBmrtyUfaXPpBjtJCvjSHdm3Jo8r 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-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210172 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 14:04:27 -0800 (PST) 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)) -- 2.41.0