Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp951343rdg; Wed, 11 Oct 2023 09:50:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1B7Q7+k8qMrNgANL7+SWB4vuS0Xr/YeEAMceFhB9Lrek57ze12O8rRoJVz05F6Ay7mnZ4 X-Received: by 2002:a05:6a20:1454:b0:16b:c22c:f99c with SMTP id a20-20020a056a20145400b0016bc22cf99cmr18027198pzi.32.1697043031462; Wed, 11 Oct 2023 09:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697043031; cv=none; d=google.com; s=arc-20160816; b=hJihOIKKzD05uSwo3EuP3Boww5mSRbh4eknaaYBYGVpmlMOwD3rM7CeNsFC4C5ovq7 W8p8VG7KbZaW5PggVFQ+AehW1I617JkzXdk/YKaUWufo9AK1wb+oYn4g8JEC64zEV72q ySetZBPBgEurNYvnJtxRS1pb4yEjDPwXM5uEsH+tFHLqvH8FNhi9iBTXcVnSAnbM3j/r WTQdebT7P8ubp1z+hv9rQFUP4q1oRP1U1Iwncb3T275UM5ndk7Y+XSbmcMPcgJVCGzBe FbRFBCPT+TBeWzwMN94y98KV3gpGWsJt2rIoq+tTPTAt0ajx8m4i63N6FI4PFF8qszDf yntg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=US6Qqr4hyH5g0TIe557DzmWqRFiWpH3h3ArDDn2Tedk=; fh=mAnUTSIwprYlZ89G6Mo4Bz0PIr675sNGOXTnOjx84hA=; b=SOR36D5+b12+KqcI6Ttgd0drJqs13CX/McyL72JQeHWsQzWXWouFZCMS+52rDAfxsv 07wh4At+kRqoz7zkIbwJa+aSc+vbKsKLAyvm5pWOLly74l7XuY+ojY6Ev/BvqyaHytjR 4YLST0FYI6enaOJAaLYKusrk167fmTCevnCgXChiMc0ld8cGWRFlM3YenqE3gLKcggtb p3XUZ9XR6xKKoconmPK8wGhfxA+M64oXfK4Wl+882Jy7Q9nZMT4U5y9sYmjS0VSRon4a hoQiRuyNnm6Tvc4WaaWaG5AmGn/Sc0IGy06NVnb8pUNNq+OC8BrfG0mtUjVXZDtbBD9M f7Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OMAZwFeP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o3-20020a656a43000000b005859aec9406si201780pgu.16.2023.10.11.09.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 09:50:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OMAZwFeP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C94F0818D53A; Wed, 11 Oct 2023 09:50:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232949AbjJKQt7 (ORCPT + 99 others); Wed, 11 Oct 2023 12:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232387AbjJKQt6 (ORCPT ); Wed, 11 Oct 2023 12:49:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD2E8F for ; Wed, 11 Oct 2023 09:49:57 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AC2DC433C7; Wed, 11 Oct 2023 16:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697042997; bh=Ikfx5L6Si4W21+HXhUSpPD2tmrZxnnj0/OglFvXXRgY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OMAZwFePMsNpP9FoedKdy8cHPLkS5INAt4XzUU7unBLqY2hTMrY4GWwu6do8ZgqP3 jOEyg58L9ClApIF7mPsAyLyGC/XqXqguLCZQnPbTbpkGX7SuFssyg1/u28sdxbHVLd FAYbXKypOrDemTS28i92ULGqeTPqCsJz77lStbP3osINIO/LmWbPijVBnT670mlGKF eq8eTQcr5nNXyQM0MsQzzc04Znmu6sdQ0V6j5pvAEF6j0u9LlKAVHtL/+9VLlnfceG ZQ0JehyzWxsagjrMQzeI/o6eGqjhhBD+kppEW83ivBhNtEKBbjkl2dHczYTo4HQ0rg QHWywNFjV9AiA== Date: Wed, 11 Oct 2023 09:49:55 -0700 From: Josh Poimboeuf To: Breno Leitao Cc: tglx@linutronix.de, bp@alien8.de, Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Pawan Gupta , leit@meta.com, "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v4] x86/bugs: Add a separate config for each mitigation Message-ID: <20231011164955.mm5ipmuyf4rje5u3@treble> References: <20231010103028.4192223-1-leitao@debian.org> <20231011044252.42bplzjsam3qsasz@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 09:50:07 -0700 (PDT) X-Spam-Level: ** On Wed, Oct 11, 2023 at 05:20:59AM -0700, Breno Leitao wrote: > On Tue, Oct 10, 2023 at 09:42:52PM -0700, Josh Poimboeuf wrote: > > On Tue, Oct 10, 2023 at 03:30:27AM -0700, Breno Leitao wrote: > > > +config MITIGATE_MDS > > > + bool "Mitigate Microarchitectural Data Sampling (MDS) hardware bug" > > > + depends on CPU_SUP_INTEL > > > + default y > > > + help > > > + Enable mitigation for Microarchitectural Data Sampling (MDS). MDS is > > > + a hardware vulnerability which allows unprivileged speculative access > > > + to data which is available in various CPU internal buffer. Deeper > > > + technical information is available in the MDS specific x86 architecture > > > + section: Documentation/arch/x86/mds.rst. > > > > MITIGATE_GDS seems to be missing? > > GDS is named `GDS_FORCE_MITIGATION` instead of MITIGATE_GDS. See > 11cf22869ea ("x86/speculation: Add Kconfig option for GDS") Enabling/disabling GDS_FORCE_MITIGATION doesn't enable/disable the mitigation, it just changes the default. For consistency that option should probably be renamed to MITIGATION_GDS_FORCE. It should depend on MITIGATION_GDS. If MITIGATION_GDS is disabled, gds_mitigation should default to GDS_MITIGATION_OFF. e.g., something like diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 66bfabae8814..c8c879302b37 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2549,9 +2549,16 @@ config SLS against straight line speculation. The kernel image might be slightly larger. -config GDS_FORCE_MITIGATION - bool "Force GDS Mitigation" +config MITIGATION_GDS + bool" Mitigate Gather Data Sampling" depends on CPU_SUP_INTEL + default y + help + (Insert actual description here) + +config MITIGATION_GDS_FORCE + bool "Force GDS Mitigation" + depends on MITIGATION_GDS default n help Gather Data Sampling (GDS) is a hardware vulnerability which allows diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index f081d26616ac..43ad3eee3d4c 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -671,11 +671,15 @@ enum gds_mitigations { GDS_MITIGATION_HYPERVISOR, }; -#if IS_ENABLED(CONFIG_GDS_FORCE_MITIGATION) +#if IS_ENABLED(CONFIG_MITIGATION_GDS) +#if IS_ENABLED(CONFIG_MITIGATION_GDS_FORCE) static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FORCE; #else static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FULL; #endif +#else +static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_OFF; +#endif static const char * const gds_strings[] = { [GDS_MITIGATION_OFF] = "Vulnerable",