Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aUcfk-0004WP-Ib for mharc-grub-devel@gnu.org; Sat, 13 Feb 2016 11:03:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUcfh-0004Uu-J8 for grub-devel@gnu.org; Sat, 13 Feb 2016 11:03:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUcfd-0000JU-D7 for grub-devel@gnu.org; Sat, 13 Feb 2016 11:03:45 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:17501) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUcfd-0000JJ-6i for grub-devel@gnu.org; Sat, 13 Feb 2016 11:03:41 -0500 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1DG3dpF005062 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 13 Feb 2016 16:03:39 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u1DG3dEv015329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 13 Feb 2016 16:03:39 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u1DG3ccq003231; Sat, 13 Feb 2016 16:03:38 GMT Received: from dhcp-amer-vpn-rmdc-anyconnect-10-159-96-157.vpn.oracle.com (/10.159.96.157) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Feb 2016 08:03:38 -0800 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: [PATCH] sparc64: OBP available region contains grub. Start at grub_phys_end From: Eric Snowberg In-Reply-To: <56BEBF61.8040205@gmail.com> Date: Sat, 13 Feb 2016 09:03:45 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <828E6F6D-D06F-4611-9F49-C51403B862AC@oracle.com> References: <1455312923-166743-1-git-send-email-eric.snowberg@oracle.com> <56BEBF61.8040205@gmail.com> To: Andrei Borzenkov X-Mailer: Apple Mail (2.2104) X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 Cc: The development of GNU GRUB , daniel.kiper@oracle.com X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Feb 2016 16:03:46 -0000 > On Feb 12, 2016, at 10:30 PM, Andrei Borzenkov = wrote: >=20 > 13.02.2016 00:35, Eric Snowberg =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> OBP available region contains grub. Start at grub_phys_end. >>=20 >> This prevents a problem where grub was being overwritten since >> grub_phys_start does not start at a zero offset within the memory >> map. >>=20 >> Signed-off-by: Eric Snowberg >> --- >> grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- >> 1 files changed, 8 insertions(+), 8 deletions(-) >>=20 >> diff --git a/grub-core/loader/sparc64/ieee1275/linux.c = b/grub-core/loader/sparc64/ieee1275/linux.c >> index d44d7a1..67ef048 100644 >> --- a/grub-core/loader/sparc64/ieee1275/linux.c >> +++ b/grub-core/loader/sparc64/ieee1275/linux.c >> @@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, = grub_uint64_t len, >> if (addr + ctx->size >=3D end) >> return 0; >>=20 >> - if (addr >=3D grub_phys_start && addr < grub_phys_end) >> - { >> - addr =3D ALIGN_UP (grub_phys_end, FOUR_MB); >> - if (addr + ctx->size >=3D end) >> - return 0; >> - } >> - if ((addr + ctx->size) >=3D grub_phys_start >> - && (addr + ctx->size) < grub_phys_end) >> + /* OBP available region contains grub. Start at grub_phys_end. */ >> + /* grub_phys_start does not start at the beginning of the memory = region */ >> + if ((grub_phys_start >=3D addr && grub_phys_end < end) || >> + (addr > grub_phys_start && addr < grub_phys_end)) >=20 > What about >=20 > a) overlapping regions? >=20 > addr < grub_phys_start < end < grub_phys_end >=20 > b) is is possible for requested region to fit before grub? >=20 > addr < end < grub_phys_start >=20 On SPARC, there is always an 8k offset from the beginning of memory to = grub_phys_start. I had intentionally skipped this memory for the 2 cases = above. >> { >> addr =3D ALIGN_UP (grub_phys_end, FOUR_MB); >> if (addr + ctx->size >=3D end) >> return 0; >> } >>=20 >> + grub_dprintf("loader", >> + "addr =3D 0x%lx grub_phys_start =3D 0x%lx grub_phys_end =3D = 0x%lx\n", >> + addr, grub_phys_start, grub_phys_end); >> + >> if (loaded) >> { >> grub_addr_t linux_end =3D ALIGN_UP (linux_paddr + linux_size, = FOUR_MB);