* [PATCH] Print a user-friendly message on failed vmentry
@ 2010-05-19 21:16 Mohammed Gamal
2010-05-19 21:52 ` Anthony Liguori
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Mohammed Gamal @ 2010-05-19 21:16 UTC (permalink / raw)
To: avi; +Cc: mtosatti, anthony, kvm, Mohammed Gamal
This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
Failed vmentries were handled with handle_unhandled() which prints a rather
unfriendly message to the user. This patch separates handling vmentry failures
from unknown exit reasons and prints a friendly message to the user.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
qemu-kvm.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 35a4c8a..deb4df8 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
return -EINVAL;
}
+static int handle_failed_vmentry(uint64_t reason)
+{
+ fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
+ fprintf(stderr, "If you're runnning a guest on an Intel machine, it can be\n");
+ fprintf(stderr, "most-likely due to the guest going into an invalid state\n");
+ fprintf(stderr, "for Intel VT. For example, the guest maybe running in big\n");
+ fprintf(stderr, "real mode which is not supported by Intel VT.\n\n");
+ fprintf(stderr, "You may want to try enabling real mode emulation in KVM.\n");
+ fprintf(stderr, "To Enable it, you may run the following commands as root:\n");
+ fprintf(stderr, "# rmmod kvm_intel\n");
+ fprintf(stderr, "# rmmod kvm\n");
+ fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n");
+ return -EINVAL;
+}
static inline void set_gsi(kvm_context_t kvm, unsigned int gsi)
{
@@ -586,7 +600,7 @@ int kvm_run(CPUState *env)
r = handle_unhandled(run->hw.hardware_exit_reason);
break;
case KVM_EXIT_FAIL_ENTRY:
- r = handle_unhandled(run->fail_entry.hardware_entry_failure_reason);
+ r = handle_failed_vmentry(run->fail_entry.hardware_entry_failure_reason);
break;
case KVM_EXIT_EXCEPTION:
fprintf(stderr, "exception %d (%x)\n", run->ex.exception,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH] Print a user-friendly message on failed vmentry
2010-05-19 21:16 [PATCH] Print a user-friendly message on failed vmentry Mohammed Gamal
@ 2010-05-19 21:52 ` Anthony Liguori
2010-05-20 1:28 ` Ryan Harper
2010-05-20 14:37 ` Chris Lalancette
2 siblings, 0 replies; 13+ messages in thread
From: Anthony Liguori @ 2010-05-19 21:52 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: avi, mtosatti, kvm
On 05/19/2010 04:16 PM, Mohammed Gamal wrote:
> This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
>
> Failed vmentries were handled with handle_unhandled() which prints a rather
> unfriendly message to the user. This patch separates handling vmentry failures
> from unknown exit reasons and prints a friendly message to the user.
>
> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
> ---
> qemu-kvm.c | 16 +++++++++++++++-
> 1 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-kvm.c b/qemu-kvm.c
> index 35a4c8a..deb4df8 100644
> --- a/qemu-kvm.c
> +++ b/qemu-kvm.c
> @@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
> return -EINVAL;
> }
>
> +static int handle_failed_vmentry(uint64_t reason)
> +{
> + fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
> + fprintf(stderr, "If you're runnning a guest on an Intel machine, it can be\n");
> + fprintf(stderr, "most-likely due to the guest going into an invalid state\n");
> + fprintf(stderr, "for Intel VT. For example, the guest maybe running in big\n");
> + fprintf(stderr, "real mode which is not supported by Intel VT.\n\n");
> + fprintf(stderr, "You may want to try enabling real mode emulation in KVM.\n");
> + fprintf(stderr, "To Enable it, you may run the following commands as root:\n");
> + fprintf(stderr, "# rmmod kvm_intel\n");
> + fprintf(stderr, "# rmmod kvm\n");
> + fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n");
> + return -EINVAL;
> +}
>
>
Very nice.
Regards,
Anthony Liguori
> static inline void set_gsi(kvm_context_t kvm, unsigned int gsi)
> {
> @@ -586,7 +600,7 @@ int kvm_run(CPUState *env)
> r = handle_unhandled(run->hw.hardware_exit_reason);
> break;
> case KVM_EXIT_FAIL_ENTRY:
> - r = handle_unhandled(run->fail_entry.hardware_entry_failure_reason);
> + r = handle_failed_vmentry(run->fail_entry.hardware_entry_failure_reason);
> break;
> case KVM_EXIT_EXCEPTION:
> fprintf(stderr, "exception %d (%x)\n", run->ex.exception,
>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Print a user-friendly message on failed vmentry
2010-05-19 21:16 [PATCH] Print a user-friendly message on failed vmentry Mohammed Gamal
2010-05-19 21:52 ` Anthony Liguori
@ 2010-05-20 1:28 ` Ryan Harper
2010-05-20 2:06 ` Mohammed Gamal
2010-05-20 14:37 ` Chris Lalancette
2 siblings, 1 reply; 13+ messages in thread
From: Ryan Harper @ 2010-05-20 1:28 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: avi, mtosatti, anthony, kvm
* Mohammed Gamal <m.gamal005@gmail.com> [2010-05-19 16:17]:
> This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
>
> Failed vmentries were handled with handle_unhandled() which prints a rather
> unfriendly message to the user. This patch separates handling vmentry failures
> from unknown exit reasons and prints a friendly message to the user.
>
> Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
> ---
> qemu-kvm.c | 16 +++++++++++++++-
> 1 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-kvm.c b/qemu-kvm.c
> index 35a4c8a..deb4df8 100644
> --- a/qemu-kvm.c
> +++ b/qemu-kvm.c
> @@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
> return -EINVAL;
> }
>
> +static int handle_failed_vmentry(uint64_t reason)
> +{
> + fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
> + fprintf(stderr, "If you're runnning a guest on an Intel machine, it can be\n");
> + fprintf(stderr, "most-likely due to the guest going into an invalid state\n");
> + fprintf(stderr, "for Intel VT. For example, the guest maybe running in big\n");
> + fprintf(stderr, "real mode which is not supported by Intel VT.\n\n");
We might want to qualify this with certain cpu versions. IIRC, the VMX
unrestricted mode should handle big real mode correctly, no? Maybe,
+ fprintf(stderr, "on some Intel processors. For example, the guest maybe running in big\n");
+ fprintf(stderr, "real mode which is not supported on most Intel processors.\n\n");
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh@us.ibm.com
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Print a user-friendly message on failed vmentry
2010-05-20 1:28 ` Ryan Harper
@ 2010-05-20 2:06 ` Mohammed Gamal
0 siblings, 0 replies; 13+ messages in thread
From: Mohammed Gamal @ 2010-05-20 2:06 UTC (permalink / raw)
To: Ryan Harper; +Cc: avi, mtosatti, anthony, kvm
On Thu, May 20, 2010 at 4:28 AM, Ryan Harper <ryanh@us.ibm.com> wrote:
>
> * Mohammed Gamal <m.gamal005@gmail.com> [2010-05-19 16:17]:
> > This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
> >
> > Failed vmentries were handled with handle_unhandled() which prints a rather
> > unfriendly message to the user. This patch separates handling vmentry failures
> > from unknown exit reasons and prints a friendly message to the user.
> >
> > Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
> > ---
> > qemu-kvm.c | 16 +++++++++++++++-
> > 1 files changed, 15 insertions(+), 1 deletions(-)
> >
> > diff --git a/qemu-kvm.c b/qemu-kvm.c
> > index 35a4c8a..deb4df8 100644
> > --- a/qemu-kvm.c
> > +++ b/qemu-kvm.c
> > @@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
> > return -EINVAL;
> > }
> >
> > +static int handle_failed_vmentry(uint64_t reason)
> > +{
> > + fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
> > + fprintf(stderr, "If you're runnning a guest on an Intel machine, it can be\n");
> > + fprintf(stderr, "most-likely due to the guest going into an invalid state\n");
> > + fprintf(stderr, "for Intel VT. For example, the guest maybe running in big\n");
> > + fprintf(stderr, "real mode which is not supported by Intel VT.\n\n");
>
> We might want to qualify this with certain cpu versions. IIRC, the VMX
> unrestricted mode should handle big real mode correctly, no? Maybe,
>
> + fprintf(stderr, "on some Intel processors. For example, the guest maybe running in big\n");
> + fprintf(stderr, "real mode which is not supported on most Intel processors.\n\n");
>
Good point. Will correct and resend.
> --
> Ryan Harper
> Software Engineer; Linux Technology Center
> IBM Corp., Austin, Tx
> ryanh@us.ibm.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Print a user-friendly message on failed vmentry
2010-05-19 21:16 [PATCH] Print a user-friendly message on failed vmentry Mohammed Gamal
2010-05-19 21:52 ` Anthony Liguori
2010-05-20 1:28 ` Ryan Harper
@ 2010-05-20 14:37 ` Chris Lalancette
2010-05-20 14:46 ` Anthony Liguori
2010-05-20 14:46 ` Mohammed Gamal
2 siblings, 2 replies; 13+ messages in thread
From: Chris Lalancette @ 2010-05-20 14:37 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: avi, mtosatti, anthony, kvm
On 05/19/2010 05:16 PM, Mohammed Gamal wrote:
> This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
>
> Failed vmentries were handled with handle_unhandled() which prints a rather
> unfriendly message to the user. This patch separates handling vmentry failures
> from unknown exit reasons and prints a friendly message to the user.
>
> Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
> ---
> qemu-kvm.c | 16 +++++++++++++++-
> 1 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-kvm.c b/qemu-kvm.c
> index 35a4c8a..deb4df8 100644
> --- a/qemu-kvm.c
> +++ b/qemu-kvm.c
> @@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
> return -EINVAL;
> }
>
> +static int handle_failed_vmentry(uint64_t reason)
> +{
> + fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
> + fprintf(stderr, "If you're runnning a guest on an Intel machine, it can be\n");
> + fprintf(stderr, "most-likely due to the guest going into an invalid state\n");
> + fprintf(stderr, "for Intel VT. For example, the guest maybe running in big\n");
> + fprintf(stderr, "real mode which is not supported by Intel VT.\n\n");
> + fprintf(stderr, "You may want to try enabling real mode emulation in KVM.\n");
> + fprintf(stderr, "To Enable it, you may run the following commands as root:\n");
> + fprintf(stderr, "# rmmod kvm_intel\n");
> + fprintf(stderr, "# rmmod kvm\n");
> + fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n");
> + return -EINVAL;
> +}
The thing is, there are other valid reasons for vmentry failure. A while ago I tracked
down a bug in the Linux kernel that was causing us to vmenter with invalid segments;
this message would have been very misleading in that case. I think you'd have to do
more complete analysis of the vmentry failure code to be more certain about the reason
for failure.
--
Chris Lalancette
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Print a user-friendly message on failed vmentry
2010-05-20 14:37 ` Chris Lalancette
@ 2010-05-20 14:46 ` Anthony Liguori
2010-05-20 14:46 ` Mohammed Gamal
1 sibling, 0 replies; 13+ messages in thread
From: Anthony Liguori @ 2010-05-20 14:46 UTC (permalink / raw)
To: Chris Lalancette; +Cc: Mohammed Gamal, avi, mtosatti, kvm
On 05/20/2010 09:37 AM, Chris Lalancette wrote:
> On 05/19/2010 05:16 PM, Mohammed Gamal wrote:
>
>> This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
>>
>> Failed vmentries were handled with handle_unhandled() which prints a rather
>> unfriendly message to the user. This patch separates handling vmentry failures
>> from unknown exit reasons and prints a friendly message to the user.
>>
>> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
>> ---
>> qemu-kvm.c | 16 +++++++++++++++-
>> 1 files changed, 15 insertions(+), 1 deletions(-)
>>
>> diff --git a/qemu-kvm.c b/qemu-kvm.c
>> index 35a4c8a..deb4df8 100644
>> --- a/qemu-kvm.c
>> +++ b/qemu-kvm.c
>> @@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
>> return -EINVAL;
>> }
>>
>> +static int handle_failed_vmentry(uint64_t reason)
>> +{
>> + fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
>> + fprintf(stderr, "If you're runnning a guest on an Intel machine, it can be\n");
>> + fprintf(stderr, "most-likely due to the guest going into an invalid state\n");
>> + fprintf(stderr, "for Intel VT. For example, the guest maybe running in big\n");
>> + fprintf(stderr, "real mode which is not supported by Intel VT.\n\n");
>> + fprintf(stderr, "You may want to try enabling real mode emulation in KVM.\n");
>> + fprintf(stderr, "To Enable it, you may run the following commands as root:\n");
>> + fprintf(stderr, "# rmmod kvm_intel\n");
>> + fprintf(stderr, "# rmmod kvm\n");
>> + fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n");
>> + return -EINVAL;
>> +}
>>
> The thing is, there are other valid reasons for vmentry failure. A while ago I tracked
> down a bug in the Linux kernel that was causing us to vmenter with invalid segments;
> this message would have been very misleading in that case. I think you'd have to do
> more complete analysis of the vmentry failure code to be more certain about the reason
> for failure.
>
We should probably only display this message if reason == 0x80000021.
It may be worth looking at the cpu_state to verify that we're trying to
enter 16-bit mode too.
Then the message can be much more definitive too.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Print a user-friendly message on failed vmentry
2010-05-20 14:37 ` Chris Lalancette
2010-05-20 14:46 ` Anthony Liguori
@ 2010-05-20 14:46 ` Mohammed Gamal
2010-05-20 15:53 ` Avi Kivity
1 sibling, 1 reply; 13+ messages in thread
From: Mohammed Gamal @ 2010-05-20 14:46 UTC (permalink / raw)
To: Chris Lalancette; +Cc: avi, mtosatti, anthony, kvm
On Thu, May 20, 2010 at 5:37 PM, Chris Lalancette <clalance@redhat.com> wrote:
> On 05/19/2010 05:16 PM, Mohammed Gamal wrote:
>> This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
>>
>> Failed vmentries were handled with handle_unhandled() which prints a rather
>> unfriendly message to the user. This patch separates handling vmentry failures
>> from unknown exit reasons and prints a friendly message to the user.
>>
>> Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
>> ---
>> qemu-kvm.c | 16 +++++++++++++++-
>> 1 files changed, 15 insertions(+), 1 deletions(-)
>>
>> diff --git a/qemu-kvm.c b/qemu-kvm.c
>> index 35a4c8a..deb4df8 100644
>> --- a/qemu-kvm.c
>> +++ b/qemu-kvm.c
>> @@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
>> return -EINVAL;
>> }
>>
>> +static int handle_failed_vmentry(uint64_t reason)
>> +{
>> + fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
>> + fprintf(stderr, "If you're runnning a guest on an Intel machine, it can be\n");
>> + fprintf(stderr, "most-likely due to the guest going into an invalid state\n");
>> + fprintf(stderr, "for Intel VT. For example, the guest maybe running in big\n");
>> + fprintf(stderr, "real mode which is not supported by Intel VT.\n\n");
>> + fprintf(stderr, "You may want to try enabling real mode emulation in KVM.\n");
>> + fprintf(stderr, "To Enable it, you may run the following commands as root:\n");
>> + fprintf(stderr, "# rmmod kvm_intel\n");
>> + fprintf(stderr, "# rmmod kvm\n");
>> + fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n");
>> + return -EINVAL;
>> +}
>
> The thing is, there are other valid reasons for vmentry failure. A while ago I tracked
> down a bug in the Linux kernel that was causing us to vmenter with invalid segments;
> this message would have been very misleading in that case. I think you'd have to do
> more complete analysis of the vmentry failure code to be more certain about the reason
> for failure.
>
Your point is definitely valid, yet big real mode is usually the most
likely case, and that's why this message is shown. Note also that it
says it's _most likely_ a failure caused by an invalid guest state,
but it doesn't rule out all other reasons. And in any case, it'd be
better than just printing something along the lines of:
" kvm: unhandled exit 80000021
kvm_run returned -22"
> --
> Chris Lalancette
>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Print a user-friendly message on failed vmentry
2010-05-20 14:46 ` Mohammed Gamal
@ 2010-05-20 15:53 ` Avi Kivity
2010-05-20 15:55 ` Mohammed Gamal
0 siblings, 1 reply; 13+ messages in thread
From: Avi Kivity @ 2010-05-20 15:53 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: Chris Lalancette, mtosatti, anthony, kvm
On 05/20/2010 05:46 PM, Mohammed Gamal wrote:
> On Thu, May 20, 2010 at 5:37 PM, Chris Lalancette<clalance@redhat.com> wrote:
>
>> On 05/19/2010 05:16 PM, Mohammed Gamal wrote:
>>
>>> This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
>>>
>>> Failed vmentries were handled with handle_unhandled() which prints a rather
>>> unfriendly message to the user. This patch separates handling vmentry failures
>>> from unknown exit reasons and prints a friendly message to the user.
>>>
>>> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
>>> ---
>>> qemu-kvm.c | 16 +++++++++++++++-
>>> 1 files changed, 15 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/qemu-kvm.c b/qemu-kvm.c
>>> index 35a4c8a..deb4df8 100644
>>> --- a/qemu-kvm.c
>>> +++ b/qemu-kvm.c
>>> @@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
>>> return -EINVAL;
>>> }
>>>
>>> +static int handle_failed_vmentry(uint64_t reason)
>>> +{
>>> + fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
>>> + fprintf(stderr, "If you're runnning a guest on an Intel machine, it can be\n");
>>> + fprintf(stderr, "most-likely due to the guest going into an invalid state\n");
>>> + fprintf(stderr, "for Intel VT. For example, the guest maybe running in big\n");
>>> + fprintf(stderr, "real mode which is not supported by Intel VT.\n\n");
>>> + fprintf(stderr, "You may want to try enabling real mode emulation in KVM.\n");
>>> + fprintf(stderr, "To Enable it, you may run the following commands as root:\n");
>>> + fprintf(stderr, "# rmmod kvm_intel\n");
>>> + fprintf(stderr, "# rmmod kvm\n");
>>> + fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n");
>>> + return -EINVAL;
>>> +}
>>>
>> The thing is, there are other valid reasons for vmentry failure. A while ago I tracked
>> down a bug in the Linux kernel that was causing us to vmenter with invalid segments;
>> this message would have been very misleading in that case. I think you'd have to do
>> more complete analysis of the vmentry failure code to be more certain about the reason
>> for failure.
>>
>>
> Your point is definitely valid, yet big real mode is usually the most
> likely case, and that's why this message is shown. Note also that it
> says it's _most likely_ a failure caused by an invalid guest state,
> but it doesn't rule out all other reasons. And in any case, it'd be
> better than just printing something along the lines of:
> " kvm: unhandled exit 80000021
> kvm_run returned -22"
>
However, we're still giving bad advice. Currently
emulate_invalid_guest_state=1 is not going to work well (right?). Once
it does, we'll simply make it the default and the message will never appear.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] Print a user-friendly message on failed vmentry
2010-05-20 15:53 ` Avi Kivity
@ 2010-05-20 15:55 ` Mohammed Gamal
0 siblings, 0 replies; 13+ messages in thread
From: Mohammed Gamal @ 2010-05-20 15:55 UTC (permalink / raw)
To: Avi Kivity; +Cc: Chris Lalancette, mtosatti, anthony, kvm
On Thu, May 20, 2010 at 6:53 PM, Avi Kivity <avi@redhat.com> wrote:
> On 05/20/2010 05:46 PM, Mohammed Gamal wrote:
>>
>> On Thu, May 20, 2010 at 5:37 PM, Chris Lalancette<clalance@redhat.com>
>> wrote:
>>
>>>
>>> On 05/19/2010 05:16 PM, Mohammed Gamal wrote:
>>>
>>>>
>>>> This patch address bug report in
>>>> https://bugs.launchpad.net/qemu/+bug/530077.
>>>>
>>>> Failed vmentries were handled with handle_unhandled() which prints a
>>>> rather
>>>> unfriendly message to the user. This patch separates handling vmentry
>>>> failures
>>>> from unknown exit reasons and prints a friendly message to the user.
>>>>
>>>> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
>>>> ---
>>>> qemu-kvm.c | 16 +++++++++++++++-
>>>> 1 files changed, 15 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/qemu-kvm.c b/qemu-kvm.c
>>>> index 35a4c8a..deb4df8 100644
>>>> --- a/qemu-kvm.c
>>>> +++ b/qemu-kvm.c
>>>> @@ -106,6 +106,20 @@ static int handle_unhandled(uint64_t reason)
>>>> return -EINVAL;
>>>> }
>>>>
>>>> +static int handle_failed_vmentry(uint64_t reason)
>>>> +{
>>>> + fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64
>>>> "\n\n", reason);
>>>> + fprintf(stderr, "If you're runnning a guest on an Intel machine, it
>>>> can be\n");
>>>> + fprintf(stderr, "most-likely due to the guest going into an invalid
>>>> state\n");
>>>> + fprintf(stderr, "for Intel VT. For example, the guest maybe running
>>>> in big\n");
>>>> + fprintf(stderr, "real mode which is not supported by Intel
>>>> VT.\n\n");
>>>> + fprintf(stderr, "You may want to try enabling real mode emulation
>>>> in KVM.\n");
>>>> + fprintf(stderr, "To Enable it, you may run the following commands
>>>> as root:\n");
>>>> + fprintf(stderr, "# rmmod kvm_intel\n");
>>>> + fprintf(stderr, "# rmmod kvm\n");
>>>> + fprintf(stderr, "# modprobe kvm_intel
>>>> emulate_invalid_guest_state=1\n");
>>>> + return -EINVAL;
>>>> +}
>>>>
>>>
>>> The thing is, there are other valid reasons for vmentry failure. A while
>>> ago I tracked
>>> down a bug in the Linux kernel that was causing us to vmenter with
>>> invalid segments;
>>> this message would have been very misleading in that case. I think you'd
>>> have to do
>>> more complete analysis of the vmentry failure code to be more certain
>>> about the reason
>>> for failure.
>>>
>>>
>>
>> Your point is definitely valid, yet big real mode is usually the most
>> likely case, and that's why this message is shown. Note also that it
>> says it's _most likely_ a failure caused by an invalid guest state,
>> but it doesn't rule out all other reasons. And in any case, it'd be
>> better than just printing something along the lines of:
>> " kvm: unhandled exit 80000021
>> kvm_run returned -22"
>>
>
> However, we're still giving bad advice. Currently
> emulate_invalid_guest_state=1 is not going to work well (right?). Once it
> does, we'll simply make it the default and the message will never appear.
>
I already added a warning in the second patch I sent.
> --
> Do not meddle in the internals of kernels, for they are subtle and quick to
> panic.
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] Print a user-friendly message on failed vmentry
@ 2010-05-20 2:27 Mohammed Gamal
0 siblings, 0 replies; 13+ messages in thread
From: Mohammed Gamal @ 2010-05-20 2:27 UTC (permalink / raw)
To: avi; +Cc: mtosatti, anthony, ryanh, kvm, Mohammed Gamal
This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
Failed vmentries were handled with handle_unhandled() which prints a rather
unfriendly message to the user. This patch separates handling vmentry failures
from unknown exit reasons and prints a friendly message to the user.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
qemu-kvm.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 35a4c8a..1fdb6fe 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -106,6 +106,23 @@ static int handle_unhandled(uint64_t reason)
return -EINVAL;
}
+static int handle_failed_vmentry(uint64_t reason)
+{
+ fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
+ fprintf(stderr, "If you're runnning a guest on an Intel machine without\n");
+ fprintf(stderr, "unrestricted mode support, the failure can be most likely\n");
+ fprintf(stderr, "due to the guest entering an invalid state for Intel VT.\n");
+ fprintf(stderr, "For example, the guest maybe running in big real mode\n");
+ fprintf(stderr, "which is not supported on less recent Intel processors.\n\n");
+ fprintf(stderr, "You may want to try enabling KVM real mode emulation. To\n");
+ fprintf(stderr, "enable it, you can run the following commands as root:\n");
+ fprintf(stderr, "# rmmod kvm_intel\n");
+ fprintf(stderr, "# rmmod kvm\n");
+ fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n\n");
+ fprintf(stderr, "WARNING: Real mode emulation is still work-in-progress\n");
+ fprintf(stderr, "and thus it is not always guaranteed to work.\n\n");
+ return -EINVAL;
+}
static inline void set_gsi(kvm_context_t kvm, unsigned int gsi)
{
@@ -586,7 +603,7 @@ int kvm_run(CPUState *env)
r = handle_unhandled(run->hw.hardware_exit_reason);
break;
case KVM_EXIT_FAIL_ENTRY:
- r = handle_unhandled(run->fail_entry.hardware_entry_failure_reason);
+ r = handle_failed_vmentry(run->fail_entry.hardware_entry_failure_reason);
break;
case KVM_EXIT_EXCEPTION:
fprintf(stderr, "exception %d (%x)\n", run->ex.exception,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH] Print a user-friendly message on failed vmentry
@ 2010-05-23 22:02 Mohammed Gamal
0 siblings, 0 replies; 13+ messages in thread
From: Mohammed Gamal @ 2010-05-23 22:02 UTC (permalink / raw)
To: avi; +Cc: kvm, mtosatti, anthony, ryanh, Mohammed Gamal
This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
Failed vmentries were handled with handle_unhandled() which prints a rather
unfriendly message to the user. This patch separates handling vmentry failures
from unknown exit reasons and prints a friendly message to the user.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
qemu-kvm.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 35a4c8a..3ef0565 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -106,6 +106,31 @@ static int handle_unhandled(uint64_t reason)
return -EINVAL;
}
+#define VMX_INVALID_GUEST_STATE 0x21
+
+static int handle_failed_vmentry(uint64_t reason)
+{
+ fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
+
+ /* Perhaps we will need to check if this machine is intel since exit reason 0x21
+ has a different interpretation on SVM */
+ if (reason == VMX_INVALID_GUEST_STATE) {
+ fprintf(stderr, "If you're runnning a guest on an Intel machine without\n");
+ fprintf(stderr, "unrestricted mode support, the failure can be most likely\n");
+ fprintf(stderr, "due to the guest entering an invalid state for Intel VT.\n");
+ fprintf(stderr, "For example, the guest maybe running in big real mode\n");
+ fprintf(stderr, "which is not supported on less recent Intel processors.\n\n");
+ fprintf(stderr, "You may want to try enabling KVM real mode emulation. To\n");
+ fprintf(stderr, "enable it, you can run the following commands as root:\n");
+ fprintf(stderr, "# rmmod kvm_intel\n");
+ fprintf(stderr, "# rmmod kvm\n");
+ fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n\n");
+ fprintf(stderr, "WARNING: Real mode emulation is still work-in-progress\n");
+ fprintf(stderr, "and thus it is not always guaranteed to work.\n\n");
+ }
+
+ return -EINVAL;
+}
static inline void set_gsi(kvm_context_t kvm, unsigned int gsi)
{
@@ -586,7 +611,7 @@ int kvm_run(CPUState *env)
r = handle_unhandled(run->hw.hardware_exit_reason);
break;
case KVM_EXIT_FAIL_ENTRY:
- r = handle_unhandled(run->fail_entry.hardware_entry_failure_reason);
+ r = handle_failed_vmentry(run->fail_entry.hardware_entry_failure_reason);
break;
case KVM_EXIT_EXCEPTION:
fprintf(stderr, "exception %d (%x)\n", run->ex.exception,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH] Print a user-friendly message on failed vmentry
@ 2010-06-06 11:10 Mohammed Gamal
2010-06-07 7:31 ` Avi Kivity
0 siblings, 1 reply; 13+ messages in thread
From: Mohammed Gamal @ 2010-06-06 11:10 UTC (permalink / raw)
To: avi; +Cc: mtosatti, anthony, ryanh, kvm, Mohammed Gamal
This patch address bug report in https://bugs.launchpad.net/qemu/+bug/530077.
Failed vmentries were handled with handle_unhandled() which prints a rather
unfriendly message to the user. This patch separates handling vmentry failures
from unknown exit reasons and prints a friendly message to the user.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
qemu-kvm.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 9534b31..1a66f55 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -106,6 +106,24 @@ static int handle_unhandled(uint64_t reason)
return -EINVAL;
}
+#define VMX_INVALID_GUEST_STATE 0x80000021
+
+static int handle_failed_vmentry(uint64_t reason)
+{
+ fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
+
+ /* Perhaps we will need to check if this machine is intel since exit reason 0x21
+ has a different interpretation on SVM */
+ if (reason == VMX_INVALID_GUEST_STATE) {
+ fprintf(stderr, "If you're runnning a guest on an Intel machine without\n");
+ fprintf(stderr, "unrestricted mode support, the failure can be most likely\n");
+ fprintf(stderr, "due to the guest entering an invalid state for Intel VT.\n");
+ fprintf(stderr, "For example, the guest maybe running in big real mode\n");
+ fprintf(stderr, "which is not supported on less recent Intel processors.\n\n");
+ }
+
+ return -EINVAL;
+}
static inline void set_gsi(kvm_context_t kvm, unsigned int gsi)
{
@@ -586,7 +604,7 @@ int kvm_run(CPUState *env)
r = handle_unhandled(run->hw.hardware_exit_reason);
break;
case KVM_EXIT_FAIL_ENTRY:
- r = handle_unhandled(run->fail_entry.hardware_entry_failure_reason);
+ r = handle_failed_vmentry(run->fail_entry.hardware_entry_failure_reason);
break;
case KVM_EXIT_EXCEPTION:
fprintf(stderr, "exception %d (%x)\n", run->ex.exception,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2010-06-07 7:31 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-19 21:16 [PATCH] Print a user-friendly message on failed vmentry Mohammed Gamal
2010-05-19 21:52 ` Anthony Liguori
2010-05-20 1:28 ` Ryan Harper
2010-05-20 2:06 ` Mohammed Gamal
2010-05-20 14:37 ` Chris Lalancette
2010-05-20 14:46 ` Anthony Liguori
2010-05-20 14:46 ` Mohammed Gamal
2010-05-20 15:53 ` Avi Kivity
2010-05-20 15:55 ` Mohammed Gamal
-- strict thread matches above, loose matches on Subject: below --
2010-05-20 2:27 Mohammed Gamal
2010-05-23 22:02 Mohammed Gamal
2010-06-06 11:10 Mohammed Gamal
2010-06-07 7:31 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox