Received: by 10.223.185.116 with SMTP id b49csp1380800wrg; Wed, 14 Feb 2018 16:33:02 -0800 (PST) X-Google-Smtp-Source: AH8x224qYTYdxLXFPSPK7STkiQjFb9KG87pVxHK3SBY5WtVLChp3TKyTVnAeMAFKNPmT2Dr+KTSZ X-Received: by 10.99.122.70 with SMTP id j6mr658986pgn.17.1518654782857; Wed, 14 Feb 2018 16:33:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518654782; cv=none; d=google.com; s=arc-20160816; b=07AortT1I/NPT8b9eHOEW0+ANz8fNUlfnlv9OoiX7OnmrRgSdbfD/0MDqe0sXDaba/ ZOnQje5ql6kzP5O/mhuaAE4hetAs/ktv3hM/D7pK2j6UBqkP8Nj+5Mp74ZuAp2XROAHd NLUcuJSCygD/hgs9GgjExe5UPFaeebScPKt/9VwZ7sbEVQUANqsf0LaX4x4DT0DDPImM wXXSmXNsQlr1ESE70N8aAL4ztP8xhSg1TAnk1caBKk2VNTQ0+cTov0hg9FfqRWKYJlHR gaMgXZDy/uTUayw+hAxL/f82yHaB/G38WY3b9z8FTpwkKEGss9Qk+z9qVIG2BYOTj7fY DtgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=Iy1+aFoOgPAU+zehF86El646n8x6nOt/al9kv8D9scU=; b=ih/YTSmfRO5Rw4vIJUhjgjGihhuaL63iW33QQ64CDBcpPAK1tUJfJnbKgoaaMfBRyO cpmL+0vEF1OmGzU39QAos5fpZbWzb9Ot6wFDX9LziRaIOIeqXcUmtgrg0RXAII9z5I8Q OtLHh+k+CtCNo0ysmqqndKktecxQBTd5pwpKaj/+n3W/2rcZM72P6xDul7HE3xKkZ+D0 BjMfgj+oC6NNzytONFp3uBIchW09fQA2W1JGHNDx7rFWLIYnmlFSa2+WHotKPQYfy2Ek 3iNtcKzsxr4Avs9Bn74crp0udOsguTrYwUb+IF6ztfLIHDZ0A0X/P5xaMPVf0dXPDSQV f5/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5-v6si2199543pln.274.2018.02.14.16.32.48; Wed, 14 Feb 2018 16:33:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032325AbeBOAb1 (ORCPT + 99 others); Wed, 14 Feb 2018 19:31:27 -0500 Received: from terminus.zytor.com ([198.137.202.136]:46409 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032189AbeBOAbZ (ORCPT ); Wed, 14 Feb 2018 19:31:25 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1F0UmHQ012434; Wed, 14 Feb 2018 16:30:48 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1F0UlAi012430; Wed, 14 Feb 2018 16:30:47 -0800 Date: Wed, 14 Feb 2018 16:30:47 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: "tip-bot for Gustavo A. R. Silva" Message-ID: Cc: bp@alien8.de, garsilva@embeddedor.com, linux-kernel@vger.kernel.org, hpa@zytor.com, torvalds@linux-foundation.org, mingo@kernel.org, tglx@linutronix.de, peterz@infradead.org Reply-To: linux-kernel@vger.kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de, garsilva@embeddedor.com, bp@alien8.de In-Reply-To: <20180213192208.GA26414@embeddedor.com> References: <20180213192208.GA26414@embeddedor.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/cpu: Change type of x86_cache_size variable to unsigned int Git-Commit-ID: 24dbc6000f4b9b0ef5a9daecb161f1907733765a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 24dbc6000f4b9b0ef5a9daecb161f1907733765a Gitweb: https://git.kernel.org/tip/24dbc6000f4b9b0ef5a9daecb161f1907733765a Author: Gustavo A. R. Silva AuthorDate: Tue, 13 Feb 2018 13:22:08 -0600 Committer: Ingo Molnar CommitDate: Thu, 15 Feb 2018 01:15:53 +0100 x86/cpu: Change type of x86_cache_size variable to unsigned int Currently, x86_cache_size is of type int, which makes no sense as we will never have a valid cache size equal or less than 0. So instead of initializing this variable to -1, it can perfectly be initialized to 0 and use it as an unsigned variable instead. Suggested-by: Thomas Gleixner Signed-off-by: Gustavo A. R. Silva Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Addresses-Coverity-ID: 1464429 Link: http://lkml.kernel.org/r/20180213192208.GA26414@embeddedor.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/cpu/microcode/intel.c | 2 +- arch/x86/kernel/cpu/proc.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index b7c8583..44c2c4e 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -109,7 +109,7 @@ struct cpuinfo_x86 { char x86_vendor_id[16]; char x86_model_id[64]; /* in KB - valid for CPUS which support this call: */ - int x86_cache_size; + unsigned int x86_cache_size; int x86_cache_alignment; /* In bytes */ /* Cache QoS architectural values: */ int x86_cache_max_rmid; /* max index */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index a7d8df6..824aee0 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1184,7 +1184,7 @@ static void identify_cpu(struct cpuinfo_x86 *c) int i; c->loops_per_jiffy = loops_per_jiffy; - c->x86_cache_size = -1; + c->x86_cache_size = 0; c->x86_vendor = X86_VENDOR_UNKNOWN; c->x86_model = c->x86_stepping = 0; /* So far unknown... */ c->x86_vendor_id[0] = '\0'; /* Unset */ diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index b94279b..a15db2b 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -982,7 +982,7 @@ static struct microcode_ops microcode_intel_ops = { static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c) { - u64 llc_size = c->x86_cache_size * 1024; + u64 llc_size = c->x86_cache_size * 1024ULL; do_div(llc_size, c->x86_max_cores); diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c index ee4cc38..2c8522a 100644 --- a/arch/x86/kernel/cpu/proc.c +++ b/arch/x86/kernel/cpu/proc.c @@ -91,8 +91,8 @@ static int show_cpuinfo(struct seq_file *m, void *v) } /* Cache size */ - if (c->x86_cache_size >= 0) - seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); + if (c->x86_cache_size) + seq_printf(m, "cache size\t: %u KB\n", c->x86_cache_size); show_cpuinfo_core(m, c, cpu); show_cpuinfo_misc(m, c);