Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iomap: Add support for indirect MMIO
In TDX MMIO is normally done by catching a #VE exception and then emulating the MMIO. This needs at least two VM exits and entries, which can slow them down significantly. For near all it doesn't matter because they are not performance critical, but it can hurt for the virtio mailbox write that is in the critical path of most IO operations. It is possible to avoid the extra exit by calling the MMIO TDCALL directly, but that would need hooking into every writel() at least. Currently writel is just a single mov instruction, changing it to a function call would affect code size in all drivers. It would be quite wasteful because TDX only needs it for very few drivers (only virtio currently, and possibly a small number later) Luckily virtio is using iomap to access its MMIO and the iomap iowrite* functions are already out of line. So it's possible to add hooks into them without impacting any code size. MMIO is already quite slow, since it's uncached, so adding an extra if to it is not a big deal. This patch adds the infrastructure that an architecture can hook into mmio accesses using an indirect call vector for iomap only. This is only enabled if the architecture opts in and actually fills out the indirect call vector. This will be used in a followon patch to let TDX hook in optimized functions for iommap MMIO. When the indirect pointer is not filled in the MMIO accesses still go direct. The implementation is for all read/write[bwlq]. The TDX virtio optimization currently only really needs it for writel, but with the infrastructure it's simple and cheap to do it for all. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
- Loading branch information
Showing
3 changed files
with
104 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -711,6 +711,9 @@ endmenu | |
config GENERIC_IOREMAP | ||
bool | ||
|
||
config IOMAP_IND_MMIO | ||
bool | ||
|
||
config GENERIC_LIB_ASHLDI3 | ||
bool | ||
|
||
|
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