Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x86/tdx: Use direct paravirt call for wrmsrl
TDX normally handles MSR writes using the #VE exception, or directly for some special MSRs. But there is at least one performance critical MSR which triggers #VE, which is the TSC deadline MSR. It gets reprogrammed every timer interrupt, and also every idle exit. There are noticeable slow downs by relying on #VE for this, since a #VE requires at least 3 exits to the TDX module, which adds up in overhead. Use a direct paravirt call for MSR writes. This will only be used for wrmsrl(), some of the other MSR write paths still use #VE (but these don't seem to be performance critical, so it shouldn't matter) There is one complication that TDX has both context switched MSRs (which always need to use WRMSR) and host supported MSRs (which need to use TDCALL). Unfortunately the list of both is quite long and it would be difficult to maintain a switch statement to distinguish them. For most MSRs it doesn't really matter if there is an extra VE exception or not because they are not performance critical. But it's important for a few critical ones like TSC_DEADLINE, which needs to use TDCALL. So enable the TDCALL fast path only for TSC_DEADLINE and keep using WRMSR for all the others, which may or may not result in an extra VE exception. If there are other performance critical host controlled MSRs it can be added to the switch statement here later. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
- Loading branch information