From: Richard Henderson <rth@twiddle.net>
To: Aurelien Jarno <aurelien@aurel32.net>, qemu-devel@nongnu.org
Cc: Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH v2 16/16] target-s390x: fix MVC instruction when areas overlap
Date: Wed, 03 Jun 2015 14:54:19 -0700 [thread overview]
Message-ID: <556F778B.7020905@twiddle.net> (raw)
In-Reply-To: <1433365796-1118-17-git-send-email-aurelien@aurel32.net>
On 06/03/2015 02:09 PM, Aurelien Jarno wrote:
> The MVC instruction and the memmove C funtion do not have the same
> semantic when memory areas overlap:
>
> MVC: When the operands overlap, the result is obtained as if the
> operands were processed one byte at a time and each result byte were
> stored immediately after fetching the necessary operand byte.
>
> memmove: Copying takes place as though the bytes in src are first copied
> into a temporary array that does not overlap src or dest, and the bytes
> are then copied from the temporary array to dest.
>
> The behaviour is therefore the same when the destination is at a lower
> address than the source, but not in the other case. This is actually a
> trick for propagating a value to an area. While the current code detects
> that and call memset in that case, it only does for 1-byte value. This
> trick can and is used for propagating two or more bytes to an area.
>
> In the softmmu case, the call to mvc_fast_memmove is correct as the
> above tests verify that source and destination are each within a page,
> and both in a different page. The part doing the move 8 bytes by 8 bytes
> is wrong and we need to check that if the source and destination
> overlap, they do with a distance of minimum 8 bytes before copying 8
> bytes at a time.
>
> In the user code, we should check check that the destination is at a
> lower address than source or than the end of the source is at a lower
> address than the destination before calling memmove. In the opposite
> case we fallback to the same code as the softmmu one. Note that l
> represents (length - 1).
>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
> target-s390x/mem_helper.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
Reviewed-by: Richard Henderson <rth@twiddle.net>
r~
next prev parent reply other threads:[~2015-06-03 21:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 21:09 [Qemu-devel] [PATCH v2 00/16] fixes and improvements Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 01/16] target-s390x: fix exception for invalid operation code Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 02/16] target-s390x: fix CLGIT instruction Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 03/16] target-s390x: change CHRL and CGHRL format to RIL-b Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 04/16] target-s390x: move STORE CLOCK FAST to the correct facility Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 05/16] target-s390x: move SET DFP ROUNDING MODE " Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 06/16] target-s390x: implement LOAD FP INTEGER instructions Aurelien Jarno
2015-06-03 22:26 ` Richard Henderson
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 07/16] target-s390x: implement TRANSLATE AND TEST instruction Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 08/16] target-s390x: implement TRANSLATE EXTENDED instruction Aurelien Jarno
2015-06-03 21:37 ` Richard Henderson
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 09/16] target-s390x: implement LPDFR and LNDFR instructions Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 10/16] target-s390x: implement miscellaneous-instruction-extensions facility Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 11/16] target-s390x: implement load-and-trap facility Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 12/16] target-s390x: implement high-word facility Aurelien Jarno
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 13/16] target-s390x: add a cpu_mmu_idx_to_asc function Aurelien Jarno
2015-06-03 21:40 ` Richard Henderson
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 14/16] target-s390x: support non current ASC in s390_cpu_handle_mmu_fault Aurelien Jarno
2015-06-03 21:42 ` Richard Henderson
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 15/16] target-s390x: use softmmu functions for mvcp/mvcs Aurelien Jarno
2015-06-03 22:06 ` Richard Henderson
2015-06-03 21:09 ` [Qemu-devel] [PATCH v2 16/16] target-s390x: fix MVC instruction when areas overlap Aurelien Jarno
2015-06-03 21:54 ` Richard Henderson [this message]
2015-06-03 22:29 ` [Qemu-devel] [PATCH v2 00/16] fixes and improvements Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=556F778B.7020905@twiddle.net \
--to=rth@twiddle.net \
--cc=agraf@suse.de \
--cc=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).