Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
x86/tdx: Add HLT support for TDX guests
The HLT instruction is a privileged instruction, executing it stops instruction execution and places the processor in a HALT state. It is used in kernel for cases like reboot, idle loop and exception fixup handlers. For the idle case, interrupts will be enabled (using STI) before the HLT instruction (this is also called safe_halt()). To support the HLT instruction in TDX guests, it needs to be emulated using TDVMCALL (hypercall to VMM). More details about it can be found in Intel Trust Domain Extensions (Intel TDX) Guest-Host-Communication Interface (GHCI) specification, section TDVMCALL[Instruction.HLT]. Any of the following three approaches can be used to emulate the HLT instruction: 1. Using PV ops. 2. Using #VE exception handler (In TDX guest, executing HLT will lead to #VE exception). 3. Direct substitution of TDVMCALLs in places where emulation is required. Regarding option #1, since emulation of hlt() and safe_halt() is not similar, and PV ops provides different hooks to emulate halt() and safe_halt() variants, it is the simplest solution available. But, currently halt and safe_halt hooks only exist under the CONFIG_PARAVIRT_XXL option, and enabling it for TDX guests will bring in a lot more than just the halt hooks. Hence, although this option is the simplest, it is not cost effective. Option #2 is also not preferred because, in the exception handler safe_halt() and normal halt() use cases cannot be differentiated. This differentiation is needed to add STI before the hypercall for the safe_halt() use case. In option #3, *halt() and *safe_halt() use cases will be substituted with TDX variants (like tdx_halt() or tdx_safe_halt()). In the kernel, TDX guest cares about only around 6 references of halt calls (specifically in reboot, exception support and smpboot code handlers). Direct replacement of these 6 *halt* calls with corresponding TDX variants (using alternative_call) is the best option because it is simpler and it will also make the code faster in both TDX and non TDX cases. Reviewed-by: Andi Kleen <ak@linux.intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
- Loading branch information
Kuppuswamy Sathyanarayanan
committed
Nov 23, 2021
1 parent
3d380b9
commit e565a4318c87e3d1243bb31b89c53aff081472c5
Showing
8 changed files
with
115 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters