From: "Cédric Le Goater" <clg@kaod.org>
To: Nicholas Piggin <npiggin@gmail.com>, qemu-ppc@nongnu.org
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>,
Harsh Prateek Bora <harshpb@linux.ibm.com>,
BALATON Zoltan <balaton@eik.bme.hu>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/6] target/ppc: Fix 440 tlbwe TLB invalidation gaps
Date: Thu, 25 Jan 2024 11:38:47 +0100 [thread overview]
Message-ID: <0f62f45b-7b1d-49d3-adaa-9ceb76de1a5d@kaod.org> (raw)
In-Reply-To: <20240117151238.93323-1-npiggin@gmail.com>
On 1/17/24 16:12, Nicholas Piggin wrote:
> The 440 software TLB write entry misses several cases that must flush
> the TCG TLB:
> - If the new size is smaller than the existing size, the EA no longer
> covered should be flushed. This looks like an inverted inequality test.
> - If the TLB PID changes.
> - If the TLB attr bit 0 (translation address space) changes.
> - If low prot (access control) bits change.
>
> Fix this by removing tricks to avoid TLB flushes, and just invalidate
> the TLB if any valid entry is being changed, similarly to 4xx.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
PS: A cover letter would have been nice :) I couldn't find it.
> ---
> target/ppc/mmu_helper.c | 35 ++++++++++-------------------------
> 1 file changed, 10 insertions(+), 25 deletions(-)
>
> diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
> index f87d35379a..c140f3c96d 100644
> --- a/target/ppc/mmu_helper.c
> +++ b/target/ppc/mmu_helper.c
> @@ -855,49 +855,34 @@ void helper_440_tlbwe(CPUPPCState *env, uint32_t word, target_ulong entry,
> target_ulong value)
> {
> ppcemb_tlb_t *tlb;
> - target_ulong EPN, RPN, size;
> - int do_flush_tlbs;
>
> qemu_log_mask(CPU_LOG_MMU, "%s word %d entry %d value " TARGET_FMT_lx "\n",
> __func__, word, (int)entry, value);
> - do_flush_tlbs = 0;
> entry &= 0x3F;
> tlb = &env->tlb.tlbe[entry];
> +
> + /* Invalidate previous TLB (if it's valid) */
> + if (tlb->prot & PAGE_VALID) {
> + tlb_flush(env_cpu(env));
> + }
> +
> switch (word) {
> default:
> /* Just here to please gcc */
> case 0:
> - EPN = value & 0xFFFFFC00;
> - if ((tlb->prot & PAGE_VALID) && EPN != tlb->EPN) {
> - do_flush_tlbs = 1;
> - }
> - tlb->EPN = EPN;
> - size = booke_tlb_to_page_size((value >> 4) & 0xF);
> - if ((tlb->prot & PAGE_VALID) && tlb->size < size) {
> - do_flush_tlbs = 1;
> - }
> - tlb->size = size;
> + tlb->EPN = value & 0xFFFFFC00;
> + tlb->size = booke_tlb_to_page_size((value >> 4) & 0xF);
> tlb->attr &= ~0x1;
> tlb->attr |= (value >> 8) & 1;
> if (value & 0x200) {
> tlb->prot |= PAGE_VALID;
> } else {
> - if (tlb->prot & PAGE_VALID) {
> - tlb->prot &= ~PAGE_VALID;
> - do_flush_tlbs = 1;
> - }
> + tlb->prot &= ~PAGE_VALID;
> }
> tlb->PID = env->spr[SPR_440_MMUCR] & 0x000000FF;
> - if (do_flush_tlbs) {
> - tlb_flush(env_cpu(env));
> - }
> break;
> case 1:
> - RPN = value & 0xFFFFFC0F;
> - if ((tlb->prot & PAGE_VALID) && tlb->RPN != RPN) {
> - tlb_flush(env_cpu(env));
> - }
> - tlb->RPN = RPN;
> + tlb->RPN = value & 0xFFFFFC0F;
> break;
> case 2:
> tlb->attr = (tlb->attr & 0x1) | (value & 0x0000FF00);
next prev parent reply other threads:[~2024-01-25 10:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 15:12 [PATCH 1/6] target/ppc: Fix 440 tlbwe TLB invalidation gaps Nicholas Piggin
2024-01-17 15:12 ` [PATCH 2/6] target/ppc: Factor out 4xx ppcemb_tlb_t flushing Nicholas Piggin
2024-01-25 10:39 ` Cédric Le Goater
2024-01-17 15:12 ` [PATCH 3/6] target/ppc: 4xx don't flush TLB for a newly written software TLB entry Nicholas Piggin
2024-01-25 10:44 ` Cédric Le Goater
2024-01-17 15:12 ` [PATCH 4/6] target/ppc: 4xx optimise tlbwe_lo TLB flushing Nicholas Piggin
2024-01-25 10:44 ` Cédric Le Goater
2024-01-17 15:12 ` [PATCH 5/6] target/ppc: 440 optimise tlbwe " Nicholas Piggin
2024-01-25 10:44 ` Cédric Le Goater
2024-01-17 15:12 ` [PATCH 6/6] target/ppc: optimise ppcemb_tlb_t flushing Nicholas Piggin
2024-01-25 10:45 ` Cédric Le Goater
2024-01-25 10:38 ` Cédric Le Goater [this message]
2024-02-16 13:28 ` [PATCH 1/6] target/ppc: Fix 440 tlbwe TLB invalidation gaps BALATON Zoltan
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=0f62f45b-7b1d-49d3-adaa-9ceb76de1a5d@kaod.org \
--to=clg@kaod.org \
--cc=balaton@eik.bme.hu \
--cc=danielhb413@gmail.com \
--cc=harshpb@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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).