From patchwork Sun Jul 9 06:49:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linke Li X-Patchwork-Id: 13305786 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0189EEB64DC for ; Sun, 9 Jul 2023 06:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbjGIGwr (ORCPT ); Sun, 9 Jul 2023 02:52:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbjGIGwq (ORCPT ); Sun, 9 Jul 2023 02:52:46 -0400 X-Greylist: delayed 207 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 08 Jul 2023 23:52:45 PDT Received: from out203-205-221-202.mail.qq.com (out203-205-221-202.mail.qq.com [203.205.221.202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D239194 for ; Sat, 8 Jul 2023 23:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1688885563; bh=tuqL83ggHiBrgm7wdRGtAfEK9cuBv6+QOt3TztaqU4w=; h=From:To:Cc:Subject:Date; b=uaR/4wqDulOHN130p30lwg7TlEnT0BXv+uRiffdL4SMvLpP42K7v2AiDx5szx3Agz HiEXXEThqenVDykKCm4uayIEQYYxL2qJ2iteWs3F2bQ20yt4fd1UdbAaWHpQRfuch8 yDhuLwvsCrFAJ989DpXdDX7hVw/FTIXHoWjmlSjk= Received: from linkpc.nju.edu.cn ([58.213.8.104]) by newxmesmtplogicsvrszb6-0.qq.com (NewEsmtp) with SMTP id C4E90C60; Sun, 09 Jul 2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jlb0S98EHfpR2EjbLhQLcLm6Z0KMWcqMjFMI2LAM JeAxDQ8hYPFJnM112Dj5GstwRbkzBpm8KRJjb5Uw== X-QQ-XMRINFO: Mp0Kj//9VHAxr69bL5MkOOs= From: Linke Li To: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org, tsbogend@alpha.franken.de, Linke Li Subject: [PATCH] MIPS: Fix undefined behavior in PAGE_MASK calculation Date: Sun, 9 Jul 2023 14:49:12 +0800 X-OQ-MSGID: <20230709064912.384862-1-lilinke99@foxmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Linke Li Make PAGE_MASK an unsigned long, like it is on x86, to avoid: ../arch/mips/include/asm/ginvt.h:44:20: warning: shifting a negative signed value is undefined [-Wshift-negative-value] addr &= PAGE_MASK << 1; In the MIPS architecture, the PAGE_MASK definition in arch/mips/include/asm/page.h leads to shifting a negative signed value, which is undefined according to the language specification. To address this issue, the PAGE_MASK definition is modified to be unsigned long and ensure well-defined behavior. Signed-off-by: Linke Li --- arch/mips/include/asm/page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h index 5978a8dfb917..3061a5586954 100644 --- a/arch/mips/include/asm/page.h +++ b/arch/mips/include/asm/page.h @@ -33,7 +33,7 @@ #define PAGE_SHIFT 16 #endif #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) -#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1)) +#define PAGE_MASK (~(PAGE_SIZE - 1)) /* * This is used for calculating the real page sizes