From: Auger Eric <eric.auger@redhat.com>
To: Andrew Jones <drjones@redhat.com>,
Andre Przywara <andre.przywara@arm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
kvm@vger.kernel.org, Marc Zyngier <marc.zyngier@arm.com>,
qemu-devel@nongnu.org, kvmarm@lists.cs.columbia.edu,
Christoffer Dall <christoffer.dall@linaro.org>
Subject: Re: [Qemu-devel] [kvm-unit-tests PATCH 3/4] arm/arm64: GICv2: add GICD_ITARGETSR testing
Date: Wed, 23 Nov 2016 14:51:04 +0100 [thread overview]
Message-ID: <2df007cd-bfde-e79a-46c8-f0a399cd7bd9@redhat.com> (raw)
In-Reply-To: <d2ff98ec-7bf0-46b5-35e1-6d41ef11996f@redhat.com>
Hi Andre,
On 23/11/2016 14:24, Auger Eric wrote:
> Hi,
>
> On 18/11/2016 15:20, Andrew Jones wrote:
>> On Thu, Nov 17, 2016 at 05:57:51PM +0000, Andre Przywara wrote:
>>> Some tests for the ITARGETS registers.
>>> Bits corresponding to non-existent CPUs must be RAZ/WI.
>>> These registers must be byte-accessible, also check that accesses beyond
>>> the implemented IRQ limit are actually read-as-zero/write-ignore.
>>>
>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>> ---
>>> arm/gic.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> lib/arm/asm/gic.h | 1 +
>>> 2 files changed, 55 insertions(+)
>>>
>>> diff --git a/arm/gic.c b/arm/gic.c
>>> index a27da2c..02b1be1 100644
>>> --- a/arm/gic.c
>>> +++ b/arm/gic.c
>>> @@ -397,6 +397,57 @@ static bool test_priorities(int nr_irqs, void *priptr)
>>> return true;
>>> }
>>>
>>> +static bool test_targets(int nr_irqs)
>>> +{
>>> + void *targetsptr = gicv2_dist_base() + GICD_ITARGETSR;
>>> + u32 orig_targets;
>>> + u32 cpu_mask;
>>> + u32 pattern, reg;
>>> +
>>> + orig_targets = readl(targetsptr + 32);
>>> + report_prefix_push("ITARGETSR");
>>> +
>>> + cpu_mask = (1 << nr_cpus) - 1;
>>
>> Shouldn't this be 1 << (nr_cpus - 1) ?
> original looks correct to me.
>>
>> Is this test always going to be gicv2-only? We should probably comment it,
>> if so. We don't want to risk this being run when nr_cpus can be larger
>> than 8.
>>
>>> + cpu_mask |= cpu_mask << 8;
>>> + cpu_mask |= cpu_mask << 16;
> Don't we miss the 4th byte mask?
>
> Thanks
>
> Eric
>>> +
>>> + /* Check that bits for non implemented CPUs are RAZ/WI. */
>>> + if (nr_cpus < 8) {
>>> + writel(0xffffffff, targetsptr + 32);
>>> + report("bits for %d non-existent CPUs masked",
>>> + !(readl(targetsptr + 32) & ~cpu_mask), 8 - nr_cpus);
yep on AMD overdrive with smp=4 I get:
FAIL: gicv2: mmio: ITARGETSR: bits for 4 non-existent CPUs masked
Thanks
Eric
>>> + } else {
>>> + report_skip("CPU masking (all CPUs implemented)");
>>> + }
>>> +
>>> + report("accesses beyond limit RAZ/WI",
>>> + test_readonly_32(targetsptr + nr_irqs, true));
>>> +
>>> + pattern = 0x0103020f;
>>> + writel(pattern, targetsptr + 32);
>>> + reg = readl(targetsptr + 32);
>>> + report("register content preserved (%08x => %08x)",
>>> + reg == (pattern & cpu_mask), pattern & cpu_mask, reg);
>>> +
>>> + /*
>>> + * The TARGETS registers are byte accessible, do a byte-wide
>>> + * read and write of known content to check for this.
>>> + */
>>> + reg = readb(targetsptr + 33);
>>> + report("byte reads successful (0x%08x => 0x%02x)",
>>> + reg == (BYTE(pattern, 1) & cpu_mask),
>>> + pattern & cpu_mask, reg);
>>> +
>>> + pattern = REPLACE_BYTE(pattern, 2, 0x04);
>>> + writeb(BYTE(pattern, 2), targetsptr + 34);
>>> + reg = readl(targetsptr + 32);
>>> + report("byte writes successful (0x%02x => 0x%08x)",
>>> + reg == (pattern & cpu_mask), BYTE(pattern, 2), reg);
>>
>> Last patch also had a byte addressability test. Maybe we should make
>> a helper function?
>>
>>> +
>>> + writel(orig_targets, targetsptr + 32);
>>> + return true;
>>
>> Function can/should be void.
>>
>>> +}
>>> +
>>> static int gic_test_mmio(int gic_version)
>>> {
>>> u32 reg;
>>> @@ -436,6 +487,9 @@ static int gic_test_mmio(int gic_version)
>>>
>>> test_priorities(nr_irqs, gic_dist_base + GICD_IPRIORITYR);
>>>
>>> + if (gic_version == 2)
>>> + test_targets(nr_irqs);
>>> +
>>> return 0;
>>> }
>>>
>>> diff --git a/lib/arm/asm/gic.h b/lib/arm/asm/gic.h
>>> index cef748d..6f170cb 100644
>>> --- a/lib/arm/asm/gic.h
>>> +++ b/lib/arm/asm/gic.h
>>> @@ -14,6 +14,7 @@
>>> #define GICD_IGROUPR 0x0080
>>> #define GICD_ISENABLER 0x0100
>>> #define GICD_IPRIORITYR 0x0400
>>> +#define GICD_ITARGETSR 0x0800
>>> #define GICD_SGIR 0x0f00
>>> #define GICD_ICPIDR2 0x0fe8
>>>
>>> --
>>> 2.9.0
>>>
>>>
>>
>> Thanks,
>> drew
>>
next prev parent reply other threads:[~2016-11-23 13:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-17 17:57 [Qemu-devel] [kvm-unit-tests PATCH 0/4] kvm-unit-tests: add first GIC MMIO tests Andre Przywara
2016-11-17 17:57 ` [Qemu-devel] [kvm-unit-tests PATCH 1/4] arm/arm64: GIC: basic GICv2 " Andre Przywara
2016-11-18 13:06 ` Andrew Jones
2016-11-18 14:06 ` Andre Przywara
2016-11-23 13:00 ` Auger Eric
2016-11-17 17:57 ` [Qemu-devel] [kvm-unit-tests PATCH 2/4] arm/arm64: GICv2: add GICD_IPRIORITYR testing Andre Przywara
2016-11-18 14:02 ` Andrew Jones
2016-11-23 13:09 ` Auger Eric
2016-11-17 17:57 ` [Qemu-devel] [kvm-unit-tests PATCH 3/4] arm/arm64: GICv2: add GICD_ITARGETSR testing Andre Przywara
2016-11-18 14:20 ` Andrew Jones
2016-11-23 13:24 ` Auger Eric
2016-11-23 13:51 ` Auger Eric [this message]
2016-11-23 14:13 ` Andre Przywara
2016-11-23 14:57 ` Auger Eric
2016-11-17 17:57 ` [Qemu-devel] [kvm-unit-tests PATCH 4/4] arm/arm64: GICv3: add TYPER test Andre Przywara
2016-11-18 14:41 ` Andrew Jones
2016-11-23 14:04 ` Auger Eric
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=2df007cd-bfde-e79a-46c8-f0a399cd7bd9@redhat.com \
--to=eric.auger@redhat.com \
--cc=andre.przywara@arm.com \
--cc=christoffer.dall@linaro.org \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).