From: Andre Przywara <andre.przywara@amd.com>
To: avi@redhat.com
Cc: amit.shah@redhat.com, kvm@vger.kernel.org,
Andre Przywara <andre.przywara@amd.com>
Subject: [PATCH] set accessed bit for VMCB segment selectors
Date: Fri, 9 Jan 2009 22:27:35 +0100 [thread overview]
Message-ID: <12315364554190-git-send-email-andre.przywara@amd.com> (raw)
In-Reply-To: <49678FF9.2040404@redhat.com>
In the segment descriptor _cache_ the accessed bit is always set
(although it can be cleared in the descriptor itself). Since Intel
checks for this condition on a VMENTRY, set this bit in the AMD path
to enable cross vendor migration.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
arch/x86/kvm/svm.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 32dafb7..ffaba66 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -793,20 +793,36 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
var->db = (s->attrib >> SVM_SELECTOR_DB_SHIFT) & 1;
var->g = (s->attrib >> SVM_SELECTOR_G_SHIFT) & 1;
+ switch (seg) {
+ case VCPU_SREG_CS:
/*
* SVM always stores 0 for the 'G' bit in the CS selector in
* the VMCB on a VMEXIT. This hurts cross-vendor migration:
* Intel's VMENTRY has a check on the 'G' bit.
*/
- if (seg == VCPU_SREG_CS)
var->g = s->limit > 0xfffff;
-
+ break;
+ case VCPU_SREG_TR:
/*
* Work around a bug where the busy flag in the tr selector
* isn't exposed
*/
- if (seg == VCPU_SREG_TR)
var->type |= 0x2;
+ break;
+ case VCPU_SREG_DS:
+ case VCPU_SREG_ES:
+ case VCPU_SREG_FS:
+ case VCPU_SREG_GS:
+ /*
+ * The accessed bit must always be set in the segment
+ * descriptor cache, although it can be cleared in the
+ * descriptor, the cached bit always remains at 1. Since
+ * Intel has a check on this, set it here to support
+ * cross-vendor migration.
+ */
+ if (!var->unusable) var->type |= 0x1;
+ break;
+ }
var->unusable = !var->present;
}
--
1.5.2.2
next prev parent reply other threads:[~2009-01-09 21:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-09 12:02 [PATCH] kvm: always set accessed bit in VMCS segment selectors Andre Przywara
2009-01-09 17:57 ` Avi Kivity
2009-01-09 21:27 ` Andre Przywara [this message]
2009-01-10 5:17 ` [PATCH] set accessed bit for VMCB " Amit Shah
2009-01-11 21:39 ` [PATCH] kvm: " Andre Przywara
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=12315364554190-git-send-email-andre.przywara@amd.com \
--to=andre.przywara@amd.com \
--cc=amit.shah@redhat.com \
--cc=avi@redhat.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 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.