summaryrefslogtreecommitdiffstats
path: root/src/usr/testcore
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2011-09-29 15:42:30 -0500
committerMATTHEW S. BARTH <msbarth@us.ibm.com>2011-10-10 15:51:19 -0500
commit8c062af8b6bd50a59823c7ec430ec5fc019052d2 (patch)
treedbe0625a3024a3737ddfa5d32634ce8225fda991 /src/usr/testcore
parent4de170997eee6244b2091bb8bf065ae2da1396d7 (diff)
downloadtalos-hostboot-8c062af8b6bd50a59823c7ec430ec5fc019052d2.tar.gz
talos-hostboot-8c062af8b6bd50a59823c7ec430ec5fc019052d2.zip
Flush/Release/Evict pages functionality
Change-Id: Ic0bb4122164e11f6d13e6850abf8ae9bd32caea2 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/393 Tested-by: Jenkins Server Reviewed-by: MATTHEW S. BARTH <msbarth@us.ibm.com>
Diffstat (limited to 'src/usr/testcore')
-rw-r--r--src/usr/testcore/kernel/ptmgrtest.H2
-rw-r--r--src/usr/testcore/kernel/segmenttest.H (renamed from src/usr/testcore/kernel/slbtest.H)77
-rw-r--r--src/usr/testcore/kernel/vmmpagetest.H186
3 files changed, 194 insertions, 71 deletions
diff --git a/src/usr/testcore/kernel/ptmgrtest.H b/src/usr/testcore/kernel/ptmgrtest.H
index c32573a43..1d87b312e 100644
--- a/src/usr/testcore/kernel/ptmgrtest.H
+++ b/src/usr/testcore/kernel/ptmgrtest.H
@@ -96,7 +96,7 @@ class ptmgrtest : public CxxTest::TestSuite
void test_hash40( void )
{
TS_TRACE( ">> ptmgrtest::test_hash40 <<" );
- uint64_t fails, total = 0;
+ uint64_t fails = 0, total = 0;
// Initialize the Page Table
PageTableManager* ptmgr = new PageTableManager(true);
diff --git a/src/usr/testcore/kernel/slbtest.H b/src/usr/testcore/kernel/segmenttest.H
index fef88b5d5..d98e3c7b1 100644
--- a/src/usr/testcore/kernel/slbtest.H
+++ b/src/usr/testcore/kernel/segmenttest.H
@@ -1,7 +1,7 @@
// IBM_PROLOG_BEGIN_TAG
// This is an automatically generated prolog.
//
-// $Source: src/usr/testcore/kernel/slbtest.H $
+// $Source: src/usr/testcore/kernel/segmenttest.H $
//
// IBM CONFIDENTIAL
//
@@ -20,26 +20,24 @@
// Origin: 30
//
// IBM_PROLOG_END
-#ifndef __SLBTEST_H
-#define __SLBTEST_H
+#ifndef __SEGMENTTEST_H
+#define __SEGMENTTEST_H
/**
- * @file slbtest.H
+ * @file segmenttest.H
*
- * @brief Test cases for the segment lookaside buffers
+ * @brief Test cases for the virtual memory segments
*/
#include <cxxtest/TestSuite.H>
#include <arch/ppc.H>
#include <sys/time.h>
#include <sys/task.h>
#include <sys/mmio.h>
-#include <sys/mm.h>
+#include <usr/vmmconst.h>
-class slbtest: public CxxTest::TestSuite
+class segmenttest: public CxxTest::TestSuite
{
public:
- static volatile int rc;
-
void testDevSeg()
{
int rc = 0;
@@ -96,67 +94,6 @@ class slbtest: public CxxTest::TestSuite
}
}
- void testPageRemoval()
- {
- int rc = -1;
- uint64_t va = 0xC800000000; //800GB
- uint64_t size = 0x100000; //1MB
- rc = mm_remove_pages(FLUSH,reinterpret_cast<void*>(va),size);
- if (rc != 0)
- {
- TS_FAIL("Failed to remove pages\n");
- }
- }
-
- void testSetPerm()
- {
- int rc = 1;
- uint64_t va = 0xC800000000; //800GB
- uint64_t size = 0x0;
- uint64_t access = (uint64_t)(WRITABLE | ALLOCATE_FROM_ZERO); //Access value
- printkd("Update Page Permissions. Writable/Allocate from zero to addr 800Gb and size = 0 \n");
- rc = mm_set_permission(reinterpret_cast<void*>(va), size, access);
- if (rc != 0)
- {
- TS_FAIL(" 1 Failed to Update permissions.\n");
- }
-
- rc = 1;
- size = PAGESIZE * 3;
- access = (uint64_t)(WRITE_TRACKED); //Access value
- printkd("Update Page Permissions. write_tracked to addr 800Gb and size = 3 pages\n");
- rc = mm_set_permission(reinterpret_cast<void*>(va), size, access);
- if (rc != 0)
- {
- TS_FAIL("2 Failed to Update permissions.\n");
- }
- rc = 1;
- va = 0xC800000000 + (PAGESIZE * 10);
- size = PAGESIZE * 2;
- access = (uint64_t)(EXECUTABLE); //Access value
- printkd("Update Page Permissions. executable to addr C800A000 and size = 2 pages\n");
- rc = mm_set_permission(reinterpret_cast<void*>(va), size, access);
- if (rc != 0)
- {
- TS_FAIL("3 Failed to Update permissions.\n");
- }
- rc = 0;
- va = 0xC800000000; //800GB
- size = 0x0;
- access = (uint64_t)(WRITABLE | EXECUTABLE); //Access value
- printkd("Update Page Permissions. Writable/executable to addr 800Gb and size = 0 \n");
- rc = mm_set_permission(reinterpret_cast<void*>(va), size, access);
- if (rc == 0)
- {
- printk("Error .. invalid combination that did not get detected\n");
- TS_FAIL(" 4 Failed to detect a bad parm condition.\n");
- }
-
- }
-
- private:
-
};
-volatile int slbtest::rc = 0;
#endif
diff --git a/src/usr/testcore/kernel/vmmpagetest.H b/src/usr/testcore/kernel/vmmpagetest.H
new file mode 100644
index 000000000..39090b542
--- /dev/null
+++ b/src/usr/testcore/kernel/vmmpagetest.H
@@ -0,0 +1,186 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/usr/testcore/kernel/vmmpagetest.H $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2011
+//
+// p1
+//
+// Object Code Only (OCO) source materials
+// Licensed Internal Code Source Materials
+// IBM HostBoot Licensed Internal Code
+//
+// The source code for this program is not published or other-
+// wise divested of its trade secrets, irrespective of what has
+// been deposited with the U.S. Copyright Office.
+//
+// Origin: 30
+//
+// IBM_PROLOG_END
+#ifndef __VMMPAGETEST_H
+#define __VMMPAGETEST_H
+/**
+ * @file vmmpagetest.H
+ *
+ * @brief Test cases for handling pages within virtual memory
+*/
+#include <cxxtest/TestSuite.H>
+#include <arch/ppc.H>
+#include <sys/time.h>
+#include <sys/task.h>
+#include <sys/mm.h>
+#include <usr/vmmconst.h>
+
+class vmmpagetest: public CxxTest::TestSuite
+{
+ public:
+
+ static volatile int rc;
+ //Testing page removal variables
+ static msg_q_t iv_mq;
+ static uint64_t iv_va;
+ static uint64_t iv_size;
+
+ void testPageSetup()
+ {
+ uint64_t initPerm = (uint64_t)(READ_ONLY);
+ rc = mm_alloc_block(iv_mq,reinterpret_cast<void*>(iv_va),iv_size);
+ if (rc != 0)
+ {
+ TS_FAIL("Unable to allocate block.\n");
+ }
+ rc = mm_set_permission(reinterpret_cast<void*>(iv_va),iv_size,
+ initPerm);
+ if (rc != 0)
+ {
+ TS_FAIL("Failed to set block permissions to READ_ONLY.\n");
+ }
+ task_create(testDaemon, NULL);
+ }
+
+ void testReadPageRelease()
+ {
+ //Dependent on block being initialized to READ_ONLY
+ (*(volatile uint64_t *)(iv_va+2*PAGESIZE)) = 0x11111111; sync();
+ rc = mm_remove_pages(RELEASE,
+ reinterpret_cast<void*>(iv_va),iv_size);
+ if (rc != 0)
+ {
+ TS_FAIL("Failed to release read pages\n");
+ }
+ }
+
+ void testWriteTrackPageFlush()
+ {
+ (*(volatile uint64_t *)iv_va) = 0x12345678; sync();
+ (*(volatile uint64_t *)(iv_va+PAGESIZE)) = 0x87654321; sync();
+ (*(volatile uint64_t *)(iv_va+2*PAGESIZE)) = 0x22222222; sync();
+ uint64_t updPerm = (uint64_t)(WRITE_TRACKED);
+ rc = mm_set_permission(reinterpret_cast<void*>(iv_va),0,updPerm);
+ if (rc != 0)
+ {
+ TS_FAIL(
+ "Failed to set WRITE_TRACKED permissions on first page.\n");
+ }
+ rc = mm_set_permission(reinterpret_cast<void*>((iv_va+PAGESIZE)),0,
+ updPerm);
+ if (rc != 0)
+ {
+ TS_FAIL(
+ "Failed to set WRITE_TRACKED permissions on second page.\n");
+ }
+ rc = mm_remove_pages(FLUSH,
+ reinterpret_cast<void*>(iv_va),iv_size);
+ if (rc != 0)
+ {
+ TS_FAIL("Failed to flush write tracked pages\n");
+ }
+ }
+
+ void testWriteTrackPageRelease()
+ {
+ (*(volatile uint64_t *)(iv_va+2*PAGESIZE)) = 0x33333333; sync();
+ (*(volatile uint64_t *)iv_va) = 0x12121212; sync();
+ rc = mm_remove_pages(RELEASE,
+ reinterpret_cast<void*>(iv_va),iv_size);
+ if (rc != 0)
+ {
+ TS_FAIL("Failed to release write track pages\n");
+ }
+ }
+
+ void testSetPerm()
+ {
+ int rc = 1;
+ uint64_t va = 0xC800000000; //800GB
+ uint64_t size = 0x0;
+ uint64_t access = (uint64_t)(WRITABLE | ALLOCATE_FROM_ZERO); //Access value
+ printkd("Update Page Permissions. Writable/Allocate from zero to addr 800Gb and size = 0 \n");
+ rc = mm_set_permission(reinterpret_cast<void*>(va), size, access);
+ if (rc != 0)
+ {
+ TS_FAIL(" 1 Failed to Update permissions.\n");
+ }
+
+ rc = 1;
+ size = PAGESIZE * 3;
+ access = (uint64_t)(WRITE_TRACKED); //Access value
+ printkd("Update Page Permissions. write_tracked to addr 800Gb and size = 3 pages\n");
+ rc = mm_set_permission(reinterpret_cast<void*>(va), size, access);
+ if (rc != 0)
+ {
+ TS_FAIL("2 Failed to Update permissions.\n");
+ }
+ rc = 1;
+ va = 0xC800000000 + (PAGESIZE * 10);
+ size = PAGESIZE * 2;
+ access = (uint64_t)(EXECUTABLE); //Access value
+ printkd("Update Page Permissions. executable to addr C800A000 and size = 2 pages\n");
+ rc = mm_set_permission(reinterpret_cast<void*>(va), size, access);
+ if (rc != 0)
+ {
+ TS_FAIL("3 Failed to Update permissions.\n");
+ }
+ rc = 0;
+ va = 0xC800000000; //800GB
+ size = 0x0;
+ access = (uint64_t)(WRITABLE | EXECUTABLE); //Access value
+ printkd("Update Page Permissions. Writable/executable to addr 800Gb and size = 0 \n");
+ rc = mm_set_permission(reinterpret_cast<void*>(va), size, access);
+ if (rc == 0)
+ {
+ printk("Error .. invalid combination that did not get detected\n");
+ TS_FAIL(" 4 Failed to detect a bad parm condition.\n");
+ }
+ }
+
+ private:
+
+ static void testDaemon(void* unused)
+ {
+ msg_t* message = NULL;
+ uint64_t ea = 0;
+ while (1)
+ {
+ message = msg_wait(iv_mq);
+ if (message)
+ {
+ ea = message->data[0];
+ printkd("Effective Addr: 0x%lX, %s\n",ea,
+ message->type==MSG_MM_RP_READ?"READ":"WRITE");
+ message->data[1] = 0;
+ rc = msg_respond(iv_mq, message);
+ }
+ }
+ }
+
+};
+volatile int vmmpagetest::rc = 0;
+msg_q_t vmmpagetest::iv_mq = msg_q_create();
+uint64_t vmmpagetest::iv_va = VMM_VADDR_RMVPAGE_TEST;
+uint64_t vmmpagetest::iv_size = VMM_SIZE_RMVPAGE_TEST;
+
+#endif
OpenPOWER on IntegriCloud