All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
	marc.zyngier@arm.com, christoffer.dall@linaro.org,
	vijayak@caviumnetworks.com, Vijaya.Kumar@cavium.com,
	peter.maydell@linaro.org, linux-arm-kernel@lists.infradead.org,
	drjones@redhat.com, kvmarm@lists.cs.columbia.edu,
	kvm@vger.kernel.org
Cc: andre.przywara@arm.com, pbonzini@redhat.com, dgilbert@redhat.com,
	Prasun.Kapoor@cavium.com
Subject: [RFC 07/13] KVM: arm64: ITS: Change entry_size and indirect bit in BASER
Date: Thu, 12 Jan 2017 16:56:47 +0100	[thread overview]
Message-ID: <1484236613-24633-8-git-send-email-eric.auger@redhat.com> (raw)
In-Reply-To: <1484236613-24633-1-git-send-email-eric.auger@redhat.com>

Change the device table entry_size to 16 bytes instead of 8.
We also Store the device and collection device in the its
struct.

The patch also clears the indirect bit for the device BASER.
The indirect bit is set as read-only.

Signed-off-by: Eric Auger <eric.auger@redhat.com>

---

TODO: investigate support of 2 level tables, ie. enabling
Indirect = 1. Support of 2 level tables is implementation
defined.
---
 include/kvm/arm_vgic.h       |  3 +++
 virt/kvm/arm/vgic/vgic-its.c | 25 ++++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index 730a18a..e6fc727 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -156,6 +156,9 @@ struct vgic_its {
 	u64			baser_device_table;
 	u64			baser_coll_table;
 
+	size_t			device_table_size;
+	size_t			collection_table_size;
+
 	/* Protects the command queue */
 	struct mutex		cmd_lock;
 	u64			cbaser;
diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index 96378b8..358ae38 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -34,6 +34,8 @@
 #include "vgic-mmio.h"
 
 #define ITTE_SIZE 16
+#define DEV_ENTRY_SIZE 16
+#define COLL_ENTRY_SIZE 16
 
 /*
  * Creates a new (reference to a) struct vgic_irq for a given LPI.
@@ -1269,14 +1271,16 @@ static unsigned long vgic_mmio_read_its_baser(struct kvm *kvm,
 	return extract_bytes(reg, addr & 7, len);
 }
 
-#define GITS_BASER_RO_MASK	(GENMASK_ULL(52, 48) | GENMASK_ULL(58, 56))
+#define GITS_BASER_RO_MASK	(GENMASK_ULL(52, 48) | GENMASK_ULL(58, 56) | \
+				 GENMASK_ULL(62, 62))
 static void vgic_mmio_write_its_baser(struct kvm *kvm,
 				      struct vgic_its *its,
 				      gpa_t addr, unsigned int len,
 				      unsigned long val)
 {
 	u64 entry_size, device_type;
-	u64 reg, *regptr, clearbits = 0;
+	u64 reg, *regptr;
+	size_t *psize;
 
 	/* When GITS_CTLR.Enable is 1, we ignore write accesses. */
 	if (its->enabled)
@@ -1285,14 +1289,15 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm,
 	switch (BASER_INDEX(addr)) {
 	case 0:
 		regptr = &its->baser_device_table;
-		entry_size = 8;
+		entry_size = DEV_ENTRY_SIZE;
 		device_type = GITS_BASER_TYPE_DEVICE;
+		psize = &its->device_table_size;
 		break;
 	case 1:
 		regptr = &its->baser_coll_table;
-		entry_size = 8;
+		entry_size = COLL_ENTRY_SIZE;
 		device_type = GITS_BASER_TYPE_COLLECTION;
-		clearbits = GITS_BASER_INDIRECT;
+		psize = &its->collection_table_size;
 		break;
 	default:
 		return;
@@ -1300,12 +1305,13 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm,
 
 	reg = update_64bit_reg(*regptr, addr & 7, len, val);
 	reg &= ~GITS_BASER_RO_MASK;
-	reg &= ~clearbits;
 
 	reg |= (entry_size - 1) << GITS_BASER_ENTRY_SIZE_SHIFT;
 	reg |= device_type << GITS_BASER_TYPE_SHIFT;
 	reg = vgic_sanitise_its_baser(reg);
 
+	*psize = ((reg & 0xFF) + 1) << 16;
+
 	*regptr = reg;
 }
 
@@ -1390,7 +1396,6 @@ static int vgic_register_its_iodev(struct kvm *kvm, struct vgic_its *its)
 	(GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWb)		| \
 	 GIC_BASER_CACHEABILITY(GITS_BASER, OUTER, SameAsInner)		| \
 	 GIC_BASER_SHAREABILITY(GITS_BASER, InnerShareable)		| \
-	 ((8ULL - 1) << GITS_BASER_ENTRY_SIZE_SHIFT)			| \
 	 GITS_BASER_PAGE_SIZE_64K)
 
 #define INITIAL_PROPBASER_VALUE						  \
@@ -1423,9 +1428,11 @@ static int vgic_its_create(struct kvm_device *dev, u32 type)
 	its->dev = dev;
 
 	its->baser_device_table = INITIAL_BASER_VALUE			|
-		((u64)GITS_BASER_TYPE_DEVICE << GITS_BASER_TYPE_SHIFT);
+		((u64)GITS_BASER_TYPE_DEVICE << GITS_BASER_TYPE_SHIFT)  |
+		((u64)(DEV_ENTRY_SIZE - 1) << GITS_BASER_ENTRY_SIZE_SHIFT);
 	its->baser_coll_table = INITIAL_BASER_VALUE |
-		((u64)GITS_BASER_TYPE_COLLECTION << GITS_BASER_TYPE_SHIFT);
+		((u64)GITS_BASER_TYPE_COLLECTION << GITS_BASER_TYPE_SHIFT) |
+		((u64)(COLL_ENTRY_SIZE - 1) << GITS_BASER_ENTRY_SIZE_SHIFT);
 	dev->kvm->arch.vgic.propbaser = INITIAL_PROPBASER_VALUE;
 
 	dev->private = its;
-- 
2.5.5

  parent reply	other threads:[~2017-01-12 15:56 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12 15:56 [RFC 00/13] vITS save/restore Eric Auger
2017-01-12 15:56 ` Eric Auger
2017-01-12 15:56 ` [RFC 01/13] KVM: arm/arm64: Add vITS save/restore API documentation Eric Auger
2017-01-12 16:52   ` Marc Zyngier
2017-01-12 16:52     ` Marc Zyngier
2017-01-13  9:07     ` Auger Eric
2017-01-13  9:07       ` Auger Eric
2017-01-13  9:46       ` Marc Zyngier
2017-01-13  9:46         ` Marc Zyngier
2017-01-30 16:15         ` Auger Eric
2017-01-30 16:15           ` Auger Eric
2017-02-03 14:00   ` Peter Maydell
2017-02-03 14:00     ` Peter Maydell
2017-02-03 14:51     ` Marc Zyngier
2017-02-03 14:51       ` Marc Zyngier
2017-01-12 15:56 ` [RFC 02/13] arm/arm64: vgic: turn vgic_find_mmio_region into public Eric Auger
2017-01-12 15:56 ` [RFC 03/13] KVM: arm64: ITS: KVM_DEV_ARM_VGIC_GRP_ITS_REGS group Eric Auger
2017-01-12 15:56 ` [RFC 04/13] KVM: arm64: ITS: Implement vgic_its_has_attr_regs and attr_regs_access Eric Auger
2017-01-12 15:56 ` [RFC 05/13] KVM: arm64: ITS: Implement vgic_mmio_uaccess_write_its_creadr Eric Auger
2017-01-12 15:56 ` [RFC 06/13] KVM: arm64: ITS: Expose ITT_Entry_Size in GITS_TYPER Eric Auger
2017-01-12 17:06   ` Andre Przywara
2017-01-12 17:06     ` Andre Przywara
2017-01-13  8:31     ` Auger Eric
2017-01-13  8:31       ` Auger Eric
2017-01-12 15:56 ` Eric Auger [this message]
2017-01-12 17:05   ` [RFC 07/13] KVM: arm64: ITS: Change entry_size and indirect bit in BASER Marc Zyngier
2017-01-12 17:05     ` Marc Zyngier
2017-01-13  8:57     ` Auger Eric
2017-01-13  8:57       ` Auger Eric
2017-01-13  9:22       ` Marc Zyngier
2017-01-13  9:22         ` Marc Zyngier
2017-01-12 15:56 ` [RFC 08/13] KVM: arm64: ITS: On MAPD interpret and store itt_addr and size Eric Auger
2017-01-12 15:56 ` [RFC 09/13] KVM: arm64: ITS: KVM_DEV_ARM_VGIC_GRP_ITS_TABLES group Eric Auger
2017-01-12 15:56 ` [RFC 10/13] KVM: arm64: ITS: vgic_its_alloc_itte/device Eric Auger
2017-01-12 15:56 ` [RFC 11/13] KVM: arm64: ITS: Collection table save/restore Eric Auger
2017-01-12 15:56 ` [RFC 12/13] KVM: arm64: ITS: Device and translation table flush Eric Auger
2017-01-12 15:56 ` [RFC 13/13] KVM: arm64: ITS: Pending table save/restore Eric Auger

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=1484236613-24633-8-git-send-email-eric.auger@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=Prasun.Kapoor@cavium.com \
    --cc=Vijaya.Kumar@cavium.com \
    --cc=andre.przywara@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=dgilbert@redhat.com \
    --cc=drjones@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=vijayak@caviumnetworks.com \
    /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.