All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugene Korenevsky <ekorenevsky@gmail.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH 2/5] KVM: nVMX: fix limit check for protected mode
Date: Thu, 20 Aug 2015 22:36:58 +0300	[thread overview]
Message-ID: <20150820193658.GA3539@unote> (raw)

Fix limit checking for all segment types except expand-down data segments.
The effective limit is the last address that is allowed to be accessed in the
segment. The condition for exceeding the limit should be

offset + operand_size - 1 > limit

For example, if offset == limit and operand size is one, there is no limit
exceeding (limit + 1 - 1 == limit), but if operand size is two, the limit
is exceeded (limit + 2 - 1 > limit).

Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com>
---
 arch/x86/kvm/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 32d2979..faa05a4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6377,7 +6377,7 @@ 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 > s->limit);
+	exn = exn || (off + mem_op_size - 1 > s->limit);
 	if (exn) {
 		kvm_queue_exception_e(vcpu,
 				      seg == VCPU_SREG_SS ?
-- 
2.1.4


                 reply	other threads:[~2015-08-20 19:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20150820193658.GA3539@unote \
    --to=ekorenevsky@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@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 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.