Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp178165rwd; Wed, 31 May 2023 21:27:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7hKbn6vQoF2d/4pErVOVsFLWPaSUqib60XRWobCTwo1jFlo3TLalqEChqT8KMBsK381ONr X-Received: by 2002:a05:6214:21ac:b0:625:aa1a:9382 with SMTP id t12-20020a05621421ac00b00625aa1a9382mr7613423qvc.62.1685593655653; Wed, 31 May 2023 21:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685593655; cv=none; d=google.com; s=arc-20160816; b=pLSFoc0zmjLsyIw/Qy6xBcvA5kUYW0udStr4FqkDUYTb7TV0YBaAVIVh5Bo9rFKGXk 1Bc+Umi6GrJ6I1MaMueun+8WW8eRYD8NnbubPckrCgOIZodSwerKMyvlHf3gtNHqy3vp SuQkkcmFRhZEnEYNuf8Gzwi1p+Dd+JY6vsoBQzkj6TypoI18lpmBmfU90DV3H0PZmNGc 52xkhn8Mg8klZ8aZSkaSF+LrDUAO2wX2fVXBuKKgghDLj6L51suD5MeWBcgbW56xU+Tt 2q6t88nCD0sT8RnlDrN1RFosoIr7tyfck44Mo7Qi3DqtEaGCvzVCgYtSoeI0Pza2nfPx OBqg== 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=+XmftBQ2GUrr1C2QB212jScEy7KQ25bSCs0hYphIrnQ=; b=UXtoa5HIoEIasCBnwlRX9Gq0Ul3iLMCF/+pwbZwluCa7g8cBgDldq5CW2iaeSQYXqP 9VRUaynKSHlSrPrDn6kp3R8BKNZfIIx/tEZOEzsuRgAEDIHGKMjzpE97fK6lQODx1nlE SZqJzgtmFp0qb95RRD/0h7xTcKBociLt56C9KQOL2XDrMgHBctqsROOvRfeFF/i5VEJn yEsfSyxizk1/vl0Ir0x+1HUWtxyBAHxwyk0UZC91YKwdK6LWCECIELqcIZ41oUExh7F4 CMUSxhgelm9bsoKuogQCY8AlTVxxJANQtJvECwdXnYXc6oTKkub9W7UCT1OMhGe6Oixv 3r4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UCFdHtTH; 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 o7-20020a170902bcc700b001ab1a00d95dsi1473383pls.250.2023.05.31.21.27.21; Wed, 31 May 2023 21:27: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=UCFdHtTH; 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 S231222AbjFAEYB (ORCPT + 99 others); Thu, 1 Jun 2023 00:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbjFAEXw (ORCPT ); Thu, 1 Jun 2023 00:23:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36F701A7; Wed, 31 May 2023 21:23:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9B42D60FB2; Thu, 1 Jun 2023 04:23:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69790C433D2; Thu, 1 Jun 2023 04:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685593428; bh=Vmpu+tmCB/j9OAOBTooih5ZpKTBAnxG8w5d/DuPgqXI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UCFdHtTH5VEzC1+pmZ3T87kKogT0MTYfFt7PRafT1FvG7D63uzz84O4mAi6U9G494 fY21pcXWnOUWPP6qxc5XGrxUQZDPG9M46HYaIUHYssG11DGwyU+QViWVcnVYeLj9Yl MTvlqI/F1DgANamPu783SDAjFtdIJpL6+OT6rvHWRWgGCq0Vb0TkLgkBCXoW0GzTp2 X7lF18ta1lA16F84YbnT/lxEBLAFN9Hln/rcakNqWjM5eFEgldSEs2HRvS7W4dMQgM WnMZfSLsI3giBUkPpSXcQofLILYK3IL1y46cLcWOvvxNoun45SPtG/bNe0k5wTKe57 qK3BV21uK31OQ== Date: Wed, 31 May 2023 21:23:45 -0700 From: Josh Poimboeuf To: Pawan Gupta Cc: Andrew Cooper , Jon Kohler , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H. Peter Anvin" , "Peter Zijlstra (Intel)" , Daniel Sneddon , "kvm @ vger . kernel . org" , LKML Subject: Re: [PATCH] KVM: VMX: remove LFENCE in vmx_spec_ctrl_restore_host() Message-ID: <20230601042345.52s5337uz62p6aow@treble> References: <20230531150112.76156-1-jon@nutanix.com> <20230531231820.trrs2uugc24gegj4@treble> <20230601004202.63yulqs73kuh3ep6@treble> <846dd0c5-d431-e20e-fdb3-a4a26b6a22ca@citrix.com> <20230601012323.36te7hfv366danpf@desk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230601012323.36te7hfv366danpf@desk> X-Spam-Status: No, score=-7.3 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,T_SCC_BODY_TEXT_LINE 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, May 31, 2023 at 06:24:29PM -0700, Pawan Gupta wrote: ## 2023-05-31 > On Thu, Jun 01, 2023 at 01:50:48AM +0100, Andrew Cooper wrote: > > On 01/06/2023 1:42 am, Josh Poimboeuf wrote: > > > So each LFENCE has a distinct purpose. That said, there are no indirect > > > branches or unbalanced RETs between them. > > > > How lucky are you feeling? > > > > You're in C at this point, which means the compiler could have emitted a > > call to mem{cpy,cmp}() in place of a simple assignment/comparison. > > Moving the second LFENCE to the else part of WRMSR should be possible? > So that the serialization can be achived either by WRMSR or LFENCE. This > saves an LFENCE when host and guest value of MSR_SPEC_CTRL differ. Yes. Though in practice it might not make much of a difference. With wrmsr+lfence, the lfence has nothing to do so it might be almost instantaneous anyway. -- Josh