From patchwork Fri Jan 23 15:03:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43670 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B38E218DB for ; Fri, 23 Jan 2015 15:04:55 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id bs8sf1698128wib.1 for ; Fri, 23 Jan 2015 07:04:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=oyS6k6bnIiKH8bj2xyuME0dbqiK8jZrPprPp4qLXhHw=; b=EkEeYd6tnwiKIMUJdnZ7sfH5WRolnVx+OU1sJHfGuClZYQBpMIGTZOcmj3z5672hjb fy4Hj2o/mkbuA6BiHaWuRl1b7VtYJg9Vb5yXiWbFfAsokUzZHo74HsJF0aHKbrSqpWm5 7bqol/KyvCrgFpCTw+pROQVDiH5H8ENuTtZjpbpITNdUuTQSeIVVl/6maY6GD+ONMVoU LAK+11GgtMejb4dOFsAK0hlRHsCA9v8SKMGPghgmbSr1QnZW47PaFBsiJgf4/Wy/fJ0z PBT4+6aAfR5X6alOptxPdT0OydpUceJxAh5108iw9ZEXsqu7BqZBrZP6wa2Ta7hhe35h dH8w== X-Gm-Message-State: ALoCoQls+RWa/wHaFIJgNLlqLAOQVS02Z8SamiCh8j3a2afrrX0qKYFXTDur1DRiGGaFnXNwGk/v X-Received: by 10.112.160.41 with SMTP id xh9mr294635lbb.12.1422025494766; Fri, 23 Jan 2015 07:04:54 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.220.164 with SMTP id px4ls281699lac.34.gmail; Fri, 23 Jan 2015 07:04:54 -0800 (PST) X-Received: by 10.112.144.136 with SMTP id sm8mr7808588lbb.95.1422025494547; Fri, 23 Jan 2015 07:04:54 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id jc7si1573623lbc.80.2015.01.23.07.04.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 07:04:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id b6so7439147lbj.11 for ; Fri, 23 Jan 2015 07:04:54 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr7811610lal.29.1422025494416; Fri, 23 Jan 2015 07:04:54 -0800 (PST) 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.112.9.200 with SMTP id c8csp283340lbb; Fri, 23 Jan 2015 07:04:53 -0800 (PST) X-Received: by 10.50.82.68 with SMTP id g4mr2319783igy.26.1422025491087; Fri, 23 Jan 2015 07:04:51 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ly5si1744039icb.101.2015.01.23.07.04.50 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Jan 2015 07:04:51 -0800 (PST) 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-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YEfmt-0007vV-7Y; Fri, 23 Jan 2015 15:04:43 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YEfmr-0007vL-KD for edk2-devel@lists.sourceforge.net; Fri, 23 Jan 2015 15:04:41 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.177 as permitted sender) client-ip=209.85.212.177; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f177.google.com; Received: from mail-wi0-f177.google.com ([209.85.212.177]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YEfmq-0004uq-Ct for edk2-devel@lists.sourceforge.net; Fri, 23 Jan 2015 15:04:41 +0000 Received: by mail-wi0-f177.google.com with SMTP id r20so3411610wiv.4 for ; Fri, 23 Jan 2015 07:04:34 -0800 (PST) X-Received: by 10.194.185.15 with SMTP id ey15mr14741709wjc.3.1422025474388; Fri, 23 Jan 2015 07:04:34 -0800 (PST) Received: from ards-macbook-pro.local ([197.129.136.117]) by mx.google.com with ESMTPSA id pl1sm2176036wic.16.2015.01.23.07.04.30 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Jan 2015 07:04:33 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, anthony.perard@citrix.com, christoffer.dall@linaro.org, xen-devel@lists.xen.org, ilias.biris@linaro.org Date: Fri, 23 Jan 2015 15:03:09 +0000 Message-Id: <1422025390-8036-21-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422025390-8036-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422025390-8036-1-git-send-email-ard.biesheuvel@linaro.org> 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_PASS SPF: sender matches SPF record X-Headers-End: 1YEfmq-0004uq-Ct Subject: [edk2] [PATCH v1 20/21] ArmVirtualizationPkg/VirtFdtDxe: wire up XenBusDxe to "xen, xen" DT node 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: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 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 This patchs adds support to VirtFdtDxe for the Xen DT node which contains the base address of the Grant Table. This data is communicated to XenBusDxe using a XENIO_PROTOCOL instance. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 96 +++++++++++++++++++--- .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 2 + 2 files changed, 86 insertions(+), 12 deletions(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c index 96aeec61ee7f..d8071f3e72aa 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c @@ -30,6 +30,9 @@ #include #include #include +#include + +#include #pragma pack (1) typedef struct { @@ -39,6 +42,13 @@ typedef struct { } VIRTIO_TRANSPORT_DEVICE_PATH; #pragma pack () +#pragma pack (1) +typedef struct { + VENDOR_DEVICE_PATH Vendor; + EFI_DEVICE_PATH_PROTOCOL End; +} XENBUS_ROOT_DEVICE_PATH; +#pragma pack () + typedef enum { PropertyTypeUnknown, PropertyTypeGic, @@ -49,6 +59,7 @@ typedef enum { PropertyTypePsci, PropertyTypeFwCfg, PropertyTypeGicV3, + PropertyTypeXen, } PROPERTY_TYPE; typedef struct { @@ -66,6 +77,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = { { PropertyTypePsci, "arm,psci-0.2" }, { PropertyTypeFwCfg, "qemu,fw-cfg-mmio" }, { PropertyTypeGicV3, "arm,gic-v3" }, + { PropertyTypeXen, "xen,xen" }, { PropertyTypeUnknown, "" } }; @@ -116,7 +128,7 @@ InitializeVirtFdtDxe ( INT32 Len; PROPERTY_TYPE PropType; CONST VOID *RegProp; - VIRTIO_TRANSPORT_DEVICE_PATH *DevicePath; + VIRTIO_TRANSPORT_DEVICE_PATH *VirtIoDevicePath; EFI_HANDLE Handle; UINT64 RegBase; UINT64 DistBase, CpuBase; @@ -127,6 +139,8 @@ InitializeVirtFdtDxe ( UINT64 FwCfgSelectorSize; UINT64 FwCfgDataAddress; UINT64 FwCfgDataSize; + XENIO_PROTOCOL *XenIo; + XENBUS_ROOT_DEVICE_PATH *XenBusDevicePath; Hob = GetFirstGuidHob(&gFdtHobGuid); if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof DeviceTreeBase) { @@ -209,31 +223,31 @@ InitializeVirtFdtDxe ( // Create a unique device path for this transport on the fly // RegBase = fdt64_to_cpu (((UINT64 *)RegProp)[0]); - DevicePath = (VIRTIO_TRANSPORT_DEVICE_PATH *)CreateDeviceNode ( + VirtIoDevicePath = (VIRTIO_TRANSPORT_DEVICE_PATH *)CreateDeviceNode ( HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VIRTIO_TRANSPORT_DEVICE_PATH)); - if (DevicePath == NULL) { + if (VirtIoDevicePath == NULL) { DEBUG ((EFI_D_ERROR, "%a: Out of memory\n", __FUNCTION__)); break; } - CopyMem (&DevicePath->Vendor.Guid, &gVirtioMmioTransportGuid, + CopyMem (&VirtIoDevicePath->Vendor.Guid, &gVirtioMmioTransportGuid, sizeof (EFI_GUID)); - DevicePath->PhysBase = RegBase; - SetDevicePathNodeLength (&DevicePath->Vendor, - sizeof (*DevicePath) - sizeof (DevicePath->End)); - SetDevicePathEndNode (&DevicePath->End); + VirtIoDevicePath->PhysBase = RegBase; + SetDevicePathNodeLength (&VirtIoDevicePath->Vendor, + sizeof (*VirtIoDevicePath) - sizeof (VirtIoDevicePath->End)); + SetDevicePathEndNode (&VirtIoDevicePath->End); Handle = NULL; Status = gBS->InstallProtocolInterface (&Handle, &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, - DevicePath); + VirtIoDevicePath); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "%a: Failed to install the EFI_DEVICE_PATH " "protocol on a new handle (Status == %r)\n", __FUNCTION__, Status)); - FreePool (DevicePath); + FreePool (VirtIoDevicePath); break; } @@ -244,9 +258,9 @@ InitializeVirtFdtDxe ( Handle, Status)); Status = gBS->UninstallProtocolInterface (Handle, - &gEfiDevicePathProtocolGuid, DevicePath); + &gEfiDevicePathProtocolGuid, VirtIoDevicePath); ASSERT_EFI_ERROR (Status); - FreePool (DevicePath); + FreePool (VirtIoDevicePath); } break; @@ -332,6 +346,64 @@ InitializeVirtFdtDxe ( } break; + case PropertyTypeXen: + ASSERT (Len == 16); + + // + // Retrieve the reg base from this node and add it to a + // XENIO_PROTOCOL instance installed on a new handle. + // + XenIo = AllocateZeroPool (sizeof *XenIo); + ASSERT (XenIo != NULL); + XenIo->GrantTableAddress = fdt64_to_cpu (((UINT64 *)RegProp)[0]); + + XenBusDevicePath = (XENBUS_ROOT_DEVICE_PATH *)CreateDeviceNode ( + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + sizeof (XENBUS_ROOT_DEVICE_PATH)); + if (XenBusDevicePath == NULL) { + DEBUG ((EFI_D_ERROR, "%a: Out of memory\n", __FUNCTION__)); + break; + } + + CopyMem (&XenBusDevicePath->Vendor.Guid, &gXenBusRootDeviceGuid, + sizeof (EFI_GUID)); + SetDevicePathNodeLength (&XenBusDevicePath->Vendor, + sizeof (*XenBusDevicePath) - sizeof (XenBusDevicePath->End)); + SetDevicePathEndNode (&XenBusDevicePath->End); + + Handle = NULL; + Status = gBS->InstallProtocolInterface (&Handle, + &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, + XenBusDevicePath); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a: Failed to install the EFI_DEVICE_PATH " + "protocol on a new handle (Status == %r)\n", + __FUNCTION__, Status)); + FreePool (XenBusDevicePath); + break; + } + + Status = gBS->InstallProtocolInterface (&Handle, + &gXenIoProtocolGuid, EFI_NATIVE_INTERFACE, + XenIo); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a: Failed to install XENIO_PROTOCOL on handle %p " + "(Status == %r)\n", __FUNCTION__, Status)); + + Status = gBS->UninstallProtocolInterface (Handle, + &gEfiDevicePathProtocolGuid, XenBusDevicePath); + ASSERT_EFI_ERROR (Status); + FreePool (XenBusDevicePath); + FreePool (XenIo); + break; + } + + DEBUG ((EFI_D_INFO, "Found Xen node with Grant table @ 0x%p\n", + XenIo->GrantTableAddress)); + + break; + default: break; } diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf index 1392c7c3fa45..01a154ef1b8a 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf @@ -46,6 +46,7 @@ gFdtTableGuid gVirtioMmioTransportGuid gFdtHobGuid + gXenBusRootDeviceGuid [Pcd] gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod @@ -61,6 +62,7 @@ [Protocols] gEfiDevicePathProtocolGuid + gXenIoProtocolGuid [Depex] TRUE