Skip to content

Commit a777e41

Browse files
committed
x86/sev: Make sure pages are not skipped during kdump
JIRA: https://issues.redhat.com/browse/RHEL-10019 commit 82b7f88 Author: Ashish Kalra <ashish.kalra@amd.com> Date: Tue May 6 18:35:29 2025 +0000 x86/sev: Make sure pages are not skipped during kdump When shared pages are being converted to private during kdump, additional checks are performed. They include handling the case of a GHCB page being contained within a huge page. Currently, this check incorrectly skips a page just below the GHCB page from being transitioned back to private during kdump preparation. This skipped page causes a 0x404 #VC exception when it is accessed later while dumping guest memory for vmcore generation. Correct the range to be checked for GHCB contained in a huge page. Also, ensure that the skipped huge page containing the GHCB page is transitioned back to private by applying the correct address mask later when changing GHCBs to private at end of kdump preparation. [ bp: Massage commit message. ] Fixes: 3074152 ("x86/sev: Convert shared memory back to private on kexec") Signed-off-by: Ashish Kalra <ashish.kalra@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Tested-by: Srikanth Aithal <sraithal@amd.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/20250506183529.289549-1-Ashish.Kalra@amd.com Signed-off-by: Bandan Das <bsd@redhat.com>
1 parent 4ba21ea commit a777e41

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

arch/x86/coco/sev/core.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,8 @@ static void unshare_all_memory(void)
11521152
data = per_cpu(runtime_data, cpu);
11531153
ghcb = (unsigned long)&data->ghcb_page;
11541154

1155-
if (addr <= ghcb && ghcb <= addr + size) {
1155+
/* Handle the case of a huge page containing the GHCB page */
1156+
if (addr <= ghcb && ghcb < addr + size) {
11561157
skipped_addr = true;
11571158
break;
11581159
}
@@ -1264,8 +1265,8 @@ static void shutdown_all_aps(void)
12641265
void snp_kexec_finish(void)
12651266
{
12661267
struct sev_es_runtime_data *data;
1268+
unsigned long size, addr;
12671269
unsigned int level, cpu;
1268-
unsigned long size;
12691270
struct ghcb *ghcb;
12701271
pte_t *pte;
12711272

@@ -1293,8 +1294,10 @@ void snp_kexec_finish(void)
12931294
ghcb = &data->ghcb_page;
12941295
pte = lookup_address((unsigned long)ghcb, &level);
12951296
size = page_level_size(level);
1296-
set_pte_enc(pte, level, (void *)ghcb);
1297-
snp_set_memory_private((unsigned long)ghcb, (size / PAGE_SIZE));
1297+
/* Handle the case of a huge page containing the GHCB page */
1298+
addr = (unsigned long)ghcb & page_level_mask(level);
1299+
set_pte_enc(pte, level, (void *)addr);
1300+
snp_set_memory_private(addr, (size / PAGE_SIZE));
12981301
}
12991302
}
13001303

0 commit comments

Comments
 (0)