Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MYdZj-0004mr-QH for mharc-grub-devel@gnu.org; Wed, 05 Aug 2009 06:18:27 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MYdZg-0004jP-Np for grub-devel@gnu.org; Wed, 05 Aug 2009 06:18:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MYdZb-0004dZ-RQ for grub-devel@gnu.org; Wed, 05 Aug 2009 06:18:24 -0400 Received: from [199.232.76.173] (port=41486 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MYdZb-0004dA-E9 for grub-devel@gnu.org; Wed, 05 Aug 2009 06:18:19 -0400 Received: from mail-fx0-f205.google.com ([209.85.220.205]:51684) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MYdZa-0002IY-UZ for grub-devel@gnu.org; Wed, 05 Aug 2009 06:18:19 -0400 Received: by fxm1 with SMTP id 1so4629619fxm.31 for ; Wed, 05 Aug 2009 03:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=HhbJRpqkst6ObS4LzQpY6Fm64r1a1m0USmwng0tI25k=; b=v+IZ1wSkJbzqSi7Trau58RvTsWDHU7MkN4X/MtHI/9axD8Wat/OTaaLimqvPxNM4Xc X6gqHZMcvSfuSaC+mUr0X9OO9blk+7pMltneFvACRrhzGZOGsyiBK03vveMdoSOPSuTz NPNcjP2uDZUnWBOHytKI5/wr38JlcQaQV9Xd0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=rEBjh4ya9DcxvEPaGJjb6lf20yPursxcApjgsVg2xNy5Wvo/nfzEV17JKlZgi2SvWO DmabnsaqpWh1hxLFQByELxmxhlQKy/aKYkdRBvu+hVhBvRuHshEDTVuwGK43qV2SYbm8 n0i3BQTqDTkL56XvZ/t/tLmYh/KpgjhfYa81Y= MIME-Version: 1.0 Received: by 10.204.71.82 with SMTP id g18mr740773bkj.120.1249467497999; Wed, 05 Aug 2009 03:18:17 -0700 (PDT) In-Reply-To: <20090804205256.GE15811@thorin> References: <20090804205256.GE15811@thorin> Date: Wed, 5 Aug 2009 12:18:17 +0200 Message-ID: From: "Vladimir 'phcoder' Serbinenko" To: The development of GRUB 2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH 1/2] Relocator framework X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Aug 2009 10:18:25 -0000 >> +#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 :-)). grub_addr_t would actually do the job. > >> +#ifndef __x86_64__ >> + =A0 =A0 /* mov imm32, %eax */ >> + =A0 =A0 .byte =A0 0xb8 >> +RELOCATOR_VARIABLE(dest) >> + =A0 =A0 .long 0 >> + =A0 =A0 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). > Ok >> + =A0 =A0 /* Backward movsl is implicitly off-by-four. =A0compensate tha= t. =A0*/ >> + =A0 =A0 subl =A0 =A0$4, =A0 =A0 %esi >> + =A0 =A0 subl =A0 =A0$4, =A0 =A0 %edi >> + >> + =A0 =A0 /* Backward copy. =A0*/ >> + =A0 =A0 std >> + =A0 =A0 addl =A0 =A0%ecx, %esi >> + =A0 =A0 addl =A0 =A0%ecx, %edi >> + >> + =A0 =A0 rep >> + =A0 =A0 movsl > > Are you sure moving to movsl is a good idea? =A0Maybe the payload size is= not > 4-aligned. > On AFAIK x86 movsl works on unaligned addresses too. I'll recheck >> +#ifdef APPLE_CC >> + =A0 =A0 add $(cont0 - base), %eax >> +#else >> + =A0 =A0 add $(cont0 - base), %rax >> +#endif > > What's the issue at hand? =A0Apple assembler [1] can't add an inmediate t= o > %rax ? > Apple linker can't handle 64-bit differences > Truncating it seems like it could be problematic if %eax overflows. > Actually it's not a problem since this code is put together with kernel which executes in 32-bit mode so it can't be over 4GiB. If we base 64-bit relocator it will be a problem if OS wants to go over 4GiB. > [1] btw, APPLE_CC macro for assembler checks is really confusing > I'll try with __apple__ > Please use macros for such things (see GRUB_MEMORY_MACHINE_CR0_PE_ON). Will look into it > > -- > Robert Millan > > =A0The DRM opt-in fallacy: "Your data belongs to us. We will decide when = (and > =A0how) you may access your data; but nobody's threatening your freedom: = we > =A0still allow you to remove your data and not access it at all." > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > --=20 Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git