[Crash-utility] Fwd: [PATCH] s390x: Fix virtual address check for 5 level page tables

Zaslonko Mikhail zaslonko at linux.vnet.ibm.com
Thu May 11 17:50:42 UTC 2017


Hello Dave,

We have recently found that Crash is not capable of processing 5 level 
page tables virtual addresses (higher than 8 Petabytes). Please find the 
enclosed patch below.

Thanks,
Mikhail Zaslonko


[PATCH] s390x: Fix virtual address check for 5 level page tables


The current validity check for virtual addresses fails for
five level page tables because in that case it uses a 64 bit
left-shift operation which is undefined in the C standard.

Quote from C99 standard:

  If the  value  of  the  right  operand  is  negative or is
  greater than or equal to the width of the promoted left operand,
  the behavior is undefined.

To fix this, we just skip the validity check in case of highest
page-level (level = 3) due to redundancy

Signed-off-by: Mikhail Zaslonko <zaslonko at linux.vnet.ibm.com>
---
  s390x.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/s390x.c b/s390x.c
index e13bd59..96ce3dc 100644
--- a/s390x.c
+++ b/s390x.c
@@ -688,7 +688,7 @@ int s390x_vtop(ulong table, ulong vaddr, physaddr_t *phys_addr, int verbose)
  	/* Read the first entry to find the number of page table levels. */
  	readmem(table, KVADDR, &entry, sizeof(entry), "entry", FAULT_ON_ERROR);
  	level = (entry & 0xcULL) >> 2;
-	if ((vaddr >> (31 + 11*level)) != 0ULL) {
+	if ((level < 3) && (vaddr >> (31 + 11*level)) != 0ULL) {
  		/* Address too big for the number of page table levels. */
  		return FALSE;
  	}
-- 
2.10.2

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/crash-utility/attachments/20170511/75b23e22/attachment.htm>
-------------- next part --------------
>From 581f58c755399423e58d22a2751baf753785ba82 Mon Sep 17 00:00:00 2001
From: Mikhail Zaslonko <zaslonko at linux.vnet.ibm.com>
Date: Thu, 11 May 2017 19:17:39 +0200
Subject: [PATCH] s390x: Fix virtual address check for 5 level page tables

The current validity check for virtual addresses fails for
five level page tables because in that case it uses a 64 bit
left-shift operation which is undefined in the C standard.

Quote from C99 standard:

 If the  value  of  the  right  operand  is  negative or is
 greater than or equal to the width of the promoted left operand,
 the behavior is undefined.

To fix this, we just skip the validity check in case of highest
page-level (level = 3) due to redundancy

Signed-off-by: Mikhail Zaslonko <zaslonko at linux.vnet.ibm.com>
---
 s390x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/s390x.c b/s390x.c
index e13bd59..96ce3dc 100644
--- a/s390x.c
+++ b/s390x.c
@@ -688,7 +688,7 @@ int s390x_vtop(ulong table, ulong vaddr, physaddr_t *phys_addr, int verbose)
 	/* Read the first entry to find the number of page table levels. */
 	readmem(table, KVADDR, &entry, sizeof(entry), "entry", FAULT_ON_ERROR);
 	level = (entry & 0xcULL) >> 2;
-	if ((vaddr >> (31 + 11*level)) != 0ULL) {
+	if ((level < 3) && (vaddr >> (31 + 11*level)) != 0ULL) {
 		/* Address too big for the number of page table levels. */
 		return FALSE;
 	}
-- 
2.10.2



More information about the Crash-utility mailing list