Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp455869rdh; Thu, 26 Oct 2023 06:59:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGE1covFK/daOUVGpWKXVIiansT9+sawt2G/xHF60qdLGe//c+4Oi3OyMoL9K+8zFNLO78X X-Received: by 2002:a81:77d7:0:b0:594:e148:3c42 with SMTP id s206-20020a8177d7000000b00594e1483c42mr18171884ywc.52.1698328750058; Thu, 26 Oct 2023 06:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698328750; cv=none; d=google.com; s=arc-20160816; b=Vkvk96d5jeYbWRqtUAg/x4UbROAbNc6UMudSu3oP2VCz4sDJnMK7pLTwb+vAO5q8x5 ywF48mUYg30FlNnTCQehWQIGM5bhovSLs4ixbYhtxI/BCQI5+QrT7Y5bW9JsiyyIWA1Y UrZp/ZV7CNVknsLKbtWxEhEKyZeBvROLcD5mh52uHIaOyshWm22wpXJ8jZUqOwzLPNRQ MoLWbhzKYoab1UwdESpaGEeJ/6UtaZEeN+WFp08FC29VLp3UI3DlWBk6t3k0jOEAHnhO vYt6h2x3ulcbukp/1xlHPwnDPl16qL4TUHE9nSaFVuokXoNBM2C8ewj7t+tLtf1OQ3PL hjCQ== 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 :references:cc:to:content-language:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=f/KYa4HkxjjRaaNse5zZEBCRtWEDy9TvEZNCSQroKlA=; fh=PEfD+KWOGLjsnOcjk8GJOCmN6Zd3ZJelWvDafczHXQA=; b=MyRfP2gjp/RW9QrO4ozZgss5n36eoTr8raJ2HcuwFaCMfWfC3YdsCvr9XahGrSN8c1 heQSntdbLt6am9LdpPYPLYdvjAHB7LcPZzW5F1IxMqsfSdOLjVtuWic38g0KZa6rZPtV kqZnBMjQ/kO7DD+A/zpkBVjyGtk/mBUaG0jU2OfuY4sk+3gEgSsJ1SwoFfTW80WvmaVs YkJvzLVf7706R8bbE5l4AOUWOo8/F2MAu50fq1hb6H+lT5M4O3ndE7pfdifQPw4f68I2 yViVdkcgO+hwu/3WTRGoiyGWppFayHTk+ADmgu6ZOFl6NUrH0p3rEvy0l1isntoBrbVE kZ+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=OmRaJlt3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l128-20020a819486000000b005a81a9a260fsi15895547ywg.460.2023.10.26.06.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 06:59:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=OmRaJlt3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id EC352801B6C7; Thu, 26 Oct 2023 06:59:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345120AbjJZN6s (ORCPT + 99 others); Thu, 26 Oct 2023 09:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjJZN6r (ORCPT ); Thu, 26 Oct 2023 09:58:47 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF396183 for ; Thu, 26 Oct 2023 06:58:44 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9bf86b77a2aso140882066b.0 for ; Thu, 26 Oct 2023 06:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1698328723; x=1698933523; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :content-language:subject:from:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=f/KYa4HkxjjRaaNse5zZEBCRtWEDy9TvEZNCSQroKlA=; b=OmRaJlt3h3pl7MI6mS0dHtDwDLhFscUlKG/I0p2L14uNCUXYP/uIiNVS/IIb54VzlQ rtVbLQQgM17vGASinGX+XKUpbfkmM4PXahpGGWAchVQanhNIxYYpjE3bIXyxI9Dy1fSw YiKeKr7EgiUWPQproy/AtMTfecv+3Gffgp+XI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698328723; x=1698933523; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :content-language:subject:from:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f/KYa4HkxjjRaaNse5zZEBCRtWEDy9TvEZNCSQroKlA=; b=WJfHNEf2l7ibBePDvkBz+7cRJ8HzP9lxmvyIq+Y4JCWmk4WarBS1Nxa7PqO6CKpNNv C7ZbN+c5018npoVuVrVfpkhm/Yr6WdMeRHcaYmPMSONfBX4GNjanuT1Fy6jEhnQA36kN pwi//2oUVoKjzyFS2KwY9t1prrF66lf+pnbDbDep12mPHpA1We3ljHs1Z4FkyTe6xAbE 8WPfEcqYKShrH1khhv/MvL+sATLiI2w4l30B6zujfM/VFIjXArNFHrvTTPBm3MPRsdRA P7k84HtrYv0GhXLMeXpWGysIhlQ5mQ4dRktvoqCNKRQjnmSoDvpoY2x4XqjjQNIP8Jpk gHwA== X-Gm-Message-State: AOJu0YzVlzjjXAuJG7QIxL8bik1tF/Wki93JoZA+zda9ctkJ0tbj74h7 /pMCF8NFjOcPI6CGHniXPnUxtQ== X-Received: by 2002:a17:907:70a:b0:9b8:b683:5854 with SMTP id xb10-20020a170907070a00b009b8b6835854mr15025269ejb.61.1698328723124; Thu, 26 Oct 2023 06:58:43 -0700 (PDT) Received: from [10.80.67.28] (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id bm11-20020a170906c04b00b009a193a5acffsm11621069ejb.121.2023.10.26.06.58.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Oct 2023 06:58:42 -0700 (PDT) Message-ID: <37b334b2-c040-458d-9c1f-2546dc9b378d@citrix.com> Date: Thu, 26 Oct 2023 14:58:41 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Andrew Cooper Subject: Re: [PATCH v3 1/6] x86/bugs: Add asm helpers for executing VERW Content-Language: en-GB To: Nikolay Borisov , 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: <20231025-delay-verw-v3-0-52663677ee35@linux.intel.com> <20231025-delay-verw-v3-1-52663677ee35@linux.intel.com> <1f756579-8f33-40ca-ae50-4db78c615f60@suse.com> Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABzSlBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPsLBegQTAQgAJAIbAwULCQgHAwUVCgkI CwUWAgMBAAIeAQIXgAUCWKD95wIZAQAKCRBlw/kGpdefoHbdD/9AIoR3k6fKl+RFiFpyAhvO 59ttDFI7nIAnlYngev2XUR3acFElJATHSDO0ju+hqWqAb8kVijXLops0gOfqt3VPZq9cuHlh IMDquatGLzAadfFx2eQYIYT+FYuMoPZy/aTUazmJIDVxP7L383grjIkn+7tAv+qeDfE+txL4 SAm1UHNvmdfgL2/lcm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R/uSiUFjewJdT/LX1EklKDcQwpk06Af/N7VZtSfEJeRV04unbsKVXWZAk uAJyDDKN99ziC0Wz5kcPyVD1HNf8bgaqGDzrv3TfYjwqayRFcMf7xJaL9xXedMcAEQEAAcLB 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: <1f756579-8f33-40ca-ae50-4db78c615f60@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 26 Oct 2023 06:59:04 -0700 (PDT) On 26/10/2023 2:44 pm, Nikolay Borisov wrote: > > > >> + >> +.pushsection .entry.text, "ax" >> + >> +.align L1_CACHE_BYTES, 0xcc >> +SYM_CODE_START_NOALIGN(mds_verw_sel) >> +    UNWIND_HINT_UNDEFINED >> +    ANNOTATE_NOENDBR >> +    .word __KERNEL_DS >> +SYM_CODE_END(mds_verw_sel); >> +/* For KVM */ >> +EXPORT_SYMBOL_GPL(mds_verw_sel); >> + >> +.popsection > > > >> diff --git a/arch/x86/include/asm/nospec-branch.h >> b/arch/x86/include/asm/nospec-branch.h >> index c55cc243592e..005e69f93115 100644 >> --- a/arch/x86/include/asm/nospec-branch.h >> +++ b/arch/x86/include/asm/nospec-branch.h >> @@ -329,6 +329,21 @@ >>   #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. >> + */ >> +.macro EXEC_VERW >> +    verw _ASM_RIP(mds_verw_sel) >> +.endm >> + >> +.macro CLEAR_CPU_BUFFERS >> +    ALTERNATIVE "", __stringify(EXEC_VERW), X86_FEATURE_CLEAR_CPU_BUF >> +.endm > > > What happened with the first 5 bytes of a 7 byte nop being > complemented by __KERNEL_DS in order to handle VERW being executed > after user registers are restored and having its memory operand ? It was moved out of line (so no need to hide a constant in a nop), deduped, and renamed to mds_verw_sel. verw _ASM_RIP(mds_verw_sel) *is* the memory form. ~Andrew