Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5742619rwb; Wed, 9 Aug 2023 08:32:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSjO2Vov6LFrx71DLNXusCKLe9PTp0xvozNHLlWcso67xFIdoJIHoKQ4Qa7A4p3EAkiyVa X-Received: by 2002:a05:6a00:398c:b0:687:52ae:34ee with SMTP id fi12-20020a056a00398c00b0068752ae34eemr3164928pfb.5.1691595168873; Wed, 09 Aug 2023 08:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691595168; cv=none; d=google.com; s=arc-20160816; b=LuyKxiWUDpw8Yc0lUW260QKa+qhWgUEYHvNcViKx9OXNBM1b6MiKAEryzLrz0Pt5qW N0z+uBU/IHn7K/PiBHjkhEJ8rZ9HIkvIJ6ut6pRW6LIORIMcHCdkFUCp/4ClzW/6KQFM 0Udc81wUiisUc0YmCDbbdiZ6MdmR5w8A1R6kKkTNzwOpYEhwBqdC2PXQG3rO6jJR83tB 4V2yrrBfyHKaHkmvMYfysNt04bgLTLFv+JmRqLQWhqxEm3zl3l+3I1y+CAHtfc7wq1N3 m4BwLk+3pdEh+zsyfD2zHZ7T+YwlEKRs41T0J2hSPhC+r2fMPWenwPqiXbzZlamBRCwP LtcQ== 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=Nq53flwXpdKrq1FEAZ/DvgTKwoCB9Gvf+jI35rMDeMc=; fh=nIqJPQrB4V45MOdRoOCBABHD990j3QSMCgsf+X0qIaI=; b=Lkc9jQeqpKcWOiEKGLUWlA8jBwf/ZnFN+KL0zzBpioDybQ+9dY6ohNOAeyhaRomTNa nTJumelY2nB34G3/53/Qn1M6Ul2p6GIYquQy2Xr+UBYvc8Yh0S38/nsAAWpaIzuvzgr/ MBAdbVSpxu7QzTxn5NtybuRF0jqsGDxi9aFdr+YGPtFeklnF6k+40KiXrtxA3bdAOMXU XcZRH1b448xZ+eUBqPpO8ae8AAifPGBVwkrMiA5HQxudxUF4XFWvmlYeil773dmi54yL t4461BUWq4WNOlQcC7VniVHPOlXtJG/oorZ79PSkSoFPDhSAN/bkIj7hTyp6vDpJcyIc 09yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p87ULpwe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j21-20020a056a00235500b00677eac1cd9dsi9338540pfj.329.2023.08.09.08.32.36; Wed, 09 Aug 2023 08:32:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p87ULpwe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233322AbjHIOaI (ORCPT + 99 others); Wed, 9 Aug 2023 10:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233327AbjHIOaH (ORCPT ); Wed, 9 Aug 2023 10:30:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E98210A for ; Wed, 9 Aug 2023 07:30:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 71E1763BE0 for ; Wed, 9 Aug 2023 14:30:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17FF0C433C7; Wed, 9 Aug 2023 14:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691591403; bh=MFK5uGh92qEq1YLPYeOW8l/+naM+KPMX4g9a252PIq8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p87ULpwepzMvz3T7OKMoJlsNgVv847O4EHzJ6A5pZnNbMtmBJTtnOP2NKIyihW9Yt GLmRx7WChr5lIoHl9vf6C8I7z5I6+xQ8Sk65LUAhqF+VTvACXZIv1pc+WBhAXB/E5o 11I0PvQTKLAWvdYz0bML9kGs3XWopBYx+nYXRKdFgWGfe57tfwWVmsH0zK7PkBdzn4 yi8iHOl/FxPKfHacNlE8/Gy9ScmOWv5+bjKmAc5VejPDzdBfrKY2SVIX4Xrl1J+cAk /lspXWX+pZdKxR4FQIAuI1Q+AVcwfMrriMBKpdINPKEc2TY/L6Amz0HBZzfcW+DYet a7MiSaefg/gdA== Date: Wed, 9 Aug 2023 10:30:00 -0400 From: Josh Poimboeuf To: Peter Zijlstra Cc: x86@kernel.org, linux-kernel@vger.kernel.org, David.Kaplan@amd.com, Andrew.Cooper3@citrix.com, gregkh@linuxfoundation.org Subject: Re: [RFC][PATCH 07/17] x86/cpu/kvm: Provide UNTRAIN_RET_VM Message-ID: <20230809143000.tus4hqdaobk667eo@treble> References: <20230809071218.000335006@infradead.org> <20230809072200.922634286@infradead.org> <20230809135004.2xy76kqpptfqxsp5@treble> <20230809140644.GP212435@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230809140644.GP212435@hirez.programming.kicks-ass.net> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Wed, Aug 09, 2023 at 04:06:44PM +0200, Peter Zijlstra wrote: > On Wed, Aug 09, 2023 at 09:50:04AM -0400, Josh Poimboeuf wrote: > > On Wed, Aug 09, 2023 at 09:12:25AM +0200, Peter Zijlstra wrote: > > > With the difference being that UNTRAIN_RET_VM uses > > > X86_FEATURE_IBPB_ON_VMEXIT instead of X86_FEATURE_ENTRY_IBPB. > > > > > > This cures VMEXIT doing potentially unret+IBPB or double IBPB. > > > > > > Signed-off-by: Peter Zijlstra (Intel) > > > --- > > > arch/x86/include/asm/nospec-branch.h | 11 +++++++++++ > > > arch/x86/kernel/cpu/bugs.c | 17 ++++++++++++++++- > > > arch/x86/kvm/svm/vmenter.S | 7 ++----- > > > 3 files changed, 29 insertions(+), 6 deletions(-) > > > > > > --- a/arch/x86/include/asm/nospec-branch.h > > > +++ b/arch/x86/include/asm/nospec-branch.h > > > @@ -299,6 +299,17 @@ > > > #endif > > > .endm > > > > > > +.macro UNTRAIN_RET_VM > > > +#if defined(CONFIG_CPU_UNRET_ENTRY) || defined(CONFIG_CPU_IBPB_ENTRY) || \ > > > + defined(CONFIG_CALL_DEPTH_TRACKING) || defined(CONFIG_CPU_SRSO) > > > > Maybe can be simplified? > > > > See patches 9 and 10 :-) Can still be further simplified to CONFIG_RETHUNK? -- Josh