All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Magnus Lindholm" <linmag7@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v3 6/8] sparc64: add SPARC64 VII CPU, MMU and SMP support
Date: Mon, 12 Oct 2026 19:03:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-168563@kernel.org> (raw)
In-Reply-To: <20261012184826.986050-7-linmag7@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] sparc64: missing membar #Sync in VII __flush_tlb_mm and xcall_flush_tlb_mm
- [High] sparc64: off-by-one error in VII TLB slot verification loop causes false panic
--

commit 83e75cdd0104cea9f29069ae3640894a08ee2f5f
Author: Magnus Lindholm <linmag7@gmail.com>
Subject: sparc64: add SPARC64 VII CPU, MMU and SMP support

This commit adds support for SPARC64 VII CPU, MMU, and SMP hardware paths.
It handles topology, interrupt dispatch, restrained ECC handling, and
synchronizes context writes and instruction demaps for supported firmware
modes.

Link: https://lore.kernel.org/oe-kbuild-all/202610121549.5ejZQ08o-lkp@intel.com/

> diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
> --- a/arch/sparc/mm/init_64.c
> +++ b/arch/sparc/mm/init_64.c
[ ... ]
> @@ -675,6 +675,50 @@ static unsigned long kern_large_tte(unsigned long paddr);
>  
> +/*
> + * Reserve two 4MB kernel mappings and an adjacent slot in the lower half
> + * of the fully associative bank. Check existing reservations, firmware
> + * status and physical slot readback before using the mappings.
> + */
> +static void __init vii_check_slots(void)
> +{
> +	int i;
> +
> +	if (num_kernel_image_mappings > 2) {
> +		prom_printf("VII-BOOT: kernel exceeds initial 8MB mapping budget\n");
> +		prom_halt();
> +	}
> +	for (i = 15 - num_kernel_image_mappings; i <= 15; i++) {
> +		unsigned long d = cheetah_get_ldtlb_data(i);

[Severity: High]
Does this loop bounds check evaluate an extra unallocated slot?

Since remap_kernel() exclusively populates slots tlb_ent - i, the kernel
only uses slots 14 and 15 when num_kernel_image_mappings is 2. However,
evaluating 15 - num_kernel_image_mappings results in iterating through
slots 13, 14, and 15.

If the firmware legitimately uses slot 13 for its own translations, will
this false conflict cause the kernel to incorrectly panic and halt on boot?

> diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
> --- a/arch/sparc/mm/ultra.S
> +++ b/arch/sparc/mm/ultra.S
[ ... ]
> +	.globl		sparc64_vii_patch_cachetlbops
> +sparc64_vii_patch_cachetlbops:
> +	save		%sp, -128, %sp
> +
> +	sethi		%hi(__flush_tlb_mm), %o0
> +	or		%o0, %lo(__flush_tlb_mm), %o0
> +	sethi		%hi(__cheetah_flush_tlb_mm), %o1
> +	or		%o1, %lo(__cheetah_flush_tlb_mm), %o1
> +	call		tlb_patch_one

[Severity: Critical]
Does patching __flush_tlb_mm with __cheetah_flush_tlb_mm violate the VII
hardware synchronization requirements?

The commit message notes that VII requires a membar #Sync to safely
synchronize context writes and instruction demaps, but __cheetah_flush_tlb_mm
lacks this barrier after restoring ASI_DMMU.

Could this omission cause the hardware to execute the demap against the
wrong MMU context, leading to silent TLB corruption during process address
space teardowns like exit() or large munmap() operations?

[ ... ]
> +	sethi		%hi(__flush_tlb_kernel_range), %o0
> +	or		%o0, %lo(__flush_tlb_kernel_range), %o0
> +	sethi		%hi(__vii_flush_tlb_kernel_range_patch), %o1
> +	or		%o1, %lo(__vii_flush_tlb_kernel_range_patch), %o1
> +	call		tlb_patch_one
> +	 mov		3, %o2
> +
> +#ifdef CONFIG_SMP
> +	sethi		%hi(xcall_flush_tlb_page), %o0
> +	or		%o0, %lo(xcall_flush_tlb_page), %o0
> +	sethi		%hi(__vii_xcall_flush_tlb_page_patch), %o1
> +	or		%o1, %lo(__vii_xcall_flush_tlb_page_patch), %o1
> +	call		tlb_patch_one
> +	 mov		3, %o2
> +
> +	/* VII uses 32-entry fTLBs: do not use the Spitfire 64-slot sweep. */
> +	sethi		%hi(xcall_flush_tlb_kernel_range), %o0

[Severity: Critical]
Is xcall_flush_tlb_mm unintentionally omitted from being patched here?

Failing to patch xcall_flush_tlb_mm causes SMP cross-CPU MM flushes on VII
to fall back to the generic Spitfire default.

Since the Spitfire default also lacks the necessary membar #Sync
synchronization before its DEMAP instructions, this appears to leave a path
for TLB corruption on SMP.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012184826.986050-1-linmag7@gmail.com?part=6

  reply	other threads:[~2026-10-12 19:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 18:48 [PATCH v3 0/8] sparc64: add Fujitsu M3000 support Magnus Lindholm
2026-10-12 18:48 ` [PATCH v3 1/8] sparc64: return from the generic clear_page implementation Magnus Lindholm
2026-10-12 18:55   ` sashiko-bot
2026-10-12 18:48 ` [PATCH v3 2/8] sparc64: honor queued spinlock layout in secondary startup Magnus Lindholm
2026-10-12 18:55   ` sashiko-bot
2026-10-12 18:48 ` [PATCH v3 3/8] sparc64: avoid huge kernel PUD mappings on sun4u Magnus Lindholm
2026-10-12 18:55   ` sashiko-bot
2026-10-12 18:48 ` [PATCH v3 4/8] sparc64: stop IRQ setup when descriptor allocation fails Magnus Lindholm
2026-10-12 19:03   ` sashiko-bot
2026-10-12 18:48 ` [PATCH v3 5/8] sparc64: validate Fire register properties before initialization Magnus Lindholm
2026-10-12 18:55   ` sashiko-bot
2026-10-12 18:48 ` [PATCH v3 6/8] sparc64: add SPARC64 VII CPU, MMU and SMP support Magnus Lindholm
2026-10-12 19:03   ` sashiko-bot [this message]
2026-10-12 18:48 ` [PATCH v3 7/8] sparc64: add M3000 Oberon PCIe support Magnus Lindholm
2026-10-12 19:01   ` sashiko-bot
2026-10-12 18:48 ` [PATCH v3 8/8] hvc: add an M3000 firmware console backend Magnus Lindholm
2026-10-12 18:57   ` sashiko-bot
2026-10-13 13:04   ` Greg KH

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=sashiko-outbox-168563@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linmag7@gmail.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.