From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 BEEBC33A711 for ; Thu, 26 Mar 2026 19:04:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551879; cv=none; b=HneUJ1Bb0GUqztjc86JKxKICiIdS4CQmtLoBf+Q/bz2kVwogy5e4nTjON4tPstPqFymstyxYjKiav5bOkVz0oWklQ+LrlJn/Qb+JznjrmAYF9p/oUjbx+vF6I91nola9Of2u0lhTOzp10CHiNBx0D5vtBOsGwS/NjnaGSjPwRVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551879; c=relaxed/simple; bh=omJ3LHNtDWKI+9KTRck6IHtFUOryPD5QxbcqMBYhIrk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Qnv50zjEEmOs3JeISKsUW67ykVMG60orGBdlalJB/kjF1T2kb+xG3atuWvY/qbQBqA5aKwoGMxKQ/F21AMInHEr4VnK1vEp82tHElri2nbZaCt0vsPRUmoZtwmeYnmvL3XhnbIQCrTHnogUjZ+/q96I6v+PvAci4mEtwLBJxD8U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ewy5Qxw7; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ewy5Qxw7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774551879; x=1806087879; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=omJ3LHNtDWKI+9KTRck6IHtFUOryPD5QxbcqMBYhIrk=; b=ewy5Qxw7zeiAEaNT0ugkW22AamQDgeu0vTrL9vVff0cmxxuEF5aXjTyz 6ZGcGD11e04AVCrixzWb7ka1NB5CUZv3r7NPw3LgLs5+4d6dkKM1s5om3 T2zDJueFIsCSHbSXOMgFjdsVAXAH2dc9dfoWypaKQI1Ho8iqOOLUK3VBs 4oZbha4b9K7fTceMtQS/kZm1cqhgSTBiTj6ZroEekvpuT0Bt+CcFP0ySi C2IcRXD3mRHdcPJkGpy0y2axidxkTRz7P5EI73vuWOsa9ZTx03e0WQIFZ +0JmK2GZAv7xy99a4VU9YrDQkJb34mQJBo+ZBCKR4nlqf5uSzB4+K53cz Q==; X-CSE-ConnectionGUID: Ok5jI9aIQJGfsUmDlGCDMg== X-CSE-MsgGUID: xYqkfpLHR8mvjUKEUp0KWw== X-IronPort-AV: E=McAfee;i="6800,10657,11741"; a="75691812" X-IronPort-AV: E=Sophos;i="6.23,142,1770624000"; d="scan'208";a="75691812" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2026 12:04:38 -0700 X-CSE-ConnectionGUID: Qt1Qp0dKRuGgAgnb1ecgRA== X-CSE-MsgGUID: 3PUxEhLqQRiePro1CjaxhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,142,1770624000"; d="scan'208";a="224273237" Received: from guptapa-desk.jf.intel.com (HELO desk) ([10.165.239.46]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2026 12:04:38 -0700 Date: Thu, 26 Mar 2026 12:04:30 -0700 From: Pawan Gupta To: Maciej Wieczor-Retman Cc: tglx@kernel.org, peterz@infradead.org, xin@zytor.com, maciej.wieczor-retman@intel.com, babu.moger@amd.com, chang.seok.bae@intel.com, sohil.mehta@intel.com, dave.hansen@linux.intel.com, jpoimboe@kernel.org, elena.reshetova@intel.com, hpa@zytor.com, ak@linux.intel.com, darwi@linutronix.de, bp@alien8.de, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v11 3/4] x86/cpu: Do a sanity check on required feature bits Message-ID: <20260326190430.i4dt2dxqpfzwlhcc@desk> References: <7312c9f2feab8aea4612ed9a1841e8c22f5f69b1.1774008873.git.m.wieczorretman@pm.me> <20260321003015.4i7wrqmaunbljguw@desk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Mar 26, 2026 at 06:36:15PM +0000, Maciej Wieczor-Retman wrote: > >Do we need 2 loops? Can this be simplified as below: > > > >static void verify_required_features(const struct cpuinfo_x86 *c) > >{ > > u32 required_features[NCAPINTS + 1] = REQUIRED_MASK_INIT; > > char cap_buf[X86_CAP_BUF_SIZE]; > > int i, error = 0; > > Isn't this [NCAPINTS + 1] still a problem because for_each_set_bit() works in 64 > bit chunks? If NCAPINTS becomes an odd number in the future, the > required_features[] last 32 bits will be uninitialized - REQUIRED_MASK_INIT is > of (NCAPINTS * sizeof(u32)) size. So they might have some bits set and trigger > the pr_warn() below. Isn't a partially initialized array always zeroed out for the uninitialized part?