Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1408659rda; Mon, 23 Oct 2023 11:36:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYq9y+qBERsHU8srbne05Miey6uJHDlvW5G+GQRjrNo76ljBaWHYtO1Z5F90kbBY9ZjoMI X-Received: by 2002:a05:6a20:7f95:b0:16b:a5fb:eee5 with SMTP id d21-20020a056a207f9500b0016ba5fbeee5mr605624pzj.28.1698086161431; Mon, 23 Oct 2023 11:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698086161; cv=none; d=google.com; s=arc-20160816; b=BbsjlzQn+ddcUqRk9Tr7/QnKPIE+NaCtwO913oOhDDVJBIcZZ0xlSJZQR5zAcY2dmd wHonD8SHvcO7j+5CasXm1Ls1O0ViWCREpjMLg3zCtCfJXIL51YFm7yKe9X3Ym4wTZHEB cULbyTJq85WSeuH9LRXjN1gPOZgAqKdLjZEukuSpY0EkEDS/ci0ptRRhx8BwcUCQ7z3d gDAwvMb7M6+LnGN9ixTb3qe1StTwl/DJWjbkDZUVMjxSHtm0ORoxSHI3exUAfuHXiaKS ckO6vwOiHKFobZSjPIIVWWfa7GNKgv3naKxKN3Hw9BUm3xuA0AOkRerbTLvqA0oVCVoc AiYA== 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=qpajGmJf5mfS/iNCmhTcGPMbI6c/urPUa7VVU6jrRio=; fh=EEmuDgHe7+GkkgYSN4e1h/DfOT9/bZas3+va72Szr1k=; b=QpJ2TvHKxIquqvmeMqbJhOoINaB9DvNhl8IhyRTVbEAxBQ+VixhrjdHn3aPiKAOA8s E3Osj0n6g7PkCgCIdlmTNpj0nwiQg3YLbnA9k1Z5EtSuJd8+YPOG01GjtP+NomRr+XBV gYrWj32rsOW6GtPsME2Vsf9NZALRMQA6n5k+72meeaUtNoSAjiEshmaX3ETJsRcP8ZnN KSu6tbsQDv3AoGuLx4XbFdo3UnMGKix2CO1tL/ioLoxYtZRxUbog06dIf9KD7eCbanH/ CuPCgwiLpvMFMgH0t61pWbBVdQOaH/sZcbWCyXTeky/ww25RHO/oGLI351xcySFlZCvL jNyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R4ShAgpx; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id mh1-20020a17090b4ac100b002680abc3699si9914960pjb.115.2023.10.23.11.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 11:36:01 -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=@kernel.org header.s=k20201202 header.b=R4ShAgpx; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A187C807E45C; Mon, 23 Oct 2023 11:35:42 -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 S231128AbjJWSf1 (ORCPT + 99 others); Mon, 23 Oct 2023 14:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbjJWSf0 (ORCPT ); Mon, 23 Oct 2023 14:35:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 689E8B7; Mon, 23 Oct 2023 11:35:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 465DCC433C7; Mon, 23 Oct 2023 18:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698086124; bh=ZsGdHEJshdR0ozQSfQrtf6wqTgfeXHC3XAo8ZSd8pBo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R4ShAgpxrBRydKmuUVFVNqKZZf2P1pZNI3c3pn71hOqSL3rMDVW4qYqLdeox0rkgY EWMFK7pUlfLLfzyOzNY/m9LKCct1tP33FcbmOx3d8WckKt1fTqo1/coGrwZNetYfIM D7XIDHR4ByBwehxXpJ7yjsFWpTUgQ7YOyKxKrTQ9XUyzr+zks1VB6cP2XisGX7e2Cq wtyN3iJ3u+b7JPef/WPICWcVC5p/7ts0sS9cRTeXod1fItZRVeijhR+QtPHaHcGQNS 5BNO+lnuP/igOYZjK/2PuobSAs+SO+PpgVsOmoNm3oLlcsF+lnfWeAdDQd2giW7sCT UE4WGukub5n2A== Date: Mon, 23 Oct 2023 11:35:21 -0700 From: Josh Poimboeuf To: Pawan Gupta Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , 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, Dave Hansen Subject: Re: [PATCH 2/6] x86/entry_64: Add VERW just before userspace transition Message-ID: <20231023183521.zdlrfxvsdxftpxly@treble> References: <20231020-delay-verw-v1-0-cff54096326d@linux.intel.com> <20231020-delay-verw-v1-2-cff54096326d@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231020-delay-verw-v1-2-cff54096326d@linux.intel.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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]); Mon, 23 Oct 2023 11:35:42 -0700 (PDT) On Fri, Oct 20, 2023 at 01:45:03PM -0700, Pawan Gupta wrote: > @@ -663,6 +665,10 @@ SYM_INNER_LABEL(swapgs_restore_regs_and_return_to_usermode, SYM_L_GLOBAL) > /* Restore RDI. */ > popq %rdi > swapgs > + > + /* Mitigate CPU data sampling attacks .e.g. MDS */ > + USER_CLEAR_CPU_BUFFERS > + > jmp .Lnative_iret > > > @@ -774,6 +780,9 @@ native_irq_return_ldt: > */ > popq %rax /* Restore user RAX */ > > + /* Mitigate CPU data sampling attacks .e.g. MDS */ > + USER_CLEAR_CPU_BUFFERS > + Can the above two USER_CLEAR_CPU_BUFFERS be replaced with a single one just above native_irq_return_iret? Otherwise the native_irq_return_ldt case ends up getting two VERWs. > /* > * RSP now points to an ordinary IRET frame, except that the page > * is read-only and RSP[31:16] are preloaded with the userspace > @@ -1502,6 +1511,9 @@ nmi_restore: > std > movq $0, 5*8(%rsp) /* clear "NMI executing" */ > > + /* Mitigate CPU data sampling attacks .e.g. MDS */ > + USER_CLEAR_CPU_BUFFERS > + > /* > * iretq reads the "iret" frame and exits the NMI stack in a > * single instruction. We are returning to kernel mode, so this This isn't needed here. This is the NMI return-to-kernel path. The NMI return-to-user path is already mitigated as it goes through swapgs_restore_regs_and_return_to_usermode. -- Josh