From patchwork Mon Jan 11 23:23:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 59579 Delivered-To: patches@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2408217lbb; Mon, 11 Jan 2016 15:23:40 -0800 (PST) X-Received: by 10.202.226.141 with SMTP id z135mr61689466oig.21.1452554620161; Mon, 11 Jan 2016 15:23:40 -0800 (PST) Return-Path: Received: from mail-ob0-x22e.google.com (mail-ob0-x22e.google.com. [2607:f8b0:4003:c01::22e]) by mx.google.com with ESMTPS id y196si32731984oie.8.2016.01.11.15.23.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2016 15:23:40 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::22e as permitted sender) client-ip=2607:f8b0:4003:c01::22e; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::22e as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-ob0-x22e.google.com with SMTP id ba1so421430192obb.3 for ; Mon, 11 Jan 2016 15:23:39 -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=aXewMC7jaC8KnCUgwlBd+ciHB4rZS5ZMyuMvsJwZMfA=; b=LqgNtsRwYDvg896rd/FDo67iSwsaolnocFLLhgLbFt/vAWy5ChhH/oPYyi3e70SLXX GBWEK3r5xQxu51lihHmrNn3mpe3H2/aW50SPAst2Fikaeb/gYklEuR2LQ/cOp9HejtDz orm8K7BH4DQIE/8Fd8lsqZ6oGj3n1C9FrI5S4= 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=aXewMC7jaC8KnCUgwlBd+ciHB4rZS5ZMyuMvsJwZMfA=; b=UttTYZWQz1dnqfhK2veYtyDQtVwd5l+D3I3D/ziuEVLnytalJdM86SwQJTbuSWQp/V E0YVe91zhtnl1uHG2oYPV+a2x5Kwh6tSUmt/Hf9YYnO9oNTMgKKOpA+EfgYgBZhDChov 3elEQdd8s4JEN06TY2KbbWcIWioKS1vkYc/+iae8UgI2ygvIDS5aBRrGxwHwdK2Xvs34 /YDjTZ7O5FU75WuFkbx6Y9ekFeVp+gM5lcS3tEBDQksmlF2Ji6pHUIBhAly7t/ERXmX4 rQbgq05EaFo1gBXqgdX5Zg57ooc0ogH47bXqbfA/G8XA3A13lYjaHrL7FTOV7RVXrBHI g5yg== X-Gm-Message-State: ALoCoQmqSrlb8fUrCqjvEgqHVkckP/DQPfjKuq5fg5v09pHJWFAAJ8PVD4Xs9ih78NAo+dUuu/ky0MMli8aRVvWLmCVCK23hjA== X-Received: by 10.182.92.234 with SMTP id cp10mr65297764obb.79.1452554619847; Mon, 11 Jan 2016 15:23:39 -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 d9sm52206445obt.23.2016.01.11.15.23.37 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Jan 2016 15:23:38 -0800 (PST) From: Al Stone To: fwts-devel@lists.ubuntu.com Cc: linaro-acpi@lists.linaro.org, patches@linaro.org, Al Stone Subject: [PATCH v2 3/3] ACPI: MADT: add in compliance checks for the GIC ITS subtable Date: Mon, 11 Jan 2016 16:23:09 -0700 Message-Id: <1452554589-3841-4-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452554589-3841-1-git-send-email-al.stone@linaro.org> References: <1452554589-3841-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/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 78cf4ac..8ba16ed 100644 --- a/src/acpi/compliance/madt.c +++ b/src/acpi/compliance/madt.c @@ -202,6 +202,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) { @@ -253,8 +254,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) ? FWTS_ERROR : FWTS_OK; } @@ -1090,6 +1095,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; @@ -1238,6 +1312,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, @@ -1268,8 +1346,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) ? FWTS_ERROR : FWTS_OK; }