summaryrefslogtreecommitdiffstats
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/misc.C51
-rw-r--r--src/kernel/pagemgr.C111
-rw-r--r--src/kernel/syscall.C4
-rw-r--r--src/kernel/vmmmgr.C14
4 files changed, 45 insertions, 135 deletions
diff --git a/src/kernel/misc.C b/src/kernel/misc.C
index 6122e40a2..75f476187 100644
--- a/src/kernel/misc.C
+++ b/src/kernel/misc.C
@@ -490,54 +490,6 @@ namespace KernelMisc
kassert(false);
}
- int expand_half_cache()
- {
- static bool executed = false;
-
- if (executed) // Why are we being called a second time?
- {
- return -EFAULT;
- }
-
- uint64_t startAddr = 512*KILOBYTE;
- uint64_t endAddr = 1*MEGABYTE;
-
- size_t cache_columns = 0;
-
- switch(CpuID::getCpuType())
- {
- case CORE_POWER8_MURANO:
- case CORE_POWER8_VENICE:
- case CORE_POWER8_NAPLES:
- case CORE_POWER9_NIMBUS:
- case CORE_POWER9_CUMULUS:
- cache_columns = 4;
- break;
-
- default:
- kassert(false);
- break;
- }
-
- for (size_t i = 0; i < cache_columns; i++)
- {
- size_t offset = i * MEGABYTE;
- populate_cache_lines(
- reinterpret_cast<uint64_t*>(startAddr + offset),
- reinterpret_cast<uint64_t*>(endAddr + offset));
-
- PageManager::addMemory(startAddr + offset,
- (512*KILOBYTE)/PAGESIZE);
- }
-
- executed = true;
-
- KernelMemState::setMemScratchReg(KernelMemState::MEM_CONTAINED_L3,
- KernelMemState::HALF_CACHE);
-
- return 0;
- }
-
int expand_full_cache(uint64_t i_expandSize)
{
static bool executed = false;
@@ -596,6 +548,9 @@ namespace KernelMisc
{
size_t cache_line_size = getCacheLineWords();
+ // Assert start/end address is divisible by Cache Line Words
+ kassert(reinterpret_cast<uint64_t>(i_start)%cache_line_size == 0);
+ kassert(reinterpret_cast<uint64_t>(i_end)%cache_line_size == 0);
while(i_start != i_end)
{
dcbz(i_start);
diff --git a/src/kernel/pagemgr.C b/src/kernel/pagemgr.C
index 5382dc0e0..02e8ce710 100644
--- a/src/kernel/pagemgr.C
+++ b/src/kernel/pagemgr.C
@@ -206,95 +206,44 @@ void PageManager::_initialize()
uint64_t totalPages = 0;
page_t* startAddr = reinterpret_cast<page_t*>(firstPageAddr());
- page_t* endAddr = reinterpret_cast<page_t*>(VmmManager::INITIAL_MEM_SIZE);
- printk("PageManager starts at %p...", startAddr);
+ printk("PageManager starts at %p\n", startAddr);
+ // Populate cache lines from end of HBB to PT offset and add to heap
+ uint64_t startBlock = reinterpret_cast<uint64_t>(startAddr);
+ uint64_t endBlock = VmmManager::INITIAL_PT_OFFSET;
+ KernelMisc::populate_cache_lines(
+ reinterpret_cast<uint64_t*>(startBlock),
+ reinterpret_cast<uint64_t*>(endBlock));
+
+ uint64_t pages = (endBlock - startBlock) / PAGESIZE;
+ iv_heap.addMemory(startBlock, pages);
+ totalPages += pages;
+
+ // Populate cache lines of PT
+ startBlock = VmmManager::INITIAL_PT_OFFSET;
+ endBlock = VmmManager::INITIAL_PT_OFFSET + VmmManager::PTSIZE;
+ KernelMisc::populate_cache_lines(reinterpret_cast<uint64_t*>(startBlock),
+ reinterpret_cast<uint64_t*>(endBlock));
+
+ // Populate cachelines from end of Preserved read (PT + securebood data) to
+ // 4MB and add to heap
// Add on secureboot data size to end of reserved space
size_t securebootDataSize = 0;
if (g_BlToHbDataManager.isValid())
{
securebootDataSize = g_BlToHbDataManager.getPreservedSize();
}
- size_t l_endReservedPage = VmmManager::END_RESERVED_PAGE
+ size_t l_endReservedPage = VmmManager::BLTOHB_DATA_START
+ securebootDataSize;
-
- // Calculate chunks along the top half of the L3 and erase them.
- uint64_t currentBlock = reinterpret_cast<uint64_t>(startAddr);
- do
- {
- if (currentBlock % (1*MEGABYTE) >= (512*KILOBYTE))
- {
- currentBlock = ALIGN_MEGABYTE(currentBlock);
- continue;
- }
-
- uint64_t endBlock = ALIGN_MEGABYTE_DOWN(currentBlock) + 512*KILOBYTE;
-
- // Adjust address to compensate for reserved hole and add to
- // heap...
-
- // Check if this block starts in the hole.
- if ((currentBlock >= VmmManager::FIRST_RESERVED_PAGE) &&
- (currentBlock < l_endReservedPage))
- {
- // End of the block is in the hole, skip.
- if (endBlock < l_endReservedPage)
- {
- currentBlock = ALIGN_MEGABYTE(endBlock);
- continue;
- }
-
- // Advance the current block past the hole.
- currentBlock = l_endReservedPage;
- }
-
- // Check if the block is has the hole in it.
- if ((endBlock >= VmmManager::FIRST_RESERVED_PAGE) &&
- (currentBlock < VmmManager::FIRST_RESERVED_PAGE))
- {
- // Hole is at the end of the block, shrink it down.
- if (endBlock < l_endReservedPage)
- {
- endBlock = VmmManager::FIRST_RESERVED_PAGE;
- }
- // Hole is in the middle... yuck.
- else
- {
- uint64_t hole_end =
- (VmmManager::FIRST_RESERVED_PAGE - currentBlock);
-
- // Populate L3 for the first part of the chunk.
- KernelMisc::populate_cache_lines(
- reinterpret_cast<uint64_t*>(currentBlock),
- reinterpret_cast<uint64_t*>(hole_end));
-
- // Add it to the heap.
- iv_heap.addMemory(currentBlock, hole_end / PAGESIZE);
- totalPages += (hole_end / PAGESIZE);
-
- currentBlock = l_endReservedPage;
- }
- }
-
- // Populate L3 cache lines for this chunk.
- KernelMisc::populate_cache_lines(
- reinterpret_cast<uint64_t*>(currentBlock),
- reinterpret_cast<uint64_t*>(endBlock));
-
- uint64_t pages = (endBlock - currentBlock) / PAGESIZE;
-
- iv_heap.addMemory(currentBlock, pages);
- totalPages += pages;
-
- currentBlock = ALIGN_MEGABYTE(endBlock);
-
- } while (reinterpret_cast<page_t*>(currentBlock) != endAddr);
-
- // Ensure HW page table area is erased / populated.
+ startBlock = l_endReservedPage;
+ endBlock = VmmManager::INITIAL_MEM_SIZE;
KernelMisc::populate_cache_lines(
- reinterpret_cast<uint64_t*>(VmmManager::INITIAL_PT_OFFSET),
- reinterpret_cast<uint64_t*>(VmmManager::INITIAL_PT_OFFSET +
- VmmManager::PTSIZE));
+ reinterpret_cast<uint64_t*>(startBlock),
+ reinterpret_cast<uint64_t*>(endBlock));
+
+ pages = (endBlock - startBlock) / PAGESIZE;
+ iv_heap.addMemory(startBlock, pages);
+ totalPages += pages;
printk("%ld pages.\n", totalPages);
@@ -309,7 +258,7 @@ void PageManager::_initialize()
cv_low_page_count = totalPages;
KernelMemState::setMemScratchReg(KernelMemState::MEM_CONTAINED_L3,
- KernelMemState::PRE_SECURE_BOOT);
+ KernelMemState::HALF_CACHE);
}
void* PageManager::_allocatePage(size_t n, bool userspace)
diff --git a/src/kernel/syscall.C b/src/kernel/syscall.C
index adef18afe..bf92fe913 100644
--- a/src/kernel/syscall.C
+++ b/src/kernel/syscall.C
@@ -908,10 +908,6 @@ namespace Systemcalls
switch (size)
{
- case MM_EXTEND_PARTIAL_CACHE:
- TASK_SETRTN(t, KernelMisc::expand_half_cache());
- break;
-
case MM_EXTEND_REDUCED_CACHE:
TASK_SETRTN(t, KernelMisc::expand_full_cache(8*MEGABYTE));
break;
diff --git a/src/kernel/vmmmgr.C b/src/kernel/vmmmgr.C
index e7240dc11..9902a0527 100644
--- a/src/kernel/vmmmgr.C
+++ b/src/kernel/vmmmgr.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2010,2016 */
+/* Contributors Listed Below - COPYRIGHT 2010,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -277,7 +277,7 @@ int VmmManager::_devUnmap(void* ea)
uint64_t VmmManager::HTABORG()
{
- return ((uint32_t)HTABORG_OFFSET + getHRMOR());
+ return static_cast<uint32_t>(pageTableOffset()) + getHRMOR();
}
uint64_t VmmManager::findKernelAddress(uint64_t i_vaddr)
@@ -304,3 +304,13 @@ int VmmManager::_mmLinearMap(void *i_paddr, uint64_t i_size)
lock.unlock();
return rc;
}
+
+uint64_t VmmManager::pageTableOffset()
+{
+ return Singleton<VmmManager>::instance()._pageTableOffset();
+}
+
+uint64_t VmmManager::_pageTableOffset() const
+{
+ return INITIAL_PT_OFFSET;
+}
OpenPOWER on IntegriCloud