Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1053761ybg; Wed, 29 Jul 2020 04:46:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtGk1agSlnH89Jg1rRI1vyMLGHboxviGuphrmYkr8AymUOQ410SDuwE0/77E7R5lO267Zy X-Received: by 2002:a17:906:198e:: with SMTP id g14mr28978498ejd.266.1596023215581; Wed, 29 Jul 2020 04:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596023215; cv=none; d=google.com; s=arc-20160816; b=pfQbDold5U4qbuB5HT6d1eXtg+ojU7u4RonY6imZKex75ik69apjy1aI7uwoOsdqvw wceQZl8/EohWYkO0IsOa1H94L2U15hLg8IX3trokYVttUs5BzPArMZg+FFloT21iE60d xTX435xS0T0Qqe98hotfev5lzdyuWP3XYZ9hbln/NNukxREr+14ZkQ/dt2ESMh6updU2 A09Nwd7S/j1qN+d2EydXzObXtT2xqWgdYE7rOlqm2yK1tzqp1vsHQg7rRFA5s48marNy txHQr/dgFjDwhprpt8sE3K3GAlrygXbkbcI+cLTfgCG68Shn9zS0PXXd1+s+awQkhMd0 sLpQ== 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=xsG6ynHSDdLlDhm8vf3XgtZpZt1ehZFUXFwbfdt+lYI=; b=MVM3jnCowY7Gd72fO6Bd+w4qCEEV4JRjeYnIbn5pWdRPKKL8a6oreYWAlJ4p+r3bwg B2mi5uyW1L5qMB/OcVjgIY5daFgXJWRHZqer/RfBY+rKJ/48MdRF1iHNw2GC4lhsuEn5 yAd6gLzaGtPOmhO+OqDkr9X0LpwOm428ypokrDiM7c8bhwdVI6KaUFlQSRVdOj5P/ayj BOQVs5NXmfxDTWOA3V4exrs1GLVvXbGcXsgrF2cceidATFbj+qjYVFiaIo8ZuI312jG9 PDowZ5Sp3m1GvqGjwegAAvpIyU9lbkhDUsdgAVlgKArih+njcCp56mZ+1ki67bK/3nxa ru4Q== 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 x17si1250410edq.518.2020.07.29.04.46.33; Wed, 29 Jul 2020 04:46:55 -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 S1726779AbgG2Lo0 (ORCPT + 99 others); Wed, 29 Jul 2020 07:44:26 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:19898 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726353AbgG2Lo0 (ORCPT ); Wed, 29 Jul 2020 07:44:26 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06TBWxLU050275; Wed, 29 Jul 2020 07:44:16 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 32k72ba5gt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2020 07:44:15 -0400 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06TBeJKb075474; Wed, 29 Jul 2020 07:44:15 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 32k72ba5ga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2020 07:44:15 -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 06TBgtlD016170; Wed, 29 Jul 2020 11:44:13 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06ams.nl.ibm.com with ESMTP id 32gcqgn059-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2020 11:44:13 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06TBgjEj66584988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jul 2020 11:42:45 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D30975204E; Wed, 29 Jul 2020 11:44:10 +0000 (GMT) Received: from [192.168.0.8] (unknown [9.79.217.86]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 83E1352050; Wed, 29 Jul 2020 11:44:07 +0000 (GMT) Subject: [PATCH v6 11/11] ppc64/kexec_file: enable early kernel's OPAL calls From: Hari Bathini To: Michael Ellerman Cc: Thiago Jung Bauermann , Mahesh J Salgaonkar , Sourabh Jain , Vivek Goyal , Dave Young , Petr Tesarik , Pingfan Liu , linuxppc-dev , Kexec-ml , lkml , Pingfan Liu , Eric Biederman , Thiago Jung Bauermann , Mimi Zohar , Nayna Jain , Andrew Morton Date: Wed, 29 Jul 2020 17:14:06 +0530 Message-ID: <159602303975.575379.5032301944162937479.stgit@hbathini> In-Reply-To: <159602259854.575379.16910915605574571585.stgit@hbathini> References: <159602259854.575379.16910915605574571585.stgit@hbathini> User-Agent: StGit/0.21 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.235,18.0.687 definitions=2020-07-29_04:2020-07-29,2020-07-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 suspectscore=0 impostorscore=0 phishscore=0 adultscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007290071 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kernel built with CONFIG_PPC_EARLY_DEBUG_OPAL enabled expects r8 & r9 to be filled with OPAL base & entry addresses respectively. Setting these registers allows the kernel to perform OPAL calls before the device tree is parsed. Signed-off-by: Hari Bathini Reviewed-by: Thiago Jung Bauermann --- v5 -> v6: * Added Reviewed-by tag from Thiago. * Moved the patch to end of the series for mpe to take a call on whether to have it or not. v4 -> v5: * New patch. Updated opal_base & opal_entry values in r8 & r9 respectively. This change was part of the below dropped patch in v4: - https://lore.kernel.org/patchwork/patch/1275667/ arch/powerpc/kexec/file_load_64.c | 20 ++++++++++++++++++++ arch/powerpc/purgatory/trampoline_64.S | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index c6a37ad5a0a4..53bb71e3a2e1 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -876,6 +876,7 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code, const void *fdt, unsigned long kernel_load_addr, unsigned long fdt_load_addr) { + struct device_node *dn = NULL; int ret; ret = setup_purgatory(image, slave_code, fdt, kernel_load_addr, @@ -903,9 +904,28 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code, &image->arch.backup_start, sizeof(image->arch.backup_start), false); + if (ret) + goto out; + + /* Setup OPAL base & entry values */ + dn = of_find_node_by_path("/ibm,opal"); + if (dn) { + u64 val; + + of_property_read_u64(dn, "opal-base-address", &val); + ret = kexec_purgatory_get_set_symbol(image, "opal_base", &val, + sizeof(val), false); + if (ret) + goto out; + + of_property_read_u64(dn, "opal-entry-address", &val); + ret = kexec_purgatory_get_set_symbol(image, "opal_entry", &val, + sizeof(val), false); + } out: if (ret) pr_err("Failed to setup purgatory symbols"); + of_node_put(dn); return ret; } diff --git a/arch/powerpc/purgatory/trampoline_64.S b/arch/powerpc/purgatory/trampoline_64.S index e79077ff1355..e6a6e7e6dfe4 100644 --- a/arch/powerpc/purgatory/trampoline_64.S +++ b/arch/powerpc/purgatory/trampoline_64.S @@ -87,6 +87,10 @@ master: li %r4,28 STWX_BE %r17,%r3,%r4 /* Store my cpu as __be32 at byte 28 */ 1: + /* Load opal base and entry values in r8 & r9 respectively */ + ld %r8,(opal_base - 0b)(%r18) + ld %r9,(opal_entry - 0b)(%r18) + /* load the kernel address */ ld %r4,(kernel - 0b)(%r18) @@ -133,6 +137,18 @@ backup_start: .8byte 0x0 .size backup_start, . - backup_start + .balign 8 + .globl opal_base +opal_base: + .8byte 0x0 + .size opal_base, . - opal_base + + .balign 8 + .globl opal_entry +opal_entry: + .8byte 0x0 + .size opal_entry, . - opal_entry + .data .balign 8 .globl purgatory_sha256_digest