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
<https://wiki.linaro.org/LEG/UEFIforQEMU> 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
>From 79f01e17e417f4272969ac29896175da7e0d21c1 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <[email protected]>
Date: Fri, 29 Aug 2014 03:13:40 +0200
Subject: [PATCH 1/2] ensure that VirtFdtDxe runs as early as possible

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
 ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf
index 5b9ac21..bb86ccb 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf
@@ -102,6 +102,7 @@ READ_LOCK_STATUS   = TRUE
 
   APRIORI DXE {
     INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
+    INF ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
   }
   INF MdeModulePkg/Core/Dxe/DxeMain.inf
   INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
-- 
1.8.3.1

>From 46991a86fd21eaa774738f268a7927b08464e55f Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <[email protected]>
Date: Fri, 29 Aug 2014 04:08:40 +0200
Subject: [PATCH 2/2] sync DXE modules between DSC(.inc) and FDF

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
 .../ArmVirtualizationPkg/ArmVirtualizationQemu.dsc        |  1 -
 .../ArmVirtualizationPkg/ArmVirtualizationQemu.fdf        | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index c5129cf..e98c3ff 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -210,7 +210,6 @@
   MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
   MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
-  EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
   EmbeddedPkg/SerialDxe/SerialDxe.inf
  
   MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf
index bb86ccb..9dfdd56 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.fdf
@@ -163,6 +163,21 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
   INF ArmPlatformPkg/Bds/Bds.inf
 
+  #
+  # Networking stack
+  #
+  INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
+  INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
+  INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
+  INF MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
+  INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
+  INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
+  INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
+  INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
+  INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
+  INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
+  INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
+  INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
 
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 16
-- 
1.8.3.1

>From 43c2037be5c25654656b75a1f237e23f7bb12e1e Mon Sep 17 00:00:00 2001
From: Peter Maydell <[email protected]>
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 <[email protected]>
Signed-off-by: Laszlo Ersek <[email protected]>
---
 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

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to