From: Tao Wu <lepton@google.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com,
Tao Wu <lepton@google.com>
Subject: [Qemu-devel] [PATCH v2 2/3] target/i386: hax: change to use x86_update_hflags
Date: Wed, 10 Jan 2018 11:50:55 -0800 [thread overview]
Message-ID: <20180110195056.85403-2-lepton@google.com> (raw)
In-Reply-To: <20180110195056.85403-1-lepton@google.com>
Change to use x86_update_hflags instead of keeping another copy
at hax side. This also fix bug like HF_CPL_MASK should be SS.DPL,
not CS.DPL.
Signed-off-by: Tao Wu <lepton@google.com>
---
target/i386/hax-all.c | 53 ++-------------------------------------------------
1 file changed, 2 insertions(+), 51 deletions(-)
diff --git a/target/i386/hax-all.c b/target/i386/hax-all.c
index 3ce6950296..dc379373f7 100644
--- a/target/i386/hax-all.c
+++ b/target/i386/hax-all.c
@@ -31,6 +31,7 @@
#include "qemu-common.h"
#include "strings.h"
+#include "common_i386.h"
#include "hax-i386.h"
#include "sysemu/accel.h"
#include "sysemu/sysemu.h"
@@ -782,56 +783,6 @@ static int hax_set_segments(CPUArchState *env, struct vcpu_state_t *sregs)
return 0;
}
-/*
- * After get the state from the kernel module, some
- * qemu emulator state need be updated also
- */
-static int hax_setup_qemu_emulator(CPUArchState *env)
-{
-
-#define HFLAG_COPY_MASK (~( \
- HF_CPL_MASK | HF_PE_MASK | HF_MP_MASK | HF_EM_MASK | \
- HF_TS_MASK | HF_TF_MASK | HF_VM_MASK | HF_IOPL_MASK | \
- HF_OSFXSR_MASK | HF_LMA_MASK | HF_CS32_MASK | \
- HF_SS32_MASK | HF_CS64_MASK | HF_ADDSEG_MASK))
-
- uint32_t hflags;
-
- hflags = (env->segs[R_CS].flags >> DESC_DPL_SHIFT) & HF_CPL_MASK;
- hflags |= (env->cr[0] & CR0_PE_MASK) << (HF_PE_SHIFT - CR0_PE_SHIFT);
- hflags |= (env->cr[0] << (HF_MP_SHIFT - CR0_MP_SHIFT)) &
- (HF_MP_MASK | HF_EM_MASK | HF_TS_MASK);
- hflags |= (env->eflags & (HF_TF_MASK | HF_VM_MASK | HF_IOPL_MASK));
- hflags |= (env->cr[4] & CR4_OSFXSR_MASK) <<
- (HF_OSFXSR_SHIFT - CR4_OSFXSR_SHIFT);
-
- if (env->efer & MSR_EFER_LMA) {
- hflags |= HF_LMA_MASK;
- }
-
- if ((hflags & HF_LMA_MASK) && (env->segs[R_CS].flags & DESC_L_MASK)) {
- hflags |= HF_CS32_MASK | HF_SS32_MASK | HF_CS64_MASK;
- } else {
- hflags |= (env->segs[R_CS].flags & DESC_B_MASK) >>
- (DESC_B_SHIFT - HF_CS32_SHIFT);
- hflags |= (env->segs[R_SS].flags & DESC_B_MASK) >>
- (DESC_B_SHIFT - HF_SS32_SHIFT);
- if (!(env->cr[0] & CR0_PE_MASK) ||
- (env->eflags & VM_MASK) || !(hflags & HF_CS32_MASK)) {
- hflags |= HF_ADDSEG_MASK;
- } else {
- hflags |= ((env->segs[R_DS].base |
- env->segs[R_ES].base |
- env->segs[R_SS].base) != 0) << HF_ADDSEG_SHIFT;
- }
- }
-
- hflags &= ~HF_SMM_MASK;
-
- env->hflags = (env->hflags & HFLAG_COPY_MASK) | hflags;
- return 0;
-}
-
static int hax_sync_vcpu_register(CPUArchState *env, int set)
{
struct vcpu_state_t regs;
@@ -888,7 +839,7 @@ static int hax_sync_vcpu_register(CPUArchState *env, int set)
}
}
if (!set) {
- hax_setup_qemu_emulator(env);
+ x86_update_hflags(env);
}
return 0;
}
--
2.16.0.rc1.238.g530d649a79-goog
next prev parent reply other threads:[~2018-01-10 19:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 6:47 [Qemu-devel] [PATCH] target/i386: hax: Move hax_setup_qemu_emulator Tao Wu
2018-01-10 13:27 ` Paolo Bonzini
2018-01-10 18:05 ` Tao Wu(吴涛@Eng)
2018-01-10 19:50 ` [Qemu-devel] [PATCH v2 1/3] target/i386: move hflags update code to a function Tao Wu
2018-01-10 19:50 ` Tao Wu [this message]
2018-01-10 19:50 ` [Qemu-devel] [PATCH v2 3/3] target/i386: hax: Move x86_update_hflags Tao Wu
2018-01-11 13:16 ` [Qemu-devel] [PATCH v2 1/3] target/i386: move hflags update code to a function 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=20180110195056.85403-2-lepton@google.com \
--to=lepton@google.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).