From: "Radim Krčmář" <rkrcmar@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Laszlo Ersek <lersek@redhat.com>
Subject: [PATCH 3/3] KVM: x86: simplify RSM into 64-bit protected mode
Date: Fri, 30 Oct 2015 16:36:26 +0100 [thread overview]
Message-ID: <1446219386-23937-4-git-send-email-rkrcmar@redhat.com> (raw)
In-Reply-To: <1446219386-23937-1-git-send-email-rkrcmar@redhat.com>
This reverts 0123456789abc ("KVM: x86: fix RSM into 64-bit protected
mode, round 2"). We've achieved the same by treating SMBASE as a
physical address in the previous patch.
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
arch/x86/kvm/emulate.c | 37 +++++++------------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 59e80e0de865..b60fed56671b 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2311,16 +2311,7 @@ static int rsm_load_seg_32(struct x86_emulate_ctxt *ctxt, u64 smbase, int n)
return X86EMUL_CONTINUE;
}
-struct rsm_stashed_seg_64 {
- u16 selector;
- struct desc_struct desc;
- u32 base3;
-};
-
-static int rsm_stash_seg_64(struct x86_emulate_ctxt *ctxt,
- struct rsm_stashed_seg_64 *stash,
- u64 smbase,
- int n)
+static int rsm_load_seg_64(struct x86_emulate_ctxt *ctxt, u64 smbase, int n)
{
struct desc_struct desc;
int offset;
@@ -2335,20 +2326,10 @@ static int rsm_stash_seg_64(struct x86_emulate_ctxt *ctxt,
set_desc_base(&desc, GET_SMSTATE(u32, smbase, offset + 8));
base3 = GET_SMSTATE(u32, smbase, offset + 12);
- stash[n].selector = selector;
- stash[n].desc = desc;
- stash[n].base3 = base3;
+ ctxt->ops->set_segment(ctxt, selector, &desc, base3, n);
return X86EMUL_CONTINUE;
}
-static inline void rsm_load_seg_64(struct x86_emulate_ctxt *ctxt,
- struct rsm_stashed_seg_64 *stash,
- int n)
-{
- ctxt->ops->set_segment(ctxt, stash[n].selector, &stash[n].desc,
- stash[n].base3, n);
-}
-
static int rsm_enter_protected_mode(struct x86_emulate_ctxt *ctxt,
u64 cr0, u64 cr4)
{
@@ -2438,7 +2419,6 @@ static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt, u64 smbase)
u32 base3;
u16 selector;
int i, r;
- struct rsm_stashed_seg_64 stash[6];
for (i = 0; i < 16; i++)
*reg_write(ctxt, i) = GET_SMSTATE(u64, smbase, 0x7ff8 - i * 8);
@@ -2480,18 +2460,15 @@ static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt, u64 smbase)
dt.address = GET_SMSTATE(u64, smbase, 0x7e68);
ctxt->ops->set_gdt(ctxt, &dt);
- for (i = 0; i < ARRAY_SIZE(stash); i++) {
- r = rsm_stash_seg_64(ctxt, stash, smbase, i);
- if (r != X86EMUL_CONTINUE)
- return r;
- }
-
r = rsm_enter_protected_mode(ctxt, cr0, cr4);
if (r != X86EMUL_CONTINUE)
return r;
- for (i = 0; i < ARRAY_SIZE(stash); i++)
- rsm_load_seg_64(ctxt, stash, i);
+ for (i = 0; i < 6; i++) {
+ r = rsm_load_seg_64(ctxt, smbase, i);
+ if (r != X86EMUL_CONTINUE)
+ return r;
+ }
return X86EMUL_CONTINUE;
}
--
2.5.3
next prev parent reply other threads:[~2015-10-30 15:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-30 15:36 [PATCH 0/3] " Radim Krčmář
2015-10-30 15:36 ` [PATCH 1/3] KVM: x86: add read_phys to x86_emulate_ops Radim Krčmář
2015-10-30 15:36 ` [PATCH 2/3] KVM: x86: handle SMBASE as physical address in RSM Radim Krčmář
2015-10-30 15:36 ` Radim Krčmář [this message]
2015-10-31 19:50 ` [PATCH 0/3] KVM: x86: simplify RSM into 64-bit protected mode Laszlo Ersek
2015-11-02 9:32 ` Paolo Bonzini
2015-11-03 9:40 ` Laszlo Ersek
2015-11-03 10: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=1446219386-23937-4-git-send-email-rkrcmar@redhat.com \
--to=rkrcmar@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lersek@redhat.com \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®