All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	Christophe Fergeau <cfergeau@redhat.com>
Subject: Re: [PATCH][uq/master] kvm: x86: Save/restore FPU OP, IP and DP
Date: Wed, 15 Jun 2011 12:39:21 +0200	[thread overview]
Message-ID: <4DF88BD9.2050106@siemens.com> (raw)
In-Reply-To: <4DF88773.3050401@web.de>

On 2011-06-15 12:20, Jan Kiszka wrote:
> On 2011-06-15 11:10, Avi Kivity wrote:
>> On 06/14/2011 09:10 AM, Jan Kiszka wrote:
>>> On 2011-06-13 10:45, Avi Kivity wrote:
>>>>  On 06/11/2011 12:23 PM, Jan Kiszka wrote:
>>>>>  From: Jan Kiszka<jan.kiszka@siemens.com>
>>>>>
>>>>>  These FPU states are properly maintained by KVM but not yet by
>>> TCG. So
>>>>>  far we unconditionally set them to 0 in the guest which may cause
>>>>>  state corruptions - not only during migration.
>>>>>
>>>>>
>>>>>  -#define CPU_SAVE_VERSION 12
>>>>>  +#define CPU_SAVE_VERSION 13
>>>>>
>>>>
>>>>  Incrementing the version number seems excessive - I can't imagine a
>>>>  real-life guest will break due to fp pointer corruption
>>>>
>>>>  However, I don't think we have a mechanism for optional state.  We
>>>>  discussed this during the 18th VMState Subsection Symposium and IIRC
>>>>  agreed to re-raise the issue when we encountered it, which appears
>>> to be
>>>>  now.
>>>>
>>>
>>> Whatever we invent, it has to be backported as well to allow that
>>> infamous traveling back in time, migrating VMs from newer to older
>>> versions.
>>>
>>> Would that backporting be simpler if we used an unconditional subsection
>>> for the additional states?
>>
>> Thinking about it, a conditional subsection would work fine.  Most
>> threads will never see an fpu error, and are all initialized to a clean
>> slate.
>>
>> SDM 1 8.1.9.1 says:
>>
>>> 8.1.9.1 Fopcode Compatibility Sub-mode
>>> Beginning with the Pentium 4 and Intel Xeon processors, the IA-32
>>> architecture
>>> provides program control over the storing of the last instruction
>>> opcode (sometimes
>>> referred to as the fopcode). Here, bit 2 of the IA32_MISC_ENABLE MSR
>>> enables (set)
>>> or disables (clear) the fopcode compatibility mode.
>>> If FOP code compatibility mode is enabled, the FOP is defined as it
>>> has always been
>>> in previous IA32 implementations (always defined as the FOP of the
>>> last non-trans-
>>> parent FP instruction executed before a FSAVE/FSTENV/FXSAVE). If FOP code
>>> compatibility mode is disabled (default), FOP is only valid if the
>>> last non-transparent
>>> FP instruction executed before a FSAVE/FSTENV/FXSAVE had an unmasked
>>> exception.
>>
>> So fopcode will usually be clear.
>>
> 
> OK. So if bit 2 of IA32_MISC_ENABLE MSR, we must save that fields. But
> if it's off, how to test for that other condition "last non-transparent
> FP instruction ... had an unmasked exception" from the host?

I briefly thought about status.ES == 1. But the guest may clear the flag
in its exception handler before reading opcode etc.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>
Cc: Christophe Fergeau <cfergeau@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>, kvm <kvm@vger.kernel.org>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH][uq/master] kvm: x86: Save/restore FPU OP, IP and DP
Date: Wed, 15 Jun 2011 12:39:21 +0200	[thread overview]
Message-ID: <4DF88BD9.2050106@siemens.com> (raw)
In-Reply-To: <4DF88773.3050401@web.de>

On 2011-06-15 12:20, Jan Kiszka wrote:
> On 2011-06-15 11:10, Avi Kivity wrote:
>> On 06/14/2011 09:10 AM, Jan Kiszka wrote:
>>> On 2011-06-13 10:45, Avi Kivity wrote:
>>>>  On 06/11/2011 12:23 PM, Jan Kiszka wrote:
>>>>>  From: Jan Kiszka<jan.kiszka@siemens.com>
>>>>>
>>>>>  These FPU states are properly maintained by KVM but not yet by
>>> TCG. So
>>>>>  far we unconditionally set them to 0 in the guest which may cause
>>>>>  state corruptions - not only during migration.
>>>>>
>>>>>
>>>>>  -#define CPU_SAVE_VERSION 12
>>>>>  +#define CPU_SAVE_VERSION 13
>>>>>
>>>>
>>>>  Incrementing the version number seems excessive - I can't imagine a
>>>>  real-life guest will break due to fp pointer corruption
>>>>
>>>>  However, I don't think we have a mechanism for optional state.  We
>>>>  discussed this during the 18th VMState Subsection Symposium and IIRC
>>>>  agreed to re-raise the issue when we encountered it, which appears
>>> to be
>>>>  now.
>>>>
>>>
>>> Whatever we invent, it has to be backported as well to allow that
>>> infamous traveling back in time, migrating VMs from newer to older
>>> versions.
>>>
>>> Would that backporting be simpler if we used an unconditional subsection
>>> for the additional states?
>>
>> Thinking about it, a conditional subsection would work fine.  Most
>> threads will never see an fpu error, and are all initialized to a clean
>> slate.
>>
>> SDM 1 8.1.9.1 says:
>>
>>> 8.1.9.1 Fopcode Compatibility Sub-mode
>>> Beginning with the Pentium 4 and Intel Xeon processors, the IA-32
>>> architecture
>>> provides program control over the storing of the last instruction
>>> opcode (sometimes
>>> referred to as the fopcode). Here, bit 2 of the IA32_MISC_ENABLE MSR
>>> enables (set)
>>> or disables (clear) the fopcode compatibility mode.
>>> If FOP code compatibility mode is enabled, the FOP is defined as it
>>> has always been
>>> in previous IA32 implementations (always defined as the FOP of the
>>> last non-trans-
>>> parent FP instruction executed before a FSAVE/FSTENV/FXSAVE). If FOP code
>>> compatibility mode is disabled (default), FOP is only valid if the
>>> last non-transparent
>>> FP instruction executed before a FSAVE/FSTENV/FXSAVE had an unmasked
>>> exception.
>>
>> So fopcode will usually be clear.
>>
> 
> OK. So if bit 2 of IA32_MISC_ENABLE MSR, we must save that fields. But
> if it's off, how to test for that other condition "last non-transparent
> FP instruction ... had an unmasked exception" from the host?

I briefly thought about status.ES == 1. But the guest may clear the flag
in its exception handler before reading opcode etc.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  reply	other threads:[~2011-06-15 10:39 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-11  9:23 [PATCH][uq/master] kvm: x86: Save/restore FPU OP, IP and DP Jan Kiszka
2011-06-11  9:23 ` [Qemu-devel] " Jan Kiszka
2011-06-13  8:45 ` Avi Kivity
2011-06-13  8:45   ` [Qemu-devel] " Avi Kivity
2011-06-14  6:10   ` Jan Kiszka
2011-06-14  6:10     ` [Qemu-devel] " Jan Kiszka
2011-06-14  8:23     ` Avi Kivity
2011-06-14  8:23       ` [Qemu-devel] " Avi Kivity
2011-06-14  8:28       ` Jan Kiszka
2011-06-14  8:28         ` [Qemu-devel] " Jan Kiszka
2011-06-15  9:10     ` Avi Kivity
2011-06-15  9:10       ` [Qemu-devel] " Avi Kivity
2011-06-15 10:20       ` Jan Kiszka
2011-06-15 10:20         ` [Qemu-devel] " Jan Kiszka
2011-06-15 10:39         ` Jan Kiszka [this message]
2011-06-15 10:39           ` Jan Kiszka
2011-06-15 11:26         ` Avi Kivity
2011-06-15 11:26           ` [Qemu-devel] " Avi Kivity
2011-06-15 11:32           ` Jan Kiszka
2011-06-15 11:32             ` [Qemu-devel] " Jan Kiszka
2011-06-15 11:33             ` Avi Kivity
2011-06-15 11:33               ` [Qemu-devel] " Avi Kivity
2011-06-15 11:45               ` Jan Kiszka
2011-06-15 11:45                 ` [Qemu-devel] " Jan Kiszka
2011-06-15 13:17 ` [PATCH v2][uq/master] " Jan Kiszka
2011-06-15 13:17   ` [Qemu-devel] " Jan Kiszka
2011-06-16  9:42   ` Christophe Fergeau
2011-06-16  9:42     ` Christophe Fergeau
2011-06-19 12:58   ` Avi Kivity
2011-06-19 12:58     ` [Qemu-devel] " Avi Kivity
2011-06-16  9:35 ` [PATCH][uq/master] " Christophe Fergeau
2011-06-16  9:35   ` [Qemu-devel] " Christophe Fergeau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DF88BD9.2050106@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=cfergeau@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.