From patchwork Sat Oct 22 07:20:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1097749wrr; Sat, 22 Oct 2022 01:08:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6a7kPjs5EthPuDC+EOXmp1pMpNaM3u4QLlskvN5esxx1SsF78SztzSIXuQsHQygL2ae5rK X-Received: by 2002:a05:6a00:4192:b0:563:5e95:1db3 with SMTP id ca18-20020a056a00419200b005635e951db3mr23507613pfb.14.1666426116524; Sat, 22 Oct 2022 01:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666426116; cv=none; d=google.com; s=arc-20160816; b=ezFvJSSaoPnVLQI4EpV+h3Xqb8NN0ajCh0wKW1RjYNeojGpfusFkKB+U8vOywySzb8 HPJtabhthx/pDuCY/SewyG8XhMrESk8G3Brn3VIlbTjeCIN5mfqhX5Dp3AJlSovFt2ar F+0llpbX1X59gykosc7Uvrmh9COq+pW7r7/OdVXWsjsTNwAM+lZlcOUOMjOE45ZOZ7rI ctucdjqd3uXcWR5ji5T/WHDKt0ewwR6WMwsvgpySl/GPOS/HYjtFehO5uKHBN3/sa9fm rTjTZCsY4xoz1y39p6+AbffeXrrmqfsRCWe/jIiq4355EdN1RpMOVt5dIPJkiTTua4jJ 9mtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nbdpIwOTd+3hQC/ZXLxoAWUZeeIQV3xkMoJmIPj9VKI=; b=Dy07r3keCOIAmQETjGNZwe8rDRoZLpGI1n2GmQnh9BzPiKReU+9RzEb12FgGFAnVm0 Q6payWHnOC7IauOLqa2WGAb7WRyMwr7FUo3+aubn5UHHQ2TBJOZnMu9MiacQQQt/MZbo r032dEr489KAq+sPN6oWpHWGMydoccQmrQ23N/2BYNGgyX3EkFkURbddPRxiGSQ4SIaf 8Ll+C5gYaMuzfXLQJ7+g/53g9tqIE7ZnfgektuhMnY/1q0DiwVvhlc3FD7u1QC0tH0oJ RO+82qwkw7G6L0tneiWCj8A/QOYbpybDwPNlHhj9ajYzv3z/+rptD+TisF0yLENKw4Mm 99Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gZ/uv0kV"; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a17090302c900b0017f5ea214a8si27835044plk.462.2022.10.22.01.08.23; Sat, 22 Oct 2022 01:08:36 -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=@linuxfoundation.org header.s=korg header.b="gZ/uv0kV"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233025AbiJVIIF (ORCPT + 99 others); Sat, 22 Oct 2022 04:08:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232837AbiJVIER (ORCPT ); Sat, 22 Oct 2022 04:04:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D78B213469; Sat, 22 Oct 2022 00:51: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 ams.source.kernel.org (Postfix) with ESMTPS id C4F3DB82E16; Sat, 22 Oct 2022 07:43:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F28EC433D6; Sat, 22 Oct 2022 07:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424589; bh=tGmVrJk+gjBfAMLrT91eA5xLi5kGZV2ZSL7JKmMaxAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gZ/uv0kVi7gsXW1/JrN435rVSiNJXot6FQptbe2iJX80Vgj9oZMUJn4fgqlo2Hptr +aruEZpLVO5uOm0fi7a0sQ+GN8J+Y7XdIG7RidS3fiqyRfAtqGc4BVrmP/1DNnFv72 3lCVwdxJPgDFxk5aiProtcOL5GOcWM4/u3bLHUac= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Vitaly Kuznetsov , Paolo Bonzini Subject: [PATCH 5.19 162/717] KVM: nVMX: Dont propagate vmcs12s PERF_GLOBAL_CTRL settings to vmcs02 Date: Sat, 22 Oct 2022 09:20:41 +0200 Message-Id: <20221022072444.133355302@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747374431283598197?= X-GMAIL-MSGID: =?utf-8?q?1747374431283598197?= From: Sean Christopherson commit def9d705c05eab3fdedeb10ad67907513b12038e upstream. Don't propagate vmcs12's VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL to vmcs02. KVM doesn't disallow L1 from using VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL even when KVM itself doesn't use the control, e.g. due to the various CPU errata that where the MSR can be corrupted on VM-Exit. Preserve KVM's (vmcs01) setting to hopefully avoid having to toggle the bit in vmcs02 at a later point. E.g. if KVM is loading PERF_GLOBAL_CTRL when running L1, then odds are good KVM will also load the MSR when running L2. Fixes: 8bf00a529967 ("KVM: VMX: add support for switching of PERF_GLOBAL_CTRL") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov Link: https://lore.kernel.org/r/20220830133737.1539624-18-vkuznets@redhat.com Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx/nested.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -2322,9 +2322,14 @@ static void prepare_vmcs02_early(struct * are emulated by vmx_set_efer() in prepare_vmcs02(), but speculate * on the related bits (if supported by the CPU) in the hope that * we can avoid VMWrites during vmx_set_efer(). + * + * Similarly, take vmcs01's PERF_GLOBAL_CTRL in the hope that if KVM is + * loading PERF_GLOBAL_CTRL via the VMCS for L1, then KVM will want to + * do the same for L2. */ exec_control = __vm_entry_controls_get(vmcs01); - exec_control |= vmcs12->vm_entry_controls; + exec_control |= (vmcs12->vm_entry_controls & + ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL); exec_control &= ~(VM_ENTRY_IA32E_MODE | VM_ENTRY_LOAD_IA32_EFER); if (cpu_has_load_ia32_efer()) { if (guest_efer & EFER_LMA)