From: "Hulin, Patrick - 0559 - MITLL" <Patrick.Hulin@ll.mit.edu>
To: Richard Henderson <rth@twiddle.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] QEMU, self-modifying code, and Windows 7 64-bit (no KVM)
Date: Mon, 18 Aug 2014 20:50:24 +0000 [thread overview]
Message-ID: <D017DEE0.758%Patrick.Hulin@ll.mit.edu> (raw)
In-Reply-To: <98E51B30-6FC2-42D3-A5D2-6504B0B6472D@ll.mit.edu>
[-- Attachment #1: Type: text/plain, Size: 765 bytes --]
On 8/18/14, 1:47 PM, "Hulin, Patrick - 0559 - MITLL"
<Patrick.Hulin@ll.mit.edu> wrote:
>On Aug 18, 2014, at 1:37 PM, Richard Henderson <rth@twiddle.net> wrote:
>
>>On 08/16/2014 10:21 PM, Paolo Bonzini wrote:
>>>>>Would it work to just call tb_invalidate_phys_page_range before the
>>>>>helper_ret_stb loop?
>>I doubt it.
>
>Correct. Doesn¹t work. Haven¹t fully diagnosed why, but it doesn¹t seem
>to ever hit the current_tb_modified passage if you invalidate beforehand.
Yeah - mem_io_pc doesn¹t get updated until we¹re inside io_write, so
tb_invalidate_phys_page_range thinks we¹re inside a different TB. As a
result, it¹s ³is this TB modified² check still returns false.
I¹ve attached the correct source patch for the test case as well.
[-- Attachment #2: selfmodify.patch --]
[-- Type: application/octet-stream, Size: 2113 bytes --]
diff --git a/config/config-x86-common.mak b/config/config-x86-common.mak
index 0b0da85..0ddf5ad 100644
--- a/config/config-x86-common.mak
+++ b/config/config-x86-common.mak
@@ -105,6 +105,8 @@ $(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o
$(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o
+$(TEST_DIR)/selfmodify.elf: $(cstart.o) $(TEST_DIR)/selfmodify.o
+
arch_clean:
$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
$(TEST_DIR)/.*.d lib/x86/.*.d
diff --git a/config/config-x86_64.mak b/config/config-x86_64.mak
index 06b2581..edb22ca 100644
--- a/config/config-x86_64.mak
+++ b/config/config-x86_64.mak
@@ -9,5 +9,6 @@ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
$(TEST_DIR)/pcid.flat $(TEST_DIR)/debug.flat
tests += $(TEST_DIR)/svm.flat
tests += $(TEST_DIR)/vmx.flat
+tests += $(TEST_DIR)/selfmodify.flat
include config/config-x86-common.mak
diff --git a/x86/run b/x86/run
index 646c577..a35678f 100755
--- a/x86/run
+++ b/x86/run
@@ -33,7 +33,7 @@ else
pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out"
fi
-command="${qemu} -enable-kvm $pc_testdev -display none -serial stdio $pci_testdev -kernel"
+command="${qemu} $pc_testdev -display none -serial stdio $pci_testdev -kernel"
echo ${command} "$@"
${command} "$@"
ret=$?
diff --git a/x86/selfmodify.S b/x86/selfmodify.S
new file mode 100644
index 0000000..8d985cc
--- /dev/null
+++ b/x86/selfmodify.S
@@ -0,0 +1,20 @@
+geteip:
+ mov (%rsp), %rax
+ ret
+
+.global main
+.type main, @function
+
+main:
+ movq $0x947B967B00000000, %rbx
+ call geteip
+ xorq %rbx, (%rax)
+ nop
+ jmp fail
+ jmp fail
+ xor %rax, %rax
+ retq
+
+fail:
+ movq $2, %rax
+ retq
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 6d3e23a..646130b 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -6,6 +6,10 @@
# arch = i386/x86_64 # Only if the test case works only on one of them
# groups = group1 group2 # Used to identify test cases with run_tests -g ...
+[selfmodify]
+file = selfmodify.flat
+arch = x86_64
+
[apic]
file = apic.flat
smp = 2
[-- Attachment #3: selfmodify.flat --]
[-- Type: application/octet-stream, Size: 85963 bytes --]
next prev parent reply other threads:[~2014-08-18 20:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG5rQryFDdrYZKPWYm8k_5EPGOP9RgvUqamSkjWiO3UikieeAw@mail.gmail.com>
2014-08-13 18:36 ` [Qemu-devel] QEMU, self-modifying code, and Windows 7 64-bit (no KVM) Hulin, Patrick - 0559 - MITLL
2014-08-14 13:53 ` Hulin, Patrick - 0559 - MITLL
2014-08-15 20:48 ` Paolo Bonzini
2014-08-15 21:49 ` Hulin, Patrick - 0559 - MITLL
2014-08-17 5:21 ` Paolo Bonzini
2014-08-18 17:37 ` Richard Henderson
2014-08-18 17:47 ` Hulin, Patrick - 0559 - MITLL
2014-08-18 20:50 ` Hulin, Patrick - 0559 - MITLL [this message]
2014-08-19 6:16 ` Paolo Bonzini
2014-08-20 14:03 ` Hulin, Patrick - 0559 - MITLL
2014-08-20 15:12 ` Richard Henderson
2014-08-18 21:12 ` Paolo Bonzini
2014-08-18 17:47 ` Hulin, Patrick - 0559 - MITLL
2014-08-18 18:08 ` Hulin, Patrick - 0559 - MITLL
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=D017DEE0.758%Patrick.Hulin@ll.mit.edu \
--to=patrick.hulin@ll.mit.edu \
--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).