From patchwork Fri Feb 27 08:56:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wincy Van X-Patchwork-Id: 5899541 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4D00E9F38E for ; Fri, 27 Feb 2015 08:56:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78A7E20148 for ; Fri, 27 Feb 2015 08:56:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 985612013A for ; Fri, 27 Feb 2015 08:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754637AbbB0I43 (ORCPT ); Fri, 27 Feb 2015 03:56:29 -0500 Received: from mail-lb0-f181.google.com ([209.85.217.181]:46816 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752093AbbB0I42 (ORCPT ); Fri, 27 Feb 2015 03:56:28 -0500 Received: by lbjf15 with SMTP id f15so15801317lbj.13; Fri, 27 Feb 2015 00:56:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=qQcN+Auf7h0MknlBGOQF/ECMQJlQ+4kEUYc2lcNY8XU=; b=IsprR53cvvffiKMGN9XyPwxmpkQkZOeG26LFm9di9dvHcZj2YcBG4ZHaFbirli6n69 EfRDh/U8Akm8uKcJvoFlKG81C3qMPGDo1bG2l76H4g3LDKChZEaD5fZMeE+zSvzCwv57 BgA4uDTjk59MMGS5UxMX3DWpLB70JZl7V4XIA7/pVUE8vjH/JECGdHFV4KGoNGHg2Emd I87bhaBLiISlQ59dtBeOEfLz+foHDQQjDi48Ntldg/p16RlMPu4nTYKTt35KO5FA6/Gw dsXK8Wjn5EDdqOcRXWCppfwXrxOeMvjfL7aAe7BQI8qoEeQK2qVMmda7u1SMl4v8j4UR tGOQ== X-Received: by 10.112.97.106 with SMTP id dz10mr11462006lbb.4.1425027386313; Fri, 27 Feb 2015 00:56:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.36.4 with HTTP; Fri, 27 Feb 2015 00:56:06 -0800 (PST) In-Reply-To: <20150215062755.GA2603@ywang-linux> References: <1422979097-2203-1-git-send-email-fanwenyi0529@gmail.com> <20150215062755.GA2603@ywang-linux> From: Wincy Van Date: Fri, 27 Feb 2015 16:56:06 +0800 Message-ID: Subject: Re: [PATCH resend v5 6/6] KVM: nVMX: Enable nested posted interrupt processing To: Yong Wang Cc: Paolo Bonzini , "gleb@kernel.org" , "Zhang, Yang Z" , Wanpeng Li , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jan Kiszka , mtosatti@redhat.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sun, Feb 15, 2015 at 2:27 PM, Yong Wang wrote: > > Wincy, our QA found regressions with this patch that 64bit L2 linux guest > fails to boot up when running nested kvm on kvm. > > Environment: > ------------ > Host OS (ia32/ia32e/IA64):ia32e > Guest OS (ia32/ia32e/IA64):ia32e > Guest OS Type (Linux/Windows):Linux > kvm.git Commit:6557bada461afeaa920a189fae2cff7c8fdce39f > qemu.kvm Commit:5c697ae74170d43928cb185f5ac1a9058adcae0b > Host Kernel Version:3.19.0-rc3 > Hardware:Ivytown_EP, Haswell_EP > > > Bug detailed description: > -------------------------- > create 64bit linux guest as L2 guest, the guest boot up fail > > note: > 1. create a 32bit linux guest as L2 guest, the guest boots up fine. > 2. create a 64bit windows guest as L2 guest, the guest boots up fine. > 3. this should be a kernel bug: > kvm + qemu = result > 6557bada + 5c697ae7 = bad > 8fff5e37 + 5c697ae7 = good > > Reproduce steps: > ---------------- > 1 create L1 guest: > qemu-system-x86_64 -enable-kvm -m 8G -smp 4 -net nic,macaddr=00:12:31:34:51:31 -net tap,script=/etc/kvm/qemu-ifup nested-kvm.qcow -cpu host > > 2. create L2 guest > qemu-system-x86_64 -enable-kvm -m 2G -smp 2 -net none rhel6u5.qcow > > Current result: > ---------------- > create 64bit linux guest as L2 guest, the guest boots up fail > > Expected result: > ---------------- > create 64bit linux guest as L2 guest, the guest boots up fine > > Please take a look. > Yong, according to the logs, I found that L1 may have disabled x2apic, and the MSR_BITMAP field will be modified by following vmx_set_efer in prepare_vmcs02. So I think we can fix this issue by: Thanks, Wincy --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f7b20b4..f6e3457 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2168,7 +2168,10 @@ static void vmx_set_msr_bitmap(struct kvm_vcpu *vcpu) { unsigned long *msr_bitmap; - if (irqchip_in_kernel(vcpu->kvm) && apic_x2apic_mode(vcpu->arch.apic)) { + if (is_guest_mode(vcpu)) + msr_bitmap = vmx_msr_bitmap_nested; + else if (irqchip_in_kernel(vcpu->kvm) && + apic_x2apic_mode(vcpu->arch.apic)) { if (is_long_mode(vcpu)) msr_bitmap = vmx_msr_bitmap_longmode_x2apic; else