<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/dev/mpr, branch releng/13.4</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>mpr: Handle errors from copyout() in ioctl handlers</title>
<updated>2024-01-02T01:12:45+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2023-12-26T01:42:49+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=4392ef59412d7954c09283208781f5dbf4cabd24'/>
<id>4392ef59412d7954c09283208781f5dbf4cabd24</id>
<content type='text'>
In preparation for adding a __result_use_check annotation to copyin()
and related functions, start checking for errors from copyout() in
the mpr(4) user command handler.  This should make it easier to catch
bugs.

Reviewed by:	imp, asomers
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D43177

(cherry picked from commit 68cc77a3b73ffda1e8ac891b9852faca833e11b7)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In preparation for adding a __result_use_check annotation to copyin()
and related functions, start checking for errors from copyout() in
the mpr(4) user command handler.  This should make it easier to catch
bugs.

Reviewed by:	imp, asomers
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D43177

(cherry picked from commit 68cc77a3b73ffda1e8ac891b9852faca833e11b7)
</pre>
</div>
</content>
</entry>
<entry>
<title>mpr, mps:  Establish busdma boundaries for memory pools</title>
<updated>2023-12-20T15:43:21+00:00</updated>
<author>
<name>Kenneth D. Merry</name>
<email>ken@FreeBSD.org</email>
</author>
<published>2023-12-14T20:05:17+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=5ffcdc96ac71a54e33b86a13fe5b53ebf303f3af'/>
<id>5ffcdc96ac71a54e33b86a13fe5b53ebf303f3af</id>
<content type='text'>
Most all of the memory used by the cards in the mpr(4) and mps(4)
drivers is required, according to the specs and Broadcom developers,
to be within a 4GB segment of memory.

This includes:

System Request Message Frames pool
Reply Free Queues pool
ReplyDescriptorPost Queues pool
Chain Segments pool
Sense Buffers pool
SystemReply message pool

We got a bug report from Dwight Engen, who ran into data corruption
in the BAE port of FreeBSD:

&gt; We have a port of the FreeBSD mpr driver to our kernel and recently
&gt; I found an issue under heavy load where a DMA may go to the wrong
&gt; address. The test system is a Supermicro X10SRH-CLN4F with the
&gt; onboard SAS3008 controller setup with 2 enterprise Micron SSDs in
&gt; RAID 0 (striped). I have debugged the issue and narrowed down that
&gt; the errant DMA is one that has a segment that crosses a 4GB
&gt; physical boundary.  There are more details I can provide if you'd
&gt; like, but with the attached patch in place I can no longer
&gt; re-create the issue.

&gt; I'm not sure if this is a known limit of the card (have not found a
&gt; datasheet/programming docs for the chip) or our system is just
&gt; doing something a bit different. Any helpful info or insight would
&gt; be welcome.

&gt; Anyway, just thought this might be helpful info if you want to
&gt; apply a similar fix to FreeBSD. You can ignore/discard the commit
&gt; message as it is my internal commit (blkio is our own tool we use
&gt; to write/read every block of a device with CRC verification which
&gt; is how I found the problem).

The commit message was:

&gt; [PATCH 8/9] mpr: fix memory corrupting DMA when sg segment crosses
&gt; 4GB boundary

&gt; Test case was two SSD's in RAID 0 (stripe). The logical disk was
&gt; then partitioned into two partitions. One partition had lots of
&gt; filesystem I/O and the other was initially filled using blkio with
&gt; CRCable data and then read back with blkio CRC verify in a loop.
&gt; Eventually blkio would report a bad CRC block because the physical
&gt; page being read-ahead into didn't contain the right data. If the
&gt; physical address in the arq/segs was for example 0x500003000 the
&gt; data would actually be DMAed to 0x400003000.

The original patch was against mpr(4) before busdma templates were
introduced, and only affected the buffer pool (sc-&gt;buffer_dmat) in
the mpr(4) driver. After some discussion with Dwight and the
LSI/Broadcom developers and looking through the driver, it looks
like most of the queues in the driver are ok, because they limit
the memory used to memory below 4GB. The buffer queue and the chain
frames seem to be the exceptions.

This is pretty much the same between the mpr(4) and mps(4) drivers.

So, apply a 4GB boundary limitation for the buffer and chain frame pools
in the mpr(4) and mps(4) drivers.

Reported by:	Dwight Engen &lt;dwight.engen@gmail.com&gt;
Reviewed by:	imp
Obtained from:	Dwight Engen &lt;dwight.engen@gmail.com&gt;
Differential Revision:	&lt;https://reviews.freebsd.org/D43008&gt;

(cherry picked from commit 264610a86e14f8e123d94c3c3bd9632d75c078a3)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Most all of the memory used by the cards in the mpr(4) and mps(4)
drivers is required, according to the specs and Broadcom developers,
to be within a 4GB segment of memory.

This includes:

System Request Message Frames pool
Reply Free Queues pool
ReplyDescriptorPost Queues pool
Chain Segments pool
Sense Buffers pool
SystemReply message pool

We got a bug report from Dwight Engen, who ran into data corruption
in the BAE port of FreeBSD:

&gt; We have a port of the FreeBSD mpr driver to our kernel and recently
&gt; I found an issue under heavy load where a DMA may go to the wrong
&gt; address. The test system is a Supermicro X10SRH-CLN4F with the
&gt; onboard SAS3008 controller setup with 2 enterprise Micron SSDs in
&gt; RAID 0 (striped). I have debugged the issue and narrowed down that
&gt; the errant DMA is one that has a segment that crosses a 4GB
&gt; physical boundary.  There are more details I can provide if you'd
&gt; like, but with the attached patch in place I can no longer
&gt; re-create the issue.

&gt; I'm not sure if this is a known limit of the card (have not found a
&gt; datasheet/programming docs for the chip) or our system is just
&gt; doing something a bit different. Any helpful info or insight would
&gt; be welcome.

&gt; Anyway, just thought this might be helpful info if you want to
&gt; apply a similar fix to FreeBSD. You can ignore/discard the commit
&gt; message as it is my internal commit (blkio is our own tool we use
&gt; to write/read every block of a device with CRC verification which
&gt; is how I found the problem).

The commit message was:

&gt; [PATCH 8/9] mpr: fix memory corrupting DMA when sg segment crosses
&gt; 4GB boundary

&gt; Test case was two SSD's in RAID 0 (stripe). The logical disk was
&gt; then partitioned into two partitions. One partition had lots of
&gt; filesystem I/O and the other was initially filled using blkio with
&gt; CRCable data and then read back with blkio CRC verify in a loop.
&gt; Eventually blkio would report a bad CRC block because the physical
&gt; page being read-ahead into didn't contain the right data. If the
&gt; physical address in the arq/segs was for example 0x500003000 the
&gt; data would actually be DMAed to 0x400003000.

The original patch was against mpr(4) before busdma templates were
introduced, and only affected the buffer pool (sc-&gt;buffer_dmat) in
the mpr(4) driver. After some discussion with Dwight and the
LSI/Broadcom developers and looking through the driver, it looks
like most of the queues in the driver are ok, because they limit
the memory used to memory below 4GB. The buffer queue and the chain
frames seem to be the exceptions.

This is pretty much the same between the mpr(4) and mps(4) drivers.

So, apply a 4GB boundary limitation for the buffer and chain frame pools
in the mpr(4) and mps(4) drivers.

Reported by:	Dwight Engen &lt;dwight.engen@gmail.com&gt;
Reviewed by:	imp
Obtained from:	Dwight Engen &lt;dwight.engen@gmail.com&gt;
Differential Revision:	&lt;https://reviews.freebsd.org/D43008&gt;

(cherry picked from commit 264610a86e14f8e123d94c3c3bd9632d75c078a3)
</pre>
</div>
</content>
</entry>
<entry>
<title>mprutil: "fix user reply buffer (64)..." warnings</title>
<updated>2023-10-05T17:35:27+00:00</updated>
<author>
<name>Alan Somers</name>
<email>asomers@FreeBSD.org</email>
</author>
<published>2023-02-22T22:06:43+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=51426ad9c75b21424a05208a0c3d122beb08ddd7'/>
<id>51426ad9c75b21424a05208a0c3d122beb08ddd7</id>
<content type='text'>
Depending on the card's firmware version, it may return different length
responses for MPI2_FUNCTION_IOC_FACTS.  But the first part of the
response contains the length of the rest, so query it first to get the
length and then use that to size the buffer for the full response.

Also, correctly zero-initialize MPI2_IOC_FACTS_REQUEST.  It only worked
by luck before.

PR:		264848
Reported by:	Julien Cigar &lt;julien@perdition.city&gt;
Sponsored by:	Axcient
Reviewed by:	scottl, imp
Differential Revision: https://reviews.freebsd.org/D38739

(cherry picked from commit 7d154c4dc64e61af7ca536c4e9927fa07c675a83)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Depending on the card's firmware version, it may return different length
responses for MPI2_FUNCTION_IOC_FACTS.  But the first part of the
response contains the length of the rest, so query it first to get the
length and then use that to size the buffer for the full response.

Also, correctly zero-initialize MPI2_IOC_FACTS_REQUEST.  It only worked
by luck before.

PR:		264848
Reported by:	Julien Cigar &lt;julien@perdition.city&gt;
Sponsored by:	Axcient
Reviewed by:	scottl, imp
Differential Revision: https://reviews.freebsd.org/D38739

(cherry picked from commit 7d154c4dc64e61af7ca536c4e9927fa07c675a83)
</pre>
</div>
</content>
</entry>
<entry>
<title>sys: Remove $FreeBSD$: one-line .c pattern</title>
<updated>2023-08-23T17:43:25+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-22T01:31:27+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=3bc80996974a61a4223eae4c1ccd47b6ee32a48a'/>
<id>3bc80996974a61a4223eae4c1ccd47b6ee32a48a</id>
<content type='text'>
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in current:
(cherry picked from commit 685dc743dc3b)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in current:
(cherry picked from commit 685dc743dc3b)
</pre>
</div>
</content>
</entry>
<entry>
<title>sys: Remove $FreeBSD$: two-line .h pattern</title>
<updated>2023-08-23T17:43:20+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-22T01:31:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=f8167e0404dab9ffeaca95853dd237ab7c587f82'/>
<id>f8167e0404dab9ffeaca95853dd237ab7c587f82</id>
<content type='text'>
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

Similar commit in current:
(cherry picked from commit 95ee2897e98f)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

Similar commit in current:
(cherry picked from commit 95ee2897e98f)
</pre>
</div>
</content>
</entry>
<entry>
<title>mpr: don't use hardcoded value in debug branch</title>
<updated>2023-05-02T12:21:48+00:00</updated>
<author>
<name>Mariusz Zaborski</name>
<email>oshogbo@FreeBSD.org</email>
</author>
<published>2023-04-21T07:57:38+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=834fdebb56fbf9ae111f5da91683fea5ddcebe08'/>
<id>834fdebb56fbf9ae111f5da91683fea5ddcebe08</id>
<content type='text'>
Pointed out by:	imp
Sponsored by:   Klara Inc.

(cherry picked from commit 444c6615459efe2b015deb1cffc54fcaa3ea1fca)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pointed out by:	imp
Sponsored by:   Klara Inc.

(cherry picked from commit 444c6615459efe2b015deb1cffc54fcaa3ea1fca)
</pre>
</div>
</content>
</entry>
<entry>
<title>mpr: fix copying of event_mask</title>
<updated>2023-05-02T12:21:35+00:00</updated>
<author>
<name>Mariusz Zaborski</name>
<email>oshogbo@FreeBSD.org</email>
</author>
<published>2023-04-21T07:50:16+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=e7a3a08febd01c95b74185bb971ec29cca64b8e1'/>
<id>e7a3a08febd01c95b74185bb971ec29cca64b8e1</id>
<content type='text'>
Before the commit 6cc44223cb6717795afdac4348bbe7e2a968a07d the
field event_mask was fully copied to the EventMasks field.
After this commit the event_mask (uint8_t) is 4 times casted to
EventMask (uint32_t). Because of that 24 bits of each event_mask array
is lost.

This commits brings back simple copying of field, and after words
converting 32 bits field to the requested endian.

I don't think we need more sophisticated method,
as the array is of size 4 (for 32 bits version).

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D39562

(cherry picked from commit ea6597c38c77c7bfaae71259d8636cbb89add6a3)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before the commit 6cc44223cb6717795afdac4348bbe7e2a968a07d the
field event_mask was fully copied to the EventMasks field.
After this commit the event_mask (uint8_t) is 4 times casted to
EventMask (uint32_t). Because of that 24 bits of each event_mask array
is lost.

This commits brings back simple copying of field, and after words
converting 32 bits field to the requested endian.

I don't think we need more sophisticated method,
as the array is of size 4 (for 32 bits version).

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D39562

(cherry picked from commit ea6597c38c77c7bfaae71259d8636cbb89add6a3)
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix kernel memory disclosures in mpr and mps</title>
<updated>2023-03-22T16:52:42+00:00</updated>
<author>
<name>Alan Somers</name>
<email>asomers@FreeBSD.org</email>
</author>
<published>2023-03-01T18:53:46+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=1a798187e5546c817a3bab845d73520d4a88a185'/>
<id>1a798187e5546c817a3bab845d73520d4a88a185</id>
<content type='text'>
In every mpr and mps ioctl that copies kernel data to userland, validate
that the requested length does not exceed the size of the kernel's
buffer.

Note that all of these ioctls already required root access.

Sponsored by:	Axcient
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D38842

(cherry picked from commit 72aad3f9028af12e6c56a3a461b46a153abd7b24)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In every mpr and mps ioctl that copies kernel data to userland, validate
that the requested length does not exceed the size of the kernel's
buffer.

Note that all of these ioctls already required root access.

Sponsored by:	Axcient
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D38842

(cherry picked from commit 72aad3f9028af12e6c56a3a461b46a153abd7b24)
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix mpr(4) panic during a firmware update.</title>
<updated>2022-10-20T15:01:03+00:00</updated>
<author>
<name>Kenneth D. Merry</name>
<email>ken@FreeBSD.org</email>
</author>
<published>2022-10-17T16:48:34+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=2edc70060d1e0f75eb975b4318345343600852d8'/>
<id>2edc70060d1e0f75eb975b4318345343600852d8</id>
<content type='text'>
Issue Description:
The RequestCredits field of IOCFacts got changed between the Phase23
firmware to Phase24 firmware. So as part of firmware update operation,
driver has to free the resources &amp; pools which are created with the Phase23
Firmware's IOCFacts data (i.e. during driver load time) and has to
reallocate the resources and pools using Phase24's IOCFacts data. Here
driver has freed the interrupts but missed to reallocate the interrupts and
hence config page read operation is getting timed out and controller is
going for recursive reinit (controller reset) operations and leading to
kernel panic.

Fix:
Reallocate the interrupts if the interrupts are disabled as part of
firmware update/downgrade operation.

Submitted by:	Sreekanth Ready &lt;sreekanth.reddy@broadcom.com&gt;
Tested by:	ken
MFC after:	3 days

(cherry picked from commit 11778fca4a83f5e3b597c75785aa5c0ee0dc518e)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Issue Description:
The RequestCredits field of IOCFacts got changed between the Phase23
firmware to Phase24 firmware. So as part of firmware update operation,
driver has to free the resources &amp; pools which are created with the Phase23
Firmware's IOCFacts data (i.e. during driver load time) and has to
reallocate the resources and pools using Phase24's IOCFacts data. Here
driver has freed the interrupts but missed to reallocate the interrupts and
hence config page read operation is getting timed out and controller is
going for recursive reinit (controller reset) operations and leading to
kernel panic.

Fix:
Reallocate the interrupts if the interrupts are disabled as part of
firmware update/downgrade operation.

Submitted by:	Sreekanth Ready &lt;sreekanth.reddy@broadcom.com&gt;
Tested by:	ken
MFC after:	3 days

(cherry picked from commit 11778fca4a83f5e3b597c75785aa5c0ee0dc518e)
</pre>
</div>
</content>
</entry>
<entry>
<title>mpr(4): Remove a double word in a source code comment</title>
<updated>2022-09-07T07:31:30+00:00</updated>
<author>
<name>Gordon Bergling</name>
<email>gbe@FreeBSD.org</email>
</author>
<published>2022-09-04T11:46:44+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=100fede3d3304a8d00c187e909cebabda4f7f2f1'/>
<id>100fede3d3304a8d00c187e909cebabda4f7f2f1</id>
<content type='text'>
- s/the the/the/

(cherry picked from commit 2f9de90b22a6478752534eb5b772d2c1d134b309)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- s/the the/the/

(cherry picked from commit 2f9de90b22a6478752534eb5b772d2c1d134b309)
</pre>
</div>
</content>
</entry>
</feed>
