From: "Emilio G. Cota" <cota@braap.org>
To: Richard Henderson <rth@twiddle.net>
Cc: Peter Maydell <peter.maydell@linaro.org>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [qemu] How to reliably obtain physaddr from vaddr
Date: Mon, 16 Mar 2015 16:08:37 -0400 [thread overview]
Message-ID: <20150316200837.GA30330@flamenco> (raw)
In-Reply-To: <20150316004231.GA13273@flamenco>
On Sun, Mar 15, 2015 at 20:42:31 -0400, Emilio G. Cota wrote:
> On Sun, Mar 15, 2015 at 16:10:21 -0700, Richard Henderson wrote:
> > It goes into softmmu_template.h. Which then tests a victim tlb, and finally
> > calls tlb_fill. You'll probably need to do the same.
>
> I've defined this vaddr->paddr as a helper and I'm calling it
> before every aa32 store. However, this isn't a smooth sailing:
>
> 1. futex_init in the kernel causes an oops--it passes vaddr=0
> but the call happens with pagefaults disabled:
> http://lxr.free-electrons.com/source/kernel/futex.c?v=3.18#L590
> in the code below I'm just returning to avoid the oops.
Please disregard this point--the oops doesn't happen with the code
I appended (it was triggered by previous iterations of it).
> 2. The kernel (vexpress-a9 from buildroot) doesn't boot.
Removing the call to tlb_fill() on a TLB miss solves the problem.
But of course this also means the helper doesn't work as intended.
I fail to see why calling tlb_fill() from the helper causes
trouble. What I thought would happen is that the exception
(if any) is started from the helper, gets serviced, and then
both the helper and the subsequent store hit in the TLB. I was
seeing this as a "TLB prefetch", but I cannot make it work.
What am I missing?
FWIW I'm appending the delta wrt my previous email.
Thanks,
Emilio
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
index 39cde9d..48c54f9 100644
--- a/include/exec/cpu_ldst_template.h
+++ b/include/exec/cpu_ldst_template.h
@@ -140,14 +140,6 @@ glue(cpu_st_paddr, MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
hwaddr ret;
addr = ptr;
- /*
- * XXX Understand why this is necessary.
- * futex_init on linux bootup calls cmpxchg on a NULL pointer. It expects
- * -EFAULT to be read back, but when we do the below we get a kernel oops.
- * However, when doing the load from TCG -EFAULT is read just fine--no oops.
- */
- if (unlikely(addr == 0))
- return 0;
page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
mmu_idx = CPU_MMU_INDEX;
if (unlikely(env->tlb_table[mmu_idx][page_index].addr_write !=
diff --git a/softmmu_template.h b/softmmu_template.h
index 172b718..1b6655e 100644
--- a/softmmu_template.h
+++ b/softmmu_template.h
@@ -476,7 +476,7 @@ hwaddr helper_ret_st_paddr(CPUArchState *env, target_ulong addr,
if ((addr & TARGET_PAGE_MASK)
!= (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) {
if (!VICTIM_TLB_HIT(addr_write)) {
- tlb_fill(ENV_GET_CPU(env), addr, MMU_DATA_STORE, mmu_idx, retaddr);
+ return 0;
}
}
return env->tlb_table[mmu_idx][index].addr_phys;
next prev parent reply other threads:[~2015-03-16 20:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20150315100051.GA26584@flamenco>
2015-03-15 23:10 ` [Qemu-devel] [qemu] How to reliably obtain physaddr from vaddr Richard Henderson
2015-03-16 0:42 ` Emilio G. Cota
2015-03-16 20:08 ` Emilio G. Cota [this message]
2015-03-16 22:23 ` Peter Maydell
2015-03-17 1:10 ` Emilio G. Cota
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=20150316200837.GA30330@flamenco \
--to=cota@braap.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).