All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Steve Rutherford <srutherford@google.com>
Cc: kvm@vger.kernel.org, dvyukov@google.com, rkrcmar@redhat.com,
	ppandit@redhat.com, kernellwp@gmail.com
Subject: Re: [PATCH] KVM: x86: Introduce segmented_write_std
Date: Thu, 12 Jan 2017 08:40:30 -0500 (EST)	[thread overview]
Message-ID: <1890312293.7237408.1484228430752.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170112022829.15140-1-srutherford@google.com>



----- Original Message -----
> From: "Steve Rutherford" <srutherford@google.com>
> To: kvm@vger.kernel.org
> Cc: pbonzini@redhat.com, dvyukov@google.com, rkrcmar@redhat.com, ppandit@redhat.com, kernellwp@gmail.com
> Sent: Thursday, January 12, 2017 3:28:29 AM
> Subject: [PATCH] KVM: x86: Introduce segmented_write_std
> 
> Introduces segemented_write_std.
> 
> Switches from emulated reads/writes to standard read/writes in fxsave,
> fxrstor, sgdt, and sidt.
> 
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Steve Rutherford <srutherford@google.com>
> ---
>  arch/x86/kvm/emulate.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 2b8349a2b14b..ad258aa0b302 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -819,6 +819,20 @@ static int segmented_read_std(struct x86_emulate_ctxt
> *ctxt,
>  	return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception);
>  }
>  
> +static int segmented_write_std(struct x86_emulate_ctxt *ctxt,
> +			       struct segmented_address addr,
> +			       void *data,
> +			       unsigned int size)
> +{
> +	int rc;
> +	ulong linear;
> +
> +	rc = linearize(ctxt, addr, size, true, &linear);
> +	if (rc != X86EMUL_CONTINUE)
> +		return rc;
> +	return ctxt->ops->write_std(ctxt, linear, data, size, &ctxt->exception);
> +}
> +
>  /*
>   * Prefetch the remaining bytes of the instruction without crossing page
>   * boundary if they are not in fetch_cache yet.
> @@ -3686,8 +3700,8 @@ static int emulate_store_desc_ptr(struct
> x86_emulate_ctxt *ctxt,
>  	}
>  	/* Disable writeback. */
>  	ctxt->dst.type = OP_NONE;
> -	return segmented_write(ctxt, ctxt->dst.addr.mem,
> -			       &desc_ptr, 2 + ctxt->op_bytes);
> +	return segmented_write_std(ctxt, ctxt->dst.addr.mem,
> +				   &desc_ptr, 2 + ctxt->op_bytes);
>  }
>  
>  static int em_sgdt(struct x86_emulate_ctxt *ctxt)
> @@ -3933,7 +3947,7 @@ static int em_fxsave(struct x86_emulate_ctxt *ctxt)
>  	else
>  		size = offsetof(struct fxregs_state, xmm_space[0]);
>  
> -	return segmented_write(ctxt, ctxt->memop.addr.mem, &fx_state, size);
> +	return segmented_write_std(ctxt, ctxt->memop.addr.mem, &fx_state, size);
>  }
>  
>  static int fxrstor_fixup(struct x86_emulate_ctxt *ctxt,
> @@ -3975,7 +3989,7 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt)
>  	if (rc != X86EMUL_CONTINUE)
>  		return rc;
>  
> -	rc = segmented_read(ctxt, ctxt->memop.addr.mem, &fx_state, 512);
> +	rc = segmented_read_std(ctxt, ctxt->memop.addr.mem, &fx_state, 512);
>  	if (rc != X86EMUL_CONTINUE)
>  		return rc;
>  
> --
> 2.11.0.390.gc69c2f50cf-goog
> 
> 

Queued for 4.10, thanks.  At least fxsave/fxrstor is not in any
released version, but that was close.  I owe Dmitry some (more) beer.

Paolo

  reply	other threads:[~2017-01-12 14:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12  2:28 [PATCH] KVM: x86: Introduce segmented_write_std Steve Rutherford
2017-01-12 13:40 ` Paolo Bonzini [this message]
2017-01-20 16:55   ` Jim Mattson
2017-01-20 17:09     ` Paolo Bonzini
2017-01-20 17:57       ` Radim Krčmář

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=1890312293.7237408.1484228430752.JavaMail.zimbra@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dvyukov@google.com \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=ppandit@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=srutherford@google.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.