[PATCH v5 6/6] target/i386: emulate: emulate SLDT and STR

Mohamed Mediouni posted 6 patches 6 days, 19 hours ago
Maintainers: Pierrick Bouvier <pierrick.bouvier@linaro.org>, Pedro Barbuda <pbarbuda@microsoft.com>, Mohamed Mediouni <mohamed@unpredictable.fr>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Wei Liu <wei.liu@kernel.org>, Magnus Kulke <magnuskulke@linux.microsoft.com>
There is a newer version of this series
[PATCH v5 6/6] target/i386: emulate: emulate SLDT and STR
Posted by Mohamed Mediouni 6 days, 19 hours ago
Never saw that one being trapped and could not reproduce on AMD.
But from the QEMU bug tracker, that looks like another story on
Intel processors.

Present in "whpx_failures.txt" on
https://gitlab.com/qemu-project/qemu/-/work_items/3349#note_3195249254

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
 target/i386/emulate/x86_emu.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/target/i386/emulate/x86_emu.c b/target/i386/emulate/x86_emu.c
index c2da1a133f..e6e6500ea5 100644
--- a/target/i386/emulate/x86_emu.c
+++ b/target/i386/emulate/x86_emu.c
@@ -1338,6 +1338,22 @@ static bool exec_xadd(CPUX86State *env, struct x86_decode *decode)
     return 0;
 }
 
+static bool exec_sldt(CPUX86State *env, struct x86_decode *decode)
+{
+    x86_segment_selector seg = emul_ops->read_segment_selector(env_cpu(env), R_LDTR);
+    write_val_ext(env, &decode->op[0], seg.sel, 2);
+    env->eip += decode->len;
+    return 0;
+}
+
+static bool exec_str(CPUX86State *env, struct x86_decode *decode)
+{
+    x86_segment_selector seg = emul_ops->read_segment_selector(env_cpu(env), R_TR);
+    write_val_ext(env, &decode->op[0], seg.sel, 2);
+    env->eip += decode->len;
+    return 0;
+}
+
 static struct cmd_handler {
     enum x86_decode_cmd cmd;
     bool (*handler)(CPUX86State *env, struct x86_decode *ins);
@@ -1382,6 +1398,8 @@ static struct cmd_handler {
     {X86_DECODE_CMD_MOVSX, exec_movsx},
     {X86_DECODE_CMD_XCHG, exec_xchg},
     {X86_DECODE_CMD_XADD, exec_xadd},
+    {X86_DECODE_CMD_SLDT, exec_sldt},
+    {X86_DECODE_CMD_STR, exec_str}
 };
 
 static struct cmd_handler _cmd_handler[X86_DECODE_CMD_LAST];
-- 
2.50.1 (Apple Git-155)