From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755276AbcGFRLq (ORCPT ); Wed, 6 Jul 2016 13:11:46 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:34016 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752945AbcGFRLo (ORCPT ); Wed, 6 Jul 2016 13:11:44 -0400 Subject: Re: [PATCH v3] KVM: nVMX: Fix incorrect preemption timer vmexit in nested guest To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Wanpeng Li , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Yunhong Jiang , Jan Kiszka , Jim Mattson References: <1467805375-4676-1-git-send-email-wanpeng.li@hotmail.com> <20160706132601.qxcn7sm365xf6pos@hz-desktop> <65eb56ae-c55d-cca4-d685-83413621bb9a@redhat.com> <20160706160322.kg3jbwztkfhl7gw5@hz-desktop> From: Paolo Bonzini Message-ID: <7ae48d13-5349-0b81-df2b-e14217feb8f2@redhat.com> Date: Wed, 6 Jul 2016 19:11:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <20160706160322.kg3jbwztkfhl7gw5@hz-desktop> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/07/2016 18:03, Haozhong Zhang wrote: >>> This patch also fixed the crash of L1 Xen with L2 HVM guest. Xen does >>> not enable preemption timer for HVM guests, and will get panic if it >>> receives a preemption timer vmexit. >> >> Thanks! I'm still not sure why the bit is set in the vmcs02 though... > > Yes, it looks really weird. > > I replaced "return false" in Wanpeng's patch by > > pr_info("VMCS: preemption timer enabled = %d\n", > !!(vmcs_read32(PIN_BASED_VM_EXEC_CONTROL) & PIN_BASED_VMX_PREEMPTION_TIMER)); > > and redid my test. As expected, L1 Xen crashed due to the unexpected > preemption timer vmexit. I got a log from above statement just before crash: > > VMCS: preemption timer enabled = 1 > > which is expected to be 0, because preemption timer is disabled in > vmcs02. I also modified L1 Xen to dump VMCS at crash, and it says > preemption timer is disabled. > > I noticed Jim Mattson recently sent a patch "KVM: nVMX: Fix memory > corruption when using VMCS shadowing" to fix the inconsistency between > vmcs12 and its shadow. Is it relevant here? I'll test his patch > tomorrow. No, it shouldn't have any effect. I think it happens when the post_block hook switches back from sw_timer to hv_timer, and L2 is running. So the right fix should be along the lines of what I posted earlier. If you don't beat me to it, I'll take another look tomorrow. Paolo