Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp432091ybk; Wed, 20 May 2020 03:22:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJpm5eg0KIXNQRkQPdOIaUHYt/75f9ydJdnaQUNxQpcWFOnGJsvZf3YEvlMVqhk6xVPdKX X-Received: by 2002:a17:906:355b:: with SMTP id s27mr3098133eja.492.1589970132510; Wed, 20 May 2020 03:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589970132; cv=none; d=google.com; s=arc-20160816; b=nYYP78BCiH5f9cCKxPEp+dLevTo1fIZ1MgxJUn1srrMld+tEFqJ+vZcYov27DwFhd1 33HPGkfxrzB3IqZMJk//pNxDZcLckCVtGWPcORdPFCVsR4FmeYkrU5f7HulZZ8OsyBcy 5VJpe4yLXUJ25DUcwInOSBaL5c0EdUSYJdHtZBLtHe0Bq6/17kA3ShSzM/m+5kmLXzLK RcR+8ieq+yqiYOBILJDHmK21og6O5xnphKkbvC+2Nrs+xlgTsGTtEL8RY8aYaSBFqCal i6jY68WOU7lw65Fg4QcR9CDhUFCZ/gYlVtsKSJ7xfFanBjmpU4JnfY+ctCbh/QfNOuGr q7cA== 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=VR9Ld0m2L4IV0wHelwR6Vrz5xIp7UpfprkIsj1DtVN4=; b=ea3x5qS5X9ufODeh4DNtXDSU4Hgvrn42R2BC5HJso9vZTFIC/ySk7LDgY7gJBSTBma zCBU8261Y/lwgEpA1kJqh5airY/q2PBsvB8Rfz7TloeHbwWUJjKog/nngj4WmjSRdTzT K2UQv79pSXQA9Rp83kAPH3QgMGJmqLhZjTNxQNtYoY+EIp4knNCWc0BSIfwJH1SenKl6 B1qzYyAdN5hA3fCY7PG5XULKPEG6B0Fm5+0mvkJ8KpCDwkfbWWyIriYhuf7F3jQUj10a 0wuufehWbnZzT1njq+2bBS60X/zlOmpbPHu0rswxEnPI/X0a5lXqAuzXWTBVLJuQ9HTc 3byA== 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 k4si1284237edi.24.2020.05.20.03.21.48; Wed, 20 May 2020 03:22:12 -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 S1726804AbgETKUW (ORCPT + 99 others); Wed, 20 May 2020 06:20:22 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48738 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbgETKUV (ORCPT ); Wed, 20 May 2020 06:20:21 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04KA2CrK001868; Wed, 20 May 2020 06:19:46 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 312cb1g4f6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2020 06:19:46 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 04KAGN8M024752; Wed, 20 May 2020 10:19:44 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 313xas3dr0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2020 10:19:43 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04KAJfKo54001720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2020 10:19:41 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA8A6A4055; Wed, 20 May 2020 10:19:41 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47229A404D; Wed, 20 May 2020 10:19:39 +0000 (GMT) Received: from vajain21-in-ibm-com (unknown [9.85.92.5]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Wed, 20 May 2020 10:19:39 +0000 (GMT) Received: by vajain21-in-ibm-com (sSMTP sendmail emulation); Wed, 20 May 2020 15:49:37 +0530 From: Vaibhav Jain To: "Aneesh Kumar K.V" , linuxppc-dev@lists.ozlabs.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Cc: Michael Ellerman , Steven Rostedt Subject: Re: [RESEND PATCH v7 4/5] ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific methods In-Reply-To: <87a723f5fs.fsf@linux.ibm.com> References: <20200519190058.257981-1-vaibhav@linux.ibm.com> <20200519190058.257981-5-vaibhav@linux.ibm.com> <87a723f5fs.fsf@linux.ibm.com> Date: Wed, 20 May 2020 15:49:37 +0530 Message-ID: <87y2pmx612.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-20_05:2020-05-19,2020-05-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=1 spamscore=0 impostorscore=0 malwarescore=0 adultscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005200083 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for reviewing this patch Aneesh. "Aneesh Kumar K.V" writes: > Vaibhav Jain writes: > > .... > > + >> +/* Papr-scm-header + payload expected with ND_CMD_CALL ioctl from libnvdimm */ >> +struct nd_pdsm_cmd_pkg { >> + struct nd_cmd_pkg hdr; /* Package header containing sub-cmd */ >> + __s32 cmd_status; /* Out: Sub-cmd status returned back */ >> + __u16 payload_offset; /* In: offset from start of struct */ >> + __u16 payload_version; /* In/Out: version of the payload */ >> + __u8 payload[]; /* In/Out: Sub-cmd data buffer */ >> +} __packed; > > that payload_offset can be avoided if we prevent userspace to user a > different variant of nd_pdsm_cmd_pkg which different header. We can keep > things simpler if we can always find payload at > nd_pdsm_cmd_pkg->payload. Had introduced this member to handle case where new fields are added to 'struct nd_pdsm_cmd_pkg' without having to break the ABI. But agree with the point that you made later that this can be simplified by replacing 'payload_offset' with a set of reserved variables. Will address this in next iteration of this patchset. > >> + >> +/* >> + * Methods to be embedded in ND_CMD_CALL request. These are sent to the kernel >> + * via 'nd_pdsm_cmd_pkg.hdr.nd_command' member of the ioctl struct >> + */ >> +enum papr_scm_pdsm { >> + PAPR_SCM_PDSM_MIN = 0x0, >> + PAPR_SCM_PDSM_MAX, >> +}; >> + >> +/* Convert a libnvdimm nd_cmd_pkg to pdsm specific pkg */ >> +static inline struct nd_pdsm_cmd_pkg *nd_to_pdsm_cmd_pkg(struct nd_cmd_pkg *cmd) >> +{ >> + return (struct nd_pdsm_cmd_pkg *) cmd; >> +} >> + >> +/* Return the payload pointer for a given pcmd */ >> +static inline void *pdsm_cmd_to_payload(struct nd_pdsm_cmd_pkg *pcmd) >> +{ >> + if (pcmd->hdr.nd_size_in == 0 && pcmd->hdr.nd_size_out == 0) >> + return NULL; >> + else >> + return (void *)((__u8 *) pcmd + pcmd->payload_offset); >> +} >> + > > we need to make sure userspace is not passing a wrong payload_offset. Agree, that this function should have more strict checking for payload_offset field. However will be getting rid of 'payload_offset' all together in the next iteration as you previously suggested. > and in the next patch you do > > + /* Copy the health struct to the payload */ > + memcpy(pdsm_cmd_to_payload(pkg), &p->health, copysize); > + pkg->hdr.nd_fw_size = copysize; > + Yes this is already being done in the patchset and changes proposed to this pdsm_cmd_to_payload() should not impact other patches as pdsm_cmd_to_payload() abstracts rest of the code from how to access the payload. > All this can be simplified if you can keep payload at > nd_pdsm_cmd_pkg->payload. > > If you still want to have the ability to extend the header, then added a > reserved field similar to nd_cmd_pkg. > Agree to this and will address this in V8. > > -aneesh -- Cheers ~ Vaibhav