Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard changes #2

Merged
merged 5 commits into from
Sep 7, 2021
Merged

Guard changes #2

merged 5 commits into from
Sep 7, 2021

Conversation

chiragsibm
Copy link

This commit contains the changes related in libguard

Copy link
Collaborator

@RameshIyyar RameshIyyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Reviewed last three commits

Please make sure which name is best resolved vs invalid

libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/include/guard_record.hpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.hpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@RameshIyyar RameshIyyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please add UT for all exceptions (wherever is possible).
  • Please document the exception usage like what is the scope of that exception and conditions that need to meet to use that exception to throw.
  • I have added comments for one exception it applicable to all exceptions.
  • I would spit patches differently.
    • Add a separate patch for all exceptions, good documentation with the condition, details in the commit message, and UT (if possible).
    • Add a patch to throw each exception (more than one throw is possible for the same exception) from libguard and UT (if possible) - it help to reviewer to ask - is there anything to consider for that exception from existing code.

libguard/guard_exception.hpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
@RameshIyyar
Copy link
Collaborator

RameshIyyar commented Jun 30, 2021

Please rebase your patch before pushing the next patch set for this pr

libguard/guard_exception.hpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
@chiragsibm chiragsibm force-pushed the guard_changes branch 2 times, most recently from ba21247 to 07b2b12 Compare July 16, 2021 08:44
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
guard.cpp Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
test/guard_intf_test.cpp Show resolved Hide resolved
test/guard_intf_test.cpp Outdated Show resolved Hide resolved
@chiragsibm chiragsibm force-pushed the guard_changes branch 2 times, most recently from ef11c3a to 4eafe6c Compare July 26, 2021 23:52
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Show resolved Hide resolved
libguard/guard_interface.cpp Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.hpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
test/guard_intf_test.cpp Show resolved Hide resolved
test/guard_intf_test.cpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Show resolved Hide resolved
libguard/guard_file.cpp Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
test/guard_intf_test.cpp Show resolved Hide resolved
libguard/guard_interface.cpp Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
guard.cpp Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.hpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_file.cpp Outdated Show resolved Hide resolved
libguard/guard_file.cpp Outdated Show resolved Hide resolved
libguard/guard_file.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
if (!isHeaderPrinted)
{
std::cout << "No "
<< (displayResolved == true ? "resolved" : "unresolved")
Copy link
Collaborator

@RameshIyyar RameshIyyar Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS: displayResolved == true ? -> displayResolved ?

guard.cpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
@chiragsibm chiragsibm force-pushed the guard_changes branch 2 times, most recently from 2083004 to b0de547 Compare August 30, 2021 17:23
@dhruvibm
Copy link
Collaborator

Looks good to me

libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
@chiragsibm chiragsibm force-pushed the guard_changes branch 2 times, most recently from e6a25b7 to 3c848c9 Compare September 1, 2021 06:26
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@chiragsibm chiragsibm force-pushed the guard_changes branch 2 times, most recently from ea8fa52 to a4edcb6 Compare September 3, 2021 06:14
README.md Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Show resolved Hide resolved
libguard/guard_interface.cpp Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Show resolved Hide resolved
libguard/guard_interface.cpp Show resolved Hide resolved
README.md Show resolved Hide resolved
Changes:
-Adding check in create API, which will calculate the available
size in the file before writing the guard record.

Signed-off-by: Chirag Sharma <[email protected]>
guard.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Outdated Show resolved Hide resolved
libguard/guard_exception.hpp Show resolved Hide resolved
guard.cpp Outdated Show resolved Hide resolved
libguard/guard_interface.cpp Outdated Show resolved Hide resolved
libguard/guard_common.hpp Outdated Show resolved Hide resolved
Chirag Sharma added 2 commits September 6, 2021 06:18
Changes:
-Currently in libguard the guard records were wiped out
from the file, but changing it now to maintain the record
history. Hence instead of deleting, making the recordID
as FFFFFFFF and not displaying it.
-Change in create guard function, for marking correct recordId
because of change in delete function as we are marking recordId
as FF..FF it will take maxId is that and will not allocate correct
recordId to newly created guard record.
-Allowing to create guard of resolved guard record
-Adding function invalidateAll to invalidate all the guard records
i.e. mark recordId as FFFFFFFF for all the guard records present.
-Changing clearAll function to erase the data in guard file.
-Adding UT for invalidateAll function.
-Changes in Guard tool to not display invalidated guard records.

Test:
-Created guard record deleted the same, the recordId was setting
to FFFFFFFF and not getting displaying in guard tool output.
-Clearall is marking all recordId as FF...FF
-Created a guard record and deleted the same, tried to guard
the same record.

Signed-off-by: Chirag Sharma <[email protected]>
Change:
-Adding check in create api to store the location/position
of invalid/resolved record, incase there is no space left
that resolved record position will be used to create a
new record.
-Adding UT for the above change where when no space is
left in guard file the oldest guard records will be replaced
with the new guard record.

Test:
-Created guard records and deleted few of them,
for the deleted guard records record id got set
to 0xFFFFFFFF. When no space is left in guard file
the 1st resolved record location will be used to create
the new record.

Signed-off-by: Chirag Sharma <[email protected]>
README.md Show resolved Hide resolved
Chirag Sharma added 2 commits September 7, 2021 00:26
Changes:
-Adding user defined exceptions in libguard so that the caller
can distinguish the type of error at his end.
-Changes in respective UTs.

Test:
Created guard record, tried creating the same.
Deleting a non guarded record.
Ran UTs in docker env.

Signed-off-by: Chirag Sharma <[email protected]>
Changes:
-Making options of guardtool more meaningful as per the
backend functionality.
Like -d to -i, this will Invalidate a single Guard record
Changing --clear-all to --reset, which will erase all the
guard records.
-Adding -I, will Invalidates all the Guard records
-Adding -a option to list the resolved guard records
-Updating README with new options
-Setting GUARD_VERSION in meason.build to return correct value.

Test:
-creating and invalidating guard records, checking if its getting
displayed with new option or not.
-with changed options able to invalidate the guard records.

[==========] Running 15 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 15 tests from TestGuardRecord
[ RUN      ] TestGuardRecord.CreateGuardRecord
[       OK ] TestGuardRecord.CreateGuardRecord (0 ms)
[ RUN      ] TestGuardRecord.ClearGuardGoodPathTest
[       OK ] TestGuardRecord.ClearGuardGoodPathTest (0 ms)
[ RUN      ] TestGuardRecord.DeleteGuardGoodPathTest
[       OK ] TestGuardRecord.DeleteGuardGoodPathTest (0 ms)
[ RUN      ] TestGuardRecord.NegTestCaseEP
[       OK ] TestGuardRecord.NegTestCaseEP (0 ms)
[ RUN      ] TestGuardRecord.NegTestCaseFullGuardFile
Guard file size is 656 and space remaining in GUARD file is 0

[       OK ] TestGuardRecord.NegTestCaseFullGuardFile (0 ms)
[ RUN      ] TestGuardRecord.AlreadyGuardedTC
Already guard record is available in the GUARD partition
[       OK ] TestGuardRecord.AlreadyGuardedTC (0 ms)
[ RUN      ] TestGuardRecord.GetCreatedGuardRecordTC
[       OK ] TestGuardRecord.GetCreatedGuardRecordTC (0 ms)
[ RUN      ] TestGuardRecord.DeleteByEntityPath
[       OK ] TestGuardRecord.DeleteByEntityPath (0 ms)
[ RUN      ] TestGuardRecord.DeleteWithNotExistentEntity
Guard record not found
[       OK ] TestGuardRecord.DeleteWithNotExistentEntity (0 ms)
[ RUN      ] TestGuardRecord.DeleteByRecordId
[       OK ] TestGuardRecord.DeleteByRecordId (0 ms)
[ RUN      ] TestGuardRecord.DeleteWithNotExistentRecordId
Guard record not found
[       OK ] TestGuardRecord.DeleteWithNotExistentRecordId (0 ms)
[ RUN      ] TestGuardRecord.GetGuardFilePathTC
[       OK ] TestGuardRecord.GetGuardFilePathTC (0 ms)
[ RUN      ] TestGuardRecord.GetGuardFilePathWhenLibguradDidNotInitTC
Guard file is not initialised.
[       OK ] TestGuardRecord.GetGuardFilePathWhenLibguradDidNotInitTC (0 ms)
[ RUN      ] TestGuardRecord.ClearGuardInvalidatePathTest
[       OK ] TestGuardRecord.ClearGuardInvalidatePathTest (0 ms)
[ RUN      ] TestGuardRecord.ClearResolvedGuardRecord
[       OK ] TestGuardRecord.ClearResolvedGuardRecord (0 ms)
[----------] 15 tests from TestGuardRecord (4 ms total)

[----------] Global test environment tear-down
[==========] 15 tests from 1 test suite ran. (5 ms total)
[  PASSED  ] 15 tests.
------------------------------------------------------------------------------
Ok:                 1
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            0
Timeout:            0

Signed-off-by: Chirag Sharma <[email protected]>
Copy link
Collaborator

@RameshIyyar RameshIyyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Tested with HardwareIsolation manager to make sure actual libguard is working or not.

@ojayanth ojayanth merged commit ebb9771 into open-power:main Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants