mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] hab: Print events on info command.
@ 2018-10-04  7:05 Denis OSTERLAND
  2018-10-04 21:14 ` Andrey Smirnov
  2018-10-05  6:58 ` [PATCH v2] " Denis OSTERLAND
  0 siblings, 2 replies; 8+ messages in thread
From: Denis OSTERLAND @ 2018-10-04  7:05 UTC (permalink / raw)
  To: barebox; +Cc: Denis OSTERLAND

From: Denis Osterland <Denis.Osterland@diehl.com>

This patch calls *_hab_get_status function as part of hab info command.
This function works only if MMU is disabled.

Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
---
 commands/hab.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/commands/hab.c b/commands/hab.c
index 0d7ee8e76..9027b7cb5 100644
--- a/commands/hab.c
+++ b/commands/hab.c
@@ -72,6 +72,18 @@ static int do_hab(int argc, char *argv[])
 		else
 			printf("devel mode\n");
 
+#ifdef CONFIG_MMU
+		printf("Disable MMU to access HAB API!\n");
+#else
+# if defined(CONFIG_ARCH_IMX6)
+		imx6_hab_get_status();
+# elif defined(CONFIG_ARCH_IMX28)
+		imx28_hab_get_status();
+# elif defined(CONFIG_ARCH_IMX25)
+		imx25_hab_get_status();
+# endif
+#endif // CONFIG_MMU
+
 		return 0;
 	}
 
-- 
2.19.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___________________________________________________________________________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited. 

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hab: Print events on info command.
  2018-10-04  7:05 [PATCH] hab: Print events on info command Denis OSTERLAND
@ 2018-10-04 21:14 ` Andrey Smirnov
  2018-10-05  6:58 ` [PATCH v2] " Denis OSTERLAND
  1 sibling, 0 replies; 8+ messages in thread
From: Andrey Smirnov @ 2018-10-04 21:14 UTC (permalink / raw)
  To: denis.osterland; +Cc: Barebox List

On Thu, Oct 4, 2018 at 12:05 AM Denis OSTERLAND
<denis.osterland@diehl.com> wrote:
>
> From: Denis Osterland <Denis.Osterland@diehl.com>
>
> This patch calls *_hab_get_status function as part of hab info command.
> This function works only if MMU is disabled.
>
> Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
> ---
>  commands/hab.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/commands/hab.c b/commands/hab.c
> index 0d7ee8e76..9027b7cb5 100644
> --- a/commands/hab.c
> +++ b/commands/hab.c
> @@ -72,6 +72,18 @@ static int do_hab(int argc, char *argv[])
>                 else
>                         printf("devel mode\n");
>
> +#ifdef CONFIG_MMU
> +               printf("Disable MMU to access HAB API!\n");
> +#else

Minor suggestion: using IS_ENABLED() might be better since it'll make
the code visible to the compiler regardless of CONFIG_MMU, which might
help better to prevent accidental bitrot (not very likely in this
particular instance, but still).

> +# if defined(CONFIG_ARCH_IMX6)
> +               imx6_hab_get_status();
> +# elif defined(CONFIG_ARCH_IMX28)
> +               imx28_hab_get_status();
> +# elif defined(CONFIG_ARCH_IMX25)
> +               imx25_hab_get_status();
> +# endif

Should this check be done at runtime with cpu_is_*()? I'd imagine that
it would be possible to create a multi-board image that supports both
i.MX25 and and i.MX6.

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] hab: Print events on info command.
  2018-10-04  7:05 [PATCH] hab: Print events on info command Denis OSTERLAND
  2018-10-04 21:14 ` Andrey Smirnov
@ 2018-10-05  6:58 ` Denis OSTERLAND
  2018-10-10  7:51   ` Sascha Hauer
  1 sibling, 1 reply; 8+ messages in thread
From: Denis OSTERLAND @ 2018-10-05  6:58 UTC (permalink / raw)
  To: barebox; +Cc: Denis OSTERLAND

From: Denis Osterland <Denis.Osterland@diehl.com>

This patch adds hab_get_status convenience function
and uses it in hab info command.
It returns -EIO if MMU is disabled and -ENXIO if no HAB device
is available.

Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
---
v1 -> v2: use runtime if, as suggested by Andrey Smirnov,
          add hab_get_status to have hab implementation
          selection at a central place

 commands/hab.c |  3 +++
 include/hab.h  | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/commands/hab.c b/commands/hab.c
index 0d7ee8e76..af51e73fc 100644
--- a/commands/hab.c
+++ b/commands/hab.c
@@ -72,6 +72,9 @@ static int do_hab(int argc, char *argv[])
 		else
 			printf("devel mode\n");
 
+		if (hab_get_status() == -EIO)
+			printf("Disable MMU to access HAB API!\n");
+
 		return 0;
 	}
 
diff --git a/include/hab.h b/include/hab.h
index 78c2b865b..7c2ffab5e 100644
--- a/include/hab.h
+++ b/include/hab.h
@@ -19,6 +19,7 @@
 #define __HABV4_H
 
 #include <errno.h>
+#include <mach/generic.h>
 
 #ifdef CONFIG_HABV4
 int imx28_hab_get_status(void);
@@ -43,6 +44,20 @@ static inline int imx25_hab_get_status(void)
 }
 #endif
 
+static inline int hab_get_status(void)
+{
+	if (IS_ENABLED(CONFIG_MMU))
+		return -EIO;
+	else if (cpu_is_mx6())
+		return imx6_hab_get_status();
+	else if (cpu_is_mx28())
+		return imx28_hab_get_status();
+	else if (cpu_is_mx25())
+		return imx25_hab_get_status();
+	else
+		return -ENXIO;
+}
+
 #define SRK_HASH_SIZE	32
 
 /* Force writing of key, even when a key is already written */
-- 
2.19.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___________________________________________________________________________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited. 

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] hab: Print events on info command.
  2018-10-05  6:58 ` [PATCH v2] " Denis OSTERLAND
@ 2018-10-10  7:51   ` Sascha Hauer
  2018-10-10  9:29     ` Denis OSTERLAND
  2018-10-12  6:23     ` Marc Kleine-Budde
  0 siblings, 2 replies; 8+ messages in thread
From: Sascha Hauer @ 2018-10-10  7:51 UTC (permalink / raw)
  To: Denis OSTERLAND; +Cc: barebox

Hi Denis,

On Fri, Oct 05, 2018 at 06:58:04AM +0000, Denis OSTERLAND wrote:
> From: Denis Osterland <Denis.Osterland@diehl.com>
> 
> This patch adds hab_get_status convenience function
> and uses it in hab info command.
> It returns -EIO if MMU is disabled and -ENXIO if no HAB device
> is available.
> 
> Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
> ---
> v1 -> v2: use runtime if, as suggested by Andrey Smirnov,
>           add hab_get_status to have hab implementation
>           selection at a central place
> 
>  commands/hab.c |  3 +++
>  include/hab.h  | 15 +++++++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/commands/hab.c b/commands/hab.c
> index 0d7ee8e76..af51e73fc 100644
> --- a/commands/hab.c
> +++ b/commands/hab.c
> @@ -72,6 +72,9 @@ static int do_hab(int argc, char *argv[])
>  		else
>  			printf("devel mode\n");
>  
> +		if (hab_get_status() == -EIO)
> +			printf("Disable MMU to access HAB API!\n");
> +
>  		return 0;
>  	}
>  
> diff --git a/include/hab.h b/include/hab.h
> index 78c2b865b..7c2ffab5e 100644
> --- a/include/hab.h
> +++ b/include/hab.h
> @@ -19,6 +19,7 @@
>  #define __HABV4_H
>  
>  #include <errno.h>
> +#include <mach/generic.h>
>  
>  #ifdef CONFIG_HABV4
>  int imx28_hab_get_status(void);
> @@ -43,6 +44,20 @@ static inline int imx25_hab_get_status(void)
>  }
>  #endif
>  
> +static inline int hab_get_status(void)
> +{
> +	if (IS_ENABLED(CONFIG_MMU))
> +		return -EIO;

This restriction makes this patch rather unhandy to use. Internally we
use imx*_hab_get_status() indeed with MMU enabled and it works fine, but
we call it before mmu_init is called. In this state the MMU is enabled
already, but the zero page is not yet set to faulting. So I think the
problem is not the MMU as such, but instead the faulting zero page.

It would be great if we could overcome this issue. One way to do this
would be to add a function pair mmu_zero_page_map() and
mmu_zero_page_set_faulting() to be called in hab_get_status().

I don't know if you are willing to add that, but I don't want to
motivate people to disable the MMU, so the patch is not acceptable as
is.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] hab: Print events on info command.
  2018-10-10  7:51   ` Sascha Hauer
@ 2018-10-10  9:29     ` Denis OSTERLAND
  2018-10-12  6:23     ` Marc Kleine-Budde
  1 sibling, 0 replies; 8+ messages in thread
From: Denis OSTERLAND @ 2018-10-10  9:29 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

Hi Sasha,

Am Mittwoch, den 10.10.2018, 09:51 +0200 schrieb Sascha Hauer:
> >  
> > +static inline int hab_get_status(void)
> > +{
> > +	if (IS_ENABLED(CONFIG_MMU))
> > +		return -EIO;
> This restriction makes this patch rather unhandy to use. Internally we
> use imx*_hab_get_status() indeed with MMU enabled and it works fine, but
> we call it before mmu_init is called. In this state the MMU is enabled
> already, but the zero page is not yet set to faulting. So I think the
> problem is not the MMU as such, but instead the faulting zero page.
indeed
> 
> It would be great if we could overcome this issue. One way to do this
> would be to add a function pair mmu_zero_page_map() and
> mmu_zero_page_set_faulting() to be called in hab_get_status().
I will have a look, when there is a little slack in sprints.
> 
> I don't know if you are willing to add that, but I don't want to
> motivate people to disable the MMU, so the patch is not acceptable as
> is.
I got your point
> 
> Sascha
> 

Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___________________________________________________________________________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited. 
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] hab: Print events on info command.
  2018-10-10  7:51   ` Sascha Hauer
  2018-10-10  9:29     ` Denis OSTERLAND
@ 2018-10-12  6:23     ` Marc Kleine-Budde
  2018-10-15  8:41       ` Denis OSTERLAND
  1 sibling, 1 reply; 8+ messages in thread
From: Marc Kleine-Budde @ 2018-10-12  6:23 UTC (permalink / raw)
  To: Sascha Hauer, Denis OSTERLAND; +Cc: barebox


[-- Attachment #1.1.1: Type: text/plain, Size: 1409 bytes --]

On 10/10/2018 09:51 AM, Sascha Hauer wrote:
>> +static inline int hab_get_status(void)
>> +{
>> +	if (IS_ENABLED(CONFIG_MMU))
>> +		return -EIO;
> 
> This restriction makes this patch rather unhandy to use. Internally we
> use imx*_hab_get_status() indeed with MMU enabled and it works fine, but
> we call it before mmu_init is called. In this state the MMU is enabled
> already, but the zero page is not yet set to faulting. So I think the
> problem is not the MMU as such, but instead the faulting zero page.

BTW:

The faulting zero page problem doesn't occur on mx25 and mx28 as the HAB
ROM doesn't live at 0x0:

#define HABV4_RVT_IMX28 0xffff8af8

int imx25_hab_get_status(void)
{
        return imx_habv3_get_status(readl(IOMEM(0x780018d4)));
}

> It would be great if we could overcome this issue. One way to do this
> would be to add a function pair mmu_zero_page_map() and
> mmu_zero_page_set_faulting() to be called in hab_get_status().
> 
> I don't know if you are willing to add that, but I don't want to
> motivate people to disable the MMU, so the patch is not acceptable as
> is.
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] hab: Print events on info command.
  2018-10-12  6:23     ` Marc Kleine-Budde
@ 2018-10-15  8:41       ` Denis OSTERLAND
  2018-10-15  8:46         ` Marc Kleine-Budde
  0 siblings, 1 reply; 8+ messages in thread
From: Denis OSTERLAND @ 2018-10-15  8:41 UTC (permalink / raw)
  To: s.hauer, mkl; +Cc: barebox

Hi,

Am Freitag, den 12.10.2018, 08:23 +0200 schrieb Marc Kleine-Budde:
> 
> The faulting zero page problem doesn't occur on mx25 and mx28 as the HAB
> ROM doesn't live at 0x0:
> 
> #define HABV4_RVT_IMX28 0xffff8af8
> 
> int imx25_hab_get_status(void)
> {
>         return imx_habv3_get_status(readl(IOMEM(0x780018d4)));
> }
> 
> Marc
> 

Thanks for the info.
This becomes a problem when MMU is enabled again.
I think this will require explicit mapping.
I am not sure if it is possible to access the ABI through mapped addresses.
Is it possible to force mapping at exact this addresses?

Regards Denis


Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___________________________________________________________________________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited. 
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] hab: Print events on info command.
  2018-10-15  8:41       ` Denis OSTERLAND
@ 2018-10-15  8:46         ` Marc Kleine-Budde
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2018-10-15  8:46 UTC (permalink / raw)
  To: Denis OSTERLAND, s.hauer; +Cc: barebox


[-- Attachment #1.1.1: Type: text/plain, Size: 1033 bytes --]

On 10/15/2018 10:41 AM, Denis OSTERLAND wrote:
>> The faulting zero page problem doesn't occur on mx25 and mx28 as the HAB
>> ROM doesn't live at 0x0:
>>
>> #define HABV4_RVT_IMX28 0xffff8af8
>>
>> int imx25_hab_get_status(void)
>> {
>>         return imx_habv3_get_status(readl(IOMEM(0x780018d4)));
>> }
>>  
>> Marc
>>
> 
> Thanks for the info.
> This becomes a problem when MMU is enabled again.

I think we have a 1-to-1 mapping by default, modulo the zero page.

> I think this will require explicit mapping.
> I am not sure if it is possible to access the ABI through mapped addresses.

Probably not, I assume the code is not position independent.

> Is it possible to force mapping at exact this addresses?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-15  8:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-04  7:05 [PATCH] hab: Print events on info command Denis OSTERLAND
2018-10-04 21:14 ` Andrey Smirnov
2018-10-05  6:58 ` [PATCH v2] " Denis OSTERLAND
2018-10-10  7:51   ` Sascha Hauer
2018-10-10  9:29     ` Denis OSTERLAND
2018-10-12  6:23     ` Marc Kleine-Budde
2018-10-15  8:41       ` Denis OSTERLAND
2018-10-15  8:46         ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox