kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Eugene Korenevsky <ekorenevsky@gmail.com>, kvm@vger.kernel.org
Subject: Re: [PATCH 3/5] KVM: nVMX: add limit check for expand-down segments
Date: Mon, 7 Sep 2015 13:39:53 +0200	[thread overview]
Message-ID: <55ED7789.3010700@redhat.com> (raw)
In-Reply-To: <20150820193739.GA3555@unote>



On 20/08/2015 21:37, Eugene Korenevsky wrote:
> Add limit checking for expand-down data segments. For such segments, the
> effective limit specifies the last address that is not allowed to be accessed
> within the segment. I.e. offset <= limit means means limit exceeding.
> 
> Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com>
> ---
>  arch/x86/kvm/vmx.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index faa05a4..4a4d677 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -6377,7 +6377,10 @@ static int vmx_protmode_seg_check(struct kvm_vcpu *vcpu,
>  	/* #GP(0)/#SS(0) if the segment is unusable. */
>  	exn = (s->unusable != 0);
>  	/* #GP(0)/#SS(0) if the memory operand is outside the segment limit. */
> -	exn = exn || (off + mem_op_size - 1 > s->limit);
> +	if (!(s->type & 8) && (s->type & 4)) /* expand-down segment? */
> +		exn = exn || (off <= s->limit);
> +	else
> +		exn = exn || (off + mem_op_size - 1 > s->limit);

For expand-down segments you also have to check against the size of the
segment (48 bits for 64-bit segments and positive addresses, 32 bits for
32-bit segments, 16 bits for 16-bit segments; see __linearize in emulate.c).

Paolo

      reply	other threads:[~2015-09-07 11:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20 19:37 [PATCH 3/5] KVM: nVMX: add limit check for expand-down segments Eugene Korenevsky
2015-09-07 11:39 ` Paolo Bonzini [this message]

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=55ED7789.3010700@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ekorenevsky@gmail.com \
    --cc=kvm@vger.kernel.org \
    /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).