arch/powerpc/lib/test_emulate_step.c

Source file repositories/reference/linux-study-clean/arch/powerpc/lib/test_emulate_step.c

File Facts

System
Linux kernel
Corpus path
arch/powerpc/lib/test_emulate_step.c
Extension
.c
Size
37745 bytes
Lines
1742
Domain
Architecture Layer
Bucket
arch/powerpc
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

struct compute_test {
	char *mnemonic;
	unsigned long cpu_feature;
	struct {
		char *descr;
		unsigned long flags;
		ppc_inst_t instr;
		struct pt_regs regs;
	} subtests[MAX_SUBTESTS + 1];
};

/* Extreme values for si0||si1 (the MLS:D-form 34 bit immediate field) */
#define SI_MIN BIT(33)
#define SI_MAX (BIT(33) - 1)
#define SI_UMAX (BIT(34) - 1)

static struct compute_test compute_tests[] = {
	{
		.mnemonic = "nop",
		.subtests = {
			{
				.descr = "R0 = LONG_MAX",
				.instr = ppc_inst(PPC_RAW_NOP()),
				.regs = {
					.gpr[0] = LONG_MAX,
				}
			}
		}
	},
	{
		.mnemonic = "setb",
		.cpu_feature = CPU_FTR_ARCH_300,
		.subtests = {
			{
				.descr = "BFA = 1, CR = GT",
				.instr = ppc_inst(PPC_RAW_SETB(20, 1)),
				.regs = {
					.ccr = 0x4000000,
				}
			},
			{
				.descr = "BFA = 4, CR = LT",
				.instr = ppc_inst(PPC_RAW_SETB(20, 4)),
				.regs = {
					.ccr = 0x8000,
				}
			},
			{
				.descr = "BFA = 5, CR = EQ",
				.instr = ppc_inst(PPC_RAW_SETB(20, 5)),
				.regs = {
					.ccr = 0x200,
				}
			}
		}
	},
	{
		.mnemonic = "add",
		.subtests = {
			{
				.descr = "RA = LONG_MIN, RB = LONG_MIN",
				.instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
				.regs = {
					.gpr[21] = LONG_MIN,
					.gpr[22] = LONG_MIN,
				}
			},
			{
				.descr = "RA = LONG_MIN, RB = LONG_MAX",
				.instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
				.regs = {
					.gpr[21] = LONG_MIN,
					.gpr[22] = LONG_MAX,
				}
			},
			{
				.descr = "RA = LONG_MAX, RB = LONG_MAX",
				.instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
				.regs = {
					.gpr[21] = LONG_MAX,
					.gpr[22] = LONG_MAX,
				}
			},
			{
				.descr = "RA = ULONG_MAX, RB = ULONG_MAX",
				.instr = ppc_inst(PPC_RAW_ADD(20, 21, 22)),
				.regs = {
					.gpr[21] = ULONG_MAX,
					.gpr[22] = ULONG_MAX,
				}

Annotation

Implementation Notes