XenPVHMain.asm 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ;------------------------------------------------------------------------------
  2. ; @file
  3. ; An entry point use by Xen when a guest is started in PVH mode.
  4. ;
  5. ; Copyright (c) 2019, Citrix Systems, Inc.
  6. ;
  7. ; SPDX-License-Identifier: BSD-2-Clause-Patent
  8. ;
  9. ;------------------------------------------------------------------------------
  10. BITS 32
  11. xenPVHMain:
  12. ;
  13. ; 'BP' to indicate boot-strap processor
  14. ;
  15. mov di, 'BP'
  16. ;
  17. ; Store "Start of day" struct pointer for later use
  18. ;
  19. mov dword[PVH_SPACE (0)], ebx
  20. mov dword[PVH_SPACE (4)], 'XPVH'
  21. ;
  22. ; calculate delta between build-addr and run position
  23. ;
  24. mov esp, PVH_SPACE(16) ; create a temporary stack
  25. call .delta
  26. .delta:
  27. pop edx ; get addr of .delta
  28. sub edx, ADDR_OF(.delta) ; calculate delta
  29. ;
  30. ; Find address of GDT and gdtr and fix the later
  31. ;
  32. mov ebx, ADDR_OF(gdtr)
  33. add ebx, edx ; add delta gdtr
  34. mov eax, ADDR_OF(GDT_BASE)
  35. add eax, edx ; add delta to GDT_BASE
  36. mov dword[ebx + 2], eax ; fix GDT_BASE addr in gdtr
  37. lgdt [ebx]
  38. mov eax, SEC_DEFAULT_CR0
  39. mov cr0, eax
  40. ;
  41. ; push return addr to the stack, then return far
  42. ;
  43. push dword LINEAR_CODE_SEL ; segment to select
  44. mov eax, ADDR_OF(.jmpToNewCodeSeg) ; return addr
  45. add eax, edx ; add delta to return addr
  46. push eax
  47. retf
  48. .jmpToNewCodeSeg:
  49. mov eax, SEC_DEFAULT_CR4
  50. mov cr4, eax
  51. mov ax, LINEAR_SEL
  52. mov ds, ax
  53. mov es, ax
  54. mov fs, ax
  55. mov gs, ax
  56. mov ss, ax
  57. ;
  58. ; ESP will be used as initial value of the EAX register
  59. ; in Main.asm
  60. ;
  61. xor esp, esp
  62. ;
  63. ; parameter for Flat32SearchForBfvBase
  64. ;
  65. mov eax, 0 ; ADDR_OF(fourGigabytes)
  66. add eax, edx ; add delta
  67. ;
  68. ; Jump to the main routine of the pre-SEC code
  69. ; skiping the 16-bit part of the routine and
  70. ; into the 32-bit flat mode part
  71. ;
  72. OneTimeCallRet TransitionFromReal16To32BitFlat