diff mbox series

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

Message ID 20220126085716.57274-1-ivan.hu@canonical.com
State Accepted
Headers show
Series uefirtmisc: add option to specify iterations get next high monitonic count | expand

Commit Message

ivanhu Jan. 26, 2022, 8:57 a.m. UTC
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@canonical.com>
---
 src/uefi/uefirtmisc/uefirtmisc.c | 54 ++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 3 deletions(-)

Comments

Sunny Wang Jan. 27, 2022, 3:41 p.m. UTC | #1
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@arm.com>

Best Regards,
Sunny Wang
-----Original Message-----
From: fwts-devel <fwts-devel-bounces@lists.ubuntu.com> On Behalf Of Ivan Hu
Sent: 26 January 2022 08:57
To: fwts-devel@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@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@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.
ivanhu Jan. 28, 2022, 12:51 a.m. UTC | #2
Hi Sunny,


"--uefi-set-var-multiple"  had already been provided, please check with
$fwts -h


Cheers,

Ivan


On 1/27/22 23:41, Sunny Wang wrote:
> 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@arm.com>
>
> Best Regards,
> Sunny Wang
> -----Original Message-----
> From: fwts-devel <fwts-devel-bounces@lists.ubuntu.com> On Behalf Of Ivan Hu
> Sent: 26 January 2022 08:57
> To: fwts-devel@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@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@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.
Sunny Wang Jan. 28, 2022, 9:54 a.m. UTC | #3
Great! Thanks, Ivan.
Is it possible to push this commit by next Tuesday or earlier? We would like to merge this change into our next ACS release.

Best Regards,
Sunny

-----Original Message-----
From: ivanhu <ivan.hu@canonical.com>
Sent: 28 January 2022 00:51
To: Sunny Wang <Sunny.Wang@arm.com>; fwts-devel@lists.ubuntu.com
Subject: Re: [PATCH] uefirtmisc: add option to specify iterations get next high monitonic count

Hi Sunny,


"--uefi-set-var-multiple"  had already been provided, please check with
$fwts -h


Cheers,

Ivan


On 1/27/22 23:41, Sunny Wang wrote:
> 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@arm.com>
>
> Best Regards,
> Sunny Wang
> -----Original Message-----
> From: fwts-devel <fwts-devel-bounces@lists.ubuntu.com> On Behalf Of Ivan Hu
> Sent: 26 January 2022 08:57
> To: fwts-devel@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@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@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.
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.
Alex Hung Jan. 29, 2022, 2:34 a.m. UTC | #4
On 2022-01-26 01:57, Ivan Hu wrote:
> 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@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)


Acked-by: Alex Hung <alex.hung@canonical.com>
Sunny Wang Feb. 7, 2022, 11:23 a.m. UTC | #5
Thanks much for satisfying our request, Ivan.
We tested it with our ACS, and it works perfectly!

Best Regards,
Sunny
-----Original Message-----
From: Sunny Wang <Sunny.Wang@arm.com>
Sent: 28 January 2022 09:54
To: ivanhu <ivan.hu@canonical.com>; fwts-devel@lists.ubuntu.com
Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>; Sunny Wang <Sunny.Wang@arm.com>
Subject: RE: [PATCH] uefirtmisc: add option to specify iterations get next high monitonic count

Great! Thanks, Ivan.
Is it possible to push this commit by next Tuesday or earlier? We would like to merge this change into our next ACS release.

Best Regards,
Sunny

-----Original Message-----
From: ivanhu <ivan.hu@canonical.com>
Sent: 28 January 2022 00:51
To: Sunny Wang <Sunny.Wang@arm.com>; fwts-devel@lists.ubuntu.com
Subject: Re: [PATCH] uefirtmisc: add option to specify iterations get next high monitonic count

Hi Sunny,


"--uefi-set-var-multiple"  had already been provided, please check with
$fwts -h


Cheers,

Ivan


On 1/27/22 23:41, Sunny Wang wrote:
> 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@arm.com>
>
> Best Regards,
> Sunny Wang
> -----Original Message-----
> From: fwts-devel <fwts-devel-bounces@lists.ubuntu.com> On Behalf Of Ivan Hu
> Sent: 26 January 2022 08:57
> To: fwts-devel@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@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@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.
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.
diff mbox series

Patch

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)