]>
Commit | Line | Data |
---|---|---|
3d4ecfe4 SL |
1 | From bf1a997c22a88b2c3b794c8f085ee1abfe73f2ab Mon Sep 17 00:00:00 2001 |
2 | From: David Kozub <zub@linux.fjfi.cvut.cz> | |
3 | Date: Thu, 14 Feb 2019 01:15:53 +0100 | |
4 | Subject: block: sed-opal: fix IOC_OPAL_ENABLE_DISABLE_MBR | |
5 | ||
6 | [ Upstream commit 78bf47353b0041865564deeed257a54f047c2fdc ] | |
7 | ||
8 | The implementation of IOC_OPAL_ENABLE_DISABLE_MBR handled the value | |
9 | opal_mbr_data.enable_disable incorrectly: enable_disable is expected | |
10 | to be one of OPAL_MBR_ENABLE(0) or OPAL_MBR_DISABLE(1). enable_disable | |
11 | was passed directly to set_mbr_done and set_mbr_enable_disable where | |
12 | is was interpreted as either OPAL_TRUE(1) or OPAL_FALSE(0). The end | |
13 | result was that calling IOC_OPAL_ENABLE_DISABLE_MBR with OPAL_MBR_ENABLE | |
14 | actually disabled the shadow MBR and vice versa. | |
15 | ||
16 | This patch adds correct conversion from OPAL_MBR_DISABLE/ENABLE to | |
17 | OPAL_FALSE/TRUE. The change affects existing programs using | |
18 | IOC_OPAL_ENABLE_DISABLE_MBR but this is typically used only once when | |
19 | setting up an Opal drive. | |
20 | ||
21 | Acked-by: Jon Derrick <jonathan.derrick@intel.com> | |
22 | Reviewed-by: Christoph Hellwig <hch@lst.de> | |
23 | Reviewed-by: Scott Bauer <sbauer@plzdonthack.me> | |
24 | Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz> | |
25 | Signed-off-by: Jens Axboe <axboe@kernel.dk> | |
26 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
27 | --- | |
28 | block/sed-opal.c | 9 ++++++--- | |
29 | 1 file changed, 6 insertions(+), 3 deletions(-) | |
30 | ||
31 | diff --git a/block/sed-opal.c b/block/sed-opal.c | |
32 | index 4f5e70d4abc3c..c64011cda9fcc 100644 | |
33 | --- a/block/sed-opal.c | |
34 | +++ b/block/sed-opal.c | |
35 | @@ -2078,13 +2078,16 @@ static int opal_erase_locking_range(struct opal_dev *dev, | |
36 | static int opal_enable_disable_shadow_mbr(struct opal_dev *dev, | |
37 | struct opal_mbr_data *opal_mbr) | |
38 | { | |
39 | + u8 enable_disable = opal_mbr->enable_disable == OPAL_MBR_ENABLE ? | |
40 | + OPAL_TRUE : OPAL_FALSE; | |
41 | + | |
42 | const struct opal_step mbr_steps[] = { | |
43 | { opal_discovery0, }, | |
44 | { start_admin1LSP_opal_session, &opal_mbr->key }, | |
45 | - { set_mbr_done, &opal_mbr->enable_disable }, | |
46 | + { set_mbr_done, &enable_disable }, | |
47 | { end_opal_session, }, | |
48 | { start_admin1LSP_opal_session, &opal_mbr->key }, | |
49 | - { set_mbr_enable_disable, &opal_mbr->enable_disable }, | |
50 | + { set_mbr_enable_disable, &enable_disable }, | |
51 | { end_opal_session, }, | |
52 | { NULL, } | |
53 | }; | |
54 | @@ -2204,7 +2207,7 @@ static int __opal_lock_unlock(struct opal_dev *dev, | |
55 | ||
56 | static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key) | |
57 | { | |
58 | - u8 mbr_done_tf = 1; | |
59 | + u8 mbr_done_tf = OPAL_TRUE; | |
60 | const struct opal_step mbrdone_step [] = { | |
61 | { opal_discovery0, }, | |
62 | { start_admin1LSP_opal_session, key }, | |
63 | -- | |
64 | 2.20.1 | |
65 |