From: liguang <lig.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: blauwirbel@gmail.com, pbonzini@redhat.com, aliguori@us.ibm.com,
afaerber@suse.de, liguang <lig.fnst@cn.fujitsu.com>
Subject: [Qemu-devel] [PATCH 6/6] target-i386/seg_helper: define names for code/data segment types
Date: Fri, 19 Apr 2013 10:52:25 +0800 [thread overview]
Message-ID: <1366339945-17151-7-git-send-email-lig.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1366339945-17151-1-git-send-email-lig.fnst@cn.fujitsu.com>
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
target-i386/seg_helper.c | 71 +++++++++++++++++++++++++++++++++------------
1 files changed, 52 insertions(+), 19 deletions(-)
diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c
index 635c5ab..aed5499 100644
--- a/target-i386/seg_helper.c
+++ b/target-i386/seg_helper.c
@@ -2292,6 +2292,39 @@ void helper_sysexit(CPUX86State *env, int dflag)
EIP = EDX;
}
+/*
+ * for data segment types
+ * RO -- read-only, A -- accessed,
+ * W -- write, E -- expand-down
+ */
+#define DESC_DSEG_RO 0
+#define DESC_DSEG_ROA 1
+#define DESC_DSEG_RW 2
+#define DESC_DSEG_RWA 3
+#define DESC_DSEG_ROE 4
+#define DESC_DSEG_ROEA 5
+#define DESC_DSEG_RWE 6
+#define DESC_DSEG_RWEA 7
+
+/*
+ * for code segment types
+ * EO -- execute-only, A -- accessed,
+ * C -- conforming, E -- expand-down, R -- read
+ */
+
+#define DESC_CSEG_EO 8
+#define DESC_CSEG_EOA 9
+#define DESC_CSEG_ER 10
+#define DESC_CSEG_ERA 11
+#define DESC_CSEG_EOC 12
+#define DESC_CSEG_EOCA 13
+#define DESC_CSEG_ERC 14
+#define DESC_CSEG_ERCA 15
+
+#define FUNC_LSL 4
+#define FUNC_LAR 3
+#define FUNC_VERR 2
+#define FUNC_VERW 1
static target_ulong misc_check_helper(CPUX86State *env, target_ulong selector1,
int inst)
@@ -2317,15 +2350,15 @@ static target_ulong misc_check_helper(CPUX86State *env, target_ulong selector1,
if (e2 & DESC_S_MASK) {
if (e2 & DESC_CS_MASK) {
switch (inst) {
- case 1:
+ case FUNC_VERW:
goto fail;
- case 2:
+ case FUNC_VERR:
if (!(e2 & (DESC_R_MASK | DESC_C_MASK))) {
goto fail;
}
break;
- case 3:
- case 4:
+ case FUNC_LAR:
+ case FUNC_LSL:
if (!(e2 & DESC_C_MASK)) {
goto check_pl;
}
@@ -2337,17 +2370,17 @@ static target_ulong misc_check_helper(CPUX86State *env, target_ulong selector1,
} else {
type = (e2 >> DESC_TYPE_SHIFT) & 0xf;
switch (type) {
- case 1:
- case 2:
- case 3:
- case 9:
- case 11:
- if (inst == 3) {
+ case DESC_DSEG_ROA:
+ case DESC_DSEG_RW:
+ case DESC_DSEG_RWA:
+ case DESC_CSEG_EOA:
+ case DESC_CSEG_ERA:
+ if (inst == FUNC_LAR) {
break;
}
- case 5:
- case 12:
- if (inst == 4) {
+ case DESC_DSEG_ROEA:
+ case DESC_CSEG_EOC:
+ if (inst == FUNC_LSL) {
break;
}
default:
@@ -2356,10 +2389,10 @@ static target_ulong misc_check_helper(CPUX86State *env, target_ulong selector1,
goto check_pl;
}
- if (inst == 3) {
+ if (inst == FUNC_LAR) {
e2 &= 0x00f0ff00;
}
- if (inst == 4) {
+ if (inst == FUNC_LSL) {
e2 = get_seg_limit(e1, e2);
}
@@ -2376,22 +2409,22 @@ fail:
target_ulong helper_lsl(CPUX86State *env, target_ulong selector1)
{
- return misc_check_helper(env, selector1, 4);
+ return misc_check_helper(env, selector1, FUNC_LSL);
}
target_ulong helper_lar(CPUX86State *env, target_ulong selector1)
{
- return misc_check_helper(env, selector1, 3);
+ return misc_check_helper(env, selector1, FUNC_LAR);
}
void helper_verr(CPUX86State *env, target_ulong selector1)
{
- misc_check_helper(env, selector1, 2);
+ misc_check_helper(env, selector1, FUNC_VERR);
}
void helper_verw(CPUX86State *env, target_ulong selector1)
{
- misc_check_helper(env, selector1, 1);
+ misc_check_helper(env, selector1, FUNC_VERW);
}
#if defined(CONFIG_USER_ONLY)
--
1.7.2.5
prev parent reply other threads:[~2013-04-19 2:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-19 2:52 [Qemu-devel] [PATCH 0/6] target-i386:do some cleanups liguang
2013-04-19 2:52 ` [Qemu-devel] [PATCH 1/6] target-i386/seg_helper: replace env->eip with EIP liguang
2013-04-19 7:48 ` Richard Henderson
2013-04-19 7:55 ` li guang
2013-04-19 8:08 ` Richard Henderson
2013-04-19 2:52 ` [Qemu-devel] [PATCH 2/6] target-i386/smm_helper: " liguang
2013-04-19 2:52 ` [Qemu-devel] [PATCH 3/6] target-i386/svm_helper: " liguang
2013-04-19 2:52 ` [Qemu-devel] [PATCH 4/6] target-i386/svm_helper: remove redundant assignment liguang
2013-04-19 2:52 ` [Qemu-devel] [PATCH 5/6] target-i386/seg_helper: refactor 4 helper functions liguang
2013-04-19 2:52 ` liguang [this message]
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=1366339945-17151-7-git-send-email-lig.fnst@cn.fujitsu.com \
--to=lig.fnst@cn.fujitsu.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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).