mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] MIPS: generic: Fix KASLR for generic kernel.
@ 2016-10-17 10:05 Matt Redfearn
  2016-10-17 10:22 ` James Hogan
  2016-10-17 15:24 ` Paul Burton
  0 siblings, 2 replies; 3+ messages in thread
From: Matt Redfearn @ 2016-10-17 10:05 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, Matt Redfearn, linux-kernel, Paul Burton

The KASLR code requires that the plat_get_fdt() function return the
address of the device tree, and it must be available early in the boot,
before prom_init() is called. Move the code determining the address of
the device tree into plat_get_fdt, and call that from prom_init().

The fdt pointer will be set up by plat_get_fdt() called from
relocate_kernel initially and once the relocated kernel has started,
prom_init() will use it again to determine the address in the relocated
image.

Fixes: eed0eabd12ef
Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---

 arch/mips/generic/init.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/mips/generic/init.c b/arch/mips/generic/init.c
index 0ea73e845440..d493ccbf274a 100644
--- a/arch/mips/generic/init.c
+++ b/arch/mips/generic/init.c
@@ -30,9 +30,19 @@ static __initdata const void *mach_match_data;
 
 void __init prom_init(void)
 {
+	plat_get_fdt();
+	BUG_ON(!fdt);
+}
+
+void __init *plat_get_fdt(void)
+{
 	const struct mips_machine *check_mach;
 	const struct of_device_id *match;
 
+	if (fdt)
+		/* Already set up */
+		return (void *)fdt;
+
 	if ((fw_arg0 == -2) && !fdt_check_header((void *)fw_arg1)) {
 		/*
 		 * We booted using the UHI boot protocol, so we have been
@@ -75,12 +85,6 @@ void __init prom_init(void)
 		/* Retrieve the machine's FDT */
 		fdt = mach->fdt;
 	}
-
-	BUG_ON(!fdt);
-}
-
-void __init *plat_get_fdt(void)
-{
 	return (void *)fdt;
 }
 
-- 
2.7.4

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

* Re: [PATCH] MIPS: generic: Fix KASLR for generic kernel.
  2016-10-17 10:05 [PATCH] MIPS: generic: Fix KASLR for generic kernel Matt Redfearn
@ 2016-10-17 10:22 ` James Hogan
  2016-10-17 15:24 ` Paul Burton
  1 sibling, 0 replies; 3+ messages in thread
From: James Hogan @ 2016-10-17 10:22 UTC (permalink / raw)
  To: Matt Redfearn; +Cc: Ralf Baechle, linux-mips, linux-kernel, Paul Burton

[-- Attachment #1: Type: text/plain, Size: 1961 bytes --]

Hi Matt,

On Mon, Oct 17, 2016 at 11:05:09AM +0100, Matt Redfearn wrote:
> The KASLR code requires that the plat_get_fdt() function return the
> address of the device tree, and it must be available early in the boot,
> before prom_init() is called. Move the code determining the address of
> the device tree into plat_get_fdt, and call that from prom_init().
> 
> The fdt pointer will be set up by plat_get_fdt() called from
> relocate_kernel initially and once the relocated kernel has started,
> prom_init() will use it again to determine the address in the relocated
> image.
> 
> Fixes: eed0eabd12ef

I believe this is the preferred form:

Fixes: eed0eabd12ef ("MIPS: generic: Introduce generic DT-based board support")

Otherwise looks good to me

Reviewed-by: James Hogan <james.hogan@imgtec.com>

Cheers
James

> Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
> ---
> 
>  arch/mips/generic/init.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/mips/generic/init.c b/arch/mips/generic/init.c
> index 0ea73e845440..d493ccbf274a 100644
> --- a/arch/mips/generic/init.c
> +++ b/arch/mips/generic/init.c
> @@ -30,9 +30,19 @@ static __initdata const void *mach_match_data;
>  
>  void __init prom_init(void)
>  {
> +	plat_get_fdt();
> +	BUG_ON(!fdt);
> +}
> +
> +void __init *plat_get_fdt(void)
> +{
>  	const struct mips_machine *check_mach;
>  	const struct of_device_id *match;
>  
> +	if (fdt)
> +		/* Already set up */
> +		return (void *)fdt;
> +
>  	if ((fw_arg0 == -2) && !fdt_check_header((void *)fw_arg1)) {
>  		/*
>  		 * We booted using the UHI boot protocol, so we have been
> @@ -75,12 +85,6 @@ void __init prom_init(void)
>  		/* Retrieve the machine's FDT */
>  		fdt = mach->fdt;
>  	}
> -
> -	BUG_ON(!fdt);
> -}
> -
> -void __init *plat_get_fdt(void)
> -{
>  	return (void *)fdt;
>  }
>  
> -- 
> 2.7.4
> 
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH] MIPS: generic: Fix KASLR for generic kernel.
  2016-10-17 10:05 [PATCH] MIPS: generic: Fix KASLR for generic kernel Matt Redfearn
  2016-10-17 10:22 ` James Hogan
@ 2016-10-17 15:24 ` Paul Burton
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Burton @ 2016-10-17 15:24 UTC (permalink / raw)
  To: Matt Redfearn; +Cc: Ralf Baechle, linux-mips, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]

On Monday, 17 October 2016 11:05:09 BST Matt Redfearn wrote:
> The KASLR code requires that the plat_get_fdt() function return the
> address of the device tree, and it must be available early in the boot,
> before prom_init() is called. Move the code determining the address of
> the device tree into plat_get_fdt, and call that from prom_init().
> 
> The fdt pointer will be set up by plat_get_fdt() called from
> relocate_kernel initially and once the relocated kernel has started,
> prom_init() will use it again to determine the address in the relocated
> image.
> 
> Fixes: eed0eabd12ef
> Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
> ---
> 
>  arch/mips/generic/init.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/mips/generic/init.c b/arch/mips/generic/init.c
> index 0ea73e845440..d493ccbf274a 100644
> --- a/arch/mips/generic/init.c
> +++ b/arch/mips/generic/init.c
> @@ -30,9 +30,19 @@ static __initdata const void *mach_match_data;
> 
>  void __init prom_init(void)
>  {
> +	plat_get_fdt();
> +	BUG_ON(!fdt);
> +}
> +
> +void __init *plat_get_fdt(void)
> +{
>  	const struct mips_machine *check_mach;
>  	const struct of_device_id *match;
> 
> +	if (fdt)
> +		/* Already set up */
> +		return (void *)fdt;
> +
>  	if ((fw_arg0 == -2) && !fdt_check_header((void *)fw_arg1)) {
>  		/*
>  		 * We booted using the UHI boot protocol, so we have been
> @@ -75,12 +85,6 @@ void __init prom_init(void)
>  		/* Retrieve the machine's FDT */
>  		fdt = mach->fdt;
>  	}
> -
> -	BUG_ON(!fdt);
> -}
> -
> -void __init *plat_get_fdt(void)
> -{
>  	return (void *)fdt;
>  }

Hi Matt,

Apart from the Fixes tag niggle James mentioned (which checkpatch ought to 
pick up on):

    Reviewed-by: Paul Burton <paul.burton@imgtec.com>

Thanks,
    Paul

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

end of thread, other threads:[~2016-10-17 15:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17 10:05 [PATCH] MIPS: generic: Fix KASLR for generic kernel Matt Redfearn
2016-10-17 10:22 ` James Hogan
2016-10-17 15:24 ` Paul Burton

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

all inboxes | Powered by JetHome®