* [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure
@ 2010-05-23 22:01 Mohammed Gamal
2010-05-23 22:01 ` [PATCH 2/2] VMX: Add constant for invalid guest state exit reason Mohammed Gamal
2010-05-25 11:45 ` [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure Avi Kivity
0 siblings, 2 replies; 7+ messages in thread
From: Mohammed Gamal @ 2010-05-23 22:01 UTC (permalink / raw)
To: avi; +Cc: mtosatti, kvm, Mohammed Gamal
The vmexit handler returns KVM_EXIT_UNKNOWN since there is no handler
for vmentry failures. This intercepts vmentry failures and returns
KVM_FAIL_ENTRY to userspace instead.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
arch/x86/kvm/vmx.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 99ae513..4edcffb 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3665,6 +3665,13 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu)
if (enable_ept && is_paging(vcpu))
vcpu->arch.cr3 = vmcs_readl(GUEST_CR3);
+ if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) {
+ vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
+ vcpu->run->fail_entry.hardware_entry_failure_reason
+ = exit_reason & ~VMX_EXIT_REASONS_FAILED_VMENTRY;
+ return 0;
+ }
+
if (unlikely(vmx->fail)) {
vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
vcpu->run->fail_entry.hardware_entry_failure_reason
--
1.7.0.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] VMX: Add constant for invalid guest state exit reason
2010-05-23 22:01 [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure Mohammed Gamal
@ 2010-05-23 22:01 ` Mohammed Gamal
2010-05-25 11:46 ` Avi Kivity
2010-05-25 11:45 ` [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure Avi Kivity
1 sibling, 1 reply; 7+ messages in thread
From: Mohammed Gamal @ 2010-05-23 22:01 UTC (permalink / raw)
To: avi; +Cc: mtosatti, kvm, Mohammed Gamal
For the sake of completeness, this patch adds a symbolic
constant for VMX exit reason 0x21 (invalid guest state).
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
arch/x86/include/asm/vmx.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 9e6779f..104cf86 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -257,6 +257,7 @@ enum vmcs_field {
#define EXIT_REASON_IO_INSTRUCTION 30
#define EXIT_REASON_MSR_READ 31
#define EXIT_REASON_MSR_WRITE 32
+#define EXIT_REASON_INVALID_STATE 33
#define EXIT_REASON_MWAIT_INSTRUCTION 36
#define EXIT_REASON_MONITOR_INSTRUCTION 39
#define EXIT_REASON_PAUSE_INSTRUCTION 40
--
1.7.0.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure
2010-05-23 22:01 [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure Mohammed Gamal
2010-05-23 22:01 ` [PATCH 2/2] VMX: Add constant for invalid guest state exit reason Mohammed Gamal
@ 2010-05-25 11:45 ` Avi Kivity
2010-05-25 12:01 ` Mohammed Gamal
1 sibling, 1 reply; 7+ messages in thread
From: Avi Kivity @ 2010-05-25 11:45 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: mtosatti, kvm
On 05/24/2010 01:01 AM, Mohammed Gamal wrote:
> The vmexit handler returns KVM_EXIT_UNKNOWN since there is no handler
> for vmentry failures. This intercepts vmentry failures and returns
> KVM_FAIL_ENTRY to userspace instead.
>
> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
> ---
> arch/x86/kvm/vmx.c | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 99ae513..4edcffb 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3665,6 +3665,13 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu)
> if (enable_ept&& is_paging(vcpu))
> vcpu->arch.cr3 = vmcs_readl(GUEST_CR3);
>
> + if (exit_reason& VMX_EXIT_REASONS_FAILED_VMENTRY) {
> + vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
> + vcpu->run->fail_entry.hardware_entry_failure_reason
> + = exit_reason& ~VMX_EXIT_REASONS_FAILED_VMENTRY;
> + return 0;
> + }
> +
> if (unlikely(vmx->fail)) {
> vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
> vcpu->run->fail_entry.hardware_entry_failure_reason
>
How does the user distinguish between KVM_EXIT_FAIL_ENTRY due to an exit
reason with bit 31 set and vmlauch/vmresume failure (vmx->fail set)? We
need separate exit codes (with documentation in api.txt).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] VMX: Add constant for invalid guest state exit reason
2010-05-23 22:01 ` [PATCH 2/2] VMX: Add constant for invalid guest state exit reason Mohammed Gamal
@ 2010-05-25 11:46 ` Avi Kivity
0 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2010-05-25 11:46 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: mtosatti, kvm
On 05/24/2010 01:01 AM, Mohammed Gamal wrote:
> For the sake of completeness, this patch adds a symbolic
> constant for VMX exit reason 0x21 (invalid guest state).
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure
2010-05-25 11:45 ` [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure Avi Kivity
@ 2010-05-25 12:01 ` Mohammed Gamal
2010-05-25 12:10 ` Avi Kivity
0 siblings, 1 reply; 7+ messages in thread
From: Mohammed Gamal @ 2010-05-25 12:01 UTC (permalink / raw)
To: Avi Kivity; +Cc: mtosatti, kvm
On Tue, May 25, 2010 at 2:45 PM, Avi Kivity <avi@redhat.com> wrote:
> On 05/24/2010 01:01 AM, Mohammed Gamal wrote:
>>
>> The vmexit handler returns KVM_EXIT_UNKNOWN since there is no handler
>> for vmentry failures. This intercepts vmentry failures and returns
>> KVM_FAIL_ENTRY to userspace instead.
>>
>> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
>> ---
>> arch/x86/kvm/vmx.c | 7 +++++++
>> 1 files changed, 7 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>> index 99ae513..4edcffb 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -3665,6 +3665,13 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu)
>> if (enable_ept&& is_paging(vcpu))
>> vcpu->arch.cr3 = vmcs_readl(GUEST_CR3);
>>
>> + if (exit_reason& VMX_EXIT_REASONS_FAILED_VMENTRY) {
>> + vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
>> + vcpu->run->fail_entry.hardware_entry_failure_reason
>> + = exit_reason& ~VMX_EXIT_REASONS_FAILED_VMENTRY;
>> + return 0;
>> + }
>> +
>> if (unlikely(vmx->fail)) {
>> vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
>> vcpu->run->fail_entry.hardware_entry_failure_reason
>>
>
> How does the user distinguish between KVM_EXIT_FAIL_ENTRY due to an exit
> reason with bit 31 set and vmlauch/vmresume failure (vmx->fail set)? We
> need separate exit codes (with documentation in api.txt).
In both cases the vm fails entry, and I don't think the hardware entry
failure reason codes would overlap between the vmx->fail case and exit
reasons with bit 31 set, so why should there be such distinction
between both cases?
>
> --
> error compiling committee.c: too many arguments to function
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure
2010-05-25 12:01 ` Mohammed Gamal
@ 2010-05-25 12:10 ` Avi Kivity
2010-05-25 12:15 ` Mohammed Gamal
0 siblings, 1 reply; 7+ messages in thread
From: Avi Kivity @ 2010-05-25 12:10 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: mtosatti, kvm
On 05/25/2010 03:01 PM, Mohammed Gamal wrote:
>>
>> How does the user distinguish between KVM_EXIT_FAIL_ENTRY due to an exit
>> reason with bit 31 set and vmlauch/vmresume failure (vmx->fail set)? We
>> need separate exit codes (with documentation in api.txt).
>>
> In both cases the vm fails entry, and I don't think the hardware entry
> failure reason codes would overlap between the vmx->fail case and exit
> reasons with bit 31 set, so why should there be such distinction
> between both cases?
>
Only 5 more error codes (28->33) and we have overlap.
If you return the new codes with bit 31 still set then we can use the
existing KVM_EXIT_FAIL_ENTRY.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure
2010-05-25 12:10 ` Avi Kivity
@ 2010-05-25 12:15 ` Mohammed Gamal
0 siblings, 0 replies; 7+ messages in thread
From: Mohammed Gamal @ 2010-05-25 12:15 UTC (permalink / raw)
To: Avi Kivity; +Cc: mtosatti, kvm
On Tue, May 25, 2010 at 3:10 PM, Avi Kivity <avi@redhat.com> wrote:
> On 05/25/2010 03:01 PM, Mohammed Gamal wrote:
>>>
>>> How does the user distinguish between KVM_EXIT_FAIL_ENTRY due to an exit
>>> reason with bit 31 set and vmlauch/vmresume failure (vmx->fail set)? We
>>> need separate exit codes (with documentation in api.txt).
>>>
>>
>> In both cases the vm fails entry, and I don't think the hardware entry
>> failure reason codes would overlap between the vmx->fail case and exit
>> reasons with bit 31 set, so why should there be such distinction
>> between both cases?
>>
>
> Only 5 more error codes (28->33) and we have overlap.
>
> If you return the new codes with bit 31 still set then we can use the
> existing KVM_EXIT_FAIL_ENTRY.
That'd be a better idea.
>
>
> --
> error compiling committee.c: too many arguments to function
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-05-25 12:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-23 22:01 [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure Mohammed Gamal
2010-05-23 22:01 ` [PATCH 2/2] VMX: Add constant for invalid guest state exit reason Mohammed Gamal
2010-05-25 11:46 ` Avi Kivity
2010-05-25 11:45 ` [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure Avi Kivity
2010-05-25 12:01 ` Mohammed Gamal
2010-05-25 12:10 ` Avi Kivity
2010-05-25 12:15 ` Mohammed Gamal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox