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: 59951 Delivered-To: patches@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2280778lbb; Mon, 18 Jan 2016 16:26:59 -0800 (PST) X-Received: by 10.60.176.162 with SMTP id cj2mr22232952oec.78.1453163219316; Mon, 18 Jan 2016 16:26:59 -0800 (PST) Return-Path: Received: from mail-oi0-x22c.google.com (mail-oi0-x22c.google.com. [2607:f8b0:4003:c06::22c]) by mx.google.com with ESMTPS id cp7si28986106oeb.83.2016.01.18.16.26.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jan 2016 16:26:59 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c06::22c as permitted sender) client-ip=2607:f8b0:4003:c06::22c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c06::22c as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-oi0-x22c.google.com with SMTP id w75so152488125oie.0 for ; Mon, 18 Jan 2016 16:26:59 -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=CFI9Q856szErfSujvaxXFJtqtSQ0mEmlACYWg2zR8z4v/tyaks4TlHKLPCFOlNwciZ bBK6ghv7+e/HdUQi4LyX/9RPZBdy5R+vOV5IJVS8ikdiVeV6MU9UhfuaH9/BMT2ZJpl1 07NSn4I/7HaPqTI5pvLbIPRSfLgblOUCVszTIe/f6xfSlf3+UCftr/mNNItspkS8pHzT iQ2uclJjpS4FVmxwDjDsawfOCr8HMNIwmRVobJSYuP4DHFpllig/tfIc/3X4ORgInFtC HOjTKyGSGUlytFveFRLA+F8R8ABN1rwA/fYrc1OE3P+r9gvxoz1BHsV45JkLMJ3b2mH3 cYDQ== X-Gm-Message-State: ALoCoQn/QA/NY8mJFEEMQNiq66ylOdzN/CxQBeODIwSv8EI0M118zbRpYttLmY4ZS5KzdL4iv2UnMPCRDtJMzaByZtCPoJoxfg== X-Received: by 10.202.68.84 with SMTP id r81mr19144255oia.41.1453163218994; Mon, 18 Jan 2016 16:26:58 -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 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 Cc: linaro-acpi@lists.linaro.org, patches@linaro.org, Al Stone 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> 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 --- src/acpi/madt/madt.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 2 deletions(-) -- 2.5.0 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; }