From b9ba5107bae2bef69b1d55ed9d9521a761ad93a3 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 8 Nov 2022 01:48:25 -0500 Subject: [PATCH] import crash-ptdump-command-1.0.7-2.el8 --- .crash-ptdump-command.metadata | 1 + .gitignore | 1 + .../0001-Fix-for-the-topa_entry-issue.patch | 34 +++++++ ...ix-for-the-invalid-ring_buffer-issue.patch | 82 ++++++++++++++++ ...dump-on-the-Single-Range-Output-mode.patch | 44 +++++++++ SOURCES/rhel8_build.patch | 11 +++ SPECS/crash-ptdump-command.spec | 94 +++++++++++++++++++ 7 files changed, 267 insertions(+) create mode 100644 .crash-ptdump-command.metadata create mode 100644 .gitignore create mode 100644 SOURCES/0001-Fix-for-the-topa_entry-issue.patch create mode 100644 SOURCES/0002-Fix-for-the-invalid-ring_buffer-issue.patch create mode 100644 SOURCES/0003-Do-not-dump-on-the-Single-Range-Output-mode.patch create mode 100644 SOURCES/rhel8_build.patch create mode 100644 SPECS/crash-ptdump-command.spec diff --git a/.crash-ptdump-command.metadata b/.crash-ptdump-command.metadata new file mode 100644 index 0000000..4c7eedb --- /dev/null +++ b/.crash-ptdump-command.metadata @@ -0,0 +1 @@ +d6cdad06d5bbf06208a55097405d8a9906ba2440 SOURCES/ptdump-1.0.7.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..99d2f83 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/ptdump-1.0.7.tar.gz diff --git a/SOURCES/0001-Fix-for-the-topa_entry-issue.patch b/SOURCES/0001-Fix-for-the-topa_entry-issue.patch new file mode 100644 index 0000000..75de36d --- /dev/null +++ b/SOURCES/0001-Fix-for-the-topa_entry-issue.patch @@ -0,0 +1,34 @@ +From 374cde9c0aeb84da9e993641220c8b23adebab20 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Wed, 13 Jul 2022 17:23:05 +0800 +Subject: [PATCH 1/3] Fix for the topa_entry issue + +kernel commit 59388b9cbe20 ("[x86] perf/x86/intel/pt: Split ToPA metadata +and page layout") moved out the table of topa entry from struct topa, which +may cause the following failures: +[1] invalid kernel virtual address: 0 type: "struct topa_entry" +[2] current buffer not found + +Signed-off-by: Lianbo Jiang +--- + ptdump.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/ptdump.c b/ptdump.c +index f5eb110fe1cd..736e1c8cddaf 100644 +--- a/ptdump.c ++++ b/ptdump.c +@@ -183,6 +183,10 @@ int init_pt_info(int cpu) + &output_off)) + goto out_error; + ++ /* fixup the address of topa table */ ++ if (STRUCT_EXISTS("topa_page") && topa_base) ++ topa_base -= MEMBER_SIZE("topa_page", "table"); ++ + dbgprintf(fp, "[%d] buf.cur=0x%016lx\n", cpu, topa_base); + dbgprintf(fp, "[%d] buf.cur_idx=0x%08x\n", cpu, topa_idx); + dbgprintf(fp, "[%d] buf.output_off=0x%016lx\n", cpu, output_off); +-- +2.31.1 + diff --git a/SOURCES/0002-Fix-for-the-invalid-ring_buffer-issue.patch b/SOURCES/0002-Fix-for-the-invalid-ring_buffer-issue.patch new file mode 100644 index 0000000..011eeba --- /dev/null +++ b/SOURCES/0002-Fix-for-the-invalid-ring_buffer-issue.patch @@ -0,0 +1,82 @@ +From 86022cd76d9391f3c93553d1c76a444b2143a4e8 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Wed, 13 Jul 2022 22:27:33 +0800 +Subject: [PATCH 2/3] Fix for the invalid ring_buffer issue + +Kernel commit e028157062b9 ("[kernel] perf: Make struct ring_buffer +less ambiguous") renamed the struct ring_buffer to struct perf_buffer, +which cause the following failure: + +[0] invalid ring_buffer +[1] invalid ring_buffer +[2] invalid ring_buffer + +Signed-off-by: Lianbo Jiang +--- + ptdump.c | 45 +++++++++++++++++++++++++++++++-------------- + 1 file changed, 31 insertions(+), 14 deletions(-) + +diff --git a/ptdump.c b/ptdump.c +index 736e1c8cddaf..54e4391739e3 100644 +--- a/ptdump.c ++++ b/ptdump.c +@@ -114,25 +114,42 @@ int init_pt_info(int cpu) + struct_ring_buffer); + + /* symbol access check */ +- if (STRUCT_EXISTS("ring_buffer") && +- !MEMBER_EXISTS("ring_buffer", "aux_pages")) { +- fprintf(fp, "[%d] invalid ring_buffer\n", cpu); ++ if ((STRUCT_EXISTS("ring_buffer") && ++ !MEMBER_EXISTS("ring_buffer", "aux_pages")) || ++ (STRUCT_EXISTS("perf_buffer") && ++ !MEMBER_EXISTS("perf_buffer", "aux_pages"))) { ++ fprintf(fp, "[%d] invalid {ring|perf}_buffer\n", cpu); + return FALSE; + } + +- /* array of struct pages for pt buffer */ +- if(!get_member(struct_ring_buffer, "ring_buffer", "aux_pages", +- &aux_pages)) +- return FALSE; ++ if (STRUCT_EXISTS("ring_buffer")) { ++ /* array of struct pages for pt buffer */ ++ if(!get_member(struct_ring_buffer, "ring_buffer", "aux_pages", ++ &aux_pages)) ++ return FALSE; + +- /* number of pages */ +- if(!get_member(struct_ring_buffer, "ring_buffer", "aux_nr_pages", +- &aux_nr_pages)) +- return FALSE; ++ /* number of pages */ ++ if(!get_member(struct_ring_buffer, "ring_buffer", "aux_nr_pages", ++ &aux_nr_pages)) ++ return FALSE; ++ ++ /* private data (struct pt_buffer) */ ++ if(!get_member(struct_ring_buffer, "ring_buffer", "aux_priv", ++ &aux_priv)) ++ return FALSE; ++ } else if (STRUCT_EXISTS("perf_buffer")) { ++ if(!get_member(struct_ring_buffer, "perf_buffer", "aux_pages", ++ &aux_pages)) ++ return FALSE; + +- /* private data (struct pt_buffer) */ +- if(!get_member(struct_ring_buffer, "ring_buffer", "aux_priv", +- &aux_priv)) ++ if(!get_member(struct_ring_buffer, "perf_buffer", "aux_nr_pages", ++ &aux_nr_pages)) ++ return FALSE; ++ ++ if(!get_member(struct_ring_buffer, "perf_buffer", "aux_priv", ++ &aux_priv)) ++ return FALSE; ++ } else + return FALSE; + + if (!aux_nr_pages) { +-- +2.31.1 + diff --git a/SOURCES/0003-Do-not-dump-on-the-Single-Range-Output-mode.patch b/SOURCES/0003-Do-not-dump-on-the-Single-Range-Output-mode.patch new file mode 100644 index 0000000..f64fca5 --- /dev/null +++ b/SOURCES/0003-Do-not-dump-on-the-Single-Range-Output-mode.patch @@ -0,0 +1,44 @@ +From 14fe81602c9dd2f64ab803ed9c83b243226a6b05 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Tue, 19 Jul 2022 13:31:02 +0800 +Subject: [PATCH 3/3] Do not dump on the Single Range Output mode + +Kernel commit 670638477aed ("perf/x86/intel/pt: Opportunistically use +single range output mode") may cause the following failure: + + ptdump: page excluded: kernel virtual address: xxx type: "struct topa_entry" + Cannot read topa table + +When working on the Single Range Output mode, not support to dump and +pint a warning. + +Signed-off-by: Lianbo Jiang +--- + ptdump.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/ptdump.c b/ptdump.c +index 54e4391739e3..d48cd0126716 100644 +--- a/ptdump.c ++++ b/ptdump.c +@@ -189,6 +189,17 @@ int init_pt_info(int cpu) + dbgprintf(fp, " %d: 0x%016lx\n", i, page); + } + ++ if (MEMBER_EXISTS("pt_buffer", "single")) { ++ uint single = 0; ++ if(!get_member(pt_info_ptr->pt_buffer, "pt_buffer", "single", &single)) { ++ fprintf(fp, "failed to read pt_buffer."); ++ return FALSE; ++ } ++ ++ if (!!single) ++ error(FATAL, "Not support because of using Single Range Output instead of ToPA.\n"); ++ } ++ + /* Get pt registes saved on panic */ + if(!get_member(pt_info_ptr->pt_buffer, "pt_buffer", "cur", + &topa_base)) +-- +2.31.1 + diff --git a/SOURCES/rhel8_build.patch b/SOURCES/rhel8_build.patch new file mode 100644 index 0000000..8cec66a --- /dev/null +++ b/SOURCES/rhel8_build.patch @@ -0,0 +1,11 @@ +--- ptdump-1.0.3/ptdump.mk.orig ++++ ptdump-1.0.3/ptdump.mk +@@ -43,7 +43,7 @@ ptdump.so: $(TARGET_CFILES) $(INCDIR)/de + ifeq ($(ARCH),UNSUPPORTED) + @echo "ptdump: architecture not supported" + else +- gcc $(RPM_OPT_FLAGS) $(CFLAGS) $(TARGET_CFLAGS) $(COMMON_CFLAGS) -nostartfiles -shared -rdynamic -o $@ $(TARGET_CFILES) ++ gcc $(RPM_OPT_FLAGS) $(CFLAGS) $(TARGET_CFLAGS) $(COMMON_CFLAGS) -nostartfiles -shared -rdynamic -o $@ $(TARGET_CFILES) -Wl,-z,now + endif + + debug: COMMON_CFLAGS+=-DDEBUG diff --git a/SPECS/crash-ptdump-command.spec b/SPECS/crash-ptdump-command.spec new file mode 100644 index 0000000..e0ab6f5 --- /dev/null +++ b/SPECS/crash-ptdump-command.spec @@ -0,0 +1,94 @@ +# +# crash core analysis suite +# +Summary: ptdump extension module for the crash utility +Name: crash-ptdump-command +Version: 1.0.7 +Release: 2%{?dist} +License: GPLv2 +Group: Development/Debuggers +Source: https://github.com/crash-utility/crash-extensions/blob/master/ptdump-%{version}.tar.gz +URL: https://crash-utility.github.io/extensions.html +ExclusiveOS: Linux +ExclusiveArch: x86_64 +Buildroot: %{_tmppath}/%{name}-root +BuildRequires: crash-devel >= 5.1.5 +Requires: crash >= 5.1.5 +Patch0: rhel8_build.patch +Patch1: 0001-Fix-for-the-topa_entry-issue.patch +Patch2: 0002-Fix-for-the-invalid-ring_buffer-issue.patch +Patch3: 0003-Do-not-dump-on-the-Single-Range-Output-mode.patch + +%description +Retrieve and decode the log buffer generated by the Intel(R) Processor +Trace facility + +%prep +%setup -q -n ptdump-%{version} +%patch0 -p1 -b rhel8_build.patch +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +%build +make -f ptdump.mk + +%install +rm -Rf $RPM_BUILD_ROOT +mkdir -p %{buildroot}%{_libdir}/crash/extensions/ +cp %{_builddir}/ptdump-%{version}/ptdump.so %{buildroot}%{_libdir}/crash/extensions/ + +%clean +rm -rf %{buildroot} +rm -Rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%{_libdir}/crash/extensions/ptdump.so +%doc COPYING + +%changelog +* Thu Jul 14 2022 Lianbo Jiang - 1.0.7-2 +- Fix for "current buffer not found" +- Fix for "invalid kernel virtual address: 0 type: struct topa_entry" +- Fix for "invalid ring_buffer" + Resolves: rhbz#1838927 + +* Wed Jul 8 2020 Bhupesh Sharma - 1.0.7-1 +- ptdump: Rebase to upstream extension version ptdump-1.0.7 (github) + Resolves: rhbz#1851749 + +* Wed Jan 29 2020 Dave Anderson - 1.0.3-5 +- ptdump: fix build warning: warning: this ‘if’ clause does not guard +- ptdump: fix failure: ptdump: invalid size request: 0 type: "read page for write" +- ptdump: fix heap memory and fd leak when fault happens + Resolves: rhbz#1786497 + +* Wed Sep 19 2018 Dave Anderson - 1.0.3-4 +- Address annocheck link issue + Resolves: rhbz#1630557 + +* Mon Aug 13 2018 Dave Anderson - 1.0.3-3 +- Bump release for mass rebuild + Resolves: rhbz#1615510 + +* Wed May 31 2017 Dave Anderson - 1.0.3-2.el7 +- Add RPM_OPT_FLAGS to gcc line in ptdump.mk + Resolves: rhbz#1450708 +- Set gdb scope to get appropriate ring_buffer structure + Resolves: rhbz#1451181 + +* Tue Mar 15 2016 Dave Anderson - 1.0.3-1.el7 +- Fix for coverity scan issues generated by 1.0.2 + Resolves: rhbz#1298172 + +* Mon Mar 14 2016 Dave Anderson - 1.0.2-1.el7 +- Memory leak fix and coverity scan fixes. + Resolves: rhbz#1298172 + +* Mon Feb 29 2016 Dave Anderson - 1.0.1-1.el7 +- Initial check-in. + Resolves: rhbz#1298172 + +* Tue Jan 26 2016 MUNEDA Takahiro - 1.0.1-1 +- Initial crash-ptdump-command package