[PATCH v4 1/8] HV: refine excp/external_interrupt_save_frame and excp_rsvd


Kaige Fu
 

There are lines of repeated codes in excp/external_interrupt_save_frame
and excp_rsvd. So, this patch defines two .macro, save_frame and restore_frame,
to reduce the repeated codes.

No functional change.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/idt.S | 105 +++++++-------------------------------
1 file changed, 19 insertions(+), 86 deletions(-)

diff --git a/hypervisor/arch/x86/idt.S b/hypervisor/arch/x86/idt.S
index cb42ea9e..c6f346b8 100644
--- a/hypervisor/arch/x86/idt.S
+++ b/hypervisor/arch/x86/idt.S
@@ -257,13 +257,7 @@ vector =0x20
vector = vector + 1
.endr

-
-
-/*
- * Common entry point for defined exceptions
- */
-.align 8
-excp_save_frame:
+.macro save_frame
pushq %r15
pushq %r14
pushq %r13
@@ -281,12 +275,11 @@ excp_save_frame:
pushq %rcx
pushq %rax

-
/* Put current stack pointer into 1st param register (rdi) */
movq %rsp, %rdi
+.endm

- call dispatch_exception
-
+.macro restore_frame
popq %rax
popq %rcx
popq %rdx
@@ -306,6 +299,18 @@ excp_save_frame:

/* Skip vector and error code*/
add $16, %rsp
+.endm
+
+/*
+ * Common entry point for defined exceptions
+ */
+.align 8
+excp_save_frame:
+ save_frame
+
+ call dispatch_exception
+
+ restore_frame

iretq

@@ -317,47 +322,11 @@ excp_save_frame:
*/
.align 8
excp_rsvd:
- pushq %r15
- pushq %r14
- pushq %r13
- pushq %r12
- pushq %r11
- pushq %r10
- pushq %r9
- pushq %r8
- pushq %rdi
- pushq %rsi
- pushq %rbp
- pushq %rsp
- pushq %rbx
- pushq %rdx
- pushq %rcx
- pushq %rax
-
- /* Put current stack pointer into 1st param register (rdi) */
- movq %rsp, %rdi
+ save_frame

call dispatch_exception

- popq %rax
- popq %rcx
- popq %rdx
- popq %rbx
- popq %rsp
- popq %rbp
- popq %rsi
- popq %rdi
- popq %r8
- popq %r9
- popq %r10
- popq %r11
- popq %r12
- popq %r13
- popq %r14
- popq %r15
-
- /* Skip vector and error code*/
- add $16, %rsp
+ restore_frame

iretq

@@ -368,25 +337,7 @@ excp_rsvd:
*/
.align 8
external_interrupt_save_frame:
- pushq %r15
- pushq %r14
- pushq %r13
- pushq %r12
- pushq %r11
- pushq %r10
- pushq %r9
- pushq %r8
- pushq %rdi
- pushq %rsi
- pushq %rbp
- pushq %rsp
- pushq %rbx
- pushq %rdx
- pushq %rcx
- pushq %rax
-
- /* Put current stack pointer into 1st param register (rdi) */
- movq %rsp, %rdi
+ save_frame

call dispatch_interrupt

@@ -395,25 +346,7 @@ external_interrupt_save_frame:
* are for Guest.
*/

- popq %rax
- popq %rcx
- popq %rdx
- popq %rbx
- popq %rsp
- popq %rbp
- popq %rsi
- popq %rdi
- popq %r8
- popq %r9
- popq %r10
- popq %r11
- popq %r12
- popq %r13
- popq %r14
- popq %r15
-
- /* Skip vector and error code*/
- add $16, %rsp
+ restore_frame

iretq

--
2.20.0

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.