From patchwork Thu Jan 28 17:02:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 60745 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp599911lbb; Thu, 28 Jan 2016 09:05:37 -0800 (PST) X-Received: by 10.66.139.166 with SMTP id qz6mr6129547pab.148.1454000737757; Thu, 28 Jan 2016 09:05:37 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ud10si17938384pab.54.2016.01.28.09.05.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jan 2016 09:05:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOpzp-0000NV-51; Thu, 28 Jan 2016 17:04:37 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOpyG-0007QH-Kl for linux-arm-kernel@lists.infradead.org; Thu, 28 Jan 2016 17:03:02 +0000 Received: by mail-wm0-x22d.google.com with SMTP id p63so33655577wmp.1 for ; Thu, 28 Jan 2016 09:02:40 -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=pWPfhJWYdmFDacaYADRfd1juRrjUBHlIq2klqSe5yTw=; b=PjVxqv9zCdT2hPDz+26Cye9dFsFnKUS1zQiZ2/FUsNZSLjw1yOGkCLrOdrm1vPwJ0S iJqiy8WM8Yms4g697GfiIaSmSwfZw+gxEJ4qfzKkZ6gnw4L4HToOdfR8UTqDZpoa18Qj LCO+mzKUlDWdvfNbfYRBD5l6RIT+w9LSruoCw= 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=pWPfhJWYdmFDacaYADRfd1juRrjUBHlIq2klqSe5yTw=; b=R1xrOPn9MbYfSVZ4psrlUuzlcqRND88PHOuea2T7ephpweTR3ZANoSP1PJPAzykkRK eyZFvlZKW0QiwevMxN4B3gLmW/KJDqG4WeVqtAmluc25eA8LQEhUuOg1NVSfOd6c62eW 9VFEFDwxnJLY+g7FcF/vv8RM8enu68mBTYBtB87GBZUTnnI4DgP9UfiV3NJu/AfIwqBR sni/CV9qQKJTSIDCciG0WJnZszGlSg7HZ9BKxDCSHQabqHKjplKiwntroVHuUcqsqFww bOu/DDyt4ZfXS3W8DpN1T39fD1pgljhsNrcHOlI1q3ULB2E5w1hEOGUNgoOXH8YBzwN7 94nQ== X-Gm-Message-State: AG10YORuj0p7dqiNuepQ7dbQ3qZsEr3sIKnC2wEMbSp6hYi0Y3jxbgIQ+vpiZ0LcRYwYeFlI X-Received: by 10.28.99.69 with SMTP id x66mr4348808wmb.10.1454000558921; Thu, 28 Jan 2016 09:02:38 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id b127sm3709301wmh.9.2016.01.28.09.02.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jan 2016 09:02:38 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, jeremy.linton@arm.com, Suzuki.Poulose@arm.com Subject: [PATCH 2/3] arm64: efistub: check for h/w support before booting a >4 KB granule kernel Date: Thu, 28 Jan 2016 18:02:28 +0100 Message-Id: <1454000549-9189-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454000549-9189-1-git-send-email-ard.biesheuvel@linaro.org> References: <1454000549-9189-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160128_090301_021914_4FB36F55 X-CRM114-Status: GOOD ( 13.39 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel , dann.frazier@canonical.com, dhdang@apm.com, leif.lindholm@linaro.org, lho@apm.com, ksankaran@apm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org A kernel built with support for a page size that is not supported by the hardware it runs on cannot boot to a state where it can inform the user about it. If we happen to be booting via UEFI, we can fail gracefully so check if the currently configured page size is supported by the hardware before entering the kernel proper. Note that UEFI mandates support for 4 KB pages, so in that case, no check is needed. Suggested-by: Jeremy Linton Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/arm64-stub.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c index 9e0342745e4f..aef04ad60e0d 100644 --- a/drivers/firmware/efi/libstub/arm64-stub.c +++ b/drivers/firmware/efi/libstub/arm64-stub.c @@ -12,6 +12,26 @@ #include #include #include +#include + +efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) +{ + u64 tg; + + /* UEFI mandates support for 4 KB granule, no need to check */ + if (IS_ENABLED(CONFIG_ARM64_4K_PAGES)) + return EFI_SUCCESS; + + tg = (read_cpuid(ID_AA64MMFR0_EL1) >> ID_AA64MMFR0_TGRAN_SHIFT) & 0xf; + if (tg != ID_AA64MMFR0_TGRAN_SUPPORTED) { + if (IS_ENABLED(CONFIG_ARM64_64K_PAGES)) + pr_efi_err(sys_table_arg, "This 64 KB granule kernel is not supported by your CPU\n"); + else + pr_efi_err(sys_table_arg, "This 16 KB granule kernel is not supported by your CPU\n"); + return EFI_UNSUPPORTED; + } + return EFI_SUCCESS; +} efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg, unsigned long *image_addr,