kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Abel Gordon <abelg@il.ibm.com>
Cc: kvm@vger.kernel.org, owasserm@redhat.com, nadav@harel.org.il,
	jun.nakajima@intel.com, dongxiao.xu@intel.com
Subject: Re: [PATCH 05/11] KVM: nVMX: Refactor handle_vmwrite
Date: Tue, 9 Apr 2013 14:05:07 +0300	[thread overview]
Message-ID: <20130409110507.GV17919@redhat.com> (raw)
In-Reply-To: <20130310160555.C2117380134@moren.haifa.ibm.com>

On Sun, Mar 10, 2013 at 06:05:55PM +0200, Abel Gordon wrote:
> Refactor existent code so we re-use vmcs12_write_any to copy fields from the
> shadow vmcs specified by the link pointer (used by the processor,
> implementation-specific) to the VMCS12 software format used by L0 to hold
> the fields in L1 memory address space.
> 
> Signed-off-by: Abel Gordon <abelg@il.ibm.com>
> ---
>  arch/x86/kvm/vmx.c |   52 +++++++++++++++++++++++--------------------
>  1 file changed, 28 insertions(+), 24 deletions(-)
> 
> --- .before/arch/x86/kvm/vmx.c	2013-03-10 18:00:54.000000000 +0200
> +++ .after/arch/x86/kvm/vmx.c	2013-03-10 18:00:54.000000000 +0200
> @@ -5741,6 +5741,33 @@ static inline bool vmcs12_read_any(struc
>  	}
>  }
>  
> +
> +static inline bool vmcs12_write_any(struct kvm_vcpu *vcpu,
> +				    unsigned long field, u64 field_value){
> +	short offset = vmcs_field_to_offset(field);
> +	char *p = ((char *) get_vmcs12(vcpu)) + offset;
> +	if (offset < 0)
> +		return 0;
The function returns bool, so use true/false please.

> +
> +	switch (vmcs_field_type(field)) {
> +	case VMCS_FIELD_TYPE_U16:
> +		*(u16 *)p = field_value;
> +		return 1;
> +	case VMCS_FIELD_TYPE_U32:
> +		*(u32 *)p = field_value;
> +		return 1;
> +	case VMCS_FIELD_TYPE_U64:
> +		*(u64 *)p = field_value;
> +		return 1;
> +	case VMCS_FIELD_TYPE_NATURAL_WIDTH:
> +		*(natural_width *)p = field_value;
> +		return 1;
> +	default:
> +		return 0; /* can never happen. */
> +	}
> +
> +}
> +
>  /*
>   * VMX instructions which assume a current vmcs12 (i.e., that VMPTRLD was
>   * used before) all generate the same failure when it is missing.
> @@ -5806,8 +5833,6 @@ static int handle_vmwrite(struct kvm_vcp
>  	gva_t gva;
>  	unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
>  	u32 vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);
> -	char *p;
> -	short offset;
>  	/* The value to write might be 32 or 64 bits, depending on L1's long
>  	 * mode, and eventually we need to write that into a field of several
>  	 * possible lengths. The code below first zero-extends the value to 64
> @@ -5846,28 +5871,7 @@ static int handle_vmwrite(struct kvm_vcp
>  		return 1;
>  	}
>  
> -	offset = vmcs_field_to_offset(field);
> -	if (offset < 0) {
> -		nested_vmx_failValid(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT);
> -		skip_emulated_instruction(vcpu);
> -		return 1;
> -	}
> -	p = ((char *) get_vmcs12(vcpu)) + offset;
> -
> -	switch (vmcs_field_type(field)) {
> -	case VMCS_FIELD_TYPE_U16:
> -		*(u16 *)p = field_value;
> -		break;
> -	case VMCS_FIELD_TYPE_U32:
> -		*(u32 *)p = field_value;
> -		break;
> -	case VMCS_FIELD_TYPE_U64:
> -		*(u64 *)p = field_value;
> -		break;
> -	case VMCS_FIELD_TYPE_NATURAL_WIDTH:
> -		*(natural_width *)p = field_value;
> -		break;
> -	default:
> +	if (!vmcs12_write_any(vcpu, field, field_value)) {
>  		nested_vmx_failValid(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT);
>  		skip_emulated_instruction(vcpu);
>  		return 1;
> 
> --
> 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

--
			Gleb.

  reply	other threads:[~2013-04-09 11:05 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-10 16:03 [PATCH 0/11] KVM: nVMX: shadow VMCS support, v1 Abel Gordon
2013-03-10 16:03 ` [PATCH 01/11] KVM: nVMX: Stats counters for nVMX Abel Gordon
2013-04-08 10:27   ` Gleb Natapov
2013-04-10 19:08     ` Abel Gordon
2013-04-11  6:10       ` Gleb Natapov
2013-03-10 16:04 ` [PATCH 02/11] KVM: nVMX: Shadow-vmcs control fields/bits Abel Gordon
2013-03-10 16:04 ` [PATCH 03/11] KVM: nVMX: Detect shadow-vmcs capability Abel Gordon
2013-04-08 11:12   ` Gleb Natapov
2013-04-10 19:14     ` Abel Gordon
2013-03-10 16:05 ` [PATCH 04/11] KVM: nVMX: Introduce vmread and vmwrite bitmaps Abel Gordon
2013-04-08 11:50   ` Gleb Natapov
2013-04-10 19:14     ` Abel Gordon
2013-03-10 16:05 ` [PATCH 05/11] KVM: nVMX: Refactor handle_vmwrite Abel Gordon
2013-04-09 11:05   ` Gleb Natapov [this message]
2013-04-10 20:35     ` Abel Gordon
2013-03-10 16:06 ` [PATCH 06/11] KVM: nVMX: Allocate shadow vmcs Abel Gordon
2013-03-10 16:06 ` [PATCH 07/11] KVM: nVMX: Release " Abel Gordon
2013-03-10 16:07 ` [PATCH 08/11] KVM: nVMX: Copy processor-specific shadow-vmcs to VMCS12 Abel Gordon
2013-03-10 16:07 ` [PATCH 09/11] KVM: nVMX: Copy VMCS12 to processor-specific shadow vmcs Abel Gordon
2013-04-09 12:47   ` Gleb Natapov
2013-04-10 19:15     ` Abel Gordon
2013-03-10 16:08 ` [PATCH 10/11] KVM: nVMX: Synchronize VMCS12 content with the " Abel Gordon
2013-03-10 22:43   ` Nadav Har'El
2013-03-11  7:54     ` Abel Gordon
2013-04-09 13:14       ` Gleb Natapov
2013-04-10 19:15         ` Abel Gordon
2013-04-11  6:54           ` Gleb Natapov
2013-04-12 10:26             ` Abel Gordon
2013-04-12 10:31               ` Gleb Natapov
2013-04-12 10:44                 ` Abel Gordon
2013-04-12 10:48                   ` Gleb Natapov
2013-04-14  9:51                     ` Abel Gordon
2013-04-14 10:00                       ` Gleb Natapov
2013-04-14 10:07                         ` Gleb Natapov
2013-04-14 10:27                           ` Jan Kiszka
2013-04-14 10:34                             ` Abel Gordon
2013-04-14 10:34                             ` Gleb Natapov
2013-04-14 10:49                               ` Abel Gordon
2013-04-14 11:16                                 ` Gleb Natapov
2013-04-14 13:47                                   ` Abel Gordon
2013-04-14 14:41                                     ` Gleb Natapov
2013-03-10 16:08 ` [PATCH 11/11] KVM: nVMX: Enable and disable shadow vmcs functionality Abel Gordon
2013-03-21 12:22 ` [PATCH 0/11] KVM: nVMX: shadow VMCS support, v1 Orit Wasserman
2013-03-21 13:56   ` Abel Gordon

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=20130409110507.GV17919@redhat.com \
    --to=gleb@redhat.com \
    --cc=abelg@il.ibm.com \
    --cc=dongxiao.xu@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=nadav@harel.org.il \
    --cc=owasserm@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).