From patchwork Wed Feb 17 12:36:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 62105 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2257929lbl; Wed, 17 Feb 2016 04:38:33 -0800 (PST) X-Received: by 10.66.120.200 with SMTP id le8mr1744344pab.61.1455712713052; Wed, 17 Feb 2016 04:38:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id aj1si1666369pad.244.2016.02.17.04.38.32; Wed, 17 Feb 2016 04:38:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@codeblueprint-co-uk.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934499AbcBQMib (ORCPT + 30 others); Wed, 17 Feb 2016 07:38:31 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:35544 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965290AbcBQMg1 (ORCPT ); Wed, 17 Feb 2016 07:36:27 -0500 Received: by mail-wm0-f50.google.com with SMTP id c200so211243500wme.0 for ; Wed, 17 Feb 2016 04:36:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeblueprint-co-uk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=310HGqBxVBQIrliR7GMKIr1whcFcoQsSIEx2BuTstVw=; b=oFOA8egmVy7a7rJCpP8sbbr6Dg33NBqaSyFkzECrCga2kNvrqwlOCD121VoPnCbIKW ltV9KmbbZJqmf4qxOCruoPnwjZQraCybohvcuvAWV0IaBEoGtFiie5L3j3ezGhBDhXwG Rg81pIwhHOKSt+9Dkmn224nih4AB8+WKXnVO/tTFtFB/IIQvw9MSfy9jk/3rvNtEFHvx Ax5ytLt3qP5xBjOVYA3Mc9iQ5Uyk4eBZh3pAEcXkKumhP8riQxJsNGDO0r0I3bp4Jrkr ZJ8SChvcqpLr/JTUk7OrfSA4RXIVE4hFHYb+k8zCvo9ALskuRkeixesJem5+TNgwCFbb DDoA== 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=310HGqBxVBQIrliR7GMKIr1whcFcoQsSIEx2BuTstVw=; b=KPvK0d8qy3FcaAHbn434vhV/hdHwVDEqpKRea2oFNltDxL2IxLO/Zv54jNjiMtv6ir ++2CszYHF94cJ5L7cRXIkJiobCGVzKu8JeRXlCwMmNVEv3sTwAQ/JgLYQvEP/3Cge1RP zpU09IjwJHqOLjxAiuhw7mI/w+l++TVl5pdcHFt+HKy4uuQwitSatsh5gb3AryewNV6p Uly+q1Gwx8+GdV20hJiOia6nJzXPAdA5yWJQFB8BMcb4RKpV+aGQ6e4yD7PHnKwFlBtJ o0tPTdB7rSxdol6M9U0bH+tvTlXwx/AZiEaAIChNyEnXsA0P7IdswBPgPub10w7mzaH2 TXRQ== X-Gm-Message-State: AG10YOSoZ4ftysEG/UQwydnJyxME9TfS13RVo0vw1OnHDaVZP2oUQyHsnI6XU5Sg95TghQ== X-Received: by 10.194.63.202 with SMTP id i10mr1686186wjs.118.1455712586439; Wed, 17 Feb 2016 04:36:26 -0800 (PST) Received: from localhost (5ec16434.skybroadband.com. [94.193.100.52]) by smtp.gmail.com with ESMTPSA id k124sm2910412wmb.11.2016.02.17.04.36.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Feb 2016 04:36:25 -0800 (PST) From: Matt Fleming To: Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Matt Fleming , Jeremy Linton , Mark Rutland , Suzuki K Poulose Subject: [PATCH 09/13] efi/arm64: Check for h/w support before booting a >4 KB granule kernel Date: Wed, 17 Feb 2016 12:36:02 +0000 Message-Id: <1455712566-16727-10-git-send-email-matt@codeblueprint.co.uk> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1455712566-16727-1-git-send-email-matt@codeblueprint.co.uk> References: <1455712566-16727-1-git-send-email-matt@codeblueprint.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel 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. Reviewed-by: Jeremy Linton Tested-by: Suzuki K Poulose Signed-off-by: Ard Biesheuvel Acked-by: Mark Rutland Signed-off-by: Matt Fleming --- drivers/firmware/efi/libstub/arm64-stub.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.6.2 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,