All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] common: hash: Manually relocate struct hash_algo
Date: Mon, 14 Oct 2019 14:56:35 +0200	[thread overview]
Message-ID: <2538531aba93f7bef01450e0c3640d99ad7c22aa.1571057794.git.michal.simek@xilinx.com> (raw)
In-Reply-To: <cover.1571057794.git.michal.simek@xilinx.com>

From: T Karthik Reddy <t.karthik.reddy@xilinx.com>

This patch adds manual relocation for struct hash_algo if
CONFIG_NEEDS_MANUAL_RELOC is enabled.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 common/hash.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/common/hash.c b/common/hash.c
index d33e329897e1..d0d825e38986 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -30,6 +30,12 @@
 #include <u-boot/sha256.h>
 #include <u-boot/md5.h>
 
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+DECLARE_GLOBAL_DATA_PTR;
+#endif
+
+static void reloc_update(void);
+
 #if defined(CONFIG_SHA1) && !defined(CONFIG_SHA_PROG_HW_ACCEL)
 static int hash_init_sha1(struct hash_algo *algo, void **ctxp)
 {
@@ -215,10 +221,31 @@ static struct hash_algo hash_algo[] = {
 #define multi_hash()	0
 #endif
 
+static void reloc_update(void)
+{
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+	int i;
+	static bool done;
+
+	if (!done) {
+		done = true;
+		for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
+			hash_algo[i].name += gd->reloc_off;
+			hash_algo[i].hash_func_ws += gd->reloc_off;
+			hash_algo[i].hash_init += gd->reloc_off;
+			hash_algo[i].hash_update += gd->reloc_off;
+			hash_algo[i].hash_finish += gd->reloc_off;
+		}
+	}
+#endif
+}
+
 int hash_lookup_algo(const char *algo_name, struct hash_algo **algop)
 {
 	int i;
 
+	reloc_update();
+
 	for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
 		if (!strcmp(algo_name, hash_algo[i].name)) {
 			*algop = &hash_algo[i];
@@ -235,6 +262,8 @@ int hash_progressive_lookup_algo(const char *algo_name,
 {
 	int i;
 
+	reloc_update();
+
 	for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
 		if (!strcmp(algo_name, hash_algo[i].name)) {
 			if (hash_algo[i].hash_init) {
-- 
2.17.1

  reply	other threads:[~2019-10-14 12:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 12:56 [U-Boot] [PATCH 0/3] crypto: Add manual relocation Michal Simek
2019-10-14 12:56 ` Michal Simek [this message]
2019-10-14 12:56 ` [U-Boot] [PATCH 2/3] drivers: crypto: rsa_mod_exp: Add manual relocation for ops->mod_exp() Michal Simek
2019-10-14 12:56 ` [U-Boot] [PATCH 3/3] common: image-sig.c: Add manual relocation Michal Simek
2019-10-24 11:23 ` [U-Boot] [PATCH 0/3] crypto: " Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2538531aba93f7bef01450e0c3640d99ad7c22aa.1571057794.git.michal.simek@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.