From patchwork Tue Feb 16 15:49:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 8328571 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5BEEBC02AA for ; Tue, 16 Feb 2016 15:52:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B6F620272 for ; Tue, 16 Feb 2016 15:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFE7A202E5 for ; Tue, 16 Feb 2016 15:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932444AbcBPPwU (ORCPT ); Tue, 16 Feb 2016 10:52:20 -0500 Received: from foss.arm.com ([217.140.101.70]:54557 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932452AbcBPPwS (ORCPT ); Tue, 16 Feb 2016 10:52:18 -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 989035E9; Tue, 16 Feb 2016 07:51:28 -0800 (PST) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.209.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2B82D3F213; Tue, 16 Feb 2016 07:52:16 -0800 (PST) From: James Morse To: linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Sudeep Holla , Geoff Levand , Catalin Marinas , Lorenzo Pieralisi , Mark Rutland , AKASHI Takahiro , Marc Zyngier , "Rafael J . Wysocki" , Pavel Machek , linux-pm@vger.kernel.org, James Morse Subject: [PATCH v5 15/15] arm64: hibernate: Prevent resume from a different kernel version Date: Tue, 16 Feb 2016 15:49:27 +0000 Message-Id: <1455637767-31561-16-git-send-email-james.morse@arm.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1455637767-31561-1-git-send-email-james.morse@arm.com> References: <1455637767-31561-1-git-send-email-james.morse@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Resuming using a different kernel version is fragile, while there are sufficient details in the hibernate arch-header to perform the restore, changes in the boot process can have a long-lasting impact on the system. In particular, if the EFI stub causes more memory to be allocated, the amount of memory left for linux is reduced. If we are lucky, this will cause restore to fail with the message: > PM: Image mismatch: memory size If we are unlucky, the system will explode sometime later when an EFI runtime services call is made. Prevent resuming with a different kernel version, by making HIBERNATE_VERSION the current kernel version. Signed-off-by: James Morse --- arch/arm64/kernel/hibernate.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index fd2faca358f6..99ebdbb06e85 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -56,14 +56,9 @@ extern int in_suspend; /* * This value is written to the hibernate arch header, and prevents resuming - * from a hibernate image produced by an incompatible kernel. If you change - * a value that isn't saved/restored by hibernate, you should change this value. - * - * For example, if the mair_el1 values used by the kernel are changed, you - * should prevent resuming from a kernel with incompatible attributes, as these - * aren't saved/restored. + * from a hibernate image produced by a different kernel version. */ -#define HIBERNATE_VERSION KERNEL_VERSION(4, 6, 0) +#define HIBERNATE_VERSION LINUX_VERSION_CODE /* * Start/end of the hibernate exit code, this must be copied to a 'safe'