From patchwork Fri Oct 17 08:08:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 38839 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56F5220C5D for ; Fri, 17 Oct 2014 08:12:43 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id b6sf179706lbj.3 for ; Fri, 17 Oct 2014 01:12:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ATGcpXVh5TEUaLt1EgGQfTSoAD8DXwsptXgf/yvwuV0=; b=EnEDeF5plfJ3cTkOYGocaTff0BnHnDH0MBcsDKGS11DuJ+rUGifP6lzTkq+GtvyjEw wYMHCb8xd0IMWs1ZbJSAenPiaoKz3Id0EFOpVEZ27fpDLAwQ/OkhwndcwN0ZC5KtGlpp J7s5aDk1msORA4rUIZ3I8BDBgMa3kcCv0srB58NTqTB0iM+kflzYUTgT0Ac/9Sbx7a2A x5PSIyznz25Oa6ooYGgGTpo8Nmv5yDBHN2+MN/DVNRBrvynn/Bg4unLR7xW1QKXPBKTt 2uYqUVj7Tyuxfq+Sxz1zb1QCcP55JZ5epnyPIM4/451xt6p/9NnOECy24B4Am+Rtsxsy Nxyw== X-Gm-Message-State: ALoCoQmk8XXX1QAuM8RDJvQCg3C19agNtmLkaSqdJnSnYzy4Iq00dUJiPDiJ5v2evp2O6jpcfZCQ X-Received: by 10.112.99.72 with SMTP id eo8mr1093905lbb.7.1413533562084; Fri, 17 Oct 2014 01:12:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.34 with SMTP id ir2ls240991lac.7.gmail; Fri, 17 Oct 2014 01:12:41 -0700 (PDT) X-Received: by 10.112.201.138 with SMTP id ka10mr7134799lbc.20.1413533561965; Fri, 17 Oct 2014 01:12:41 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id s2si918914lag.22.2014.10.17.01.12.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 01:12:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so256942lbd.6 for ; Fri, 17 Oct 2014 01:12:41 -0700 (PDT) X-Received: by 10.152.6.228 with SMTP id e4mr6923013laa.71.1413533561880; Fri, 17 Oct 2014 01:12:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp184077lbz; Fri, 17 Oct 2014 01:12:41 -0700 (PDT) X-Received: by 10.70.91.204 with SMTP id cg12mr6805056pdb.33.1413533555379; Fri, 17 Oct 2014 01:12:35 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si482018pdp.169.2014.10.17.01.12.34 for ; Fri, 17 Oct 2014 01:12:35 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753575AbaJQIMb (ORCPT + 1 other); Fri, 17 Oct 2014 04:12:31 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36344 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751158AbaJQIMM (ORCPT ); Fri, 17 Oct 2014 04:12:12 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 61508ACDD; Fri, 17 Oct 2014 08:11:54 +0000 (UTC) Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.83) (envelope-from ) id 1Xf2dd-00006u-W9; Fri, 17 Oct 2014 10:11:53 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: Dave Martin , Dave Martin , Russell King , Jiri Slaby Subject: [PATCH 3.12 006/197] ARM: 7897/1: kexec: Use the right ISA for relocate_new_kernel Date: Fri, 17 Oct 2014 10:08:42 +0200 Message-Id: <0a6afabb7d57d5dff388e0a8e7022028056a9485.1413533329.git.jslaby@suse.cz> X-Mailer: git-send-email 2.1.1 In-Reply-To: <7d97f39bc813aa9f11fe03d602885f81de07007c.1413533329.git.jslaby@suse.cz> References: <7d97f39bc813aa9f11fe03d602885f81de07007c.1413533329.git.jslaby@suse.cz> In-Reply-To: References: Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Dave Martin 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit e2ccba49085ab5d71b092de2a5176eb9b19cc876 upstream. Copying a function with memcpy() and then trying to execute the result isn't trivially portable to Thumb. This patch modifies the kexec soft restart code to copy its assembler trampoline relocate_new_kernel() using fncpy() instead, so that relocate_new_kernel can be in the same ISA as the rest of the kernel without problems. Signed-off-by: Dave Martin Acked-by: Will Deacon Reported-by: Taras Kondratiuk Tested-by: Taras Kondratiuk Signed-off-by: Russell King Signed-off-by: Jiri Slaby --- arch/arm/kernel/machine_kexec.c | 17 ++++++++++------- arch/arm/kernel/relocate_kernel.S | 8 ++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c index faa3d4c41ece..8cf0996aa1a8 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -14,11 +14,12 @@ #include #include #include +#include #include #include #include -extern const unsigned char relocate_new_kernel[]; +extern void relocate_new_kernel(void); extern const unsigned int relocate_new_kernel_size; extern unsigned long kexec_start_address; @@ -142,6 +143,8 @@ void machine_kexec(struct kimage *image) { unsigned long page_list; unsigned long reboot_code_buffer_phys; + unsigned long reboot_entry = (unsigned long)relocate_new_kernel; + unsigned long reboot_entry_phys; void *reboot_code_buffer; /* @@ -168,18 +171,18 @@ void machine_kexec(struct kimage *image) /* copy our kernel relocation code to the control code page */ - memcpy(reboot_code_buffer, - relocate_new_kernel, relocate_new_kernel_size); + reboot_entry = fncpy(reboot_code_buffer, + reboot_entry, + relocate_new_kernel_size); + reboot_entry_phys = (unsigned long)reboot_entry + + (reboot_code_buffer_phys - (unsigned long)reboot_code_buffer); - - flush_icache_range((unsigned long) reboot_code_buffer, - (unsigned long) reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE); printk(KERN_INFO "Bye!\n"); if (kexec_reinit) kexec_reinit(); - soft_restart(reboot_code_buffer_phys); + soft_restart(reboot_entry_phys); } void arch_crash_save_vmcoreinfo(void) diff --git a/arch/arm/kernel/relocate_kernel.S b/arch/arm/kernel/relocate_kernel.S index d0cdedf4864d..95858966d84e 100644 --- a/arch/arm/kernel/relocate_kernel.S +++ b/arch/arm/kernel/relocate_kernel.S @@ -2,10 +2,12 @@ * relocate_kernel.S - put the kernel image in place to boot */ +#include #include - .globl relocate_new_kernel -relocate_new_kernel: + .align 3 /* not needed for this code, but keeps fncpy() happy */ + +ENTRY(relocate_new_kernel) ldr r0,kexec_indirection_page ldr r1,kexec_start_address @@ -79,6 +81,8 @@ kexec_mach_type: kexec_boot_atags: .long 0x0 +ENDPROC(relocate_new_kernel) + relocate_new_kernel_end: .globl relocate_new_kernel_size