Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1307387imu; Wed, 16 Jan 2019 16:53:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN6aBeKL7kwMzgiGbhlf1gpiHZZier2vDSXMmt8gs0n3nM9Ke2uxPXEU5HoiXIC+kWXZfBHJ X-Received: by 2002:a17:902:9691:: with SMTP id n17mr13155755plp.9.1547686417367; Wed, 16 Jan 2019 16:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547686417; cv=none; d=google.com; s=arc-20160816; b=toGoxdHhajUBrexnoNMAD7zCBrqVBg29NgfGXt63TDpzw6H6uhkmzJv3fTx89MXPel X4MbqOEhkSFZaV1inOQpczcUjeUjFVU1PDlzOiyLYA/OooPbNDrjjF6U4I/DRd9KAgQE PJD91/VnvwtFeGs6tAnc7zFIioZEerXzxLOtQNvBTEs3iFmO0gg5XJ36EVSHeZBJMRVh vT3LDiXUaPTrrvipJqg+fyPSy+1Yj/6EjttCehwmZwHv31KnRlirD79IkNWDmlhr7K1o 4P5Qd3CdiU5NRml3+zQQxdXqiWqjCy7531bqwyi4JKfMdaK5mUFMvvBrN2TYr5c15Pqc nRUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:cc:to:subject:date:from :dkim-filter; bh=R9pIjgyJA8Nmxv4zO/uJnHfaOoN0XUyyZd3t6O9wVrc=; b=JMTURof+G+jTNk7KyBF3x+ShWFOqcbtNu3CDV4DMLz05eYN/cbq369AXYF3GJDDJOL XaVMRw0p0I/6jL6RZlcSqt5ZmVxivZI41mhb1FCfq97sLbQIQZd2YaD2blDxb5q5adtp f72OUGiMfh8Y26Jq17Pm7pZeLiKMmpgv/al1ptIkiBmicmDIJ4KnUGpG1OY8z6n8Tc6n xp7UWh8lFRdzvpHy+qAebrI7WoyFMsWWg+I+8MjN0NanoP3M/3p69x9EBXUDYu/QlmNq U2wX8RB9Y8H66DJ4Pa4KqhKZHQIBLkBjLVK3pyV3fJcSA7fO2x2hIwt26B/HSk7lDTXW zWYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si6869540pls.367.2019.01.16.16.53.21; Wed, 16 Jan 2019 16:53:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729288AbfAPXD7 (ORCPT + 99 others); Wed, 16 Jan 2019 18:03:59 -0500 Received: from mailgw1.fjfi.cvut.cz ([147.32.9.3]:45650 "EHLO mailgw1.fjfi.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725648AbfAPXDy (ORCPT ); Wed, 16 Jan 2019 18:03:54 -0500 X-Greylist: delayed 496 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Jan 2019 18:03:53 EST Received: from localhost (localhost [127.0.0.1]) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTP id BD3E9B043C; Wed, 16 Jan 2019 23:55:51 +0100 (CET) X-CTU-FNSPE-Virus-Scanned: amavisd-new at fjfi.cvut.cz Received: from mailgw1.fjfi.cvut.cz ([127.0.0.1]) by localhost (mailgw1.fjfi.cvut.cz [127.0.0.1]) (amavisd-new, port 10022) with ESMTP id 6z5eUEOji-HB; Wed, 16 Jan 2019 23:55:47 +0100 (CET) Received: from linux.fjfi.cvut.cz (linux.fjfi.cvut.cz [147.32.5.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTPS id C043FB03DA; Wed, 16 Jan 2019 23:55:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailgw1.fjfi.cvut.cz C043FB03DA Received: by linux.fjfi.cvut.cz (Postfix, from userid 1001) id A3AE26004E; Wed, 16 Jan 2019 23:55:44 +0100 (CET) From: Jonas Rabenstein Date: Mon, 19 Mar 2018 19:36:49 +0100 Subject: [PATCH 10/16] block: sed-opal: add ioctl for done-mark of shadow mbr To: Jens Axboe , Scott Bauer , Jonathan Derrick , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonas Rabenstein Message-Id: <20190116225544.A3AE26004E@linux.fjfi.cvut.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable users to mark the shadow mbr as done without completely deactivating the shadow mbr feature. This may be useful on reboots, when the power to the disk is not disconnected in between and the shadow mbr stores the required boot files. Of course, this saves also the (few) commands required to enable the feature if it is already enabled and one only wants to mark the shadow mbr as done. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 33 +++++++++++++++++++++++++++++++-- include/linux/sed-opal.h | 1 + include/uapi/linux/sed-opal.h | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index db966bbc5a05..f85d9e53aab8 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -1996,13 +1996,39 @@ static int opal_erase_locking_range(struct opal_dev *dev, static int opal_enable_disable_shadow_mbr(struct opal_dev *dev, struct opal_mbr_data *opal_mbr) { + u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE + ? OPAL_TRUE : OPAL_FALSE; const struct opal_step mbr_steps[] = { { opal_discovery0, }, { start_admin1LSP_opal_session, &opal_mbr->key }, - { set_mbr_done, &opal_mbr->enable_disable }, + { set_mbr_done, &token }, { end_opal_session, }, { start_admin1LSP_opal_session, &opal_mbr->key }, - { set_mbr_enable_disable, &opal_mbr->enable_disable }, + { set_mbr_enable_disable, &token }, + { end_opal_session, }, + { NULL, } + }; + int ret; + + if (opal_mbr->enable_disable != OPAL_MBR_ENABLE && + opal_mbr->enable_disable != OPAL_MBR_DISABLE) + return -EINVAL; + + mutex_lock(&dev->dev_lock); + setup_opal_dev(dev, mbr_steps); + ret = next(dev); + mutex_unlock(&dev->dev_lock); + return ret; +} + +static int opal_mbr_status(struct opal_dev *dev, struct opal_mbr_data *opal_mbr) +{ + u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE + ? OPAL_TRUE : OPAL_FALSE; + const struct opal_step mbr_steps[] = { + { opal_discovery0, }, + { start_admin1LSP_opal_session, &opal_mbr->key }, + { set_mbr_done, &token }, { end_opal_session, }, { NULL, } }; @@ -2349,6 +2375,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg) case IOC_OPAL_ENABLE_DISABLE_MBR: ret = opal_enable_disable_shadow_mbr(dev, p); break; + case IOC_OPAL_MBR_STATUS: + ret = opal_mbr_status(dev, p); + break; case IOC_OPAL_ERASE_LR: ret = opal_erase_locking_range(dev, p); break; diff --git a/include/linux/sed-opal.h b/include/linux/sed-opal.h index 04b124fca51e..b38dc602cae3 100644 --- a/include/linux/sed-opal.h +++ b/include/linux/sed-opal.h @@ -47,6 +47,7 @@ static inline bool is_sed_ioctl(unsigned int cmd) case IOC_OPAL_ENABLE_DISABLE_MBR: case IOC_OPAL_ERASE_LR: case IOC_OPAL_SECURE_ERASE_LR: + case IOC_OPAL_MBR_STATUS: return true; } return false; diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h index 627624d35030..0cb9890cdc04 100644 --- a/include/uapi/linux/sed-opal.h +++ b/include/uapi/linux/sed-opal.h @@ -116,5 +116,6 @@ struct opal_mbr_data { #define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data) #define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info) #define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info) +#define IOC_OPAL_MBR_STATUS _IOW('p', 232, struct opal_mbr_data) #endif /* _UAPI_SED_OPAL_H */ -- 2.20.1