Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1146859imj; Thu, 14 Feb 2019 01:57:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IZgyzuS+IKPuPMVRe1HALj2wrhX6q6A6iqCyQJ17aOUDRwF4zNgqKRZOcO2ZWUoL+Gb5LB4 X-Received: by 2002:a17:902:9a04:: with SMTP id v4mr3303497plp.34.1550138254414; Thu, 14 Feb 2019 01:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550138254; cv=none; d=google.com; s=arc-20160816; b=Wn3MqelqZfvX79FE4G2afh5lkZfW2YrUWLDdu82hgESnuWBp4lgAfngpx9GrycmALm iBpfqIP3EY0YuG5LCcwADbuZULqRh4D7/1xN4oVn7zyMEkawJ+xBa/PtFYnKxHyciyNS bR/8EFVGRAcQN98lycP4ypOqCa4NX4lo/x3l7aKEFM0uocNMCQLVUtf7xE79hLzEoyW5 7kRRH+she7U7sqashm/Aw+HLI69V1Alzg70l/7GonOMwwfjWXmIx466NnuGTK3l5H5HP vYDvLZFO4ZlwZZGbLonUostt4jQf7aPjDwd3vdF5UWeM2su0L/6WeUO9XsDponT4xXUl 2hsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-filter:dkim-signature; bh=zhyW1qjEm7GKf1p0kEpQjvfSBMsodQlUnddUok6KFLA=; b=I5qMB+mFllL5ocZZBwZ+4W6jPqB5tgUFxbAawIZWMgv2AzrqGstOGHZ2cA/FfRWnCb G2loZgGhtZqZIc7jRxIb//Y2t2X4T/IsLqogEvvhCDtJOZ9j9yxNSQZIWPfX5XhJJvmZ xQ8SXVA8D3tgoFSg9dPkne9XJZxdXwj6fwdYog5TOWKWAx/vGjpolm3ij++8UfF+tQrb CAGCBuuH3lRHaZfd/oqjC4k5yxfOZc2534Mn8a0nN+oMMSZPHj1e7MS83X40d6C6E1Tg Xb8GE6t/+JS7HFsiS0dVbFGwQuT3DbT5TlWnxZ8XtWy22ou0lzXYWRJEgzv9XsayyN5o o/Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fjfi.cvut.cz header.s=20151024 header.b=Zjb6hNty; 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 k26si2022014pgb.72.2019.02.14.01.57.18; Thu, 14 Feb 2019 01:57:34 -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; dkim=pass header.i=@fjfi.cvut.cz header.s=20151024 header.b=Zjb6hNty; 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 S2404635AbfBNAQl (ORCPT + 99 others); Wed, 13 Feb 2019 19:16:41 -0500 Received: from mailgw1.fjfi.cvut.cz ([147.32.9.3]:47178 "EHLO mailgw1.fjfi.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727054AbfBNAQl (ORCPT ); Wed, 13 Feb 2019 19:16:41 -0500 Received: from localhost (localhost [127.0.0.1]) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTP id BAF2BAA230; Thu, 14 Feb 2019 01:16:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fjfi.cvut.cz; s=20151024; t=1550103397; i=@fjfi.cvut.cz; bh=zhyW1qjEm7GKf1p0kEpQjvfSBMsodQlUnddUok6KFLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Zjb6hNtyBR3v4NGGMxM+hMeCjPQxrKx2ZUKo2cJicVZ2x0bVaGuGd7SNuiJar8MkE G9iAR4E/9j+Gu85SeHWpzjBCp0DnTmiz8fE/b2QdrTggJGSd4+RjJ59m8gcyfzv3nW s2Za9kpABAWC3cmZIW/3WHvX5KG5734lzKLE5T4I= 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 vL2cAQ5wNTrP; Thu, 14 Feb 2019 01:16:33 +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 EEA59AA26F; Thu, 14 Feb 2019 01:16:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailgw1.fjfi.cvut.cz EEA59AA26F Received: by linux.fjfi.cvut.cz (Postfix, from userid 1001) id D092A6004E; Thu, 14 Feb 2019 01:16:32 +0100 (CET) From: David Kozub To: Jens Axboe , Jonathan Derrick , Scott Bauer , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonas Rabenstein , David Kozub Subject: [PATCH 01/16] block: sed-opal: fix IOC_OPAL_ENABLE_DISABLE_MBR Date: Thu, 14 Feb 2019 01:15:53 +0100 Message-Id: <1550103368-4605-2-git-send-email-zub@linux.fjfi.cvut.cz> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1550103368-4605-1-git-send-email-zub@linux.fjfi.cvut.cz> References: <1550103368-4605-1-git-send-email-zub@linux.fjfi.cvut.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The implementation of IOC_OPAL_ENABLE_DISABLE_MBR handled the value opal_mbr_data.enable_disable incorrectly: enable_disable is expected to be one of OPAL_MBR_ENABLE(0) or OPAL_MBR_DISABLE(1). enable_disable was passed directly to set_mbr_done and set_mbr_enable_disable where is was interpreted as either OPAL_TRUE(1) or OPAL_FALSE(0). The end result was that calling IOC_OPAL_ENABLE_DISABLE_MBR with OPAL_MBR_ENABLE actually disabled the shadow MBR and vice versa. This patch adds correct conversion from OPAL_MBR_DISABLE/ENABLE to OPAL_FALSE/TRUE. The change affects existing programs using IOC_OPAL_ENABLE_DISABLE_MBR but this is typically used only once when setting up an Opal drive. Signed-off-by: David Kozub Acked-by: Jon Derrick --- block/sed-opal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index e0de4dd448b3..119640897293 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -2095,13 +2095,16 @@ 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 enable_disable = 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, &enable_disable }, { end_opal_session, }, { start_admin1LSP_opal_session, &opal_mbr->key }, - { set_mbr_enable_disable, &opal_mbr->enable_disable }, + { set_mbr_enable_disable, &enable_disable }, { end_opal_session, }, { NULL, } }; @@ -2221,7 +2224,7 @@ static int __opal_lock_unlock(struct opal_dev *dev, static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key) { - u8 mbr_done_tf = 1; + u8 mbr_done_tf = OPAL_TRUE; const struct opal_step mbrdone_step [] = { { opal_discovery0, }, { start_admin1LSP_opal_session, key }, -- 2.20.1