Skip to content

Commit f07329d

Browse files
committed
Simplify the remote connect assembly a bit
1 parent 8b38663 commit f07329d

2 files changed

Lines changed: 24 additions & 27 deletions

File tree

lib/tinykvm/amd64/builtin/interrupts.asm

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,21 +287,19 @@ ALIGN 0x10
287287
mov rdx, rax
288288
shr rdx, 32
289289
wrmsr
290-
pop rdx
291-
pop rcx
292290

293291
;; Make the next function call return to a custom system call location
294-
push rbx
295292
;; Get remote-disconnect syscall address
296293
mov rax, [INTR_ASM_BASE + .vm64_remote_return_addr]
297294
;; Get original stack pointer
298-
mov rbx, [rsp + 16 + 32] ;; Original RSP
295+
mov rcx, [rsp + 24 + 32] ;; Original RSP
299296
;; Overwrite the return address
300297
stac
301-
mov [rbx], rax ;; Return address
298+
mov [rcx], rax ;; Return address
302299
clac
303300

304-
pop rbx
301+
pop rdx
302+
pop rcx
305303
pop rax
306304
add rsp, 8 ;; Skip error code
307305

lib/tinykvm/amd64/builtin/kernel_assembly.h

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
unsigned char interrupts[] = {
2-
0x50, 0x01, 0xc2, 0x02, 0x50, 0x03, 0x08, 0x00, 0xca, 0x02, 0x00, 0x00,
2+
0x50, 0x01, 0xc2, 0x02, 0x48, 0x03, 0x08, 0x00, 0xca, 0x02, 0x00, 0x00,
33
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00,
55
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -66,24 +66,23 @@ unsigned char interrupts[] = {
6666
0x57, 0x0f, 0x20, 0xd7, 0xe7, 0x8e, 0x0f, 0x01, 0x3f, 0x5f, 0x85, 0xc0,
6767
0x75, 0x07, 0x58, 0x48, 0x83, 0xc4, 0x08, 0x48, 0xcf, 0x51, 0x52, 0xb9,
6868
0x00, 0x01, 0x00, 0xc0, 0x48, 0x89, 0xc2, 0x48, 0xc1, 0xea, 0x20, 0x0f,
69-
0x30, 0x5a, 0x59, 0x53, 0x48, 0x8b, 0x04, 0x25, 0x0a, 0x20, 0x00, 0x00,
70-
0x48, 0x8b, 0x5c, 0x24, 0x30, 0x0f, 0x01, 0xcb, 0x48, 0x89, 0x03, 0x0f,
71-
0x01, 0xca, 0x5b, 0x58, 0x48, 0x83, 0xc4, 0x08, 0x48, 0xcf, 0xe7, 0xa1,
72-
0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x80, 0x48, 0xcf,
73-
0x90, 0x90, 0x90, 0x90, 0xe7, 0x81, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90,
74-
0xe7, 0x82, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x83, 0x48, 0xcf,
75-
0x90, 0x90, 0x90, 0x90, 0xe7, 0x84, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90,
76-
0xe7, 0x85, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x86, 0x48, 0xcf,
77-
0x90, 0x90, 0x90, 0x90, 0xe7, 0x87, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90,
78-
0xe7, 0x88, 0xe9, 0x78, 0xff, 0xff, 0xff, 0x90, 0xe7, 0x89, 0x48, 0xcf,
79-
0x90, 0x90, 0x90, 0x90, 0xe7, 0x8a, 0xe9, 0x68, 0xff, 0xff, 0xff, 0x90,
80-
0xe7, 0x8b, 0xe9, 0x60, 0xff, 0xff, 0xff, 0x90, 0xe7, 0x8c, 0xe9, 0x58,
81-
0xff, 0xff, 0xff, 0x90, 0xe7, 0x8d, 0xe9, 0x50, 0xff, 0xff, 0xff, 0x90,
82-
0xe9, 0x3a, 0xff, 0xff, 0xff, 0x90, 0x90, 0x90, 0xe7, 0x8f, 0x48, 0xcf,
83-
0x90, 0x90, 0x90, 0x90, 0xe7, 0x90, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90,
84-
0xe7, 0x91, 0xe9, 0x30, 0xff, 0xff, 0xff, 0x90, 0xe7, 0x92, 0x48, 0xcf,
85-
0x90, 0x90, 0x90, 0x90, 0xe7, 0x93, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90,
86-
0xe7, 0x94, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe9, 0x49, 0xff, 0xff,
87-
0xff
69+
0x30, 0x48, 0x8b, 0x04, 0x25, 0x0a, 0x20, 0x00, 0x00, 0x48, 0x8b, 0x4c,
70+
0x24, 0x38, 0x0f, 0x01, 0xcb, 0x48, 0x89, 0x01, 0x0f, 0x01, 0xca, 0x5a,
71+
0x59, 0x58, 0x48, 0x83, 0xc4, 0x08, 0x48, 0xcf, 0xe7, 0xa1, 0x48, 0xcf,
72+
0xe7, 0x80, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x81, 0x48, 0xcf,
73+
0x90, 0x90, 0x90, 0x90, 0xe7, 0x82, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90,
74+
0xe7, 0x83, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x84, 0x48, 0xcf,
75+
0x90, 0x90, 0x90, 0x90, 0xe7, 0x85, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90,
76+
0xe7, 0x86, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x87, 0x48, 0xcf,
77+
0x90, 0x90, 0x90, 0x90, 0xe7, 0x88, 0xeb, 0x83, 0x90, 0x90, 0x90, 0x90,
78+
0xe7, 0x89, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x8a, 0xe9, 0x70,
79+
0xff, 0xff, 0xff, 0x90, 0xe7, 0x8b, 0xe9, 0x68, 0xff, 0xff, 0xff, 0x90,
80+
0xe7, 0x8c, 0xe9, 0x60, 0xff, 0xff, 0xff, 0x90, 0xe7, 0x8d, 0xe9, 0x58,
81+
0xff, 0xff, 0xff, 0x90, 0xe9, 0x42, 0xff, 0xff, 0xff, 0x90, 0x90, 0x90,
82+
0xe7, 0x8f, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x90, 0x48, 0xcf,
83+
0x90, 0x90, 0x90, 0x90, 0xe7, 0x91, 0xe9, 0x38, 0xff, 0xff, 0xff, 0x90,
84+
0xe7, 0x92, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90, 0xe7, 0x93, 0x48, 0xcf,
85+
0x90, 0x90, 0x90, 0x90, 0xe7, 0x94, 0x48, 0xcf, 0x90, 0x90, 0x90, 0x90,
86+
0xe9, 0x4f, 0xff, 0xff, 0xff
8887
};
89-
unsigned int interrupts_len = 1021;
88+
unsigned int interrupts_len = 1013;

0 commit comments

Comments
 (0)