<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/block/sed-opal.c, branch v4.14.331</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>block: sed-opal: kmalloc the cmd/resp buffers</title>
<updated>2022-11-25T16:36:49+00:00</updated>
<author>
<name>Serge Semin</name>
<email>Sergey.Semin@baikalelectronics.ru</email>
</author>
<published>2022-11-07T20:39:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=53699e24bd6811d200489149d3ead6a7f90f9217'/>
<id>53699e24bd6811d200489149d3ead6a7f90f9217</id>
<content type='text'>
[ Upstream commit f829230dd51974c1f4478900ed30bb77ba530b40 ]

In accordance with [1] the DMA-able memory buffers must be
cacheline-aligned otherwise the cache writing-back and invalidation
performed during the mapping may cause the adjacent data being lost. It's
specifically required for the DMA-noncoherent platforms [2]. Seeing the
opal_dev.{cmd,resp} buffers are implicitly used for DMAs in the NVME and
SCSI/SD drivers in framework of the nvme_sec_submit() and sd_sec_submit()
methods respectively they must be cacheline-aligned to prevent the denoted
problem. One of the option to guarantee that is to kmalloc the buffers
[2]. Let's explicitly allocate them then instead of embedding into the
opal_dev structure instance.

Note this fix was inspired by the commit c94b7f9bab22 ("nvme-hwmon:
kmalloc the NVME SMART log buffer").

[1] Documentation/core-api/dma-api.rst
[2] Documentation/core-api/dma-api-howto.rst

Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
Signed-off-by: Serge Semin &lt;Sergey.Semin@baikalelectronics.ru&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Link: https://lore.kernel.org/r/20221107203944.31686-1-Sergey.Semin@baikalelectronics.ru
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit f829230dd51974c1f4478900ed30bb77ba530b40 ]

In accordance with [1] the DMA-able memory buffers must be
cacheline-aligned otherwise the cache writing-back and invalidation
performed during the mapping may cause the adjacent data being lost. It's
specifically required for the DMA-noncoherent platforms [2]. Seeing the
opal_dev.{cmd,resp} buffers are implicitly used for DMAs in the NVME and
SCSI/SD drivers in framework of the nvme_sec_submit() and sd_sec_submit()
methods respectively they must be cacheline-aligned to prevent the denoted
problem. One of the option to guarantee that is to kmalloc the buffers
[2]. Let's explicitly allocate them then instead of embedding into the
opal_dev structure instance.

Note this fix was inspired by the commit c94b7f9bab22 ("nvme-hwmon:
kmalloc the NVME SMART log buffer").

[1] Documentation/core-api/dma-api.rst
[2] Documentation/core-api/dma-api-howto.rst

Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
Signed-off-by: Serge Semin &lt;Sergey.Semin@baikalelectronics.ru&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Link: https://lore.kernel.org/r/20221107203944.31686-1-Sergey.Semin@baikalelectronics.ru
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block: sed-opal: fix IOC_OPAL_ENABLE_DISABLE_MBR</title>
<updated>2019-05-31T13:47:29+00:00</updated>
<author>
<name>David Kozub</name>
<email>zub@linux.fjfi.cvut.cz</email>
</author>
<published>2019-02-14T00:15:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=4654327bee80808636592c27a0ddca3a1ec0934b'/>
<id>4654327bee80808636592c27a0ddca3a1ec0934b</id>
<content type='text'>
[ Upstream commit 78bf47353b0041865564deeed257a54f047c2fdc ]

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.

Acked-by: Jon Derrick &lt;jonathan.derrick@intel.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Scott Bauer &lt;sbauer@plzdonthack.me&gt;
Signed-off-by: David Kozub &lt;zub@linux.fjfi.cvut.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 78bf47353b0041865564deeed257a54f047c2fdc ]

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.

Acked-by: Jon Derrick &lt;jonathan.derrick@intel.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Scott Bauer &lt;sbauer@plzdonthack.me&gt;
Signed-off-by: David Kozub &lt;zub@linux.fjfi.cvut.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block: sed-opal: Fix a couple off by one bugs</title>
<updated>2018-08-24T11:09:03+00:00</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2018-06-20T10:41:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=6d2b87505f7a59b464a59e1d0870aa26d0b1f0e1'/>
<id>6d2b87505f7a59b464a59e1d0870aa26d0b1f0e1</id>
<content type='text'>
[ Upstream commit ce042c183bcb94eb2919e8036473a1fc203420f9 ]

resp-&gt;num is the number of tokens in resp-&gt;tok[].  It gets set in
response_parse().  So if n == resp-&gt;num then we're reading beyond the
end of the data.

Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
Reviewed-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Tested-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit ce042c183bcb94eb2919e8036473a1fc203420f9 ]

resp-&gt;num is the number of tokens in resp-&gt;tok[].  It gets set in
response_parse().  So if n == resp-&gt;num then we're reading beyond the
end of the data.

Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
Reviewed-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Tested-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block: sed-opal: Set MBRDone on S3 resume path if TPER is MBREnabled</title>
<updated>2017-09-11T15:45:52+00:00</updated>
<author>
<name>Scott Bauer</name>
<email>scott.bauer@intel.com</email>
</author>
<published>2017-09-01T14:53:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=dbec491b12b52888d120e5be8f15886b3216eb19'/>
<id>dbec491b12b52888d120e5be8f15886b3216eb19</id>
<content type='text'>
Users who are booting off their Opal enabled drives are having
issues when they have a shadow MBR set up after s3/resume cycle.
When the Drive has a shadow MBR setup the MBRDone flag is set to
false upon power loss (S3/S4/S5). When the MBRDone flag is false
I/O to LBA 0 -&gt; LBA_END_MBR are remapped to the shadow mbr
of the drive. If the drive contains useful data in the 0 -&gt; end_mbr
range upon s3 resume the user can never get to that data as the
drive will keep remapping it to the MBR. To fix this when we unlock
on S3 resume, we need to tell the drive that we're done with the
shadow mbr (even though we didnt use it) by setting true to MBRDone.
This way the drive will stop the remapping and the user can access
their data.

Acked-by Jon Derrick: &lt;jonathan.derrick@intel.com&gt;
Signed-off-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Users who are booting off their Opal enabled drives are having
issues when they have a shadow MBR set up after s3/resume cycle.
When the Drive has a shadow MBR setup the MBRDone flag is set to
false upon power loss (S3/S4/S5). When the MBRDone flag is false
I/O to LBA 0 -&gt; LBA_END_MBR are remapped to the shadow mbr
of the drive. If the drive contains useful data in the 0 -&gt; end_mbr
range upon s3 resume the user can never get to that data as the
drive will keep remapping it to the MBR. To fix this when we unlock
on S3 resume, we need to tell the drive that we're done with the
shadow mbr (even though we didnt use it) by setting true to MBRDone.
This way the drive will stop the remapping and the user can access
their data.

Acked-by Jon Derrick: &lt;jonathan.derrick@intel.com&gt;
Signed-off-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block: sed-opal: Tone down all the pr_* to debugs</title>
<updated>2017-04-07T20:24:16+00:00</updated>
<author>
<name>Scott Bauer</name>
<email>scott.bauer@intel.com</email>
</author>
<published>2017-04-07T19:58:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=591c59d18f72c98ad7a992809c3a9a1789687845'/>
<id>591c59d18f72c98ad7a992809c3a9a1789687845</id>
<content type='text'>
Lets not flood the kernel log with messages unless
the user requests so.

Signed-off-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Lets not flood the kernel log with messages unless
the user requests so.

Signed-off-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block/sed-opal: fix spelling mistake: "Lifcycle" -&gt; "Lifecycle"</title>
<updated>2017-03-30T15:22:53+00:00</updated>
<author>
<name>Colin Ian King</name>
<email>colin.king@canonical.com</email>
</author>
<published>2017-03-30T09:58:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=47d752076a92c67f548faa018efd7d4ac51f17f7'/>
<id>47d752076a92c67f548faa018efd7d4ac51f17f7</id>
<content type='text'>
trivial fix to spelling mistake in pr_err error message

Signed-off-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
trivial fix to spelling mistake in pr_err error message

Signed-off-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block/sed: Fix opal user range check and unused variables</title>
<updated>2017-03-08T16:56:12+00:00</updated>
<author>
<name>Jon Derrick</name>
<email>jonathan.derrick@intel.com</email>
</author>
<published>2017-03-06T15:41:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=b0bfdfc2bf7fa85317824c6a389fc373dfcef5bc'/>
<id>b0bfdfc2bf7fa85317824c6a389fc373dfcef5bc</id>
<content type='text'>
Fixes check that the opal user is within the range, and cleans up unused
method variables.

Signed-off-by: Jon Derrick &lt;jonathan.derrick@intel.com&gt;
Reviewed-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes check that the opal user is within the range, and cleans up unused
method variables.

Signed-off-by: Jon Derrick &lt;jonathan.derrick@intel.com&gt;
Reviewed-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block/sed-opal: Propagate original error message to userland.</title>
<updated>2017-02-23T18:55:44+00:00</updated>
<author>
<name>Scott Bauer</name>
<email>scott.bauer@intel.com</email>
</author>
<published>2017-02-22T17:15:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=2d19020b085eaf61d24377db27e8630cd9cff7ce'/>
<id>2d19020b085eaf61d24377db27e8630cd9cff7ce</id>
<content type='text'>
During an error on a comannd, ex: user provides wrong pw to unlock
range, we will gracefully terminate the opal session. We want to
propagate the original error to userland instead of the result of
the session termination, which is almost always a success.

Signed-off-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
During an error on a comannd, ex: user provides wrong pw to unlock
range, we will gracefully terminate the opal session. We want to
propagate the original error to userland instead of the result of
the session termination, which is almost always a success.

Signed-off-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block/sed-opal: Introduce free_opal_dev to free the structure and clean up state</title>
<updated>2017-02-23T18:55:41+00:00</updated>
<author>
<name>Scott Bauer</name>
<email>scott.bauer@intel.com</email>
</author>
<published>2017-02-22T17:15:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=7d6d15789d69856f1c5405e106a773c87277eb8c'/>
<id>7d6d15789d69856f1c5405e106a773c87277eb8c</id>
<content type='text'>
Before we free the opal structure we need to clean up any saved
locking ranges that the user had told us to unlock from a suspend.

Signed-off-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before we free the opal structure we need to clean up any saved
locking ranges that the user had told us to unlock from a suspend.

Signed-off-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>block/sed: Embed function data into the function sequence</title>
<updated>2017-02-22T18:54:49+00:00</updated>
<author>
<name>Jon Derrick</name>
<email>jonathan.derrick@intel.com</email>
</author>
<published>2017-02-22T14:55:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=eed64951f15d63beac75e0f848ac03c14f8a4a6c'/>
<id>eed64951f15d63beac75e0f848ac03c14f8a4a6c</id>
<content type='text'>
By embedding the function data with the function sequence, we can
eliminate the external function data and state variable code. It also
made obvious some other small cleanups.

Signed-off-by: Jon Derrick &lt;jonathan.derrick@intel.com&gt;
Reviewed-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
By embedding the function data with the function sequence, we can
eliminate the external function data and state variable code. It also
made obvious some other small cleanups.

Signed-off-by: Jon Derrick &lt;jonathan.derrick@intel.com&gt;
Reviewed-by: Scott Bauer &lt;scott.bauer@intel.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
