Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1294632rdb; Fri, 1 Dec 2023 12:01:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IERuk5sq2xHW0e42Il7agLnC/Wt7hXmzwpFgpoB6dAzqFUZKs75hmu29kmgUB9kPJYy17NC X-Received: by 2002:a05:6a00:1d86:b0:6cd:dfff:19b3 with SMTP id z6-20020a056a001d8600b006cddfff19b3mr46474pfw.32.1701460916809; Fri, 01 Dec 2023 12:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701460916; cv=none; d=google.com; s=arc-20160816; b=Vn9wlIdNcd6SdZMi2Ld2IAUeHUevh60wf8FIC5tTNx3p8AMs4Yr6I8OIVf0xLF/RwQ 8t8XEn3RjpQHdAZi1U6LQ/flFUVP5YagyW4vTOJlLBGMAoesCM7yG1yz+snk8PkpHrvW mrQoRv0raVdNuP5dZfI/69/JYwra5WoUU8aVDnGKiGMDvAlLqfW1K5Kvwa/Fgiz702Pj 0hKue/nT3nLHI9BIaTxEWxoEH1ZuOQNn3U1875B/mp/uA285BkT6CeCZPfRRnp2qhxQL KwatmMetT5PO87EUrUasmL68QetBKgKU6vPdmv2hdrP/CaqiYXlo7U6oDeheuWDXJ8Bq ApTw== 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=rcjODhvGG2R6WJn0rkxcbCyXIazGTzlhqKqtXDjy+ZY=; fh=fn3Mli8hHmON3HPRYVq8bb/0kBhEcxKYt/5phEi34xo=; b=lBUgwYai+g5YXjvq4VYIalMbFz8p6T+xyAu2vX+AdYRr/KbpvUd9LgK8PkePvLXQaM KDykuFyHTcAJZgibe9L+zpiWYR7uX7xi6+UteBWHzbzoDSPtuefSkxBFyT7QoBS1i0rE x3Pw4ehsMVhKurnwYAoql/XpEZKw0XQUN8Ur801+kVu55h5YDVOWRZdiQwDXCFqbQB+U Q3xohrmzTL5hVQO6kmWV1eKjwScr/kqU51elbk7kQugyCGl/HK5AtbhPolSZdVL98e6e uS1EuSBj1Lr1XJJzHe4rUvXvHWEL0Sx5togHNKzKLUJmF4hOdHJU1rUqz2dgCz9PLyJk EPDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="fNPWC/g0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id fc36-20020a056a002e2400b006cb68ae3b58si3940424pfb.182.2023.12.01.12.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:01:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="fNPWC/g0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 1BE1480739ED; Fri, 1 Dec 2023 12:01:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379567AbjLAUAw (ORCPT + 99 others); Fri, 1 Dec 2023 15:00:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379559AbjLAUAu (ORCPT ); Fri, 1 Dec 2023 15:00:50 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E517795 for ; Fri, 1 Dec 2023 12:00:56 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5042AC433C8; Fri, 1 Dec 2023 20:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701460856; bh=IT7yyK2lIBKnfcOQs1byPql0uqwNmalDnLqIwsW1VZw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fNPWC/g0a2x2cmuUHv1mcctnA+KRhgd9p3y7l11tr/iMr9fHvbQmGdDAPGs/jBW3e 530pOyTqaWrhQf8yGhGd4F42a+0XOxsg5GcCntPFajZbuaumj792bydrBtBr8nepZE vasZlw/KSLZs2v7F2Co9V/rhqlGoCLT1ixGg30992DzMr4WAaUWoXWfX1DPvC9900h ds+5HasFsw0cILwlbw0SOvFzuFPCHPzAhhqJzdZaDgZmkyLzdvOfUYVeeZI5AZQ5qo 2CZRh1FWiqD0QgXUYu6yjSeF9hePz4ANF0XrwvzDmWpKdbjcU73s7Tl0xJikEijj6Q x63GZHSbidejw== Date: Fri, 1 Dec 2023 11:59:54 -0800 From: Josh Poimboeuf To: Pawan Gupta Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Andy Lutomirski , Jonathan Corbet , Sean Christopherson , Paolo Bonzini , tony.luck@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com, Andrew Cooper , Nikolay Borisov , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, Alyssa Milburn , Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com, Greg Kroah-Hartman Subject: Re: [PATCH v4 4/6] x86/bugs: Use ALTERNATIVE() instead of mds_user_clear static key Message-ID: <20231201195954.sr3nhvectmtkc47q@treble> References: <20231027-delay-verw-v4-0-9a3622d4bcf7@linux.intel.com> <20231027-delay-verw-v4-4-9a3622d4bcf7@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231027-delay-verw-v4-4-9a3622d4bcf7@linux.intel.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Fri, 01 Dec 2023 12:01:08 -0800 (PST) On Fri, Oct 27, 2023 at 07:38:59AM -0700, Pawan Gupta wrote: > The VERW mitigation at exit-to-user is enabled via a static branch > mds_user_clear. This static branch is never toggled after boot, and can > be safely replaced with an ALTERNATIVE() which is convenient to use in > asm. > > Switch to ALTERNATIVE() to use the VERW mitigation late in exit-to-user > path. Also remove the now redundant VERW in exc_nmi() and > arch_exit_to_user_mode(). > > Signed-off-by: Pawan Gupta > --- > Documentation/arch/x86/mds.rst | 38 +++++++++++++++++++++++++----------- > arch/x86/include/asm/entry-common.h | 1 - > arch/x86/include/asm/nospec-branch.h | 12 ------------ > arch/x86/kernel/cpu/bugs.c | 15 ++++++-------- > arch/x86/kernel/nmi.c | 2 -- > arch/x86/kvm/vmx/vmx.c | 2 +- > 6 files changed, 34 insertions(+), 36 deletions(-) > > diff --git a/Documentation/arch/x86/mds.rst b/Documentation/arch/x86/mds.rst > index e73fdff62c0a..a5c5091b9ccd 100644 > --- a/Documentation/arch/x86/mds.rst > +++ b/Documentation/arch/x86/mds.rst > @@ -95,6 +95,9 @@ The kernel provides a function to invoke the buffer clearing: > > mds_clear_cpu_buffers() > > +Also macro CLEAR_CPU_BUFFERS is meant to be used in ASM late in exit-to-user > +path. This macro works for cases where GPRs can't be clobbered. What does this last sentence mean? Is it trying to say that the macro doesn't clobber registers (other than ZF)? -- Josh