From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E31CAC433FE for ; Thu, 4 Nov 2021 14:01:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1CFE4611C1 for ; Thu, 4 Nov 2021 14:01:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1CFE4611C1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 93BB06B0071; Thu, 4 Nov 2021 10:01:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C2FD940008; Thu, 4 Nov 2021 10:01:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 763E0940007; Thu, 4 Nov 2021 10:01:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 61B4E6B0071 for ; Thu, 4 Nov 2021 10:01:38 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8F4B98248D52 for ; Thu, 4 Nov 2021 14:01:37 +0000 (UTC) X-FDA: 78771410634.18.7626894 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id E4E9210000B6 for ; Thu, 4 Nov 2021 14:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=TcxeMmdf9PMM1bk2EyTfoeHBwMvJzyVyT3rTUBUqfjY=; b=f9B6oJqv03KRyTJYCdPePuVqh8 DfHgyDJklMqgPHS9BtUAe+6plFoVMVlW2rJdPNbWSPFSkiPky/qrZmudNiHEjitYUSKYFSwMUFHvA LwGzJyky6L3T9mM+JVCF+gcHZy4IKLhyp6T5IsyfH0yqcjfHUHVxBtgeLLcWYw7n6RJvANZpejNJQ biK+oP8YntFy0sAjsVHzXIy7cGZ8PisYgebbPjx0Mk7sJKGvFRTu8H2+bno/GdRNStNcMLC86R6JL ESCamt9QSJ2mgI/EjZjyRmpZIPQG0+c6qU9gYVkGxLYdGiBbbywN6ppGGunP24d/rfbO1QG57CPtt 5HsBoIvw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1midEi-005u4V-RG; Thu, 04 Nov 2021 13:57:18 +0000 Date: Thu, 4 Nov 2021 13:57:00 +0000 From: Matthew Wilcox To: Arnd Bergmann Cc: Andrew Morton , Arnd Bergmann , "Uladzislau Rezki (Sony)" , Stephen Rothwell , Nicholas Piggin , Michal Hocko , "Paul E. McKenney" , Chen Wandun , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: vmap: avoid -Wsequence-point warning Message-ID: References: <20211104133549.1150058-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211104133549.1150058-1-arnd@kernel.org> Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=f9B6oJqv; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E4E9210000B6 X-Stat-Signature: hzwmacscnbt86yof57e4a1613x3q9me8 X-HE-Tag: 1636034493-850722 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Nov 04, 2021 at 02:35:40PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > gcc warns about potentially undefined behavior in an array index: > > mm/vmalloc.c: In function 'vmap_pfn_apply': > mm/vmalloc.c:2800:58: error: operation on 'data->idx' may be undefined [-Werror=sequence-point] > 2800 | *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot)); > | ~~~~~~~~~^~ > arch/arm64/include/asm/pgtable-types.h:25:37: note: in definition of macro '__pte' > 25 | #define __pte(x) ((pte_t) { (x) } ) > | ^ > arch/arm64/include/asm/pgtable.h:80:15: note: in expansion of macro '__phys_to_pte_val' > 80 | __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) > | ^~~~~~~~~~~~~~~~~ > mm/vmalloc.c:2800:30: note: in expansion of macro 'pfn_pte' > 2800 | *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot)); > | ^~~~~~~ > > This only appeared in one randconfig build so far, and I don't know > what caused it, but moving the index increment out of the expression > at least addresses the warning. Would that randconfig include CONFIG_ARM64_PA_BITS_52? #define __phys_to_pte_val(phys) (((phys) | ((phys) >> 36)) & PTE_ADDR_MASK) because that's going to double-increment idx. Or single increment. Or whatever else the compiler feels like doing.