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] [day] [month] [year] [list]
Message-ID: <aJIC8o1WmVHol9RY@antec>
Date: Tue, 5 Aug 2025 14:11:14 +0100
From: Stafford Horne <shorne@...il.com>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
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

On Tue, Aug 05, 2025 at 11:38:07AM +0200, Geert Uytterhoeven wrote:
> 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)?

Yes, typo, thanks.

> >
> > > +     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.

Thanks, yes for us it's more correct to use u32.  I always thing unsigned long is
OK in openrisc as we have no 64-bit implementations.  But might as well have it
correct in case we ever add the 64-bit implementation.

-Stafford

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ