Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1171548rdh; Fri, 27 Oct 2023 06:48:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHa5tN67VtfK9v3k1QrMkl+LflBC0XY/xKyHWzuf2uay7bJp7We+EdZFnJThXsdcqLvxt7l X-Received: by 2002:a25:244f:0:b0:d9a:f948:aae1 with SMTP id k76-20020a25244f000000b00d9af948aae1mr2657422ybk.29.1698414527460; Fri, 27 Oct 2023 06:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698414527; cv=none; d=google.com; s=arc-20160816; b=OUevZyrDT1SJYa1Ju8iqZZfzdkTc/D1BnCWYOsdj1207FPgWcXS3/ZA8m9nsKzOYvY H8Me0PMfBDhdo7rQvjBtsBP/R4dHDHS4kmVGOCpT6jZjyr0/6dPTkzaFG+cgz+77UEIR jV87JNt9Avdbtn4Vug4rK0zBI/tzMBzIJd2jeEhkJYGDBzaymr127gsP4S6jyzzNjYbg D52XI5/kieB+ugSCLHCYh9bZr3xU58MXVXNNcb99Q8KflL0/oPtiBP+9RIyaIpH8q1H1 g737E6DumdzZluuTs1i33JEDo4ON3gGnDgx0xSMG0rAUgZWkQf5/zLhrVhV1prYuG5Jd PFyw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2hq79WUfpFqvU7st8QuQ+5K+wZ4bIHxOns0r1GRYcuU=; fh=p7ekuMuBKYy6HfUq8fyIfc2tMYhRoZsUjTVXFIuLfSY=; b=rwdGyCOheMd9PB6diUMHwpzSbRGbA9rK658zRkfq59T//6FDvTfnhEaX2Kl0lJUtdX NuFmwJetOIoAXtFr5JoEIbGEqoa66elPHndWxdGFwtLjtq6kAhzCsTut5ugdlF1zcL1Z iWct1eMuUbENQaXTxh6dCMbpaH6tAe+G161L0uGP/6l7TviUzS0CyP2Y+xAiir6YvgVt ll8yThOtzXN0mn/3de4AhbxAtiQIFbh40Z/CrD9sGwnI/1UP20rd06rf0z3Y1CUGKlpW vBlANjuVOihpXAQMKfUH/d9wqgYy10R2oCEKs3TD8718cXXuFVHfD9rgA6tpM5ttG3xx y45w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=m+NrMq5x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a10-20020a5b000a000000b00d743b93bda0si2777387ybp.386.2023.10.27.06.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 06:48:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=m+NrMq5x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 82E338061CF2; Fri, 27 Oct 2023 06:48:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345989AbjJ0Nsf (ORCPT + 99 others); Fri, 27 Oct 2023 09:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345458AbjJ0Nse (ORCPT ); Fri, 27 Oct 2023 09:48:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A31E818A; Fri, 27 Oct 2023 06:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698414512; x=1729950512; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=FT3SYkcDyStolkfc5gH/ZZusESEYmy+fhjCdCEwgFao=; b=m+NrMq5x8XTO8B+y5VFoGpoFawbGMxON/uXoytD3lQz+q37nH29B8WNw gT8vZRZYo3r0Ya4bOdfkv003Z5uMLE2+WWz+DztOzqPln7dg+WEsBUM6i 8IUzagthItg5fclMLZUb0Bnb6UHTodX6LvjY6dNawgeB4atNH+4oftbl3 pger6YfOtxbJKMfmj9UHGNF9mY4cAGlVeoaocfqgP1tcTVNby0L+Lvenl 1+/d4GM5sQ5gZaL5ddgbnAPwzdcniYuaIu6IUmqlaY7bMJv5AMCIVAE0V aDavWdX8lQRT+eJy5qGW+0t1VvWregmm/4l3UAFxOcdCKMYK/UZAq3TAS g==; X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="384983499" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="384983499" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 06:48:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="838066" Received: from dmnassar-mobl.amr.corp.intel.com (HELO desk) ([10.212.203.39]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 06:48:19 -0700 Date: Fri, 27 Oct 2023 06:48:29 -0700 From: Pawan Gupta To: Andrew Cooper Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , 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 v3 1/6] x86/bugs: Add asm helpers for executing VERW Message-ID: <20231027134829.7ehdjwf5pfcqr6xp@desk> References: <20231025-delay-verw-v3-0-52663677ee35@linux.intel.com> <20231025-delay-verw-v3-1-52663677ee35@linux.intel.com> <8b6d857f-cbf6-4969-8285-f90254bdafc0@citrix.com> <20231025220735.gpopnng76klkbuu3@desk> <0ee3e3cd-01b2-4662-ba08-d137663f1699@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0ee3e3cd-01b2-4662-ba08-d137663f1699@citrix.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 27 Oct 2023 06:48:44 -0700 (PDT) On Wed, Oct 25, 2023 at 11:13:46PM +0100, Andrew Cooper wrote: > On 25/10/2023 11:07 pm, Pawan Gupta wrote: > > On Wed, Oct 25, 2023 at 10:10:41PM +0100, Andrew Cooper wrote: > >>> +.align L1_CACHE_BYTES, 0xcc > >>> +SYM_CODE_START_NOALIGN(mds_verw_sel) > >>> + UNWIND_HINT_UNDEFINED > >>> + ANNOTATE_NOENDBR > >>> + .word __KERNEL_DS > >> You need another .align here.  Otherwise subsequent code will still > >> start in this cacheline and defeat the purpose of trying to keep it > >> separate. > > Right. > > > >>> +SYM_CODE_END(mds_verw_sel); > >> Thinking about it, should this really be CODE and not a data entry? > > Would that require adding a data equivalent of .entry.text and update > > KPTI to keep it mapped? Or is there an easier option? > > Leave it right here in .entry.text , but try using SYM_DATA() and > friends.  See whether objtool vomits over the result or not. objtool still complaints when using SYM_DATA*() without the annotations: vmlinux.o: warning: objtool: mds_verw_sel+0x0: unreachable instruction vmlinux.o: warning: objtool: .altinstr_replacement+0x2c: relocation to !ENDBR: mds_verw_sel+0x0 > And if objtool does vomit over the result, then leaving it as it is in > this patch with SYM_CODE() is good enough. Settling with SYM_CODE(). On the bright-side, I am seeing even better perf with VERW operand out-of-line: Baseline: v6.6-rc5 | Test | Configuration | v1 | v3 | | ------------------ | ---------------------- | ---- | ---- | | build-linux-kernel | defconfig | 1.00 | 1.00 | | hackbench | 32 - Process | 1.02 | 1.06 | | nginx | Short Connection - 500 | 1.01 | 1.04 | Disclaimer: These are collected by a stupid dev who knows nothing about perf, please take this with a grain of salt. I will be sending v4 soon.