From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E31E2D3748
	for <linux-kernel@vger.kernel.org>; Mon, 21 Jul 2025 18:01:10 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1753120871; cv=none; b=A5pkTQookQtzzNczkr2wPQ+6a1zc0E+DuWKwbI3vYUhWBxO6Xg6brljU36pUj3D56U9Dx8atQekGRReUZZ9ahnmQEMPI+LneyhMAuFSq+QuigIN4y2AqKXU2MUjSX6CIi3KAcu7LG6YaCXgT6acDyt0ig+mPe69mYEI0dtQKTII=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1753120871; c=relaxed/simple;
	bh=pFi0iNg20dO512kniaVlxq0eQv3JXBjCcE9+ainODKU=;
	h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=LEWPqN3IYJ5DVFF4nk97x9ajR/qeNX9PtmwXXyefWjKFkw6/8helw0Er6r0yhkpY8Yd+qa2UuVh12SfRPr29x2rtfFIVhVfSRbgdhoW0AFjGp2OVPA21aUT+2hLgQITATrRNQcnmlrF+JAK5QpI5P3TnYSCLjBCQzFhgqx4LGXM=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--brho.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GBKxpzo4; arc=none smtp.client-ip=209.85.216.74
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--brho.bounces.google.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GBKxpzo4"
Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3132c1942a1so6216226a91.2
        for <linux-kernel@vger.kernel.org>; Mon, 21 Jul 2025 11:01:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20230601; t=1753120870; x=1753725670; darn=vger.kernel.org;
        h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject
         :date:message-id:reply-to;
        bh=nkwILaoRvCGTt3850C+OpAJVMyb+bC6KByMj+ffuFyY=;
        b=GBKxpzo4jIZzmsmtFRmy4Ai2ztTkE98/cfShd+T5qQuDogeuTHR/0v/T8cuuvx7tXN
         pzXluF6ypAH2eIGEzMVPA8zw5LArsc6TwjRtMkb6FYgVHQ6YCGkexRtezOC2JgY4jzds
         GNrGI5OABDpr3XletwY2aHwiP7LISWu8uVkQBmyVmMmzfz+Us+GOSwVn7zkSTRnPmV6B
         sgWNpB+4r00Q0RXlSWBh2r9n80707UoYI9TDHlKf9p0Tzyf4EQwP/WQPrm1rj4+7WkVy
         J82EvENiGsMkKSXhRegPHV55Ceg0iMxSFrm0SPAZLN66X7ssLH2P7uaMiYb9PXbU6Bhm
         QfDA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1753120870; x=1753725670;
        h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state
         :from:to:cc:subject:date:message-id:reply-to;
        bh=nkwILaoRvCGTt3850C+OpAJVMyb+bC6KByMj+ffuFyY=;
        b=fdC8xsr9X7X0WafjSPX+4vWUOn7m64zFCHQK3sk18Xm7u0yCVkyil5IuB6/Rg6DOuS
         ++9ikhQRXf3tEdq+CxOxX0vjibBC7+NuQCmRT2NzSDWz3fN9rRNtvv8kzE/k7fwbJIKc
         RZVbKX7G2MEnvKxlQFSu+RztL+Vf3F8lv+5c6qp/MTC4DrRyq2OFlA9D/dU9BbcJLNTA
         xMI9fq4nVoPHi1BeiJS4l8xdbeSEKmLLEwjWDPpBQG2o8JD7m5pfg75ozZGp+Tv6t2I6
         DtWYy8EY38LJOfktae7wuzhGj4E50JLPU7CHAKxoJfE/Xb2z3BwAWc57GUrOljgIFn5w
         L55g==
X-Forwarded-Encrypted: i=1; AJvYcCUfuHYO8DJWOUgcNKIdQNBFAlGxlc1RIIQCg7gFuEINULrocp2iuA6UbFqn5xiDsyXwQ2suIW4AUcayh8c=@vger.kernel.org
X-Gm-Message-State: AOJu0YxqUkxoq6b627332RT5XiUrGE1prb/rDShXGee8I0TvOGsXaqte
	i2qg1DpHuSPAxGu/endYLPp9o2yJ87mrHhIh0AoGLzieg2ygxO4kaEt34/uDyEQ90UAiRLEPKw=
	=
X-Google-Smtp-Source: AGHT+IEMVgugN4IL+CFFSpkR2FwGQ9XHs+U2c8+mJb7PyriwEGtvZrHfeHjlWf5Bk3t3+bv1LkyTurDn
X-Received: from qkab26.prod.google.com ([2002:a05:620a:89a:b0:7e0:f93f:98db])
 (user=brho job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:4892:b0:7e3:54d8:3fdd
 with SMTP id af79cd13be357-7e354d84002mr1925664085a.16.1753120857996; Mon, 21
 Jul 2025 11:00:57 -0700 (PDT)
Date: Mon, 21 Jul 2025 18:00:47 +0000
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
Mime-Version: 1.0
X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog
Message-ID: <20250721180051.3645697-1-brho@google.com>
Subject: [PATCH] x86/resctrl: avoid divide by 0 num_rmid
From: Barret Rhoden <brho@google.com>
To: Tony Luck <tony.luck@intel.com>, Reinette Chatre <reinette.chatre@intel.com>
Cc: Dave Martin <Dave.Martin@arm.com>, James Morse <james.morse@arm.com>, 
	linux-kernel@vger.kernel.org
Content-Type: text/plain; charset="UTF-8"

x86_cache_max_rmid's default is -1.  If the hardware or VM doesn't set
the right cpuid bits, num_rmid can be 0.

Signed-off-by: Barret Rhoden <brho@google.com>

---
I ran into this on a VM on granite rapids.  I guess the VMM told the
kernel it was a GNR, but didn't set all the cache/rsctl bits.

 arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index c261558276cd..226dee05f96e 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -359,6 +359,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 	else if (mbm_offset > MBM_CNTR_WIDTH_OFFSET_MAX)
 		pr_warn("Ignoring impossible MBM counter offset\n");
 
+	if (r->num_rmid < 1) {
+		pr_warn("Invalid num_rmid %d, cach_max_rmid was %d\n",
+			r->num_rmid, boot_cpu_data.x86_cache_max_rmid);
+		r->num_rmid = 1;
+	}
+
 	/*
 	 * A reasonable upper limit on the max threshold is the number
 	 * of lines tagged per RMID if all RMIDs have the same number of
-- 
2.50.0.727.gbf7dc18ff4-goog


From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C8A22E36FD
	for <linux-kernel@vger.kernel.org>; Tue, 22 Jul 2025 18:20:20 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.20
ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1753208423; cv=fail; b=apMxQpK7Y15eWyfg0jBgyAFnA2pzcYfpUyTdUiVX/M8WkM/+zBC8kQm0DM6oGx8fbZOSFWwnNshjufZtwijcYXZLPIXbgxrQWQM0bKL/l1dTWo0c78HlZ4rqj//j3B50W+HeJS9JQtuTrV369Sl+yiVCuTK1clXt6YJCZ7PIzUw=
ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1753208423; c=relaxed/simple;
	bh=PoFPdY4M1QRGJLIAsxwvjJjURUe60I9R5KiWZOWJUiM=;
	h=Message-ID:Date:Subject:To:CC:References:From:In-Reply-To:
	 Content-Type:MIME-Version; b=Q/mUm2PpzrCRwlAgmOLvrK+We2Qk8kIRmUp/5QYo5m+wr9V1D4xXtx8Mkm16Jzt3FZ0/Jx1LCc4xryO517MShGxcAB78wfnv19uuoyuaRk++rdIsY918Q0OrRaosIUVnjv0xYgpP+FHTeBA+ewYehTT+dRLQsds0lWDcjxYSDUA=
ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DWjgBkkd; arc=fail smtp.client-ip=198.175.65.20
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DWjgBkkd"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1753208422; x=1784744422;
  h=message-id:date:subject:to:cc:references:from:
   in-reply-to:content-transfer-encoding:mime-version;
  bh=PoFPdY4M1QRGJLIAsxwvjJjURUe60I9R5KiWZOWJUiM=;
  b=DWjgBkkdKb9aIpBH/TmBcelpGeZTibpLhRgUvs2Y9o1HDu2Ux5XnsKpf
   ONE8ZFlN27vz10a6U1N1biLwMLLMoGlQx2AMeJlP9FBo9R9t8a97PE/pF
   jQc4lZz70cyTl/BBsgkm4hegIjyoR5NsbttA/jCmVTrf8In5NDDgjci9I
   eh9WpIHn5F4giwho9d+/eApfqJA//ApqfSh4Y3MZOiNG94U4iCIBKfooq
   W4hT2A1PiDmj+iqZOTWKjahCy+1dpSlwXnv181Rh78qWUwgRXN1iaddLT
   Hdfvn++AN/koUUFYI0YkoHASjB9x1ussCgGlEEo55g0XrybXcntgzkrxs
   Q==;
X-CSE-ConnectionGUID: J9wCTw22SsaaNbzHZwtpMA==
X-CSE-MsgGUID: glXhVu2rQYWpK1GI/fRmRg==
X-IronPort-AV: E=McAfee;i="6800,10657,11500"; a="55179389"
X-IronPort-AV: E=Sophos;i="6.16,332,1744095600"; 
   d="scan'208";a="55179389"
Received: from orviesa010.jf.intel.com ([10.64.159.150])
  by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2025 11:20:20 -0700
X-CSE-ConnectionGUID: 56uLI95DS+iKmyao+AiE3Q==
X-CSE-MsgGUID: uesW/cryRNmI1VQhCSZ9dA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.16,332,1744095600"; 
   d="scan'208";a="158512704"
Received: from orsmsx902.amr.corp.intel.com ([10.22.229.24])
  by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2025 11:20:19 -0700
Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by
 ORSMSX902.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1748.26; Tue, 22 Jul 2025 11:20:19 -0700
Received: from ORSEDG901.ED.cps.intel.com (10.7.248.11) by
 ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1748.26 via Frontend Transport; Tue, 22 Jul 2025 11:20:19 -0700
Received: from NAM04-MW2-obe.outbound.protection.outlook.com (40.107.101.49)
 by edgegateway.intel.com (134.134.137.111) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1748.26; Tue, 22 Jul 2025 11:20:19 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=vs6/t44Nx4iv6XCKPA2sjpXOpNTt7rO+Pim/gjPH/euF1E2cE5pcpwD+IBerLyBufCEyyjHN7Z2oyt4RqyJ8McxmRPmvOx9bG8d7vwnifKw9vwDnoHQN2izjZ1+OAzOg+t2qihgmN5WSDwOf8VF8YzpOzjoegY24div0F8FCnEldgIEaCdNLnaCFEAcxJ5W45+/lXKJj5ZXqm72Xypri7Zbf7b+ybpP03d9lJApZ86E29G0iaN7NYYB0Nkv5wUQPMHuzmYj8t5Rfgr00pchAX+TR/5wM5CB6R7KYyAFJ08TFrOkWAAty20pwMvWFJVYdY6qjgi5ZyW6RHhXzXW/qow==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=oyFI8nFMUWVko4wn9koGO7RIyx4m/oeroILmuMJ1uRw=;
 b=Q3THXx+wowgB4UHZLq/EF9Q0hkMBZRd3kPmN1uNiTnON05Jjwq5EPQSiaLmnh0XPmSBI8XohnZtj+I3WqlIMqzUem8Y8YD5YLlk4zqZS2hODfFoLkw8wNSYORqERtm5PAMAyp4fegwmO0fDfmobcUO9sbYQ46BQ9yFLwoNuUAAEqnSfxwtExQeUxFd7e1rNJ5ikvyEUWeX3xbKg+Xwu7vxk3bQCQZJIoCRIfexPy7DT0vs/X7NeTKohglTbdCin/yMraqTXx6qEPDmXAApoUKZvElOAh+rnC1fCD7kn/uKhILwqvHoL5zcXdh41pXWQ6ELlV5IY38REKJ20yKtCaBw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
Authentication-Results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=intel.com;
Received: from SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10)
 by DM3PPF4D011AE7D.namprd11.prod.outlook.com (2603:10b6:f:fc00::f20) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8943.24; Tue, 22 Jul
 2025 18:20:00 +0000
Received: from SJ2PR11MB7573.namprd11.prod.outlook.com
 ([fe80::61a:aa57:1d81:a9cf]) by SJ2PR11MB7573.namprd11.prod.outlook.com
 ([fe80::61a:aa57:1d81:a9cf%4]) with mapi id 15.20.8943.028; Tue, 22 Jul 2025
 18:20:00 +0000
Message-ID: <c4518fe2-dce3-46d1-8d79-cd63377bdcad@intel.com>
Date: Tue, 22 Jul 2025 11:19:58 -0700
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] x86/resctrl: avoid divide by 0 num_rmid
To: Barret Rhoden <brho@google.com>, Tony Luck <tony.luck@intel.com>
CC: Dave Martin <Dave.Martin@arm.com>, James Morse <james.morse@arm.com>,
	<linux-kernel@vger.kernel.org>, "x86@kernel.org" <x86@kernel.org>
References: <20250721180051.3645697-1-brho@google.com>
Content-Language: en-US
From: Reinette Chatre <reinette.chatre@intel.com>
In-Reply-To: <20250721180051.3645697-1-brho@google.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-ClientProxiedBy: MW4PR03CA0213.namprd03.prod.outlook.com
 (2603:10b6:303:b9::8) To SJ2PR11MB7573.namprd11.prod.outlook.com
 (2603:10b6:a03:4d2::10)
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: SJ2PR11MB7573:EE_|DM3PPF4D011AE7D:EE_
X-MS-Office365-Filtering-Correlation-Id: 3a524324-f0e7-47c9-1ffb-08ddc94c5eb2
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7053199007;
X-Microsoft-Antispam-Message-Info: =?utf-8?B?TVpHN2dWOEhyRWgyWG0yVGF1Q2JvRkFBS1d5MzExRndQQkVTMWdra3RpSWlo?=
 =?utf-8?B?VEJpeE5iOWE1b3Bvay84U3I5NVBlbDRoQndKL1VDZHRHZlZuWEJOY0xBM3Bx?=
 =?utf-8?B?djh4UUluQ0ROVTZ4KzVuT3ZsY1RuN2hpeGpLaC9wZTZBMlYrdllPUW1iTHhq?=
 =?utf-8?B?NkFCS1MzMDZTYkVsZi9HRlFQNWhPZ3N0SHJRU1AvaUJGbkZuYUs3VGdadHRT?=
 =?utf-8?B?MlZjUmNIUGxHem9CQ2U4WEM2NjZnWTF1RDJydE5uNXVxdEpSUUd1WXFNWUNi?=
 =?utf-8?B?bVVSMThVTUZsMm1mT0dDaWhHWjhMaFVkb2ttM3FkdzZWZzlGbTNnbmp5SGM4?=
 =?utf-8?B?aEZNbE1Zb3pRSHNpSHVzWkw4TThRVTQ1blJURFBTYVZVUWhtQ0R0cHRTTHBH?=
 =?utf-8?B?YzBpZmUvZ0FQcWNEbEIrTUV5QzY5RVczdG5MNnJINi9ZMzhqWGs4cXlUUUU2?=
 =?utf-8?B?a0FsZDN1NkIrMFZJNGpx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BHVFVHTmxNa1lETEdmTmRy?=
 =?utf-8?B?SUJLQWtqejI5TTJRYlNjNkRRaHNuUkFmTjlNWmFjdTFlZ3R6T04rV01mSTYv?=
 =?utf-8?B?NzN3TnZCVnk0NEozbVFLTzlrUVAxTDJ4NnRhalJlUjJUUTFXNlAxTUNwUlMz?=
 =?utf-8?B?VVc3WHpobGJrWnRLZmJSMGFMMlhQR3JJV3BHTU5qa0RFK21FZWlRRThqamNh?=
 =?utf-8?B?bzJVWnVqSmlyZWNBTmNBS01uaWNubkVZcG1nNDV3enFCZHpXekc1OExMeHJY?=
 =?utf-8?B?NDBUWmJ5cE9aVVVwQjBlYmVIQ0xYM3JXYk83Qjl1TytqVGRaZ2xwVGp1OTFV?=
 =?utf-8?B?QUJDS1AxbEx3Q25VRGxCVnQ5NW8rcnhyTWg5OEUzYXA2bXdzcGJjL0FBWDJm?=
 =?utf-8?B?em5kVmxncWR6ZlJvOFo5UlRtcjZzT0R6MW9mOHUzUDZIQzJmYm15WG1TWi9t?=
 =?utf-8?B?cE93RERTSk9XZ01jL01HQ2NMeitzTEo3bXJ0SkIyZXJMSTdGWXBDdzNrYWZi?=
 =?utf-8?B?QVpvNVZvWFhhSVp0aWhUVXVvWExmbHRNVGVOc3plRjdUOEQ2YWJaRThVMzlC?=
 =?utf-8?Q?m6pXFG496Es=3D?=
X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR11MB7573.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7053199007);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cUlGK3QwakRkQmxVU29ZQTJtcndRNm9HSVllc2d1bVphRnNUbldOSUF6Y1R6?=
 =?utf-8?B?M3NCeWVnV0VXU2FPM1VFTVFPZ2JyOTlXZ01tZW1nV3NN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WmN5MXpnQ0VOaVRzUDlqdXRqM0FURmJ0QVVSWW9Z?=
 =?utf-8?B?eDJkeGY1U2JHeVZuSXRJRzY2SFFsZFRadG9kQmVqdWhIYVpXWGlJTThZeHlk?=
 =?utf-8?B?aVFPMk94djUyNkV6bndLOVpYdHgzYmxmNnI2OUxnQ3lZSUtsbC8wcElwblFy?=
 =?utf-8?B?VWFIUEZwTlExNWhJV29pRGF6K3JmanFjU1RMcVFhZGFldWZoTGtCUlRGVUh3?=
 =?utf-8?B?a25BbGdSWVhyYk4yWVRZbStRbmNnU2N0VzdYSzFTbnhxU1diV21OMTllSEFk?=
 =?utf-8?B?bU02U0FqV1ZMMS9tWVU2UHZla1ZBNTZrK2RIbTFaa3JrdFJhbVdyRW9kL3gw?=
 =?utf-8?B?SEE9PQ==?=
X-MS-Exchange-CrossTenant-Network-Message-Id: 3a524324-f0e7-47c9-1ffb-08ddc94c5eb2
X-MS-Exchange-CrossTenant-AuthSource: SJ2PR11MB7573.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2025 18:20:00.1630
 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: ak/j2wFYZZs46+dcsS6eBm6ochJ+V6PUY3c9lfmT1/9lMhzFVRpb1oUWb6iXog5Qhgm5q/Izc49TVTJAn5D8mZFm8QiykNuea9l5+cDRUTI=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PPF4D011AE7D
X-OriginatorOrg: intel.com

Hi Barret,

On 7/21/25 11:00 AM, Barret Rhoden wrote:
> x86_cache_max_rmid's default is -1.  If the hardware or VM doesn't set
> the right cpuid bits, num_rmid can be 0.
> 
> Signed-off-by: Barret Rhoden <brho@google.com>
> 
> ---
> I ran into this on a VM on granite rapids.  I guess the VMM told the
> kernel it was a GNR, but didn't set all the cache/rsctl bits.
> 

The -1 default of x86_cache_max_rmid is assigned if the hardware does not
support *any* L3 monitoring. Specifically:

resctrl_cpu_detect():
	if (!cpu_has(c, X86_FEATURE_CQM_LLC)) {
		c->x86_cache_max_rmid  = -1;
		...
	}

The function modified by this patch, rdt_get_mon_l3_config() only runs if
the hardware supports one or more of the L3 monitoring sub-features
(X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL, or
X86_FEATURE_CQM_MBM_LOCAL) that depend on X86_FEATURE_CQM_LLC per cpuid_deps[].

I tried to reproduce the issue on real hardware by using clearcpuid to
disable X86_FEATURE_CQM_LLC and the CPUID dependencies did the right thing
by automatically disabling X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL, 
X86_FEATURE_CQM_MBM_LOCAL, not running rdt_get_mon_l3_config() at all, and
not even attempt to enumerate any of the L3 monitoring details.

What are the symptoms when you encounter this issue?

Would it be possible to send me the CPUID flags of leaf 7, subleaf 0 as
well as all sub-leaves of leaf 0xF?

Could you please also elaborate what the impact of this issue is? Is this
a VM that has been released with many users impacted or something encountered
during development of this VM?

>  arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index c261558276cd..226dee05f96e 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -359,6 +359,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
>  	else if (mbm_offset > MBM_CNTR_WIDTH_OFFSET_MAX)
>  		pr_warn("Ignoring impossible MBM counter offset\n");
>  
> +	if (r->num_rmid < 1) {
> +		pr_warn("Invalid num_rmid %d, cach_max_rmid was %d\n",
> +			r->num_rmid, boot_cpu_data.x86_cache_max_rmid);
> +		r->num_rmid = 1;

I do not think enumeration of this feature should proceed/succeed if there clearly
is a configuration issue.

> +	}
> +
>  	/*
>  	 * A reasonable upper limit on the max threshold is the number
>  	 * of lines tagged per RMID if all RMIDs have the same number of

Reinette

From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98D0C283FD8
	for <linux-kernel@vger.kernel.org>; Tue, 22 Jul 2025 18:51:25 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1753210287; cv=none; b=fPSBEBQGkJpGc+Icz8BPfoMHSBOpTLSo8XnXAb0CnrkwGR462y+FTOBV04GuK9cewDBSY5436iQ2QoLS1O1+53QBQWgytf9a3QcZHtzsFJp6TWce1z2E1KXbPc7pZTWsnXGHx7sgFOTj3MnWzbhL01FzI2SVAyKE85qSVnocisk=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1753210287; c=relaxed/simple;
	bh=0gJflN5+ftncUl1+V5yfeO9DL6q4suunebrkcoCQ1SQ=;
	h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:
	 In-Reply-To:Content-Type; b=f7AKROwfcNkoCSsY52stBLKsl1YSLLo6MjaOsaZI3ZtvvHJPpY7j7SBdpZDK6WKFsJMy7JrridaaVLadOprLsJaHg6L2VrPeKRkNkmsxPNoLoRwH1enSNOzY+maEBNWR8HhLIrVmR4mhta5g3j0sDsrG11zXDAv4dC0XzH9kM+4=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IKvDLxuP; arc=none smtp.client-ip=209.85.160.180
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IKvDLxuP"
Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-4ab3ad4c61fso77701cf.0
        for <linux-kernel@vger.kernel.org>; Tue, 22 Jul 2025 11:51:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20230601; t=1753210284; x=1753815084; darn=vger.kernel.org;
        h=content-transfer-encoding:in-reply-to:content-language:from
         :references:cc:to:subject:user-agent:mime-version:date:message-id
         :from:to:cc:subject:date:message-id:reply-to;
        bh=Y4v/0bSm2eOQeRU/QVLO9OgyL4pkFF+iWSGFdfVifOE=;
        b=IKvDLxuPSJxIJBBStDUOAeBr0YMs85ALIEYoBVb1g8eoB+Sf75MrpJbiaSXSwSbE5b
         ep350QhIsBc5JnfNVF73u7MtF9YybgeVVcOGu+7/Rg7mjOC62QxdN2oEJqzyadACXUjn
         +ofRRN09DFisBFlyBrSSAev1XB1rE2WjkDB0glY+UwrMHJ6d9PlTkTAheMOyyzfFeiIN
         9jP5e7oU2/Us/hbaSk1JW9XWWOeg+2/+Dx99uAo/a19W+iAu9BtAdE4t4aUP12decs06
         yYn7hFz0VdsCWmvKPAQ41gFPpUyQY6lOMSya56/8ga3aW876db28336KhbAyEQqLGTBe
         4Thg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1753210284; x=1753815084;
        h=content-transfer-encoding:in-reply-to:content-language:from
         :references:cc:to:subject:user-agent:mime-version:date:message-id
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
        bh=Y4v/0bSm2eOQeRU/QVLO9OgyL4pkFF+iWSGFdfVifOE=;
        b=fApSJno2W3pxbffWbVgUUaoTmq76R5W9kffcM2/xRBCDYF0OLFKxZscMPSLU7KUdVD
         3oUH2c8VGLPtsfAANHH223nGrh7jpmmYSRDUyml7kr8TESffIdJpluHxEGdJ4X2lZYYv
         LtyugrXQjb9Im4SY/sYVv/JNZNVAUUegUu0Bf0YOqmlwFWx3ca6rV80gN7be/tsVWtTx
         f1BnDkOMH+rqlcdJoBBh5WUomzKdaZTqA/Frfby17Q0OrR1bkuwpMmwFc1nT88sIJIfH
         Y1Qg2PmHGLl2QQLcnbo8QltceChQ5Rsjnrp45IVu1Fzu6zxwYRJYf+GfB611pbYI57qR
         G63A==
X-Forwarded-Encrypted: i=1; AJvYcCWkCC+io1NecNr56Ztet3bRYahYQ3GF+4sHz7AGKyAPbPB61zOAPA7+aiFYOivkXl67DyibwpsVgqmpbro=@vger.kernel.org
X-Gm-Message-State: AOJu0YwsEpiQn/uIxznsNHkt8xS3CyCoENVbtbrRfLvMlf+D8RHA2U3d
	RHxO/78GYPC/k5p7Y0GZTkPiPId7n4BdTeLEuE3M5JXYZXL66ltM2Km3cp1C7sUfA91Q1KNa4sN
	G3LOp0j0e
X-Gm-Gg: ASbGncvI5p4Evv0SBsbQ/30bO5Wbr6tWk8Qymrli4K9SriK5SoEu/0Dh4IZTn7o8AKn
	qVA0nX84pUXztFdKV8Fo0XaSXY2W70J5Y4ZfbUtOdZiJ8qpbg3mN5AFid+cSheU+l8UKGiEmUU4
	gCXxMpNAehBhNNiLDiJr8AT/QHDvtu4bs01x/rDxvVuSPsGQruQhNhQLbGnFPE8YOhlK5GyvhW8
	hJHnRF/Fyfj3Kccnzc3Tk+rGVnrByVZFH5aQ/CZS3A8a0lTlC1oV0TTDqLOGlPQmkePlRcsi9DD
	eys/Xofruowl2p4O14K3+QM7RAkR3W0SYwdI03XyV0OivaCT2DepiGm0Y8pqvDaiTEMae1KiUgZ
	Zwr05zobNMSbqRnK9G6qk+fiItwRiNOIQ4Pfya2/g8rVuRidLgRB7UEBpSjlS
X-Google-Smtp-Source: AGHT+IHlSLCdiZvSP/je7fwpuEm0Rkobn5lZYibCSnHYZ1wOnpR0k9uvVTjSvbsymnzgnmsfE/Qdsg==
X-Received: by 2002:a05:622a:a547:b0:497:75b6:e542 with SMTP id d75a77b69052e-4ae6d77cb7bmr374721cf.10.1753210283624;
        Tue, 22 Jul 2025 11:51:23 -0700 (PDT)
Received: from [192.168.1.31] (d-24-233-113-28.nh.cpe.atlanticbb.net. [24.233.113.28])
        by smtp.gmail.com with ESMTPSA id d75a77b69052e-4abb499fea2sm57461881cf.22.2025.07.22.11.51.22
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Tue, 22 Jul 2025 11:51:22 -0700 (PDT)
Message-ID: <dcc38ba0-cbb4-494e-bc10-2df2b4aa2cb0@google.com>
Date: Tue, 22 Jul 2025 14:51:21 -0400
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] x86/resctrl: avoid divide by 0 num_rmid
To: Reinette Chatre <reinette.chatre@intel.com>
Cc: Tony Luck <tony.luck@intel.com>, Dave Martin <Dave.Martin@arm.com>,
 James Morse <james.morse@arm.com>, linux-kernel@vger.kernel.org,
 "x86@kernel.org" <x86@kernel.org>
References: <20250721180051.3645697-1-brho@google.com>
 <c4518fe2-dce3-46d1-8d79-cd63377bdcad@intel.com>
From: Barret Rhoden <brho@google.com>
Content-Language: en-US
In-Reply-To: <c4518fe2-dce3-46d1-8d79-cd63377bdcad@intel.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 7/22/25 2:19 PM, Reinette Chatre wrote:
> Hi Barret,
> 
> On 7/21/25 11:00 AM, Barret Rhoden wrote:
>> x86_cache_max_rmid's default is -1.  If the hardware or VM doesn't set
>> the right cpuid bits, num_rmid can be 0.
>>
>> Signed-off-by: Barret Rhoden <brho@google.com>
>>
>> ---
>> I ran into this on a VM on granite rapids.  I guess the VMM told the
>> kernel it was a GNR, but didn't set all the cache/rsctl bits.
>>
> 
> The -1 default of x86_cache_max_rmid is assigned if the hardware does not
> support *any* L3 monitoring. Specifically:
> 
> resctrl_cpu_detect():
> 	if (!cpu_has(c, X86_FEATURE_CQM_LLC)) {
> 		c->x86_cache_max_rmid  = -1;
> 		...
> 	}
> 
> The function modified by this patch, rdt_get_mon_l3_config() only runs if
> the hardware supports one or more of the L3 monitoring sub-features
> (X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL, or
> X86_FEATURE_CQM_MBM_LOCAL) that depend on X86_FEATURE_CQM_LLC per cpuid_deps[].
> 
> I tried to reproduce the issue on real hardware by using clearcpuid to
> disable X86_FEATURE_CQM_LLC and the CPUID dependencies did the right thing
> by automatically disabling X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL,
> X86_FEATURE_CQM_MBM_LOCAL, not running rdt_get_mon_l3_config() at all, and
> not even attempt to enumerate any of the L3 monitoring details.
> 
> What are the symptoms when you encounter this issue?

Linux crashes during boot with a divide error, and the splat backtrace 
is in rdt_get_mon_l3_config().

> Would it be possible to send me the CPUID flags of leaf 7, subleaf 0 as
> well as all sub-leaves of leaf 0xF?

# ./cpuid 0x7 0
CPUID for Leaf 0x00000007, Sublevel 0x00000000:
	eax: 00000002
	ebx: f1bf2ffb
	ecx: 1b415f7e
	edx: bc814410

# ./cpuid 0x7 1
CPUID for Leaf 0x00000007, Sublevel 0x00000001:
	eax: 00201c30
	ebx: 00000000
	ecx: 00000000
	edx: 00084000

# ./cpuid 0x7 2
CPUID for Leaf 0x00000007, Sublevel 0x00000002:
	eax: 00000000
	ebx: 00000000
	ecx: 00000000
	edx: 0000003f

> Could you please also elaborate what the impact of this issue is? Is this
> a VM that has been released with many users impacted or something encountered
> during development of this VM?

This is with cloud-hypervisor.  We do have a couple of local patches for 
running on machines with more than 256 cpus.  I didn't see anything in 
our changes related to cpuid 0x7, but maybe it's on our end.

But I imagine the problem isn't widespread and could be considered 
developmental.

I'll keep poking on my end - maybe I had some other cruft in my system 
(in the kernel build or in cloud_hypervisor).

Thanks,
Barret


From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 847506F06B
	for <linux-kernel@vger.kernel.org>; Tue, 22 Jul 2025 21:16:56 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.15
ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1753219018; cv=fail; b=MYIE7/BiUsoOKiLwMhSGovGQY9EqN/RgJz54X4P/f686bPpZFy5gU2RQLCwD+hrHeMiysZ2HcSVzbl1h3IlBimqNIYvrLs+o4lQvBuI+IonJxVZmnt/yrKcFQ5fq9VFK+kepBiTIb4zxvWdou5S9cUPInw3CSB16WLb9pnr+CNA=
ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1753219018; c=relaxed/simple;
	bh=H+1/a3P1ldzyt/tGqcxoYXgDAlp+sYLCX5qRvjKlCpE=;
	h=Message-ID:Date:Subject:To:CC:References:From:In-Reply-To:
	 Content-Type:MIME-Version; b=jOj71SkCv1sVsPf2/Eljz9HB40wONuQGfQJkuQvm4vyG0UoZE+q6oPyC18AhKPZPD8jiI20Zf8aQCaXSjhbuHDsW41EsgM5RsF6nMikFC9o2HvshtSet5PNivDTbLYRio7ZdcTdjaGtH4W4T/aAGBluZd/bYamFhGHaoOnsA+UI=
ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mhKFkwyw; arc=fail smtp.client-ip=198.175.65.15
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mhKFkwyw"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1753219017; x=1784755017;
  h=message-id:date:subject:to:cc:references:from:
   in-reply-to:content-transfer-encoding:mime-version;
  bh=H+1/a3P1ldzyt/tGqcxoYXgDAlp+sYLCX5qRvjKlCpE=;
  b=mhKFkwyw82NZV+/KA8o2QnfcHulHPOLRnHO2bxAqJ2fIXxUwCmQNKZue
   Axw/oFptFHVcLK9wGJSPw7bV8Y5C+80yQOqBB6thYP6VdrY3j7WE+tXDr
   FRO2PC9mLo0GTVbIylIsp6yPdtgZv6yVw2gcaZJiICs2qe9bSc9uUl8jZ
   OgKh+lYcCmDKe0mNaBZBebdPaEN8AbPGKtE2A1ETWCjZ9/QaV/s2yawBY
   MA+DE4f7VpohZ3Mn3vnMFSdkbx8wUCMLJKz1quWja/8ZTrreN+StRQYqU
   rnleM1K7pdhFSiGhGRNHtgvtemd0sCzvGvy5htwyRtHZSqGSXZ4UmM2dB
   A==;
X-CSE-ConnectionGUID: eUnMLcjcR6GQIh1J0uLbPQ==
X-CSE-MsgGUID: 4U+A1ytITZyxhIT9Ltg9FQ==
X-IronPort-AV: E=McAfee;i="6800,10657,11500"; a="59143419"
X-IronPort-AV: E=Sophos;i="6.16,332,1744095600"; 
   d="scan'208";a="59143419"
Received: from fmviesa006.fm.intel.com ([10.60.135.146])
  by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2025 14:16:56 -0700
X-CSE-ConnectionGUID: 8nKKHuukQYyEJL0KsApOQA==
X-CSE-MsgGUID: 4hHEm+IwR2WGN6b/6BHpSA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.16,332,1744095600"; 
   d="scan'208";a="159296510"
Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25])
  by fmviesa006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2025 14:16:54 -0700
Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by
 ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1748.26; Tue, 22 Jul 2025 14:16:54 -0700
Received: from ORSEDG901.ED.cps.intel.com (10.7.248.11) by
 ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1748.26 via Frontend Transport; Tue, 22 Jul 2025 14:16:54 -0700
Received: from NAM10-DM6-obe.outbound.protection.outlook.com (40.107.93.64) by
 edgegateway.intel.com (134.134.137.111) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1748.26; Tue, 22 Jul 2025 14:16:53 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=v+05OLBHOKY5kecHAhRRl1SH2aSnMbya9xnrzi4EoRluxsccFL9WephI87lqJkaw+ZX98xRvIMVag+pT0jI0cDdW724TgBjyOEdXX4O6AhBKwJCoIkwGMuCqsvawUcy93Z+FQ3GppHMklrTrYIZH9q+C/83SiF1MI+GVY7m/ISZci8pxXbRBOc8iAu9jzPvV53zpkG7dJqWLG/qhCb9CbDVnpb8BLjF3gU33bv63oVVIZyqYC28U/6ra2shS1jU5nLnPeARYEUes1zm4b0tGweydMUarZ0tzA0yn2ay5xYkypkAX51OiiDKa3hTG2rKKB3a73vWnKg4wITrQfwc8jg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=SQqZXD7XT4PqdD3zPmw8UMD8ZUQ3CPRwDsA2A0CUouk=;
 b=kYiYYKSH/WM8gLZ5ELErYUZG4rBWw/7hFuwmKMRmaXiDZlKrzlUeh7iq04nvdq+xbQr6Mz/nSUcTjiS73Bc6adrcmhb0zCHIVa33EfLJa45TWuDgYSQf01bz7lokE812TT4JQ08mG5QMTGBIZDYe/IvGwjJrI4Blr8QpeH1dvKP1n/j0rQjZlshqwpUUUWKL7dX19yQ1Zm8rLeXeD3EEX7Kz9NHBxV0uvQw1o8mFXVYMPDuMewjxIqwDw/rBOVzyXvr4zGqtWhP5NBFEkZl6YhA/LFHXA1hWWuyptZE1iCPsb6PjXincliegGjeLAUZC9oTGPTVmYfG8xZFgdgrwdg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
Authentication-Results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=intel.com;
Received: from SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10)
 by DS0PR11MB7735.namprd11.prod.outlook.com (2603:10b6:8:dd::6) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.8943.30; Tue, 22 Jul 2025 21:16:38 +0000
Received: from SJ2PR11MB7573.namprd11.prod.outlook.com
 ([fe80::61a:aa57:1d81:a9cf]) by SJ2PR11MB7573.namprd11.prod.outlook.com
 ([fe80::61a:aa57:1d81:a9cf%4]) with mapi id 15.20.8943.028; Tue, 22 Jul 2025
 21:16:38 +0000
Message-ID: <2249977a-e291-494f-8c84-f16ec9fba10b@intel.com>
Date: Tue, 22 Jul 2025 14:16:35 -0700
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] x86/resctrl: avoid divide by 0 num_rmid
To: Barret Rhoden <brho@google.com>
CC: Tony Luck <tony.luck@intel.com>, Dave Martin <Dave.Martin@arm.com>, "James
 Morse" <james.morse@arm.com>, <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>
References: <20250721180051.3645697-1-brho@google.com>
 <c4518fe2-dce3-46d1-8d79-cd63377bdcad@intel.com>
 <dcc38ba0-cbb4-494e-bc10-2df2b4aa2cb0@google.com>
From: Reinette Chatre <reinette.chatre@intel.com>
Content-Language: en-US
In-Reply-To: <dcc38ba0-cbb4-494e-bc10-2df2b4aa2cb0@google.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-ClientProxiedBy: MW4PR04CA0125.namprd04.prod.outlook.com
 (2603:10b6:303:84::10) To SJ2PR11MB7573.namprd11.prod.outlook.com
 (2603:10b6:a03:4d2::10)
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: SJ2PR11MB7573:EE_|DS0PR11MB7735:EE_
X-MS-Office365-Filtering-Correlation-Id: ca3df044-8f40-4c57-8881-08ddc9650b5c
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7053199007;
X-Microso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wK3JSYXc3bWdLcWtIMUJKUTF1amNT?=
 =?utf-8?B?Ujh1bkhzeWphWUtXVThYMWZCZXFjYVJITTFjQjI4K3NXakE3S3pmbGhoN1hP?=
 =?utf-8?B?WGVkYkVXdlJaM3kwNC9FT0U4S3FLVGhMSzZVY3k3RFVjRmJuUXVoelpzamZo?=
 =?utf-8?B?d0FuSjNFSzFvT2JCSytOY0g5Y3U5bmlxaHliZG5Fc3d1SkY4VTBIUWYvL05r?=
 =?utf-8?Q?WMmyqiCgbqM=3D?=
X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR11MB7573.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(7053199007);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MGNjN0duc3lQN2hoUlRKRFlJSjVIU1pLMWMreGY3MmdVci8yaHIzeEMzNFNn?=
 =?utf-8?B?RFc1Q0Vja0c1cXFGdmczZ2JEVldxVmx2VnArb1FySk10MDNhc1ZjenduRFo3?=
 =?utf-8?B?ZlpUNCs5UEQxS2prNGJIWm5BREtrWTJPZ1k0NzBzS3BZTDIwRERzOGpZMHhm?=
 =?utf-8?B?WmhTdDdQSXhseXM3SXhkTmpOWTc5T2lJemF6aVV1a0syWFd2UWprRCtBVjNB?=
 =?utf-8?B?SHZxZ3phVGxvSkdrclJuWnAyRkQ3TUFGYWg0K293eFlXYlpMc00wYVp2QlFu?=
 =?utf-8?B?eERWY3E1aG9OdnR4cHM1am4raVN2KzliS2t5Zm5uMWwycGkwNnRzenVTcG9K?=
 =?utf-8?B?Mm5ERjdaZjdteVJxeGVNbi9EV0NlYUwvb2cyTGxvOUNFL3NWZ1YwZlI1TlJX?=
 =?utf-8?B?WnNEZEpXQ3lyY09hNVlZNDlwZGlwUnhHUGRYbk9vSz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X-MS-Exchange-CrossTenant-Network-Message-Id: ca3df044-8f40-4c57-8881-08ddc9650b5c
X-MS-Exchange-CrossTenant-AuthSource: SJ2PR11MB7573.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2025 21:16:37.9590
 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: N0uN89vswqQf+e03vvBQtOutJ6Q2rTsBYuswDJJRH+g+55/8KWa6Y7pOokkW681digWje2usSyJovnCI9tVszLQ8G0wZobJyrZJGVCUrr20=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7735
X-OriginatorOrg: intel.com

Hi Barret,

On 7/22/25 11:51 AM, Barret Rhoden wrote:
> On 7/22/25 2:19 PM, Reinette Chatre wrote:
>> Hi Barret,
>>
>> On 7/21/25 11:00 AM, Barret Rhoden wrote:
>>> x86_cache_max_rmid's default is -1.  If the hardware or VM doesn't set
>>> the right cpuid bits, num_rmid can be 0.
>>>
>>> Signed-off-by: Barret Rhoden <brho@google.com>
>>>
>>> ---
>>> I ran into this on a VM on granite rapids.  I guess the VMM told the
>>> kernel it was a GNR, but didn't set all the cache/rsctl bits.
>>>
>>
>> The -1 default of x86_cache_max_rmid is assigned if the hardware does not
>> support *any* L3 monitoring. Specifically:
>>
>> resctrl_cpu_detect():
>>     if (!cpu_has(c, X86_FEATURE_CQM_LLC)) {
>>         c->x86_cache_max_rmid  = -1;
>>         ...
>>     }
>>
>> The function modified by this patch, rdt_get_mon_l3_config() only runs if
>> the hardware supports one or more of the L3 monitoring sub-features
>> (X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL, or
>> X86_FEATURE_CQM_MBM_LOCAL) that depend on X86_FEATURE_CQM_LLC per cpuid_deps[].
>>
>> I tried to reproduce the issue on real hardware by using clearcpuid to
>> disable X86_FEATURE_CQM_LLC and the CPUID dependencies did the right thing
>> by automatically disabling X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL,
>> X86_FEATURE_CQM_MBM_LOCAL, not running rdt_get_mon_l3_config() at all, and
>> not even attempt to enumerate any of the L3 monitoring details.
>>
>> What are the symptoms when you encounter this issue?
> 
> Linux crashes during boot with a divide error, and the splat backtrace is in rdt_get_mon_l3_config().
> 
>> Would it be possible to send me the CPUID flags of leaf 7, subleaf 0 as
>> well as all sub-leaves of leaf 0xF?
> 
> # ./cpuid 0x7 0
> CPUID for Leaf 0x00000007, Sublevel 0x00000000:
>     eax: 00000002
>     ebx: f1bf2ffb

Looks like X86_FEATURE_CQM_LLC is off.

>     ecx: 1b415f7e
>     edx: bc814410
> 
> # ./cpuid 0x7 1
> CPUID for Leaf 0x00000007, Sublevel 0x00000001:
>     eax: 00201c30
>     ebx: 00000000
>     ecx: 00000000
>     edx: 00084000
> 
> # ./cpuid 0x7 2
> CPUID for Leaf 0x00000007, Sublevel 0x00000002:
>     eax: 00000000
>     ebx: 00000000
>     ecx: 00000000
>     edx: 0000003f
> 

Thank you. Could you please also pass on all sub-leaves of leaf 0xF?

Thank you very much.

Reinette

From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 485DB2F32
	for <linux-kernel@vger.kernel.org>; Tue, 22 Jul 2025 21:33:38 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.20
ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1753220019; cv=fail; b=a4PqeOhsDict1zsWVjgX+3/QtQZx6PeLY8wOGONM+QXiK0EmI1i+2YjMd0NisTcMd/7fep1mO99F9rCTjYxCU94ljdffa07Ln9dWwyQbjC7VVt5VGLjMGlF8/CpVbKW9qOoF6SJRtIs6W5pLwcmxh4yZSowLOTJ2IbNPIV8yJ+s=
ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1753220019; c=relaxed/simple;
	bh=s36OVj/J8GrsjoaDhmg5l0PUPGApYC74BkI2t4UBZCQ=;
	h=Message-ID:Date:Subject:From:To:CC:References:In-Reply-To:
	 Content-Type:MIME-Version; b=X0KzoNAWNwTx9SuubQpNqmZ5Q39v5pYBuQkHQE+3b+LgtBRjh6Z0iXStqx0IJrFfFtY8WeFHoJX/zRSBJk16syXZr5m1Sr/ZzzuldTznImGW3gNF7q8y1Oyt+yzSvGWPBUjSVyaQ7wkglW+k2GhgiO4KlH+6kjDcoorrSHtCVIk=
ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gwTpxiYQ; arc=fail smtp.client-ip=198.175.65.20
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gwTpxiYQ"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1753220019; x=1784756019;
  h=message-id:date:subject:from:to:cc:references:
   in-reply-to:content-transfer-encoding:mime-version;
  bh=s36OVj/J8GrsjoaDhmg5l0PUPGApYC74BkI2t4UBZCQ=;
  b=gwTpxiYQ4+CuNhQTgW3PD7o1ZayRCN0qQbr9ro8o8I0Qrk8zm3WpP1CV
   eEnC2BhHjakG+rW4R8oy5DcL0da207rC+HSkWNj+17hUo0BtnqrdFRXVy
   TBRLhCDgXRp1vGJnD4rAEBqCtP5oR4a56uNCB4QFjVopTL17lBAxMeZLw
   zLfpJyFYaeNSJa+oLYgTNGMjmJb99zKCupuQtjpXrjMo+pbH6/hkbv703
   PF/ScC3nqseJuh8Qfjw/2KOCwRikaXSH4aANHlKu22RG55v9yIoudrTb6
   aDXM8kLcH/yOImFhal9v0NnnFsenIVw1/XkWd3URTAEq1q9DqtS9iXLJx
   g==;
X-CSE-ConnectionGUID: i7n1yvzGT/GrFlH3NZJ6eA==
X-CSE-MsgGUID: gkvk5YOiQmOmy9y49vhQAA==
X-IronPort-AV: E=McAfee;i="6800,10657,11500"; a="55192061"
X-IronPort-AV: E=Sophos;i="6.16,332,1744095600"; 
   d="scan'208";a="55192061"
Received: from orviesa005.jf.intel.com ([10.64.159.145])
  by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2025 14:33:38 -0700
X-CSE-ConnectionGUID: nYw0o7CyR1i0l3POGekLIA==
X-CSE-MsgGUID: Fpe6BwiJS762MfOkbkMULA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.16,332,1744095600"; 
   d="scan'208";a="164903269"
Received: from orsmsx901.amr.corp.intel.com ([10.22.229.23])
  by orviesa005.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2025 14:33:38 -0700
Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by
 ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1748.26; Tue, 22 Jul 2025 14:33:37 -0700
Received: from ORSEDG902.ED.cps.intel.com (10.7.248.12) by
 ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1748.26 via Frontend Transport; Tue, 22 Jul 2025 14:33:37 -0700
Received: from NAM11-CO1-obe.outbound.protection.outlook.com (40.107.220.63)
 by edgegateway.intel.com (134.134.137.112) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1544.25; Tue, 22 Jul 2025 14:33:37 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=duqH1prodDnRuS+5loH/KTBOqs+lBgyDBosOzwipfwlE41gBgVttC9dJNzpPUjZ4Io+VtAyhGL7UB6IRxUhFTTAlcBQdKT8qTNSOzYVP8ZN3c3WgFVedThZixEWb11Nz+4g7xo81WqphFRhSGSF33xX7ZDcCjlAnvS4aliv1QoNUAoy+GHGO8tdH0THHtsWrJiw7K1pJ9pM3gsyFU8rlRks1TAKHpOrzG+aseYIQ7kt0G6Q6nLNK+bqBROJdcUQRxEwn/b3fc8wb0lw5xLTkotftHHKRvxfgLp20a+DTPMoaC3JS0Xz52OmZmzWLbf1RxN1G8FnOKo7r06gDoB2AEQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=GQKNYupxB3iTwGeXb+Wk7dE/9HIolKCSy16o6QdZgUA=;
 b=K9VGjCwDuBZX+EQ4/B6SciUIXREuWa67P/Wl1ZD3uYHlCwXGLBIvrowIfzEx06WfsaMwFzWuGa2ovqnoiNQgVUF/Ws49hBxPDIOfh3iUFsUa2nBqi2f4ZEyGKM2LyKNunXSrogH757sU248iz5lW4krztrbIDYG6cT+MTTx2Gyw/o2suPCtFXEYuR933YcnXG0maBTZ7Ftoe+9cbWRg7cFHYfWFnJesnqPAjmJnm03+kZb65byASQ5rWqxjdtsoSXCai9DknMtHx5NowfV2iycOwUTCh5Uv55WCsaRnzWy+kQKSxDcHKXKqKquK/geoyBmQ+iAdGzqdF0b5X5YR1JQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
Authentication-Results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=intel.com;
Received: from SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10)
 by MN0PR11MB6010.namprd11.prod.outlook.com (2603:10b6:208:371::11) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8943.30; Tue, 22 Jul
 2025 21:33:33 +0000
Received: from SJ2PR11MB7573.namprd11.prod.outlook.com
 ([fe80::61a:aa57:1d81:a9cf]) by SJ2PR11MB7573.namprd11.prod.outlook.com
 ([fe80::61a:aa57:1d81:a9cf%4]) with mapi id 15.20.8943.028; Tue, 22 Jul 2025
 21:33:33 +0000
Message-ID: <d3c65087-c846-439c-8f46-ceb899809b70@intel.com>
Date: Tue, 22 Jul 2025 14:33:30 -0700
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] x86/resctrl: avoid divide by 0 num_rmid
From: Reinette Chatre <reinette.chatre@intel.com>
To: Barret Rhoden <brho@google.com>
CC: Tony Luck <tony.luck@intel.com>, Dave Martin <Dave.Martin@arm.com>, "James
 Morse" <james.morse@arm.com>, <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>
References: <20250721180051.3645697-1-brho@google.com>
 <c4518fe2-dce3-46d1-8d79-cd63377bdcad@intel.com>
 <dcc38ba0-cbb4-494e-bc10-2df2b4aa2cb0@google.com>
 <2249977a-e291-494f-8c84-f16ec9fba10b@intel.com>
Content-Language: en-US
In-Reply-To: <2249977a-e291-494f-8c84-f16ec9fba10b@intel.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-ClientProxiedBy: MW4PR03CA0038.namprd03.prod.outlook.com
 (2603:10b6:303:8e::13) To SJ2PR11MB7573.namprd11.prod.outlook.com
 (2603:10b6:a03:4d2::10)
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: SJ2PR11MB7573:EE_|MN0PR11MB6010:EE_
X-MS-Office365-Filtering-Correlation-Id: a5f9b47f-ef48-4669-4017-08ddc967682e
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024|7053199007;
X-Microsoft-Antispam-Message-Info: =?utf-8?B?NFBtaWd2SHNSU1p5ekUzaDlGb2hTRmpWUUh6N1l4YXZqLzJvV0xqbDlNSXR5?=
 =?utf-8?B?YjhrZkxMYkJWQSt1N0txNzRJQlowRnZSM3lGZHU0TEZ4ZU1MMlY2VFFISFdo?=
 =?utf-8?B?eVpscmVhU0NFbDhXak1yMWRJUVBPOFd4dUczZjIxZGdYYk5lRkZQSlI1cFh1?=
 =?utf-8?B?VlVPMVUxV09mMkNNWVZNV0VBM0l3dVpXQWhuZEwrcXIvSElDeUdpMkw1R0FQ?=
 =?utf-8?B?eWt1cjJqekdVMHFONkh2SFAzK1o4TFBNTDB0OTl5enc4WTY1YVRKWGZZYVc1?=
 =?utf-8?B?M2tsT0h0cnlpS1I4UlBROUhPS1p1dGIwcHBkbE5kdG9mc2l3Q0VCaExFenVp?=
 =?utf-8?B?dWZRSEpoWHBwZE8xK2RaMmdlYUxaZkNiZkZHcW1zTERCZFJQR0FLemxSQnFw?=
 =?utf-8?B?OG00R0V6MjY2a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x0bnRBbm5oWitTT1dIZWtxWmR5?=
 =?utf-8?B?MTZKZUNlSWxwdkNKQTlsOG4vcnIvQUZ0TVRXbG8rM0gwNE1iMFNFbkdFRkR3?=
 =?utf-8?B?NHJEUDRWcS8xeDRZU2pvb3FSMHZGeDQ0N1Z3SnFRRlJVTGhvdnhabm93czUr?=
 =?utf-8?B?T0YwZ0NvY2F6SldrbzFBOHU0UTlFRDVtNmxsc0NPQ0tRZjhLRkdGM0JuTmRW?=
 =?utf-8?B?eFpWUkNaekZFMUtRZjJrVDRaRUF0YkNiZFQ1aytkQU9XdDZjQVI5SEd2UDdl?=
 =?utf-8?B?RmlDQzBxR0dvKzE1NHpTSHhnRGcvOVdHUnNEc3FicmN4Z0NsOTZ1NHVZTVlG?=
 =?utf-8?B?MURtUnZtTUp6MWMxbDl1eUxmMzZXbnIxUzB4R3NYNVZRNUlBU0xENFJVVlcx?=
 =?utf-8?B?ZmZqdHpQREQ5UjBPZ3pQRnNyV0M1eCt1UDdQMzVhZ1ZWMWgzcGNUTUlac3VR?=
 =?utf-8?B?RFE0R1RYU3dVQnVaREtobTQ4R2JDZURJS2psWnZzdG0xYkx6TDFzcit5KytT?=
 =?utf-8?B?dGorblBudkRsWVVRUFpVc3QxT2o1MW1NcG9GajczandqRjE3azYzRzFlb1NN?=
 =?utf-8?B?bDNwdmpFMUhIODRkOGJZUEg3cEkyeldBNDJ0UlQ4MFVibTNtWTV4VWZoUFpv?=
 =?utf-8?Q?pJt6LYy8mQ0=3D?=
X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR11MB7573.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024)(7053199007);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dDBvTXFvcGVIbVc0RzV4dmw2TzlYY0I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TQwRTA5alFRRUhrWWs5bzhZYTRXS1U4enRhLy9ONHZYbWxWdzdPUTN3TlBR?=
 =?utf-8?B?ZG1MMStFaTh4eTR5WGU5aWVkeks0ZElHNm1zd1pJaHRCaWplNjNzVjFHd2xL?=
 =?utf-8?B?OERPZFI5RFZ2V0xTTjZzdGhocWNvWnpvKzFWays0MTBKWHNPdUtEd3RuMm9D?=
 =?utf-8?B?VzNzUGJ2SmtKTUJxMnZ6WUlKZURqZWR2akpQUWVobDVwTkRqaGd5a2kxcDZl?=
 =?utf-8?B?dURHY3JMQ1JSSCs0MXpUaG1SZnZ3OXVnRHhKa2NqOGhtcUsvZHRBdUx4S3FY?=
 =?utf-8?B?b3NoQmV3YXJtMUhjdHVlMVJVY3phSGJxUkxxN21nY1RuUjA5WUpwSFp6MDdM?=
 =?utf-8?B?NnFLckw4a2w4WEN5S1lhZDVaYjdSQngxRVdzRlJJZzNnMzZ5SUZQR0RRbU9h?=
 =?utf-8?B?V1E9PQ==?=
X-MS-Exchange-CrossTenant-Network-Message-Id: a5f9b47f-ef48-4669-4017-08ddc967682e
X-MS-Exchange-CrossTenant-AuthSource: SJ2PR11MB7573.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2025 21:33:32.4490
 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: Ps2eGUMK1W2XU7/fE7cEmRBlf7vjnQi5wzq2IPWEuD1a2GHBTnwN7rc5yWgBcHCnXPWJ9db9nhv6A/jfGEg3oZMEy9MxlVdkEAWK1AP5e/s=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR11MB6010
X-OriginatorOrg: intel.com

Hi Barret,

On 7/22/25 2:16 PM, Reinette Chatre wrote:
> On 7/22/25 11:51 AM, Barret Rhoden wrote:
>> On 7/22/25 2:19 PM, Reinette Chatre wrote:
>>> Hi Barret,
>>>
>>> On 7/21/25 11:00 AM, Barret Rhoden wrote:
>>>> x86_cache_max_rmid's default is -1.  If the hardware or VM doesn't set
>>>> the right cpuid bits, num_rmid can be 0.
>>>>
>>>> Signed-off-by: Barret Rhoden <brho@google.com>
>>>>
>>>> ---
>>>> I ran into this on a VM on granite rapids.  I guess the VMM told the
>>>> kernel it was a GNR, but didn't set all the cache/rsctl bits.
>>>>
>>>
>>> The -1 default of x86_cache_max_rmid is assigned if the hardware does not
>>> support *any* L3 monitoring. Specifically:
>>>
>>> resctrl_cpu_detect():
>>>     if (!cpu_has(c, X86_FEATURE_CQM_LLC)) {
>>>         c->x86_cache_max_rmid  = -1;
>>>         ...
>>>     }
>>>
>>> The function modified by this patch, rdt_get_mon_l3_config() only runs if
>>> the hardware supports one or more of the L3 monitoring sub-features
>>> (X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL, or
>>> X86_FEATURE_CQM_MBM_LOCAL) that depend on X86_FEATURE_CQM_LLC per cpuid_deps[].
>>>
>>> I tried to reproduce the issue on real hardware by using clearcpuid to
>>> disable X86_FEATURE_CQM_LLC and the CPUID dependencies did the right thing
>>> by automatically disabling X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL,
>>> X86_FEATURE_CQM_MBM_LOCAL, not running rdt_get_mon_l3_config() at all, and
>>> not even attempt to enumerate any of the L3 monitoring details.
>>>
>>> What are the symptoms when you encounter this issue?
>>
>> Linux crashes during boot with a divide error, and the splat backtrace is in rdt_get_mon_l3_config().
>>
>>> Would it be possible to send me the CPUID flags of leaf 7, subleaf 0 as
>>> well as all sub-leaves of leaf 0xF?
>>
>> # ./cpuid 0x7 0
>> CPUID for Leaf 0x00000007, Sublevel 0x00000000:
>>     eax: 00000002
>>     ebx: f1bf2ffb
> 
> Looks like X86_FEATURE_CQM_LLC is off.
> 
>>     ecx: 1b415f7e
>>     edx: bc814410
>>
>> # ./cpuid 0x7 1
>> CPUID for Leaf 0x00000007, Sublevel 0x00000001:
>>     eax: 00201c30
>>     ebx: 00000000
>>     ecx: 00000000
>>     edx: 00084000
>>
>> # ./cpuid 0x7 2
>> CPUID for Leaf 0x00000007, Sublevel 0x00000002:
>>     eax: 00000000
>>     ebx: 00000000
>>     ecx: 00000000
>>     edx: 0000003f
>>
> 
> Thank you. Could you please also pass on all sub-leaves of leaf 0xF?
> 

One more thing, could you please check the kernel logs for any other issues
when that VM boots up?
I would like to check if it contains a warning with text like:
"x86 CPU feature dependency check failure"

Reinette


