Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mariospaok4 authored Dec 18, 2024
2 parents ac62273 + 9481855 commit 899bf1c
Show file tree
Hide file tree
Showing 9 changed files with 924 additions and 55 deletions.
14 changes: 9 additions & 5 deletions api/docs/code_reviews.dox
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ appear. Do not simply reply at the top level, as such comments are more
difficult to follow as a conversation thread with context.

After making changes in response to review comments, commit those changes
locally as a new commit on top of your original commit. If the reviewer
requested changes to the commit message, use a new proposed final commit
message as the message for this change commit so that the reviewer can
review the new message.
locally as a new commit on top of your original commit (do not squash the
new changes into the original commit; use separate commits). If the reviewer
requested changes to the commit message or title, edit those directly in
the pull request text boxes as those are what become the final commit
message.

Project members should then push the new commit to the pull request via:

Expand All @@ -215,7 +216,10 @@ separate commit (these separate commits will all be squashed together upon mergi
When the requested changes have been pushed, request a re-review from the reviewer so they know that the pull request is ready for another round of reviewing.
This can be done by clicking the re-review button next to the reviewer's name at the top of the right sidebar on the pull request page.

The final squash-and-merge step will squash these additional commits with the original to make a single commit that will be fast-forward-merged into master (see below for more details).
The final squash-and-merge step will squash these additional commits with the
original to make a single commit that will be fast-forward-merged into master (see
below for more details). The final master branch merge commit's title and
description come directly from the pull request title and description.

# Updating from Master

Expand Down
20 changes: 10 additions & 10 deletions core/ir/x86/decode_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -6159,20 +6159,20 @@ const instr_info_t e_vex_extensions[][3] = {
{INVALID, 0x6638db18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 32 */
{OP_aesenc, 0x6638dc18, catSIMD, "aesenc", Vdq, xx, Wdq,Vdq, xx, mrm|reqp, x, END_LIST},
{OP_vaesenc, 0x6638dc18, catSIMD, "vaesenc", Vx, xx, Hx,Wx, xx, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x6638dc18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
{OP_vaesenc, 0x6638dc18, catSIMD, "vaesenc", Vx, xx, Hx,Wx, xx, mrm|vex|reqp, x, tvex[32][2]},
{OP_vaesenc, 0x6638dc18, catSIMD, "vaesenc", Ve, xx, He,We, xx, mrm|evex|reqp|ttfvm, x, END_LIST},
}, { /* e_vex ext 33 */
{OP_aesenclast, 0x6638dd18, catSIMD, "aesenclast",Vdq,xx,Wdq,Vdq,xx, mrm|reqp, x, END_LIST},
{OP_vaesenclast, 0x6638dd18, catSIMD, "vaesenclast",Vx,xx,Hx,Wx,xx, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x6638dd18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
{OP_vaesenclast, 0x6638dd18, catSIMD, "vaesenclast",Vx,xx,Hx,Wx,xx, mrm|vex|reqp, x, tvex[33][2]},
{OP_vaesenclast, 0x6638dd18, catSIMD, "vaesenclast",Ve,xx,He,We,xx, mrm|evex|reqp|ttfvm, x, END_LIST},
}, { /* e_vex ext 34 */
{OP_aesdec, 0x6638de18, catSIMD, "aesdec", Vdq, xx, Wdq,Vdq, xx, mrm|reqp, x, END_LIST},
{OP_vaesdec, 0x6638de18, catSIMD, "vaesdec", Vx, xx, Hx,Wx, xx, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x6638de18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
{OP_vaesdec, 0x6638de18, catSIMD, "vaesdec", Vx, xx, Hx,Wx, xx, mrm|vex|reqp, x, tvex[34][2]},
{OP_vaesdec, 0x6638de18, catSIMD, "vaesdec", Ve, xx, He,We, xx, mrm|evex|reqp|ttfvm, x, END_LIST},
}, { /* e_vex ext 35 */
{OP_aesdeclast, 0x6638df18, catSIMD, "aesdeclast",Vdq,xx,Wdq,Vdq,xx, mrm|reqp, x, END_LIST},
{OP_vaesdeclast, 0x6638df18, catSIMD, "vaesdeclast",Vx,xx,Hx,Wx,xx, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x6638df18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
{OP_vaesdeclast, 0x6638df18, catSIMD, "vaesdeclast",Vx,xx,Hx,Wx,xx, mrm|vex|reqp, x, tvex[35][2]},
{OP_vaesdeclast, 0x6638df18, catSIMD, "vaesdeclast",Ve,xx,He,We,xx, mrm|evex|reqp|ttfvm, x, END_LIST},
}, { /* e_vex ext 36 */
{OP_pextrb, 0x663a1418, catSIMD, "pextrb", Rd_Mb, xx, Vb_dq, Ib, xx, mrm|reqp, x, END_LIST},
{OP_vpextrb, 0x663a1418, catSIMD, "vpextrb", Rd_Mb, xx, Vb_dq, Ib, xx, mrm|vex|reqp, x, tvex[36][2]},
Expand Down Expand Up @@ -6260,8 +6260,8 @@ const instr_info_t e_vex_extensions[][3] = {
{INVALID, 0x663a6318, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 57 */
{OP_pclmulqdq, 0x663a4418, catSIMD, "pclmulqdq", Vdq, xx, Wdq, Ib, Vdq, mrm|reqp, x, END_LIST},
{OP_vpclmulqdq,0x663a4418, catSIMD, "vpclmulqdq", Vx, xx, Hx, Wx, Ib, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x663a4418, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
{OP_vpclmulqdq,0x663a4418, catSIMD, "vpclmulqdq", Vx, xx, Hx, Wx, Ib, mrm|vex|reqp, x, tvex[57][2]},
{OP_vpclmulqdq,0x663a4418, catSIMD, "vpclmulqdq", Ve, xx, He, We, Ib, mrm|evex|reqp|ttfvm, x, END_LIST},
}, { /* e_vex ext 58 */
{OP_aeskeygenassist, 0x663adf18, catSIMD, "aeskeygenassist",Vdq,xx,Wdq,Ib,xx,mrm|reqp,x,END_LIST},
{OP_vaeskeygenassist,0x663adf18, catSIMD, "vaeskeygenassist",Vdq,xx,Wdq,Ib,xx,mrm|vex|reqp,x,END_LIST},
Expand Down
49 changes: 37 additions & 12 deletions core/unix/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
# error Unsupported architecture
#endif

#define MAX_BUFFER_SIZE 4096
#define MAX_SECTION_HEADERS 300
#define MAX_SECTION_NAME_BUFFER_SIZE 8192
#define SECTION_HEADER_TABLE ".shstrtab"
Expand Down Expand Up @@ -484,11 +485,23 @@ os_dump_core_internal(dcontext_t *dcontext)
// of LOAD program header (number of sections minus one since shstrtab does not
// require a LOAD header).
const ELF_OFF program_header_count = section_count;
// core_file_offset is the current offset of the core file to write the next
// section data.
ELF_OFF core_file_offset = sizeof(ELF_HEADER_TYPE) +
sizeof(ELF_PROGRAM_HEADER_TYPE) * program_header_count +
PROGRAM_HEADER_NOTE_LENGTH;
// We add padding to the core file so that loadable segments in the
// core file are page size aligned. The p_align field in the program header
// is applied to both memory and the offset to the core file.
const size_t loadable_segment_padding =
ALIGN_FORWARD(core_file_offset, os_page_size()) - core_file_offset;
core_file_offset = ALIGN_FORWARD(core_file_offset, os_page_size());

if (!write_elf_header(elf_file, /*entry_point=*/(uint64_t)mc.pc,
/*section_header_table_offset*/ sizeof(ELF_HEADER_TYPE) +
/*section_header_table_offset=*/sizeof(ELF_HEADER_TYPE) +
PROGRAM_HEADER_NOTE_LENGTH +
sizeof(ELF_PROGRAM_HEADER_TYPE) * program_header_count +
section_data_size,
loadable_segment_padding + section_data_size,
/*flags=*/0,
/*program_header_count=*/program_header_count,
/*section_header_count=*/section_count,
Expand All @@ -509,9 +522,6 @@ os_dump_core_internal(dcontext_t *dcontext)
return false;
}
// Write loadable program segment program headers.
ELF_OFF file_offset = sizeof(ELF_HEADER_TYPE) +
sizeof(ELF_PROGRAM_HEADER_TYPE) * program_header_count +
PROGRAM_HEADER_NOTE_LENGTH;
// TODO i#7046: Merge adjacent sections with the same prot values.
// The last section is shstrtab which stores the section names and it does
// not require a LOAD program header.
Expand All @@ -530,7 +540,7 @@ os_dump_core_internal(dcontext_t *dcontext)
section_header_info[section_index].vm_start;
if (!write_program_header(
elf_file, PT_LOAD, flags,
/*offset=*/file_offset,
/*offset=*/core_file_offset,
/*virtual_address=*/(ELF_ADDR)section_header_info[section_index].vm_start,
/*physical_address=*/
(ELF_ADDR)section_header_info[section_index].vm_start,
Expand All @@ -540,7 +550,7 @@ os_dump_core_internal(dcontext_t *dcontext)
os_close(elf_file);
return false;
}
file_offset += section_header_info[section_index].vm_end -
core_file_offset += section_header_info[section_index].vm_end -
section_header_info[section_index].vm_start;
}
if (!write_prstatus_note(&mc, elf_file)) {
Expand All @@ -551,6 +561,20 @@ os_dump_core_internal(dcontext_t *dcontext)
os_close(elf_file);
return false;
}
// Add padding to the core file such that loadable segments are aligned to
// the page size in the core file.
char buffer[MAX_BUFFER_SIZE];
size_t remaining_bytes = loadable_segment_padding;
memset(buffer, 0, MIN(MAX_BUFFER_SIZE, loadable_segment_padding));
while (remaining_bytes > 0) {
const size_t bytes = MIN(remaining_bytes, MAX_BUFFER_SIZE);
if (os_write(elf_file, buffer, bytes) != bytes) {
SYSLOG_INTERNAL_ERROR("Failed to add padding to the core dump file.");
os_close(elf_file);
return false;
}
remaining_bytes -= bytes;
}
// Write memory content to the core dump file.
for (int section_index = 0; section_index < section_count - 1; ++section_index) {
const size_t length = section_header_info[section_index].vm_end -
Expand All @@ -577,9 +601,9 @@ os_dump_core_internal(dcontext_t *dcontext)
return false;
}
// Write section headers to the core dump file.
file_offset = sizeof(ELF_HEADER_TYPE) +
core_file_offset = sizeof(ELF_HEADER_TYPE) +
sizeof(ELF_PROGRAM_HEADER_TYPE) * program_header_count +
PROGRAM_HEADER_NOTE_LENGTH;
PROGRAM_HEADER_NOTE_LENGTH + loadable_segment_padding;

// The section_count includes the section name section, so we need to skip
// it in the loop. The section name section is handled differently after
Expand All @@ -594,7 +618,8 @@ os_dump_core_internal(dcontext_t *dcontext)
}
if (!write_section_header(
elf_file, section_header_info[section_index].name_offset, SHT_PROGBITS,
flags, (ELF_ADDR)section_header_info[section_index].vm_start, file_offset,
flags, (ELF_ADDR)section_header_info[section_index].vm_start,
core_file_offset,
section_header_info[section_index].vm_end -
section_header_info[section_index].vm_start,
/*link=*/0,
Expand All @@ -603,13 +628,13 @@ os_dump_core_internal(dcontext_t *dcontext)
os_close(elf_file);
return false;
}
file_offset += section_header_info[section_index].vm_end -
core_file_offset += section_header_info[section_index].vm_end -
section_header_info[section_index].vm_start;
}
// Write the section name section.
if (!write_section_header(
elf_file, string_table_offset - strlen(SECTION_HEADER_TABLE), SHT_STRTAB,
/*flags=*/0, /*virtual_address=*/0, file_offset,
/*flags=*/0, /*virtual_address=*/0, core_file_offset,
/*section_size=*/string_table_offset, /*link=*/0,
/*info=*/0, /*alignment=*/1,
/*entry_size=*/0)) {
Expand Down
64 changes: 64 additions & 0 deletions suite/tests/api/ir_x86_3args_avx512_evex.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,67 @@ OPCODE(vpsadbw_zhizhizhi, vpsadbw, vpsadbw, X64_ONLY, REGARG(ZMM16), REGARG(ZMM1
REGARG(ZMM31))
OPCODE(vpsadbw_zhizhild, vpsadbw, vpsadbw, X64_ONLY, REGARG(ZMM16), REGARG(ZMM31),
MEMARG(OPSZ_64))
OPCODE(vaesenc_evex_xhixhixhi, vaesenc, vaesenc, X64_ONLY, REGARG(XMM16), REGARG(XMM17),
REGARG(XMM18))
OPCODE(vaesenc_evex_xhixhild, vaesenc, vaesenc, X64_ONLY, REGARG(XMM16), REGARG(XMM17),
MEMARG(OPSZ_16))
OPCODE(vaesenc_evex_yhiyhiyhi, vaesenc, vaesenc, X64_ONLY, REGARG(YMM16), REGARG(YMM17),
REGARG(YMM18))
OPCODE(vaesenc_evex_yhiyhild, vaesenc, vaesenc, X64_ONLY, REGARG(YMM16), REGARG(YMM17),
MEMARG(OPSZ_32))
OPCODE(vaesenc_evex_zlozlozlo, vaesenc, vaesenc, 0, REGARG(ZMM0), REGARG(ZMM1),
REGARG(ZMM2))
OPCODE(vaesenc_evex_zlozlold, vaesenc, vaesenc, 0, REGARG(ZMM0), REGARG(ZMM1),
MEMARG(OPSZ_64))
OPCODE(vaesenc_evex_zhizhizhi, vaesenc, vaesenc, X64_ONLY, REGARG(ZMM16), REGARG(ZMM17),
REGARG(ZMM18))
OPCODE(vaesenc_evex_zhizhild, vaesenc, vaesenc, X64_ONLY, REGARG(ZMM16), REGARG(ZMM17),
MEMARG(OPSZ_64))
OPCODE(vaesenclast_evex_xhixhixhi, vaesenclast, vaesenclast, X64_ONLY, REGARG(XMM16),
REGARG(XMM17), REGARG(XMM18))
OPCODE(vaesenclast_evex_xhixhild, vaesenclast, vaesenclast, X64_ONLY, REGARG(XMM16),
REGARG(XMM17), MEMARG(OPSZ_16))
OPCODE(vaesenclast_evex_yhiyhiyhi, vaesenclast, vaesenclast, X64_ONLY, REGARG(YMM16),
REGARG(YMM17), REGARG(YMM15))
OPCODE(vaesenclast_evex_yhiyhild, vaesenclast, vaesenclast, X64_ONLY, REGARG(YMM16),
REGARG(YMM17), MEMARG(OPSZ_32))
OPCODE(vaesenclast_evex_zlozlozlo, vaesenclast, vaesenclast, 0, REGARG(ZMM0),
REGARG(ZMM1), REGARG(ZMM2))
OPCODE(vaesenclast_evex_zlozlold, vaesenclast, vaesenclast, 0, REGARG(ZMM0), REGARG(ZMM1),
MEMARG(OPSZ_64))
OPCODE(vaesenclast_evex_zhizhizhi, vaesenclast, vaesenclast, X64_ONLY, REGARG(ZMM16),
REGARG(ZMM17), REGARG(ZMM15))
OPCODE(vaesenclast_evex_zhizhild, vaesenclast, vaesenclast, X64_ONLY, REGARG(ZMM16),
REGARG(ZMM17), MEMARG(OPSZ_64))
OPCODE(vaesdec_evex_xhixhixlo, vaesdec, vaesdec, X64_ONLY, REGARG(XMM16), REGARG(XMM17),
REGARG(XMM0))
OPCODE(vaesdec_evex_xhixhild, vaesdec, vaesdec, X64_ONLY, REGARG(XMM16), REGARG(XMM17),
MEMARG(OPSZ_16))
OPCODE(vaesdec_evex_yhiyhiylo, vaesdec, vaesdec, X64_ONLY, REGARG(YMM16), REGARG(YMM17),
REGARG(YMM0))
OPCODE(vaesdec_evex_yhiyhild, vaesdec, vaesdec, X64_ONLY, REGARG(YMM16), REGARG(YMM17),
MEMARG(OPSZ_32))
OPCODE(vaesdec_evex_zlozlozlo, vaesdec, vaesdec, 0, REGARG(ZMM0), REGARG(ZMM1),
REGARG(ZMM2))
OPCODE(vaesdec_evex_zlozlold, vaesdec, vaesdec, 0, REGARG(ZMM0), REGARG(ZMM1),
MEMARG(OPSZ_64))
OPCODE(vaesdec_evex_zhizhizlo, vaesdec, vaesdec, X64_ONLY, REGARG(ZMM16), REGARG(ZMM17),
REGARG(ZMM15))
OPCODE(vaesdec_evex_zhizhild, vaesdec, vaesdec, X64_ONLY, REGARG(ZMM8), REGARG(ZMM9),
MEMARG(OPSZ_64))
OPCODE(vaesdeclast_evex_xhixhixhi, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(XMM16),
REGARG(XMM17), REGARG(XMM18))
OPCODE(vaesdeclast_evex_xhixhild, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(XMM16),
REGARG(XMM17), MEMARG(OPSZ_16))
OPCODE(vaesdeclast_evex_yhiyhiyhi, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(YMM16),
REGARG(YMM17), REGARG(YMM31))
OPCODE(vaesdeclast_evex_yhiyhild, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(YMM16),
REGARG(YMM17), MEMARG(OPSZ_32))
OPCODE(vaesdeclast_evex_zlozlozlo, vaesdeclast, vaesdeclast, 0, REGARG(ZMM0),
REGARG(ZMM1), REGARG(ZMM2))
OPCODE(vaesdeclast_evex_zlozlold, vaesdeclast, vaesdeclast, 0, REGARG(ZMM0), REGARG(ZMM1),
MEMARG(OPSZ_64))
OPCODE(vaesdeclast_evex_zhizhizhi, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(ZMM16),
REGARG(ZMM17), REGARG(ZMM31))
OPCODE(vaesdeclast_evex_zhizhild, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(ZMM16),
REGARG(ZMM17), MEMARG(OPSZ_64))
14 changes: 14 additions & 0 deletions suite/tests/api/ir_x86_4args_avx512_evex.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,17 @@ OPCODE(vpinsrq_xhixhir, vpinsrq, vpinsrq, X64_ONLY, REGARG(XMM16),
REGARG_PARTIAL(XMM31, OPSZ_8), REGARG(RAX), IMMARG(OPSZ_1))
OPCODE(vpinsrq_xhixhim, vpinsrq, vpinsrq, X64_ONLY, REGARG(XMM16),
REGARG_PARTIAL(XMM31, OPSZ_8), MEMARG(OPSZ_8), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_evex_xhixhixhi, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(XMM16),
REGARG(XMM17), REGARG(XMM18), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_evex_xhixhild, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(XMM16),
REGARG(XMM17), MEMARG(OPSZ_16), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_evex_yhiyhiyhi, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(YMM16),
REGARG(YMM17), REGARG(YMM18), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_evex_yhiyhild, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(YMM16),
REGARG(YMM17), MEMARG(OPSZ_32), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_zlozlozlo, vpclmulqdq, vpclmulqdq, 0, REGARG(ZMM0), REGARG(ZMM1),
REGARG(ZMM2), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_zlozlold, vpclmulqdq, vpclmulqdq, 0, REGARG(ZMM0), REGARG(ZMM1),
MEMARG(OPSZ_64), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_zhizhizhi, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(ZMM16),
REGARG(ZMM17), REGARG(ZMM18), IMMARG(OPSZ_1))
Loading

0 comments on commit 899bf1c

Please sign in to comment.