Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp17444rda; Fri, 20 Oct 2023 18:28:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGT3ao53OD5SCrfeEaNiN09UeLR82OQoU7mmV70Cva9Z90/oEC85pwXxObxBQeqKK2pi61D X-Received: by 2002:a1f:7d42:0:b0:49d:fab:fa37 with SMTP id y63-20020a1f7d42000000b0049d0fabfa37mr3694450vkc.4.1697851732619; Fri, 20 Oct 2023 18:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697851732; cv=none; d=google.com; s=arc-20160816; b=zY2W9g0VTY75urA7Zxelw+v+Pev13v594bARG1zmE+vVj8VgNSCFBeHnI86pYY2Ik3 nAhZUWM0b5pdTgOnCq99M9wkgjuJYby+lYQXi7WVavShTSVLMD3P/Q9igUdsV/30aNg5 cV3deX8wKXGy2DdpjzEZtagsjifvPelMaphn9aCkl6TwaQgum97cSgDAJVGcEsCQAf5r Yr7FzeoxW1VoLrbDWsSOc/592yf9QiY32dLyqjEejb7FbQAnlxeEVEHr7ECqPbsktEJq aQcmDqljq/0bcOoex4OtYy4YIhscUzvzuSx8zizfNszBAn+w+fAsOsUaLUdHq1D3C6DG cM6A== 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=mma9C50aDVRcZWrMbX/Xa17xzeBlnRFYrYa+JYGFDms=; fh=p7ekuMuBKYy6HfUq8fyIfc2tMYhRoZsUjTVXFIuLfSY=; b=wB5/zEf9VXBGQST7aMXiedLNqK+nNGNreNRqAjkD6rBqsZJqmDifxVisgBF3hdS47P NHnRytoImTd5VXB8XH74A9eDY1BTxv2bN6LRPMN6+C7fsAol9UEFo92w7PCFRLAtuHQj Fb+Ih6869H1lQNx6GLoOA+mbzA0us02ld8VrYgNpGye+rIH9R3wnNJ2L2VlItjvRLo6S c3afQKbyiBux7Dd6Kh/b7dnx/fP3CMJAIzujk4kAb0YHrlhqNwDLc0Xw+x34fYM9qgUQ M32xo1cTNtTmRjm8tam4PTUQgOZODyRDjtD3i/g8prKEHEDFup1ppLimzaADRwZfuHTk wzcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bqTLis+S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ca15-20020a056a02068f00b005891f742953si3062817pgb.29.2023.10.20.18.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 18:28:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bqTLis+S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id F0AB183383DB; Fri, 20 Oct 2023 18:28:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbjJUBTO (ORCPT + 99 others); Fri, 20 Oct 2023 21:19:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjJUBTN (ORCPT ); Fri, 20 Oct 2023 21:19:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3526BD67; Fri, 20 Oct 2023 18:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697851148; x=1729387148; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=czgDYYnGMR+x6IWe3MoUs9kSDZkqARZu11lHJOx2X7w=; b=bqTLis+SD8VPoBFNPZmTqWEaHYUC/5bhprHxghuFu9y0J/EToCBfZqNe X8yxzE6QcgIa8uDzrrYI7AaDOKCvQwBfAfcqFA9SUTMwaZw32YbXtH2DI DhNYc8hd7Q+Z/E+//Q8kZPM5QOPQTn15Gv/V11z3z3FUP+YIRP7JoHLiN UITYBpYHdwx3tRtreV60os912VwjsBxbj/GBDRjS2pjdSx9YzIxj5yc4T kX7YU8btB1USQ6Z2HELCAbzh+VfQXLmzY7KFXrF5yyfoHBu5GXp9L+asX Ou/iLx6PC8nJ2odqQTbr+mU68Audt8nSwnI1h9GNec4TEqD5VSQS3wn++ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="417732654" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="417732654" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 18:19:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="5268375" Received: from hkchanda-mobl.amr.corp.intel.com (HELO desk) ([10.209.90.113]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 18:17:55 -0700 Date: Fri, 20 Oct 2023 18:18:59 -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: [RESEND][PATCH 1/6] x86/bugs: Add asm helpers for executing VERW Message-ID: <20231021011859.c2rtc4vl7l2cl4q6@desk> References: <20231020-delay-verw-v1-0-cff54096326d@linux.intel.com> <20231020-delay-verw-v1-1-cff54096326d@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 18:28:47 -0700 (PDT) On Sat, Oct 21, 2023 at 12:55:45AM +0100, Andrew Cooper wrote: > On 20/10/2023 9:44 pm, Pawan Gupta wrote: > > +#define EXEC_VERW \ > > + __EXEC_VERW(551f); \ > > + /* nopl __KERNEL_DS(%rax) */ \ > > + .byte 0x0f, 0x1f, 0x80, 0x00, 0x00; \ > > +551: .word __KERNEL_DS; \ > > Is this actually wise from a perf point of view? > > You're causing a data access to the instruction stream, and not only > that, the immediate next instruction. Some parts don't take kindly to > snoops hitting L1I. I suspected the same and asked CPU architects, they did not anticipate reads being interpreted as part of self modifying code. The perf numbers do not indicate a problem, but they dont speak for all the parts. It could be an issue with some parts. > A better option would be to simply have > > .section .text.entry > .align CACHELINE > mds_verw_sel: > .word __KERNEL_DS > int3 > .align CACHELINE > > > And then just have EXEC_VERW be > > verw mds_verw_sel(%rip) > > in the fastpaths. That keeps the memory operand in .text.entry it works > on Meltdown-vulnerable CPUs, but creates effectively a data cacheline > that isn't mixed into anywhere in the frontend, which also gets far > better locality of reference rather than having it duplicated in 9 > different places. > Also it avoids playing games with hiding data inside an instruction. > It's a neat trick, but the neater trick is avoid it whenever possible. Thanks for the pointers. I think verw in 32-bit mode won't be able to address the operand outside of 4GB range. Maybe this is fine or could it be a problem addressing from e.g. KVM module?