| 1 |
#include <os.h> |
| 2 |
#include <arch_limits.h> |
| 3 |
#include <xen/arch-x86_64.h> |
| 4 |
|
| 5 |
/* For simplicity, we keep all of this into just one data page */ |
| 6 |
.data |
| 7 |
.globl _boot_page |
| 8 |
_boot_page: |
| 9 |
.align __PAGE_SIZE |
| 10 |
|
| 11 |
/* |
| 12 |
* The following data is initialized from C code |
| 13 |
*/ |
| 14 |
|
| 15 |
/* Pte of this page */ |
| 16 |
.globl _boot_page_entry |
| 17 |
_boot_page_entry: |
| 18 |
.quad 0 |
| 19 |
|
| 20 |
/* mmuext_op structure */ |
| 21 |
/* Set new page directory */ |
| 22 |
_boot_mmuext: |
| 23 |
/* Op # */ |
| 24 |
.long MMUEXT_NEW_BASEPTR |
| 25 |
.long 0 /* pad */ |
| 26 |
|
| 27 |
/* MFN of target page table directory */ |
| 28 |
.globl _boot_pdmfn |
| 29 |
_boot_pdmfn: |
| 30 |
.quad 0 |
| 31 |
|
| 32 |
/* Unused */ |
| 33 |
.quad 0 |
| 34 |
|
| 35 |
/* Unpin old page directory */ |
| 36 |
/* Op # */ |
| 37 |
.long MMUEXT_UNPIN_TABLE |
| 38 |
.long 0 /* pad */ |
| 39 |
|
| 40 |
/* MFN of old page table directory */ |
| 41 |
.globl _boot_oldpdmfn |
| 42 |
_boot_oldpdmfn: |
| 43 |
.quad 0 |
| 44 |
|
| 45 |
/* Unused */ |
| 46 |
.quad 0 |
| 47 |
|
| 48 |
/* Target stack address, also target virtual address of this page */ |
| 49 |
.globl _boot_stack |
| 50 |
_boot_stack: |
| 51 |
.quad 0 |
| 52 |
.globl _boot_target |
| 53 |
_boot_target: |
| 54 |
.quad 0 |
| 55 |
|
| 56 |
/* Target start info */ |
| 57 |
.globl _boot_start_info |
| 58 |
_boot_start_info: |
| 59 |
.quad 0 |
| 60 |
|
| 61 |
/* Target start address */ |
| 62 |
.globl _boot_start |
| 63 |
_boot_start: |
| 64 |
.quad 0 |
| 65 |
|
| 66 |
/* |
| 67 |
* Boot target OS, does not return |
| 68 |
*/ |
| 69 |
.globl _boot |
| 70 |
_boot: |
| 71 |
/* Project ourselves at the target place. */ |
| 72 |
movq _boot_target, %rdi |
| 73 |
movq _boot_page_entry, %rsi |
| 74 |
movq $2, %rdx /* UVMF_INVLPG */ |
| 75 |
movq $__HYPERVISOR_update_va_mapping, %rax |
| 76 |
syscall |
| 77 |
testq %rax, %rax |
| 78 |
jz 0f |
| 79 |
ud2 |
| 80 |
|
| 81 |
0: |
| 82 |
/* Go there. */ |
| 83 |
movq $(0f - _boot_page), %rax |
| 84 |
movq _boot_target, %rbx |
| 85 |
addq %rbx, %rax |
| 86 |
jmpq *%rax |
| 87 |
0: |
| 88 |
|
| 89 |
/* Load target page table and unpin old page table. */ |
| 90 |
/* We shouldn't have any problem since in the new page table our page is |
| 91 |
mapped at the same place. */ |
| 92 |
leaq _boot_mmuext(%rip), %rdi |
| 93 |
movq $2, %rsi |
| 94 |
xorq %rdx, %rdx |
| 95 |
movq $0x7FF0, %r10 /* DOMID_SELF */ |
| 96 |
movq $__HYPERVISOR_mmuext_op, %rax |
| 97 |
syscall |
| 98 |
testq %rax, %rax |
| 99 |
jns 0f |
| 100 |
ud2 |
| 101 |
|
| 102 |
0: |
| 103 |
/* Initialize registers. */ |
| 104 |
movq _boot_stack(%rip), %rsp |
| 105 |
movq _boot_start_info(%rip), %rsi |
| 106 |
|
| 107 |
/* Jump! */ |
| 108 |
jmpq *_boot_start(%rip) |