From patchwork Thu Sep 25 09:53:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu hua X-Patchwork-Id: 37915 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BDA3420560 for ; Thu, 25 Sep 2014 10:06:57 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id hi2sf4444052wib.3 for ; Thu, 25 Sep 2014 03:06:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=KR1nPYJhcqtw7cxbY2waC8d+5yzHFMRjdtG9ZRpPC2A=; b=TjP8QdJ3fg8OdJpW3GmP0l4ZzUOGL2g4A+uoz89XD66cEPtWt0Qh4En3QkFptdX7ft gBIqGn/uJXHNKuEaBYElubGcMINk4z17iAgCfgIvOqGFX2FYxwHqPxSseLtNOCQMjt4u GvnTYFGSImUoLSK9nDhwEQHF1Y8Kqrq83x5An+VZSv8riNkUdFY+IzuKCk52S2J86dly tJddOju3mUbywDYxYuksAldr3zUsjOnr1s49U3E5XnEWzlykdTLbenBl6EJIrXnNtIZS sV0ypt1N1peSBFlh5GmbcC8I75K9qvnH0yLsWaPETpTVU+FhImBgn1d0Svi+gDYBctPV Sj+Q== X-Gm-Message-State: ALoCoQnWKiJdotgaY9+zo2qfTbqVRc/uWINQyy251EpZwbsNi99sS3iVeWKpDgO9VjKU+nY25eWx X-Received: by 10.152.3.134 with SMTP id c6mr1569112lac.5.1411639616946; Thu, 25 Sep 2014 03:06:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.73 with SMTP id z9ls243319lag.55.gmail; Thu, 25 Sep 2014 03:06:56 -0700 (PDT) X-Received: by 10.112.147.74 with SMTP id ti10mr11573956lbb.29.1411639616446; Thu, 25 Sep 2014 03:06:56 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id dy7si2261687lbc.95.2014.09.25.03.06.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Sep 2014 03:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id z12so9615302lbi.37 for ; Thu, 25 Sep 2014 03:06:56 -0700 (PDT) X-Received: by 10.112.130.226 with SMTP id oh2mr1790112lbb.100.1411639616332; Thu, 25 Sep 2014 03:06:56 -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.130.169 with SMTP id of9csp722988lbb; Thu, 25 Sep 2014 03:06:55 -0700 (PDT) X-Received: by 10.66.172.36 with SMTP id az4mr17504568pac.104.1411639614776; Thu, 25 Sep 2014 03:06:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gw1si3041658pbd.5.2014.09.25.03.06.54 for ; Thu, 25 Sep 2014 03:06:54 -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 S1752592AbaIYKGw (ORCPT + 1 other); Thu, 25 Sep 2014 06:06:52 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:10816 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752095AbaIYKGv (ORCPT ); Thu, 25 Sep 2014 06:06:51 -0400 Received: from 172.24.2.119 (EHLO szxeml409-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AUV46652; Thu, 25 Sep 2014 18:06:43 +0800 (CST) Received: from localhost (10.107.197.247) by szxeml409-hub.china.huawei.com (10.82.67.136) with Microsoft SMTP Server id 14.3.158.1; Thu, 25 Sep 2014 18:06:32 +0800 From: Liu Hua To: CC: , , , , Subject: [PATCH] ARM: 7897/1: kexec: Use the right ISA for relocate_new_kernel Date: Thu, 25 Sep 2014 17:53:44 +0800 Message-ID: <1411638824-66243-1-git-send-email-sdu.liu@huawei.com> X-Mailer: git-send-email 1.9.0 MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5423E934.012B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: eca7000d57bb52b41e6fd65c3585fb86 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.178 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 Hi Greg, 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. Without this patch THUMB2 kernel can not go through kdump process. I have test it on 3.10. This patch applies to v3.13+. 3.10 stable and 3.12stable need it. (1) A separate backport is needed for 3.10; (2) it can apply to 3.12 stable directly. Signed-off-by: Dave Martin Acked-by: Will Deacon Reported-by: Taras Kondratiuk Tested-by: Taras Kondratiuk Signed-off-by: Russell King Integrated-by: Liu Hua Signed-off-by: Liu Hua Signed-off-by: Zefan Li ] --- 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 c3ef920..70ae735 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -14,10 +14,11 @@ #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; @@ -133,6 +134,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; if (num_online_cpus() > 1) { @@ -156,18 +159,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 d0cdedf..9585896 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