zipl: Update page_is_valid() function to avoid tprot usage

Old implementation was using Test Protection (TPROT) instruction to
validate the memory page. Given that it is a rather slow instruction and
the fact that we only need to validate the read-access for a page, we can
use simple Load or Insert Character instruction to test that.
The new version of page_is_valid() without a TPROT is introduced.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.vnet.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Mikhail Zaslonko
2018-03-27 13:10:17 +02:00
committed by Jan Höppner
parent 9f2e406525
commit 54519b4465
2 changed files with 16 additions and 19 deletions
+1
View File
@@ -74,6 +74,7 @@ stage3.exec: head.o stage3.o kdump3.o libc.o sclp.o sclp_stage3.o \
--only-section=.rodata \
--only-section=.stage2dump.tail \
--only-section=.eckd2dump_mv.tail \
--only-section=.fixup \
$< $@
data.o: $(FILES)
+15 -19
View File
@@ -18,6 +18,7 @@
#define __pa(x) ((unsigned long)(x))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define barrier() __asm__ __volatile__("": : :"memory")
#define inline inline __attribute__((always_inline))
/*
* Helper macro for exception table entries
@@ -207,29 +208,24 @@ do { \
libc_stop(reason); \
} while (0)
#define CHUNK_READ_WRITE 0
#define CHUNK_READ_ONLY 1
static inline int tprot(unsigned long addr)
{
int rc = -EFAULT;
asm volatile(
" tprot 0(%1),0\n"
"0: ipm %0\n"
" srl %0,28\n"
"1:\n"
EX_TABLE(0b, 1b)
: "+d" (rc) : "a" (addr) : "cc");
return rc;
}
static inline int page_is_valid(unsigned long addr)
{
unsigned long tmp;
int rc;
rc = tprot(addr);
return (rc == CHUNK_READ_WRITE) || (rc == CHUNK_READ_ONLY);
asm volatile(
"0: ic %1,%2\n"
"1: lhi %0,1\n"
"2:\n"
".pushsection .fixup, \"ax\"\n"
"3: xr %0,%0\n"
" jg 2b\n"
".popsection\n"
EX_TABLE(0b, 3b) EX_TABLE(1b, 3b)
: "=d" (rc), "=d" (tmp)
: "Q" (*(unsigned long *) addr)
: "cc");
return rc;
}
static inline uint32_t csum_partial(const void *buf, int len, uint32_t sum)