Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5710967rwb; Wed, 9 Aug 2023 08:10:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTcK2sJ9C7bXIjBWR2OtLA8sKnR1yN/m5vb5X0Hv84Xy/xfgx7kExDNLFI+LNpkZMLBnHJ X-Received: by 2002:a17:902:7006:b0:1b7:f546:44d7 with SMTP id y6-20020a170902700600b001b7f54644d7mr2743812plk.17.1691593835389; Wed, 09 Aug 2023 08:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691593835; cv=none; d=google.com; s=arc-20160816; b=VsG7F1o80uWotOxDRj+9o2fM/USEMpC37eRumI5r65mGXXHw/xEuGtsEPVaW/GFBci HfhZneuv/oKIekPTKEExN9aXArEN0nJSHUrJCNSv2hSWDqApzmfUMMYmyTju3rhq/FW4 99Y2ZPE9lC7nlDOp+EyhG3Kwnfd9iD4mffMGrBGPIfG51iFK0vIAWpFhfCTsYQ4W7Hpr o3WWwWuXi4gHSuZHQgv0aNh26xjF3ClLzceXoElONU3h8OmoPJY8+CAE1DZHfpci7Oep qRIgXYrpWEYf9BPNCDtlrs43T0ia2JLBxXsAFq7Jdqjf9zGw2awpLKpR6CDz+J1gy4fB MeqA== 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=UhBq5YDQkhttS7K8uA7Ch9aUHAUm37TNpobWDrvgXzs=; fh=nIqJPQrB4V45MOdRoOCBABHD990j3QSMCgsf+X0qIaI=; b=AIshYKk4E1otpj0cVOEzlHkDVK0fvR3KpKGlmKLHBxvNhrRmi6kf+hr+BfceVx32XA KlBiRIt4sF0g99n4qzkmJy1HogwmjGtXp0/Wz/52u4z84TfzWHu0yZNHnOtgiGpavYAa FHaBy18MKKXDw2Jglz9kVLStaExZuCt6/4Sr2+/e7hhajiDzCgzHjwmsIT6n+qc4btof hm9kZkFPWlE0emW5mac+n16NlV1qVH7vjm2nSnqG9ng5WsGbJnj5YB0aFNF0798R3N4a qdtUG6iP+OYY81RAHe0lc3/RTn9n99SvivH1F/uc9ltWhnOJSEsqEAbovEE9/iIRgEKf AMBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TDSxERMi; 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 x16-20020a170902ec9000b001bc52116351si8762771plg.70.2023.08.09.08.10.16; Wed, 09 Aug 2023 08:10:35 -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=TDSxERMi; 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 S232406AbjHINuN (ORCPT + 99 others); Wed, 9 Aug 2023 09:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbjHINuK (ORCPT ); Wed, 9 Aug 2023 09:50:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 781B21FC2 for ; Wed, 9 Aug 2023 06:50:10 -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 ABC14616A0 for ; Wed, 9 Aug 2023 13:50:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35FC9C433C7; Wed, 9 Aug 2023 13:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691589009; bh=FNqeWc4kMaof6TZwaAnCoTBocYhWY2edTP9MmNEAyfM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TDSxERMiPbIy1HuPhWzbE/EffbyxhqOLAG8IiGjE5XXO8cJSQEJyCE2vclFfsZAtI LVoebBeIHkF8EQVYh4LuG8k/yBk59lUVxK93tTHsj0vbzDN0qgOGQklTDuYWI9dPsg JdhO2TkSlfmk1CjxwqEt/IWfY02YNIncHDG67JwQs6+eJN804VbAhxzCovxhbCdxpp ZoNGVt6H0phXeiHyrwUNDOYgqk9qZdMol4EsmVssLT5W49Xwk258lF21hBXMYPNh1w rezsOm39BpOdsay1a5Jbbyj4s/+q3qVd9YRIEzc5KsPx2h4r6AnZPLVZvfB5rD/3k+ VXBXZ80S5k/VQ== Date: Wed, 9 Aug 2023 09:50:04 -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: <20230809135004.2xy76kqpptfqxsp5@treble> References: <20230809071218.000335006@infradead.org> <20230809072200.922634286@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230809072200.922634286@infradead.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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? #if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) -- Josh