Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp198029rbe; Wed, 28 Feb 2024 17:39:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX2oOXJ9G77ucBQjJcP9lLn7Fpszg5EmsiVkuto8lApqML+bHDahIhXoWe3OfjXoG89JQFpARglzkBiVmGuQorx+tew2v7HQD44cYMXzg== X-Google-Smtp-Source: AGHT+IHx9l9NLgQ4rs6EnlQ/z4izyHBP7rXXVz7OCbfoOoSF99CmxP4iPfRVnYkoww32rVZmKiA7 X-Received: by 2002:a05:6402:3881:b0:566:f60:1b0 with SMTP id fd1-20020a056402388100b005660f6001b0mr519571edb.11.1709170777706; Wed, 28 Feb 2024 17:39:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709170777; cv=pass; d=google.com; s=arc-20160816; b=aBmD8WmTtTpktL+L5a0QUDUnm61COVwrXxbKRvybyVRNxcIDY4G4Fg0bmO0fIPtc2l JGX33NAZlHjei0CGE2duc7ZK9kWOajVdRp/lEbChwyAIym63htMKgnxoNeM5Zm9BVcZn cGRXBA3S42tLdOnHCeIJmif98nH4DNJBkZ9qR9CJWO+joOfIeYrwSw2UTbZrQdWgrnMP gnEDSSNsPRmXei/gYljcX6haXS68Srwi00EzdjZKHJgicC0XDFN0cCwpkXtuaz0EQhUx RBhDwiz5+REckb/rTq1XlIVwCiIqkoXsFGS+GoZ5wIOIcS3ISjoz+pi58cEgLlgBfrNE /wIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=k7TFwWWgSQBFVOHErfuj01vMgkl5KjFujWJvgAHsyOs=; fh=q4WM2wqCedR9mFQITHsb+HJeE9hhEB6CqCtrioT94vQ=; b=rRHzC6BNRsKp0GZOIpeuH05BezkHH4D/rJ9PyN08fdSSsOy+5tkHE5z7rbQcRxI0p2 +xbykitSwBuFtmyCZC8fEighUfmTAVr9w/uFtvvZacyRFV2fiw8KNkZWOCi8y1MWernA iyc97Kn36xoXEADjy2kWu7t+3rtZdyWtzVgzRVFxRusoCsFnpp2EiWmY67GmlZrbAgbV hL0+ebdtbfeERMwOHlcLF3JvtgBSY678P4VjGd6oHk/hGQj/UMJ7tVoujc2PCsyEgzmT +cuAv8tOOgN3SWZNT3b7Tb++yabpyzGKOHFosbJq8dANMnwcwxgkxUOLCqwlNtVUtc62 +mYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FYVBmOLu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-86007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m21-20020a509315000000b005657ae92735si104270eda.376.2024.02.28.17.39.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 17:39:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FYVBmOLu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-86007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 629D31F2302B for ; Thu, 29 Feb 2024 01:39:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB2942E410; Thu, 29 Feb 2024 01:39:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FYVBmOLu" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 1BCE62C856 for ; Thu, 29 Feb 2024 01:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709170769; cv=none; b=TSaAjlH1A3Q4KiIcv4fQz3Q/z9XRJN36pHLRoBOZfBSN7T/6Xy+6s3RsIHgcUzFkvCsiT873iByfN62PR3ZGRZ/7TqcZY8Zkg/OnI0i6lY+/5WgtinxTtGOw00O1TvxLo89pZRWPpF/eAeCcU3S4MHOrS7JrhF28ZU5esJo0vu4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709170769; c=relaxed/simple; bh=Te/ym0F/L4+BIzQVM6AcrzTissbR9x1/wUhg7GZObjM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YlhrzZlXsjaRIzg1OwS334gldpnS3ZztDtImrSHSQh0mVszNi9cLQMdJxykBjTJqg88MbVzUZeumjCec1viipSTY1bryd8UxF0h0M2cxXm+UrIcR/7z7gjMSqNbkxrN4MtsNWOmTNkONdW++ixcJoyNTdmbwkL4MWeuXSpEId0A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FYVBmOLu; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709170768; x=1740706768; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=Te/ym0F/L4+BIzQVM6AcrzTissbR9x1/wUhg7GZObjM=; b=FYVBmOLuwDuHLMyMzb41P4dVCgPtC2397DiR92r1uOYUerwQ6bwCsjvJ 5F3hWFuPWSKa+AYKZLgk8Vdxmpybqg4Cpx5nkSwAJjEhuETvc3yTjUlyy N/IpmS64CDQ5MQOJsFGkXvzT7gsss6jrsNmTDgQ9o9OP/bhma7zywGFat yuepQxfMlvEOQfdd6C+HZqahQmG4ByVgkn8BzJxWl2QMTGMruU+CggEA6 n0TmjJKMHvIO/bZIYYzxNAYmscx2NxZaEfMNTnffVXSe9vyjLEfupqfgk b/kiPIZ73WLq0SCnHEz39ZnZPyahp00qN4WRpfUjUf44bQepUQfVLk2Js w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="4196284" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="4196284" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 17:39:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7514126" Received: from vabarca-mobl1.amr.corp.intel.com (HELO desk) ([10.209.19.138]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 17:39:26 -0800 Date: Wed, 28 Feb 2024 17:39:24 -0800 From: Pawan Gupta To: Jiri Slaby Cc: Nikolay Borisov , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Daniel Sneddon , linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/bugs: Use fixed addressing for VERW operand Message-ID: <20240229013924.cksuxebpylyeymzo@desk> References: <20240226-verw-arg-fix-v1-1-7b37ee6fd57d@linux.intel.com> <92440f47-21b7-4f4f-ad99-a99358cfbedf@suse.com> <373674e4-cbd0-44d7-98c7-304b0ab4f34b@kernel.org> 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 Content-Transfer-Encoding: 8bit In-Reply-To: <373674e4-cbd0-44d7-98c7-304b0ab4f34b@kernel.org> On Tue, Feb 27, 2024 at 10:43:53AM +0100, Jiri Slaby wrote: > On 27. 02. 24, 9:47, Nikolay Borisov wrote: > > > > > > On 27.02.24 г. 1:52 ч., Pawan Gupta wrote: > > > Macro used for MDS mitigation executes VERW with relative addressing for > > > the operand. This is unnecessary and creates a problem for backports on > > > older kernels that don't support relocations in alternatives. Relocation > > > support was added by commit 270a69c4485d ("x86/alternative: Support > > > relocations in alternatives"). Also asm for fixed addressing is much > > > more cleaner than relative RIP addressing. > > > > > > Simplify the asm by using fixed addressing for VERW operand. > > > > > > Fixes: baf8361e5455 ("x86/bugs: Add asm helpers for executing VERW") > > > Reported-by: Nikolay Borisov > > > Closes: https://lore.kernel.org/lkml/20558f89-299b-472e-9a96-171403a83bd6@suse.com/ > > > Signed-off-by: Pawan Gupta > > > --- > > >   arch/x86/include/asm/nospec-branch.h | 2 +- > > >   1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/arch/x86/include/asm/nospec-branch.h > > > b/arch/x86/include/asm/nospec-branch.h > > > index 2aa52cab1e46..ab19c7f1167b 100644 > > > --- a/arch/x86/include/asm/nospec-branch.h > > > +++ b/arch/x86/include/asm/nospec-branch.h > > > @@ -323,7 +323,7 @@ > > >    * Note: Only the memory operand variant of VERW clears the CPU > > > buffers. > > >    */ > > >   .macro CLEAR_CPU_BUFFERS > > > -    ALTERNATIVE "", __stringify(verw _ASM_RIP(mds_verw_sel)), > > > X86_FEATURE_CLEAR_CPU_BUF > > > +    ALTERNATIVE "", __stringify(verw mds_verw_sel), > > > X86_FEATURE_CLEAR_CPU_BUF > > > > Actually thinking about it more and discussing with Jiri (cc'ed), will > > this work with KASLR enabled? > > I might of course be wrong. We appear to rely on the asm+linker here. You were right, with KASLR enabled, instructions with fixed addressing in alternatives don't get relocated. I guess we will have to keep rip-relative as is. Thanks for catching that.