[PULL kvm-unit-tests 36/39] arm/arm64: ITS: INT functional tests

2020-04-04 Thread Andrew Jones
From: Eric Auger Triggers LPIs through the INT command. the test checks the LPI hits the right CPU and triggers the right LPI intid, ie. the translation is correct. Updates to the config table also are tested, along with inv and invall commands. Signed-off-by: Eric Auger Reviewed-by: Zenghui

[PULL kvm-unit-tests 34/39] arm/arm64: ITS: Device and collection Initialization

2020-04-04 Thread Andrew Jones
From: Eric Auger Introduce an helper functions to register - a new device, characterized by its device id and the max number of event IDs that dimension its ITT (Interrupt Translation Table). The function allocates the ITT. - a new collection, characterized by its ID and the target

[PULL kvm-unit-tests 39/39] arm/arm64: ITS: pending table migration test

2020-04-04 Thread Andrew Jones
From: Eric Auger Add two new migration tests. One testing the migration of a topology where collection were unmapped. The second test checks the migration of the pending table. Signed-off-by: Eric Auger [ Complete migration even when the test is skipped. Otherwise the migration scripts hang.

[PULL kvm-unit-tests 35/39] arm/arm64: ITS: Commands

2020-04-04 Thread Andrew Jones
From: Eric Auger Implement main ITS commands. The code is largely inherited from the ITS driver. Signed-off-by: Eric Auger Reviewed-by: Zenghui Yu Signed-off-by: Andrew Jones --- arm/Makefile.arm64 | 2 +- lib/arm64/asm/gic-v3-its.h | 55 + lib/arm64/gic-v3-its-cmd.c | 459

[PULL kvm-unit-tests 30/39] arm/arm64: gicv3: Add some re-distributor defines

2020-04-04 Thread Andrew Jones
From: Eric Auger PROPBASER, PENDBASE and GICR_CTRL will be used for LPI management. Signed-off-by: Eric Auger Reviewed-by: Zenghui Yu Signed-off-by: Andrew Jones --- lib/arm/asm/gic-v3.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/lib/arm/asm/gic-v3.h b/lib/arm/asm/gic-v3.h

[PULL kvm-unit-tests 37/39] arm/run: Allow Migration tests

2020-04-04 Thread Andrew Jones
From: Eric Auger Let's link getchar.o to use puts and getchar from the tests. Then allow tests belonging to the migration group to trigger the migration from the test code by putting "migrate" into the uart. Then the code can wait for the migration completion by using getchar(). The __getchar

[PULL kvm-unit-tests 38/39] arm/arm64: ITS: migration tests

2020-04-04 Thread Andrew Jones
From: Eric Auger This test maps LPIs (populates the device table, the collection table, interrupt translation tables, configuration table), migrates and make sure the translation is correct on the destination. Signed-off-by: Eric Auger Reviewed-by: Zenghui Yu [ Complete migration even when

[PULL kvm-unit-tests 33/39] arm/arm64: ITS: its_enable_defaults

2020-04-04 Thread Andrew Jones
From: Eric Auger its_enable_defaults() enable LPIs at redistributor level and ITS level. gicv3_enable_defaults must be called before. Signed-off-by: Eric Auger Reviewed-by: Zenghui Yu Signed-off-by: Andrew Jones --- lib/arm/asm/gic-v3.h | 6 ++ lib/arm/gic-v3.c | 25

[PULL kvm-unit-tests 31/39] arm/arm64: gicv3: Set the LPI config and pending tables

2020-04-04 Thread Andrew Jones
From: Eric Auger Allocate the LPI configuration and per re-distributor pending table. Set redistributor's PROPBASER and PENDBASER. The LPIs are enabled by default in the config table. Also introduce a helper routine that allows to set the pending table bit for a given LPI and macros to set/get

[PULL kvm-unit-tests 21/39] arm: pmu: Basic event counter Tests

2020-04-04 Thread Andrew Jones
From: Eric Auger Adds the following tests: - event-counter-config: test event counter configuration - basic-event-count: - programs counters #0 and #1 to count 2 required events (resp. CPU_CYCLES and INST_RETIRED). Counter #0 is preset to a value close enough to the 32b overflow limit so

[PULL kvm-unit-tests 25/39] arm: gic: Introduce gic_irq_set_clr_enable() helper

2020-04-04 Thread Andrew Jones
From: Eric Auger Allows to set or clear the enable state of a PPI/SGI/SPI. Signed-off-by: Eric Auger Signed-off-by: Andrew Jones --- lib/arm/asm/gic.h | 4 lib/arm/gic.c | 31 +++ 2 files changed, 35 insertions(+) diff --git a/lib/arm/asm/gic.h

[PULL kvm-unit-tests 16/39] arm: pmu: Let pmu tests take a sub-test parameter

2020-04-04 Thread Andrew Jones
From: Eric Auger As we intend to introduce more PMU tests, let's add a sub-test parameter that will allow to categorize them. Existing tests are in the cycle-counter category. Signed-off-by: Eric Auger Reviewed-by: Andre Przywara Signed-off-by: Andrew Jones --- arm/pmu.c | 25

[PULL kvm-unit-tests 23/39] arm: pmu: Test chained counters

2020-04-04 Thread Andrew Jones
From: Eric Auger Add 2 tests exercising chained counters. The first one uses CPU_CYCLES and the second one uses SW_INCR. Signed-off-by: Eric Auger Signed-off-by: Andrew Jones --- arm/pmu.c | 98 ++- arm/unittests.cfg | 12 ++ 2 files

[PULL kvm-unit-tests 17/39] arm: pmu: Don't check PMCR.IMP anymore

2020-04-04 Thread Andrew Jones
From: Eric Auger check_pmcr() checks the IMP field is different than 0. However A zero IMP field is permitted by the architecture, meaning the MIDR_EL1 should be looked at instead. This causes TCG to fail this test on '-cpu max' because in that case PMCR.IMP is set equal to MIDR_EL1.Implementer

[PULL kvm-unit-tests 15/39] arm64: Provide read/write_sysreg_s

2020-04-04 Thread Andrew Jones
Sometimes we need to test access to system registers which are missing assembler mnemonics. Signed-off-by: Andrew Jones Reviewed-by: Alexandru Elisei --- lib/arm64/asm/sysreg.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/lib/arm64/asm/sysreg.h b/lib/arm64/asm/sysreg.h

[PULL kvm-unit-tests 20/39] arm: pmu: Check Required Event Support

2020-04-04 Thread Andrew Jones
From: Eric Auger If event counters are implemented check the common events required by the PMUv3 are implemented. Some are unconditionally required (SW_INCR, CPU_CYCLES, either INST_RETIRED or INST_SPEC). Some others only are required if the implementation implements some other features. Check

[PULL kvm-unit-tests 22/39] arm: pmu: Test SW_INCR event count

2020-04-04 Thread Andrew Jones
From: Eric Auger Add tests dedicated to SW_INCR event counting. Signed-off-by: Eric Auger Signed-off-by: Andrew Jones --- arm/pmu.c | 47 +++ arm/unittests.cfg | 6 ++ 2 files changed, 53 insertions(+) diff --git a/arm/pmu.c

[PULL kvm-unit-tests 24/39] arm: pmu: test 32-bit <-> 64-bit transitions

2020-04-04 Thread Andrew Jones
From: Eric Auger Test configurations where we transit from 32b to 64b counters and conversely. Also tests configuration where chain counters are configured but only one counter is enabled. Signed-off-by: Eric Auger Signed-off-by: Andrew Jones --- arm/pmu.c | 138

[PULL kvm-unit-tests 32/39] arm/arm64: ITS: Introspection tests

2020-04-04 Thread Andrew Jones
From: Eric Auger Detect the presence of an ITS as part of the GICv3 init routine, initialize its base address and read few registers the IIDR, the TYPER to store its dimensioning parameters. Parse the BASER registers. As part of the init sequence we also init all the requested tables. This is

[PULL kvm-unit-tests 19/39] arm: pmu: Introduce defines for PMU versions

2020-04-04 Thread Andrew Jones
From: Eric Auger Introduce some defines encoding the different PMU versions. v3 is encoded differently in 32 and 64 bits. Signed-off-by: Eric Auger Signed-off-by: Andrew Jones --- arm/pmu.c | 26 +- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git

[PULL kvm-unit-tests 26/39] arm: pmu: Test overflow interrupts

2020-04-04 Thread Andrew Jones
From: Eric Auger Test overflows for MEM_ACCESS and SW_INCR events. Also tests overflows with 64-bit events. Signed-off-by: Eric Auger Signed-off-by: Andrew Jones --- arm/pmu.c | 139 ++ arm/unittests.cfg | 6 ++ 2 files changed, 145

[PULL kvm-unit-tests 27/39] libcflat: Add other size defines

2020-04-04 Thread Andrew Jones
From: Eric Auger Introduce additional SZ_256, SZ_8K, SZ_16K macros that will be used by ITS tests. Signed-off-by: Eric Auger Reviewed-by: Thomas Huth Signed-off-by: Andrew Jones --- lib/libcflat.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/libcflat.h b/lib/libcflat.h index

[PULL kvm-unit-tests 29/39] arm/arm64: gic: Introduce setup_irq() helper

2020-04-04 Thread Andrew Jones
From: Eric Auger ipi_enable() code would be reusable for other interrupts than IPI. Let's rename it setup_irq() and pass an interrupt handler pointer. Signed-off-by: Eric Auger Signed-off-by: Andrew Jones --- arm/gic.c | 19 ++- lib/arm/asm/processor.h | 2 ++

[PULL kvm-unit-tests 28/39] page_alloc: Introduce get_order()

2020-04-04 Thread Andrew Jones
From: Eric Auger Compute the power of 2 order of a size. Use it in page_memalign. Other users are looming. Signed-off-by: Eric Auger Signed-off-by: Andrew Jones --- lib/alloc_page.c | 7 ++- lib/alloc_page.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git

[PULL kvm-unit-tests 13/39] arm64: timer: Use existing helpers to access counter/timers

2020-04-04 Thread Andrew Jones
From: Zenghui Yu We already have some good helpers to access the counter and timer registers. Use them to avoid open coding the accessors again. Signed-off-by: Zenghui Yu Signed-off-by: Andrew Jones --- arm/timer.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff

[PULL kvm-unit-tests 14/39] arm64: timer: Speed up gic-timer-state check

2020-04-04 Thread Andrew Jones
Let's bail out of the wait loop if we see the expected state to save over six seconds of run time. Make sure we wait a bit before reading the registers and double check again after, though, to somewhat mitigate the chance of seeing the expected state by accident. We also take this opportunity to

[PULL kvm-unit-tests 18/39] arm: pmu: Add a pmu struct

2020-04-04 Thread Andrew Jones
From: Eric Auger This struct aims at storing information potentially used by all tests such as the pmu version, the read-only part of the PMCR, the number of implemented event counters, ... Signed-off-by: Eric Auger Reviewed-by: Andre Przywara Signed-off-by: Andrew Jones --- arm/pmu.c | 29

[PULL kvm-unit-tests 11/39] arm/arm64: gic: Move gic_state enumeration to asm/gic.h

2020-04-04 Thread Andrew Jones
From: Zenghui Yu The status of each interrupt are defined by the GIC architecture and maintained by GIC hardware. They're not specified to the timer HW. Let's move this software enumeration to a more proper place. Signed-off-by: Zenghui Yu Signed-off-by: Andrew Jones --- arm/timer.c |

[PULL kvm-unit-tests 09/39] arm64: timer: Test behavior when timer disabled or masked

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei When the timer is disabled (the *_CTL_EL0.ENABLE bit is clear) or the timer interrupt is masked at the timer level (the *_CTL_EL0.IMASK bit is set), timer interrupts must not be pending or asserted by the VGIC. However, only when the timer interrupt is masked, we can still

[PULL kvm-unit-tests 10/39] arm/arm64: Perform dcache clean + invalidate after turning MMU off

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei When the MMU is off, data accesses are to Device nGnRnE memory on arm64 [1] or to Strongly-Ordered memory on arm [2]. This means that the accesses are non-cacheable. Perform a dcache clean to PoC so we can read the newer values from the cache after we turn the MMU off,

[PULL kvm-unit-tests 03/39] arm64: timer: Add ISB after register writes

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei >From ARM DDI 0487E.a glossary, the section "Context synchronization event": "All direct and indirect writes to System registers that are made before the Context synchronization event affect any instruction, including a direct read, that appears in program order after the

[PULL kvm-unit-tests 12/39] arm64: timer: Use the proper RDist register name in GICv3

2020-04-04 Thread Andrew Jones
From: Zenghui Yu We're actually going to read GICR_ISACTIVER0 and GICR_ISPENDR0 (in SGI_base frame of the redistribitor) to get the active/pending state of the timer interrupt. Fix this typo. And since they have the same value, there's no functional change. Signed-off-by: Zenghui Yu

[PULL kvm-unit-tests 08/39] arm64: timer: Check the timer interrupt state

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei We check that the interrupt is pending (or not) at the GIC level, but we don't check if the timer is asserting it (or not). Let's make sure we don't run into a strange situation where the two devices' states aren't synchronized. Coincidently, the "interrupt signal no

[PULL kvm-unit-tests 01/39] Makefile: Use no-stack-protector compiler options

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei Let's fix the typos so that the -fno-stack-protector and -fno-stack-protector-all compiler options are actually used. Tested by compiling for arm64, x86_64 and ppc64 little endian. Before the patch, the arguments were missing from the gcc invocation; after the patch, they

[PULL kvm-unit-tests 02/39] arm/arm64: psci: Don't run C code without stack or vectors

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei The psci test performs a series of CPU_ON/CPU_OFF cycles for CPU 1. This is done by setting the entry point for the CPU_ON call to the physical address of the C function cpu_psci_cpu_die. The compiler is well within its rights to use the stack when generating code for

[PULL kvm-unit-tests 06/39] arm64: timer: EOIR the interrupt after masking the timer

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei Writing to the EOIR register before masking the HW mapped timer interrupt can cause taking another timer interrupt immediately after exception return. This doesn't happen all the time, because KVM reevaluates the state of pending HW mapped level sensitive interrupts on

[PULL kvm-unit-tests 07/39] arm64: timer: Wait for the GIC to sample timer interrupt state

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei There is a delay between the timer asserting the interrupt and the GIC sampling the interrupt state. Let's take that into account when we are checking if the timer interrupt is pending (or not) at the GIC level. An interrupt can be pending or active and pending [1,2].

[PULL kvm-unit-tests 05/39] arm64: timer: Make irq_received volatile

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei The irq_received field is modified by the interrupt handler. Make it volatile so that the compiler doesn't reorder accesses with regard to the instruction that will be causing the interrupt. Suggested-by: Andre Przywara Signed-off-by: Alexandru Elisei Signed-off-by:

[PULL kvm-unit-tests 00/39] arm/arm64: The old and new

2020-04-04 Thread Andrew Jones
Hi Paolo, This pull request is a repost of an older request, plus it contains Eric's new PMU and ITS tests. Thanks, drew The following changes since commit ce27fa2c7cd4d07859a9a2e81c7ff641897818d1: x86: vmx: skip atomic_switch_overflow_msrs_test on bare metal (2020-03-31 13:01:41 -0400)

[PULL kvm-unit-tests 04/39] arm64: timer: Add ISB before reading the counter value

2020-04-04 Thread Andrew Jones
From: Alexandru Elisei Reads of the physical counter and the virtual counter registers "can occur speculatively and out of order relative to other instructions executed on the same PE" [1, 2]. There is no theoretical limit to the number of instructions that the CPU can reorder and we use the