lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdX-hQ3XaQtTnbP50ngFB=wKG43m4cxFDUh++Hx7q_LnSw@mail.gmail.com>
Date: Tue, 5 Aug 2025 11:38:07 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Stafford Horne <shorne@...il.com>
Cc: ChenMiao <chenmiao.ku@...il.com>, Jonas Bonn <jonas@...thpole.se>, 
	Stefan Kristiansson <stefan.kristiansson@...nalahti.fi>, Arnd Bergmann <arnd@...db.de>, 
	"Mike Rapoport (Microsoft)" <rppt@...nel.org>, Luis Chamberlain <mcgrof@...nel.org>, Sahil Siddiq <sahilcdq0@...il.com>, 
	Johannes Berg <johannes@...solutions.net>, Masahiro Yamada <masahiroy@...nel.org>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, Andrew Morton <akpm@...ux-foundation.org>, 
	"open list:OPENRISC ARCHITECTURE" <linux-openrisc@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] openrisc: Add text patching API support

Hi Stafford,

On Tue, 5 Aug 2025 at 11:15, Stafford Horne <shorne@...il.com> wrote:
> On Tue, Aug 05, 2025 at 08:40:57AM +0000, ChenMiao wrote:
> > From: chenmiao <chenmiao.ku@...il.com>
> >
> > We need a text patching mechanism to ensure that in the subsequent
> > implementation of jump_label, the code can be modified to the correct
> > location. Therefore, FIX_TEXT_POKE0 has been added as a mapping area.
> >
> > And, I create a new file named insn-def.h to define the or1k insn macro
> > size and more define in the future.
> >
> > Among these changes, we implement patch_map and support the
> > patch_insn_write API for single instruction writing.
> >
> > Signed-off-by: chenmiao <chenmiao.ku@...il.com>

> > --- /dev/null
> > +++ b/arch/openrisc/include/asm/insn-def.h

> > +/* or1k instructions are always 32 bits. */
> > +#define      OPENRISC_INSN_SIZE              4

> > --- /dev/null
> > +++ b/arch/openrisc/kernel/patching.c

> > +static int __patch_insn_write(void *addr, const void *insn)
> > +{
> > +     void *waddr = addr;
> > +     unsigned long flags = 0;
> > +     int ret;
> > +
> > +     raw_spin_lock_irqsave(&patch_lock, flags);
> > +
> > +     waddr = patch_map(addr, FIX_TEXT_POKE0);
> > +
> > +     ret = copy_to_kernel_nofault(waddr, insn, OPENRISC_INSN_SIZE);
>
> If you change *insn to unsigned long insn, you can do:
>
>         ret = copy_to_kernel_nofault(waddr, &insn, iszeof(insn));

sizeof(*insn)?

>
> > +     local_icache_range_inv((unsigned long)waddr,
> > +                            (unsigned long)waddr + OPENRISC_INSN_SIZE);
> > +
> > +     patch_unmap(FIX_TEXT_POKE0);
> > +
> > +     raw_spin_unlock_irqrestore(&patch_lock, flags);
> > +
> > +     return ret;
> > +}
> > +
> > +int patch_insn_write(void *addr, const void *insn)
>
> Does insn need to be void *?  It think it could be just unsigned long. See
> comment above.

u32?

unsigned long would be 64-bit on 64-bit platforms.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ