Skip to contentSkip to conversation

xen: add support for crash dump analysis with xen.efi

PATCH In review Juergen Gross 2 participants 3 messages Apr 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen: add support for crash dump analysis with xen.efi

Today it is not possible to analyse crash dumps of a system in hypervisor mode when it had been booted via EFI, as the crash utility doesn't understand the file format of xen.efi.

This can easily be solved by creating an ELF file from xen.efi via objcopy. Using that file as name list for crash enables the user to analyse the dump in hypervisor mode. Note that crash isn't happy with a file containing no text and data, so using --only-keep-debug is not an option.

---
V2:
- drop Kconfig help text changes (Jan Beulich)
- apply some Makefile changes (Jan Beulich)
- add xen.efi.elf removal to _clean target

---
 xen/Makefile          | 11 +++++++----
 xen/arch/x86/Makefile |  3 +++
 2 files changed, 10 insertions(+), 4 deletions(-)
xen/Makefile +7 -4
index 2710d7327e..5166403cff 100644
@@ -502,9 +502,11 @@ _install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX)
 	if [ -r $(TARGET).efi -a -n '$(EFI_DIR)' ]; then \
 		[ -d $(D)$(EFI_DIR) ] || $(INSTALL_DIR) $(D)$(EFI_DIR); \
 		$(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi; \
-		if [ -e $(TARGET).efi.map ]; then \
-			$(INSTALL_DATA) $(TARGET).efi.map $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.map; \
-		fi; \
+		for x in map elf; do \
+			if [ -e $(TARGET).efi.$$x ]; then \
+				$(INSTALL_DATA) $(TARGET).efi.$$x $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.$$x; \
+			fi; \
+		done; \
 		ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi; \
 		ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi; \
 		ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T).efi; \
@@ -539,6 +541,7 @@ _uninstall:
 	rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION).map
 	rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi
 	rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi
+	rm -f $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.elf
 	rm -f $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.map
 	rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi
 	rm -f $(D)$(EFI_DIR)/$(T).efi
@@ -569,7 +572,7 @@ _clean:
 		-o -name '*.lex.c' -o -name '*.tab.[ch]' -o -name "*.gcno" \
 		-o -name ".*.cmd" -o -name "lib.a" \) -exec rm -f {} \;
 	rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET)-syms $(TARGET)-syms.map
-	rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.stripped
+	rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.elf $(TARGET).efi.stripped
 	rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h
 	rm -f .banner .allconfig.tmp include/xen/compile.h
 
xen/arch/x86/Makefile +3 -0
index fc9487aa40..0c66ba9086 100644
@@ -226,6 +226,9 @@ endif
 	      $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o $(orphan-handling-y) $(note_file_option) -o $@
 	$(NM) -pa --format=sysv $(@D)/$(@F) \
 		| $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort >$(@D)/$(@F).map
+ifeq ($(CONFIG_DEBUG_INFO),y)
+	$(if $(filter --strip-debug,$(EFI_LDFLAGS)),:,$(OBJCOPY) -O elf64-x86-64 $@ [email protected])
+endif
 	rm -f $(@D)/.$(@F).[0-9]* $(@D)/..$(@F).[0-9]*
 ifeq ($(CONFIG_XEN_IBT),y)
 	$(SHELL) $(srctree)/tools/check-endbr.sh $@
Signature · 1 line
2.35.3
Reviewed-by on v2 1/1
#1 lore raw

xen/arch/x86/Makefile endif · line 230

Quoted 8 lines · Juergen Gross
xen/arch/x86/Makefile +2 -0
@@ -226,6 +226,9 @@ endif
 	      $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o $(orphan-handling-y) $(note_file_option) -o $@
 	$(NM) -pa --format=sysv $(@D)/$(@F) \
 		| $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort >$(@D)/$(@F).map
+ifeq ($(CONFIG_DEBUG_INFO),y)
+	$(if $(filter --strip-debug,$(EFI_LDFLAGS)),:,$(OBJCOPY) -O elf64-x86-64 $@ [email protected])

This only addresses one of the two earlier raised aspects, as you didn't use what I proposed:

	$(if $(filter --strip-debug,$(EFI_LDFLAGS)),:)$(OBJCOPY) -O elf64-x86-64 $@ [email protected]

Quite possibly because there was a blank missing in there, to separate the colon from $(OBJCOPY). Preferably with the adjustment (which I'd be fine doing while committing, as long as you're okay)

To also mention what we have just discussed: Since we're talking about duplicating over 30Mb of data (at least according to my build), an option is going to be to then strip debug info off of xen.efi itself, getting its size into reasonable range again.

Jan

#2 lore raw
Quoted 13 lines · Jan Beulich

xen/arch/x86/Makefile endif · line 230

Quoted 8 lines · Juergen Gross
xen/arch/x86/Makefile +2 -0
@@ -226,6 +226,9 @@ endif
  	      $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o $(orphan-handling-y) $(note_file_option) -o $@
  	$(NM) -pa --format=sysv $(@D)/$(@F) \
  		| $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort >$(@D)/$(@F).map
+ifeq ($(CONFIG_DEBUG_INFO),y)
+	$(if $(filter --strip-debug,$(EFI_LDFLAGS)),:,$(OBJCOPY) -O elf64-x86-64 $@ [email protected])

This only addresses one of the two earlier raised aspects, as you didn't use what I proposed:

Quoted 5 lines
	$(if $(filter --strip-debug,$(EFI_LDFLAGS)),:)$(OBJCOPY) -O elf64-x86-64 $@ [email protected]

Quite possibly because there was a blank missing in there, to separate the colon from $(OBJCOPY). Preferably with the adjustment (which I'd be fine doing while committing, as long as you're okay)

Took some time to understand your concern here, but finally I've got it. :-)

Yes, I'm fine with this change.

Quoted 1 line

Thanks.

Quoted 4 lines

To also mention what we have just discussed: Since we're talking about duplicating over 30Mb of data (at least according to my build), an option is going to be to then strip debug info off of xen.efi itself, getting its size into reasonable range again.

Yes, this would shrink it to a little bit above 3MB.

Juergen