Re: [PATCH v2 2/4] ARC: handle DSP presence in HW

From: Eugeniy Paltsev
Date: Tue Mar 10 2020 - 08:18:38 EST


>From: Vineet Gupta <vgupta@xxxxxxxxxxxx>
>Sent: Saturday, March 7, 2020 03:12
>To: Eugeniy Paltsev; linux-snps-arc@xxxxxxxxxxxxxxxxxxx
>Cc: Alexey Brodkin; linux-kernel@xxxxxxxxxxxxxxx
>Subject: Re: [PATCH v2 2/4] ARC: handle DSP presence in HW
>
>On 3/5/20 12:02 PM, Eugeniy Paltsev wrote:
>> In case of DSP extension presence in HW some instructions
>> (related to integer multiply, multiply-accumulate, and divide
>> operation) executes on this DSP execution unit. So their
>> execution will depend on dsp configuration register (DSP_CTRL)
>>
>> As we want these instructions to execute the same way regardless
>> of DSP presence we need to set DSP_CTRL properly. However this
>> register can be modified bu any usersace app therefore any
>> usersace may break kernel execution.
>>
>> Fix that by configure DSP_CTRL in CPU early code and in IRQs
>> entries.
>
> How about below ....
>
> "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 which this actually saved/restored upon kernel entry."
>From: Vineet Gupta <vgupta@xxxxxxxxxxxx>
>Sent: Saturday, March 7, 2020 03:12
>To: Eugeniy Paltsev; linux-snps-arc@xxxxxxxxxxxxxxxxxxx
>Cc: Alexey Brodkin; linux-kernel@xxxxxxxxxxxxxxx
>Subject: Re: [PATCH v2 2/4] ARC: handle DSP presence in HW
>
>On 3/5/20 12:02 PM, Eugeniy Paltsev wrote:
>> In case of DSP extension presence in HW some instructions
>> (related to integer multiply, multiply-accumulate, and divide
>> operation) executes on this DSP execution unit. So their
>> execution will depend on dsp configuration register (DSP_CTRL)
>>
>> As we want these instructions to execute the same way regardless
>> of DSP presence we need to set DSP_CTRL properly. However this
>> register can be modified bu any usersace app therefore any
>> usersace may break kernel execution.
>>
>> Fix that by configure DSP_CTRL in CPU early code and in IRQs
>> entries.
>
> How about below ....

>
> "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 which this actually saved/restored upon kernel entry."