loading 'VIRT' kernel in qemu

Oleksandr Tymoshenko gonzo at bluezbox.com
Fri Dec 30 01:25:41 UTC 2016


> On Dec 29, 2016, at 5:12 AM, Jason Harmening <jason.harmening at gmail.com> wrote:
> 
> On Wed, Dec 28, 2016 at 11:25 AM, Oleksandr Tymoshenko <gonzo at bluezbox.com <mailto:gonzo at bluezbox.com>> wrote:
> 
>> On Dec 27, 2016, at 1:48 PM, Jason Harmening <jason.harmening at gmail.com <mailto:jason.harmening at gmail.com>> 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 <VIRT kernel binary> -hda <fs image>
>> -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 <http://sources.freebsd.org/HEAD/src/tools/tools/nanobsd/embedded/qemu-armv7.cfg>
> You can probably use NanoBSD-generated image for your experiments
> 
> 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
> 
> 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’s going to take a bit of time to track down, I can’t identify it immediately.  



More information about the freebsd-arm mailing list