Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * x86 instruction attribute tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Written by Masami Hiramatsu <mhiramat@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <asm/insn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) /* Attribute tables are generated from opcode map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "inat-tables.c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /* Attribute search APIs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	return inat_primary_table[opcode];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) int inat_get_last_prefix_id(insn_byte_t last_pfx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	insn_attr_t lpfx_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	lpfx_attr = inat_get_opcode_attribute(last_pfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	return inat_last_prefix_id(lpfx_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) insn_attr_t inat_get_escape_attribute(insn_byte_t opcode, int lpfx_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 				      insn_attr_t esc_attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	const insn_attr_t *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	int n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	n = inat_escape_id(esc_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	table = inat_escape_tables[n][0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	if (!table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	if (inat_has_variant(table[opcode]) && lpfx_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		table = inat_escape_tables[n][lpfx_id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		if (!table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	return table[opcode];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) insn_attr_t inat_get_group_attribute(insn_byte_t modrm, int lpfx_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 				     insn_attr_t grp_attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	const insn_attr_t *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	int n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	n = inat_group_id(grp_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	table = inat_group_tables[n][0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	if (!table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		return inat_group_common_attribute(grp_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	if (inat_has_variant(table[X86_MODRM_REG(modrm)]) && lpfx_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		table = inat_group_tables[n][lpfx_id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		if (!table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 			return inat_group_common_attribute(grp_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	return table[X86_MODRM_REG(modrm)] |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	       inat_group_common_attribute(grp_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) insn_attr_t inat_get_avx_attribute(insn_byte_t opcode, insn_byte_t vex_m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 				   insn_byte_t vex_p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	const insn_attr_t *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	if (vex_m > X86_VEX_M_MAX || vex_p > INAT_LSTPFX_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	/* At first, this checks the master table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	table = inat_avx_tables[vex_m][0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	if (!table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	if (!inat_is_group(table[opcode]) && vex_p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 		/* If this is not a group, get attribute directly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 		table = inat_avx_tables[vex_m][vex_p];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 		if (!table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 	return table[opcode];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)