aboutsummaryrefslogtreecommitdiff
path: root/core/nvram-format.c
AgeCommit message (Collapse)AuthorFilesLines
2018-09-17nvram: Fix wait-for-nvram messageOliver O'Halloran1-2/+3
We print a message when nvram_query() needs to wait for the NVRAM to be loaded from the BMC/FSP. Currently this is printed at PR_WARNING which is excessive since this doesn't actually indicate that anything is wrong. There's also nothing that we can really do about loading the NVRAM being slow, so just print this at PR_DEBUG. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-09-17nvram: Print how long we waited for nvramOliver O'Halloran1-0/+2
Print how long we had to wait for NVRAM to become available if we needed to wait. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-09-17nvram: Fix a possible NULL pointer de-ref in nvram_query_eq()Vaibhav Jain1-0/+9
A fault will occur if 'value == NULL' is passed to nvram_query_eq() to check if a given key doesn't exists in nvram partition. This is an invalid use of the API as its only supposed to be used for keys that exist in nvram and 'value == NULL' is never possible. Hence this patch adds an assert to the function to flag such a use and also prevent NULL being passed as an argument to strcmp(). Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com> Suggested-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-03-27nvram: run nvram_validate() after nvram_reformat()Nicholas Piggin1-0/+3
nvram_reformat() sets nvram_valid = true, but it does not set skiboot_part_hdr. Call nvram_validate() instead, which sets everything up properly. Reviewed-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-11-30nvram: Fix 'missing' nvram on FSP systems.Cyril Bur1-0/+9
commit ba4d46fdd9eb ("console: Set log level from nvram") wants to read from NVRAM rather early. This works fine on BMC based systems as nvram_init() is actually synchronous. This is not true for FSP systems and it turns out that the query for the console log level simply queries blank nvram. The simple fix is to wait for the NVRAM read to complete before performing any query. Unfortunately it turns out that the fsp-nvram code does not inform the generic NVRAM layer when the read is complete, rather, it must be prompted to do so. This patch addresses both these problems. This patch adds a check before the first read of the NVRAM (for the console log level) that the read has completed. The fsp-nvram code has been updated to inform the generic layer as soon as the read completes. The old prompt to the fsp-nvram code has been removed but a check to ensure that the NVRAM has been loaded remains. It is conservative but if the NVRAM is not done loading before the host is booted it will not have an nvram device-tree node which means it won't be able to access the NVRAM at all, ever, even after the NVRAM has loaded. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-06-26Big log level reduction...Benjamin Herrenschmidt1-6/+3
90% of what we print isn't useful to a normal user. This dramatically reduces the amount of messages printed by OPAL in normal circumstances. We still need to add a way to bump the log level at boot based on a BMC scratch register or some HDAT property. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-02-23nvram-format: Fix endian issuesStewart Smith1-15/+20
NVRAM formats are always BE, so let's use the sparse annotation to catch any issues (and correct said issues). On LE platforms, the test was erroneously passing as with building the nvram-format code on LE we were produces an incorrect NVRAM image. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-01-05treewide: squash sparse static warningsAndrew Donnellan1-1/+1
Add static to various declarations that can use it, as found by sparse. It turns out that one of these (fsp_pcie_inv_lock in platform/ibm-fsp/firenze.c) is actually unused, so remove it. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-14nvram: add nvram_query_eq()Oliver O'Halloran1-0/+11
Adds a helper that looks for the given NVRAM config string and checks that associated value is equal to the supplied value. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-14nvram: force re-verification after writingOliver O'Halloran1-4/+19
The running OS is free to re-write the contents of NVRAM. The skiboot NVRAM parser relies on the NVRAM contents being valid so we need to force the NVRAM contents to be revalidated after the host OS has written to it. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-30core/nvram: add support for skiboot config stringsOliver O'Halloran1-0/+68
This allows the ibm,skiboot partition to be used to store NUL terminated key=value OF configuration strings. These strings can be written using the nvram utility found in the linux powerpc-utils package. Currently the only use case for this is passing command line arguments to the boot kernel so only ASCII strings are supported. The 0xFF binary escaping mechanism for configuration strings is not supported. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-30nvram: ibm,skiboot NUL terminator checkOliver O'Halloran1-5/+22
NVRAM configuration strings are required to be NUL terminated and unused data bytes in the partition should be set to NUL. Badly behaved system software may not do this so same sanity checking is required. Ensuring that the final data byte in a partition is a NUL should be sufficient. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-30nvram: rename nvram-format.h to nvram.hOliver O'Halloran1-1/+1
The NVRAM handling code was split into two files so that the partition parsing could be separately tested. Currently there is no nvram.h and the tests #include nvram-format.c directly. This patch renames nvram-format.h to something more sensible. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-02log_level: Reduce the in memory console log_level to lower priorityPridhiviraj Paidipeddi1-1/+1
Below are the in-memory console log messages observed with error level(PR_ERROR) [54460318,3] HBRT: Mem region 'ibm,homer-image' not found ! [54465404,3] HBRT: Mem region 'ibm,homer-image' not found ! [54470372,3] HBRT: Mem region 'ibm,homer-image' not found ! [54475369,3] HBRT: Mem region 'ibm,homer-image' not found ! [11540917382,3] NVRAM: Layout appears sane [11694529822,3] OPAL: Trying a CPU re-init with flags: 0x2 [61291003267,3] OPAL: Trying a CPU re-init with flags: 0x1 [61394005956,3] OPAL: Trying a CPU re-init with flags: 0x2 Lowering the log level of mem region not found messages to PR_WARNING and remaining messages to PR_INFO level [54811683,4] HBRT: Mem region 'ibm,homer-image' not found ! [10923382751,6] NVRAM: Layout appears sane [55533988976,6] OPAL: Trying a CPU re-init with flags: 0x1 Signed-off-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-27nvram: Add extra debug printing when NVRAM needs formattingCyril Bur1-3/+9
Be more verbose (at debug level) when formatting the NVRAM, this can help catch errors at other levels of the stack. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-11nvram-format: fix inconsistent indentingStewart Smith1-3/+3
Found by smatch static analysis (http://smatch.sourceforge.net/): core/nvram-format.c:146 nvram_check() warn: inconsistent indenting core/nvram-format.c:151 nvram_check() warn: inconsistent indenting Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-24Use memcpy for NVRAM free partition name, is part of stdStewart Smith1-1/+2
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-24Expand nvram-format unit test to cover all error pathsStewart Smith1-1/+9
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-24Move NVRAM format/check code out into separate file to unit testStewart Smith1-0/+149
We (slightly) change the internal API so that we operate on parameters rather than globals, this means it's easier to unit test too. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>