Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1351277rdb; Fri, 20 Oct 2023 16:55:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9/lf5H49dlpxpIyr0MOvznZY1SbyPdyeBecewoJGcN/EvZDqEAvjnSA84LIizFUf2d/1O X-Received: by 2002:a05:6358:89f:b0:14a:ddb8:9a12 with SMTP id m31-20020a056358089f00b0014addb89a12mr3419706rwj.6.1697846158186; Fri, 20 Oct 2023 16:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697846158; cv=none; d=google.com; s=arc-20160816; b=JSSeSz+deHMvEbJy+BKjSyQjKYXSNGrnQ+5lmWMRyFCAV3kA7nfEBeLOXvgdthF7Qi L8Knns7LxwX89nFGKT19c5MtT9+u8m7TgnU4Md8xPYWBToiQxO1MWHcl2JWePRR+L3Zm 3aBYqW9Vey9dDYjwXOrAmWCCFAdW/MpWc4I+ZrIgvZZ1DdABoKFbYDmKGdDiDY2zOcsh +j6Ga9V0Fl9kUaEKjLv8tcy9DSprhMTBJ9XKWD/jR9tzUvBMtnIQnSrSYdXVt3XPPvs6 x383QxNLjceQUxI2xXlgedO3SRQtmkIarSYc5TzD79am32/1nyxQoqcOg4X4dm23F0XM HVUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=ip1Aeveb78fjb7WfIxeGcmZAFpv9+SodWkVoyClpqlY=; fh=Xe/+c4QMt9PJzG7LiOuXlUDyhgsfhdyK+4KMZrQimP0=; b=rqbNY5OZVTpqDIbTaEGPiYsBBiBruXmQdGsgKQCoTUL71xatOunqzHMKrJDK0HCg3n uO37OinFGc4qFAPO3+/fIFLBqLGgxNTIePbkAxJqdL2ap5j0JTgMCZEVCtfeyKIwHHlj s3SJGFKWui7YJMv21f5meJTOgYLCs2HBNPqmDVP0e58SoHzI/6eJfXQkk/d1MJ/dgHDQ Cy9bgbuG+7U6a+PzXnKJbr/2ga8Y+K3SniS4Qr59/eDfiGPXXEMvwP2nOGAqpNQYEjEc uyvbyzZ2Xrl6KCKLQBJK3z7XoHQSjWGcK05iJQFwRRZZKA1tvgeZojFJG7LA0qJAUwNL iQdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b="qOwEsU/w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s29-20020a63925d000000b00577f4d736bbsi2755716pgn.373.2023.10.20.16.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 16:55:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b="qOwEsU/w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 49DA282FABE5; Fri, 20 Oct 2023 16:55:57 -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 S230311AbjJTXzz (ORCPT + 99 others); Fri, 20 Oct 2023 19:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjJTXzx (ORCPT ); Fri, 20 Oct 2023 19:55:53 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDD13D79 for ; Fri, 20 Oct 2023 16:55:48 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-408002b5b9fso10708375e9.3 for ; Fri, 20 Oct 2023 16:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1697846147; x=1698450947; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ip1Aeveb78fjb7WfIxeGcmZAFpv9+SodWkVoyClpqlY=; b=qOwEsU/wNv/M7uE2HtK5F3Ex97t8AoBzQN/+c+EZfAfvuIibyGgcwk5lzXjOW+4mhl 2PBHmb0DATH2hqktgQtrOUqZ1f7ar94eHTyn5PCOFh3t+1Fh746BJwoGlTulmGzHbYiS QmDnmehikN8FjG/mam8hyDD2iK3xm1In4IT4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697846147; x=1698450947; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ip1Aeveb78fjb7WfIxeGcmZAFpv9+SodWkVoyClpqlY=; b=ao0ExgawcxWlHq9/OEq5pwZlqL1Yv73JxleRwQDWW3FJehODrkMd1F6u+rhesWBhTy UgnLN4yI9d7RvpVGhJWBVWOH30bfCK+hYgaYPQ/2zkcQaHw3l+UE21ZB7uoutaSyXjQU cry2778VLaVZK7rSxQWWdcPH3uSxEAdgREOyZGaRhXWg9l5Xjv07GiGxFWhZd3x7BmCs uPmSs/cJk/DCMiidtKeQyZfbyWv1/exLaDZmhgWX3QjZNiGDYQ89TajNe1aoSxOkZP/5 v0kbLgRq02dz2IHKRLonB3DauoODaGADPVDnU9UVuecgIgOAeC7b1d1xMGuNcABN8itt w1ZQ== X-Gm-Message-State: AOJu0YyFzi/0foCEL/MdJUM5M00lQlfXFOOy3gmURZmFwuigZVXj/lIJ ysoimuR/mwXMr0gvXAkvxRTbYg== X-Received: by 2002:a05:600c:6027:b0:405:3b1f:968b with SMTP id az39-20020a05600c602700b004053b1f968bmr2462730wmb.21.1697846147230; Fri, 20 Oct 2023 16:55:47 -0700 (PDT) Received: from [192.168.1.10] (host-92-26-107-252.as13285.net. [92.26.107.252]) by smtp.gmail.com with ESMTPSA id r4-20020a05600c458400b00405391f485fsm3167587wmo.41.2023.10.20.16.55.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Oct 2023 16:55:46 -0700 (PDT) Message-ID: Date: Sat, 21 Oct 2023 00:55:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND][PATCH 1/6] x86/bugs: Add asm helpers for executing VERW Content-Language: en-GB To: Pawan Gupta , 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 Cc: 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 References: <20231020-delay-verw-v1-0-cff54096326d@linux.intel.com> <20231020-delay-verw-v1-1-cff54096326d@linux.intel.com> From: Andrew Cooper Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/u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TfYjwqayRFcMf7xJaL9xXedMcAEQEAAcLB XwQYAQgACQUCUuE2fwIbDAAKCRBlw/kGpdefoG4XEACD1Qf/er8EA7g23HMxYWd3FXHThrVQ HgiGdk5Yh632vjOm9L4sd/GCEACVQKjsu98e8o3ysitFlznEns5EAAXEbITrgKWXDDUWGYxd pnjj2u+GkVdsOAGk0kxczX6s+VRBhpbBI2PWnOsRJgU2n10PZ3mZD4Xu9kU2IXYmuW+e5KCA vTArRUdCrAtIa1k01sPipPPw6dfxx2e5asy21YOytzxuWFfJTGnVxZZSCyLUO83sh6OZhJkk b9rxL9wPmpN/t2IPaEKoAc0FTQZS36wAMOXkBh24PQ9gaLJvfPKpNzGD8XWR5HHF0NLIJhgg 4ZlEXQ2fVp3XrtocHqhu4UZR4koCijgB8sB7Tb0GCpwK+C4UePdFLfhKyRdSXuvY3AHJd4CP 4JzW0Bzq/WXY3XMOzUTYApGQpnUpdOmuQSfpV9MQO+/jo7r6yPbxT7CwRS5dcQPzUiuHLK9i nvjREdh84qycnx0/6dDroYhp0DFv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: <20231020-delay-verw-v1-1-cff54096326d@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=no 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]); Fri, 20 Oct 2023 16:55:57 -0700 (PDT) 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. 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. ~Andrew