arch/s390/mm/fault.c

Source file repositories/reference/linux-study-clean/arch/s390/mm/fault.c

File Facts

System
Linux kernel
Corpus path
arch/s390/mm/fault.c
Extension
.c
Size
12895 bytes
Lines
481
Domain
Architecture Layer
Bucket
arch/s390
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

fault = handle_mm_fault(vma, address, flags | FAULT_FLAG_VMA_LOCK, regs);
	if (!(fault & (VM_FAULT_RETRY | VM_FAULT_COMPLETED)))
		vma_end_read(vma);
	if (!(fault & VM_FAULT_RETRY)) {
		count_vm_vma_lock_event(VMA_LOCK_SUCCESS);
		goto done;
	}
	count_vm_vma_lock_event(VMA_LOCK_RETRY);
	if (fault & VM_FAULT_MAJOR)
		flags |= FAULT_FLAG_TRIED;
	/* Quick path to respond to signals */
	if (fault_signal_pending(fault, regs)) {
		if (!user_mode(regs))
			handle_fault_error_nolock(regs, 0);
		return;
	}
lock_mmap:
retry:
	vma = lock_mm_and_find_vma(mm, address, regs);
	if (!vma)
		return handle_fault_error_nolock(regs, SEGV_MAPERR);
	if (unlikely(!(vma->vm_flags & access)))
		return handle_fault_error(regs, SEGV_ACCERR);
	fault = handle_mm_fault(vma, address, flags, regs);
	if (fault_signal_pending(fault, regs)) {
		if (!user_mode(regs))
			handle_fault_error_nolock(regs, 0);
		return;
	}
	/* The fault is fully completed (including releasing mmap lock) */
	if (fault & VM_FAULT_COMPLETED)
		return;
	if (fault & VM_FAULT_RETRY) {
		flags |= FAULT_FLAG_TRIED;
		goto retry;
	}
	mmap_read_unlock(mm);
done:
	if (!(fault & VM_FAULT_ERROR))
		return;
	if (fault & VM_FAULT_OOM) {
		if (!user_mode(regs))
			handle_fault_error_nolock(regs, 0);
		else
			pagefault_out_of_memory();
	} else if (fault & VM_FAULT_SIGSEGV) {
		if (!user_mode(regs))
			handle_fault_error_nolock(regs, 0);
		else
			do_sigsegv(regs, SEGV_MAPERR);
	} else if (fault & (VM_FAULT_SIGBUS | VM_FAULT_HWPOISON |
			    VM_FAULT_HWPOISON_LARGE)) {
		if (!user_mode(regs))
			handle_fault_error_nolock(regs, 0);
		else
			do_sigbus(regs);
	} else {
		pr_emerg("Unexpected fault flags: %08x\n", fault);
		BUG();
	}
}

void do_protection_exception(struct pt_regs *regs)
{
	union teid teid = { .val = regs->int_parm_long };

	/*
	 * Protection exceptions are suppressing, decrement psw address.
	 * The exception to this rule are aborted transactions, for these
	 * the PSW already points to the correct location.
	 */
	if (!(regs->int_code & 0x200)) {
		regs->psw.addr = __rewind_psw(regs->psw, regs->int_code >> 16);
		set_pt_regs_flag(regs, PIF_PSW_ADDR_ADJUSTED);
	}
	/*
	 * If bit 61 if the TEID is not set, the remainder of the
	 * TEID is unpredictable. Special handling is required.
	 */
	if (unlikely(!teid.b61)) {
		if (user_mode(regs)) {
			dump_fault_info(regs);
			die(regs, "Unexpected TEID");
		}
		/* Assume low-address protection in kernel mode. */
		return handle_fault_error_nolock(regs, 0);
	}
	if (unlikely(cpu_has_nx() && teid.b56)) {
		regs->int_parm_long = (teid.addr * PAGE_SIZE) | (regs->psw.addr & PAGE_MASK);
		return handle_fault_error_nolock(regs, SEGV_ACCERR);

Annotation

Implementation Notes