From patchwork Wed Oct 19 08:24:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4579 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp205816wrs; Wed, 19 Oct 2022 01:50:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5KMRbCz+0gdNjPVPFVA3/oJ4NQ53yV6LzhNp6bxiuQaLsFWnj6k3Vyn7mKb9zUIgvvPV8c X-Received: by 2002:a17:90b:1808:b0:20d:4e7f:5f53 with SMTP id lw8-20020a17090b180800b0020d4e7f5f53mr43267525pjb.170.1666169443720; Wed, 19 Oct 2022 01:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169443; cv=none; d=google.com; s=arc-20160816; b=Ok7jvfkZDdvF7xCn9MyXHFYrViUcYvW2t3h2nvyCXXOUlxVK/YW5J/1ARZJBUnflKR pltmOHJ1Hid7A14tzWpDFX6+kmHkyEOF1J8qyV/I1S+ufDZsMgklr5MtAewwb6yMSC6q dBrieLMFkb9TOU0nDdbuMHPlAMb4Y0koeM9+YtioTvrRxv6ECCZWS6HtUGBip0CBbh/l 3gwdTea+vVw8VdqlXE8O/yERbSe/fJSRUchc1YMbzmhLWpI7r2J/tnEOqgmDcl0idaba KbI4wFT/CLMH34rmlVO5bC+uCS8yhqPZiY6U6zlFm3wjNRAs70KVekohguNOS4ZfY2Hg 5sGA== 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=1jI6VR+rh5Gyq2VbzrG0Tj1bOQoslCIQ3xyOS8sVGpg=; b=SaUM1hQzurCsGLuhWblXWxqd/IzzBcEuQ6PgISTnfdbVzav1NMQQNf4P63CgL4IBmR h7vfheh4SJs4xNvaP2idf09bP5DplzJJMoGValmhC7pKlHk3ED0BGYagu2wpnZV+mWwK Yj03eNXtJUEIWKLbrT7++IPYOClYKoQ4lE/Ui4g5s0R7gQf7GyzAFLhIeOTpz5XfXOw1 hlgYLClNgcRaTlDjNCPtFQBCliZCp0Fs6VkRbUZwYC79OkImEODdc5aZaOOFosre5Vt2 8/+bKcepEJfpUZoj1cSQZPOQHVLfCz07f7auE7u+lWWueQ6YEb1Q4Owo5r60rjv/kw4Q ieAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cnj8zd4f; 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 pi10-20020a17090b1e4a00b00202ae67f30asi20005707pjb.163.2022.10.19.01.50.30; Wed, 19 Oct 2022 01:50:43 -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=cnj8zd4f; 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 S231633AbiJSIsv (ORCPT + 99 others); Wed, 19 Oct 2022 04:48:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbiJSIsI (ORCPT ); Wed, 19 Oct 2022 04:48:08 -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 E15C48E729; Wed, 19 Oct 2022 01:45:55 -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 D8E9061806; Wed, 19 Oct 2022 08:45:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8241C433C1; Wed, 19 Oct 2022 08:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169154; bh=OHv+KpWGBeMvBQ7lMYmjy5WHvn3BF9Zmb+vVx3Mx7hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cnj8zd4fxYI8wbqaOFelsaFpU2VpT0M2eMn+abZ0uUHBaM5Eavlk4UWTmBTxiJChb DIcoo9YWTFnLKPXJvbHrmK9pRixvUuCxl50Jb7l/toAvOjseyadHbtruF6cNJMbmu1 XfZT8zP4UnebZPZ+HxC8vjIN3ruDIcwIBhOxlDNI= 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 6.0 176/862] KVM: nVMX: Dont propagate vmcs12s PERF_GLOBAL_CTRL settings to vmcs02 Date: Wed, 19 Oct 2022 10:24:23 +0200 Message-Id: <20221019083257.733482554@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747105290600522847?= X-GMAIL-MSGID: =?utf-8?q?1747105290600522847?= 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 @@ -2328,9 +2328,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)