From patchwork Thu May 13 10:01:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1477984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FgnJ40gljz9sTD for ; Thu, 13 May 2021 20:01:56 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lh8AD-0000aU-Fr; Thu, 13 May 2021 10:01:53 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lh8AB-0000aO-MC for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:01:51 +0000 Received: from 112-104-30-83.adsl.dynamic.seed.net.tw ([112.104.30.83] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lh8AA-0005a1-R3 for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:01:51 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/4] uefirttime: check time services supported before testing (LP: #1913351) Date: Thu, 13 May 2021 18:01:42 +0800 Message-Id: <20210513100145.29713-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" UEFI runtime tests are being done without checking RTPROT table which intruduced after UEFI 2.8a. This might lead to false alarm for those unsupported runtime service platforms. Add checking the time services supported status before runing the related tests. Signed-off-by: Ivan Hu Acked-by: Alex Hung Acked-by: Colin Ian King --- src/uefi/uefirttime/uefirttime.c | 84 ++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/uefi/uefirttime/uefirttime.c b/src/uefi/uefirttime/uefirttime.c index e2ab7d61..41503843 100644 --- a/src/uefi/uefirttime/uefirttime.c +++ b/src/uefi/uefirttime/uefirttime.c @@ -199,6 +199,12 @@ static int uefirttime_test1(fwts_framework *fw) EFI_TIME_CAPABILITIES efi_time_cap; uint64_t status = ~0ULL; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Capabilities = &efi_time_cap; gettime.Time = &efi_time; gettime.status = &status; @@ -234,6 +240,12 @@ static int uefirttime_test_gettime_invalid( struct efi_gettime gettime; uint64_t status = ~0ULL; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Capabilities = efi_time_cap; gettime.Time = efi_time; gettime.status = &status; @@ -286,6 +298,12 @@ static int uefirttime_test4(fwts_framework *fw) EFI_TIME time; EFI_TIME_CAPABILITIES efi_time_cap; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Capabilities = &efi_time_cap; gettime.Time = &oldtime; gettime.status = &status; @@ -330,6 +348,12 @@ static int uefirttime_test4(fwts_framework *fw) /* Unspecified timezone, local time */ time.TimeZone = 2047; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME)) { + fwts_skipped(fw, "Skipping test, SetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + settime.Time = &time; status = ~0ULL; settime.status = &status; @@ -424,6 +448,12 @@ static int uefirttime_test_settime_invalid( long ioret; static uint64_t status; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME)) { + fwts_skipped(fw, "Skipping test, SetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + status = ~0ULL; settime->status = &status; @@ -460,6 +490,12 @@ static int uefirttime_test_settime_invalid_time( uint64_t status = ~0ULL; int ret, ioret; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Time = &oldtime; gettime.status = &status; gettime.Capabilities = NULL; @@ -500,6 +536,9 @@ static int uefirttime_test_settime_invalid_time( ret = uefirttime_test_settime_invalid(fw, &settime); + if (ret == FWTS_SKIP) + return ret; + /* Restore original time */ settime.Time = &oldtime; status = ~0ULL; @@ -654,6 +693,12 @@ static int uefirttime_test18(fwts_framework *fw) uint8_t enabled, pending; EFI_TIME efi_time; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, GetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + getwakeuptime.Enabled = &enabled; getwakeuptime.Pending = &pending; getwakeuptime.Time = &efi_time; @@ -687,6 +732,12 @@ static int uefirttime_test_getwaketime_invalid( long ioret; static uint64_t status; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, GetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + status = ~0ULL; getwakeuptime->status = &status; @@ -777,6 +828,12 @@ static int uefirttime_test23(fwts_framework *fw) struct efi_getwakeuptime getwakeuptime; uint8_t enabled, pending; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Capabilities = &efi_time_cap; gettime.Time = &oldtime; gettime.status = &status; @@ -795,6 +852,12 @@ static int uefirttime_test23(fwts_framework *fw) return FWTS_ERROR; } + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, SetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + /* change the hour, add 1 hour*/ addonehour(&oldtime); @@ -818,6 +881,12 @@ static int uefirttime_test23(fwts_framework *fw) sleep(1); + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, SetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + getwakeuptime.Enabled = &enabled; getwakeuptime.Pending = &pending; getwakeuptime.Time = &newtime; @@ -907,6 +976,12 @@ static int uefirttime_test_setwakeuptime_invalid( long ioret; static uint64_t status; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, SetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + status = ~0ULL; setwakeuptime->status = &status; @@ -954,6 +1029,12 @@ static int uefirttime_test_setwakeuptime_invalid_time( uint8_t pending, enabled; int ret, ioret; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, GetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + getwakeuptime.Enabled = &enabled; getwakeuptime.Pending = &pending; getwakeuptime.Time = &oldtime; @@ -996,6 +1077,9 @@ static int uefirttime_test_setwakeuptime_invalid_time( ret = uefirttime_test_setwakeuptime_invalid(fw, &setwakeuptime); + if (ret == FWTS_SKIP) + return ret; + /* Restore original time */ setwakeuptime.Time = &oldtime; status = ~0ULL; From patchwork Thu May 13 10:01:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1477985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FgnJ80sCKz9sTD for ; Thu, 13 May 2021 20:02:00 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lh8AH-0000bL-Ic; Thu, 13 May 2021 10:01:57 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lh8AF-0000au-Ot for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:01:55 +0000 Received: from 112-104-30-83.adsl.dynamic.seed.net.tw ([112.104.30.83] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lh8AE-0005ad-UA for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:01:55 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/4] uefirtmisc: check misc runtime services supported before testing (LP: #1913351) Date: Thu, 13 May 2021 18:01:43 +0800 Message-Id: <20210513100145.29713-2-ivan.hu@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513100145.29713-1-ivan.hu@canonical.com> References: <20210513100145.29713-1-ivan.hu@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" UEFI runtime tests are being done without checking RTPROT table which intruduced after UEFI 2.8a. This might lead to false alarm for those unsupported runtime service platforms. Add checking the miscellaneous services supported status before runing the related tests. Signed-off-by: Ivan Hu Acked-by: Alex Hung Acked-by: Colin Ian King --- src/uefi/uefirtmisc/uefirtmisc.c | 54 +++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/src/uefi/uefirtmisc/uefirtmisc.c b/src/uefi/uefirtmisc/uefirtmisc.c index 580f92ac..bddff487 100644 --- a/src/uefi/uefirtmisc/uefirtmisc.c +++ b/src/uefi/uefirtmisc/uefirtmisc.c @@ -72,6 +72,12 @@ static int getnexthighmonotoniccount_test(fwts_framework *fw, uint32_t multitest uint32_t highcount; uint32_t i; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT)) { + fwts_skipped(fw, "Skipping test, GetNextHighMonotonicCount " + "runtime service is not supported on this platform."); + return FWTS_SKIP; + } + getnexthighmonotoniccount.HighCount = &highcount; getnexthighmonotoniccount.status = &status; @@ -107,6 +113,12 @@ static int querycapsulecapabilities_test(fwts_framework *fw, uint32_t multitestt uint64_t maxcapsulesize; uint64_t capsulecount; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES)) { + fwts_skipped(fw, "Skipping test, QueryCapsuleCapabilities " + "runtime service is not supported on this platform."); + return FWTS_SKIP; + } + memset(&capsuleheader, 0, sizeof(capsuleheader)); pcapsuleheaderarray[0] = &capsuleheader; @@ -162,10 +174,9 @@ static int uefirtmisc_test1(fwts_framework *fw) fwts_log_info(fw, "Testing UEFI runtime service GetNextHighMonotonicCount interface."); ret = getnexthighmonotoniccount_test(fw, multitesttime); - if (ret != FWTS_OK) - return ret; - - fwts_passed(fw, "UEFI runtime service GetNextHighMonotonicCount interface test passed."); + if (ret == FWTS_OK) + fwts_passed(fw, "UEFI runtime service GetNextHighMonotonicCount" + " interface test passed."); fwts_log_info(fw, "Testing UEFI runtime service QueryCapsuleCapabilities interface."); for (i = 0; i < (sizeof(flag)/(sizeof flag[0])); i++) { @@ -175,10 +186,12 @@ static int uefirtmisc_test1(fwts_framework *fw) if (ret != FWTS_OK) return ret; - fwts_passed(fw, "UEFI runtime service QueryCapsuleCapabilities interface test with flag value 0x%"PRIx32 " passed.", flag[i]); + fwts_passed(fw, "UEFI runtime service QueryCapsuleCapabilities" + " interface test with flag value 0x%"PRIx32 " passed.", + flag[i]); } - return FWTS_OK; + return ret; } static int uefirtmisc_test2(fwts_framework *fw) @@ -195,12 +208,23 @@ static int uefirtmisc_test2(fwts_framework *fw) CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE | CAPSULE_FLAGS_INITIATE_RESET }; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT)) { + fwts_skipped(fw, "Skipping test, GetNextHighMonotonicCount " + "runtime service is not supported on this platform."); + return FWTS_SKIP; + } + fwts_log_info(fw, "Stress testing for UEFI runtime service GetNextHighMonotonicCount interface."); ret = getnexthighmonotoniccount_test(fw, multitesttime); - if (ret != FWTS_OK) - return ret; + if (ret == FWTS_OK) + fwts_passed(fw, "UEFI runtime service GetNextHighMonotonicCount" + " interface test passed."); - fwts_passed(fw, "UEFI runtime service GetNextHighMonotonicCount interface stress test passed."); + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES)) { + fwts_skipped(fw, "Skipping test, QueryCapsuleCapabilities " + "runtime service is not supported on this platform."); + return FWTS_SKIP; + } fwts_log_info(fw, "Stress testing UEFI runtime service QueryCapsuleCapabilities interface."); for (i = 0; i < (sizeof(flag)/(sizeof flag[0])); i++) { @@ -209,11 +233,13 @@ static int uefirtmisc_test2(fwts_framework *fw) continue; if (ret != FWTS_OK) return ret; - fwts_passed(fw, "UEFI runtime service QueryCapsuleCapabilities interface stress test with flag value 0x%" PRIx32 " passed.", flag[i]); + fwts_passed(fw, "UEFI runtime service QueryCapsuleCapabilities" + " interface test with flag value 0x%"PRIx32 " passed.", + flag[i]); } - return FWTS_OK; + return ret; } static int uefirtmisc_test3(fwts_framework *fw) @@ -222,6 +248,12 @@ static int uefirtmisc_test3(fwts_framework *fw) long ioret; struct efi_getnexthighmonotoniccount getnexthighmonotoniccount; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT)) { + fwts_skipped(fw, "Skipping test, GetNextHighMonotonicCount " + "runtime service is not supported on this platform."); + return FWTS_SKIP; + } + getnexthighmonotoniccount.HighCount = NULL; getnexthighmonotoniccount.status = &status; From patchwork Thu May 13 10:01:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1477986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FgnJD1hf2z9sTD for ; Thu, 13 May 2021 20:02:04 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lh8AL-0000d1-MD; Thu, 13 May 2021 10:02:01 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lh8AK-0000cG-70 for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:02:00 +0000 Received: from 112-104-30-83.adsl.dynamic.seed.net.tw ([112.104.30.83] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lh8AJ-0005b0-Ap for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:02:00 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 3/4] uefirtvariable: check variable runtime services supported before testing (LP: #1913351) Date: Thu, 13 May 2021 18:01:44 +0800 Message-Id: <20210513100145.29713-3-ivan.hu@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513100145.29713-1-ivan.hu@canonical.com> References: <20210513100145.29713-1-ivan.hu@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" UEFI runtime tests are being done without checking RTPROT table which intruduced after UEFI 2.8a. This might lead to false alarm for those unsupported runtime service platforms. Add checking the variable services supported status before runing the related tests. Signed-off-by: Ivan Hu Acked-by: Alex Hung Acked-by: Colin Ian King --- src/uefi/uefirtvariable/uefirtvariable.c | 109 +++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index db0e80bb..b756ac96 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -134,6 +134,12 @@ static int getvariable_test( uint8_t data[datasize]; uint32_t i; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, SetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + for (dataindex = 0; dataindex < datasize; dataindex++) data[dataindex] = (uint8_t)dataindex; @@ -169,6 +175,12 @@ static int getvariable_test( return FWTS_ERROR; } + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, GetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + getvariable.VariableName = varname; getvariable.VendorGuid = >estguid1; getvariable.Attributes = &attributestest; @@ -311,6 +323,12 @@ static int getnextvariable_test1(fwts_framework *fw) bool found_name = false, found_guid = false; int ret = FWTS_OK; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, SetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + for (dataindex = 0; dataindex < datasize; dataindex++) data[dataindex] = (uint8_t)dataindex; @@ -346,6 +364,12 @@ static int getnextvariable_test1(fwts_framework *fw) return FWTS_ERROR; } + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) { + fwts_skipped(fw, "Skipping test, GetNextVariableName runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + variablename = malloc(sizeof(uint16_t) * variablenamesize); if (!variablename) { fwts_skipped(fw, "Unable to alloc memory for variable name"); @@ -497,6 +521,12 @@ static int getnextvariable_test2(fwts_framework *fw) EFI_GUID vendorguid; int ret = FWTS_OK; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) { + fwts_skipped(fw, "Skipping test, GetNextVariableName runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + variablename = malloc(sizeof(uint16_t) * variablenamesize); if (!variablename) { fwts_skipped(fw, "Unable to alloc memory for variable name"); @@ -662,6 +692,12 @@ static int getnextvariable_test3(fwts_framework *fw) EFI_GUID vendorguid; int ret; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) { + fwts_skipped(fw, "Skipping test, GetNextVariableName runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + variablename = malloc(sizeof(uint16_t) * variablenamesize); if (!variablename) { fwts_skipped(fw, "Unable to alloc memory for variable name"); @@ -795,6 +831,12 @@ static int getnextvariable_test4(fwts_framework *fw) uint16_t variablename[MAX_DATA_LENGTH]; EFI_GUID vendorguid; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) { + fwts_skipped(fw, "Skipping test, GetNextVariableName runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + getnextvariablename.VariableNameSize = &variablenamesize; getnextvariablename.VendorGuid = &vendorguid; getnextvariablename.status = &status; @@ -912,6 +954,12 @@ static int setvariable_insertvariable( uint8_t data[datasize + 1]; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, SetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + for (dataindex = 0; dataindex < datasize; dataindex++) data[dataindex] = (uint8_t)dataindex + datadiff; @@ -987,6 +1035,12 @@ static int setvariable_checkvariable( uint64_t getdatasize = sizeof(testdata); uint32_t attributestest; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, GetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + getvariable.VariableName = varname; getvariable.VendorGuid = gtestguid; getvariable.Attributes = &attributestest; @@ -1047,6 +1101,12 @@ static int setvariable_checkvariable_notfound( uint64_t getdatasize = sizeof(testdata); uint32_t attributestest; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, GetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + getvariable.VariableName = varname; getvariable.VendorGuid = gtestguid; getvariable.Attributes = &attributestest; @@ -1086,6 +1146,13 @@ static int setvariable_invalidattr( uint64_t dataindex; uint8_t data[datasize]; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, SetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + + for (dataindex = 0; dataindex < datasize; dataindex++) data[dataindex] = (uint8_t)dataindex + datadiff; @@ -1437,6 +1504,12 @@ static int setvariable_test8(fwts_framework *fw) uint8_t data = 1; uint64_t status = ~0ULL; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, SetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + setvariable.VariableName = variablenametest; setvariable.VendorGuid = >estguid1; setvariable.Attributes = attr; @@ -1500,6 +1573,12 @@ static int getnextvariable_multitest( uint16_t variablename[MAX_DATA_LENGTH]; EFI_GUID vendorguid; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, SetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + for (dataindex = 0; dataindex < datasize; dataindex++) data[dataindex] = (uint8_t)dataindex; @@ -1534,6 +1613,12 @@ static int getnextvariable_multitest( return FWTS_ERROR; } + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) { + fwts_skipped(fw, "Skipping test, GetNextVariableName runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + getnextvariablename.VariableNameSize = &variablenamesize; getnextvariablename.VariableName = variablename; getnextvariablename.VendorGuid = &vendorguid; @@ -1697,6 +1782,12 @@ static int uefirtvariable_test4(fwts_framework *fw) uint64_t remvarstoragesize; uint64_t maxvariablesize; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)) { + fwts_skipped(fw, "Skipping test, QueryVariableInfo runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + if (do_queryvariableinfo(&status, &remvarstoragesize, &maxvariablesize) == FWTS_ERROR) { if (status == EFI_UNSUPPORTED) { fwts_skipped(fw, @@ -1846,6 +1937,12 @@ static int uefirtvariable_test7(fwts_framework *fw) fwts_log_info(fw, "Testing QueryVariableInfo on querying the variable %" PRIu32 " times.", uefi_query_variable_multiple); + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)) { + fwts_skipped(fw, "Skipping test, QueryVariableInfo runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + /* first check if the firmware support QueryVariableInfo interface */ if (do_queryvariableinfo(&status, &remvarstoragesize, &maxvariablesize) == FWTS_ERROR) { if (status == EFI_UNSUPPORTED) { @@ -1890,6 +1987,12 @@ static void getvariable_test_invalid( { long ioret; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, GetVariable runtime service " + "is not supported on this platform."); + return; + } + fwts_log_info(fw, "Testing GetVariable with %s.", test); *(getvariable->status) = ~0ULL; @@ -1933,6 +2036,12 @@ static int uefirtvariable_test8(fwts_framework *fw) uint32_t attr; int ioret; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, SetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + for (dataindex = 0; dataindex < sizeof(data); dataindex++) data[dataindex] = (uint8_t)dataindex; From patchwork Thu May 13 10:01:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1477987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FgnJJ1sT1z9sTD for ; Thu, 13 May 2021 20:02:08 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lh8AP-0000eW-PE; Thu, 13 May 2021 10:02:05 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lh8AO-0000e8-85 for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:02:04 +0000 Received: from 112-104-30-83.adsl.dynamic.seed.net.tw ([112.104.30.83] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lh8AN-0005bT-Ag for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:02:04 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 4/4] uefirtauthvar: check variable runtime services supported before testing (LP: #1913351) Date: Thu, 13 May 2021 18:01:45 +0800 Message-Id: <20210513100145.29713-4-ivan.hu@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513100145.29713-1-ivan.hu@canonical.com> References: <20210513100145.29713-1-ivan.hu@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" The uefirtauthvar tests use the getvariable and setvariable runtime services. Add checking the get and set variable services supported status before runing the related tests. Signed-off-by: Ivan Hu Acked-by: Alex Hung Acked-by: Colin Ian King --- src/uefi/uefirtauthvar/uefirtauthvar.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c index 644d99c9..e6ab9d45 100644 --- a/src/uefi/uefirtauthvar/uefirtauthvar.c +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c @@ -54,6 +54,8 @@ static const uint32_t attributes = static uint16_t variablenametest[] = {'A', 'u', 't', 'h', 'V', 'a', 'r', 'T', 'e', 's', 't', '\0'}; +static uint32_t runtimeservicessupported; + static long setvar( EFI_GUID *guid, uint32_t var_attributes, @@ -118,6 +120,18 @@ static int uefirtauthvar_init(fwts_framework *fw) if (fwts_lib_efi_runtime_module_init(fw, &fd) == FWTS_ABORTED) return FWTS_ABORTED; + fwts_uefi_rt_support_status_get(fd, &runtimeservicessupported); + + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, SetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } else if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)) { + fwts_skipped(fw, "Skipping test, GetVariable runtime service " + "is not supported on this platform."); + return FWTS_SKIP; + } + uefirtvariable_env_cleanup(); return FWTS_OK;