From patchwork Thu Jun 30 07:47:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 1650613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=riBZN+gS; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=Cd/RaHs8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LYVnL4zspz9s07 for ; Thu, 30 Jun 2022 17:48:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=zDIY4fKcaNyd1zDzHRaVA/fJClaLe06Ho1XlDJCn0mA=; b=riB ZN+gSxa85VCo/Hb0gHMZzYGfNXqkFsykqMDfFKx/q3dTLtlHNEaMnLJOFaPYUSfBTovD61uZNXKDp qv6fHAijtfPv6tWAYMbwfac42KWuHiKju+4ykJlzoE8lc36x3u8d1K9/3BbgnCW6TFzowilk+0LpQ 79ZP9Zz508KAqriZgGVCmlMhEkVsQjv0keTf3+ww/PzAnvkFqXxDN6a511oFXeWx/7+/kxDNrT22V ssHMkpfkqfeS8yczmDgOCi7XN/r5q2326yY9j28+xyO+CuIROIeiTlGsIgfzCzCfjeJnV2bKMwwOl XpHO4pkv0GmLseInh3zcFaklv/M7zwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6ouL-00FpK8-5z; Thu, 30 Jun 2022 07:48:13 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6ouI-00FpHF-7G for linux-um@lists.infradead.org; Thu, 30 Jun 2022 07:48:11 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-317f6128c86so148642077b3.22 for ; Thu, 30 Jun 2022 00:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=XzzQ2qeoRIHvL3OIKjNQCubCMmqjty1j1wRkBLGrTgU=; b=Cd/RaHs88ciLdA0+wMopNk5kjW44si1O/9QcrziajxdH20xK3UlUrP0+vLXx20MY1D RUAPNooz1wh14yhNsjZ2DPh04r1TSjAWbZGLdxIfADNCLsKIMVoe0rCwGDelPXBS/q07 bfBF8ggVR84eJmwoJcidKJXXyP0skwxvM4oMo5jDBjsdLzw0hq+urk9Vt1El1I0pNXOY Ui9qvmcqqGBAUjeUZNZ2TMfeCjGGtWzShSjtdHoo+rJ8+Q89q47gWg1OYS6AOODEA8yv r7cKAeIge6MraBq4l/vTR1evClWD+lPEjdb8uPAySVuqmLU0+iIs7L3MgEN1SzQNTG1I CBDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=XzzQ2qeoRIHvL3OIKjNQCubCMmqjty1j1wRkBLGrTgU=; b=gy1rDMj0UeH6N2BlHw2nCW6rCfCfooSGRBEi3144PjGLV44DHxxbKOdsID3IEf6E5s 2Xk8RJr2Y3rKMtxyxy8v/Ft/kLcYaaivMF9W9DQnYmumxQwWgHRXpdXyXf+eVjg/eToL uknWERU3RfNZpBd/m4ZdKUBQKWdwFWDAzMHjKciAv+Klym5SJo+++qmWIu4t8Z1Wx9aX fmpY9Y02EW3cieg/YzHIyoPQl0Kh7qFCDk6YiV5WvCgWHpKppl3TxIn44J8izt7j6XO2 +3xousXSaGeQXt3OJigvny7R3L7Dh4JfFzhvhPTOtBaDSnUUEhNL/JATQrpfhfcKXpnn rehQ== X-Gm-Message-State: AJIora+pbdWCo8Yu3AnVsrpHI93J/S+dydAPCCMSXLS26qS+EAZznYhQ DOX48exDjJk+Go93wOvDhSiqNdTFMRHH/A== X-Google-Smtp-Source: AGRyM1vSiWG5UsJn1FGs8y/l+5be4umvT4PkYpnDFc4Cbi+MLFCVLCTtuQ8PN01k8FUWH9WOK1+ovGD2Wp1BOA== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a25:2f81:0:b0:66d:9a86:f6de with SMTP id v123-20020a252f81000000b0066d9a86f6demr3315237ybv.590.1656575286295; Thu, 30 Jun 2022 00:48:06 -0700 (PDT) Date: Thu, 30 Jun 2022 15:47:56 +0800 Message-Id: <20220630074757.2739000-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v3 1/2] mm: Add PAGE_ALIGN_DOWN macro From: David Gow To: Vincent Whitchurch , Johannes Berg , Patricia Alfonso , Jeff Dike , Richard Weinberger , anton.ivanov@cambridgegreys.com, Dmitry Vyukov , Brendan Higgins , Andrew Morton , Andrey Konovalov , Andrey Ryabinin Cc: David Gow , kasan-dev , linux-um@lists.infradead.org, LKML , Daniel Latypov , linux-mm@kvack.org, kunit-dev@googlegroups.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_004810_293343_67EE2638 X-CRM114-Status: GOOD ( 11.22 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This is just the same as PAGE_ALIGN(), but rounds the address down, not up. Suggested-by: Dmitry Vyukov Signed-off-by: David Gow Acked-by: Andrew Morton --- Content analysis details: (-7.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1149 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This is just the same as PAGE_ALIGN(), but rounds the address down, not up. Suggested-by: Dmitry Vyukov Signed-off-by: David Gow Acked-by: Andrew Morton --- Please take this patch as part of the UML tree, along with patch #2, thanks! Changes since v2: https://lore.kernel.org/lkml/20220527185600.1236769-1-davidgow@google.com/ - Add Andrew's Acked-by tag. v2 was the first version of this patch (it having been introduced as part of v2 of the UML/KASAN series). There are almost certainly lots of places where this macro should be used: just look for ALIGN_DOWN(..., PAGE_SIZE). I haven't gone through to try to replace them all. --- include/linux/mm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9f44254af8ce..9abe5975ad11 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -221,6 +221,9 @@ int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *, /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) +/* to align the pointer to the (prev) page boundary */ +#define PAGE_ALIGN_DOWN(addr) ALIGN_DOWN(addr, PAGE_SIZE) + /* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */ #define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)