[PATCH] uefirtmisc: add option to specify iterations get next high monitonic count

Sunny Wang Sunny.Wang at arm.com
Thu Jan 27 15:41:08 UTC 2022


The change looks GREAT, Ivan.
Appreciate your consideration of the case that FWTS is also being used for ONLY checking spec compliance (our case/SystemReady certificate). This significantly help ARM SiPs and ODMs/OEMs get rid of the confusion and uncertainty during the testing.
Moreover, can we also add an option for changing the uefi_set_variable_multiple value in uefirtvariable_test6? It will not only be helpful for avoiding the same problem as monitonic count but also good for the case that the user wants to run the test more times.

Reviewed-by: Sunny Wang <sunny.wang at arm.com>

Best Regards,
Sunny Wang
-----Original Message-----
From: fwts-devel <fwts-devel-bounces at lists.ubuntu.com> On Behalf Of Ivan Hu
Sent: 26 January 2022 08:57
To: fwts-devel at lists.ubuntu.com
Subject: [PATCH] uefirtmisc: add option to specify iterations get next high monitonic count

BugLink: https://bugs.launchpad.net/fwts/+bug/1958206
Set the default of get next high monotonic count stress test to 50, and add
option to specify iterations.

ex:
$sudo fwts --uefitests --uefi-get-mn-count-multiple=5

Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
 src/uefi/uefirtmisc/uefirtmisc.c | 54 ++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/uefi/uefirtmisc/uefirtmisc.c b/src/uefi/uefirtmisc/uefirtmisc.c
index f6038f5f..b3ee56ca 100644
--- a/src/uefi/uefirtmisc/uefirtmisc.c
+++ b/src/uefi/uefirtmisc/uefirtmisc.c
@@ -34,6 +34,9 @@
 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000
 #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000

+static uint32_t uefi_get_mn_count_multiple = 50;
+#define UEFI_GET_NEXT_HIGH_MN_COUNT_MULTIPLE_MAX       (10000)
+
 #define EFI_CAPSULE_GUID \
 { \
        0x3B6686BD, 0x0D76, 0x4030, {0xB7, 0x0E, 0xB5, \
@@ -197,7 +200,7 @@ static int uefirtmisc_test1(fwts_framework *fw)
 static int uefirtmisc_test2(fwts_framework *fw)
 {
        int ret;
-       uint32_t multitesttime = 512;
+       uint32_t multitesttime = uefi_get_mn_count_multiple;
        uint32_t i;

        static const uint32_t flag[] = {
@@ -214,7 +217,9 @@ static int uefirtmisc_test2(fwts_framework *fw)
                return FWTS_SKIP;
        }

-       fwts_log_info(fw, "Stress testing for UEFI runtime service GetNextHighMonotonicCount interface.");
+       fwts_log_info(fw, "Stress testing for UEFI runtime service "
+               "GetNextHighMonotonicCount interface %" PRIu32 " times.",
+               multitesttime);
        ret = getnexthighmonotoniccount_test(fw, multitesttime);
        if (ret == FWTS_OK)
                fwts_passed(fw, "UEFI runtime service GetNextHighMonotonicCount"
@@ -331,7 +336,47 @@ static int uefirtmisc_test4(fwts_framework *fw)
        return FWTS_OK;
 }

+static int options_check(fwts_framework *fw)
+{
+       FWTS_UNUSED(fw);
+
+       if ((uefi_get_mn_count_multiple < 1) ||
+           (uefi_get_mn_count_multiple >
+           UEFI_GET_NEXT_HIGH_MN_COUNT_MULTIPLE_MAX)) {
+               fprintf(stderr, "uefi_get_mn_count_multiple is %"
+                       PRIu32 ", it should be 1..%" PRIu32 "\n",
+                       uefi_get_mn_count_multiple,
+                       UEFI_GET_NEXT_HIGH_MN_COUNT_MULTIPLE_MAX);
+               return FWTS_ERROR;
+       }
+       return FWTS_OK;
+}
+
+static int options_handler(
+       fwts_framework *fw,
+       int argc,
+       char * const argv[],
+       int option_char,
+       int long_index)
+{
+       FWTS_UNUSED(fw);
+       FWTS_UNUSED(argc);
+       FWTS_UNUSED(argv);
+
+       if (option_char == 0) {
+               switch (long_index) {
+               case 0: /* --uefi_get_mn_count_multiple */
+                       uefi_get_mn_count_multiple = strtoul(optarg, NULL, 10);
+                       break;
+               }
+       }
+       return FWTS_OK;
+}

+static fwts_option options[] = {
+       { "uefi-get-mn-count-multiple", "", 1, "Run uefirtmisc getnexthighmonotoniccount test multiple times." },
+       { NULL, NULL, 0, NULL }
+};
 static fwts_framework_minor_test uefirtmisc_tests[] = {
        { uefirtmisc_test1, "Test for UEFI miscellaneous runtime service interfaces." },
        { uefirtmisc_test2, "Stress test for UEFI miscellaneous runtime service interfaces." },
@@ -344,7 +389,10 @@ static fwts_framework_ops uefirtmisc_ops = {
        .description = "UEFI miscellaneous runtime service interface tests.",
        .init        = uefirtmisc_init,
        .deinit      = uefirtmisc_deinit,
-       .minor_tests = uefirtmisc_tests
+       .minor_tests = uefirtmisc_tests,
+       .options         = options,
+       .options_handler = options_handler,
+       .options_check   = options_check
 };

 FWTS_REGISTER("uefirtmisc", &uefirtmisc_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_UEFI | FWTS_FLAG_UNSAFE | FWTS_FLAG_ROOT_PRIV | FWTS_FLAG_XBBR)
--
2.25.1


--
fwts-devel mailing list
fwts-devel at lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/fwts-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the fwts-devel mailing list