From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 D1E75ECC for ; Fri, 10 Jan 2025 20:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736541070; cv=none; b=BzFJ26YYrtg9lwbKjYEvMRHo/NXmzo6PZZl6GOWowMiX5kQqWmZoydFNLbjBqf3POBoF+uw1ilUKZaEooIMDKRYGTm6G3pIMvqe9jnVHLU/U1EKEXuMaLVftWNj66eZHR4dET67LEKspiCVdfhDwO/2NkkEl2DkLb41mtmVsm5M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736541070; c=relaxed/simple; bh=a7v5xHJr9Eri2Oh3yf4iXOaA2oWXSazFAa6NPDSVX8s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=l17CObdLVRISk9wm729Rc14I+u+MT/VyyrOPQwInFvWigT7ThxSkeCiwh1p+HaRCTBjUeiRJ+o8Lo/eYiHmFIoZF9UT2My40WKkpG6bp3ASXLE9DHYGD1wqPeW7hLUKSN0cP1qMgWocI6aVKLLoVZhnEilKaDRIH9kl8v93ZiU8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Pv9L3UvE; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none 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="Pv9L3UvE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1736541069; x=1768077069; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=a7v5xHJr9Eri2Oh3yf4iXOaA2oWXSazFAa6NPDSVX8s=; b=Pv9L3UvEJ8pTUTPjEtvQNy0iyosgJ3C7+AEExrxnmA9xmr1zJ3yY1Us/ bPUSPV0Ktk3BjuTJ9LWVhE4ZL2DLMME0MWdxXky2G+r3PpqpmvdDmNVLC i5X9J5lZ7RVZvZUiZOVxLwA3jFzLKpABlC/zx9cFqWOqY8/yjPam6qxFJ lhXHvPW+66I/sapYVTdgND1/CpLwLja4EGcgsGXF+a0EC22qSCQXVs3oP +z3NH6+VY4BsB7CSngGqReYhWLOWq4wlRatthk+NMFTnCYzaNlU7gJ0Rt hN+h5ar0ZyDlUKtE1rVS3yCpmNELLfTJksjvbse8KaC+fcNe4YV8i8+HO g==; X-CSE-ConnectionGUID: Vyd0zFFzQrS4FVADNjXP5g== X-CSE-MsgGUID: +HW9mny7SIqmi3dO6VH8GQ== X-IronPort-AV: E=McAfee;i="6700,10204,11311"; a="54265292" X-IronPort-AV: E=Sophos;i="6.12,305,1728975600"; d="scan'208";a="54265292" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2025 12:31:09 -0800 X-CSE-ConnectionGUID: Tbz0slmWSTCWWwqH5sqqAA== X-CSE-MsgGUID: uGBJGisHTr+MnTQNGQqjwg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="103708935" Received: from dorits-mobl2.amr.corp.intel.com (HELO desk) ([10.125.145.71]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2025 12:31:08 -0800 Date: Fri, 10 Jan 2025 12:30:58 -0800 From: Pawan Gupta To: David Laight Cc: David Kaplan , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Ingo Molnar , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation Message-ID: <20250110203058.66cd7zlajfbpqf5k@desk> References: <20250108202515.385902-1-david.kaplan@amd.com> <20250108202515.385902-13-david.kaplan@amd.com> <20250109052237.pq4irr2iycitl5il@desk> <20250110184545.2c7a9976@pumpkin> 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: <20250110184545.2c7a9976@pumpkin> On Fri, Jan 10, 2025 at 06:45:45PM +0000, David Laight wrote: > On Wed, 8 Jan 2025 21:22:37 -0800 > Pawan Gupta wrote: > > > On Wed, Jan 08, 2025 at 02:24:52PM -0600, David Kaplan wrote: > > [...] > > > @@ -1064,6 +1063,7 @@ enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init = SPECTRE_V2_NONE; > > > > > > enum retbleed_mitigation { > > > RETBLEED_MITIGATION_NONE, > > > + RETBLEED_MITIGATION_AUTO, > > > > This new enum ... > > > > > RETBLEED_MITIGATION_UNRET, > > > RETBLEED_MITIGATION_IBPB, > > > RETBLEED_MITIGATION_IBRS, > > > @@ -1071,14 +1071,6 @@ enum retbleed_mitigation { > > > RETBLEED_MITIGATION_STUFF, > > > }; > ... > > > static const char * const retbleed_strings[] = { > > > [RETBLEED_MITIGATION_NONE] = "Vulnerable", > > > [RETBLEED_MITIGATION_UNRET] = "Mitigation: untrained return thunk", > > > > ... does not have a corresponding entry in the strings array. AUTO is the > > default, and it is possible that mitigation mode can stay AUTO throughout > > the retbleed mitigation selection depending on cmdline and CONFIGs. e.g. > > retbleed=stuff and spectre_v2=off. > > It is possible to use 'a bit of cpp magic' to put the definitions on one line. > Something like: > #define RETBLEED_MITIGATION(x) \ > x(NONE, "Vulnerable") \ > x(AUTO, "xxxx") \ > x(UNRET, "Mitigation: untrained return thunk") \ > ... > > #define X(NAME, msg) RETBLEED_MITIGATION_##NAME), > enum retbleed_mitigation { RETBLEED_MITIGATION(X) }; > #undef X > > #define X(NAME, msg) [RETBLEED_MITIGATION_##NAME] = msg, > static const char * const retbleed_strings[] = { RETBLEED_MITIGATION(X) }; > #undef X > > Then you can't lose message texts even when they are in a different file. > The lower case name (for the strcmp() loop) can also be added. > > (and don't let the rust bindgen near it :-) Wow, this is mind blowing!