From patchwork Tue Jan 19 00:26:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 569717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id B74B61402C0; Tue, 19 Jan 2016 11:27:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=chOsB7+U; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1aLK8Z-00029s-Ho; Tue, 19 Jan 2016 00:27:07 +0000 Received: from mail-oi0-f45.google.com ([209.85.218.45]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.76) (envelope-from ) id 1aLK8S-000264-2Y for fwts-devel@lists.ubuntu.com; Tue, 19 Jan 2016 00:27:00 +0000 Received: by mail-oi0-f45.google.com with SMTP id p187so166094734oia.2 for ; Mon, 18 Jan 2016 16:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sRQW7wxAZZUK6cTN+tHoTUfcibSbWa9Dk5Si49zNEyY=; b=chOsB7+UKTg8nHk/v3hIGWsLumrjlt4q07pn1pqjahn7Ut2o+EXyCZkmLxCSVhfVCY 55K6TDBF7l1kt84a3vV5EQ4Qf14cKxG2ZR6KSbjBr8btTG4UlEeqqXJuy5yT3KmUJYgb O1SZV9DIY30eEzOocYs2byZoK9lL7lTtHkRdY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sRQW7wxAZZUK6cTN+tHoTUfcibSbWa9Dk5Si49zNEyY=; b=h+hdgOP9CR/Ks8Or4JQ4CnhNhy4+fT/Ma7im6zQwPLC+7zmek217lz3hvGJIvWzX0c BR6quwoTeej32nUXB6Rxl/B1Neak+CJ0zlXTg/8UxrxlklTigk23IyHn0xXykG9lwm3G h+WbtU0HU27gGuloY1QDTtpN1TIqKjIohAa4Yter5/U2Dv1OAfNBPECwdKG7efKZv8st Ld9kMTPbKiyNWujI8qykTD70klB7afM0qPOlNCh8ukKV+TS6X3QhswPn+0E3tX51zenR YS7wcZFiD3Jj/Pli9Ih6caTriISVaVN6OVsuY6LJkt7iWD1a290IDfHgsGJmSWfpjVnM OdTA== X-Gm-Message-State: ALoCoQnVVAsOW6sAKL/1IppJlBCIZ+MS6oBkDDxkKjVQWOkQKlaIXpWDil2Ncseb73s5QKK+OYWB/QzhDObnzmg7WTSa8bHUKg== X-Received: by 10.202.68.84 with SMTP id r81mr19144255oia.41.1453163218994; Mon, 18 Jan 2016 16:26:58 -0800 (PST) Received: from fidelio.ahs3 (c-50-134-239-249.hsd1.co.comcast.net. [50.134.239.249]) by smtp.googlemail.com with ESMTPSA id y9sm14289969obg.4.2016.01.18.16.26.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jan 2016 16:26:57 -0800 (PST) From: Al Stone To: fwts-devel@lists.ubuntu.com Subject: [PATCH v3 6/6] ACPI: MADT: add in compliance checks for the GIC ITS subtable Date: Mon, 18 Jan 2016 17:26:15 -0700 Message-Id: <1453163175-5801-7-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453163175-5801-1-git-send-email-al.stone@linaro.org> References: <1453163175-5801-1-git-send-email-al.stone@linaro.org> Cc: patches@linaro.org, linaro-acpi@lists.linaro.org X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 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-bounces@lists.ubuntu.com Having previously added the proper structs for the GIC ITS subtable of the MADT, add in test to make sure the content is reasonably correct if one is being used. Signed-off-by: Al Stone Acked-by: Alex Hung --- src/acpi/madt/madt.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/src/acpi/madt/madt.c b/src/acpi/madt/madt.c index d66e0c2..2c06d2c 100644 --- a/src/acpi/madt/madt.c +++ b/src/acpi/madt/madt.c @@ -200,6 +200,7 @@ static fwts_acpi_table_info *mtable; static fwts_acpi_table_info *ftable; static fwts_list msi_frame_ids; +static fwts_list its_ids; static int madt_init(fwts_framework *fw) { @@ -261,8 +262,12 @@ static int madt_init(fwts_framework *fw) ms++; } - /* initialize the MSI frame ID list should we need it later */ + /* + * Initialize the MSI frame ID and ITS ID lists should we need + * them later + */ fwts_list_init(&msi_frame_ids); + fwts_list_init(&its_ids); return (spec_data) ? FWTS_OK : FWTS_ERROR; } @@ -1100,6 +1105,75 @@ static int madt_gicr(fwts_framework *fw, return (hdr->length - sizeof(fwts_acpi_madt_sub_table_header)); } +static int madt_gic_its(fwts_framework *fw, + fwts_acpi_madt_sub_table_header *hdr, + const uint8_t *data) +{ + /* specific checks for subtable type 0xf: GIC ITS */ + fwts_acpi_madt_gic_its *gic_its = (fwts_acpi_madt_gic_its *)data; + fwts_list_link *item; + bool found; + + if (gic_its->reserved) + fwts_failed(fw, LOG_LEVEL_LOW, + "SPECMADTGICITSReservedNonZero", + "MADT %s first reserved field should be zero, " + "instead got 0x%" PRIx32 ".", + madt_sub_names[hdr->type], gic_its->reserved); + else + fwts_passed(fw, + "MADT %s first reserved field is properly set " + "to zero.", + madt_sub_names[hdr->type]); + + /* + * Check ITS ID against previously found IDs to see if it + * is unique. According to the spec, they must be. + */ + found = false; + fwts_list_foreach(item, &its_ids) { + uint32_t *its_id = fwts_list_data(uint32_t *, item); + + if (*its_id == gic_its->its_id) + found = true; + } + if (found) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "SPECMADTGICITSNonUniqueId", + "MADT %s ITS ID 0x%" PRIx32 " is not unique " + "and has already be defined in a previous %s.", + madt_sub_names[hdr->type], + gic_its->its_id, + madt_sub_names[hdr->type]); + } else { + fwts_list_append(&its_ids, &(gic_its->its_id)); + fwts_passed(fw, + "MADT %s ITS ID 0x%" PRIx32 " is unique " + "as is required.", + madt_sub_names[hdr->type], + gic_its->its_id); + } + + /* + * TODO: can the physical base address be tested, or is zero + * allowed? + */ + + if (gic_its->reserved2) + fwts_failed(fw, LOG_LEVEL_LOW, + "SPECMADTGICITSReserved2NonZero", + "MADT %s second reserved field should be zero, " + "instead got 0x%" PRIx32 ".", + madt_sub_names[hdr->type], gic_its->reserved2); + else + fwts_passed(fw, + "MADT %s second reserved field is properly set " + "to zero.", + madt_sub_names[hdr->type]); + + return (hdr->length - sizeof(fwts_acpi_madt_sub_table_header)); +} + static int madt_subtables(fwts_framework *fw) { fwts_acpi_table_madt *madt = (fwts_acpi_table_madt *)mtable->data; @@ -1248,6 +1322,10 @@ static int madt_subtables(fwts_framework *fw) skip = madt_gicr(fw, hdr, data); break; + case FWTS_ACPI_MADT_GIC_ITS: + skip = madt_gic_its(fw, hdr, data); + break; + default: if (hdr->type >= 0x10 && hdr->type <= 0x7f) fwts_failed(fw, LOG_LEVEL_MEDIUM, @@ -1278,8 +1356,9 @@ static int madt_subtables(fwts_framework *fw) static int madt_deinit(fwts_framework *fw) { - /* only one minor clean up needed */ + /* only minor clean up needed */ fwts_list_free_items(&msi_frame_ids, NULL); + fwts_list_free_items(&its_ids, NULL); return (fw) ? FWTS_ERROR : FWTS_OK; }