From: Xu Zhang <xzhang@cs.uic.edu>
To: xen-devel@lists.xen.org
Cc: samuel.thibault@ens-lyon.org, jeremy@goop.org,
Xu Zhang <xzhang@cs.uic.edu>,
gm281@cam.ac.uk, stefano.stabellini@eu.citrix.com
Subject: [PATCH 3/6] mini-os/x86-64 entry: code refactoring; no functional changes
Date: Fri, 8 Mar 2013 15:30:16 -0600 [thread overview]
Message-ID: <1362778219-8576-4-git-send-email-xzhang@cs.uic.edu> (raw)
In-Reply-To: <1362778219-8576-1-git-send-email-xzhang@cs.uic.edu>
Re-arrange assembly code blocks so that they are in called
order instead of jumping around, enhancing readability.
Macros are grouped together as well.
Signed-off-by: Xu Zhang <xzhang@cs.uic.edu>
---
| 118 +++++++++++++++++++-------------------
1 files changed, 59 insertions(+), 59 deletions(-)
--git a/extras/mini-os/arch/x86/x86_64.S b/extras/mini-os/arch/x86/x86_64.S
index addb7b1..79e893f 100644
--- a/extras/mini-os/arch/x86/x86_64.S
+++ b/extras/mini-os/arch/x86/x86_64.S
@@ -36,6 +36,22 @@ hypercall_page:
.org 0x3000
+#define XEN_GET_VCPU_INFO(reg) movq HYPERVISOR_shared_info,reg
+#define XEN_PUT_VCPU_INFO(reg)
+#define XEN_PUT_VCPU_INFO_fixup
+#define XEN_LOCKED_BLOCK_EVENTS(reg) movb $1,evtchn_upcall_mask(reg)
+#define XEN_LOCKED_UNBLOCK_EVENTS(reg) movb $0,evtchn_upcall_mask(reg)
+#define XEN_TEST_PENDING(reg) testb $0xFF,evtchn_upcall_pending(reg)
+
+#define XEN_BLOCK_EVENTS(reg) XEN_GET_VCPU_INFO(reg) ; \
+ XEN_LOCKED_BLOCK_EVENTS(reg) ; \
+ XEN_PUT_VCPU_INFO(reg)
+
+#define XEN_UNBLOCK_EVENTS(reg) XEN_GET_VCPU_INFO(reg) ; \
+ XEN_LOCKED_UNBLOCK_EVENTS(reg) ; \
+ XEN_PUT_VCPU_INFO(reg)
+
+
/* Offsets into shared_info_t. */
#define evtchn_upcall_pending /* 0 */
#define evtchn_upcall_mask 1
@@ -46,6 +62,27 @@ NMI_MASK = 0x80000000
#define ORIG_RAX 120 /* + error_code */
#define EFLAGS 144
+
+/* Macros */
+.macro zeroentry sym
+ movq (%rsp),%rcx
+ movq 8(%rsp),%r11
+ addq $0x10,%rsp /* skip rcx and r11 */
+ pushq $0 /* push error code/oldrax */
+ pushq %rax /* push real oldrax to the rdi slot */
+ leaq \sym(%rip),%rax
+ jmp error_entry
+.endm
+
+.macro errorentry sym
+ movq (%rsp),%rcx
+ movq 8(%rsp),%r11
+ addq $0x10,%rsp /* rsp points to the error code */
+ pushq %rax
+ leaq \sym(%rip),%rax
+ jmp error_entry
+.endm
+
.macro SAVE_REST
subq $6*8,%rsp
movq %rbx,5*8(%rsp)
@@ -79,7 +116,6 @@ NMI_MASK = 0x80000000
addq $9*8+8,%rsp
.endm
-
.macro HYPERVISOR_IRET flag
testl $NMI_MASK,2*8(%rsp)
jnz 2f
@@ -98,6 +134,8 @@ NMI_MASK = 0x80000000
jmp hypercall_page + (__HYPERVISOR_iret * 32)
.endm
+
+
/*
* Exception entry point. This expects an error code/orig_rax on the stack
* and the exception handler in %rax.
@@ -130,73 +168,24 @@ error_call_handler:
call *%rax
jmp error_exit
-.macro zeroentry sym
- movq (%rsp),%rcx
- movq 8(%rsp),%r11
- addq $0x10,%rsp /* skip rcx and r11 */
- pushq $0 /* push error code/oldrax */
- pushq %rax /* push real oldrax to the rdi slot */
- leaq \sym(%rip),%rax
- jmp error_entry
-.endm
-
-.macro errorentry sym
- movq (%rsp),%rcx
- movq 8(%rsp),%r11
- addq $0x10,%rsp /* rsp points to the error code */
- pushq %rax
- leaq \sym(%rip),%rax
- jmp error_entry
-.endm
-
-#define XEN_GET_VCPU_INFO(reg) movq HYPERVISOR_shared_info,reg
-#define XEN_PUT_VCPU_INFO(reg)
-#define XEN_PUT_VCPU_INFO_fixup
-#define XEN_LOCKED_BLOCK_EVENTS(reg) movb $1,evtchn_upcall_mask(reg)
-#define XEN_LOCKED_UNBLOCK_EVENTS(reg) movb $0,evtchn_upcall_mask(reg)
-#define XEN_TEST_PENDING(reg) testb $0xFF,evtchn_upcall_pending(reg)
-
-#define XEN_BLOCK_EVENTS(reg) XEN_GET_VCPU_INFO(reg) ; \
- XEN_LOCKED_BLOCK_EVENTS(reg) ; \
- XEN_PUT_VCPU_INFO(reg)
-
-#define XEN_UNBLOCK_EVENTS(reg) XEN_GET_VCPU_INFO(reg) ; \
- XEN_LOCKED_UNBLOCK_EVENTS(reg) ; \
- XEN_PUT_VCPU_INFO(reg)
-
ENTRY(hypervisor_callback)
zeroentry hypervisor_callback2
ENTRY(hypervisor_callback2)
- movq %rdi, %rsp
+ movq %rdi, %rsp
11: movq %gs:8,%rax
incl %gs:0
cmovzq %rax,%rsp
pushq %rdi
- call do_hypervisor_callback
+ call do_hypervisor_callback
popq %rsp
decl %gs:0
- jmp error_exit
-
-restore_all_enable_events:
- XEN_UNBLOCK_EVENTS(%rsi) # %rsi is already set up...
-
-scrit: /**** START OF CRITICAL REGION ****/
- XEN_TEST_PENDING(%rsi)
- jnz 14f # process more events if necessary...
- XEN_PUT_VCPU_INFO(%rsi)
- RESTORE_ALL
- HYPERVISOR_IRET 0
-
-14: XEN_LOCKED_BLOCK_EVENTS(%rsi)
- XEN_PUT_VCPU_INFO(%rsi)
- SAVE_REST
- movq %rsp,%rdi # set the argument again
- jmp 11b
-ecrit: /**** END OF CRITICAL REGION ****/
+error_exit:
+ RESTORE_REST
+ XEN_BLOCK_EVENTS(%rsi)
retint_kernel:
retint_restore_args:
@@ -211,11 +200,22 @@ retint_restore_args:
RESTORE_ALL
HYPERVISOR_IRET 0
+restore_all_enable_events:
+ XEN_UNBLOCK_EVENTS(%rsi) # %rsi is already set up...
-error_exit:
- RESTORE_REST
- XEN_BLOCK_EVENTS(%rsi)
- jmp retint_kernel
+scrit: /**** START OF CRITICAL REGION ****/
+ XEN_TEST_PENDING(%rsi)
+ jnz 14f # process more events if necessary...
+ XEN_PUT_VCPU_INFO(%rsi)
+ RESTORE_ALL
+ HYPERVISOR_IRET 0
+
+14: XEN_LOCKED_BLOCK_EVENTS(%rsi)
+ XEN_PUT_VCPU_INFO(%rsi)
+ SAVE_REST
+ movq %rsp,%rdi # set the argument again
+ jmp 11b
+ecrit: /**** END OF CRITICAL REGION ****/
--
1.7.7.6
next prev parent reply other threads:[~2013-03-08 21:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-08 21:30 [PATCH 0/6] mini-os: check and fix up against nested events in x86-64 kernel entry Xu Zhang
2013-03-08 21:30 ` [PATCH 1/6] mini-os/x86-64 entry: code clean-ups Xu Zhang
2013-03-09 20:57 ` Samuel Thibault
2013-03-08 21:30 ` [PATCH 2/6] mini-os/x86-64 entry: define macros for registers partial save and restore Xu Zhang
2013-03-09 20:55 ` Samuel Thibault
2013-03-08 21:30 ` Xu Zhang [this message]
2013-03-09 21:03 ` [PATCH 3/6] mini-os/x86-64 entry: code refactoring; no functional changes Samuel Thibault
2013-04-11 4:40 ` Xu Zhang
2013-03-08 21:30 ` [PATCH 4/6] mini-os/x86-64 entry: remove unnecessary event blocking Xu Zhang
2013-03-09 21:07 ` Samuel Thibault
2013-03-15 20:16 ` Konrad Rzeszutek Wilk
2013-04-11 4:40 ` Xu Zhang
2013-03-08 21:30 ` [PATCH 5/6] mini-os/x86-64 entry: defer RESTORE_REST until return Xu Zhang
2013-03-09 21:15 ` Samuel Thibault
2013-03-08 21:30 ` [PATCH 6/6] mini-os/x86-64 entry: check against nested events and try to fix up Xu Zhang
2013-03-09 21:19 ` Samuel Thibault
2013-03-13 2:42 ` Xu Zhang
2013-03-09 22:44 ` Jeremy Fitzhardinge
2013-03-13 2:42 ` Xu Zhang
2013-03-13 5:53 ` Xu Zhang
2013-03-14 1:09 ` Jeremy Fitzhardinge
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=1362778219-8576-4-git-send-email-xzhang@cs.uic.edu \
--to=xzhang@cs.uic.edu \
--cc=gm281@cam.ac.uk \
--cc=jeremy@goop.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.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).