Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2367055rda; Tue, 24 Oct 2023 23:59:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5cfivTunED+zCuUkloTwkK7Kuhr0o2Ivz6e8fUC6QhuC5LqzLPwKaq2Xs1IFVeWQVWNxr X-Received: by 2002:a0d:e6c9:0:b0:5a7:c924:9bdd with SMTP id p192-20020a0de6c9000000b005a7c9249bddmr18132253ywe.6.1698217142030; Tue, 24 Oct 2023 23:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698217142; cv=none; d=google.com; s=arc-20160816; b=sbuyqIZJWm3v778a7G76ZVL0LBWm+7Ulys02hlPjMWWx3mVc0MQJABWwf6YH/HJx7K Q7s1gVOz2cpsy8w7lK/g9hcH10OyZVj3zgPscCVO8H7qc6uAxwV0h+x0d9RKGNXgg5Yo 6SCGNbfQKYHaOUgdLStCz5eQplQNC67/zDYWuYl9t/KyrkhXN9CJIuKaPHNKIu1N+xXW yDZsUuPzvJkjl1fLyT/8eR1XPttXk1uba+S3MidcjOpEzhd49xt52XVBfoLft0558ZEv DQ4QK6X5Igo3ZHALUmVrbtx0b1BZ0R8oonSiWoggmAR+f9DqZHFmo6R+Af9zZJhz5Vi/ 80Cg== 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=eDKxmuej9tXfCEvb9vvcLDbQO6JariJ+oFUVHWu6xYU=; fh=FtUvlj3N+mHXQqmPX59TJy8Xsw0SZcoZZJJFTd27Pr0=; b=rdb7q2bgoZqAqOdwMhAZzEMHBt6BLnqSUewyp2r8ZcxhWjmHAtSpbwTZzAdOsKWeoT hat8lVSoPMkQVgXp6awY1Voc+Qyfnbbqo4vVwB2m4XAjuHYZmTFk34uqlAe55hT0HF44 XJy9b47epV7jDBVhdqVzkqjkpsAx1DMrl+LXfLl5H9RZrTmW5WmZ8wCm45v1E7uzvQcN 64p+mzv34qk4iCjf/nNANuEeZ8q5bOrXHP8KDUmz7d13vlLbG1Lc96WIfMGpte4mi335 DnZZnPnZiTgwBiyXxDx0QJvOh5XGkoshzFGY2qBhCEmSLUemyFTscbZJ6sk/hh5wIIkE Qwwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=lXRiBz0f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x62-20020a817c41000000b005a7fbac35c5si9760184ywc.451.2023.10.24.23.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 23:59:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=lXRiBz0f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BBD2C80236FA; Tue, 24 Oct 2023 23:59:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232448AbjJYG6z (ORCPT + 99 others); Wed, 25 Oct 2023 02:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232504AbjJYG6x (ORCPT ); Wed, 25 Oct 2023 02:58:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6671DD; Tue, 24 Oct 2023 23:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eDKxmuej9tXfCEvb9vvcLDbQO6JariJ+oFUVHWu6xYU=; b=lXRiBz0fpXvDJLERZRH4R6/dOH 8WcES3v/b44vy20LpA3DpgZjtcOxXkV04gv+3jtsISxr/DHSqc9/a06KYB9iwYwCy1a3m5959tzve 3l7VW09AOplEaTSe/3KEOsT6trZpwbG8OND6mSMxxXvTHyCDks1p372/+sWzgCVQht6CACs+dEDst Wlf9qsXXrbbMuoejkBaHDbs0NL5Jvf7q+cqI/O9NKQ+6ti8K6Ak07Cp+nisGb8iZfrmQehOe/X0ez doIHoEEeFwKKyKPRHrXnwCbUwPwTQc64qhqN19lmEC8VIyNdOkFy2DljqH4vsIivevY0Uzg47nCTG KibtAllw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qvXqN-007H5T-Bg; Wed, 25 Oct 2023 06:58:19 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 0A9E030047C; Wed, 25 Oct 2023 08:58:19 +0200 (CEST) Date: Wed, 25 Oct 2023 08:58:18 +0200 From: Peter Zijlstra To: Pawan Gupta Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Andy Lutomirski , Jonathan Corbet , Sean Christopherson , Paolo Bonzini , tony.luck@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, Alyssa Milburn , Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com, Alyssa Milburn Subject: Re: [PATCH v2 1/6] x86/bugs: Add asm helpers for executing VERW Message-ID: <20231025065818.GB31201@noisy.programming.kicks-ass.net> References: <20231024-delay-verw-v2-0-f1881340c807@linux.intel.com> <20231024-delay-verw-v2-1-f1881340c807@linux.intel.com> <20231024103601.GH31411@noisy.programming.kicks-ass.net> <20231025040029.uglv4dwmlnfhcjde@desk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231025040029.uglv4dwmlnfhcjde@desk> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 23:59:01 -0700 (PDT) On Tue, Oct 24, 2023 at 09:00:29PM -0700, Pawan Gupta wrote: > diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h > index c55cc243592e..ed8218e2d9a7 100644 > --- a/arch/x86/include/asm/nospec-branch.h > +++ b/arch/x86/include/asm/nospec-branch.h > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > /* > * Call depth tracking for Intel SKL CPUs to address the RSB underflow > @@ -329,6 +330,29 @@ > #endif > .endm > > +/* > + * Macros to execute VERW instruction that mitigate transient data sampling > + * attacks such as MDS. On affected systems a microcode update overloaded VERW > + * instruction to also clear the CPU buffers. VERW clobbers CFLAGS.ZF. > + * > + * Note: Only the memory operand variant of VERW clears the CPU buffers. > + */ > +.pushsection .rodata > +.align 64 > +mds_verw_sel: > + .word __KERNEL_DS > + .byte 0xcc > +.align 64 > +.popsection This should not be in a header file, you'll get an instance of this per translation unit, not what you want. > + > +.macro EXEC_VERW > + verw _ASM_RIP(mds_verw_sel) > +.endm > + > +.macro CLEAR_CPU_BUFFERS > + ALTERNATIVE "", __stringify(EXEC_VERW), X86_FEATURE_CLEAR_CPU_BUF > +.endm > + > #else /* __ASSEMBLY__ */