public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: Atish Patra <atishp@rivosinc.com>, Palmer Dabbelt <palmer@dabbelt.com>
Cc: linux-riscv@lists.infradead.org
Subject: Re: RFC: extern illegal instruction trap and trap RDCYCLE
Date: Wed, 18 Sep 2024 10:57:51 +0100	[thread overview]
Message-ID: <1bf46ac0-2ab4-44d3-bcf0-7a29ba6380c1@codethink.co.uk> (raw)
In-Reply-To: <6ea17387-6efc-49c7-b631-b6a682054d49@rivosinc.com>

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@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@lists.infradead.org
>>>> http://lists.infradead.org/mailman/listinfo/linux-riscv
>>>
>>> _______________________________________________
>>> linux-riscv mailing list
>>> linux-riscv@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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2024-09-18  9:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-17 13:08 RFC: extern illegal instruction trap and trap RDCYCLE Ben Dooks
2024-09-17 13:08 ` [PATCH 1/3] riscv: ptrace: add regs_set_register() Ben Dooks
2024-09-17 13:08 ` [PATCH 2/3] riscv: traps: make insn fetch common in unknown instruction Ben Dooks
2024-09-17 13:08 ` [PATCH 3/3] riscv: add trap and emulation for RDCYCLE Ben Dooks
2024-09-17 14:08   ` Ben Dooks
2024-09-18  6:45   ` Andrew Jones
2024-09-18  9:07     ` Ben Dooks
2024-09-18  9:15     ` Ben Dooks
2024-09-17 13:46 ` RFC: extern illegal instruction trap and trap RDCYCLE Palmer Dabbelt
2024-09-17 14:01   ` Ben Dooks
2024-09-18  9:55     ` Atish Patra
2024-09-18  9:57       ` Ben Dooks [this message]
2024-09-18 23:23         ` Atish Kumar Patra
2024-10-01  9:41           ` Alexandre Ghiti
2024-10-01 21:00             ` Ben Dooks
2024-10-01 21:07               ` Ben Dooks

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=1bf46ac0-2ab4-44d3-bcf0-7a29ba6380c1@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=atishp@rivosinc.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox