From: Richard Henderson <rth@twiddle.net>
To: identifier scorpio <cidentifier@yahoo.com.cn>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Porting TCG to alpha platform
Date: Sun, 31 Jan 2010 15:09:05 -0800 [thread overview]
Message-ID: <4B660D91.1010205@twiddle.net> (raw)
In-Reply-To: <180712.4158.qm@web15902.mail.cnb.yahoo.com>
[-- Attachment #1: Type: text/plain, Size: 684 bytes --]
> tcg_out_ld(s, TCG_TYPE_I64, r1, r1, offsetof(CPUTLBEntry, addend) -
> offsetof(CPUTLBEntry, addr_read));
>
> should be modified to
>
> tcg_out_ld(s, TCG_TYPE_I64, r1, r1, offsetof(CPUTLBEntry, addend));
Actually, it should be the entire offset from CPUState. The ADDR_WRITE
offset before was entirely stuffed into the LD offset.
> At the end of tcg_out_tlb_cmp(), R0's value is (page# | low bit of
> VA), if the branch is taken, i.e., TLB miss, R0 will be passed as an
> argument to helper functions, is it currently holding the correct
> value? I think at this time R0 should equal to addr_reg.
You're absolutely right here.
Here's the kind of patch I think will fix it.
r~
[-- Attachment #2: commit-04e0dc2 --]
[-- Type: text/plain, Size: 4403 bytes --]
commit 04e0dc252203bfbc5b02c2d3d8757a005e304a39
Author: Richard Henderson <rth@twiddle.net>
Date: Sun Jan 31 15:06:35 2010 -0800
tcg-alpha: Fix problems in qemu_ld/st.
Copy address to R0 in tcg_out_tlb_cmp, for use in helper path.
Use entire TLB constant offset performing the ADDEND read.
diff --git a/tcg/alpha/tcg-target.c b/tcg/alpha/tcg-target.c
index 519edef..463b7ee 100644
--- a/tcg/alpha/tcg-target.c
+++ b/tcg/alpha/tcg-target.c
@@ -709,9 +709,10 @@ static void *qemu_st_helpers[4] = {
static void tcg_out_tlb_cmp(TCGContext *s, int sizeop, int r0, int r1,
int addr_reg, int label1, long tlb_offset)
{
+ int addrsizeop = TARGET_LONG_BITS == 32 ? 2 : 3;
long val;
- /* Mask the page, plus the low bits of the access, into R0. Note
+ /* Mask the page, plus the low bits of the access, into TMP3. Note
that the low bits are added in order to catch unaligned accesses,
as those bits won't be set in the TLB entry. For 32-bit targets,
force the high bits of the mask to be zero, as the high bits of
@@ -720,7 +721,7 @@ static void tcg_out_tlb_cmp(TCGContext *s, int sizeop, int r0, int r1,
if (TARGET_LONG_BITS == 32) {
val &= 0xffffffffu;
}
- tcg_out_andi(s, addr_reg, val, r0);
+ tcg_out_andi(s, addr_reg, val, TMP_REG3);
/* Compute the index into the TLB into R1. Again, note that the
high bits of a 32-bit address must be cleared. */
@@ -736,11 +737,14 @@ static void tcg_out_tlb_cmp(TCGContext *s, int sizeop, int r0, int r1,
/* Load the word at (R1 + CPU_ENV + TLB_OFFSET). Note that we
arrange for a 32-bit load to be zero-extended. */
tcg_out_fmt_opr(s, INSN_ADDQ, r1, TCG_AREG0, r1);
- tcg_out_ld_sz(s, TARGET_LONG_BITS == 32 ? 2 : 3,
- TMP_REG2, r1, tlb_offset);
+ tcg_out_ld_sz(s, addrsizeop, TMP_REG2, r1, tlb_offset);
- /* Compare R0 with the value loaded from the TLB. */
- tcg_out_brcond(s, TCG_COND_NE, TMP_REG2, r0, 0, label1);
+ /* Copy the original address into R0. This is needed on the
+ slow path through the helper function. */
+ tcg_out_extend(s, addrsizeop, addr_reg, r0);
+
+ /* Compare TMP3 with the value loaded from the TLB. */
+ tcg_out_brcond(s, TCG_COND_NE, TMP_REG2, TMP_REG3, 0, label1);
}
#endif /* SOFTMMU */
@@ -769,20 +773,12 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int sizeop)
/* TLB Hit. Note that Alpha statically predicts forward branch as
not taken, so arrange the fallthru as the common case.
- ADDR_REG contains the guest address, and R1 contains the pointer
- to TLB_ENTRY.ADDR_READ. We need to load TLB_ENTRY.ADDEND and
- add it to ADDR_REG to get the host address. */
+ R0 contains the guest address, and R1 contains the pointer
+ to CPU_ENV plus the TLB entry offset. */
tcg_out_ld(s, TCG_TYPE_I64, r1, r1,
- offsetof(CPUTLBEntry, addend)
- - offsetof(CPUTLBEntry, addr_read));
-
- if (TARGET_LONG_BITS == 32) {
- tcg_out_extend(s, 2, addr_reg, r0);
- addr_reg = r0;
- }
-
- tcg_out_fmt_opr(s, INSN_ADDQ, addr_reg, r1, r0);
+ offsetof(CPUState, tlb_table[mem_index][0].addend));
+ tcg_out_fmt_opr(s, INSN_ADDQ, r0, r1, r0);
val = 0;
#else
r0 = addr_reg;
@@ -841,20 +837,12 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int sizeop)
/* TLB Hit. Note that Alpha statically predicts forward branch as
not taken, so arrange the fallthru as the common case.
- ADDR_REG contains the guest address, and R1 contains the pointer
- to TLB_ENTRY.ADDR_READ. We need to load TLB_ENTRY.ADDEND and
- add it to ADDR_REG to get the host address. */
+ R0 contains the guest address, and R1 contains the pointer
+ to CPU_ENV plus the TLB entry offset. */
tcg_out_ld(s, TCG_TYPE_I64, r1, r1,
- offsetof(CPUTLBEntry, addend)
- - offsetof(CPUTLBEntry, addr_write));
-
- if (TARGET_LONG_BITS == 32) {
- tcg_out_extend(s, 2, addr_reg, r0);
- addr_reg = r0;
- }
-
- tcg_out_fmt_opr(s, INSN_ADDQ, addr_reg, r1, r0);
+ offsetof(CPUState, tlb_table[mem_index][0].addend));
+ tcg_out_fmt_opr(s, INSN_ADDQ, r0, r1, r0);
val = 0;
#else
r0 = addr_reg;
next prev parent reply other threads:[~2010-01-31 23:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-22 15:47 [Qemu-devel] [PATCH] Porting TCG to alpha platform identifier scorpio
2010-01-22 18:00 ` Richard Henderson
2010-01-26 1:19 ` Richard Henderson
2010-01-29 1:55 ` identifier scorpio
2010-01-29 17:04 ` Richard Henderson
2010-01-29 21:38 ` Edgar E. Iglesias
2010-01-29 23:04 ` Stefan Weil
2010-01-30 0:38 ` Edgar E. Iglesias
2010-01-30 1:14 ` Laurent Desnogues
2010-01-30 9:30 ` [Qemu-devel] [BUG] qemu-x86_64 crash when running bntest (was: [PATCH] Porting TCG to alpha platform) Stefan Weil
2010-01-30 9:59 ` Laurent Desnogues
2010-01-30 14:47 ` Laurent Desnogues
2010-01-29 17:37 ` [Qemu-devel] [PATCH] Porting TCG to alpha platform Richard Henderson
2010-01-29 19:19 ` Richard Henderson
2010-01-30 2:45 ` identifier scorpio
2010-01-31 23:09 ` Richard Henderson [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-01-21 3:42 identifier scorpio
2010-01-21 18:18 ` Stefan Weil
2010-01-20 17:19 identifier scorpio
2010-01-20 21:26 ` Richard Henderson
2010-01-19 8:47 identifier scorpio
2010-01-19 20:18 ` Richard Henderson
2010-01-19 21:35 ` malc
2010-01-19 21:42 ` Stefan Weil
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=4B660D91.1010205@twiddle.net \
--to=rth@twiddle.net \
--cc=cidentifier@yahoo.com.cn \
--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).