From patchwork Thu Feb 4 15:50:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 61209 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp572721lbl; Thu, 4 Feb 2016 08:55:51 -0800 (PST) X-Received: by 10.66.142.234 with SMTP id rz10mr12344568pab.113.1454604951273; Thu, 04 Feb 2016 08:55:51 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id x72si12635215pfi.196.2016.02.04.08.55.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Feb 2016 08:55:51 -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 1aRNB9-0002co-Nf; Thu, 04 Feb 2016 16:54:47 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aRNB6-0002bp-Tx for linux-arm-kernel@bombadil.infradead.org; Thu, 04 Feb 2016 16:54:45 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by merlin.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1aRMBZ-0007qI-SL for linux-arm-kernel@lists.infradead.org; Thu, 04 Feb 2016 15:51:10 +0000 Received: by mail-wm0-x22b.google.com with SMTP id g62so10743029wme.0 for ; Thu, 04 Feb 2016 07:50:48 -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=WO67hA4o5qC9n6eh0CQ+2L7DKLO0TTbTLuLAlMGMWd4=; b=kWXn+eEgfFaKqs6jPFky5/PLcFZ5Nwu0BI/hOlPZuBetolFJZmJLZwAessY3joxarn aCtjM64VjYUPV/epsY/FlPG2c9L6i/MbpRXImq4/HHDlppRrQiYMUbP4M4EJhJ6g9p6P 8CuoDDgFHOpbvjDvAfROFMAzas2Pt98syIrrw= 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=WO67hA4o5qC9n6eh0CQ+2L7DKLO0TTbTLuLAlMGMWd4=; b=D8WtZcPVpvKLAyYm5PN34lNc6DZX6gzDY7djsALSJge79qmO3mIukNzqhjEMRxFgP4 9e7DW/0/AOiZZs0mMwzKRIa1r+xUI9Wivi1ZqCKr6DSkirlCf8OMu5v51KCca44sux47 LBTzKi/Z2rItGOBTI2pDL46rn0z3TPJg/yoL6iplA+rRoL31YUEXcZ3DC/92Lks7/KbS beFmiefRiu7pq8ux6VmvCign/kSzxwEVduQeJVQtTo6gh4lrFvBAAbbTCc7HD0xwM48g 6DAJB9Tw8L5XLrWvoS0/DtPh1jwWZvHkfCmUjPk3tEW005oIuXnX/1IyTxBFMMEUVhpY V2GA== X-Gm-Message-State: AG10YOQsbcCK1lKYYQ/lPI2Eh+fWZhVr2Y0jOXxFjr1dvr3xKQL0Lcu2g3xMYP60sJKzNqVN X-Received: by 10.28.213.204 with SMTP id m195mr32809951wmg.53.1454601047145; Thu, 04 Feb 2016 07:50:47 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id q73sm26885838wmb.1.2016.02.04.07.50.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Feb 2016 07:50:46 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, matt@codeblueprint.co.uk, catalin.marinas@arm.com Subject: [PATCH v2 6/7] arm64: efistub: check for h/w support before booting a >4 KB granule kernel Date: Thu, 4 Feb 2016 16:50:29 +0100 Message-Id: <1454601030-9093-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454601030-9093-1-git-send-email-ard.biesheuvel@linaro.org> References: <1454601030-9093-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160204_105110_142181_72E374EF X-CRM114-Status: GOOD ( 14.45 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.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:22b 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 Message has at least one valid DKIM or DK signature -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 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: mark.rutland@arm.com, Ard Biesheuvel , will.deacon@arm.com, jeremy.linton@arm.com, suzuki.poulose@arm.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. Reviewed-by: Jeremy Linton Tested-by: Suzuki K Poulose 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,