qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* tcg: Requesting clarification on return value of prepare_host_addr
@ 2025-12-05  8:38 Shusaku KURAMITSU
  2025-12-05 14:44 ` Peter Maydell
  0 siblings, 1 reply; 5+ messages in thread
From: Shusaku KURAMITSU @ 2025-12-05  8:38 UTC (permalink / raw)
  To: qemu-devel

Hello,


I've noticed a possible discrepancy between the comment and the behavior

of i386's prepare_host_addr (located at tcg/i386/tcg-target.c.inc, line 
2157-2260):


```

/*
  * For softmmu, perform the TLB load and compare.
  * For useronly, perform any required alignment tests.
  * In both cases, return a TCGLabelQemuLdst structure if the slow path
  * is required and fill in @h with the host address for the fast path.
  */
static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
                                            TCGReg addr, MemOpIdx oi, 
bool is_ld)
{
     TCGLabelQemuLdst *ldst = NULL;

...
     if (tcg_use_softmmu) {

...

         ldst = new_ldst_label(s);
         ldst->is_ld = is_ld;
         ldst->oi = oi;
         ldst->addr_reg = addr;

...

     } else if (a_mask) {
...
     }

     return ldst;
}

```


The code appears to always assign (in case of softmmu) a label to `ldst` 
and return it,

contrary to what the comment suggests (that, "in both cases [of softmmu 
and useronly],

return a TCGLabelQemuLdst structure *if the slow path is required*".)

As I understand it, there is no way to determine, at this point, which 
of the two paths to use;

the generated machine code (see L2233-2237), not the C code here, 
performs the TLB comparison.


I am currently building a modified version of QEMU for my undergraduate 
project, and this is

one of the most complicated code paths I've had to deal with.

I hope this is the right place to ask these kinds of questions, and if 
not, please let me know.


Thanks,


Shusaku KURAMITSU

Dept. of Computer Science and Networks

School of Computer Science and Systems Engineering

Kyushu Institute of Technology, Japan




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-09  7:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05  8:38 tcg: Requesting clarification on return value of prepare_host_addr Shusaku KURAMITSU
2025-12-05 14:44 ` Peter Maydell
2025-12-08  9:37   ` Shusaku KURAMITSU
2025-12-08 10:11     ` Peter Maydell
2025-12-09  7:39       ` Shusaku KURAMITSU

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).