From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <cdall@linaro.org>,
kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Cc: Andre Przywara <andre.przywara@arm.com>,
Vijaya.Kumar@cavium.com, kvm@vger.kernel.org
Subject: Re: [PATCH 5/5] KVM: arm/arm64: vgic: Get rid of struct vmcr for GICv2
Date: Tue, 21 Mar 2017 14:36:00 +0000 [thread overview]
Message-ID: <8db97d92-be13-2e9a-90c6-e834e442ba5e@arm.com> (raw)
In-Reply-To: <20170321110530.15857-6-cdall@linaro.org>
On 21/03/17 11:05, Christoffer Dall wrote:
> There is no common code in the VGIC that uses the VMCR, so we have no
> use of the intermediate architecture-agnostic representation of the VMCR
> and might as well manipulate the bits specifically using the logic for
> the version of the GIC that the code supports.
>
> For GICv2, this means translating between the GICH_VMCR register format
> stored in memory and the GICC_X registers exported to user space, with
> the annoying quirk around the format of the GICC_PMR, where we export
> the 8 bit prority field using the lower 5 bits and always assuming
> bits[2:0] are clear.
>
> This now lets us get completely rid of struct vmcr and its common
> accessor functions.
>
> Signed-off-by: Christoffer Dall <cdall@linaro.org>
> ---
> virt/kvm/arm/vgic/vgic-mmio-v2.c | 51 +++++++++++++++++++++++++++++-----------
> virt/kvm/arm/vgic/vgic-mmio.c | 16 -------------
> virt/kvm/arm/vgic/vgic-v2.c | 29 -----------------------
> virt/kvm/arm/vgic/vgic.h | 14 -----------
> 4 files changed, 37 insertions(+), 73 deletions(-)
>
> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v2.c b/virt/kvm/arm/vgic/vgic-mmio-v2.c
> index a3ad7ff..1bdb990 100644
> --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c
> +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c
> @@ -219,23 +219,33 @@ static void vgic_mmio_write_sgipends(struct kvm_vcpu *vcpu,
> static unsigned long vgic_mmio_read_vcpuif(struct kvm_vcpu *vcpu,
> gpa_t addr, unsigned int len)
> {
> - struct vgic_vmcr vmcr;
> + u32 vmcr = vcpu->arch.vgic_cpu.vgic_v2.vgic_vmcr;
> u32 val;
>
> - vgic_get_vmcr(vcpu, &vmcr);
>
> switch (addr & 0xff) {
> case GIC_CPU_CTRL:
> - val = vmcr.ctlr;
> + val = (vmcr & GICH_VMCR_CTRL_MASK) >>
> + GICH_VMCR_CTRL_SHIFT;
> break;
> case GIC_CPU_PRIMASK:
> - val = vmcr.pmr;
> + /*
> + * Our KVM_DEV_TYPE_ARM_VGIC_V2 device ABI exports the
> + * the PMR field as GICH_VMCR.VMPriMask rather than
> + * GICC_PMR.Priority, so we expose the upper five bits of
> + * priority mask to userspace using the lower bits in the
> + * 32-bit word provided by userspace.
> + */
> + val = (vmcr & GICH_VMCR_PRIMASK_MASK) >>
> + GICH_VMCR_PRIMASK_SHIFT;
> break;
> case GIC_CPU_BINPOINT:
> - val = vmcr.bpr;
> + val = (vmcr & GICH_VMCR_BINPOINT_MASK) >>
> + GICH_VMCR_BINPOINT_SHIFT;
> break;
> case GIC_CPU_ALIAS_BINPOINT:
> - val = vmcr.abpr;
> + val = (vmcr & GICH_VMCR_ALIAS_BINPOINT_MASK) >>
> + GICH_VMCR_ALIAS_BINPOINT_SHIFT;
> break;
> case GIC_CPU_IDENT:
> val = ((PRODUCT_ID_KVM << 20) |
> @@ -253,26 +263,39 @@ static void vgic_mmio_write_vcpuif(struct kvm_vcpu *vcpu,
> gpa_t addr, unsigned int len,
> unsigned long val)
> {
> - struct vgic_vmcr vmcr;
> -
> - vgic_get_vmcr(vcpu, &vmcr);
> + u32 *vmcr = &vcpu->arch.vgic_cpu.vgic_v2.vgic_vmcr;
> + u32 mask, field;
>
> switch (addr & 0xff) {
> case GIC_CPU_CTRL:
> - vmcr.ctlr = val;
> + mask = GICH_VMCR_CTRL_MASK;
> + field = val << GICH_VMCR_CTRL_SHIFT;
> break;
> case GIC_CPU_PRIMASK:
> - vmcr.pmr = val;
> + /*
> + * Our KVM_DEV_TYPE_ARM_VGIC_V2 device ABI exports the
> + * the PMR field as GICH_VMCR.VMPriMask rather than
> + * GICC_PMR.Priority, so we obtain the upper five bits of
> + * priority mask from userspace using the lower bits in the
> + * 32-bit word provided by userspace.
> + */
> + mask = GICH_VMCR_PRIMASK_MASK;
> + field = val << GICH_VMCR_PRIMASK_SHIFT;
> break;
> case GIC_CPU_BINPOINT:
> - vmcr.bpr = val;
> + mask = GICH_VMCR_BINPOINT_MASK;
> + field = val << GICH_VMCR_BINPOINT_SHIFT;
> break;
> case GIC_CPU_ALIAS_BINPOINT:
> - vmcr.abpr = val;
> + mask = GICH_VMCR_ALIAS_BINPOINT_MASK;
> + field = val << GICH_VMCR_ALIAS_BINPOINT_SHIFT;
> break;
> + default:
> + return;
Something seems fishy here. If I have a GICv2-on-GICv3, my vmcr is still
that of a GICv3, not of a GICv2. Here, you're cramming everything into a
v2 representation, which is not going to work on GICv3.
Or am I missing something?
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2017-03-21 14:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 11:05 [PATCH 0/5] Clarify GICC_PMR export format and remove struct vmcr Christoffer Dall
2017-03-21 11:05 ` [PATCH 1/5] KVM: arm/arm64: Clarify GICC_PMR export format Christoffer Dall
2017-03-21 11:05 ` [PATCH 2/5] KVM: arm64: vgic: Factor out access_gic_ctlr into separate r/w functions Christoffer Dall
2017-03-21 11:05 ` [PATCH 3/5] KVM: arm64: vgic: Rename vgic_v3_cpu to vgic_cpu Christoffer Dall
2017-03-21 11:05 ` [PATCH 4/5] KVM: arm64: vgic: Get rid of struct vmcr for GICv3 Christoffer Dall
2017-03-21 14:17 ` Marc Zyngier
2017-03-21 11:05 ` [PATCH 5/5] KVM: arm/arm64: vgic: Get rid of struct vmcr for GICv2 Christoffer Dall
2017-03-21 14:36 ` Marc Zyngier [this message]
2017-03-21 16:01 ` Christoffer Dall
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=8db97d92-be13-2e9a-90c6-e834e442ba5e@arm.com \
--to=marc.zyngier@arm.com \
--cc=Vijaya.Kumar@cavium.com \
--cc=andre.przywara@arm.com \
--cc=cdall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox