From patchwork Tue Nov 27 17:59:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 152147 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp76445ljp; Tue, 27 Nov 2018 09:59:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/X3OYcO189v1VmGW2w5o5MMPKbd2Hf4Zn2z6VvLQNQo2ZoujkkygtKGgj+wuCRf15w/qf2I X-Received: by 2002:a17:902:4503:: with SMTP id m3mr3535301pld.23.1543341576832; Tue, 27 Nov 2018 09:59:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543341576; cv=none; d=google.com; s=arc-20160816; b=ZJMcLeWWoHQUsKWnIZFp3JUUVuPtQKGZegAVm2Ve+rtq8jFkFJZVIDfXAo6CRkezVk Z53I/+WPirAOEv6Dltsi+iNPe7fn+G4qU90vi8hClWlVVUUw4WmVops7loTTlQehwpEr gNFnud0itc3D78hFIs3MQfOPMSlk9RgfxLWJewTruncVuHoBJco/QEhfKb/RywNuEc1L +ARv9yRERBrSC1jhQ6guBpq8M1CVthIokwOWA10anEisDg24NWVv1BHdsMYM8yHs+46C 4sVw1mZHUfWjeJzIMWKEATvSyFE+2+CobgpCpQGrki3kLnupsD36yIG8CGRSgm67XIkr KPxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ztjHpeG60BLE7ORb7xG+xxN2zubTeC8+OE0Z+aDSMo4=; b=I6lfcPrieadMpijcvYEI2XBQmp1T0m6KwjvouPYpEWnBQ43SvOp9iyX0cd6tQFlGxC N+wXy2ceko2/Ix0Er1FXt/kWfii5kcbOlUyi37+EKAK/B1cgBeKxMlcXC6xVC1SFaCjx sXAJx0WY82Cc9VWvx2MVVSI2rWVeJWUDjHIqk8nNM6XQhfEV0bPGWsr410TVxWFtRfkd OB+7cJj3JKYMK3uQTivPKii/ozRjs+14LknQz8rUWu4wRfoXMmYDWj3e5ZmYvZmKJn1M 0xi8BNgOj63rdYeUvGWfc2iAHGpRNC+0R8iQhiR7+ZeWYCKgPgqQfSQPrEOvHpoW8E/l lyeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37si4036187pgw.590.2018.11.27.09.59.29; Tue, 27 Nov 2018 09:59:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726389AbeK1E6K (ORCPT + 9 others); Tue, 27 Nov 2018 23:58:10 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44208 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726288AbeK1E6K (ORCPT ); Tue, 27 Nov 2018 23:58:10 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 953521DC8; Tue, 27 Nov 2018 09:59:28 -0800 (PST) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.197.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EB7413F575; Tue, 27 Nov 2018 09:59:26 -0800 (PST) From: Lorenzo Pieralisi To: Will Deacon , Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: sudeep.holla@arm.com, Jeremy Linton , Lorenzo Pieralisi , Al Stone , "Rafael J. Wysocki" Subject: [RESEND PATCH] arm64: acpi: Prepare for longer MADTs Date: Tue, 27 Nov 2018 17:59:12 +0000 Message-Id: <20181127175912.2651-1-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Jeremy Linton The BAD_MADT_GICC_ENTRY check is a little too strict because it rejects MADT entries that don't match the currently known lengths. We should remove this restriction to avoid problems if the table length changes. Future code which might depend on additional fields should be written to validate those fields before using them, rather than trying to globally check known MADT version lengths. Link: https://lkml.kernel.org/r/20181012192937.3819951-1-jeremy.linton@arm.com Signed-off-by: Jeremy Linton [lorenzo.pieralisi@arm.com: added MADT macro comments] Signed-off-by: Lorenzo Pieralisi Acked-by: Sudeep Holla Cc: Will Deacon Cc: Catalin Marinas Cc: Al Stone Cc: "Rafael J. Wysocki" --- Hi Will, Catalin, resending a patch already posted on public mailing lists[1], I have just added a comment to the existing patch for future reference as discussed in [1], please consider merging it. Thanks, Lorenzo [1] https://lore.kernel.org/lkml/20181012192937.3819951-1-jeremy.linton@arm.com/T/#u arch/arm64/include/asm/acpi.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) -- 2.19.2 diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 709208dfdc8b..2def77ec14be 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -22,12 +22,23 @@ #include /* Macros for consistency checks of the GICC subtable of MADT */ -#define ACPI_MADT_GICC_LENGTH \ - (acpi_gbl_FADT.header.revision < 6 ? 76 : 80) + +/* + * MADT GICC minimum length refers to the MADT GICC structure table length as + * defined in the earliest ACPI version supported on arm64, ie ACPI 5.1. + * + * The efficiency_class member was added to the + * struct acpi_madt_generic_interrupt to represent the MADT GICC structure + * "Processor Power Efficiency Class" field, added in ACPI 6.0 whose offset + * is therefore used to delimit the MADT GICC structure minimum length + * appropriately. + */ +#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ + struct acpi_madt_generic_interrupt, efficiency_class) #define BAD_MADT_GICC_ENTRY(entry, end) \ - (!(entry) || (entry)->header.length != ACPI_MADT_GICC_LENGTH || \ - (unsigned long)(entry) + ACPI_MADT_GICC_LENGTH > (end)) + (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ + (unsigned long)(entry) + (entry)->header.length > (end)) /* Basic configuration for ACPI */ #ifdef CONFIG_ACPI