qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Self-modifying test case for mttcg


From: Andrew Jones
Subject: Re: [Qemu-devel] Self-modifying test case for mttcg
Date: Wed, 22 Jul 2015 17:01:17 +0200
User-agent: Mutt/1.5.23.1 (2014-03-12)

On Wed, Jul 22, 2015 at 02:38:11PM +0200, Andrew Jones wrote:
> On Tue, Jul 21, 2015 at 12:58:56PM +0200, Alexander Spyridakis wrote:
> > Hello all,
> > 
> > You can find a new self-modifying test case in the following branch:
> > > git clone https://git.virtualopensystems.com/dev/tcg_baremetal_tests.git 
> > > -b smc_test
> > 
> > For each core, the test will run a small assembly snippet which
> > increments a variable. Immediately after, the snippet is modified in
> > memory to increment by 1 or 2 every other loop cycle, then passes
> > execution to the next core. At the end of the test we calculate the
> > expected result and compare it to the actual incremented variable. If
> > all code modifications happened correctly we pass the test.
> > 
> > The test case has been tested with upstream QEMU, MTTCG and KVM with
> > success. Next version of the test will include more corner cases, such
> > as changing TBs immediately after code modification, to make sure that
> > we cover every scenario.
> > 
> > To run it:
> > > make virt (or virt64/vexpress for other targets)
> > > ~/mttcg/arm-softmmu/qemu-system-arm -nographic -M virt -cpu cortex-a15 
> > > -kernel build-virt/image-virt.axf -smp 8
> > 
> > Also, by popular demand I started a port of the test for kvm-unit-tests:
> > > git clone https://git.virtualopensystems.com/dev/kvm-unit-tests.git
> 
> I took a quick look at this and see issues with the test code. First,
> you're spinning on a stack variable with this,
> 
>     /* Wait for our turn */
>     while(next_cpu != cpu);
> 
> next_cpu needs to be global, and incremented atomically. I haven't gotten
> around to adding atomic_add/inc yet, but it would easy, and I'm happy to
> do it, even yet this week.
> 
> And, as for the MMU, I see from the comment in your test code that you're
> hitting an exception when trying to modify code. This is because the code
> is mapped readonly in order to use it from usermode. I suggest you modify
> the page tables (see below for how) to map the code writeable. Do this
> before kicking your secondary cpus, so they'll come up ready.
> 
> There are other issues you'll need to fix as well though in the test code;
> count should be initialized, result should be volatile, others? I suggest
> you make sure it works for one vcpu first.
> 
> For modifying page tables, I think something like this should work for
> you (untested)
> 
> #include <asm/setup.h>
> int main(void)
> {
>     mmu_set_range_ptes(mmu_idmap, PHYS_OFFSET, PHYS_OFFSET,
>                        PHYS_END, __pgprot(PTE_WBWA));
>     flush_tlb_all();
> 
>     ...
> 
> I look forward to seeing your fixed up kvm-unit-test test posted. Please
> CC me on it.

Just thought of another issue with the unit test. There's no isb()
following the code modification.

> 
> drew
> 
> > 
> > For the kvm-unit-tests version, I have some troubles with caches and
> > the MMU (which is disabled for this test). While TCG and MTTCG work,
> > KVM fails the test with strange results. I will keep looking to find
> > the exact problem.
> > 
> > Best regards.
> > 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]