From patchwork Fri Aug 29 02:20:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 36267 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14ED42054F for ; Fri, 29 Aug 2014 02:21:18 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id cm18sf6461067qab.11 for ; Thu, 28 Aug 2014 19:21:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:references:in-reply-to:subject:precedence:reply-to :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type; bh=OC7Xcde2HCx+3U3na6cUCIFawmVT7y8yIVFchzVJap0=; b=GL8mEAmaNxfAXbinVynLosmaaMKX6n2anaVwpfDN7V5nYU+/uwxJdx7QcsT7RxT2sy llnPQCUnost4RZAoaiq3SK7SI3+y7JGC2pdd7wq3y/9rKgvA3sboX1aum3ANF5T3d6f8 VEk8B+POvZIw7QcduxAQEyz+rX+Icq9Q52JMsHczeZA/bCOGCYQdRa9RD1fI1J2j70rT cHGLms/w5EiPDnKCngaNNJlaDG6w9lU92l6w2mQhXu12EoMay+OfI7Q1GwLqs3++xjeB KlDlWOQsB/s8dY+Wtajo7b9yC5PJ3E2AmnpgWoGML/GnynbV5hny8NC9g/x2lw5ZNhWL Cbiw== X-Gm-Message-State: ALoCoQnFHIkmH+EAeaCLXpepAF28FC+Eod/MHG7lBYimC0wbIn8/ID5ffDtzJMMNXZQTs7sHtrn+ X-Received: by 10.236.7.14 with SMTP id 14mr4109679yho.34.1409278877870; Thu, 28 Aug 2014 19:21:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.112 with SMTP id 103ls893596qga.9.gmail; Thu, 28 Aug 2014 19:21:17 -0700 (PDT) X-Received: by 10.220.105.201 with SMTP id u9mr7686195vco.11.1409278877765; Thu, 28 Aug 2014 19:21:17 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id o8si5661579vda.105.2014.08.28.19.21.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 19:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so1845039vcb.37 for ; Thu, 28 Aug 2014 19:21:17 -0700 (PDT) X-Received: by 10.52.156.100 with SMTP id wd4mr4531669vdb.39.1409278877645; Thu, 28 Aug 2014 19:21:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp324878vcb; Thu, 28 Aug 2014 19:21:16 -0700 (PDT) X-Received: by 10.42.35.8 with SMTP id o8mr8441227icd.41.1409278876283; Thu, 28 Aug 2014 19:21:16 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id en16si6077283icb.5.2014.08.28.19.21.15 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 Aug 2014 19:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XNBoJ-0004Fk-Jf; Fri, 29 Aug 2014 02:21:07 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XNBoH-0004Fc-Vx for edk2-devel@lists.sourceforge.net; Fri, 29 Aug 2014 02:21:06 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=lersek@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XNBoF-0000yG-2T for edk2-devel@lists.sourceforge.net; Fri, 29 Aug 2014 02:21:05 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7T2Knfb013790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 28 Aug 2014 22:20:49 -0400 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-99.ams2.redhat.com [10.36.116.99]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7T2KkWA012028; Thu, 28 Aug 2014 22:20:47 -0400 Message-ID: <53FFE37E.8000405@redhat.com> Date: Fri, 29 Aug 2014 04:20:46 +0200 From: Laszlo Ersek User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Ard Biesheuvel , olivier.martin@arm.com, edk2-devel@lists.sourceforge.net, peter.maydell@linaro.org, christoffer.dall@linaro.org, drjones@redhat.com, ilias.biris@linaro.org, leif.lindholm@linaro.org References: <1409240449-12136-1-git-send-email-ard.biesheuvel@linaro.org> <53FFB87F.1030504@redhat.com> In-Reply-To: <53FFB87F.1030504@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XNBoF-0000yG-2T Subject: Re: [edk2] [PATCH v5 16/16] ArmVirtualizationPkg: add ArmVirtualizationQemu platform X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lersek@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Apologies, I have some updates here: On 08/29/14 01:17, Laszlo Ersek wrote: > On 08/28/14 17:40, Ard Biesheuvel wrote: > >> + APRIORI DXE { >> + INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf >> + } >> + INF MdeModulePkg/Core/Dxe/DxeMain.inf >> + INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf >> + INF ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf >> + >> + # >> + # PI DXE Drivers producing Architectural Protocols (EFI Services) >> + # >> + INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf >> + INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf >> + INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf >> + INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf >> + INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf >> + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf > > from the prev. norflash patch, ok... > >> + INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf >> + INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf >> + INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf >> + INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf >> + INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf >> + >> + # >> + # Multiple Console IO support >> + # >> + INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf >> + INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf >> + INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf >> + INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf >> + INF EmbeddedPkg/SerialDxe/SerialDxe.inf >> + >> + INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf >> + INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf >> + INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf > > ditto, OK > >> + INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf >> + >> + # >> + # FAT filesystem + GPT/MBR partitioning >> + # >> + INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf >> + INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf >> + INF FatBinPkg/EnhancedFatDxe/Fat.inf >> + INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf >> + >> + # >> + # Platform Driver >> + # >> + INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf >> + INF OvmfPkg/VirtioNetDxe/VirtioNet.inf >> + INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf >> + >> + # >> + # UEFI application (Shell Embedded Boot Loader) >> + # >> + INF ShellBinPkg/UefiShell/UefiShell.inf >> + >> + # >> + # Bds >> + # >> + INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf >> + INF ArmPlatformPkg/Bds/Bds.inf I. So, VirtFdtDxe sets the following PCDs, keying off the DTB: - PcdGicDistributorBase - PcdGicInterruptInterfaceBase - PcdPL031RtcBase - PcdArmArchTimerSecIntrNum - PcdArmArchTimerIntrNum - PcdArmArchTimerVirtIntrNum - PcdArmArchTimerHypIntrNum It is imperative that DXE drivers that depend on these PCDs run *after* VirtFdtDxe. Ordering between DXE drivers can be ensured in several ways: - the APRIORI DXE file - Depex (some drivers produce protocols, and others depend on them) - protocol installation callbacks (gBS->RegisterProtocolNotify()) - theoretically, PcdSetXX() callbacks (I've never seen any use of this) Of these, I recommend the APRIORI DXE file, because - there are no suitable protocols here, - we're delaying cross-ARM-platform drivers, ie. nothing that's specific to virt Please squash the first attached patch. I tested it. It makes no difference *in practice*, right now. The first DXE driver that is loaded is PcdDxe.efi, the 2nd one is VirtFdtDxe.efi, anyway. But that only happens because you placed the VirtFdtDxe line in the FDF file quite "high". The ordering of the module lines in the FDF file, in an [FV] section, has unspecified effect; you just got lucky that it ended up creating a load order that you wanted. Again, this is not guaranteed, plus module lines can be reshuffled any time in the [FV] section of the FDF. If you want to prescribe a dispatch order, you must use the APRIORI file. Whatever drivers you reference there will be dispatched first from the firmware volume, in the order you listed them in the APRIORI file, and then the rest will be dispatched, in unspecified order (subject to Depexes of course). Please refer to "2.4.4 APRIORI Scoping" in the FDF spec. So, please squash this patch -- it has no effect right now (luckily), but it's needed for safety down the road. You can keep my Reviewed-by of course. II. I compared the list of modules you build in the DSC file(s) against the modules you include in the flash image with the FDF file. There are two discrepancies: - EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf is built uselessly (simply drop it from the DSC) - the networking modules that are built through the dsc.inc are not included by the FDF. They should be. IOW, please squash the 2nd patch too. III. Notes about testing: - this series doesn't apply on current edk2 master; please rebase it for v6. For testing, I applied it on git commit 421ccda3. - the first QEMU patch that you link in doesn't apply on current QEMU master (git-am can't cope with the context changes); I'm attaching a forward-ported version. Maybe you can add it to the wiki page. IV. More notes about testing -- try this (if you haven't yet): (a) as root, on your host: G=$(id -g $YOUR_NORMAL_USER) sysctl -w net.ipv4.ping_group_range="$G $G" (b) as your normal user: qemu-system-aarch64 \ -m 1024 \ -cpu cortex-a57 \ -M virt \ -bios Build/ArmVirtualizationQemu/DEBUG_GCC48/FV/QEMU_EFI.fd \ -serial stdio \ -netdev user,id=netdev0,hostname=aarch64-guest \ -device virtio-net-device,netdev=netdev0 (c) drop to the UEFI shell (d) Shell> ifconfig -s eth0 dhcp (e) Shell> ping FAVORITE_PUBLIC_IPv4_ADDRESS This is what I've been wanting to see for months! :) - side note: backspace works perfectly for me in my xterm (my erase character has been ^H for ~15 yrs) Thanks! Laszlo ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ >From 43c2037be5c25654656b75a1f237e23f7bb12e1e Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Fri, 29 Aug 2014 02:57:06 +0200 Subject: [PATCH] hw/arm/virt: Provide flash devices for boot ROMs Add two flash devices to the virt board, so that it can be used for running guests which want a bootrom image such as UEFI. We provide two flash devices to make it more convenient to provide both a read-only UEFI image and a read-write place to store guest-set UEFI config variables. The '-bios' command line option is set up to provide an image for the first of the two flash devices. Signed-off-by: Peter Maydell Signed-off-by: Laszlo Ersek --- hw/arm/virt.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index bd206a0..61597c2 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -37,6 +37,7 @@ #include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "hw/boards.h" +#include "hw/loader.h" #include "exec/address-spaces.h" #include "qemu/bitops.h" #include "qemu/error-report.h" @@ -97,7 +98,6 @@ typedef struct VirtBoardInfo { * to accommodate guests using 64K pages. */ static const MemMapEntry a15memmap[] = { - /* Space up to 0x8000000 is reserved for a boot ROM */ [VIRT_FLASH] = { 0, 0x08000000 }, [VIRT_CPUPERIPHS] = { 0x08000000, 0x00020000 }, /* GIC distributor and CPU interfaces sit inside the CPU peripheral space */ @@ -437,6 +437,73 @@ static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) } } +static void create_one_flash(const char *name, hwaddr flashbase, + hwaddr flashsize) +{ + /* Create and map a single flash device. We use the same + * parameters as the flash devices on the Versatile Express board. + */ + DriveInfo *dinfo = drive_get_next(IF_PFLASH); + DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); + const uint64_t sectorlength = 256 * 1024; + + if (dinfo && qdev_prop_set_drive(dev, "drive", dinfo->bdrv)) { + abort(); + } + + qdev_prop_set_uint32(dev, "num-blocks", flashsize / sectorlength); + qdev_prop_set_uint64(dev, "sector-length", sectorlength); + qdev_prop_set_uint8(dev, "width", 4); + qdev_prop_set_uint8(dev, "device-width", 2); + qdev_prop_set_uint8(dev, "big-endian", 0); + qdev_prop_set_uint16(dev, "id0", 0x89); + qdev_prop_set_uint16(dev, "id1", 0x18); + qdev_prop_set_uint16(dev, "id2", 0x00); + qdev_prop_set_uint16(dev, "id3", 0x00); + qdev_prop_set_string(dev, "name", name); + qdev_init_nofail(dev); + + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, flashbase); +} + +static void create_flash(const VirtBoardInfo *vbi) +{ + /* Create two flash devices to fill the VIRT_FLASH space in the memmap. + * Any file passed via -bios goes in the first of these. + */ + hwaddr flashsize = vbi->memmap[VIRT_FLASH].size / 2; + hwaddr flashbase = vbi->memmap[VIRT_FLASH].base; + char *nodename; + + if (bios_name) { + const char *fn; + + if (drive_get(IF_PFLASH, 0, 0)) { + error_report("The contents of the first flash device may be " + "specified with -bios or with -drive if=pflash... " + "but you cannot use both options at once"); + exit(1); + } + fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (!fn || load_image_targphys(fn, flashbase, flashsize) < 0) { + error_report("Could not load ROM image '%s'", bios_name); + exit(1); + } + } + + create_one_flash("virt.flash0", flashbase, flashsize); + create_one_flash("virt.flash1", flashbase + flashsize, flashsize); + + nodename = g_strdup_printf("/flash@%" PRIx64, flashbase); + qemu_fdt_add_subnode(vbi->fdt, nodename); + qemu_fdt_setprop_string(vbi->fdt, nodename, "compatible", "cfi-flash"); + qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", + 2, flashbase, 2, flashsize, + 2, flashbase + flashsize, 2, flashsize); + qemu_fdt_setprop_cell(vbi->fdt, nodename, "bank-width", 4); + g_free(nodename); +} + static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) { const VirtBoardInfo *board = (const VirtBoardInfo *)binfo; @@ -514,6 +581,8 @@ static void machvirt_init(MachineState *machine) vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, vbi->memmap[VIRT_MEM].base, ram); + create_flash(vbi); + create_gic(vbi, pic); create_uart(vbi, pic); -- 1.8.3.1