From patchwork Wed Nov 11 00:18:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 56358 Delivered-To: patches@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1070664lbb; Tue, 10 Nov 2015 16:18:19 -0800 (PST) X-Received: by 10.50.61.34 with SMTP id m2mr30114404igr.34.1447201099156; Tue, 10 Nov 2015 16:18:19 -0800 (PST) Return-Path: Received: from mail-ig0-x22d.google.com (mail-ig0-x22d.google.com. [2607:f8b0:4001:c05::22d]) by mx.google.com with ESMTPS id a20si7765808ign.64.2015.11.10.16.18.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2015 16:18:19 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4001:c05::22d as permitted sender) client-ip=2607:f8b0:4001:c05::22d; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4001:c05::22d as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro_org.20150623.gappssmtp.com Received: by igbxm8 with SMTP id xm8so12129453igb.1 for ; Tue, 10 Nov 2015 16:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=hGNiGuSiZgu8YVCBwSrTRMtIJNonW8paZiYcTpc2I1Y=; b=Lv0pE9TilNEEVxGbPU6hN+LhtcDBfulQISo5sGygAiNVa1Y02AHUeaEg0Me8bNQEU2 d4RboRMi/X3a5PBczDfDBQZ/TWAnx2ERxbb+cc5DTQDsSGm4kLQq+K07mIzSpko0B6An Ww8P+A1ezDXLMsh9vIFayV63bPVWffl/dgOcXcM5+1jf1wqlTLMdrETmq/5d/J9AYyMd fAC2diFFgpKcJvdG6wIYCu7nmz12cBJtQPSr3FvtsCOKzERIO1j2icCcZmvsXbLUj8iI U4uuybQPhKC8lEg0K4YnlSVqOErBxOZ6JuDjF9Nhmcu0IOvbAxAmrDLo2YQy/a6Xh0eB NLFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=hGNiGuSiZgu8YVCBwSrTRMtIJNonW8paZiYcTpc2I1Y=; b=cZ2fJr4R5pyPPj0NthizoEUgoUCaCJBGOD155QAIeBodoDUG3TuabBKWC3hH7uZPSN g0SzFRt3OmFX68i/4RDow2FZMMm/NS6oo7wNl7U3mPQPDE1dsl6GuzyQICjCOaSUhh4k H3O0jLs0tFntvYhH72S0j60GgtKmlNEEe6X5oCUIkVFFkYQdWn69lsRGid/L4wMe23eE j0/OgBN+tP9k4MFThnCBfKe4kI8Drux0QMm0E8uJ9FcVtmD0lkM3sBN7/Ys6A4tX0Nn1 4VSI9aK6qItwuceGIO3mnxU2dCwAjP3pBBHCeIuS0q/ATqp6HWXXdsJ0A/hPXdh1OV+f bTcg== X-Gm-Message-State: ALoCoQmH+3RmX+KPT9RZxjtJn1MoCm8uQ5CBA2lPrJJAZFXv4/oXUWmPpQioBYTKwCYWhsrjzloX X-Received: by 10.50.222.75 with SMTP id qk11mr7112443igc.60.1447201098763; Tue, 10 Nov 2015 16:18:18 -0800 (PST) Return-Path: Received: from fidelio.ahs3 (c-50-134-239-249.hsd1.co.comcast.net. [50.134.239.249]) by smtp.googlemail.com with ESMTPSA id i69sm2285699iod.27.2015.11.10.16.18.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2015 16:18:17 -0800 (PST) Subject: [PATCH 3/3] ACPI: MADT: add in compliance checks for the GIC ITS,subtable To: fwts-devel@lists.ubuntu.com References: <1447200422-11500-1-git-send-email-al.stone@linaro.org> Cc: linaro-acpi@lists.linaro.org, patches@linaro.org From: Al Stone Message-ID: <56428948.1080409@linaro.org> Date: Tue, 10 Nov 2015 17:18:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1447200422-11500-1-git-send-email-al.stone@linaro.org> Having previously added the proper structs for the GIC ITS subtable of the MADT, add in tests to make sure the content is reasonably correct if one is being used. Signed-off-by: Al Stone --- src/acpi/compliance/madt.c | 83 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 2 deletions(-) -- 2.5.0 diff --git a/src/acpi/compliance/madt.c b/src/acpi/compliance/madt.c index db7d0a9..ffa3eba 100644 --- a/src/acpi/compliance/madt.c +++ b/src/acpi/compliance/madt.c @@ -207,6 +207,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 spec_madt_init(fwts_framework *fw) { @@ -259,8 +260,12 @@ static int spec_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 == NULL) ? FWTS_ERROR : FWTS_OK; } @@ -1095,6 +1100,75 @@ static int spec_madt_gicr(fwts_framework *fw, return (hdr->length - sizeof(fwts_acpi_madt_sub_table_header)); } +static int spec_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 ".", + spec_madt_sub_names[hdr->type], gic_its->reserved); + else + fwts_passed(fw, + "MADT %s first reserved field is properly set " + "to zero.", + spec_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.", + spec_madt_sub_names[hdr->type], + gic_its->its_id, + spec_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.", + spec_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 ".", + spec_madt_sub_names[hdr->type], gic_its->reserved2); + else + fwts_passed(fw, + "MADT %s second reserved field is properly set " + "to zero.", + spec_madt_sub_names[hdr->type]); + + return (hdr->length - sizeof(fwts_acpi_madt_sub_table_header)); +} + static int spec_madt_subtables(fwts_framework *fw) { fwts_acpi_table_madt *madt = (fwts_acpi_table_madt*)mtable->data; @@ -1243,6 +1317,10 @@ static int spec_madt_subtables(fwts_framework *fw) skip = spec_madt_gicr(fw, hdr, data); break; + case FWTS_ACPI_MADT_GIC_ITS: + skip = spec_madt_gic_its(fw, hdr, data); + break; + default: if (hdr->type >= 0x10 && hdr->type <= 0x7f) fwts_failed(fw, LOG_LEVEL_MEDIUM, @@ -1273,8 +1351,9 @@ static int spec_madt_subtables(fwts_framework *fw) static int spec_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 != NULL) ? FWTS_ERROR : FWTS_OK; }