Message ID | 20151205003334.GB3117@hawk.localdomain (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hello! > FYI, I tried writing test cases for this issue with kvm-unit-tests. The > issue didn't reproduce for me. It's quite possible my test cases are > flawed, so I'm not making any claims about the validity of the series This is indeed very interesting, so i'll take a look at it. For now i've just only took a quick glance at the code, and i have at least one suggestion. Could you happen to have sp == 0 in check_xzr_sysreg()? In this case it will magically work. Also, you could try to write a test which tries to overwrite xzr. Something like: volatile int *addr1; volatile int *addr2; asm volatile("str %3, [%1]\n\t" "ldr wzr, [%1]\n\t" "str wzr, [%2]\n\t", "ldr %0, [%2]\n\t" :"=r"(res):"r"(addr1), "r"(addr2), "r"(some_nonzero_val):"memory"); Then check for res == some_nonzero_val. If they are equal, you've got the bug :) Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello! > But, if Pavel doesn't > mind trying them out on his system, then it'd be good to know if they > reproduce there. I'd like to find out if it's a test case problem or > something else strange going on with environments. Does not build, applied to master: --- cut --- aarch64-unknown-linux-gnu-gcc -std=gnu99 -ffreestanding -Wextra -O2 -I lib -I lib/libfdt -g -MMD -MF arm/.xzr-test.d -Wall -fomit-frame-pointer -fno-stack-protector -c -o arm/xzr-test.o arm/xzr-test.c arm/xzr-test.c: In function 'check_xzr_sysreg': arm/xzr-test.c:13:2: warning: implicit declaration of function 'mmu_disable' [-Wimplicit-function-declaration] mmu_disable(); /* Tell KVM to set HCR_TVM for this VCPU */ ^ aarch64-unknown-linux-gnu-gcc -std=gnu99 -ffreestanding -Wextra -O2 -I lib -I lib/libfdt -g -MMD -MF arm/.xzr-test.d -Wall -fomit-frame-pointer -fno-stack-protector -nostdlib -o arm/xzr-test.elf \ -Wl,-T,arm/flat.lds,--build-id=none,-Ttext=40080000 \ arm/xzr-test.o arm/cstart64.o lib/libcflat.a lib/libfdt/libfdt.a /usr/lib/gcc/aarch64-unknown-linux-gnu/4.9.0/libgcc.a lib/arm/libeabi.a arm/xzr-test.o: In function `check_xzr_sysreg': /cygdrive/d/Projects/kvm-unit-tests/arm/xzr-test.c:13: undefined reference to `mmu_disable' --- cut --- Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Dec 07, 2015 at 11:47:44AM +0300, Pavel Fedin wrote: > Hello! > > > But, if Pavel doesn't > > mind trying them out on his system, then it'd be good to know if they > > reproduce there. I'd like to find out if it's a test case problem or > > something else strange going on with environments. > > Does not build, applied to master: > --- cut --- > aarch64-unknown-linux-gnu-gcc -std=gnu99 -ffreestanding -Wextra -O2 -I lib -I lib/libfdt -g -MMD -MF arm/.xzr-test.d -Wall > -fomit-frame-pointer -fno-stack-protector -c -o arm/xzr-test.o arm/xzr-test.c > arm/xzr-test.c: In function 'check_xzr_sysreg': > arm/xzr-test.c:13:2: warning: implicit declaration of function 'mmu_disable' [-Wimplicit-function-declaration] > mmu_disable(); /* Tell KVM to set HCR_TVM for this VCPU */ > ^ > aarch64-unknown-linux-gnu-gcc -std=gnu99 -ffreestanding -Wextra -O2 -I lib -I lib/libfdt -g -MMD -MF arm/.xzr-test.d -Wall > -fomit-frame-pointer -fno-stack-protector -nostdlib -o arm/xzr-test.elf \ > -Wl,-T,arm/flat.lds,--build-id=none,-Ttext=40080000 \ > arm/xzr-test.o arm/cstart64.o lib/libcflat.a lib/libfdt/libfdt.a /usr/lib/gcc/aarch64-unknown-linux-gnu/4.9.0/libgcc.a > lib/arm/libeabi.a > arm/xzr-test.o: In function `check_xzr_sysreg': > /cygdrive/d/Projects/kvm-unit-tests/arm/xzr-test.c:13: undefined reference to `mmu_disable' > --- cut --- Have you done a git pull of your kvm-unit-tests repo lately? The patch that introduces mmu_disable was commit a few months ago or so. Other than your repo just not having mmu_disable(), then I can't think of why it compiles for me and not you. If you have done a recent git pull, then maybe do a 'make distclean; ./configure; make' Thanks, drew > > Kind regards, > Pavel Fedin > Expert Engineer > Samsung Electronics Research center Russia > > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arm/xzr-test.c b/arm/xzr-test.c new file mode 100644 index 0000000000000..77a11461c955c --- /dev/null +++ b/arm/xzr-test.c @@ -0,0 +1,61 @@ +#include <libcflat.h> +#include <chr-testdev.h> +#include <asm/setup.h> +#include <asm/smp.h> +#include <asm/mmu.h> +#include <asm/io.h> + +static void check_xzr_sysreg(void) +{ + uint64_t val; + + flush_tlb_all(); + mmu_disable(); /* Tell KVM to set HCR_TVM for this VCPU */ + + asm volatile("msr ttbr0_el1, %0" : : "r" (0x5555555555555555 & PAGE_MASK)); + isb(); + asm volatile("mrs %0, ttbr0_el1" : "=r" (val)); + isb(); + report("sysreg: sanity check: read 0x%016lx", val == (0x5555555555555555 & PAGE_MASK), val); + + asm volatile("msr ttbr0_el1, xzr"); + isb(); + asm volatile("mrs %0, ttbr0_el1" : "=r" (val)); + isb(); + report("sysreg: xzr check: read 0x%016lx", val == 0, val); + + halt(); +} + +static uint32_t *steal_mmio_addr(void) +{ + /* + * Steal an MMIO addr from chr-testdev. Before calling exit() + * chr-testdev must be reinit. + */ + return (uint32_t *)(0x0a003e00UL /* base */ + 0x40 /* queue pfn */); +} + +int main(void) +{ + volatile uint32_t *addr = steal_mmio_addr(); + uint32_t val; + long i; + + writel(0x55555555, addr); + val = readl(addr); + report("mmio: sanity check: read 0x%08lx", val == 0x55555555, val); + + mb(); + asm volatile("str wzr, [%0]" : : "r" (addr)); + val = readl(addr); + report("mmio: 'str wzr' check: read 0x%08lx", val == 0, val); + + chr_testdev_init(); + + smp_boot_secondary(1, check_xzr_sysreg); + for (i = 0; i < 1000000000; ++i) + cpu_relax(); + + return report_summary(); +} diff --git a/config/config-arm64.mak b/config/config-arm64.mak index d61b703c8140e..65b355175f8a0 100644 --- a/config/config-arm64.mak +++ b/config/config-arm64.mak @@ -12,9 +12,11 @@ cflatobjs += lib/arm64/processor.o cflatobjs += lib/arm64/spinlock.o # arm64 specific tests -tests = +tests = $(TEST_DIR)/xzr-test.flat include config/config-arm-common.mak arch_clean: arm_clean $(RM) lib/arm64/.*.d + +$(TEST_DIR)/xzr-test.elf: $(cstart.o) $(TEST_DIR)/xzr-test.o