Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp133379rdh; Mon, 21 Aug 2023 09:48:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJvZto7UD6ksNr3uuR3u14jOTOYac6cMfnWB6+KaX/IHaG0TVdgxDG9aV358RqE6YJ4NNY X-Received: by 2002:a05:6870:6124:b0:1c8:bfd1:ecb8 with SMTP id s36-20020a056870612400b001c8bfd1ecb8mr9557295oae.30.1692636513922; Mon, 21 Aug 2023 09:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692636513; cv=none; d=google.com; s=arc-20160816; b=a6I6b9X9sE8r0bvj06lh5lEJzjAQDxCHs2o2efcOn41i8NQMZn/aUYFTU/duptA5v/ ouevO757iP9gC49vmsomYLw8i2BxuTCAQLy/2k/Exl1+fh2uW2me69ZYJG3X+09jXdg2 uBmPiCXXXgg/s04ofUFGJJcS1mgE/9U8Zakk+NtH6YZtcl2bBmLcYW5nXUrARC0q1IkC wMptb/Qur7MAE0AUskQ6z1Ae5t7mLZbsewQ2Xgs2crn1mSNi9Amuxu22E27dxqX3lGBt c4VToDysVYr0vpj1JYsayI1LPBjD4hEvKpSDuMNqCRoN/Q1lMFoGJk4ukHViwyww6t6W 4/rg== 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=yH0j0mYGlIoyoWUi8VKdpIHsOKJeVVMyyYiOIVqjYHo=; fh=TVVLdfxB977rCRKpHnzBXxrMnouaLKKXxHTfAoUDcjk=; b=XBf83L2VQEoTQcX2Ukl3BGo8K5TbV8neztLxjOyApTGXFaZrLXdIjf1xly0t2tNkSy lp+bfe+VFBEMm68tOE1z17N9nK7ph5Ja6TgzzJ7DuJbp5DKMpK9U9xfWBjRx+PYpidNB xCX+DOqfK7izzEhEfQ5syJRwNkDBsQfn2q7M+T5+R2S0kbF2QWwNWSnIaf/8IeFvNu1d ey8dZo8eN0pIJ5rbeurd/Fxex/XAYzKYHnEd89fT7xrd1xhf0cqdhlPvF86EpL2MbJAT LpajEexkbZTZLFEn8I65DGwaUCogIF9//iDSepk0cLQP/k3IvLhFx3JyIlW8eyn/4kSc knQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=odovd64E; 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 gv20-20020a17090b11d400b002637aa0a4dbsi9104362pjb.103.2023.08.21.09.48.21; Mon, 21 Aug 2023 09:48:33 -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=odovd64E; 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 S236610AbjHUQX5 (ORCPT + 99 others); Mon, 21 Aug 2023 12:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236574AbjHUQX4 (ORCPT ); Mon, 21 Aug 2023 12:23:56 -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 7F5A211F for ; Mon, 21 Aug 2023 09:23:40 -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 16861637E1 for ; Mon, 21 Aug 2023 16:23:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DDE4C433C8; Mon, 21 Aug 2023 16:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692635019; bh=wy/hATjJpLN/hdBFtferCjdg7QYh8ITV/KbyY2Fnfok=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=odovd64E72Tmof4zCCrdG3sOQEV55zZXxCiwFLRe9LNjDV6iyeNg0AfiJgZ3BRx01 hl0LaGO/1MeGRi3Ty2PWKJOWAzgAd999lT/co/PuJIswQamZfjt+EiQGKGk+q04chO ug/1uRw+7zNHa68B/xMqn6P3qO0wu6Eh878EgE5dQDkU0W4uvCzyaaqkTIRuEIkAlE qNnG3x8fxHRYKp1MOcH+XRjqD43M/F0Uss11J66Yhsi666n6t4ZGYRYNQkHphhAnTr QC/PUGTbiJ35qw/6iAfeXiNYEzWm0iadmC5pfGThaKRckPjp4z/Swip5tl0Ed4n4ZF cYCUN1xkjx06A== Date: Mon, 21 Aug 2023 09:23:37 -0700 From: Josh Poimboeuf To: Andrew Cooper Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Peter Zijlstra , Babu Moger , Paolo Bonzini , Sean Christopherson , David.Kaplan@amd.com, Nikolay Borisov , gregkh@linuxfoundation.org, Thomas Gleixner Subject: Re: [PATCH 03/22] KVM: x86: Support IBPB_BRTYPE and SBPB Message-ID: <20230821162337.imzjf3golstkrrgd@treble> References: <45ef7bcc-d52e-3759-403b-e4b5a79a4a4f@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <45ef7bcc-d52e-3759-403b-e4b5a79a4a4f@citrix.com> 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 Mon, Aug 21, 2023 at 10:34:38AM +0100, Andrew Cooper wrote: > On 21/08/2023 2:19 am, Josh Poimboeuf wrote: > > The IBPB_BRTYPE and SBPB CPUID bits aren't set by HW. > > "Current hardware". > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index c381770bcbf1..dd7472121142 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -3676,12 +3676,13 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) > > if (!msr_info->host_initiated && !guest_has_pred_cmd_msr(vcpu)) > > return 1; > > > > - if (!boot_cpu_has(X86_FEATURE_IBPB) || (data & ~PRED_CMD_IBPB)) > > + if (boot_cpu_has(X86_FEATURE_IBPB) && data == PRED_CMD_IBPB) > > + wrmsrl(MSR_IA32_PRED_CMD, PRED_CMD_IBPB); > > + else if (boot_cpu_has(X86_FEATURE_SBPB) && data == PRED_CMD_SBPB) > > + wrmsrl(MSR_IA32_PRED_CMD, PRED_CMD_SBPB); > > + else if (data) > > return 1; > > SBPB | IBPB is an explicitly permitted combination, but will be rejected > by this logic. Ah yes, I see that now: If software writes PRED_CMD with both bits 0 and 7 set to 1, the processor performs an IBPB operation. -- Josh