All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH 1/2] Relocator framework
Date: Tue, 4 Aug 2009 22:52:56 +0200	[thread overview]
Message-ID: <20090804205256.GE15811@thorin> (raw)
In-Reply-To: <d7ead6de0908030506w147fc337y9352cb57cea301d2@mail.gmail.com>

On Mon, Aug 03, 2009 at 02:06:03PM +0200, Vladimir 'phcoder' Serbinenko wrote:
> Hello. As discussed on IRC it would be preferable if all loaders use
> flexible technics for loading kernels using relocators as currently
> multiboot and xnu does.

Well, as for what I said on IRC, I'm not sure if it'd be preferable.  I
think it *could* be, if it makes things simpler & more maintainable (which
greatly depends on how the patches for multiboot.c/linux.c look like).

Anyway, I'll comment some things on this patch:

> +#ifdef __x86_64__
> +extern grub_uint64_t grub_relocator32_backward_src;
> +#else
> +extern grub_uint32_t grub_relocator32_backward_src;
> +#endif

You could make this a pointer, or grub_uintptr_t
(the latter we don't yet have, it seems like a good excuse to
add it if a pointer is not suitable :-)).

> +#ifndef __x86_64__
> +	/* mov imm32, %eax */
> +	.byte	0xb8
> +RELOCATOR_VARIABLE(dest)
> +	.long 0
> +	mov %eax, %edi

Please use size qualifiers (e.g. movl).

Also, remember to indent the first parameter like we do elsewhere
(e.g. ".long\t0", "movl\t%eax, %edi", etc).

> +	/* Backward movsl is implicitly off-by-four.  compensate that.  */
> +	subl	$4,	%esi
> +	subl	$4,	%edi
> +
> +	/* Backward copy.  */
> +	std
> +	addl	%ecx, %esi
> +	addl	%ecx, %edi
> +
> +	rep
> +	movsl

Are you sure moving to movsl is a good idea?  Maybe the payload size is not
4-aligned.

> +#ifdef APPLE_CC
> +	add $(cont0 - base), %eax
> +#else
> +	add $(cont0 - base), %rax
> +#endif

What's the issue at hand?  Apple assembler [1] can't add an inmediate to
%rax ?

Truncating it seems like it could be problematic if %eax overflows.

[1] btw, APPLE_CC macro for assembler checks is really confusing

> +	/* Update %cs. Thanks to David Miller for pointing this mistake out. */
> +	ljmp *(jump_vector - base) (%esi,1)

Comments ought to be for useful information.  For praise/acknoledgements (and I
think David deserves it) we have the THANKS file.

> +	/* Disable paging. */
> +	mov %cr0, %eax
> +	and $0x7fffffff, %eax
> +	mov %eax, %cr0
> +
> +	/* Disable amd64. */
> +	mov $0xc0000080, %ecx
> +	rdmsr
> +	and $0xfffffeff, %eax
> +	wrmsr
> +
> +	/* Turn off PAE. */
> +	movl %cr4, %eax
> +	and $0xffffffcf, %eax
> +	mov %eax, %cr4

Please use macros for such things (see GRUB_MEMORY_MACHINE_CR0_PE_ON).

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



  parent reply	other threads:[~2009-08-04 20:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-03 12:06 [PATCH 1/2] Relocator framework Vladimir 'phcoder' Serbinenko
2009-08-03 12:39 ` Vladimir 'phcoder' Serbinenko
2009-08-04 20:52 ` Robert Millan [this message]
2009-08-05 10:18   ` Vladimir 'phcoder' Serbinenko
2009-08-07 11:06     ` Robert Millan
2009-08-07 11:16       ` Marco Gerards
2009-08-07 12:01         ` Vladimir 'phcoder' Serbinenko
2009-08-08  3:52           ` Pavel Roskin
2009-08-08 13:11             ` Vladimir 'phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090804205256.GE15811@thorin \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.