aboutsummaryrefslogtreecommitdiff
path: root/external/gard/gard.c
AgeCommit message (Collapse)AuthorFilesLines
2016-06-20Fix for typosFrederic Bonnard1-1/+1
While reviewing the Debian packaging, codespell found those. Most proposed fixes are based on codespell's default dictionnary. Signed-off-by: Frederic Bonnard <frediz@linux.vnet.ibm.com> Reviewed-by: Mukesh Ojha <mukesh02@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-07gard: fix compile error on ARMCédric Le Goater1-3/+3
gard can be used on the BMC to query garded records, but currently compile fails with : cc -O2 -Wall -Werror -I. -c gard.c -o gard.o gard.c: In function 'do_clear_i': gard.c:421:12: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' [-Werror=format] gard.c: In function 'check_gard_partition': gard.c:489:36: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'unsigned int' [-Werror=format] This patches provides a fix compatible with x86, armel, ppc64. Signed-off-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-05-02gard: remove err.h includeStewart Smith1-1/+0
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-04-29Fix gard --help outputStewart Smith1-1/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-01-15libflash/blocklevel: Add keep_alive parameterCyril Bur1-1/+1
Currently the file backend will keep a file descriptor open until the structure is destroyed. This is undesirable for daemons and long running processes that only have a very occasional need to access the file. Keeping the file open requires users of blocklevel to close and reinit their structures every time, doing is isn't disastrous but can easily be managed at the interface level. This has been done at the blocklevel_device interface so as to provide minimal changes to arch_flash_init(). At the moment there isn't a need for the actually flash driver to be able to do this, this remains unimplmented there. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-01-15external/gard: Fix displaying 'cleared' gard recordsCyril Bur1-3/+33
When a garded component is replaced hostboot detects this and updates the gard partition. What hostboot does is set the record_id field to 0xFFFFFFFF but leaves the rest of the flash untouched, this has caused issues with the gard tool the thinking was that an entire record of all 0xFF bytes would signal not a valid record. This patch add rectifies this issue and `gard list` will no longer show any record with an id of 0xFFFFFFFF. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Sam Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-16external/gard: Make use of the common/ flash reading codeCyril Bur1-153/+11
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-16external/gard: Add version informationCyril Bur1-0/+9
Method for recording version is identical to pflash. Uses the current skiboot version and any current repository state. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-16external/gard: Fix memory leakCyril Bur1-6/+13
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-10-23gard: print error message when we can't open a flash deviceJeremy Kerr1-1/+1
If I run gard on system flash as a non-root user, I get: $ ./external/gard/gard list $ echo $? 1 which isn't too helpful. This change adds a basic error message to the open() failure. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-08external/gard: Fix Coverity defect 107465Cyril Bur1-1/+1
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-08external/gard: Fix Coverity defect 107466Cyril Bur1-1/+1
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-08external/gard: Fix Coverity defect 107467Cyril Bur1-1/+2
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-07external/gard: Recover the entire gard partitionCyril Bur1-12/+2
If the gard tool detects that the GUARD partition has been corrupted it has logic to attempt to recover the GUARD partition in a best effort attempt to leave the GUARD partition in a state that will allow the machine to boot. It has come to light that Hostboot is more sensitive to what must be in the GUARD partition in order to be able to bring a machine up, as such, the gard tool will now fill the entire partition with all 1's and ECC bytes, not simply the first record as it currently does Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-07external/gard: Update record clearing to match Hostboots expectationsCyril Bur1-46/+59
When the gard tool is told to clear all the gard records it actually erases the entire flash and inserts ECC bytes only for the size of the first gard record. The current method appears to have stopped working, Hostboot expects the entire partition to have ECC bytes throughout the entire partition, and as such the current method causes Hostboot to error and be unable to bring up machines. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-28external/gard: Check the validity of the flashCyril Bur1-5/+55
If the GUARD partition has been corrupted such that ECC checks fail and not even the first gard record can be read then the gard tool will be unable to do anything. If this happens it is possible that hostboot will have a similar problem. The only sane thing to do at is point is probably to wipe the GUARD partition. This patch adds a check for this case and provides the user with the option to wipe the entirety of the GUARD partition to attempt recovery. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-19in skbioot-5.1.0 commit, accidentally somehow removed two compiler warning ↵Stewart Smith1-1/+1
fixes. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17Add skiboot-5.1.0 release notesskiboot-5.1.0Stewart Smith1-1/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17external/gard: Fix uninitialised variable warningJeremy Kerr1-1/+1
gcc -g -O3 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -m64 -Werror -Wall -g2 -ggdb -D_FORTIFY_SOURCE=2 -I. -I../../ -c gard.c -o gard.o gard.c: In function main: gard.c:741:5: error: i may be used uninitialized in this function [-Werror=maybe-uninitialized] if (i == ARRAY_SIZE(actions)) { ^ cc1: all warnings being treated as errors If we 'goto out;', we'll perform the check on 'i' without having initialised it. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-17external/gard: Update gard tool to new blocklevel interfaceCyril Bur1-76/+54
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-23libflash/ecc: Simplify and cleanup ecc code.Cyril Bur1-1/+1
The ecc 'memcpy' style functions return success or fail in terms of the ECC enum. This doesn't really make sense, use true or false. As the result the ecc enum doesn't need to be exposed anymore, which makes more sense, not clear why it was exposed in the first place. Convert some of the ecc #defines to static inlines, shouldn't make any difference but feels safer. Fix minor stylistic and typo issues. Reviewed-By: Alistair Popple <alistair@popple.id.au> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-23Fixes for compilation with -WerrorFrederic Bonnard1-3/+1
On Debian/Ubuntu, additionnal compilation flags are added such as -Werror which make compilation fail. So : - checking function return codes so that the compilation doesn't fail. - moving 'largest' variable so that gcc always sees it with a value. Signed-off-by: Frederic Bonnard <frediz@linux.vnet.ibm.com> Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-04-01external: create a GUARD partition parsing utilityCyril Bur1-0/+777
This utility is designed to run completely in userland linux and make use of OPAL APIs (exposed to userland via the linux MTD abstraction) to read, parse, display and optionally clear firmware GUARD partition information. The main intended use case is to have the tool run on the OpenPOWER machine and automatically detect the flash device containing the gard data and display information about the running system. The tool can also read a flash imagine contained in a specified file. The tool can also be used to parse just guard data not contained in a flash image but rather dumped to a file. The tool understands ECC and does its best to detect this automatically. There are three commands: - list: lists all the records - show: show more information about a specific record - clear: clear/erase a specific record or the entire flash. The tool makes some assumptions: - gard data is terminated by an entry containing all FF bytes. In the case of the tool detecting ECC it will always read with ECC correction so the final all FF record will still need to contain ECC bytes. - The GUARD partition will not have gaps, the clear code does shuffle entires up and set the last one to all FF bytes. Note: This tool has been named 'gard' because this is the traditional name for hardware that has been detected as faulty and has been 'gard'ed. It turns out that in the flash the partition is named 'GUARD'. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Daniel Axtens <dja@axtens.net> [stewart@linux.vnet.ibm.com: add correct (C) header to gard.c] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>