An updated version of the load_unaligned_zeropad() fix.
v4:
- Allow unaligned MMIO access, but fail split page accesses;
- Explicit switch() in ve_instr_len() helper;
- Update comments;
v3:
- Rework load_unaligned_zeropad() fix: fail misaligned MMIO accesses
instead of upfront exception fixups;
- Add ve_instr_len() helper to wrap access to ve->instr_len;
- Add Reviewed-by from Sathya;
v2:
- Clarify RIP adjustments during #VE handling;
- Fix early #VE handling;
- Fix comment and commit message;
Kirill A. Shutemov (3):
x86/tdx: Fix early #VE handling
x86/tdx: Clarify RIP adjustments in #VE handler
x86/tdx: Handle load_unaligned_zeropad() page-cross to a shared page
arch/x86/coco/tdx/tdx.c | 187 +++++++++++++++++++++++++++++-----------
1 file changed, 136 insertions(+), 51 deletions(-)
--
2.35.1
Move RIP in tdx_early_handle_ve() after handling the exception. Failure
to do that leads to infinite loop of exceptions.
Signed-off-by: Kirill A. Shutemov <[email protected]>
Fixes: 32e72854fa5f ("x86/tdx: Port I/O: Add early boot support")
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
---
arch/x86/coco/tdx/tdx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 03deb4d6920d..faae53f8d559 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -447,13 +447,17 @@ static bool handle_io(struct pt_regs *regs, u32 exit_qual)
__init bool tdx_early_handle_ve(struct pt_regs *regs)
{
struct ve_info ve;
+ bool ret;
tdx_get_ve_info(&ve);
if (ve.exit_reason != EXIT_REASON_IO_INSTRUCTION)
return false;
- return handle_io(regs, ve.exit_qual);
+ ret = handle_io(regs, ve.exit_qual);
+ if (ret)
+ regs->ip += ve.instr_len;
+ return ret;
}
void tdx_get_ve_info(struct ve_info *ve)
--
2.35.1
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 60428d8bc27f52e8f1540f98e1b6ef0156d43f0d
Gitweb: https://git.kernel.org/tip/60428d8bc27f52e8f1540f98e1b6ef0156d43f0d
Author: Kirill A. Shutemov <[email protected]>
AuthorDate: Tue, 14 Jun 2022 15:01:33 +03:00
Committer: Dave Hansen <[email protected]>
CommitterDate: Wed, 15 Jun 2022 10:52:59 -07:00
x86/tdx: Fix early #VE handling
tdx_early_handle_ve() does not increment RIP after successfully
handling the exception. That leads to infinite loop of exceptions.
Move RIP when exceptions are successfully handled.
[ dhansen: make problem statement more clear ]
Fixes: 32e72854fa5f ("x86/tdx: Port I/O: Add early boot support")
Signed-off-by: Kirill A. Shutemov <[email protected]>
Signed-off-by: Dave Hansen <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
arch/x86/coco/tdx/tdx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 03deb4d..faae53f 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -447,13 +447,17 @@ static bool handle_io(struct pt_regs *regs, u32 exit_qual)
__init bool tdx_early_handle_ve(struct pt_regs *regs)
{
struct ve_info ve;
+ bool ret;
tdx_get_ve_info(&ve);
if (ve.exit_reason != EXIT_REASON_IO_INSTRUCTION)
return false;
- return handle_io(regs, ve.exit_qual);
+ ret = handle_io(regs, ve.exit_qual);
+ if (ret)
+ regs->ip += ve.instr_len;
+ return ret;
}
void tdx_get_ve_info(struct ve_info *ve)