lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230206101642.22720-2-wdehoog@exalondelft.nl>
Date:   Mon,  6 Feb 2023 13:16:41 +0300
From:   arinc9.unal@...il.com
To:     Rafał Miłecki <zajec5@...il.com>,
        Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        Linus Walleij <linus.walleij@...aro.org>,
        Willem-Jan de Hoog <wdehoog@...londelft.nl>,
        Florian Fainelli <f.fainelli@...il.com>
Cc:     Arınç ÜNAL <arinc.unal@...nc9.com>,
        Rafał Miłecki <rafal@...ecki.pl>,
        linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org,
        erkin.bozoglu@...ont.com
Subject: [PATCH v2 1/2] firmware: bcm47xx_nvram: allow to read from buffered nvram data

From: Willem-Jan de Hoog <wdehoog@...londelft.nl>

The bcm47xx code makes a copy of the NVRAM data in ram. Allow access to
this data so property values can be read using nvmem cell api.

[ arinc.unal@...nc9.com: Improved patch subject and log ]

Signed-off-by: Willem-Jan de Hoog <wdehoog@...londelft.nl>
Signed-off-by: Arınç ÜNAL <arinc.unal@...nc9.com>
---
 drivers/firmware/broadcom/bcm47xx_nvram.c | 14 ++++++++++++++
 include/linux/bcm47xx_nvram.h             |  6 ++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/firmware/broadcom/bcm47xx_nvram.c b/drivers/firmware/broadcom/bcm47xx_nvram.c
index 5f47dbf4889a..7e5c62dc702f 100644
--- a/drivers/firmware/broadcom/bcm47xx_nvram.c
+++ b/drivers/firmware/broadcom/bcm47xx_nvram.c
@@ -182,6 +182,20 @@ static int nvram_init(void)
 	return -ENXIO;
 }
 
+int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len)
+{
+	if (!nvram_len)
+		return -ENXIO;
+
+	if ((offset+val_len) > nvram_len)
+		return -EINVAL;
+
+	while (val_len--)
+		*val++ = nvram_buf[offset++];
+
+	return 0;
+}
+
 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
 {
 	char *var, *value, *end, *eq;
diff --git a/include/linux/bcm47xx_nvram.h b/include/linux/bcm47xx_nvram.h
index 7615f8d7b1ed..b265b8ce6434 100644
--- a/include/linux/bcm47xx_nvram.h
+++ b/include/linux/bcm47xx_nvram.h
@@ -20,6 +20,7 @@ static inline void bcm47xx_nvram_release_contents(char *nvram)
 {
 	vfree(nvram);
 };
+int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len);
 #else
 static inline int bcm47xx_nvram_init_from_iomem(void __iomem *nvram_start,
 						size_t res_size)
@@ -48,6 +49,11 @@ static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
 static inline void bcm47xx_nvram_release_contents(char *nvram)
 {
 };
+
+static inline int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len)
+{
+	return -ENOTSUPP;
+}:
 #endif
 
 #endif /* __BCM47XX_NVRAM_H */
-- 
2.37.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ