All of lore.kernel.org
 help / color / mirror / Atom feed
* Restoring saved guest causes guest to reboot
@ 2011-05-24  7:11 Markus Schade
  2011-05-24  9:18 ` Joerg Roedel
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Schade @ 2011-05-24  7:11 UTC (permalink / raw)
  To: kvm

Hello,

after upgrading the kernel from 2.6.37.6 to 2.6.38.X the guest domain
reboots immediately after restore from a saved state. The OS of the guest is not
a factor as it is the same for Linux (Debian, Ubuntu, CentOS, etc.), FreeBSD
and Windows.

While save and restore seems to work on a suspended guest. But once the guest
is resumed, the domain reboots. Last working kernel version is 2.6.37.6.

I can confirm this behaviour with qemu-kvm 0.13.0 to latest 0.14.1
and vanilla kernels up to 2.6.39.

This also won't work on unmodified stock installs of Ubuntu 11.04 or
Fedora 15.

Please let me know, if you need further information or testing.

Best regards,
Markus

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24  7:11 Restoring saved guest causes guest to reboot Markus Schade
@ 2011-05-24  9:18 ` Joerg Roedel
  2011-05-24  9:35   ` Markus Schade
  0 siblings, 1 reply; 18+ messages in thread
From: Joerg Roedel @ 2011-05-24  9:18 UTC (permalink / raw)
  To: Markus Schade; +Cc: kvm

On Tue, May 24, 2011 at 09:11:44AM +0200, Markus Schade wrote:
> after upgrading the kernel from 2.6.37.6 to 2.6.38.X the guest domain
> reboots immediately after restore from a saved state. The OS of the guest is not
> a factor as it is the same for Linux (Debian, Ubuntu, CentOS, etc.), FreeBSD
> and Windows.
>
> While save and restore seems to work on a suspended guest. But once the guest
> is resumed, the domain reboots. Last working kernel version is 2.6.37.6.
>
> I can confirm this behaviour with qemu-kvm 0.13.0 to latest 0.14.1
> and vanilla kernels up to 2.6.39.
>
> This also won't work on unmodified stock installs of Ubuntu 11.04 or
> Fedora 15.
>
> Please let me know, if you need further information or testing.

What hardware does your host run on?

	Joerg


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24  9:18 ` Joerg Roedel
@ 2011-05-24  9:35   ` Markus Schade
  2011-05-24  9:40     ` Joerg Roedel
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Schade @ 2011-05-24  9:35 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: kvm

On Tue, 24 May 2011, Joerg Roedel wrote:

> On Tue, May 24, 2011 at 09:11:44AM +0200, Markus Schade wrote:
>> after upgrading the kernel from 2.6.37.6 to 2.6.38.X the guest domain
>> reboots immediately after restore from a saved state. The OS of the guest is not
>> a factor as it is the same for Linux (Debian, Ubuntu, CentOS, etc.), FreeBSD
>> and Windows.
>>
>> While save and restore seems to work on a suspended guest. But once the guest
>> is resumed, the domain reboots. Last working kernel version is 2.6.37.6.
>>
>> I can confirm this behaviour with qemu-kvm 0.13.0 to latest 0.14.1
>> and vanilla kernels up to 2.6.39.
>>
>> This also won't work on unmodified stock installs of Ubuntu 11.04 or
>> Fedora 15.
>>
>> Please let me know, if you need further information or testing.
>
> What hardware does your host run on?

The main target systems are Intel Core i7 (920 to 950) on a MSI X58 Pro
mainboard with 24GB RAM and an Adaptec 5405 RAID controller with 3 disks
in a RAID-5 configuration. The controller is not a factor (happens also
with MD RAID).

To rule out an issue with this specific mainboard and CPU, i have also
check this (only with F15) on a Core i5 and and Asus P55 mainboard.

I could try to also confirm this on AMD X2, but it will take me a little
to setup a machine.

Gruß,
Markus


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24  9:35   ` Markus Schade
@ 2011-05-24  9:40     ` Joerg Roedel
  2011-05-24 11:42       ` Markus Schade
  0 siblings, 1 reply; 18+ messages in thread
From: Joerg Roedel @ 2011-05-24  9:40 UTC (permalink / raw)
  To: Markus Schade; +Cc: kvm

On Tue, May 24, 2011 at 11:35:27AM +0200, Markus Schade wrote:
> On Tue, 24 May 2011, Joerg Roedel wrote:
>
>> On Tue, May 24, 2011 at 09:11:44AM +0200, Markus Schade wrote:
>>> after upgrading the kernel from 2.6.37.6 to 2.6.38.X the guest domain
>>> reboots immediately after restore from a saved state. The OS of the guest is not
>>> a factor as it is the same for Linux (Debian, Ubuntu, CentOS, etc.), FreeBSD
>>> and Windows.
>>>
>>> While save and restore seems to work on a suspended guest. But once the guest
>>> is resumed, the domain reboots. Last working kernel version is 2.6.37.6.
>>>
>>> I can confirm this behaviour with qemu-kvm 0.13.0 to latest 0.14.1
>>> and vanilla kernels up to 2.6.39.
>>>
>>> This also won't work on unmodified stock installs of Ubuntu 11.04 or
>>> Fedora 15.
>>>
>>> Please let me know, if you need further information or testing.
>>
>> What hardware does your host run on?
>
> The main target systems are Intel Core i7 (920 to 950) on a MSI X58 Pro
> mainboard with 24GB RAM and an Adaptec 5405 RAID controller with 3 disks
> in a RAID-5 configuration. The controller is not a factor (happens also
> with MD RAID).
>
> To rule out an issue with this specific mainboard and CPU, i have also
> check this (only with F15) on a Core i5 and and Asus P55 mainboard.
>
> I could try to also confirm this on AMD X2, but it will take me a little
> to setup a machine.

Your description points to some problem in the kernel. Would be good if
you could try the same on your AMD X2 to find out if the problem is in
generic kvm code or in the vmx part.

	Joerg


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24  9:40     ` Joerg Roedel
@ 2011-05-24 11:42       ` Markus Schade
  2011-05-24 13:02         ` Joerg Roedel
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Schade @ 2011-05-24 11:42 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: kvm

Hi,

On Tue, 24 May 2011, Joerg Roedel wrote:

>> I could try to also confirm this on AMD X2, but it will take me a little
>> to setup a machine.
>
> Your description points to some problem in the kernel. Would be good if
> you could try the same on your AMD X2 to find out if the problem is in
> generic kvm code or in the vmx part.

Okay, it seems to be an Intel-specific bug. I have tested multiple qemu-kvm
(0.13, 0.14 and 0.14.1) and kernel versions (2.6.37.6, 2.6.38.6 and
2.6.39) on an AMD X2 6000+. Neither of them causes the guest to reboot.
Everything works as expected.

Best regards,
Markus


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24 11:42       ` Markus Schade
@ 2011-05-24 13:02         ` Joerg Roedel
  2011-05-24 13:20           ` Avi Kivity
  0 siblings, 1 reply; 18+ messages in thread
From: Joerg Roedel @ 2011-05-24 13:02 UTC (permalink / raw)
  To: Markus Schade; +Cc: kvm, avi

On Tue, May 24, 2011 at 01:42:23PM +0200, Markus Schade wrote:
> Hi,
>
> On Tue, 24 May 2011, Joerg Roedel wrote:
>
>>> I could try to also confirm this on AMD X2, but it will take me a little
>>> to setup a machine.
>>
>> Your description points to some problem in the kernel. Would be good if
>> you could try the same on your AMD X2 to find out if the problem is in
>> generic kvm code or in the vmx part.
>
> Okay, it seems to be an Intel-specific bug. I have tested multiple qemu-kvm
> (0.13, 0.14 and 0.14.1) and kernel versions (2.6.37.6, 2.6.38.6 and
> 2.6.39) on an AMD X2 6000+. Neither of them causes the guest to reboot.
> Everything works as expected.

Hmm, only 19 patches between .37 and .38 touch vmx.c. Avi, any idea which
of those patches could cause this?

Regards,

	Joerg

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24 13:02         ` Joerg Roedel
@ 2011-05-24 13:20           ` Avi Kivity
  2011-05-24 13:37             ` Markus Schade
  0 siblings, 1 reply; 18+ messages in thread
From: Avi Kivity @ 2011-05-24 13:20 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Markus Schade, kvm

On 05/24/2011 04:02 PM, Joerg Roedel wrote:
> On Tue, May 24, 2011 at 01:42:23PM +0200, Markus Schade wrote:
> >  Hi,
> >
> >  On Tue, 24 May 2011, Joerg Roedel wrote:
> >
> >>>  I could try to also confirm this on AMD X2, but it will take me a little
> >>>  to setup a machine.
> >>
> >>  Your description points to some problem in the kernel. Would be good if
> >>  you could try the same on your AMD X2 to find out if the problem is in
> >>  generic kvm code or in the vmx part.
> >
> >  Okay, it seems to be an Intel-specific bug. I have tested multiple qemu-kvm
> >  (0.13, 0.14 and 0.14.1) and kernel versions (2.6.37.6, 2.6.38.6 and
> >  2.6.39) on an AMD X2 6000+. Neither of them causes the guest to reboot.
> >  Everything works as expected.
>
> Hmm, only 19 patches between .37 and .38 touch vmx.c. Avi, any idea which
> of those patches could cause this?

Might be several.

Markus, can you try a bisect?

The command

  $ git bisect start v2.6.38 v2.6.37 arch/x86/kvm

will generate test kernels for you to compile and run.  There will be 
7-8 tests needed, and most of the compiles should be short (esp. if you 
install ccache).

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24 13:20           ` Avi Kivity
@ 2011-05-24 13:37             ` Markus Schade
  2011-05-24 13:42               ` Avi Kivity
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Schade @ 2011-05-24 13:37 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Joerg Roedel, kvm

On Tue, 24 May 2011, Avi Kivity wrote:

>> Hmm, only 19 patches between .37 and .38 touch vmx.c. Avi, any idea which
>> of those patches could cause this?
>
> Might be several.
>
> Markus, can you try a bisect?
>
> The command
>
> $ git bisect start v2.6.38 v2.6.37 arch/x86/kvm
>
> will generate test kernels for you to compile and run.  There will be 7-8 
> tests needed, and most of the compiles should be short (esp. if you install 
> ccache).

Sure. I will take some time, though. Shall I use Linus git tree or the
kvm one?

Best regards,
Markus

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24 13:37             ` Markus Schade
@ 2011-05-24 13:42               ` Avi Kivity
  2011-05-25  6:49                 ` Markus Schade
  0 siblings, 1 reply; 18+ messages in thread
From: Avi Kivity @ 2011-05-24 13:42 UTC (permalink / raw)
  To: Markus Schade; +Cc: Joerg Roedel, kvm

On 05/24/2011 04:37 PM, Markus Schade wrote:
> On Tue, 24 May 2011, Avi Kivity wrote:
>
>>> Hmm, only 19 patches between .37 and .38 touch vmx.c. Avi, any idea 
>>> which
>>> of those patches could cause this?
>>
>> Might be several.
>>
>> Markus, can you try a bisect?
>>
>> The command
>>
>> $ git bisect start v2.6.38 v2.6.37 arch/x86/kvm
>>
>> will generate test kernels for you to compile and run.  There will be 
>> 7-8 tests needed, and most of the compiles should be short (esp. if 
>> you install ccache).
>
> Sure. I will take some time, though. Shall I use Linus git tree or the
> kvm one?

Either will work - the kvm tree includes the Linus tree.  Since you 
tested .37 and .38, best to give those to git as starting points.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-24 13:42               ` Avi Kivity
@ 2011-05-25  6:49                 ` Markus Schade
  2011-05-26  6:44                   ` Avi Kivity
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Schade @ 2011-05-25  6:49 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Joerg Roedel, kvm

On 05/24/2011 03:42 PM, Avi Kivity wrote:
> On 05/24/2011 04:37 PM, Markus Schade wrote:
>> On Tue, 24 May 2011, Avi Kivity wrote:
>>
>>>> Hmm, only 19 patches between .37 and .38 touch vmx.c. Avi, any idea
>>>> which
>>>> of those patches could cause this?
>>>
>>> Might be several.
>>>
>>> Markus, can you try a bisect?
>>>
>>> The command
>>>
>>> $ git bisect start v2.6.38 v2.6.37 arch/x86/kvm
>>>
>>> will generate test kernels for you to compile and run. There will be
>>> 7-8 tests needed, and most of the compiles should be short (esp. if
>>> you install ccache).
>>
>> Sure. I will take some time, though. Shall I use Linus git tree or the
>> kvm one?
>
> Either will work - the kvm tree includes the Linus tree. Since you
> tested .37 and .38, best to give those to git as starting points.

Git bisect tells me that this is the first bad commit:
-----------------%<-----------------
aff48baa34c033318ad322ecbf2e4bcd891b29ca is the first bad commit
commit aff48baa34c033318ad322ecbf2e4bcd891b29ca
Author: Avi Kivity <avi@redhat.com>
Date:   Sun Dec 5 18:56:11 2010 +0200

     KVM: Fetch guest cr3 from hardware on demand

     Instead of syncing the guest cr3 every exit, which is expensince on vmx
     with ept enabled, sync it only on demand.

     [sheng: fix incorrect cr3 seen by Windows XP]

     Signed-off-by: Sheng Yang <sheng@linux.intel.com>
     Signed-off-by: Avi Kivity <avi@redhat.com>

:040000 040000 fb059dc23facd323cafc88a39cff862f044d693d 
77247dfbfe49f0a732cbaa2593d794c3b6c8f0fc M      arch
-----------------%<-----------------

The full log is:

# bad: [521cb40b0c44418a4fd36dc633f575813d59a43d] Linux 2.6.38
# good: [3c0eee3fe6a3a1c745379547c7e7c904aa64f6d5] Linux 2.6.37
git bisect start 'v2.6.38' 'v2.6.37' 'arch/x86/kvm'
# good: [ec9e60b21977007e3dfacc2b8fe3a8fbb9276b51] KVM: X86: Introduce 
generic guest-mode representation
git bisect good ec9e60b21977007e3dfacc2b8fe3a8fbb9276b51
# good: [d4dbf470096c51cb4785167ea59fdbdea87ccbe4] KVM: MMU: Make the 
way of accessing lpage_info more generic
git bisect good d4dbf470096c51cb4785167ea59fdbdea87ccbe4
# good: [c445f8ef43bd9d2fb28213920d9b21f2465d22df] KVM: MMU: Initialize 
base_role for tdp mmus
git bisect good c445f8ef43bd9d2fb28213920d9b21f2465d22df
# bad: [444e863d13373b958ec6b133dcecf140d6c6c2ab] KVM: VMX: when 
entering real mode align segment base to 16 bytes
git bisect bad 444e863d13373b958ec6b133dcecf140d6c6c2ab
# good: [9f8fe5043fd26627c2fa2e9a41896885e675000b] KVM: Replace reads of 
vcpu->arch.cr3 by an accessor
git bisect good 9f8fe5043fd26627c2fa2e9a41896885e675000b
# bad: [b034cf0105235e65ee1b0161dbe8fef0338d06e7] KVM: MMU: audit: allow 
audit more guests at the same time
git bisect bad b034cf0105235e65ee1b0161dbe8fef0338d06e7
# bad: [aff48baa34c033318ad322ecbf2e4bcd891b29ca] KVM: Fetch guest cr3 
from hardware on demand
git bisect bad aff48baa34c033318ad322ecbf2e4bcd891b29ca

Best regards,
Markus

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-25  6:49                 ` Markus Schade
@ 2011-05-26  6:44                   ` Avi Kivity
  2011-05-26 11:28                     ` Markus Schade
  0 siblings, 1 reply; 18+ messages in thread
From: Avi Kivity @ 2011-05-26  6:44 UTC (permalink / raw)
  To: Markus Schade; +Cc: Joerg Roedel, kvm

On 05/25/2011 09:49 AM, Markus Schade wrote:
>
> Git bisect tells me that this is the first bad commit:
> -----------------%<-----------------
> aff48baa34c033318ad322ecbf2e4bcd891b29ca is the first bad commit
> commit aff48baa34c033318ad322ecbf2e4bcd891b29ca
> Author: Avi Kivity <avi@redhat.com>
> Date:   Sun Dec 5 18:56:11 2010 +0200
>
>     KVM: Fetch guest cr3 from hardware on demand
>
>     Instead of syncing the guest cr3 every exit, which is expensince 
> on vmx
>     with ept enabled, sync it only on demand.
>
>     [sheng: fix incorrect cr3 seen by Windows XP]
>
>     Signed-off-by: Sheng Yang <sheng@linux.intel.com>
>     Signed-off-by: Avi Kivity <avi@redhat.com>
>

Does your machine have ept?

(cat /sys/module/kvm_intel/parameters/ept)

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-26  6:44                   ` Avi Kivity
@ 2011-05-26 11:28                     ` Markus Schade
  2011-05-26 15:20                       ` Markus Schade
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Schade @ 2011-05-26 11:28 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Joerg Roedel, kvm

On 05/26/2011 08:44 AM, Avi Kivity wrote:
> On 05/25/2011 09:49 AM, Markus Schade wrote:
>>
>> Git bisect tells me that this is the first bad commit:
>> -----------------%<-----------------
>> aff48baa34c033318ad322ecbf2e4bcd891b29ca is the first bad commit
>> commit aff48baa34c033318ad322ecbf2e4bcd891b29ca Author: Avi Kivity
>> <avi@redhat.com> Date: Sun Dec 5 18:56:11 2010 +0200
>>
>> KVM: Fetch guest cr3 from hardware on demand
>>
>> Instead of syncing the guest cr3 every exit, which is expensince on
>> vmx with ept enabled, sync it only on demand.
>>
>> [sheng: fix incorrect cr3 seen by Windows XP]
>>
>> Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by:
>> Avi Kivity <avi@redhat.com>
>>
>
> Does your machine have ept?
>
> (cat /sys/module/kvm_intel/parameters/ept)
>

Sure. (Assuming that the Y means yes). I am no C developer, but I was 
wondering, if the issue is related to the difference in 
ept_update_paging_mode_cr0 between original patch in the kvm git and the 
linux-2.6. git tree.

Best regards,
Markus

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-26 11:28                     ` Markus Schade
@ 2011-05-26 15:20                       ` Markus Schade
  2011-05-26 15:25                         ` Joerg Roedel
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Schade @ 2011-05-26 15:20 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Joerg Roedel, kvm

On 05/26/2011 01:28 PM, Markus Schade wrote:
> On 05/26/2011 08:44 AM, Avi Kivity wrote:
>> On 05/25/2011 09:49 AM, Markus Schade wrote:
>>>
>>> Git bisect tells me that this is the first bad commit:
>>> -----------------%<-----------------
>>> aff48baa34c033318ad322ecbf2e4bcd891b29ca is the first bad commit
>>
>> Does your machine have ept?
>>
>> (cat /sys/module/kvm_intel/parameters/ept)
>>
>
> Sure. (Assuming that the Y means yes). I am no C developer, but I was
> wondering, if the issue is related to the difference in
> ept_update_paging_mode_cr0 between original patch in the kvm git and the
> linux-2.6. git tree.

I have re-added the missing 4 lines to ept_update_paging_mode_cr0 in 
vmx.c, which resolves this issue for in Kernel 2.6,37 and 2.6.39.
I haven't tested all guests, but neither Squeeze nor 2008 R2 reboot anymore.

Markus

static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer)
@@ -1921,6 +1940,8 @@
                                         unsigned long cr0,
                                         struct kvm_vcpu *vcpu)
  {
+       ulong cr3;
+
         vmx_decache_cr3(vcpu);
         if (!(cr0 & X86_CR0_PG)) {
                 /* From paging/starting to nonpaging */
@@ -1936,8 +1957,11 @@
                              vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) &
                              ~(CPU_BASED_CR3_LOAD_EXITING |
                                CPU_BASED_CR3_STORE_EXITING));
+               /* Must fetch cr3 before updating cr0 */
+               cr3 = kvm_read_cr3(vcpu);
                 vcpu->arch.cr0 = cr0;
                 vmx_set_cr4(vcpu, kvm_read_cr4(vcpu));
+               vmx_set_cr3(vcpu, cr3);




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-26 15:20                       ` Markus Schade
@ 2011-05-26 15:25                         ` Joerg Roedel
  2011-05-30 12:16                           ` Markus Schade
  0 siblings, 1 reply; 18+ messages in thread
From: Joerg Roedel @ 2011-05-26 15:25 UTC (permalink / raw)
  To: Markus Schade; +Cc: Avi Kivity, kvm

On Thu, May 26, 2011 at 05:20:32PM +0200, Markus Schade wrote:
> On 05/26/2011 01:28 PM, Markus Schade wrote:
>> On 05/26/2011 08:44 AM, Avi Kivity wrote:
>>> On 05/25/2011 09:49 AM, Markus Schade wrote:
>>>>
>>>> Git bisect tells me that this is the first bad commit:
>>>> -----------------%<-----------------
>>>> aff48baa34c033318ad322ecbf2e4bcd891b29ca is the first bad commit
>>>
>>> Does your machine have ept?
>>>
>>> (cat /sys/module/kvm_intel/parameters/ept)
>>>
>>
>> Sure. (Assuming that the Y means yes). I am no C developer, but I was
>> wondering, if the issue is related to the difference in
>> ept_update_paging_mode_cr0 between original patch in the kvm git and the
>> linux-2.6. git tree.
>
> I have re-added the missing 4 lines to ept_update_paging_mode_cr0 in  
> vmx.c, which resolves this issue for in Kernel 2.6,37 and 2.6.39.
> I haven't tested all guests, but neither Squeeze nor 2008 R2 reboot anymore.
>
> Markus
>
> static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer)
> @@ -1921,6 +1940,8 @@
>                                         unsigned long cr0,
>                                         struct kvm_vcpu *vcpu)
>  {
> +       ulong cr3;
> +
>         vmx_decache_cr3(vcpu);
>         if (!(cr0 & X86_CR0_PG)) {
>                 /* From paging/starting to nonpaging */
> @@ -1936,8 +1957,11 @@
>                              vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) &
>                              ~(CPU_BASED_CR3_LOAD_EXITING |
>                                CPU_BASED_CR3_STORE_EXITING));
> +               /* Must fetch cr3 before updating cr0 */
> +               cr3 = kvm_read_cr3(vcpu);
>                 vcpu->arch.cr0 = cr0;
>                 vmx_set_cr4(vcpu, kvm_read_cr4(vcpu));
> +               vmx_set_cr3(vcpu, cr3);

Hmm, not 100% sure, but the issue might be that the arch.cr3 value does
not make it into the vmcs after cr3 was changed from user-space? This
would also be fixed with the change above.

	Joerg


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-26 15:25                         ` Joerg Roedel
@ 2011-05-30 12:16                           ` Markus Schade
  2011-05-30 18:02                             ` Marcelo Tosatti
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Schade @ 2011-05-30 12:16 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Avi Kivity, kvm

On Thu, 26 May 2011, Joerg Roedel wrote:

> On Thu, May 26, 2011 at 05:20:32PM +0200, Markus Schade wrote:
>> On 05/26/2011 01:28 PM, Markus Schade wrote:
>>> On 05/26/2011 08:44 AM, Avi Kivity wrote:
>>>> On 05/25/2011 09:49 AM, Markus Schade wrote:
>>>>>
>>>>> Git bisect tells me that this is the first bad commit:
>>>>> -----------------%<-----------------
>>>>> aff48baa34c033318ad322ecbf2e4bcd891b29ca is the first bad commit
>>>>
>>>> Does your machine have ept?
>>>>
>>>> (cat /sys/module/kvm_intel/parameters/ept)
>>>>
>>>
>>> Sure. (Assuming that the Y means yes). I am no C developer, but I was
>>> wondering, if the issue is related to the difference in
>>> ept_update_paging_mode_cr0 between original patch in the kvm git and the
>>> linux-2.6. git tree.
>>
>> I have re-added the missing 4 lines to ept_update_paging_mode_cr0 in
>> vmx.c, which resolves this issue for in Kernel 2.6,37 and 2.6.39.
>> I haven't tested all guests, but neither Squeeze nor 2008 R2 reboot anymore.
>
> Hmm, not 100% sure, but the issue might be that the arch.cr3 value does
> not make it into the vmcs after cr3 was changed from user-space? This
> would also be fixed with the change above.

So, basically, Linus just has to re-pull, since the
"change" I made is already in the tree. Or is there another way to solve
this? I find it hard to believe that I am the only one using
save/restore on Nehalem CPUs or that this bug only affects me.
Although I can verify this on dozens of machines.


Best regards,
Markus

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-30 12:16                           ` Markus Schade
@ 2011-05-30 18:02                             ` Marcelo Tosatti
  2011-05-31  9:44                               ` Markus Schade
  2011-06-06 13:57                               ` Markus Schade
  0 siblings, 2 replies; 18+ messages in thread
From: Marcelo Tosatti @ 2011-05-30 18:02 UTC (permalink / raw)
  To: Markus Schade; +Cc: Joerg Roedel, Avi Kivity, kvm

On Mon, May 30, 2011 at 02:16:41PM +0200, Markus Schade wrote:
> On Thu, 26 May 2011, Joerg Roedel wrote:
> 
> >On Thu, May 26, 2011 at 05:20:32PM +0200, Markus Schade wrote:
> >>On 05/26/2011 01:28 PM, Markus Schade wrote:
> >>>On 05/26/2011 08:44 AM, Avi Kivity wrote:
> >>>>On 05/25/2011 09:49 AM, Markus Schade wrote:
> >>>>>
> >>>>>Git bisect tells me that this is the first bad commit:
> >>>>>-----------------%<-----------------
> >>>>>aff48baa34c033318ad322ecbf2e4bcd891b29ca is the first bad commit
> >>>>
> >>>>Does your machine have ept?
> >>>>
> >>>>(cat /sys/module/kvm_intel/parameters/ept)
> >>>>
> >>>
> >>>Sure. (Assuming that the Y means yes). I am no C developer, but I was
> >>>wondering, if the issue is related to the difference in
> >>>ept_update_paging_mode_cr0 between original patch in the kvm git and the
> >>>linux-2.6. git tree.
> >>
> >>I have re-added the missing 4 lines to ept_update_paging_mode_cr0 in
> >>vmx.c, which resolves this issue for in Kernel 2.6,37 and 2.6.39.
> >>I haven't tested all guests, but neither Squeeze nor 2008 R2 reboot anymore.
> >
> >Hmm, not 100% sure, but the issue might be that the arch.cr3 value does
> >not make it into the vmcs after cr3 was changed from user-space? This
> >would also be fixed with the change above.
> 
> So, basically, Linus just has to re-pull, since the
> "change" I made is already in the tree. Or is there another way to solve
> this? I find it hard to believe that I am the only one using
> save/restore on Nehalem CPUs or that this bug only affects me.
> Although I can verify this on dozens of machines.

Markus,

Please check whether the following patch fixes the problem for you.

-----

Only decache guest CR3 value if vcpu->arch.cr3 is stale.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 750b0ff..772c4d2 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2049,7 +2049,9 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0,
 					unsigned long cr0,
 					struct kvm_vcpu *vcpu)
 {
-	vmx_decache_cr3(vcpu);
+
+	if (!test_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail))
+		vmx_decache_cr3(vcpu);
 	if (!(cr0 & X86_CR0_PG)) {
 		/* From paging/starting to nonpaging */
 		vmcs_write32(CPU_BASED_VM_EXEC_CONTROL,

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-30 18:02                             ` Marcelo Tosatti
@ 2011-05-31  9:44                               ` Markus Schade
  2011-06-06 13:57                               ` Markus Schade
  1 sibling, 0 replies; 18+ messages in thread
From: Markus Schade @ 2011-05-31  9:44 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Markus Schade, Joerg Roedel, Avi Kivity, kvm

Am 30.05.2011 20:02, schrieb Marcelo Tosatti:
> On Mon, May 30, 2011 at 02:16:41PM +0200, Markus Schade wrote:
>> On Thu, 26 May 2011, Joerg Roedel wrote:
>>
>>> On Thu, May 26, 2011 at 05:20:32PM +0200, Markus Schade wrote:
>>>> I have re-added the missing 4 lines to ept_update_paging_mode_cr0 in
>>>> vmx.c, which resolves this issue for in Kernel 2.6,37 and 2.6.39.
>>>> I haven't tested all guests, but neither Squeeze nor 2008 R2 reboot anymore.
>>>
>>> Hmm, not 100% sure, but the issue might be that the arch.cr3 value does
>>> not make it into the vmcs after cr3 was changed from user-space? This
>>> would also be fixed with the change above.
>>
>> So, basically, Linus just has to re-pull, since the
>> "change" I made is already in the tree. Or is there another way to solve
>> this? I find it hard to believe that I am the only one using
>> save/restore on Nehalem CPUs or that this bug only affects me.
>> Although I can verify this on dozens of machines.
>
> Markus,
>
> Please check whether the following patch fixes the problem for you.

Thanks, I will try that. But I won't be able to get back to you before 
next week (short week in Germany *g*)

Markus

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Restoring saved guest causes guest to reboot
  2011-05-30 18:02                             ` Marcelo Tosatti
  2011-05-31  9:44                               ` Markus Schade
@ 2011-06-06 13:57                               ` Markus Schade
  1 sibling, 0 replies; 18+ messages in thread
From: Markus Schade @ 2011-06-06 13:57 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Joerg Roedel, Avi Kivity, kvm

On 05/30/2011 08:02 PM, Marcelo Tosatti wrote:
> On Mon, May 30, 2011 at 02:16:41PM +0200, Markus Schade wrote:
>> On Thu, 26 May 2011, Joerg Roedel wrote:
>>
>>> On Thu, May 26, 2011 at 05:20:32PM +0200, Markus Schade wrote:
>>>> On 05/26/2011 01:28 PM, Markus Schade wrote:
>>>>> On 05/26/2011 08:44 AM, Avi Kivity wrote:
>>>>>> On 05/25/2011 09:49 AM, Markus Schade wrote:
>>>>>>>
>>>>>>> Git bisect tells me that this is the first bad commit:
>>>>>>> -----------------%<-----------------
>>>>>>> aff48baa34c033318ad322ecbf2e4bcd891b29ca is the first bad commit
>>>>>>
>>>>>> Does your machine have ept?
>>>>>>
>>>>>> (cat /sys/module/kvm_intel/parameters/ept)
>>>>>>
>>>>>
>>>>> Sure. (Assuming that the Y means yes). I am no C developer, but I was
>>>>> wondering, if the issue is related to the difference in
>>>>> ept_update_paging_mode_cr0 between original patch in the kvm git and the
>>>>> linux-2.6. git tree.
>>>>
>>>> I have re-added the missing 4 lines to ept_update_paging_mode_cr0 in
>>>> vmx.c, which resolves this issue for in Kernel 2.6,37 and 2.6.39.
>>>> I haven't tested all guests, but neither Squeeze nor 2008 R2 reboot anymore.
>
> Please check whether the following patch fixes the problem for you.

Marcelo,

your patch fixes the problem as well (tested in 2.6.39.1). Thanks a lot.

Markus

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2011-06-06 13:58 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-24  7:11 Restoring saved guest causes guest to reboot Markus Schade
2011-05-24  9:18 ` Joerg Roedel
2011-05-24  9:35   ` Markus Schade
2011-05-24  9:40     ` Joerg Roedel
2011-05-24 11:42       ` Markus Schade
2011-05-24 13:02         ` Joerg Roedel
2011-05-24 13:20           ` Avi Kivity
2011-05-24 13:37             ` Markus Schade
2011-05-24 13:42               ` Avi Kivity
2011-05-25  6:49                 ` Markus Schade
2011-05-26  6:44                   ` Avi Kivity
2011-05-26 11:28                     ` Markus Schade
2011-05-26 15:20                       ` Markus Schade
2011-05-26 15:25                         ` Joerg Roedel
2011-05-30 12:16                           ` Markus Schade
2011-05-30 18:02                             ` Marcelo Tosatti
2011-05-31  9:44                               ` Markus Schade
2011-06-06 13:57                               ` Markus Schade

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.