Revision 5e714bf1713b4b096d20ec75c13880b7086964bd authored by Linus Torvalds on 14 October 2022, 19:28:43 UTC, committed by Linus Torvalds on 14 October 2022, 19:28:43 UTC
Pull more MM updates from Andrew Morton:

 - fix a race which causes page refcounting errors in ZONE_DEVICE pages
   (Alistair Popple)

 - fix userfaultfd test harness instability (Peter Xu)

 - various other patches in MM, mainly fixes

* tag 'mm-stable-2022-10-13' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (29 commits)
  highmem: fix kmap_to_page() for kmap_local_page() addresses
  mm/page_alloc: fix incorrect PGFREE and PGALLOC for high-order page
  mm/selftest: uffd: explain the write missing fault check
  mm/hugetlb: use hugetlb_pte_stable in migration race check
  mm/hugetlb: fix race condition of uffd missing/minor handling
  zram: always expose rw_page
  LoongArch: update local TLB if PTE entry exists
  mm: use update_mmu_tlb() on the second thread
  kasan: fix array-bounds warnings in tests
  hmm-tests: add test for migrate_device_range()
  nouveau/dmem: evict device private memory during release
  nouveau/dmem: refactor nouveau_dmem_fault_copy_one()
  mm/migrate_device.c: add migrate_device_range()
  mm/migrate_device.c: refactor migrate_vma and migrate_deivce_coherent_page()
  mm/memremap.c: take a pgmap reference on page allocation
  mm: free device private pages have zero refcount
  mm/memory.c: fix race when faulting a device private page
  mm/damon: use damon_sz_region() in appropriate place
  mm/damon: move sz_damon_region to damon_sz_region
  lib/test_meminit: add checks for the allocation functions
  ...
2 parent s f2e4413 + ef6e06b
Raw File
syscallhdr.sh
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# Generate a syscall number header.
#
# Each line of the syscall table should have the following format:
#
# NR ABI NAME [NATIVE] [COMPAT]
#
# NR       syscall number
# ABI      ABI name
# NAME     syscall name
# NATIVE   native entry point (optional)
# COMPAT   compat entry point (optional)

set -e

usage() {
	echo >&2 "usage: $0 [--abis ABIS] [--emit-nr] [--offset OFFSET] [--prefix PREFIX] INFILE OUTFILE" >&2
	echo >&2
	echo >&2 "  INFILE    input syscall table"
	echo >&2 "  OUTFILE   output header file"
	echo >&2
	echo >&2 "options:"
	echo >&2 "  --abis ABIS        ABI(s) to handle (By default, all lines are handled)"
	echo >&2 "  --emit-nr          Emit the macro of the number of syscalls (__NR_syscalls)"
	echo >&2 "  --offset OFFSET    The offset of syscall numbers"
	echo >&2 "  --prefix PREFIX    The prefix to the macro like __NR_<PREFIX><NAME>"
	exit 1
}

# default unless specified by options
abis=
emit_nr=
offset=
prefix=

while [ $# -gt 0 ]
do
	case $1 in
	--abis)
		abis=$(echo "($2)" | tr ',' '|')
		shift 2;;
	--emit-nr)
		emit_nr=1
		shift 1;;
	--offset)
		offset=$2
		shift 2;;
	--prefix)
		prefix=$2
		shift 2;;
	-*)
		echo "$1: unknown option" >&2
		usage;;
	*)
		break;;
	esac
done

if [ $# -ne 2 ]; then
	usage
fi

infile="$1"
outfile="$2"

guard=_UAPI_ASM_$(basename "$outfile" |
	sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
	-e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g')

grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$infile" | {
	echo "#ifndef $guard"
	echo "#define $guard"
	echo

	max=0
	while read nr abi name native compat ; do

		max=$nr

		if [ -n "$offset" ]; then
			nr="($offset + $nr)"
		fi

		echo "#define __NR_$prefix$name $nr"
	done

	if [ -n "$emit_nr" ]; then
		echo
		echo "#ifdef __KERNEL__"
		echo "#define __NR_${prefix}syscalls $(($max + 1))"
		echo "#endif"
	fi

	echo
	echo "#endif /* $guard */"
} > "$outfile"
back to top