Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp550091imp; Thu, 21 Feb 2019 06:40:39 -0800 (PST) X-Google-Smtp-Source: AHgI3Iant+EvoswRVhPDz0659vPjRok8C4bmYyBh8Id0JpXIw8E0F9TECoS5c3h7pMaKpy6k0N2+ X-Received: by 2002:a62:b2c3:: with SMTP id z64mr40611608pfl.149.1550760039606; Thu, 21 Feb 2019 06:40:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550760039; cv=none; d=google.com; s=arc-20160816; b=xW7pygoq8JYvq/vpRlFJdHAKFB98ZSNfy1MZp4Qc1Y8RlzFNI/B6OJcKQXm9s4EtdZ +XgAJK36lUIyKJd06cczUVny1TS9dQNhgvBTZ7DeEp7lBZBUCHLk/4mW3HxkDoXPVwT4 QOPc3ovsEOl5bxjAMHj0BLk1ksJ0rcBLhBkashB8h1aRyc2ns/tPBmksiJjNMYf4x8gf Lzgi/iWcPBHEcRE8PlqtDTNrV7A3+zW4PrjT3Ph1Dgbr066pNhD3J+9PgPe82XbiHgGL RjJFbTQ1a3PqZoBU5MSc4mwrpI/ZtwRWDTEEj0iA43A9bAfiSy1qmY2iq7hIPV+1rAvg SBNw== 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=313XNCvzsExt6fqxhx+9/t7wE5QS3Th2jzOPGQR/UPc=; b=ZSohJBIvHLxbQwDJzUbfmUZdWbC86C1jwpo1psUqY7b5fM38dYvh/FJK8zEEjPIXbj 8iyWPvLlqHQIQTAN4UWxCR0nKXyNb282C8wON3UHZ/X6BiJfPWW7ep/8vq+pcZW/9l7U Z8x4GrgU/1qQ603u4kv0YKhS+XQqROAVa4DNhk92Osp1dYxt+s8w7IxeP7v7KKtGhuNL Ae5tIGD4+KjGnEWNM2gaU5T+Jc12a9NMlNmrtaU86y7R+J8sk4/uIZbaZkyHW+HCApg0 GUA2Fq72qOcjAlcZcOSRuphg+OgW/rC5XpvSJ71IDSD9F8uxu+CHw6RQ9nqxLti1tm7t s0Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M0urddS7; 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 e11si790884pgk.524.2019.02.21.06.40.24; Thu, 21 Feb 2019 06:40:39 -0800 (PST) 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=M0urddS7; 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 S1728564AbfBUOiB (ORCPT + 99 others); Thu, 21 Feb 2019 09:38:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:59436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728546AbfBUOh5 (ORCPT ); Thu, 21 Feb 2019 09:37:57 -0500 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 22E082075C; Thu, 21 Feb 2019 14:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550759876; bh=kD7zn9V1OnIjigT1RIjipb2iDl/cpsRBWgdmTtiTzns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0urddS7CY0DJ0h0D90r7KXVqpUnog+4rjOTzVDMYsIsRoaup5LeBNGvXsFeuqHVA gKDAAx2L+mqjV+XvslOKR96RjE8KQy8wRT6HHCA2oPRIapIOtuaCwzuDv4j/QkMATn 52Z8M2h/qzofYkITQ5CUzeuG+GsSv00BBEH0Y3Vs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel Subject: [PATCH 4.4 20/20] KVM: VMX: Fix x2apic check in vmx_msr_bitmap_mode() Date: Thu, 21 Feb 2019 15:35:50 +0100 Message-Id: <20190221141947.351023124@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221141946.772985220@linuxfoundation.org> References: <20190221141946.772985220@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joerg Roedel The stable backport of upstream commit 904e14fb7cb96 KVM: VMX: make MSR bitmaps per-VCPU has a bug in vmx_msr_bitmap_mode(). It enables the x2apic MSR-bitmap when the kernel emulates x2apic for the guest in software. The upstream version of the commit checkes whether the hardware has virtualization enabled for x2apic emulation. Since KVM emulates x2apic for guests even when the host does not support x2apic in hardware, this causes the intercept of at least the X2APIC_TASKPRI MSR to be disabled on machines not supporting that MSR. The result is undefined behavior, on some machines (Intel Westmere based) it causes a crash of the guest kernel when it tries to access that MSR. Change the check in vmx_msr_bitmap_mode() to match the upstream code. This fixes the guest crashes observed with stable kernels starting with v4.4.168 through v4.4.175. Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4628,7 +4628,9 @@ static u8 vmx_msr_bitmap_mode(struct kvm { u8 mode = 0; - if (irqchip_in_kernel(vcpu->kvm) && apic_x2apic_mode(vcpu->arch.apic)) { + if (cpu_has_secondary_exec_ctrls() && + (vmcs_read32(SECONDARY_VM_EXEC_CONTROL) & + SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE)) { mode |= MSR_BITMAP_MODE_X2APIC; if (enable_apicv) mode |= MSR_BITMAP_MODE_X2APIC_APICV;