From: Arthur Chunqi Li <yzt356@gmail.com>
To: kvm@vger.kernel.org
Cc: jan.kiszka@web.de, gleb@redhat.com, pbonzini@redhat.com,
Arthur Chunqi Li <yzt356@gmail.com>
Subject: [PATCH v4 1/2] kvm-unit-tests : Add setjmp/longjmp to libcflat
Date: Wed, 17 Jul 2013 14:05:52 +0800 [thread overview]
Message-ID: <1374041153-32235-2-git-send-email-yzt356@gmail.com> (raw)
In-Reply-To: <1374041153-32235-1-git-send-email-yzt356@gmail.com>
Add setjmp and longjmp functions to libcflat. Now these two functions
are only supported in X86_64 arch.
New files added:
lib/x86/setjmp64.S
lib/x86/setjmp64.c
Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
---
config-x86_64.mak | 2 ++
lib/setjmp.h | 11 +++++++++++
lib/x86/setjmp64.S | 27 +++++++++++++++++++++++++++
3 files changed, 40 insertions(+)
create mode 100644 lib/setjmp.h
create mode 100644 lib/x86/setjmp64.S
diff --git a/config-x86_64.mak b/config-x86_64.mak
index 4e525f5..91ffcce 100644
--- a/config-x86_64.mak
+++ b/config-x86_64.mak
@@ -4,6 +4,8 @@ bits = 64
ldarch = elf64-x86-64
CFLAGS += -D__x86_64__
+cflatobjs += lib/x86/setjmp64.o
+
tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
$(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \
$(TEST_DIR)/xsave.flat $(TEST_DIR)/rmap_chain.flat \
diff --git a/lib/setjmp.h b/lib/setjmp.h
new file mode 100644
index 0000000..eca70d9
--- /dev/null
+++ b/lib/setjmp.h
@@ -0,0 +1,11 @@
+#ifndef LIBCFLAT_SETJMP64_H
+#define LIBCFLAT_SETJMP64_H
+
+#include "libcflat.h"
+
+typedef char jmp_buf[64];
+
+void longjmp(jmp_buf env, int val);
+int setjmp(jmp_buf env);
+
+#endif
diff --git a/lib/x86/setjmp64.S b/lib/x86/setjmp64.S
new file mode 100644
index 0000000..c8ae790
--- /dev/null
+++ b/lib/x86/setjmp64.S
@@ -0,0 +1,27 @@
+.globl setjmp
+setjmp:
+ mov (%rsp), %rsi
+ mov %rsi, (%rdi)
+ mov %rsp, 0x8(%rdi)
+ mov %rbp, 0x10(%rdi)
+ mov %rbx, 0x18(%rdi)
+ mov %r12, 0x20(%rdi)
+ mov %r13, 0x28(%rdi)
+ mov %r14, 0x30(%rdi)
+ mov %r15, 0x38(%rdi)
+ xor %eax, %eax
+ ret
+
+.globl longjmp
+longjmp:
+ mov %esi, %eax
+ mov 0x38(%rdi), %r15
+ mov 0x30(%rdi), %r14
+ mov 0x28(%rdi), %r13
+ mov 0x20(%rdi), %r12
+ mov 0x18(%rdi), %rbx
+ mov 0x10(%rdi), %rbp
+ mov 0x8(%rdi), %rsp
+ mov (%rdi), %rsi
+ mov %rsi, (%rsp)
+ ret
--
1.7.9.5
next prev parent reply other threads:[~2013-07-17 6:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-17 6:05 [PATCH v4 0/2] Basic nested VMX test suite Arthur Chunqi Li
2013-07-17 6:05 ` Arthur Chunqi Li [this message]
2013-07-17 6:05 ` [PATCH v4 2/2] kvm-unit-tests : The first version of VMX nested test case Arthur Chunqi Li
2013-07-17 6:26 ` Jan Kiszka
2013-07-17 6:36 ` Arthur Chunqi Li
2013-07-17 10:13 ` Paolo Bonzini
2013-07-17 6:08 ` [PATCH v4 0/2] Basic nested VMX test suite Arthur Chunqi Li
2013-07-17 6:21 ` Gleb Natapov
2013-07-17 7:52 ` Paolo Bonzini
2013-07-17 9:03 ` Gleb Natapov
2013-07-17 10:19 ` Paolo Bonzini
2013-07-17 10:31 ` Gleb Natapov
2013-07-17 10:46 ` Jan Kiszka
2013-07-17 10:54 ` Paolo Bonzini
2013-07-17 13:48 ` Arthur Chunqi Li
2013-07-17 14:10 ` 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=1374041153-32235-2-git-send-email-yzt356@gmail.com \
--to=yzt356@gmail.com \
--cc=gleb@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kvm@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