From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 BA4443DABFE for ; Fri, 10 Jan 2025 18:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736534750; cv=none; b=FxE5o9Ey72Lt7Na0TieYM0IYwvFTInyTJDmKrLg1IYNtd8EStnMcND+XGatAVH4H+0EPdw7SntLIePrRLk3VPgdhyHwo7KKTmeDUsQo7dFgGs1hkRvfst5NJk+kYLJUrtG2gpp3wOFIkn200O0z0FgWCB+zWs2rpVepEQc68e0Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736534750; c=relaxed/simple; bh=8RtjUYc+KT4r/bnv7EQBXoQ6yB6o+WZOfHsQ0PrYs1s=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cx+vi9HCUVWwEE8mS/Bn0Bup6l8iZJ7D8wSmlLx8G7cemg74bYwy0CPAX58Dy7wVLtgEzyXpVKjhMY31vOWSoURQlzy1mWD62Do3J45VFlJJoWjR4AMfzA3U5wi+OyM3l5QTcYkeZ2WqYp8HzbJMD/DOqdmccdTD676aiGDHjbc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a5c+GIbV; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a5c+GIbV" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-43621d27adeso17730805e9.2 for ; Fri, 10 Jan 2025 10:45:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736534747; x=1737139547; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=TvgHH9kAIZ9xVVmPzu/4tXnzs6wsXBEQQVM3XvIaUXg=; b=a5c+GIbV+TOjbWzCasSOAPtR7FrvA7o0q+ygzgPsX2jxNOyfT+uvinnswmwCVvuy1K snhrMxZz1kB1yYTcN120spe99veiunIGK/NjIBhXHQ84GgY9t6w8p0iVN0xubpFoAZq1 DlAVwDAkMPkojtr/6k6PvsEC4ACg8DfUX1dBnzdvCGYLwZN4V0bya9WLA9AJX8dnxZRA piUURCoReoa35JpNpk4IC/lCcBQVyh+gOXAqn1cO8qkpoX3evDciiiPQVyOstFDjIG/g sMY29ZbXxFWgD5PyWRqXyjrAgoNiPYWikyZIV44lnvyq1+R2sFw+q/hr8Zawxef++rzd Bi4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736534747; x=1737139547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TvgHH9kAIZ9xVVmPzu/4tXnzs6wsXBEQQVM3XvIaUXg=; b=p4dwurLj9D7Gejwq/oKII3oJbryibyg6JPbbeqK3Wy8xBoVxqylsX2PgUTbFudvWro fKRkMDts6iNLa3OyYsePrgwg7IO8PDSUjo3ng55ZLmYxSAmpOsEDXzBHBB+2KB++PPln 77RvaiN3GYu8ZRdBhzdMiANMtLBSpEXB7IfQ+zZ3/DEVUBsY/kIIt2wxVkxlUA8u4UrW de4jJdSKgqg/uDbj7qb5DgOFzIPtsF4PaREHSrETBnLXqdIuZdokdTrE8KSEEc9H12TS xLOl3dakJP2Ee4MgzP35oK4DxyjxsrV2nktYNyEXWeMIIq4fb2GUwMqvREL5TSaezTVE xjqg== X-Forwarded-Encrypted: i=1; AJvYcCUn7Nqqg08kHC/GORINmgDcFAplmr/oWywXKKJ1b7d/Fta6fixx1w5D8ZofMQ0kHb5NotqH6mbUpNivRDA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3/vU1kpaESkxIX5sXJNRR3NjFHSkPLAvrQzVQ+ZIWSN6AMkA2 HOQBDSE14jXDpAX5jo/1aTOGuy3ibpEaKWf/QBkVEqhq6cdMQ7qT X-Gm-Gg: ASbGncsb5lqXYaMTBQJi6Z9u++RNyXvXjg4pBeUrdTkEYDrJauzHFBZDai+JmKnqxjm T7nXTm/AHW/MonH2f7D3GDg7bt9KLOmXCxSrIabNmhwXiFokoE1whW/H3U0UBbg41GP7GzrUX8T ELsPWaT0Jz0pVX9kzJMpEGNDnr81Oxsi65tNuUdfrSCXpAKayPrcj9i4a2ujTccRPFEYPbZMpsF hfo3n7+ZE9Tw4/m0AKEuboN9jvQzjwrh3uX2wmijt788iQkgKGTyU6aHwt8CAD6o6aK2belizXU aKlJevcB4498IMZN9bQ= X-Google-Smtp-Source: AGHT+IEqZkq5Ey7MjtRtw+WU75wRTk1HYYHW+B6GiQ+a2vCgSaT0/11CjqhxEi7nyYaXCC+m06Rubg== X-Received: by 2002:a05:6000:2c5:b0:386:2fc8:ef86 with SMTP id ffacd0b85a97d-38a872da886mr10006577f8f.14.1736534746781; Fri, 10 Jan 2025 10:45:46 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e38428bsm5221555f8f.37.2025.01.10.10.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 10:45:46 -0800 (PST) Date: Fri, 10 Jan 2025 18:45:45 +0000 From: David Laight To: Pawan Gupta 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: <20250110184545.2c7a9976@pumpkin> In-Reply-To: <20250109052237.pq4irr2iycitl5il@desk> References: <20250108202515.385902-1-david.kaplan@amd.com> <20250108202515.385902-13-david.kaplan@amd.com> <20250109052237.pq4irr2iycitl5il@desk> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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-Transfer-Encoding: 7bit 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 :-) David