Re: [PATCH 17/27] sparc32: Drop run-time patching of ASI instructions

From: Andreas Larsson
Date: Fri Feb 16 2024 - 12:15:21 EST


On 2023-12-19 23:03, Sam Ravnborg via B4 Relay wrote:
> From: Sam Ravnborg <sam@xxxxxxxxxxxx>
>
> With only LEON supported there is no need to run-time patch
> the instructions to match ASI.
>
> Move a few functions back to C with inline asm, now that
> run-time patching is not needed.
>
> Deleted a few functions that turns out not to be used rather
> than re-implement them in C.
..
> diff --git a/arch/sparc/include/asm/sections.h b/arch/sparc/include/asm/sections.h
> index 08f833453ab3..e9d28148850b 100644
> --- a/arch/sparc/include/asm/sections.h
> +++ b/arch/sparc/include/asm/sections.h
> @@ -8,7 +8,4 @@
> /* sparc entry point */
> extern char _start[];
>
> -extern char __leon_1insn_patch[];
> -extern char __leon_1insn_patch_end[];
> -
> #endif
> diff --git a/arch/sparc/include/asm/winmacro.h b/arch/sparc/include/asm/winmacro.h
> index b6e911f5d93c..c496b04cdfaf 100644
> --- a/arch/sparc/include/asm/winmacro.h
> +++ b/arch/sparc/include/asm/winmacro.h
> @@ -108,18 +108,11 @@
> 661: rd %tbr, %idreg; \
> srl %idreg, 10, %idreg; \
> and %idreg, 0xc, %idreg; \

These three lines, including the label, should also be removed as they
are not for LEON. Additionally, I think it would be best to split out
removing the cpuid instruction fixups to one patch and the MMU ASI
instruction fixups to another patch.

> - .section .cpuid_patch, "ax"; \
> - /* Instruction location. */ \
> - .word 661b; \
> - /* SUN4D implementation. */ \
> - lda [%g0] ASI_M_VIKING_TMP1, %idreg; \
> - sll %idreg, 2, %idreg; \
> - nop; \
> - /* LEON implementation. */ \
> + \
> rd %asr17, %idreg; \
> srl %idreg, 0x1c, %idreg; \
> sll %idreg, 0x02, %idreg; \
> - .previous; \
> + \
> sethi %hi(current_set), %dest_reg; \
> or %dest_reg, %lo(current_set), %dest_reg;\
> ld [%idreg + %dest_reg], %dest_reg;
> diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
> index 0f2417ee3f95..9cf8f87e8c42 100644
> --- a/arch/sparc/kernel/entry.S
> +++ b/arch/sparc/kernel/entry.S

The hard_smp_processor_id function also needs to be reduced to just the
LEON code. With the patching removed, SMP otherwise breaks with CPUs
other than CPU 0 getting stuck.

Thanks,
Andreas