diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2015-02-08 16:50:00 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2015-02-08 16:50:00 +0000 |
commit | 02ff4e5e54488c40efabc9b77d43ebf695038a0f (patch) | |
tree | 39246c750ce1931aa24b50f28526844f9816d4a9 | |
parent | 1d4f21933c63f435a6aef3d6a046dbcf550fa157 (diff) | |
download | FreeBSD-src-02ff4e5e54488c40efabc9b77d43ebf695038a0f.zip FreeBSD-src-02ff4e5e54488c40efabc9b77d43ebf695038a0f.tar.gz |
Add some error checking on the supplied page size list. This makes sure
that we (a) get the correct large page size to provide to pmap and (b)
we can alert the user if running under incorrectly-configured PowerKVM
on POWER7 and POWER8 systems.
MFC after: 1 week
-rw-r--r-- | sys/powerpc/pseries/mmu_phyp.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sys/powerpc/pseries/mmu_phyp.c b/sys/powerpc/pseries/mmu_phyp.c index cdf5dfe..c9d06e3 100644 --- a/sys/powerpc/pseries/mmu_phyp.c +++ b/sys/powerpc/pseries/mmu_phyp.c @@ -102,6 +102,7 @@ mphyp_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) char buf[8]; uint32_t prop[2]; uint32_t nptlp, shift = 0, slb_encoding = 0; + uint32_t lp_size, lp_encoding; phandle_t dev, node, root; int idx, len, res; @@ -148,9 +149,9 @@ mphyp_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) * We have to use a variable length array on the stack * since we have very limited stack space. */ - cell_t arr[len/sizeof(cell_t)]; - res = OF_getprop(node, "ibm,segment-page-sizes", &arr, - sizeof(arr)); + pcell_t arr[len/sizeof(cell_t)]; + res = OF_getencprop(node, "ibm,segment-page-sizes", arr, + sizeof(arr)); len /= 4; idx = 0; while (len > 0) { @@ -160,18 +161,26 @@ mphyp_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) idx += 3; len -= 3; while (len > 0 && nptlp) { + lp_size = arr[idx]; + lp_encoding = arr[idx+1]; + if (slb_encoding == SLBV_L && lp_encoding == 0) + break; + idx += 2; len -= 2; nptlp--; } + if (nptlp && slb_encoding == SLBV_L && lp_encoding == 0) + break; } - /* For now we allow shift only to be <= 0x18. */ - if (shift >= 0x18) - shift = 0x18; + if (len == 0) + panic("Standard large pages (SLB[L] = 1, PTE[LP] = 0) " + "not supported by this system. Please enable huge " + "page backing if running under PowerKVM."); moea64_large_page_shift = shift; - moea64_large_page_size = 1ULL << shift; + moea64_large_page_size = 1ULL << lp_size; } moea64_mid_bootstrap(mmup, kernelstart, kernelend); |