Miroslav Benes c38cd1
From: Peter Zijlstra <peterz@infradead.org>
Miroslav Benes c38cd1
Date: Fri, 24 Apr 2020 16:18:58 +0200
Miroslav Benes c38cd1
Subject: objtool: Remove INSN_STACK
Miroslav Benes c38cd1
Git-commit: b09fb65e863733e192d4825a285b4b4998969ce0
Miroslav Benes c38cd1
Patch-mainline: v5.8-rc1
Miroslav Benes c38cd1
References: bsc#1202396
Miroslav Benes c38cd1
Miroslav Benes c38cd1
With the unconditional use of handle_insn_ops(), INSN_STACK has lost
Miroslav Benes c38cd1
its purpose. Remove it.
Miroslav Benes c38cd1
Miroslav Benes c38cd1
Suggested-by: Julien Thierry <jthierry@redhat.com>
Miroslav Benes c38cd1
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Miroslav Benes c38cd1
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Miroslav Benes c38cd1
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Miroslav Benes c38cd1
Link: https://lkml.kernel.org/r/20200428191659.854203028@infradead.org
Miroslav Benes c38cd1
Miroslav Benes c38cd1
Acked-by: Miroslav Benes <mbenes@suse.cz>
Miroslav Benes c38cd1
---
Miroslav Benes c38cd1
 tools/objtool/arch.h            |    1 -
Miroslav Benes c38cd1
 tools/objtool/arch/x86/decode.c |   23 -----------------------
Miroslav Benes c38cd1
 tools/objtool/check.c           |    3 ---
Miroslav Benes c38cd1
 3 files changed, 27 deletions(-)
Miroslav Benes c38cd1
Miroslav Benes c38cd1
--- a/tools/objtool/arch.h
Miroslav Benes c38cd1
+++ b/tools/objtool/arch.h
Miroslav Benes c38cd1
@@ -20,7 +20,6 @@ enum insn_type {
Miroslav Benes c38cd1
 	INSN_CALL_DYNAMIC,
Miroslav Benes c38cd1
 	INSN_RETURN,
Miroslav Benes c38cd1
 	INSN_CONTEXT_SWITCH,
Miroslav Benes c38cd1
-	INSN_STACK,
Miroslav Benes c38cd1
 	INSN_BUG,
Miroslav Benes c38cd1
 	INSN_NOP,
Miroslav Benes c38cd1
 	INSN_STAC,
Miroslav Benes c38cd1
--- a/tools/objtool/arch/x86/decode.c
Miroslav Benes c38cd1
+++ b/tools/objtool/arch/x86/decode.c
Miroslav Benes c38cd1
@@ -130,7 +130,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		if (rex_w && !rex_b && modrm_mod == 3 && modrm_rm == 4) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* add/sub reg, %rsp */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_ADD;
Miroslav Benes c38cd1
 				op->src.reg = op_to_cfi_reg[modrm_reg][rex_r];
Miroslav Benes c38cd1
@@ -143,7 +142,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 	case 0x50 ... 0x57:
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 		/* push reg */
Miroslav Benes c38cd1
-		*type = INSN_STACK;
Miroslav Benes c38cd1
 		ADD_OP(op) {
Miroslav Benes c38cd1
 			op->src.type = OP_SRC_REG;
Miroslav Benes c38cd1
 			op->src.reg = op_to_cfi_reg[op1 & 0x7][rex_b];
Miroslav Benes c38cd1
@@ -155,7 +153,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 	case 0x58 ... 0x5f:
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 		/* pop reg */
Miroslav Benes c38cd1
-		*type = INSN_STACK;
Miroslav Benes c38cd1
 		ADD_OP(op) {
Miroslav Benes c38cd1
 			op->src.type = OP_SRC_POP;
Miroslav Benes c38cd1
 			op->dest.type = OP_DEST_REG;
Miroslav Benes c38cd1
@@ -167,7 +164,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 	case 0x68:
Miroslav Benes c38cd1
 	case 0x6a:
Miroslav Benes c38cd1
 		/* push immediate */
Miroslav Benes c38cd1
-		*type = INSN_STACK;
Miroslav Benes c38cd1
 		ADD_OP(op) {
Miroslav Benes c38cd1
 			op->src.type = OP_SRC_CONST;
Miroslav Benes c38cd1
 			op->dest.type = OP_DEST_PUSH;
Miroslav Benes c38cd1
@@ -185,7 +181,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 		if (modrm == 0xe4) {
Miroslav Benes c38cd1
 			/* and imm, %rsp */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_AND;
Miroslav Benes c38cd1
 				op->src.reg = CFI_SP;
Miroslav Benes c38cd1
@@ -204,7 +199,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 			break;
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 		/* add/sub imm, %rsp */
Miroslav Benes c38cd1
-		*type = INSN_STACK;
Miroslav Benes c38cd1
 		ADD_OP(op) {
Miroslav Benes c38cd1
 			op->src.type = OP_SRC_ADD;
Miroslav Benes c38cd1
 			op->src.reg = CFI_SP;
Miroslav Benes c38cd1
@@ -218,7 +212,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		if (rex_w && !rex_r && modrm_mod == 3 && modrm_reg == 4) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* mov %rsp, reg */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_REG;
Miroslav Benes c38cd1
 				op->src.reg = CFI_SP;
Miroslav Benes c38cd1
@@ -231,7 +224,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		if (rex_w && !rex_b && modrm_mod == 3 && modrm_rm == 4) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* mov reg, %rsp */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_REG;
Miroslav Benes c38cd1
 				op->src.reg = op_to_cfi_reg[modrm_reg][rex_r];
Miroslav Benes c38cd1
@@ -247,7 +239,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		    (modrm_mod == 1 || modrm_mod == 2) && modrm_rm == 5) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* mov reg, disp(%rbp) */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_REG;
Miroslav Benes c38cd1
 				op->src.reg = op_to_cfi_reg[modrm_reg][rex_r];
Miroslav Benes c38cd1
@@ -259,7 +250,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		} else if (rex_w && !rex_b && modrm_rm == 4 && sib == 0x24) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* mov reg, disp(%rsp) */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_REG;
Miroslav Benes c38cd1
 				op->src.reg = op_to_cfi_reg[modrm_reg][rex_r];
Miroslav Benes c38cd1
@@ -275,7 +265,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		if (rex_w && !rex_b && modrm_mod == 1 && modrm_rm == 5) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* mov disp(%rbp), reg */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_REG_INDIRECT;
Miroslav Benes c38cd1
 				op->src.reg = CFI_BP;
Miroslav Benes c38cd1
@@ -288,7 +277,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 			   modrm_mod != 3 && modrm_rm == 4) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* mov disp(%rsp), reg */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_REG_INDIRECT;
Miroslav Benes c38cd1
 				op->src.reg = CFI_SP;
Miroslav Benes c38cd1
@@ -303,7 +291,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 	case 0x8d:
Miroslav Benes c38cd1
 		if (sib == 0x24 && rex_w && !rex_b && !rex_x) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				if (!insn.displacement.value) {
Miroslav Benes c38cd1
 					/* lea (%rsp), reg */
Miroslav Benes c38cd1
@@ -321,7 +308,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		} else if (rex == 0x48 && modrm == 0x65) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* lea disp(%rbp), %rsp */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_ADD;
Miroslav Benes c38cd1
 				op->src.reg = CFI_BP;
Miroslav Benes c38cd1
@@ -339,7 +325,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 			 * Restoring rsp back to its original value after a
Miroslav Benes c38cd1
 			 * stack realignment.
Miroslav Benes c38cd1
 			 */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_ADD;
Miroslav Benes c38cd1
 				op->src.reg = CFI_R10;
Miroslav Benes c38cd1
@@ -357,7 +342,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 			 * Restoring rsp back to its original value after a
Miroslav Benes c38cd1
 			 * stack realignment.
Miroslav Benes c38cd1
 			 */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_ADD;
Miroslav Benes c38cd1
 				op->src.reg = CFI_R13;
Miroslav Benes c38cd1
@@ -371,7 +355,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 	case 0x8f:
Miroslav Benes c38cd1
 		/* pop to mem */
Miroslav Benes c38cd1
-		*type = INSN_STACK;
Miroslav Benes c38cd1
 		ADD_OP(op) {
Miroslav Benes c38cd1
 			op->src.type = OP_SRC_POP;
Miroslav Benes c38cd1
 			op->dest.type = OP_DEST_MEM;
Miroslav Benes c38cd1
@@ -384,7 +367,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 	case 0x9c:
Miroslav Benes c38cd1
 		/* pushf */
Miroslav Benes c38cd1
-		*type = INSN_STACK;
Miroslav Benes c38cd1
 		ADD_OP(op) {
Miroslav Benes c38cd1
 			op->src.type = OP_SRC_CONST;
Miroslav Benes c38cd1
 			op->dest.type = OP_DEST_PUSHF;
Miroslav Benes c38cd1
@@ -393,7 +375,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 	case 0x9d:
Miroslav Benes c38cd1
 		/* popf */
Miroslav Benes c38cd1
-		*type = INSN_STACK;
Miroslav Benes c38cd1
 		ADD_OP(op) {
Miroslav Benes c38cd1
 			op->src.type = OP_SRC_POPF;
Miroslav Benes c38cd1
 			op->dest.type = OP_DEST_MEM;
Miroslav Benes c38cd1
@@ -432,7 +413,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		} else if (op2 == 0xa0 || op2 == 0xa8) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* push fs/gs */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_CONST;
Miroslav Benes c38cd1
 				op->dest.type = OP_DEST_PUSH;
Miroslav Benes c38cd1
@@ -441,7 +421,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		} else if (op2 == 0xa1 || op2 == 0xa9) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* pop fs/gs */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_POP;
Miroslav Benes c38cd1
 				op->dest.type = OP_DEST_MEM;
Miroslav Benes c38cd1
@@ -458,7 +437,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		 * mov bp, sp
Miroslav Benes c38cd1
 		 * pop bp
Miroslav Benes c38cd1
 		 */
Miroslav Benes c38cd1
-		*type = INSN_STACK;
Miroslav Benes c38cd1
 		ADD_OP(op)
Miroslav Benes c38cd1
 			op->dest.type = OP_DEST_LEAVE;
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
@@ -514,7 +492,6 @@ int arch_decode_instruction(struct elf *
Miroslav Benes c38cd1
 		else if (modrm_reg == 6) {
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
 			/* push from mem */
Miroslav Benes c38cd1
-			*type = INSN_STACK;
Miroslav Benes c38cd1
 			ADD_OP(op) {
Miroslav Benes c38cd1
 				op->src.type = OP_SRC_CONST;
Miroslav Benes c38cd1
 				op->dest.type = OP_DEST_PUSH;
Miroslav Benes c38cd1
--- a/tools/objtool/check.c
Miroslav Benes c38cd1
+++ b/tools/objtool/check.c
Miroslav Benes c38cd1
@@ -2249,9 +2249,6 @@ static int validate_branch(struct objtoo
Miroslav Benes c38cd1
 			}
Miroslav Benes c38cd1
 			return 0;
Miroslav Benes c38cd1
 
Miroslav Benes c38cd1
-		case INSN_STACK:
Miroslav Benes c38cd1
-			break;
Miroslav Benes c38cd1
-
Miroslav Benes c38cd1
 		case INSN_STAC:
Miroslav Benes c38cd1
 			if (state.uaccess) {
Miroslav Benes c38cd1
 				WARN_FUNC("recursive UACCESS enable", sec, insn->offset);