Commit Graph

20 Commits

Author SHA1 Message Date
Warner Losh
031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
Mitchell Horne
b926b6db37 riscv: always include frame pointer
Specifically it is missing in kernel modules, meaning a proper backtrace
can't be constructed.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37657
2023-01-12 11:04:24 -04:00
Emmanuel Vadot
384bd0b5b0 riscv: Add the device-tree path to the include path 2021-01-16 11:31:17 +01:00
Mitchell Horne
e1a6e0e33e Simplify the RISC-V kernel linker invocation
Remove our custom SYSTEM_LD definition. This generates program headers
that are more consistent with other architectures, and more importantly,
are in line with what loader(8) expects when loading a kernel.

As noted in https://reviews.freebsd.org/D22920, there is no apparent
reason why the kernel would need a writable text segment, so removal of
the -N flag isn't likely to cause issue.

Reviewed by:	kp, br
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24909
2020-05-22 18:54:56 +00:00
John Baldwin
02343a67c2 Retire the GENERICSF kernel config.
Now that hw.machine_arch handles soft-float vs hard-float there is no
longer a reason for this config.

Submitted by:	mhorne (kern.mk hunk)
Reviewed by:	imp (earlier version), kp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24544
2020-04-27 21:51:22 +00:00
Warner Losh
6b72948d73 Better check for floating point type.
Use __riscv_flen instead of __riscv_float_abi_soft. While the latter works for
userland (and one could argue it's more correct), it fails for the kernel. We
compile the kernel with -mabi=lp64 (eg soft float abi) to avoid floating point
instructions in the kernel. We also compile the kernel -march=rv64imafdc for
hard float kernels (eg those with options FPE), but with -march=rv64imac for
softfloat kernels (eg those with FPE). Since we do this, in the kernel (as in
userland) __riscv_flen will be defined for 'riscv64' and not for 'riscv64sf'.

This also removes the -DMACHINE_ARCH hack now that it's no longer needed.

Longer term, we should return the ABI from the sysctl hw.machine_arch like on
amd64 for i386 binaries.

Suggested by: mhorne@
Differential Revision: https://reviews.freebsd.org/D23813
2020-02-27 15:34:30 +00:00
Warner Losh
990a56e866 Add a soft-float riscv kernel config
GENERICSF is just like GENERIC, only creates a soft-float kernel. Omit it from the
universe build for now.

Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D23812
2020-02-24 16:42:44 +00:00
Warner Losh
1f8198e347 Use MACHINE_ARCH instead of TARGET_ARCH
TARGET_ARCH is only for use in Makefile.inc1 contexts. MACHINE_ARCH is the
preferred thing to set.  Makefile.inc1 sets MACHINE_ARCH in the cross build
case, and make sets it in the native build case. This will fix anybody doing a
native build. Add a comment for why we have to do this dance so when/if the
problem with CFLAGS is fixed for the kernel this workaround can be removed.
2020-02-23 19:04:15 +00:00
Kristof Provost
6ebb17dfa7 riscv: Set MACHINE_ARCH correctly
MACHINE_ARCH sets the hw.machine_arch sysctl in the kernel. In userspace
it sets MACHINE_ARCH in bmake, which bsd.cpu.mk uses to configure the
target ABI for ports.

For riscv64sf builds (i.e. soft-float) that needs to be riscv64sf, but
the sysctl didn't reflect that. It is static.

Set the define from the riscv makefile so that we correctly reflect our
actual build (i.e. riscv64 or riscv64sf), depending on what TARGET_ARCH
we were built with.

That still doesn't satisfy userspace builds (e.g. bmake), so check if
we're building with a software-floating point toolchain there. That
check doesn't work in the kernel, because it never uses floating point.

Reviewed by:	philip (previous version), mhorne
Sponsored by:	Axiado
Differential Revision:	https://reviews.freebsd.org/D23741
2020-02-22 13:23:27 +00:00
Alex Richardson
febe2bd226 Set the LMA of the riscv kernel to the OpenSBI jump target by default
This allows us to boot FreeBSD RISCV on QEMU using the -kernel command line
options. When using that option, QEMU maps the kernel ELF file to the
addresses specified in the LMAs in the program headers.

Since version 4.2 QEMU ships with OpenSBI fw_jump by default so this allows
booting FreeBSD using the following command line:
qemu-system-riscv64 -bios default -kernel /.../boot/kernel/kernel -nographic -M virt

Without this change the -kernel option cannot be used since the LMAs start
at address zero and QEMU already maps a ROM to these low physical addresses.

For targets that require a different kernel LMA the make variable
KERNEL_LMA can be overwritten in the config file. For example, adding
`makeoptions	KERNEL_LMA=0xc0200000` will create an ELF file that will be
loaded at 0xc0200000.

Before:
There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000000000000 0x75e598 0x8be318 RWE 0x1000
  DYNAMIC        0x71fb20 0xffffffc00071eb20 0x000000000071eb20 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x693400 0xffffffc000692400 0x0000000000692400 0x000024 0x000024 R   0x4

After:

There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000080200000 0x734198 0x893e18 RWE 0x1000
  DYNAMIC        0x6f7810 0xffffffc0006f6810 0x00000000808f6810 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x66ca70 0xffffffc00066ba70 0x000000008086ba70 0x000024 0x000024 R   0x4

Reviewed By:	br, mhorne (earlier version)
Differential Revision: https://reviews.freebsd.org/D23436
2020-02-04 00:06:16 +00:00
Ian Lepore
eb342591f3 Revert r356077, apparently the change doesn't work after all (failed to
build in CI).
2019-12-25 18:24:38 +00:00
Ian Lepore
0b15fc2993 For riscv kernel builds, add -N to LDFLAGS instead of replacing the
SYSTEM_LD variable.  This avoids duplicating the contents of SYSTEM_LD
from kern.pre.mk just to add the -N flag to it.  If the basic linker command
ever needs to be changed, this will be one less place that has to be found
and fixed.

Some testing by kp@ indicates that the -N flag may not be needed at all,
so a comment to that effect is also added, and the -N flag may be removed
in a followup commit.

Differential Revision:	https://reviews.freebsd.org/D22920
2019-12-25 17:26:51 +00:00
Kyle Evans
e47edf50dd Revert r336353 completely based on protest; compatibility shims incoming 2018-07-17 14:11:30 +00:00
Kyle Evans
59996cb2aa Revert 336358 and step away fron machine for the day...
VERSREQ < 7.+ physically will not work with new config(8) due to major bump,
which is why I bumped it in the first place... Back to the original version
2018-07-16 23:32:24 +00:00
Kyle Evans
78a25cc760 Partially revert r336353: sys/conf/* %VERSREQ bumps
The changes made in r335998 don't strictly require a newer config(8),
though it is advised. The %VERSREQ bumps were premature.
2018-07-16 21:53:30 +00:00
Kyle Evans
2df45ae0d0 config(8): Bump major version after r335998
config-generated hints.c/env.c from r335998 and later are incompatible with
earlier kernels due to no longer setting envmode/hintmode. A minor bump for
this is insufficient, as matching major version with a later minor version
is still viewed as backwards-compatible.

This was an MI kernel change, soo all VERSREQ's are bumped.
2018-07-16 19:05:50 +00:00
Ruslan Bukin
af19cc59ca Support for v1.10 (latest) of RISC-V privilege specification.
New version is not compatible on supervisor mode with v1.9.1
(previous version).

Highlights:
    o BBL (Berkeley Boot Loader) provides no initial page tables
      anymore allowing us to choose VM, to build page tables manually
      and enable MMU in S-mode.
    o SBI interface changed.
    o GENERIC kernel.
      FDT is now chosen standard for RISC-V hardware description.
      DTB is now provided by Spike (golden model simulator). This
      allows us to introduce GENERIC kernel. However, description
      for console and timer devices is not provided in DTB, so move
      these devices temporary to nexus bus.
    o Supervisor can't access userspace by default. Solution is to
      set SUM (permit Supervisor User Memory access) bit in sstatus
      register.
    o Compressed extension is now turned on by default.
    o External GCC 7.1 compiler used.
    o _gp renamed to __global_pointer$
    o Compiler -march= string is now in use allowing us to choose
      required extensions (compressed, FPU, atomic, etc).

Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D11800
2017-08-10 14:18:09 +00:00
Ruslan Bukin
fa851a8bfb Set dependencies for genassym.c.
This fixes non-parallel build.
2016-05-24 16:30:05 +00:00
Ruslan Bukin
d52d6d7ca7 Add support for ddb(4).
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-03-10 15:51:43 +00:00
Ruslan Bukin
28029b68c0 Welcome the RISC-V 64-bit kernel.
This is the final step required allowing to compile and to run RISC-V
kernel and userland from HEAD.

RISC-V is a completely open ISA that is freely available to academia
and industry.

Thanks to all the people involved! Special thanks to Andrew Turner,
David Chisnall, Ed Maste, Konstantin Belousov, John Baldwin and
Arun Thomas for their help.
Thanks to Robert Watson for organizing this project.

This project sponsored by UK Higher Education Innovation Fund (HEIF5) and
DARPA CTSRD project at the University of Cambridge Computer Laboratory.

FreeBSD/RISC-V project home: https://wiki.freebsd.org/riscv

Reviewed by:	andrew, emaste, kib
Relnotes:	Yes
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D4982
2016-01-29 15:12:31 +00:00