Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72dace96 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky
Browse files

s390/jump label: improve and fix sanity check



Fix the output of the jump label sanity check and also print the
code pattern that is supposed to be written to the jump label.

Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 6f367769
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -36,16 +36,20 @@ static void jump_label_make_branch(struct jump_entry *entry, struct insn *insn)
	insn->offset = (entry->target - entry->code) >> 1;
}

static void jump_label_bug(struct jump_entry *entry, struct insn *insn)
static void jump_label_bug(struct jump_entry *entry, struct insn *expected,
			   struct insn *new)
{
	unsigned char *ipc = (unsigned char *)entry->code;
	unsigned char *ipe = (unsigned char *)insn;
	unsigned char *ipe = (unsigned char *)expected;
	unsigned char *ipn = (unsigned char *)new;

	pr_emerg("Jump label code mismatch at %pS [%p]\n", ipc, ipc);
	pr_emerg("Found:    %02x %02x %02x %02x %02x %02x\n",
		 ipc[0], ipc[1], ipc[2], ipc[3], ipc[4], ipc[5]);
	pr_emerg("Expected: %02x %02x %02x %02x %02x %02x\n",
		 ipe[0], ipe[1], ipe[2], ipe[3], ipe[4], ipe[5]);
	pr_emerg("New:      %02x %02x %02x %02x %02x %02x\n",
		 ipn[0], ipn[1], ipn[2], ipn[3], ipn[4], ipn[5]);
	panic("Corrupted kernel text");
}

@@ -69,10 +73,10 @@ static void __jump_label_transform(struct jump_entry *entry,
	}
	if (init) {
		if (memcmp((void *)entry->code, &orignop, sizeof(orignop)))
			jump_label_bug(entry, &old);
			jump_label_bug(entry, &orignop, &new);
	} else {
		if (memcmp((void *)entry->code, &old, sizeof(old)))
			jump_label_bug(entry, &old);
			jump_label_bug(entry, &old, &new);
	}
	probe_kernel_write((void *)entry->code, &new, sizeof(new));
}