RFC: extern illegal instruction trap and trap RDCYCLE

Ben Dooks ben.dooks at codethink.co.uk
Wed Sep 18 02:57:51 PDT 2024


On 18/09/2024 10:55, Atish Patra wrote:
> On 9/17/24 7:01 AM, Ben Dooks wrote:
>> On 17/09/2024 14:46, Palmer Dabbelt wrote:
>>> On Tue, 17 Sep 2024 06:08:50 PDT (-0700), ben.dooks at codethink.co.uk 
>>> wrote:
>>>> This is a RFC series to change how the illegal instruction trap
>>>> is handled and then how to trap RDCYCLE and emulate it with RDTIME
>>>> instead.
>>>
>>> Only 1/3 made it to lore for me, not sure if it's just stuck somewhere.
>>>
>>>>
>>>> I did this when we found multiple libraries using RDCYCLE and
>>>> upgrading multiple runners to newer kernels caused many problems
>>>
>>> OK, so I think we're kind of just stuck with RDCYCLE then -- it was 
>>> part of the base ISA when we merged the port, and every time it 
>>> disappears we end up breaking userspace.
>>
>> Yes, it was an annoyance, we managed to track down all the users and
>> patch out.
>>
>> I thought this might be a useful idea for more generic type, so might
>> look at updating to have a table of instruction masks to call.
>>
>>> I'm not sure what exactly the right way to do this is: IIRC there's 
>>> some perf-related hooks for this, but there's also systems that just 
>>> don't implement the RDCYCLE instruction at all and thus we'll need 
>>> some sort of emulation for those.
>>
>> I couldn't get the PMU driver to allow it, not sure if there was an
>> issue higher up or some other issue?
>>
> 
> Here is the way to properly allow it via the driver.
> 
> https://www.kernel.org/doc/Documentation/admin-guide/sysctl/kernel.rst
> 
> Check the perf_user_access

Didn't work for me, not sure why

> 
> As you noted, the user space application shouldn't use RDCYCLE for 
> various reasons discussed in the past.
> 
> If RDTIME is really not an option, you can always set the legacy mode to 
> enable access.
> 
>>> So hopefully the other two patches get through the lists at some 
>>> point, but I think in general this is a reasonable thing to do -- or 
>>> I guess maybe a completely unreasonable thing to be stuck needing to 
>>> do, but no way around it ;)
>>
>> I'll check back later, currently as OSS-EU
>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> linux-riscv mailing list
>>>> linux-riscv at lists.infradead.org
>>>> http://lists.infradead.org/mailman/listinfo/linux-riscv
>>>
>>> _______________________________________________
>>> linux-riscv mailing list
>>> linux-riscv at lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-riscv
>>>
>>
>>
> 
> 


-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html



More information about the linux-riscv mailing list