Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9937901ybi; Wed, 24 Jul 2019 12:40:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3YnmMnJrwx8TVlzrXvc9yyDpa/l7i3oxl/+aw2tA7INjdvWfDYzV9tt9nAFyU2lVvdEye X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr84747433plk.113.1563997208354; Wed, 24 Jul 2019 12:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563997208; cv=none; d=google.com; s=arc-20160816; b=brgAtd3duuPAr/HAyLB+u3JnBlLdaE2UDFcdmgvwg41GL0TZt5NVmwzxunqFfMhLFk TRGSIfjpUFkmx+OBmT6cTDcSIgxL/vZiNSmcBIEEO5em/yZtDPlqXufjc4P/mUE8VnaP 8YBeXaX/CkJLRfhCt1NgPvxTBTzjmUDMM1lYBClWMsLXIuJBIpZSDW/58Qibko0XJquT YiYeNjdsyI14iLSUY/4t8s6CIEmMiQsp1wJiES6x71yddXf3mWAR9uI+e6/000cOaQbw 2v9ETD8Pt6irM85HBWJRK6scAKigheQWNgA19rY/0IsC7mPfYeqBz+ydA9XddPKslu9y 75yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IsBjr3H6L/Z6BDLiEBjLOopTiJZxs7zNFZ4Ig1rFOWQ=; b=OmaJu4ulR3QPa5UjOMD3J2xnNqhB7f7rfcJNSLueVFOuvgw6h4jRZz3+bTVeFM5XJv GFvUjOkjTemcZ37vA7ycXcDo4/HucerqnjzGWPeq7lmmhx/KRqT9EH+92ePbyvf4wXVW OKlgjSTM7RqkzD99+jbqqv7nmua8s4/NeXtM4kzk4Y7LmLoG1PVjKMBQd0ZrH9bW8MFG AbPMe9RyIkf0Oj3HFZY9bWtDyT2iTxwsJotAsbW7WAV/veovxQtAX/jNMOcz0icgJ9Wy H3wQIfmTqVX9136OZZg0zgNTmELNqPVTM+6x/uIrDRt4w9gQOEaTVBSNAM+WPn8DYx2I HkKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f2J+gmR7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m143si16056341pfd.224.2019.07.24.12.39.53; Wed, 24 Jul 2019 12:40:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f2J+gmR7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389752AbfGXTis (ORCPT + 99 others); Wed, 24 Jul 2019 15:38:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:39526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389655AbfGXTip (ORCPT ); Wed, 24 Jul 2019 15:38:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C02FA214AF; Wed, 24 Jul 2019 19:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997125; bh=gMosxPRiO7H46AAqnKYGYXV1XV4C1JG52ordBThffJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f2J+gmR7dBA7/blHBUaenntZb6uYA/GCxrIdQMpt8ojF0wDylnq99Tw4+yH4k8nfm LpjZ/shCI1stDZmYKeypeMgsdQt2bXOfNL4ToDOm+48uQ5nMz1D24vzETWTDlQ1e4H k24QXHPhLDC7ibWt/8myEqrNgl2pcKSoLmQyNvrY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liran Alon , Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.2 328/413] KVM: nVMX: Always sync GUEST_BNDCFGS when it comes from vmcs01 Date: Wed, 24 Jul 2019 21:20:19 +0200 Message-Id: <20190724191759.330135107@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit 3b013a2972d5bc344d6eaa8f24fdfe268211e45f upstream. If L1 does not set VM_ENTRY_LOAD_BNDCFGS, then L1's BNDCFGS value must be propagated to vmcs02 since KVM always runs with VM_ENTRY_LOAD_BNDCFGS when MPX is supported. Because the value effectively comes from vmcs01, vmcs02 must be updated even if vmcs12 is clean. Fixes: 62cf9bd8118c4 ("KVM: nVMX: Fix emulation of VM_ENTRY_LOAD_BNDCFGS") Cc: stable@vger.kernel.org Cc: Liran Alon Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx/nested.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -2234,13 +2234,9 @@ static void prepare_vmcs02_full(struct v set_cr4_guest_host_mask(vmx); - if (kvm_mpx_supported()) { - if (vmx->nested.nested_run_pending && - (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) - vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs); - else - vmcs_write64(GUEST_BNDCFGS, vmx->nested.vmcs01_guest_bndcfgs); - } + if (kvm_mpx_supported() && vmx->nested.nested_run_pending && + (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) + vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs); } /* @@ -2283,6 +2279,9 @@ static int prepare_vmcs02(struct kvm_vcp kvm_set_dr(vcpu, 7, vcpu->arch.dr7); vmcs_write64(GUEST_IA32_DEBUGCTL, vmx->nested.vmcs01_debugctl); } + if (kvm_mpx_supported() && (!vmx->nested.nested_run_pending || + !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS))) + vmcs_write64(GUEST_BNDCFGS, vmx->nested.vmcs01_guest_bndcfgs); vmx_set_rflags(vcpu, vmcs12->guest_rflags); /* EXCEPTION_BITMAP and CR0_GUEST_HOST_MASK should basically be the