code:
# SPDX-License-Identifier: GPL-2.0
#
# General architecture dependent options
#

#
# Note: arch/$(SRCARCH)/Kconfig needs to be included first so that it can
# override the default values in this file.
#
source "arch/$(SRCARCH)/Kconfig"

menu "General architecture-dependent options"

config CRASH_CORE
	bool

config KEXEC_CORE
	select CRASH_CORE
	bool

config KEXEC_ELF
	bool

config HAVE_IMA_KEXEC
	bool

config ARCH_HAS_SUBPAGE_FAULTS
	bool
	help
	  Select if the architecture can check permissions at sub-page
	  granularity (e.g. arm64 MTE). The probe_user_*() functions
	  must be implemented.

config HOTPLUG_SMT
	bool

config GENERIC_ENTRY
       bool

config KPROBES
	bool "Kprobes"
	depends on MODULES
	depends on HAVE_KPROBES
	select KALLSYMS
	select TASKS_RCU if PREEMPTION
	help
	  Kprobes allows you to trap at almost any kernel address and
	  execute a callback function.  register_kprobe() establishes
	  a probepoint and specifies the callback.  Kprobes is useful
	  for kernel debugging, non-intrusive instrumentation and testing.
	  If in doubt, say "N".

config JUMP_LABEL
	bool "Optimize very unlikely/likely branches"
	depends on HAVE_ARCH_JUMP_LABEL
	select OBJTOOL if HAVE_JUMP_LABEL_HACK
	help
	 This option enables a transparent branch optimization that
	 makes certain almost-always-true or almost-always-false branch
	 conditions even cheaper to execute within the kernel.

	 Certain performance-sensitive kernel code, such as trace points,
	 scheduler functionality, networking code and KVM have such
	 branches and include support for this optimization technique.

	 If it is detected that the compiler has support for "asm goto",
	 the kernel will compile such branches with just a nop
	 instruction. When the condition flag is toggled to true, the
	 nop will be converted to a jump instruction to execute the
	 conditional block of instructions.

	 This technique lowers overhead and stress on the branch prediction
	 of the processor and generally makes the kernel faster. The update
	 of the condition is slower, but those are always very rare.

	 ( On 32-bit x86, the necessary options added to the compiler
	   flags may increase the size of the kernel slightly. )

config STATIC_KEYS_SELFTEST
	bool "Static key selftest"
	depends on JUMP_LABEL
	help
	  Boot time self-test of the branch patching code.

config STATIC_CALL_SELFTEST
	bool "Static call selftest"
	depends on HAVE_STATIC_CALL
	help
	  Boot time self-test of the call patching code.

config OPTPROBES
	def_bool y
	depends on KPROBES && HAVE_OPTPROBES
	select TASKS_RCU if PREEMPTION

config KPROBES_ON_FTRACE
	def_bool y
	depends on KPROBES && HAVE_KPROBES_ON_FTRACE
	depends on DYNAMIC_FTRACE_WITH_REGS
	help
	 If function tracer is enabled and the arch supports full
	 passing of pt_regs to function tracing, then kprobes can
	 optimize on top of function tracing.

config UPROBES
	def_bool n
	depends on ARCH_SUPPORTS_UPROBES
	help
	  Uprobes is the user-space counterpart to kprobes: they
	  enable instrumentation applications (such as 'perf probe')
	  to establish unintrusive probes in user-space binaries and
	  libraries, by executing handler functions when the probes
	  are hit by user-space applications.

	  ( These probes come in the form of single-byte breakpoints,
	    managed by the kernel and kept transparent to the probed
	    application. )

config HAVE_64BIT_ALIGNED_ACCESS
	def_bool 64BIT && !HAVE_EFFICIENT_UNALIGNED_ACCESS
	help
	  Some architectures require 64 bit accesses to be 64 bit
	  aligned, which also requires structs containing 64 bit values
	  to be 64 bit aligned too. This includes some 32 bit
	  architectures which can do 64 bit accesses, as well as 64 bit
	  architectures without unaligned access.

	  This symbol should be selected by an architecture if 64 bit
	  accesses are required to be 64 bit aligned in this way even
	  though it is not a 64 bit architecture.

	  See Documentation/core-api/unaligned-memory-access.rst for
	  more information on the topic of unaligned memory accesses.

config HAVE_EFFICIENT_UNALIGNED_ACCESS
	bool
	help
	  Some architectures are unable to perform unaligned accesses
	  without the use of get_unaligned/put_unaligned. Others are
	  unable to perform such accesses efficiently (e.g. trap on
	  unaligned access and require fixing it up in the exception
	  handler.)

	  This symbol should be selected by an architecture if it can
	  perform unaligned accesses efficiently to allow different
	  code paths to be selected for these cases. Some network
	  drivers, for example, could opt to not fix up alignment
	  problems with received packets if doing so would not help
	  much.

	  See Documentation/core-api/unaligned-memory-access.rst for more
	  information on the topic of unaligned memory accesses.

config ARCH_USE_BUILTIN_BSWAP
	bool
	help
	 Modern versions of GCC (since 4.4) have builtin functions
	 for handling byte-swapping. Using these, instead of the old
	 inline assembler that the architecture code provides in the
	 __arch_bswapXX() macros, allows the compiler to see what's
	 happening and offers more opportunity for optimisation. In
	 particular, the compiler will be able to combine the byteswap
	 with a nearby load or store and use load-and-swap or
	 store-and-swap instructions if the architecture has them. It
	 should almost *never* result in code which is worse than the
	 hand-coded assembler in <asm/swab.h>.  But just in case it
	 does, the use of the builtins is optional.

	 Any architecture with load-and-swap or store-and-swap
	 instructions should set this. And it shouldn't hurt to set it
	 on architectures that don't have such instructions.

config KRETPROBES
	def_bool y
	depends on KPROBES && (HAVE_KRETPROBES || HAVE_RETHOOK)

config KRETPROBE_ON_RETHOOK
	def_bool y
	depends on HAVE_RETHOOK
	depends on KRETPROBES
	select RETHOOK

config USER_RETURN_NOTIFIER
	bool
	depends on HAVE_USER_RETURN_NOTIFIER
	help
	  Provide a kernel-internal notification when a cpu is about to
	  switch to user mode.

config HAVE_IOREMAP_PROT
	bool

config HAVE_KPROBES
	bool

config HAVE_KRETPROBES
	bool

config HAVE_OPTPROBES
	bool

config HAVE_KPROBES_ON_FTRACE
	bool

config ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
	bool
	help
	  Since kretprobes modifies return address on the stack, the
	  stacktrace may see the kretprobe trampoline address instead
	  of correct one. If the architecture stacktrace code and
	  unwinder can adjust such entries, select this configuration.

config HAVE_FUNCTION_ERROR_INJECTION
	bool

config HAVE_NMI
	bool

config HAVE_FUNCTION_DESCRIPTORS
	bool

config TRACE_IRQFLAGS_SUPPORT
	bool

config TRACE_IRQFLAGS_NMI_SUPPORT
	bool

#
# An arch should select this if it provides all these things:
#
#	task_pt_regs()		in asm/processor.h or asm/ptrace.h
#	arch_has_single_step()	if there is hardware single-step support
#	arch_has_block_step()	if there is hardware block-step support
#	asm/syscall.h		supplying asm-generic/syscall.h interface
#	linux/regset.h		user_regset interfaces
#	CORE_DUMP_USE_REGSET	#define'd in linux/elf.h
#	TIF_SYSCALL_TRACE	calls ptrace_report_syscall_{entry,exit}
#	TIF_NOTIFY_RESUME	calls resume_user_mode_work()
#
config HAVE_ARCH_TRACEHOOK
	bool

config HAVE_DMA_CONTIGUOUS
	bool

config GENERIC_SMP_IDLE_THREAD
	bool

config GENERIC_IDLE_POLL_SETUP
	bool

config ARCH_HAS_FORTIFY_SOURCE
	bool
	help
	  An architecture should select this when it can successfully
	  build and run with CONFIG_FORTIFY_SOURCE.

#
# Select if the arch provides a historic keepinit alias for the retain_initrd
# command line option
#
config ARCH_HAS_KEEPINITRD
	bool

# Select if arch has all set_memory_ro/rw/x/nx() functions in asm/cacheflush.h
config ARCH_HAS_SET_MEMORY
	bool

# Select if arch has all set_direct_map_invalid/default() functions
config ARCH_HAS_SET_DIRECT_MAP
	bool

#
# Select if the architecture provides the arch_dma_set_uncached symbol to
# either provide an uncached segment alias for a DMA allocation, or
# to remap the page tables in place.
#
config ARCH_HAS_DMA_SET_UNCACHED
	bool

#
# Select if the architectures provides the arch_dma_clear_uncached symbol
# to undo an in-place page table remap for uncached access.
#
config ARCH_HAS_DMA_CLEAR_UNCACHED
	bool

# Select if arch init_task must go in the __init_task_data section
config ARCH_TASK_STRUCT_ON_STACK
	bool

# Select if arch has its private alloc_task_struct() function
config ARCH_TASK_STRUCT_ALLOCATOR
	bool

config HAVE_ARCH_THREAD_STRUCT_WHITELIST
	bool
	depends on !ARCH_TASK_STRUCT_ALLOCATOR
	help
	  An architecture should select this to provide hardened usercopy
	  knowledge about what region of the thread_struct should be
	  whitelisted for copying to userspace. Normally this is only the
	  FPU registers. Specifically, arch_thread_struct_whitelist()
	  should be implemented. Without this, the entire thread_struct
	  field in task_struct will be left whitelisted.

# Select if arch has its private alloc_thread_stack() function
config ARCH_THREAD_STACK_ALLOCATOR
	bool

# Select if arch wants to size task_struct dynamically via arch_task_struct_size:
config ARCH_WANTS_DYNAMIC_TASK_STRUCT
	bool

config ARCH_WANTS_NO_INSTR
	bool
	help
	  An architecture should select this if the noinstr macro is being used on
	  functions to denote that the toolchain should avoid instrumenting such
	  functions and is required for correctness.

config ARCH_32BIT_OFF_T
	bool
	depends on !64BIT
	help
	  All new 32-bit architectures should have 64-bit off_t type on
	  userspace side which corresponds to the loff_t kernel type. This
	  is the requirement for modern ABIs. Some existing architectures
	  still support 32-bit off_t. This option is enabled for all such
	  architectures explicitly.

# Selected by 64 bit architectures which have a 32 bit f_tinode in struct ustat
config ARCH_32BIT_USTAT_F_TINODE
	bool

config HAVE_ASM_MODVERSIONS
	bool
	help
	  This symbol should be selected by an architecture if it provides
	  <asm/asm-prototypes.h> to support the module versioning for symbols
	  exported from assembly code.

config HAVE_REGS_AND_STACK_ACCESS_API
	bool
	help
	  This symbol should be selected by an architecture if it supports
	  the API needed to access registers and stack entries from pt_regs,
	  declared in asm/ptrace.h
	  For example the kprobes-based event tracer needs this API.

config HAVE_RSEQ
	bool
	depends on HAVE_REGS_AND_STACK_ACCESS_API
	help
	  This symbol should be selected by an architecture if it
	  supports an implementation of restartable sequences.

config HAVE_RUST
	bool
	help
	  This symbol should be selected by an architecture if it
	  supports Rust.

config HAVE_FUNCTION_ARG_ACCESS_API
	bool
	help
	  This symbol should be selected by an architecture if it supports
	  the API needed to access function arguments from pt_regs,
	  declared in asm/ptrace.h

config HAVE_HW_BREAKPOINT
	bool
	depends on PERF_EVENTS

config HAVE_MIXED_BREAKPOINTS_REGS
	bool
	depends on HAVE_HW_BREAKPOINT
	help
	  Depending on the arch implementation of hardware breakpoints,
	  some of them have separate registers for data and instruction
	  breakpoints addresses, others have mixed registers to store
	  them but define the access type in a control register.
	  Select this option if your arch implements breakpoints under the
	  latter fashion.

config HAVE_USER_RETURN_NOTIFIER
	bool

config HAVE_PERF_EVENTS_NMI
	bool
	help
	  System hardware can generate an NMI using the perf event
	  subsystem.  Also has support for calculating CPU cycle events
	  to determine how many clock cycles in a given period.

config HAVE_HARDLOCKUP_DETECTOR_PERF
	bool
	depends on HAVE_PERF_EVENTS_NMI
	help
	  The arch chooses to use the generic perf-NMI-based hardlockup
	  detector. Must define HAVE_PERF_EVENTS_NMI.

config HAVE_NMI_WATCHDOG
	depends on HAVE_NMI
	bool
	help
	  The arch provides a low level NMI watchdog. It provides
	  asm/nmi.h, and defines its own arch_touch_nmi_watchdog().

config HAVE_HARDLOCKUP_DETECTOR_ARCH
	bool
	select HAVE_NMI_WATCHDOG
	help
	  The arch chooses to provide its own hardlockup detector, which is
	  a superset of the HAVE_NMI_WATCHDOG. It also conforms to config
	  interfaces and parameters provided by hardlockup detector subsystem.

config HAVE_PERF_REGS
	bool
	help
	  Support selective register dumps for perf events. This includes
	  bit-mapping of each registers and a unique architecture id.

config HAVE_PERF_USER_STACK_DUMP
	bool
	help
	  Support user stack dumps for perf event samples. This needs
	  access to the user stack pointer which is not unified across
	  architectures.

config HAVE_ARCH_JUMP_LABEL
	bool

config HAVE_ARCH_JUMP_LABEL_RELATIVE
	bool

config MMU_GATHER_TABLE_FREE
	bool

config MMU_GATHER_RCU_TABLE_FREE
	bool
	select MMU_GATHER_TABLE_FREE

config MMU_GATHER_PAGE_SIZE
	bool

config MMU_GATHER_NO_RANGE
	bool
	select MMU_GATHER_MERGE_VMAS

config MMU_GATHER_NO_FLUSH_CACHE
	bool

config MMU_GATHER_MERGE_VMAS
	bool

config MMU_GATHER_NO_GATHER
	bool
	depends on MMU_GATHER_TABLE_FREE

config ARCH_WANT_IRQS_OFF_ACTIVATE_MM
	bool
	help
	  Temporary select until all architectures can be converted to have
	  irqs disabled over activate_mm. Architectures that do IPI based TLB
	  shootdowns should enable this.

config ARCH_HAVE_NMI_SAFE_CMPXCHG
	bool

config ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
	bool

config HAVE_ALIGNED_STRUCT_PAGE
	bool
	help
	  This makes sure that struct pages are double word aligned and that
	  e.g. the SLUB allocator can perform double word atomic operations
	  on a struct page for better performance. However selecting this
	  might increase the size of a struct page by a word.

config HAVE_CMPXCHG_LOCAL
	bool

config HAVE_CMPXCHG_DOUBLE
	bool

config ARCH_WEAK_RELEASE_ACQUIRE
	bool

config ARCH_WANT_IPC_PARSE_VERSION
	bool

config ARCH_WANT_COMPAT_IPC_PARSE_VERSION
	bool

config ARCH_WANT_OLD_COMPAT_IPC
	select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
	bool

config HAVE_ARCH_SECCOMP
	bool
	help
	  An arch should select this symbol to support seccomp mode 1 (the fixed
	  syscall policy), and must provide an overrides for __NR_seccomp_sigreturn,
	  and compat syscalls if the asm-generic/seccomp.h defaults need adjustment:
	  - __NR_seccomp_read_32
	  - __NR_seccomp_write_32
	  - __NR_seccomp_exit_32
	  - __NR_seccomp_sigreturn_32

config HAVE_ARCH_SECCOMP_FILTER
	bool
	select HAVE_ARCH_SECCOMP
	help
	  An arch should select this symbol if it provides all of these things:
	  - all the requirements for HAVE_ARCH_SECCOMP
	  - syscall_get_arch()
	  - syscall_get_arguments()
	  - syscall_rollback()
	  - syscall_set_return_value()
	  - SIGSYS siginfo_t support
	  - secure_computing is called from a ptrace_event()-safe context
	  - secure_computing return value is checked and a return value of -1
	    results in the system call being skipped immediately.
	  - seccomp syscall wired up
	  - if !HAVE_SPARSE_SYSCALL_NR, have SECCOMP_ARCH_NATIVE,
	    SECCOMP_ARCH_NATIVE_NR, SECCOMP_ARCH_NATIVE_NAME defined. If
	    COMPAT is supported, have the SECCOMP_ARCH_COMPAT* defines too.

config SECCOMP
	prompt "Enable seccomp to safely execute untrusted bytecode"
	def_bool y
	depends on HAVE_ARCH_SECCOMP
	help
	  This kernel feature is useful for number crunching applications
	  that may need to handle untrusted bytecode during their
	  execution. By using pipes or other transports made available
	  to the process as file descriptors supporting the read/write
	  syscalls, it's possible to isolate those applications in their
	  own address space using seccomp. Once seccomp is enabled via
	  prctl(PR_SET_SECCOMP) or the seccomp() syscall, it cannot be
	  disabled and the task is only allowed to execute a few safe
	  syscalls defined by each seccomp mode.

	  If unsure, say Y.

config SECCOMP_FILTER
	def_bool y
	depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET
	help
	  Enable tasks to build secure computing environments defined
	  in terms of Berkeley Packet Filter programs which implement
	  task-defined system call filtering polices.

	  See Documentation/userspace-api/seccomp_filter.rst for details.

config SECCOMP_CACHE_DEBUG
	bool "Show seccomp filter cache status in /proc/pid/seccomp_cache"
	depends on SECCOMP_FILTER && !HAVE_SPARSE_SYSCALL_NR
	depends on PROC_FS
	help
	  This enables the /proc/pid/seccomp_cache interface to monitor
	  seccomp cache data. The file format is subject to change. Reading
	  the file requires CAP_SYS_ADMIN.

	  This option is for debugging only. Enabling presents the risk that
	  an adversary may be able to infer the seccomp filter logic.

	  If unsure, say N.

config HAVE_ARCH_STACKLEAK
	bool
	help
	  An architecture should select this if it has the code which
	  fills the used part of the kernel stack with the STACKLEAK_POISON
	  value before returning from system calls.

config HAVE_STACKPROTECTOR
	bool
	help
	  An arch should select this symbol if:
	  - it has implemented a stack canary (e.g. __stack_chk_guard)

config STACKPROTECTOR
	bool "Stack Protector buffer overflow detection"
	depends on HAVE_STACKPROTECTOR
	depends on $(cc-option,-fstack-protector)
	default y
	help
	  This option turns on the "stack-protector" GCC feature. This
	  feature puts, at the beginning of functions, a canary value on
	  the stack just before the return address, and validates
	  the value just before actually returning.  Stack based buffer
	  overflows (that need to overwrite this return address) now also
	  overwrite the canary, which gets detected and the attack is then
	  neutralized via a kernel panic.

	  Functions will have the stack-protector canary logic added if they
	  have an 8-byte or larger character array on the stack.

	  This feature requires gcc version 4.2 or above, or a distribution
	  gcc with the feature backported ("-fstack-protector").

	  On an x86 "defconfig" build, this feature adds canary checks to
	  about 3% of all kernel functions, which increases kernel code size
	  by about 0.3%.

config STACKPROTECTOR_STRONG
	bool "Strong Stack Protector"
	depends on STACKPROTECTOR
	depends on $(cc-option,-fstack-protector-strong)
	default y
	help
	  Functions will have the stack-protector canary logic added in any
	  of the following conditions:

	  - local variable's address used as part of the right hand side of an
	    assignment or function argument
	  - local variable is an array (or union containing an array),
	    regardless of array type or length
	  - uses register local variables

	  This feature requires gcc version 4.9 or above, or a distribution
	  gcc with the feature backported ("-fstack-protector-strong").

	  On an x86 "defconfig" build, this feature adds canary checks to
	  about 20% of all kernel functions, which increases the kernel code
	  size by about 2%.

config ARCH_SUPPORTS_SHADOW_CALL_STACK
	bool
	help
	  An architecture should select this if it supports the compiler's
	  Shadow Call Stack and implements runtime support for shadow stack
	  switching.

config SHADOW_CALL_STACK
	bool "Shadow Call Stack"
	depends on ARCH_SUPPORTS_SHADOW_CALL_STACK
	depends on DYNAMIC_FTRACE_WITH_ARGS || DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER
	help
	  This option enables the compiler's Shadow Call Stack, which
	  uses a shadow stack to protect function return addresses from
	  being overwritten by an attacker. More information can be found
	  in the compiler's documentation:

	  - Clang: https://clang.llvm.org/docs/ShadowCallStack.html
	  - GCC: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#Instrumentation-Options

	  Note that security guarantees in the kernel differ from the
	  ones documented for user space. The kernel must store addresses
	  of shadow stacks in memory, which means an attacker capable of
	  reading and writing arbitrary memory may be able to locate them
	  and hijack control flow by modifying the stacks.

config DYNAMIC_SCS
	bool
	help
	  Set by the arch code if it relies on code patching to insert the
	  shadow call stack push and pop instructions rather than on the
	  compiler.

config LTO
	bool
	help
	  Selected if the kernel will be built using the compiler's LTO feature.

config LTO_CLANG
	bool
	select LTO
	help
	  Selected if the kernel will be built using Clang's LTO feature.

config ARCH_SUPPORTS_LTO_CLANG
	bool
	help
	  An architecture should select this option if it supports:
	  - compiling with Clang,
	  - compiling inline assembly with Clang's integrated assembler,
	  - and linking with LLD.

config ARCH_SUPPORTS_LTO_CLANG_THIN
	bool
	help
	  An architecture should select this option if it can support Clang's
	  ThinLTO mode.

config HAS_LTO_CLANG
	def_bool y
	depends on CC_IS_CLANG && LD_IS_LLD && AS_IS_LLVM
	depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm)
	depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm)
	depends on ARCH_SUPPORTS_LTO_CLANG
	depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT
	depends on !KASAN || KASAN_HW_TAGS
	depends on !GCOV_KERNEL
	help
	  The compiler and Kconfig options support building with Clang's
	  LTO.

choice
	prompt "Link Time Optimization (LTO)"
	default LTO_NONE
	help
	  This option enables Link Time Optimization (LTO), which allows the
	  compiler to optimize binaries globally.

	  If unsure, select LTO_NONE. Note that LTO is very resource-intensive
	  so it's disabled by default.

config LTO_NONE
	bool "None"
	help
	  Build the kernel normally, without Link Time Optimization (LTO).

config LTO_CLANG_FULL
	bool "Clang Full LTO (EXPERIMENTAL)"
	depends on HAS_LTO_CLANG
	depends on !COMPILE_TEST
	select LTO_CLANG
	help
          This option enables Clang's full Link Time Optimization (LTO), which
          allows the compiler to optimize the kernel globally. If you enable
          this option, the compiler generates LLVM bitcode instead of ELF
          object files, and the actual compilation from bitcode happens at
          the LTO link step, which may take several minutes depending on the
          kernel configuration. More information can be found from LLVM's
          documentation:

	    https://llvm.org/docs/LinkTimeOptimization.html

	  During link time, this option can use a large amount of RAM, and
	  may take much longer than the ThinLTO option.

config LTO_CLANG_THIN
	bool "Clang ThinLTO (EXPERIMENTAL)"
	depends on HAS_LTO_CLANG && ARCH_SUPPORTS_LTO_CLANG_THIN
	select LTO_CLANG
	help
	  This option enables Clang's ThinLTO, which allows for parallel
	  optimization and faster incremental compiles compared to the
	  CONFIG_LTO_CLANG_FULL option. More information can be found
	  from Clang's documentation:

	    https://clang.llvm.org/docs/ThinLTO.html

	  If unsure, say Y.
endchoice

config ARCH_SUPPORTS_CFI_CLANG
	bool
	help
	  An architecture should select this option if it can support Clang's
	  Control-Flow Integrity (CFI) checking.

config ARCH_USES_CFI_TRAPS
	bool

config CFI_CLANG
	bool "Use Clang's Control Flow Integrity (CFI)"
	depends on ARCH_SUPPORTS_CFI_CLANG
	depends on $(cc-option,-fsanitize=kcfi)
	help
	  This option enables Clang’s forward-edge Control Flow Integrity
	  (CFI) checking, where the compiler injects a runtime check to each
	  indirect function call to ensure the target is a valid function with
	  the correct static type. This restricts possible call targets and
	  makes it more difficult for an attacker to exploit bugs that allow
	  the modification of stored function pointers. More information can be
	  found from Clang's documentation:

	    https://clang.llvm.org/docs/ControlFlowIntegrity.html

config CFI_PERMISSIVE
	bool "Use CFI in permissive mode"
	depends on CFI_CLANG
	help
	  When selected, Control Flow Integrity (CFI) violations result in a
	  warning instead of a kernel panic. This option should only be used
	  for finding indirect call type mismatches during development.

	  If unsure, say N.

config HAVE_ARCH_WITHIN_STACK_FRAMES
	bool
	help
	  An architecture should select this if it can walk the kernel stack
	  frames to determine if an object is part of either the arguments
	  or local variables (i.e. that it excludes saved return addresses,
	  and similar) by implementing an inline arch_within_stack_frames(),
	  which is used by CONFIG_HARDENED_USERCOPY.

config HAVE_CONTEXT_TRACKING_USER
	bool
	help
	  Provide kernel/user boundaries probes necessary for subsystems
	  that need it, such as userspace RCU extended quiescent state.
	  Syscalls need to be wrapped inside user_exit()-user_enter(), either
	  optimized behind static key or through the slow path using TIF_NOHZ
	  flag. Exceptions handlers must be wrapped as well. Irqs are already
	  protected inside ct_irq_enter/ct_irq_exit() but preemption or signal
	  handling on irq exit still need to be protected.

config HAVE_CONTEXT_TRACKING_USER_OFFSTACK
	bool
	help
	  Architecture neither relies on exception_enter()/exception_exit()
	  nor on schedule_user(). Also preempt_schedule_notrace() and
	  preempt_schedule_irq() can't be called in a preemptible section
	  while context tracking is CONTEXT_USER. This feature reflects a sane
	  entry implementation where the following requirements are met on
	  critical entry code, ie: before user_exit() or after user_enter():

	  - Critical entry code isn't preemptible (or better yet:
	    not interruptible).
	  - No use of RCU read side critical sections, unless ct_nmi_enter()
	    got called.
	  - No use of instrumentation, unless instrumentation_begin() got
	    called.

config HAVE_TIF_NOHZ
	bool
	help
	  Arch relies on TIF_NOHZ and syscall slow path to implement context
	  tracking calls to user_enter()/user_exit().

config HAVE_VIRT_CPU_ACCOUNTING
	bool

config HAVE_VIRT_CPU_ACCOUNTING_IDLE
	bool
	help
	  Architecture has its own way to account idle CPU time and therefore
	  doesn't implement vtime_account_idle().

config ARCH_HAS_SCALED_CPUTIME
	bool

config HAVE_VIRT_CPU_ACCOUNTING_GEN
	bool
	default y if 64BIT
	help
	  With VIRT_CPU_ACCOUNTING_GEN, cputime_t becomes 64-bit.
	  Before enabling this option, arch code must be audited
	  to ensure there are no races in concurrent read/write of
	  cputime_t. For example, reading/writing 64-bit cputime_t on
	  some 32-bit arches may require multiple accesses, so proper
	  locking is needed to protect against concurrent accesses.

config HAVE_IRQ_TIME_ACCOUNTING
	bool
	help
	  Archs need to ensure they use a high enough resolution clock to
	  support irq time accounting and then call enable_sched_clock_irqtime().

config HAVE_MOVE_PUD
	bool
	help
	  Architectures that select this are able to move page tables at the
	  PUD level. If there are only 3 page table levels, the move effectively
	  happens at the PGD level.

config HAVE_MOVE_PMD
	bool
	help
	  Archs that select this are able to move page tables at the PMD level.

config HAVE_ARCH_TRANSPARENT_HUGEPAGE
	bool

config HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
	bool

config HAVE_ARCH_HUGE_VMAP
	bool

#
#  Archs that select this would be capable of PMD-sized vmaps (i.e.,
#  arch_vmap_pmd_supported() returns true). The VM_ALLOW_HUGE_VMAP flag
#  must be used to enable allocations to use hugepages.
#
config HAVE_ARCH_HUGE_VMALLOC
	depends on HAVE_ARCH_HUGE_VMAP
	bool

config ARCH_WANT_HUGE_PMD_SHARE
	bool

config HAVE_ARCH_SOFT_DIRTY
	bool

config HAVE_MOD_ARCH_SPECIFIC
	bool
	help
	  The arch uses struct mod_arch_specific to store data.  Many arches
	  just need a simple module loader without arch specific data - those
	  should not enable this.

config MODULES_USE_ELF_RELA
	bool
	help
	  Modules only use ELF RELA relocations.  Modules with ELF REL
	  relocations will give an error.

config MODULES_USE_ELF_REL
	bool
	help
	  Modules only use ELF REL relocations.  Modules with ELF RELA
	  relocations will give an error.

config ARCH_WANTS_MODULES_DATA_IN_VMALLOC
	bool
	help
	  For architectures like powerpc/32 which have constraints on module
	  allocation and need to allocate module data outside of module area.

config HAVE_IRQ_EXIT_ON_IRQ_STACK
	bool
	help
	  Architecture doesn't only execute the irq handler on the irq stack
	  but also irq_exit(). This way we can process softirqs on this irq
	  stack instead of switching to a new one when we call __do_softirq()
	  in the end of an hardirq.
	  This spares a stack switch and improves cache usage on softirq
	  processing.

config HAVE_SOFTIRQ_ON_OWN_STACK
	bool
	help
	  Architecture provides a function to run __do_softirq() on a
	  separate stack.

config SOFTIRQ_ON_OWN_STACK
	def_bool HAVE_SOFTIRQ_ON_OWN_STACK && !PREEMPT_RT

config ALTERNATE_USER_ADDRESS_SPACE
	bool
	help
	  Architectures set this when the CPU uses separate address
	  spaces for kernel and user space pointers. In this case, the
	  access_ok() check on a __user pointer is skipped.

config PGTABLE_LEVELS
	int
	default 2

config ARCH_HAS_ELF_RANDOMIZE
	bool
	help
	  An architecture supports choosing randomized locations for
	  stack, mmap, brk, and ET_DYN. Defined functions:
	  - arch_mmap_rnd()
	  - arch_randomize_brk()

config HAVE_ARCH_MMAP_RND_BITS
	bool
	help
	  An arch should select this symbol if it supports setting a variable
	  number of bits for use in establishing the base address for mmap
	  allocations, has MMU enabled and provides values for both:
	  - ARCH_MMAP_RND_BITS_MIN
	  - ARCH_MMAP_RND_BITS_MAX

config HAVE_EXIT_THREAD
	bool
	help
	  An architecture implements exit_thread.

config ARCH_MMAP_RND_BITS_MIN
	int

config ARCH_MMAP_RND_BITS_MAX
	int

config ARCH_MMAP_RND_BITS_DEFAULT
	int

config ARCH_MMAP_RND_BITS
	int "Number of bits to use for ASLR of mmap base address" if EXPERT
	range ARCH_MMAP_RND_BITS_MIN ARCH_MMAP_RND_BITS_MAX
	default ARCH_MMAP_RND_BITS_DEFAULT if ARCH_MMAP_RND_BITS_DEFAULT
	default ARCH_MMAP_RND_BITS_MIN
	depends on HAVE_ARCH_MMAP_RND_BITS
	help
	  This value can be used to select the number of bits to use to
	  determine the random offset to the base address of vma regions
	  resulting from mmap allocations. This value will be bounded
	  by the architecture's minimum and maximum supported values.

	  This value can be changed after boot using the
	  /proc/sys/vm/mmap_rnd_bits tunable

config HAVE_ARCH_MMAP_RND_COMPAT_BITS
	bool
	help
	  An arch should select this symbol if it supports running applications
	  in compatibility mode, supports setting a variable number of bits for
	  use in establishing the base address for mmap allocations, has MMU
	  enabled and provides values for both:
	  - ARCH_MMAP_RND_COMPAT_BITS_MIN
	  - ARCH_MMAP_RND_COMPAT_BITS_MAX

config ARCH_MMAP_RND_COMPAT_BITS_MIN
	int

config ARCH_MMAP_RND_COMPAT_BITS_MAX
	int

config ARCH_MMAP_RND_COMPAT_BITS_DEFAULT
	int

config ARCH_MMAP_RND_COMPAT_BITS
	int "Number of bits to use for ASLR of mmap base address for compatible applications" if EXPERT
	range ARCH_MMAP_RND_COMPAT_BITS_MIN ARCH_MMAP_RND_COMPAT_BITS_MAX
	default ARCH_MMAP_RND_COMPAT_BITS_DEFAULT if ARCH_MMAP_RND_COMPAT_BITS_DEFAULT
	default ARCH_MMAP_RND_COMPAT_BITS_MIN
	depends on HAVE_ARCH_MMAP_RND_COMPAT_BITS
	help
	  This value can be used to select the number of bits to use to
	  determine the random offset to the base address of vma regions
	  resulting from mmap allocations for compatible applications This
	  value will be bounded by the architecture's minimum and maximum
	  supported values.

	  This value can be changed after boot using the
	  /proc/sys/vm/mmap_rnd_compat_bits tunable

config HAVE_ARCH_COMPAT_MMAP_BASES
	bool
	help
	  This allows 64bit applications to invoke 32-bit mmap() syscall
	  and vice-versa 32-bit applications to call 64-bit mmap().
	  Required for applications doing different bitness syscalls.

config PAGE_SIZE_LESS_THAN_64KB
	def_bool y
	depends on !ARM64_64K_PAGES
	depends on !IA64_PAGE_SIZE_64KB
	depends on !PAGE_SIZE_64KB
	depends on !PARISC_PAGE_SIZE_64KB
	depends on PAGE_SIZE_LESS_THAN_256KB

config PAGE_SIZE_LESS_THAN_256KB
	def_bool y
	depends on !PAGE_SIZE_256KB

# This allows to use a set of generic functions to determine mmap base
# address by giving priority to top-down scheme only if the process
# is not in legacy mode (compat task, unlimited stack size or
# sysctl_legacy_va_layout).
# Architecture that selects this option can provide its own version of:
# - STACK_RND_MASK
config ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
	bool
	depends on MMU
	select ARCH_HAS_ELF_RANDOMIZE

config HAVE_OBJTOOL
	bool

config HAVE_JUMP_LABEL_HACK
	bool

config HAVE_NOINSTR_HACK
	bool

config HAVE_NOINSTR_VALIDATION
	bool

config HAVE_UACCESS_VALIDATION
	bool
	select OBJTOOL

config HAVE_STACK_VALIDATION
	bool
	help
	  Architecture supports objtool compile-time frame pointer rule
	  validation.

config HAVE_RELIABLE_STACKTRACE
	bool
	help
	  Architecture has either save_stack_trace_tsk_reliable() or
	  arch_stack_walk_reliable() function which only returns a stack trace
	  if it can guarantee the trace is reliable.

config HAVE_ARCH_HASH
	bool
	default n
	help
	  If this is set, the architecture provides an <asm/hash.h>
	  file which provides platform-specific implementations of some
	  functions in <linux/hash.h> or fs/namei.c.

config HAVE_ARCH_NVRAM_OPS
	bool

config ISA_BUS_API
	def_bool ISA

#
# ABI hall of shame
#
config CLONE_BACKWARDS
	bool
	help
	  Architecture has tls passed as the 4th argument of clone(2),
	  not the 5th one.

config CLONE_BACKWARDS2
	bool
	help
	  Architecture has the first two arguments of clone(2) swapped.

config CLONE_BACKWARDS3
	bool
	help
	  Architecture has tls passed as the 3rd argument of clone(2),
	  not the 5th one.

config ODD_RT_SIGACTION
	bool
	help
	  Architecture has unusual rt_sigaction(2) arguments

config OLD_SIGSUSPEND
	bool
	help
	  Architecture has old sigsuspend(2) syscall, of one-argument variety

config OLD_SIGSUSPEND3
	bool
	help
	  Even weirder antique ABI - three-argument sigsuspend(2)

config OLD_SIGACTION
	bool
	help
	  Architecture has old sigaction(2) syscall.  Nope, not the same
	  as OLD_SIGSUSPEND | OLD_SIGSUSPEND3 - alpha has sigsuspend(2),
	  but fairly different variant of sigaction(2), thanks to OSF/1
	  compatibility...

config COMPAT_OLD_SIGACTION
	bool

config COMPAT_32BIT_TIME
	bool "Provide system calls for 32-bit time_t"
	default !64BIT || COMPAT
	help
	  This enables 32 bit time_t support in addition to 64 bit time_t support.
	  This is relevant on all 32-bit architectures, and 64-bit architectures
	  as part of compat syscall handling.

config ARCH_NO_PREEMPT
	bool

config ARCH_EPHEMERAL_INODES
	def_bool n
	help
	  An arch should select this symbol if it doesn't keep track of inode
	  instances on its own, but instead relies on something else (e.g. the
	  host kernel for an UML kernel).

config ARCH_SUPPORTS_RT
	bool

config CPU_NO_EFFICIENT_FFS
	def_bool n

config HAVE_ARCH_VMAP_STACK
	def_bool n
	help
	  An arch should select this symbol if it can support kernel stacks
	  in vmalloc space.  This means:

	  - vmalloc space must be large enough to hold many kernel stacks.
	    This may rule out many 32-bit architectures.

	  - Stacks in vmalloc space need to work reliably.  For example, if
	    vmap page tables are created on demand, either this mechanism
	    needs to work while the stack points to a virtual address with
	    unpopulated page tables or arch code (switch_to() and switch_mm(),
	    most likely) needs to ensure that the stack's page table entries
	    are populated before running on a possibly unpopulated stack.

	  - If the stack overflows into a guard page, something reasonable
	    should happen.  The definition of "reasonable" is flexible, but
	    instantly rebooting without logging anything would be unfriendly.

config VMAP_STACK
	default y
	bool "Use a virtually-mapped stack"
	depends on HAVE_ARCH_VMAP_STACK
	depends on !KASAN || KASAN_HW_TAGS || KASAN_VMALLOC
	help
	  Enable this if you want the use virtually-mapped kernel stacks
	  with guard pages.  This causes kernel stack overflows to be
	  caught immediately rather than causing difficult-to-diagnose
	  corruption.

	  To use this with software KASAN modes, the architecture must support
	  backing virtual mappings with real shadow memory, and KASAN_VMALLOC
	  must be enabled.

config HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
	def_bool n
	help
	  An arch should select this symbol if it can support kernel stack
	  offset randomization with calls to add_random_kstack_offset()
	  during syscall entry and choose_random_kstack_offset() during
	  syscall exit. Careful removal of -fstack-protector-strong and
	  -fstack-protector should also be applied to the entry code and
	  closely examined, as the artificial stack bump looks like an array
	  to the compiler, so it will attempt to add canary checks regardless
	  of the static branch state.

config RANDOMIZE_KSTACK_OFFSET
	bool "Support for randomizing kernel stack offset on syscall entry" if EXPERT
	default y
	depends on HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
	depends on INIT_STACK_NONE || !CC_IS_CLANG || CLANG_VERSION >= 140000
	help
	  The kernel stack offset can be randomized (after pt_regs) by
	  roughly 5 bits of entropy, frustrating memory corruption
	  attacks that depend on stack address determinism or
	  cross-syscall address exposures.

	  The feature is controlled via the "randomize_kstack_offset=on/off"
	  kernel boot param, and if turned off has zero overhead due to its use
	  of static branches (see JUMP_LABEL).

	  If unsure, say Y.

config RANDOMIZE_KSTACK_OFFSET_DEFAULT
	bool "Default state of kernel stack offset randomization"
	depends on RANDOMIZE_KSTACK_OFFSET
	help
	  Kernel stack offset randomization is controlled by kernel boot param
	  "randomize_kstack_offset=on/off", and this config chooses the default
	  boot state.

config ARCH_OPTIONAL_KERNEL_RWX
	def_bool n

config ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
	def_bool n

config ARCH_HAS_STRICT_KERNEL_RWX
	def_bool n

config STRICT_KERNEL_RWX
	bool "Make kernel text and rodata read-only" if ARCH_OPTIONAL_KERNEL_RWX
	depends on ARCH_HAS_STRICT_KERNEL_RWX
	default !ARCH_OPTIONAL_KERNEL_RWX || ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
	help
	  If this is set, kernel text and rodata memory will be made read-only,
	  and non-text memory will be made non-executable. This provides
	  protection against certain security exploits (e.g. executing the heap
	  or modifying text)

	  These features are considered standard security practice these days.
	  You should say Y here in almost all cases.

config ARCH_HAS_STRICT_MODULE_RWX
	def_bool n

config STRICT_MODULE_RWX
	bool "Set loadable kernel module data as NX and text as RO" if ARCH_OPTIONAL_KERNEL_RWX
	depends on ARCH_HAS_STRICT_MODULE_RWX && MODULES
	default !ARCH_OPTIONAL_KERNEL_RWX || ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
	help
	  If this is set, module text and rodata memory will be made read-only,
	  and non-text memory will be made non-executable. This provides
	  protection against certain security exploits (e.g. writing to text)

# select if the architecture provides an asm/dma-direct.h header
config ARCH_HAS_PHYS_TO_DMA
	bool

config HAVE_ARCH_COMPILER_H
	bool
	help
	  An architecture can select this if it provides an
	  asm/compiler.h header that should be included after
	  linux/compiler-*.h in order to override macro definitions that those
	  headers generally provide.

config HAVE_ARCH_PREL32_RELOCATIONS
	bool
	help
	  May be selected by an architecture if it supports place-relative
	  32-bit relocations, both in the toolchain and in the module loader,
	  in which case relative references can be used in special sections
	  for PCI fixup, initcalls etc which are only half the size on 64 bit
	  architectures, and don't require runtime relocation on relocatable
	  kernels.

config ARCH_USE_MEMREMAP_PROT
	bool

config LOCK_EVENT_COUNTS
	bool "Locking event counts collection"
	depends on DEBUG_FS
	help
	  Enable light-weight counting of various locking related events
	  in the system with minimal performance impact. This reduces
	  the chance of application behavior change because of timing
	  differences. The counts are reported via debugfs.

# Select if the architecture has support for applying RELR relocations.
config ARCH_HAS_RELR
	bool

config RELR
	bool "Use RELR relocation packing"
	depends on ARCH_HAS_RELR && TOOLS_SUPPORT_RELR
	default y
	help
	  Store the kernel's dynamic relocations in the RELR relocation packing
	  format. Requires a compatible linker (LLD supports this feature), as
	  well as compatible NM and OBJCOPY utilities (llvm-nm and llvm-objcopy
	  are compatible).

config ARCH_HAS_MEM_ENCRYPT
	bool

config ARCH_HAS_CC_PLATFORM
	bool

config HAVE_SPARSE_SYSCALL_NR
       bool
       help
          An architecture should select this if its syscall numbering is sparse
	  to save space. For example, MIPS architecture has a syscall array with
	  entries at 4000, 5000 and 6000 locations. This option turns on syscall
	  related optimizations for a given architecture.

config ARCH_HAS_VDSO_DATA
	bool

config HAVE_STATIC_CALL
	bool

config HAVE_STATIC_CALL_INLINE
	bool
	depends on HAVE_STATIC_CALL
	select OBJTOOL

config HAVE_PREEMPT_DYNAMIC
	bool

config HAVE_PREEMPT_DYNAMIC_CALL
	bool
	depends on HAVE_STATIC_CALL
	select HAVE_PREEMPT_DYNAMIC
	help
	   An architecture should select this if it can handle the preemption
	   model being selected at boot time using static calls.

	   Where an architecture selects HAVE_STATIC_CALL_INLINE, any call to a
	   preemption function will be patched directly.

	   Where an architecture does not select HAVE_STATIC_CALL_INLINE, any
	   call to a preemption function will go through a trampoline, and the
	   trampoline will be patched.

	   It is strongly advised to support inline static call to avoid any
	   overhead.

config HAVE_PREEMPT_DYNAMIC_KEY
	bool
	depends on HAVE_ARCH_JUMP_LABEL
	select HAVE_PREEMPT_DYNAMIC
	help
	   An architecture should select this if it can handle the preemption
	   model being selected at boot time using static keys.

	   Each preemption function will be given an early return based on a
	   static key. This should have slightly lower overhead than non-inline
	   static calls, as this effectively inlines each trampoline into the
	   start of its callee. This may avoid redundant work, and may
	   integrate better with CFI schemes.

	   This will have greater overhead than using inline static calls as
	   the call to the preemption function cannot be entirely elided.

config ARCH_WANT_LD_ORPHAN_WARN
	bool
	help
	  An arch should select this symbol once all linker sections are explicitly
	  included, size-asserted, or discarded in the linker scripts. This is
	  important because we never want expected sections to be placed heuristically
	  by the linker, since the locations of such sections can change between linker
	  versions.

config HAVE_ARCH_PFN_VALID
	bool

config ARCH_SUPPORTS_DEBUG_PAGEALLOC
	bool

config ARCH_SUPPORTS_PAGE_TABLE_CHECK
	bool

config ARCH_SPLIT_ARG64
	bool
	help
	   If a 32-bit architecture requires 64-bit arguments to be split into
	   pairs of 32-bit arguments, select this option.

config ARCH_HAS_ELFCORE_COMPAT
	bool

config ARCH_HAS_PARANOID_L1D_FLUSH
	bool

config ARCH_HAVE_TRACE_MMIO_ACCESS
	bool

config DYNAMIC_SIGFRAME
	bool

# Select, if arch has a named attribute group bound to NUMA device nodes.
config HAVE_ARCH_NODE_DEV_GROUP
	bool

config ARCH_HAS_NONLEAF_PMD_YOUNG
	bool
	help
	  Architectures that select this option are capable of setting the
	  accessed bit in non-leaf PMD entries when using them as part of linear
	  address translations. Page table walkers that clear the accessed bit
	  may use this capability to reduce their search space.

source "kernel/gcov/Kconfig"

source "scripts/gcc-plugins/Kconfig"

config FUNCTION_ALIGNMENT_4B
	bool

config FUNCTION_ALIGNMENT_8B
	bool

config FUNCTION_ALIGNMENT_16B
	bool

config FUNCTION_ALIGNMENT_32B
	bool

config FUNCTION_ALIGNMENT_64B
	bool

config FUNCTION_ALIGNMENT
	int
	default 64 if FUNCTION_ALIGNMENT_64B
	default 32 if FUNCTION_ALIGNMENT_32B
	default 16 if FUNCTION_ALIGNMENT_16B
	default 8 if FUNCTION_ALIGNMENT_8B
	default 4 if FUNCTION_ALIGNMENT_4B
	default 0

endmenu

path: arch/Kconfig


code:
# SPDX-License-Identifier: GPL-2.0-only
obj-y			+= kernel/ mm/
obj-$(CONFIG_MATHEMU)	+= math-emu/

# for cleaning
subdir- += boot

repo_name: angery/linux

path: arch/alpha/Kbuild


code:
# SPDX-License-Identifier: GPL-2.0
config ALPHA
	bool
	default y
	select ARCH_32BIT_USTAT_F_TINODE
	select ARCH_MIGHT_HAVE_PC_PARPORT
	select ARCH_MIGHT_HAVE_PC_SERIO
	select ARCH_NO_PREEMPT
	select ARCH_NO_SG_CHAIN
	select ARCH_USE_CMPXCHG_LOCKREF
	select DMA_OPS if PCI
	select FORCE_PCI if !ALPHA_JENSEN
	select PCI_DOMAINS if PCI
	select PCI_SYSCALL if PCI
	select HAVE_ASM_MODVERSIONS
	select HAVE_PCSPKR_PLATFORM
	select HAVE_PERF_EVENTS
	select NEED_DMA_MAP_STATE
	select NEED_SG_DMA_LENGTH
	select GENERIC_IRQ_PROBE
	select GENERIC_PCI_IOMAP
	select AUTO_IRQ_AFFINITY if SMP
	select GENERIC_IRQ_SHOW
	select ARCH_WANT_IPC_PARSE_VERSION
	select ARCH_HAVE_NMI_SAFE_CMPXCHG
	select AUDIT_ARCH
	select GENERIC_CPU_VULNERABILITIES
	select GENERIC_SMP_IDLE_THREAD
	select HAVE_ARCH_AUDITSYSCALL
	select HAVE_MOD_ARCH_SPECIFIC
	select MODULES_USE_ELF_RELA
	select ODD_RT_SIGACTION
	select OLD_SIGSUSPEND
	select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67
	select MMU_GATHER_NO_RANGE
	select SPARSEMEM_EXTREME if SPARSEMEM
	select ZONE_DMA
	help
	  The Alpha is a 64-bit general-purpose processor designed and
	  marketed by the Digital Equipment Corporation of blessed memory,
	  now Hewlett-Packard.  The Alpha Linux project has a home page at
	  <http://www.alphalinux.org/>.

config 64BIT
	def_bool y

config MMU
	bool
	default y

config ARCH_HAS_ILOG2_U32
	bool
	default n

config ARCH_HAS_ILOG2_U64
	bool
	default n

config GENERIC_CALIBRATE_DELAY
	bool
	default y

config GENERIC_ISA_DMA
	bool
	default y

config PGTABLE_LEVELS
	int
	default 3

config AUDIT_ARCH
	bool

menu "System setup"

choice
	prompt "Alpha system type"
	default ALPHA_GENERIC
	help
	  This is the system type of your hardware.  A "generic" kernel will
	  run on any supported Alpha system. However, if you configure a
	  kernel for your specific system, it will be faster and smaller.

	  To find out what type of Alpha system you have, you may want to
	  check out the Linux/Alpha FAQ, accessible on the WWW from
	  <http://www.alphalinux.org/>. In summary:

	  Alcor/Alpha-XLT     AS 600, AS 500, XL-300, XL-366
	  Alpha-XL            XL-233, XL-266
	  AlphaBook1          Alpha laptop
	  Avanti              AS 200, AS 205, AS 250, AS 255, AS 300, AS 400
	  Cabriolet           AlphaPC64, AlphaPCI64
	  DP264               DP264 / DS20 / ES40 / DS10 / DS10L
	  EB164               EB164 21164 evaluation board
	  EB64+               EB64+ 21064 evaluation board
	  EB66                EB66 21066 evaluation board
	  EB66+               EB66+ 21066 evaluation board
	  Jensen              DECpc 150, DEC 2000 models 300, 500
	  LX164               AlphaPC164-LX
	  Lynx                AS 2100A
	  Miata               Personal Workstation 433/500/600 a/au
	  Marvel              AlphaServer ES47 / ES80 / GS1280
	  Mikasa              AS 1000
	  Noname              AXPpci33, UDB (Multia)
	  Noritake            AS 1000A, AS 600A, AS 800
	  PC164               AlphaPC164
	  Rawhide             AS 1200, AS 4000, AS 4100
	  Ruffian             RPX164-2, AlphaPC164-UX, AlphaPC164-BX
	  SX164               AlphaPC164-SX
	  Sable               AS 2000, AS 2100
	  Shark               DS 20L
	  Takara              Takara (OEM)
	  Titan               AlphaServer ES45 / DS25 / DS15
	  Wildfire            AlphaServer GS 40/80/160/320

	  If you don't know what to do, choose "generic".

config ALPHA_GENERIC
	bool "Generic"
	depends on TTY
	select HAVE_EISA
	help
	  A generic kernel will run on all supported Alpha hardware.

config ALPHA_ALCOR
	bool "Alcor/Alpha-XLT"
	select HAVE_EISA
	help
	  For systems using the Digital ALCOR chipset: 5 chips (4, 64-bit data
	  slices (Data Switch, DSW) - 208-pin PQFP and 1 control (Control, I/O
	  Address, CIA) - a 383 pin plastic PGA).  It provides a DRAM
	  controller (256-bit memory bus) and a PCI interface.  It also does
	  all the work required to support an external Bcache and to maintain
	  memory coherence when a PCI device DMAs into (or out of) memory.

config ALPHA_XL
	bool "Alpha-XL"
	help
	  XL-233 and XL-266-based Alpha systems.

config ALPHA_BOOK1
	bool "AlphaBook1"
	help
	  Dec AlphaBook1/Burns Alpha-based laptops.

config ALPHA_AVANTI_CH
	bool "Avanti"

config ALPHA_CABRIOLET
	bool "Cabriolet"
	help
	  Cabriolet AlphaPC64, AlphaPCI64 systems.  Derived from EB64+ but now
	  baby-AT with Flash boot ROM, no on-board SCSI or Ethernet. 3 ISA
	  slots, 4 PCI slots (one pair are on a shared slot), uses plug-in
	  Bcache SIMMs.  Requires power supply with 3.3V output.

config ALPHA_DP264
	bool "DP264"
	help
	  Various 21264 systems with the tsunami core logic chipset.
	  API Networks: 264DP, UP2000(+), CS20;
	  Compaq: DS10(E,L), XP900, XP1000, DS20(E), ES40.

config ALPHA_EB164
	bool "EB164"
	help
	  EB164 21164 evaluation board from DEC.  Uses 21164 and ALCOR.  Has
	  ISA and PCI expansion (3 ISA slots, 2 64-bit PCI slots (one is
	  shared with an ISA slot) and 2 32-bit PCI slots.  Uses plus-in
	  Bcache SIMMs. I/O sub-system provides SuperI/O (2S, 1P, FD), KBD,
	  MOUSE (PS2 style), RTC/NVRAM.  Boot ROM is Flash.  PC-AT-sized
	  motherboard.  Requires power supply with 3.3V output.

config ALPHA_EB64P_CH
	bool "EB64+"

config ALPHA_EB66
	bool "EB66"
	help
	  A Digital DS group board.  Uses 21066 or 21066A.  I/O sub-system is
	  identical to EB64+.  Baby PC-AT size.  Runs from standard PC power
	  supply.  The EB66 schematic was published as a marketing poster
	  advertising the 21066 as "the first microprocessor in the world with
	  embedded PCI".

config ALPHA_EB66P
	bool "EB66+"
	help
	  Later variant of the EB66 board.

config ALPHA_EIGER
	bool "Eiger"
	help
	  Apparently an obscure OEM single-board computer based on the
	  Typhoon/Tsunami chipset family. Information on it is scanty.

config ALPHA_JENSEN
	bool "Jensen"
	select HAVE_EISA
	help
	  DEC PC 150 AXP (aka Jensen): This is a very old Digital system - one
	  of the first-generation Alpha systems. A number of these systems
	  seem to be available on the second- hand market. The Jensen is a
	  floor-standing tower system which originally used a 150MHz 21064 It
	  used programmable logic to interface a 486 EISA I/O bridge to the
	  CPU.

config ALPHA_LX164
	bool "LX164"
	help
	  A technical overview of this board is available at
	  <http://www.unix-ag.org/Linux-Alpha/Architectures/LX164.html>.

config ALPHA_LYNX
	bool "Lynx"
	select HAVE_EISA
	help
	  AlphaServer 2100A-based systems.

config ALPHA_MARVEL
	bool "Marvel"
	help
	  AlphaServer ES47 / ES80 / GS1280 based on EV7.

config ALPHA_MIATA
	bool "Miata"
	select HAVE_EISA
	help
	  The Digital PersonalWorkStation (PWS 433a, 433au, 500a, 500au, 600a,
	  or 600au).

config ALPHA_MIKASA
	bool "Mikasa"
	help
	  AlphaServer 1000-based Alpha systems.

config ALPHA_NAUTILUS
	bool "Nautilus"
	help
	  Alpha systems based on the AMD 751 & ALI 1543C chipsets.

config ALPHA_NONAME_CH
	bool "Noname"

config ALPHA_NORITAKE
	bool "Noritake"
	select HAVE_EISA
	help
	  AlphaServer 1000A, AlphaServer 600A, and AlphaServer 800-based
	  systems.

config ALPHA_PC164
	bool "PC164"

config ALPHA_P2K
	bool "Platform2000"

config ALPHA_RAWHIDE
	bool "Rawhide"
	select HAVE_EISA
	help
	  AlphaServer 1200, AlphaServer 4000 and AlphaServer 4100 machines.
	  See HOWTO at
	  <http://www.alphalinux.org/docs/rawhide/4100_install.shtml>.

config ALPHA_RUFFIAN
	bool "Ruffian"
	help
	  Samsung APC164UX.  There is a page on known problems and workarounds
	  at <http://www.alphalinux.org/faq/FAQ-11.html>.

config ALPHA_RX164
	bool "RX164"

config ALPHA_SX164
	bool "SX164"

config ALPHA_SABLE
	bool "Sable"
	select HAVE_EISA
	help
	  Digital AlphaServer 2000 and 2100-based systems.

config ALPHA_SHARK
	bool "Shark"

config ALPHA_TAKARA
	bool "Takara"
	help
	  Alpha 11164-based OEM single-board computer.

config ALPHA_TITAN
	bool "Titan"
	help
	  AlphaServer ES45/DS25 SMP based on EV68 and Titan chipset.

config ALPHA_WILDFIRE
	bool "Wildfire"
	help
	  AlphaServer GS 40/80/160/320 SMP based on the EV67 core.

endchoice

# clear all implied options (don't want default values for those):
# Most of these machines have ISA slots; not exactly sure which don't,
# and this doesn't activate hordes of code, so do it always.
config ISA
	bool
	default y
	help
	  Find out whether you have ISA slots on your motherboard.  ISA is the
	  name of a bus system, i.e. the way the CPU talks to the other stuff
	  inside your box.  Other bus systems are PCI, EISA, MicroChannel
	  (MCA) or VESA.  ISA is an older system, now being displaced by PCI;
	  newer boards don't support it.  If you have ISA, say Y, otherwise N.

config ISA_DMA_API
	bool
	default y

config ALPHA_NONAME
	bool
	depends on ALPHA_BOOK1 || ALPHA_NONAME_CH
	default y
	help
	  The AXPpci33 (aka NoName), is based on the EB66 (includes the Multia
	  UDB).  This design was produced by Digital's Technical OEM (TOEM)
	  group. It uses the 21066 processor running at 166MHz or 233MHz. It
	  is a baby-AT size, and runs from a standard PC power supply. It has
	  5 ISA slots and 3 PCI slots (one pair are a shared slot). There are
	  2 versions, with either PS/2 or large DIN connectors for the
	  keyboard.

config ALPHA_EV4
	bool
	depends on ALPHA_JENSEN || (ALPHA_SABLE && !ALPHA_GAMMA) || ALPHA_LYNX || ALPHA_NORITAKE && !ALPHA_PRIMO || ALPHA_MIKASA && !ALPHA_PRIMO || ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P_CH || ALPHA_XL || ALPHA_NONAME || ALPHA_EB66 || ALPHA_EB66P || ALPHA_P2K
	default y if !ALPHA_LYNX

config ALPHA_LCA
	bool
	depends on ALPHA_NONAME || ALPHA_EB66 || ALPHA_EB66P || ALPHA_P2K
	default y

config ALPHA_APECS
	bool
	depends on !ALPHA_PRIMO && (ALPHA_NORITAKE || ALPHA_MIKASA) || ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P_CH || ALPHA_XL
	default y

config ALPHA_EB64P
	bool
	depends on ALPHA_CABRIOLET || ALPHA_EB64P_CH
	default y
	help
	  Uses 21064 or 21064A and APECs.  Has ISA and PCI expansion (3 ISA,
	  2 PCI, one pair are on a shared slot). Supports 36-bit DRAM SIMs.
	  ISA bus generated by Intel SaturnI/O PCI-ISA bridge. On-board SCSI
	  (NCR 810 on PCI) Ethernet (Digital 21040), KBD, MOUSE (PS2 style),
	  SuperI/O (2S, 1P, FD), RTC/NVRAM. Boot ROM is EPROM.  PC-AT size.
	  Runs from standard PC power supply.

config ALPHA_EV5
	bool "EV5 CPU(s) (model 5/xxx)?" if ALPHA_LYNX
	default y if ALPHA_RX164 || ALPHA_RAWHIDE || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_RUFFIAN || ALPHA_SABLE && ALPHA_GAMMA || ALPHA_NORITAKE && ALPHA_PRIMO || ALPHA_MIKASA && ALPHA_PRIMO || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR

config ALPHA_EV4
	bool
	default y if ALPHA_LYNX && !ALPHA_EV5

config ALPHA_CIA
	bool
	depends on ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_RUFFIAN || ALPHA_NORITAKE && ALPHA_PRIMO || ALPHA_MIKASA && ALPHA_PRIMO || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR
	default y

config ALPHA_EV56
	bool "EV56 CPU (speed >= 366MHz)?" if ALPHA_ALCOR
	default y if ALPHA_RX164 || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_RUFFIAN || ALPHA_PC164 || ALPHA_TAKARA

config ALPHA_EV56
	prompt "EV56 CPU (speed >= 333MHz)?"
	depends on ALPHA_NORITAKE || ALPHA_PRIMO

config ALPHA_EV56
	prompt "EV56 CPU (speed >= 400MHz)?"
	depends on ALPHA_RAWHIDE

config ALPHA_PRIMO
	bool "EV5 CPU daughtercard (model 5/xxx)?"
	depends on ALPHA_NORITAKE || ALPHA_MIKASA
	help
	  Say Y if you have an AS 1000 5/xxx or an AS 1000A 5/xxx.

config ALPHA_GAMMA
	bool "EV5 CPU(s) (model 5/xxx)?"
	depends on ALPHA_SABLE
	help
	  Say Y if you have an AS 2000 5/xxx or an AS 2100 5/xxx.

config ALPHA_GAMMA
	bool
	depends on ALPHA_LYNX
	default y

config ALPHA_T2
	bool
	depends on ALPHA_SABLE || ALPHA_LYNX
	default y

config ALPHA_PYXIS
	bool
	depends on ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_RUFFIAN
	default y

config ALPHA_EV6
	bool
	depends on ALPHA_NAUTILUS || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_SHARK || ALPHA_DP264 || ALPHA_EIGER || ALPHA_MARVEL
	default y

config ALPHA_TSUNAMI
	bool
	depends on ALPHA_SHARK || ALPHA_DP264 || ALPHA_EIGER
	default y

config ALPHA_EV67
	bool "EV67 (or later) CPU (speed > 600MHz)?" if ALPHA_DP264 || ALPHA_EIGER
	default y if ALPHA_NAUTILUS || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_SHARK || ALPHA_MARVEL
	help
	  Is this a machine based on the EV67 core?  If in doubt, select N here
	  and the machine will be treated as an EV6.

config ALPHA_MCPCIA
	bool
	depends on ALPHA_RAWHIDE
	default y

config ALPHA_POLARIS
	bool
	depends on ALPHA_RX164
	default y

config ALPHA_IRONGATE
	bool
	depends on ALPHA_NAUTILUS
	default y

config GENERIC_HWEIGHT
	bool
	default y if !ALPHA_EV67

config ALPHA_AVANTI
	bool
	depends on ALPHA_XL || ALPHA_AVANTI_CH
	default y
	help
	  Avanti AS 200, AS 205, AS 250, AS 255, AS 300, and AS 400-based
	  Alphas. Info at
	  <http://www.unix-ag.org/Linux-Alpha/Architectures/Avanti.html>.

config ALPHA_BROKEN_IRQ_MASK
	bool
	depends on ALPHA_GENERIC || ALPHA_PC164
	default y

config VGA_HOSE
	bool
	depends on VGA_CONSOLE && (ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI)
	default y
	help
	  Support VGA on an arbitrary hose; needed for several platforms
	  which always have multiple hoses, and whose consoles support it.

config ALPHA_QEMU
	bool "Run under QEMU emulation"
	depends on !ALPHA_GENERIC
	help
	  Assume the presence of special features supported by QEMU PALcode
	  that reduce the overhead of system emulation.

	  Generic kernels will auto-detect QEMU.  But when building a
	  system-specific kernel, the assumption is that we want to
	  eliminate as many runtime tests as possible.

	  If unsure, say N.

config ALPHA_SRM
	bool "Use SRM as bootloader" if ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_NAUTILUS || ALPHA_NONAME
	depends on TTY
	default y if ALPHA_JENSEN || ALPHA_MIKASA || ALPHA_SABLE || ALPHA_LYNX || ALPHA_NORITAKE || ALPHA_DP264 || ALPHA_RAWHIDE || ALPHA_EIGER || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_SHARK || ALPHA_MARVEL
	help
	  There are two different types of booting firmware on Alphas: SRM,
	  which is command line driven, and ARC, which uses menus and arrow
	  keys. Details about the Linux/Alpha booting process are contained in
	  the Linux/Alpha FAQ, accessible on the WWW from
	  <http://www.alphalinux.org/>.

	  The usual way to load Linux on an Alpha machine is to use MILO
	  (a bootloader that lets you pass command line parameters to the
	  kernel just like lilo does for the x86 architecture) which can be
	  loaded either from ARC or can be installed directly as a permanent
	  firmware replacement from floppy (which requires changing a certain
	  jumper on the motherboard). If you want to do either of these, say N
	  here. If MILO doesn't work on your system (true for Jensen
	  motherboards), you can bypass it altogether and boot Linux directly
	  from an SRM console; say Y here in order to do that. Note that you
	  won't be able to boot from an IDE disk using SRM.

	  If unsure, say N.

config ARCH_MAY_HAVE_PC_FDC
	def_bool y

config SMP
	bool "Symmetric multi-processing support"
	depends on ALPHA_SABLE || ALPHA_LYNX || ALPHA_RAWHIDE || ALPHA_DP264 || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_GENERIC || ALPHA_SHARK || ALPHA_MARVEL
	help
	  This enables support for systems with more than one CPU. If you have
	  a system with only one CPU, say N. If you have a system with more
	  than one CPU, say Y.

	  If you say N here, the kernel will run on uni- and multiprocessor
	  machines, but will use only one CPU of a multiprocessor machine. If
	  you say Y here, the kernel will run on many, but not all,
	  uniprocessor machines. On a uniprocessor machine, the kernel
	  will run faster if you say N here.

	  See also the SMP-HOWTO available at
	  <https://www.tldp.org/docs.html#howto>.

	  If you don't know what to do here, say N.

config NR_CPUS
	int "Maximum number of CPUs (2-32)"
	range 2 32
	depends on SMP
	default "32" if ALPHA_GENERIC || ALPHA_MARVEL
	default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL
	help
	  MARVEL support can handle a maximum of 32 CPUs, all the others
	  with working support have a maximum of 4 CPUs.

config ARCH_SPARSEMEM_ENABLE
	bool "Sparse Memory Support"
	help
	  Say Y to support efficient handling of discontiguous physical memory,
	  for systems that have huge holes in the physical address space.

config ALPHA_WTINT
	bool "Use WTINT" if ALPHA_SRM || ALPHA_GENERIC
	default y if ALPHA_QEMU
	default n if ALPHA_EV5 || ALPHA_EV56 || (ALPHA_EV4 && !ALPHA_LCA)
	default n if !ALPHA_SRM && !ALPHA_GENERIC
	default y if SMP
	help
	  The Wait for Interrupt (WTINT) PALcall attempts to place the CPU
	  to sleep until the next interrupt.  This may reduce the power
	  consumed, and the heat produced by the computer.  However, it has
	  the side effect of making the cycle counter unreliable as a timing
	  device across the sleep.

	  For emulation under QEMU, definitely say Y here, as we have other
	  mechanisms for measuring time than the cycle counter.

	  For EV4 (but not LCA), EV5 and EV56 systems, or for systems running
	  MILO, sleep mode is not supported so you might as well say N here.

	  For SMP systems we cannot use the cycle counter for timing anyway,
	  so you might as well say Y here.

	  If unsure, say N.

# LARGE_VMALLOC is racy, if you *really* need it then fix it first
config ALPHA_LARGE_VMALLOC
	bool
	help
	  Process creation and other aspects of virtual memory management can
	  be streamlined if we restrict the kernel to one PGD for all vmalloc
	  allocations.  This equates to about 8GB.

	  Under normal circumstances, this is so far and above what is needed
	  as to be laughable.  However, there are certain applications (such
	  as benchmark-grade in-kernel web serving) that can make use of as
	  much vmalloc space as is available.

	  Say N unless you know you need gobs and gobs of vmalloc space.

config VERBOSE_MCHECK
	bool "Verbose Machine Checks"

config VERBOSE_MCHECK_ON
	int "Verbose Printing Mode (0=off, 1=on, 2=all)"
	depends on VERBOSE_MCHECK
	default 1
	help
	  This option allows the default printing mode to be set, and then
	  possibly overridden by a boot command argument.

	  For example, if one wanted the option of printing verbose
	  machine checks, but wanted the default to be as if verbose
	  machine check printing was turned off, then one would choose
	  the printing mode to be 0. Then, upon reboot, one could add
	  the boot command line "verbose_mcheck=1" to get the normal
	  verbose machine check printing, or "verbose_mcheck=2" to get
	  the maximum information available.

	  Take the default (1) unless you want more control or more info.

choice
	prompt "Timer interrupt frequency (HZ)?"
	default HZ_128 if ALPHA_QEMU
	default HZ_1200 if ALPHA_RAWHIDE
	default HZ_1024
	help
	  The frequency at which timer interrupts occur.  A high frequency
	  minimizes latency, whereas a low frequency minimizes overhead of
	  process accounting.  The later effect is especially significant
	  when being run under QEMU.

	  Note that some Alpha hardware cannot change the interrupt frequency
	  of the timer.  If unsure, say 1024 (or 1200 for Rawhide).

	config HZ_32
		bool "32 Hz"
	config HZ_64
		bool "64 Hz"
	config HZ_128
		bool "128 Hz"
	config HZ_256
		bool "256 Hz"
	config HZ_1024
		bool "1024 Hz"
	config HZ_1200
		bool "1200 Hz"
endchoice

config HZ
	int
	default 32 if HZ_32
	default 64 if HZ_64
	default 128 if HZ_128
	default 256 if HZ_256
	default 1200 if HZ_1200
	default 1024

config SRM_ENV
	tristate "SRM environment through procfs"
	depends on PROC_FS
	help
	  If you enable this option, a subdirectory inside /proc called
	  /proc/srm_environment will give you access to the all important
	  SRM environment variables (those which have a name) and also
	  to all others (by their internal number).

	  SRM is something like a BIOS for Alpha machines. There are some
	  other such BIOSes, like AlphaBIOS, which this driver cannot
	  support (hey, that's not SRM!).

	  Despite the fact that this driver doesn't work on all Alphas (but
	  only on those which have SRM as their firmware), it's save to
	  build it even if your particular machine doesn't know about SRM
	  (or if you intend to compile a generic kernel). It will simply
	  not create those subdirectory in /proc (and give you some warning,
	  of course).

	  This driver is also available as a module and will be called
	  srm_env then.

endmenu

# DUMMY_CONSOLE may be defined in drivers/video/console/Kconfig
# but we also need it if VGA_HOSE is set
config DUMMY_CONSOLE
	bool
	depends on VGA_HOSE
	default y

path: arch/alpha/Kconfig


code:
# SPDX-License-Identifier: GPL-2.0

config EARLY_PRINTK
	bool
	depends on ALPHA_GENERIC || ALPHA_SRM
	default y

config ALPHA_LEGACY_START_ADDRESS
	bool "Legacy kernel start address"
	depends on ALPHA_GENERIC
	default n
	help
	  The 2.4 kernel changed the kernel start address from 0x310000
	  to 0x810000 to make room for the Wildfire's larger SRM console.
	  Recent consoles on Titan and Marvel machines also require the
	  extra room.

	  If you're using aboot 0.7 or later, the bootloader will examine the
	  ELF headers to determine where to transfer control. Unfortunately,
	  most older bootloaders -- APB or MILO -- hardcoded the kernel start
	  address rather than examining the ELF headers, and the result is a
	  hard lockup.

	  Say Y if you have a broken bootloader.  Say N if you do not, or if
	  you wish to run on Wildfire, Titan, or Marvel.

config ALPHA_LEGACY_START_ADDRESS
	bool
	depends on !ALPHA_GENERIC && !ALPHA_TITAN && !ALPHA_MARVEL && !ALPHA_WILDFIRE
	default y

config MATHEMU
	tristate "Kernel FP software completion" if DEBUG_KERNEL && !SMP
	default y if !DEBUG_KERNEL || SMP
	help
	  This option is required for IEEE compliant floating point arithmetic
	  on the Alpha. The only time you would ever not say Y is to say M in
	  order to debug the code. Say Y unless you know what you are doing.


code:
#
# alpha/Makefile
#
# This file is subject to the terms and conditions of the GNU General Public
# License.  See the file "COPYING" in the main directory of this archive
# for more details.
#
# Copyright (C) 1994 by Linus Torvalds
#

NM := $(NM) -B

LDFLAGS_vmlinux	:= -static -N #-relax
CHECKFLAGS	+= -D__alpha__
cflags-y	:= -pipe -mno-fp-regs -ffixed-8
cflags-y	+= $(call cc-option, -fno-jump-tables)

cpuflags-$(CONFIG_ALPHA_EV4)		:= -mcpu=ev4
cpuflags-$(CONFIG_ALPHA_EV5)		:= -mcpu=ev5
cpuflags-$(CONFIG_ALPHA_EV56)		:= -mcpu=ev56
cpuflags-$(CONFIG_ALPHA_POLARIS)	:= -mcpu=pca56
cpuflags-$(CONFIG_ALPHA_SX164)		:= -mcpu=pca56
cpuflags-$(CONFIG_ALPHA_EV6)		:= -mcpu=ev6
cpuflags-$(CONFIG_ALPHA_EV67)		:= -mcpu=ev67
# If GENERIC, make sure to turn off any instruction set extensions that
# the host compiler might have on by default.  Given that EV4 and EV5
# have the same instruction set, prefer EV5 because an EV5 schedule is
# more likely to keep an EV4 processor busy than vice-versa.
cpuflags-$(CONFIG_ALPHA_GENERIC)	:= -mcpu=ev5

cflags-y				+= $(cpuflags-y)

# For TSUNAMI, we must have the assembler not emulate our instructions.
# The same is true for IRONGATE, POLARIS, PYXIS.
# BWX is most important, but we don't really want any emulation ever.
KBUILD_CFLAGS += $(cflags-y) -Wa,-mev6

libs-y				+= arch/alpha/lib/

# export what is needed by arch/alpha/boot/Makefile
LIBS_Y := $(patsubst %/, %/lib.a, $(libs-y))
export LIBS_Y

boot := arch/alpha/boot

#Default target when executing make with no arguments
all boot: $(boot)/vmlinux.gz

$(boot)/vmlinux.gz: vmlinux
	$(Q)$(MAKE) $(build)=$(boot) $@

bootimage bootpfile bootpzfile: vmlinux
	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@

archheaders:
	$(Q)$(MAKE) $(build)=arch/alpha/kernel/syscalls all

define archhelp
  echo '* boot		- Compressed kernel image (arch/alpha/boot/vmlinux.gz)'
  echo '  bootimage	- SRM bootable image (arch/alpha/boot/bootimage)'
  echo '  bootpfile	- BOOTP bootable image (arch/alpha/boot/bootpfile)'
  echo '  bootpzfile	- compressed kernel BOOTP image (arch/alpha/boot/bootpzfile)'
endef

path: arch/alpha/Makefile


code:
#
# arch/alpha/boot/Makefile
#
# This file is subject to the terms and conditions of the GNU General Public
# License.  See the file "COPYING" in the main directory of this archive
# for more details.
#
# Copyright (C) 1994 by Linus Torvalds
#

hostprogs	:= tools/mkbb tools/objstrip
targets		:= vmlinux.gz vmlinux \
		   vmlinux.nh tools/lxboot tools/bootlx tools/bootph \
		   tools/bootpzh bootloader bootpheader bootpzheader
OBJSTRIP	:= $(obj)/tools/objstrip

KBUILD_HOSTCFLAGS := -Wall -I$(objtree)/usr/include
BOOTCFLAGS	+= -I$(objtree)/$(obj) -I$(srctree)/$(obj)

# SRM bootable image.  Copy to offset 512 of a partition.
$(obj)/bootimage: $(addprefix $(obj)/tools/,mkbb lxboot bootlx) $(obj)/vmlinux.nh
	( cat $(obj)/tools/lxboot $(obj)/tools/bootlx $(obj)/vmlinux.nh ) > $@
	$(obj)/tools/mkbb $@ $(obj)/tools/lxboot
	@echo '  Bootimage $@ is ready'

# BOOTP bootable image.  Define INITRD during make to append initrd image.
$(obj)/bootpfile: $(obj)/tools/bootph $(obj)/vmlinux.nh
	cat $(obj)/tools/bootph $(obj)/vmlinux.nh > $@
ifdef INITRD
	cat $(INITRD) >> $@
endif

# Compressed kernel BOOTP bootable image.
# Define INITRD during make to append initrd image.
$(obj)/bootpzfile: $(obj)/tools/bootpzh $(obj)/vmlinux.nh.gz
	cat $(obj)/tools/bootpzh $(obj)/vmlinux.nh.gz > $@
ifdef INITRD
	cat $(INITRD) >> $@
endif

# Compressed kernel image
$(obj)/vmlinux.gz: $(obj)/vmlinux FORCE
	$(call if_changed,gzip)
	@echo '  Kernel $@ is ready'

$(obj)/main.o: $(obj)/ksize.h
$(obj)/bootp.o: $(obj)/ksize.h
$(obj)/bootpz.o: $(obj)/kzsize.h

$(obj)/ksize.h: $(obj)/vmlinux.nh FORCE
	echo "#define KERNEL_SIZE `ls -l $(obj)/vmlinux.nh | awk '{print $$5}'`" > $@T
ifdef INITRD
	[ -f $(INITRD) ] || exit 1
	echo "#define INITRD_IMAGE_SIZE `ls -l $(INITRD) | awk '{print $$5}'`" >> $@T
endif
	cmp -s $@T $@ || mv -f $@T $@
	rm -f $@T

$(obj)/kzsize.h: $(obj)/vmlinux.nh.gz FORCE
	echo "#define KERNEL_SIZE `ls -l $(obj)/vmlinux.nh | awk '{print $$5}'`" > $@T
	echo "#define KERNEL_Z_SIZE `ls -l $(obj)/vmlinux.nh.gz | awk '{print $$5}'`" >> $@T
ifdef INITRD
	[ -f $(INITRD) ] || exit 1
	echo "#define INITRD_IMAGE_SIZE `ls -l $(INITRD) | awk '{print $$5}'`" >> $@T
endif
	cmp -s $@T $@ || mv -f $@T $@
	rm -f $@T

quiet_cmd_strip = STRIP  $@
      cmd_strip = $(STRIP) -o $@ $<

$(obj)/vmlinux: vmlinux FORCE
	$(call if_changed,strip)

quiet_cmd_objstrip = OBJSTRIP $@
      cmd_objstrip = $(OBJSTRIP) $(OSFLAGS_$(@F)) $< $@

OSFLAGS_vmlinux.nh	:= -v
OSFLAGS_lxboot		:= -p
OSFLAGS_bootlx		:= -vb
OSFLAGS_bootph		:= -vb
OSFLAGS_bootpzh		:= -vb

$(obj)/vmlinux.nh: vmlinux $(OBJSTRIP) FORCE
	$(call if_changed,objstrip)

$(obj)/vmlinux.nh.gz: $(obj)/vmlinux.nh FORCE
	$(call if_changed,gzip)

$(obj)/tools/lxboot: $(obj)/bootloader $(OBJSTRIP) FORCE
	$(call if_changed,objstrip)

$(obj)/tools/bootlx: $(obj)/bootloader $(OBJSTRIP) FORCE
	$(call if_changed,objstrip)

$(obj)/tools/bootph: $(obj)/bootpheader $(OBJSTRIP) FORCE
	$(call if_changed,objstrip)

$(obj)/tools/bootpzh: $(obj)/bootpzheader $(OBJSTRIP) FORCE
	$(call if_changed,objstrip)

LDFLAGS_bootloader   := -static -T # -N -relax
LDFLAGS_bootloader   := -static -T # -N -relax
LDFLAGS_bootpheader  := -static -T # -N -relax
LDFLAGS_bootpzheader := -static -T # -N -relax

OBJ_bootlx   := $(obj)/head.o $(obj)/stdio.o $(obj)/main.o
OBJ_bootph   := $(obj)/head.o $(obj)/stdio.o $(obj)/bootp.o
OBJ_bootpzh  := $(obj)/head.o $(obj)/stdio.o $(obj)/bootpz.o $(obj)/misc.o

$(obj)/bootloader: $(obj)/bootloader.lds $(OBJ_bootlx) $(LIBS_Y) FORCE
	$(call if_changed,ld)

$(obj)/bootpheader: $(obj)/bootloader.lds $(OBJ_bootph) $(LIBS_Y) FORCE
	$(call if_changed,ld)

$(obj)/bootpzheader: $(obj)/bootloader.lds $(OBJ_bootpzh) $(LIBS_Y) FORCE
	$(call if_changed,ld)

$(obj)/misc.o: lib/inflate.c

path: arch/alpha/boot/Makefile


code:
/* SPDX-License-Identifier: GPL-2.0 */
OUTPUT_FORMAT("elf64-alpha")
ENTRY(__start)
printk = srm_printk;
SECTIONS
{
  . = 0x20000000;
  .text : { *(.text) }
  _etext = .;
  PROVIDE (etext = .);
  .rodata : { *(.rodata) *(.rodata.*) }
  .data : { *(.data) CONSTRUCTORS }
  .got : { *(.got) }
  .sdata : { *(.sdata) }
  _edata = .;
  PROVIDE (edata = .);
  .sbss : { *(.sbss) *(.scommon) }
  .bss : { *(.bss) *(COMMON) }
  _end = . ;
  PROVIDE (end = .);

  .mdebug 0 : { *(.mdebug) }
  .note 0 : { *(.note) }
  .comment 0 : { *(.comment) }
}


code:
// SPDX-License-Identifier: GPL-2.0
/*
 * arch/alpha/boot/bootp.c
 *
 * Copyright (C) 1997 Jay Estabrook
 *
 * This file is used for creating a bootp file for the Linux/AXP kernel
 *
 * based significantly on the arch/alpha/boot/main.c of Linus Torvalds
 */
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <generated/utsrelease.h>
#include <linux/mm.h>

#include <asm/console.h>
#include <asm/hwrpb.h>
#include <asm/io.h>

#include <stdarg.h>

#include "ksize.h"

extern unsigned long switch_to_osf_pal(unsigned long nr,
	struct pcb_struct *pcb_va, struct pcb_struct *pcb_pa,
	unsigned long *vptb);

extern void move_stack(unsigned long new_stack);

struct hwrpb_struct *hwrpb = INIT_HWRPB;
static struct pcb_struct pcb_va[1];

/*
 * Find a physical address of a virtual object..
 *
 * This is easy using the virtual page table address.
 */

static inline void *
find_pa(unsigned long *vptb, void *ptr)
{
	unsigned long address = (unsigned long) ptr;
	unsigned long result;

	result = vptb[address >> 13];
	result >>= 32;
	result <<= 13;
	result |= address & 0x1fff;
	return (void *) result;
}

/*
 * This function moves into OSF/1 pal-code, and has a temporary
 * PCB for that. The kernel proper should replace this PCB with
 * the real one as soon as possible.
 *
 * The page table muckery in here depends on the fact that the boot
 * code has the L1 page table identity-map itself in the second PTE
 * in the L1 page table. Thus the L1-page is virtually addressable
 * itself (through three levels) at virtual address 0x200802000.
 */

#define VPTB	((unsigned long *) 0x200000000)
#define L1	((unsigned long *) 0x200802000)

void
pal_init(void)
{
	unsigned long i, rev;
	struct percpu_struct * percpu;
	struct pcb_struct * pcb_pa;

	/* Create the dummy PCB.  */
	pcb_va->ksp = 0;
	pcb_va->usp = 0;
	pcb_va->ptbr = L1[1] >> 32;
	pcb_va->asn = 0;
	pcb_va->pcc = 0;
	pcb_va->unique = 0;
	pcb_va->flags = 1;
	pcb_va->res1 = 0;
	pcb_va->res2 = 0;
	pcb_pa = find_pa(VPTB, pcb_va);

	/*
	 * a0 = 2 (OSF)
	 * a1 = return address, but we give the asm the vaddr of the PCB
	 * a2 = physical addr of PCB
	 * a3 = new virtual page table pointer
	 * a4 = KSP (but the asm sets it)
	 */
	srm_printk("Switching to OSF PAL-code .. ");

	i = switch_to_osf_pal(2, pcb_va, pcb_pa, VPTB);
	if (i) {
		srm_printk("failed, code %ld\n", i);
		__halt();
	}

	percpu = (struct percpu_struct *)
		(INIT_HWRPB->processor_offset + (unsigned long) INIT_HWRPB);
	rev = percpu->pal_revision = percpu->palcode_avail[2];

	srm_printk("Ok (rev %lx)\n", rev);

	tbia(); /* do it directly in case we are SMP */
}

static inline void
load(unsigned long dst, unsigned long src, unsigned long count)
{
	memcpy((void *)dst, (void *)src, count);
}

/*
 * Start the kernel.
 */
static inline void
runkernel(void)
{
	__asm__ __volatile__(
		"bis %0,%0,$27\n\t"
		"jmp ($27)"
		: /* no outputs: it doesn't even return */
		: "r" (START_ADDR));
}

extern char _end;
#define KERNEL_ORIGIN \
	((((unsigned long)&_end) + 511) & ~511)

void
start_kernel(void)
{
	/*
	 * Note that this crufty stuff with static and envval
	 * and envbuf is because:
	 *
	 * 1. Frequently, the stack is short, and we don't want to overrun;
	 * 2. Frequently the stack is where we are going to copy the kernel to;
	 * 3. A certain SRM console required the GET_ENV output to stack.
	 *    ??? A comment in the aboot sources indicates that the GET_ENV
	 *    destination must be quadword aligned.  Might this explain the
	 *    behaviour, rather than requiring output to the stack, which
	 *    seems rather far-fetched.
	 */
	static long nbytes;
	static char envval[256] __attribute__((aligned(8)));
	static unsigned long initrd_start;

	srm_printk("Linux/AXP bootp loader for Linux " UTS_RELEASE "\n");
	if (INIT_HWRPB->pagesize != 8192) {
		srm_printk("Expected 8kB pages, got %ldkB\n",
		           INIT_HWRPB->pagesize >> 10);
		return;
	}
	if (INIT_HWRPB->vptb != (unsigned long) VPTB) {
		srm_printk("Expected vptb at %p, got %p\n",
			   VPTB, (void *)INIT_HWRPB->vptb);
		return;
	}
	pal_init();

	/* The initrd must be page-aligned.  See below for the
	   cause of the magic number 5.  */
	initrd_start = ((START_ADDR + 5*KERNEL_SIZE + PAGE_SIZE) |
			(PAGE_SIZE-1)) + 1;
#ifdef INITRD_IMAGE_SIZE
	srm_printk("Initrd positioned at %#lx\n", initrd_start);
#endif

	/*
	 * Move the stack to a safe place to ensure it won't be
	 * overwritten by kernel image.
	 */
	move_stack(initrd_start - PAGE_SIZE);

	nbytes = callback_getenv(ENV_BOOTED_OSFLAGS, envval, sizeof(envval));
	if (nbytes < 0 || nbytes >= sizeof(envval)) {
		nbytes = 0;
	}
	envval[nbytes] = '\0';
	srm_printk("Loading the kernel...'%s'\n", envval);

	/* NOTE: *no* callbacks or printouts from here on out!!! */

	/* This is a hack, as some consoles seem to get virtual 20000000 (ie
	 * where the SRM console puts the kernel bootp image) memory
	 * overlapping physical memory where the kernel wants to be put,
	 * which causes real problems when attempting to copy the former to
	 * the latter... :-(
	 *
	 * So, we first move the kernel virtual-to-physical way above where
	 * we physically want the kernel to end up, then copy it from there
	 * to its final resting place... ;-}
	 *
	 * Sigh...  */

#ifdef INITRD_IMAGE_SIZE
	load(initrd_start, KERNEL_ORIGIN+KERNEL_SIZE, INITRD_IMAGE_SIZE);
#endif
        load(START_ADDR+(4*KERNEL_SIZE), KERNEL_ORIGIN, KERNEL_SIZE);
        load(START_ADDR, START_ADDR+(4*KERNEL_SIZE), KERNEL_SIZE);

	memset((char*)ZERO_PGE, 0, PAGE_SIZE);
	strcpy((char*)ZERO_PGE, envval);
#ifdef INITRD_IMAGE_SIZE
	((long *)(ZERO_PGE+256))[0] = initrd_start;
	((long *)(ZERO_PGE+256))[1] = INITRD_IMAGE_SIZE;
#endif

	runkernel();
}


code:
// SPDX-License-Identifier: GPL-2.0
/*
 * arch/alpha/boot/bootpz.c
 *
 * Copyright (C) 1997 Jay Estabrook
 *
 * This file is used for creating a compressed BOOTP file for the
 * Linux/AXP kernel
 *
 * based significantly on the arch/alpha/boot/main.c of Linus Torvalds
 * and the decompression code from MILO.
 */
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <generated/utsrelease.h>
#include <linux/mm.h>

#include <asm/console.h>
#include <asm/hwrpb.h>
#include <asm/io.h>

#include <stdarg.h>

#include "kzsize.h"

/* FIXME FIXME FIXME */
#define MALLOC_AREA_SIZE 0x200000 /* 2MB for now */
/* FIXME FIXME FIXME */

/*
  WARNING NOTE

  It is very possible that turning on additional messages may cause
  kernel image corruption due to stack usage to do the printing.

*/

#undef DEBUG_CHECK_RANGE
#undef DEBUG_ADDRESSES
#undef DEBUG_LAST_STEPS

extern unsigned long switch_to_osf_pal(unsigned long nr,
	struct pcb_struct * pcb_va, struct pcb_struct * pcb_pa,
	unsigned long *vptb);

extern int decompress_kernel(void* destination, void *source,
			     size_t ksize, size_t kzsize);

extern void move_stack(unsigned long new_stack);

struct hwrpb_struct *hwrpb = INIT_HWRPB;
static struct pcb_struct pcb_va[1];

/*
 * Find a physical address of a virtual object..
 *
 * This is easy using the virtual page table address.
 */
#define VPTB	((unsigned long *) 0x200000000)

static inline unsigned long
find_pa(unsigned long address)
{
	unsigned long result;

	result = VPTB[address >> 13];
	result >>= 32;
	result <<= 13;
	result |= address & 0x1fff;
	return result;
}

int
check_range(unsigned long vstart, unsigned long vend,
	    unsigned long kstart, unsigned long kend)
{
	unsigned long vaddr, kaddr;

#ifdef DEBUG_CHECK_RANGE
	srm_printk("check_range: V[0x%lx:0x%lx] K[0x%lx:0x%lx]\n",
		   vstart, vend, kstart, kend);
#endif
	/* do some range checking for detecting an overlap... */
	for (vaddr = vstart; vaddr <= vend; vaddr += PAGE_SIZE)
	{
		kaddr = (find_pa(vaddr) | PAGE_OFFSET);
		if (kaddr >= kstart && kaddr <= kend)
		{
#ifdef DEBUG_CHECK_RANGE
			srm_printk("OVERLAP: vaddr 0x%lx kaddr 0x%lx"
				   " [0x%lx:0x%lx]\n",
				   vaddr, kaddr, kstart, kend);
#endif
			return 1;
		}
	}
	return 0;
}

/*
 * This function moves into OSF/1 pal-code, and has a temporary
 * PCB for that. The kernel proper should replace this PCB with
 * the real one as soon as possible.
 *
 * The page table muckery in here depends on the fact that the boot
 * code has the L1 page table identity-map itself in the second PTE
 * in the L1 page table. Thus the L1-page is virtually addressable
 * itself (through three levels) at virtual address 0x200802000.
 */

#define L1	((unsigned long *) 0x200802000)

void
pal_init(void)
{
	unsigned long i, rev;
	struct percpu_struct * percpu;
	struct pcb_struct * pcb_pa;

	/* Create the dummy PCB.  */
	pcb_va->ksp = 0;
	pcb_va->usp = 0;
	pcb_va->ptbr = L1[1] >> 32;
	pcb_va->asn = 0;
	pcb_va->pcc = 0;
	pcb_va->unique = 0;
	pcb_va->flags = 1;
	pcb_va->res1 = 0;
	pcb_va->res2 = 0;
	pcb_pa = (struct pcb_struct *)find_pa((unsigned long)pcb_va);

	/*
	 * a0 = 2 (OSF)
	 * a1 = return address, but we give the asm the vaddr of the PCB
	 * a2 = physical addr of PCB
	 * a3 = new virtual page table pointer
	 * a4 = KSP (but the asm sets it)
	 */
	srm_printk("Switching to OSF PAL-code... ");

	i = switch_to_osf_pal(2, pcb_va, pcb_pa, VPTB);
	if (i) {
		srm_printk("failed, code %ld\n", i);
		__halt();
	}

	percpu = (struct percpu_struct *)
		(INIT_HWRPB->processor_offset + (unsigned long) INIT_HWRPB);
	rev = percpu->pal_revision = percpu->palcode_avail[2];

	srm_printk("OK (rev %lx)\n", rev);

	tbia(); /* do it directly in case we are SMP */
}

/*
 * Start the kernel.
 */
static inline void
runkernel(void)
{
	__asm__ __volatile__(
		"bis %0,%0,$27\n\t"
		"jmp ($27)"
		: /* no outputs: it doesn't even return */
		: "r" (START_ADDR));
}

/* Must record the SP (it is virtual) on entry, so we can make sure
   not to overwrite it during movement or decompression. */
unsigned long SP_on_entry;

/* Calculate the kernel image address based on the end of the BOOTP
   bootstrapper (ie this program).
*/
extern char _end;
#define KERNEL_ORIGIN \
	((((unsigned long)&_end) + 511) & ~511)

/* Round address to next higher page boundary. */
#define NEXT_PAGE(a)	(((a) | (PAGE_SIZE - 1)) + 1)

#ifdef INITRD_IMAGE_SIZE
# define REAL_INITRD_SIZE INITRD_IMAGE_SIZE
#else
# define REAL_INITRD_SIZE 0
#endif

/* Defines from include/asm-alpha/system.h

	BOOT_ADDR	Virtual address at which the consoles loads
			the BOOTP image.

	KERNEL_START    KSEG address at which the kernel is built to run,
			which includes some initial data pages before the
			code.

	START_ADDR	KSEG address of the entry point of kernel code.

	ZERO_PGE	KSEG address of page full of zeroes, but
			upon entry to kernel, it can be expected
			to hold the parameter list and possible
			INTRD information.

   These are used in the local defines below.
*/

/* Virtual addresses for the BOOTP image. Note that this includes the
   bootstrapper code as well as the compressed kernel image, and
   possibly the INITRD image.

   Oh, and do NOT forget the STACK, which appears to be placed virtually
   beyond the end of the loaded image.
*/
#define V_BOOT_IMAGE_START	BOOT_ADDR
#define V_BOOT_IMAGE_END	SP_on_entry

/* Virtual addresses for just the bootstrapper part of the BOOTP image. */
#define V_BOOTSTRAPPER_START	BOOT_ADDR
#define V_BOOTSTRAPPER_END	KERNEL_ORIGIN

/* Virtual addresses for just the data part of the BOOTP
   image. This may also include the INITRD image, but always
   includes the STACK.
*/
#define V_DATA_START		KERNEL_ORIGIN
#define V_INITRD_START		(KERNEL_ORIGIN + KERNEL_Z_SIZE)
#define V_INTRD_END		(V_INITRD_START + REAL_INITRD_SIZE)
#define V_DATA_END	 	V_BOOT_IMAGE_END

/* KSEG addresses for the uncompressed kernel.

   Note that the end address includes workspace for the decompression.
   Note also that the DATA_START address is ZERO_PGE, to which we write
   just before jumping to the kernel image at START_ADDR.
 */
#define K_KERNEL_DATA_START	ZERO_PGE
#define K_KERNEL_IMAGE_START	START_ADDR
#define K_KERNEL_IMAGE_END	(START_ADDR + KERNEL_SIZE)

/* Define to where we may have to decompress the kernel image, before
   we move it to the final position, in case of overlap. This will be
   above the final position of the kernel.

   Regardless of overlap, we move the INITRD image to the end of this
   copy area, because there needs to be a buffer area after the kernel
   for "bootmem" anyway.
*/
#define K_COPY_IMAGE_START	NEXT_PAGE(K_KERNEL_IMAGE_END)
/* Reserve one page below INITRD for the new stack. */
#define K_INITRD_START \
    NEXT_PAGE(K_COPY_IMAGE_START + KERNEL_SIZE + PAGE_SIZE)
#define K_COPY_IMAGE_END \
    (K_INITRD_START + REAL_INITRD_SIZE + MALLOC_AREA_SIZE)
#define K_COPY_IMAGE_SIZE \
    NEXT_PAGE(K_COPY_IMAGE_END - K_COPY_IMAGE_START)

void
start_kernel(void)
{
	int must_move = 0;

	/* Initialize these for the decompression-in-place situation,
	   which is the smallest amount of work and most likely to
	   occur when using the normal START_ADDR of the kernel
	   (currently set to 16MB, to clear all console code.
	*/
	unsigned long uncompressed_image_start = K_KERNEL_IMAGE_START;
	unsigned long uncompressed_image_end = K_KERNEL_IMAGE_END;

	unsigned long initrd_image_start = K_INITRD_START;

	/*
	 * Note that this crufty stuff with static and envval
	 * and envbuf is because:
	 *
	 * 1. Frequently, the stack is short, and we don't want to overrun;
	 * 2. Frequently the stack is where we are going to copy the kernel to;
	 * 3. A certain SRM console required the GET_ENV output to stack.
	 *    ??? A comment in the aboot sources indicates that the GET_ENV
	 *    destination must be quadword aligned.  Might this explain the
	 *    behaviour, rather than requiring output to the stack, which
	 *    seems rather far-fetched.
	 */
	static long nbytes;
	static char envval[256] __attribute__((aligned(8)));
	register unsigned long asm_sp asm("30");

	SP_on_entry = asm_sp;

	srm_printk("Linux/Alpha BOOTPZ Loader for Linux " UTS_RELEASE "\n");

	/* Validity check the HWRPB. */
	if (INIT_HWRPB->pagesize != 8192) {
		srm_printk("Expected 8kB pages, got %ldkB\n",
		           INIT_HWRPB->pagesize >> 10);
		return;
	}
	if (INIT_HWRPB->vptb != (unsigned long) VPTB) {
		srm_printk("Expected vptb at %p, got %p\n",
			   VPTB, (void *)INIT_HWRPB->vptb);
		return;
	}

	/* PALcode (re)initialization. */
	pal_init();

	/* Get the parameter list from the console environment variable. */
	nbytes = callback_getenv(ENV_BOOTED_OSFLAGS, envval, sizeof(envval));
	if (nbytes < 0 || nbytes >= sizeof(envval)) {
		nbytes = 0;
	}
	envval[nbytes] = '\0';

#ifdef DEBUG_ADDRESSES
	srm_printk("START_ADDR 0x%lx\n", START_ADDR);
	srm_printk("KERNEL_ORIGIN 0x%lx\n", KERNEL_ORIGIN);
	srm_printk("KERNEL_SIZE 0x%x\n", KERNEL_SIZE);
	srm_printk("KERNEL_Z_SIZE 0x%x\n", KERNEL_Z_SIZE);
#endif

	/* Since all the SRM consoles load the BOOTP image at virtual
	 * 0x20000000, we have to ensure that the physical memory
	 * pages occupied by that image do NOT overlap the physical
	 * address range where the kernel wants to be run.  This
	 * causes real problems when attempting to cdecompress the
	 * former into the latter... :-(
	 *
	 * So, we may have to decompress/move the kernel/INITRD image
	 * virtual-to-physical someplace else first before moving
	 * kernel /INITRD to their final resting places... ;-}
	 *
	 * Sigh...
	 */

	/* First, check to see if the range of addresses occupied by
	   the bootstrapper part of the BOOTP image include any of the
	   physical pages into which the kernel will be placed for
	   execution.

	   We only need check on the final kernel image range, since we
	   will put the INITRD someplace that we can be sure is not
	   in conflict.
	 */
	if (check_range(V_BOOTSTRAPPER_START, V_BOOTSTRAPPER_END,
			K_KERNEL_DATA_START, K_KERNEL_IMAGE_END))
	{
		srm_printk("FATAL ERROR: overlap of bootstrapper code\n");
		__halt();
	}

	/* Next, check to see if the range of addresses occupied by
	   the compressed kernel/INITRD/stack portion of the BOOTP
	   image include any of the physical pages into which the
	   decompressed kernel or the INITRD will be placed for
	   execution.
	 */
	if (check_range(V_DATA_START, V_DATA_END,
			K_KERNEL_IMAGE_START, K_COPY_IMAGE_END))
	{
#ifdef DEBUG_ADDRESSES
		srm_printk("OVERLAP: cannot decompress in place\n");
#endif
		uncompressed_image_start = K_COPY_IMAGE_START;
		uncompressed_image_end = K_COPY_IMAGE_END;
		must_move = 1;

		/* Finally, check to see if the range of addresses
		   occupied by the compressed kernel/INITRD part of
		   the BOOTP image include any of the physical pages
		   into which that part is to be copied for
		   decompression.
		*/
		while (check_range(V_DATA_START, V_DATA_END,
				   uncompressed_image_start,
				   uncompressed_image_end))
		{
#if 0
			uncompressed_image_start += K_COPY_IMAGE_SIZE;
			uncompressed_image_end += K_COPY_IMAGE_SIZE;
			initrd_image_start += K_COPY_IMAGE_SIZE;
#else
			/* Keep as close as possible to end of BOOTP image. */
			uncompressed_image_start += PAGE_SIZE;
			uncompressed_image_end += PAGE_SIZE;
			initrd_image_start += PAGE_SIZE;
#endif
		}
	}

	srm_printk("Starting to load the kernel with args '%s'\n", envval);

#ifdef DEBUG_ADDRESSES
	srm_printk("Decompressing the kernel...\n"
		   "...from 0x%lx to 0x%lx size 0x%x\n",
		   V_DATA_START,
		   uncompressed_image_start,
		   KERNEL_SIZE);
#endif
        decompress_kernel((void *)uncompressed_image_start,
			  (void *)V_DATA_START,
			  KERNEL_SIZE, KERNEL_Z_SIZE);

	/*
	 * Now, move things to their final positions, if/as required.
	 */

#ifdef INITRD_IMAGE_SIZE

	/* First, we always move the INITRD image, if present. */
#ifdef DEBUG_ADDRESSES
	srm_printk("Moving the INITRD image...\n"
		   " from 0x%lx to 0x%lx size 0x%x\n",
		   V_INITRD_START,
		   initrd_image_start,
		   INITRD_IMAGE_SIZE);
#endif
	memcpy((void *)initrd_image_start, (void *)V_INITRD_START,
	       INITRD_IMAGE_SIZE);

#endif /* INITRD_IMAGE_SIZE */

	/* Next, we may have to move the uncompressed kernel to the
	   final destination.
	 */
	if (must_move) {
#ifdef DEBUG_ADDRESSES
		srm_printk("Moving the uncompressed kernel...\n"
			   "...from 0x%lx to 0x%lx size 0x%x\n",
			   uncompressed_image_start,
			   K_KERNEL_IMAGE_START,
			   (unsigned)KERNEL_SIZE);
#endif
		/*
		 * Move the stack to a safe place to ensure it won't be
		 * overwritten by kernel image.
		 */
		move_stack(initrd_image_start - PAGE_SIZE);

		memcpy((void *)K_KERNEL_IMAGE_START,
		       (void *)uncompressed_image_start, KERNEL_SIZE);
	}

	/* Clear the zero page, then move the argument list in. */
#ifdef DEBUG_LAST_STEPS
	srm_printk("Preparing ZERO_PGE...\n");
#endif
	memset((char*)ZERO_PGE, 0, PAGE_SIZE);
	strcpy((char*)ZERO_PGE, envval);

#ifdef INITRD_IMAGE_SIZE

#ifdef DEBUG_LAST_STEPS
	srm_printk("Preparing INITRD info...\n");
#endif
	/* Finally, set the INITRD paramenters for the kernel. */
	((long *)(ZERO_PGE+256))[0] = initrd_image_start;
	((long *)(ZERO_PGE+256))[1] = INITRD_IMAGE_SIZE;

#endif /* INITRD_IMAGE_SIZE */

#ifdef DEBUG_LAST_STEPS
	srm_printk("Doing 'runkernel()'...\n");
#endif
	runkernel();
}

 /* dummy function, should never be called. */
void *__kmalloc(size_t size, gfp_t flags)
{
	return (void *)NULL;
}


code:
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * arch/alpha/boot/head.S
 *
 * initial bootloader stuff..
 */

#include <asm/pal.h>

	.set noreorder
	.globl	__start
	.ent	__start
__start:
	br	$29,2f
2:	ldgp	$29,0($29)
	jsr	$26,start_kernel
	call_pal PAL_halt
	.end __start

	.align 5
	.globl	wrent
	.ent	wrent
wrent:
	.prologue 0
	call_pal PAL_wrent
	ret ($26)
	.end wrent

	.align 5
	.globl	wrkgp
	.ent	wrkgp
wrkgp:
	.prologue 0
	call_pal PAL_wrkgp
	ret ($26)
	.end wrkgp

	.align 5
	.globl	switch_to_osf_pal
	.ent	switch_to_osf_pal
switch_to_osf_pal:
	subq	$30,128,$30
	.frame	$30,128,$26
	stq	$26,0($30)
	stq	$1,8($30)
	stq	$2,16($30)
	stq	$3,24($30)
	stq	$4,32($30)
	stq	$5,40($30)
	stq	$6,48($30)
	stq	$7,56($30)
	stq	$8,64($30)
	stq	$9,72($30)
	stq	$10,80($30)
	stq	$11,88($30)
	stq	$12,96($30)
	stq	$13,104($30)
	stq	$14,112($30)
	stq	$15,120($30)
	.prologue 0

	stq	$30,0($17)	/* save KSP in PCB */

	bis	$30,$30,$20	/* a4 = KSP */
	br	$17,1f

	ldq	$26,0($30)
	ldq	$1,8($30)
	ldq	$2,16($30)
	ldq	$3,24($30)
	ldq	$4,32($30)
	ldq	$5,40($30)
	ldq	$6,48($30)
	ldq	$7,56($30)
	ldq	$8,64($30)
	ldq	$9,72($30)
	ldq	$10,80($30)
	ldq	$11,88($30)
	ldq	$12,96($30)
	ldq	$13,104($30)
	ldq	$14,112($30)
	ldq	$15,120($30)
	addq	$30,128,$30
	ret ($26)
1:	call_pal PAL_swppal
	.end	switch_to_osf_pal

	.align 3
	.globl	tbi
	.ent	tbi
tbi:
	.prologue 0
	call_pal PAL_tbi
	ret	($26)
	.end tbi

	.align 3
	.globl	halt
	.ent	halt
halt:
	.prologue 0
	call_pal PAL_halt
	.end halt

/* $16 - new stack page */
	.align 3
	.globl	move_stack
	.ent	move_stack
move_stack:
	.prologue 0
	lda	$0, 0x1fff($31)
	and	$0, $30, $1			/* Stack offset */
	or	$1, $16, $16			/* New stack pointer */
	mov	$30, $1
	mov	$16, $2
1:	ldq	$3, 0($1)			/* Move the stack */
	addq	$1, 8, $1
	stq	$3, 0($2)
	and	$0, $1, $4
	addq	$2, 8, $2
	bne	$4, 1b
	mov	$16, $30
	ret	($26)
	.end move_stack


code:
// SPDX-License-Identifier: GPL-2.0
/*
 * arch/alpha/boot/main.c
 *
 * Copyright (C) 1994, 1995 Linus Torvalds
 *
 * This file is the bootloader for the Linux/AXP kernel
 */
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <generated/utsrelease.h>
#include <linux/mm.h>

#include <asm/console.h>
#include <asm/hwrpb.h>

#include <stdarg.h>

#include "ksize.h"

extern unsigned long switch_to_osf_pal(unsigned long nr,
	struct pcb_struct * pcb_va, struct pcb_struct * pcb_pa,
	unsigned long *vptb);
struct hwrpb_struct *hwrpb = INIT_HWRPB;
static struct pcb_struct pcb_va[1];

/*
 * Find a physical address of a virtual object..
 *
 * This is easy using the virtual page table address.
 */

static inline void *
find_pa(unsigned long *vptb, void *ptr)
{
	unsigned long address = (unsigned long) ptr;
	unsigned long result;

	result = vptb[address >> 13];
	result >>= 32;
	result <<= 13;
	result |= address & 0x1fff;
	return (void *) result;
}

/*
 * This function moves into OSF/1 pal-code, and has a temporary
 * PCB for that. The kernel proper should replace this PCB with
 * the real one as soon as possible.
 *
 * The page table muckery in here depends on the fact that the boot
 * code has the L1 page table identity-map itself in the second PTE
 * in the L1 page table. Thus the L1-page is virtually addressable
 * itself (through three levels) at virtual address 0x200802000.
 */

#define VPTB	((unsigned long *) 0x200000000)
#define L1	((unsigned long *) 0x200802000)

void
pal_init(void)
{
	unsigned long i, rev;
	struct percpu_struct * percpu;
	struct pcb_struct * pcb_pa;

	/* Create the dummy PCB.  */
	pcb_va->ksp = 0;
	pcb_va->usp = 0;
	pcb_va->ptbr = L1[1] >> 32;
	pcb_va->asn = 0;
	pcb_va->pcc = 0;
	pcb_va->unique = 0;
	pcb_va->flags = 1;
	pcb_va->res1 = 0;
	pcb_va->res2 = 0;
	pcb_pa = find_pa(VPTB, pcb_va);

	/*
	 * a0 = 2 (OSF)
	 * a1 = return address, but we give the asm the vaddr of the PCB
	 * a2 = physical addr of PCB
	 * a3 = new virtual page table pointer
	 * a4 = KSP (but the asm sets it)
	 */
	srm_printk("Switching to OSF PAL-code .. ");

	i = switch_to_osf_pal(2, pcb_va, pcb_pa, VPTB);
	if (i) {
		srm_printk("failed, code %ld\n", i);
		__halt();
	}

	percpu = (struct percpu_struct *)
		(INIT_HWRPB->processor_offset + (unsigned long) INIT_HWRPB);
	rev = percpu->pal_revision = percpu->palcode_avail[2];

	srm_printk("Ok (rev %lx)\n", rev);

	tbia(); /* do it directly in case we are SMP */
}

static inline long openboot(void)
{
	char bootdev[256];
	long result;

	result = callback_getenv(ENV_BOOTED_DEV, bootdev, 255);
	if (result < 0)
		return result;
	return callback_open(bootdev, result & 255);
}

static inline long close(long dev)
{
	return callback_close(dev);
}

static inline long load(long dev, unsigned long addr, unsigned long count)
{
	char bootfile[256];
	extern char _end;
	long result, boot_size = &_end - (char *) BOOT_ADDR;

	result = callback_getenv(ENV_BOOTED_FILE, bootfile, 255);
	if (result < 0)
		return result;
	result &= 255;
	bootfile[result] = '\0';
	if (result)
		srm_printk("Boot file specification (%s) not implemented\n",
		       bootfile);
	return callback_read(dev, count, (void *)addr, boot_size/512 + 1);
}

/*
 * Start the kernel.
 */
static void runkernel(void)
{
	__asm__ __volatile__(
		"bis %1,%1,$30\n\t"
		"bis %0,%0,$26\n\t"
		"ret ($26)"
		: /* no outputs: it doesn't even return */
		: "r" (START_ADDR),
		  "r" (PAGE_SIZE + INIT_STACK));
}

void start_kernel(void)
{
	long i;
	long dev;
	int nbytes;
	char envval[256];

	srm_printk("Linux/AXP bootloader for Linux " UTS_RELEASE "\n");
	if (INIT_HWRPB->pagesize != 8192) {
		srm_printk("Expected 8kB pages, got %ldkB\n", INIT_HWRPB->pagesize >> 10);
		return;
	}
	pal_init();
	dev = openboot();
	if (dev < 0) {
		srm_printk("Unable to open boot device: %016lx\n", dev);
		return;
	}
	dev &= 0xffffffff;
	srm_printk("Loading vmlinux ...");
	i = load(dev, START_ADDR, KERNEL_SIZE);
	close(dev);
	if (i != KERNEL_SIZE) {
		srm_printk("Failed (%lx)\n", i);
		return;
	}

	nbytes = callback_getenv(ENV_BOOTED_OSFLAGS, envval, sizeof(envval));
	if (nbytes < 0) {
		nbytes = 0;
	}
	envval[nbytes] = '\0';
	strcpy((char*)ZERO_PGE, envval);

	srm_printk(" Ok\nNow booting the kernel\n");
	runkernel();
	for (i = 0 ; i < 0x100000000 ; i++)
		/* nothing */;
	__halt();
}