Home | History | Annotate | Download | only in include
History log of /src/sys/arch/arm/include/asm.h
RevisionDateAuthorComments
 1.39  07-May-2025  uwe arm: asm.h - change GOT_INIT to take the normal asm label

Don't pass the label to use for the "current address" as the macro
parameter. It obscures its purpose and makes the use of local labels
extremely unobvious, so you are forced to invent a name that is mostly
useless otherwise:

GOT_INIT(r3, .Lgot.execsp_start, .Lpc.execsp_start)
GOT_INITSYM(.Lgot.execsp_start, .Lpc.execsp_start)
vs.
0: GOT_INIT(r3, .Lgot.execsp_start)
GOT_INITSYM(.Lgot.execsp_start, 0b)

Same object code is generated.
 1.38  07-May-2025  uwe arm: asm.h - no ## at token boundaries

For the ## "if the result is not a valid preprocessing token, the
behavior is undefined", so you 1) don't need to 2) must not use it to
concatenate a token with a non-token, like .arg or arg()

The point is kinda moot, as traditionally asm with cpp uses traditional
cpp, not ANSI cpp (many assemblers use # for literals, which conflicts
with the ANSI CPP # stringization and requires awkward workarounds),
but don't set a bad example even if it never gets called out by the
compiler.
 1.37  06-May-2025  uwe arm/asm.h: revert PCREL_GET &c in previous (ok riastradh)

This change needs to be redone and re-verified. I have detailed some
issues in the PR, and it also turns out that some of the changes were
in the !_REENTRANT branch of #ifdef and thus not checked at all.
riastradh asked to back out the changes for now.

PR lib/59391: unnecessary __PIC__ conditionals clutter .S files
 1.36  03-May-2025  riastradh arm: Nix most __PIC__ conditionals in .S files.

New macros PCREL_GET(rN,label,pclabel) and PCREL_SYM(label,pclabel)
to enable this by the pattern:

ldr rN, label
#ifdef __PIC__
pclabel:
add rN, rN, pc
#endif
...
label:
#ifdef __PIC__
.word (label - (pclabel + 2*sizeof(instruction)))
#else
.word label
#endif

(sizeof(instruction) = 2 for thumb, 4 for non-thumb.)

No binary change in libc with MKPIE=no (i.e., testing both for
changes to the PIC build and changes to the non-PIC build).

In principle, assembly routines could improve instruction scheduling
by splitting up the ldr and add instructions. But in practice, the
maintenance and auditing burden likely makes this worthwhile by
improving legibility vs a tangle of in-line #ifdefs.

brk.S does things a little differently making it harder to unify.
Could redo it but I don't want to make changes without testing them
first.

PR lib/59391: unnecessary __PIC__ conditionals clutter .S files
 1.35  09-Jun-2024  riastradh branches: 1.35.2;
arm/asm.h: Respect NETBSD_REVISIONID.
 1.34  23-Apr-2020  jakllsch Fix userland gprof profiling on aarch64.

Adjusts _PROF_PROLOGUE to match OpenBSD; reworks our MCOUNT to retrieve
frompc placed on stack by the prologue, and to streamline sp manipulation
when preserving argument registers.
 1.33  21-Apr-2020  joerg LLVM is a bit stricter and wants the ARM variant of %progbits.
 1.32  17-Apr-2020  joerg Mark the .ident section as mergable string section to avoid redundant
entries.
 1.31  13-Apr-2020  maxv Add support for Branch Target Identification (BTI).

On the executable pages that have the GP (Guarded Page) bit, the semantic
of the "br" and "blr" instructions is changed: the CPU expects the first
instruction of the jump/call target to be "bti", and faults if it isn't.

We add the GP bit on the kernel .text pages (and incidentally the .rodata
pages, but we don't care). The compiler adds a "bti c" instruction at the
beginning of each C function. We modify the ENTRY() macros to manually add
"bti c" in the asm functions.

cpuswitch.S needs a specific change: with "br x27" the CPU expects "bti j",
which is bad because the functions begin with "bti c"; switch to "br x16",
for the CPU to accept "bti c".

BTI helps defend against JOP/COP. Tested on Qemu.
 1.30  27-Jan-2019  dholland branches: 1.30.10;
fix duplicated chunk from merge
 1.29  27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.28  01-Apr-2018  ryo branches: 1.28.2;
Add initial support for ARMv8 (AARCH64) (by nisimura@ and ryo@)

- sys/arch/evbarm64 is gone and integrated into sys/arch/evbarm. (by skrll@)
- add support fdt. evbarm/conf/GENERIC64 fdt (bcm2837,sunxi,tegra) based generic 64bit kernel config. (by skrll@, jmcneill@)
 1.27  04-Mar-2014  matt branches: 1.27.28;
Remove duplicate END(y) macro
 1.26  29-Jan-2014  matt Make multiple inclusion symbols always start with _ARM_ (not _ARM32_ or
_MACHINE_).
 1.25  30-Nov-2013  matt arm doesn't need to use (PLT) anymore.
 1.24  12-Sep-2013  joerg Pass PICFLAGS down to cc-as-as and use __PIC__ to decide if it is small
vs big PIC mode. Retire -DPIC and -DBIGPIC.
 1.23  19-Aug-2013  matt Do alternative text sections better, add a _TEXT_SECTION which defaults to
.text but can be overridden before <arm/asm.h> gets included.
 1.22  18-Aug-2013  matt remove __thumb__ PIC specifics. no different from ARM except being pc+4 not
pc+8
 1.21  16-Aug-2013  matt Don't define RETc if Thumb1
Add REL_SYM(a, b)
Make GOT_INIT* thumb aware.
 1.20  13-Aug-2013  matt Add _THUMB_ENTRY and _ARM_ENTRY which do the appropriate things including
switching instruction sets.
Use __thumb__ to decide which _ENTRY gets defined as
 1.19  11-Aug-2013  matt Switch to unified syntax
use it to get condition return on thumb
 1.18  07-Aug-2013  matt Add KMODTRAMPOLINE(name)
There are 3 variations:
one for armv7 using movw ip,#:lower16:func; movt ip,#:upper16:func; bx ip
one for armv4t+ using ldr ip, pc; bx ip; .word func
one for everything else using ldr pc, [pc, #-4]; .word func
 1.17  28-Jan-2013  matt branches: 1.17.2;
Add a RETr(r) macro (indirect return through register r).
 1.16  01-Sep-2012  matt branches: 1.16.2;
Add __BITS to asm.h (remove from imxuartreg.h)
Add L1_S_AP_KR to genassym.h
Use L1_S_AP_* in omap_start.S and don't include pmap.h
 1.15  29-Aug-2012  matt Add __BIT(n) macro
 1.14  30-Jun-2011  wiz branches: 1.14.2; 1.14.10;
dependant -> dependent
 1.13  20-Dec-2010  joerg Consistently use .gnu.warning with .pushsectio and .popsection on all
architectures instead of obsolete STABS frames for linker warnings.
 1.12  29-Aug-2008  matt branches: 1.12.12; 1.12.16;
Remove non-__ELF__ support. Use .pushsection/.popsection for RCSID.
 1.11  27-Apr-2008  matt branches: 1.11.2; 1.11.6;
Merge kernel changes in matt-armv6 to HEAD.
 1.10  17-Oct-2007  garbled branches: 1.10.16; 1.10.18; 1.10.20;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.9  26-Aug-2007  matt branches: 1.9.2;
Move _ARM_ARCH_* from asm.h to cdefs.h so everyone can use them.
Add _END/END/ASEND which every port's asm.h should have.
Add GET_CPUFINO(rX). Reserved for future use. :)
Use %foo instead of #foo
 1.8  20-Jan-2006  christos branches: 1.8.28; 1.8.36; 1.8.42; 1.8.44; 1.8.46; 1.8.48;
Add a STRONG_ALIAS macro
 1.7  11-Dec-2005  christos branches: 1.7.2;
merge ktrace-lwp.
 1.6  21-Aug-2004  rearnsha branches: 1.6.12;
Define _ARM_ARCH_6, _ARM_ARCH_5 and _ARM_ARCH_4T, based on
architecture defines passed from the compiler.

Define RET and RETc macros for return and conditional return. If BX is
available in the current instruction set then make use of it.

Note: these really are from the compiler's -march/-mcpu flags, not
from the kernel config, so they can be relied on in user space.
 1.5  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4  16-Jul-2001  matt branches: 1.4.6; 1.4.24;
Change way PIC stuff is emitted for ELF to be more flexible.
 1.3  14-Jul-2001  matt Add a GOTSYM which emits the right stuff to GOT symbols under ELF and/or
a.out.
 1.2  26-Apr-2001  bjh21 branches: 1.2.2;
Add ELF version of _PROF_PROLOGUE.
 1.1  10-Jan-2001  bjh21 branches: 1.1.2; 1.1.4;
Header files which don't differ between arm32 and arm26 and can thus be
shared.
 1.1.4.1  21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2  10-Jan-2001  bjh21 Header files which don't differ between arm32 and arm26 and can thus be
shared.
 1.1.2.1  10-Jan-2001  bjh21 file asm.h was added on branch thorpej_scsipi on 2001-01-10 19:02:06 +0000
 1.2.2.1  03-Aug-2001  lukem update to -current
 1.4.24.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.24.3  18-Sep-2004  skrll Sync with HEAD.
 1.4.24.2  25-Aug-2004  skrll Sync with HEAD.
 1.4.24.1  03-Aug-2004  skrll Sync with HEAD
 1.4.6.2  16-Jul-2001  matt Change way PIC stuff is emitted for ELF to be more flexible.
 1.4.6.1  16-Jul-2001  matt file asm.h was added on branch nathanw_sa on 2001-07-16 05:43:33 +0000
 1.6.12.2  03-Sep-2007  yamt sync with head.
 1.6.12.1  21-Jun-2006  yamt sync with head.
 1.7.2.1  01-Feb-2006  yamt sync with head.
 1.8.48.1  01-Jan-2008  chris Sync with HEAD.
 1.8.46.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.8.44.1  01-Nov-2007  rjs Sync with HEAD.
 1.8.42.1  03-Sep-2007  skrll Sync with HEAD.
 1.8.36.1  03-Oct-2007  garbled Sync with HEAD
 1.8.28.1  09-Oct-2007  ad Sync with head.
 1.9.2.1  28-Aug-2007  matt Support thumb code. Add convience macros.
 1.10.20.2  04-May-2009  yamt sync with head.
 1.10.20.1  16-May-2008  yamt sync with head.
 1.10.18.1  18-May-2008  yamt sync with head.
 1.10.16.2  28-Sep-2008  mjf Sync with HEAD.
 1.10.16.1  02-Jun-2008  mjf Sync with HEAD.
 1.11.6.1  19-Oct-2008  haad Sync with HEAD.
 1.11.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.12.16.1  05-Mar-2011  rmind sync with head
 1.12.12.1  15-Feb-2014  matt Merge armv7 support from HEAD, specifically support for the BCM5301X
and BCM56340 evbarm kernels.
 1.14.10.1  28-Nov-2012  matt Merge improved arm support (especially Cortex) from HEAD
including OMAP and BCM53xx support.
 1.14.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.2.1  30-Oct-2012  yamt sync with head
 1.16.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.2.1  25-Feb-2013  tls resync with head
 1.17.2.2  18-May-2014  rmind sync with head
 1.17.2.1  28-Aug-2013  rmind sync with head
 1.27.28.1  07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.28.2.2  21-Apr-2020  martin Sync with HEAD
 1.28.2.1  10-Jun-2019  christos Sync with HEAD
 1.30.10.2  25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.30.10.1  20-Apr-2020  bouyer Sync with HEAD
 1.35.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed