arch/parisc/kernel/alternative.c

Source file repositories/reference/linux-study-clean/arch/parisc/kernel/alternative.c

File Facts

System
Linux kernel
Corpus path
arch/parisc/kernel/alternative.c
Extension
.c
Size
3376 bytes
Lines
123
Domain
Architecture Layer
Bucket
arch/parisc
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

if (replacement == INSN_PxTLB) {
			replacement = *from;
			if (boot_cpu_data.cpu_type >= pcxu) /* >= pa2.0 ? */
				replacement |= (1 << 10); /* set el bit */
		}

		/*
		 * Replace instruction with NOPs?
		 * For long distance insert a branch instruction instead.
		 */
		if (replacement == INSN_NOP && len > 1)
			replacement = 0xe8000002 + (len-2)*8; /* "b,n .+8" */

		pr_debug("ALTERNATIVE %3d: Cond %2x, Replace %2d instructions to 0x%08x @ 0x%px (%pS)\n",
			index, cond, len, replacement, from, from);

		if (len < 0) {
			/* Replace multiple instruction by new code */
			u32 *source;
			len = -len;
			source = (u32 *)((ulong)&entry->replacement + entry->replacement);
			memcpy(from, source, 4 * len);
		} else {
			/* Replace by one instruction */
			*from = replacement;
		}
		applied++;
	}

	pr_info("%s%salternatives: applied %d out of %d patches\n",
		module_name ? : "", module_name ? " " : "",
		applied, index);
}


void __init apply_alternatives_all(void)
{
	set_kernel_text_rw(1);

	apply_alternatives((struct alt_instr *) &__alt_instructions,
		(struct alt_instr *) &__alt_instructions_end, NULL);

	if (cache_info.dc_size == 0 && cache_info.ic_size == 0) {
		pr_info("alternatives: optimizing cache-flushes.\n");
		static_branch_disable(&parisc_has_cache);
	}
	if (cache_info.dc_size == 0)
		static_branch_disable(&parisc_has_dcache);
	if (cache_info.ic_size == 0)
		static_branch_disable(&parisc_has_icache);

	set_kernel_text_rw(0);
}

Annotation

Implementation Notes