qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org,
	qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, git@xen0n.name,
	jiaxun.yang@flygoat.com
Subject: Re: [PATCH v3 06/57] tcg/i386: Generalize multi-part load overlap test
Date: Mon, 1 May 2023 08:42:15 +0100	[thread overview]
Message-ID: <8ae3e772-c5c2-42ad-ffeb-f594f81b6a48@linaro.org> (raw)
In-Reply-To: <92b3252a-fd8a-91c6-c90a-3a858fd126fe@linaro.org>

On 4/29/23 14:01, Philippe Mathieu-Daudé wrote:
> On 24/4/23 07:40, Richard Henderson wrote:
>> Test for both base and index; use datahi as a temporary, overwritten
>> by the final load.  Always perform the loads in ascending order, so
>> that any (user-only) fault sees the correct address.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   tcg/i386/tcg-target.c.inc | 31 +++++++++++++++----------------
>>   1 file changed, 15 insertions(+), 16 deletions(-)
>>
>> diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc
>> index b986109d77..794d440a9e 100644
>> --- a/tcg/i386/tcg-target.c.inc
>> +++ b/tcg/i386/tcg-target.c.inc
>> @@ -2223,23 +2223,22 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, 
>> TCGReg datahi,
>>           if (TCG_TARGET_REG_BITS == 64) {
>>               tcg_out_modrm_sib_offset(s, movop + P_REXW + seg, datalo,
>>                                        base, index, 0, ofs);
>> +            break;
>> +        }
>> +        if (use_movbe) {
>> +            TCGReg t = datalo;
>> +            datalo = datahi;
>> +            datahi = t;
>> +        }
>> +        if (base == datalo || index == datalo) {
>> +            tcg_out_modrm_sib_offset(s, OPC_LEA, datahi, base, index, 0, ofs);
>> +            tcg_out_modrm_offset(s, movop + seg, datalo, datahi, 0);
>> +            tcg_out_modrm_offset(s, movop + seg, datahi, datahi, 4);
> 
> LGTM but I'd rather have someone fluent with x86 review this one...

The original address is (base + (index << 0) + ofs).

If datalo overlaps either base or index, then we can't use the same form of address for 
the second load for datahi.  So we "Load Effective Address" to perform the computation of 
the original address once, storing into datahi as temporary (we are guaranteed that datalo 
!= datahi because they're both outputs).  After that, the two addresses that we want are 
(datahi + 0) and (datahi + 4).


r~


  reply	other threads:[~2023-05-01  7:43 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24  5:40 [PATCH v3 00/57] tcg: Simplify calls to load/store helpers Richard Henderson
2023-04-24  5:40 ` [PATCH v3 01/57] tcg/loongarch64: Conditionalize tcg_out_exts_i32_i64 Richard Henderson
2023-04-25 19:40   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 02/57] tcg/mips: " Richard Henderson
2023-04-25 19:41   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 03/57] tcg/i386: Conditionalize tcg_out_extu_i32_i64 Richard Henderson
2023-04-25 19:41   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 04/57] tcg: Introduce tcg_out_movext2 Richard Henderson
2023-04-25 19:46   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 05/57] tcg/i386: Rationalize args to tcg_out_qemu_{ld,st} Richard Henderson
2023-04-24  5:40 ` [PATCH v3 06/57] tcg/i386: Generalize multi-part load overlap test Richard Henderson
2023-04-29 13:01   ` Philippe Mathieu-Daudé
2023-05-01  7:42     ` Richard Henderson [this message]
2023-04-24  5:40 ` [PATCH v3 07/57] tcg/i386: Introduce HostAddress Richard Henderson
2023-04-25 19:54   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 08/57] tcg/i386: Drop r0+r1 local variables from tcg_out_tlb_load Richard Henderson
2023-04-25 19:55   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 09/57] tcg/i386: Introduce tcg_out_testi Richard Henderson
2023-04-24  5:40 ` [PATCH v3 10/57] tcg/i386: Introduce prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 11/57] tcg/i386: Use indexed addressing for softmmu fast path Richard Henderson
2023-04-24  5:40 ` [PATCH v3 12/57] tcg/aarch64: Rationalize args to tcg_out_qemu_{ld, st} Richard Henderson
2023-04-24  5:40 ` [PATCH v3 13/57] tcg/aarch64: Introduce HostAddress Richard Henderson
2023-04-25 14:22   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 14/57] tcg/aarch64: Introduce prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 15/57] tcg/arm: Rationalize args to tcg_out_qemu_{ld,st} Richard Henderson
2023-04-24  5:40 ` [PATCH v3 16/57] tcg/arm: Introduce HostAddress Richard Henderson
2023-04-24  5:40 ` [PATCH v3 17/57] tcg/arm: Introduce prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 18/57] tcg/loongarch64: Rationalize args to tcg_out_qemu_{ld, st} Richard Henderson
2023-04-26 11:24   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 19/57] tcg/loongarch64: Introduce HostAddress Richard Henderson
2023-04-25 14:29   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 20/57] tcg/loongarch64: Introduce prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 21/57] tcg/mips: Rationalize args to tcg_out_qemu_{ld,st} Richard Henderson
2023-04-26 13:15   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 22/57] tcg/mips: Introduce prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 23/57] tcg/ppc: Rationalize args to tcg_out_qemu_{ld,st} Richard Henderson
2023-04-24  5:40 ` [PATCH v3 24/57] tcg/ppc: Introduce HostAddress Richard Henderson
2023-04-25 14:39   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 25/57] tcg/ppc: Introduce prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 26/57] tcg/riscv: Require TCG_TARGET_REG_BITS == 64 Richard Henderson
2023-04-24  5:40 ` [PATCH v3 27/57] tcg/riscv: Rationalize args to tcg_out_qemu_{ld,st} Richard Henderson
2023-04-24  5:40 ` [PATCH v3 28/57] tcg/riscv: Introduce prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 29/57] tcg/s390x: Pass TCGType to tcg_out_qemu_{ld,st} Richard Henderson
2023-04-24  5:40 ` [PATCH v3 30/57] tcg/s390x: Introduce HostAddress Richard Henderson
2023-04-25 14:40   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 31/57] tcg/s390x: Introduce prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 32/57] tcg/sparc64: Drop is_64 test from tcg_out_qemu_ld data return Richard Henderson
2023-04-24  5:40 ` [PATCH v3 33/57] tcg/sparc64: Pass TCGType to tcg_out_qemu_{ld,st} Richard Henderson
2023-04-24  5:40 ` [PATCH v3 34/57] tcg: Move TCGLabelQemuLdst to tcg.c Richard Henderson
2023-04-26 13:18   ` Philippe Mathieu-Daudé
2023-04-24  5:40 ` [PATCH v3 35/57] tcg: Replace REG_P with arg_loc_reg_p Richard Henderson
2023-04-24  5:40 ` [PATCH v3 36/57] tcg: Introduce arg_slot_stk_ofs Richard Henderson
2023-04-24  5:40 ` [PATCH v3 37/57] tcg: Widen helper_*_st[bw]_mmu val arguments Richard Henderson
2023-04-24  5:40 ` [PATCH v3 38/57] tcg: Add routines for calling slow-path helpers Richard Henderson
2023-04-24  5:40 ` [PATCH v3 39/57] tcg/i386: Convert tcg_out_qemu_ld_slow_path Richard Henderson
2023-04-24  5:40 ` [PATCH v3 40/57] tcg/i386: Convert tcg_out_qemu_st_slow_path Richard Henderson
2023-04-24  5:40 ` [PATCH v3 41/57] tcg/aarch64: Convert tcg_out_qemu_{ld,st}_slow_path Richard Henderson
2023-04-24  5:40 ` [PATCH v3 42/57] tcg/arm: " Richard Henderson
2023-04-24  5:40 ` [PATCH v3 43/57] tcg/loongarch64: Convert tcg_out_qemu_{ld, st}_slow_path Richard Henderson
2023-04-24  5:40 ` [PATCH v3 44/57] tcg/mips: Convert tcg_out_qemu_{ld,st}_slow_path Richard Henderson
2023-04-24  5:40 ` [PATCH v3 45/57] tcg/ppc: " Richard Henderson
2023-04-24  5:40 ` [PATCH v3 46/57] tcg/riscv: " Richard Henderson
2023-04-24  5:40 ` [PATCH v3 47/57] tcg/s390x: " Richard Henderson
2023-04-24  5:40 ` [PATCH v3 48/57] tcg/loongarch64: Simplify constraints on qemu_ld/st Richard Henderson
2023-04-24  5:40 ` [PATCH v3 49/57] tcg/mips: Remove MO_BSWAP handling Richard Henderson
2023-04-24  5:40 ` [PATCH v3 50/57] tcg/mips: Reorg tlb load within prepare_host_addr Richard Henderson
2023-04-24  5:40 ` [PATCH v3 51/57] tcg/mips: Simplify constraints on qemu_ld/st Richard Henderson
2023-04-24  5:41 ` [PATCH v3 52/57] tcg/ppc: Reorg tcg_out_tlb_read Richard Henderson
2023-04-24  5:41 ` [PATCH v3 53/57] tcg/ppc: Adjust constraints on qemu_ld/st Richard Henderson
2023-04-24  5:41 ` [PATCH v3 54/57] tcg/ppc: Remove unused constraints A, B, C, D Richard Henderson
2023-04-29 12:29   ` Philippe Mathieu-Daudé
2023-05-01  7:23     ` Richard Henderson
2023-04-24  5:41 ` [PATCH v3 55/57] tcg/riscv: Simplify constraints on qemu_ld/st Richard Henderson
2023-04-24  5:41 ` [PATCH v3 56/57] tcg/s390x: Use ALGFR in constructing softmmu host address Richard Henderson
2023-04-24  5:41 ` [PATCH v3 57/57] tcg/s390x: Simplify constraints on qemu_ld/st Richard Henderson

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=8ae3e772-c5c2-42ad-ffeb-f594f81b6a48@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=git@xen0n.name \
    --cc=jiaxun.yang@flygoat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@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).