From: "tip-bot2 for Gerd Hoffmann" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
Pankaj Gupta <pankaj.gupta@amd.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/sev] x86/sev/vc: Fix EFI runtime instruction emulation
Date: Fri, 27 Jun 2025 12:30:42 -0000 [thread overview]
Message-ID: <175102744208.406.15035701661646196374.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250626114014.373748-2-kraxel@redhat.com>
The following commit has been merged into the x86/sev branch of tip:
Commit-ID: 7b22e0432981c2fa230f1b493082b7e67112c4aa
Gitweb: https://git.kernel.org/tip/7b22e0432981c2fa230f1b493082b7e67112c4aa
Author: Gerd Hoffmann <kraxel@redhat.com>
AuthorDate: Thu, 26 Jun 2025 13:40:11 +02:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 27 Jun 2025 13:53:12 +02:00
x86/sev/vc: Fix EFI runtime instruction emulation
In case efi_mm is active go use the userspace instruction decoder which
supports fetching instructions from active_mm. This is needed to make
instruction emulation work for EFI runtime code, so it can use CPUID and
RDMSR.
EFI runtime code uses the CPUID instruction to gather information about
the environment it is running in, such as SEV being enabled or not, and
choose (if needed) the SEV code path for ioport access.
EFI runtime code uses the RDMSR instruction to get the location of the
CAA page (see SVSM spec, section 4.2 - "Post Boot").
The big picture behind this is that the kernel needs to be able to
properly handle #VC exceptions that come from EFI runtime services.
Since EFI runtime services have a special page table mapping for the EFI
virtual address space, the efi_mm context must be used when decoding
instructions during #VC handling.
[ bp: Massage. ]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Link: https://lore.kernel.org/20250626114014.373748-2-kraxel@redhat.com
---
arch/x86/coco/sev/vc-handle.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/x86/coco/sev/vc-handle.c b/arch/x86/coco/sev/vc-handle.c
index 0989d98..faf1fce 100644
--- a/arch/x86/coco/sev/vc-handle.c
+++ b/arch/x86/coco/sev/vc-handle.c
@@ -17,6 +17,7 @@
#include <linux/mm.h>
#include <linux/io.h>
#include <linux/psp-sev.h>
+#include <linux/efi.h>
#include <uapi/linux/sev-guest.h>
#include <asm/init.h>
@@ -178,9 +179,15 @@ static enum es_result __vc_decode_kern_insn(struct es_em_ctxt *ctxt)
return ES_OK;
}
+/*
+ * User instruction decoding is also required for the EFI runtime. Even though
+ * the EFI runtime is running in kernel mode, it uses special EFI virtual
+ * address mappings that require the use of efi_mm to properly address and
+ * decode.
+ */
static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt)
{
- if (user_mode(ctxt->regs))
+ if (user_mode(ctxt->regs) || mm_is_efi(current->active_mm))
return __vc_decode_user_insn(ctxt);
else
return __vc_decode_kern_insn(ctxt);
next prev parent reply other threads:[~2025-06-27 12:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250626114014.373748-1-kraxel@redhat.com>
2025-06-26 11:40 ` [PATCH v4 1/3] x86/sev/vc: fix efi " Gerd Hoffmann
2025-06-27 8:33 ` Gupta, Pankaj
2025-06-27 12:30 ` tip-bot2 for Gerd Hoffmann [this message]
2025-06-26 11:40 ` [PATCH v4 2/3] x86/sev: fix error handling in sev_es_efi_map_ghcbs_caas() Gerd Hoffmann
2025-06-27 12:01 ` Borislav Petkov
2025-06-26 11:40 ` [PATCH v4 3/3] x86/sev: Let sev_es_efi_map_ghcbs() map the caa pages too Gerd Hoffmann
2025-06-27 12:30 ` [tip: x86/sev] x86/sev: Let sev_es_efi_map_ghcbs() map the CA " tip-bot2 for Gerd Hoffmann
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=175102744208.406.15035701661646196374.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@alien8.de \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=pankaj.gupta@amd.com \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®