From patchwork Tue Feb 9 01:32:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 61462 Delivered-To: patches@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1766723lbl; Mon, 8 Feb 2016 17:33:53 -0800 (PST) X-Received: by 10.60.138.67 with SMTP id qo3mr27281445oeb.80.1454981624421; Mon, 08 Feb 2016 17:33:44 -0800 (PST) Return-Path: Received: from mail-ob0-x234.google.com (mail-ob0-x234.google.com. [2607:f8b0:4003:c01::234]) by mx.google.com with ESMTPS id 9si1081240oid.148.2016.02.08.17.33.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 17:33:44 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::234 as permitted sender) client-ip=2607:f8b0:4003:c01::234; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::234 as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-ob0-x234.google.com with SMTP id ba1so173675082obb.3 for ; Mon, 08 Feb 2016 17:33:44 -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=PwKw6REYYMBHoIM/QEWRESKor+lQF/EFO8ciZ+zSEic=; b=davdv9vfiRhL3uihnYP9HVa1QQHkHEZ7Az4PnERq7/hiQ4JhzVy6en8ywmDx4Cz1s6 l02wAaRgOXvCWGm4w7vTk02QQuhSLHVcom9lZOxtKvxgPlOUDgHRU1LN0scJB8gXZW0p c+lYo+89xbFXYK/OQEr1Sg6DoOVZIH6LQcM5U= 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=PwKw6REYYMBHoIM/QEWRESKor+lQF/EFO8ciZ+zSEic=; b=IIMDIgN8A653Vvp5QHz7YsKljrTv+dRrcL9SK2PlLKcCjNvQN9WhMNkx3P4hASqXUT ZlM85FuVlIT0qf3TKSw/CAlAYA24YITsEcOGAkYiFiC2jV77JENmey/9Lcm8E8uJ+k7j TqCg3CzNmQSaDXUhq+29YzRhQgg9LrpmGTg2tZS5NzbwXhvW8GmSLWzqkvuOYbX85jij f4qRXC5dFCqkPfCo00RqxoQaKdAnCmLcQjDsea8En3682ZUIwFXtxwJUgMKoGU3MWGOF 5cDzElsLEuKRzQ1SGRWbQyR3JApks05t6UhA/uRpZJJ9Ae8OEoyToozCEbK2xZ1HBZRW C8rQ== X-Gm-Message-State: AG10YORR40q2Ex0dh6tilvHc3MF1I/GkZ32V2cKoZ6/YR/JckzPf6NQmGrOJJpjNrlouTn7JH5o= X-Received: by 10.60.78.105 with SMTP id a9mr27526636oex.76.1454981624144; Mon, 08 Feb 2016 17:33:44 -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 qp4sm19097135obc.9.2016.02.08.17.33.42 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Feb 2016 17:33:43 -0800 (PST) From: Al Stone To: fwts-devel@lists.ubuntu.com Cc: linaro-acpi@lists.linaro.org, patches@linaro.org, Al Stone Subject: [PATCH 09/21] FADT: expand the compliance test for FIRMWARE_CTRL fields Date: Mon, 8 Feb 2016 18:32:51 -0700 Message-Id: <1454981583-31872-10-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454981583-31872-1-git-send-email-al.stone@linaro.org> References: <1454981583-31872-1-git-send-email-al.stone@linaro.org> Expand the testing of the FIRMWARE_CTRL -- and by extension, the X_FIRMWARE_CTRL field -- to check for full compliance with the spec. Only one or the other may be used at any one time, per 6.1, but we also have to acknowledge there are tables that do use both the 32- and 64-bit values. At that point, we re-use parts of the existing test to verify that they are at least consistent. Signed-off-by: Al Stone --- src/acpi/fadt/fadt.c | 146 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 95 insertions(+), 51 deletions(-) -- 2.5.0 diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c index 6e5ee26..84f4e09 100644 --- a/src/acpi/fadt/fadt.c +++ b/src/acpi/fadt/fadt.c @@ -192,61 +192,105 @@ static int fadt_revision(fwts_framework *fw) return FWTS_OK; } - -static void acpi_table_check_fadt_firmware_control( - fwts_framework *fw, - const fwts_acpi_table_fadt *fadt, - bool *passed) +static void acpi_table_check_fadt_firmware_ctrl(fwts_framework *fw) { - if (fadt->firmware_control == 0) { - if (fadt->header.length >= 140) { - if ((fadt->x_firmware_ctrl == 0) && - !(fwts_acpi_is_reduced_hardware(fadt))) { - *passed = false; - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "FADTFACSZero", - "FADT 32 bit FIRMWARE_CONTROL and " - "64 bit X_FIRMWARE_CONTROL (FACS " - "address) are null."); - fwts_advice(fw, - "The 32 bit FIRMWARE_CTRL or 64 " - "bit X_FIRMWARE_CTRL should point " - "to a valid Firmware ACPI Control " - "Structure (FACS) when ACPI hardware " - "reduced mode is not set. "); - } + /* tests for very old FADTs */ + if (fadt->header.length < 140 && fadt->firmware_control == 0) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "FADT32BitFACSNull", + "FADT 32 bit FIRMWARE_CONTROL is null."); + fwts_advice(fw, + "The ACPI version 1.0 FADT has a NULL " + "FIRMWARE_CTRL and it needs to be defined " + "to point to a valid Firmware ACPI Control " + "Structure (FACS)."); + + /* can't do much else */ + return; + } + + /* for more recent FADTs, things get more complicated */ + if (fadt->firmware_control == 0 && fadt->x_firmware_ctrl == 0) { + if (fwts_acpi_is_reduced_hardware(fadt)) { + fwts_passed(fw, + "FADT 32 bit FIRMWARE_CONTROL and " + "64 bit X_FIRMWARE_CONTROL (FACS " + "address) are null in hardware reduced " + "mode."); + fwts_advice(fw, + "When in hardware reduced mode, it is " + "allowed to have both the 32-bit " + "FIRMWARE_CTRL and 64-bit X_FIRMWARE_CTRL " + "fields set to zero as they are. This " + "indicates that no FACS is available."); } else { - *passed = false; - fwts_failed(fw, LOG_LEVEL_MEDIUM, - "FADT32BitFACSNull", - "FADT 32 bit FIRMWARE_CONTROL is null."); + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "FADTFACSZero", + "FADT 32 bit FIRMWARE_CONTROL and " + "64 bit X_FIRMWARE_CONTROL (FACS " + "address) are both null."); fwts_advice(fw, - "The ACPI version 1.0 FADT has a NULL " - "FIRMWARE_CTRL and it needs to be defined " - "to point to a valid Firmware ACPI Control " - "Structure (FACS)."); + "The 32 bit FIRMWARE_CTRL or 64 " + "bit X_FIRMWARE_CTRL should point " + "to a valid Firmware ACPI Control " + "Structure (FACS) when ACPI hardware " + "reduced mode is not set. "); } + + } + + if ((fadt->firmware_control != 0 && fadt->x_firmware_ctrl == 0) || + (fadt->firmware_control == 0 && fadt->x_firmware_ctrl != 0)) { + fwts_passed(fw, + "Only one of FIRMWARE_CTRL and X_FIRMWARE_CTRL " + "is non-zero."); } else { - if (fadt->header.length >= 140) { - if (fadt->x_firmware_ctrl != 0) { - if (((uint64_t)fadt->firmware_control != fadt->x_firmware_ctrl)) { - *passed = false; - fwts_failed(fw, LOG_LEVEL_MEDIUM, - "FwCtrl32and64Differ", - "FIRMWARE_CONTROL is 0x%" PRIx32 - " and differs from X_FIRMWARE_CONTROL " - "0x%" PRIx64, - fadt->firmware_control, - fadt->x_firmware_ctrl); - fwts_advice(fw, - "One would expect the 32 bit FIRMWARE_CTRL " - "and 64 bit X_FIRMWARE_CTRL pointers to " - "point to the same FACS, however they don't " - "which is clearly ambiguous and wrong. " - "The kernel works around this by using the " - "64 bit X_FIRMWARE_CTRL pointer to the FACS. "); - } - } + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "FADTFACSBothSet", + "Both 32-bit FIRMWARE_CTRL and 64-bit " + "X_FIRMWARE_CTRL pointers to the FACS are " + "set but only one is allowed."); + fwts_advice(fw, + "Having both FACS pointers set is ambiguous; " + "there is no way to determine which one is " + "the correct address. The kernel workaround " + "is to always use the 64-bit X_FIRMWARE_CTRL."); + } + + + if (fadt->firmware_control != 0 && fadt->x_firmware_ctrl != 0) { + if ((uint64_t)fadt->firmware_control == fadt->x_firmware_ctrl) { + fwts_passed(fw, + "Both FIRMWARE_CTRL and X_FIRMWARE_CTRL " + "are being used and contain the same FACS " + "address."); + fwts_advice(fw, + "While having FIRMWARE_CTRL and " + "X_FIRMWARE_CTRL both set to an address " + "is not compliant with the ACPI " + "specification, they are both set to " + "the same address, which at least " + "mitigates the ambiguity in determining " + "which address is the correct one to use " + "for the FACS. Ideally, only one of the " + "two addresses should be set but as a " + "practical matter, this will work."); + } else { + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "FwCtrl32and64Differ", + "FIRMWARE_CONTROL is 0x%" PRIx32 + " and differs from X_FIRMWARE_CONTROL " + "0x%" PRIx64, + fadt->firmware_control, + fadt->x_firmware_ctrl); + fwts_advice(fw, + "One would expect the 32 bit FIRMWARE_CTRL " + "and 64 bit X_FIRMWARE_CTRL pointers to " + "point to the same FACS, however they do " + "not which is clearly ambiguous and wrong. " + "The kernel works around this by using the " + "64-bit X_FIRMWARE_CTRL pointer to the " + "FACS. "); } } } @@ -486,7 +530,7 @@ static int fadt_test1(fwts_framework *fw) { bool passed = true; - acpi_table_check_fadt_firmware_control(fw, fadt, &passed); + acpi_table_check_fadt_firmware_ctrl(fw); acpi_table_check_fadt_dsdt(fw, fadt, &passed); acpi_table_check_fadt_smi(fw, fadt, &passed); acpi_table_check_fadt_pm_tmr(fw, fadt, &passed);