From patchwork Thu Nov 7 07:46:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1190951 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com 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 477wTW2jqTzB3x1; Thu, 7 Nov 2019 18:46:55 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iScVI-0006eI-SF; Thu, 07 Nov 2019 07:46:52 +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 1iScVG-0006e2-NN for fwts-devel@lists.ubuntu.com; Thu, 07 Nov 2019 07:46:50 +0000 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iScVG-0000cn-1E; Thu, 07 Nov 2019 07:46:50 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 5/5 V2] uefirtmisc: add unsupported checking with RuntimeServicesSupported variable Date: Thu, 7 Nov 2019 15:46:33 +0800 Message-Id: <1573112794-4284-4-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1573112794-4284-1-git-send-email-ivan.hu@canonical.com> References: <1573112794-4284-1-git-send-email-ivan.hu@canonical.com> 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: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" UEFI spec 2.8 introduced the variable RuntimeServicesSupported, which is Bitmask of which calls are implemented by the firmware during runtime services. Add tests for checking GetNextHighMonotonicCount services with RuntimeServicesSupported variable. Currently, won't test with QueryCapsuleCapabilities becasue QueryCapsuleCapabilities may return unsupported due to the update flag of firmware behavior unsupported, not runtime service unsupported. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/uefi/uefirtmisc/uefirtmisc.c | 78 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/uefi/uefirtmisc/uefirtmisc.c b/src/uefi/uefirtmisc/uefirtmisc.c index 2270ca5..a0a4c4c 100644 --- a/src/uefi/uefirtmisc/uefirtmisc.c +++ b/src/uefi/uefirtmisc/uefirtmisc.c @@ -254,11 +254,89 @@ static int uefirtmisc_test3(fwts_framework *fw) return FWTS_ERROR; } +static int uefirtmisc_test4(fwts_framework *fw) +{ + long ioret; + uint64_t status; + bool getvar_supported; + uint32_t var_runtimeservicessupported; + + struct efi_getnexthighmonotoniccount getnexthighmonotoniccount; + uint32_t highcount; + + fwts_uefi_rt_support_status_get(fd, &getvar_supported, + &var_runtimeservicessupported); + if (!getvar_supported || (var_runtimeservicessupported == 0xFFFF)) { + fwts_skipped(fw, "Cannot get the RuntimeServicesSupported " + "variable, maybe the runtime service " + "GetVariable is not supported or " + "RuntimeServicesSupported not provided by " + "firmware."); + return FWTS_SKIP; + } + + getnexthighmonotoniccount.HighCount = &highcount; + getnexthighmonotoniccount.status = &status; + status = ~0ULL; + ioret = ioctl(fd, EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT, &getnexthighmonotoniccount); + if (ioret == -1) { + if (status == EFI_UNSUPPORTED) { + if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT) + || (var_runtimeservicessupported == 0)) { + fwts_failed(fw, LOG_LEVEL_HIGH, + "UEFIRuntimeGetNextHighMonotonicCount", + "Get the GetNextHighMonotonicCount runtime " + "service supported via RuntimeServicesSupported " + "variable. But actually is not supported by " + "firmware."); + } else { + fwts_passed(fw, "UEFI GetNextHighMonotonicCount runtime " + "service supported status test passed."); + } + } else { + if (status == ~0ULL) { + fwts_skipped(fw, "Unknown error occurred, skip test."); + return FWTS_SKIP; + } + if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT) + || (var_runtimeservicessupported == 0)) { + fwts_passed(fw, "UEFI GetNextHighMonotonicCount runtime " + "service supported status test passed."); + } else { + fwts_failed(fw, LOG_LEVEL_HIGH, + "UEFIRuntimeGetNextHighMonotonicCount", + "Get the GetNextHighMonotonicCount runtime " + "service unsupported via RuntimeServicesSupported " + "variable. But actually is supported by firmware."); + } + } + } else { + if (status != EFI_SUCCESS ) { + fwts_skipped(fw, "Unknown error occurred, skip test."); + return FWTS_SKIP; + } + if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT) + || (var_runtimeservicessupported == 0)) { + fwts_passed(fw, "UEFI GetNextHighMonotonicCount runtime " + "service supported status test passed."); + } else { + fwts_failed(fw, LOG_LEVEL_HIGH, + "UEFIRuntimeGetNextHighMonotonicCount", + "Get the GetNextHighMonotonicCount runtime " + "service unsupported via RuntimeServicesSupported " + "variable. But actually is supported by firmware."); + } + } + + return FWTS_OK; +} + 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." }, { uefirtmisc_test3, "Test GetNextHighMonotonicCount with invalid NULL parameter." }, + { uefirtmisc_test4, "Test UEFI miscellaneous runtime services supported status." }, { NULL, NULL } };