From patchwork Fri Feb 19 23:39:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 62438 Delivered-To: patches@linaro.org Received: by 10.112.43.199 with SMTP id y7csp78777lbl; Fri, 19 Feb 2016 15:41:27 -0800 (PST) X-Received: by 10.182.111.137 with SMTP id ii9mr13846264obb.77.1455925287168; Fri, 19 Feb 2016 15:41:27 -0800 (PST) Return-Path: Received: from mail-oi0-x229.google.com (mail-oi0-x229.google.com. [2607:f8b0:4003:c06::229]) by mx.google.com with ESMTPS id u7si1496633obt.78.2016.02.19.15.41.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Feb 2016 15:41:27 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c06::229 as permitted sender) client-ip=2607:f8b0:4003:c06::229; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c06::229 as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-oi0-x229.google.com with SMTP id w5so22762926oie.3 for ; Fri, 19 Feb 2016 15:41:26 -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=zKtvutkZqwOHsmzpxfdb2biRk5SQdlks+56hTCAlXZc=; b=NwEhKtNAOAfrokb0tc6GjrOZvQA5CXEzyfOaFjmOOGmNIp3442CLFzMrpYuwRJKB7V /2N1wWwt3IQ75zjWX7wq5vja4TN7VgWy5E4d/sYEL6pccbl5O1yn3OOwGy44urZclCtt UA8leeh38or/LAeSLN1Q8v/bQBw+0LxctsJNc= 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=zKtvutkZqwOHsmzpxfdb2biRk5SQdlks+56hTCAlXZc=; b=O7QNvD9efGtNvNDCTkaFP9HGSL+w2VfHAG7VEmqR+qV9pzecA/GdTSQdoV35SxwIyz ZanmruluPoCj2+U0T09mP9r0+aMUokSXMBnHNiGkH6t1cLRBuX70M4Iit9XfWIqZAhT2 6NFx1zQS/gTEcGNvFfiN49nMYEdXnahTR0QzekH2bLIAchjx0mDQaL4yWYIJu7DL+Ajm Me9OOMkXvx8KxOFYEcILvwdpsWIr8seP82pxSYcN0nIP5/d1skWSsG9iikskgZZpAxdQ PZ1Sj1HqSjh/yOM5cX0W0U1Va3yfLqKjHpRmRuz2P9oN8Is321DegPDNgTr+Gd8d/XsV SK1Q== X-Gm-Message-State: AG10YOSVZwhxXelXrsg9LXpIm8Ar9X9LkDAjdl8oCUvQXoMOPz8/wlhtVSU7kVgNG0GZwfDofq8= X-Received: by 10.202.96.68 with SMTP id u65mr13525750oib.83.1455925286854; Fri, 19 Feb 2016 15:41:26 -0800 (PST) Return-Path: Received: from fidelio.ahs3.com (c-50-134-239-249.hsd1.co.comcast.net. [50.134.239.249]) by smtp.googlemail.com with ESMTPSA id kg7sm8655217obb.27.2016.02.19.15.41.25 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Feb 2016 15:41:25 -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 22/23] FADT: add safety checks for older versions of FADT Date: Fri, 19 Feb 2016 16:39:58 -0700 Message-Id: <1455925199-8587-23-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455925199-8587-1-git-send-email-al.stone@linaro.org> References: <1455925199-8587-1-git-send-email-al.stone@linaro.org> Not every set of FADT entries will make nice and clean ACPI 6.0/6.1 FADTs. So, assume that we will also test older versions of the FADT and be more paranoid about whether or not the field we're testing is even defined for this version, skipping the test if is not. Signed-off-by: Al Stone --- src/acpi/fadt/fadt.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) -- 2.5.0 diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c index 40a0028..6dc324e 100644 --- a/src/acpi/fadt/fadt.c +++ b/src/acpi/fadt/fadt.c @@ -334,6 +334,8 @@ static void acpi_table_check_fadt_dsdt(fwts_framework *fw) fwts_failed(fw, LOG_LEVEL_MEDIUM, "FADTDSDTNull", "FADT DSDT address is null."); + /* can't do much else */ + return; } /* if one field is being used, the other should be null */ @@ -412,6 +414,9 @@ static void acpi_table_check_fadt_reserved(fwts_framework *fw) "FADT first reserved field is not zero: 0x%02x", fadt->reserved); + if (fadt->header.length < 112) + return; + if (fadt->reserved1 == (uint8_t)0) fwts_passed(fw, "FADT second reserved field is zero."); else @@ -914,6 +919,21 @@ static void acpi_table_check_fadt_pm1a_evt_blk(fwts_framework *fw) bool both_zero; bool both_nonzero; + if (fadt->header.length < 160) { + if (fadt->pm1a_evt_blk == 0) + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "FADTPm1aEvtBlkNotSet", + "FADT PM1A_EVT_BLK is a required field " + "and must have a 32-bit address set."); + else + fwts_passed(fw, + "FADT required PM1A_EVT_BLK field is " + "non-zero."); + + /* can't do much else */ + return; + } + if (fadt->pm1a_evt_blk == 0 && fadt->x_pm1a_evt_blk.address == 0) { both_zero = true; fwts_failed(fw, LOG_LEVEL_MEDIUM, @@ -968,6 +988,11 @@ static void acpi_table_check_fadt_pm1a_evt_blk(fwts_framework *fw) static void acpi_table_check_fadt_pm1b_evt_blk(fwts_framework *fw) { + if (fadt->pm1b_evt_blk == 0 && fadt->header.length < 172) { + fwts_skipped(fw, "FADT PM1B_EVT_BLK not being used."); + return; + } + if (fadt->pm1b_evt_blk == 0 && fadt->x_pm1b_evt_blk.address == 0) { fwts_skipped(fw, "FADT PM1B_EVT_BLK not being used."); return; @@ -1009,6 +1034,21 @@ static void acpi_table_check_fadt_pm1b_evt_blk(fwts_framework *fw) static void acpi_table_check_fadt_pm1a_cnt_blk(fwts_framework *fw) { + if (fadt->header.length < 184) { + if (fadt->pm1a_cnt_blk == 0) + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "FADTPm1aCntBlkNotSet", + "FADT PM1A_CNT_BLK is a required field " + "and must have a 32-bit address set."); + else + fwts_passed(fw, + "FADT required PM1A_EVT_BLK field is " + "non-zero."); + + /* can't do much else */ + return; + } + if (fadt->pm1a_cnt_blk != 0 || fadt->x_pm1a_cnt_blk.address != 0) fwts_passed(fw, "FADT required PM1A_CNT_BLK field is non-zero"); @@ -1054,6 +1094,11 @@ static void acpi_table_check_fadt_pm1a_cnt_blk(fwts_framework *fw) static void acpi_table_check_fadt_pm1b_cnt_blk(fwts_framework *fw) { + if (fadt->pm1b_cnt_blk == 0 && fadt->header.length < 196) { + fwts_skipped(fw, "FADT PM1B_CNT_BLK not being used."); + return; + } + if (fadt->pm1b_cnt_blk == 0 && fadt->x_pm1b_cnt_blk.address == 0) { fwts_skipped(fw, "FADT PM1B_CNT_BLK not being used."); return; @@ -1095,6 +1140,11 @@ static void acpi_table_check_fadt_pm1b_cnt_blk(fwts_framework *fw) static void acpi_table_check_fadt_pm2_cnt_blk(fwts_framework *fw) { + if (fadt->pm2_cnt_blk == 0 && fadt->header.length < 208) { + fwts_skipped(fw, "FADT PM2_CNT_BLK not being used."); + return; + } + if (fadt->pm2_cnt_blk == 0 && fadt->x_pm2_cnt_blk.address == 0) { fwts_skipped(fw, "FADT PM2_CNT_BLK not being used."); return; @@ -1136,6 +1186,11 @@ static void acpi_table_check_fadt_pm2_cnt_blk(fwts_framework *fw) static void acpi_table_check_fadt_pm_tmr_blk(fwts_framework *fw) { + if (fadt->pm_tmr_blk == 0 && fadt->header.length < 220) { + fwts_skipped(fw, "FADT PM_TMR_BLK not being used."); + return; + } + if (fadt->pm_tmr_blk == 0 && fadt->x_pm_tmr_blk.address == 0) { fwts_skipped(fw, "FADT PM_TMR_BLK not being used."); return;