From: Richard Henderson <rth@twiddle.net>
To: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, zealot351@gmail.com,
maria.klimushenkova@ispras.ru, batuzovk@ispras.ru
Subject: Re: [Qemu-devel] [PATCH] softmmu: fixing usage of cpu_st/ld* from helpers
Date: Mon, 15 Sep 2014 09:28:28 -0700 [thread overview]
Message-ID: <541713AC.9010105@twiddle.net> (raw)
In-Reply-To: <20140915105055.5548.45260.stgit@PASHA-ISP>
On 09/15/2014 03:50 AM, Pavel Dovgalyuk wrote:
> +/* inline helper ld function */
> +
> +static inline DATA_TYPE
> +glue(glue(helper_inline_ld, SUFFIX), MEMSUFFIX)(CPUArchState *env,
> + target_ulong addr,
> + int mmu_idx)
> +{
> + return glue(glue(helper_call_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx,
> + GETRA());
> +}
You'd have to mark this always_inline to make absolutely sure that the caller's
GETRA value is used. That said...
> @@ -76,7 +87,8 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
> mmu_idx = CPU_MMU_INDEX;
> if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ !=
> (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> - res = glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx);
> + res = glue(glue(helper_inline_ld, SUFFIX), MEMSUFFIX)(env, addr,
> + mmu_idx);
> } else {
> uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
> res = glue(glue(ld, USUFFIX), _raw)(hostaddr);
... this is also the wrong context.
The only GETRA value that helps you at all is the one from the *top level*
helper -- the one that's directly called from TCG code. So, in the case of
maskmov, helper_maskmov_xmm. Anything else and you aren't getting the call
site address from the TCG code, and so can't be used to detect the PC of the
MMU fault.
I guess there are only two real possibilities:
(1) Have the cpu_ldst_template helpers all be marked always_inline so that they
could use GETRA. I'm not too fond of this because we'd still get the wrong
results if these are not used from top-level helpers.
(2) Add helpers that accept the GETRA value from the top-level helper. And not
hidden within a macro or always_inline function. This helps us see what
portions of the code have been audited for the new interface. This will
involve quite a bit more code churn, but shouldn't been too difficult for any
single function.
r~
prev parent reply other threads:[~2014-09-15 16:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 10:50 [Qemu-devel] [PATCH] softmmu: fixing usage of cpu_st/ld* from helpers Pavel Dovgalyuk
2014-09-15 13:55 ` Peter Maydell
2014-09-15 16:28 ` Richard Henderson [this message]
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=541713AC.9010105@twiddle.net \
--to=rth@twiddle.net \
--cc=Pavel.Dovgaluk@ispras.ru \
--cc=batuzovk@ispras.ru \
--cc=maria.klimushenkova@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zealot351@gmail.com \
/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).