From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 D346E3093C6 for ; Wed, 18 Mar 2026 23:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773877348; cv=none; b=NTy6IqgSMNmFx5XDc76Pejcgl8yzOnMpYH2sfhMCifQ8R8ewhwp9zRRvzDssqHx5HH6sfOHRDpF7abEpa7tdRYcPPanvE0ImRFvq8iuBIDPOazp/nxxT/gh1kpJOmV2G6+zRZBlmlqmedp4PgJgkCvFxqgumiJ6x9wWjKrGR6PQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773877348; c=relaxed/simple; bh=H58Csq1a8mF9XSEvaejdDtt7WmUs4vF1qSPhISCUIe0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=U6TSVXAAtMY9jjsvR9Jao5UmPXBZQFIJM/bK7bHsXvobRq4ct0HAgN27QFy2dMCqkQepPAnRKL1FizdBQriwiBXyHN0JEisELc2norpJk+MwnlmzKSk0EY2T7eMITDsfE+6GB4q+dJ7l0ku4lH1IEGms1xNWR8/fEkpEvZG8Owc= 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=TcT1qMng; arc=none smtp.client-ip=192.198.163.9 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="TcT1qMng" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773877347; x=1805413347; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=H58Csq1a8mF9XSEvaejdDtt7WmUs4vF1qSPhISCUIe0=; b=TcT1qMngwgRslquo/h91tbPsr57UhiVk4Kmgtgkwu5nPKbbcm8Kgfu4j MmWIevQ6ooXs6sE0qio0i+4kB3lYzhcRuVuzSRzL5ew9U6ttfldsnam81 WXkXndpfgv+1RxaxIcqGjFBboJ/X9Qcv4ggY1mtQmyagPfXQDdNHQclAn Ku/HpEqAzdEUfnleKuUJwe3M6TfHrPSGGU4MD0Ms402/v1GDjgdWwnDf+ EoV8rjZiNW2YJe4sjaU1oxOu8+zsQRU1xl+qEz3LVHdYLb6ohAmdV4b+Y Zp8g5lU4ohhRc+qNKsGqHPMzRxTU5OzyU+YD/oolkY7Y9eADlxxq066CU Q==; X-CSE-ConnectionGUID: 2TVL+OE4Sny3kTTiUNNLfA== X-CSE-MsgGUID: fA0zfTWbQpuZT3nIVxZEJQ== X-IronPort-AV: E=McAfee;i="6800,10657,11733"; a="85649094" X-IronPort-AV: E=Sophos;i="6.23,128,1770624000"; d="scan'208";a="85649094" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2026 16:42:26 -0700 X-CSE-ConnectionGUID: gt83pjNTTGa5zI7XhNnkXw== X-CSE-MsgGUID: eU1QRwa3TS2gsGFKkix9sQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,128,1770624000"; d="scan'208";a="221895224" Received: from guptapa-desk.jf.intel.com (HELO desk) ([10.165.239.46]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2026 16:42:26 -0700 Date: Wed, 18 Mar 2026 16:41:58 -0700 From: Pawan Gupta To: Maciej Wieczor-Retman Cc: tglx@kernel.org, bp@alien8.de, mingo@redhat.com, darwi@linutronix.de, thuth@redhat.com, dave.hansen@linux.intel.com, ak@linux.intel.com, babu.moger@amd.com, chang.seok.bae@intel.com, peterz@infradead.org, nik.borisov@suse.com, jpoimboe@kernel.org, hpa@zytor.com, xin@zytor.com, maciej.wieczor-retman@intel.com, sohil.mehta@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 2/3] x86/cpu: Check if feature string is non-zero Message-ID: <20260318234158.4nluxyckypcezyam@desk> References: <92b57f62940b1972d39ae270b1b1ea497462c9ec.1773771353.git.m.wieczorretman@pm.me> 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: <92b57f62940b1972d39ae270b1b1ea497462c9ec.1773771353.git.m.wieczorretman@pm.me> On Tue, Mar 17, 2026 at 08:00:16PM +0000, Maciej Wieczor-Retman wrote: > From: Maciej Wieczor-Retman > > In filter_cpuid_features(), x86_cap_flags[] is read, but it's not verified > whether the string is non-zero which could lead to unwanted output. > > In two more places there are open coded paths that try to retrieve a > feature string, and if there isn't one, the feature word and bit are > returned instead. > > Add a common helper to fix filter_cpuid_features() as well as clean up > the open coded cases. > > Signed-off-by: Maciej Wieczor-Retman > --- > Changelog v10: > - Reword the patch message a bit. > - Move x86_cap_name() declaration and X86_CAP_BUF_SIZE define to > asm/cpufeature.h. > - Don't include asm/cpu.h in cpuid-deps.c > - Extend the comment above x86_cap_name to include information on buffer > size that needs to be prepared before calling the function. > - Remove the likely(), unlikely() calls since this is not a hot path. > > Changelog v9: > - 16 -> X86_CAP_BUF_SIZE. > - Add comment to the x86_cap_name(). > > Changelog v8: > - Move x86_cap_name() declaration from linux/cpu.h to the arch/cpu.h. > Include arch/cpu.h in the cpuid-deps.c file instead of linux/cpu.h. > > Changelog v7: > - sizeof(buf) -> 16 > - Rebase onto 7.01-rc1. > > Changelog v6: > - Remove parts of the patch message that are redundant and just copy > what's visible in the diff. > - Redo the helper to use an external char buffer instead of a local > static string. > > arch/x86/include/asm/cpufeature.h | 4 ++++ > arch/x86/kernel/cpu/common.c | 32 ++++++++++++++++++++++++++----- > arch/x86/kernel/cpu/cpuid-deps.c | 21 +++----------------- > 3 files changed, 34 insertions(+), 23 deletions(-) > > diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h > index 3ddc1d33399b..dc1cd44ddd63 100644 > --- a/arch/x86/include/asm/cpufeature.h > +++ b/arch/x86/include/asm/cpufeature.h > @@ -138,5 +138,9 @@ static __always_inline bool _static_cpu_has(u16 bit) > #define CPU_FEATURE_TYPEVAL boot_cpu_data.x86_vendor, boot_cpu_data.x86, \ > boot_cpu_data.x86_model > > +#define X86_CAP_BUF_SIZE 16 This can get rid of the extra tab. Reviewed-by: Pawan Gupta