From patchwork Tue Feb 24 18:02:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44960 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E24BA2029F for ; Tue, 24 Feb 2015 18:04:48 +0000 (UTC) Received: by wghb13 with SMTP id b13sf5277514wgh.2 for ; Tue, 24 Feb 2015 10:04:48 -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:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=xwDXv8wDruKW+/18ZcP90y4gZ91cUQGptS5tdmfD64A=; b=b6NepmcUJ38KSwXYlSN44zdl7QueN1wZOB6N7vZ+zkLxZ28ehuC1MuJhndeft3+JkD +F4AMsyGfxLgtRaF9bAvu0qpcKfabHmGV6dmMgx9TyxLa2r9dWDYJL2B3AtVfxtKB/fj bQQYTdywcjVvVpZsgXqFUZO07I8ALMmTQVGVFR1CeSAzio3f0De8sn5OyBD/aMnPum1i cyDusTEEpJ8dHePE3NHxEsYjzMt0EYg108cYzOIZFiONJFnDcxLqnHb2V24GdOSknAWr TjRTtWiIEuzxmqa5MiLfHeRFC6t1fem4gDNHbBpvGzjTpzxxKgLmf+1mn9SxJoGsnwIL VCdw== X-Gm-Message-State: ALoCoQlKRzhxQfvbptj+iHxwZI3aszZ3THjlQpMvWQ+V1uiRdHRCIIXxsI3BhSK8490hv096oVD2 X-Received: by 10.152.19.100 with SMTP id d4mr2343787lae.7.1424801088092; Tue, 24 Feb 2015 10:04:48 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.9 with SMTP id p9ls657644lag.86.gmail; Tue, 24 Feb 2015 10:04:47 -0800 (PST) X-Received: by 10.112.215.9 with SMTP id oe9mr15584938lbc.40.1424801087921; Tue, 24 Feb 2015 10:04:47 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id tz3si26840166lbb.66.2015.02.24.10.04.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 10:04:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbjb6 with SMTP id b6so26770951lbj.2 for ; Tue, 24 Feb 2015 10:04:47 -0800 (PST) X-Received: by 10.112.114.230 with SMTP id jj6mr15157883lbb.112.1424801087749; Tue, 24 Feb 2015 10:04:47 -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.35.133 with SMTP id h5csp2078093lbj; Tue, 24 Feb 2015 10:04:47 -0800 (PST) X-Received: by 10.194.156.133 with SMTP id we5mr35678415wjb.37.1424801086454; Tue, 24 Feb 2015 10:04:46 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id q7si68751976wja.145.2015.02.24.10.04.42 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:04:46 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQJqI-0001bq-6E; Tue, 24 Feb 2015 18:04:22 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQJqH-0001ar-4T for xen-devel@lists.xen.org; Tue, 24 Feb 2015 18:04:21 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 9B/C4-02810-42DBCE45; Tue, 24 Feb 2015 18:04:20 +0000 X-Env-Sender: ard.biesheuvel@linaro.org X-Msg-Ref: server-7.tower-206.messagelabs.com!1424801059!11138378!1 X-Originating-IP: [74.125.82.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6712 invoked from network); 24 Feb 2015 18:04:19 -0000 Received: from mail-we0-f169.google.com (HELO mail-we0-f169.google.com) (74.125.82.169) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 24 Feb 2015 18:04:19 -0000 Received: by wevm14 with SMTP id m14so26812832wev.13 for ; Tue, 24 Feb 2015 10:04:19 -0800 (PST) X-Received: by 10.180.87.165 with SMTP id az5mr32587575wib.29.1424801059557; Tue, 24 Feb 2015 10:04:19 -0800 (PST) Received: from ards-macbook-pro.lan (bl11-65-113.dsl.telepac.pt. [85.244.65.113]) by mx.google.com with ESMTPSA id w8sm12792521wja.4.2015.02.24.10.04.15 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:04:17 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, olivier.martin@arm.com, lersek@redhat.com, roy.franz@linaro.org, leif.lindholm@linaro.org, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, anthony.perard@citrix.com, xen-devel@lists.xen.org, julien.grall@linaro.org, jordan.l.justen@intel.com, michael.d.kinney@intel.com Date: Tue, 24 Feb 2015 18:02:45 +0000 Message-Id: <1424800990-15777-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1424800990-15777-1-git-send-email-ard.biesheuvel@linaro.org> References: <1424800990-15777-1-git-send-email-ard.biesheuvel@linaro.org> Cc: wei.liu2@citrix.com, Ard Biesheuvel Subject: [Xen-devel] [PATCH v5 04/29] ArmVirtualizationPkg: add GICv3 detection to VirtFdtDxe X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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.177 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 List-Archive: This adds support for detecting the presence of a GICv3 interrupt controller from the device tree, and recording its distributor and redistributor base addresses in their respective PCDs. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: Olivier Martin Acked-by: Laszlo Ersek Signed-off-by: Ard Biesheuvel --- .../ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 1 + .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 34 +++++++++++++++++++++- .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc index d3384a7dc1b3..035437482c1d 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc @@ -203,6 +203,7 @@ # ARM General Interrupt Controller # gArmTokenSpaceGuid.PcdGicDistributorBase|0x0 + gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x0 gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x0 ## PL031 RealTimeClock diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c index 274cdeb8c8f4..041ad88e10bc 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c @@ -47,6 +47,7 @@ typedef enum { PropertyTypePsci, PropertyTypeFwCfg, PropertyTypePciHost, + PropertyTypeGicV3, } PROPERTY_TYPE; typedef struct { @@ -64,6 +65,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = { { PropertyTypePsci, "arm,psci-0.2" }, { PropertyTypeFwCfg, "qemu,fw-cfg-mmio" }, { PropertyTypePciHost, "pci-host-ecam-generic" }, + { PropertyTypeGicV3, "arm,gic-v3" }, { PropertyTypeUnknown, "" } }; @@ -286,7 +288,7 @@ InitializeVirtFdtDxe ( VIRTIO_TRANSPORT_DEVICE_PATH *DevicePath; EFI_HANDLE Handle; UINT64 RegBase; - UINT64 DistBase, CpuBase; + UINT64 DistBase, CpuBase, RedistBase; CONST INTERRUPT_PROPERTY *InterruptProp; INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum; CONST CHAR8 *PsciMethod; @@ -434,6 +436,36 @@ InitializeVirtFdtDxe ( DEBUG ((EFI_D_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase)); break; + case PropertyTypeGicV3: + // + // The GIC v3 DT binding describes a series of at least 3 physical (base + // addresses, size) pairs: the distributor interface (GICD), at least one + // redistributor region (GICR) containing dedicated redistributor + // interfaces for all individual CPUs, and the CPU interface (GICC). + // Under virtualization, we assume that the first redistributor region + // listed covers the boot CPU. Also, our GICv3 driver only supports the + // system register CPU interface, so we can safely ignore the MMIO version + // which is listed after the sequence of redistributor interfaces. + // This means we are only interested in the first two memory regions + // supplied, and ignore everything else. + // + ASSERT (Len >= 32); + + // RegProp[0..1] == { GICD base, GICD size } + DistBase = fdt64_to_cpu (((UINT64 *)RegProp)[0]); + ASSERT (DistBase < MAX_UINT32); + + // RegProp[2..3] == { GICR base, GICR size } + RedistBase = fdt64_to_cpu (((UINT64 *)RegProp)[2]); + ASSERT (RedistBase < MAX_UINT32); + + PcdSet32 (PcdGicDistributorBase, (UINT32)DistBase); + PcdSet32 (PcdGicRedistributorsBase, (UINT32)RedistBase); + + DEBUG ((EFI_D_INFO, "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n", + DistBase, RedistBase)); + break; + case PropertyTypeRtc: ASSERT (Len == 16); diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf index ff05c5e058fb..cdfca610604a 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf @@ -52,6 +52,7 @@ gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress gArmTokenSpaceGuid.PcdGicDistributorBase + gArmTokenSpaceGuid.PcdGicRedistributorsBase gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum gArmTokenSpaceGuid.PcdArmArchTimerIntrNum