├── .clang-format ├── .dockerignore ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── Makefile ├── Makefile.lib ├── README.md ├── arch ├── arm │ └── net │ │ ├── bpf_jit_32.c │ │ └── bpf_jit_32.h ├── arm64 │ ├── kernel │ │ └── insn.c │ └── net │ │ ├── bpf_jit.h │ │ └── bpf_jit_comp.c ├── riscv │ ├── include │ │ ├── asm │ │ │ ├── Kbuild │ │ │ ├── asm.h │ │ │ ├── atomic.h │ │ │ ├── barrier.h │ │ │ ├── bitops.h │ │ │ ├── bug.h │ │ │ ├── cache.h │ │ │ ├── cacheflush.h │ │ │ ├── cmpxchg.h │ │ │ ├── csr.h │ │ │ ├── current.h │ │ │ ├── delay.h │ │ │ ├── elf.h │ │ │ ├── fence.h │ │ │ ├── io.h │ │ │ ├── irq.h │ │ │ ├── irqflags.h │ │ │ ├── linkage.h │ │ │ ├── mmio.h │ │ │ ├── mmiowb.h │ │ │ ├── mmu.h │ │ │ ├── module.h │ │ │ ├── page.h │ │ │ ├── pgtable-64.h │ │ │ ├── pgtable-bits.h │ │ │ ├── pgtable.h │ │ │ ├── processor.h │ │ │ ├── ptrace.h │ │ │ ├── seccomp.h │ │ │ ├── set_memory.h │ │ │ ├── smp.h │ │ │ ├── spinlock.h │ │ │ ├── spinlock_types.h │ │ │ ├── string.h │ │ │ ├── thread_info.h │ │ │ ├── timex.h │ │ │ ├── tlbflush.h │ │ │ ├── uaccess.h │ │ │ ├── unistd.h │ │ │ ├── vdso │ │ │ │ └── processor.h │ │ │ └── vmalloc.h │ │ ├── generated │ │ │ ├── asm │ │ │ │ ├── checksum.h │ │ │ │ ├── compat.h │ │ │ │ ├── device.h │ │ │ │ ├── div64.h │ │ │ │ ├── dma-mapping.h │ │ │ │ ├── extable.h │ │ │ │ ├── hardirq.h │ │ │ │ ├── hw_irq.h │ │ │ │ ├── irq_regs.h │ │ │ │ ├── local.h │ │ │ │ ├── local64.h │ │ │ │ ├── percpu.h │ │ │ │ ├── preempt.h │ │ │ │ ├── sections.h │ │ │ │ ├── shmparam.h │ │ │ │ ├── topology.h │ │ │ │ └── unaligned.h │ │ │ └── uapi │ │ │ │ └── asm │ │ │ │ ├── errno.h │ │ │ │ ├── fcntl.h │ │ │ │ ├── ioctl.h │ │ │ │ ├── ipcbuf.h │ │ │ │ ├── param.h │ │ │ │ ├── posix_types.h │ │ │ │ ├── resource.h │ │ │ │ ├── sembuf.h │ │ │ │ ├── shmbuf.h │ │ │ │ ├── siginfo.h │ │ │ │ ├── signal.h │ │ │ │ ├── socket.h │ │ │ │ ├── sockios.h │ │ │ │ ├── stat.h │ │ │ │ ├── swab.h │ │ │ │ └── types.h │ │ └── uapi │ │ │ └── asm │ │ │ ├── Kbuild │ │ │ ├── auxvec.h │ │ │ ├── bitsperlong.h │ │ │ ├── byteorder.h │ │ │ ├── elf.h │ │ │ ├── ptrace.h │ │ │ ├── sigcontext.h │ │ │ └── unistd.h │ └── net │ │ ├── bpf_jit.h │ │ ├── bpf_jit_comp32.c │ │ ├── bpf_jit_comp64.c │ │ └── bpf_jit_core.c ├── sync-linux.sh └── x86 │ └── net │ ├── Makefile │ ├── bpf_jit_comp.c │ └── bpf_jit_comp32.c ├── include ├── asm-generic │ ├── Kbuild │ ├── atomic-long.h │ ├── barrier.h │ ├── bitops │ │ ├── __ffs.h │ │ ├── __fls.h │ │ ├── arch_hweight.h │ │ ├── const_hweight.h │ │ ├── ext2-atomic.h │ │ ├── ffs.h │ │ ├── ffz.h │ │ ├── find.h │ │ ├── fls.h │ │ ├── fls64.h │ │ ├── hweight.h │ │ ├── le.h │ │ ├── non-atomic.h │ │ └── sched.h │ ├── bitsperlong.h │ ├── bug.h │ ├── cacheflush.h │ ├── checksum.h │ ├── compat.h │ ├── device.h │ ├── div64.h │ ├── dma-mapping.h │ ├── error-injection.h │ ├── extable.h │ ├── getorder.h │ ├── hardirq.h │ ├── hw_irq.h │ ├── int-ll64.h │ ├── io.h │ ├── ioctl.h │ ├── irq.h │ ├── irq_regs.h │ ├── local.h │ ├── local64.h │ ├── memory_model.h │ ├── mmiowb.h │ ├── mmiowb_types.h │ ├── module.h │ ├── param.h │ ├── pci_iomap.h │ ├── percpu.h │ ├── pgtable-nop4d.h │ ├── pgtable-nopud.h │ ├── pgtable_uffd.h │ ├── preempt.h │ ├── resource.h │ ├── seccomp.h │ ├── sections.h │ ├── shmparam.h │ ├── signal.h │ ├── topology.h │ └── unaligned.h ├── config │ ├── auto.conf │ └── kernel.release ├── crypto │ ├── hash.h │ └── sha.h ├── generated │ ├── autoconf.h │ ├── bounds.h │ └── timeconst.h ├── linux │ ├── alarmtimer.h │ ├── arch_topology.h │ ├── assoc_array.h │ ├── atomic-fallback.h │ ├── atomic.h │ ├── auxvec.h │ ├── bit_spinlock.h │ ├── bitmap.h │ ├── bitops.h │ ├── bitrev.h │ ├── bits.h │ ├── bottom_half.h │ ├── bpf-cgroup.h │ ├── bpf-netns.h │ ├── bpf.h │ ├── bpf_types.h │ ├── bug.h │ ├── build_bug.h │ ├── bvec.h │ ├── byteorder │ │ ├── generic.h │ │ └── little_endian.h │ ├── cache.h │ ├── capability.h │ ├── cgroup-defs.h │ ├── cgroup.h │ ├── cgroup_subsys.h │ ├── compat.h │ ├── compiler-clang.h │ ├── compiler.h │ ├── compiler_attributes.h │ ├── compiler_types.h │ ├── completion.h │ ├── const.h │ ├── context_tracking_state.h │ ├── cpumask.h │ ├── crc32.h │ ├── cred.h │ ├── crypto.h │ ├── dcache.h │ ├── debug_locks.h │ ├── debugobjects.h │ ├── delay.h │ ├── delayed_call.h │ ├── dev_printk.h │ ├── device.h │ ├── device │ │ ├── bus.h │ │ ├── class.h │ │ └── driver.h │ ├── dma-debug.h │ ├── dma-direction.h │ ├── dma-mapping.h │ ├── dqblk_qtree.h │ ├── dqblk_v1.h │ ├── dqblk_v2.h │ ├── dynamic_queue_limits.h │ ├── elf.h │ ├── err.h │ ├── errno.h │ ├── error-injection.h │ ├── errseq.h │ ├── etherdevice.h │ ├── ethtool.h │ ├── export.h │ ├── fcntl.h │ ├── file.h │ ├── filter.h │ ├── fs.h │ ├── fs_types.h │ ├── ftrace_irq.h │ ├── fwnode.h │ ├── gfp.h │ ├── hardirq.h │ ├── hash.h │ ├── hashtable.h │ ├── highuid.h │ ├── hrtimer.h │ ├── hrtimer_defs.h │ ├── huge_mm.h │ ├── idr.h │ ├── if_ether.h │ ├── if_link.h │ ├── if_vlan.h │ ├── in.h │ ├── in6.h │ ├── init.h │ ├── instrumented.h │ ├── interrupt.h │ ├── io.h │ ├── iocontext.h │ ├── ioport.h │ ├── ioprio.h │ ├── ipc.h │ ├── irq.h │ ├── irq_cpustat.h │ ├── irqdesc.h │ ├── irqflags.h │ ├── irqhandler.h │ ├── irqnr.h │ ├── irqreturn.h │ ├── jhash.h │ ├── jiffies.h │ ├── jump_label.h │ ├── kallsyms.h │ ├── kasan-checks.h │ ├── kasan.h │ ├── kconfig.h │ ├── kcov.h │ ├── kcsan-checks.h │ ├── kcsan.h │ ├── kdev_t.h │ ├── kern_levels.h │ ├── kernel.h │ ├── kernel_stat.h │ ├── kernfs.h │ ├── key.h │ ├── klist.h │ ├── kmod.h │ ├── kobject.h │ ├── kobject_ns.h │ ├── kref.h │ ├── kthread.h │ ├── ktime.h │ ├── latencytop.h │ ├── limits.h │ ├── linkage.h │ ├── list.h │ ├── list_bl.h │ ├── list_lru.h │ ├── list_nulls.h │ ├── llist.h │ ├── local_lock.h │ ├── local_lock_internal.h │ ├── lockdep.h │ ├── lockref.h │ ├── log2.h │ ├── logic_pio.h │ ├── math64.h │ ├── mem_encrypt.h │ ├── memory_hotplug.h │ ├── memremap.h │ ├── migrate_mode.h │ ├── mm.h │ ├── mm_types.h │ ├── mm_types_task.h │ ├── mmap_lock.h │ ├── mmdebug.h │ ├── mmzone.h │ ├── module.h │ ├── moduleparam.h │ ├── mutex.h │ ├── net.h │ ├── netdev_features.h │ ├── netdevice.h │ ├── netfilter_defs.h │ ├── netlink.h │ ├── nfs_fs_i.h │ ├── nodemask.h │ ├── notifier.h │ ├── ns_common.h │ ├── nsproxy.h │ ├── numa.h │ ├── once.h │ ├── osq_lock.h │ ├── overflow.h │ ├── page-flags-layout.h │ ├── page-flags.h │ ├── page_ext.h │ ├── page_ref.h │ ├── pageblock-flags.h │ ├── path.h │ ├── percpu-defs.h │ ├── percpu-refcount.h │ ├── percpu-rwsem.h │ ├── percpu.h │ ├── percpu_counter.h │ ├── pfn.h │ ├── pgtable.h │ ├── pid.h │ ├── pipe_fs_i.h │ ├── plist.h │ ├── pm.h │ ├── pm_wakeup.h │ ├── poison.h │ ├── posix-timers.h │ ├── preempt.h │ ├── prefetch.h │ ├── printk.h │ ├── projid.h │ ├── psi_types.h │ ├── quota.h │ ├── radix-tree.h │ ├── random.h │ ├── range.h │ ├── ratelimit.h │ ├── rbtree.h │ ├── rbtree_latch.h │ ├── rcu_node_tree.h │ ├── rcu_segcblist.h │ ├── rcu_sync.h │ ├── rculist.h │ ├── rculist_bl.h │ ├── rcupdate.h │ ├── rcutree.h │ ├── rcuwait.h │ ├── refcount.h │ ├── resource.h │ ├── restart_block.h │ ├── rhashtable-types.h │ ├── rhashtable.h │ ├── rtnetlink.h │ ├── rwlock.h │ ├── rwlock_api_smp.h │ ├── rwlock_types.h │ ├── rwsem.h │ ├── scatterlist.h │ ├── sched.h │ ├── sched │ │ ├── clock.h │ │ ├── coredump.h │ │ ├── jobctl.h │ │ ├── prio.h │ │ ├── rt.h │ │ ├── signal.h │ │ ├── task.h │ │ ├── types.h │ │ └── user.h │ ├── seccomp.h │ ├── security.h │ ├── sem.h │ ├── semaphore.h │ ├── seq_file.h │ ├── seq_file_net.h │ ├── seqlock.h │ ├── set_memory.h │ ├── shm.h │ ├── shrinker.h │ ├── signal.h │ ├── signal_types.h │ ├── siphash.h │ ├── sizes.h │ ├── skbuff.h │ ├── slab.h │ ├── smp.h │ ├── smp_types.h │ ├── socket.h │ ├── spinlock.h │ ├── spinlock_api_smp.h │ ├── spinlock_types.h │ ├── splice.h │ ├── srcu.h │ ├── srcutree.h │ ├── stackdepot.h │ ├── stacktrace.h │ ├── stat.h │ ├── static_key.h │ ├── stddef.h │ ├── string.h │ ├── stringhash.h │ ├── stringify.h │ ├── swab.h │ ├── swait.h │ ├── sysctl.h │ ├── sysfs.h │ ├── task_io_accounting.h │ ├── textsearch.h │ ├── thread_info.h │ ├── threads.h │ ├── time.h │ ├── time32.h │ ├── time64.h │ ├── timekeeping.h │ ├── timekeeping32.h │ ├── timer.h │ ├── timerqueue.h │ ├── timex.h │ ├── topology.h │ ├── tracepoint-defs.h │ ├── typecheck.h │ ├── types.h │ ├── u64_stats_sync.h │ ├── uaccess.h │ ├── uidgid.h │ ├── uio.h │ ├── umh.h │ ├── unaligned │ │ ├── be_byteshift.h │ │ ├── generic.h │ │ ├── le_struct.h │ │ └── packed_struct.h │ ├── uprobes.h │ ├── user_namespace.h │ ├── uuid.h │ ├── vm_event_item.h │ ├── vmalloc.h │ ├── vmstat.h │ ├── vtime.h │ ├── wait.h │ ├── wait_bit.h │ ├── workqueue.h │ └── xarray.h ├── net │ ├── checksum.h │ ├── dst_ops.h │ ├── flow.h │ ├── flow_dissector.h │ ├── flow_offload.h │ ├── gen_stats.h │ ├── inet_frag.h │ ├── net_namespace.h │ ├── netlink.h │ ├── netns │ │ ├── bpf.h │ │ ├── can.h │ │ ├── core.h │ │ ├── dccp.h │ │ ├── ieee802154_6lowpan.h │ │ ├── ipv4.h │ │ ├── ipv6.h │ │ ├── mib.h │ │ ├── mpls.h │ │ ├── netfilter.h │ │ ├── nexthop.h │ │ ├── nftables.h │ │ ├── packet.h │ │ ├── sctp.h │ │ ├── unix.h │ │ ├── x_tables.h │ │ ├── xdp.h │ │ └── xfrm.h │ ├── netprio_cgroup.h │ ├── rtnetlink.h │ ├── sch_generic.h │ ├── scm.h │ ├── snmp.h │ └── xdp.h ├── uapi │ ├── Kbuild │ ├── asm-generic │ │ ├── Kbuild │ │ ├── bitsperlong.h │ │ ├── errno-base.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── hugetlb_encode.h │ │ ├── int-ll64.h │ │ ├── ioctl.h │ │ ├── ipcbuf.h │ │ ├── param.h │ │ ├── posix_types.h │ │ ├── resource.h │ │ ├── sembuf.h │ │ ├── shmbuf.h │ │ ├── siginfo.h │ │ ├── signal-defs.h │ │ ├── signal.h │ │ ├── socket.h │ │ ├── sockios.h │ │ ├── stat.h │ │ ├── swab.h │ │ ├── types.h │ │ └── unistd.h │ └── linux │ │ ├── aio_abi.h │ │ ├── auxvec.h │ │ ├── bpf.h │ │ ├── bpf_common.h │ │ ├── byteorder │ │ └── little_endian.h │ │ ├── capability.h │ │ ├── cgroupstats.h │ │ ├── const.h │ │ ├── dqblk_xfs.h │ │ ├── elf-em.h │ │ ├── elf.h │ │ ├── errno.h │ │ ├── ethtool.h │ │ ├── fcntl.h │ │ ├── filter.h │ │ ├── fs.h │ │ ├── gen_stats.h │ │ ├── hdlc │ │ └── ioctl.h │ │ ├── icmpv6.h │ │ ├── if.h │ │ ├── if_addr.h │ │ ├── if_bonding.h │ │ ├── if_ether.h │ │ ├── if_link.h │ │ ├── if_packet.h │ │ ├── if_vlan.h │ │ ├── in.h │ │ ├── in6.h │ │ ├── ioctl.h │ │ ├── ipc.h │ │ ├── irqnr.h │ │ ├── kcov.h │ │ ├── kdev_t.h │ │ ├── kernel.h │ │ ├── libc-compat.h │ │ ├── limits.h │ │ ├── neighbour.h │ │ ├── net.h │ │ ├── netdevice.h │ │ ├── netfilter.h │ │ ├── netlink.h │ │ ├── openat2.h │ │ ├── param.h │ │ ├── pkt_cls.h │ │ ├── pkt_sched.h │ │ ├── posix_types.h │ │ ├── quota.h │ │ ├── random.h │ │ ├── resource.h │ │ ├── rseq.h │ │ ├── rtnetlink.h │ │ ├── sched.h │ │ ├── seccomp.h │ │ ├── sem.h │ │ ├── shm.h │ │ ├── signal.h │ │ ├── snmp.h │ │ ├── socket.h │ │ ├── sockios.h │ │ ├── stat.h │ │ ├── stddef.h │ │ ├── string.h │ │ ├── swab.h │ │ ├── sysctl.h │ │ ├── sysinfo.h │ │ ├── taskstats.h │ │ ├── time.h │ │ ├── time_types.h │ │ ├── timex.h │ │ ├── types.h │ │ ├── uio.h │ │ ├── unistd.h │ │ ├── uuid.h │ │ ├── wait.h │ │ └── xfrm.h └── vdso │ ├── bits.h │ ├── const.h │ ├── jiffies.h │ ├── ktime.h │ ├── limits.h │ ├── math64.h │ ├── processor.h │ ├── time.h │ ├── time32.h │ └── time64.h ├── lean ├── .gitignore ├── attic │ ├── bitvec-ind │ │ ├── bv │ │ │ ├── basic.lean │ │ │ ├── helper.lean │ │ │ └── lemmas.lean │ │ └── bvaxioms.lean │ ├── bitvec-nat.lean │ ├── bitvec-vector.lean │ ├── jit-concrete.lean │ └── natutil.lean ├── leanpkg.toml ├── src │ ├── bv │ │ ├── basic.lean │ │ ├── helper.lean │ │ └── lemmas.lean │ ├── bvaxioms.lean │ └── jit.lean └── test │ └── bv.lean ├── racket ├── arm32 │ ├── bpf_jit.rkt │ ├── bpf_jit_comp.rkt │ └── spec.rkt ├── arm64 │ ├── bpf_jit.rkt │ ├── bpf_jit_comp.rkt │ ├── insn.rkt │ └── spec.rkt ├── common.rkt ├── lemmas.rkt ├── lib │ ├── bpf-common.rkt │ ├── bvaxiom.rkt │ ├── env.rkt │ ├── extraction │ │ └── c.rkt │ ├── hybrid-memory.rkt │ ├── patch.rkt │ ├── spec │ │ ├── bpf.rkt │ │ ├── epilogue.rkt │ │ ├── per-insn.rkt │ │ ├── prologue.rkt │ │ ├── proof.rkt │ │ └── tail-call.rkt │ └── tests.rkt ├── riscv │ ├── encoding │ │ ├── bpf_jit.h.tmpl │ │ ├── bpf_jit.rkt │ │ └── gen.rkt │ ├── impl-common.rkt │ ├── rv32 │ │ ├── bpf_jit_comp32.c.tmpl │ │ ├── bpf_jit_comp32.rkt │ │ ├── gen.rkt │ │ ├── spec.rkt │ │ └── synthesis.rkt │ ├── rv64 │ │ ├── bpf_jit_comp64.rkt │ │ ├── spec.rkt │ │ └── synthesis.rkt │ ├── spec-common.rkt │ └── synthesis-common.rkt ├── stacklang │ ├── .gitignore │ ├── gcd.sh │ ├── gen.rkt │ ├── jit.c │ ├── jit.c.tmpl │ ├── jit.h │ ├── jit.rkt │ ├── main.c │ ├── sema.rkt │ └── spec.rkt ├── test │ ├── arm32 │ │ ├── bugs.rkt │ │ ├── verify-alu32-k.rkt │ │ ├── verify-alu32-x.rkt │ │ ├── verify-alu64-k.rkt │ │ ├── verify-alu64-x.rkt │ │ ├── verify-endian.rkt │ │ ├── verify-epilogue.rkt │ │ ├── verify-jmp-call.rkt │ │ ├── verify-jmp32-k.rkt │ │ ├── verify-jmp32-x.rkt │ │ ├── verify-jmp64-k.rkt │ │ ├── verify-jmp64-x.rkt │ │ ├── verify-ld-imm.rkt │ │ ├── verify-ldx-mem.rkt │ │ ├── verify-prologue.rkt │ │ ├── verify-st-mem.rkt │ │ └── verify-stx-mem.rkt │ ├── arm64 │ │ ├── gen-logic-imm.py │ │ ├── logic-imm.rkt │ │ ├── test-logic-imm.rkt │ │ ├── verify-alu32-k.rkt │ │ ├── verify-alu32-x.rkt │ │ ├── verify-alu64-k.rkt │ │ ├── verify-alu64-x.rkt │ │ ├── verify-endian.rkt │ │ ├── verify-epilogue.rkt │ │ ├── verify-jmp-call.rkt │ │ ├── verify-jmp32-k.rkt │ │ ├── verify-jmp32-x.rkt │ │ ├── verify-jmp64-k.rkt │ │ ├── verify-jmp64-x.rkt │ │ ├── verify-ld-imm.rkt │ │ ├── verify-ldx-mem.rkt │ │ ├── verify-prologue.rkt │ │ ├── verify-st-mem.rkt │ │ ├── verify-stx-mem.rkt │ │ └── verify-stx-xadd.rkt │ ├── rv32 │ │ ├── synthesize-alu32-x.rkt │ │ ├── synthesize-alu64-x.rkt │ │ ├── verify-alu32-k.rkt │ │ ├── verify-alu32-x.rkt │ │ ├── verify-alu64-k.rkt │ │ ├── verify-alu64-x.rkt │ │ ├── verify-endian.rkt │ │ ├── verify-epilogue.rkt │ │ ├── verify-jmp-call.rkt │ │ ├── verify-jmp32-k.rkt │ │ ├── verify-jmp32-x.rkt │ │ ├── verify-jmp64-k.rkt │ │ ├── verify-jmp64-x.rkt │ │ ├── verify-ld-imm.rkt │ │ ├── verify-ldx-mem.rkt │ │ ├── verify-prologue.rkt │ │ ├── verify-st-mem.rkt │ │ ├── verify-stx-mem.rkt │ │ └── verify-stx-xadd.rkt │ ├── rv64 │ │ ├── bugs.rkt │ │ ├── check-llvm-encoding.rkt │ │ ├── encoding.c │ │ ├── synthesize-alu32-x.rkt │ │ ├── synthesize-alu64-x.rkt │ │ ├── verify-alu32-k.rkt │ │ ├── verify-alu32-x.rkt │ │ ├── verify-alu64-k.rkt │ │ ├── verify-alu64-x.rkt │ │ ├── verify-endian.rkt │ │ ├── verify-epilogue.rkt │ │ ├── verify-jmp-call.rkt │ │ ├── verify-jmp32-k.rkt │ │ ├── verify-jmp32-x.rkt │ │ ├── verify-jmp64-k.rkt │ │ ├── verify-jmp64-x.rkt │ │ ├── verify-ld-imm.rkt │ │ ├── verify-ldx-mem.rkt │ │ ├── verify-prologue.rkt │ │ ├── verify-st-mem.rkt │ │ ├── verify-stx-mem.rkt │ │ └── verify-stx-xadd.rkt │ ├── rvenc │ │ ├── verify-rvc.rkt │ │ └── verify-rvenc.rkt │ ├── stacklang │ │ ├── test-gcd.rkt │ │ └── verify.rkt │ ├── x86_32 │ │ ├── bugs.rkt │ │ ├── verify-alu32-k.rkt │ │ ├── verify-alu32-x.rkt │ │ ├── verify-alu64-k.rkt │ │ ├── verify-alu64-x.rkt │ │ ├── verify-endian.rkt │ │ ├── verify-epilogue.rkt │ │ ├── verify-jmp-call.rkt │ │ ├── verify-jmp32-k.rkt │ │ ├── verify-jmp32-x.rkt │ │ ├── verify-jmp64-k.rkt │ │ ├── verify-jmp64-x.rkt │ │ ├── verify-ld-imm.rkt │ │ ├── verify-ldx-mem.rkt │ │ ├── verify-prologue.rkt │ │ ├── verify-st-mem.rkt │ │ └── verify-stx-mem.rkt │ └── x86_64 │ │ ├── verify-alu32-k.rkt │ │ ├── verify-alu32-x.rkt │ │ ├── verify-alu64-k.rkt │ │ ├── verify-alu64-x.rkt │ │ ├── verify-endian.rkt │ │ ├── verify-epilogue.rkt │ │ ├── verify-jmp-call.rkt │ │ ├── verify-jmp32-k.rkt │ │ ├── verify-jmp32-x.rkt │ │ ├── verify-jmp64-k.rkt │ │ ├── verify-jmp64-x.rkt │ │ ├── verify-ld-imm.rkt │ │ ├── verify-ldx-mem.rkt │ │ ├── verify-prologue.rkt │ │ ├── verify-st-mem.rkt │ │ ├── verify-stx-mem.rkt │ │ └── verify-stx-xadd.rkt └── x86 │ ├── common.rkt │ ├── x86_32 │ ├── bpf_jit_comp32.rkt │ └── spec.rkt │ └── x86_64 │ ├── bpf_jit_comp.rkt │ └── spec.rkt └── scripts ├── Dockerfile ├── cleanheader.py ├── gen-perf-table.py ├── loc.py └── verif-perf.py /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.git 2 | **/.github 3 | **/.gitlab-ci.yml 4 | **/.gitignore 5 | **/.gitmodules 6 | **/.dockerignore 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.generated.* 2 | compiled/ 3 | .DS_Store 4 | *.o 5 | *.ll 6 | *.ll.rkt 7 | *.elf 8 | *.globals.rkt 9 | *.map 10 | *.map.rkt 11 | .codemod.bookmark 12 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: unsat/serval-tools:latest 2 | 3 | variables: 4 | GIT_SUBMODULE_STRATEGY: recursive 5 | BOOLECTOR: /opt/boolector/3.2.1-cadical/bin/boolector 6 | Z3: /opt/z3/4.8.7/bin/z3 7 | 8 | before_script: 9 | - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64" 10 | - raco pkg install ./serval 11 | 12 | verify-stacklang: 13 | script: 14 | - make verify-stacklang 15 | 16 | verify-bpf-jit-arm32: 17 | script: 18 | - make verify-arm32 19 | 20 | verify-bpf-jit-arm64: 21 | script: 22 | - make verify-arm64 23 | 24 | verify-bpf-jit-rv32: 25 | script: 26 | - make verify-rv32 27 | 28 | generate-rv32-jit: 29 | script: 30 | - make -B gen 31 | 32 | verify-bpf-jit-rv64: 33 | script: 34 | - make verify-rv64 35 | 36 | verify-bpf-jit-rvenc: 37 | script: 38 | - make verify-rvenc 39 | 40 | verify-bpf-jit-x86_32: 41 | script: 42 | - make verify-x86_32 43 | 44 | verify-bpf-jit-x86_64: 45 | script: 46 | - make verify-x86_64 47 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "serval"] 2 | path = serval 3 | url = https://github.com/uw-unsat/serval.git 4 | -------------------------------------------------------------------------------- /Makefile.lib: -------------------------------------------------------------------------------- 1 | 2 | MAKEFLAGS += --no-builtin-rules 3 | 4 | LLVM_CONFIG := llvm-config 5 | ifeq ($(shell which $(LLVM_CONFIG) 2> /dev/null),) 6 | LLVM_CONFIG := /usr/local/opt/llvm/bin/llvm-config 7 | endif 8 | ifeq ($(shell which $(LLVM_CONFIG) 2> /dev/null),) 9 | LLVM_CONFIG := /opt/homebrew/opt/llvm/bin/llvm-config 10 | endif 11 | ifeq ($(shell which $(LLVM_CONFIG) 2> /dev/null),) 12 | LLVM_PREFIX := 13 | else 14 | LLVM_PREFIX := "$(shell $(LLVM_CONFIG) --bindir)/" 15 | endif 16 | 17 | LLVM_CC := $(LLVM_PREFIX)clang 18 | LLVM_CLANG_FORMAT := $(LLVM_PREFIX)clang-format 19 | LLVM_LINK := $(LLVM_PREFIX)llvm-link 20 | LLVM_LD := $(LLVM_PREFIX)ld.lld 21 | LLVM_OBJDUMP := $(LLVM_PREFIX)llvm-objdump 22 | LLVM_OPT := $(LLVM_PREFIX)opt 23 | 24 | HOST_CC := gcc 25 | 26 | NM := nm 27 | 28 | V = @ 29 | Q = $(V:1=) 30 | QUIET_CC = $(Q:@=@echo ' CC '$@;) 31 | QUIET_CXX = $(Q:@=@echo ' CXX '$@;) 32 | QUIET_IRPY = $(Q:@=@echo ' IRPY '$@;) 33 | QUIET_AR = $(Q:@=@echo ' AR '$@;) 34 | QUIET_LD = $(Q:@=@echo ' LD '$@;) 35 | QUIET_GEN = $(Q:@=@echo ' GEN '$@;) 36 | QUIET_CPP = $(Q:@=@echo ' CPP '$@;) 37 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/Kbuild: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | generic-y += extable.h 3 | generic-y += flat.h 4 | generic-y += kvm_para.h 5 | generic-y += local64.h 6 | generic-y += user.h 7 | generic-y += vmlinux.lds.h 8 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/cache.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2017 Chen Liqin 4 | * Copyright (C) 2012 Regents of the University of California 5 | */ 6 | 7 | #ifndef _ASM_RISCV_CACHE_H 8 | #define _ASM_RISCV_CACHE_H 9 | 10 | #define L1_CACHE_SHIFT 6 11 | 12 | #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 13 | 14 | /* 15 | * RISC-V requires the stack pointer to be 16-byte aligned, so ensure that 16 | * the flat loader aligns it accordingly. 17 | */ 18 | #ifndef CONFIG_MMU 19 | #define ARCH_SLAB_MINALIGN 16 20 | #endif 21 | 22 | #endif /* _ASM_RISCV_CACHE_H */ 23 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/cacheflush.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2015 Regents of the University of California 4 | */ 5 | 6 | #ifndef _ASM_RISCV_CACHEFLUSH_H 7 | #define _ASM_RISCV_CACHEFLUSH_H 8 | 9 | #include 10 | 11 | static inline void local_flush_icache_all(void) 12 | { 13 | asm volatile ("fence.i" ::: "memory"); 14 | } 15 | 16 | #define PG_dcache_clean PG_arch_1 17 | 18 | static inline void flush_dcache_page(struct page *page) 19 | { 20 | if (test_bit(PG_dcache_clean, &page->flags)) 21 | clear_bit(PG_dcache_clean, &page->flags); 22 | } 23 | #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 24 | 25 | /* 26 | * RISC-V doesn't have an instruction to flush parts of the instruction cache, 27 | * so instead we just flush the whole thing. 28 | */ 29 | #define flush_icache_range(start, end) flush_icache_all() 30 | #define flush_icache_user_page(vma, pg, addr, len) \ 31 | flush_icache_mm(vma->vm_mm, 0) 32 | 33 | #ifndef CONFIG_SMP 34 | 35 | #define flush_icache_all() local_flush_icache_all() 36 | #define flush_icache_mm(mm, local) flush_icache_all() 37 | 38 | #else /* CONFIG_SMP */ 39 | 40 | void flush_icache_all(void); 41 | void flush_icache_mm(struct mm_struct *mm, bool local); 42 | 43 | #endif /* CONFIG_SMP */ 44 | 45 | /* 46 | * Bits in sys_riscv_flush_icache()'s flags argument. 47 | */ 48 | #define SYS_RISCV_FLUSH_ICACHE_LOCAL 1UL 49 | #define SYS_RISCV_FLUSH_ICACHE_ALL (SYS_RISCV_FLUSH_ICACHE_LOCAL) 50 | 51 | #include 52 | 53 | #endif /* _ASM_RISCV_CACHEFLUSH_H */ 54 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/current.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Based on arm/arm64/include/asm/current.h 4 | * 5 | * Copyright (C) 2016 ARM 6 | * Copyright (C) 2017 SiFive 7 | */ 8 | 9 | 10 | #ifndef _ASM_RISCV_CURRENT_H 11 | #define _ASM_RISCV_CURRENT_H 12 | 13 | #include 14 | #include 15 | 16 | #ifndef __ASSEMBLY__ 17 | 18 | struct task_struct; 19 | 20 | register struct task_struct *riscv_current_is_tp __asm__("tp"); 21 | 22 | /* 23 | * This only works because "struct thread_info" is at offset 0 from "struct 24 | * task_struct". This constraint seems to be necessary on other architectures 25 | * as well, but __switch_to enforces it. We can't check TASK_TI here because 26 | * includes this, and I can't get the definition of "struct 27 | * task_struct" here due to some header ordering problems. 28 | */ 29 | static __always_inline struct task_struct *get_current(void) 30 | { 31 | return riscv_current_is_tp; 32 | } 33 | 34 | #define current get_current() 35 | 36 | #endif /* __ASSEMBLY__ */ 37 | 38 | #endif /* _ASM_RISCV_CURRENT_H */ 39 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/delay.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2009 Chen Liqin 4 | * Copyright (C) 2016 Regents of the University of California 5 | */ 6 | 7 | #ifndef _ASM_RISCV_DELAY_H 8 | #define _ASM_RISCV_DELAY_H 9 | 10 | extern unsigned long riscv_timebase; 11 | 12 | #define udelay udelay 13 | extern void udelay(unsigned long usecs); 14 | 15 | #define ndelay ndelay 16 | extern void ndelay(unsigned long nsecs); 17 | 18 | extern void __delay(unsigned long cycles); 19 | 20 | #endif /* _ASM_RISCV_DELAY_H */ 21 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/fence.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_RISCV_FENCE_H 2 | #define _ASM_RISCV_FENCE_H 3 | 4 | #ifdef CONFIG_SMP 5 | #define RISCV_ACQUIRE_BARRIER "\tfence r , rw\n" 6 | #define RISCV_RELEASE_BARRIER "\tfence rw, w\n" 7 | #else 8 | #define RISCV_ACQUIRE_BARRIER 9 | #define RISCV_RELEASE_BARRIER 10 | #endif 11 | 12 | #endif /* _ASM_RISCV_FENCE_H */ 13 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/irq.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2012 Regents of the University of California 4 | * Copyright (C) 2017 SiFive 5 | */ 6 | 7 | #ifndef _ASM_RISCV_IRQ_H 8 | #define _ASM_RISCV_IRQ_H 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #endif /* _ASM_RISCV_IRQ_H */ 16 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/irqflags.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2012 Regents of the University of California 4 | */ 5 | 6 | 7 | #ifndef _ASM_RISCV_IRQFLAGS_H 8 | #define _ASM_RISCV_IRQFLAGS_H 9 | 10 | #include 11 | #include 12 | 13 | /* read interrupt enabled status */ 14 | static inline unsigned long arch_local_save_flags(void) 15 | { 16 | return csr_read(CSR_STATUS); 17 | } 18 | 19 | /* unconditionally enable interrupts */ 20 | static inline void arch_local_irq_enable(void) 21 | { 22 | csr_set(CSR_STATUS, SR_IE); 23 | } 24 | 25 | /* unconditionally disable interrupts */ 26 | static inline void arch_local_irq_disable(void) 27 | { 28 | csr_clear(CSR_STATUS, SR_IE); 29 | } 30 | 31 | /* get status and disable interrupts */ 32 | static inline unsigned long arch_local_irq_save(void) 33 | { 34 | return csr_read_clear(CSR_STATUS, SR_IE); 35 | } 36 | 37 | /* test flags */ 38 | static inline int arch_irqs_disabled_flags(unsigned long flags) 39 | { 40 | return !(flags & SR_IE); 41 | } 42 | 43 | /* test hardware interrupt enable bit */ 44 | static inline int arch_irqs_disabled(void) 45 | { 46 | return arch_irqs_disabled_flags(arch_local_save_flags()); 47 | } 48 | 49 | /* set interrupt enabled status */ 50 | static inline void arch_local_irq_restore(unsigned long flags) 51 | { 52 | csr_set(CSR_STATUS, flags & SR_IE); 53 | } 54 | 55 | #endif /* _ASM_RISCV_IRQFLAGS_H */ 56 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/linkage.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2015 Regents of the University of California 4 | */ 5 | 6 | #ifndef _ASM_RISCV_LINKAGE_H 7 | #define _ASM_RISCV_LINKAGE_H 8 | 9 | #define __ALIGN .balign 4 10 | #define __ALIGN_STR ".balign 4" 11 | 12 | #endif /* _ASM_RISCV_LINKAGE_H */ 13 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/mmiowb.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #ifndef _ASM_RISCV_MMIOWB_H 4 | #define _ASM_RISCV_MMIOWB_H 5 | 6 | /* 7 | * "o,w" is sufficient to ensure that all writes to the device have completed 8 | * before the write to the spinlock is allowed to commit. 9 | */ 10 | #define mmiowb() __asm__ __volatile__ ("fence o,w" : : : "memory"); 11 | 12 | #include 13 | #include 14 | 15 | #endif /* _ASM_RISCV_MMIOWB_H */ 16 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/mmu.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2012 Regents of the University of California 4 | */ 5 | 6 | 7 | #ifndef _ASM_RISCV_MMU_H 8 | #define _ASM_RISCV_MMU_H 9 | 10 | #ifndef __ASSEMBLY__ 11 | 12 | typedef struct { 13 | #ifndef CONFIG_MMU 14 | unsigned long end_brk; 15 | #endif 16 | void *vdso; 17 | #ifdef CONFIG_SMP 18 | /* A local icache flush is needed before user execution can resume. */ 19 | cpumask_t icache_stale_mask; 20 | #endif 21 | } mm_context_t; 22 | 23 | #endif /* __ASSEMBLY__ */ 24 | 25 | #endif /* _ASM_RISCV_MMU_H */ 26 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/pgtable-bits.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2012 Regents of the University of California 4 | */ 5 | 6 | #ifndef _ASM_RISCV_PGTABLE_BITS_H 7 | #define _ASM_RISCV_PGTABLE_BITS_H 8 | 9 | /* 10 | * PTE format: 11 | * | XLEN-1 10 | 9 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 12 | * PFN reserved for SW D A G U X W R V 13 | */ 14 | 15 | #define _PAGE_ACCESSED_OFFSET 6 16 | 17 | #define _PAGE_PRESENT (1 << 0) 18 | #define _PAGE_READ (1 << 1) /* Readable */ 19 | #define _PAGE_WRITE (1 << 2) /* Writable */ 20 | #define _PAGE_EXEC (1 << 3) /* Executable */ 21 | #define _PAGE_USER (1 << 4) /* User */ 22 | #define _PAGE_GLOBAL (1 << 5) /* Global */ 23 | #define _PAGE_ACCESSED (1 << 6) /* Set by hardware on any access */ 24 | #define _PAGE_DIRTY (1 << 7) /* Set by hardware on any write */ 25 | #define _PAGE_SOFT (1 << 8) /* Reserved for software */ 26 | 27 | #define _PAGE_SPECIAL _PAGE_SOFT 28 | #define _PAGE_TABLE _PAGE_PRESENT 29 | 30 | /* 31 | * _PAGE_PROT_NONE is set on not-present pages (and ignored by the hardware) to 32 | * distinguish them from swapped out pages 33 | */ 34 | #define _PAGE_PROT_NONE _PAGE_READ 35 | 36 | #define _PAGE_PFN_SHIFT 10 37 | 38 | /* Set of bits to preserve across pte_modify() */ 39 | #define _PAGE_CHG_MASK (~(unsigned long)(_PAGE_PRESENT | _PAGE_READ | \ 40 | _PAGE_WRITE | _PAGE_EXEC | \ 41 | _PAGE_USER | _PAGE_GLOBAL)) 42 | 43 | #endif /* _ASM_RISCV_PGTABLE_BITS_H */ 44 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/seccomp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #ifndef _ASM_SECCOMP_H 4 | #define _ASM_SECCOMP_H 5 | 6 | #include 7 | 8 | #include 9 | 10 | #endif /* _ASM_SECCOMP_H */ 11 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/set_memory.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2019 SiFive 4 | */ 5 | 6 | #ifndef _ASM_RISCV_SET_MEMORY_H 7 | #define _ASM_RISCV_SET_MEMORY_H 8 | 9 | #ifndef __ASSEMBLY__ 10 | /* 11 | * Functions to change memory attributes. 12 | */ 13 | #ifdef CONFIG_MMU 14 | int set_memory_ro(unsigned long addr, int numpages); 15 | int set_memory_rw(unsigned long addr, int numpages); 16 | int set_memory_x(unsigned long addr, int numpages); 17 | int set_memory_nx(unsigned long addr, int numpages); 18 | #else 19 | static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; } 20 | static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; } 21 | static inline int set_memory_x(unsigned long addr, int numpages) { return 0; } 22 | static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; } 23 | #endif 24 | 25 | int set_direct_map_invalid_noflush(struct page *page); 26 | int set_direct_map_default_noflush(struct page *page); 27 | 28 | #endif /* __ASSEMBLY__ */ 29 | 30 | #ifdef CONFIG_ARCH_HAS_STRICT_KERNEL_RWX 31 | #ifdef CONFIG_64BIT 32 | #define SECTION_ALIGN (1 << 21) 33 | #else 34 | #define SECTION_ALIGN (1 << 22) 35 | #endif 36 | #else /* !CONFIG_ARCH_HAS_STRICT_KERNEL_RWX */ 37 | #define SECTION_ALIGN L1_CACHE_BYTES 38 | #endif /* CONFIG_ARCH_HAS_STRICT_KERNEL_RWX */ 39 | 40 | #endif /* _ASM_RISCV_SET_MEMORY_H */ 41 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/spinlock_types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2015 Regents of the University of California 4 | */ 5 | 6 | #ifndef _ASM_RISCV_SPINLOCK_TYPES_H 7 | #define _ASM_RISCV_SPINLOCK_TYPES_H 8 | 9 | #ifndef __LINUX_SPINLOCK_TYPES_H 10 | # error "please don't include this file directly" 11 | #endif 12 | 13 | typedef struct { 14 | volatile unsigned int lock; 15 | } arch_spinlock_t; 16 | 17 | #define __ARCH_SPIN_LOCK_UNLOCKED { 0 } 18 | 19 | typedef struct { 20 | volatile unsigned int lock; 21 | } arch_rwlock_t; 22 | 23 | #define __ARCH_RW_LOCK_UNLOCKED { 0 } 24 | 25 | #endif /* _ASM_RISCV_SPINLOCK_TYPES_H */ 26 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/string.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2013 Regents of the University of California 4 | */ 5 | 6 | #ifndef _ASM_RISCV_STRING_H 7 | #define _ASM_RISCV_STRING_H 8 | 9 | #include 10 | #include 11 | 12 | #define __HAVE_ARCH_MEMSET 13 | extern asmlinkage void *memset(void *, int, size_t); 14 | extern asmlinkage void *__memset(void *, int, size_t); 15 | 16 | #define __HAVE_ARCH_MEMCPY 17 | extern asmlinkage void *memcpy(void *, const void *, size_t); 18 | extern asmlinkage void *__memcpy(void *, const void *, size_t); 19 | 20 | /* For those files which don't want to check by kasan. */ 21 | #if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__) 22 | 23 | #define memcpy(dst, src, len) __memcpy(dst, src, len) 24 | #define memset(s, c, n) __memset(s, c, n) 25 | 26 | #endif 27 | #endif /* _ASM_RISCV_STRING_H */ 28 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/unistd.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2012 Regents of the University of California 4 | */ 5 | 6 | /* 7 | * There is explicitly no include guard here because this file is expected to 8 | * be included multiple times. 9 | */ 10 | 11 | #define __ARCH_WANT_SYS_CLONE 12 | 13 | #include 14 | 15 | #define NR_syscalls (__NR_syscalls) 16 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/vdso/processor.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | #ifndef __ASM_VDSO_PROCESSOR_H 3 | #define __ASM_VDSO_PROCESSOR_H 4 | 5 | #ifndef __ASSEMBLY__ 6 | 7 | static inline void cpu_relax(void) 8 | { 9 | #ifdef __riscv_muldiv 10 | int dummy; 11 | /* In lieu of a halt instruction, induce a long-latency stall. */ 12 | __asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy)); 13 | #endif 14 | barrier(); 15 | } 16 | 17 | #endif /* __ASSEMBLY__ */ 18 | 19 | #endif /* __ASM_VDSO_PROCESSOR_H */ 20 | -------------------------------------------------------------------------------- /arch/riscv/include/asm/vmalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_RISCV_VMALLOC_H 2 | #define _ASM_RISCV_VMALLOC_H 3 | 4 | #endif /* _ASM_RISCV_VMALLOC_H */ 5 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/checksum.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/compat.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/device.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/div64.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/dma-mapping.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/extable.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/hardirq.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/hw_irq.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/irq_regs.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/local.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/local64.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/percpu.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/preempt.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/sections.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/shmparam.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/topology.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/asm/unaligned.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/errno.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/fcntl.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/ioctl.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/ipcbuf.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/param.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/posix_types.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/resource.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/sembuf.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/shmbuf.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/siginfo.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/signal.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/socket.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/sockios.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/stat.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/swab.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/generated/uapi/asm/types.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /arch/riscv/include/uapi/asm/Kbuild: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | -------------------------------------------------------------------------------- /arch/riscv/include/uapi/asm/auxvec.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (C) 2012 ARM Ltd. 4 | * Copyright (C) 2015 Regents of the University of California 5 | */ 6 | 7 | #ifndef _UAPI_ASM_RISCV_AUXVEC_H 8 | #define _UAPI_ASM_RISCV_AUXVEC_H 9 | 10 | /* vDSO location */ 11 | #define AT_SYSINFO_EHDR 33 12 | 13 | #endif /* _UAPI_ASM_RISCV_AUXVEC_H */ 14 | -------------------------------------------------------------------------------- /arch/riscv/include/uapi/asm/bitsperlong.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (C) 2012 ARM Ltd. 4 | * Copyright (C) 2015 Regents of the University of California 5 | */ 6 | 7 | #ifndef _UAPI_ASM_RISCV_BITSPERLONG_H 8 | #define _UAPI_ASM_RISCV_BITSPERLONG_H 9 | 10 | #define __BITS_PER_LONG (__SIZEOF_POINTER__ * 8) 11 | 12 | #include 13 | 14 | #endif /* _UAPI_ASM_RISCV_BITSPERLONG_H */ 15 | -------------------------------------------------------------------------------- /arch/riscv/include/uapi/asm/byteorder.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (C) 2012 ARM Ltd. 4 | * Copyright (C) 2015 Regents of the University of California 5 | */ 6 | 7 | #ifndef _UAPI_ASM_RISCV_BYTEORDER_H 8 | #define _UAPI_ASM_RISCV_BYTEORDER_H 9 | 10 | #include 11 | 12 | #endif /* _UAPI_ASM_RISCV_BYTEORDER_H */ 13 | -------------------------------------------------------------------------------- /arch/riscv/include/uapi/asm/sigcontext.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 | /* 3 | * Copyright (C) 2012 Regents of the University of California 4 | */ 5 | 6 | #ifndef _UAPI_ASM_RISCV_SIGCONTEXT_H 7 | #define _UAPI_ASM_RISCV_SIGCONTEXT_H 8 | 9 | #include 10 | 11 | /* 12 | * Signal context structure 13 | * 14 | * This contains the context saved before a signal handler is invoked; 15 | * it is restored by sys_sigreturn / sys_rt_sigreturn. 16 | */ 17 | struct sigcontext { 18 | struct user_regs_struct sc_regs; 19 | union __riscv_fp_state sc_fpregs; 20 | }; 21 | 22 | #endif /* _UAPI_ASM_RISCV_SIGCONTEXT_H */ 23 | -------------------------------------------------------------------------------- /arch/sync-linux.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail; 3 | 4 | if [[ "$#" -ne 1 ]]; then 5 | echo "Usage: $0 [path to linux tree]"; 6 | exit 1; 7 | fi 8 | 9 | LINUX="$1" 10 | 11 | for ARCH in arm arm64 riscv x86; do 12 | echo "Syncing $ARCH"; 13 | cp "$LINUX"/arch/"$ARCH"/net/*bpf* ./"$ARCH"/net/; 14 | done 15 | 16 | # Also copy arm64 insn.c 17 | cp "$LINUX"/arch/arm64/kernel/insn.c ./arm64/kernel/; 18 | -------------------------------------------------------------------------------- /arch/x86/net/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0-only 2 | # 3 | # Arch-specific network modules 4 | # 5 | 6 | ifeq ($(CONFIG_X86_32),y) 7 | obj-$(CONFIG_BPF_JIT) += bpf_jit_comp32.o 8 | else 9 | obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o 10 | endif 11 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/__ffs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS___FFS_H_ 3 | #define _ASM_GENERIC_BITOPS___FFS_H_ 4 | 5 | #include 6 | 7 | /** 8 | * __ffs - find first bit in word. 9 | * @word: The word to search 10 | * 11 | * Undefined if no bit exists, so code should check against 0 first. 12 | */ 13 | static __always_inline unsigned long __ffs(unsigned long word) 14 | { 15 | int num = 0; 16 | 17 | #if BITS_PER_LONG == 64 18 | if ((word & 0xffffffff) == 0) { 19 | num += 32; 20 | word >>= 32; 21 | } 22 | #endif 23 | if ((word & 0xffff) == 0) { 24 | num += 16; 25 | word >>= 16; 26 | } 27 | if ((word & 0xff) == 0) { 28 | num += 8; 29 | word >>= 8; 30 | } 31 | if ((word & 0xf) == 0) { 32 | num += 4; 33 | word >>= 4; 34 | } 35 | if ((word & 0x3) == 0) { 36 | num += 2; 37 | word >>= 2; 38 | } 39 | if ((word & 0x1) == 0) 40 | num += 1; 41 | return num; 42 | } 43 | 44 | #endif /* _ASM_GENERIC_BITOPS___FFS_H_ */ 45 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/__fls.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS___FLS_H_ 3 | #define _ASM_GENERIC_BITOPS___FLS_H_ 4 | 5 | #include 6 | 7 | /** 8 | * __fls - find last (most-significant) set bit in a long word 9 | * @word: the word to search 10 | * 11 | * Undefined if no set bit exists, so code should check against 0 first. 12 | */ 13 | static __always_inline unsigned long __fls(unsigned long word) 14 | { 15 | int num = BITS_PER_LONG - 1; 16 | 17 | #if BITS_PER_LONG == 64 18 | if (!(word & (~0ul << 32))) { 19 | num -= 32; 20 | word <<= 32; 21 | } 22 | #endif 23 | if (!(word & (~0ul << (BITS_PER_LONG-16)))) { 24 | num -= 16; 25 | word <<= 16; 26 | } 27 | if (!(word & (~0ul << (BITS_PER_LONG-8)))) { 28 | num -= 8; 29 | word <<= 8; 30 | } 31 | if (!(word & (~0ul << (BITS_PER_LONG-4)))) { 32 | num -= 4; 33 | word <<= 4; 34 | } 35 | if (!(word & (~0ul << (BITS_PER_LONG-2)))) { 36 | num -= 2; 37 | word <<= 2; 38 | } 39 | if (!(word & (~0ul << (BITS_PER_LONG-1)))) 40 | num -= 1; 41 | return num; 42 | } 43 | 44 | #endif /* _ASM_GENERIC_BITOPS___FLS_H_ */ 45 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/arch_hweight.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS_ARCH_HWEIGHT_H_ 3 | #define _ASM_GENERIC_BITOPS_ARCH_HWEIGHT_H_ 4 | 5 | #include 6 | 7 | static inline unsigned int __arch_hweight32(unsigned int w) 8 | { 9 | return __sw_hweight32(w); 10 | } 11 | 12 | static inline unsigned int __arch_hweight16(unsigned int w) 13 | { 14 | return __sw_hweight16(w); 15 | } 16 | 17 | static inline unsigned int __arch_hweight8(unsigned int w) 18 | { 19 | return __sw_hweight8(w); 20 | } 21 | 22 | static inline unsigned long __arch_hweight64(__u64 w) 23 | { 24 | return __sw_hweight64(w); 25 | } 26 | #endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ 27 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/ext2-atomic.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ 3 | #define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ 4 | 5 | /* 6 | * Spinlock based version of ext2 atomic bitops 7 | */ 8 | 9 | #define ext2_set_bit_atomic(lock, nr, addr) \ 10 | ({ \ 11 | int ret; \ 12 | spin_lock(lock); \ 13 | ret = __test_and_set_bit_le(nr, addr); \ 14 | spin_unlock(lock); \ 15 | ret; \ 16 | }) 17 | 18 | #define ext2_clear_bit_atomic(lock, nr, addr) \ 19 | ({ \ 20 | int ret; \ 21 | spin_lock(lock); \ 22 | ret = __test_and_clear_bit_le(nr, addr); \ 23 | spin_unlock(lock); \ 24 | ret; \ 25 | }) 26 | 27 | #endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ */ 28 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/ffs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS_FFS_H_ 3 | #define _ASM_GENERIC_BITOPS_FFS_H_ 4 | 5 | /** 6 | * ffs - find first bit set 7 | * @x: the word to search 8 | * 9 | * This is defined the same way as 10 | * the libc and compiler builtin ffs routines, therefore 11 | * differs in spirit from the above ffz (man ffs). 12 | */ 13 | static inline int ffs(int x) 14 | { 15 | int r = 1; 16 | 17 | if (!x) 18 | return 0; 19 | if (!(x & 0xffff)) { 20 | x >>= 16; 21 | r += 16; 22 | } 23 | if (!(x & 0xff)) { 24 | x >>= 8; 25 | r += 8; 26 | } 27 | if (!(x & 0xf)) { 28 | x >>= 4; 29 | r += 4; 30 | } 31 | if (!(x & 3)) { 32 | x >>= 2; 33 | r += 2; 34 | } 35 | if (!(x & 1)) { 36 | x >>= 1; 37 | r += 1; 38 | } 39 | return r; 40 | } 41 | 42 | #endif /* _ASM_GENERIC_BITOPS_FFS_H_ */ 43 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/ffz.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS_FFZ_H_ 3 | #define _ASM_GENERIC_BITOPS_FFZ_H_ 4 | 5 | /* 6 | * ffz - find first zero in word. 7 | * @word: The word to search 8 | * 9 | * Undefined if no zero exists, so code should check against ~0UL first. 10 | */ 11 | #define ffz(x) __ffs(~(x)) 12 | 13 | #endif /* _ASM_GENERIC_BITOPS_FFZ_H_ */ 14 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/fls.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS_FLS_H_ 3 | #define _ASM_GENERIC_BITOPS_FLS_H_ 4 | 5 | /** 6 | * fls - find last (most-significant) bit set 7 | * @x: the word to search 8 | * 9 | * This is defined the same way as ffs. 10 | * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 11 | */ 12 | 13 | static __always_inline int fls(unsigned int x) 14 | { 15 | int r = 32; 16 | 17 | if (!x) 18 | return 0; 19 | if (!(x & 0xffff0000u)) { 20 | x <<= 16; 21 | r -= 16; 22 | } 23 | if (!(x & 0xff000000u)) { 24 | x <<= 8; 25 | r -= 8; 26 | } 27 | if (!(x & 0xf0000000u)) { 28 | x <<= 4; 29 | r -= 4; 30 | } 31 | if (!(x & 0xc0000000u)) { 32 | x <<= 2; 33 | r -= 2; 34 | } 35 | if (!(x & 0x80000000u)) { 36 | x <<= 1; 37 | r -= 1; 38 | } 39 | return r; 40 | } 41 | 42 | #endif /* _ASM_GENERIC_BITOPS_FLS_H_ */ 43 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/fls64.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS_FLS64_H_ 3 | #define _ASM_GENERIC_BITOPS_FLS64_H_ 4 | 5 | #include 6 | 7 | /** 8 | * fls64 - find last set bit in a 64-bit word 9 | * @x: the word to search 10 | * 11 | * This is defined in a similar way as the libc and compiler builtin 12 | * ffsll, but returns the position of the most significant set bit. 13 | * 14 | * fls64(value) returns 0 if value is 0 or the position of the last 15 | * set bit if value is nonzero. The last (most significant) bit is 16 | * at position 64. 17 | */ 18 | #if BITS_PER_LONG == 32 19 | static __always_inline int fls64(__u64 x) 20 | { 21 | __u32 h = x >> 32; 22 | if (h) 23 | return fls(h) + 32; 24 | return fls(x); 25 | } 26 | #elif BITS_PER_LONG == 64 27 | static __always_inline int fls64(__u64 x) 28 | { 29 | if (x == 0) 30 | return 0; 31 | return __fls(x) + 1; 32 | } 33 | #else 34 | #error BITS_PER_LONG not 32 or 64 35 | #endif 36 | 37 | #endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */ 38 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/hweight.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS_HWEIGHT_H_ 3 | #define _ASM_GENERIC_BITOPS_HWEIGHT_H_ 4 | 5 | #include 6 | #include 7 | 8 | #endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ 9 | -------------------------------------------------------------------------------- /include/asm-generic/bitops/sched.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_BITOPS_SCHED_H_ 3 | #define _ASM_GENERIC_BITOPS_SCHED_H_ 4 | 5 | #include /* unlikely() */ 6 | #include 7 | 8 | /* 9 | * Every architecture must define this function. It's the fastest 10 | * way of searching a 100-bit bitmap. It's guaranteed that at least 11 | * one of the 100 bits is cleared. 12 | */ 13 | static inline int sched_find_first_bit(const unsigned long *b) 14 | { 15 | #if BITS_PER_LONG == 64 16 | if (b[0]) 17 | return __ffs(b[0]); 18 | return __ffs(b[1]) + 64; 19 | #elif BITS_PER_LONG == 32 20 | if (b[0]) 21 | return __ffs(b[0]); 22 | if (b[1]) 23 | return __ffs(b[1]) + 32; 24 | if (b[2]) 25 | return __ffs(b[2]) + 64; 26 | return __ffs(b[3]) + 96; 27 | #else 28 | #error BITS_PER_LONG not defined 29 | #endif 30 | } 31 | 32 | #endif /* _ASM_GENERIC_BITOPS_SCHED_H_ */ 33 | -------------------------------------------------------------------------------- /include/asm-generic/bitsperlong.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_BITS_PER_LONG 3 | #define __ASM_GENERIC_BITS_PER_LONG 4 | 5 | #include 6 | 7 | 8 | #ifdef CONFIG_64BIT 9 | #define BITS_PER_LONG 64 10 | #else 11 | #define BITS_PER_LONG 32 12 | #endif /* CONFIG_64BIT */ 13 | 14 | /* 15 | * FIXME: The check currently breaks x86-64 build, so it's 16 | * temporarily disabled. Please fix x86-64 and reenable 17 | */ 18 | #if 0 && BITS_PER_LONG != __BITS_PER_LONG 19 | #error Inconsistent word size. Check asm/bitsperlong.h 20 | #endif 21 | 22 | #ifndef BITS_PER_LONG_LONG 23 | #define BITS_PER_LONG_LONG 64 24 | #endif 25 | 26 | #endif /* __ASM_GENERIC_BITS_PER_LONG */ 27 | -------------------------------------------------------------------------------- /include/asm-generic/compat.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_COMPAT_H 3 | #define __ASM_GENERIC_COMPAT_H 4 | 5 | /* These types are common across all compat ABIs */ 6 | typedef u32 compat_size_t; 7 | typedef s32 compat_ssize_t; 8 | typedef s32 compat_clock_t; 9 | typedef s32 compat_pid_t; 10 | typedef u32 compat_ino_t; 11 | typedef s32 compat_off_t; 12 | typedef s64 compat_loff_t; 13 | typedef s32 compat_daddr_t; 14 | typedef s32 compat_timer_t; 15 | typedef s32 compat_key_t; 16 | typedef s16 compat_short_t; 17 | typedef s32 compat_int_t; 18 | typedef s32 compat_long_t; 19 | typedef u16 compat_ushort_t; 20 | typedef u32 compat_uint_t; 21 | typedef u32 compat_ulong_t; 22 | typedef u32 compat_uptr_t; 23 | typedef u32 compat_aio_context_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/asm-generic/device.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Arch specific extensions to struct device 4 | */ 5 | #ifndef _ASM_GENERIC_DEVICE_H 6 | #define _ASM_GENERIC_DEVICE_H 7 | 8 | struct dev_archdata { 9 | }; 10 | 11 | struct pdev_archdata { 12 | }; 13 | 14 | #endif /* _ASM_GENERIC_DEVICE_H */ 15 | -------------------------------------------------------------------------------- /include/asm-generic/dma-mapping.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_DMA_MAPPING_H 3 | #define _ASM_GENERIC_DMA_MAPPING_H 4 | 5 | static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) 6 | { 7 | return NULL; 8 | } 9 | 10 | #endif /* _ASM_GENERIC_DMA_MAPPING_H */ 11 | -------------------------------------------------------------------------------- /include/asm-generic/error-injection.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_ERROR_INJECTION_H 3 | #define _ASM_GENERIC_ERROR_INJECTION_H 4 | 5 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) 6 | enum { 7 | EI_ETYPE_NONE, /* Dummy value for undefined case */ 8 | EI_ETYPE_NULL, /* Return NULL if failure */ 9 | EI_ETYPE_ERRNO, /* Return -ERRNO if failure */ 10 | EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */ 11 | EI_ETYPE_TRUE, /* Return true if failure */ 12 | }; 13 | 14 | struct error_injection_entry { 15 | unsigned long addr; 16 | int etype; 17 | }; 18 | 19 | struct pt_regs; 20 | 21 | #ifdef CONFIG_FUNCTION_ERROR_INJECTION 22 | /* 23 | * Whitelist ganerating macro. Specify functions which can be 24 | * error-injectable using this macro. 25 | */ 26 | #define ALLOW_ERROR_INJECTION(fname, _etype) \ 27 | static struct error_injection_entry __used \ 28 | __attribute__((__section__("_error_injection_whitelist"))) \ 29 | _eil_addr_##fname = { \ 30 | .addr = (unsigned long)fname, \ 31 | .etype = EI_ETYPE_##_etype, \ 32 | }; 33 | 34 | void override_function_with_return(struct pt_regs *regs); 35 | #else 36 | #define ALLOW_ERROR_INJECTION(fname, _etype) 37 | 38 | static inline void override_function_with_return(struct pt_regs *regs) { } 39 | #endif 40 | #endif 41 | 42 | #endif /* _ASM_GENERIC_ERROR_INJECTION_H */ 43 | -------------------------------------------------------------------------------- /include/asm-generic/extable.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_EXTABLE_H 3 | #define __ASM_GENERIC_EXTABLE_H 4 | 5 | /* 6 | * The exception table consists of pairs of addresses: the first is the 7 | * address of an instruction that is allowed to fault, and the second is 8 | * the address at which the program should continue. No registers are 9 | * modified, so it is entirely up to the continuation code to figure out 10 | * what to do. 11 | * 12 | * All the routines below use bits of fixup code that are out of line 13 | * with the main instruction path. This means when everything is well, 14 | * we don't even have to jump over them. Further, they do not intrude 15 | * on our cache or tlb entries. 16 | */ 17 | 18 | struct exception_table_entry 19 | { 20 | unsigned long insn, fixup; 21 | }; 22 | 23 | 24 | struct pt_regs; 25 | extern int fixup_exception(struct pt_regs *regs); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/asm-generic/getorder.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_GETORDER_H 3 | #define __ASM_GENERIC_GETORDER_H 4 | 5 | #ifndef __ASSEMBLY__ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * get_order - Determine the allocation order of a memory size 12 | * @size: The size for which to get the order 13 | * 14 | * Determine the allocation order of a particular sized block of memory. This 15 | * is on a logarithmic scale, where: 16 | * 17 | * 0 -> 2^0 * PAGE_SIZE and below 18 | * 1 -> 2^1 * PAGE_SIZE to 2^0 * PAGE_SIZE + 1 19 | * 2 -> 2^2 * PAGE_SIZE to 2^1 * PAGE_SIZE + 1 20 | * 3 -> 2^3 * PAGE_SIZE to 2^2 * PAGE_SIZE + 1 21 | * 4 -> 2^4 * PAGE_SIZE to 2^3 * PAGE_SIZE + 1 22 | * ... 23 | * 24 | * The order returned is used to find the smallest allocation granule required 25 | * to hold an object of the specified size. 26 | * 27 | * The result is undefined if the size is 0. 28 | */ 29 | static inline __attribute_const__ int get_order(unsigned long size) 30 | { 31 | if (__builtin_constant_p(size)) { 32 | if (!size) 33 | return BITS_PER_LONG - PAGE_SHIFT; 34 | 35 | if (size < (1UL << PAGE_SHIFT)) 36 | return 0; 37 | 38 | return ilog2((size) - 1) - PAGE_SHIFT + 1; 39 | } 40 | 41 | size--; 42 | size >>= PAGE_SHIFT; 43 | #if BITS_PER_LONG == 32 44 | return fls(size); 45 | #else 46 | return fls64(size); 47 | #endif 48 | } 49 | 50 | #endif /* __ASSEMBLY__ */ 51 | 52 | #endif /* __ASM_GENERIC_GETORDER_H */ 53 | -------------------------------------------------------------------------------- /include/asm-generic/hardirq.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_HARDIRQ_H 3 | #define __ASM_GENERIC_HARDIRQ_H 4 | 5 | #include 6 | #include 7 | 8 | typedef struct { 9 | unsigned int __softirq_pending; 10 | } ____cacheline_aligned irq_cpustat_t; 11 | 12 | #include /* Standard mappings for irq_cpustat_t above */ 13 | #include 14 | 15 | #ifndef ack_bad_irq 16 | static inline void ack_bad_irq(unsigned int irq) 17 | { 18 | printk(KERN_CRIT "unexpected IRQ trap at vector %02x\n", irq); 19 | } 20 | #endif 21 | 22 | #endif /* __ASM_GENERIC_HARDIRQ_H */ 23 | -------------------------------------------------------------------------------- /include/asm-generic/hw_irq.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_GENERIC_HW_IRQ_H 2 | #define __ASM_GENERIC_HW_IRQ_H 3 | /* 4 | * hw_irq.h has internal declarations for the low-level interrupt 5 | * controller, like the original i8259A. 6 | * In general, this is not needed for new architectures. 7 | */ 8 | 9 | #endif /* __ASM_GENERIC_HW_IRQ_H */ 10 | -------------------------------------------------------------------------------- /include/asm-generic/int-ll64.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * asm-generic/int-ll64.h 4 | * 5 | * Integer declarations for architectures which use "long long" 6 | * for 64-bit types. 7 | */ 8 | #ifndef _ASM_GENERIC_INT_LL64_H 9 | #define _ASM_GENERIC_INT_LL64_H 10 | 11 | #include 12 | 13 | 14 | #ifndef __ASSEMBLY__ 15 | 16 | typedef __s8 s8; 17 | typedef __u8 u8; 18 | typedef __s16 s16; 19 | typedef __u16 u16; 20 | typedef __s32 s32; 21 | typedef __u32 u32; 22 | typedef __s64 s64; 23 | typedef __u64 u64; 24 | 25 | #define S8_C(x) x 26 | #define U8_C(x) x ## U 27 | #define S16_C(x) x 28 | #define U16_C(x) x ## U 29 | #define S32_C(x) x 30 | #define U32_C(x) x ## U 31 | #define S64_C(x) x ## LL 32 | #define U64_C(x) x ## ULL 33 | 34 | #else /* __ASSEMBLY__ */ 35 | 36 | #define S8_C(x) x 37 | #define U8_C(x) x 38 | #define S16_C(x) x 39 | #define U16_C(x) x 40 | #define S32_C(x) x 41 | #define U32_C(x) x 42 | #define S64_C(x) x 43 | #define U64_C(x) x 44 | 45 | #endif /* __ASSEMBLY__ */ 46 | 47 | #endif /* _ASM_GENERIC_INT_LL64_H */ 48 | -------------------------------------------------------------------------------- /include/asm-generic/ioctl.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_IOCTL_H 3 | #define _ASM_GENERIC_IOCTL_H 4 | 5 | #include 6 | 7 | #ifdef __CHECKER__ 8 | #define _IOC_TYPECHECK(t) (sizeof(t)) 9 | #else 10 | /* provoke compile error for invalid uses of size argument */ 11 | extern unsigned int __invalid_size_argument_for_IOC; 12 | #define _IOC_TYPECHECK(t) \ 13 | ((sizeof(t) == sizeof(t[1]) && \ 14 | sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ 15 | sizeof(t) : __invalid_size_argument_for_IOC) 16 | #endif 17 | 18 | #endif /* _ASM_GENERIC_IOCTL_H */ 19 | -------------------------------------------------------------------------------- /include/asm-generic/irq.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_IRQ_H 3 | #define __ASM_GENERIC_IRQ_H 4 | 5 | /* 6 | * NR_IRQS is the upper bound of how many interrupts can be handled 7 | * in the platform. It is used to size the static irq_map array, 8 | * so don't make it too big. 9 | */ 10 | #ifndef NR_IRQS 11 | #define NR_IRQS 64 12 | #endif 13 | 14 | static inline int irq_canonicalize(int irq) 15 | { 16 | return irq; 17 | } 18 | 19 | #endif /* __ASM_GENERIC_IRQ_H */ 20 | -------------------------------------------------------------------------------- /include/asm-generic/irq_regs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 | /* Fallback per-CPU frame pointer holder 3 | * 4 | * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. 5 | * Written by David Howells (dhowells@redhat.com) 6 | */ 7 | 8 | #ifndef _ASM_GENERIC_IRQ_REGS_H 9 | #define _ASM_GENERIC_IRQ_REGS_H 10 | 11 | #include 12 | 13 | /* 14 | * Per-cpu current frame pointer - the location of the last exception frame on 15 | * the stack 16 | */ 17 | DECLARE_PER_CPU(struct pt_regs *, __irq_regs); 18 | 19 | static inline struct pt_regs *get_irq_regs(void) 20 | { 21 | return __this_cpu_read(__irq_regs); 22 | } 23 | 24 | static inline struct pt_regs *set_irq_regs(struct pt_regs *new_regs) 25 | { 26 | struct pt_regs *old_regs; 27 | 28 | old_regs = __this_cpu_read(__irq_regs); 29 | __this_cpu_write(__irq_regs, new_regs); 30 | return old_regs; 31 | } 32 | 33 | #endif /* _ASM_GENERIC_IRQ_REGS_H */ 34 | -------------------------------------------------------------------------------- /include/asm-generic/mmiowb_types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_MMIOWB_TYPES_H 3 | #define __ASM_GENERIC_MMIOWB_TYPES_H 4 | 5 | #include 6 | 7 | struct mmiowb_state { 8 | u16 nesting_count; 9 | u16 mmiowb_pending; 10 | }; 11 | 12 | #endif /* __ASM_GENERIC_MMIOWB_TYPES_H */ 13 | -------------------------------------------------------------------------------- /include/asm-generic/module.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_MODULE_H 3 | #define __ASM_GENERIC_MODULE_H 4 | 5 | /* 6 | * Many architectures just need a simple module 7 | * loader without arch specific data. 8 | */ 9 | #ifndef CONFIG_HAVE_MOD_ARCH_SPECIFIC 10 | struct mod_arch_specific 11 | { 12 | }; 13 | #endif 14 | 15 | #ifdef CONFIG_64BIT 16 | #define Elf_Shdr Elf64_Shdr 17 | #define Elf_Phdr Elf64_Phdr 18 | #define Elf_Sym Elf64_Sym 19 | #define Elf_Dyn Elf64_Dyn 20 | #define Elf_Ehdr Elf64_Ehdr 21 | #define Elf_Addr Elf64_Addr 22 | #ifdef CONFIG_MODULES_USE_ELF_REL 23 | #define Elf_Rel Elf64_Rel 24 | #endif 25 | #ifdef CONFIG_MODULES_USE_ELF_RELA 26 | #define Elf_Rela Elf64_Rela 27 | #endif 28 | #define ELF_R_TYPE(X) ELF64_R_TYPE(X) 29 | #define ELF_R_SYM(X) ELF64_R_SYM(X) 30 | 31 | #else /* CONFIG_64BIT */ 32 | 33 | #define Elf_Shdr Elf32_Shdr 34 | #define Elf_Phdr Elf32_Phdr 35 | #define Elf_Sym Elf32_Sym 36 | #define Elf_Dyn Elf32_Dyn 37 | #define Elf_Ehdr Elf32_Ehdr 38 | #define Elf_Addr Elf32_Addr 39 | #ifdef CONFIG_MODULES_USE_ELF_REL 40 | #define Elf_Rel Elf32_Rel 41 | #endif 42 | #ifdef CONFIG_MODULES_USE_ELF_RELA 43 | #define Elf_Rela Elf32_Rela 44 | #endif 45 | #define ELF_R_TYPE(X) ELF32_R_TYPE(X) 46 | #define ELF_R_SYM(X) ELF32_R_SYM(X) 47 | #endif 48 | 49 | #endif /* __ASM_GENERIC_MODULE_H */ 50 | -------------------------------------------------------------------------------- /include/asm-generic/param.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_PARAM_H 3 | #define __ASM_GENERIC_PARAM_H 4 | 5 | #include 6 | 7 | # undef HZ 8 | # define HZ CONFIG_HZ /* Internal kernel timer frequency */ 9 | # define USER_HZ 100 /* some user interfaces are */ 10 | # define CLOCKS_PER_SEC (USER_HZ) /* in "ticks" like times() */ 11 | #endif /* __ASM_GENERIC_PARAM_H */ 12 | -------------------------------------------------------------------------------- /include/asm-generic/pgtable_uffd.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_GENERIC_PGTABLE_UFFD_H 2 | #define _ASM_GENERIC_PGTABLE_UFFD_H 3 | 4 | #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP 5 | static __always_inline int pte_uffd_wp(pte_t pte) 6 | { 7 | return 0; 8 | } 9 | 10 | static __always_inline int pmd_uffd_wp(pmd_t pmd) 11 | { 12 | return 0; 13 | } 14 | 15 | static __always_inline pte_t pte_mkuffd_wp(pte_t pte) 16 | { 17 | return pte; 18 | } 19 | 20 | static __always_inline pmd_t pmd_mkuffd_wp(pmd_t pmd) 21 | { 22 | return pmd; 23 | } 24 | 25 | static __always_inline pte_t pte_clear_uffd_wp(pte_t pte) 26 | { 27 | return pte; 28 | } 29 | 30 | static __always_inline pmd_t pmd_clear_uffd_wp(pmd_t pmd) 31 | { 32 | return pmd; 33 | } 34 | 35 | static __always_inline pte_t pte_swp_mkuffd_wp(pte_t pte) 36 | { 37 | return pte; 38 | } 39 | 40 | static __always_inline int pte_swp_uffd_wp(pte_t pte) 41 | { 42 | return 0; 43 | } 44 | 45 | static __always_inline pte_t pte_swp_clear_uffd_wp(pte_t pte) 46 | { 47 | return pte; 48 | } 49 | 50 | static inline pmd_t pmd_swp_mkuffd_wp(pmd_t pmd) 51 | { 52 | return pmd; 53 | } 54 | 55 | static inline int pmd_swp_uffd_wp(pmd_t pmd) 56 | { 57 | return 0; 58 | } 59 | 60 | static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd) 61 | { 62 | return pmd; 63 | } 64 | #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_WP */ 65 | 66 | #endif /* _ASM_GENERIC_PGTABLE_UFFD_H */ 67 | -------------------------------------------------------------------------------- /include/asm-generic/resource.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _ASM_GENERIC_RESOURCE_H 3 | #define _ASM_GENERIC_RESOURCE_H 4 | 5 | #include 6 | 7 | 8 | /* 9 | * boot-time rlimit defaults for the init task: 10 | */ 11 | #define INIT_RLIMITS \ 12 | { \ 13 | [RLIMIT_CPU] = { RLIM_INFINITY, RLIM_INFINITY }, \ 14 | [RLIMIT_FSIZE] = { RLIM_INFINITY, RLIM_INFINITY }, \ 15 | [RLIMIT_DATA] = { RLIM_INFINITY, RLIM_INFINITY }, \ 16 | [RLIMIT_STACK] = { _STK_LIM, RLIM_INFINITY }, \ 17 | [RLIMIT_CORE] = { 0, RLIM_INFINITY }, \ 18 | [RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 19 | [RLIMIT_NPROC] = { 0, 0 }, \ 20 | [RLIMIT_NOFILE] = { INR_OPEN_CUR, INR_OPEN_MAX }, \ 21 | [RLIMIT_MEMLOCK] = { MLOCK_LIMIT, MLOCK_LIMIT }, \ 22 | [RLIMIT_AS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 23 | [RLIMIT_LOCKS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 24 | [RLIMIT_SIGPENDING] = { 0, 0 }, \ 25 | [RLIMIT_MSGQUEUE] = { MQ_BYTES_MAX, MQ_BYTES_MAX }, \ 26 | [RLIMIT_NICE] = { 0, 0 }, \ 27 | [RLIMIT_RTPRIO] = { 0, 0 }, \ 28 | [RLIMIT_RTTIME] = { RLIM_INFINITY, RLIM_INFINITY }, \ 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/asm-generic/seccomp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * include/asm-generic/seccomp.h 4 | * 5 | * Copyright (C) 2014 Linaro Limited 6 | * Author: AKASHI Takahiro 7 | */ 8 | #ifndef _ASM_GENERIC_SECCOMP_H 9 | #define _ASM_GENERIC_SECCOMP_H 10 | 11 | #include 12 | 13 | #if defined(CONFIG_COMPAT) && !defined(__NR_seccomp_read_32) 14 | #define __NR_seccomp_read_32 __NR_read 15 | #define __NR_seccomp_write_32 __NR_write 16 | #define __NR_seccomp_exit_32 __NR_exit 17 | #ifndef __NR_seccomp_sigreturn_32 18 | #define __NR_seccomp_sigreturn_32 __NR_rt_sigreturn 19 | #endif 20 | #endif /* CONFIG_COMPAT && ! already defined */ 21 | 22 | #define __NR_seccomp_read __NR_read 23 | #define __NR_seccomp_write __NR_write 24 | #define __NR_seccomp_exit __NR_exit 25 | #ifndef __NR_seccomp_sigreturn 26 | #define __NR_seccomp_sigreturn __NR_rt_sigreturn 27 | #endif 28 | 29 | #ifdef CONFIG_COMPAT 30 | #ifndef get_compat_mode1_syscalls 31 | static inline const int *get_compat_mode1_syscalls(void) 32 | { 33 | static const int mode1_syscalls_32[] = { 34 | __NR_seccomp_read_32, __NR_seccomp_write_32, 35 | __NR_seccomp_exit_32, __NR_seccomp_sigreturn_32, 36 | 0, /* null terminated */ 37 | }; 38 | return mode1_syscalls_32; 39 | } 40 | #endif 41 | #endif /* CONFIG_COMPAT */ 42 | 43 | #endif /* _ASM_GENERIC_SECCOMP_H */ 44 | -------------------------------------------------------------------------------- /include/asm-generic/shmparam.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_SHMPARAM_H 3 | #define __ASM_GENERIC_SHMPARAM_H 4 | 5 | #define SHMLBA PAGE_SIZE /* attach addr a multiple of this */ 6 | 7 | #endif /* _ASM_GENERIC_SHMPARAM_H */ 8 | -------------------------------------------------------------------------------- /include/asm-generic/signal.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_SIGNAL_H 3 | #define __ASM_GENERIC_SIGNAL_H 4 | 5 | #include 6 | 7 | #ifndef __ASSEMBLY__ 8 | #ifdef SA_RESTORER 9 | #endif 10 | 11 | #include 12 | #undef __HAVE_ARCH_SIG_BITOPS 13 | 14 | #endif /* __ASSEMBLY__ */ 15 | #endif /* _ASM_GENERIC_SIGNAL_H */ 16 | -------------------------------------------------------------------------------- /include/asm-generic/unaligned.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __ASM_GENERIC_UNALIGNED_H 3 | #define __ASM_GENERIC_UNALIGNED_H 4 | 5 | /* 6 | * This is the most generic implementation of unaligned accesses 7 | * and should work almost anywhere. 8 | */ 9 | #include 10 | 11 | /* Set by the arch if it can handle unaligned accesses in hardware. */ 12 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 13 | # include 14 | #endif 15 | 16 | #if defined(__LITTLE_ENDIAN) 17 | # ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 18 | # include 19 | # include 20 | # endif 21 | # include 22 | # define get_unaligned __get_unaligned_le 23 | # define put_unaligned __put_unaligned_le 24 | #elif defined(__BIG_ENDIAN) 25 | # ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 26 | # include 27 | # include 28 | # endif 29 | # include 30 | # define get_unaligned __get_unaligned_be 31 | # define put_unaligned __put_unaligned_be 32 | #else 33 | # error need to define endianess 34 | #endif 35 | 36 | #endif /* __ASM_GENERIC_UNALIGNED_H */ 37 | -------------------------------------------------------------------------------- /include/config/kernel.release: -------------------------------------------------------------------------------- 1 | 5.8.0-rc4-01858-g89d81671b6d7 2 | -------------------------------------------------------------------------------- /include/generated/bounds.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_BOUNDS_H__ 2 | #define __LINUX_BOUNDS_H__ 3 | /* 4 | * DO NOT MODIFY. 5 | * 6 | * This file was generated by Kbuild 7 | */ 8 | 9 | #define NR_PAGEFLAGS 22 /* __NR_PAGEFLAGS */ 10 | #define MAX_NR_ZONES 3 /* __MAX_NR_ZONES */ 11 | #define NR_CPUS_BITS 3 /* ilog2(CONFIG_NR_CPUS) */ 12 | #define SPINLOCK_SIZE 4 /* sizeof(spinlock_t) */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/generated/timeconst.h: -------------------------------------------------------------------------------- 1 | /* Automatically generated by kernel/time/timeconst.bc */ 2 | /* Time conversion constants for HZ == 250 */ 3 | 4 | #ifndef KERNEL_TIMECONST_H 5 | #define KERNEL_TIMECONST_H 6 | 7 | #include 8 | #include 9 | 10 | #if HZ != 250 11 | #error "include/generated/timeconst.h has the wrong HZ value!" 12 | #endif 13 | 14 | #define HZ_TO_MSEC_MUL32 U64_C(0x80000000) 15 | #define HZ_TO_MSEC_ADJ32 U64_C(0x0) 16 | #define HZ_TO_MSEC_SHR32 29 17 | #define MSEC_TO_HZ_MUL32 U64_C(0x80000000) 18 | #define MSEC_TO_HZ_ADJ32 U64_C(0x180000000) 19 | #define MSEC_TO_HZ_SHR32 33 20 | #define HZ_TO_MSEC_NUM 4 21 | #define HZ_TO_MSEC_DEN 1 22 | #define MSEC_TO_HZ_NUM 1 23 | #define MSEC_TO_HZ_DEN 4 24 | 25 | #define HZ_TO_USEC_MUL32 U64_C(0xFA000000) 26 | #define HZ_TO_USEC_ADJ32 U64_C(0x0) 27 | #define HZ_TO_USEC_SHR32 20 28 | #define USEC_TO_HZ_MUL32 U64_C(0x83126E98) 29 | #define USEC_TO_HZ_ADJ32 U64_C(0x7FF7CED9168) 30 | #define USEC_TO_HZ_SHR32 43 31 | #define HZ_TO_USEC_NUM 4000 32 | #define HZ_TO_USEC_DEN 1 33 | #define USEC_TO_HZ_NUM 1 34 | #define USEC_TO_HZ_DEN 4000 35 | #define HZ_TO_NSEC_NUM 4000000 36 | #define HZ_TO_NSEC_DEN 1 37 | #define NSEC_TO_HZ_NUM 1 38 | #define NSEC_TO_HZ_DEN 4000000 39 | 40 | #endif /* KERNEL_TIMECONST_H */ 41 | -------------------------------------------------------------------------------- /include/linux/auxvec.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_AUXVEC_H 3 | #define _LINUX_AUXVEC_H 4 | 5 | #include 6 | 7 | #define AT_VECTOR_SIZE_BASE 20 /* NEW_AUX_ENT entries in auxiliary table */ 8 | /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */ 9 | #endif /* _LINUX_AUXVEC_H */ 10 | -------------------------------------------------------------------------------- /include/linux/bottom_half.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_BH_H 3 | #define _LINUX_BH_H 4 | 5 | #include 6 | 7 | #ifdef CONFIG_TRACE_IRQFLAGS 8 | extern void __local_bh_disable_ip(unsigned long ip, unsigned int cnt); 9 | #else 10 | static __always_inline void __local_bh_disable_ip(unsigned long ip, unsigned int cnt) 11 | { 12 | preempt_count_add(cnt); 13 | barrier(); 14 | } 15 | #endif 16 | 17 | static inline void local_bh_disable(void) 18 | { 19 | __local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET); 20 | } 21 | 22 | extern void _local_bh_enable(void); 23 | extern void __local_bh_enable_ip(unsigned long ip, unsigned int cnt); 24 | 25 | static inline void local_bh_enable_ip(unsigned long ip) 26 | { 27 | __local_bh_enable_ip(ip, SOFTIRQ_DISABLE_OFFSET); 28 | } 29 | 30 | static inline void local_bh_enable(void) 31 | { 32 | __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET); 33 | } 34 | 35 | #endif /* _LINUX_BH_H */ 36 | -------------------------------------------------------------------------------- /include/linux/byteorder/little_endian.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H 3 | #define _LINUX_BYTEORDER_LITTLE_ENDIAN_H 4 | 5 | #include 6 | 7 | #ifdef CONFIG_CPU_BIG_ENDIAN 8 | #warning inconsistent configuration, CONFIG_CPU_BIG_ENDIAN is set 9 | #endif 10 | 11 | #include 12 | #endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ 13 | -------------------------------------------------------------------------------- /include/linux/cgroup_subsys.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * List of cgroup subsystems. 4 | * 5 | * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS. 6 | */ 7 | 8 | /* 9 | * This file *must* be included with SUBSYS() defined. 10 | */ 11 | 12 | #if IS_ENABLED(CONFIG_CPUSETS) 13 | SUBSYS(cpuset) 14 | #endif 15 | 16 | #if IS_ENABLED(CONFIG_CGROUP_SCHED) 17 | SUBSYS(cpu) 18 | #endif 19 | 20 | #if IS_ENABLED(CONFIG_CGROUP_CPUACCT) 21 | SUBSYS(cpuacct) 22 | #endif 23 | 24 | #if IS_ENABLED(CONFIG_BLK_CGROUP) 25 | SUBSYS(io) 26 | #endif 27 | 28 | #if IS_ENABLED(CONFIG_MEMCG) 29 | SUBSYS(memory) 30 | #endif 31 | 32 | #if IS_ENABLED(CONFIG_CGROUP_DEVICE) 33 | SUBSYS(devices) 34 | #endif 35 | 36 | #if IS_ENABLED(CONFIG_CGROUP_FREEZER) 37 | SUBSYS(freezer) 38 | #endif 39 | 40 | #if IS_ENABLED(CONFIG_CGROUP_NET_CLASSID) 41 | SUBSYS(net_cls) 42 | #endif 43 | 44 | #if IS_ENABLED(CONFIG_CGROUP_PERF) 45 | SUBSYS(perf_event) 46 | #endif 47 | 48 | #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) 49 | SUBSYS(net_prio) 50 | #endif 51 | 52 | #if IS_ENABLED(CONFIG_CGROUP_HUGETLB) 53 | SUBSYS(hugetlb) 54 | #endif 55 | 56 | #if IS_ENABLED(CONFIG_CGROUP_PIDS) 57 | SUBSYS(pids) 58 | #endif 59 | 60 | #if IS_ENABLED(CONFIG_CGROUP_RDMA) 61 | SUBSYS(rdma) 62 | #endif 63 | 64 | /* 65 | * The following subsystems are not supported on the default hierarchy. 66 | */ 67 | #if IS_ENABLED(CONFIG_CGROUP_DEBUG) 68 | SUBSYS(debug) 69 | #endif 70 | 71 | /* 72 | * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS. 73 | */ 74 | -------------------------------------------------------------------------------- /include/linux/const.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_CONST_H 2 | #define _LINUX_CONST_H 3 | 4 | #include 5 | 6 | #endif /* _LINUX_CONST_H */ 7 | -------------------------------------------------------------------------------- /include/linux/delayed_call.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _DELAYED_CALL_H 3 | #define _DELAYED_CALL_H 4 | 5 | /* 6 | * Poor man's closures; I wish we could've done them sanely polymorphic, 7 | * but... 8 | */ 9 | 10 | struct delayed_call { 11 | void (*fn)(void *); 12 | void *arg; 13 | }; 14 | 15 | #define DEFINE_DELAYED_CALL(name) struct delayed_call name = {NULL, NULL} 16 | 17 | /* I really wish we had closures with sane typechecking... */ 18 | static inline void set_delayed_call(struct delayed_call *call, 19 | void (*fn)(void *), void *arg) 20 | { 21 | call->fn = fn; 22 | call->arg = arg; 23 | } 24 | 25 | static inline void do_delayed_call(struct delayed_call *call) 26 | { 27 | if (call->fn) 28 | call->fn(call->arg); 29 | } 30 | 31 | static inline void clear_delayed_call(struct delayed_call *call) 32 | { 33 | call->fn = NULL; 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /include/linux/dma-direction.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_DMA_DIRECTION_H 3 | #define _LINUX_DMA_DIRECTION_H 4 | 5 | enum dma_data_direction { 6 | DMA_BIDIRECTIONAL = 0, 7 | DMA_TO_DEVICE = 1, 8 | DMA_FROM_DEVICE = 2, 9 | DMA_NONE = 3, 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/linux/dqblk_v1.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * File with in-memory structures of old quota format 4 | */ 5 | 6 | #ifndef _LINUX_DQBLK_V1_H 7 | #define _LINUX_DQBLK_V1_H 8 | 9 | /* Numbers of blocks needed for updates */ 10 | #define V1_INIT_ALLOC 1 11 | #define V1_INIT_REWRITE 1 12 | #define V1_DEL_ALLOC 0 13 | #define V1_DEL_REWRITE 2 14 | 15 | #endif /* _LINUX_DQBLK_V1_H */ 16 | -------------------------------------------------------------------------------- /include/linux/dqblk_v2.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * Definitions for vfsv0 quota format 4 | */ 5 | 6 | #ifndef _LINUX_DQBLK_V2_H 7 | #define _LINUX_DQBLK_V2_H 8 | 9 | #include 10 | 11 | /* Numbers of blocks needed for updates */ 12 | #define V2_INIT_ALLOC QTREE_INIT_ALLOC 13 | #define V2_INIT_REWRITE QTREE_INIT_REWRITE 14 | #define V2_DEL_ALLOC QTREE_DEL_ALLOC 15 | #define V2_DEL_REWRITE QTREE_DEL_REWRITE 16 | 17 | #endif /* _LINUX_DQBLK_V2_H */ 18 | -------------------------------------------------------------------------------- /include/linux/errno.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_ERRNO_H 3 | #define _LINUX_ERRNO_H 4 | 5 | #include 6 | 7 | 8 | /* 9 | * These should never be seen by user programs. To return one of ERESTART* 10 | * codes, signal_pending() MUST be set. Note that ptrace can observe these 11 | * at syscall exit tracing, but they will never be left for the debugged user 12 | * process to see. 13 | */ 14 | #define ERESTARTSYS 512 15 | #define ERESTARTNOINTR 513 16 | #define ERESTARTNOHAND 514 /* restart if no handler.. */ 17 | #define ENOIOCTLCMD 515 /* No ioctl command */ 18 | #define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ 19 | #define EPROBE_DEFER 517 /* Driver requests probe retry */ 20 | #define EOPENSTALE 518 /* open found a stale dentry */ 21 | #define ENOPARAM 519 /* Parameter not supported */ 22 | 23 | /* Defined for the NFSv3 protocol */ 24 | #define EBADHANDLE 521 /* Illegal NFS file handle */ 25 | #define ENOTSYNC 522 /* Update synchronization mismatch */ 26 | #define EBADCOOKIE 523 /* Cookie is stale */ 27 | #define ENOTSUPP 524 /* Operation is not supported */ 28 | #define ETOOSMALL 525 /* Buffer or request is too small */ 29 | #define ESERVERFAULT 526 /* An untranslatable error occurred */ 30 | #define EBADTYPE 527 /* Type not supported by server */ 31 | #define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ 32 | #define EIOCBQUEUED 529 /* iocb queued, will get completion event */ 33 | #define ERECALLCONFLICT 530 /* conflict with recalled state */ 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/linux/error-injection.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_ERROR_INJECTION_H 3 | #define _LINUX_ERROR_INJECTION_H 4 | 5 | #include 6 | #include 7 | 8 | #ifdef CONFIG_FUNCTION_ERROR_INJECTION 9 | 10 | extern bool within_error_injection_list(unsigned long addr); 11 | extern int get_injectable_error_type(unsigned long addr); 12 | 13 | #else /* !CONFIG_FUNCTION_ERROR_INJECTION */ 14 | 15 | static inline bool within_error_injection_list(unsigned long addr) 16 | { 17 | return false; 18 | } 19 | 20 | static inline int get_injectable_error_type(unsigned long addr) 21 | { 22 | return EI_ETYPE_NONE; 23 | } 24 | 25 | #endif 26 | 27 | #endif /* _LINUX_ERROR_INJECTION_H */ 28 | -------------------------------------------------------------------------------- /include/linux/errseq.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * See Documentation/core-api/errseq.rst and lib/errseq.c 4 | */ 5 | #ifndef _LINUX_ERRSEQ_H 6 | #define _LINUX_ERRSEQ_H 7 | 8 | typedef u32 errseq_t; 9 | 10 | errseq_t errseq_set(errseq_t *eseq, int err); 11 | errseq_t errseq_sample(errseq_t *eseq); 12 | int errseq_check(errseq_t *eseq, errseq_t since); 13 | int errseq_check_and_advance(errseq_t *eseq, errseq_t *since); 14 | #endif 15 | -------------------------------------------------------------------------------- /include/linux/ftrace_irq.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_FTRACE_IRQ_H 3 | #define _LINUX_FTRACE_IRQ_H 4 | 5 | #ifdef CONFIG_HWLAT_TRACER 6 | extern bool trace_hwlat_callback_enabled; 7 | extern void trace_hwlat_callback(bool enter); 8 | #endif 9 | 10 | static inline void ftrace_nmi_enter(void) 11 | { 12 | #ifdef CONFIG_HWLAT_TRACER 13 | if (trace_hwlat_callback_enabled) 14 | trace_hwlat_callback(true); 15 | #endif 16 | } 17 | 18 | static inline void ftrace_nmi_exit(void) 19 | { 20 | #ifdef CONFIG_HWLAT_TRACER 21 | if (trace_hwlat_callback_enabled) 22 | trace_hwlat_callback(false); 23 | #endif 24 | } 25 | 26 | #endif /* _LINUX_FTRACE_IRQ_H */ 27 | -------------------------------------------------------------------------------- /include/linux/hrtimer_defs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_HRTIMER_DEFS_H 3 | #define _LINUX_HRTIMER_DEFS_H 4 | 5 | #include 6 | 7 | #ifdef CONFIG_HIGH_RES_TIMERS 8 | 9 | /* 10 | * The resolution of the clocks. The resolution value is returned in 11 | * the clock_getres() system call to give application programmers an 12 | * idea of the (in)accuracy of timers. Timer values are rounded up to 13 | * this resolution values. 14 | */ 15 | # define HIGH_RES_NSEC 1 16 | # define KTIME_HIGH_RES (HIGH_RES_NSEC) 17 | # define MONOTONIC_RES_NSEC HIGH_RES_NSEC 18 | # define KTIME_MONOTONIC_RES KTIME_HIGH_RES 19 | 20 | #else 21 | 22 | # define MONOTONIC_RES_NSEC LOW_RES_NSEC 23 | # define KTIME_MONOTONIC_RES KTIME_LOW_RES 24 | 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/linux/if_ether.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 | /* 3 | * INET An implementation of the TCP/IP protocol suite for the LINUX 4 | * operating system. INET is implemented using the BSD Socket 5 | * interface as the means of communication with the user level. 6 | * 7 | * Global definitions for the Ethernet IEEE 802.3 interface. 8 | * 9 | * Version: @(#)if_ether.h 1.0.1a 02/08/94 10 | * 11 | * Author: Fred N. van Kempen, 12 | * Donald Becker, 13 | * Alan Cox, 14 | * Steve Whitehouse, 15 | */ 16 | #ifndef _LINUX_IF_ETHER_H 17 | #define _LINUX_IF_ETHER_H 18 | 19 | #include 20 | #include 21 | 22 | static inline struct ethhdr *eth_hdr(const struct sk_buff *skb) 23 | { 24 | return (struct ethhdr *)skb_mac_header(skb); 25 | } 26 | 27 | /* Prefer this version in TX path, instead of 28 | * skb_reset_mac_header() + eth_hdr() 29 | */ 30 | static inline struct ethhdr *skb_eth_hdr(const struct sk_buff *skb) 31 | { 32 | return (struct ethhdr *)skb->data; 33 | } 34 | 35 | static inline struct ethhdr *inner_eth_hdr(const struct sk_buff *skb) 36 | { 37 | return (struct ethhdr *)skb_inner_mac_header(skb); 38 | } 39 | 40 | int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr); 41 | 42 | extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len); 43 | 44 | #endif /* _LINUX_IF_ETHER_H */ 45 | -------------------------------------------------------------------------------- /include/linux/if_link.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_IF_LINK_H 3 | #define _LINUX_IF_LINK_H 4 | 5 | #include 6 | 7 | 8 | /* We don't want this structure exposed to user space */ 9 | struct ifla_vf_stats { 10 | __u64 rx_packets; 11 | __u64 tx_packets; 12 | __u64 rx_bytes; 13 | __u64 tx_bytes; 14 | __u64 broadcast; 15 | __u64 multicast; 16 | __u64 rx_dropped; 17 | __u64 tx_dropped; 18 | }; 19 | 20 | struct ifla_vf_info { 21 | __u32 vf; 22 | __u8 mac[32]; 23 | __u32 vlan; 24 | __u32 qos; 25 | __u32 spoofchk; 26 | __u32 linkstate; 27 | __u32 min_tx_rate; 28 | __u32 max_tx_rate; 29 | __u32 rss_query_en; 30 | __u32 trusted; 31 | __be16 vlan_proto; 32 | }; 33 | #endif /* _LINUX_IF_LINK_H */ 34 | -------------------------------------------------------------------------------- /include/linux/ipc.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_IPC_H 3 | #define _LINUX_IPC_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /* used by in-kernel data structures */ 12 | struct kern_ipc_perm { 13 | spinlock_t lock; 14 | bool deleted; 15 | int id; 16 | key_t key; 17 | kuid_t uid; 18 | kgid_t gid; 19 | kuid_t cuid; 20 | kgid_t cgid; 21 | umode_t mode; 22 | unsigned long seq; 23 | void *security; 24 | 25 | struct rhash_head khtnode; 26 | 27 | struct rcu_head rcu; 28 | refcount_t refcount; 29 | } ____cacheline_aligned_in_smp __randomize_layout; 30 | 31 | #endif /* _LINUX_IPC_H */ 32 | -------------------------------------------------------------------------------- /include/linux/irq_cpustat.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __irq_cpustat_h 3 | #define __irq_cpustat_h 4 | 5 | /* 6 | * Contains default mappings for irq_cpustat_t, used by almost every 7 | * architecture. Some arch (like s390) have per cpu hardware pages and 8 | * they define their own mappings for irq_stat. 9 | * 10 | * Keith Owens July 2000. 11 | */ 12 | 13 | 14 | /* 15 | * Simple wrappers reducing source bloat. Define all irq_stat fields 16 | * here, even ones that are arch dependent. That way we get common 17 | * definitions instead of differing sets for each arch. 18 | */ 19 | 20 | #ifndef __ARCH_IRQ_STAT 21 | DECLARE_PER_CPU_ALIGNED(irq_cpustat_t, irq_stat); /* defined in asm/hardirq.h */ 22 | #define __IRQ_STAT(cpu, member) (per_cpu(irq_stat.member, cpu)) 23 | #endif 24 | 25 | /* arch dependent irq_stat fields */ 26 | #define nmi_count(cpu) __IRQ_STAT((cpu), __nmi_count) /* i386 */ 27 | 28 | #endif /* __irq_cpustat_h */ 29 | -------------------------------------------------------------------------------- /include/linux/irqhandler.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_IRQHANDLER_H 3 | #define _LINUX_IRQHANDLER_H 4 | 5 | /* 6 | * Interrupt flow handler typedefs are defined here to avoid circular 7 | * include dependencies. 8 | */ 9 | 10 | struct irq_desc; 11 | struct irq_data; 12 | typedef void (*irq_flow_handler_t)(struct irq_desc *desc); 13 | typedef void (*irq_preflow_handler_t)(struct irq_data *data); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/linux/irqnr.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_IRQNR_H 3 | #define _LINUX_IRQNR_H 4 | 5 | #include 6 | 7 | 8 | extern int nr_irqs; 9 | extern struct irq_desc *irq_to_desc(unsigned int irq); 10 | unsigned int irq_get_next_irq(unsigned int offset); 11 | 12 | # define for_each_irq_desc(irq, desc) \ 13 | for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \ 14 | irq++, desc = irq_to_desc(irq)) \ 15 | if (!desc) \ 16 | ; \ 17 | else 18 | 19 | 20 | # define for_each_irq_desc_reverse(irq, desc) \ 21 | for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \ 22 | irq--, desc = irq_to_desc(irq)) \ 23 | if (!desc) \ 24 | ; \ 25 | else 26 | 27 | # define for_each_active_irq(irq) \ 28 | for (irq = irq_get_next_irq(0); irq < nr_irqs; \ 29 | irq = irq_get_next_irq(irq + 1)) 30 | 31 | #define for_each_irq_nr(irq) \ 32 | for (irq = 0; irq < nr_irqs; irq++) 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/linux/irqreturn.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_IRQRETURN_H 3 | #define _LINUX_IRQRETURN_H 4 | 5 | /** 6 | * enum irqreturn 7 | * @IRQ_NONE interrupt was not from this device or was not handled 8 | * @IRQ_HANDLED interrupt was handled by this device 9 | * @IRQ_WAKE_THREAD handler requests to wake the handler thread 10 | */ 11 | enum irqreturn { 12 | IRQ_NONE = (0 << 0), 13 | IRQ_HANDLED = (1 << 0), 14 | IRQ_WAKE_THREAD = (1 << 1), 15 | }; 16 | 17 | typedef enum irqreturn irqreturn_t; 18 | #define IRQ_RETVAL(x) ((x) ? IRQ_HANDLED : IRQ_NONE) 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/linux/kasan-checks.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_KASAN_CHECKS_H 3 | #define _LINUX_KASAN_CHECKS_H 4 | 5 | #include 6 | 7 | /* 8 | * __kasan_check_*: Always available when KASAN is enabled. This may be used 9 | * even in compilation units that selectively disable KASAN, but must use KASAN 10 | * to validate access to an address. Never use these in header files! 11 | */ 12 | #ifdef CONFIG_KASAN 13 | bool __kasan_check_read(const volatile void *p, unsigned int size); 14 | bool __kasan_check_write(const volatile void *p, unsigned int size); 15 | #else 16 | static inline bool __kasan_check_read(const volatile void *p, unsigned int size) 17 | { 18 | return true; 19 | } 20 | static inline bool __kasan_check_write(const volatile void *p, unsigned int size) 21 | { 22 | return true; 23 | } 24 | #endif 25 | 26 | /* 27 | * kasan_check_*: Only available when the particular compilation unit has KASAN 28 | * instrumentation enabled. May be used in header files. 29 | */ 30 | #ifdef __SANITIZE_ADDRESS__ 31 | #define kasan_check_read __kasan_check_read 32 | #define kasan_check_write __kasan_check_write 33 | #else 34 | static inline bool kasan_check_read(const volatile void *p, unsigned int size) 35 | { 36 | return true; 37 | } 38 | static inline bool kasan_check_write(const volatile void *p, unsigned int size) 39 | { 40 | return true; 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/linux/kmod.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 | #ifndef __LINUX_KMOD_H__ 3 | #define __LINUX_KMOD_H__ 4 | 5 | /* 6 | * include/linux/kmod.h 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define KMOD_PATH_LEN 256 18 | 19 | #ifdef CONFIG_MODULES 20 | extern char modprobe_path[]; /* for sysctl */ 21 | /* modprobe exit status on success, -ve on error. Return value 22 | * usually useless though. */ 23 | extern __printf(2, 3) 24 | int __request_module(bool wait, const char *name, ...); 25 | #define request_module(mod...) __request_module(true, mod) 26 | #define request_module_nowait(mod...) __request_module(false, mod) 27 | #define try_then_request_module(x, mod...) \ 28 | ((x) ?: (__request_module(true, mod), (x))) 29 | #else 30 | static inline int request_module(const char *name, ...) { return -ENOSYS; } 31 | static inline int request_module_nowait(const char *name, ...) { return -ENOSYS; } 32 | #define try_then_request_module(x, mod...) (x) 33 | #endif 34 | 35 | #endif /* __LINUX_KMOD_H__ */ 36 | -------------------------------------------------------------------------------- /include/linux/latencytop.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * latencytop.h: Infrastructure for displaying latency 4 | * 5 | * (C) Copyright 2008 Intel Corporation 6 | * Author: Arjan van de Ven 7 | * 8 | */ 9 | 10 | #ifndef _INCLUDE_GUARD_LATENCYTOP_H_ 11 | #define _INCLUDE_GUARD_LATENCYTOP_H_ 12 | 13 | #include 14 | struct task_struct; 15 | 16 | #ifdef CONFIG_LATENCYTOP 17 | 18 | #define LT_SAVECOUNT 32 19 | #define LT_BACKTRACEDEPTH 12 20 | 21 | struct latency_record { 22 | unsigned long backtrace[LT_BACKTRACEDEPTH]; 23 | unsigned int count; 24 | unsigned long time; 25 | unsigned long max; 26 | }; 27 | 28 | 29 | 30 | extern int latencytop_enabled; 31 | void __account_scheduler_latency(struct task_struct *task, int usecs, int inter); 32 | static inline void 33 | account_scheduler_latency(struct task_struct *task, int usecs, int inter) 34 | { 35 | if (unlikely(latencytop_enabled)) 36 | __account_scheduler_latency(task, usecs, inter); 37 | } 38 | 39 | void clear_tsk_latency_tracing(struct task_struct *p); 40 | 41 | int sysctl_latencytop(struct ctl_table *table, int write, void *buffer, 42 | size_t *lenp, loff_t *ppos); 43 | 44 | #else 45 | 46 | static inline void 47 | account_scheduler_latency(struct task_struct *task, int usecs, int inter) 48 | { 49 | } 50 | 51 | static inline void clear_tsk_latency_tracing(struct task_struct *p) 52 | { 53 | } 54 | 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/linux/limits.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_LIMITS_H 3 | #define _LINUX_LIMITS_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #define SIZE_MAX (~(size_t)0) 10 | #define PHYS_ADDR_MAX (~(phys_addr_t)0) 11 | 12 | #define U8_MAX ((u8)~0U) 13 | #define S8_MAX ((s8)(U8_MAX >> 1)) 14 | #define S8_MIN ((s8)(-S8_MAX - 1)) 15 | #define U16_MAX ((u16)~0U) 16 | #define S16_MAX ((s16)(U16_MAX >> 1)) 17 | #define S16_MIN ((s16)(-S16_MAX - 1)) 18 | #define U32_MAX ((u32)~0U) 19 | #define U32_MIN ((u32)0) 20 | #define S32_MAX ((s32)(U32_MAX >> 1)) 21 | #define S32_MIN ((s32)(-S32_MAX - 1)) 22 | #define U64_MAX ((u64)~0ULL) 23 | #define S64_MAX ((s64)(U64_MAX >> 1)) 24 | #define S64_MIN ((s64)(-S64_MAX - 1)) 25 | 26 | #endif /* _LINUX_LIMITS_H */ 27 | -------------------------------------------------------------------------------- /include/linux/mem_encrypt.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * AMD Memory Encryption Support 4 | * 5 | * Copyright (C) 2016 Advanced Micro Devices, Inc. 6 | * 7 | * Author: Tom Lendacky 8 | */ 9 | 10 | #ifndef __MEM_ENCRYPT_H__ 11 | #define __MEM_ENCRYPT_H__ 12 | 13 | #ifndef __ASSEMBLY__ 14 | 15 | #ifdef CONFIG_ARCH_HAS_MEM_ENCRYPT 16 | 17 | #include 18 | 19 | #else /* !CONFIG_ARCH_HAS_MEM_ENCRYPT */ 20 | 21 | static inline bool mem_encrypt_active(void) { return false; } 22 | 23 | #endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */ 24 | 25 | #ifdef CONFIG_AMD_MEM_ENCRYPT 26 | /* 27 | * The __sme_set() and __sme_clr() macros are useful for adding or removing 28 | * the encryption mask from a value (e.g. when dealing with pagetable 29 | * entries). 30 | */ 31 | #define __sme_set(x) ((x) | sme_me_mask) 32 | #define __sme_clr(x) ((x) & ~sme_me_mask) 33 | #else 34 | #define __sme_set(x) (x) 35 | #define __sme_clr(x) (x) 36 | #endif 37 | 38 | #endif /* __ASSEMBLY__ */ 39 | 40 | #endif /* __MEM_ENCRYPT_H__ */ 41 | -------------------------------------------------------------------------------- /include/linux/migrate_mode.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef MIGRATE_MODE_H_INCLUDED 3 | #define MIGRATE_MODE_H_INCLUDED 4 | /* 5 | * MIGRATE_ASYNC means never block 6 | * MIGRATE_SYNC_LIGHT in the current implementation means to allow blocking 7 | * on most operations but not ->writepage as the potential stall time 8 | * is too significant 9 | * MIGRATE_SYNC will block when migrating pages 10 | * MIGRATE_SYNC_NO_COPY will block when migrating pages but will not copy pages 11 | * with the CPU. Instead, page copy happens outside the migratepage() 12 | * callback and is likely using a DMA engine. See migrate_vma() and HMM 13 | * (mm/hmm.c) for users of this mode. 14 | */ 15 | enum migrate_mode { 16 | MIGRATE_ASYNC, 17 | MIGRATE_SYNC_LIGHT, 18 | MIGRATE_SYNC, 19 | MIGRATE_SYNC_NO_COPY, 20 | }; 21 | 22 | #endif /* MIGRATE_MODE_H_INCLUDED */ 23 | -------------------------------------------------------------------------------- /include/linux/netfilter_defs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __LINUX_NETFILTER_CORE_H_ 3 | #define __LINUX_NETFILTER_CORE_H_ 4 | 5 | #include 6 | 7 | /* in/out/forward only */ 8 | #define NF_ARP_NUMHOOKS 3 9 | 10 | /* max hook is NF_DN_ROUTE (6), also see uapi/linux/netfilter_decnet.h */ 11 | #define NF_DN_NUMHOOKS 7 12 | 13 | #if IS_ENABLED(CONFIG_DECNET) 14 | /* Largest hook number + 1, see uapi/linux/netfilter_decnet.h */ 15 | #define NF_MAX_HOOKS NF_DN_NUMHOOKS 16 | #else 17 | #define NF_MAX_HOOKS NF_INET_NUMHOOKS 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/linux/nfs_fs_i.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _NFS_FS_I 3 | #define _NFS_FS_I 4 | 5 | struct nlm_lockowner; 6 | 7 | /* 8 | * NFS lock info 9 | */ 10 | struct nfs_lock_info { 11 | u32 state; 12 | struct nlm_lockowner *owner; 13 | struct list_head list; 14 | }; 15 | 16 | struct nfs4_lock_state; 17 | struct nfs4_lock_info { 18 | struct nfs4_lock_state *owner; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/linux/ns_common.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_NS_COMMON_H 3 | #define _LINUX_NS_COMMON_H 4 | 5 | struct proc_ns_operations; 6 | 7 | struct ns_common { 8 | atomic_long_t stashed; 9 | const struct proc_ns_operations *ops; 10 | unsigned int inum; 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/linux/numa.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_NUMA_H 3 | #define _LINUX_NUMA_H 4 | #include 5 | 6 | #ifdef CONFIG_NODES_SHIFT 7 | #define NODES_SHIFT CONFIG_NODES_SHIFT 8 | #else 9 | #define NODES_SHIFT 0 10 | #endif 11 | 12 | #define MAX_NUMNODES (1 << NODES_SHIFT) 13 | 14 | #define NUMA_NO_NODE (-1) 15 | 16 | /* optionally keep NUMA memory info available post init */ 17 | #ifdef CONFIG_NUMA_KEEP_MEMINFO 18 | #define __initdata_or_meminfo 19 | #else 20 | #define __initdata_or_meminfo __initdata 21 | #endif 22 | 23 | #ifdef CONFIG_NUMA 24 | /* Generic implementation available */ 25 | int numa_map_to_online_node(int node); 26 | 27 | /* 28 | * Optional architecture specific implementation, users need a "depends 29 | * on $ARCH" 30 | */ 31 | int phys_to_target_node(phys_addr_t addr); 32 | #else 33 | static inline int numa_map_to_online_node(int node) 34 | { 35 | return NUMA_NO_NODE; 36 | } 37 | 38 | static inline int phys_to_target_node(phys_addr_t addr) 39 | { 40 | return NUMA_NO_NODE; 41 | } 42 | #endif 43 | 44 | #endif /* _LINUX_NUMA_H */ 45 | -------------------------------------------------------------------------------- /include/linux/osq_lock.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __LINUX_OSQ_LOCK_H 3 | #define __LINUX_OSQ_LOCK_H 4 | 5 | /* 6 | * An MCS like lock especially tailored for optimistic spinning for sleeping 7 | * lock implementations (mutex, rwsem, etc). 8 | */ 9 | struct optimistic_spin_node { 10 | struct optimistic_spin_node *next, *prev; 11 | int locked; /* 1 if lock acquired */ 12 | int cpu; /* encoded CPU # + 1 value */ 13 | }; 14 | 15 | struct optimistic_spin_queue { 16 | /* 17 | * Stores an encoded value of the CPU # of the tail node in the queue. 18 | * If the queue is empty, then it's set to OSQ_UNLOCKED_VAL. 19 | */ 20 | atomic_t tail; 21 | }; 22 | 23 | #define OSQ_UNLOCKED_VAL (0) 24 | 25 | /* Init macro and function. */ 26 | #define OSQ_LOCK_UNLOCKED { ATOMIC_INIT(OSQ_UNLOCKED_VAL) } 27 | 28 | static inline void osq_lock_init(struct optimistic_spin_queue *lock) 29 | { 30 | atomic_set(&lock->tail, OSQ_UNLOCKED_VAL); 31 | } 32 | 33 | extern bool osq_lock(struct optimistic_spin_queue *lock); 34 | extern void osq_unlock(struct optimistic_spin_queue *lock); 35 | 36 | static inline bool osq_is_locked(struct optimistic_spin_queue *lock) 37 | { 38 | return atomic_read(&lock->tail) != OSQ_UNLOCKED_VAL; 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/linux/path.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_PATH_H 3 | #define _LINUX_PATH_H 4 | 5 | struct dentry; 6 | struct vfsmount; 7 | 8 | struct path { 9 | struct vfsmount *mnt; 10 | struct dentry *dentry; 11 | } __randomize_layout; 12 | 13 | extern void path_get(const struct path *); 14 | extern void path_put(const struct path *); 15 | 16 | static inline int path_equal(const struct path *path1, const struct path *path2) 17 | { 18 | return path1->mnt == path2->mnt && path1->dentry == path2->dentry; 19 | } 20 | 21 | static inline void path_put_init(struct path *path) 22 | { 23 | path_put(path); 24 | *path = (struct path) { }; 25 | } 26 | 27 | #endif /* _LINUX_PATH_H */ 28 | -------------------------------------------------------------------------------- /include/linux/pfn.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_PFN_H_ 3 | #define _LINUX_PFN_H_ 4 | 5 | #ifndef __ASSEMBLY__ 6 | #include 7 | 8 | /* 9 | * pfn_t: encapsulates a page-frame number that is optionally backed 10 | * by memmap (struct page). Whether a pfn_t has a 'struct page' 11 | * backing is indicated by flags in the high bits of the value. 12 | */ 13 | typedef struct { 14 | u64 val; 15 | } pfn_t; 16 | #endif 17 | 18 | #define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) 19 | #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) 20 | #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) 21 | #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT) 22 | #define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT)) 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/linux/range.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_RANGE_H 3 | #define _LINUX_RANGE_H 4 | 5 | struct range { 6 | u64 start; 7 | u64 end; 8 | }; 9 | 10 | int add_range(struct range *range, int az, int nr_range, 11 | u64 start, u64 end); 12 | 13 | 14 | int add_range_with_merge(struct range *range, int az, int nr_range, 15 | u64 start, u64 end); 16 | 17 | void subtract_range(struct range *range, int az, u64 start, u64 end); 18 | 19 | int clean_sort_range(struct range *range, int az); 20 | 21 | void sort_range(struct range *range, int nr_range); 22 | 23 | #define MAX_RESOURCE ((resource_size_t)~0) 24 | static inline resource_size_t cap_resource(u64 val) 25 | { 26 | if (val > MAX_RESOURCE) 27 | return MAX_RESOURCE; 28 | 29 | return val; 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /include/linux/resource.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_RESOURCE_H 3 | #define _LINUX_RESOURCE_H 4 | 5 | #include 6 | 7 | 8 | struct task_struct; 9 | 10 | void getrusage(struct task_struct *p, int who, struct rusage *ru); 11 | int do_prlimit(struct task_struct *tsk, unsigned int resource, 12 | struct rlimit *new_rlim, struct rlimit *old_rlim); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/linux/restart_block.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * Common syscall restarting data 4 | */ 5 | #ifndef __LINUX_RESTART_BLOCK_H 6 | #define __LINUX_RESTART_BLOCK_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | struct timespec; 13 | struct old_timespec32; 14 | struct pollfd; 15 | 16 | enum timespec_type { 17 | TT_NONE = 0, 18 | TT_NATIVE = 1, 19 | TT_COMPAT = 2, 20 | }; 21 | 22 | /* 23 | * System call restart block. 24 | */ 25 | struct restart_block { 26 | long (*fn)(struct restart_block *); 27 | union { 28 | /* For futex_wait and futex_wait_requeue_pi */ 29 | struct { 30 | u32 __user *uaddr; 31 | u32 val; 32 | u32 flags; 33 | u32 bitset; 34 | u64 time; 35 | u32 __user *uaddr2; 36 | } futex; 37 | /* For nanosleep */ 38 | struct { 39 | clockid_t clockid; 40 | enum timespec_type type; 41 | union { 42 | struct __kernel_timespec __user *rmtp; 43 | struct old_timespec32 __user *compat_rmtp; 44 | }; 45 | u64 expires; 46 | } nanosleep; 47 | /* For poll */ 48 | struct { 49 | struct pollfd __user *ufds; 50 | int nfds; 51 | int has_timeout; 52 | unsigned long tv_sec; 53 | unsigned long tv_nsec; 54 | } poll; 55 | }; 56 | }; 57 | 58 | extern long do_no_restart_syscall(struct restart_block *parm); 59 | 60 | #endif /* __LINUX_RESTART_BLOCK_H */ 61 | -------------------------------------------------------------------------------- /include/linux/rwlock_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_RWLOCK_TYPES_H 2 | #define __LINUX_RWLOCK_TYPES_H 3 | 4 | /* 5 | * include/linux/rwlock_types.h - generic rwlock type definitions 6 | * and initializers 7 | * 8 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar 9 | * Released under the General Public License (GPL). 10 | */ 11 | typedef struct { 12 | arch_rwlock_t raw_lock; 13 | #ifdef CONFIG_DEBUG_SPINLOCK 14 | unsigned int magic, owner_cpu; 15 | void *owner; 16 | #endif 17 | #ifdef CONFIG_DEBUG_LOCK_ALLOC 18 | struct lockdep_map dep_map; 19 | #endif 20 | } rwlock_t; 21 | 22 | #define RWLOCK_MAGIC 0xdeaf1eed 23 | 24 | #ifdef CONFIG_DEBUG_LOCK_ALLOC 25 | # define RW_DEP_MAP_INIT(lockname) \ 26 | .dep_map = { \ 27 | .name = #lockname, \ 28 | .wait_type_inner = LD_WAIT_CONFIG, \ 29 | } 30 | #else 31 | # define RW_DEP_MAP_INIT(lockname) 32 | #endif 33 | 34 | #ifdef CONFIG_DEBUG_SPINLOCK 35 | #define __RW_LOCK_UNLOCKED(lockname) \ 36 | (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ 37 | .magic = RWLOCK_MAGIC, \ 38 | .owner = SPINLOCK_OWNER_INIT, \ 39 | .owner_cpu = -1, \ 40 | RW_DEP_MAP_INIT(lockname) } 41 | #else 42 | #define __RW_LOCK_UNLOCKED(lockname) \ 43 | (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ 44 | RW_DEP_MAP_INIT(lockname) } 45 | #endif 46 | 47 | #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x) 48 | 49 | #endif /* __LINUX_RWLOCK_TYPES_H */ 50 | -------------------------------------------------------------------------------- /include/linux/sched/types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_SCHED_TYPES_H 3 | #define _LINUX_SCHED_TYPES_H 4 | 5 | #include 6 | 7 | /** 8 | * struct task_cputime - collected CPU time counts 9 | * @stime: time spent in kernel mode, in nanoseconds 10 | * @utime: time spent in user mode, in nanoseconds 11 | * @sum_exec_runtime: total time spent on the CPU, in nanoseconds 12 | * 13 | * This structure groups together three kinds of CPU time that are tracked for 14 | * threads and thread groups. Most things considering CPU time want to group 15 | * these counts together and treat all three of them in parallel. 16 | */ 17 | struct task_cputime { 18 | u64 stime; 19 | u64 utime; 20 | unsigned long long sum_exec_runtime; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/linux/sem.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_SEM_H 3 | #define _LINUX_SEM_H 4 | 5 | #include 6 | 7 | struct task_struct; 8 | struct sem_undo_list; 9 | 10 | #ifdef CONFIG_SYSVIPC 11 | 12 | struct sysv_sem { 13 | struct sem_undo_list *undo_list; 14 | }; 15 | 16 | extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk); 17 | extern void exit_sem(struct task_struct *tsk); 18 | 19 | #else 20 | 21 | struct sysv_sem { 22 | /* empty */ 23 | }; 24 | 25 | static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk) 26 | { 27 | return 0; 28 | } 29 | 30 | static inline void exit_sem(struct task_struct *tsk) 31 | { 32 | return; 33 | } 34 | #endif 35 | 36 | #endif /* _LINUX_SEM_H */ 37 | -------------------------------------------------------------------------------- /include/linux/semaphore.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (c) 2008 Intel Corporation 4 | * Author: Matthew Wilcox 5 | * 6 | * Please see kernel/locking/semaphore.c for documentation of these functions 7 | */ 8 | #ifndef __LINUX_SEMAPHORE_H 9 | #define __LINUX_SEMAPHORE_H 10 | 11 | #include 12 | #include 13 | 14 | /* Please don't access any members of this structure directly */ 15 | struct semaphore { 16 | raw_spinlock_t lock; 17 | unsigned int count; 18 | struct list_head wait_list; 19 | }; 20 | 21 | #define __SEMAPHORE_INITIALIZER(name, n) \ 22 | { \ 23 | .lock = __RAW_SPIN_LOCK_UNLOCKED((name).lock), \ 24 | .count = n, \ 25 | .wait_list = LIST_HEAD_INIT((name).wait_list), \ 26 | } 27 | 28 | #define DEFINE_SEMAPHORE(name) \ 29 | struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 30 | 31 | static inline void sema_init(struct semaphore *sem, int val) 32 | { 33 | static struct lock_class_key __key; 34 | *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val); 35 | lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0); 36 | } 37 | 38 | extern void down(struct semaphore *sem); 39 | extern int __must_check down_interruptible(struct semaphore *sem); 40 | extern int __must_check down_killable(struct semaphore *sem); 41 | extern int __must_check down_trylock(struct semaphore *sem); 42 | extern int __must_check down_timeout(struct semaphore *sem, long jiffies); 43 | extern void up(struct semaphore *sem); 44 | 45 | #endif /* __LINUX_SEMAPHORE_H */ 46 | -------------------------------------------------------------------------------- /include/linux/seq_file_net.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __SEQ_FILE_NET_H__ 3 | #define __SEQ_FILE_NET_H__ 4 | 5 | #include 6 | 7 | struct net; 8 | extern struct net init_net; 9 | 10 | struct seq_net_private { 11 | #ifdef CONFIG_NET_NS 12 | struct net *net; 13 | #endif 14 | }; 15 | 16 | static inline struct net *seq_file_net(struct seq_file *seq) 17 | { 18 | #ifdef CONFIG_NET_NS 19 | return ((struct seq_net_private *)seq->private)->net; 20 | #else 21 | return &init_net; 22 | #endif 23 | } 24 | 25 | /* 26 | * This one is needed for proc_create_net_single since net is stored directly 27 | * in private not as a struct i.e. seq_file_net can't be used. 28 | */ 29 | static inline struct net *seq_file_single_net(struct seq_file *seq) 30 | { 31 | #ifdef CONFIG_NET_NS 32 | return (struct net *)seq->private; 33 | #else 34 | return &init_net; 35 | #endif 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /include/linux/set_memory.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright 2017, Michael Ellerman, IBM Corporation. 4 | */ 5 | #ifndef _LINUX_SET_MEMORY_H_ 6 | #define _LINUX_SET_MEMORY_H_ 7 | 8 | #ifdef CONFIG_ARCH_HAS_SET_MEMORY 9 | #include 10 | #else 11 | static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; } 12 | static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; } 13 | static inline int set_memory_x(unsigned long addr, int numpages) { return 0; } 14 | static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; } 15 | #endif 16 | 17 | #ifndef CONFIG_ARCH_HAS_SET_DIRECT_MAP 18 | static inline int set_direct_map_invalid_noflush(struct page *page) 19 | { 20 | return 0; 21 | } 22 | static inline int set_direct_map_default_noflush(struct page *page) 23 | { 24 | return 0; 25 | } 26 | #endif 27 | 28 | #ifndef set_mce_nospec 29 | static inline int set_mce_nospec(unsigned long pfn, bool unmap) 30 | { 31 | return 0; 32 | } 33 | #endif 34 | 35 | #ifndef clear_mce_nospec 36 | static inline int clear_mce_nospec(unsigned long pfn) 37 | { 38 | return 0; 39 | } 40 | #endif 41 | 42 | #ifndef CONFIG_ARCH_HAS_MEM_ENCRYPT 43 | static inline int set_memory_encrypted(unsigned long addr, int numpages) 44 | { 45 | return 0; 46 | } 47 | 48 | static inline int set_memory_decrypted(unsigned long addr, int numpages) 49 | { 50 | return 0; 51 | } 52 | #endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */ 53 | 54 | #endif /* _LINUX_SET_MEMORY_H_ */ 55 | -------------------------------------------------------------------------------- /include/linux/shm.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_SHM_H_ 3 | #define _LINUX_SHM_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct file; 11 | 12 | #ifdef CONFIG_SYSVIPC 13 | struct sysv_shm { 14 | struct list_head shm_clist; 15 | }; 16 | 17 | long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr, 18 | unsigned long shmlba); 19 | bool is_file_shm_hugepages(struct file *file); 20 | void exit_shm(struct task_struct *task); 21 | #define shm_init_task(task) INIT_LIST_HEAD(&(task)->sysvshm.shm_clist) 22 | #else 23 | struct sysv_shm { 24 | /* empty */ 25 | }; 26 | 27 | static inline long do_shmat(int shmid, char __user *shmaddr, 28 | int shmflg, unsigned long *addr, 29 | unsigned long shmlba) 30 | { 31 | return -ENOSYS; 32 | } 33 | static inline bool is_file_shm_hugepages(struct file *file) 34 | { 35 | return false; 36 | } 37 | static inline void exit_shm(struct task_struct *task) 38 | { 39 | } 40 | static inline void shm_init_task(struct task_struct *task) 41 | { 42 | } 43 | #endif 44 | 45 | #endif /* _LINUX_SHM_H_ */ 46 | -------------------------------------------------------------------------------- /include/linux/signal_types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_SIGNAL_TYPES_H 3 | #define _LINUX_SIGNAL_TYPES_H 4 | 5 | /* 6 | * Basic signal handling related data type definitions: 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | typedef struct kernel_siginfo { 13 | __SIGINFO; 14 | } kernel_siginfo_t; 15 | 16 | /* 17 | * Real Time signals may be queued. 18 | */ 19 | 20 | struct sigqueue { 21 | struct list_head list; 22 | int flags; 23 | kernel_siginfo_t info; 24 | struct user_struct *user; 25 | }; 26 | 27 | /* flags values. */ 28 | #define SIGQUEUE_PREALLOC 1 29 | 30 | struct sigpending { 31 | struct list_head list; 32 | sigset_t signal; 33 | }; 34 | 35 | struct sigaction { 36 | #ifndef __ARCH_HAS_IRIX_SIGACTION 37 | __sighandler_t sa_handler; 38 | unsigned long sa_flags; 39 | #else 40 | unsigned int sa_flags; 41 | __sighandler_t sa_handler; 42 | #endif 43 | #ifdef __ARCH_HAS_SA_RESTORER 44 | __sigrestore_t sa_restorer; 45 | #endif 46 | sigset_t sa_mask; /* mask last for extensibility */ 47 | }; 48 | 49 | struct k_sigaction { 50 | struct sigaction sa; 51 | #ifdef __ARCH_HAS_KA_RESTORER 52 | __sigrestore_t ka_restorer; 53 | #endif 54 | }; 55 | 56 | #ifdef CONFIG_OLD_SIGACTION 57 | struct old_sigaction { 58 | __sighandler_t sa_handler; 59 | old_sigset_t sa_mask; 60 | unsigned long sa_flags; 61 | __sigrestore_t sa_restorer; 62 | }; 63 | #endif 64 | 65 | struct ksignal { 66 | struct k_sigaction ka; 67 | kernel_siginfo_t info; 68 | int sig; 69 | }; 70 | 71 | #endif /* _LINUX_SIGNAL_TYPES_H */ 72 | -------------------------------------------------------------------------------- /include/linux/sizes.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * include/linux/sizes.h 4 | */ 5 | #ifndef __LINUX_SIZES_H__ 6 | #define __LINUX_SIZES_H__ 7 | 8 | #include 9 | 10 | #define SZ_1 0x00000001 11 | #define SZ_2 0x00000002 12 | #define SZ_4 0x00000004 13 | #define SZ_8 0x00000008 14 | #define SZ_16 0x00000010 15 | #define SZ_32 0x00000020 16 | #define SZ_64 0x00000040 17 | #define SZ_128 0x00000080 18 | #define SZ_256 0x00000100 19 | #define SZ_512 0x00000200 20 | 21 | #define SZ_1K 0x00000400 22 | #define SZ_2K 0x00000800 23 | #define SZ_4K 0x00001000 24 | #define SZ_8K 0x00002000 25 | #define SZ_16K 0x00004000 26 | #define SZ_32K 0x00008000 27 | #define SZ_64K 0x00010000 28 | #define SZ_128K 0x00020000 29 | #define SZ_256K 0x00040000 30 | #define SZ_512K 0x00080000 31 | 32 | #define SZ_1M 0x00100000 33 | #define SZ_2M 0x00200000 34 | #define SZ_4M 0x00400000 35 | #define SZ_8M 0x00800000 36 | #define SZ_16M 0x01000000 37 | #define SZ_32M 0x02000000 38 | #define SZ_64M 0x04000000 39 | #define SZ_128M 0x08000000 40 | #define SZ_256M 0x10000000 41 | #define SZ_512M 0x20000000 42 | 43 | #define SZ_1G 0x40000000 44 | #define SZ_2G 0x80000000 45 | 46 | #define SZ_4G _AC(0x100000000, ULL) 47 | #define SZ_64T _AC(0x400000000000, ULL) 48 | 49 | #endif /* __LINUX_SIZES_H__ */ 50 | -------------------------------------------------------------------------------- /include/linux/stackdepot.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 | /* 3 | * A generic stack depot implementation 4 | * 5 | * Author: Alexander Potapenko 6 | * Copyright (C) 2016 Google, Inc. 7 | * 8 | * Based on code by Dmitry Chernenkov. 9 | */ 10 | 11 | #ifndef _LINUX_STACKDEPOT_H 12 | #define _LINUX_STACKDEPOT_H 13 | 14 | typedef u32 depot_stack_handle_t; 15 | 16 | depot_stack_handle_t stack_depot_save(unsigned long *entries, 17 | unsigned int nr_entries, gfp_t gfp_flags); 18 | 19 | unsigned int stack_depot_fetch(depot_stack_handle_t handle, 20 | unsigned long **entries); 21 | 22 | unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/linux/stat.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_STAT_H 3 | #define _LINUX_STAT_H 4 | 5 | 6 | #include 7 | #include 8 | 9 | #define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) 10 | #define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) 11 | #define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) 12 | #define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) 13 | #define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) 14 | 15 | #define UTIME_NOW ((1l << 30) - 1l) 16 | #define UTIME_OMIT ((1l << 30) - 2l) 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #define KSTAT_QUERY_FLAGS (AT_STATX_SYNC_TYPE) 23 | 24 | struct kstat { 25 | u32 result_mask; /* What fields the user got */ 26 | umode_t mode; 27 | unsigned int nlink; 28 | uint32_t blksize; /* Preferred I/O size */ 29 | u64 attributes; 30 | u64 attributes_mask; 31 | #define KSTAT_ATTR_FS_IOC_FLAGS \ 32 | (STATX_ATTR_COMPRESSED | \ 33 | STATX_ATTR_IMMUTABLE | \ 34 | STATX_ATTR_APPEND | \ 35 | STATX_ATTR_NODUMP | \ 36 | STATX_ATTR_ENCRYPTED | \ 37 | STATX_ATTR_VERITY \ 38 | )/* Attrs corresponding to FS_*_FL flags */ 39 | u64 ino; 40 | dev_t dev; 41 | dev_t rdev; 42 | kuid_t uid; 43 | kgid_t gid; 44 | loff_t size; 45 | struct timespec64 atime; 46 | struct timespec64 mtime; 47 | struct timespec64 ctime; 48 | struct timespec64 btime; /* File creation time */ 49 | u64 blocks; 50 | u64 mnt_id; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /include/linux/static_key.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/linux/stddef.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_STDDEF_H 3 | #define _LINUX_STDDEF_H 4 | 5 | #include 6 | 7 | #undef NULL 8 | #define NULL ((void *)0) 9 | 10 | enum { 11 | false = 0, 12 | true = 1 13 | }; 14 | 15 | #undef offsetof 16 | #ifdef __compiler_offsetof 17 | #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER) 18 | #else 19 | #define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER) 20 | #endif 21 | 22 | /** 23 | * sizeof_field(TYPE, MEMBER) 24 | * 25 | * @TYPE: The structure containing the field of interest 26 | * @MEMBER: The field to return the size of 27 | */ 28 | #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) 29 | 30 | /** 31 | * offsetofend(TYPE, MEMBER) 32 | * 33 | * @TYPE: The type of the structure 34 | * @MEMBER: The member within the structure to get the end offset of 35 | */ 36 | #define offsetofend(TYPE, MEMBER) \ 37 | (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/linux/stringify.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_STRINGIFY_H 2 | #define __LINUX_STRINGIFY_H 3 | 4 | /* Indirect stringification. Doing two levels allows the parameter to be a 5 | * macro itself. For example, compile with -DFOO=bar, __stringify(FOO) 6 | * converts to "bar". 7 | */ 8 | 9 | #define __stringify_1(x...) #x 10 | #define __stringify(x...) __stringify_1(x) 11 | 12 | #endif /* !__LINUX_STRINGIFY_H */ 13 | -------------------------------------------------------------------------------- /include/linux/swab.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_SWAB_H 3 | #define _LINUX_SWAB_H 4 | 5 | #include 6 | 7 | # define swab16 __swab16 8 | # define swab32 __swab32 9 | # define swab64 __swab64 10 | # define swab __swab 11 | # define swahw32 __swahw32 12 | # define swahb32 __swahb32 13 | # define swab16p __swab16p 14 | # define swab32p __swab32p 15 | # define swab64p __swab64p 16 | # define swahw32p __swahw32p 17 | # define swahb32p __swahb32p 18 | # define swab16s __swab16s 19 | # define swab32s __swab32s 20 | # define swab64s __swab64s 21 | # define swahw32s __swahw32s 22 | # define swahb32s __swahb32s 23 | #endif /* _LINUX_SWAB_H */ 24 | -------------------------------------------------------------------------------- /include/linux/task_io_accounting.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * task_io_accounting: a structure which is used for recording a single task's 4 | * IO statistics. 5 | * 6 | * Don't include this header file directly - it is designed to be dragged in via 7 | * sched.h. 8 | * 9 | * Blame Andrew Morton for all this. 10 | */ 11 | 12 | struct task_io_accounting { 13 | #ifdef CONFIG_TASK_XACCT 14 | /* bytes read */ 15 | u64 rchar; 16 | /* bytes written */ 17 | u64 wchar; 18 | /* # of read syscalls */ 19 | u64 syscr; 20 | /* # of write syscalls */ 21 | u64 syscw; 22 | #endif /* CONFIG_TASK_XACCT */ 23 | 24 | #ifdef CONFIG_TASK_IO_ACCOUNTING 25 | /* 26 | * The number of bytes which this task has caused to be read from 27 | * storage. 28 | */ 29 | u64 read_bytes; 30 | 31 | /* 32 | * The number of bytes which this task has caused, or shall cause to be 33 | * written to disk. 34 | */ 35 | u64 write_bytes; 36 | 37 | /* 38 | * A task can cause "negative" IO too. If this task truncates some 39 | * dirty pagecache, some IO which another task has been accounted for 40 | * (in its write_bytes) will not be happening. We _could_ just 41 | * subtract that from the truncating task's write_bytes, but there is 42 | * information loss in doing that. 43 | */ 44 | u64 cancelled_write_bytes; 45 | #endif /* CONFIG_TASK_IO_ACCOUNTING */ 46 | }; 47 | -------------------------------------------------------------------------------- /include/linux/threads.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_THREADS_H 3 | #define _LINUX_THREADS_H 4 | 5 | 6 | /* 7 | * The default limit for the nr of threads is now in 8 | * /proc/sys/kernel/threads-max. 9 | */ 10 | 11 | /* 12 | * Maximum supported processors. Setting this smaller saves quite a 13 | * bit of memory. Use nr_cpu_ids instead of this except for static bitmaps. 14 | */ 15 | #ifndef CONFIG_NR_CPUS 16 | /* FIXME: This should be fixed in the arch's Kconfig */ 17 | #define CONFIG_NR_CPUS 1 18 | #endif 19 | 20 | /* Places which use this should consider cpumask_var_t. */ 21 | #define NR_CPUS CONFIG_NR_CPUS 22 | 23 | #define MIN_THREADS_LEFT_FOR_ROOT 4 24 | 25 | /* 26 | * This controls the default maximum pid allocated to a process 27 | */ 28 | #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) 29 | 30 | /* 31 | * A maximum of 4 million PIDs should be enough for a while. 32 | * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.] 33 | */ 34 | #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ 35 | (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)) 36 | 37 | /* 38 | * Define a minimum number of pids per cpu. Heuristically based 39 | * on original pid max of 32k for 32 cpus. Also, increase the 40 | * minimum settable value for pid_max on the running system based 41 | * on similar defaults. See kernel/pid.c:pidmap_init() for details. 42 | */ 43 | #define PIDS_PER_CPU_DEFAULT 1024 44 | #define PIDS_PER_CPU_MIN 8 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/linux/timekeeping32.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_TIMEKEEPING32_H 2 | #define _LINUX_TIMEKEEPING32_H 3 | /* 4 | * These interfaces are all based on the old timespec type 5 | * and should get replaced with the timespec64 based versions 6 | * over time so we can remove the file here. 7 | */ 8 | 9 | static inline unsigned long get_seconds(void) 10 | { 11 | return ktime_get_real_seconds(); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/linux/tracepoint-defs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef TRACEPOINT_DEFS_H 3 | #define TRACEPOINT_DEFS_H 1 4 | 5 | /* 6 | * File can be included directly by headers who only want to access 7 | * tracepoint->key to guard out of line trace calls, or the definition of 8 | * trace_print_flags{_u64}. Otherwise linux/tracepoint.h should be used. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | struct trace_print_flags { 15 | unsigned long mask; 16 | const char *name; 17 | }; 18 | 19 | struct trace_print_flags_u64 { 20 | unsigned long long mask; 21 | const char *name; 22 | }; 23 | 24 | struct tracepoint_func { 25 | void *func; 26 | void *data; 27 | int prio; 28 | }; 29 | 30 | struct tracepoint { 31 | const char *name; /* Tracepoint name */ 32 | struct static_key key; 33 | int (*regfunc)(void); 34 | void (*unregfunc)(void); 35 | struct tracepoint_func __rcu *funcs; 36 | }; 37 | 38 | #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 39 | typedef const int tracepoint_ptr_t; 40 | #else 41 | typedef struct tracepoint * const tracepoint_ptr_t; 42 | #endif 43 | 44 | struct bpf_raw_event_map { 45 | struct tracepoint *tp; 46 | void *bpf_func; 47 | u32 num_args; 48 | u32 writable_size; 49 | } __aligned(32); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/linux/typecheck.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef TYPECHECK_H_INCLUDED 3 | #define TYPECHECK_H_INCLUDED 4 | 5 | /* 6 | * Check at compile time that something is of a particular type. 7 | * Always evaluates to 1 so you may use it easily in comparisons. 8 | */ 9 | #define typecheck(type,x) \ 10 | ({ type __dummy; \ 11 | typeof(x) __dummy2; \ 12 | (void)(&__dummy == &__dummy2); \ 13 | 1; \ 14 | }) 15 | 16 | /* 17 | * Check at compile time that 'function' is a certain type, or is a pointer 18 | * to that type (needs to use typedef for the function type.) 19 | */ 20 | #define typecheck_fn(type,function) \ 21 | ({ typeof(type) __tmp = function; \ 22 | (void)__tmp; \ 23 | }) 24 | 25 | #endif /* TYPECHECK_H_INCLUDED */ 26 | -------------------------------------------------------------------------------- /include/linux/unaligned/le_struct.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _LINUX_UNALIGNED_LE_STRUCT_H 3 | #define _LINUX_UNALIGNED_LE_STRUCT_H 4 | 5 | #include 6 | 7 | static inline u16 get_unaligned_le16(const void *p) 8 | { 9 | return __get_unaligned_cpu16((const u8 *)p); 10 | } 11 | 12 | static inline u32 get_unaligned_le32(const void *p) 13 | { 14 | return __get_unaligned_cpu32((const u8 *)p); 15 | } 16 | 17 | static inline u64 get_unaligned_le64(const void *p) 18 | { 19 | return __get_unaligned_cpu64((const u8 *)p); 20 | } 21 | 22 | static inline void put_unaligned_le16(u16 val, void *p) 23 | { 24 | __put_unaligned_cpu16(val, p); 25 | } 26 | 27 | static inline void put_unaligned_le32(u32 val, void *p) 28 | { 29 | __put_unaligned_cpu32(val, p); 30 | } 31 | 32 | static inline void put_unaligned_le64(u64 val, void *p) 33 | { 34 | __put_unaligned_cpu64(val, p); 35 | } 36 | 37 | #endif /* _LINUX_UNALIGNED_LE_STRUCT_H */ 38 | -------------------------------------------------------------------------------- /include/linux/unaligned/packed_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_PACKED_STRUCT_H 2 | #define _LINUX_UNALIGNED_PACKED_STRUCT_H 3 | 4 | #include 5 | 6 | struct __una_u16 { u16 x; } __packed; 7 | struct __una_u32 { u32 x; } __packed; 8 | struct __una_u64 { u64 x; } __packed; 9 | 10 | static inline u16 __get_unaligned_cpu16(const void *p) 11 | { 12 | const struct __una_u16 *ptr = (const struct __una_u16 *)p; 13 | return ptr->x; 14 | } 15 | 16 | static inline u32 __get_unaligned_cpu32(const void *p) 17 | { 18 | const struct __una_u32 *ptr = (const struct __una_u32 *)p; 19 | return ptr->x; 20 | } 21 | 22 | static inline u64 __get_unaligned_cpu64(const void *p) 23 | { 24 | const struct __una_u64 *ptr = (const struct __una_u64 *)p; 25 | return ptr->x; 26 | } 27 | 28 | static inline void __put_unaligned_cpu16(u16 val, void *p) 29 | { 30 | struct __una_u16 *ptr = (struct __una_u16 *)p; 31 | ptr->x = val; 32 | } 33 | 34 | static inline void __put_unaligned_cpu32(u32 val, void *p) 35 | { 36 | struct __una_u32 *ptr = (struct __una_u32 *)p; 37 | ptr->x = val; 38 | } 39 | 40 | static inline void __put_unaligned_cpu64(u64 val, void *p) 41 | { 42 | struct __una_u64 *ptr = (struct __una_u64 *)p; 43 | ptr->x = val; 44 | } 45 | 46 | #endif /* _LINUX_UNALIGNED_PACKED_STRUCT_H */ 47 | -------------------------------------------------------------------------------- /include/net/netns/bpf.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * BPF programs attached to network namespace 4 | */ 5 | 6 | #ifndef __NETNS_BPF_H__ 7 | #define __NETNS_BPF_H__ 8 | 9 | #include 10 | 11 | struct bpf_prog; 12 | struct bpf_prog_array; 13 | 14 | struct netns_bpf { 15 | /* Array of programs to run compiled from progs or links */ 16 | struct bpf_prog_array __rcu *run_array[MAX_NETNS_BPF_ATTACH_TYPE]; 17 | struct bpf_prog *progs[MAX_NETNS_BPF_ATTACH_TYPE]; 18 | struct list_head links[MAX_NETNS_BPF_ATTACH_TYPE]; 19 | }; 20 | 21 | #endif /* __NETNS_BPF_H__ */ 22 | -------------------------------------------------------------------------------- /include/net/netns/can.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * can in net namespaces 4 | */ 5 | 6 | #ifndef __NETNS_CAN_H__ 7 | #define __NETNS_CAN_H__ 8 | 9 | #include 10 | 11 | struct can_dev_rcv_lists; 12 | struct can_pkg_stats; 13 | struct can_rcv_lists_stats; 14 | 15 | struct netns_can { 16 | #if IS_ENABLED(CONFIG_PROC_FS) 17 | struct proc_dir_entry *proc_dir; 18 | struct proc_dir_entry *pde_version; 19 | struct proc_dir_entry *pde_stats; 20 | struct proc_dir_entry *pde_reset_stats; 21 | struct proc_dir_entry *pde_rcvlist_all; 22 | struct proc_dir_entry *pde_rcvlist_fil; 23 | struct proc_dir_entry *pde_rcvlist_inv; 24 | struct proc_dir_entry *pde_rcvlist_sff; 25 | struct proc_dir_entry *pde_rcvlist_eff; 26 | struct proc_dir_entry *pde_rcvlist_err; 27 | struct proc_dir_entry *bcmproc_dir; 28 | #endif 29 | 30 | /* receive filters subscribed for 'all' CAN devices */ 31 | struct can_dev_rcv_lists *rx_alldev_list; 32 | spinlock_t rcvlists_lock; 33 | struct timer_list stattimer; /* timer for statistics update */ 34 | struct can_pkg_stats *pkg_stats; 35 | struct can_rcv_lists_stats *rcv_lists_stats; 36 | 37 | /* CAN GW per-net gateway jobs */ 38 | struct hlist_head cgw_list; 39 | }; 40 | 41 | #endif /* __NETNS_CAN_H__ */ 42 | -------------------------------------------------------------------------------- /include/net/netns/core.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __NETNS_CORE_H__ 3 | #define __NETNS_CORE_H__ 4 | 5 | struct ctl_table_header; 6 | struct prot_inuse; 7 | 8 | struct netns_core { 9 | /* core sysctls */ 10 | struct ctl_table_header *sysctl_hdr; 11 | 12 | int sysctl_somaxconn; 13 | 14 | #ifdef CONFIG_PROC_FS 15 | int __percpu *sock_inuse; 16 | struct prot_inuse __percpu *prot_inuse; 17 | #endif 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/net/netns/dccp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __NETNS_DCCP_H__ 3 | #define __NETNS_DCCP_H__ 4 | 5 | struct sock; 6 | 7 | struct netns_dccp { 8 | struct sock *v4_ctl_sk; 9 | struct sock *v6_ctl_sk; 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/net/netns/ieee802154_6lowpan.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * ieee802154 6lowpan in net namespaces 4 | */ 5 | 6 | #include 7 | 8 | #ifndef __NETNS_IEEE802154_6LOWPAN_H__ 9 | #define __NETNS_IEEE802154_6LOWPAN_H__ 10 | 11 | struct netns_sysctl_lowpan { 12 | #ifdef CONFIG_SYSCTL 13 | struct ctl_table_header *frags_hdr; 14 | #endif 15 | }; 16 | 17 | struct netns_ieee802154_lowpan { 18 | struct netns_sysctl_lowpan sysctl; 19 | struct fqdir *fqdir; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/net/netns/mib.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __NETNS_MIB_H__ 3 | #define __NETNS_MIB_H__ 4 | 5 | #include 6 | 7 | struct netns_mib { 8 | DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); 9 | DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics); 10 | DEFINE_SNMP_STAT(struct linux_mib, net_statistics); 11 | DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); 12 | DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); 13 | DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); 14 | DEFINE_SNMP_STAT_ATOMIC(struct icmpmsg_mib, icmpmsg_statistics); 15 | 16 | #if IS_ENABLED(CONFIG_IPV6) 17 | struct proc_dir_entry *proc_net_devsnmp6; 18 | DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); 19 | DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); 20 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); 21 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); 22 | DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib, icmpv6msg_statistics); 23 | #endif 24 | #ifdef CONFIG_XFRM_STATISTICS 25 | DEFINE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); 26 | #endif 27 | #if IS_ENABLED(CONFIG_TLS) 28 | DEFINE_SNMP_STAT(struct linux_tls_mib, tls_statistics); 29 | #endif 30 | #ifdef CONFIG_MPTCP 31 | DEFINE_SNMP_STAT(struct mptcp_mib, mptcp_statistics); 32 | #endif 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/net/netns/mpls.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * mpls in net namespaces 4 | */ 5 | 6 | #ifndef __NETNS_MPLS_H__ 7 | #define __NETNS_MPLS_H__ 8 | 9 | struct mpls_route; 10 | struct ctl_table_header; 11 | 12 | struct netns_mpls { 13 | int ip_ttl_propagate; 14 | int default_ttl; 15 | size_t platform_labels; 16 | struct mpls_route __rcu * __rcu *platform_label; 17 | 18 | struct ctl_table_header *ctl; 19 | }; 20 | 21 | #endif /* __NETNS_MPLS_H__ */ 22 | -------------------------------------------------------------------------------- /include/net/netns/netfilter.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __NETNS_NETFILTER_H 3 | #define __NETNS_NETFILTER_H 4 | 5 | #include 6 | 7 | struct proc_dir_entry; 8 | struct nf_logger; 9 | struct nf_queue_handler; 10 | 11 | struct netns_nf { 12 | #if defined CONFIG_PROC_FS 13 | struct proc_dir_entry *proc_netfilter; 14 | #endif 15 | const struct nf_queue_handler __rcu *queue_handler; 16 | const struct nf_logger __rcu *nf_loggers[NFPROTO_NUMPROTO]; 17 | #ifdef CONFIG_SYSCTL 18 | struct ctl_table_header *nf_log_dir_header; 19 | #endif 20 | struct nf_hook_entries __rcu *hooks_ipv4[NF_INET_NUMHOOKS]; 21 | struct nf_hook_entries __rcu *hooks_ipv6[NF_INET_NUMHOOKS]; 22 | #ifdef CONFIG_NETFILTER_FAMILY_ARP 23 | struct nf_hook_entries __rcu *hooks_arp[NF_ARP_NUMHOOKS]; 24 | #endif 25 | #ifdef CONFIG_NETFILTER_FAMILY_BRIDGE 26 | struct nf_hook_entries __rcu *hooks_bridge[NF_INET_NUMHOOKS]; 27 | #endif 28 | #if IS_ENABLED(CONFIG_DECNET) 29 | struct nf_hook_entries __rcu *hooks_decnet[NF_DN_NUMHOOKS]; 30 | #endif 31 | #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) 32 | bool defrag_ipv4; 33 | #endif 34 | #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) 35 | bool defrag_ipv6; 36 | #endif 37 | }; 38 | #endif 39 | -------------------------------------------------------------------------------- /include/net/netns/nexthop.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * nexthops in net namespaces 4 | */ 5 | 6 | #ifndef __NETNS_NEXTHOP_H__ 7 | #define __NETNS_NEXTHOP_H__ 8 | 9 | #include 10 | 11 | struct netns_nexthop { 12 | struct rb_root rb_root; /* tree of nexthops by id */ 13 | struct hlist_head *devhash; /* nexthops by device */ 14 | 15 | unsigned int seq; /* protected by rtnl_mutex */ 16 | u32 last_id_allocated; 17 | struct atomic_notifier_head notifier_chain; 18 | }; 19 | #endif 20 | -------------------------------------------------------------------------------- /include/net/netns/nftables.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _NETNS_NFTABLES_H_ 3 | #define _NETNS_NFTABLES_H_ 4 | 5 | #include 6 | 7 | struct netns_nftables { 8 | struct list_head tables; 9 | struct list_head commit_list; 10 | struct list_head module_list; 11 | struct mutex commit_mutex; 12 | unsigned int base_seq; 13 | u8 gencursor; 14 | u8 validate_state; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/net/netns/packet.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * Packet network namespace 4 | */ 5 | #ifndef __NETNS_PACKET_H__ 6 | #define __NETNS_PACKET_H__ 7 | 8 | #include 9 | #include 10 | 11 | struct netns_packet { 12 | struct mutex sklist_lock; 13 | struct hlist_head sklist; 14 | }; 15 | 16 | #endif /* __NETNS_PACKET_H__ */ 17 | -------------------------------------------------------------------------------- /include/net/netns/unix.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * Unix network namespace 4 | */ 5 | #ifndef __NETNS_UNIX_H__ 6 | #define __NETNS_UNIX_H__ 7 | 8 | struct ctl_table_header; 9 | struct netns_unix { 10 | int sysctl_max_dgram_qlen; 11 | struct ctl_table_header *ctl; 12 | }; 13 | 14 | #endif /* __NETNS_UNIX_H__ */ 15 | -------------------------------------------------------------------------------- /include/net/netns/x_tables.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __NETNS_X_TABLES_H 3 | #define __NETNS_X_TABLES_H 4 | 5 | #include 6 | #include 7 | 8 | struct ebt_table; 9 | 10 | struct netns_xt { 11 | struct list_head tables[NFPROTO_NUMPROTO]; 12 | bool notrack_deprecated_warning; 13 | bool clusterip_deprecated_warning; 14 | #if defined(CONFIG_BRIDGE_NF_EBTABLES) || \ 15 | defined(CONFIG_BRIDGE_NF_EBTABLES_MODULE) 16 | struct ebt_table *broute_table; 17 | struct ebt_table *frame_filter; 18 | struct ebt_table *frame_nat; 19 | #endif 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /include/net/netns/xdp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __NETNS_XDP_H__ 3 | #define __NETNS_XDP_H__ 4 | 5 | #include 6 | #include 7 | 8 | struct netns_xdp { 9 | struct mutex lock; 10 | struct hlist_head list; 11 | }; 12 | 13 | #endif /* __NETNS_XDP_H__ */ 14 | -------------------------------------------------------------------------------- /include/net/netprio_cgroup.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 | /* 3 | * netprio_cgroup.h Control Group Priority set 4 | * 5 | * Authors: Neil Horman 6 | */ 7 | 8 | #ifndef _NETPRIO_CGROUP_H 9 | #define _NETPRIO_CGROUP_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) 16 | struct netprio_map { 17 | struct rcu_head rcu; 18 | u32 priomap_len; 19 | u32 priomap[]; 20 | }; 21 | 22 | static inline u32 task_netprioidx(struct task_struct *p) 23 | { 24 | struct cgroup_subsys_state *css; 25 | u32 idx; 26 | 27 | rcu_read_lock(); 28 | css = task_css(p, net_prio_cgrp_id); 29 | idx = css->id; 30 | rcu_read_unlock(); 31 | return idx; 32 | } 33 | 34 | static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd) 35 | { 36 | if (in_interrupt()) 37 | return; 38 | 39 | sock_cgroup_set_prioidx(skcd, task_netprioidx(current)); 40 | } 41 | 42 | #else /* !CONFIG_CGROUP_NET_PRIO */ 43 | 44 | static inline u32 task_netprioidx(struct task_struct *p) 45 | { 46 | return 0; 47 | } 48 | 49 | static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd) 50 | { 51 | } 52 | 53 | #endif /* CONFIG_CGROUP_NET_PRIO */ 54 | #endif /* _NET_CLS_CGROUP_H */ 55 | -------------------------------------------------------------------------------- /include/uapi/Kbuild: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | ifeq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/a.out.h),) 3 | no-export-headers += linux/a.out.h 4 | endif 5 | 6 | ifeq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/kvm.h),) 7 | no-export-headers += linux/kvm.h 8 | endif 9 | 10 | ifeq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/kvm_para.h),) 11 | ifeq ($(wildcard $(objtree)/arch/$(SRCARCH)/include/generated/uapi/asm/kvm_para.h),) 12 | no-export-headers += linux/kvm_para.h 13 | endif 14 | endif 15 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/Kbuild: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | # 3 | # Headers that are mandatory in usr/include/asm/ 4 | # (This file is not included when SRCARCH=um since UML does not support UAPI.) 5 | 6 | mandatory-y += auxvec.h 7 | mandatory-y += bitsperlong.h 8 | mandatory-y += bpf_perf_event.h 9 | mandatory-y += byteorder.h 10 | mandatory-y += errno.h 11 | mandatory-y += fcntl.h 12 | mandatory-y += ioctl.h 13 | mandatory-y += ioctls.h 14 | mandatory-y += ipcbuf.h 15 | mandatory-y += mman.h 16 | mandatory-y += msgbuf.h 17 | mandatory-y += param.h 18 | mandatory-y += poll.h 19 | mandatory-y += posix_types.h 20 | mandatory-y += ptrace.h 21 | mandatory-y += resource.h 22 | mandatory-y += sembuf.h 23 | mandatory-y += setup.h 24 | mandatory-y += shmbuf.h 25 | mandatory-y += sigcontext.h 26 | mandatory-y += siginfo.h 27 | mandatory-y += signal.h 28 | mandatory-y += socket.h 29 | mandatory-y += sockios.h 30 | mandatory-y += stat.h 31 | mandatory-y += statfs.h 32 | mandatory-y += swab.h 33 | mandatory-y += termbits.h 34 | mandatory-y += termios.h 35 | mandatory-y += types.h 36 | mandatory-y += unistd.h 37 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/bitsperlong.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI__ASM_GENERIC_BITS_PER_LONG 3 | #define _UAPI__ASM_GENERIC_BITS_PER_LONG 4 | 5 | /* 6 | * There seems to be no way of detecting this automatically from user 7 | * space, so 64 bit architectures should override this in their 8 | * bitsperlong.h. In particular, an architecture that supports 9 | * both 32 and 64 bit user space must not rely on CONFIG_64BIT 10 | * to decide it, but rather check a compiler provided macro. 11 | */ 12 | #ifndef __BITS_PER_LONG 13 | #define __BITS_PER_LONG 32 14 | #endif 15 | 16 | #endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */ 17 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/int-ll64.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* 3 | * asm-generic/int-ll64.h 4 | * 5 | * Integer declarations for architectures which use "long long" 6 | * for 64-bit types. 7 | */ 8 | 9 | #ifndef _UAPI_ASM_GENERIC_INT_LL64_H 10 | #define _UAPI_ASM_GENERIC_INT_LL64_H 11 | 12 | #include 13 | 14 | #ifndef __ASSEMBLY__ 15 | /* 16 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the 17 | * header files exported to user space 18 | */ 19 | 20 | typedef __signed__ char __s8; 21 | typedef unsigned char __u8; 22 | 23 | typedef __signed__ short __s16; 24 | typedef unsigned short __u16; 25 | 26 | typedef __signed__ int __s32; 27 | typedef unsigned int __u32; 28 | 29 | #ifdef __GNUC__ 30 | __extension__ typedef __signed__ long long __s64; 31 | __extension__ typedef unsigned long long __u64; 32 | #else 33 | typedef __signed__ long long __s64; 34 | typedef unsigned long long __u64; 35 | #endif 36 | 37 | #endif /* __ASSEMBLY__ */ 38 | 39 | 40 | #endif /* _UAPI_ASM_GENERIC_INT_LL64_H */ 41 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/ipcbuf.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __ASM_GENERIC_IPCBUF_H 3 | #define __ASM_GENERIC_IPCBUF_H 4 | 5 | #include 6 | 7 | /* 8 | * The generic ipc64_perm structure: 9 | * Note extra padding because this structure is passed back and forth 10 | * between kernel and user space. 11 | * 12 | * ipc64_perm was originally meant to be architecture specific, but 13 | * everyone just ended up making identical copies without specific 14 | * optimizations, so we may just as well all use the same one. 15 | * 16 | * Pad space is left for: 17 | * - 32-bit mode_t on architectures that only had 16 bit 18 | * - 32-bit seq 19 | * - 2 miscellaneous 32-bit values 20 | */ 21 | 22 | struct ipc64_perm { 23 | __kernel_key_t key; 24 | __kernel_uid32_t uid; 25 | __kernel_gid32_t gid; 26 | __kernel_uid32_t cuid; 27 | __kernel_gid32_t cgid; 28 | __kernel_mode_t mode; 29 | /* pad if mode_t is u16: */ 30 | unsigned char __pad1[4 - sizeof(__kernel_mode_t)]; 31 | unsigned short seq; 32 | unsigned short __pad2; 33 | __kernel_ulong_t __unused1; 34 | __kernel_ulong_t __unused2; 35 | }; 36 | 37 | #endif /* __ASM_GENERIC_IPCBUF_H */ 38 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/param.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI__ASM_GENERIC_PARAM_H 3 | #define _UAPI__ASM_GENERIC_PARAM_H 4 | 5 | #ifndef HZ 6 | #define HZ 100 7 | #endif 8 | 9 | #ifndef EXEC_PAGESIZE 10 | #define EXEC_PAGESIZE 4096 11 | #endif 12 | 13 | #ifndef NOGROUP 14 | #define NOGROUP (-1) 15 | #endif 16 | 17 | #define MAXHOSTNAMELEN 64 /* max length of hostname */ 18 | 19 | 20 | #endif /* _UAPI__ASM_GENERIC_PARAM_H */ 21 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/signal-defs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __ASM_GENERIC_SIGNAL_DEFS_H 3 | #define __ASM_GENERIC_SIGNAL_DEFS_H 4 | 5 | #include 6 | 7 | #ifndef SIG_BLOCK 8 | #define SIG_BLOCK 0 /* for blocking signals */ 9 | #endif 10 | #ifndef SIG_UNBLOCK 11 | #define SIG_UNBLOCK 1 /* for unblocking signals */ 12 | #endif 13 | #ifndef SIG_SETMASK 14 | #define SIG_SETMASK 2 /* for setting the signal mask */ 15 | #endif 16 | 17 | #ifndef __ASSEMBLY__ 18 | typedef void __signalfn_t(int); 19 | typedef __signalfn_t __user *__sighandler_t; 20 | 21 | typedef void __restorefn_t(void); 22 | typedef __restorefn_t __user *__sigrestore_t; 23 | 24 | #define SIG_DFL ((__force __sighandler_t)0) /* default signal handling */ 25 | #define SIG_IGN ((__force __sighandler_t)1) /* ignore signal */ 26 | #define SIG_ERR ((__force __sighandler_t)-1) /* error return from signal */ 27 | #endif 28 | 29 | #endif /* __ASM_GENERIC_SIGNAL_DEFS_H */ 30 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/sockios.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef __ASM_GENERIC_SOCKIOS_H 3 | #define __ASM_GENERIC_SOCKIOS_H 4 | 5 | /* Socket-level I/O control calls. */ 6 | #define FIOSETOWN 0x8901 7 | #define SIOCSPGRP 0x8902 8 | #define FIOGETOWN 0x8903 9 | #define SIOCGPGRP 0x8904 10 | #define SIOCATMARK 0x8905 11 | #define SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */ 12 | #define SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */ 13 | 14 | #endif /* __ASM_GENERIC_SOCKIOS_H */ 15 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/swab.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _ASM_GENERIC_SWAB_H 3 | #define _ASM_GENERIC_SWAB_H 4 | 5 | #include 6 | 7 | /* 8 | * 32 bit architectures typically (but not always) want to 9 | * set __SWAB_64_THRU_32__. In user space, this is only 10 | * valid if the compiler supports 64 bit data types. 11 | */ 12 | 13 | #if __BITS_PER_LONG == 32 14 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) 15 | #define __SWAB_64_THRU_32__ 16 | #endif 17 | #endif 18 | 19 | #endif /* _ASM_GENERIC_SWAB_H */ 20 | -------------------------------------------------------------------------------- /include/uapi/asm-generic/types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _ASM_GENERIC_TYPES_H 3 | #define _ASM_GENERIC_TYPES_H 4 | /* 5 | * int-ll64 is used everywhere now. 6 | */ 7 | #include 8 | 9 | #endif /* _ASM_GENERIC_TYPES_H */ 10 | -------------------------------------------------------------------------------- /include/uapi/linux/const.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* const.h: Macros for dealing with constants. */ 3 | 4 | #ifndef _UAPI_LINUX_CONST_H 5 | #define _UAPI_LINUX_CONST_H 6 | 7 | /* Some constant macros are used in both assembler and 8 | * C code. Therefore we cannot annotate them always with 9 | * 'UL' and other type specifiers unilaterally. We 10 | * use the following macros to deal with this. 11 | * 12 | * Similarly, _AT() will cast an expression with a type in C, but 13 | * leave it unchanged in asm. 14 | */ 15 | 16 | #ifdef __ASSEMBLY__ 17 | #define _AC(X,Y) X 18 | #define _AT(T,X) X 19 | #else 20 | #define __AC(X,Y) (X##Y) 21 | #define _AC(X,Y) __AC(X,Y) 22 | #define _AT(T,X) ((T)(X)) 23 | #endif 24 | 25 | #define _UL(x) (_AC(x, UL)) 26 | #define _ULL(x) (_AC(x, ULL)) 27 | 28 | #define _BITUL(x) (_UL(1) << (x)) 29 | #define _BITULL(x) (_ULL(1) << (x)) 30 | 31 | #endif /* _UAPI_LINUX_CONST_H */ 32 | -------------------------------------------------------------------------------- /include/uapi/linux/errno.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/uapi/linux/ioctl.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_IOCTL_H 3 | #define _LINUX_IOCTL_H 4 | 5 | #include 6 | 7 | #endif /* _LINUX_IOCTL_H */ 8 | 9 | -------------------------------------------------------------------------------- /include/uapi/linux/irqnr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * There isn't anything here anymore, but the file must not be empty or patch 3 | * will delete it. 4 | */ 5 | -------------------------------------------------------------------------------- /include/uapi/linux/kdev_t.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_KDEV_T_H 3 | #define _UAPI_LINUX_KDEV_T_H 4 | #ifndef __KERNEL__ 5 | 6 | /* 7 | Some programs want their definitions of MAJOR and MINOR and MKDEV 8 | from the kernel sources. These must be the externally visible ones. 9 | */ 10 | #define MAJOR(dev) ((dev)>>8) 11 | #define MINOR(dev) ((dev) & 0xff) 12 | #define MKDEV(ma,mi) ((ma)<<8 | (mi)) 13 | #endif /* __KERNEL__ */ 14 | #endif /* _UAPI_LINUX_KDEV_T_H */ 15 | -------------------------------------------------------------------------------- /include/uapi/linux/kernel.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_KERNEL_H 3 | #define _UAPI_LINUX_KERNEL_H 4 | 5 | #include 6 | 7 | /* 8 | * 'kernel.h' contains some often-used function prototypes etc 9 | */ 10 | #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) 11 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) 12 | 13 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) 14 | 15 | #endif /* _UAPI_LINUX_KERNEL_H */ 16 | -------------------------------------------------------------------------------- /include/uapi/linux/limits.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_LIMITS_H 3 | #define _UAPI_LINUX_LIMITS_H 4 | 5 | #define NR_OPEN 1024 6 | 7 | #define NGROUPS_MAX 65536 /* supplemental group IDs are available */ 8 | #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ 9 | #define LINK_MAX 127 /* # links a file may have */ 10 | #define MAX_CANON 255 /* size of the canonical input queue */ 11 | #define MAX_INPUT 255 /* size of the type-ahead buffer */ 12 | #define NAME_MAX 255 /* # chars in a file name */ 13 | #define PATH_MAX 4096 /* # chars in a path name including nul */ 14 | #define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */ 15 | #define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */ 16 | #define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */ 17 | #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ 18 | 19 | #define RTSIG_MAX 32 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/uapi/linux/openat2.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_OPENAT2_H 3 | #define _UAPI_LINUX_OPENAT2_H 4 | 5 | #include 6 | 7 | /* 8 | * Arguments for how openat2(2) should open the target path. If only @flags and 9 | * @mode are non-zero, then openat2(2) operates very similarly to openat(2). 10 | * 11 | * However, unlike openat(2), unknown or invalid bits in @flags result in 12 | * -EINVAL rather than being silently ignored. @mode must be zero unless one of 13 | * {O_CREAT, O_TMPFILE} are set. 14 | * 15 | * @flags: O_* flags. 16 | * @mode: O_CREAT/O_TMPFILE file mode. 17 | * @resolve: RESOLVE_* flags. 18 | */ 19 | struct open_how { 20 | __u64 flags; 21 | __u64 mode; 22 | __u64 resolve; 23 | }; 24 | 25 | /* how->resolve flags for openat2(2). */ 26 | #define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings 27 | (includes bind-mounts). */ 28 | #define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style 29 | "magic-links". */ 30 | #define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks 31 | (implies OEXT_NO_MAGICLINKS) */ 32 | #define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like 33 | "..", symlinks, and absolute 34 | paths which escape the dirfd. */ 35 | #define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".." 36 | be scoped inside the dirfd 37 | (similar to chroot(2)). */ 38 | 39 | #endif /* _UAPI_LINUX_OPENAT2_H */ 40 | -------------------------------------------------------------------------------- /include/uapi/linux/param.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_PARAM_H 3 | #define _LINUX_PARAM_H 4 | 5 | #include 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/uapi/linux/posix_types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_POSIX_TYPES_H 3 | #define _LINUX_POSIX_TYPES_H 4 | 5 | #include 6 | 7 | /* 8 | * This allows for 1024 file descriptors: if NR_OPEN is ever grown 9 | * beyond that you'll have to change this too. But 1024 fd's seem to be 10 | * enough even for such "real" unices like OSF/1, so hopefully this is 11 | * one limit that doesn't have to be changed [again]. 12 | * 13 | * Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in 14 | * (and thus ) - but this is a more logical 15 | * place for them. Solved by having dummy defines in . 16 | */ 17 | 18 | /* 19 | * This macro may have been defined in . But we always 20 | * use the one here. 21 | */ 22 | #undef __FD_SETSIZE 23 | #define __FD_SETSIZE 1024 24 | 25 | typedef struct { 26 | unsigned long fds_bits[__FD_SETSIZE / (8 * sizeof(long))]; 27 | } __kernel_fd_set; 28 | 29 | /* Type of a signal handler. */ 30 | typedef void (*__kernel_sighandler_t)(int); 31 | 32 | /* Type of a SYSV IPC key. */ 33 | typedef int __kernel_key_t; 34 | typedef int __kernel_mqd_t; 35 | 36 | #include 37 | 38 | #endif /* _LINUX_POSIX_TYPES_H */ 39 | -------------------------------------------------------------------------------- /include/uapi/linux/signal.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_SIGNAL_H 3 | #define _UAPI_LINUX_SIGNAL_H 4 | 5 | #include 6 | #include 7 | 8 | #define SS_ONSTACK 1 9 | #define SS_DISABLE 2 10 | 11 | /* bit-flags */ 12 | #define SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ 13 | /* mask for all SS_xxx flags */ 14 | #define SS_FLAG_BITS SS_AUTODISARM 15 | 16 | #endif /* _UAPI_LINUX_SIGNAL_H */ 17 | -------------------------------------------------------------------------------- /include/uapi/linux/socket.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_SOCKET_H 3 | #define _UAPI_LINUX_SOCKET_H 4 | 5 | /* 6 | * Desired design of maximum size and alignment (see RFC2553) 7 | */ 8 | #define _K_SS_MAXSIZE 128 /* Implementation specific max size */ 9 | 10 | typedef unsigned short __kernel_sa_family_t; 11 | 12 | /* 13 | * The definition uses anonymous union and struct in order to control the 14 | * default alignment. 15 | */ 16 | struct __kernel_sockaddr_storage { 17 | union { 18 | struct { 19 | __kernel_sa_family_t ss_family; /* address family */ 20 | /* Following field(s) are implementation specific */ 21 | char __data[_K_SS_MAXSIZE - sizeof(unsigned short)]; 22 | /* space to achieve desired size, */ 23 | /* _SS_MAXSIZE value minus size of ss_family */ 24 | }; 25 | void *__align; /* implementation specific desired alignment */ 26 | }; 27 | }; 28 | 29 | #endif /* _UAPI_LINUX_SOCKET_H */ 30 | -------------------------------------------------------------------------------- /include/uapi/linux/stddef.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #include 3 | 4 | #ifndef __always_inline 5 | #define __always_inline inline 6 | #endif 7 | -------------------------------------------------------------------------------- /include/uapi/linux/string.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_STRING_H_ 3 | #define _UAPI_LINUX_STRING_H_ 4 | 5 | /* We don't want strings.h stuff being used by user stuff by accident */ 6 | 7 | #ifndef __KERNEL__ 8 | #include 9 | #endif /* __KERNEL__ */ 10 | #endif /* _UAPI_LINUX_STRING_H_ */ 11 | -------------------------------------------------------------------------------- /include/uapi/linux/sysinfo.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_SYSINFO_H 3 | #define _LINUX_SYSINFO_H 4 | 5 | #include 6 | 7 | #define SI_LOAD_SHIFT 16 8 | struct sysinfo { 9 | __kernel_long_t uptime; /* Seconds since boot */ 10 | __kernel_ulong_t loads[3]; /* 1, 5, and 15 minute load averages */ 11 | __kernel_ulong_t totalram; /* Total usable main memory size */ 12 | __kernel_ulong_t freeram; /* Available memory size */ 13 | __kernel_ulong_t sharedram; /* Amount of shared memory */ 14 | __kernel_ulong_t bufferram; /* Memory used by buffers */ 15 | __kernel_ulong_t totalswap; /* Total swap space size */ 16 | __kernel_ulong_t freeswap; /* swap space still available */ 17 | __u16 procs; /* Number of current processes */ 18 | __u16 pad; /* Explicit padding for m68k */ 19 | __kernel_ulong_t totalhigh; /* Total high memory size */ 20 | __kernel_ulong_t freehigh; /* Available high memory size */ 21 | __u32 mem_unit; /* Memory unit size in bytes */ 22 | char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)]; /* Padding: libc5 uses this.. */ 23 | }; 24 | 25 | #endif /* _LINUX_SYSINFO_H */ 26 | -------------------------------------------------------------------------------- /include/uapi/linux/time_types.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_TIME_TYPES_H 3 | #define _UAPI_LINUX_TIME_TYPES_H 4 | 5 | #include 6 | 7 | struct __kernel_timespec { 8 | __kernel_time64_t tv_sec; /* seconds */ 9 | long long tv_nsec; /* nanoseconds */ 10 | }; 11 | 12 | struct __kernel_itimerspec { 13 | struct __kernel_timespec it_interval; /* timer period */ 14 | struct __kernel_timespec it_value; /* timer expiration */ 15 | }; 16 | 17 | /* 18 | * legacy timeval structure, only embedded in structures that 19 | * traditionally used 'timeval' to pass time intervals (not absolute 20 | * times). Do not add new users. If user space fails to compile 21 | * here, this is probably because it is not y2038 safe and needs to 22 | * be changed to use another interface. 23 | */ 24 | #ifndef __kernel_old_timeval 25 | struct __kernel_old_timeval { 26 | __kernel_long_t tv_sec; 27 | __kernel_long_t tv_usec; 28 | }; 29 | #endif 30 | 31 | struct __kernel_old_timespec { 32 | __kernel_old_time_t tv_sec; /* seconds */ 33 | long tv_nsec; /* nanoseconds */ 34 | }; 35 | 36 | struct __kernel_old_itimerval { 37 | struct __kernel_old_timeval it_interval;/* timer interval */ 38 | struct __kernel_old_timeval it_value; /* current value */ 39 | }; 40 | 41 | struct __kernel_sock_timeval { 42 | __s64 tv_sec; 43 | __s64 tv_usec; 44 | }; 45 | 46 | #endif /* _UAPI_LINUX_TIME_TYPES_H */ 47 | -------------------------------------------------------------------------------- /include/uapi/linux/uio.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 | /* 3 | * Berkeley style UIO structures - Alan Cox 1994. 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 8 | * 2 of the License, or (at your option) any later version. 9 | */ 10 | #ifndef _UAPI__LINUX_UIO_H 11 | #define _UAPI__LINUX_UIO_H 12 | 13 | #include 14 | #include 15 | 16 | 17 | struct iovec 18 | { 19 | void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ 20 | __kernel_size_t iov_len; /* Must be size_t (1003.1g) */ 21 | }; 22 | 23 | /* 24 | * UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1) 25 | */ 26 | 27 | #define UIO_FASTIOV 8 28 | #define UIO_MAXIOV 1024 29 | 30 | 31 | #endif /* _UAPI__LINUX_UIO_H */ 32 | -------------------------------------------------------------------------------- /include/uapi/linux/unistd.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _LINUX_UNISTD_H_ 3 | #define _LINUX_UNISTD_H_ 4 | 5 | /* 6 | * Include machine specific syscall numbers 7 | */ 8 | #include 9 | 10 | #endif /* _LINUX_UNISTD_H_ */ 11 | -------------------------------------------------------------------------------- /include/uapi/linux/uuid.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | /* 3 | * UUID/GUID definition 4 | * 5 | * Copyright (C) 2010, Intel Corp. 6 | * Huang Ying 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License version 10 | * 2 as published by the Free Software Foundation; 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | 18 | #ifndef _UAPI_LINUX_UUID_H_ 19 | #define _UAPI_LINUX_UUID_H_ 20 | 21 | #include 22 | 23 | typedef struct { 24 | __u8 b[16]; 25 | } guid_t; 26 | 27 | #define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 28 | ((guid_t) \ 29 | {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 30 | (b) & 0xff, ((b) >> 8) & 0xff, \ 31 | (c) & 0xff, ((c) >> 8) & 0xff, \ 32 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 33 | 34 | /* backwards compatibility, don't use in new code */ 35 | typedef guid_t uuid_le; 36 | #define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 37 | GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) 38 | #define NULL_UUID_LE \ 39 | UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 40 | 0x00, 0x00, 0x00, 0x00) 41 | 42 | #endif /* _UAPI_LINUX_UUID_H_ */ 43 | -------------------------------------------------------------------------------- /include/uapi/linux/wait.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 | #ifndef _UAPI_LINUX_WAIT_H 3 | #define _UAPI_LINUX_WAIT_H 4 | 5 | #define WNOHANG 0x00000001 6 | #define WUNTRACED 0x00000002 7 | #define WSTOPPED WUNTRACED 8 | #define WEXITED 0x00000004 9 | #define WCONTINUED 0x00000008 10 | #define WNOWAIT 0x01000000 /* Don't reap, just poll status. */ 11 | 12 | #define __WNOTHREAD 0x20000000 /* Don't wait on children of other threads in this group */ 13 | #define __WALL 0x40000000 /* Wait on all children, regardless of type */ 14 | #define __WCLONE 0x80000000 /* Wait only on non-SIGCHLD children */ 15 | 16 | /* First argument to waitid: */ 17 | #define P_ALL 0 18 | #define P_PID 1 19 | #define P_PGID 2 20 | #define P_PIDFD 3 21 | 22 | 23 | #endif /* _UAPI_LINUX_WAIT_H */ 24 | -------------------------------------------------------------------------------- /include/vdso/bits.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_BITS_H 3 | #define __VDSO_BITS_H 4 | 5 | #include 6 | 7 | #define BIT(nr) (UL(1) << (nr)) 8 | 9 | #endif /* __VDSO_BITS_H */ 10 | -------------------------------------------------------------------------------- /include/vdso/const.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_CONST_H 3 | #define __VDSO_CONST_H 4 | 5 | #include 6 | 7 | #define UL(x) (_UL(x)) 8 | #define ULL(x) (_ULL(x)) 9 | 10 | #endif /* __VDSO_CONST_H */ 11 | -------------------------------------------------------------------------------- /include/vdso/jiffies.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_JIFFIES_H 3 | #define __VDSO_JIFFIES_H 4 | 5 | #include /* for HZ */ 6 | #include 7 | 8 | /* TICK_NSEC is the time between ticks in nsec assuming SHIFTED_HZ */ 9 | #define TICK_NSEC ((NSEC_PER_SEC+HZ/2)/HZ) 10 | 11 | #endif /* __VDSO_JIFFIES_H */ 12 | -------------------------------------------------------------------------------- /include/vdso/ktime.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_KTIME_H 3 | #define __VDSO_KTIME_H 4 | 5 | #include 6 | 7 | /* 8 | * The resolution of the clocks. The resolution value is returned in 9 | * the clock_getres() system call to give application programmers an 10 | * idea of the (in)accuracy of timers. Timer values are rounded up to 11 | * this resolution values. 12 | */ 13 | #define LOW_RES_NSEC TICK_NSEC 14 | #define KTIME_LOW_RES (LOW_RES_NSEC) 15 | 16 | #endif /* __VDSO_KTIME_H */ 17 | -------------------------------------------------------------------------------- /include/vdso/limits.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_LIMITS_H 3 | #define __VDSO_LIMITS_H 4 | 5 | #define USHRT_MAX ((unsigned short)~0U) 6 | #define SHRT_MAX ((short)(USHRT_MAX >> 1)) 7 | #define SHRT_MIN ((short)(-SHRT_MAX - 1)) 8 | #define INT_MAX ((int)(~0U >> 1)) 9 | #define INT_MIN (-INT_MAX - 1) 10 | #define UINT_MAX (~0U) 11 | #define LONG_MAX ((long)(~0UL >> 1)) 12 | #define LONG_MIN (-LONG_MAX - 1) 13 | #define ULONG_MAX (~0UL) 14 | #define LLONG_MAX ((long long)(~0ULL >> 1)) 15 | #define LLONG_MIN (-LLONG_MAX - 1) 16 | #define ULLONG_MAX (~0ULL) 17 | #define UINTPTR_MAX ULONG_MAX 18 | 19 | #endif /* __VDSO_LIMITS_H */ 20 | -------------------------------------------------------------------------------- /include/vdso/math64.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_MATH64_H 3 | #define __VDSO_MATH64_H 4 | 5 | static __always_inline u32 6 | __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) 7 | { 8 | u32 ret = 0; 9 | 10 | while (dividend >= divisor) { 11 | /* The following asm() prevents the compiler from 12 | optimising this loop into a modulo operation. */ 13 | asm("" : "+rm"(dividend)); 14 | 15 | dividend -= divisor; 16 | ret++; 17 | } 18 | 19 | *remainder = dividend; 20 | 21 | return ret; 22 | } 23 | 24 | #endif /* __VDSO_MATH64_H */ 25 | -------------------------------------------------------------------------------- /include/vdso/processor.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Copyright (C) 2020 ARM Ltd. 4 | */ 5 | #ifndef __VDSO_PROCESSOR_H 6 | #define __VDSO_PROCESSOR_H 7 | 8 | #ifndef __ASSEMBLY__ 9 | 10 | #include 11 | 12 | #endif /* __ASSEMBLY__ */ 13 | 14 | #endif /* __VDSO_PROCESSOR_H */ 15 | -------------------------------------------------------------------------------- /include/vdso/time.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_TIME_H 3 | #define __VDSO_TIME_H 4 | 5 | #include 6 | 7 | struct timens_offset { 8 | s64 sec; 9 | u64 nsec; 10 | }; 11 | 12 | #endif /* __VDSO_TIME_H */ 13 | -------------------------------------------------------------------------------- /include/vdso/time32.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_TIME32_H 3 | #define __VDSO_TIME32_H 4 | 5 | typedef s32 old_time32_t; 6 | 7 | struct old_timespec32 { 8 | old_time32_t tv_sec; 9 | s32 tv_nsec; 10 | }; 11 | 12 | struct old_timeval32 { 13 | old_time32_t tv_sec; 14 | s32 tv_usec; 15 | }; 16 | 17 | #endif /* __VDSO_TIME32_H */ 18 | -------------------------------------------------------------------------------- /include/vdso/time64.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __VDSO_TIME64_H 3 | #define __VDSO_TIME64_H 4 | 5 | /* Parameters used to convert the timespec values: */ 6 | #define MSEC_PER_SEC 1000L 7 | #define USEC_PER_MSEC 1000L 8 | #define NSEC_PER_USEC 1000L 9 | #define NSEC_PER_MSEC 1000000L 10 | #define USEC_PER_SEC 1000000L 11 | #define NSEC_PER_SEC 1000000000L 12 | #define FSEC_PER_SEC 1000000000000000LL 13 | 14 | #endif /* __VDSO_TIME64_H */ 15 | -------------------------------------------------------------------------------- /lean/.gitignore: -------------------------------------------------------------------------------- 1 | *.olean 2 | /_target 3 | /leanpkg.path 4 | -------------------------------------------------------------------------------- /lean/attic/bitvec-ind/bv/helper.lean: -------------------------------------------------------------------------------- 1 | -- nat helpers 2 | 3 | import data.nat.basic 4 | import data.num.basic 5 | import data.num.lemmas 6 | import data.int.modeq 7 | import tactic.ring 8 | 9 | namespace bv.helper 10 | open nat 11 | 12 | lemma pow2_succ (n : ℕ) : 2^(succ n) = 2 * 2^n := 13 | by simp [nat.pow_succ, mul_comm] 14 | 15 | lemma pow2_pos (n : ℕ) : 2^n > 0 := 16 | pos_pow_of_pos _ two_pos 17 | 18 | lemma pow2_succ_gt (n : ℕ) : 2^(succ n) > 1 := 19 | calc 20 | 2^(succ n) > (2^0) : by { apply nat.pow_lt_pow_of_lt_right, 21 | apply nat.lt_succ_self, 22 | apply nat.zero_lt_succ } 23 | ... = 1 : by simp 24 | 25 | lemma bit_div_two (b : bool) (n : ℕ) : bit b n / 2 = n := 26 | begin 27 | cases b; simp [bit_val], 28 | simp [add_comm, add_mul_div_left _ _ two_pos, div_eq_of_lt] 29 | end 30 | 31 | lemma bit_mod_two (b : bool) (n : ℕ) : bit b n % 2 = cond b 1 0 := 32 | begin 33 | cases b; simp [bit_val], 34 | simp [add_comm, add_mul_mod_self_left, mod_eq_of_lt] 35 | end 36 | 37 | lemma bit0_pow2 (n : ℕ): bit0 (2^n) = 2^n.succ := 38 | by rw [pow2_succ, bit0_val (2^n)] 39 | 40 | lemma bit1_pow2_sub_one (n : ℕ) : bit1 (2^n - 1) = 2^n.succ - 1 := 41 | calc 42 | bit1 (2^n - 1) = 2 * (2^n - 1) + 1 : by rw bit1_val 43 | ... = 2^n.succ - 2 + 1 : by simp [nat.mul_sub_left_distrib, pow2_succ] 44 | ... = 2^n.succ - 1 : by { rw ← nat.sub_sub_assoc; try { simp }, 45 | apply pow2_succ_gt } 46 | 47 | end bv.helper 48 | -------------------------------------------------------------------------------- /lean/leanpkg.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "jitterbug" 3 | version = "0.1" 4 | lean_version = "leanprover-community/lean:3.51.1" 5 | path = "src" 6 | 7 | [dependencies] 8 | mathlib = {git = "https://github.com/leanprover-community/mathlib", rev = "lean-3.51.1"} 9 | -------------------------------------------------------------------------------- /lean/src/bv/helper.lean: -------------------------------------------------------------------------------- 1 | import tactic.basic 2 | import tactic.linarith.frontend 3 | import tactic.ring_exp 4 | 5 | namespace bv.helper 6 | open nat 7 | 8 | lemma pow2_succ (n : ℕ) : 2^(succ n) = 2 * 2^n := 9 | by simp [pow_succ, mul_comm] 10 | 11 | lemma pow2_pos (n : ℕ) : 2^n > 0 := 12 | pow_pos two_pos n 13 | 14 | @[simp] 15 | lemma bit_div_two (b : bool) (n : ℕ) : bit b n / 2 = n := 16 | by rw [← nat.div2_val, nat.div2_bit] 17 | 18 | @[simp] 19 | lemma bit_mod_two (b : bool) (n : ℕ) : bit b n % 2 = cond b 1 0 := 20 | by rw [nat.mod_two_of_bodd, nat.bodd_bit] 21 | 22 | lemma int.sub_mod_self (a b : ℤ) : 23 | (a - b) % b = a % b := 24 | by simp [int.sub_mod, int.mod_self] 25 | 26 | end bv.helper 27 | -------------------------------------------------------------------------------- /racket/lib/env.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide (all-defined-out)) 4 | 5 | ; Boolean flags that act as parameters in Racket but can be controlled 6 | ; using environment variables. 7 | (define (make-environment-flag env-varname default) 8 | (define env-var (getenv env-varname)) 9 | (define value 10 | (cond 11 | [(false? env-var) default] 12 | [(member (string-downcase env-var) (list "false" "#f" "0")) 13 | #f] 14 | [(member (string-downcase env-var) (list "true" "#t" "1")) 15 | #t] 16 | [else ; Reject anything else 17 | (error "Environment variable flags must be truthy or falsey: [false, #f, 0, true, #t, 1]")])) 18 | (eprintf "~a=~v\n" env-varname value) 19 | (make-parameter value)) 20 | -------------------------------------------------------------------------------- /racket/lib/patch.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide BUG PATCH PATCH-TEST with-jit-bug) 4 | 5 | (define jit-bug (make-parameter #f)) 6 | 7 | (define-syntax-rule (BUG body ...) 8 | (when (jit-bug) 9 | body ...)) 10 | 11 | (define-syntax-rule (PATCH body ...) 12 | (unless (jit-bug) 13 | body ...)) 14 | 15 | (define-syntax-rule (PATCH-TEST expr) 16 | (and (not (jit-bug)) expr)) 17 | 18 | (define-syntax-rule (with-jit-bug body ...) 19 | (parameterize ([jit-bug #t]) 20 | body ...)) 21 | -------------------------------------------------------------------------------- /racket/riscv/encoding/gen.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require web-server/templates 4 | "bpf_jit.generated.c.rkt") 5 | 6 | (displayln (include-template "bpf_jit.h.tmpl")) 7 | -------------------------------------------------------------------------------- /racket/riscv/rv32/gen.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require web-server/templates 4 | "bpf_jit_comp32.generated.c.rkt") 5 | 6 | (displayln (include-template "bpf_jit_comp32.c.tmpl")) 7 | -------------------------------------------------------------------------------- /racket/stacklang/.gitignore: -------------------------------------------------------------------------------- 1 | /jit 2 | -------------------------------------------------------------------------------- /racket/stacklang/gcd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR=$(dirname "${BASH_SOURCE[0]}") 4 | cc -o "$DIR"/jit "$DIR"/main.c "$DIR"/jit.c 5 | "$DIR"/jit "=6<4-j0sj0." "$@" 6 | -------------------------------------------------------------------------------- /racket/stacklang/gen.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require web-server/templates 4 | "jit.generated.c.rkt") 5 | 6 | (displayln (include-template "jit.c.tmpl")) 7 | -------------------------------------------------------------------------------- /racket/stacklang/jit.c: -------------------------------------------------------------------------------- 1 | #include "jit.h" 2 | 3 | void emit_insn(int idx, char *insn, int *addrs, struct jit_context *ctx) 4 | { 5 | int base = addrs[idx]; 6 | int opcode = opcodeof(insn); 7 | 8 | switch (opcode) { 9 | case POP: 10 | /* mov eax,[edi] */ 11 | EMIT2(0x8B, 0x07); 12 | /* add edi,4 */ 13 | EMIT3(0x83, 0xC7, 0x04); 14 | break; 15 | case SUB: 16 | /* sub eax,[edi] */ 17 | EMIT2(0x2B, 0x07); 18 | break; 19 | case SWAP: 20 | /* xchg [edi],eax */ 21 | EMIT2(0x87, 0x07); 22 | break; 23 | case PUSH: 24 | /* sub edi,4 */ 25 | EMIT3(0x83, 0xEF, 0x04); 26 | /* mov [edi],eax */ 27 | EMIT2(0x89, 0x07); 28 | /* mov eax,imm32 */ 29 | EMIT1(0xB8); 30 | EMIT(immof(insn), 4); 31 | break; 32 | case JUMP: 33 | /* jmp off32 */ 34 | EMIT1(0xE9); 35 | EMIT(addrs[immof(insn)] - base - 5, 4); 36 | break; 37 | case JEQ: 38 | /* cmp eax,[edi] */ 39 | EMIT2(0x3B, 0x07); 40 | /* je off32 */ 41 | EMIT2(0x0F, 0x84); 42 | if (inject_bugs()) 43 | EMIT(addrs[immof(insn)] - base - 5, 4); 44 | else 45 | EMIT(addrs[immof(insn)] - base - 8, 4); 46 | break; 47 | case JLT: 48 | /* cmp eax,[edi] */ 49 | EMIT2(0x3B, 0x07); 50 | /* jb off32 */ 51 | EMIT2(0x0F, 0x82); 52 | EMIT(addrs[immof(insn)] - base - 8, 4); 53 | break; 54 | case STOP: 55 | /* jmp edx */ 56 | EMIT2(0xFF, 0xE2); 57 | break; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /racket/stacklang/jit.c.tmpl: -------------------------------------------------------------------------------- 1 | // clang-format off 2 | #include "jit.h" 3 | 4 | void emit_insn(int idx, char *insn, int *addrs, struct jit_context *ctx) 5 | { 6 | // clang-format on 7 | @|emit_insn| 8 | // clang-format off 9 | } 10 | -------------------------------------------------------------------------------- /racket/stacklang/jit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define INJECT_BUGS 0 7 | 8 | #define EMIT(v, n) emit_code(ctx, v, n) 9 | #define EMIT1(b0) EMIT(b0, 1) 10 | #define EMIT2(b0, b1) EMIT((b0) + (b1 << 8), 2) 11 | #define EMIT3(b0, b1, b2) EMIT((b0) + ((b1) << 8) + ((b2) << 16), 3) 12 | 13 | struct jit_context { 14 | size_t ninsns; 15 | uint8_t *insns; 16 | int *addrs; 17 | }; 18 | 19 | enum { 20 | POP = 'p', 21 | SUB = '-', 22 | SWAP = 's', 23 | PUSH = 'c', 24 | JUMP = 'j', 25 | JEQ = '=', 26 | JLT = '<', 27 | STOP = '.', 28 | }; 29 | 30 | static inline int opcodeof(char *insn) 31 | { 32 | return insn[0]; 33 | } 34 | 35 | static inline int immof(char *insn) 36 | { 37 | return insn[1] - '0'; 38 | } 39 | 40 | static inline int has_imm(char opcode) 41 | { 42 | switch (opcode) { 43 | case PUSH: 44 | case JUMP: 45 | case JEQ: 46 | case JLT: 47 | return 1; 48 | default: 49 | return 0; 50 | } 51 | } 52 | 53 | static inline int inject_bugs(void) 54 | { 55 | return INJECT_BUGS; 56 | } 57 | 58 | static inline void emit_code(struct jit_context *ctx, uint32_t v, size_t len) 59 | { 60 | memcpy(ctx->insns + ctx->ninsns, &v, len); 61 | ctx->ninsns += len; 62 | } 63 | 64 | void emit_insn(int idx, char *insn, int *addrs, struct jit_context *ctx); 65 | -------------------------------------------------------------------------------- /racket/test/arm32/bugs.rkt: -------------------------------------------------------------------------------- 1 | #lang rosette 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit) 6 | (prefix-in bpf: serval/bpf) 7 | serval/lib/unittest) 8 | 9 | (define (check-shift info) 10 | (define insn (dict-ref info 'bpf-insn)) 11 | (define imm (bpf:insn-imm insn)) 12 | ; The bug is triggered when the shifting amount is zero. 13 | (check-equal? imm (bv 0 32))) 14 | 15 | (module+ test 16 | (time (test-bugs "arm32 bugs" check-jit 17 | ; https://git.kernel.org/linus/bb9562cf5c67 18 | ['(BPF_ALU64 BPF_RSH BPF_K) check-shift] 19 | ['(BPF_ALU64 BPF_ARSH BPF_K) check-shift]))) 20 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-alu32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-k "arm32-alu32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-alu32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-x "arm32-alu32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-alu64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-k "arm32-alu64-k tests" check-jit 9 | #:selector skip-div+mod))) 10 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-alu64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-x "arm32-alu64-x tests" check-jit 9 | #:selector skip-div+mod))) 10 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-endian.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-endian "arm32-endian tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-epilogue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-epilogue "arm32-epilogue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-jmp-call.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | "../../lib/hybrid-memory.rkt" 6 | (only-in "../../arm32/spec.rkt" check-jit)) 7 | 8 | (module+ test 9 | (time 10 | (parameterize ([enable-stack-addr-symopt #f]) 11 | (verify-jmp-call "arm32-jmp-call tests" check-jit)))) -------------------------------------------------------------------------------- /racket/test/arm32/verify-jmp32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-k "arm32-jmp32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-jmp32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-x "arm32-jmp32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-jmp64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-k "arm32-jmp64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-jmp64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-x "arm32-jmp64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-ld-imm.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ld-imm "arm32-ld-imm tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-ldx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ldx-mem "arm32-ldx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-prologue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-prologue "arm32-prologue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-st-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-st-mem "arm32-st-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm32/verify-stx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-mem "arm32-stx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/test-logic-imm.rkt: -------------------------------------------------------------------------------- 1 | #lang rosette 2 | 3 | (require 4 | (only-in rackunit check-equal? check-not-false) 5 | serval/lib/unittest 6 | (only-in serval/arm64/interp/common decode-bit-masks) 7 | (only-in "../../arm64/insn.rkt" encode-logical-immediate) 8 | "logic-imm.rkt") 9 | 10 | (define (check-decode) 11 | (for ([e data]) 12 | (match-define (list exp-val (list n immr imms)) e) 13 | (define (proc m) 14 | (define-values (act-val _) (decode-bit-masks m (bv n 1) (bv imms 6) (bv immr 6) #t)) 15 | (check-equal? act-val (bv exp-val m))) 16 | (proc 64) 17 | (when (zero? n) 18 | (proc 32)))) 19 | 20 | (define (check-encode) 21 | (for ([e data]) 22 | (match-define (list x (list exp-n exp-immr exp-imms)) e) 23 | (define (proc m) 24 | (define lst (encode-logical-immediate (zero-extend (bv x m) (bitvector 64)) (bool->bitvector (= m 64)))) 25 | (check-not-false lst) 26 | (match-define (list act-n act-immr act-imms) lst) 27 | (check-equal? act-n (bv exp-n 1) "n") 28 | (check-equal? act-immr (bv exp-immr 6) "immr") 29 | (check-equal? act-imms (bv exp-imms 6) "imms")) 30 | (proc 64) 31 | (when (zero? exp-n) 32 | (proc 32)))) 33 | 34 | (define tests 35 | (test-suite+ "arm64-logic-imm tests" 36 | (test-case+ 37 | "decode" 38 | (check-decode)) 39 | (test-case+ 40 | "encode" 41 | (check-encode)))) 42 | 43 | (module+ test 44 | (time (run-tests tests))) 45 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-alu32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-k "arm64-alu32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-alu32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-x "arm64-alu32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-alu64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-k "arm64-alu64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-alu64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-x "arm64-alu64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-endian.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-endian "arm64-endian tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-epilogue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-epilogue "arm64-epilogue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-jmp-call.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp-call "arm64-jmp-call tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-jmp32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-k "arm64-jmp32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-jmp32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-x "arm64-jmp32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-jmp64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-k "arm64-jmp64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-jmp64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-x "arm64-jmp64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-ld-imm.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ld-imm "arm64-ld-imm tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-ldx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ldx-mem "arm64-ldx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-prologue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-prologue "arm64-prologue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-st-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-st-mem "arm64-st-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-stx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-mem "arm64-stx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/arm64/verify-stx-xadd.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../arm64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-xadd "arm64-stx-xadd tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/synthesize-alu32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "../../riscv/rv32/spec.rkt" "../../riscv/rv32/synthesis.rkt") 4 | (require serval/lib/unittest) 5 | 6 | (define tests 7 | (test-suite+ 8 | "riscv32-alu32-x synthesis" 9 | ; (jit-verify-case '(BPF_ALU BPF_END BPF_FROM_BE)) 10 | ; (jit-verify-case '(BPF_ALU BPF_END BPF_FROM_LE)) 11 | 12 | (jit-synthesize-case '(BPF_ALU BPF_MOV BPF_X)) 13 | ; (jit-synthesize-case '(BPF_ALU BPF_ADD BPF_X)) 14 | ; (jit-synthesize-case '(BPF_ALU BPF_SUB BPF_X)) 15 | (jit-synthesize-case '(BPF_ALU BPF_AND BPF_X)) 16 | (jit-synthesize-case '(BPF_ALU BPF_OR BPF_X)) 17 | (jit-synthesize-case '(BPF_ALU BPF_XOR BPF_X)) 18 | ; (jit-synthesize-case '(BPF_ALU BPF_MUL BPF_X)) 19 | ; (jit-synthesize-case '(BPF_ALU BPF_DIV BPF_X)) 20 | ; (jit-synthesize-case '(BPF_ALU BPF_MOD BPF_X)) 21 | ; (jit-synthesize-case '(BPF_ALU BPF_LSH BPF_X)) 22 | ; (jit-synthesize-case '(BPF_ALU BPF_RSH BPF_X)) 23 | ; (jit-synthesize-case '(BPF_ALU BPF_ARSH BPF_X)) 24 | ; (jit-synthesize-case '(BPF_ALU BPF_NEG)) 25 | )) 26 | 27 | (module+ test 28 | (time (run-tests tests))) 29 | -------------------------------------------------------------------------------- /racket/test/rv32/synthesize-alu64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "../../riscv/rv32/spec.rkt" "../../riscv/rv32/synthesis.rkt") 4 | (require serval/lib/unittest) 5 | 6 | (define tests 7 | (test-suite+ 8 | "riscv32-alu64-x synthesis" 9 | 10 | (jit-synthesize-case '(BPF_ALU64 BPF_MOV BPF_X)) 11 | ; (jit-synthesize-case '(BPF_ALU64 BPF_ADD BPF_X)) 12 | ; (jit-synthesize-case '(BPF_ALU64 BPF_SUB BPF_X)) 13 | ; (jit-synthesize-case '(BPF_ALU64 BPF_AND BPF_X)) 14 | ; (jit-synthesize-case '(BPF_ALU64 BPF_OR BPF_X)) 15 | ; (jit-synthesize-case '(BPF_ALU64 BPF_XOR BPF_X)) 16 | ; (jit-synthesize-case '(BPF_ALU64 BPF_MUL BPF_X)) 17 | ; (jit-synthesize-case '(BPF_ALU64 BPF_DIV BPF_X)) 18 | ; (jit-synthesize-case '(BPF_ALU64 BPF_MOD BPF_X)) 19 | ; (jit-synthesize-case '(BPF_ALU64 BPF_LSH BPF_X)) 20 | ; (jit-synthesize-case '(BPF_ALU64 BPF_RSH BPF_X)) 21 | ; (jit-synthesize-case '(BPF_ALU64 BPF_ARSH BPF_X)) 22 | ; (jit-synthesize-case '(BPF_ALU64 BPF_NEG)) 23 | )) 24 | 25 | (module+ test 26 | (time (run-tests tests))) 27 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-alu32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-k "riscv32-alu32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-alu32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-x "riscv32-alu32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-alu64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-k "riscv32-alu64-k tests" check-jit 9 | #:selector skip-div+mod))) 10 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-alu64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-x "riscv32-alu64-x tests" check-jit 9 | #:selector skip-div+mod))) 10 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-endian.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-endian "riscv32-endian tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-epilogue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-epilogue "riscv32-epilogue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-jmp-call.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp-call "riscv32-jmp-call tests" check-jit #:selector verify-all))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-jmp32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-k "riscv32-jmp32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-jmp32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-x "riscv32-jmp32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-jmp64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-k "riscv32-jmp64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-jmp64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-x "riscv32-jmp64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-ld-imm.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ld-imm "riscv32-ld-imm tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-ldx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ldx-mem "riscv32-ldx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-prologue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-prologue "riscv32-prologue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-st-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-st-mem "riscv32-st-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-stx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-mem "riscv32-stx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv32/verify-stx-xadd.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-xadd "riscv32-stx-xadd tests" check-jit 9 | #:selector skip-dw-mem))) 10 | -------------------------------------------------------------------------------- /racket/test/rv64/bugs.rkt: -------------------------------------------------------------------------------- 1 | #lang rosette 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit) 6 | (prefix-in bpf: serval/bpf) 7 | serval/lib/unittest) 8 | 9 | (define (check-alu32 info) 10 | (define insn (dict-ref info 'bpf-insn)) 11 | (define final-bpf-regs (dict-ref info 'final-bpf-regs)) 12 | (define dst (bpf:insn-dst insn)) 13 | (define dstval (bpf:@reg-ref final-bpf-regs dst)) 14 | ; The bug is triggered when the upper half of the result is zero in BPF 15 | ; but non-zero in target (which we are not checking yet). 16 | (check-equal? (extract 63 32 dstval) (bv 0 32))) 17 | 18 | (module+ test 19 | (time (test-bugs "rv64 bugs" check-jit 20 | ; https://git.kernel.org/linus/1e692f09e091 21 | ['(BPF_ALU BPF_ADD BPF_X) check-alu32] 22 | ['(BPF_ALU BPF_SUB BPF_X) check-alu32] 23 | ['(BPF_ALU BPF_LSH BPF_X) check-alu32] 24 | ['(BPF_ALU BPF_RSH BPF_X) check-alu32] 25 | ['(BPF_ALU BPF_ARSH BPF_X) check-alu32] 26 | ['(BPF_ALU BPF_NEG) check-alu32] 27 | ['(BPF_ALU BPF_LSH BPF_K) check-alu32] 28 | ['(BPF_ALU BPF_RSH BPF_K) check-alu32] 29 | ['(BPF_ALU BPF_ARSH BPF_K) check-alu32] 30 | ; https://git.kernel.org/linus/fe121ee531d1 31 | ['(BPF_ALU BPF_AND BPF_X) check-alu32] 32 | ['(BPF_ALU BPF_OR BPF_X) check-alu32] 33 | ['(BPF_ALU BPF_XOR BPF_X) check-alu32] 34 | ))) 35 | -------------------------------------------------------------------------------- /racket/test/rv64/synthesize-alu32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "../../riscv/rv64/spec.rkt" "../../riscv/rv64/synthesis.rkt") 4 | (require serval/lib/unittest) 5 | 6 | ;;; (define tests 7 | ;;; (test-suite+ 8 | ;;; "riscv64-alu32-x synthesis" 9 | 10 | ;;; (jit-synthesize-case '(BPF_ALU BPF_MOV BPF_X)) 11 | ;;; (jit-synthesize-case '(BPF_ALU BPF_ADD BPF_X)) 12 | ;;; (jit-synthesize-case '(BPF_ALU BPF_SUB BPF_X)) 13 | ;;; (jit-synthesize-case '(BPF_ALU BPF_AND BPF_X)) 14 | ;;; (jit-synthesize-case '(BPF_ALU BPF_OR BPF_X)) 15 | ;;; (jit-synthesize-case '(BPF_ALU BPF_XOR BPF_X)) 16 | ;;; ; (jit-synthesize-case '(BPF_ALU BPF_MUL BPF_X)) 17 | ;;; ; (jit-synthesize-case '(BPF_ALU BPF_DIV BPF_X)) 18 | ;;; ; (jit-synthesize-case '(BPF_ALU BPF_MOD BPF_X)) 19 | ;;; ; (jit-synthesize-case '(BPF_ALU BPF_LSH BPF_X)) 20 | ;;; ; (jit-synthesize-case '(BPF_ALU BPF_RSH BPF_X)) 21 | ;;; ; (jit-synthesize-case '(BPF_ALU BPF_ARSH BPF_X)) 22 | ;;; ; (jit-synthesize-case '(BPF_ALU BPF_NEG)) 23 | ;;; )) 24 | 25 | (module+ test (void)) 26 | ;;; (time (run-tests tests))) 27 | -------------------------------------------------------------------------------- /racket/test/rv64/synthesize-alu64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "../../riscv/rv64/spec.rkt" "../../riscv/rv64/synthesis.rkt") 4 | (require serval/lib/unittest) 5 | 6 | ;;; (define tests 7 | ;;; (test-suite+ 8 | ;;; "riscv64-alu64-x synthesis" 9 | 10 | ;;; (jit-synthesize-case '(BPF_ALU64 BPF_MOV BPF_X)) 11 | ;;; (jit-synthesize-case '(BPF_ALU64 BPF_ADD BPF_X)) 12 | ;;; (jit-synthesize-case '(BPF_ALU64 BPF_SUB BPF_X)) 13 | ;;; (jit-synthesize-case '(BPF_ALU64 BPF_AND BPF_X)) 14 | ;;; (jit-synthesize-case '(BPF_ALU64 BPF_OR BPF_X)) 15 | ;;; (jit-synthesize-case '(BPF_ALU64 BPF_XOR BPF_X)) 16 | ;;; ; (jit-synthesize-case '(BPF_ALU64 BPF_MUL BPF_X)) 17 | ;;; ; (jit-synthesize-case '(BPF_ALU64 BPF_DIV BPF_X)) 18 | ;;; ; (jit-synthesize-case '(BPF_ALU64 BPF_MOD BPF_X)) 19 | ;;; ; (jit-synthesize-case '(BPF_ALU64 BPF_LSH BPF_X)) 20 | ;;; ; (jit-synthesize-case '(BPF_ALU64 BPF_RSH BPF_X)) 21 | ;;; ; (jit-synthesize-case '(BPF_ALU64 BPF_ARSH BPF_X)) 22 | ;;; ; (jit-synthesize-case '(BPF_ALU64 BPF_NEG)) 23 | ;;; )) 24 | 25 | (module+ test (void)) 26 | ;;; (time (run-tests tests))) 27 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-alu32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-k "riscv64-alu32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-alu32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-x "riscv64-alu32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-alu64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-k "riscv64-alu64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-alu64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-x "riscv64-alu64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-endian.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-endian "riscv64-endian tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-epilogue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-epilogue "riscv64-epilogue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-jmp-call.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp-call "riscv64-jmp-call tests" check-jit #:selector skip-tail-call))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-jmp32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-k "riscv64-jmp32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-jmp32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-x "riscv64-jmp32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-jmp64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-k "riscv64-jmp64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-jmp64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-x "riscv64-jmp64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-ld-imm.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ld-imm "riscv64-ld-imm tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-ldx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ldx-mem "riscv64-ldx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-prologue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-prologue "riscv64-prologue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-st-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-st-mem "riscv64-st-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-stx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-mem "riscv64-stx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/rv64/verify-stx-xadd.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../riscv/rv64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-xadd "riscv64-stx-xadd tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/stacklang/test-gcd.rkt: -------------------------------------------------------------------------------- 1 | #lang rosette 2 | 3 | (require 4 | serval/lib/unittest) 5 | 6 | (define cmd (find-executable-path "../../stacklang/gcd.sh")) 7 | 8 | (define (gcd-jitted x y) 9 | (define result 10 | (with-output-to-string (lambda () (system* cmd (~a x) (~a y))))) 11 | (define act (string->number (last (string-split result)))) 12 | (define exp (gcd x y)) 13 | (check-equal? act exp)) 14 | 15 | (define-syntax-rule (gcd-case x y) 16 | (test-case+ 17 | (format "gcd ~a ~a" x y) 18 | (gcd-jitted x y))) 19 | 20 | (define tests 21 | (test-suite+ "stacklang gcd tests" 22 | (gcd-case 135 345) 23 | (gcd-case 2 200000000) 24 | (gcd-case 200000000 2) 25 | )) 26 | 27 | (module+ test 28 | (time (run-tests tests))) 29 | -------------------------------------------------------------------------------- /racket/test/x86_32/bugs.rkt: -------------------------------------------------------------------------------- 1 | #lang rosette 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit) 6 | (prefix-in bpf: serval/bpf) 7 | serval/lib/unittest) 8 | 9 | (define (check-shift info) 10 | (define insn (dict-ref info 'bpf-insn)) 11 | (define imm (bpf:insn-imm insn)) 12 | ; The bug is triggered when the shifting amount is zero. 13 | (check-equal? imm (bv 0 32))) 14 | 15 | (define (check-jset32 info) 16 | ; 1) ((u32)src & (u32)dst) is zero; and 17 | ; 2) eax/edx are polluated from previous instructions such that 18 | ; (eax & edx) is non-zero (which we don't check here). 19 | (define bpf-regs (dict-ref info 'bpf-regs)) 20 | (define insn (dict-ref info 'bpf-insn)) 21 | (define dst (bpf:insn-dst insn)) 22 | (define src (bpf:insn-src insn)) 23 | (define dstval (bpf:@reg-ref bpf-regs dst)) 24 | (define srcval (bpf:@reg-ref bpf-regs src)) 25 | (check-equal? (bvand (extract 31 0 dstval) (extract 31 0 srcval)) (bv 0 32))) 26 | 27 | (module+ test 28 | (time (test-bugs "x86_32 bugs" check-jit 29 | ; https://git.kernel.org/linus/6fa632e719ee 30 | ['(BPF_ALU64 BPF_LSH BPF_K) check-shift] 31 | ; https://git.kernel.org/linus/80f1f8503635 32 | ['(BPF_JMP32 BPF_JSET BPF_X) check-jset32]))) 33 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-alu32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-k "x86_32-alu32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-alu32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-x "x86_32-alu32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-alu64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-k "x86_32-alu64-k tests" check-jit 9 | #:selector skip-div+mod))) 10 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-alu64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-x "x86_32-alu64-x tests" check-jit 9 | #:selector skip-div+mod))) 10 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-endian.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-endian "x86_32-endian tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-epilogue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-epilogue "x86_32-epilogue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-jmp-call.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp-call "x86_32-jmp-call tests" check-jit 9 | #:selector (verify-only-in (list 'BPF_CALL 'BPF_EXIT))))) 10 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-jmp32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-k "x86_32-jmp32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-jmp32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-x "x86_32-jmp32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-jmp64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-k "x86_32-jmp64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-jmp64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-x "x86_32-jmp64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-ld-imm.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ld-imm "x86_32-ld-imm tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-ldx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ldx-mem "x86_32-ldx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-prologue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-prologue "x86_32-prologue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-st-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-st-mem "x86_32-st-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_32/verify-stx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_32/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-mem "x86_32-stx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-alu32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-k "x86_64-alu32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-alu32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu32-x "x86_64-alu32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-alu64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-k "x86_64-alu64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-alu64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-alu64-x "x86_64-alu64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-endian.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-endian "x86_64-endian tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-epilogue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-epilogue "x86_64-epilogue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-jmp-call.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp-call "x86_64-jmp-call tests" check-jit 9 | #:selector (verify-only-in (list 'BPF_CALL 'BPF_EXIT))))) 10 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-jmp32-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-k "x86_64-jmp32-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-jmp32-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp32-x "x86_64-jmp32-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-jmp64-k.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-k "x86_64-jmp64-k tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-jmp64-x.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-jmp64-x "x86_64-jmp64-x tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-ld-imm.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ld-imm "x86_64-ld-imm tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-ldx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-ldx-mem "x86_64-ldx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-prologue.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-prologue "x86_64-prologue tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-st-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-st-mem "x86_64-st-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-stx-mem.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-mem "x86_64-stx-mem tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/test/x86_64/verify-stx-xadd.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require 4 | "../../lib/tests.rkt" 5 | (only-in "../../x86/x86_64/spec.rkt" check-jit)) 6 | 7 | (module+ test 8 | (time (verify-stx-xadd "x86_64-stx-xadd tests" check-jit))) 9 | -------------------------------------------------------------------------------- /racket/x86/common.rkt: -------------------------------------------------------------------------------- 1 | #lang rosette 2 | 3 | (require 4 | (prefix-in core: serval/lib/core)) 5 | 6 | (provide (all-defined-out)) 7 | 8 | ; Ensure that expr is concretely true. 9 | (define (static-assert expr msg) 10 | (unless expr 11 | (eprintf "static assertion failed: ~a" msg) 12 | (exit 1))) 13 | 14 | ; Simplify e1 with e2 and return e2. 15 | ; This is used to rewrite REX and ModR/M bytes. 16 | (define (simplify-with e1 e2 #:msg msg) 17 | (core:bug-on (! (equal? e1 e2)) #:msg msg) 18 | e2) 19 | -------------------------------------------------------------------------------- /scripts/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM unsat/serval-tools:latest 2 | 3 | ARG LEAN_VERSION=v3.30.0 4 | 5 | # Install some dependencies 6 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ 7 | libgmp-dev \ 8 | python3-pandas \ 9 | && rm -rf /var/lib/apt/lists/* 10 | 11 | # Install Lean for proof checking 12 | RUN git clone 'https://github.com/leanprover-community/lean' && \ 13 | cd lean && \ 14 | git checkout ${LEAN_VERSION} && \ 15 | mkdir -p build/release && \ 16 | cd build/release && \ 17 | cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../../src && \ 18 | make -j4 && make install && \ 19 | cd ../../../ && rm -rf lean 20 | 21 | # Install tokei for LOC counting 22 | RUN wget 'https://github.com/XAMPPRocky/tokei/releases/download/v12.0.4/tokei-x86_64-unknown-linux-gnu.tar.gz' && \ 23 | tar -xzvf tokei*.gz && \ 24 | rm -f tokei*.gz && \ 25 | mv tokei /usr/bin 26 | 27 | # Add Jitterbug sources 28 | ADD . /jitterbug 29 | WORKDIR /jitterbug 30 | 31 | # Install the version of Serval packaged with Jitterbug 32 | RUN raco pkg install ./serval 33 | 34 | ENV BOOLECTOR=/opt/boolector/3.2.1-cadical/bin/boolector 35 | ENV Z3=/opt/z3/4.8.7/bin/z3 36 | ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64" 37 | -------------------------------------------------------------------------------- /scripts/cleanheader.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import glob 4 | import os 5 | import sys 6 | import argparse 7 | 8 | # A script to delete headers delete unused headers. 9 | 10 | # Usage: 11 | # First generate the list of headers to keep: 12 | # cc -H ... 2> keep.txt 13 | # Then run this script to delete headers not in keep.txt: 14 | # python3 cleanheader.py -k keep.txt arch/riscv/include include 15 | 16 | parser = argparse.ArgumentParser() 17 | parser.add_argument('-n', '--dry-run', action='store_true') 18 | parser.add_argument('-k', '--keep', required=True, type=str) 19 | parser.add_argument('paths', metavar='PATH', type=str, nargs='+') 20 | args = parser.parse_args() 21 | dryrun = args.dry_run 22 | paths = args.paths 23 | keepfile = args.keep 24 | 25 | keep = set() 26 | 27 | with open(keepfile, 'r') as f: 28 | for line in f.readlines(): 29 | keep.add(line.lstrip('. ').rstrip().casefold()) 30 | 31 | def decide(path): 32 | path = path.casefold() 33 | if path in keep: 34 | print(f'Keeping {path}') 35 | else: 36 | if dryrun: 37 | print(f'Would delete {path}') 38 | else: 39 | print(f'Deleting {path}') 40 | os.unlink(path) 41 | 42 | for gl in paths: 43 | for path in glob.glob(gl + '/**/*.h', recursive=True): 44 | decide(path) 45 | --------------------------------------------------------------------------------