summaryrefslogtreecommitdiffstats
path: root/libc
Commit message (Collapse)AuthorAgeFilesLines
* Move FSP specific abort() code to platform layerVasant Hegde2015-09-092-10/+4
| | | | | | | | | | | | | | | Presently abort() call sets up HID0, triggers attention and finally calls infinite for loop. FSP takes care of collecting required logs and reboots the system. This sequence is specific to FSP machine and it will not work on BMC based machine. Hence move FSP specific code to hw/fsp/fsp-attn.c. Note that this patch adds new parameter to abort call. Hence replaced _abort() by abort() in exception.c so that we can capture file info as well. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* fix wrong operator use in stdlib/rand.cStewart Smith2015-07-081-1/+1
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Increase unit test coverage of printf h and z length modifiersStewart Smith2015-07-021-0/+31
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Increase unit test coverage of printf %p and %oStewart Smith2015-07-021-0/+22
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc tolower() and toupper()Stewart Smith2015-06-242-0/+22
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc isdigit, isprint, isspace, isxdigitStewart Smith2015-06-242-0/+93
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc memmoveStewart Smith2015-06-242-2/+27
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc strncasecmpStewart Smith2015-06-242-0/+17
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc strcasecmpStewart Smith2015-06-242-0/+27
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc strcmpStewart Smith2015-06-242-0/+10
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc memcmpStewart Smith2015-06-242-0/+10
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc memchrStewart Smith2015-06-242-0/+13
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/blocklevel: Extend the block level to be able to do eccCyril Bur2015-06-231-0/+2
| | | | | | | | | | | | | | | | At the moment ECC reads and writes are still being handled by the low level core of libflash. ECC should be none of libflashes concern, it is primarily a hardware access backend. It makes sense for blocklevel to take care of ECC but currently it has no way of knowing. With some simple modifications (which are rudimentary at the moment and will need a performance improvement) blocklevel can handle ECC, and with a little more effort this can be extended to provide read and write protection in blocklevel. 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>
* Remove unused struct tm elementsStewart Smith2015-06-151-5/+0
| | | | | | Better to error out than suddenly have places use uninitalized data. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Optimized memset() implementation for POWERStewart Smith2015-06-013-0/+55
| | | | | | | | | | | | This uses the dcbz instruction to clear cacheline at a time rather than byte at a time. This means that even without high levels of optimization, we *dramatically* improve boot performance with SKIBOOT_GCOV=1 and probably ever so slightly speed things up for normal builds. We currently just hard-code 128 as cacheline size as all CPUs that skiboot currently boots on have 128 byte cachelines. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add pr_fmt to do printf/prlog prefixing automagicallyStewart Smith2015-05-121-1/+9
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* sparse: fix libc declarationsCédric Le Goater2015-02-261-6/+8
| | | | | Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* sparse: fix Using plain integer as NULL pointer warningCédric Le Goater2015-02-262-2/+2
| | | | | Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* sparse: declare errnoCédric Le Goater2015-02-261-0/+1
| | | | | Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* atoi/atol should assume base 10, not autodetect base.Daniel Axtens2015-02-233-6/+9
| | | | | | | | | The behaviour of atoi/atol on glibc (and according to the spec) is to assume base 10, not to autodetect the base. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Don't recognise a double hex prefix (0x0xNN) as valid.Daniel Axtens2015-02-233-8/+3
| | | | | | | | | When autodetecting the base, the code would strip hex prefixes twice. Now the string is not modified in the detection stage. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Test libc stdlib functions (atoi/strtol and friends)Daniel Axtens2015-02-231-0/+60
| | | | | | | | This increases coverage of atoi, atol, strtol and strtoul to 100%. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Make abort() update sp attn area (like assert does)Stewart Smith2015-02-111-1/+7
| | | | | | Gives better diagnostics in error logs/dumps Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Fix commit 16c80346Jeremy Kerr2015-02-091-2/+11
| | | | | | | | | Commit 16c80346 change included some reverts of previous commits, which we need. This change reverts those reverts, leaving the original intent of that change. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add OPAL_INVALID_CALL explicitly in opal.h and docsStewart Smith2015-02-051-11/+2
| | | | | | | Was mentioned in linux as possibly being used by some external test modules. It's harmless to make this official behaviour. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Makefile: clean the gcov files created during coverageNeelesh Gupta2015-02-051-2/+11
| | | | | | | | Fix the Makefile to clean up the coverage data files generated through gcov. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add libc/test/.gitignore for the new libc unit testsStewart Smith2015-01-271-0/+10
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add skeleton for libc/ctype unit testsStewart Smith2015-01-203-1/+62
| | | | | | Now it shows up as untested in lcov! Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add skeleton for libc/stdlib unit testStewart Smith2015-01-203-1/+62
| | | | | | Now it shows up as untested in lcov! Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Skeleton unit tests for libc memops (libc/string/*)Stewart Smith2015-01-203-1/+71
| | | | | | This means that it shows up in lcov as untested. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add some skiboot snprintf test casesStewart Smith2015-01-204-5/+242
| | | | | | Initial implementation and support for more libc test cases Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Merge branch 'update-2.1.1.1'Stewart Smith2015-01-191-55/+108
|\
| * opal: Fix buffer overrun in print_* functions.Mahesh Salgaonkar2015-01-191-55/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While running HMI tests I saw a massive corruption in OPAL for one of the HMI test that injects TB error. On investigation I found that vsnprintf()->print_itoa() was the culprit. print_itoa function uses tmp array of size 16 to convert unsigned long value to ASCII. But an unsigned value of 0xffffffffffffffff needs atleast 25 characters to print its ASCII representation. This caused an array to overflow resulting into corruption, unpredictable behavior and finally system termination. We could fix this by increasing the size of tmp[] array but that still won't fix this bug completely. While auditing vsnprintf() function I found that it makes use of print_*() functions to write data to buffer. But none of the print_* function have any check on buffer size before writing data to it. Without size check print_*() can easily overrun buffer passed by vprlog()->vsnprintf()->print_format()->print_*() causing massive corruption leading to unpredictable behavior. This patch fixes this bug by modifying print_*() function to check for buffer size to avoid buffer overrun. - Modified print_format(), print_fill() and print_itoa() to take bufsize as argument and added a size check while writing to buffer. - Remove temporary array from print_itoa(), instead write data directly to buffer. - Added two new function print_str_fill() and print_str() to be used as helper routine for '%s' fmt case in print_format() function. These new routines now has a check on buffer size while copying NULL terminated string to buffer. - Added "!bufsize" check in vsnprintf() to avoid buffer overrun while setting NULL character before returning. I ran HMI tests with this patch successfully. I also tested this patch by reducing size of the buffer (in core/console-log.c:vprlog()) from 320 to 50 and booted the lid successfully with no corruption at all. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | Exclude all test cases from coverage-reportStewart Smith2014-12-191-0/+2
| | | | | | | | | | | | | | | | This way we get a true representation from the lcov coverage-report about what firmware code we're testing (besides, test cases are always going to only have 50% of branches hit - we're asserting the tests pass!) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | Pretty print make check and coverage outputStewart Smith2014-12-191-4/+4
| | | | | | | | | | | | Can still get the details with V=1, just like normal make. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | Fix makefile dependency generation, especially for HOSTCCStewart Smith2014-12-151-7/+0
| | | | | | | | | | | | | | | | | | | | | | Instead of having individual rules to generate .d, add -MMD to HOSTCC parameters, and just include the generated .d files. This fixes a few weird dependency issues. Also, make the mambo hello_kernel test depend on skiboot.lid Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | Remove vsprintf: just like sprintf, vsnprintf is a much better ideaStewart Smith2014-11-283-21/+1
| | | | | | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | Remove sprintf: there's no good reason to have this in firmwareStewart Smith2014-11-283-32/+1
| | | | | | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | Merge branch 'update-2.1.1.1'Stewart Smith2014-11-262-9/+10
|\ \ | |/
| * Include stdint.h for libc/test/run-time.c, fixing buildStewart Smith2014-11-261-0/+1
| | | | | | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
| * vsnprintf: Change print_itoa to use less stackShreyas B. Prabhu2014-11-261-9/+9
| | | | | | | | | | | | | | Remove recursive call in print_itoa to reduce the stack usage. Signed-off-by: Shreyas B. Prabhu <shreyas@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | use $(wildcard ) in test MakefilesDan Streetman2014-11-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The core/test/ and libc/test/ Makefile.check files both contain: -include core/test/*.d (or libc/test/*d) which is incorrect, since that evaluates literally to a *.d file. This results in each build trying to find that file, and creating it when not found (in an incorrect way because of other problems in the Makefile). The correct way to specify it is: -include $(wildcard core/test/*.d) Signed-off-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* | Preliminary code coverage reporting infrastructureStewart Smith2014-10-221-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support in core/test/Makefile.check to build -gcov binaries (with -lgcov and -fprofile-blah-blah) as well as some targets for producing lcov HTML code coverage reports. As part of this, I had to fix up an oddity in run-mem_region_init where that due to running under Valgrind, we'd be malloc()ed a heap with a small address, well inside the mem_regions we added but when not running under valgrind (e.g. for code coverage reporting) we would get a much larger address, outside this range and hit an assert. So, after fiddling with the memory stuff for this test, I think I have it right - it passes both under valgrind and not and does produce code coverage data. Currently, we're at this level of code coverage by unit tests: Hit Total Coverage Lines: 1936 2574 75.2 % Functions: 177 225 78.7 % Branches: 1243 2360 52.7 % The totals should largely be ignored due to the only code being counted is that linked into the unit tests (total LOC is ~50kLOC according to sloccount... so unit tests currently cover < 5%) Try the "make coverage-report" target, you'll get coverage-report directory with a LCOV HTML report Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | libc/test: Fix timeJoel Stanley2014-10-011-1/+0
|/ | | | | | | | | | | | | | | | There is no use for time, remove it. Fixes the following error (and the warning once stdint.h was included): libc/test/run-time.c:40:2: error: unknown type name ‘uint32_t’ uint32_t time; libc/test/run-time.c:41:11: warning: unused variable ‘time’ [-Wunused-variable] uint32_t time; Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* libc: Add mktime and gmtime_rAlistair Popple2014-08-155-3/+250
| | | | | | | | | | | | Both the FSP RTC and the upcoming IPMI RTC implementation need to manipulate time in various ways. Rather than re-implementing slightly different versions of the calculations twice lets implement some standard library functions (with tests) and use those. This patch adds mktime and gmtime_r to the libc. Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* attn: Add git version and backtrace details to user dataAruna Balakrishnaiah2014-08-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For better debugability, the patch adds git version and backtrace details to user data section (along with file info which was already present). After adding required details TermImmedData looks like: TermImmedData | | 00000000 63386631 6639322D 64697274 793A0000 c8f1f92-dirty:.. | | 00000010 00000000 00000000 00000000 00000000 ................ | | 00000020 00000000 00000000 43505520 30303030 ........CPU 0000 | | 00000030 30303264 20426163 6B747261 63653A0A 002d Backtrace:. | | 00000040 20533A20 30303030 30303030 33316162 S: 0000000031ab | | 00000050 36626130 20523A20 30303030 30303030 6ba0 R: 00000000 | | 00000060 33303031 33306238 0A20533A 20303030 300130b8. S: 000 | | 00000070 30303030 30333161 62366334 3020523A 0000031ab6c40 R: | | 00000080 20303030 30303030 30333030 34623738 000000003004b78 | | 00000090 380A2053 3A203030 30303030 30303331 8. S: 0000000031 | | 000000A0 61623663 63302052 3A203030 30303030 ab6cc0 R: 000000 | | 000000B0 30303330 30313736 31300A20 533A2030 0030017610. S: 0 | | 000000C0 30303030 30303033 31616236 64343020 000000031ab6d40 | | 000000D0 523A2030 30303030 30303033 30303035 R: 0000000030005 | | 000000E0 3133340A 20533A20 30303030 30303030 134. S: 00000000 | | 000000F0 33316162 36663030 20523A20 30303030 31ab6f00 R: 0000 | | 00000100 30303030 33303030 32353534 0A000000 000030002554.... | | 00000110 00000000 00000000 00000000 00000000 ................ | | 00000120 00000000 00000000 00000000 00000000 ................ | | 00000130 00000000 00000000 00000000 00000000 ................ | | 00000140 00000000 00000000 00000000 00000000 ................ | | 00000150 00000000 00000000 00000000 00000000 ................ | | 00000160 00000000 00000000 00000000 00000000 ................ | | 00000170 00000000 00000000 00000000 00000000 ................ | | 00000180 00000000 00000000 00000000 00000000 ................ | | 00000190 00000000 00000000 00000000 00000000 ................ | | 000001A0 00000000 00000000 00000000 00000000 ................ | | 000001B0 00000000 00000000 00000000 00000000 ................ | | 000001C0 00000000 00000000 00000000 636F7265 ............core | | 000001D0 2F6F7061 6C2E633A 3233383A 30000000 /opal.c:238:0... | |------------------------------------------------------------------------------| Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* Use PR_EMERG priority in assert() codepathStewart Smith2014-08-082-24/+1
| | | | | | | | | | | | | Moving assert_fail() out of libc and into core/utils.c so that we can sanely call prlog(PR_EMERG). We shorten it from three fputs calls down to one prlog() call. This may increase the number of cycles and stack usage for when we hit an assert, which may not be desirable. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* replace printf() with console log, level 5 aka INFO messagesStewart Smith2014-08-082-28/+1
| | | | | | | | Replace the libc printf implementation with a wrapper that does fancy log things such as display timestamp and the log level. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* ATTN: Set up attention area to handle attentionAruna Balakrishnaiah2014-08-011-2/+6
| | | | | | | | | | | | | | | | | | | | | | At present CPU control area ntuple in SPIRA structure is NULL. ATTN component in Service Processor side checks for this field and if its empty, it logs hardcoded SRC (0xBB821410) and generates SYSDUMP. So we have 1 SRC for all failure (assert call) from OPAL side. This makes difficult to debug the issue. Service processor provides attention area interface (FIPS PHyp Attentions spec), so that we can pass SRC and user data (error message) to service processor. This will helps us identify different failures in OPAL. This patch enables attention area and provides interface (update_sp_attn_area()) to add src and user data (error message) through assert macro. Attention SRC format: 1st byte - Opal src type 2-4 bytes - Holds the address of the assert function call Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* Initial commit of Open Source releaseBenjamin Herrenschmidt2014-07-0265-0/+2536
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
OpenPOWER on IntegriCloud