From patchwork Thu Jan 29 18:25:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 43964 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5DF8624128 for ; Thu, 29 Jan 2015 18:28:18 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id f15sf1773631lbj.2 for ; Thu, 29 Jan 2015 10:28:17 -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=QtzioeceIci4YEg22rljHm1CEWXycFVX+l3quoagQ1E=; b=TJiVssIZs+eXoXzkULcJzHv+hDf1dIYVXlQnAFNbgX1hu1a0QRxJNH/Pu0tbfWNbN4 Hr/Kv6YYx6+QJRWJnqK1kPqUAtB4rJO8XnltNA+SZ+l+3U2KlD1FTbUlpPkXZd1jFYwC MbR0w4amlS8brox6UPy124HIoVWzsfEd4auSVa8GIFOuak33asWm52dIFrEcrDUvbIQV PkTU6U/OrhO6pqIrPeN+G9AfS0awTT0mvZIUfgTIO50cChM0ArUlvAgLNuxGivO7cHeV AAVZGysJ7ChoxqkGQst53suiKaFTHiBNgfbmgzp4lzxUvhkJMyHKGp2xamrBlDONxoGa +Rww== X-Gm-Message-State: ALoCoQn8jEFznp2Zzj3VKknXnFAxwirpEaftN2UNZZsKg8Qnk0lTQMHsvI5eQ+ZsTjZygxCBBJqk X-Received: by 10.152.36.168 with SMTP id r8mr314657laj.2.1422556097395; Thu, 29 Jan 2015 10:28:17 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.229 with SMTP id e5ls282701laa.105.gmail; Thu, 29 Jan 2015 10:28:16 -0800 (PST) X-Received: by 10.152.198.200 with SMTP id je8mr2405866lac.93.1422556096917; Thu, 29 Jan 2015 10:28:16 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id rb6si8232038lbb.8.2015.01.29.10.28.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 10:28:16 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id 10so31240408lbg.6 for ; Thu, 29 Jan 2015 10:28:16 -0800 (PST) X-Received: by 10.112.44.230 with SMTP id h6mr2532564lbm.98.1422556096798; Thu, 29 Jan 2015 10:28:16 -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 h5csp34246lbj; Thu, 29 Jan 2015 10:28:15 -0800 (PST) X-Received: by 10.180.88.103 with SMTP id bf7mr3700186wib.21.1422556090311; Thu, 29 Jan 2015 10:28:10 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ba9si1836124wjc.135.2015.01.29.10.28.09 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 10:28:10 -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 1YGtnz-0004tk-30; Thu, 29 Jan 2015 18:27:03 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YGtnv-0004pW-85 for xen-devel@lists.xenproject.org; Thu, 29 Jan 2015 18:26:59 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id F2/E2-03000-27B7AC45; Thu, 29 Jan 2015 18:26:58 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-21.messagelabs.com!1422556017!13337572!1 X-Originating-IP: [209.85.212.181] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25424 invoked from network); 29 Jan 2015 18:26:57 -0000 Received: from mail-wi0-f181.google.com (HELO mail-wi0-f181.google.com) (209.85.212.181) by server-12.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 29 Jan 2015 18:26:57 -0000 Received: by mail-wi0-f181.google.com with SMTP id fb4so28233593wid.2 for ; Thu, 29 Jan 2015 10:26:56 -0800 (PST) X-Received: by 10.194.172.35 with SMTP id az3mr3742226wjc.43.1422556016841; Thu, 29 Jan 2015 10:26:56 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id x18sm3518503wia.12.2015.01.29.10.26.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 10:26:56 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 29 Jan 2015 18:25:49 +0000 Message-Id: <1422555950-31821-15-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422555950-31821-1-git-send-email-julien.grall@linaro.org> References: <1422555950-31821-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Vijaya.Kumar@caviumnetworks.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v2 14/15] xen/arm: vgic: Drop iactive, ipend, pendsgi field 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: julien.grall@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.175 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 current VGIC code doesn't support to change the pending and active status of an IRQ via the (re-)distributor. If we plan to support it in the future, it will unlikely require a specific bitfield as we already store the status per vIRQ. Rather than wasting memory for nothing, drop thoses field. Any read to these registers will be RAZ and any write will print an error and inject a data abort to the guest. Signed-off-by: Julien Grall --- Changes in v2: - Patch added --- xen/arch/arm/vgic-v2.c | 71 +++++-------------------- xen/arch/arm/vgic-v3.c | 125 +++++++++++++++------------------------------ xen/include/asm-arm/vgic.h | 2 +- 3 files changed, 55 insertions(+), 143 deletions(-) diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 1a02541..3cf67a9 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -94,41 +94,15 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info) vgic_unlock_rank(v, rank, flags); return 1; + /* Read the pending status of an IRQ via GICD is not supported */ case GICD_ISPENDR ... GICD_ISPENDRN: - if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicd_reg - GICD_ISPENDR, DABT_WORD); - if ( rank == NULL) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = vgic_byte_read(rank->ipend, dabt.sign, gicd_reg); - vgic_unlock_rank(v, rank, flags); - return 1; - case GICD_ICPENDR ... GICD_ICPENDRN: - if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 0, gicd_reg - GICD_ICPENDR, DABT_WORD); - if ( rank == NULL) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = vgic_byte_read(rank->ipend, dabt.sign, gicd_reg); - vgic_unlock_rank(v, rank, flags); - return 1; + goto read_as_zero; + /* Read the active status of an IRQ via GICD is not supported */ case GICD_ISACTIVER ... GICD_ISACTIVERN: - if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicd_reg - GICD_ISACTIVER, DABT_WORD); - if ( rank == NULL) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = rank->iactive; - vgic_unlock_rank(v, rank, flags); - return 1; - case GICD_ICACTIVER ... GICD_ICACTIVERN: - if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicd_reg - GICD_ICACTIVER, DABT_WORD); - if ( rank == NULL) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = rank->iactive; - vgic_unlock_rank(v, rank, flags); - return 1; + goto read_as_zero; case GICD_ITARGETSR ... GICD_ITARGETSRN: if ( dabt.size != DABT_BYTE && dabt.size != DABT_WORD ) goto bad_width; @@ -174,23 +148,10 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info) *r = 0xdeadbeef; return 1; + /* Setting/Clearing the SGI pending bit via GICD is not supported */ case GICD_CPENDSGIR ... GICD_CPENDSGIRN: - if ( dabt.size != DABT_BYTE && dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicd_reg - GICD_CPENDSGIR, DABT_WORD); - if ( rank == NULL) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = vgic_byte_read(rank->pendsgi, dabt.sign, gicd_reg); - vgic_unlock_rank(v, rank, flags); - return 1; - case GICD_SPENDSGIR ... GICD_SPENDSGIRN: - if ( dabt.size != DABT_BYTE && dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicd_reg - GICD_SPENDSGIR, DABT_WORD); - if ( rank == NULL) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = vgic_byte_read(rank->pendsgi, dabt.sign, gicd_reg); - vgic_unlock_rank(v, rank, flags); - return 1; + goto read_as_zero; /* Implementation defined -- read as zero */ case 0xfd0 ... 0xfe4: @@ -346,21 +307,17 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info) case GICD_ISACTIVER ... GICD_ISACTIVERN: if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicd_reg - GICD_ISACTIVER, DABT_WORD); - if ( rank == NULL) goto write_ignore; - vgic_lock_rank(v, rank, flags); - rank->iactive &= ~*r; - vgic_unlock_rank(v, rank, flags); - return 1; + printk(XENLOG_G_ERR + "%pv: vGICD: unhandled word write %#"PRIregister" to ISACTIVER%d\n", + v, *r, gicd_reg - GICD_ISACTIVER); + return 0; case GICD_ICACTIVER ... GICD_ICACTIVERN: if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicd_reg - GICD_ICACTIVER, DABT_WORD); - if ( rank == NULL) goto write_ignore; - vgic_lock_rank(v, rank, flags); - rank->iactive &= ~*r; - vgic_unlock_rank(v, rank, flags); - return 1; + printk(XENLOG_ERR + "%pv: vGICD: unhandled word write %#"PRIregister" to ICACTIVER%d\n", + v, *r, gicd_reg - GICD_ICACTIVER); + return 0; case GICD_ITARGETSR ... GICD_ITARGETSR + 7: /* SGI/PPI target is read only */ diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index b59cc49..c68ef05 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -306,38 +306,16 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v, *r = rank->ienable; vgic_unlock_rank(v, rank, flags); return 1; + /* Read the pending status of an IRQ via GICD/GICR is not supported */ case GICD_ISPENDR ... GICD_ISPENDRN: - if ( dabt.size != DABT_BYTE && dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, reg - GICD_ISPENDR, DABT_WORD); - if ( rank == NULL ) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = vgic_byte_read(rank->ipend, dabt.sign, reg); - vgic_unlock_rank(v, rank, flags); - return 1; case GICD_ICPENDR ... GICD_ICPENDRN: - if ( dabt.size != DABT_BYTE && dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, reg - GICD_ICPENDR, DABT_WORD); - if ( rank == NULL ) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = vgic_byte_read(rank->ipend, dabt.sign, reg); - vgic_unlock_rank(v, rank, flags); - return 1; + goto read_as_zero; + + /* Read the active status of an IRQ via GICD/GICR is not supported */ case GICD_ISACTIVER ... GICD_ISACTIVERN: - if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, reg - GICD_ISACTIVER, DABT_WORD); - if ( rank == NULL ) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = rank->iactive; - vgic_unlock_rank(v, rank, flags); - return 1; case GICD_ICACTIVER ... GICD_ICACTIVERN: - if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, reg - GICD_ICACTIVER, DABT_WORD); - if ( rank == NULL ) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = rank->iactive; - vgic_unlock_rank(v, rank, flags); - return 1; + goto read_as_zero; + case GICD_IPRIORITYR ... GICD_IPRIORITYRN: if ( dabt.size != DABT_BYTE && dabt.size != DABT_WORD ) goto bad_width; rank = vgic_rank_offset(v, 8, reg - GICD_IPRIORITYR, DABT_WORD); @@ -415,36 +393,32 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v, return 1; case GICD_ISPENDR ... GICD_ISPENDRN: if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, reg - GICD_ISPENDR, DABT_WORD); - if ( rank == NULL ) goto write_ignore; - vgic_lock_rank(v, rank, flags); - rank->ipend = *r; - vgic_unlock_rank(v, rank, flags); - return 1; + printk(XENLOG_G_ERR + "%pv: %s: unhandled word write %#"PRIregister" to ISPENDR%d\n", + v, name, *r, reg - GICD_ISPENDR); + return 0; + case GICD_ICPENDR ... GICD_ICPENDRN: if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, reg - GICD_ICPENDR, DABT_WORD); - if ( rank == NULL ) goto write_ignore; - vgic_lock_rank(v, rank, flags); - rank->ipend &= ~*r; - vgic_unlock_rank(v, rank, flags); - return 1; + printk(XENLOG_G_ERR + "%pv: %s: unhandled word write %#"PRIregister" to ICPENDR%d\n", + v, name, *r, reg - GICD_ICPENDR); + return 0; + case GICD_ISACTIVER ... GICD_ISACTIVERN: if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, reg - GICD_ISACTIVER, DABT_WORD); - if ( rank == NULL ) goto write_ignore; - vgic_lock_rank(v, rank, flags); - rank->iactive &= ~*r; - vgic_unlock_rank(v, rank, flags); - return 1; + printk(XENLOG_G_ERR + "%pv: %s: unhandled word write %#"PRIregister" to ISACTIVER%d\n", + v, name, *r, reg - GICD_ISACTIVER); + return 0; + case GICD_ICACTIVER ... GICD_ICACTIVERN: if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, reg - GICD_ICACTIVER, DABT_WORD); - if ( rank == NULL ) goto write_ignore; - vgic_lock_rank(v, rank, flags); - rank->iactive &= ~*r; - vgic_unlock_rank(v, rank, flags); - return 1; + printk(XENLOG_G_ERR + "%pv: %s: unhandled word write %#"PRIregister" to ICACTIVER%d\n", + v, name, *r, reg - GICD_ICACTIVER); + return 0; + case GICD_IPRIORITYR ... GICD_IPRIORITYRN: if ( dabt.size != DABT_BYTE && dabt.size != DABT_WORD ) goto bad_width; rank = vgic_rank_offset(v, 8, reg - GICD_IPRIORITYR, DABT_WORD); @@ -496,8 +470,6 @@ static int vgic_v3_rdistr_sgi_mmio_read(struct vcpu *v, mmio_info_t *info, struct hsr_dabt dabt = info->dabt; struct cpu_user_regs *regs = guest_cpu_user_regs(); register_t *r = select_user_reg(regs, dabt.reg); - struct vgic_irq_rank *rank; - unsigned long flags; switch ( gicr_reg ) { @@ -517,22 +489,12 @@ static int vgic_v3_rdistr_sgi_mmio_read(struct vcpu *v, mmio_info_t *info, */ return __vgic_v3_distr_common_mmio_read("vGICR: SGI", v, info, gicr_reg); + + /* Read the pending status of an SGI is via GICR is not supported */ case GICR_ISPENDR0: - if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicr_reg - GICR_ISPENDR0, DABT_WORD); - if ( rank == NULL ) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = rank->pendsgi; - vgic_unlock_rank(v, rank, flags); - return 1; case GICR_ICPENDR0: - if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicr_reg - GICR_ICPENDR0, DABT_WORD); - if ( rank == NULL ) goto read_as_zero; - vgic_lock_rank(v, rank, flags); - *r = rank->pendsgi; - vgic_unlock_rank(v, rank, flags); - return 1; + goto read_as_zero; + case GICR_NSACR: /* We do not implement security extensions for guests, read zero */ goto read_as_zero_32; @@ -562,8 +524,6 @@ static int vgic_v3_rdistr_sgi_mmio_write(struct vcpu *v, mmio_info_t *info, struct hsr_dabt dabt = info->dabt; struct cpu_user_regs *regs = guest_cpu_user_regs(); register_t *r = select_user_reg(regs, dabt.reg); - struct vgic_irq_rank *rank; - unsigned long flags; switch ( gicr_reg ) { @@ -585,22 +545,18 @@ static int vgic_v3_rdistr_sgi_mmio_write(struct vcpu *v, mmio_info_t *info, info, gicr_reg); case GICR_ISPENDR0: if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicr_reg - GICR_ISACTIVER0, DABT_WORD); - if ( rank == NULL ) goto write_ignore; - vgic_lock_rank(v, rank, flags); - /* TODO: we just store the SGI pending status. Handle it properly */ - rank->pendsgi |= *r; - vgic_unlock_rank(v, rank, flags); - return 1; + printk(XENLOG_G_ERR + "%pv: vGICR: SGI: unhandled word write %#"PRIregister" to ISPENDR0\n", + v, *r); + return 0; + case GICR_ICPENDR0: if ( dabt.size != DABT_WORD ) goto bad_width; - rank = vgic_rank_offset(v, 1, gicr_reg - GICR_ISACTIVER0, DABT_WORD); - if ( rank == NULL ) goto write_ignore; - vgic_lock_rank(v, rank, flags); - /* TODO: we just store the SGI pending status. Handle it properly */ - rank->pendsgi &= ~*r; - vgic_unlock_rank(v, rank, flags); - return 1; + printk(XENLOG_G_ERR + "%pv: vGICR: SGI: unhandled word write %#"PRIregister" to ICPENDR0\n", + v, *r); + return 0; + case GICR_NSACR: /* We do not implement security extensions for guests, write ignore */ goto write_ignore_32; @@ -620,7 +576,6 @@ bad_width: write_ignore_32: if ( dabt.size != DABT_WORD ) goto bad_width; -write_ignore: return 1; } diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index 74d5a4e..0c7da7f 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -85,7 +85,7 @@ struct pending_irq /* Represents state corresponding to a block of 32 interrupts */ struct vgic_irq_rank { spinlock_t lock; /* Covers access to all other members of this struct */ - uint32_t ienable, iactive, ipend, pendsgi; + uint32_t ienable; uint32_t icfg[2]; uint32_t ipriority[8]; union {