-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confirm noinline produces the right asm for saving register state #565
Comments
(Migrated internal issue #1266. Also covers internal issue #1260 which is a duplicate.) yjiang5 on Oct 30: I checked the binary built out and it's working. One minor concern is, if the not-used output operand may have potential issue in future since gcc does not have explicit definition on such situation, but at least the build out binary is correct. |
The code: #define TDCALL_ASM ".byte 0x66,0x0f,0x01,0xcc" /* TODO TDX: Confirm noinline produces the right asm for saving register state */
...
|
Discussed with @yamahata. His comment: @peterfang do you have any suggestion? |
From another discussion with @yamahata: @peterfang please confirm if TDX modifies RBP in TDG.VP.ENTER |
The function seems over complicated. I guess inline assembly and specifying register are for optimization. We should drop noinline, inline assebmly, asm("regname"). And introduce .S file to write small assembly code to call TDCALL. Probably its signature is somethign like u64 tdg_vp_enter_asm(tdx_exit_info). mshv_vtl_return_tdx() should just call tdg_vp_enter_asm(). The overhead of one function call is negligible because of the TDG call and acessing MSR. Then the ugly code will be gone.
This applies to the following issues. |
RBP isn't preserved with TDG.VP.ENTER. 5.5.15. TDG.VP.ENTER Leaf
please note that some registers are implicitly preserved as VMX guest register state. |
@yamahata That section seems to imply any register can be modified in TDG.VP.ENTER. Does it explicitly mention anywhere which registers are preserved and which are not? The inline assembly code is only preserving RBP, so is it currently assumed that everything other than RBP is preserved? |
RBP is NOT preserved. The figure states on L2->L1 VM Exit, the tdx module restores the L1 VCPU states with VMRESUME with L1 vCPU RIP advanced. The following fields in the guest-state area correspond to processor registers: For L0 TDH.VP.ENTER RBP preserving, TDX module enhancement is needed to save/restore L0 vCPU RBP. |
I can also confirm that the TDX module does not preserve RBP in TDG.VP.ENTER |
Yes, that would be good. Shouldn't it be normal expectation for the host to be not concerned of its state getting altered in VP.ENTER? Otherwise, we would need to know exactly what to save and restore, not just RBP. If this is not the case, I am not sure how even moving the code to a separate .S assembly file will help, unless we can be sure that the stack frame will preserve all state that can get altered. |
In drivers/hv/mshv_vtl_main.c: mshv_vtl_return_tdx()
17605 +/* TODO TDX: Confirm noinline produces the right asm for saving register
state */
17606 +noinline static void mshv_vtl_return_tdx(void)
The text was updated successfully, but these errors were encountered: