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: <20201007195351.776555-4-nivedita@alum.mit.edu>
Date:   Wed,  7 Oct 2020 15:53:49 -0400
From:   Arvind Sankar <nivedita@...m.mit.edu>
To:     x86@...nel.org, Joerg Roedel <jroedel@...e.de>
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH 3/5] x86/boot/64: Change add_identity_map() to take size for ease of use

Change back the arguments of add_identity_map() to (start, size) instead
of (start, end). This reverts

  21cf2372618e ("x86/boot/compressed/64: Change add_identity_map() to take start and end")

since we will soon have more callers that know the size rather than the
end address.

This also makes the #PF handler print the original CR2 value in case of
error, instead of after aligning to PMD_SIZE.

Signed-off-by: Arvind Sankar <nivedita@...m.mit.edu>
---
 arch/x86/boot/compressed/ident_map_64.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c
index 063a60edcf99..070cda70aef3 100644
--- a/arch/x86/boot/compressed/ident_map_64.c
+++ b/arch/x86/boot/compressed/ident_map_64.c
@@ -90,8 +90,9 @@ static struct x86_mapping_info mapping_info;
 /*
  * Adds the specified range to the identity mappings.
  */
-static void add_identity_map(unsigned long start, unsigned long end)
+static void add_identity_map(unsigned long start, unsigned long size)
 {
+	unsigned long end = start + size;
 	int ret;
 
 	/* Align boundary to 2M. */
@@ -152,7 +153,7 @@ void initialize_identity_maps(void)
 	 * New page-table is set up - map the kernel image and load it
 	 * into cr3.
 	 */
-	add_identity_map((unsigned long)_head, (unsigned long)_end);
+	add_identity_map((unsigned long)_head, (unsigned long)_end - (unsigned long)_head);
 	write_cr3(top_level_pgt);
 }
 
@@ -322,14 +323,10 @@ static void do_pf_error(const char *msg, unsigned long error_code,
 void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
 	unsigned long address = native_read_cr2();
-	unsigned long end;
 	bool ghcb_fault;
 
 	ghcb_fault = sev_es_check_ghcb_fault(address);
 
-	address   &= PMD_MASK;
-	end        = address + PMD_SIZE;
-
 	/*
 	 * Check for unexpected error codes. Unexpected are:
 	 *	- Faults on present pages
@@ -345,5 +342,5 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code)
 	 * Error code is sane - now identity map the 2M region around
 	 * the faulting address.
 	 */
-	add_identity_map(address, end);
+	add_identity_map(address & PMD_MASK, PMD_SIZE);
 }
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ