xen/arm: ioremap_attr: return NULL is __vmap failed
PATCH 1/1 xen/arm: ioremap_attr: return NULL is __vmap failed
Most of ioremap_* caller check if ioremap returns NULL. Actually, if the physical address is non-aligned, Xen will return the pointer given by __vmap plus the offset in the page. So if ioremap_* fails, the caller will retrieve an non-NULL address and continue as if there was no error.
--- xen/arch/arm/mm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
xen/arch/arm/mm.c +6 -1
@@ -742,8 +742,13 @@ void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes)unsigned long pfn =PFN_DOWN (pa);unsigned int offs = pa & (PAGE_SIZE -1 );unsigned int nr =PFN_UP (offs + len); +void *ptr; -return (__vmap (&pfn, nr,1 ,1 , attributes) + offs); + ptr =__vmap (&pfn, nr,1 ,1 , attributes); +if ( ptr ==NULL ) +return NULL ; + +return (ptr + offs); }void *ioremap (paddr_t pa,size_t len)
Signature · 1 line
1.8.3.1
PATCH 1/1 xen/arm: Panic if platform initialization failed
Actually, if an error occurs, Xen will silently ignore it and continue. Convert platform_init to a void function and panic if we fail to correctly initialize the platform.
--- xen/arch/arm/platform.c | 5 +++-- xen/include/asm-arm/platform.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
xen/arch/arm/platform.c +3 -2
@@ -54,7 +54,7 @@ static void dump_platform_table(void)printk (" - %s\n" , p->name); } -int __init platform_init (void ) +void __init platform_init (void ) {int res =0 ;
@@ -82,7 +82,8 @@ int __init platform_init(void)if ( platform && platform->init ) res = platform->init (); -return res; +if ( res ) +panic ("Unable to initialize the platform\n" ); }int __init platform_init_time (void )
xen/include/asm-arm/platform.h +1 -1
@@ -45,7 +45,7 @@ struct platform_desc {*/ #define PLATFORM_QUIRK_DOM0_MAPPING_11 (1 << 0) -int __init platform_init (void ); +void __init platform_init (void );int __init platform_init_time (void );int __init platform_specific_mapping (struct domain *d);#ifdef CONFIG_ARM_32
Signature · 1 line
1.8.3.1
Re: [PATCH] xen/arm: Panic if platform initialization failed
Quoted 5 lines · Julien Grall
Actually, if an error occurs, Xen will silently ignore it and continue. Convert
platform_initto a void function and panic if we fail to correctly initialize the platform.Signed-off-by Julien Grall <[email protected]>
Quoted 43 lines
xen/arch/arm/platform.c | 5 +++-- xen/include/asm-arm/platform.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)xen/arch/arm/platform.c +3
-2@@ -54,7 +54,7 @@ static void dump_platform_table(void)printk (" - %s\n" , p->name); } -int __init platform_init (void ) +void __init platform_init (void ) {int res =0 ;@@ -82,7 +82,8 @@ int __init platform_init(void)if ( platform && platform->init ) res = platform->init (); -return res; +if ( res ) +panic ("Unable to initialize the platform\n" ); }int __init platform_init_time (void )xen/include/asm-arm/platform.h +1
-1@@ -45,7 +45,7 @@ struct platform_desc {*/ #define PLATFORM_QUIRK_DOM0_MAPPING_11 (1 << 0) -int __init platform_init (void ); +void __init platform_init (void );int __init platform_init_time (void );int __init platform_specific_mapping (struct domain *d);#ifdef CONFIG_ARM_32 Signature · 1 line
1.8.3.1
Ian Campbell
Acked-byRe: [PATCH] xen/arm: Panic if platform initialization failed
Quoted 8 lines · Stefano Stabellini
Quoted 5 lines · Julien Grall
Actually, if an error occurs, Xen will silently ignore it and continue. Convert
platform_initto a void function and panic if we fail to correctly initialize the platform.Signed-off-by Julien Grall <[email protected]>
/insert similar wanderings about pushing the panic down the stack.
PATCH 1/1 xen/arm: Panic if we are unable to initialize platform timer
In reply to Julien GrallThe caller of xen_init_time, start_xen, doesn't check the return value of the function. Xen will silently ignore the error and continue.
--- xen/arch/arm/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/time.c +1 -1
@@ -132,7 +132,7 @@ int __init init_xen_time(void) res =platform_init_time ();if ( res ) -return res; +panic ("Timer: Cannot initialize platform timer\n" );/* Check that this CPU supports the Generic Timer interface */ if ( !cpu_has_gentimer )
Signature · 1 line
1.8.3.1
Re: [PATCH] xen/arm: Panic if we are unable to initialize platform timer
Quoted 4 lines · Julien Grall
The caller of
xen_init_time,start_xen, doesn't check the return value of the function. Xen will silently ignore the error and continue.Signed-off-by Julien Grall <[email protected]>
Quoted 19 lines
xen/arch/arm/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/time.c +1
-1@@ -132,7 +132,7 @@ int __init init_xen_time(void) res =platform_init_time ();if ( res ) -return res; +panic ("Timer: Cannot initialize platform timer\n" );/* Check that this CPU supports the Generic Timer interface */ if ( !cpu_has_gentimer )Signature · 1 line
1.8.3.1
Ian Campbell
Acked-byRe: [PATCH] xen/arm: Panic if we are unable to initialize platform timer
Quoted 7 lines · Stefano Stabellini
Quoted 4 lines · Julien Grall
The caller of
xen_init_time,start_xen, doesn't check the return value of the function. Xen will silently ignore the error and continue.Signed-off-by Julien Grall <[email protected]>
I did wonder if it might be worth pushing the panic down into platform_time_init, so that the message could be more specific. But that seems like it relies on platform code to be more aware of when to panic and to use consistent wording etc. So all in all I think it is better here.
Quoted 21 lines
Quoted 21 lines
xen/arch/arm/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/time.c +1
-1@@ -132,7 +132,7 @@ int __init init_xen_time(void) res =platform_init_time ();if ( res ) -return res; +panic ("Timer: Cannot initialize platform timer\n" );/* Check that this CPU supports the Generic Timer interface */ if ( !cpu_has_gentimer )Signature · 1 line
1.8.3.1
Re: [PATCH] xen/arm: Panic if we are unable to initialize platform timer
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Stefano Stabellini
Quoted 4 lines · Julien Grall
The caller of
xen_init_time,start_xen, doesn't check the return value of the function. Xen will silently ignore the error and continue.Signed-off-by Julien Grall <[email protected]>
Quoted 7 lines
Acked-by Ian Campbell <[email protected]>I did wonder if it might be worth pushing the panic down into
platform_time_init, so that the message could be more specific. But that seems like it relies on platform code to be more aware of when to panic and to use consistent wording etc. So all in all I think it is better here.
I thought about this solution. I didn't find good argument for one of these solutions. So, by default, I choose to panic in init_xen_time.
Signature · 1 line
Julien Grall
Quoted 15 lines · Julien Grall
Most of ioremap_* caller check if ioremap returns NULL. Actually, if the physical address is non-aligned, Xen will return the pointer given by
__vmapplus the offset in the page. So if ioremap_* fails, the caller will retrieve an non-NULL address and continue as if there was no error.Signed-off-by Julien Grall <[email protected]>--- xen/arch/arm/mm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)xen/arch/arm/mm.c +0
-0
xen/arch/arm/mm.c void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes) · line 747
Quoted 7 lines
xen/arch/arm/mm.c +2
-1@@ -742,8 +742,13 @@ void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes)unsigned long pfn =PFN_DOWN (pa);unsigned int offs = pa & (PAGE_SIZE -1 );unsigned int nr =PFN_UP (offs + len); +void *ptr; -return (__vmap (&pfn, nr,1 ,1 , attributes) + offs); + ptr =__vmap (&pfn, nr,1 ,1 , attributes);
No need to split the declaration of void *ptr and its initialisation.
~Andrew
Quoted 7 lines
xen/arch/arm/mm.c +4
-0+if ( ptr ==NULL ) +return NULL ; + +return (ptr + offs); }void *ioremap (paddr_t pa,size_t len)
Quoted 16 lines · Julien Grall
Most of ioremap_* caller check if ioremap returns NULL. Actually, if the physical address is non-aligned, Xen will return the pointer given by
__vmapplus the offset in the page. So if ioremap_* fails, the caller will retrieve an non-NULL address and continue as if there was no error.Signed-off-by Julien Grall <[email protected]>--- xen/arch/arm/mm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)xen/arch/arm/mm.c +0
-0@@ -742,8 +742,13 @@ void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes)unsigned long pfn =PFN_DOWN (pa);
xen/arch/arm/mm.c void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes) · line 751
Quoted 10 lines
xen/arch/arm/mm.c +6
-1unsigned int offs = pa & (PAGE_SIZE -1 );unsigned int nr =PFN_UP (offs + len); +void *ptr; -return (__vmap (&pfn, nr,1 ,1 , attributes) + offs); + ptr =__vmap (&pfn, nr,1 ,1 , attributes); +if ( ptr ==NULL ) +return NULL ; + +return (ptr + offs);
No need for brackets here.
In any case