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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201109112319.264511-13-alexandre.chartre@oracle.com>
Date:   Mon,  9 Nov 2020 12:23:07 +0100
From:   Alexandre Chartre <alexandre.chartre@...cle.com>
To:     "tglx@...utronix.de"@aserv0122.oracle.com,
        "mingo@...hat.com"@aserv0122.oracle.com,
        "bp@...en8.de"@aserv0122.oracle.com,
        "hpa@...or.com"@aserv0122.oracle.com,
        "x86@...nel.org"@aserv0122.oracle.com,
        "dave.hansen@...ux.intel.com"@aserv0122.oracle.com,
        "luto@...nel.org"@aserv0122.oracle.com,
        "peterz@...radead.org"@aserv0122.oracle.com,
        "linux-kernel@...r.kernel.org"@aserv0122.oracle.com,
        "thomas.lendacky@....com"@aserv0122.oracle.com,
        "jroedel@...e.de"@aserv0122.oracle.com
Cc:     "konrad.wilk@...cle.com"@aserv0122.oracle.com,
        "jan.setjeeilers@...cle.com"@aserv0122.oracle.com,
        "junaids@...gle.com"@aserv0122.oracle.com,
        "oweisse@...gle.com"@aserv0122.oracle.com,
        "rppt@...ux.vnet.ibm.com"@aserv0122.oracle.com,
        "graf@...zon.de"@aserv0122.oracle.com,
        "mgross@...ux.intel.com"@aserv0122.oracle.com,
        "kuzuno@...il.com"@aserv0122.oracle.com,
        "alexandre.chartre@...cle.com"@aserv0122.oracle.com
Subject: [RFC][PATCH 12/24] x86/pti: Function to map per-cpu page-table entry

Wrap the code used by PTI to map a per-cpu page-table entry into
a new function so that this code can be re-used to map other
per-cpu entries.

Signed-off-by: Alexandre Chartre <alexandre.chartre@...cle.com>
---
 arch/x86/mm/pti.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index ebc8cd2f1cd8..71ca245d7b38 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -428,6 +428,21 @@ static void __init pti_clone_p4d(unsigned long addr)
 	*user_p4d = *kernel_p4d;
 }
 
+/*
+ * Clone a single percpu page.
+ */
+static void __init pti_clone_percpu_page(void *addr)
+{
+	phys_addr_t pa = per_cpu_ptr_to_phys(addr);
+	pte_t *target_pte;
+
+	target_pte = pti_user_pagetable_walk_pte((unsigned long)addr);
+	if (WARN_ON(!target_pte))
+		return;
+
+	*target_pte = pfn_pte(pa >> PAGE_SHIFT, PAGE_KERNEL);
+}
+
 /*
  * Clone the CPU_ENTRY_AREA and associated data into the user space visible
  * page table.
@@ -448,16 +463,8 @@ static void __init pti_clone_user_shared(void)
 		 * This is done for all possible CPUs during boot to ensure
 		 * that it's propagated to all mms.
 		 */
+		pti_clone_percpu_page(&per_cpu(cpu_tss_rw, cpu));
 
-		unsigned long va = (unsigned long)&per_cpu(cpu_tss_rw, cpu);
-		phys_addr_t pa = per_cpu_ptr_to_phys((void *)va);
-		pte_t *target_pte;
-
-		target_pte = pti_user_pagetable_walk_pte(va);
-		if (WARN_ON(!target_pte))
-			return;
-
-		*target_pte = pfn_pte(pa >> PAGE_SHIFT, PAGE_KERNEL);
 	}
 }
 
-- 
2.18.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ