X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=guest%2Flinux%2Fhvm-ros%2Fv3_hvm_ros_user_low_level.S;fp=guest%2Flinux%2Fhvm-ros%2Fv3_hvm_ros_user_low_level.S;h=3cbcc07a2c17246c2f3fd91a1adbb9e5a685d8ea;hp=0000000000000000000000000000000000000000;hb=4e43946f01f687361197dc9571b7df02ae20de30;hpb=a8686374c6aa74d805b32e7675f42f7ab9a0b348 diff --git a/guest/linux/hvm-ros/v3_hvm_ros_user_low_level.S b/guest/linux/hvm-ros/v3_hvm_ros_user_low_level.S new file mode 100644 index 0000000..3cbcc07 --- /dev/null +++ b/guest/linux/hvm-ros/v3_hvm_ros_user_low_level.S @@ -0,0 +1,88 @@ +.section .text + +.extern __v3_hvm_ros_signal_handler + +/* + This is the entry point for signal dispatch + from the VMM. + + VMM invokes this stub when a user signal is + raised and: the relevant address space + is active, and we are at user-level. + It will be invoked on exactly one core, + although there are no guarantees on which one. + +*/ + + +#define GPR_SAVE() \ + pushq %rbp ; \ + pushq %rax ; \ + pushq %rbx ; \ + pushq %rcx ; \ + pushq %rdx ; \ + pushq %rsi ; \ + pushq %rdi ; \ + pushq %r8 ; \ + pushq %r9 ; \ + pushq %r10 ; \ + pushq %r11 ; \ + pushq %r12 ; \ + pushq %r13 ; \ + pushq %r14 ; \ + pushq %r15 ; \ + +#define GPR_LOAD() \ + popq %r15 ; \ + popq %r14 ; \ + popq %r13 ; \ + popq %r12 ; \ + popq %r11 ; \ + popq %r10 ; \ + popq %r9 ; \ + popq %r8 ; \ + popq %rdi ; \ + popq %rsi ; \ + popq %rdx ; \ + popq %rcx ; \ + popq %rbx ; \ + popq %rax ; \ + popq %rbp ; + + +/* + The VMM puts us here with what looks like a long mode + interrupt dispatch, but it's from CPL 3 to CPL 3 and + it's not done as an interrupt injection per se, so + we can be interrupted, and deliverable interrupts + automatically prioritize over us. + + 48bitsblank | return SS (16 bits) + Return RSP + Return RFLAGS + 48bitsblank | return CS (16 bits) + Return RIP + ERROR CODE (HVM-specific non-zero number here) <- RSP on entry + + We then need simply to do this: + + save regs + call the handler (if installed) + restore regs + iret + +*/ + +.global __v3_hvm_ros_signal_handler_stub +__v3_hvm_ros_signal_handler_stub: + GPR_SAVE() + movabs __v3_hvm_ros_signal_handler, %rax + testq %rax, %rax + jz skip_handler + movq 120(%rsp), %rdi /* error code becomes argument */ + callq *%rax +skip_handler: + GPR_LOAD() + addq $8, %rsp /* nuke the error code */ + iretq +