All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] MIPS: Align vmlinuz load address to a page boundary
@ 2018-06-10 18:20 Fredrik Noring
  2018-06-12 18:19 ` Fredrik Noring
  2018-07-02 13:11 ` Ralf Baechle
  0 siblings, 2 replies; 4+ messages in thread
From: Fredrik Noring @ 2018-06-10 18:20 UTC (permalink / raw)
  To: linux-mips; +Cc: Maciej W. Rozycki

Hi,

The kexec system call seems to require that the vmlinuz loading address is
aligned to a page boundary. 4096 bytes is a fairly common page size, but
perhaps not the only possibility? Does kexec require additional alignments?

Fredrik

Signed-off-by: Fredrik Noring <noring@nocrew.org>

--- a/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
+++ b/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
@@ -44,12 +44,8 @@ int main(int argc, char *argv[])
 	vmlinux_size = (uint64_t)sb.st_size;
 	vmlinuz_load_addr = vmlinux_load_addr + vmlinux_size;
 
-	/*
-	 * Align with 16 bytes: "greater than that used for any standard data
-	 * types by a MIPS compiler." -- See MIPS Run Linux (Second Edition).
-	 */
-
-	vmlinuz_load_addr += (16 - vmlinux_size % 16);
+	/* The kexec system call requires page alignment. */
+	vmlinuz_load_addr += (4096 - vmlinux_size % 4096);
 
 	printf("0x%llx\n", vmlinuz_load_addr);
 

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

* Re: [RFC] MIPS: Align vmlinuz load address to a page boundary
  2018-06-10 18:20 [RFC] MIPS: Align vmlinuz load address to a page boundary Fredrik Noring
@ 2018-06-12 18:19 ` Fredrik Noring
  2018-07-02 13:11 ` Ralf Baechle
  1 sibling, 0 replies; 4+ messages in thread
From: Fredrik Noring @ 2018-06-12 18:19 UTC (permalink / raw)
  To: linux-mips; +Cc: Maciej W. Rozycki

> The kexec system call seems to require that the vmlinuz loading address is
> aligned to a page boundary. 4096 bytes is a fairly common page size, but
> perhaps not the only possibility? Does kexec require additional alignments?

Sorry for the brief description. The problem, more specifically, is
reported by kexec-tools/kexec/kexec.c:343:

	/* Verify base is pagesize aligned.
	 * Finding a way to cope with this problem
	 * is important but for now error so at least
	 * we are not surprised by the code doing the wrong
	 * thing.
	 */
	if (base & (pagesize -1)) {
		die("Base address: 0x%lx is not page aligned\n", base);
	}

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/tree/kexec/kexec.c?id=HEAD#n343

A more pressing issue at the moment though is that initramfs in vmlinuz is
ignored when booting. Is it supposed to work with a MIPS kernel?

Fredrik

> --- a/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
> +++ b/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
> @@ -44,12 +44,8 @@ int main(int argc, char *argv[])
>  	vmlinux_size = (uint64_t)sb.st_size;
>  	vmlinuz_load_addr = vmlinux_load_addr + vmlinux_size;
>  
> -	/*
> -	 * Align with 16 bytes: "greater than that used for any standard data
> -	 * types by a MIPS compiler." -- See MIPS Run Linux (Second Edition).
> -	 */
> -
> -	vmlinuz_load_addr += (16 - vmlinux_size % 16);
> +	/* The kexec system call requires page alignment. */
> +	vmlinuz_load_addr += (4096 - vmlinux_size % 4096);
>  
>  	printf("0x%llx\n", vmlinuz_load_addr);
>  

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

* Re: [RFC] MIPS: Align vmlinuz load address to a page boundary
  2018-06-10 18:20 [RFC] MIPS: Align vmlinuz load address to a page boundary Fredrik Noring
  2018-06-12 18:19 ` Fredrik Noring
@ 2018-07-02 13:11 ` Ralf Baechle
  2018-07-02 18:24   ` Fredrik Noring
  1 sibling, 1 reply; 4+ messages in thread
From: Ralf Baechle @ 2018-07-02 13:11 UTC (permalink / raw)
  To: Fredrik Noring; +Cc: linux-mips, Maciej W. Rozycki

On Sun, Jun 10, 2018 at 08:20:58PM +0200, Fredrik Noring wrote:

> The kexec system call seems to require that the vmlinuz loading address is
> aligned to a page boundary. 4096 bytes is a fairly common page size, but
> perhaps not the only possibility? Does kexec require additional alignments?

Basically MIPS supports page sizes 4k, 8k, 16k, 32k, 64k.  Not every system
supports all page sizes.  4k is the safe bet while larger systems prefer 16k
or 64k.  Details are complicated.

And of course with kexec the kexecing and the kexecuted kernels do not even
have to have the same page size.  It would appear that the userland code you
were refering to in your 2nd email in

  https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/tree/kexec/kexec.c?id=HEAD#n343

might erroneously fail if pagesize on the kexecing kernel is larger than of
the kernel being kexed.

  Ralf

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

* Re: [RFC] MIPS: Align vmlinuz load address to a page boundary
  2018-07-02 13:11 ` Ralf Baechle
@ 2018-07-02 18:24   ` Fredrik Noring
  0 siblings, 0 replies; 4+ messages in thread
From: Fredrik Noring @ 2018-07-02 18:24 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, Maciej W. Rozycki

Hi Ralf,

On Mon, Jul 02, 2018 at 03:11:58PM +0200, Ralf Baechle wrote:
> Basically MIPS supports page sizes 4k, 8k, 16k, 32k, 64k.  Not every system
> supports all page sizes.  4k is the safe bet while larger systems prefer 16k
> or 64k.  Details are complicated.
> 
> And of course with kexec the kexecing and the kexecuted kernels do not even
> have to have the same page size.  It would appear that the userland code you
> were refering to in your 2nd email in
> 
>   https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/tree/kexec/kexec.c?id=HEAD#n343
> 
> might erroneously fail if pagesize on the kexecing kernel is larger than of
> the kernel being kexed.

The comment in kexec.c suggests that it might be possible to find a way to
"cope with this problem". What could that mean? It came with the initial
commit, so the log is unfortunately not informative.

If we align vmlinuz to 64 KiB then it will work on all systems, I suppose.
Would there be drawbacks? Can the kernel make use of all memory regardless
of its base address, for example?

Fredrik

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

end of thread, other threads:[~2018-07-02 18:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-10 18:20 [RFC] MIPS: Align vmlinuz load address to a page boundary Fredrik Noring
2018-06-12 18:19 ` Fredrik Noring
2018-07-02 13:11 ` Ralf Baechle
2018-07-02 18:24   ` Fredrik Noring

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.