Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2456122imd; Fri, 2 Nov 2018 11:42:45 -0700 (PDT) X-Google-Smtp-Source: AJdET5c9U/t5dIZfZMKzros72OETcJZ0efwx18Ecy6J83GpVQBH9BA2mn4HNehUA02Nq8v+MDnRM X-Received: by 2002:a62:60c6:: with SMTP id u189-v6mr5136241pfb.191.1541184165329; Fri, 02 Nov 2018 11:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184165; cv=none; d=google.com; s=arc-20160816; b=Qzg/sRaWQv7V8RKSjXvVhPjZfVMOIIc6XKIqQtmVOhe8i0uen9mf1mPcEI4Xso+NuO OkRWNIbOUKbDlSUvKsnYgrLPEIILi0OiRNpnzkePDUIvsQfiyIkxesYU8/bxPYuke8RM Z5YcChCRSUTFEStAkrP8B/skCieI/U9z2WZkEkPGzZLXSihqzViXtTmS/JFdOkV3/R56 RKPdI1+AGcSVGo35ASRrer1iLWNYOLdc7u/Ug5WoNpwsIeganTWH6OdE2MzLB4pjz1IQ 6ou37E79/XOonaPCHW1axr8PltDU5pfjh2iczy/VrWH8fEzRLwMe1Z6XGsVnGoES/ycz fwqA== 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=Zs77JGZSLcWuTLd/TNLvFKCVroUJop4H1ISy3b2Us4k=; b=CQikYqRZqAI0V/HVO3YYtl5u5SOWwsdtu02Tu1NQAkIR9mf3PVBNTcH0uROyKl3clF uJAim56vf7Qx3stEeQfF5l4Lo2pVZJR+LV4G1CdBFxNCgm6aTzbJVbrownjM1WrebXuB p2ZrTghYrC1tBXkwfZuVK/Mq+XRUZ/LrEgdneUkTLB73tCy6H8p/Sej2TaSy/YreHaM2 fsrlSRtiFI0dzqvdMiGxBWeyThUhfZc/8YwXTOxu76/LU5jlYi9ZzrdZyiJEWRht+iiv fR1SjLFEFlyTaIkR7B6y2eOYUvyBto9spJ+d/T9jax4f0kOySdnQGb3cDr4O8yr1kYSs mvBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IFODRnJN; 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 z67-v6si36619497pfz.5.2018.11.02.11.42.30; Fri, 02 Nov 2018 11:42:45 -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=IFODRnJN; 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 S1729339AbeKCDsd (ORCPT + 99 others); Fri, 2 Nov 2018 23:48:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:42896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbeKCDsc (ORCPT ); Fri, 2 Nov 2018 23:48:32 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.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 6476120837; Fri, 2 Nov 2018 18:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184021; bh=tE2YGbronOQbwIg/b2wu5kw65zwW2SZigPSBj7O1I5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IFODRnJNyJe39jkSplPbPytnlfnPK8FpLCiuWnjj6OsRGhSuP3AYpxkdsqLLkbNXH vMJ/yUgTskExqjrPxeHnWaidsCO7UlfxRlfB1deX0tU+TO7tf+jj/tyV1yaPgvorUt JCFVfddzid4ZQqE6Qoy7y7gj2VfKh86yPEcU0Z7I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikita Leshchenko , Darren Kenny , Liran Alon , Paolo Bonzini , Sasha Levin Subject: [PATCH 4.18 052/150] KVM: nVMX: Fix emulation of VM_ENTRY_LOAD_BNDCFGS Date: Fri, 2 Nov 2018 19:33:34 +0100 Message-Id: <20181102182907.122700122@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 62cf9bd8118c4009f02c477ef78c723f49e53e16 ] L2 IA32_BNDCFGS should be updated with vmcs12->guest_bndcfgs only when VM_ENTRY_LOAD_BNDCFGS is specified in vmcs12->vm_entry_controls. Otherwise, L2 IA32_BNDCFGS should be set to vmcs01->guest_bndcfgs which is L1 IA32_BNDCFGS. Reviewed-by: Nikita Leshchenko Reviewed-by: Darren Kenny Signed-off-by: Liran Alon Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 2e23fce5eb1f..9efe130ea2e6 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -819,6 +819,7 @@ struct nested_vmx { /* to migrate it to L2 if VM_ENTRY_LOAD_DEBUG_CONTROLS is off */ u64 vmcs01_debugctl; + u64 vmcs01_guest_bndcfgs; u16 vpid02; u16 last_vpid; @@ -11567,8 +11568,13 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) set_cr4_guest_host_mask(vmx); - if (kvm_mpx_supported()) - vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs); + 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 (enable_vpid) { if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02) @@ -12082,6 +12088,9 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu) if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS)) vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL); + if (kvm_mpx_supported() && + !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) + vmx->nested.vmcs01_guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS); vmx_switch_vmcs(vcpu, &vmx->nested.vmcs02); vmx_segment_cache_clear(vmx); -- 2.17.1