From owner-freebsd-arm@freebsd.org Fri Dec 30 01:25:41 2016 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C466DC9762D for ; Fri, 30 Dec 2016 01:25:41 +0000 (UTC) (envelope-from gonzo@id.bluezbox.com) Received: from id.bluezbox.com (id.bluezbox.com [45.55.20.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 954F51F87 for ; Fri, 30 Dec 2016 01:25:41 +0000 (UTC) (envelope-from gonzo@id.bluezbox.com) Received: from [136.179.10.143] (helo=[10.140.230.85]) by id.bluezbox.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87 (FreeBSD)) (envelope-from ) id 1cMlwr-0005DZ-Sf; Thu, 29 Dec 2016 17:25:35 -0800 From: Oleksandr Tymoshenko Message-Id: <58C0D791-3D3C-4DE2-9EAF-93DA40ED620D@bluezbox.com> Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: loading 'VIRT' kernel in qemu Date: Thu, 29 Dec 2016 17:25:02 -0800 In-Reply-To: Cc: freebsd-arm@freebsd.org To: Jason Harmening References: X-Mailer: Apple Mail (2.3259) Sender: gonzo@id.bluezbox.com X-Spam-Level: -- X-Spam-Report: Spam detection software, running on the system "id.bluezbox.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see The administrator of that system for details. Content preview: > On Dec 29, 2016, at 5:12 AM, Jason Harmening wrote: > > On Wed, Dec 28, 2016 at 11:25 AM, Oleksandr Tymoshenko > wrote: > >> On Dec 27, 2016, at 1:48 PM, Jason Harmening > wrote: >> >> Hi everyone, >> >> I'm making some tweaks to the armv6 pmap to mirror some recent i386 >> changes. I don't have arm hardware readily available, so I thought I'd >> give qemu a whirl instead of asking other people to test my changes for >> me. Since I need SMP but don't need any specific peripheral hw, the 'VIRT' >> kernel seems like my best bet. >> >> I've successfully booted mips[64] under qemu, so naively starting out w/ >> the same steps I use for mips: >> >> 1). build armv6 world and VIRT kernel, install world to temp directory >> 2). use makefs(8) to build a 4GB (little endian) fs image from temp dir >> 3). Run qemu: >> qemu-system-arm -M virt -kernel -hda >> -nographic -m 1024 >> >> ...fails immediately: >> qemu: fatal: Trying to execute code outside RAM or ROM at 0xc1000100 >> >> R00=00000000 R01=00000000 R02=00000000 R03=00000000 >> R04=00000000 R05=00000000 R06=00000000 R07=00000000 >> R08=00000000 R09=00000000 R10=00000000 R11=00000000 >> R12=00000000 R13=00000000 R14=00000000 R15=c1000100 >> >> hmm, looks pretty close to KERNVIRTADDR. >> >> Most online docs for qemu-system-arm seem to assume a prebuilt linux kernel >> and initrd, the rest are...fragmented-to-nonexistent. I've seen a few >> hints that I might need to wrap the kernel image up along w/ u-boot, but >> the u-boot images seem to be very SoC-specific. >> >> Any help would be much appreciated, sorry for the n00b question. > > Hi Jason, > > It looks like for VIRT kernel is supposed to be used with UEFI. At least > this part of NanoBSD sources hints at it: > http://sources.freebsd.org/HEAD/src/tools/tools/nanobsd/embedded/qemu-armv7.cfg [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: bluezbox.com] 0.0 HTML_MESSAGE BODY: HTML included in message -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Dec 2016 01:25:41 -0000 > On Dec 29, 2016, at 5:12 AM, Jason Harmening = wrote: >=20 > On Wed, Dec 28, 2016 at 11:25 AM, Oleksandr Tymoshenko = > wrote: >=20 >> On Dec 27, 2016, at 1:48 PM, Jason Harmening = > wrote: >>=20 >> Hi everyone, >>=20 >> I'm making some tweaks to the armv6 pmap to mirror some recent i386 >> changes. I don't have arm hardware readily available, so I thought = I'd >> give qemu a whirl instead of asking other people to test my changes = for >> me. Since I need SMP but don't need any specific peripheral hw, the = 'VIRT' >> kernel seems like my best bet. >>=20 >> I've successfully booted mips[64] under qemu, so naively starting out = w/ >> the same steps I use for mips: >>=20 >> 1). build armv6 world and VIRT kernel, install world to temp = directory >> 2). use makefs(8) to build a 4GB (little endian) fs image from temp = dir >> 3). Run qemu: >> qemu-system-arm -M virt -kernel -hda >> -nographic -m 1024 >>=20 >> ...fails immediately: >> qemu: fatal: Trying to execute code outside RAM or ROM at 0xc1000100 >>=20 >> R00=3D00000000 R01=3D00000000 R02=3D00000000 R03=3D00000000 >> R04=3D00000000 R05=3D00000000 R06=3D00000000 R07=3D00000000 >> R08=3D00000000 R09=3D00000000 R10=3D00000000 R11=3D00000000 >> R12=3D00000000 R13=3D00000000 R14=3D00000000 R15=3Dc1000100 >>=20 >> hmm, looks pretty close to KERNVIRTADDR. >>=20 >> Most online docs for qemu-system-arm seem to assume a prebuilt linux = kernel >> and initrd, the rest are...fragmented-to-nonexistent. I've seen a = few >> hints that I might need to wrap the kernel image up along w/ u-boot, = but >> the u-boot images seem to be very SoC-specific. >>=20 >> Any help would be much appreciated, sorry for the n00b question. >=20 > Hi Jason, >=20 > It looks like for VIRT kernel is supposed to be used with UEFI. At = least > this part of NanoBSD sources hints at it: > = http://sources.freebsd.org/HEAD/src/tools/tools/nanobsd/embedded/qemu-armv= 7.cfg = > You can probably use NanoBSD-generated image for your experiments >=20 > Ah, thanks! That should make things a good deal easier. > Using the nanobsd-generated images and the qemu invocation from = qemu-armv7.cfg, I get a bit further but end up with a repeating prefetch = abort: > Prefetch Abort Exception PC at 0xFF176790 CPSR 0x80000113 >=20 > This is either in UEFI or very early in kernel bootstrap, since the = copyright hasn't printed yet...haven't poked at it to figure out where = the pc comes from yet. Looks like it's boot1.efi. After upgrading to clang 3.9.0 -fPIC is = required to build loader. In addition to this problem there seems to be = some error when calculating value for relocation. Looks like it=E2=80=99s = going to take a bit of time to track down, I can=E2=80=99t identify it = immediately. =20