From patchwork Tue Jul 2 23:13:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Huckleberry X-Patchwork-Id: 11028723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FE7A13BD for ; Tue, 2 Jul 2019 23:13:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3494F2897E for ; Tue, 2 Jul 2019 23:13:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25D8C28984; Tue, 2 Jul 2019 23:13:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BCC902897E for ; Tue, 2 Jul 2019 23:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=TWRc0W2ESkr1v5DXcnS1BPO+PH8u5mO8smeDKr8PJ78=; b=EdhcQEXE4hrpAd DZ/H0sGqyXLouCATlS4SLBDbQeK3NKxdI59NlTGWkmxdROQ04x9+Kuv27vaRJzutqA+yxByeauCGc U/f5dVER7ark1RN8eDPqe4WSHiwUSnA1YfJcOaFnQbCQFmmmu1ItAcJONbkWsynRIYV007839yp9L 0ZVK4Qs1KwOBUDvSMfFO+7YT3vjuMCrounOgVpAmT6fVYFyink59NJSB8GaMg2/GADthYLOk5zcfO CaYaoHcfHDqfeTS1Mz/twWYgqOdIPSnL5FLLRrMt3o5hGhsAmK+t5ctRMQKeiNjnHP0WY59nlxXXB Ow+PkLbqRYxv7N0VnSPQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hiRxb-000077-Ol; Tue, 02 Jul 2019 23:13:15 +0000 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiRxX-00006e-NC for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2019 23:13:13 +0000 Received: by mail-pf1-x44a.google.com with SMTP id 6so214464pfi.6 for ; Tue, 02 Jul 2019 16:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=kOX/b18nZuUFLUmGmTpl546hS1EqehWOvqAy79HryjA=; b=PHzIGGfXetYTXGzyTnFKvYWj/S64EJ84TRcojkaEZ3zefgwEC4LsicdhwrkL2ldmKB gLAW7FqH4fV0fpD5nRCgP2WElmI4pBZ/bAxq8fzbpmZBPLR1WKxd5oKCsf/crj/4jdmt naAfJALZxW8RSMccuFYHpwcKTyChfjibhUexOeeOVyiukx4Qzs0d00o8Po9sq0lQhsZc bm/KmFcPSVoxiXPQBDZhlN7bv5zwQM8qNbDTCdGKs3xItoELX3CvzNDL5wVT124uTSa/ lgeB7jg/Jrdoqhn89hRdD8AY7lVg4ofRKcOwK/vqZ25QdXZj1E42OnQVfw8QJyKJo1bo Nv4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=kOX/b18nZuUFLUmGmTpl546hS1EqehWOvqAy79HryjA=; b=iQWUA3gN+AR98jjFpHbMXtdRfnA+19j26GY8Xs6MwyGt545MvEesxdMnqXdtXctUdg JHUnX7XtKVt3bMNB9m23DMxmE+j9cZbg4O9aGS80Z5LkxN+2/cAAxDAbJyUDQ3QCZE7i al53ysIZvutZXHHvltgHlUknLW5+983SgX9BgXSpGOI3BG0ePH5Hd6FlNa9wOw7oclyI G6/sno1Olx2ueSlqwmy/Mva+yZ0Hz+s1k8/kkf4qdVcjieYU3Io98WEJfo626FcGuEyr g979Fxl7CpH/jlJiER6vqMhdOB2KHNlKEVQVbkqljvgcKOrTIfAH27gFkDcdJUyoqSrZ WKCQ== X-Gm-Message-State: APjAAAUfVqc54jpifV+tQVymQzmsgj8hY0lt18Ua+PShpVgwylj1MCrL J5NyUZjntEL5SoPGB5W1+mth4GO11A== X-Google-Smtp-Source: APXvYqy7Ahm6xsIBAxbvahe7MpZfFhmQrJUfui7MRkmuGNA2r+KtX7OKAP2SMxHgy3LSHG1zLsGv5aFPcA== X-Received: by 2002:a63:bd0a:: with SMTP id a10mr18703895pgf.55.1562109188555; Tue, 02 Jul 2019 16:13:08 -0700 (PDT) Date: Tue, 2 Jul 2019 16:13:02 -0700 Message-Id: <20190702231302.60727-1-nhuck@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH] arm64: mm: Fix dead assignment of old_pte From: Nathan Huckleberry To: catalin.marinas@arm.com, will@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_161311_782214_9A6E75F6 X-CRM114-Status: GOOD ( 11.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: clang-built-linux@googlegroups.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nathan Huckleberry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When analyzed with the clang static analyzer the following warning occurs line 251, column 2 Value stored to 'old_pte' is never read This warning is repeated every time pgtable.h is included by another file and produces ~3500 extra warnings. Moving old_pte into preprocessor guard. Cc: clang-built-linux@googlegroups.com Signed-off-by: Nathan Huckleberry --- arch/arm64/include/asm/pgtable.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index fca26759081a..42ca4fc67f27 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -238,8 +238,6 @@ extern void __sync_icache_dcache(pte_t pteval); static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) { - pte_t old_pte; - if (pte_present(pte) && pte_user_exec(pte) && !pte_special(pte)) __sync_icache_dcache(pte); @@ -248,8 +246,11 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, * hardware updates of the pte (ptep_set_access_flags safely changes * valid ptes without going through an invalid entry). */ + #if IS_ENABLED(CONFIG_DEBUG_VM) + pte_t old_pte; + old_pte = READ_ONCE(*ptep); - if (IS_ENABLED(CONFIG_DEBUG_VM) && pte_valid(old_pte) && pte_valid(pte) && + if (pte_valid(old_pte) && pte_valid(pte) && (mm == current->active_mm || atomic_read(&mm->mm_users) > 1)) { VM_WARN_ONCE(!pte_young(pte), "%s: racy access flag clearing: 0x%016llx -> 0x%016llx", @@ -258,6 +259,7 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, "%s: racy dirty state clearing: 0x%016llx -> 0x%016llx", __func__, pte_val(old_pte), pte_val(pte)); } + #endif set_pte(ptep, pte); }