From patchwork Tue Feb 24 18:02:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44968 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 1B8222029F for ; Tue, 24 Feb 2015 18:05:58 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id h11sf16309310wiw.1 for ; Tue, 24 Feb 2015 10:05:57 -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=3v07NQ7MwH/C7mCQlbaMalf9zPzi1SzIq/mU8j16me4=; b=MSBGC4gDeqncWflLL0cX06PBoFbBKQ4O2hKORm+OLZUJxZrx9YsCTpVwZGQatC6Lz+ M9VsD3lH/LZ4wCtzQswMxGNhlZ+04dV7KIf78o5V9Rxl2Cs/KpBJ/7GYW2yMKFy73GfK O/N51KCwl/wv8BAdwlIgK6pWPv4owIQJoj0viqrkAATwqtR3mit8yF9FeRNGCt0TTTzI dBXaJaJRACGE2bLOplzC48kwAL26y/T+a2gSxjr7IPkwTjJKstuZA5tfzl352jh8N1aC ouc/kIF2fD4XHz8EpnK29N7v9Tu7GPFNe+VX5eKzk0Inp8HO8b8hg+4k3o5rIh5w+Zvt pyhg== X-Gm-Message-State: ALoCoQl4qeuE26bXuydEHgMUmP4XiqP8qZHFLcuv+GOeL1d/8nYLUXuCh3M6GGSTWOgmaqRKbQPF X-Received: by 10.194.201.10 with SMTP id jw10mr2336454wjc.3.1424801157427; Tue, 24 Feb 2015 10:05:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls462540lat.83.gmail; Tue, 24 Feb 2015 10:05:57 -0800 (PST) X-Received: by 10.152.87.3 with SMTP id t3mr15537992laz.19.1424801157137; Tue, 24 Feb 2015 10:05:57 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id lm3si9355601lac.177.2015.02.24.10.05.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 10:05:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by labhs14 with SMTP id hs14so27533731lab.1 for ; Tue, 24 Feb 2015 10:05:57 -0800 (PST) X-Received: by 10.152.197.34 with SMTP id ir2mr12816427lac.36.1424801157051; Tue, 24 Feb 2015 10:05:57 -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 h5csp2078868lbj; Tue, 24 Feb 2015 10:05:56 -0800 (PST) X-Received: by 10.52.164.230 with SMTP id yt6mr17379222vdb.66.1424801154223; Tue, 24 Feb 2015 10:05:54 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id o2si19143458vdb.25.2015.02.24.10.05.53 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:05:54 -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 1YQJq7-0001Ts-Hy; Tue, 24 Feb 2015 18:04:11 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQJq6-0001T7-0X for xen-devel@lists.xen.org; Tue, 24 Feb 2015 18:04:10 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id EB/8F-02830-91DBCE45; Tue, 24 Feb 2015 18:04:09 +0000 X-Env-Sender: ard.biesheuvel@linaro.org X-Msg-Ref: server-16.tower-21.messagelabs.com!1424801048!9430408!1 X-Originating-IP: [209.85.212.177] 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 14034 invoked from network); 24 Feb 2015 18:04:08 -0000 Received: from mail-wi0-f177.google.com (HELO mail-wi0-f177.google.com) (209.85.212.177) by server-16.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 24 Feb 2015 18:04:08 -0000 Received: by mail-wi0-f177.google.com with SMTP id bs8so27182787wib.4 for ; Tue, 24 Feb 2015 10:04:08 -0800 (PST) X-Received: by 10.194.95.66 with SMTP id di2mr35002746wjb.57.1424801048074; Tue, 24 Feb 2015 10:04:08 -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.04 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:04:07 -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:42 +0000 Message-Id: <1424800990-15777-2-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 01/29] ArmPkg: allow HYP timer interrupt to be omitted 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.215.52 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: The DT binding for the ARM generic timer describes the secure, non-secure, virtual and hypervisor timer interrupts, respectively. However, under virtualization, only the virtual timer is usable, and the device tree may omit the hypervisor timer interrupt. (Other timer interrupts cannot be omitted simply due to the fact that the virtual timer is listed third) Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: Olivier Martin Reviewed-by: Laszlo Ersek Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/TimerDxe/TimerDxe.c | 14 +++++++++++--- .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c index d0a819fc2729..1169d426b255 100644 --- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c +++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c @@ -369,7 +369,8 @@ TimerInitialize ( { EFI_HANDLE Handle = NULL; EFI_STATUS Status; - UINTN TimerCtrlReg; + UINTN TimerCtrlReg; + UINT32 TimerHypIntrNum; if (ArmIsArchTimerImplemented () == 0) { DEBUG ((EFI_D_ERROR, "ARM Architectural Timer is not available in the CPU, hence cann't use this Driver \n")); @@ -395,8 +396,15 @@ TimerInitialize ( Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerVirtIntrNum), TimerInterruptHandler); ASSERT_EFI_ERROR (Status); - Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerHypIntrNum), TimerInterruptHandler); - ASSERT_EFI_ERROR (Status); + // + // The hypervisor timer interrupt may be omitted by implementations that + // execute under virtualization. + // + TimerHypIntrNum = PcdGet32 (PcdArmArchTimerHypIntrNum); + if (TimerHypIntrNum != 0) { + Status = gInterrupt->RegisterInterruptSource (gInterrupt, TimerHypIntrNum, TimerInterruptHandler); + ASSERT_EFI_ERROR (Status); + } Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerSecIntrNum), TimerInterruptHandler); ASSERT_EFI_ERROR (Status); diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c index be74d62ad748..274cdeb8c8f4 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c @@ -452,7 +452,7 @@ InitializeVirtFdtDxe ( // hypervisor timers, in that order. // InterruptProp = fdt_getprop (DeviceTreeBase, Node, "interrupts", &Len); - ASSERT (Len == 48); + ASSERT (Len == 36 || Len == 48); SecIntrNum = fdt32_to_cpu (InterruptProp[0].Number) + (InterruptProp[0].Type ? 16 : 0); @@ -460,8 +460,8 @@ InitializeVirtFdtDxe ( + (InterruptProp[1].Type ? 16 : 0); VirtIntrNum = fdt32_to_cpu (InterruptProp[2].Number) + (InterruptProp[2].Type ? 16 : 0); - HypIntrNum = fdt32_to_cpu (InterruptProp[3].Number) - + (InterruptProp[3].Type ? 16 : 0); + HypIntrNum = Len < 48 ? 0 : fdt32_to_cpu (InterruptProp[3].Number) + + (InterruptProp[3].Type ? 16 : 0); DEBUG ((EFI_D_INFO, "Found Timer interrupts %d, %d, %d, %d\n", SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum));