From 794dd51dcb8ee25822dac196200ae396c0c77225 Mon Sep 17 00:00:00 2001 From: spashabk-in Date: Thu, 15 Jun 2017 05:46:24 -0500 Subject: [Whitelist/Blacklist] - Enable scom filter and testcase addition Implemented whitelist/blacklist filtering on scom chip-ops Removed separate scom tetcases and included the same in security testcases Included security negative testcases for scom filtering Change-Id: I41e5aa1a059b7a60b83e8740c738de41dc30dd3f Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41871 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Sachin Gupta --- src/test/testcases/test.xml | 3 +- src/test/testcases/testModifyScom.py | 98 ---------------------- src/test/testcases/testPutGetInScom.py | 83 ------------------- src/test/testcases/testPutGetScom.py | 102 ++--------------------- src/test/testcases/testPutScomUnderMask.py | 99 ----------------------- src/test/testcases/testSbeDump.py | 5 ++ src/test/testcases/testScom.xml | 43 ---------- src/test/testcases/testScomUtil.py | 125 +++++++++++++++++++++++++++++ src/test/testcases/testSecurity.py | 43 ++++++++++ 9 files changed, 182 insertions(+), 419 deletions(-) delete mode 100755 src/test/testcases/testModifyScom.py delete mode 100755 src/test/testcases/testPutGetInScom.py mode change 100755 => 100644 src/test/testcases/testPutGetScom.py delete mode 100755 src/test/testcases/testPutScomUnderMask.py delete mode 100755 src/test/testcases/testScom.xml create mode 100644 src/test/testcases/testScomUtil.py (limited to 'src/test') diff --git a/src/test/testcases/test.xml b/src/test/testcases/test.xml index a56da5de..6cbdcc17 100755 --- a/src/test/testcases/test.xml +++ b/src/test/testcases/test.xml @@ -33,7 +33,7 @@ ../simics/targets/p9_nimbus/sbeTest/testPSUSetStashPair.xml ../simics/targets/p9_nimbus/sbeTest/testIstep.xml ../simics/targets/p9_nimbus/sbeTest/testSuspendIO.xml - ../simics/targets/p9_nimbus/sbeTest/testScom.xml + ../simics/targets/p9_nimbus/sbeTest/testSecurity.xml ../simics/targets/p9_nimbus/sbeTest/testGeneric.xml ../simics/targets/p9_nimbus/sbeTest/testUnsecureMemRegions.xml @@ -52,7 +52,6 @@ ../simics/targets/p9_nimbus/sbeTest/testExecutorPutRing.xml ../simics/targets/p9_nimbus/sbeTest/testFastAccess.xml ../simics/targets/p9_nimbus/sbeTest/testQuiesce.xml - ../simics/targets/p9_nimbus/sbeTest/testSecurity.xml sbe-trace 0 diff --git a/src/test/testcases/testModifyScom.py b/src/test/testcases/testModifyScom.py deleted file mode 100755 index 487dae5b..00000000 --- a/src/test/testcases/testModifyScom.py +++ /dev/null @@ -1,98 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/test/testcases/testModifyScom.py $ -# -# OpenPOWER sbe Project -# -# Contributors Listed Below - COPYRIGHT 2016 -# [+] International Business Machines Corp. -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. -# -# IBM_PROLOG_END_TAG -import sys -sys.path.append("targets/p9_nimbus/sbeTest" ) -import testUtil -err = False -#from testWrite import * - - -PUTSCOM_TESTDATA = [0,0,0,6, - 0,0,0xA2,0x02, - 0,0,0x0,0x00, - 0,0x05,0x00,0x3E, #scratch reg 7 (32-bit) - 0x00,0xff,0x00,0xff, - 0x00,0x00,0x00,0x00 ] - -PUTSCOM_EXPDATA = [0xc0,0xde,0xa2,0x02, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - - -MODIFYSCOM_TESTDATA = [0,0,0,7, - 0,0,0xA2,0x03, - 0,0,0x0,0x01, - 0,0,0x0,0x00, - 0,0x05,0x00,0x3E, - 0xde,0x00,0xff,0x00, - 0x00,0x00,0x00,0x00] - -MODIFYSCOM_EXPDATA = [0xc0,0xde,0xa2,0x03, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - -GETSCOM4MODIFYSCOM_TESTDATA = [0,0,0,4, - 0,0,0xA2,0x01, - 0,0,0x0,0x00, - 0,0x05,0x0,0x3E] - -GETSCOM4MODIFYSCOM_EXPDATA = [0xde,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00, - 0xc0,0xde,0xa2,0x01, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - -# MAIN Test Run Starts Here... -#------------------------------------------------- -def main( ): - testUtil.runCycles( 10000000 ) - - testUtil.writeUsFifo( PUTSCOM_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( PUTSCOM_EXPDATA ) - testUtil.readEot( ) - - testUtil.writeUsFifo( MODIFYSCOM_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( MODIFYSCOM_EXPDATA ) - testUtil.readEot( ) - - testUtil.writeUsFifo( GETSCOM4MODIFYSCOM_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( GETSCOM4MODIFYSCOM_EXPDATA ) - testUtil.readEot( ) - -#------------------------------------------------- -# Calling all test code -#------------------------------------------------- -main() - -if err: - print ("\nTest Suite completed with error(s)") - #sys.exit(1) -else: - print ("\nTest Suite completed with no errors") - #sys.exit(0); - diff --git a/src/test/testcases/testPutGetInScom.py b/src/test/testcases/testPutGetInScom.py deleted file mode 100755 index 2aecb0e6..00000000 --- a/src/test/testcases/testPutGetInScom.py +++ /dev/null @@ -1,83 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/test/testcases/testPutGetInScom.py $ -# -# OpenPOWER sbe Project -# -# Contributors Listed Below - COPYRIGHT 2015,2016 -# [+] International Business Machines Corp. -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. -# -# IBM_PROLOG_END_TAG - -import sys -sys.path.append("targets/p9_nimbus/sbeTest" ) -import testUtil -err = False -#from testWrite import * - -# @TODO via RTC : 141905 -# Modify the test sequence in such a way that -# the test does not leave the Register value altered. - -# Indirect scom form 0 test case -PUTSCOM_TESTDATA = [0,0,0,6, - 0,0,0xA2,0x02, - 0x80,0x0,0x0,0x83, - 0x0D,0x01,0x0C,0x3F, - 0xde,0xca,0xff,0xee, - 0x00,0x00,0x12,0x34 ] - -PUTSCOM_EXPDATA = [0xc0,0xde,0xa2,0x02, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - -GETSCOM_TESTDATA = [0,0,0,4, - 0,0,0xA2,0x01, - 0x80,0x0,0x0,0x83, - 0x0D,0x01,0x0C,0x3F] - -GETSCOM_EXPDATA = [0x00,0x00,0x00,0x00, - 0x00,0x00,0x12,0x34, # Only last 16 bits will be returned - 0xc0,0xde,0xa2,0x01, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - -# MAIN Test Run Starts Here... -#------------------------------------------------- -def main( ): - testUtil.runCycles( 10000000 ) - testUtil.writeUsFifo( PUTSCOM_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( PUTSCOM_EXPDATA ) - testUtil.readEot( ) - testUtil.writeUsFifo( GETSCOM_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( GETSCOM_EXPDATA ) - testUtil.readEot( ) - -#------------------------------------------------- -# Calling all test code -#------------------------------------------------- -main() - -if err: - print ("\nTest Suite completed with error(s)") - #sys.exit(1) -else: - print ("\nTest Suite completed with no errors") - #sys.exit(0); - diff --git a/src/test/testcases/testPutGetScom.py b/src/test/testcases/testPutGetScom.py old mode 100755 new mode 100644 index 6378e114..8b5fe5ce --- a/src/test/testcases/testPutGetScom.py +++ b/src/test/testcases/testPutGetScom.py @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2016 +# Contributors Listed Below - COPYRIGHT 2016,2017 # [+] International Business Machines Corp. # # @@ -22,98 +22,12 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +import os import sys -sys.path.append("targets/p9_nimbus/sbeTest" ) -import testUtil -err = False -#from testWrite import * - -# @TODO via RTC : 141905 -# Modify the test sequence in such a way that -# the test does not leave the Register value altered. - -PUTSCOM_TESTDATA = [0,0,0,6, - 0,0,0xA2,0x02, - 0,0,0x0,0x00, - 0,0x05,0x00,0x3E, #scratch reg 7 (32-bit) - 0xde,0xca,0xff,0xee, - 0x00,0x00,0x00,0x00 ] - -PUTSCOM_TESTDATA_INVALID = [0,0,0,6, - 0,0,0xA2,0x02, - 0,0,0x0,0x00, - # TODO via RTC 152952: This address is invalid for - # Nimbus but not for Cumulus - 0x0a,0x00,0x00,0x00, - 0xde,0xca,0xff,0xee, - 0x00,0x00,0x00,0x00 ] - -PUTSCOM_EXPDATA = [0xc0,0xde,0xa2,0x02, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - -PUTSCOM_EXPDATA_INVALID = [0xc0,0xde,0xa2,0x02, - 0x0,0xfe,0x0,0x11] -GETSCOM_TESTDATA = [0,0,0,4, - 0,0,0xA2,0x01, - 0,0,0x0,0x00, - 0,0x05,0x0,0x3E] - -GETSCOM_TESTDATA_INVALID = [0,0,0,4, - 0,0,0xA2,0x01, - 0,0,0x0,0x00, - # TODO via RTC: 152952: This address is invalid for - # Nimbus but not for Cumulus - 0x0a,0x0,0x0,0x0] - -GETSCOM_EXPDATA = [0xde,0xca,0xff,0xee, - 0x00,0x00,0x00,0x00, - 0xc0,0xde,0xa2,0x01, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - -GETSCOM_EXPDATA_INVALID = [0xc0,0xde,0xa2,0x01, - 0x0,0xfe,0x0,0x11] -# MAIN Test Run Starts Here... -#------------------------------------------------- -def main( ): - testUtil.runCycles( 10000000 ) - print ("\nStarting putscom test") - testUtil.writeUsFifo( PUTSCOM_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( PUTSCOM_EXPDATA ) - testUtil.readEot( ) - print ("\nStarting invalid putscom test") - testUtil.writeUsFifo( PUTSCOM_TESTDATA_INVALID ) - testUtil.writeEot( ) - testUtil.readDsFifo( PUTSCOM_EXPDATA_INVALID ) - testUtil.extractHWPFFDC( ) - #flush out distance - testUtil.readDsEntryReturnVal() - testUtil.readEot( ) - print ("\nStarting getscom test") - testUtil.writeUsFifo( GETSCOM_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( GETSCOM_EXPDATA ) - testUtil.readEot( ) - print ("\nStarting invalid getscom test") - testUtil.writeUsFifo( GETSCOM_TESTDATA_INVALID ) - testUtil.writeEot( ) - testUtil.readDsFifo( GETSCOM_EXPDATA_INVALID ) - testUtil.extractHWPFFDC( ) - #flush out distance - testUtil.readDsEntryReturnVal() - testUtil.readEot( ) - -#------------------------------------------------- -# Calling all test code -#------------------------------------------------- -main() - -if err: - print ("\nTest Suite completed with error(s)") - #sys.exit(1) -else: - print ("\nTest Suite completed with no errors") - #sys.exit(0); +import struct +import testScomUtil +# getscom success +testScomUtil.getscom(0x0204001A) +# putscom success +testScomUtil.putscom(0x000F001A, testScomUtil.getscom(0x000F001A)) diff --git a/src/test/testcases/testPutScomUnderMask.py b/src/test/testcases/testPutScomUnderMask.py deleted file mode 100755 index 200c57a9..00000000 --- a/src/test/testcases/testPutScomUnderMask.py +++ /dev/null @@ -1,99 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/test/testcases/testPutScomUnderMask.py $ -# -# OpenPOWER sbe Project -# -# Contributors Listed Below - COPYRIGHT 2016 -# [+] International Business Machines Corp. -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. -# -# IBM_PROLOG_END_TAG -import sys -sys.path.append("targets/p9_nimbus/sbeTest" ) -import testUtil -err = False -#from testWrite import * - -PUTSCOM_TESTDATA = [0,0,0,6, - 0,0,0xA2,0x02, - 0,0,0x0,0x00, - 0,0x05,0x00,0x3E, #scratch reg 7 (32-bit) - 0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00 ] - -PUTSCOM_EXPDATA = [0xc0,0xde,0xa2,0x02, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - - -PUTSCOMUMASK_TESTDATA = [0,0,0,8, - 0,0,0xA2,0x04, - 0,0,0x0,0x00, - 0,0x05,0x00,0x3E, - 0xde,0xca,0xff,0xee, - 0x00,0x00,0x00,0x00, - 0xff,0x00,0xff,0x00, - 0x00,0x00,0x00,0x00] - - -PUTSCOMUMASK_EXPDATA = [0xc0,0xde,0xa2,0x04, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - -GETSCOMUMASK_TESTDATA = [0,0,0,4, - 0,0,0xA2,0x01, - 0,0,0x0,0x00, - 0,0x05,0x0,0x3E] - -GETSCOMUMASK_EXPDATA = [0xde, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, - 0xc0,0xde,0xa2,0x01, - 0x0,0x0,0x0,0x0, - 0x00,0x0,0x0,0x03]; - -# MAIN Test Run Starts Here... -#------------------------------------------------- -def main( ): - testUtil.runCycles( 10000000 ) - - testUtil.writeUsFifo( PUTSCOM_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( PUTSCOM_EXPDATA ) - testUtil.readEot( ) - - testUtil.writeUsFifo( PUTSCOMUMASK_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( PUTSCOMUMASK_EXPDATA ) - testUtil.readEot( ) - - testUtil.writeUsFifo( GETSCOMUMASK_TESTDATA ) - testUtil.writeEot( ) - testUtil.readDsFifo( GETSCOMUMASK_EXPDATA ) - testUtil.readEot( ) - -#------------------------------------------------- -# Calling all test code -#------------------------------------------------- -main() - -if err: - print ("\nTest Suite completed with error(s)") - #sys.exit(1) -else: - print ("\nTest Suite completed with no errors") - #sys.exit(0); - diff --git a/src/test/testcases/testSbeDump.py b/src/test/testcases/testSbeDump.py index 01ae81a7..f4f472a2 100644 --- a/src/test/testcases/testSbeDump.py +++ b/src/test/testcases/testSbeDump.py @@ -26,6 +26,7 @@ import sys sys.path.append("targets/p9_nimbus/sbeTest") import testUtil err = False +import testScomUtil #from testWrite import * TESTDATA = [0, 0, 0, 2, @@ -39,6 +40,10 @@ EXPDATA = [0xc0, 0xde, 0xa8, 0x01, #------------------------------------------------- def main(): testUtil.runCycles(10000000) + + # Generate FSPI rc + testScomUtil.getscom(0x0A000000, [0x00, 0xFE, 0x00, 0x11], True) + testUtil.writeUsFifo(TESTDATA) testUtil.writeEot() diff --git a/src/test/testcases/testScom.xml b/src/test/testcases/testScom.xml deleted file mode 100755 index 8b536031..00000000 --- a/src/test/testcases/testScom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - run-python-file targets/p9_nimbus/sbeTest/testPutGetScom.py - yes - - - run-python-file targets/p9_nimbus/sbeTest/testPutScomUnderMask.py - yes - - - run-python-file targets/p9_nimbus/sbeTest/testModifyScom.py - yes - - - run-python-file targets/p9_nimbus/sbeTest/testPutGetInScom.py - yes - - diff --git a/src/test/testcases/testScomUtil.py b/src/test/testcases/testScomUtil.py new file mode 100644 index 00000000..23b20005 --- /dev/null +++ b/src/test/testcases/testScomUtil.py @@ -0,0 +1,125 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/test/testcases/testScomUtil.py $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2017 +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG +import sys +import os +import struct +sys.path.append("targets/p9_nimbus/sbeTest" ) +import testUtil +err = False + +def getsingleword(dataInInt): + hex_string = '0'*(8-len(str(hex(dataInInt))[2:])) + str(hex(dataInInt))[2:] + return list(struct.unpack('L', os.urandom(4))[0] + if random_addr not in [eval(a) for a in whitelist]: + testScomUtil.putscom(random_addr, 0, [0x00, 0x05, 0x00, 0x0B]) + break + print "putscom failure testcase - passed" + # modify scom success + dataWritten = testScomUtil.getscom(0x00040006) + testScomUtil.modifyScom(0x01, 0x00040006, 0x0) + dataRead = testScomUtil.getscom(0x00040006) + if(dataRead != dataWritten): + raise Exception('modify scom failed %x != %x' % (dataRead, dataWritten)) + print "modify scom success testcase - passed" + # putscom under mask success + dataWritten = testScomUtil.getscom(0x00040006) + testScomUtil.putScomUnderMask(0x00040006, dataWritten, 0xFFFFFFFFFFFFFFFF) + dataRead = testScomUtil.getscom(0x00040006) + if(dataRead != dataWritten): + raise Exception('PutScom under mask failed %x != %x' % (dataRead, dataWritten)) + print "putscom under mask success testcase - passed" + # indirect scom test + dataWritten = testScomUtil.getscom(0x8000000D06010C3F) + dataiActWritten = (dataWritten & 0x00000000FFFFFFFF) | (0xDECAFFEE00000000) + testScomUtil.putscom(0x8000000D06010C3F, dataiActWritten) + dataRead = testScomUtil.getscom(0x8000000D06010C3F) + if(dataRead != dataWritten): + raise Exception('indirect scom test failed %x != %x' % (dataRead, dataWritten)) + print "Indirect scom success testcase - passed" + except Exception, error: raise Exception(error) -- cgit v1.2.1