From patchwork Fri Jul 1 09:16:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 1651102 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=YmCpXQad; 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=Ziw2qAXA; 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 4LZ8ht3yNPz9sFx for ; Fri, 1 Jul 2022 19:16:46 +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=OiZAwmLSMozSyZLPiVR+RzcZTwDnTSNmxtOhHiI8+84=; b=YmC pXQadhSVtGrp99idyRExqiz3KaFrV04Aeetucw+/Jip+1XFQYhuKIoaT9OzFiPmRHdHc/YFA+RMML CRlEnU3GcmiSewy9tW93BN07W/HL6yGNccqap420KDmlp9SVdsD2QMMIGtMrqNjXDaWGnrJl0OV10 yIhieOK+ZvQW5NYroqvkkXAJAwXYJrFFyJertyWFiebkbHhfHCgfxaokHN/Cr1j68d/UwuQ7xdVyb IU1ohtumUFV92o/Czqg/JmAwlhIkeyYfiK6ghdlLTNaJvg5Gvt5JqZ3VC/+eVgRMOp4zVj4dfy2oT pw540xWkboyCWeBiVC8PkZqLlftbC7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7ClL-003ohL-AI; Fri, 01 Jul 2022 09:16:31 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7ClI-003ofQ-8a for linux-um@lists.infradead.org; Fri, 01 Jul 2022 09:16:29 +0000 Received: by mail-pl1-x64a.google.com with SMTP id s9-20020a170902ea0900b0016a4515b2e4so1164924plg.16 for ; Fri, 01 Jul 2022 02:16:27 -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=Gzf9MNYfzuExJ4letAUuWlfZz/ymERxaYUyT/EuC1fc=; b=Ziw2qAXAlzhNlbhTjbP0JE77DsFllvjUC3AvzRFw4OJ8KKLOHiNYxCskVSDnjCrbmk dRi/Tm4oQcCNrIY5p5Ziht1qS27pnUQatjR262bXMIcKV9YxIj2b/0029BocKRRLJlYU HP6zwkl7J2Icx8KXYVj+zvrUrOD58dKKWVnJye31y9E4/J2F4wUXrxoAQ4WcoSR7evCz ZSbWZjPy6gy16w95t0NfHgdbfNUgudhTVrD7nIgjoc8Kl8jNzBjvQSMW/2/0mC5xaqQu Wao9C47Jn/85zScpvweq1xtOni7nOQTixCgarYqulfUgkf2NQQ33BTBk593QPAqQQhv9 cLYQ== 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=Gzf9MNYfzuExJ4letAUuWlfZz/ymERxaYUyT/EuC1fc=; b=l3xoUC+29ydzyfi3bG5qCIcSWXd0ycstwyRREjKGJuP2lC1b1E2H73VpPLX858QDBj MLapOz5ZRZlucMet2hSxhxnZVHU4R5nP7V1Uk2TAHWKyJO1aIdHVjLeg16zXKk8lp/CE IbUDRVUP73DihxmXFfXWDKHiK8zn2wsMWdLI5D+LZZoUWGOVV7Bh1DhsM+6ibe7uCC/b TyJqEF3ZPW4K/pEMnWqPpSrWX8743pNsVgpauq4UVFVcqXDFBW0w4+ap4Eh09dUwKnb3 uT55qq7sfY5dAIYq5dRcYo6OLyR+OGi9D7S7XuZ3JRimVsZmH8mZNof4ZAp91ABcoQ82 7fHg== X-Gm-Message-State: AJIora9x1CBn+PJ0zlBKo4bCfq44PEpDbJwX8AWgldq1z3y9W1ZHWWYg SS6b3lbyNnx1t+D5RolD0dO6U3wByD/PUg== X-Google-Smtp-Source: AGRyM1tlgeuz2bKn2ETD5JL0peIvZI8MizDxt/mQxTKM/Btl6ArdfthuN5ner3m8FquTDc5cMpJaiqaGXiCE8g== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a17:90b:4a42:b0:1ec:adee:e298 with SMTP id lb2-20020a17090b4a4200b001ecadeee298mr17874949pjb.161.1656666986727; Fri, 01 Jul 2022 02:16:26 -0700 (PDT) Date: Fri, 1 Jul 2022 17:16:19 +0800 Message-Id: <20220701091621.3022368-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v5 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-20220701_021628_362888_D0BEF6D6 X-CRM114-Status: GOOD ( 11.40 ) 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 --- Please take this patch as part of the UML tree, [...] 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:64a 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! No changes to this patch since v4: https://lore.kernel.org/lkml/20220630080834.2742777-1-davidgow@google.com/ No changes to this patch since v3 (just a minor issue with patch #2): https://lore.kernel.org/lkml/20220630074757.2739000-1-davidgow@google.com/ 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)