VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/TdxDxe/X64/ApRunLoop.nasm

Last change on this file was 105670, checked in by vboxsync, 3 months ago

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-asm
File size: 3.0 KB
Line 
1;------------------------------------------------------------------------------ ;
2; Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
3; SPDX-License-Identifier: BSD-2-Clause-Patent
4;
5; Module Name:
6;
7; ApRunLoop.nasm
8;
9; Abstract:
10;
11; This is the assembly code for run loop for APs in the guest TD
12;
13;-------------------------------------------------------------------------------
14
15%include "TdxCommondefs.inc"
16
17DEFAULT REL
18
19SECTION .text
20
21BITS 64
22
23%define TDVMCALL_EXPOSE_REGS_MASK 0xffcc
24%define TDVMCALL 0x0
25%define EXIT_REASON_CPUID 0xa
26
27%macro tdcall 0
28 db 0x66, 0x0f, 0x01, 0xcc
29%endmacro
30
31%macro tdcall_regs_preamble 2
32 mov rax, %1
33
34 xor rcx, rcx
35 mov ecx, %2
36
37 ; R10 = 0 (standard TDVMCALL)
38
39 xor r10d, r10d
40
41 ; Zero out unused (for standard TDVMCALL) registers to avoid leaking
42 ; secrets to the VMM.
43
44 xor esi, esi
45 xor edi, edi
46
47 xor edx, edx
48 xor ebp, ebp
49 xor r8d, r8d
50 xor r9d, r9d
51 xor r14, r14
52 xor r15, r15
53%endmacro
54
55;
56; Relocated Ap Mailbox loop
57;
58; @param[in] RBX: Relocated mailbox address
59; @param[in] RBP: vCpuId
60;
61; @return None This routine does not return
62;
63global ASM_PFX(AsmRelocateApMailBoxLoop)
64ASM_PFX(AsmRelocateApMailBoxLoop):
65AsmRelocateApMailBoxLoopStart:
66
67 mov r11, EXIT_REASON_CPUID
68 mov r12, 0xb
69 tdcall_regs_preamble TDVMCALL, TDVMCALL_EXPOSE_REGS_MASK
70 tdcall
71 test r10, r10
72 jnz Panic
73 mov r8, r15
74
75MailBoxLoop:
76 ; Spin until command set
77 cmp dword [rbx + CommandOffset], MpProtectedModeWakeupCommandNoop
78 je MailBoxLoop
79 ; Determine if this is a broadcast or directly for my apic-id, if not, ignore
80 cmp dword [rbx + ApicidOffset], MailboxApicidBroadcast
81 je MailBoxProcessCommand
82 cmp dword [rbx + ApicidOffset], r8d
83 jne MailBoxLoop
84MailBoxProcessCommand:
85 cmp dword [rbx + CommandOffset], MpProtectedModeWakeupCommandWakeup
86 je MailBoxWakeUp
87 cmp dword [rbx + CommandOffset], MpProtectedModeWakeupCommandSleep
88 je MailBoxSleep
89 ; Don't support this command, so ignore
90 jmp MailBoxLoop
91MailBoxWakeUp:
92 mov rax, [rbx + WakeupVectorOffset]
93 ; OS sends a wakeup command for a given APIC ID, firmware is supposed to reset
94 ; the command field back to zero as acknowledgement.
95 mov qword [rbx + CommandOffset], 0
96 jmp rax
97MailBoxSleep:
98 jmp $
99Panic:
100 ud2
101BITS 64
102AsmRelocateApMailBoxLoopEnd:
103
104;-------------------------------------------------------------------------------------
105; AsmGetRelocationMap (&RelocationMap);
106;-------------------------------------------------------------------------------------
107global ASM_PFX(AsmGetRelocationMap)
108ASM_PFX(AsmGetRelocationMap):
109 lea rax, [AsmRelocateApMailBoxLoopStart]
110 mov qword [rcx], rax
111 mov qword [rcx + 8h], AsmRelocateApMailBoxLoopEnd - AsmRelocateApMailBoxLoopStart
112 ret
113
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette