From patchwork Thu Dec 27 08:06:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 208277 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 9A28B2C00D0 for ; Thu, 27 Dec 2012 19:06:27 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1To8Tx-0003Fv-MY; Thu, 27 Dec 2012 08:06:25 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1To8Tr-0003FV-Fx for fwts-devel@lists.ubuntu.com; Thu, 27 Dec 2012 08:06:19 +0000 Received: from [175.41.48.77] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1To8Tq-0002c8-IV; Thu, 27 Dec 2012 08:06:19 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] uefirtvariable: add new test for UEFI runtime QueryVariableInfo Date: Thu, 27 Dec 2012 16:06:14 +0800 Message-Id: <1356595574-24123-1-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 1.7.10.4 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com This test tests the UEFI runtime service QueryVariableInfo interface. The QueryVaruableInfo interface is supported after UEFI spec 2.0. The kernel in efi.c will check the revision of system table got from firmware to see if the firmware implemented after UEFI spec 2.0, i.e. the value FirmeareRevision. If the value less than EFI_2_00_SYSTEM_TABLE_REVISION, kernel returns EFI_UNSUPPORT. If test returns EFI_UNSUPPORT, suggest firmware also need to check the system table item FirmwareRevision, to avoid that directly return unsupported from kernel. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/uefi/uefirtvariable/uefirtvariable.c | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index 189d8b3..2b66371 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -695,6 +695,26 @@ static int setvariable_test6(fwts_framework *fw) return FWTS_OK; } +static int do_queryvariableinfo(uint64_t *status, uint64_t *remvarstoragesize, uint64_t *maxvariablesize) +{ + long ioret; + struct efi_queryvariableinfo queryvariableinfo; + uint64_t maxvarstoragesize; + + queryvariableinfo.Attributes = attributes; + queryvariableinfo.MaximumVariableStorageSize = &maxvarstoragesize; + queryvariableinfo.RemainingVariableStorageSize = remvarstoragesize; + queryvariableinfo.MaximumVariableSize = maxvariablesize; + queryvariableinfo.status = status; + + ioret = ioctl(fd, EFI_RUNTIME_QUERY_VARIABLEINFO, &queryvariableinfo); + + if (ioret == -1) + return FWTS_ERROR; + + return FWTS_OK; +} + static int uefirtvariable_test1(fwts_framework *fw) { uint64_t datasize = 10; @@ -754,10 +774,36 @@ static int uefirtvariable_test3(fwts_framework *fw) return FWTS_OK; } +static int uefirtvariable_test4(fwts_framework *fw) +{ + uint64_t status; + uint64_t remvarstoragesize; + uint64_t maxvariablesize; + + if (do_queryvariableinfo(&status, &remvarstoragesize, &maxvariablesize) == FWTS_ERROR) { + if (status == EFI_UNSUPPORTED) { + fwts_skipped(fw, "Not support the QueryVariableInfo UEFI runtime interface: cannot test."); + fwts_advice(fw, "Firmware also needs to check if the revision of system table is correct or not." + " Linux kernel returns EFI_UNSUPPORTED as well, if the FirmwareRevision" + " of system table is less than EFI_2_00_SYSTEM_TABLE_REVISION."); + return FWTS_SKIP; + } else { + fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeQueryVariableInfo", + "Failed to query variable info with UEFI runtime service."); + fwts_uefi_print_status_info(fw, status); + return FWTS_ERROR; + } + } + fwts_passed(fw, "UEFI runtime service query variable info interface test passed."); + + return FWTS_OK; +} + static fwts_framework_minor_test uefirtvariable_tests[] = { { uefirtvariable_test1, "Test UEFI RT service get variable interface." }, { uefirtvariable_test2, "Test UEFI RT service get next variable name interface." }, { uefirtvariable_test3, "Test UEFI RT service set variable interface." }, + { uefirtvariable_test4, "Test UEFI RT service query variable info interface." }, { NULL, NULL } };