Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1217325ybj; Tue, 5 May 2020 15:38:48 -0700 (PDT) X-Google-Smtp-Source: APiQypKklcNgquzcbreRn1vtqJTpltqClB0+WE4ZusnLG2WrUd7UbJZWdZMplpIPHEru2wQC5elL X-Received: by 2002:a17:907:9c4:: with SMTP id bx4mr4698297ejc.199.1588718328497; Tue, 05 May 2020 15:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588718328; cv=none; d=google.com; s=arc-20160816; b=B/P5p5OtFTXDk7cmuCpkmrobvC72+L9RpfIE+bnmL/ZmBuNdP07iWzE5/i/cfcV1Ai UJuVYFyulclPqEDwBXrzbhsdoUxZ7AG+CpY0Y2tR4e22F8OtaHYV230xstoQ2KGu7RH7 fuLHt/7ij7SYUpQjrufYTDLDdK7TIv7a4MlRwAz562Zmhip4Ucj0NqdGs6Mm2zsqGh4E Tt8WP1wFJ09IBEAyj4OQZek88ZaMKuzn5UeyYeUXzq2kMOt5hc2FjHxK4KMEvPtFMswL cERDWvMYi+176S7YHCqSWAlCUCCACcE1sgGLku9Is2NkMEumYjWT+EFxVfzZXzz0f6md zUKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=2udYJ8+1lALOwUJWl4hDeQSRkiSoJ3spoJFibW98SzY=; b=ot18r2P4rpMbdLeiTPC9FKDm59YXfuZi6/0A2Yfc1XFxose+0SRzAma352L9//a2ww 8kmluCtgGRV/F3TF9tfKqwsvtvFsB/XIzxBpgrXUnhLAXZJ9FFVw8UzFtOChnVAjJXYo sRE5qkmsr2aMIaGJ5CEVQ25rmVNhJLczbcs6bwv9/Yz0lio6hhmGYVoxf/u9UGgX+vwp 0SrOAVf3j5cXo0JASojQi7uFpMtOTBQ/hUpjM2hN8OVEsABENo5bDbuI1PMIpelhY0W9 QKhc+PS4SeltKT4JL8nZkQ+ZzDo/84CwBFdbkTK4Vgy54LjhNAtS5GygPAYCEAVu2SbT zMjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v26si43227ejq.460.2020.05.05.15.38.25; Tue, 05 May 2020 15:38:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729507AbgEEWgz (ORCPT + 99 others); Tue, 5 May 2020 18:36:55 -0400 Received: from mga09.intel.com ([134.134.136.24]:41850 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729445AbgEEWgs (ORCPT ); Tue, 5 May 2020 18:36:48 -0400 IronPort-SDR: x199vza9tMpIx6AFpLuGPyZCjaTERDX/t1hpOkQ+l2q6H4/O4u1JacqRsxEgZVu0R0452sR1b8 xLNCWs4af/dg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2020 15:36:48 -0700 IronPort-SDR: fqaXLIkZ61EQWVuWyuNG+CuA+xxr8XBnas4doaa5e/L7MBHrQXsp6wxCKJZhawSXJa1tMSwfdW KAYIB/Rl/Chw== X-IronPort-AV: E=Sophos;i="5.73,357,1583222400"; d="scan'208";a="284410858" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2020 15:36:47 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com Cc: kuo-lang.tseng@intel.com, mingo@redhat.com, babu.moger@amd.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , Borislav Petkov Subject: [PATCH V2 6/7] x86/resctrl: Support CPUID enumeration of MBM counter width Date: Tue, 5 May 2020 15:36:17 -0700 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The original Memory Bandwidth Monitoring (MBM) architectural definition defines counters of up to 62 bits in the IA32_QM_CTR MSR while the first-generation MBM implementation uses statically defined 24 bit counters. Expand the MBM CPUID enumeration properties to include the MBM counter width. The previously undefined EAX output register contains, in bits [7:0], the MBM counter width encoded as an offset from 24 bits. Enumerating this property is only specified for Intel CPUs. Suggested-by: Borislav Petkov Signed-off-by: Reinette Chatre --- arch/x86/include/asm/processor.h | 3 ++- arch/x86/kernel/cpu/resctrl/core.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 3bcf27caf6c9..c4e8fd709cf6 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -113,9 +113,10 @@ struct cpuinfo_x86 { /* in KB - valid for CPUS which support this call: */ unsigned int x86_cache_size; int x86_cache_alignment; /* In bytes */ - /* Cache QoS architectural values: */ + /* Cache QoS architectural values, valid only on the BSP: */ int x86_cache_max_rmid; /* max index */ int x86_cache_occ_scale; /* scale to bytes */ + int x86_cache_mbm_width_offset; int x86_power; unsigned long loops_per_jiffy; /* cpuid returned max cores value: */ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index d5979073301e..12f967c6b603 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -964,6 +964,7 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c) if (!cpu_has(c, X86_FEATURE_CQM_LLC)) { c->x86_cache_max_rmid = -1; c->x86_cache_occ_scale = -1; + c->x86_cache_mbm_width_offset = -1; return; } @@ -980,6 +981,10 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c) c->x86_cache_max_rmid = ecx; c->x86_cache_occ_scale = ebx; + if (c->x86_vendor == X86_VENDOR_INTEL) + c->x86_cache_mbm_width_offset = eax & 0xff; + else + c->x86_cache_mbm_width_offset = -1; } } -- 2.21.0