From patchwork Mon Sep 28 12:44:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Bulwahn X-Patchwork-Id: 11803681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1CC392C for ; Mon, 28 Sep 2020 12:45:09 +0000 (UTC) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08DED221E8 for ; Mon, 28 Sep 2020 12:45:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="cd62cAy8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08DED221E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+36+4688437+8417402@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id G5iyYY4689772xpzhrBUasGl; Mon, 28 Sep 2020 05:45:08 -0700 X-Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by mx.groups.io with SMTP id smtpd.web12.35782.1601297107822227602 for ; Mon, 28 Sep 2020 05:45:08 -0700 X-Received: by mail-ej1-f67.google.com with SMTP id r7so8261555ejs.11 for ; Mon, 28 Sep 2020 05:45:07 -0700 (PDT) X-Gm-Message-State: l28NP8qQ3VyH2DfF2Puimhrbx4688437AA= X-Google-Smtp-Source: ABdhPJwrcAeGcgwC0x4c6zDkB9w6jAFa372e6W6yiAT/BrBcUqZaC6/RpiOAZ9gQGwQKzlOFDOyv0w== X-Received: by 2002:a17:906:1192:: with SMTP id n18mr1527579eja.515.1601297106102; Mon, 28 Sep 2020 05:45:06 -0700 (PDT) X-Received: from felia.fritz.box ([2001:16b8:2d9d:5000:7872:7299:adfa:b749]) by smtp.gmail.com with ESMTPSA id m4sm1589214ede.70.2020.09.28.05.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 05:45:05 -0700 (PDT) From: "Lukas Bulwahn" To: Balbir Singh , Thomas Gleixner Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, kernel-janitors@vger.kernel.org, linux-safety@lists.elisa.tech, Lukas Bulwahn Subject: [linux-safety] [PATCH -next for tip:x86/pti] x86/tlb: drop unneeded local vars in enable_l1d_flush_for_task() Date: Mon, 28 Sep 2020 14:44:57 +0200 Message-Id: <20200928124457.27289-1-lukas.bulwahn@gmail.com> Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech Delivered-To: mailing list linux-safety@lists.elisa.tech List-Post: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1601297108; bh=sk5rGTfRg6ZC1vOC0lVe/l7dAbjLuY0S//Icc1cMzqU=; h=Cc:Date:From:Subject:To; b=cd62cAy8rBprKHrMXmM6Z+s5ySE1xpuxxhz2nkBCu7A5uTwnnvDbtYe7RMiQmToS23/ +Ge/mwqKfXrlAUfE108yIJpp20wmRQvstT31PXchb1RDWZSLNh18FjmEe3ztIA2J2BjAK y2Enwz4xhYKAoJiuxQj1uqz3uIsq/PFoloI= Commit b6724f118d44 ("prctl: Hook L1D flushing in via prctl") checks the validity for enable_l1d_flush_for_task() and introduces some superfluous local variables for that implementation. make clang-analyzer on x86_64 tinyconfig caught my attention with: arch/x86/mm/tlb.c:332:2: warning: Value stored to 'cpu' is never read \ [clang-analyzer-deadcode.DeadStores] Compilers will detect these superfluous local variables and assignment and optimize this anyway. So, the resulting binary is identical before and after this change. Simplify the code and remove superfluous local variables to make clang-analyzer happy. No functional change. No change in binary with supported compilers. Signed-off-by: Lukas Bulwahn Reviewed-by: Nathan Chancellor --- applies cleanly on next-20200925 Balbir, please review and ack. Thomas, please pick this minor non-urgent clean-up patch into the x86/pti branch of tip as follow-up to: https://lore.kernel.org/lkml/160026187842.15536.285514864386042510.tip-bot2@tip-bot2/ I quickly confirmed that the binary did not change with this change to the source code; The hash of tlb.o remained the same before and after the change. So, in my setup: md5sum tlb.o 7c7e096bab0fd87bd2c8437d8c7dc3fa tlb.o linux-safety, please verify and validate this change. arch/x86/mm/tlb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 6b0f4c88b07c..90515c04d90a 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -316,7 +316,7 @@ EXPORT_SYMBOL_GPL(leave_mm); int enable_l1d_flush_for_task(struct task_struct *tsk) { - int cpu, ret = 0, i; + int i; /* * Do not enable L1D_FLUSH_OUT if @@ -329,7 +329,7 @@ int enable_l1d_flush_for_task(struct task_struct *tsk) !static_cpu_has(X86_FEATURE_FLUSH_L1D)) return -EINVAL; - cpu = get_cpu(); + get_cpu(); for_each_cpu(i, &tsk->cpus_mask) { if (cpu_data(i).smt_active == true) { @@ -340,7 +340,7 @@ int enable_l1d_flush_for_task(struct task_struct *tsk) set_ti_thread_flag(&tsk->thread_info, TIF_SPEC_L1D_FLUSH); put_cpu(); - return ret; + return 0; } int disable_l1d_flush_for_task(struct task_struct *tsk)