Skip to content

x86/fred: Fix two problems during the FRED initialization

Hou Wenlong lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 16 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2x86/fred: Always install system interrupt handler into IDTarch/x86/include/asm/idtentry.h+1 -211 replies
2/2x86/fred: Add a page fault entry stub for FREDarch/x86/entry/entry_fred.c arch/x86/include/asm/idtentry.h arch/x86/mm/fault.c+28 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] x86/fred: Fix two problems during the FRED initialization

When I reviewed the FRED code and attempted to implement a FRED-like event delivery for my PV guest, I encountered two problems which I may have misunderstood.

One issue is that FRED can be disabled in trap_init(), but sysvec_install() can be called before trap_init(), thus the system interrupt handler is not installed into the IDT if FRED is disabled later. Initially, I attempted to parse the cmdline and decide whether to enable or disable FRED after parse_early_param(). However, I ultimately chose to always install the system handler into the IDT in sysvec_install(), which is simple and should be sufficient.

Another problem is that the page fault handler (exc_page_fault()) is installed into the IDT before FRED is enabled. Consequently, if a #PF is triggered in this gap, the handler would receive the wrong CR2 from the stack if FRED feature is present. To address this, I added a page fault entry stub for FRED similar to the debug entry. However, I'm uncertain whether this is enough reason to add a new entry. Perhaps a static key may suffice to indicate whether FRED setup is completed and the handler can use it.

Note: I didn't test them on the Intel emulator, as I'm not familiar with configuring it to boot with my compiled kernel.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Xin Li <[email protected]>
Cc Jacob Pan <[email protected]>
Cc Rick Edgecombe <[email protected]>
Cc Paolo Bonzini <[email protected]>

Hou Wenlong (2):
x86/fred: Always install system interrupt handler into IDT x86/fred: Add a page fault entry stub for FRED

 arch/x86/entry/entry_fred.c     |  2 +-
 arch/x86/include/asm/idtentry.h | 15 +++++++++++++--
 arch/x86/mm/fault.c             | 19 +++++++++++++++----
 3 files changed, 29 insertions(+), 7 deletions(-)

--
2.31.1