Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5658978rdb; Wed, 13 Dec 2023 15:50:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IElnagrO7rK1poeAJsNHvURUmPD1N1sQGf+QOF9chxvbQc2uxF3K4m/k4l8hYcIBiMyfEJT X-Received: by 2002:a17:90a:458c:b0:286:6cc1:780c with SMTP id v12-20020a17090a458c00b002866cc1780cmr7435581pjg.79.1702511410439; Wed, 13 Dec 2023 15:50:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702511410; cv=none; d=google.com; s=arc-20160816; b=aNIbRXwQqLg/7BNwBae1yaV2hSvczuRjVvD4pWNhwfb8U3DwWDjMKUgAyIl8CturW+ MFfEk+6iuqH8ub98fnAN5oKdDYZIqvyLXmZv1m0GtMekJbaUf3/AWwZdzc847p8o9kVv Q4IabiBihECg+ytDDcAMUsCcu+rggLEgDSpov5wVPwKviEqkdHEbd+4ynwzggGR3VuWZ hGGT7UAOb2W7hoiD4xCjkGgYpXHCNVkMs/LnzMPtIXLpf6OXGNDjWu//m/sGi1h+tOsB Dnbxb6bZp9xrO0Zw/UaRVMkckDks01r0rognNMvjZBZttWzu36KVn9weNZrS0grJc0GT pWRA== 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=f61PT7g/vuAibsjDOy6DAIgpeWx3be7RgbReYtda3cA=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=wboq2rJSvTt72K/RA0gEC1sPAxOtibZ40TNMQv3pcRvR9l/idlO/DO37IZZrIAlkcC amEcp159DBMx01zO9RMgZC/q2knvww9pOqnGrgKSBbQVdCdQfeu+ZdTvtIwhtgFv6a7I qhjUX6phMBQlsb4vh83d069dVByToIaDR4DDIPy/MssA2YskX0vKmAag151T38tt/xbj y9RsGKciix9/fa5kiLO6XhF15j+i9FyJ46eVToPhVhX/pl+IfRvce2Oj40ZDuTUQv45e YORmM3RCGgFhJHPYab/gbbQGBQ9aMQlialWYBFL7YYrgaDRZffEgo0RV6Yxu3E7kvKXm gVyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=rug7CVLV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id k2-20020a17090a62c200b00280479459f7si1027846pjs.50.2023.12.13.15.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:50:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=rug7CVLV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 2C5B0827D0FC; Wed, 13 Dec 2023 15:50:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235400AbjLMXty (ORCPT + 99 others); Wed, 13 Dec 2023 18:49:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235105AbjLMXtp (ORCPT ); Wed, 13 Dec 2023 18:49:45 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AAF72728; Wed, 13 Dec 2023 15:40:58 -0800 (PST) Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDMe3sQ026112; Wed, 13 Dec 2023 23:40:30 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=f61PT7g/vuAibsjDOy6DAIgpeWx3be7RgbReYtda3cA=; b=rug7CVLVL28INcXomNp/6g4B/kdBN1k9Nog7MxaAWmwtJkcbANo3L8cxc70uspTQNYEh 8S2b+AJ53AuE9nAE9elA2H0d4nfcN7xeQjpOoaKLstVQ5KlgEs+5HgW8E8uAwlK3UIUo D32gzHjXfjHONXy8Zu09kgOh36c/tJUkmCzDDj8jf/8W7DUFdNO5Pkqx0tNyeemxG7fb JjS2CiNP/diYCkxf3+12GKpop7pTuyHaP+JCtq5fi8rjBjs9G6935ARRHVeLOnM0mA3s o9ziUx1TRxeyc+5hCEVGLWspNl2TkfHeYFLqN4cfeL8xrfNM+MGFrCQsgDgyUW8KznV1 fA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uymwuj5xe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:40:30 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BDNLwT7018904; Wed, 13 Dec 2023 23:40:29 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uymwuj5bb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:40:28 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDMvT5Y004899; Wed, 13 Dec 2023 23:36:33 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uw4skm9wb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:32 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BDNaUlL11600636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2023 23:36:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4060820043; Wed, 13 Dec 2023 23:36:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF4E820040; Wed, 13 Dec 2023 23:36:28 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.70.156]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Dec 2023 23:36:28 +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 v3 13/34] kmsan: Use ALIGN_DOWN() in kmsan_get_metadata() Date: Thu, 14 Dec 2023 00:24:33 +0100 Message-ID: <20231213233605.661251-14-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213233605.661251-1-iii@linux.ibm.com> References: <20231213233605.661251-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ZnvMsRQHFj5YzlpSvFIojYHFjtCw1G-g X-Proofpoint-ORIG-GUID: 9YWJfdp_hxIenSUs6PPpY0jtFMAnoXZX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-13_14,2023-12-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312130167 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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 15:50:08 -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.43.0