Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp967355lqp; Thu, 23 May 2024 05:42:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyH8oKaoj17RMDIJUg5hUuGFwWMUOtrKSxLkTQfHFgZktorxdQCq5WabuWktFklxD8dmeO4aTG29dQT0ATlpbbWkWNdBeM1VpxZ+uVlg== X-Google-Smtp-Source: AGHT+IEOnKJIe3JfoYK5s3pbVe8KFMfkcW1drPMsCBq/aNiaxMPruS6PPfrus+AU7oAzFFdqJvT9 X-Received: by 2002:aca:2b02:0:b0:3c6:574:eb45 with SMTP id 5614622812f47-3cdb6c6e269mr5057437b6e.45.1716468154885; Thu, 23 May 2024 05:42:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716468154; cv=pass; d=google.com; s=arc-20160816; b=nxoZaWrVDH6Gqc9s7qZwCO48RH4cglxhT7JeTYIbPaDJV5Rd5Wfs6JZbHsOn/G8tjZ n9wmhtF3vc3jEtC+1qnBrkhhVYWtVsyVoMbW8N8kmwoDnEmx55HYmQfgLrY7TNjgPKKt aX3Om0P6n8DqjEhLV7BrgjvDHOYCL/xNhwEAvoPEW8ob9Vn5k1KQql9Cj71mLDvVRPYg x4Anbi4WUldMABcbOnjT1Di5H5KE4C/gou4TYH5QPD444BZyutJwFCBFpNfgkUS5HczY kfyerv0vhJDanddeMC2AE+OuhbuJFqDi/PMpI4H3aXjCMZFEHjaZvNqMGJ4OOd2d4Zkk oxGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=u0TO7M+YunjW2XWp159sTlTrU8T1iTyPmvxS8aAeSJU=; fh=+CmvJ6Y1X/AnKSkpHUEvRSBWkVreS9i6MlLznoOb0Y4=; b=HQKl3wp1vuoYQQ/n4j4C2wjlWDXlNIR4J+kHv+or76IyRc5Bu46EMsIpubdS+VhlrW hcAO1PEcXdl1+3DP8JWuczT/1jsmQTsugr61dF8GjEiuFB2r2XTGatFZ9N51/POCsCdq lmcxh220468+HjMzG2pnOQd/6v+D/qFZoCCLW4LfuaufVHH/PFMfc5eQPGJgyP8777ML xx+KsK+MC2xj1+rgrzLNyolSGPlAd4ql6YnOqWTlcWQlsPLB1MjwHwA7HLD98cFlRG9I LNYApiegSLe1D2FdLAtqn2Ml4YJyeP7TAOznOsTNy5jHmHYiHfPtihYogKxYOmygxp0T BFFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=Tg7XhoIH; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-187484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf30abc9si1240767185a.287.2024.05.23.05.42.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 05:42:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=Tg7XhoIH; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-187484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9D5661C21E9D for ; Thu, 23 May 2024 12:42:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D64614901E; Thu, 23 May 2024 12:42:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Tg7XhoIH" Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B74E148FF4 for ; Thu, 23 May 2024 12:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716468139; cv=none; b=NFn1TxZW9r5IHO86Tu6B+bu65/tVfJutcrEZ6YGYzHAc3VVE3FXybmgXaZB5ZtYsD/Ha1mS3d+N/6Tyf4k371D/c1Rl48lwmHW/P7dughSDsVeeUqs8jt0NNn5XuRSe9Xf0k1jt6sXTBcTidmvTqmnhRc7Oqs0eWdyQgdlUjlsY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716468139; c=relaxed/simple; bh=U4MP831/hb1ixJbb1U8C6JGQJEg4/rE8FZTtu0IhBAA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=E2K5pQ+57DoPbVCdSGc/oe65r/0N1kd5JyQzluRZaBNa8MCev7WC5jg96fox+SLCXZADZ2Zq01l7DCPETE/8vseaO4TPfddz4//idPfV9zV6k6nCSi8SeiyVselx/laYwHgvjxJCfQtX54pJ1cBP3vjg1ARw+P3PVbIqlHGSfTM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com; spf=pass smtp.mailfrom=cloud.com; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b=Tg7XhoIH; arc=none smtp.client-ip=209.85.222.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloud.com Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-792ba098eccso458880885a.2 for ; Thu, 23 May 2024 05:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1716468137; x=1717072937; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=u0TO7M+YunjW2XWp159sTlTrU8T1iTyPmvxS8aAeSJU=; b=Tg7XhoIHACrJ+Yi6K/1FQHszPfIuorJiwDWkr1nLnQIz/vtB+11c3AcQ76pz2q2utN KE3WH0vtj4EAOX4XmHh60iUA9uq9JzxB/2hxMFEjN8tnDHw+2vovWrsQsS02seDCjrEh tl0HEYOBhEfOw7Poio7Tx9NWMDDUZzysX1L5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716468137; x=1717072937; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=u0TO7M+YunjW2XWp159sTlTrU8T1iTyPmvxS8aAeSJU=; b=Scd2riPAR4h/mHGW544Uy6KIF5eJUd1ADQoWBVUfsnHfYFAQ5G5Lrv4Ujn+eOs5whb +ohCd0g/wGm0B9TygHI9oBvgtuSJVrd9TFiYH97WMtvNJo/sh5kiBoBRYRT86SbvPNQ9 30ZKls5zTh20bXLC5/C4mj1nUrAaF5lDY1A5/gCo7bqmkbUXQ+or9EUCGsLpJxDydg3e TY+wN1uYI1vf4v0+Q1YJ6CoAaSRN+y5hdxz2IfSAH2QdwCggknLBvFptG2Wl8G0HdPSr jqREuUPwfHnUv2q3o47aNF0eQtgG4TblaIJY96spAEmyvsB84fMqAMaeY6/Wl6gOh9o+ bFMg== X-Gm-Message-State: AOJu0YwfayGXSDxg6dUVLdwRCL/y/yOdr/3wCzsqZFBkA6AVFbek5dgT QK1SFt5jQD95vxiG1gfZ0HOYz5Qysw7aAKNxBps7WSR2plk4FoZG2m+eJ/oh6Xo= X-Received: by 2002:a05:620a:424e:b0:790:fc5a:1ffd with SMTP id af79cd13be357-794994c0aebmr572293385a.66.1716468136824; Thu, 23 May 2024 05:42:16 -0700 (PDT) Received: from [10.125.231.30] ([217.156.233.157]) by smtp.gmail.com with ESMTPSA id af79cd13be357-792bf2fc57asm1488675685a.81.2024.05.23.05.42.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 May 2024 05:42:16 -0700 (PDT) Message-ID: <771bbaa3-0fa5-4b0a-a0a2-6516b4f42867@citrix.com> Date: Thu, 23 May 2024 13:42:13 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] x86/bhi: BHI mitigation can trigger warning in #DB handler To: Alexandre Chartre , x86@kernel.org, kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, daniel.sneddon@linux.intel.com, pawan.kumar.gupta@linux.intel.com, tglx@linutronix.de, konrad.wilk@oracle.com, peterz@infradead.org, gregkh@linuxfoundation.org, seanjc@google.com, dave.hansen@linux.intel.com, nik.borisov@suse.com, kpsingh@kernel.org, longman@redhat.com, bp@alien8.de, pbonzini@redhat.com, "Kaplan, David" References: <20240523123322.3326690-1-alexandre.chartre@oracle.com> Content-Language: en-GB From: Andrew Cooper 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+hqWqA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fsJT5RgvefAIFfHBg7fTY/i kBEimoUsTEQz+N4hbKwo1hULfVxDJStE4sbPhjbsPCrlXf6W9CxSyQ0qmZ2bXsLQYRj2xqd1 bpA+1o1j2N4/au1R/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: <20240523123322.3326690-1-alexandre.chartre@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 23/05/2024 1:33 pm, Alexandre Chartre wrote: > diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S > index 11c9b8efdc4c..7fa04edc87e9 100644 > --- a/arch/x86/entry/entry_64_compat.S > +++ b/arch/x86/entry/entry_64_compat.S > @@ -91,7 +91,6 @@ SYM_INNER_LABEL(entry_SYSENTER_compat_after_hwframe, SYM_L_GLOBAL) > > IBRS_ENTER > UNTRAIN_RET > - CLEAR_BRANCH_HISTORY > > /* > * SYSENTER doesn't filter flags, so we need to clear NT and AC > @@ -116,6 +115,12 @@ SYM_INNER_LABEL(entry_SYSENTER_compat_after_hwframe, SYM_L_GLOBAL) > jnz .Lsysenter_fix_flags > .Lsysenter_flags_fixed: > > + /* > + * CLEAR_BRANCH_HISTORY can call other functions. It should be invoked > + * after making sure TF is cleared because single-step is ignored only > + * for instructions inside the entry_SYSENTER_compat function. > + */ > + CLEAR_BRANCH_HISTORY Exactly the same is true of UNTRAIN_RET, although it will only manifest in i386 builds running on AMD hardware (SYSENTER is #UD on AMD hardware in Long mode.) #DB is IST so does handle it's own speculation safety.  It should be safe to move all the speculation safety logic in the sysenter handler to after .Lsysenter_flags_fixed:, I think? ~Andrew