aboutsummaryrefslogtreecommitdiff
path: root/libflash
AgeCommit message (Collapse)AuthorFilesLines
2019-10-23blocklevel: smart_write: Fix unaligned writes to ECC partitionsAndrew Jeffery1-7/+26
[ Upstream commit 96ddf4b5d3e18ed9fbf726d0dabebe1ec2424fac ] Currently trying to clear a gard record results in errors: $ ./opal-gard -pef part create /sys0/node0/proc1 $ ./opal-gard -pef part list ID | Error | Type | Path --------------------------------------------------------- 00000001 | 00000000 | Manual | /Sys0/Node0/Proc1 ========================================================= $ ./opal-gard -pef part clear 00000001 Clearing gard record 0x00000001...done ECC: uncorrectable error: ffffff00ffffffff ff libflash ecc invalid $ A little wrapper around hexdump(1) helps show where the error lies by grouping output in blocks of nine such that the last byte is the ECC byte: $ declare -f ecchd ecchd () { hexdump -e '"%08_ax""\t"' -e '9/1 "%02x ""\t""|"' -e '9/1 "%_p""|\n"' "$@" } A clean GARD partition displays as: $ ecchd part 0002c000 ff ff ff ff ff ff ff ff 00 |.........| * 00030ffb ff ff ff ff ff |.....| $ Dumping the corrupt partition shows: $ ecchd part 0002c000 ff ff ff ff ff ff ff ff 00 |.........| * 0002c024 ff ff ff ff ff ff ff ff ff |.........| 0002c02d ff ff ff 00 ff ff ff ff ff |.........| * 0002c051 ff ff ff 00 ff ff ff ff 00 |.........| 0002c05a ff ff ff ff ff ff ff ff 00 |.........| * 00030ffb ff ff ff ff ff |.....| $ blocklevel_smart_write() turned out to not be quite as smart as it thought it was in that any unaligned write to ECC protected partitions aligned the calculated ECC values to the start of the write buffer and not relative to the start of the partition. Fixes: 29d1e6f78109 ("libflash/blocklevel: add a smart write function which wraps up eraseing and writing") Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2019-10-23blocklevel: smart_write: Tidy local variable declarationsAndrew Jeffery1-4/+7
[ Upstream commit a950fd789c1ce0fbdc4f5486ccdd8301d6258ba7 ] Group them by use (and name). It's not reverse christmas tree, but it's a bit easier on the eye. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2019-10-23blocklevel: smart_write: Avoid reuse of formal parametersAndrew Jeffery1-6/+13
[ Upstream commit aa52f9439b91db5949c04acb8e1d2d21c37ddba5 ] Lays the ground-work for fixing unaligned writes to ECC protected partitions. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2019-10-23blocklevel: smart_write: Deny writes intersecting ECC protected regionsAndrew Jeffery1-1/+9
[ Upstream commit bdbbfcacccdb768db587ef73a2a28cf3dc8ceda9 ] Other code paths don't handle writes spanning mixed regions, and it's a headache, so deny it here too. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2019-10-23blocklevel: smart_write: Avoid indirectly testing formal parametersAndrew Jeffery1-1/+1
[ Upstream commit 6867bd54c21b023b74e924abd6f4c3f1cd9959c2 ] The early-exit tests write_buf, but write_buf is assigned to buf on declaration. Test buf directly instead to avoid unnecessary indirection. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2019-10-23blocklevel: smart_write: Rename size variable for clarityAndrew Jeffery1-8/+9
[ Upstream commit 518db2b216af5178a18f8b7ad06769b6acc51bcc ] We're writing in chunks, so lets make it clear that size is relative to the chunk that we're writing. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2019-10-23blocklevel: smart_write: Rename write bufferAndrew Jeffery1-7/+7
[ Upstream commit 5c935e78f335597f502e1fda1911ca50bbeed561 ] The buffer is only used for ECC protected partitions, so lets call it ecc_buf for clarity. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2019-10-23blocklevel: smart_write: Terminate line for debug output in no-change caseAndrew Jeffery1-0/+2
[ Upstream commit 8f204c12ebc07111c99d2059e1df0b86d7a203ae ] Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2019-08-15HIOMAP: Reset bmc mbox in MPIPL pathVasant Hegde7-4/+232
During boot SBE and early hostboot does not use HIOMAP protocol to get image from PNOR. Instead it expects PNOR TOC and Hostboot Boot Loader to be available at particular address in LPC bus. mbox daemon in BMC side takes care of this during normal boot. Once boot is complete mbox daemon switches to normal mode. During normal reboot, BMC side mbox daemon gets notification and takes care of loading PNOR TOC and HBBL to LPC bus again. In MPIPL path, OPAL calls SBE S0 interrupt to initiate MPIPL. BMC will not be aware of this. But SBE expects PNOR TOC and HBBL to be available in LPC bus at predefined address. Hence call HIOMAP Reset from OPAL in assert path. This needs working LPC and IPMI driver in OPAL. If we have issue in these drivers then we may not be able to reset BMC MBOX properly. Hence MPIPL may fail. We have to live with this until we find a way to intiate BMC on MPIPL. CC: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> [oliver: rebased] Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
2019-07-26SPDX-ify all skiboot codeStewart Smith26-363/+74
Use Software Package Data Exchange (SPDX) to indicate license for each file that is unique to skiboot. At the same time, ensure the (C) who and years are correct. See https://spdx.org/ Signed-off-by: Stewart Smith <stewart@linux.ibm.com> [oliver: Added a few missing files] Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
2019-07-16libflash: Fix broken continuationsOliver O'Halloran1-5/+5
Some of the libflash debug messages don't print a newlines at the end of the line and assume that the next print will be contigious with the last. This isn't true in skiboot since log messages are prefixed with a timestamp. This results in funny looking output such as: LIBFLASH: Verifying... LIBFLASH: reading page 0x01963000..0x01964000...[3.084846885,7] same ! LIBFLASH: reading page 0x01964000..0x01965000...[3.086164489,7] same ! Fix this by moving the "same !" debug message to a new line with the prefix "LIBFLASH: ..." to indicate it's a continuation of the last statement. First reported in https://github.com/open-power/skiboot/issues/51 Reported-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-05-20include/mem_region-malloc: Define calloc for CCAN HeapJordan Niethe1-8/+0
We would like to be able to use dump_trace to dump multiple trace buffers at a time. The entries should be displayed in timestamp order. As each buffer is already ordered on timestamp, a k-way merge is an efficient method to sort the buffers together by timestamp. A heap can be used to implement a k-way merge. As CCAN is already included in Skiboot, use the CCAN heap. The heap uses the calloc function which is currently not defined in skiboot. Prepare for adding this heap by defining calloc. Remove local calloc definition from libffs.c. Signed-off-by: Jordan Niethe <jniethe5@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-04-09test-ipmi-hiomap: Add read-one-byte testVasant Hegde1-0/+40
Add test case to read: - 1 byte - 1 block and 1 byte data Cc: Andrew Jeffery <andrew@aj.id.au> Cc: skiboot-stable@lists.ozlabs.org Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-04-09test-ipmi-hiomap: Fix lpc-read-successVasant Hegde1-1/+3
Cc: Andrew Jeffery <andrew@aj.id.au> Cc: skiboot-stable@lists.ozlabs.org Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-04-09test-ipmi-hiomap: Add write-one-byte testVasant Hegde1-0/+38
Add test case to write: - 1 byte - 1 block and 1 byte data Cc: Andrew Jeffery <andrew@aj.id.au> Cc: skiboot-stable@lists.ozlabs.org Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-04-09test-ipmi-hiomap: Assert if size is zeroVasant Hegde1-1/+2
Cc: Andrew Jeffery <andrew@aj.id.au> Cc: skiboot-stable@lists.ozlabs.org Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-04-09libflash/ipmi-hiomap: Fix blocks count issueVasant Hegde1-3/+18
We convert data size to block count and pass block count to BMC. If data size is not block aligned then we endup sending block count less than actual data. BMC will write partial data to flash memory. Sample log : [ 594.388458416,7] HIOMAP: Marked flash dirty at 0x42010 for 8 [ 594.398756487,7] HIOMAP: Flushed writes [ 594.409596439,7] HIOMAP: Marked flash dirty at 0x42018 for 3970 [ 594.419897507,7] HIOMAP: Flushed writes In this case HIOMAP sent data with block count=0 and hence BMC didn't flush data to flash. Lets fix this issue by adjusting block count before sending it to BMC. Cc: Andrew Jeffery <andrew@aj.id.au> Cc: skiboot-stable@lists.ozlabs.org Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-03-20libffs: Fix string truncation gcc warning.Michal Suchanek1-1/+1
Use memcpy as other libffs functions do. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add erase-one-block-twice testAndrew Jeffery1-0/+61
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add write-one-block-twice testAndrew Jeffery1-0/+65
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add read-one-block-twice testAndrew Jeffery1-0/+33
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add protocol-recovery-get-flash-info-failure testAndrew Jeffery1-0/+195
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add protocol-recovery-failure-get-info testAndrew Jeffery1-0/+191
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add protocol-recovery-failure-ack testAndrew Jeffery1-0/+170
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add erase-malformed testsAndrew Jeffery1-0/+92
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add flush-malformed testsAndrew Jeffery1-0/+95
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add mark-dirty-malformed testsAndrew Jeffery1-0/+101
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add create-write-window-malformed testsAndrew Jeffery1-0/+95
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add create-read-window-malformed testsAndrew Jeffery1-0/+95
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add get-flash-info-malformed testsAndrew Jeffery1-0/+64
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add get-info-malformed testsAndrew Jeffery1-0/+64
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add ack-malformed testsAndrew Jeffery1-0/+60
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add erase-error testAndrew Jeffery1-0/+41
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add ack-error testAndrew Jeffery1-0/+7
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add flush-error testAndrew Jeffery1-0/+42
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add mark-dirty-error testAndrew Jeffery1-0/+45
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add create-write-window-error testAndrew Jeffery1-0/+42
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add create-read-window-error testAndrew Jeffery1-0/+42
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add get-flash-info-error testAndrew Jeffery1-0/+30
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add get-info-error testAndrew Jeffery1-0/+29
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add get-flash-info testAndrew Jeffery1-0/+46
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add action-error testAndrew Jeffery1-0/+30
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add bad-sequence testAndrew Jeffery1-0/+31
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add event-during-eraseAndrew Jeffery1-0/+37
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add event-before-erase testAndrew Jeffery1-0/+18
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add erase-two-blocks testAndrew Jeffery1-0/+64
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add erase-one-block testAndrew Jeffery1-0/+54
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add event-during-write testAndrew Jeffery1-0/+41
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add event-before-write testAndrew Jeffery1-0/+15
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-02-24test-ipmi-hiomap: Add write-two-blocks testAndrew Jeffery1-0/+118
Cc: stable Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>