Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp50686ybk; Thu, 14 May 2020 15:56:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC1awB/lHUVqjwcHIsKV6FcSl/Ojuiue7SwK0AD6K6stmi8DcbnmY9nuMBdtb2AzmfFUI5 X-Received: by 2002:a05:6402:2c4:: with SMTP id b4mr313698edx.331.1589497001134; Thu, 14 May 2020 15:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589497001; cv=none; d=google.com; s=arc-20160816; b=GsArCKV+B4JLXrVdyepAmMPOfdmH9Pg4VHRBTonoGnCPHpCcvx16B356dT2l/IWz4h rvuCKHFjHhldNzQQqtBjNZM+qhvJNVD/JpBALDJgfecqITKRmXQQpHaQsPGtQU8sFoUS Q7ecw9G7Lz/488QxQEj/mlxwDHQZWn7C5J6E7GqncH/GC7cx++Z+OEFLrAwkT7LqHmVf 9qZ03jZwjexu3KKKvYo3AlMyjnwe4fLkkoXO61QM4awPdCVT2cRiXiFeg39Nrr2w1Tep gkQOJAlzV8EJ5KRhnFyuA7ONnkWr3LelT8pijakSLsFxu0cjlPiowa1V6M5dFf7TXczP It4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=kEPo6+9th3KdU7Gx8jFNOkeJfZJ65VJ5MU9T0sVp9pE=; b=uCgMYp5F7kt9JKHhXJoJgiT4rrcm3Iu845o7GKD3NXsbWBX4mDwiQcKl40IJepQhLC 50yPxLwbDNjiC98EDyK9ZRjPS4AqREHdIj3bo6CiOwSp6cK2P8qoo98nUGlZ9JiaTH39 zLEIpPG6R3YwjF+HtjRCqNtB6MvEW7vNH86Mjiq7KOg5ZzJ4Z9r28m3yorWXo/HRKfn7 p3VyUw3a7yLTdfa/aZ1S4g0O2/uAWAAMQoH/Vv+8yFWBi+Hx4ffHLM2lyiVWkMpnknrh Reixw7Wcz4BaZbCBg6HwJnugTP31fSW/YeeR7I2qhG0qECD2kPb5dLmUcLkLgjJxIple b7Pw== 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 l11si209114eja.20.2020.05.14.15.56.18; Thu, 14 May 2020 15:56:41 -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 S1729916AbgENS64 (ORCPT + 99 others); Thu, 14 May 2020 14:58:56 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:5158 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729915AbgENS6y (ORCPT ); Thu, 14 May 2020 14:58:54 -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 04EIdSpF055409; Thu, 14 May 2020 14:58:21 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3101kq446q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2020 14:58:21 -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 04EImK2Y079555; Thu, 14 May 2020 14:58:21 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3101kq4468-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2020 14:58:21 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04EIonLD013393; Thu, 14 May 2020 18:58:20 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma04wdc.us.ibm.com with ESMTP id 3100ubrvft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2020 18:58:20 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04EIwJ2Q30409116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2020 18:58:19 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BDB922805C; Thu, 14 May 2020 18:58:19 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6748E28058; Thu, 14 May 2020 18:58:19 +0000 (GMT) Received: from localhost (unknown [9.85.205.196]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 14 May 2020 18:58:19 +0000 (GMT) From: Nathan Lynch To: Leonardo Bras Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Allison Randal , Greg Kroah-Hartman , Thomas Gleixner , Nicholas Piggin , Leonardo Bras , "Gautham R. Shenoy" , Nadav Amit Subject: Re: [PATCH v3 2/2] powerpc/rtas: Implement reentrant rtas call In-Reply-To: <20200514011245.127174-3-leobras.c@gmail.com> References: <20200514011245.127174-1-leobras.c@gmail.com> <20200514011245.127174-3-leobras.c@gmail.com> Date: Thu, 14 May 2020 13:58:18 -0500 Message-ID: <878shu2vjp.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-14_06:2020-05-14,2020-05-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 cotscore=-2147483648 mlxlogscore=999 adultscore=0 clxscore=1011 suspectscore=1 spamscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005140160 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Leonardo Bras writes: > +/** > + * rtas_call_reentrant() - Used for reentrant rtas calls > + * @token: Token for desired reentrant RTAS call > + * @nargs: Number of Input Parameters > + * @nret: Number of Output Parameters > + * @outputs: Array of outputs > + * @...: Inputs for desired RTAS call > + * > + * According to LoPAR documentation, only "ibm,int-on", "ibm,int-off", > + * "ibm,get-xive" and "ibm,set-xive" are currently reentrant. > + * Reentrant calls need their own rtas_args buffer, so not using rtas.args, but > + * PACA one instead. > + * > + * Return: -1 on error, > + * First output value of RTAS call if (nret > 0), > + * 0 otherwise, > + */ > + > +int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...) > +{ > + va_list list; > + struct rtas_args *args; > + int i; > + > + if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE) > + return -1; > + > + /* We use the per-cpu (PACA) rtas args buffer */ > + args = &local_paca->reentrant_args; > + > + va_start(list, outputs); > + va_rtas_call_unlocked(args, token, nargs, nret, list); > + va_end(list); > + > + if (nret > 1 && outputs) > + for (i = 0; i < nret - 1; ++i) > + outputs[i] = be32_to_cpu(args->rets[i + 1]); Doesn't this need to be more careful about preemption and exceptions? I.e. the args structure in the paca needs to be protected from concurrent use somehow, like any per-cpu data structure. local_irq_save/restore while accessing local_paca->reentrant_args here would be sufficient I think?