From 8c062af8b6bd50a59823c7ec430ec5fc019052d2 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Thu, 29 Sep 2011 15:42:30 -0500 Subject: 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 --- src/usr/testcore/kernel/ptmgrtest.H | 2 +- src/usr/testcore/kernel/segmenttest.H | 99 ++++++++++++++++++ src/usr/testcore/kernel/slbtest.H | 162 ----------------------------- src/usr/testcore/kernel/vmmpagetest.H | 186 ++++++++++++++++++++++++++++++++++ 4 files changed, 286 insertions(+), 163 deletions(-) create mode 100644 src/usr/testcore/kernel/segmenttest.H delete mode 100644 src/usr/testcore/kernel/slbtest.H create mode 100644 src/usr/testcore/kernel/vmmpagetest.H (limited to 'src/usr/testcore') 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/segmenttest.H b/src/usr/testcore/kernel/segmenttest.H new file mode 100644 index 000000000..d98e3c7b1 --- /dev/null +++ b/src/usr/testcore/kernel/segmenttest.H @@ -0,0 +1,99 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/testcore/kernel/segmenttest.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 __SEGMENTTEST_H +#define __SEGMENTTEST_H +/** + * @file segmenttest.H + * + * @brief Test cases for the virtual memory segments +*/ +#include +#include +#include +#include +#include +#include + +class segmenttest: public CxxTest::TestSuite +{ + public: + + void testDevSeg() + { + int rc = 0; + uint64_t ra = 2*1024*1024; + printkd("Map Device @ ra = 0x%lX using mmio_map\n",ra); + uint64_t* virtAddrMMIO = static_cast + (mmio_map(reinterpret_cast(ra), 1)); + if (virtAddrMMIO == NULL) + { + TS_FAIL("Failed to map using mmio_map\n"); + } + printkd("Unmap Device @ va = %p using mmio_unmap\n",virtAddrMMIO); + rc = mmio_unmap(reinterpret_cast(virtAddrMMIO), 1); + if (rc != 0) + { + TS_FAIL("Failed to unmap using mmio_unmap\n"); + } + + printkd("Map Device @ ra = 0x%lX using dev_map\n",ra); + uint64_t* virtAddrDEV = static_cast + (mmio_dev_map(reinterpret_cast(ra), THIRTYTWO_GB)); + if (virtAddrDEV == NULL) + { + TS_FAIL("Failed to map using mmio_dev_map\n"); + } + printkd("Unmap Device @ va = %p using dev_unmap\n",virtAddrDEV); + rc = mmio_dev_unmap(reinterpret_cast(virtAddrDEV)); + if (rc != 0) + { + TS_FAIL("Failed to unmap using mmio_dev_unmap\n"); + } + } + + void testSegBlock() + { + int rc = -1; + msg_q_t mq = msg_q_create(); //Create empty message queue + uint64_t va = 0xC800000000; //800GB + uint64_t size = 0x100000; //1MB + printkd("Allocate 1MB block with empty msgq @ vaddr = 800GB within base segment\n"); + rc = mm_alloc_block(mq,reinterpret_cast(va),size); + if (rc != 0) + { + TS_FAIL("Failed to create BaseSegment block\n"); + } + msg_q_t mq2 = msg_q_create(); //Create empty message queue + uint64_t va2 = 0xE100000000; //900GB + uint64_t size2 = 0x100000; //1MB + printkd("Allocate 1MB block with empty msgq @ vaddr = 900GB within base segment\n"); + rc = mm_alloc_block(mq2,reinterpret_cast(va2),size2); + if (rc != 0) + { + TS_FAIL("Failed to create BaseSegment block\n"); + } + } + +}; + +#endif diff --git a/src/usr/testcore/kernel/slbtest.H b/src/usr/testcore/kernel/slbtest.H deleted file mode 100644 index fef88b5d5..000000000 --- a/src/usr/testcore/kernel/slbtest.H +++ /dev/null @@ -1,162 +0,0 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/testcore/kernel/slbtest.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 __SLBTEST_H -#define __SLBTEST_H -/** - * @file slbtest.H - * - * @brief Test cases for the segment lookaside buffers -*/ -#include -#include -#include -#include -#include -#include - -class slbtest: public CxxTest::TestSuite -{ - public: - - static volatile int rc; - - void testDevSeg() - { - int rc = 0; - uint64_t ra = 2*1024*1024; - printkd("Map Device @ ra = 0x%lX using mmio_map\n",ra); - uint64_t* virtAddrMMIO = static_cast - (mmio_map(reinterpret_cast(ra), 1)); - if (virtAddrMMIO == NULL) - { - TS_FAIL("Failed to map using mmio_map\n"); - } - printkd("Unmap Device @ va = %p using mmio_unmap\n",virtAddrMMIO); - rc = mmio_unmap(reinterpret_cast(virtAddrMMIO), 1); - if (rc != 0) - { - TS_FAIL("Failed to unmap using mmio_unmap\n"); - } - - printkd("Map Device @ ra = 0x%lX using dev_map\n",ra); - uint64_t* virtAddrDEV = static_cast - (mmio_dev_map(reinterpret_cast(ra), THIRTYTWO_GB)); - if (virtAddrDEV == NULL) - { - TS_FAIL("Failed to map using mmio_dev_map\n"); - } - printkd("Unmap Device @ va = %p using dev_unmap\n",virtAddrDEV); - rc = mmio_dev_unmap(reinterpret_cast(virtAddrDEV)); - if (rc != 0) - { - TS_FAIL("Failed to unmap using mmio_dev_unmap\n"); - } - } - - void testSegBlock() - { - int rc = -1; - msg_q_t mq = msg_q_create(); //Create empty message queue - uint64_t va = 0xC800000000; //800GB - uint64_t size = 0x100000; //1MB - printkd("Allocate 1MB block with empty msgq @ vaddr = 800GB within base segment\n"); - rc = mm_alloc_block(mq,reinterpret_cast(va),size); - if (rc != 0) - { - TS_FAIL("Failed to create BaseSegment block\n"); - } - msg_q_t mq2 = msg_q_create(); //Create empty message queue - uint64_t va2 = 0xE100000000; //900GB - uint64_t size2 = 0x100000; //1MB - printkd("Allocate 1MB block with empty msgq @ vaddr = 900GB within base segment\n"); - rc = mm_alloc_block(mq2,reinterpret_cast(va2),size2); - if (rc != 0) - { - TS_FAIL("Failed to create BaseSegment block\n"); - } - } - - void testPageRemoval() - { - int rc = -1; - uint64_t va = 0xC800000000; //800GB - uint64_t size = 0x100000; //1MB - rc = mm_remove_pages(FLUSH,reinterpret_cast(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(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(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(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(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 +#include +#include +#include +#include +#include + +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(iv_va),iv_size); + if (rc != 0) + { + TS_FAIL("Unable to allocate block.\n"); + } + rc = mm_set_permission(reinterpret_cast(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(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(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((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(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(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(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(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(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(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 -- cgit v1.2.1