From patchwork Wed Aug 15 07:38:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 957810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41r1Xx0K2vz9sBq; Wed, 15 Aug 2018 17:38:24 +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 1fpqNp-00043Y-V0; Wed, 15 Aug 2018 07:38:21 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fpqNo-00043R-Eb for fwts-devel@lists.ubuntu.com; Wed, 15 Aug 2018 07:38:20 +0000 Received: from 1.general.ivanhu.uk.vpn ([10.172.194.164] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fpqNn-0002yJ-Ib; Wed, 15 Aug 2018 07:38:20 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpi: gtdt: add checking the valid base physical address Date: Wed, 15 Aug 2018 15:38:14 +0800 Message-Id: <1534318694-31503-1-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 2.7.4 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" Some buggy firmwares on Arm server implement GTDT table without impementing reasonable base physical address and causes kernel complains about ail to get base address. Add checking for the valid base addresses on GTDT table. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/acpi/gtdt/gtdt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/acpi/gtdt/gtdt.c b/src/acpi/gtdt/gtdt.c index ded1d5d..dc00785 100644 --- a/src/acpi/gtdt/gtdt.c +++ b/src/acpi/gtdt/gtdt.c @@ -56,6 +56,24 @@ static int gtdt_test1(fwts_framework *fw) uint32_t i = 0, n; const fwts_acpi_table_gtdt *gtdt = (const fwts_acpi_table_gtdt *)table->data; + if (gtdt->cnt_control_base_phys_addr == 0) { + passed = false; + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "GTDTInvalidBaseAddr", + "The 64-bit physical address at which the " + "Counter Control block should not be Zero. " + "If not provided, this field must be 0xFFFFFFFFFFFFFFFF"); + } + + if (gtdt->cnt_read_base_phys_addr == 0) { + passed = false; + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "GTDTInvalidBaseAddr", + "The 64-bit physical address at which the " + "Counter Read block Read block should not be Zero. " + "If not provided, this field must be 0xFFFFFFFFFFFFFFFF"); + } + fwts_acpi_reserved_bits_check(fw, "GTDT", "Flags", gtdt->virtual_timer_flags, sizeof(gtdt->virtual_timer_flags), 3, 31, &passed); ptr = (uint8_t *)table->data + gtdt->platform_timer_offset; @@ -89,6 +107,13 @@ static int gtdt_test1(fwts_framework *fw) i, block->length); goto done; } + if (block->physical_address == 0) { + passed = false; + fwts_failed(fw, LOG_LEVEL_HIGH, + "GTDTBlockInvalidBaseAddr", + "The 64-bit physical address at which the " + "GT CntCTLBase Block shouldn't be zero."); + } if (block->reserved) { passed = false; fwts_failed(fw, LOG_LEVEL_HIGH, @@ -146,6 +171,21 @@ static int gtdt_test1(fwts_framework *fw) block_timer->reserved[1], block_timer->reserved[2]); } + if (block_timer->cntbase == 0) { + passed = false; + fwts_failed(fw, LOG_LEVEL_HIGH, + "GTDTGTxInvalidBaseAddr", + "Physical Address at which the " + "CntBase block for GTx shouldn't be zero."); + } + if (block_timer->cntel0base == 0) { + passed = false; + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "GTDTGTxInvalidBaseAddr", + "Physical Address at which the " + "CntEL0Base block for GTx should not be Zero. " + "If not provided, this field must be 0xFFFFFFFFFFFFFFFF"); + } snprintf(field, sizeof(field), "block %" PRIu32 " physical timer flags", i); fwts_acpi_reserved_bits_check(fw, "GTDT", field, block_timer->phys_timer_flags, @@ -189,6 +229,20 @@ static int gtdt_test1(fwts_framework *fw) " reserved is non-zero, got 0x%" PRIx8, i, watchdog->reserved); } + if (watchdog->refresh_frame_addr == 0) { + passed = false; + fwts_failed(fw, LOG_LEVEL_HIGH, + "GTDTInvalidWatchDogBaseAddr", + "Physical Address at which the " + "RefreshFrame block shouldn't be zero."); + } + if (watchdog->watchdog_control_frame_addr == 0) { + passed = false; + fwts_failed(fw, LOG_LEVEL_HIGH, + "GTDTInvalidWatchDogBaseAddr", + "Physical Address at which the " + "Watchdog Control Frame block shouldn't be zero."); + } snprintf(field, sizeof(field), "SBSA generic watchdog timer %" PRIu32 " flags", i); fwts_acpi_reserved_bits_check(fw, "GTDT", field, watchdog->watchdog_timer_flags,