Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp798130lqb; Wed, 17 Apr 2024 10:58:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAo1NnaQSf2MyDg/B88RUf+0QR1cmFS7dGLkwbgyz4DDEGP3OFVmqUSM5rDx08FBtBkUN1BC6x/G1WbljCtW9KHippkTWZmmjO362bvA== X-Google-Smtp-Source: AGHT+IEwNuwQAVi5Yvu8dGMIzhijwR6FOcHgUOUOQ0MwugBPtx2uTzwwx7jT6o/WfewSMmzvpBq0 X-Received: by 2002:a05:620a:319e:b0:78e:dd41:29e3 with SMTP id bi30-20020a05620a319e00b0078edd4129e3mr155674qkb.35.1713376703496; Wed, 17 Apr 2024 10:58:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713376703; cv=pass; d=google.com; s=arc-20160816; b=zns+4xXAxoGBdFFJfvuSCOaxHqT5QFMpqEtVv0aqaDT2DmppsEh+sb4mN/wXsFvi5N aTjKNkpgfYd7H87XbQ40vCSGY12OyWINe+T1txGko3XTrBqE8PyXe3hDR8ggUtVxQlku wMdoXWpL0IOFsTWfnk+vkpz7IcR7B2WwADrL7cdbTbCW9mubSOanWQUXiIPxDaUO5ikT TQcbabBfgMOakf6ysZGUiDwitmDfUIxk42kE2QLfhzVcrkaDO/IBNZmDvpIO4mjN+8dj hYL7TYCBTJVY0gZzDbLUQrq2UFQEonQkDb4+//7e5YJ1J2fHB55csZpvCZXHE/bkzKzZ YJWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=yh9slf10VIOQVRrgDHredEREC+MGyT23jI/sO3TZ7Rg=; fh=lpkRFA0PN45vwGBxC0t4tOOXa7O+Y2BWTue7S9M+heM=; b=pDkwdgC3ruiuDRUKak3/iO26rDDqZ3KfNr4LoJ+EJ+lYbeivxy/m5kay0NBJhdaTdc k+u0gfzToteC3TAheNpRk+g9qCQeo452MgK2tvnK4ZLPysFCzdfba9zz8hsfEbql3shy iOE/JzASjJQY+qJTj6EBuqrV+P1wcIJhwZR+UVQMHKwqGDuBDMe+5T8Silqp+S/eQ3Io W7C+hZJEutew24DAevXGGXPWs0o0A3T6cf1D6F8K+h3EXCSZStVivWpIxc/T60vkUwAY DD0OHYz04MjXYKaB8wZKsupU99ctFi07+Ku+2nLb+85IOw4CzZhBkrpeCtLTpAqV22nP 6EIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hTDGtFsi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-149023-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149023-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u14-20020a05620a430e00b0078ef5a93ecesi4871813qko.168.2024.04.17.10.58.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 10:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149023-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hTDGtFsi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-149023-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149023-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0A0A01C23FAF for ; Wed, 17 Apr 2024 17:58:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 867D1172BD8; Wed, 17 Apr 2024 17:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hTDGtFsi" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B132A172BC9 for ; Wed, 17 Apr 2024 17:57:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713376646; cv=none; b=TiSsphPhu0jim7Ndr7fChUMOmorDj7Etd9kTHpzNAEry6fxSiJDgNL9sgA99QnJ4Nd6E7M6rz7Nr+f1V5hMJDIhA3KG4Mg0OE8D0iCKU88xKLkqpfWpHGVT7AeljgBQXKH9E8CEbnzO503/uGxKGMV6fhGk8JczMOoOKCGvrMHI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713376646; c=relaxed/simple; bh=3d2ZLhWss3WpYFskVn7ql2myJj3BXlWA7VJpaBADf8c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YTApusvXQBMvw5o0gKhvU+BRsGA0u2G9ayF6HquvkpCXIUyDjojFJJawQRgBo6aRumzlFzyJZPLoYw9uzs61YY3TvWCAfz575Y6i3xbFwsZYLIBjsU+LdkuSrLE/RSLrSjeOLZv4gRqqgIumGf8ZRh1dle40CN+3rIfZVuTUQs4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hTDGtFsi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8293DC072AA; Wed, 17 Apr 2024 17:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713376646; bh=3d2ZLhWss3WpYFskVn7ql2myJj3BXlWA7VJpaBADf8c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hTDGtFsixswGNPPrmpqYl6s6CRY8pUO6WGUadHaGKJrRjlLd8Iz+KXWlowUQG99nX LWB07IiKpAWm25E9qp+0DZGXHXDCiaNKn9DP2an2pz3bguUFK0BeXbo0x4tIQZU6ut IgDJNPKPyuhP4/JbxCnnQhwQAkVYwwJrP/malXaDIC0Rbg0xsxEZEvNLPh+kGsgtno dwVcy6+o7oL1K/pcBgzK8eOTcYphYJPjuqcjPOzUquPGq2J5UJY24n0+/OES9D944S XpGwVMaLb123iTHENsZ5qzMFqht6/ToLU5xP3Y8elj8dY1TYG5ZQqCSManZYmyNuPo xL2hUuJFPbvQA== Date: Wed, 17 Apr 2024 10:57:23 -0700 From: Josh Poimboeuf To: Pawan Gupta Cc: Andrew Cooper , x86@kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Daniel Sneddon , Thomas Gleixner , Alexandre Chartre , Konrad Rzeszutek Wilk , Peter Zijlstra , Greg Kroah-Hartman , Sean Christopherson , Dave Hansen , Nikolay Borisov , KP Singh , Waiman Long , Borislav Petkov , Ingo Molnar Subject: Re: [PATCH v3] x86/bugs: Only harden syscalls when needed Message-ID: <20240417175723.r4si62d6oqirqadb@treble> References: <20240417164514.66hgypzxgqxt3ssk@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=utf-8 Content-Disposition: inline In-Reply-To: <20240417164514.66hgypzxgqxt3ssk@desk> On Wed, Apr 17, 2024 at 09:45:14AM -0700, Pawan Gupta wrote: > On Wed, Apr 17, 2024 at 04:14:26PM +0100, Andrew Cooper wrote: > > On 17/04/2024 12:02 am, Josh Poimboeuf wrote: > > > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > > > index ca295b0c1eee..dcb97cc2758f 100644 > > > --- a/arch/x86/kernel/cpu/bugs.c > > > +++ b/arch/x86/kernel/cpu/bugs.c > > > @@ -1678,6 +1687,21 @@ static void __init spectre_v2_select_mitigation(void) > > > enum spectre_v2_mitigation_cmd cmd = spectre_v2_parse_cmdline(); > > > enum spectre_v2_mitigation mode = SPECTRE_V2_NONE; > > > > > > + /* > > > + * X86_FEATURE_INDIRECT_SAFE indicates whether indirect calls can be > > > + * considered safe. That means either: > > > + * > > > + * - the CPU isn't vulnerable to Spectre v2 or its variants; > > > + * > > > + * - a hardware mitigation is in place (e.g., IBRS, BHI_DIS_S); or > > > + * > > > + * - the user turned off mitigations altogether. > > > + * > > > + * Assume innocence until proven guilty: set the cap bit now, then > > > + * clear it later if/when needed. > > > + */ > > > + setup_force_cpu_cap(X86_FEATURE_INDIRECT_SAFE); > > > > Following on from the (re)discovery that X86_FEATURE_RETPOLINE is a poor > > name given what it *actually* does, can I recommend s/SAFE/OK/ here? > > Or simply X86_FEATURE_USE_INDIRECT_BRANCH. > > > This flag really is "do I want indirect branches or not", which - as > > noted here - is more than just a judgement of whether indirect branches > > are "safe". X86_FEATURE_USE_INDIRECT_BRANCH sounds good. It's a bit long but does describe it better. -- Josh