qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Inquiry About PC-Relative Code Generation in QEMU
@ 2024-11-02 11:54 Yip Coekjan
  0 siblings, 0 replies; 4+ messages in thread
From: Yip Coekjan @ 2024-11-02 11:54 UTC (permalink / raw)
  To: qemu-devel

Dear QEMU Community,
I hope this message finds you well.
I recently started studying the QEMU TCG code, and I have noticed that QEMU 
seems to support generating PC-Relative Code (`CF_PCREL`), but this feature 
seems currently enabled only for System Emulation in version 9.1.0, while it 
is not available for User Emulation. Could you please clarify if there are 
specific functionality or performance considerations behind this decision?
Additionally, if this feature were to be enabled for User Emulation, could we 
consider the code generated by QEMU as Position-Independent Code (PIC)?
Thank you for your assistance.
Best regards,
Yip Coekjan




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

* Inquiry About PC-Relative Code Generation in QEMU
@ 2024-11-02 12:05 Coekjan Yip
  2024-11-04 12:51 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Coekjan Yip @ 2024-11-02 12:05 UTC (permalink / raw)
  To: qemu-devel

Dear QEMU Community,

I hope this message finds you well.

I recently started studying the QEMU TCG code, and I have noticed that QEMU
seems to support generating PC-Relative Code (`CF_PCREL`), but this feature
seems currently enabled only for System Emulation in version 9.1.0, while it
is not available for User Emulation. Could you please clarify if there are
specific functionality or performance considerations behind this decision?
Additionally, if this feature were to be enabled for User Emulation, could we
consider the code generated by QEMU as Position-Independent Code (PIC)?
Thank you for your assistance.

Best regards,
Yip Coekjan


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

* Re: Inquiry About PC-Relative Code Generation in QEMU
  2024-11-02 12:05 Inquiry About PC-Relative Code Generation in QEMU Coekjan Yip
@ 2024-11-04 12:51 ` Richard Henderson
  2024-11-05  7:57   ` Yip Coekjan
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2024-11-04 12:51 UTC (permalink / raw)
  To: Coekjan Yip, qemu-devel

On 11/2/24 12:05, Coekjan Yip wrote:
> Dear QEMU Community,
> 
> I hope this message finds you well.
> 
> I recently started studying the QEMU TCG code, and I have noticed that QEMU
> seems to support generating PC-Relative Code (`CF_PCREL`), but this feature
> seems currently enabled only for System Emulation in version 9.1.0, while it
> is not available for User Emulation. Could you please clarify if there are
> specific functionality or performance considerations behind this decision?

User emulation does not have multiple mappings of the same physical page like system mode 
does.  This is because in user emulation we have only one process to emulate.

> Additionally, if this feature were to be enabled for User Emulation, could we
> consider the code generated by QEMU as Position-Independent Code (PIC)?

No.  Treating the guest code as PC as a variable instead of a constant is different from 
generating position independent host code.


r~


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

* Re: Inquiry About PC-Relative Code Generation in QEMU
  2024-11-04 12:51 ` Richard Henderson
@ 2024-11-05  7:57   ` Yip Coekjan
  0 siblings, 0 replies; 4+ messages in thread
From: Yip Coekjan @ 2024-11-05  7:57 UTC (permalink / raw)
  To: qemu-devel, Richard Henderson

Thank you for your response.

On 11/4/24 20:51:40, Richard Henderson wrote:

> User emulation does not have multiple mappings of the same physical page
> like system mode does.  This is because in user emulation we have only one
> process to emulate.

To clarify, is the reason QEMU does not use `CF_PCREL` for user emulation 
because it could potentially generate more opcodes, thus impacting 
performance?

> No.  Treating the guest code as PC as a variable instead of a constant is
> different from generating position independent host code.

I briefly went through `target/i386/tcg/translate.c` and noticed that when 
`CF_PCREL` is enabled, the generated opcodes seem to resemble PIC (Position-
Independent Code). My understanding is that `CF_PCREL` was not originally 
intended for generating PIC, but the host code generated does appear to be 
PIC. As I'm not very familiar with QEMU, please correct me if I'm mistaken.

Best regards,
Yip Coekjan




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

end of thread, other threads:[~2024-11-05  7:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-02 12:05 Inquiry About PC-Relative Code Generation in QEMU Coekjan Yip
2024-11-04 12:51 ` Richard Henderson
2024-11-05  7:57   ` Yip Coekjan
  -- strict thread matches above, loose matches on Subject: below --
2024-11-02 11:54 Yip Coekjan

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