From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: [RFC PATCH 2/4] KVM: x86: emulate sldt and str
Date: Tue, 12 Jul 2016 21:20:21 +0200 [thread overview]
Message-ID: <1468351223-3250-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1468351223-3250-1-git-send-email-pbonzini@redhat.com>
These will be used to emulate UMIP through VMX descriptor-table
vmexits.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/emulate.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index a2f24af3c999..3e09c7461ba8 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3577,15 +3577,20 @@ static int em_rdmsr(struct x86_emulate_ctxt *ctxt)
return X86EMUL_CONTINUE;
}
+static int em_store_sreg(struct x86_emulate_ctxt *ctxt, int segment)
+{
+ ctxt->dst.val = get_segment_selector(ctxt, segment);
+ if (ctxt->dst.bytes == 4 && ctxt->dst.type == OP_MEM)
+ ctxt->dst.bytes = 2;
+ return X86EMUL_CONTINUE;
+}
+
static int em_mov_rm_sreg(struct x86_emulate_ctxt *ctxt)
{
if (ctxt->modrm_reg > VCPU_SREG_GS)
return emulate_ud(ctxt);
- ctxt->dst.val = get_segment_selector(ctxt, ctxt->modrm_reg);
- if (ctxt->dst.bytes == 4 && ctxt->dst.type == OP_MEM)
- ctxt->dst.bytes = 2;
- return X86EMUL_CONTINUE;
+ return em_store_sreg(ctxt, ctxt->modrm_reg);
}
static int em_mov_sreg_rm(struct x86_emulate_ctxt *ctxt)
@@ -3603,6 +3608,11 @@ static int em_mov_sreg_rm(struct x86_emulate_ctxt *ctxt)
return load_segment_descriptor(ctxt, sel, ctxt->modrm_reg);
}
+static int em_sldt(struct x86_emulate_ctxt *ctxt)
+{
+ return em_store_sreg(ctxt, VCPU_SREG_LDTR);
+}
+
static int em_lldt(struct x86_emulate_ctxt *ctxt)
{
u16 sel = ctxt->src.val;
@@ -3612,6 +3622,11 @@ static int em_lldt(struct x86_emulate_ctxt *ctxt)
return load_segment_descriptor(ctxt, sel, VCPU_SREG_LDTR);
}
+static int em_str(struct x86_emulate_ctxt *ctxt)
+{
+ return em_store_sreg(ctxt, VCPU_SREG_TR);
+}
+
static int em_ltr(struct x86_emulate_ctxt *ctxt)
{
u16 sel = ctxt->src.val;
@@ -4161,8 +4176,8 @@ static const struct opcode group5[] = {
};
static const struct opcode group6[] = {
- DI(Prot | DstMem, sldt),
- DI(Prot | DstMem, str),
+ II(Prot | DstMem, em_sldt, sldt),
+ II(Prot | DstMem, em_str, str),
II(Prot | Priv | SrcMem16, em_lldt, lldt),
II(Prot | Priv | SrcMem16, em_ltr, ltr),
N, N, N, N,
--
1.8.3.1
next prev parent reply other threads:[~2016-07-12 19:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 19:20 [RFC PATCH 0/4] KVM: Emulate UMIP (or almost do so) Paolo Bonzini
2016-07-12 19:20 ` [RFC PATCH 1/4] x86: add UMIP feature and CR4 bit Paolo Bonzini
2016-07-12 19:20 ` Paolo Bonzini [this message]
2016-07-12 19:20 ` [RFC PATCH 3/4] KVM: x86: add support for emulating UMIP Paolo Bonzini
2016-07-13 20:03 ` Radim Krčmář
2016-07-14 7:00 ` Paolo Bonzini
2016-07-14 12:24 ` Radim Krčmář
2016-07-12 19:20 ` [RFC PATCH 4/4] KVM: vmx: " Paolo Bonzini
2016-07-13 9:21 ` Yang Zhang
2016-07-13 9:35 ` Paolo Bonzini
2016-07-13 9:54 ` Yang Zhang
2016-07-13 9:35 ` Paolo Bonzini
2016-07-13 10:02 ` Yang Zhang
2016-07-13 10:21 ` Paolo Bonzini
2016-07-13 20:30 ` Radim Krčmář
2016-07-14 8:09 ` Paolo Bonzini
2016-07-14 12:36 ` Radim Krčmář
2016-07-14 12:54 ` Paolo Bonzini
2016-07-31 2:32 ` Wanpeng Li
2016-08-01 15:01 ` Paolo Bonzini
2016-08-02 1:05 ` Wanpeng Li
2016-07-13 8:29 ` [RFC PATCH 0/4] KVM: Emulate UMIP (or almost do so) Yang Zhang
2016-07-13 9:34 ` Paolo Bonzini
2016-12-13 4:03 ` Li, Liang Z
2016-12-13 11:03 ` Paolo Bonzini
2017-03-01 9:04 ` Yu Zhang
2017-03-06 21:07 ` Paolo Bonzini
2017-03-10 8:02 ` Yu Zhang
2017-03-10 8:36 ` Paolo Bonzini
2017-03-10 9:31 ` Yu Zhang
2017-03-10 11:28 ` Yu Zhang
2017-03-10 15:00 ` Paolo Bonzini
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=1468351223-3250-3-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@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).