|
|
bedde7 |
Delivered-To: bhsharma@gapps.redhat.com
|
|
|
bedde7 |
Received: by 2002:a2e:e0a:0:0:0:0:0 with SMTP id 10csp381404ljo;
|
|
|
bedde7 |
Fri, 21 Jun 2019 02:43:25 -0700 (PDT)
|
|
|
bedde7 |
X-Google-Smtp-Source: APXvYqzT5Jnctz0U7KDu97glThU9nNU8uoBaTPDtgGoLDaTrBerwj871GlRx1br1kO3Xi9egk5Ga
|
|
|
bedde7 |
X-Received: by 2002:a0c:d0fc:: with SMTP id b57mr43991751qvh.78.1561110205383;
|
|
|
bedde7 |
Fri, 21 Jun 2019 02:43:25 -0700 (PDT)
|
|
|
bedde7 |
ARC-Seal: i=1; a=rsa-sha256; t=1561110205; cv=none;
|
|
|
bedde7 |
d=google.com; s=arc-20160816;
|
|
|
bedde7 |
b=UGnWY4xATAi/VC/zo6DWbisWbInCXQEb7saZdCpdFg6DjOXNGTGy8OoGOrKaF2an1F
|
|
|
bedde7 |
/30UqiXL5Yd3KF5eCKmMCuvQ+CUwUKDAUtewF1t4iGMe6Z3aIi4z6mZaDZELpIIeYSOh
|
|
|
bedde7 |
WO0qQC+gnyBlQuAbDBSo5NUprcZ8xMsCs0d5kZr3BVgGOXJtZgmIBVLV4yKHRjDW29Nn
|
|
|
bedde7 |
P/pelr5UUYaNW1C0ILMv60vk0Py4VM5oRTQ4otxgkw9soGxUjTsMEA0X49vOdVrfXa9P
|
|
|
bedde7 |
QZbvmXrMB22TNGHkWgPjAkHFxXakJEDq18fwX0dTuxTbx9vlFyaaBdv+CQ+yqfixS70j
|
|
|
bedde7 |
+93w==
|
|
|
bedde7 |
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
|
|
|
bedde7 |
h=message-id:date:subject:cc:to:from:delivered-to;
|
|
|
bedde7 |
bh=0Hr1bq++ZN4c9flsD+ZIcevaW3VxsiFEPs30XoiYUL4=;
|
|
|
bedde7 |
b=paFXhKPPrG7vRaUqzedY45uKY678PbjOiGQSyfzC6DSZFuZ4NepnUyEGwVmd+b0Scc
|
|
|
bedde7 |
O6bzSXYRuXGALKasZkfkEeJLyJUldvlZcmcnGO64gmKGyEq8wmrGGG3J66y2M9UC22NI
|
|
|
bedde7 |
PQ6u0bmWizODueS2cKkHJ+MsmkJ91523n359wDPTb5hyt25mZ/Ax9s7SfHzshVHjdvLx
|
|
|
bedde7 |
Ugmod/BpgtWaxDUKoIdM4a6hM9UOLcyla/XE5HlJlijZHVa0rmQLvKqHBpdWD6FgacTJ
|
|
|
bedde7 |
BF6xPn0fDSZqWz4LwElIuzRiF405Hp8cq4LxGvTZNVm4F9WK+QurgUq/Um/LeJWZ0fgF
|
|
|
bedde7 |
kfTA==
|
|
|
bedde7 |
ARC-Authentication-Results: i=1; mx.google.com;
|
|
|
bedde7 |
spf=pass (google.com: domain gapps.redhat.com configured 209.132.183.28 as internal address) smtp.mailfrom=lijiang@redhat.com
|
|
|
bedde7 |
Return-Path: <lijiang@redhat.com>
|
|
|
bedde7 |
Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28])
|
|
|
bedde7 |
by mx.google.com with ESMTPS id u34si1484288qtj.352.2019.06.21.02.43.25
|
|
|
bedde7 |
for <bhsharma@gapps.redhat.com>
|
|
|
bedde7 |
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
|
|
|
bedde7 |
Fri, 21 Jun 2019 02:43:25 -0700 (PDT)
|
|
|
bedde7 |
Received-SPF: pass (google.com: domain gapps.redhat.com configured 209.132.183.28 as internal address)
|
|
|
bedde7 |
Authentication-Results: mx.google.com;
|
|
|
bedde7 |
spf=pass (google.com: domain gapps.redhat.com configured 209.132.183.28 as internal address) smtp.mailfrom=lijiang@redhat.com
|
|
|
bedde7 |
Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])
|
|
|
bedde7 |
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
|
|
|
bedde7 |
(No client certificate requested)
|
|
|
bedde7 |
by mx1.redhat.com (Postfix) with ESMTPS id 8C7DB3004425
|
|
|
bedde7 |
for <bhsharma@gapps.redhat.com>; Fri, 21 Jun 2019 09:43:24 +0000 (UTC)
|
|
|
bedde7 |
Received: by smtp.corp.redhat.com (Postfix)
|
|
|
bedde7 |
id 8712D5D9E5; Fri, 21 Jun 2019 09:43:24 +0000 (UTC)
|
|
|
bedde7 |
Delivered-To: bhsharma@redhat.com
|
|
|
bedde7 |
Received: from localhost.localdomain.com (ovpn-12-71.pek2.redhat.com [10.72.12.71])
|
|
|
bedde7 |
by smtp.corp.redhat.com (Postfix) with ESMTP id BF70C5D9D2;
|
|
|
bedde7 |
Fri, 21 Jun 2019 09:43:17 +0000 (UTC)
|
|
|
bedde7 |
From: Lianbo Jiang <lijiang@redhat.com>
|
|
|
bedde7 |
To: bhsharma@redhat.com
|
|
|
bedde7 |
Cc: lijiang@redhat.com
|
|
|
bedde7 |
Subject: [PATCH] x86_64: Add support for AMD Secure Memory Encryption
|
|
|
bedde7 |
Date: Fri, 21 Jun 2019 17:43:12 +0800
|
|
|
bedde7 |
Message-Id: <20190621094312.3180-1-lijiang@redhat.com>
|
|
|
bedde7 |
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14
|
|
|
bedde7 |
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 21 Jun 2019 09:43:24 +0000 (UTC)
|
|
|
bedde7 |
|
|
|
bedde7 |
On AMD machine with Secure Memory Encryption (SME) feature, if SME is
|
|
|
bedde7 |
enabled, page tables contain a specific attribute bit (C-bit) in their
|
|
|
bedde7 |
entries to indicate whether a page is encrypted or unencrypted.
|
|
|
bedde7 |
|
|
|
bedde7 |
So get NUMBER(sme_mask) from vmcoreinfo, which stores the value of
|
|
|
bedde7 |
the C-bit position, and drop it to obtain the true physical address.
|
|
|
bedde7 |
|
|
|
bedde7 |
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
|
|
bedde7 |
---
|
|
|
bedde7 |
arch/x86_64.c | 28 +++++++++++++++++++---------
|
|
|
bedde7 |
makedumpfile.c | 4 ++++
|
|
|
bedde7 |
makedumpfile.h | 1 +
|
|
|
bedde7 |
3 files changed, 24 insertions(+), 9 deletions(-)
|
|
|
bedde7 |
|
|
|
bedde7 |
diff --git a/makedumpfile-1.6.2/arch/x86_64.c b/makedumpfile-1.6.2/arch/x86_64.c
|
|
|
bedde7 |
index 33621f1f259c..d897e35f062e 100644
|
|
|
bedde7 |
--- a/makedumpfile-1.6.2/arch/x86_64.c
|
|
|
bedde7 |
+++ b/makedumpfile-1.6.2/arch/x86_64.c
|
|
|
bedde7 |
@@ -259,6 +259,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
|
|
|
bedde7 |
{
|
|
|
bedde7 |
unsigned long page_dir, pml4, pgd_paddr, pgd_pte, pmd_paddr, pmd_pte;
|
|
|
bedde7 |
unsigned long pte_paddr, pte;
|
|
|
bedde7 |
+ unsigned long entry_mask = ENTRY_MASK;
|
|
|
bedde7 |
|
|
|
bedde7 |
/*
|
|
|
bedde7 |
* Get PGD.
|
|
|
bedde7 |
@@ -269,6 +270,10 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
|
|
|
bedde7 |
if (page_dir == NOT_PADDR)
|
|
|
bedde7 |
return NOT_PADDR;
|
|
|
bedde7 |
}
|
|
|
bedde7 |
+
|
|
|
bedde7 |
+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
|
|
|
bedde7 |
+ entry_mask &= ~(NUMBER(sme_mask));
|
|
|
bedde7 |
+
|
|
|
bedde7 |
page_dir += pml4_index(vaddr) * sizeof(unsigned long);
|
|
|
bedde7 |
if (!readmem(PADDR, page_dir, &pml4, sizeof pml4)) {
|
|
|
bedde7 |
ERRMSG("Can't get pml4 (page_dir:%lx).\n", page_dir);
|
|
|
bedde7 |
@@ -285,7 +290,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
|
|
|
bedde7 |
/*
|
|
|
bedde7 |
* Get PUD.
|
|
|
bedde7 |
*/
|
|
|
bedde7 |
- pgd_paddr = pml4 & ENTRY_MASK;
|
|
|
bedde7 |
+ pgd_paddr = pml4 & entry_mask;
|
|
|
bedde7 |
pgd_paddr += pgd_index(vaddr) * sizeof(unsigned long);
|
|
|
bedde7 |
if (!readmem(PADDR, pgd_paddr, &pgd_pte, sizeof pgd_pte)) {
|
|
|
bedde7 |
ERRMSG("Can't get pgd_pte (pgd_paddr:%lx).\n", pgd_paddr);
|
|
|
bedde7 |
@@ -299,13 +304,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
|
|
|
bedde7 |
return NOT_PADDR;
|
|
|
bedde7 |
}
|
|
|
bedde7 |
if (pgd_pte & _PAGE_PSE) /* 1GB pages */
|
|
|
bedde7 |
- return (pgd_pte & ENTRY_MASK & PGDIR_MASK) +
|
|
|
bedde7 |
+ return (pgd_pte & entry_mask & PGDIR_MASK) +
|
|
|
bedde7 |
(vaddr & ~PGDIR_MASK);
|
|
|
bedde7 |
|
|
|
bedde7 |
/*
|
|
|
bedde7 |
* Get PMD.
|
|
|
bedde7 |
*/
|
|
|
bedde7 |
- pmd_paddr = pgd_pte & ENTRY_MASK;
|
|
|
bedde7 |
+ pmd_paddr = pgd_pte & entry_mask;
|
|
|
bedde7 |
pmd_paddr += pmd_index(vaddr) * sizeof(unsigned long);
|
|
|
bedde7 |
if (!readmem(PADDR, pmd_paddr, &pmd_pte, sizeof pmd_pte)) {
|
|
|
bedde7 |
ERRMSG("Can't get pmd_pte (pmd_paddr:%lx).\n", pmd_paddr);
|
|
|
bedde7 |
@@ -319,13 +324,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
|
|
|
bedde7 |
return NOT_PADDR;
|
|
|
bedde7 |
}
|
|
|
bedde7 |
if (pmd_pte & _PAGE_PSE) /* 2MB pages */
|
|
|
bedde7 |
- return (pmd_pte & ENTRY_MASK & PMD_MASK) +
|
|
|
bedde7 |
+ return (pmd_pte & entry_mask & PMD_MASK) +
|
|
|
bedde7 |
(vaddr & ~PMD_MASK);
|
|
|
bedde7 |
|
|
|
bedde7 |
/*
|
|
|
bedde7 |
* Get PTE.
|
|
|
bedde7 |
*/
|
|
|
bedde7 |
- pte_paddr = pmd_pte & ENTRY_MASK;
|
|
|
bedde7 |
+ pte_paddr = pmd_pte & entry_mask;
|
|
|
bedde7 |
pte_paddr += pte_index(vaddr) * sizeof(unsigned long);
|
|
|
bedde7 |
if (!readmem(PADDR, pte_paddr, &pte, sizeof pte)) {
|
|
|
bedde7 |
ERRMSG("Can't get pte (pte_paddr:%lx).\n", pte_paddr);
|
|
|
bedde7 |
@@ -338,7 +343,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
|
|
|
bedde7 |
ERRMSG("Can't get a valid pte.\n");
|
|
|
bedde7 |
return NOT_PADDR;
|
|
|
bedde7 |
}
|
|
|
bedde7 |
- return (pte & ENTRY_MASK) + PAGEOFFSET(vaddr);
|
|
|
bedde7 |
+ return (pte & entry_mask) + PAGEOFFSET(vaddr);
|
|
|
bedde7 |
}
|
|
|
bedde7 |
|
|
|
bedde7 |
unsigned long long
|
|
|
bedde7 |
@@ -553,6 +558,7 @@ find_vmemmap_x86_64()
|
|
|
bedde7 |
unsigned long pmd, tpfn;
|
|
|
bedde7 |
unsigned long pvaddr = 0;
|
|
|
bedde7 |
unsigned long data_addr = 0, last_data_addr = 0, start_data_addr = 0;
|
|
|
bedde7 |
+ unsigned long pmask = PMASK;
|
|
|
bedde7 |
/*
|
|
|
bedde7 |
* data_addr is the paddr of the page holding the page structs.
|
|
|
bedde7 |
* We keep lists of contiguous pages and the pfn's that their
|
|
|
bedde7 |
@@ -569,6 +575,10 @@ find_vmemmap_x86_64()
|
|
|
bedde7 |
ERRMSG("init_level4_pgt not found\n");
|
|
|
bedde7 |
return FAILED;
|
|
|
bedde7 |
}
|
|
|
bedde7 |
+
|
|
|
bedde7 |
+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
|
|
|
bedde7 |
+ pmask &= ~(NUMBER(sme_mask));
|
|
|
bedde7 |
+
|
|
|
bedde7 |
pagestructsize = size_table.page;
|
|
|
bedde7 |
hugepagesize = PTRS_PER_PMD * info->page_size;
|
|
|
bedde7 |
vaddr_base = info->vmemmap_start;
|
|
|
bedde7 |
@@ -597,7 +607,7 @@ find_vmemmap_x86_64()
|
|
|
bedde7 |
return FAILED;
|
|
|
bedde7 |
}
|
|
|
bedde7 |
/* mask the pgd entry for the address of the pud page */
|
|
|
bedde7 |
- pud_addr &= PMASK;
|
|
|
bedde7 |
+ pud_addr &= pmask;
|
|
|
bedde7 |
if (pud_addr == 0)
|
|
|
bedde7 |
continue;
|
|
|
bedde7 |
/* read the entire pud page */
|
|
|
bedde7 |
@@ -610,7 +620,7 @@ find_vmemmap_x86_64()
|
|
|
bedde7 |
/* pudp points to an entry in the pud page */
|
|
|
bedde7 |
for (pudp = (unsigned long *)pud_page, pudindex = 0;
|
|
|
bedde7 |
pudindex < PTRS_PER_PUD; pudindex++, pudp++) {
|
|
|
bedde7 |
- pmd_addr = *pudp & PMASK;
|
|
|
bedde7 |
+ pmd_addr = *pudp & pmask;
|
|
|
bedde7 |
/* read the entire pmd page */
|
|
|
bedde7 |
if (pmd_addr == 0)
|
|
|
bedde7 |
continue;
|
|
|
bedde7 |
@@ -652,7 +662,7 @@ find_vmemmap_x86_64()
|
|
|
bedde7 |
* - we discontiguous page is a string of valids
|
|
|
bedde7 |
*/
|
|
|
bedde7 |
if (pmd) {
|
|
|
bedde7 |
- data_addr = (pmd & PMASK);
|
|
|
bedde7 |
+ data_addr = (pmd & pmask);
|
|
|
bedde7 |
if (start_range) {
|
|
|
bedde7 |
/* first-time kludge */
|
|
|
bedde7 |
start_data_addr = data_addr;
|
|
|
bedde7 |
diff --git a/makedumpfile-1.6.2/makedumpfile.c b/makedumpfile-1.6.2/makedumpfile.c
|
|
|
bedde7 |
index c9634cd42858..ed097c7e597a 100644
|
|
|
bedde7 |
--- a/makedumpfile-1.6.2/makedumpfile.c
|
|
|
bedde7 |
+++ b/makedumpfile-1.6.2/makedumpfile.c
|
|
|
bedde7 |
@@ -960,6 +960,8 @@ next_page:
|
|
|
bedde7 |
read_size = MIN(info->page_size - PAGEOFFSET(paddr), size);
|
|
|
bedde7 |
|
|
|
bedde7 |
pgaddr = PAGEBASE(paddr);
|
|
|
bedde7 |
+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
|
|
|
bedde7 |
+ pgaddr = pgaddr & ~(NUMBER(sme_mask));
|
|
|
bedde7 |
pgbuf = cache_search(pgaddr, read_size);
|
|
|
bedde7 |
if (!pgbuf) {
|
|
|
bedde7 |
++cache_miss;
|
|
|
bedde7 |
@@ -2248,6 +2250,7 @@ write_vmcoreinfo_data(void)
|
|
|
bedde7 |
|
|
|
bedde7 |
WRITE_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES);
|
|
|
bedde7 |
WRITE_NUMBER("N_ONLINE", N_ONLINE);
|
|
|
bedde7 |
+ WRITE_NUMBER("sme_mask", sme_mask);
|
|
|
bedde7 |
|
|
|
bedde7 |
WRITE_NUMBER("PG_lru", PG_lru);
|
|
|
bedde7 |
WRITE_NUMBER("PG_private", PG_private);
|
|
|
bedde7 |
@@ -2642,6 +2645,7 @@ read_vmcoreinfo(void)
|
|
|
bedde7 |
|
|
|
bedde7 |
READ_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES);
|
|
|
bedde7 |
READ_NUMBER("N_ONLINE", N_ONLINE);
|
|
|
bedde7 |
+ READ_NUMBER("sme_mask", sme_mask);
|
|
|
bedde7 |
|
|
|
bedde7 |
READ_NUMBER("PG_lru", PG_lru);
|
|
|
bedde7 |
READ_NUMBER("PG_private", PG_private);
|
|
|
bedde7 |
diff --git a/makedumpfile-1.6.2/makedumpfile.h b/makedumpfile-1.6.2/makedumpfile.h
|
|
|
bedde7 |
index 5f7a1dcf3b2f..bc3a4555132a 100644
|
|
|
bedde7 |
--- a/makedumpfile-1.6.2/makedumpfile.h
|
|
|
bedde7 |
+++ b/makedumpfile-1.6.2/makedumpfile.h
|
|
|
bedde7 |
@@ -1860,6 +1860,7 @@ struct array_table {
|
|
|
bedde7 |
struct number_table {
|
|
|
bedde7 |
long NR_FREE_PAGES;
|
|
|
bedde7 |
long N_ONLINE;
|
|
|
bedde7 |
+ long sme_mask;
|
|
|
bedde7 |
|
|
|
bedde7 |
/*
|
|
|
bedde7 |
* Page flags
|
|
|
bedde7 |
--
|
|
|
bedde7 |
2.17.1
|
|
|
bedde7 |
|