Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp812101ybt; Fri, 26 Jun 2020 12:07:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy25I31oc2GUGmExKrD0cAp1n7czjDGt+WnQeyUu3Vhb2rbYFFRNm+cW/dqE9777DOBPXE4 X-Received: by 2002:aa7:c6d3:: with SMTP id b19mr4706301eds.207.1593198466907; Fri, 26 Jun 2020 12:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593198466; cv=none; d=google.com; s=arc-20160816; b=jDcxlhOsvMofS+lZ9O+UsTP5KaC8z5D2fSGjTLGp6qyWWbnoEZgFQA7byBZQWQFi8b keqTzFbgs4pkdB5Zg284n4WlvCQFAZ1SOFlFfOa+2pI8X4A0dh+UaxhzCqub/iJvozp1 EMfcFsQ9+4nIZq+SC6sLpUU4xu3+4SMiwkoMgp0FxvZG4qIzzRnYwaTqge5FJFVbqnqB yiv5leDlY6JVaIaGsvIB8slP3Ff6IDaL17AQ6Ox1YQEygWqEO3NBTrffUhs8ETuhNlPo a9zF8xwdEt3Aiz3qStysiLFWaiy75KeK6wn4p0hvxyJl/TuOt4XxXjRT7FD1o4im221N 6HBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=mrcfxpzi+ArD2D/rz8xrEy1An19hZUcdUUsAHQJrXbc=; b=gicojo9wIc9R8lED3sj/Ce1TimC6cYQjypKy12QSm4ZccIZCxtH5UcCCeAsEvIxd93 5VIYBODJNB4b19RZkd/BP8WNbEdnvj7u9zKN1IBr6r0+z7JZXVonJE0oguZUHnEFsqS/ w7MeKskIjeWiXnMEFuiwwtsJShMYJfSVsGEaycBxCu6Fs1Rzv3NmX4UFpxSU2EfSbN/j 6DR1+9Nq0w2Yj/MwgFdCi+CK4zdnMnfI6dbRwOSP+eEgPK9Q0IBUCOpdrfEG7MdEHeYZ kOzR43xTz/BANeD/nn0bmKEKUIezdE7VHuCQwCSn5YNIKqjgS83Zzy4+qTqVq7/HvuRt tbpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r6si11311217edl.422.2020.06.26.12.07.23; Fri, 26 Jun 2020 12:07:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726094AbgFZTGK (ORCPT + 99 others); Fri, 26 Jun 2020 15:06:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:18372 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbgFZTGK (ORCPT ); Fri, 26 Jun 2020 15:06:10 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05QJ40qM047602; Fri, 26 Jun 2020 15:06:00 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31vvkyr6dr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jun 2020 15:05:59 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05QJ44O1047946; Fri, 26 Jun 2020 15:05:59 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 31vvkyr6dd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jun 2020 15:05:59 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05QJ1lOh003755; Fri, 26 Jun 2020 19:05:57 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 31uusjk8gy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jun 2020 19:05:57 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05QJ5sA120381756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Jun 2020 19:05:54 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72D9E42045; Fri, 26 Jun 2020 19:05:54 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 473B34203F; Fri, 26 Jun 2020 19:05:51 +0000 (GMT) Received: from hbathini.in.ibm.com (unknown [9.102.0.159]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 26 Jun 2020 19:05:51 +0000 (GMT) Subject: [PATCH 08/11] ppc64/kexec_file: setup the stack for purgatory From: Hari Bathini To: Michael Ellerman , Andrew Morton Cc: Pingfan Liu , Kexec-ml , Mimi Zohar , Petr Tesarik , Mahesh J Salgaonkar , Sourabh Jain , lkml , linuxppc-dev , Eric Biederman , Thiago Jung Bauermann , Dave Young , Vivek Goyal Date: Sat, 27 Jun 2020 00:35:50 +0530 Message-ID: <159319835023.16351.6771622598460231857.stgit@hbathini.in.ibm.com> In-Reply-To: <159319825403.16351.7253978047621755765.stgit@hbathini.in.ibm.com> References: <159319825403.16351.7253978047621755765.stgit@hbathini.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-26_10:2020-06-26,2020-06-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 malwarescore=0 adultscore=0 impostorscore=0 priorityscore=1501 mlxscore=0 phishscore=0 cotscore=-2147483648 spamscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006260130 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To avoid any weird errors, the purgatory should run with its own stack. Set one up by adding the stack buffer to .data section of the purgatory. Signed-off-by: Hari Bathini --- arch/powerpc/include/asm/kexec.h | 4 ++++ arch/powerpc/kexec/file_load_64.c | 14 +++++++++++++- arch/powerpc/purgatory/trampoline_64.S | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h index bf47a01..e78cd0a 100644 --- a/arch/powerpc/include/asm/kexec.h +++ b/arch/powerpc/include/asm/kexec.h @@ -45,6 +45,10 @@ #define KEXEC_ARCH KEXEC_ARCH_PPC #endif +#ifdef CONFIG_KEXEC_FILE +#define KEXEC_PURGATORY_STACK_SIZE 16384 /* 16KB stack size */ +#endif + #define KEXEC_STATE_NONE 0 #define KEXEC_STATE_IRQS_OFF 1 #define KEXEC_STATE_REAL_MODE 2 diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index 4430336..8e66c28 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -878,7 +878,8 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code, const void *fdt, unsigned long kernel_load_addr, unsigned long fdt_load_addr) { - uint64_t toc_ptr; + uint64_t toc_ptr, stack_top; + void *stack_buf; int ret; ret = setup_purgatory(image, slave_code, fdt, kernel_load_addr, @@ -901,6 +902,17 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code, goto out; } + /* Setup the stack top */ + stack_buf = kexec_purgatory_get_symbol_addr(image, "stack_buf"); + if (!stack_buf) + goto out; + + stack_top = (u64)stack_buf + KEXEC_PURGATORY_STACK_SIZE; + ret = kexec_purgatory_get_set_symbol(image, "stack", &stack_top, + sizeof(stack_top), false); + if (ret) + goto out; + /* Setup the TOC pointer */ toc_ptr = get_toc_ptr(image->purgatory_info.ehdr); ret = kexec_purgatory_get_set_symbol(image, "my_toc", &toc_ptr, diff --git a/arch/powerpc/purgatory/trampoline_64.S b/arch/powerpc/purgatory/trampoline_64.S index 7b4a5f7..80615b4 100644 --- a/arch/powerpc/purgatory/trampoline_64.S +++ b/arch/powerpc/purgatory/trampoline_64.S @@ -9,6 +9,7 @@ * Copyright (C) 2013, Anton Blanchard, IBM Corporation */ +#include #include .machine ppc64 @@ -53,6 +54,8 @@ master: ld %r2,(my_toc - 0b)(%r18) /* setup toc */ + ld %r1,(stack - 0b)(%r18) /* setup stack */ + /* load device-tree address */ ld %r3, (dt_offset - 0b)(%r18) mr %r16,%r3 /* save dt address in reg16 */ @@ -111,6 +114,12 @@ my_toc: .8byte 0x0 .size my_toc, . - my_toc + .balign 8 + .globl stack +stack: + .8byte 0x0 + .size stack, . - stack + .data .balign 8 .globl purgatory_sha256_digest @@ -123,3 +132,9 @@ purgatory_sha256_digest: purgatory_sha_regions: .skip 8 * 2 * 16 .size purgatory_sha_regions, . - purgatory_sha_regions + + .balign 8 +.globl stack_buf +stack_buf: + .skip KEXEC_PURGATORY_STACK_SIZE + .size stack_buf, . - stack_buf