public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Hou Wenlong" <houwenlong.hwl@antgroup.com>
To: linux-kernel@vger.kernel.org
Cc: "Lai Jiangshan" <jiangshan.ljs@antgroup.com>,
	"Hou Wenlong" <houwenlong.hwl@antgroup.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>, <x86@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, "Xin Li" <xin3.li@intel.com>,
	"Jacob Pan" <jacob.jun.pan@linux.intel.com>,
	"Rick Edgecombe" <rick.p.edgecombe@intel.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH 0/2] x86/fred: Fix two problems during the FRED initialization
Date: Fri, 21 Jun 2024 21:12:00 +0800	[thread overview]
Message-ID: <cover.1718972598.git.houwenlong.hwl@antgroup.com> (raw)

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 <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Xin Li <xin3.li@intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>

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


             reply	other threads:[~2024-06-21 13:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-21 13:12 Hou Wenlong [this message]
2024-06-21 13:12 ` [PATCH 1/2] x86/fred: Always install system interrupt handler into IDT Hou Wenlong
2024-06-25  9:19   ` Xin Li
2024-06-25 12:31     ` Thomas Gleixner
2024-06-25 16:30       ` Xin Li
2024-06-25 17:01         ` Thomas Gleixner
2024-06-25 17:08           ` Li, Xin3
2024-06-25 17:11             ` Thomas Gleixner
2024-06-28  9:36     ` Hou Wenlong
2024-06-28 15:18       ` Xin Li
2024-07-02 17:16         ` Xin Li
2024-07-03  2:44           ` Hou Wenlong
2024-07-03  3:42             ` Xin Li
2024-06-21 13:12 ` [PATCH 2/2] x86/fred: Add a page fault entry stub for FRED Hou Wenlong
2024-06-22  0:31 ` [PATCH 0/2] x86/fred: Fix two problems during the FRED initialization Xin Li
2024-06-24  6:21   ` Hou Wenlong
2024-06-25  9:09     ` Xin Li
2024-06-25 17:24       ` H. Peter Anvin
2024-06-25 17:31         ` Xin Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1718972598.git.houwenlong.hwl@antgroup.com \
    --to=houwenlong.hwl@antgroup.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jiangshan.ljs@antgroup.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xin3.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox