mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00

When DSP extensions are present, some of the regular integer instructions such as DIV, MACD etc are executed in the DSP unit with semantics alterable by flags in DSP_CTRL aux register. This register is writable by userspace and thus can potentially affect corresponding instructions in kernel code, intentionally or otherwise. So safegaurd kernel by effectively disabling DSP_CTRL upon bootup and every entry to kernel. Do note that for this config we simply zero out the DSP_CTRL reg assuming userspace doesn't really care about DSP. The next patch caters to the DSP aware userspace where this reg is saved/restored upon kernel entry/exit. Reviewed-by: Vineet Gupta <vgupta@synopsys.com> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2020 Synopsys, Inc. (www.synopsys.com)
|
|
*
|
|
* Author: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
|
|
*/
|
|
#ifndef __ASM_ARC_DSP_IMPL_H
|
|
#define __ASM_ARC_DSP_IMPL_H
|
|
|
|
#define DSP_CTRL_DISABLED_ALL 0
|
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
/* clobbers r5 register */
|
|
.macro DSP_EARLY_INIT
|
|
lr r5, [ARC_AUX_DSP_BUILD]
|
|
bmsk r5, r5, 7
|
|
breq r5, 0, 1f
|
|
mov r5, DSP_CTRL_DISABLED_ALL
|
|
sr r5, [ARC_AUX_DSP_CTRL]
|
|
1:
|
|
.endm
|
|
|
|
/* clobbers r10, r11 registers pair */
|
|
.macro DSP_SAVE_REGFILE_IRQ
|
|
#if defined(CONFIG_ARC_DSP_KERNEL)
|
|
/*
|
|
* Drop any changes to DSP_CTRL made by userspace so userspace won't be
|
|
* able to break kernel - reset it to DSP_CTRL_DISABLED_ALL value
|
|
*/
|
|
mov r10, DSP_CTRL_DISABLED_ALL
|
|
sr r10, [ARC_AUX_DSP_CTRL]
|
|
#endif /* ARC_DSP_KERNEL */
|
|
.endm
|
|
|
|
#else /* __ASEMBLY__ */
|
|
|
|
#include <asm/asserts.h>
|
|
|
|
static inline bool dsp_exist(void)
|
|
{
|
|
struct bcr_generic bcr;
|
|
|
|
READ_BCR(ARC_AUX_DSP_BUILD, bcr);
|
|
return !!bcr.ver;
|
|
}
|
|
|
|
static inline void dsp_config_check(void)
|
|
{
|
|
CHK_OPT_STRICT(CONFIG_ARC_DSP_HANDLED, dsp_exist());
|
|
}
|
|
|
|
#endif /* __ASEMBLY__ */
|
|
#endif /* __ASM_ARC_DSP_IMPL_H */
|