From patchwork Mon Oct 24 11:27:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp624439wru; Mon, 24 Oct 2022 12:51:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM518e1zihzh0HFl3Wk6S2ZOiPavQKLmNBpwGU8GDTh9ZSiXw9MBfWe3CRUNTd2gfE0nKimb X-Received: by 2002:a05:6a00:248b:b0:56b:830d:bbdf with SMTP id c11-20020a056a00248b00b0056b830dbbdfmr13502926pfv.47.1666641075686; Mon, 24 Oct 2022 12:51:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666641075; cv=none; d=google.com; s=arc-20160816; b=ni1c1jwJ+9b6Xy2W1M1cD+4uMK+7Iv+D+RNhgar8GIgcFiOL//w8egQ7NO+W4Wx0bd 0ooiuBnh6KOTKnbbkbn+IPd2RAQB9NMG9Bp0mgmmnToE7FFu7EqOVtq/LCk3gUFUvDYu uenpHPkgXR7Z0/oRTX4TQfVLijlwiz0/xrtf70gy3egea8yVIbiS3AoH0gyCBYo421gZ DAmDPou5/atwftKYPprDZDLLBT5fgQeIYFD/Q2Gu7ZFfUUsItLrJ9ouMf0AqES5vGx1q JxK7MGNFZUHJfgY4AZdj4p+ii2yLR69xWwhfEhymxVm5zAf+d2qA5NfRY1+1OJZY4+ZM 7JtQ== 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=A4XFYVWtPvuxOo2JPGgN42Z+ZUP6TuqRBbnp4fCpnOU=; b=Pu6onlvOvrff4v4MAjPvNGzP9p7MFSzbjVJELS20Mtdcml93IxMJa/Gf+/50gWsL4i 36MxytMUMq7Y4XAsvnTXGykdJJCQZaINkoFVEVTTeRlLZvz6VWpK71Pt5SHkfHaK34dH Dz9zzcgneCWqolU54iif36avvIdjMfp6q6mt4cbOBTiMAz2L5nvo+n3lmvLnwNuuClgm EMNOzldkXoG6LKiCjnOc+hrmJYT2hbm/fX3jnJhO1FBhbLzK7ZPvhhnK5QH/pdOlNIVj E3q4XX15k2qvOrPZEJT0q8+jSiy+o4texkh7grFaEaG9/Q95dBwj2hWCcV6NQNc8u052 BIAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o08cNVQK; 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 a19-20020aa794b3000000b00536fa6bbb11si476380pfl.344.2022.10.24.12.51.03; Mon, 24 Oct 2022 12:51:15 -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=o08cNVQK; 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 S233102AbiJXTpg (ORCPT + 99 others); Mon, 24 Oct 2022 15:45:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbiJXTmy (ORCPT ); Mon, 24 Oct 2022 15:42:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DFE180F77; Mon, 24 Oct 2022 11:11:41 -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 6E903B818E3; Mon, 24 Oct 2022 12:38:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C39ACC433C1; Mon, 24 Oct 2022 12:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615112; bh=V0NzY5TYGk7oTMHRlHDPYr843DQtFpcoSee/FPoXG2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o08cNVQKRI0jQ5v9FSiNAfIzgr15IbbrtuEXBq94WiBX6sQh8EYe+4ljf6a1hLz3J c7FL45cZBfjrl9FVX41JTmEUkdP7V4KSPvnAeeEyUPc3sP8ge1PPY7z9J3VsacR/Wt sEyVnhVFaHr+lB5uSh9xwvc8cNDOoCvXzd77yRg4= 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.15 125/530] KVM: nVMX: Dont propagate vmcs12s PERF_GLOBAL_CTRL settings to vmcs02 Date: Mon, 24 Oct 2022 13:27:49 +0200 Message-Id: <20221024113050.716544161@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747599832271033959?= X-GMAIL-MSGID: =?utf-8?q?1747599832271033959?= 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 @@ -2313,9 +2313,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)