Commit Graph

336 Commits

Author SHA1 Message Date
skrll 3f0f685a44 Fix CONSADDR and save a label 2022-11-19 09:55:11 +00:00
skrll ba6b048a50 Fix SR_WPRI.
Tweak csr_cycle_read and csr_asid_write for code style, and add some
KNF whitespace.
2022-11-18 06:53:06 +00:00
simonb 46b61d649b Use updated defines for the user-mode sstatus value. 2022-11-17 13:11:08 +00:00
simonb 7b393521b8 Document lots of bits.
Remove bits no longer in the RISC-V supervisor spec.
Update defines for the user-mode sstatus value.
2022-11-17 13:10:42 +00:00
simonb cb36cbd6a9 Use better types and struct member names in the clockframe.
Avoid a magic number in CLKF_USERMODE().
2022-11-17 09:50:23 +00:00
simonb 851b900a99 Include GENERIC.local if it exists. 2022-11-15 14:44:04 +00:00
simonb b2c9644078 Use similar macro-magic to aarch64 armreg.h to add per-csr
read/write/set-bits/clear-bits inline functions.  Keep the
open-coded 32-bit version of riscvreg_cycle_read() than reads
a 64-bit cycle counter values.

Added benefit of fixing these so that the inline asm uses __volatile
and aren't opmtimised to nops by the compiler.
2022-11-15 14:33:33 +00:00
skrll c0e9c629b2 Comment fix 2022-11-13 08:13:55 +00:00
simonb c47beecfb5 Add NFS_BOOT_DHCP option. 2022-11-12 11:14:44 +00:00
skrll 669353b613 Note some SV39 PTE bits defined in extensions.
Fix pte_nv_entry for the kernel.

Fix pte_pde_ptpage. PTE.{X,W,R} must be zero for pointer to next level.
2022-11-12 07:34:18 +00:00
skrll ae1bec9b63 Use uintptr_t consistently rather than register_t 2022-11-12 07:05:40 +00:00
simonb 9247fd2106 The supervisor status register is the native word width, not fixed
at 32 bits.
2022-11-11 01:18:32 +00:00
simonb b39004e590 Parentheses police. 2022-11-08 13:47:09 +00:00
simonb 9be8eebf50 Add cause register trap types, and some macros to access cause register
fields.
2022-11-08 13:35:32 +00:00
simonb a5b79238e9 Add a #define for XLEN, the RISC-V native base integer ISA width. 2022-11-08 13:34:17 +00:00
skrll bfb25fedd6 whitepsace nit 2022-11-08 12:48:28 +00:00
simonb 9af5ed22d6 In bus_space_write_{1,2,4,8} store the correct register in write to device. 2022-10-31 12:50:49 +00:00
simonb a1923cb127 Fix tyop in END for generic_bs_r_8. 2022-10-31 12:49:18 +00:00
riastradh dbfa10e52a ddb/db_active.h: New home for extern db_active.
This can be included unconditionally, and db_active can then be
queried unconditionally; if DDB is not in the kernel, then db_active
is a constant zero.  Reduces need for #include opt_ddb.h, #ifdef DDB.
2022-10-26 23:38:05 +00:00
skrll fcb3cad7b8 Add the "memory" clobber in two places that it's needed. 2022-10-20 07:18:11 +00:00
skrll 6cab7effd2 VSXLEN=64 supports 16-bit ASID space so change tlb_asid_t to be big
enough.  Spotted by Simon.
2022-10-18 07:07:51 +00:00
skrll 70aeccae8c Some fixes from Simon. 2022-10-18 06:44:43 +00:00
skrll 7f73663de2 Correct XSEGSHIFT for RV32 case 2022-10-18 04:39:38 +00:00
skrll 5dc5ff5223 remove a stray comment 2022-10-18 04:24:54 +00:00
skrll 6ca95ba209 tlb_update_addr gets called with the KERNEL_PID (ASID) so handle this
case.
2022-10-16 08:43:44 +00:00
skrll c6d5fe7424 Re-orgnaise a litte. From Simon. 2022-10-16 06:19:16 +00:00
skrll ce041175d1 Map the DTB using VM_KERNEL_DTB_BASE and CONSADDR using VM_KERNEL_IO_BASE 2022-10-16 06:14:53 +00:00
skrll 15b4e394bf Use a local label 2022-10-16 06:03:14 +00:00
skrll 5db5842785 More register re-org 2022-10-16 05:56:50 +00:00
skrll 42e825bcc2 Fix after register re-org 2022-10-16 05:48:15 +00:00
skrll 5ac639fc22 More register use re-org. 2022-10-15 16:58:16 +00:00
skrll b044e83f94 Shuffle some register usage 2022-10-15 16:34:29 +00:00
skrll bcb0ab19e0 Comment re-arragement 2022-10-15 16:29:56 +00:00
skrll 6a65246504 Remove unnecessary register assignments 2022-10-15 16:20:32 +00:00
skrll 702642680a Fix typo in SATP_MODE_SV64 2022-10-15 06:53:49 +00:00
simonb cca431d7e8 Consistency nit: use "__volatile" instead of "volatile" with asm()s. 2022-10-15 06:52:35 +00:00
simonb 3cd6da8d86 Add SATP modes for bare, SV57 and SV64. 2022-10-15 06:48:31 +00:00
simonb 41cfb489d2 Use __volatile so the compiler doesn't optimise out successive calls
to cpu_counter().
Add a 64-bit cycle counter on _LP64.
2022-10-15 06:46:41 +00:00
simonb 64b2648003 #define<tab> 2022-10-15 06:41:43 +00:00
skrll 0932c5e1eb Update a comment 2022-10-15 06:07:04 +00:00
skrll 8ecbf38c3b Pretty print 2022-10-14 08:10:22 +00:00
skrll 7563be5a5d Split out a bunch of functions from locore.S into cpu_switch.S
NFC
2022-10-14 07:58:30 +00:00
simonb cfb0850462 "options<space><tab>" 2022-10-12 07:56:46 +00:00
simonb c49931bc1f Nuke funny trailing whitespace. 2022-10-12 07:53:56 +00:00
simonb dfbce3f931 Set RISCV_DIRECTMAP_SIZE to 2^64-PAGESIZE, since 2^64 is effectively 0
for a 64bit constant.
Bump VM_PHYSSEG_MAX from 1 to 16.
2022-10-12 07:53:15 +00:00
simonb 1a8504dc6b Fix a tyop regname in a comment. 2022-10-12 07:50:56 +00:00
simonb aa62b1157c NKMEMPAGES_MIN_DEFAULT is in pages not bytes (hint is in the name).
Also set NKMEMPAGES_MAX_UNLIMITED while we're here.
2022-10-12 07:50:00 +00:00
skrll b3ba073d92 Don't set A, D in page table pointers, but do set them in leaf entries.
Beagle-v now boots to the msgbufaddr panic same as qemu
2022-09-30 06:23:58 +00:00
riastradh 6a4b8d6081 swwdog(4): Add to GENERIC kernels.
Plus a handful of others that I'm familiar with.  Lots of special-
purpose kernels should probably have this too but I'm not going
through all the arm, mips, and ppc evaluation board kernels to see
which ones are relevant.

Omitted from systems I know to be very small:
- sun2/GENERIC
- dreamcast/GENERIC
Feel free to remove it from others that need to be kept smaller.

Compile-tested a few of these just in case:
- alpha/GENERIC
- amd64/GENERIC
- evbmips/OCTEON
- i386/GENERIC
- riscv/GENERIC

PR kern/29702
2022-09-29 10:10:05 +00:00
skrll c5465e9191 Remove unnecessary include of <sys/malloc.h>. 2022-09-29 06:47:06 +00:00
skrll 3afd55fce4 Use legacy SBI Console GetChar for earlycons. It works on qemu. 2022-09-28 06:05:28 +00:00
skrll ff805ca327 Fix RV32 so it gets to the same point as RV64 2022-09-28 05:02:02 +00:00
skrll 50a2b92a99 Basic ddb and backtrace support.
[   1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564
[   1.0000000] cpu0: Begin traceback...
[   1.0000000] trace fp ffffffc000801dd0
[   1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98
[   1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984
[   1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430
[   1.0000000] cpu0: End traceback...
[   1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0):
[   1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp =                 0
[   1.0000000] s0 =0xffffffc000600ac0, s1 =            0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80
[   1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8
[   1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8
[   1.0000000] a0 =              0x17, a1 =               0xa, a2 =                 0, a3 =0xffffffc00041f658
[   1.0000000] a4 =                 0, a5 =               0x1, a5 =                 0, a7 =               0x1
[   1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 =              0x75
[   1.0000000] t4 =                 0, t5 =              0x63, t6 =               0x1
[   1.0000000] kernel: breakpoint
Stopped in pid 0.0 (system) at  ffffffc0000007e4:       c.ebreak
db>
2022-09-27 08:18:21 +00:00
skrll 664171ed4b Add some causes and convenience macros 2022-09-21 07:07:34 +00:00
skrll b24365adcf Use c99 types. NFC. 2022-09-21 06:34:30 +00:00
skrll 17949b8dc3 Checkpoint WIP.
QEMU RV64 virt can boot into virtual mode

OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 252 KB
Runtime SBI Version       : 0.3

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008003ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x00000000bfe00000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcsuh
Boot HART Features        : scounteren,mcounteren,mcountinhibit,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 16
Boot HART MIDELEG         : 0x0000000000001666
Boot HART MEDELEG         : 0x0000000000f0b509

------------
NetBSD start

sp:      0x0000_0000_80a0_2000
pc:      0x0000_0000_8020_0090
hart:    0x0000_0000_0000_0000
dtb:     0x0000_0000_bfe0_0000
l1:      0x0000_0000_80a0_2000
l2:      0x0000_0000_80a0_3000
uspace:  0x0000_0000_80a0_0000
bootstk: 0x0000_0000_80a0_2000
vtopdiff:0xffff_ffbf_7fe0_0000

bss:     0x0000_0000_808a_8bdc - 0x0000_0000_80a0_4000

0x0000_0000_80a0_3800: 0x0000_0000_2028_0821

kern 0x0000_0000_80a0_2000: 0x0000_0000_2008_002f
kern 0x0000_0000_80a0_2008: 0x0000_0000_2010_002f
kern 0x0000_0000_80a0_2010: 0x0000_0000_2018_002f
kern 0x0000_0000_80a0_2018: 0x0000_0000_2020_002f
kern 0x0000_0000_80a0_2020: 0x0000_0000_2028_002f
kern 0x0000_0000_80a0_2028: 0x0000_0000_2030_002f
kern 0x0000_0000_80a0_2030: 0x0000_0000_2038_002f
kern 0x0000_0000_80a0_2038: 0x0000_0000_2040_002f
kern 0x0000_0000_80a0_2040: 0x0000_0000_2048_002f
kern 0x0000_0000_80a0_2048: 0x0000_0000_2050_002f
kern 0x0000_0000_80a0_2050: 0x0000_0000_2058_002f
kern 0x0000_0000_80a0_2058: 0x0000_0000_2060_002f
kern 0x0000_0000_80a0_2060: 0x0000_0000_2068_002f
kern 0x0000_0000_80a0_2068: 0x0000_0000_2070_002f
kern 0x0000_0000_80a0_2070: 0x0000_0000_2078_002f
kern 0x0000_0000_80a0_2078: 0x0000_0000_2080_002f
dtb  0x0000_0000_80a0_2080: 0x0000_0000_2ff8_0027
PM
[   1.0000000] FDT<0xffffffc002000000>
[   1.0000000] consinit ok
[   1.0000000] NetBSD/riscv (fdt) booting ...
[   1.0000000] FDT /memory @ 0x80000000 size 0x40000000
[   1.0000000] init_riscv: memory start 80000000 end c0000000 (len 40000000)
[   1.0000000] bootargs: root=ld4a -v -x
[   1.0000000] bootflag 'r' not recognised
[   1.0000000] bootflag 'o' not recognised
[   1.0000000] bootflag 'o' not recognised
[   1.0000000] bootflag 't' not recognised
[   1.0000000] bootflag '=' not recognised
[   1.0000000] bootflag 'l' not recognised
[   1.0000000] bootflag ' ' not recognised
[   1.0000000] bootflag ' ' not recognised
[   1.0000000] ------------------------------------------
[   1.0000000]            kern_vtopdiff = 0xffffffbf7fe00000
[   1.0000000]             memory_start = 0x        80000000
[   1.0000000]               memory_end = 0x        c0000000
[   1.0000000]              memory_size = 0x        40000000
[   1.0000000]           kernstart_phys = 0x        80200000
[   1.0000000]             kernend_phys = 0x        80a00000
[   1.0000000]    VM_MIN_KERNEL_ADDRESS = 0xffffffc000000000
[   1.0000000]           kernstart_mega = 0xffffffc000000000
[   1.0000000]                kernstart = 0xffffffc000000000
[   1.0000000]                  kernend = 0xffffffc000800000
[   1.0000000]             kernend_mega = 0xffffffc000800000
[   1.0000000]    VM_MAX_KERNEL_ADDRESS = 0xffffffd000000000
[   1.0000000] ------------------------------------------
[   1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564
2022-09-20 07:18:23 +00:00
skrll 2e2266275f Whitespace 2022-09-20 06:53:36 +00:00
skrll 29e7c5bfdf KNF 2022-09-20 06:48:29 +00:00
skrll 167e3ebc08 Sort. NFC. 2022-09-19 09:15:01 +00:00
skrll 224a11ec9d Add some bus_space(9), bus_dma(9) and FDT infrastructure. Baby steps.
Remove the RISC-V Host Target Interface (HTIF) Emulation code.
2022-09-11 15:31:11 +00:00
skrll 357c76e08c Remove unnecessary cast. 2022-09-10 09:28:26 +00:00
simonb c7ae7f02a8 UFS/LFS dirhash:
- Enable UFS_DIRHASH if the architecture or kernel model specific config
  file can use 128MB of RAM or more.
- Remove experimental tag from UFS_DIRHASH; it's been with RUMP kernel
  and by a number of NetBSD developers for years.
- Add LFS_DIRHASH if LFS was enabled.
- Be somewhat consistent with FS options order.
2022-08-07 02:52:23 +00:00
andvar 86c307248f fix various typos, mainly in comments. 2022-05-28 10:36:21 +00:00
andvar 142201d4f5 s/dosen't/doesn't/ in copy pasted comment. 2022-05-24 19:37:39 +00:00
andvar 75d2abaeb1 fix various typos in comments and output/log messages. 2022-04-10 09:50:44 +00:00
skrll 3e2483551d Fix thinko in tlb_record_asids memset size calculation. 2021-10-30 07:18:46 +00:00
skrll 7bf4397cf8 Hacky build fixes 2021-10-07 07:13:35 +00:00
jmcneill 271b840516 #define<tab> 2021-10-05 11:01:49 +00:00
skrll e8d9aab76d Fix riscv32 GENERIC build 2021-10-05 07:05:40 +00:00
mrg 6c82f5fe13 riscv: fix build with r/o src tree
add 'compile' to the SUBDIR list so that 'make obj' creates the
kernel compile base objdir so <bsd.kernobj.mk> sets KERNOBJDIR
correctly.
2021-10-04 18:16:48 +00:00
skrll bf021c82f6 Pass the pmap in tlb_set_asid for the benefit of aarch64. 2021-10-02 14:28:04 +00:00
jmcneill 2017b9f914 efiboot: Build and install bootriscv64.efi for riscv64 builds. 2021-09-30 20:02:54 +00:00
thorpej 26788c945d - In kern_mutex.c, if MUTEX_CAS() is not defined, define it in terms of
atomic_cas_ulong().
- For arm, ia64, m68k, mips, or1k, riscv, vax: don't define our own
  MUTEX_CAS(), as they either use atomic_cas_ulong() or equivalent
  (atomic_cas_uint() on m68k).
- For alpha and sparc64, don't define MUTEX_CAS() in terms of their own
  _lock_cas(), which has its own memory barriers; the call sites in
  kern_mutex.c already have the appropriate memory barrier calls.  Thus,
  alpha and sparc64 can use default definition.
- For sh3, don't define MUTEX_CAS() in terms of its own _lock_cas();
  atomic_cas_ulong() is strong-aliased to _lock_cas(), therefore defining
  our own MUTEX_CAS() is redundant.

Per thread:
	https://mail-index.netbsd.org/tech-kern/2021/07/25/msg027562.html
2021-08-25 04:13:41 +00:00
ryo 567a3a02e7 Improved the performance of kernel profiling on MULTIPROCESSOR, and possible to get profiling data for each CPU.
In the current implementation, locks are acquired at the entrance of the mcount
internal function, so the higher the number of cores, the more lock conflict
occurs, making profiling performance in a MULTIPROCESSOR environment unusable
and slow. Profiling buffers has been changed to be reserved for each CPU,
improving profiling performance in MP by several to several dozen times.

- Eliminated cpu_simple_lock in mcount internal function, using per-CPU buffers.
- Add ci_gmon member to struct cpu_info of each MP arch.
- Add kern.profiling.percpu node in sysctl tree.
- Add new -c <cpuid> option to kgmon(8) to specify the cpuid, like openbsd.
  For compatibility, if the -c option is not specified, the entire system can be
  operated as before, and the -p option will get the total profiling data for
  all CPUs.
2021-08-14 17:51:18 +00:00
thorpej c7fb772b85 Merge thorpej-cfargs2. 2021-08-07 16:18:40 +00:00
andvar d42188d8bf Fix various typos in comments. Also add missing NetBSD RCS Id in some of these files. 2021-08-03 23:12:14 +00:00
christos 7d815136c7 Remove definitions for CACHE_LINE_SIZE and COHERENCY_UNIT which are the same
as the default.
2021-07-19 10:28:58 +00:00
simonb b1b36fc1a1 Include "opt_param.h" (ifdef _KERNEL_OPT) everywhere that MSGBUFSIZE is
referenced since some sources include <machine/param.h>.
2021-05-31 14:38:55 +00:00
dholland 6949431564 Improve ddb disassembly for mips (and riscv, cribbed from mips).
- use db_read_bytes to get instructions
- move the address check logic previously attached only to fetching
  instructions for disassembly to db_read_bytes (and db_write_bytes)

Motivated by related x86 changes this afternoon.

Note that the address check logic is not as sophisticated as what the
x86 code does, but it's what we had before. (Except that riscv will
now also try to fetch usermode instructions instead of just failing.)
2021-05-23 23:22:55 +00:00
skrll f34a02e514 Use #define<tab> in this file 2021-05-18 06:42:11 +00:00
skrll eaa362f3de Remove argument names from function declaration prototypes.
Misc tidyup.
2021-05-18 06:40:16 +00:00
skrll a0cb3f1b57 s/ENTRY/ENTRY_NP/ in a few places 2021-05-16 09:02:04 +00:00
jmcneill cd8fccb48b Add loadfile_machdep.h for riscv 2021-05-05 12:47:02 +00:00
skrll 034e13e3b5 Sort __HAVE_ #defines. NFCI. 2021-05-03 20:07:57 +00:00
skrll e0a182239c Fixup some pmap / VM related #defines and code 2021-05-01 07:41:24 +00:00
skrll 6a4a1d7bd5 Fixup kernel linking and provide a linker script with standard sections
and symbols
2021-05-01 07:13:21 +00:00
skrll b2baafe27f Enable interrupts at the end of cpu_configure 2021-05-01 07:11:12 +00:00
skrll 36a97d5bd4 Quick hack to make this link 2021-05-01 07:10:34 +00:00
skrll 85f6ed222f Provide riscvreg_satp_{read,write} 2021-05-01 07:09:55 +00:00
skrll 81bebf3704 Indent the FCSR_FRM value #defines 2021-05-01 07:09:04 +00:00
skrll fa49a3b558 Bump MSGBUFSIZE (if not defined)
Provide COHERENCY_UNIT and CACHE_LINE_SIZE

Also provide MAXCPUS
2021-05-01 07:06:54 +00:00
skrll 52a00092ff Provide __CONCAT, __STRING and ___CONCAT 2021-05-01 07:05:07 +00:00
skrll 433a060bf4 Sprinkle #ifdef FPE for now 2021-05-01 06:53:08 +00:00
skrll 43a3ad6d87 Trailing whitespace 2021-05-01 06:48:51 +00:00
skrll 7db8e1168d Make paddr_t/psize_t __uint64_t for both 32 and 64 bit ports 2021-05-01 06:45:23 +00:00
thorpej 2685996b0e Merge thorpej-cfargs branch:
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
  actually needed.
- Don't be explicit about what interface attribute is attaching if
  the device only has one.  (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
  situations, making is visibly easier to see when indirect config is
  in play, and allowing for future change in semantics.  (As of now,
  this is just a wrapper around config_match(), but that is an
  implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance.  This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
2021-04-24 23:36:23 +00:00
skrll b8baaa4b67 KNF 2021-04-20 10:15:34 +00:00
skrll 8272934fce compile fixes 2021-04-20 10:01:37 +00:00
dholland bb5b0eea67 Make the riscv disassembler work, as best as I can test from amd64 userspace. 2021-04-19 07:55:59 +00:00
dholland 5cb406aa2a Add a ddb disassembler for riscv.
builds, but not really tested yet.
2021-04-14 06:32:20 +00:00
simonb 28b83fe374 Whitespace: #define<tab> 2021-04-01 04:35:45 +00:00
simonb 2bf5a48652 Drop 64-bit default stack sizes back to 4MB. 2021-02-26 02:18:29 +00:00
nia b82de95450 do not enable kernel OSS compat in configs without compat_linux
perhaps kernel OSS compat can be merged into compat_linux to avoid
further confusion
2021-01-20 01:20:26 +00:00
skrll 31d27c3628 Support __HAVE_PMAP_PV_TRACK in sys/uvm/pmap based pmaps (aka common pmap) 2020-12-20 16:38:25 +00:00
christos a5a15771d1 interupt -> interrupt 2020-12-16 19:49:04 +00:00
skrll 65ec053145 This file is #define<space> 2020-11-15 08:09:56 +00:00
skrll a9c9122f99 Improve dump_trapframe output layout and fix printing of s6/s7 2020-11-14 13:05:14 +00:00
skrll b841d1a29f Revamp to the point it builds, but needs more work 2020-11-10 06:58:46 +00:00
skrll 40ded65bac Fix register usage 2020-11-08 10:08:28 +00:00
skrll 051f1aaa86 Fix a typo 2020-11-08 08:12:17 +00:00
skrll f68110dc88 Remove unnecessary local labels 2020-11-08 08:11:15 +00:00
skrll a391ca1173 Use correct instruction to load address of exception_userexit into RA 2020-11-08 08:07:43 +00:00
skrll 2c41f31148 Use lower case for hex constants 2020-11-07 14:48:45 +00:00
skrll 90e54f80ea Whitespace 2020-11-07 10:48:17 +00:00
skrll f4dac48a35 Indent and annotate FP registers much like the general registers 2020-11-07 10:47:35 +00:00
skrll 062f897915 Note if a register is Caller / Callee saved 2020-11-07 10:43:47 +00:00
skrll efdf1fd0aa Miscellaneous updates to reflect riscv-privileged-20190608.pdf
Some from zmcgrew@
2020-11-04 20:04:01 +00:00
skrll 938a5fbe96 Fix some of the previous - I must have compile tested the wrong tree 2020-11-04 07:51:08 +00:00
skrll 84305e753a whitespace in comments 2020-11-04 07:41:34 +00:00
skrll 25d0daa97c typo in comment 2020-11-04 07:40:15 +00:00
skrll 70c2d72ac2 RCSID and whitespace police... 2020-11-04 07:09:45 +00:00
skrll a71b947652 Miscellaneous updates to reflect riscv-privileged-20190608.pdf
Some from zmcgrew@
2020-11-04 06:56:56 +00:00
skrll 8318de92c4 Remove incorrect comment 2020-11-04 06:24:44 +00:00
skrll 78689e4e66 Add SATP_MODE values 2020-11-02 08:37:59 +00:00
skrll 11ac086b25 Whitespace 2020-11-02 08:36:54 +00:00
skrll 5c29e7255c Update CAUSE_* defines to reflect riscv-privileged-20190608.pdf 2020-11-01 21:09:48 +00:00
skrll 1098d9f33e Remove unused variable 2020-11-01 21:06:22 +00:00
skrll 5a88071071 Don't shadow 'hz' 2020-11-01 21:01:49 +00:00
skrll 45f6848cce Typo in a trap name 2020-11-01 20:56:24 +00:00
skrll 215a301198 Comments from zmcgrew@ 2020-11-01 19:47:46 +00:00
skrll f7bc763dd3 Use the 'mv' pseudo-instruction instead of the 'move' equivalent as 'mv'
is mentioned in the ISA documentation and it's used elsewhere.  That is,
let's use 'mv' everywhere for consistency.
2020-10-31 15:18:09 +00:00
christos 4d9da7b2a0 make process_machdep.c included always since it provides register i/o used by
sys_process_getlwpstatus.c which is always included.
2020-10-21 13:31:50 +00:00
christos d1f9da992b harmonize process_machdep.c inclusion. 2020-10-20 20:36:06 +00:00
christos f5da3b7f1a GC unused MAXTSIZ32 2020-10-06 13:42:03 +00:00
skrll cf9ae24dea Whitespace 2020-08-10 06:53:11 +00:00
skrll 599fa05849 Provide a pmap_segtab_deactivate for symmetry with pmap_segtab_activate
and use it in pmap_deactivate

Call pmap_md_xtab_{,de}activate from pmap_segtab_{,de}activate to be used
for PMAP_HWPAGEWALKER and any caches ops that might be required.

Provide empty (for now) pmap_md_xtab_{,de}activate functions on the
platforms that use sys/uvm/pmap
2020-08-07 07:19:45 +00:00
maxv ca08b3e761 Make copystr() a MI C function, part of libkern and shared on all
architectures.

Notes:

 - On alpha and ia64 the function is kept but gets renamed locally to avoid
   symbol collision. This is because on these two arches, I am not sure
   whether the ASM callers do not rely on fixed registers, so I prefer to
   keep the ASM body for now.
 - On Vax, only the symbol is removed, because the body is used from other
   functions.
 - On RISC-V, this change fixes a bug: copystr() was just a wrapper around
   strlcpy(), but strlcpy() makes the operation less safe (strlen on the
   source beyond its size).
 - The kASan, kCSan and kMSan wrappers are removed, because now that
   copystr() is in C, the compiler transformations are applied to it,
   without the need for manual wrappers.

Could test on amd64 only, but should be fine.
2020-06-30 16:20:00 +00:00
ad 4b8a875ae2 uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched.  It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
2020-06-11 19:20:42 +00:00
joerg 628289e37e Mark the .ident section as mergable string section to avoid redundant
entries.
2020-04-17 14:19:43 +00:00
skrll 0edf09d843 Whitespace 2020-04-06 20:26:16 +00:00
christos 42413888fc silence lint. 2020-04-04 21:13:20 +00:00
ad 2a135a5a57 Temporarily mark hppa, mips, powerpc and riscv with __HAVE_UNLOCKED_PMAP,
for the benefit of UVM.

These need some pmap changes to support concurrent faults on the same
object.  I have changes to do just that, but they're a work in progress.
2020-03-22 17:33:58 +00:00
skrll 35563434c4 Trailing whitespace 2020-03-14 16:12:15 +00:00
thorpej 29807ee596 With DEBUG defined, it's possible to execute a TLB-vs-segmap consistency
check from a (soft) interrupt handler.  But if a platform does not otherwise
require the pmap_tlb_miss_lock, then where will be a brief window of
inconsistency that, while harmless, will still fire an assertion in the
consistency check.

Fix this with the following changes:
1- Refactor the pmap_tlb_miss_lock into MI code and rename it from
   pmap_tlb_miss_lock_{enter,exit}() to pmap_tlb_miss_lock_{enter,exit}().
   MD code can still define the "md" hooks as necessary, and if so, will
   override the common implementation.
2- Provde a pmap_bootstrap_common() function to perform common pmap bootstrap
   operations, namely initializing the pmap_tlb_miss_lock if it's needed.
   If MD code overrides the implementation, it's responsible for initializing
   its own lock.
3- Call pmap_bootstrap_common() from the mips, powerpc booke, and riscv
   pmap_bootstrap() routines.  (This required adding one for riscv.)
4- Switch powerpc booke to the common pmap_tlb_miss_lock.
5- Enable pmap_tlb_miss_lock if DEBUG is defined, even if it's not otherwise
   required.

PR port-mips/55062 (Failed assertion in pmap_md_tlb_check_entry())
2020-03-11 13:30:31 +00:00
skrll c88f2c1a4e oldlwp is always non-NULL in cpu_switchto so remove the test for NULL. 2020-01-08 20:59:18 +00:00
ad 2ddceed1d9 Hopefully fix some problems seen with MP support on non-x86, in particular
where curcpu() is defined as curlwp->l_cpu:

- mi_switch(): undo the ~2007ish optimisation to unlock curlwp before
  calling cpu_switchto().  It's not safe to let other actors mess with the
  LWP (in particular l->l_cpu) while it's still context switching.  This
  removes l->l_ctxswtch.

- Move the LP_RUNNING flag into l->l_flag and rename to LW_RUNNING since
  it's now covered by the LWP's lock.

- Ditch lwp_exit_switchaway() and just call mi_switch() instead.  Everything
  is in cache anyway so it wasn't buying much by trying to avoid saving old
  state.  This means cpu_switchto() will never be called with prevlwp ==
  NULL.

- Remove some KERNEL_LOCK handling which hasn't been needed for years.
2020-01-08 17:38:41 +00:00
ad 5c06357c90 Rename uvm_free() -> uvm_availmem(). 2019-12-31 13:07:09 +00:00
ad ddd3a0be1e uvmexp.free -> uvm_free() 2019-12-21 13:00:20 +00:00
ad 57eb66c673 Fix false sharing problems with cpu_info. Identified with tprof(8).
This was a very nice win in my tests on a 48 CPU box.

- Reorganise cpu_data slightly according to usage.
- Put cpu_onproc into struct cpu_info alongside ci_curlwp (now is ci_onproc).
- On x86, put some items in their own cache lines according to usage, like
  the IPI bitmask and ci_want_resched.
2019-12-01 15:34:44 +00:00
riastradh 398a51e047 Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE. 2019-11-29 22:55:33 +00:00