qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: WANG Xuerui <i.qemu@xen0n.name>
To: WANG Xuerui <i.qemu@xen0n.name>, Qi Hu <huqi@loongson.cn>,
	WANG Xuerui <git@xen0n.name>,
	Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] tcg/loongarch64: Add direct jump support
Date: Wed, 12 Oct 2022 19:53:26 +0800	[thread overview]
Message-ID: <5da652b8-bee2-9c34-29c6-717068ed39fb@xen0n.name> (raw)
In-Reply-To: <d386cad2-02ea-e062-9a9d-86dbbf47b251@xen0n.name>

[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]


On 2022/10/12 19:34, WANG Xuerui wrote:
>> +    tcg_insn_unit i1, i2;
>> +
>> +    ptrdiff_t offset = addr - jmp_rx;
>> +
>> +    if (offset == sextreg(offset, 0, 28)) {
>> +        i1 = OPC_B | ((offset >> 18) & 0x3ff) | ((offset << 8) & 
>> 0x3fffc00);
> Use encode_sd10k16_insn instead. No need to juggle the bits yourself 
> and you get nice range assertion for free.
>> +        i2 = NOP; 

One more thing. I think there's a certain trend of making sure 
potentially bad things don't happen and stopping speculative insn 
fetch/execution by making the NOP here a BREAK instead. Although I'm not 
sure if LoongArch or TCG is affected by the various speculation 
vulnerabilities out there, to any degree, it might not hurt to just make 
it a BREAK? Performance shouldn't get affected in any way but one could 
probably sleep better with a guaranteed termination of execution flow 
after the B.

And you should change the "tcg_out32(s, NOP)" some lines above into just 
a "tcg_out_andi(s, 0, 0, 0)". This way you wouldn't have to define a NOP 
constant at all... Or, maybe better, make a "tcg_out_nop" helper right 
after the insn-defs include and after the "TCG intrinsics" section (it 
isn't one, but there isn't a better place), then use it here, so you get 
to include some more comments while still not having to define a NOP. Like:

static void tcg_out_nop(TCGContext *s)
{
	/* Conventional NOP in LoongArch is `andi zero, zero, 0`.  */
	tcg_out_opc_andi(s, 0, 0, 0);
}

[-- Attachment #2: Type: text/html, Size: 2170 bytes --]

  reply	other threads:[~2022-10-12 11:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12  9:13 [PATCH 0/2] tcg/loongarch64: add neg tcg_op and direct jump support Qi Hu
2022-10-12  9:13 ` [PATCH 1/2] tcg/loongarch64: Implement INDEX_op_neg_i{32,64} Qi Hu
2022-10-12  9:41   ` WANG Xuerui
2022-10-13  1:25     ` Qi Hu
2022-10-12  9:13 ` [PATCH 2/2] tcg/loongarch64: Add direct jump support Qi Hu
2022-10-12 11:34   ` WANG Xuerui
2022-10-12 11:53     ` WANG Xuerui [this message]
2022-10-13  1:25     ` Qi Hu
2022-10-13  3:01   ` [PATCH v2] " Qi Hu
2022-10-13 18:52     ` Richard Henderson
2022-10-14  3:14       ` Qi Hu

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=5da652b8-bee2-9c34-29c6-717068ed39fb@xen0n.name \
    --to=i.qemu@xen0n.name \
    --cc=git@xen0n.name \
    --cc=huqi@loongson.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).