From patchwork Mon Mar 5 16:04:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130679 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2853933lja; Mon, 5 Mar 2018 08:07:16 -0800 (PST) X-Google-Smtp-Source: AG47ELu0eupQQVM9V/86724DkBhUzp/guVxHdKB+o2xtjEIduOBdjgdf9lLWvlVY52ygmlAbqp8K X-Received: by 10.36.95.78 with SMTP id r75mr11599712itb.48.1520266036790; Mon, 05 Mar 2018 08:07:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520266036; cv=none; d=google.com; s=arc-20160816; b=IygrcbuhqHLhMf0fzMzEI9yMPViARAEg/EtMgpp/HLnond8vq53EpKSDVzPG0ZyQ0F Nzauo4fkR6FjXcWyaEZUf6SkiW6jTp0E5RMIJBy6syPam+GGYvllesM9Gv5bOOUGqKgy M1LJahaz2PE5xViUY8p9yjZk/hQ4Tkn3Wi9JIqWLyLBMY9gYcZ3M6ntgYKlT1SyeR7nM a3mrahAwtlXwNJw5OSnZVO17IKj2B6Th52lQla8PZwxJWlCe09zoUcdnv4+rWCXc+Z+v dQ3In8CMGS85P8C5z8XliEhUjKARizMjkJlOLl8Tnd9SoHFmOW1V3kod4VwFgyCcQyrP np6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=+k1sKqIkRXTalO87JxSN+MN2NHhMye0bcpyU35AMJ6M=; b=BcZZX+ykFZ/KMM+n4eCEhJZXRsOQW8wUFR4NLtGbmha49J8YpJBHqVqy15rOt2lKOT 0ZS1iRkxkqnGCMRNepxpcRtl9U5b5iMHDv+Mv5izrkeINmJXWvl6Qbtytu9kj7jT6eZX qMk6yHHT5czxv1aHVjUb5x8262TKKQWdaH7rvRPiCoxsa6AqEgSIRThxv/oCtKo0hPo5 ZLd7o1SfSqesSsUK8DGTdi33F0heHddJbRrPbhjAj1bvkny6QTODZsF07jnclmTnulMQ 1HNNby58SNL9W1kfh/H/m1sBRn+P8YLquCuedqPvql/t5D+v3GYj39SkN+w5wzrQYgUN O22A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HiWYQNI5; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n15si8812358iob.258.2018.03.05.08.07.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:07:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HiWYQNI5; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1essc5-0000ui-Gb; Mon, 05 Mar 2018 16:05:21 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1essc3-0000mF-Ny for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:05:19 +0000 X-Inumbo-ID: d8576b98-208e-11e8-ba59-bc764e045a96 Received: from mail-wm0-x243.google.com (unknown [2a00:1450:400c:c09::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d8576b98-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:04:12 +0100 (CET) Received: by mail-wm0-x243.google.com with SMTP id z81so16909057wmb.4 for ; Mon, 05 Mar 2018 08:05:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T/uTKjcEOyWaxOKmMi9NvI15ZgCwmA6efF2CeQKLQFE=; b=HiWYQNI5hFLGpFGgbrEzuVFy5sUHsmJTEoM1l8XbOelM0Olam7bxkpi+fb++utB11U EMkiZDDMufheqTKd3gUmua+s1sGLI/T5y9XwyYZi4uJqNBuZ0B8Uha0QBXktBwhhlB51 4gSVI8Mi+wOGSYuI6JuSg07x40qRHKdrmw/uE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T/uTKjcEOyWaxOKmMi9NvI15ZgCwmA6efF2CeQKLQFE=; b=IJNAf7+YY8HzJ4hvghDQM/NWPxcpD1AlzGmJM+QLMr6IG9M0IvBcZoH8HGtb3u67aM DE5vuEg0JjG+wSRG6cc59AtypIKjOYX8CKTZ+inPJ/Viar6R8GLWsYwqOYZYmXxGAKG2 W9EsvG6MuR8lm/88B+m/TRFjZQRlw75seKru13iGIFxaKLS2CNNKDN7hD5pfRH718T5G HwNqYUMlugUabOB4oCJBTUSKLzPsQPHomN/Muen6iz38I8E9WRmq7rM8UG66JeKHg6ji 2i8jINYUCn3Nmv12+o85mNxj3oliMKJYZQ0/WEXMJu+9fHPLiC0SMFidANzS6w5kRLYR gUbw== X-Gm-Message-State: AElRT7ESti1Bae3vtQZp36tOjxDUo0g0JaBFGspPTEU1+t99JdSBmRP9 ewyKsQvB7upij9KnA6Q8EYuANw== X-Received: by 10.28.225.66 with SMTP id y63mr8256048wmg.148.1520265917419; Mon, 05 Mar 2018 08:05:17 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id y6sm6574381wmy.14.2018.03.05.08.05.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:05:16 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:04:12 +0000 Message-Id: <20180305160415.16760-55-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180305160415.16760-1-andre.przywara@linaro.org> References: <20180305160415.16760-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 54/57] ARM: new VGIC: vgic-init: implement map_resources X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" map_resources is the last initialization step needed before the first VCPU is run. At that stage the code stores the MMIO base addresses used. Also it registers the respective register frames with the MMIO framework. This is based on Linux commit cbae53e663ea, written by Eric Auger. Signed-off-by: Andre Przywara --- Changelog RFC ... v1: - adapting to previous changes xen/arch/arm/vgic/vgic-v2.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic/vgic.h | 1 + 2 files changed, 67 insertions(+) diff --git a/xen/arch/arm/vgic/vgic-v2.c b/xen/arch/arm/vgic/vgic-v2.c index 4e74ebf7f5..da64b4758c 100644 --- a/xen/arch/arm/vgic/vgic-v2.c +++ b/xen/arch/arm/vgic/vgic-v2.c @@ -221,6 +221,72 @@ void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr) gic_hw_ops->write_lr(lr, &lr_val); } +int vgic_v2_map_resources(struct domain *d) +{ + struct vgic_dist *dist = &d->arch.vgic; + paddr_t cbase, csize; + paddr_t vbase; + int ret; + + /* + * The hardware domain gets the hardware address. + * Guests get the virtual platform layout. + */ + if ( is_hardware_domain(d) ) + { + d->arch.vgic.vgic_dist_base = gic_v2_hw_data.dbase; + /* + * For the hardware domain, we always map the whole HW CPU + * interface region in order to match the device tree (the "reg" + * properties is copied as it is). + * Note that we assume the size of the CPU interface is always + * aligned to PAGE_SIZE. + */ + cbase = gic_v2_hw_data.cbase; /* was: dist->vgic_cpu_base */ + csize = gic_v2_hw_data.csize; + vbase = gic_v2_hw_data.vbase; /* was: kvm_vgic_global_state.vcpu_base */ + } + else + { + d->arch.vgic.vgic_dist_base = GUEST_GICD_BASE; + /* + * The CPU interface exposed to the guest is always 8kB. We may + * need to add an offset to the virtual CPU interface base + * address when in the GIC is aliased to get a 8kB contiguous + * region. + */ + BUILD_BUG_ON(GUEST_GICC_SIZE != SZ_8K); + cbase = GUEST_GICC_BASE; + csize = GUEST_GICC_SIZE; + vbase = gic_v2_hw_data.vbase + gic_v2_hw_data.aliased_offset; + } + + + ret = vgic_register_dist_iodev(d, gaddr_to_gfn(dist->vgic_dist_base), + VGIC_V2); + if ( ret ) + { + gdprintk(XENLOG_ERR, "Unable to register VGIC MMIO regions\n"); + return ret; + } + + /* + * Map the gic virtual cpu interface in the gic cpu interface + * region of the guest. + */ + ret = map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, + maddr_to_mfn(vbase)); + if ( ret ) + { + gdprintk(XENLOG_ERR, "Unable to remap VGIC CPU to VCPU\n"); + return ret; + } + + dist->ready = true; + + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vgic/vgic.h b/xen/arch/arm/vgic/vgic.h index f19dc9502f..6fab994b9c 100644 --- a/xen/arch/arm/vgic/vgic.h +++ b/xen/arch/arm/vgic/vgic.h @@ -61,6 +61,7 @@ void vgic_sync_hardware_irq(struct domain *d, void vgic_v2_fold_lr_state(struct vcpu *vcpu); void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr); void vgic_v2_set_underflow(struct vcpu *vcpu); +int vgic_v2_map_resources(struct domain *d); int vgic_register_dist_iodev(struct domain *d, gfn_t dist_base_fn, enum vgic_type);