From 1ac75f06add54089e4910ecb6a97198336155c63 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 17 Jan 2017 19:04:37 +0100 Subject: executor: fix copyin of values Currently non-bitfield values are copied incorrectly. Probably all turned into zeros or something. Fix that. Add test. --- executor/test_kvm.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'executor/test_kvm.cc') diff --git a/executor/test_kvm.cc b/executor/test_kvm.cc index 4d990dc19..6c76b5e78 100644 --- a/executor/test_kvm.cc +++ b/executor/test_kvm.cc @@ -8,6 +8,22 @@ #include +extern "C" int test_copyin() +{ + unsigned char x[4] = {}; + STORE_BY_BITMASK(uint16_t, &x[1], 0x1234, 0, 0); + if (x[0] != 0 || x[1] != 0x34 || x[2] != 0x12 || x[3] != 0) { + printf("bad result of STORE_BY_BITMASK(0, 0): %x %x %x %x\n", x[0], x[1], x[2], x[3]); + return 1; + } + STORE_BY_BITMASK(uint16_t, &x[1], 0x555a, 5, 4); + if (x[0] != 0 || x[1] != 0x54 || x[2] != 0x13 || x[3] != 0) { + printf("bad result of STORE_BY_BITMASK(7, 3): %x %x %x %x\n", x[0], x[1], x[2], x[3]); + return 1; + } + return 0; +} + static unsigned host_kernel_version(); static void dump_cpu_state(int cpufd, char* vm_mem); -- cgit mrf-deployment