From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: Eduardo Habkost <eduardo@habkost.net>,
qemu-s390x@nongnu.org, Thomas Huth <thuth@redhat.com>,
David Hildenbrand <david@redhat.com>,
Zhao Liu <zhao1.liu@intel.com>,
Pierrick Bouvier <pierrick.bouvier@linaro.org>,
Anton Johansson <anjo@rev.ng>,
Paolo Bonzini <pbonzini@redhat.com>,
Riku Voipio <riku.voipio@iki.fi>,
Ilya Leoshkevich <iii@linux.ibm.com>
Subject: Re: [PATCH-for-10.1 1/2] tcg: Introduce and use target_has_precise_smc() runtime helper
Date: Sat, 5 Apr 2025 08:57:00 -0700 [thread overview]
Message-ID: <f7d4a7a3-1e63-45ee-9556-8b155b34a05d@linaro.org> (raw)
In-Reply-To: <20250404235624.67816-2-philmd@linaro.org>
On 4/4/25 16:56, Philippe Mathieu-Daudé wrote:
> diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c
> index d479f53ae02..ae12ad2d867 100644
> --- a/accel/tcg/tb-maint.c
> +++ b/accel/tcg/tb-maint.c
> @@ -1057,10 +1057,7 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)
> * Without precise smc semantics, or when outside of a TB,
> * we can skip to invalidate.
> */
> -#ifndef TARGET_HAS_PRECISE_SMC
> - pc = 0;
> -#endif
> - if (!pc) {
> + if (!target_has_precise_smc() || !pc) {
> tb_invalidate_phys_page(addr);
> return false;
> }
For the record, in my v2 I reverse these tests, since !pc is simpler.
> @@ -1109,10 +1106,9 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,
> {
> TranslationBlock *tb;
> PageForEachNext n;
> -#ifdef TARGET_HAS_PRECISE_SMC
> bool current_tb_modified = false;
> - TranslationBlock *current_tb = retaddr ? tcg_tb_lookup(retaddr) : NULL;
> -#endif /* TARGET_HAS_PRECISE_SMC */
> + TranslationBlock *current_tb = (target_has_precise_smc() && retaddr)
> + ? tcg_tb_lookup(retaddr) : NULL;
>
> /* Range may not cross a page. */
> tcg_debug_assert(((start ^ last) & TARGET_PAGE_MASK) == 0);
> @@ -1134,8 +1130,7 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,
> tb_last = tb_start + (tb_last & ~TARGET_PAGE_MASK);
> }
> if (!(tb_last < start || tb_start > last)) {
> -#ifdef TARGET_HAS_PRECISE_SMC
> - if (current_tb == tb &&
> + if (target_has_precise_smc() && current_tb == tb &&
> (tb_cflags(current_tb) & CF_COUNT_MASK) != 1) {
For the record, we can eliminate the target_has_precise_smc() test here, because we've set
current_tb == NULL, and thus the current_tb == tb test always fails ...
> @@ -1157,15 +1151,13 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,
> tlb_unprotect_code(start);
> }
>
> -#ifdef TARGET_HAS_PRECISE_SMC
> - if (current_tb_modified) {
> + if (target_has_precise_smc() && current_tb_modified) {
... which in turn means that current_tb_modified is never set.
Thus only the one runtime test at the top of the function suffices.
r~
next prev parent reply other threads:[~2025-04-05 15:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-04 23:56 [PATCH-for-10.1 0/2] tcg: Convert TARGET_HAS_PRECISE_SMC to TCGCPUOps::has_precise_smc field Philippe Mathieu-Daudé
2025-04-04 23:56 ` [PATCH-for-10.1 1/2] tcg: Introduce and use target_has_precise_smc() runtime helper Philippe Mathieu-Daudé
2025-04-05 15:57 ` Richard Henderson [this message]
2025-04-04 23:56 ` [PATCH-for-10.1 2/2] tcg: Convert TARGET_HAS_PRECISE_SMC to TCGCPUOps::has_precise_smc field Philippe Mathieu-Daudé
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=f7d4a7a3-1e63-45ee-9556-8b155b34a05d@linaro.org \
--to=richard.henderson@linaro.org \
--cc=anjo@rev.ng \
--cc=david@redhat.com \
--cc=eduardo@habkost.net \
--cc=iii@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=thuth@redhat.com \
--cc=zhao1.liu@intel.com \
/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).