diff mbox

Check use I/O bitmap first before unconditional I/O exit

Message ID 1388436989-8597-1-git-send-email-zzhsuny@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhihui Zhang Dec. 30, 2013, 8:56 p.m. UTC
According to Table C-1 of Intel SDM 3C, a VM exit happens on an I/O instruction when
"use I/O bitmaps" VM-execution control was 0 _and_ the "unconditional I/O exiting"
VM-execution control was 1. So we can't just check "unconditional I/O exiting" alone.
This patch was improved by suggestion from Jan Kiszka.

Signed-off-by: Zhihui Zhang <zzhsuny@gmail.com>
---
 arch/x86/kvm/vmx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Jan Kiszka Dec. 31, 2013, 8:55 a.m. UTC | #1
On 2013-12-30 21:56, Zhihui Zhang wrote:
> According to Table C-1 of Intel SDM 3C, a VM exit happens on an I/O instruction when
> "use I/O bitmaps" VM-execution control was 0 _and_ the "unconditional I/O exiting"
> VM-execution control was 1. So we can't just check "unconditional I/O exiting" alone.
> This patch was improved by suggestion from Jan Kiszka.
> 
> Signed-off-by: Zhihui Zhang <zzhsuny@gmail.com>
> ---
>  arch/x86/kvm/vmx.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index b2fe1c2..45617db 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -6460,11 +6460,8 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu,
>  	int size;
>  	u8 b;
>  
> -	if (nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING))
> -		return 1;
> -
>  	if (!nested_cpu_has(vmcs12, CPU_BASED_USE_IO_BITMAPS))
> -		return 0;
> +		return nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING);
>  
>  	exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
>  
> 

Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Marcelo Tosatti Jan. 8, 2014, 9:01 p.m. UTC | #2
On Mon, Dec 30, 2013 at 03:56:29PM -0500, Zhihui Zhang wrote:
> According to Table C-1 of Intel SDM 3C, a VM exit happens on an I/O instruction when
> "use I/O bitmaps" VM-execution control was 0 _and_ the "unconditional I/O exiting"
> VM-execution control was 1. So we can't just check "unconditional I/O exiting" alone.
> This patch was improved by suggestion from Jan Kiszka.
> 
> Signed-off-by: Zhihui Zhang <zzhsuny@gmail.com>

Applied, thanks.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index b2fe1c2..45617db 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6460,11 +6460,8 @@  static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu,
 	int size;
 	u8 b;
 
-	if (nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING))
-		return 1;
-
 	if (!nested_cpu_has(vmcs12, CPU_BASED_USE_IO_BITMAPS))
-		return 0;
+		return nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING);
 
 	exit_qualification = vmcs_readl(EXIT_QUALIFICATION);