All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: stefano.stabellini@citrix.com,
	Julien Grall <julien.grall@linaro.org>,
	tim@xen.org, ian.campbell@citrix.com
Subject: [PATCH 03/10] xen/arm: vgic-v3: Correctly handle GICD_CTLR
Date: Mon, 19 Jan 2015 16:29:10 +0000	[thread overview]
Message-ID: <1421684957-29884-4-git-send-email-julien.grall@linaro.org> (raw)
In-Reply-To: <1421684957-29884-1-git-send-email-julien.grall@linaro.org>

As backward GICv2 compatibility is not supported in the VGICv3 driver,
the bit ARE_NS should be set at any time.

Futhermore, when ARE_NS is set, the guest can only modify EnableGrp1A.

At same time take the vgic_lock to write into domain.arch.vgic.ctrl. It
was already taken during read.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/arch/arm/vgic-v3.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
index 406ea93..1aa2f58 100644
--- a/xen/arch/arm/vgic-v3.c
+++ b/xen/arch/arm/vgic-v3.c
@@ -45,6 +45,12 @@
 #define GICV3_GICR_PIDR2  GICV3_GICD_PIDR2
 #define GICV3_GICR_PIDR4  GICV3_GICD_PIDR4
 
+/*
+ * GICD_CTLR default value:
+ *      - No GICv2 compatibility => ARE = 1
+ */
+#define VGICD_CTLR_DEFAULT  (GICD_CTLR_ARE_NS)
+
 static struct vcpu *vgic_v3_irouter_to_vcpu(struct vcpu *v, uint64_t irouter)
 {
     irouter &= ~(GICD_IROUTER_SPI_MODE_ANY);
@@ -834,8 +840,15 @@ static int vgic_v3_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
     {
     case GICD_CTLR:
         if ( dabt.size != DABT_WORD ) goto bad_width;
-        /* Ignore all but the enable bit */
-        v->domain->arch.vgic.ctlr = (*r) & GICD_CTL_ENABLE;
+
+        vgic_lock(v);
+        /* Only EnableGrp1A can be changed */
+        if ( *r & GICD_CTLR_ENABLE_G1A )
+            v->domain->arch.vgic.ctlr |= GICD_CTLR_ENABLE_G1A;
+        else
+            v->domain->arch.vgic.ctlr &= ~GICD_CTLR_ENABLE_G1A;
+        vgic_unlock(v);
+
         return 1;
     case GICD_TYPER:
         /* RO -- write ignored */
@@ -1092,6 +1105,8 @@ static int vgic_v3_domain_init(struct domain *d)
         register_mmio_handler(d, &vgic_rdistr_mmio_handler,
             d->arch.vgic.rbase[i], d->arch.vgic.rbase_size[i]);
 
+    d->arch.vgic.ctlr = VGICD_CTLR_DEFAULT;
+
     return 0;
 }
 
-- 
2.1.4

  parent reply	other threads:[~2015-01-19 16:29 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19 16:29 [PATCH 00/10] xen/arm: Bug fixes for the vGIC Julien Grall
2015-01-19 16:29 ` [PATCH 01/10] xen/arm: vgic-v3: Correctly set GICD_TYPER.IDbits Julien Grall
2015-01-20 15:34   ` Ian Campbell
2015-01-20 17:16     ` Julien Grall
2015-01-20 15:43   ` Ian Campbell
2015-01-19 16:29 ` [PATCH 02/10] xen/arm: vgic-v3: Correctly set GICD_TYPER.CPUNumber Julien Grall
2015-01-20 15:43   ` Ian Campbell
2015-01-19 16:29 ` Julien Grall [this message]
2015-01-20 15:51   ` [PATCH 03/10] xen/arm: vgic-v3: Correctly handle GICD_CTLR Ian Campbell
2015-01-20 17:17     ` Julien Grall
2015-01-19 16:29 ` [PATCH 04/10] xen/arm: vgic-v3: Don't check the size when we ignore the write/read as zero Julien Grall
2015-01-20 15:57   ` Ian Campbell
2015-01-20 17:41     ` Julien Grall
2015-01-20 17:57       ` Ian Campbell
2015-01-20 18:50         ` Julien Grall
2015-01-21 12:11           ` Ian Campbell
2015-01-21 12:28             ` Julien Grall
2015-01-21 12:36               ` Ian Campbell
2015-01-21 12:45                 ` Julien Grall
2015-01-21 12:50                   ` Ian Campbell
2015-01-20 18:04       ` Julien Grall
2015-01-19 16:29 ` [PATCH 05/10] xen/arm: vgic-v3: Document the current restrictions Julien Grall
2015-01-20 16:00   ` Ian Campbell
2015-01-20 17:49     ` Julien Grall
2015-01-21 12:16       ` Ian Campbell
2015-01-21 12:33         ` Julien Grall
2015-01-21 12:48           ` Ian Campbell
2015-01-21 13:19             ` Julien Grall
2015-01-22 15:19               ` Julien Grall
2015-01-19 16:29 ` [PATCH 06/10] xen/arm: vgic-v3: Print the domain/vcpu in each message Julien Grall
2015-01-20 16:05   ` Ian Campbell
2015-01-20 17:50     ` Julien Grall
2015-01-19 16:29 ` [PATCH 07/10] xen/arm: vgic-v2: Correctly set GICD_TYPER.CPUNumber Julien Grall
2015-01-20 16:06   ` Ian Campbell
2015-01-19 16:29 ` [PATCH 08/10] xen/arm: vgic-v2: Don't check the size when we ignore the write/read a zero Julien Grall
2015-01-20 16:08   ` Ian Campbell
2015-01-19 16:29 ` [PATCH 09/10] xen/arm: vgic-v2: Take the lock when writing into GICD_CTLR Julien Grall
2015-01-20 16:09   ` Ian Campbell
2015-01-19 16:29 ` [PATCH 10/10] xen/arm: vgic-v2: Print the domain/vcpu in each message Julien Grall
2015-01-20 16:09   ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421684957-29884-4-git-send-email-julien.grall@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.