* [Qemu-devel] best way to implement a "memclear" type instruction in TCG?
@ 2014-01-22 18:58 Peter Maydell
2014-01-22 19:06 ` Richard Henderson
0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2014-01-22 18:58 UTC (permalink / raw)
To: QEMU Developers; +Cc: Richard Henderson
One of the instructions I need to implement for AArch64 is "DC ZVA",
which is basically "clear the block of memory at this address to zeroes".
What's the best way in a TCG frontend to implement this sort of thing?
The block is a fixed size (implementation-dependent, but less than 2K).
The instruction has to behave like a set of stores for the purposes of
access faults, watchpoints, and so on. Obviously one way to implement
this would be to emit TCG ops for a store-and-loop, but that means we're
doing a TLB walk for every 64 bytes we write. Is there a better approach?
In theory we could just find the pointer to the memory QEMU is backing
the guest RAM with and call memset on it...
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] best way to implement a "memclear" type instruction in TCG?
2014-01-22 18:58 [Qemu-devel] best way to implement a "memclear" type instruction in TCG? Peter Maydell
@ 2014-01-22 19:06 ` Richard Henderson
2014-01-22 19:24 ` Xin Tong
2014-02-27 16:23 ` Peter Maydell
0 siblings, 2 replies; 5+ messages in thread
From: Richard Henderson @ 2014-01-22 19:06 UTC (permalink / raw)
To: Peter Maydell, QEMU Developers
On 01/22/2014 10:58 AM, Peter Maydell wrote:
> In theory we could just find the pointer to the memory QEMU is backing
> the guest RAM with and call memset on it...
That's more or less what we do for the s390 insn XC.
See mem_helper.c, especially mvc_fast_memset.
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] best way to implement a "memclear" type instruction in TCG?
2014-01-22 19:06 ` Richard Henderson
@ 2014-01-22 19:24 ` Xin Tong
2014-01-22 19:30 ` Peter Maydell
2014-02-27 16:23 ` Peter Maydell
1 sibling, 1 reply; 5+ messages in thread
From: Xin Tong @ 2014-01-22 19:24 UTC (permalink / raw)
To: Richard Henderson; +Cc: Peter Maydell, QEMU Developers
would there be any memory ordering issue ? what if the host processor
has a more relaxed memory ordering then the guest. maybe memset with
membarriers in between.
Xin
On Wed, Jan 22, 2014 at 1:06 PM, Richard Henderson <rth@twiddle.net> wrote:
> On 01/22/2014 10:58 AM, Peter Maydell wrote:
>> In theory we could just find the pointer to the memory QEMU is backing
>> the guest RAM with and call memset on it...
>
> That's more or less what we do for the s390 insn XC.
> See mem_helper.c, especially mvc_fast_memset.
>
>
> r~
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] best way to implement a "memclear" type instruction in TCG?
2014-01-22 19:24 ` Xin Tong
@ 2014-01-22 19:30 ` Peter Maydell
0 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2014-01-22 19:30 UTC (permalink / raw)
To: Xin Tong; +Cc: QEMU Developers, Richard Henderson
On 22 January 2014 19:24, Xin Tong <trent.tong@gmail.com> wrote:
> would there be any memory ordering issue ? what if the host processor
> has a more relaxed memory ordering then the guest. maybe memset with
> membarriers in between.
In general we can ignore memory ordering issues because for
system emulation every TCG guest CPU runs in a single host
thread. (For linux-user emulation with a multithreaded guest binary
we just shrug and hope, but multithreaded guest programs don't work
for all sorts of other reasons...)
For AArch64 in particular this instruction works on Normal memory
and so the CPU is at liberty to perform fairly aggressive reordering
anyway.
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] best way to implement a "memclear" type instruction in TCG?
2014-01-22 19:06 ` Richard Henderson
2014-01-22 19:24 ` Xin Tong
@ 2014-02-27 16:23 ` Peter Maydell
1 sibling, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2014-02-27 16:23 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Alexander Graf
On 22 January 2014 19:06, Richard Henderson <rth@twiddle.net> wrote:
> On 01/22/2014 10:58 AM, Peter Maydell wrote:
>> In theory we could just find the pointer to the memory QEMU is backing
>> the guest RAM with and call memset on it...
>
> That's more or less what we do for the s390 insn XC.
> See mem_helper.c, especially mvc_fast_memset.
I deduce that those instructions can't have been tested
very thoroughly, because:
void cpu_physical_memory_unmap(void *buffer, hwaddr len,
int is_write, hwaddr access_len);
but
cpu_physical_memory_unmap(dest_p, 1, len, len);
and
cpu_physical_memory_unmap(dest_p, 1, len, len);
cpu_physical_memory_unmap(src_p, 0, len, len);
Note the argument ordering error!
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-02-27 16:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-22 18:58 [Qemu-devel] best way to implement a "memclear" type instruction in TCG? Peter Maydell
2014-01-22 19:06 ` Richard Henderson
2014-01-22 19:24 ` Xin Tong
2014-01-22 19:30 ` Peter Maydell
2014-02-27 16:23 ` Peter Maydell
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).