From patchwork Tue Feb 21 01:46:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 730250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vS3KJ6SQWz9s86 for ; Tue, 21 Feb 2017 12:47:32 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vS3KJ5dQfzDqGZ for ; Tue, 21 Feb 2017 12:47:32 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vS3KF0g6HzDqD2 for ; Tue, 21 Feb 2017 12:47:28 +1100 (AEDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1L1hhcw078350 for ; Mon, 20 Feb 2017 20:47:27 -0500 Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) by mx0a-001b2d01.pphosted.com with ESMTP id 28r1202jtk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Feb 2017 20:47:27 -0500 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 Feb 2017 11:47:25 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 21 Feb 2017 11:47:22 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 07F422BB0045 for ; Tue, 21 Feb 2017 12:47:22 +1100 (EST) Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1L1lDoJ34930874 for ; Tue, 21 Feb 2017 12:47:21 +1100 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v1L1kncQ013234 for ; Tue, 21 Feb 2017 12:46:49 +1100 Received: from jupiter.in.ibm.com ([9.79.216.197]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v1L1klAL012736; Tue, 21 Feb 2017 12:46:48 +1100 From: Mahesh J Salgaonkar To: skiboot list , Benjamin Herrenschmidt Date: Tue, 21 Feb 2017 07:16:31 +0530 In-Reply-To: <148764151096.19040.14028455428324561169.stgit@jupiter.in.ibm.com> References: <148764151096.19040.14028455428324561169.stgit@jupiter.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022101-0008-0000-0000-0000010CD32B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022101-0009-0000-0000-00000917A459 Message-Id: <148764157624.19040.12352699972619657394.stgit@jupiter.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-21_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702210015 Subject: [Skiboot] [RFC PATCH 1/2] opal: Fix OPAL entry path to resue callers stack. X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Mahesh Salgaonkar OPAL uses its own stack for each opal call that are made from linux. This makes OPAL non reentrant. This patch fixes that by using caller's stack instead of switching to its own. Signed-off-by: Mahesh Salgaonkar --- asm/head.S | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/asm/head.S b/asm/head.S index d7c2821..7efacb7 100644 --- a/asm/head.S +++ b/asm/head.S @@ -36,6 +36,9 @@ #define GET_CPU() \ clrrdi %r13,%r1,STACK_SHIFT +#define GET_CPU_REG(stack_reg) \ + clrrdi %r13,stack_reg,STACK_SHIFT + #define SAVE_GPR(reg,sp) std %r##reg,STACK_GPR##reg(sp) #define REST_GPR(reg,sp) ld %r##reg,STACK_GPR##reg(sp) @@ -837,9 +840,8 @@ opal_boot_trampoline: .balign 0x10 .global opal_entry opal_entry: - /* Get our per CPU stack */ - mfspr %r12,SPR_PIR - GET_STACK(%r12,%r12) + /* Lets stick to caller's stack. */ + mr %r12,%r1 stdu %r12,-STACK_FRAMESIZE(%r12) /* Save caller r1, establish new r1 */ @@ -864,7 +866,9 @@ opal_entry: std %r12,STACK_LR(%r1) /* Get the CPU thread */ - GET_CPU() + mfspr %r12,SPR_PIR + GET_STACK(%r12,%r12) + GET_CPU_REG(%r12) /* Store token in CPU thread */ std %r0,CPUTHREAD_CUR_TOKEN(%r13)