lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220420150149.1691573-1-rppt@kernel.org>
Date:   Wed, 20 Apr 2022 18:01:49 +0300
From:   Mike Rapoport <rppt@...nel.org>
To:     Borislav Petkov <bp@...en8.de>
Cc:     Andy Lutomirski <luto@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
        Kirill Shutemov <kirill.shutemov@...el.com>,
        Kuppuswamy Sathyanarayanan 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        Mike Rapoport <rppt@...nel.org>,
        Mike Rapoport <rppt@...ux.ibm.com>,
        Thomas Gleixner <tglx@...utronix.de>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH v2] x86/mm/ptdump: display page encryption state

From: Mike Rapoport <rppt@...ux.ibm.com>

When memory encryption is enabled, for instance in SEV guest, it is useful
to see what memory ranges are mapped as encrypted in the kernel page tables
and what ranges are left plain.

Add printing of 'ENC' for the encrypted ranges to the page table dumps.

Signed-off-by: Mike Rapoport <rppt@...ux.ibm.com>
---

v2: use cc_is_enc() instead of _PAGE_ENC as Dave suggested for TDX
compatibility

 arch/x86/include/asm/coco.h   | 10 ++++++++++
 arch/x86/mm/dump_pagetables.c |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/arch/x86/include/asm/coco.h b/arch/x86/include/asm/coco.h
index 3d98c3a60d34..cfc85a080a22 100644
--- a/arch/x86/include/asm/coco.h
+++ b/arch/x86/include/asm/coco.h
@@ -17,6 +17,11 @@ void cc_set_mask(u64 mask);
 #ifdef CONFIG_ARCH_HAS_CC_PLATFORM
 u64 cc_mkenc(u64 val);
 u64 cc_mkdec(u64 val);
+
+static inline bool cc_is_enc(u64 prot)
+{
+	return cc_mkdec(prot) != prot;
+}
 #else
 static inline u64 cc_mkenc(u64 val)
 {
@@ -27,6 +32,11 @@ static inline u64 cc_mkdec(u64 val)
 {
 	return val;
 }
+
+static inline bool cc_is_enc(u64 prot)
+{
+	return false;
+}
 #endif
 
 #endif /* _ASM_X86_COCO_H */
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index e1b599ecbbc2..0eaa0cc0b3b1 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -201,6 +201,10 @@ static void printk_prot(struct seq_file *m, pgprotval_t pr, int level, bool dmsg
 			pt_dump_cont_printf(m, dmsg, "PCD ");
 		else
 			pt_dump_cont_printf(m, dmsg, "    ");
+		if (cc_is_enc(pr))
+			pt_dump_cont_printf(m, dmsg, "ENC ");
+		else
+			pt_dump_cont_printf(m, dmsg, "    ");
 
 		/* Bit 7 has a different meaning on level 3 vs 4 */
 		if (level <= 3 && pr & _PAGE_PSE)

base-commit: b2d229d4ddb17db541098b83524d901257e93845
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ