* [U-Boot] [PATCH 0/3] crypto: Add manual relocation
@ 2019-10-14 12:56 Michal Simek
2019-10-14 12:56 ` [U-Boot] [PATCH 1/3] common: hash: Manually relocate struct hash_algo Michal Simek
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Michal Simek @ 2019-10-14 12:56 UTC (permalink / raw)
To: u-boot
Hi,
This patch series fixes manual relocation issue, as it is crashing
when using RSA signed images on microblaze.
Thanks,
Michal
T Karthik Reddy (3):
common: hash: Manually relocate struct hash_algo
drivers: crypto: rsa_mod_exp: Add manual relocation for ops->mod_exp()
common: image-sig.c: Add manual relocation
common/hash.c | 29 +++++++++++++++++++++
common/image-sig.c | 29 +++++++++++++++++++++
drivers/crypto/rsa_mod_exp/mod_exp_uclass.c | 15 ++++++++++-
3 files changed, 72 insertions(+), 1 deletion(-)
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 1/3] common: hash: Manually relocate struct hash_algo
2019-10-14 12:56 [U-Boot] [PATCH 0/3] crypto: Add manual relocation Michal Simek
@ 2019-10-14 12:56 ` Michal Simek
2019-10-14 12:56 ` [U-Boot] [PATCH 2/3] drivers: crypto: rsa_mod_exp: Add manual relocation for ops->mod_exp() Michal Simek
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2019-10-14 12:56 UTC (permalink / raw)
To: u-boot
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 2/3] drivers: crypto: rsa_mod_exp: Add manual relocation for ops->mod_exp()
2019-10-14 12:56 [U-Boot] [PATCH 0/3] crypto: Add manual relocation Michal Simek
2019-10-14 12:56 ` [U-Boot] [PATCH 1/3] common: hash: Manually relocate struct hash_algo Michal Simek
@ 2019-10-14 12:56 ` 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
3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2019-10-14 12:56 UTC (permalink / raw)
To: u-boot
From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
This patch adds manual relocation for Modular Exponentiation 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>
---
drivers/crypto/rsa_mod_exp/mod_exp_uclass.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c b/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c
index 93deaa7f51e6..e91fe644580b 100644
--- a/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c
+++ b/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c
@@ -13,10 +13,23 @@
#include <asm/io.h>
#include <linux/list.h>
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+DECLARE_GLOBAL_DATA_PTR;
+#endif
+
int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
struct key_prop *node, uint8_t *out)
{
- const struct mod_exp_ops *ops = device_get_ops(dev);
+ struct mod_exp_ops *ops = (struct mod_exp_ops *)device_get_ops(dev);
+
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+ static bool done;
+
+ if (!done) {
+ done = true;
+ ops->mod_exp += gd->reloc_off;
+ }
+#endif
if (!ops->mod_exp)
return -ENOSYS;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 3/3] common: image-sig.c: Add manual relocation
2019-10-14 12:56 [U-Boot] [PATCH 0/3] crypto: Add manual relocation Michal Simek
2019-10-14 12:56 ` [U-Boot] [PATCH 1/3] common: hash: Manually relocate struct hash_algo Michal Simek
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 ` Michal Simek
2019-10-24 11:23 ` [U-Boot] [PATCH 0/3] crypto: " Michal Simek
3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2019-10-14 12:56 UTC (permalink / raw)
To: u-boot
From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
This patch adds manual relocation for struct checksum_algo & struct
crypto_algo structures.
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/image-sig.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/common/image-sig.c b/common/image-sig.c
index 004fbc525b5c..639a1124504f 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -89,6 +89,21 @@ struct checksum_algo *image_get_checksum_algo(const char *full_name)
int i;
const char *name;
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+ static bool done;
+
+ if (!done) {
+ done = true;
+ for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
+ checksum_algos[i].name += gd->reloc_off;
+#if IMAGE_ENABLE_SIGN
+ checksum_algos[i].calculate_sign += gd->reloc_off;
+#endif
+ checksum_algos[i].calculate += gd->reloc_off;
+ }
+ }
+#endif
+
for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
name = checksum_algos[i].name;
/* Make sure names match and next char is a comma */
@@ -105,6 +120,20 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name)
int i;
const char *name;
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+ static bool done;
+
+ if (!done) {
+ done = true;
+ for (i = 0; i < ARRAY_SIZE(crypto_algos); i++) {
+ crypto_algos[i].name += gd->reloc_off;
+ crypto_algos[i].sign += gd->reloc_off;
+ crypto_algos[i].add_verify_data += gd->reloc_off;
+ crypto_algos[i].verify += gd->reloc_off;
+ }
+ }
+#endif
+
/* Move name to after the comma */
name = strchr(full_name, ',');
if (!name)
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 0/3] crypto: Add manual relocation
2019-10-14 12:56 [U-Boot] [PATCH 0/3] crypto: Add manual relocation Michal Simek
` (2 preceding siblings ...)
2019-10-14 12:56 ` [U-Boot] [PATCH 3/3] common: image-sig.c: Add manual relocation Michal Simek
@ 2019-10-24 11:23 ` Michal Simek
3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2019-10-24 11:23 UTC (permalink / raw)
To: u-boot
po 14. 10. 2019 v 14:56 odesÃlatel Michal Simek
<michal.simek@xilinx.com> napsal:
>
> Hi,
>
> This patch series fixes manual relocation issue, as it is crashing
> when using RSA signed images on microblaze.
>
> Thanks,
> Michal
>
>
> T Karthik Reddy (3):
> common: hash: Manually relocate struct hash_algo
> drivers: crypto: rsa_mod_exp: Add manual relocation for ops->mod_exp()
> common: image-sig.c: Add manual relocation
>
> common/hash.c | 29 +++++++++++++++++++++
> common/image-sig.c | 29 +++++++++++++++++++++
> drivers/crypto/rsa_mod_exp/mod_exp_uclass.c | 15 ++++++++++-
> 3 files changed, 72 insertions(+), 1 deletion(-)
>
> --
> 2.17.1
>
Applied all.
M
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-10-24 11:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14 12:56 [U-Boot] [PATCH 0/3] crypto: Add manual relocation Michal Simek
2019-10-14 12:56 ` [U-Boot] [PATCH 1/3] common: hash: Manually relocate struct hash_algo Michal Simek
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
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.