|
|
3ce5e9 |
From b584eb81ff27e42547d01c521b488aaeaa35b460 Mon Sep 17 00:00:00 2001
|
|
|
3ce5e9 |
From: Lianbo Jiang <lijiang@redhat.com>
|
|
|
3ce5e9 |
Date: Thu, 28 Jul 2022 15:11:20 +0800
|
|
|
3ce5e9 |
Subject: [PATCH 14/28] x86_64: Fix for AMD SME issue
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
Kernel commit changes(see [1]/[2]) may cause the failure of crash-utility
|
|
|
3ce5e9 |
with the following error:
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
#./crash /home/vmlinux /home/vmcore
|
|
|
3ce5e9 |
...
|
|
|
3ce5e9 |
For help, type "help".
|
|
|
3ce5e9 |
Type "apropos word" to search for commands related to "word"...
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
crash: seek error: physical address: 8000760a14000 type: "p4d page"
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
Let's get the "NUMBER(sme_mask)" from vmcoreinfo, and try to remove
|
|
|
3ce5e9 |
the C-bit from the page table entries, the intention is to get the
|
|
|
3ce5e9 |
true physical address.
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
Related kernel commits:
|
|
|
3ce5e9 |
[1] aad983913d77 ("x86/mm/encrypt: Simplify sme_populate_pgd() and sme_populate_pgd_large()")
|
|
|
3ce5e9 |
[2] e7d445ab26db ("x86/sme: Use #define USE_EARLY_PGTABLE_L5 in mem_encrypt_identity.c")
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
|
|
3ce5e9 |
---
|
|
|
3ce5e9 |
defs.h | 1 +
|
|
|
3ce5e9 |
x86_64.c | 21 ++++++++++++++++++---
|
|
|
3ce5e9 |
2 files changed, 19 insertions(+), 3 deletions(-)
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
diff --git a/defs.h b/defs.h
|
|
|
3ce5e9 |
index 6a1b6f8a16a8..f8fbfdfd1152 100644
|
|
|
3ce5e9 |
--- a/defs.h
|
|
|
3ce5e9 |
+++ b/defs.h
|
|
|
3ce5e9 |
@@ -6206,6 +6206,7 @@ struct machine_specific {
|
|
|
3ce5e9 |
ulong cpu_entry_area_end;
|
|
|
3ce5e9 |
ulong page_offset_force;
|
|
|
3ce5e9 |
char **exception_functions;
|
|
|
3ce5e9 |
+ ulong sme_mask;
|
|
|
3ce5e9 |
};
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
#define KSYMS_START (0x1)
|
|
|
3ce5e9 |
diff --git a/x86_64.c b/x86_64.c
|
|
|
3ce5e9 |
index f4e5d9e77cef..b2a536e4b19c 100644
|
|
|
3ce5e9 |
--- a/x86_64.c
|
|
|
3ce5e9 |
+++ b/x86_64.c
|
|
|
3ce5e9 |
@@ -206,6 +206,10 @@ x86_64_init(int when)
|
|
|
3ce5e9 |
machdep->machspec->kernel_image_size = dtol(string, QUIET, NULL);
|
|
|
3ce5e9 |
free(string);
|
|
|
3ce5e9 |
}
|
|
|
3ce5e9 |
+ if ((string = pc->read_vmcoreinfo("NUMBER(sme_mask)"))) {
|
|
|
3ce5e9 |
+ machdep->machspec->sme_mask = dtol(string, QUIET, NULL);
|
|
|
3ce5e9 |
+ free(string);
|
|
|
3ce5e9 |
+ }
|
|
|
3ce5e9 |
if (SADUMP_DUMPFILE() || QEMU_MEM_DUMP_NO_VMCOREINFO() ||
|
|
|
3ce5e9 |
VMSS_DUMPFILE())
|
|
|
3ce5e9 |
/* Need for calculation of kaslr_offset and phys_base */
|
|
|
3ce5e9 |
@@ -937,6 +941,7 @@ x86_64_dump_machdep_table(ulong arg)
|
|
|
3ce5e9 |
ms->kernel_image_size/MEGABYTES(1));
|
|
|
3ce5e9 |
else
|
|
|
3ce5e9 |
fprintf(fp, "(uninitialized)\n");
|
|
|
3ce5e9 |
+ fprintf(fp, " sme_mask: %lx\n", ms->sme_mask);
|
|
|
3ce5e9 |
fprintf(fp, " physical_mask_shift: %ld\n", ms->physical_mask_shift);
|
|
|
3ce5e9 |
fprintf(fp, " pgdir_shift: %ld\n", ms->pgdir_shift);
|
|
|
3ce5e9 |
fprintf(fp, " GART_start: %lx\n", ms->GART_start);
|
|
|
3ce5e9 |
@@ -1814,7 +1819,7 @@ x86_64_kpgd_offset(ulong kvaddr, int verbose, int IS_XEN)
|
|
|
3ce5e9 |
if (IS_XEN)
|
|
|
3ce5e9 |
fprintf(fp, "PAGE DIRECTORY: %lx [machine]\n", *pgd);
|
|
|
3ce5e9 |
else
|
|
|
3ce5e9 |
- fprintf(fp, "PAGE DIRECTORY: %lx\n", *pgd);
|
|
|
3ce5e9 |
+ fprintf(fp, "PAGE DIRECTORY: %lx\n", *pgd & ~machdep->machspec->sme_mask);
|
|
|
3ce5e9 |
}
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
return pgd;
|
|
|
3ce5e9 |
@@ -1851,7 +1856,8 @@ x86_64_upgd_offset_legacy(struct task_context *tc, ulong uvaddr, int verbose, in
|
|
|
3ce5e9 |
if (IS_XEN)
|
|
|
3ce5e9 |
fprintf(fp, " PGD: %lx => %lx [machine]\n", (ulong)pud, pud_pte);
|
|
|
3ce5e9 |
else
|
|
|
3ce5e9 |
- fprintf(fp, " PGD: %lx => %lx\n", (ulong)pud, pud_pte);
|
|
|
3ce5e9 |
+ fprintf(fp, " PGD: %lx => %lx\n",
|
|
|
3ce5e9 |
+ (ulong)pud, pud_pte & ~machdep->machspec->sme_mask);
|
|
|
3ce5e9 |
}
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
return pud_pte;
|
|
|
3ce5e9 |
@@ -1882,7 +1888,8 @@ x86_64_upgd_offset(struct task_context *tc, ulong uvaddr, int verbose, int IS_XE
|
|
|
3ce5e9 |
if (IS_XEN)
|
|
|
3ce5e9 |
fprintf(fp, " PGD: %lx => %lx [machine]\n", (ulong)pgd, pgd_pte);
|
|
|
3ce5e9 |
else
|
|
|
3ce5e9 |
- fprintf(fp, " PGD: %lx => %lx\n", (ulong)pgd, pgd_pte);
|
|
|
3ce5e9 |
+ fprintf(fp, " PGD: %lx => %lx\n",
|
|
|
3ce5e9 |
+ (ulong)pgd, pgd_pte & ~machdep->machspec->sme_mask);
|
|
|
3ce5e9 |
}
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
return pgd_pte;
|
|
|
3ce5e9 |
@@ -1900,9 +1907,11 @@ x86_64_p4d_offset(ulong pgd_pte, ulong vaddr, int verbose, int IS_XEN)
|
|
|
3ce5e9 |
ulong p4d_pte;
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
p4d_paddr = pgd_pte & PHYSICAL_PAGE_MASK;
|
|
|
3ce5e9 |
+ p4d_paddr &= ~machdep->machspec->sme_mask;
|
|
|
3ce5e9 |
FILL_P4D(p4d_paddr, PHYSADDR, PAGESIZE());
|
|
|
3ce5e9 |
p4d = ((ulong *)p4d_paddr) + p4d_index(vaddr);
|
|
|
3ce5e9 |
p4d_pte = ULONG(machdep->machspec->p4d + PAGEOFFSET(p4d));
|
|
|
3ce5e9 |
+ p4d_pte &= ~machdep->machspec->sme_mask;
|
|
|
3ce5e9 |
if (verbose) {
|
|
|
3ce5e9 |
if (IS_XEN)
|
|
|
3ce5e9 |
fprintf(fp, " P4D: %lx => %lx [machine]\n", (ulong)p4d, p4d_pte);
|
|
|
3ce5e9 |
@@ -1925,6 +1934,7 @@ x86_64_pud_offset(ulong pgd_pte, ulong vaddr, int verbose, int IS_XEN)
|
|
|
3ce5e9 |
ulong pud_pte;
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
pud_paddr = pgd_pte & PHYSICAL_PAGE_MASK;
|
|
|
3ce5e9 |
+ pud_paddr &= ~machdep->machspec->sme_mask;
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
if (IS_XEN) {
|
|
|
3ce5e9 |
pud_paddr = xen_m2p(pud_paddr);
|
|
|
3ce5e9 |
@@ -1935,6 +1945,7 @@ x86_64_pud_offset(ulong pgd_pte, ulong vaddr, int verbose, int IS_XEN)
|
|
|
3ce5e9 |
FILL_PUD(pud_paddr, PHYSADDR, PAGESIZE());
|
|
|
3ce5e9 |
pud = ((ulong *)pud_paddr) + pud_index(vaddr);
|
|
|
3ce5e9 |
pud_pte = ULONG(machdep->pud + PAGEOFFSET(pud));
|
|
|
3ce5e9 |
+ pud_pte &= ~machdep->machspec->sme_mask;
|
|
|
3ce5e9 |
if (verbose) {
|
|
|
3ce5e9 |
if (IS_XEN)
|
|
|
3ce5e9 |
fprintf(fp, " PUD: %lx => %lx [machine]\n", (ulong)pud, pud_pte);
|
|
|
3ce5e9 |
@@ -1957,6 +1968,7 @@ x86_64_pmd_offset(ulong pud_pte, ulong vaddr, int verbose, int IS_XEN)
|
|
|
3ce5e9 |
ulong pmd_pte;
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
pmd_paddr = pud_pte & PHYSICAL_PAGE_MASK;
|
|
|
3ce5e9 |
+ pmd_paddr &= ~machdep->machspec->sme_mask;
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
if (IS_XEN) {
|
|
|
3ce5e9 |
pmd_paddr = xen_m2p(pmd_paddr);
|
|
|
3ce5e9 |
@@ -1967,6 +1979,7 @@ x86_64_pmd_offset(ulong pud_pte, ulong vaddr, int verbose, int IS_XEN)
|
|
|
3ce5e9 |
FILL_PMD(pmd_paddr, PHYSADDR, PAGESIZE());
|
|
|
3ce5e9 |
pmd = ((ulong *)pmd_paddr) + pmd_index(vaddr);
|
|
|
3ce5e9 |
pmd_pte = ULONG(machdep->pmd + PAGEOFFSET(pmd));
|
|
|
3ce5e9 |
+ pmd_pte &= ~machdep->machspec->sme_mask;
|
|
|
3ce5e9 |
if (verbose) {
|
|
|
3ce5e9 |
if (IS_XEN)
|
|
|
3ce5e9 |
fprintf(fp, " PMD: %lx => %lx [machine]\n", (ulong)pmd, pmd_pte);
|
|
|
3ce5e9 |
@@ -1988,6 +2001,7 @@ x86_64_pte_offset(ulong pmd_pte, ulong vaddr, int verbose, int IS_XEN)
|
|
|
3ce5e9 |
ulong pte;
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
pte_paddr = pmd_pte & PHYSICAL_PAGE_MASK;
|
|
|
3ce5e9 |
+ pte_paddr &= ~machdep->machspec->sme_mask;
|
|
|
3ce5e9 |
|
|
|
3ce5e9 |
if (IS_XEN) {
|
|
|
3ce5e9 |
pte_paddr = xen_m2p(pte_paddr);
|
|
|
3ce5e9 |
@@ -1998,6 +2012,7 @@ x86_64_pte_offset(ulong pmd_pte, ulong vaddr, int verbose, int IS_XEN)
|
|
|
3ce5e9 |
FILL_PTBL(pte_paddr, PHYSADDR, PAGESIZE());
|
|
|
3ce5e9 |
ptep = ((ulong *)pte_paddr) + pte_index(vaddr);
|
|
|
3ce5e9 |
pte = ULONG(machdep->ptbl + PAGEOFFSET(ptep));
|
|
|
3ce5e9 |
+ pte &= ~machdep->machspec->sme_mask;
|
|
|
3ce5e9 |
if (verbose) {
|
|
|
3ce5e9 |
if (IS_XEN)
|
|
|
3ce5e9 |
fprintf(fp, " PTE: %lx => %lx [machine]\n", (ulong)ptep, pte);
|
|
|
3ce5e9 |
--
|
|
|
3ce5e9 |
2.37.1
|
|
|
3ce5e9 |
|