* Does the page boundary check still necessary?
@ 2023-02-15  8:39 Kenneth Lee
  2023-02-15 17:27 ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Kenneth Lee @ 2023-02-15  8:39 UTC (permalink / raw)
  To: qemu-devel
Hello,
I hope I send this mail to the right place.
I'm porting a new guest arch. It jumps of out of physical page
constantly. So many TBs cannot be chained with goto_tb. I'm wondering 
if the following check is still necessary?
	bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
	{
	    /* Suppress goto_tb if requested. */
	    if (tb_cflags(db->tb) & CF_NO_GOTO_TB) {
		return false;
	    }
	    /* Check for the dest on the same page as the start of the TB.  */
	    return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0;    <--- Is this check really necessary?
	}
Now the chained TBs have been link with tb_link_page(), the chain will
be rebuilt if it is invalidate on page. So why is this check still there?
Acutally, I have tested some use cases with this check removed. It works
fine. Could anybody tell me in what case it is still necessary?
Thanks.
-- 
			-Kenneth
^ permalink raw reply	[flat|nested] 7+ messages in thread* Re: Does the page boundary check still necessary? 2023-02-15 8:39 Does the page boundary check still necessary? Kenneth Lee @ 2023-02-15 17:27 ` Richard Henderson 2023-02-16 1:45 ` Kenneth Lee 0 siblings, 1 reply; 7+ messages in thread From: Richard Henderson @ 2023-02-15 17:27 UTC (permalink / raw) To: Kenneth Lee, qemu-devel On 2/14/23 22:39, Kenneth Lee wrote: > Hello, > > I hope I send this mail to the right place. > > I'm porting a new guest arch. It jumps of out of physical page > constantly. So many TBs cannot be chained with goto_tb. I'm wondering > if the following check is still necessary? > > bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest) > { > /* Suppress goto_tb if requested. */ > if (tb_cflags(db->tb) & CF_NO_GOTO_TB) { > return false; > } > > /* Check for the dest on the same page as the start of the TB. */ > return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0; <--- Is this check really necessary? > } > > Now the chained TBs have been link with tb_link_page(), the chain will > be rebuilt if it is invalidate on page. So why is this check still there? Even for a guest which doesn't use paging, and therefore does not need to worry about memory maps changing, we still enable breakpoints and watchpoints on a per-page basis. r~ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does the page boundary check still necessary? 2023-02-15 17:27 ` Richard Henderson @ 2023-02-16 1:45 ` Kenneth Lee 2023-02-16 2:26 ` Richard Henderson 0 siblings, 1 reply; 7+ messages in thread From: Kenneth Lee @ 2023-02-16 1:45 UTC (permalink / raw) To: Richard Henderson; +Cc: qemu-devel On Wed, Feb 15, 2023 at 07:27:19AM -1000, Richard Henderson wrote: > Date: Wed, 15 Feb 2023 07:27:19 -1000 > From: Richard Henderson <richard.henderson@linaro.org> > To: Kenneth Lee <Kenneth-Lee-2012@foxmail.com>, qemu-devel@nongnu.org > Subject: Re: Does the page boundary check still necessary? > User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 > Thunderbird/102.7.1 > > On 2/14/23 22:39, Kenneth Lee wrote: > > Hello, > > > > I hope I send this mail to the right place. > > > > I'm porting a new guest arch. It jumps of out of physical page > > constantly. So many TBs cannot be chained with goto_tb. I'm wondering > > if the following check is still necessary? > > > > bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest) > > { > > /* Suppress goto_tb if requested. */ > > if (tb_cflags(db->tb) & CF_NO_GOTO_TB) { > > return false; > > } > > > > /* Check for the dest on the same page as the start of the TB. */ > > return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0; <--- Is this check really necessary? > > } > > > > Now the chained TBs have been link with tb_link_page(), the chain will > > be rebuilt if it is invalidate on page. So why is this check still there? > > Even for a guest which doesn't use paging, and therefore does not need to > worry about memory maps changing, we still enable breakpoints and > watchpoints on a per-page basis. > Thank you. So is this the only reason? May I write a fine grained checking to remove this limitation? > > r~ -- -Ken ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does the page boundary check still necessary? 2023-02-16 1:45 ` Kenneth Lee @ 2023-02-16 2:26 ` Richard Henderson 2023-02-16 2:28 ` Kenneth Lee 0 siblings, 1 reply; 7+ messages in thread From: Richard Henderson @ 2023-02-16 2:26 UTC (permalink / raw) To: Kenneth Lee; +Cc: qemu-devel On 2/15/23 15:45, Kenneth Lee wrote: >>> Now the chained TBs have been link with tb_link_page(), the chain will >>> be rebuilt if it is invalidate on page. So why is this check still there? >> >> Even for a guest which doesn't use paging, and therefore does not need to >> worry about memory maps changing, we still enable breakpoints and >> watchpoints on a per-page basis. >> > > Thank you. So is this the only reason? May I write a fine grained > checking to remove this limitation? No. r~ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does the page boundary check still necessary? 2023-02-16 2:26 ` Richard Henderson @ 2023-02-16 2:28 ` Kenneth Lee 2023-02-16 2:52 ` Richard Henderson 0 siblings, 1 reply; 7+ messages in thread From: Kenneth Lee @ 2023-02-16 2:28 UTC (permalink / raw) To: Richard Henderson; +Cc: qemu-devel On Wed, Feb 15, 2023 at 04:26:18PM -1000, Richard Henderson wrote: > Date: Wed, 15 Feb 2023 16:26:18 -1000 > From: Richard Henderson <richard.henderson@linaro.org> > To: Kenneth Lee <Kenneth-Lee-2012@foxmail.com> > Cc: qemu-devel@nongnu.org > Subject: Re: Does the page boundary check still necessary? > User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 > Thunderbird/102.7.1 > > On 2/15/23 15:45, Kenneth Lee wrote: > > > > Now the chained TBs have been link with tb_link_page(), the chain will > > > > be rebuilt if it is invalidate on page. So why is this check still there? > > > > > > Even for a guest which doesn't use paging, and therefore does not need to > > > worry about memory maps changing, we still enable breakpoints and > > > watchpoints on a per-page basis. > > > > > > > Thank you. So is this the only reason? May I write a fine grained > > checking to remove this limitation? > > No. > Why? > > r~ -- -Kenneth Lee (Hisilicon) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does the page boundary check still necessary? 2023-02-16 2:28 ` Kenneth Lee @ 2023-02-16 2:52 ` Richard Henderson 2023-02-16 9:35 ` Kenneth Lee 0 siblings, 1 reply; 7+ messages in thread From: Richard Henderson @ 2023-02-16 2:52 UTC (permalink / raw) To: Kenneth Lee; +Cc: qemu-devel On 2/15/23 16:28, Kenneth Lee wrote: > On Wed, Feb 15, 2023 at 04:26:18PM -1000, Richard Henderson wrote: >> Date: Wed, 15 Feb 2023 16:26:18 -1000 >> From: Richard Henderson <richard.henderson@linaro.org> >> To: Kenneth Lee <Kenneth-Lee-2012@foxmail.com> >> Cc: qemu-devel@nongnu.org >> Subject: Re: Does the page boundary check still necessary? >> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 >> Thunderbird/102.7.1 >> >> On 2/15/23 15:45, Kenneth Lee wrote: >>>>> Now the chained TBs have been link with tb_link_page(), the chain will >>>>> be rebuilt if it is invalidate on page. So why is this check still there? >>>> >>>> Even for a guest which doesn't use paging, and therefore does not need to >>>> worry about memory maps changing, we still enable breakpoints and >>>> watchpoints on a per-page basis. >>>> >>> >>> Thank you. So is this the only reason? May I write a fine grained >>> checking to remove this limitation? >> >> No. >> > Why? When breakpoints change, we discard all translations on the affected page, similarly to how we handle writes from self-modifying code. If you link from further away, then TBs won't be invalidated properly when breakpoints change. For most guests, this isn't a limitation because we also have to care for modifications to page tables, so we can't allow such links anyway. I have no idea what you're trying to accomplish that's different from existing guests. r~ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Does the page boundary check still necessary? 2023-02-16 2:52 ` Richard Henderson @ 2023-02-16 9:35 ` Kenneth Lee 0 siblings, 0 replies; 7+ messages in thread From: Kenneth Lee @ 2023-02-16 9:35 UTC (permalink / raw) To: Richard Henderson; +Cc: qemu-devel On Wed, Feb 15, 2023 at 04:52:24PM -1000, Richard Henderson wrote: > Date: Wed, 15 Feb 2023 16:52:24 -1000 > From: Richard Henderson <richard.henderson@linaro.org> > To: Kenneth Lee <Kenneth-Lee-2012@foxmail.com> > Cc: qemu-devel@nongnu.org > Subject: Re: Does the page boundary check still necessary? > User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 > Thunderbird/102.7.1 > > On 2/15/23 16:28, Kenneth Lee wrote: > > On Wed, Feb 15, 2023 at 04:26:18PM -1000, Richard Henderson wrote: > > > Date: Wed, 15 Feb 2023 16:26:18 -1000 > > > From: Richard Henderson <richard.henderson@linaro.org> > > > To: Kenneth Lee <Kenneth-Lee-2012@foxmail.com> > > > Cc: qemu-devel@nongnu.org > > > Subject: Re: Does the page boundary check still necessary? > > > User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 > > > Thunderbird/102.7.1 > > > > > > On 2/15/23 15:45, Kenneth Lee wrote: > > > > > > Now the chained TBs have been link with tb_link_page(), the chain will > > > > > > be rebuilt if it is invalidate on page. So why is this check still there? > > > > > > > > > > Even for a guest which doesn't use paging, and therefore does not need to > > > > > worry about memory maps changing, we still enable breakpoints and > > > > > watchpoints on a per-page basis. > > > > > > > > > > > > > Thank you. So is this the only reason? May I write a fine grained > > > > checking to remove this limitation? > > > > > > No. > > > > > Why? > > When breakpoints change, we discard all translations on the affected page, > similarly to how we handle writes from self-modifying code. If you link > from further away, then TBs won't be invalidated properly when breakpoints > change. For most guests, this isn't a limitation because we also have to > care for modifications to page tables, so we can't allow such links anyway. > > I have no idea what you're trying to accomplish that's different from existing guests. Thank you for the clarification. You are right. It is senseless to the current guests. I just consider a guest with some hint to the main sequence of the code. It jumps out of range constantely. Maybe I can find other way to solve the problem. Thanks again. > > > r~ -- -Kenneth Lee (Hisilicon) ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-02-16 9:35 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-02-15 8:39 Does the page boundary check still necessary? Kenneth Lee 2023-02-15 17:27 ` Richard Henderson 2023-02-16 1:45 ` Kenneth Lee 2023-02-16 2:26 ` Richard Henderson 2023-02-16 2:28 ` Kenneth Lee 2023-02-16 2:52 ` Richard Henderson 2023-02-16 9:35 ` Kenneth Lee
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).