Your message dated Mon, 30 Dec 2024 13:00:16 +0000
with message-id <[email protected]>
and subject line Bug#1091191: fixed in edk2 2024.11-3
has caused the Debian Bug report #1091191,
regarding edk2: Add loongarch64 build support in debian
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1091191: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1091191
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: edk2
Version: 2024.11-2
Severity: normal
Tags: FTBFS patch
User: [email protected]
Usertags: loong64

Hi maintainers,

The edk2 package is built for arch=all architectures in the Debian Package Auto-Building environment. When we tested Loongrch virtualization locally, we find that there is a lack of loongarch64 support in Debian edk2. Obviously, qemu-efi-loongarch64 package and efi-shell-loongarch64 package are not built for loong64.

Please consider the patch I attached for edk2 source package.
For the patch, I have the following 2 explanations,
Firstly, about patch: debian/patches/debian-edk2-202411-Cherry-pick-from-upstream.patch.
1. I cherry pick upstream PR for Debian edk2 (2024.11-2).
Due to we hope to enable $(COMMON_FLAGS) in d/rules for loongarch64 referring to other architectures.
2. The PR was merged in upstream which is Signed-Off-By [email protected].
Details can be found at https://github.com/tianocore/edk2/pull/6550.
```
LOONGARCH64_FLAGS = $(COMMON_FLAGS)
set -e; . ./edksetup.sh; \
                build -a LOONGARCH64 \
                        -t $(EDK2_TOOLCHAIN) \
                        -p OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc \
                        $(LOONGARCH64_FLAGS) -b $(BUILD_TYPE)
```

Secondly, about patch: 0001-edk2-12-18-enable-loongarch64-build-in-debian.patch
1. I have added loongarch64 build support for Debian edk2 (2024.11-2).
In order to building qemu-efi-loongarch64 package and efi-shell-loongarch64 package.
2. I have built edk2 package successfully on my local ENV.
```
dpkg-deb: 正在 '../efi-shell-aa64_2024.11-2+loong64_all.deb' 中构建软件包 'efi-shell-aa64'。
......
dpkg-deb: 正在 '../qemu-efi-loongarch64_2024.11-2+loong64_all.deb' 中构建软件包 'qemu-efi-loongarch64'。
dpkg-deb: 正在 '../ovmf_2024.11-2+loong64_all.deb' 中构建软件包 'ovmf'。
dpkg-deb: 正在 '../efi-shell-riscv64_2024.11-2+loong64_all.deb' 中构建软件包 'efi-shell-riscv64'。 dpkg-deb: 正在 '../efi-shell-arm_2024.11-2+loong64_all.deb' 中构建软件包 'efi-shell-arm'。 dpkg-deb: 正在 '../qemu-efi-riscv64_2024.11-2+loong64_all.deb' 中构建软件包 'qemu-efi-riscv64'。 dpkg-deb: 正在 '../efi-shell-loongarch64_2024.11-2+loong64_all.deb' 中构建软件包 'efi-shell-loongarch64'。
 dpkg-genbuildinfo -O../edk2_2024.11-2+loong64_amd64.buildinfo
 dpkg-genchanges -O../edk2_2024.11-2+loong64_amd64.changes
```

Could you add loong64 support in the next upload?
You opinions are always welcome.

Best regards,
Dandan Zhang

>From 5e3952568f20eb1d0e65d7a0eed7fe2ba8ef547c Mon Sep 17 00:00:00 2001
From: Dandan Zhang <[email protected]>
Date: Tue, 17 Dec 2024 20:07:07 +0800
Subject: [PATCH] edk2 12 18 enable loongarch64 build in debian

---
 debian/changelog                            | 12 ++++++++
 debian/control                              | 19 +++++++++++++
 debian/descriptors/60-edk2-loongarch64.json | 31 +++++++++++++++++++++
 debian/efi-shell-loongarch64.install        |  2 ++
 debian/python/UEFI/Qemu.py                  | 14 ++++++++++
 debian/qemu-efi-loongarch64.install         |  3 ++
 debian/rules                                | 29 +++++++++++++++++--
 debian/tests/control                        |  2 ++
 debian/tests/shell.py                       |  4 +++
 9 files changed, 114 insertions(+), 2 deletions(-)
 create mode 100644 debian/descriptors/60-edk2-loongarch64.json
 create mode 100755 debian/efi-shell-loongarch64.install
 create mode 100644 debian/qemu-efi-loongarch64.install

diff --git a/debian/changelog b/debian/changelog
index 95082e1b..f56b35a1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+edk2 (2024.11-2+loong64) unstable; urgency=medium
+
+  * Add loongarch64 support.
+    - Add qemu-efi-loongarch64 package.
+      + qemu-efi-loongarch64/QEMU_EFI.fd
+      + qemu-efi-loongarch64/QEMU_VARS.fd
+      + qemu/firmware/60-edk2-loongarch64.json
+    - Add efi-shell-loongarch64 package.
+      + efi-shell-loongarch64/shellloongarch64.efi
+
+ -- Dandan Zhang <[email protected]>  Mon, 16 Dec 2024 18:44:12 +0800
+
 edk2 (2024.11-2) unstable; urgency=medium
 
   * qemu-efi-riscv64: Add 60-edk2-riscv64.json firmware descriptor,
diff --git a/debian/control b/debian/control
index 25e6b735..2ff210bc 100644
--- a/debian/control
+++ b/debian/control
@@ -12,6 +12,7 @@ Build-Depends: bc,
  gcc-arm-linux-gnueabi,
  gcc-multilib [i386],
  gcc-riscv64-linux-gnu,
+ gcc-loongarch64-linux-gnu,
  iasl,
  lsb-release,
  mtools,
@@ -77,6 +78,14 @@ Multi-Arch: foreign
 Description: UEFI firmware for RISCV64 virtual machines
  qemu-efi-riscv64 is a build of EDK II for RISCV64 virtual machines.
 
+Package: qemu-efi-loongarch64
+Architecture: all
+Depends: ${misc:Depends}
+Suggests: qemu-system-misc
+Multi-Arch: foreign
+Description: UEFI firmware for LoongArch64 virtual machines
+ qemu-efi-loongarch64 is a build of EDK II for LoongArch64 virtual machines.
+
 Package: efi-shell-ia32
 Architecture: all
 Depends: ${misc:Depends}
@@ -126,3 +135,13 @@ Description: UEFI Shell for 64-bit RISC-V architecture
  options, or to display details of installed devices, drivers, and protocols.
  This package contains the shellriscv64.efi binary for the 64-bit RISC-V
  architecture.
+
+Package: efi-shell-loongarch64
+Architecture: all
+Depends: ${misc:Depends}
+Description: UEFI Shell for 64-bit LoongArch architecture
+ The UEFI Shell provides a command line interface running on top of the EFI API.
+ It can be used to execute EFI binaries, to manage EFI variables and boot
+ options, or to display details of installed devices, drivers, and protocols.
+ This package contains the shellloongarch64.efi binary for the 64-bit LoongArch
+ architecture.
diff --git a/debian/descriptors/60-edk2-loongarch64.json b/debian/descriptors/60-edk2-loongarch64.json
new file mode 100644
index 00000000..ed8de045
--- /dev/null
+++ b/debian/descriptors/60-edk2-loongarch64.json
@@ -0,0 +1,31 @@
+{
+    "description": "UEFI firmware for loongarch64",
+    "interface-types": [
+        "uefi"
+    ],
+    "mapping": {
+        "device": "flash",
+        "executable": {
+            "filename": "/usr/share/qemu-efi-loongarch64/QEMU_EFI.fd",
+            "format": "raw"
+        },
+        "nvram-template": {
+            "filename": "/usr/share/qemu-efi-loongarch64/QEMU_VARS.fd",
+            "format": "raw"
+        }
+    },
+    "targets": [
+        {
+            "architecture": "loongarch64",
+            "machines": [
+                "virt*"
+            ]
+        }
+    ],
+    "features": [
+
+    ],
+    "tags": [
+
+    ]
+}
diff --git a/debian/efi-shell-loongarch64.install b/debian/efi-shell-loongarch64.install
new file mode 100755
index 00000000..03cddc14
--- /dev/null
+++ b/debian/efi-shell-loongarch64.install
@@ -0,0 +1,2 @@
+#!/usr/bin/dh-exec
+debian/loongarch64-install/Shell.efi => /usr/share/efi-shell-loongarch64/shellloongarch64.efi
diff --git a/debian/python/UEFI/Qemu.py b/debian/python/UEFI/Qemu.py
index adf04928..624667a3 100644
--- a/debian/python/UEFI/Qemu.py
+++ b/debian/python/UEFI/Qemu.py
@@ -30,6 +30,7 @@ class QemuEfiMachine(enum.Enum):
     AAVMF = enum.auto()
     AAVMF32 = enum.auto()
     RISCV64 = enum.auto()
+    LOONGARCH64 = enum.auto()
 
 
 class QemuEfiVariant(enum.Enum):
@@ -61,6 +62,9 @@ class QemuCommand:
     RiscV_Common_Params = Qemu_Common_Params + [
         '-machine', 'virt', '-device', 'virtio-serial-device',
     ]
+    LoongArch_Common_Params = Qemu_Common_Params + [
+        '-machine', 'virt', '-device', 'virtio-serial-device',
+    ]
     Machine_Base_Command = {
         QemuEfiMachine.AAVMF: [
             'qemu-system-aarch64', '-cpu', 'cortex-a57',
@@ -83,6 +87,9 @@ class QemuCommand:
         QemuEfiMachine.RISCV64: [
             'qemu-system-riscv64',
         ] + RiscV_Common_Params,
+        QemuEfiMachine.LOONGARCH64: [
+            'qemu-system-loongarch64',
+        ] + LoongArch_Common_Params,
     }
 
     def _get_default_flash_paths(self, machine, variant, flash_size):
@@ -123,6 +130,13 @@ class QemuCommand:
                 '/usr/share/qemu-efi-riscv64/RISCV_VIRT_CODE.fd',
                 '/usr/share/qemu-efi-riscv64/RISCV_VIRT_VARS.fd',
             )
+        if machine == QemuEfiMachine.LOONGARCH64:
+            assert(variant is None)
+            assert(flash_size == QemuEfiFlashSize.DEFAULT)
+            return (
+                '/usr/share/qemu-efi-loongarch64/QEMU_EFI.fd',
+                '/usr/share/qemu-efi-loongarch64/QEMU_VARS.fd',
+            )
         # Remaining possibilities are OVMF variants
         assert(
             flash_size in [
diff --git a/debian/qemu-efi-loongarch64.install b/debian/qemu-efi-loongarch64.install
new file mode 100644
index 00000000..ea45da4f
--- /dev/null
+++ b/debian/qemu-efi-loongarch64.install
@@ -0,0 +1,3 @@
+debian/loongarch64-install/QEMU_EFI.fd /usr/share/qemu-efi-loongarch64
+debian/loongarch64-install/QEMU_VARS.fd /usr/share/qemu-efi-loongarch64
+debian/descriptors/60-edk2-loongarch64.json /usr/share/qemu/firmware
diff --git a/debian/rules b/debian/rules
index c038a6d2..12e91b89 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,6 +9,7 @@ EDK2_TOOLCHAIN = GCC5
 export $(EDK2_TOOLCHAIN)_AARCH64_PREFIX=aarch64-linux-gnu-
 export $(EDK2_TOOLCHAIN)_ARM_PREFIX=arm-linux-gnueabi-
 export $(EDK2_TOOLCHAIN)_RISCV64_PREFIX=riscv64-linux-gnu-
+export $(EDK2_TOOLCHAIN)_LOONGARCH64_PREFIX=loongarch64-linux-gnu-
 
 export PYTHON3_ENABLE=TRUE
 
@@ -48,6 +49,7 @@ AAVMF_COMMON_FLAGS += -DCAVIUM_ERRATUM_27456=TRUE
 AAVMF_SECBOOT_FLAGS = $(AAVMF_COMMON_FLAGS) -DBUILD_SHELL=FALSE -DSECURE_BOOT_ENABLE=TRUE
 
 RISCV64_FLAGS = $(COMMON_FLAGS)
+LOONGARCH64_FLAGS = $(COMMON_FLAGS)
 
 # Clear variables used internally by the edk2 build system
 undefine WORKSPACE
@@ -60,7 +62,7 @@ undefine CONF_PATH
 %:
 	dh $@
 
-override_dh_auto_build: build-qemu-efi-aarch64 build-qemu-efi-arm build-ovmf build-ovmf32 build-qemu-efi-riscv64
+override_dh_auto_build: build-qemu-efi-aarch64 build-qemu-efi-arm build-ovmf build-ovmf32 build-qemu-efi-riscv64 build-qemu-efi-loongarch64
 
 debian/setup-build-stamp:
 	set -e; . ./edksetup.sh; \
@@ -102,6 +104,11 @@ RISCV64_BUILD_ROOT = Build/RiscVVirtQemu
 RISCV64_BUILD_DIR = $(RISCV64_BUILD_ROOT)/$(BUILD_TYPE)_$(EDK2_TOOLCHAIN)
 RISCV64_IMAGES    = $(addprefix $(RISCV64_INSTALL_DIR)/,RISCV_VIRT_CODE.fd RISCV_VIRT_VARS.fd)
 
+LOONGARCH64_INSTALL_DIR = debian/loongarch64-install
+LOONGARCH64_BUILD_ROOT = Build/LoongArchVirtQemu
+LOONGARCH64_BUILD_DIR = $(LOONGARCH64_BUILD_ROOT)/$(BUILD_TYPE)_$(EDK2_TOOLCHAIN)
+LOONGARCH64_IMAGES    = $(addprefix $(LOONGARCH64_INSTALL_DIR)/,QEMU_EFI.fd QEMU_VARS.fd)
+
 build-ovmf32: $(OVMF32_BINARIES) $(OVMF32_IMAGES)
 $(OVMF32_BINARIES) $(OVMF32_IMAGES): debian/setup-build-stamp
 	rm -rf $(OVMF32_INSTALL_DIR)
@@ -284,6 +291,24 @@ $(RISCV64_IMAGES): debian/setup-build-stamp
 	truncate -s 32M $(RISCV64_INSTALL_DIR)/RISCV_VIRT_CODE.fd
 	truncate -s 32M $(RISCV64_INSTALL_DIR)/RISCV_VIRT_VARS.fd
 
+build-qemu-efi-loongarch64:  $(LOONGARCH64_IMAGES)
+$(LOONGARCH64_IMAGES): debian/setup-build-stamp
+	rm -rf $(LOONGARCH64_INSTALL_DIR)
+	mkdir $(LOONGARCH64_INSTALL_DIR)
+	set -e; . ./edksetup.sh; \
+		build -a LOONGARCH64 \
+			-t $(EDK2_TOOLCHAIN) \
+			-p OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc \
+			$(LOONGARCH64_FLAGS) -b $(BUILD_TYPE)
+	cp $(LOONGARCH64_BUILD_DIR)/LOONGARCH64/Shell.efi \
+		$(LOONGARCH64_INSTALL_DIR)/
+	cp $(LOONGARCH64_BUILD_DIR)/FV/QEMU_EFI.fd \
+		$(LOONGARCH64_INSTALL_DIR)/
+	cp $(LOONGARCH64_BUILD_DIR)/FV/QEMU_VARS.fd \
+		$(LOONGARCH64_INSTALL_DIR)/
+	truncate -s 16M $(LOONGARCH64_INSTALL_DIR)/QEMU_EFI.fd
+	truncate -s 16M $(LOONGARCH64_INSTALL_DIR)/QEMU_VARS.fd
+
 override_dh_auto_clean:
 	-. ./edksetup.sh; build clean
 	make -C BaseTools clean
@@ -322,4 +347,4 @@ get-orig-source:
 		edk2-$(DEB_VERSION_UPSTREAM)
 	rm -rf edk2.tmp edk2-$(DEB_VERSION_UPSTREAM)
 
-.PHONY: build-ovmf build-ovmf32 build-qemu-efi build-qemu-efi-aarch64 build-qemu-efi-arm build-qemu-efi-riscv64
+.PHONY: build-ovmf build-ovmf32 build-qemu-efi build-qemu-efi-aarch64 build-qemu-efi-arm build-qemu-efi-riscv64 build-qemu-efi-loongarch64
diff --git a/debian/tests/control b/debian/tests/control
index 90632672..560085ec 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -12,9 +12,11 @@ Depends:
  qemu-efi-aarch64,
  qemu-efi-arm,
  qemu-efi-riscv64,
+ qemu-efi-loongarch64,
  qemu-system-arm,
  qemu-system-riscv64,
  qemu-system-x86,
+ qemu-system-misc,
  sbsigntool [amd64 arm64],
  shim-signed [amd64 arm64],
  xorriso [amd64 arm64],
diff --git a/debian/tests/shell.py b/debian/tests/shell.py
index 8e90d6c0..70d7a8ab 100755
--- a/debian/tests/shell.py
+++ b/debian/tests/shell.py
@@ -273,5 +273,9 @@ class BootToShellTest(unittest.TestCase):
         q = Qemu.QemuCommand(QemuEfiMachine.RISCV64)
         self.run_cmd_check_shell(q.command)
 
+    def test_loongarch64(self):
+        q = Qemu.QemuCommand(QemuEfiMachine.LOONGARCH64)
+        self.run_cmd_check_shell(q.command)
+
 if __name__ == '__main__':
     unittest.main(verbosity=2)
-- 
2.43.0

Description: Cherry pick from upstream for loongarch64.
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 edk2 (2024.11-2+loong64) unstable; urgency=medium
 .
   * Add loongarch64 support.
     - Add qemu-efi-loongarch64 package.
       + qemu-efi-loongarch64/QEMU_EFI.fd
       + qemu-efi-loongarch64/QEMU_VARS.fd
       + qemu/firmware/60-edk2-loongarch64.json
     - Add efi-shell-loongarch64 package.
       + efi-shell-loongarch64/shellloongarch64.efi
Author: Dandan Zhang <[email protected]>

---
Applied-Upstream: master, (https://github.com/tianocore/edk2/pull/6550) 
Last-Update: 2024-12-23

--- edk2-2024.11.orig/OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc
+++ edk2-2024.11/OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc
@@ -155,6 +155,18 @@
   FileExplorerLib                  | MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
   ImagePropertiesRecordLib         | MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf
 
+  #
+  # CryptoPkg libraries needed by multiple firmware features
+  #
+  IntrinsicLib                     | CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+!if $(NETWORK_TLS_ENABLE) == TRUE
+  OpensslLib                       | CryptoPkg/Library/OpensslLib/OpensslLib.inf
+!else
+  OpensslLib                       | CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
+!endif
+  BaseCryptLib                     | CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+  RngLib                           | MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
 !if $(HTTP_BOOT_ENABLE) == TRUE
   HttpLib                          | MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf
 !endif
--- edk2-2024.11.orig/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c
+++ edk2-2024.11/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c
@@ -115,23 +115,22 @@ CommonExceptionHandler (
     // Interrupt
     //
     InterruptType = GetInterruptType (SystemContext);
-    if (InterruptType == 0xFF) {
-      ExceptionType = InterruptType;
-    } else {
+    if (InterruptType != 0xFF) {
       if ((ExternalInterruptHandler != NULL) && (ExternalInterruptHandler[InterruptType] != NULL)) {
         ExternalInterruptHandler[InterruptType](InterruptType, SystemContext);
         return;
       }
     }
-  } else if (ExceptionType == EXCEPT_LOONGARCH_FPD) {
-    EnableFloatingPointUnits ();
-    InitializeFloatingPointUnits ();
-    return;
   } else {
     //
     // Exception
     //
-    ExceptionType >>= CSR_ESTAT_EXC_SHIFT;
+    if (ExceptionType == EXCEPT_LOONGARCH_FPD) {
+      EnableFloatingPointUnits ();
+      InitializeFloatingPointUnits ();
+      return;
+    }
+
     if ((ExceptionHandler != NULL) && (ExceptionHandler[ExceptionType] != NULL)) {
       ExceptionHandler[ExceptionType](ExceptionType, SystemContext);
       return;
--- edk2-2024.11.orig/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.c
+++ edk2-2024.11/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.c
@@ -43,8 +43,24 @@ CONST CHAR8  *mExceptionNameStr[]    = {
   "#GCXC - Guest CSR Software/Hardware Change exception",
   "#TBR - TLB refill exception" // !!! NOTICE: Because the TLB refill exception is not instructed in ECODE, so the TLB refill exception must be the last one!
 };
+CONST CHAR8  *mInterruptNameStr[] = {
+  "#SIP0 - Software interrupt 0",
+  "#SIP1 - Software interrupt 1",
+  "#IP0 - Hardware interrupt 0",
+  "#IP1 - Hardware interrupt 1",
+  "#IP2 - Hardware interrupt 2",
+  "#IP3 - Hardware interrupt 3",
+  "#IP4 - Hardware interrupt 4",
+  "#IP5 - Hardware interrupt 5",
+  "#IP6 - Hardware interrupt 6",
+  "#IP7 - Hardware interrupt 7",
+  "#PMC - Performance counter overflow interrupt",
+  "#TIMER - Timer interrupt",
+  "#IPI - Inter-Processor interrupt"
+};
 
 INTN  mExceptionKnownNameNum = (sizeof (mExceptionNameStr) / sizeof (CHAR8 *));
+INTN  mInterruptKnownNameNum = (sizeof (mInterruptNameStr) / sizeof (CHAR8 *));
 
 /**
   Get ASCII format string exception name by exception type.
@@ -64,6 +80,26 @@ GetExceptionNameStr (
   } else {
     return mExceptionReservedStr;
   }
+}
+
+/**
+  Get ASCII format string interrupt name by exception type.
+
+  @param InterruptType  Interrupt type.
+
+  @return  ASCII format string interrupt name.
+
+**/
+CONST CHAR8 *
+GetInterruptNameStr (
+  IN EFI_EXCEPTION_TYPE  InterruptType
+  )
+{
+  if ((UINTN)InterruptType < mInterruptKnownNameNum) {
+    return mInterruptNameStr[InterruptType];
+  } else {
+    return mExceptionReservedStr;
+  }
 }
 
 /**
--- edk2-2024.11.orig/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.h
+++ edk2-2024.11/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.h
@@ -20,6 +20,7 @@
 #define MAX_LOONGARCH_EXCEPTION  64
 
 extern INTN  mExceptionKnownNameNum;
+extern INTN  mInterruptKnownNameNum;
 
 /**
   Get ASCII format string exception name by exception type.
@@ -35,6 +36,19 @@ GetExceptionNameStr (
   );
 
 /**
+  Get ASCII format string interrupt name by exception type.
+
+  @param InterruptType  Interrupt type.
+
+  @return  ASCII format string interrupt name.
+
+**/
+CONST CHAR8 *
+GetInterruptNameStr (
+  IN EFI_EXCEPTION_TYPE  InterruptType
+  );
+
+/**
   Prints a message to the serial port.
 
   @param[in]  Format      Format string for the message to print.
--- edk2-2024.11.orig/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c
+++ edk2-2024.11/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c
@@ -27,7 +27,7 @@ GetExceptionType (
 {
   EFI_EXCEPTION_TYPE  ExceptionType;
 
-  ExceptionType = (SystemContext.SystemContextLoongArch64->ESTAT & CSR_ESTAT_EXC);
+  ExceptionType = (SystemContext.SystemContextLoongArch64->ESTAT & CSR_ESTAT_EXC) >> CSR_ESTAT_EXC_SHIFT;
   return ExceptionType;
 }
 
@@ -96,6 +96,17 @@ DumpCpuContext (
     );
 
   //
+  // Dump interrupt type if the exception type is INT.
+  //
+  if (ExceptionType == EXCEPT_LOONGARCH_INT) {
+    InternalPrintMessage (
+      "\n!!!! Unhandled interrupt Type - %02x(%a) !!!!\n",
+      GetInterruptType (SystemContext),
+      GetInterruptNameStr (GetInterruptType (SystemContext))
+      );
+  }
+
+  //
   // Dump TLB refill ERA and BADV
   //
   if (ExceptionType == (mExceptionKnownNameNum - 1)) {
--- edk2-2024.11.orig/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/SecPeiExceptionLib.c
+++ edk2-2024.11/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/SecPeiExceptionLib.c
@@ -68,14 +68,7 @@ CommonExceptionHandler (
       //
       IpiInterruptHandler (InterruptType, SystemContext);
       return;
-    } else {
-      ExceptionType = InterruptType;
     }
-  } else {
-    //
-    // Exception
-    //
-    ExceptionType >>= CSR_ESTAT_EXC_SHIFT;
   }
 
   DefaultExceptionHandler (ExceptionType, SystemContext);

--- End Message ---
--- Begin Message ---
Source: edk2
Source-Version: 2024.11-3
Done: dann frazier <[email protected]>

We believe that the bug you reported is fixed in the latest version of
edk2, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
dann frazier <[email protected]> (supplier of updated edk2 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Tue, 24 Dec 2024 14:19:55 -0700
Source: edk2
Binary: efi-shell-aa64 efi-shell-arm efi-shell-ia32 efi-shell-loongarch64 
efi-shell-riscv64 efi-shell-x64 ovmf ovmf-ia32 qemu-efi-aarch64 qemu-efi-arm 
qemu-efi-loongarch64 qemu-efi-riscv64
Architecture: source all
Version: 2024.11-3
Distribution: unstable
Urgency: medium
Maintainer: Debian QEMU Team <[email protected]>
Changed-By: dann frazier <[email protected]>
Description:
 efi-shell-aa64 - UEFI Shell for 64-bit ARM architecture
 efi-shell-arm - UEFI Shell for 32-bit ARM architecture
 efi-shell-ia32 - UEFI Shell for 32-bit x86 architecture
 efi-shell-loongarch64 - UEFI Shell for 64-bit LoongArch architecture
 efi-shell-riscv64 - UEFI Shell for 64-bit RISC-V architecture
 efi-shell-x64 - UEFI Shell for 64-bit x86 architecture
 ovmf       - UEFI firmware for 64-bit x86 virtual machines
 ovmf-ia32  - UEFI firmware for 32-bit x86 virtual machines
 qemu-efi-aarch64 - UEFI firmware for 64-bit ARM virtual machines
 qemu-efi-arm - UEFI firmware for 32-bit ARM virtual machines
 qemu-efi-loongarch64 - UEFI firmware for LoongArch64 virtual machines
 qemu-efi-riscv64 - UEFI firmware for RISCV64 virtual machines
Closes: 1091191
Changes:
 edk2 (2024.11-3) unstable; urgency=medium
 .
   [ Dandan Zhang ]
   * Add loongarch64 support. (Closes: #1091191)
     - Add qemu-efi-loongarch64 package.
       + qemu-efi-loongarch64/QEMU_EFI.fd
       + qemu-efi-loongarch64/QEMU_VARS.fd
       + qemu/firmware/60-edk2-loongarch64.json
     - Add efi-shell-loongarch64 package.
       + efi-shell-loongarch64/shellloongarch64.efi
 .
   [ dann frazier ]
   * Cherry-pick upstream loongarch64 patches recommended by Dandan Zhang:
     - d/p/0001-UefiCpuPkg-Adjust-the-exception-handler-logic-on-Loo.patch
     - d/p/0002-UefiCpuPkg-Add-dump-interrupt-type-on-LoongArch64.patch
     - d/p/0003-OvmfPkg-LoongArch-Enabling-some-base-libraries.patch
   * debian/python/UEFI/Qemu: Drop virtio-serial-device from loongarch.
     QEMU does not currently seem to support it.
Checksums-Sha1:
 35c62e9862815b58c34451ee92dd2a6abd821873 2627 edk2_2024.11-3.dsc
 2fcd7daf26fe059fe12c4196821f81c49832518a 45016 edk2_2024.11-3.debian.tar.xz
 080c5d54387e2fdc4daea312aff7b14a4bce1e88 14212 edk2_2024.11-3_amd64.buildinfo
 4ab747287f4f72f4677cfad7d278c6fab9fcdd35 224728 
efi-shell-aa64_2024.11-3_all.deb
 70c5fc7d7924cc832d52b4f952b1c1f676c5743c 223896 efi-shell-arm_2024.11-3_all.deb
 0c8c8b82be2113e966cbe89a9a4e24bb08553946 241292 
efi-shell-ia32_2024.11-3_all.deb
 27e3d2403689f0aba541c0c7301362a67bddd7e7 253576 
efi-shell-loongarch64_2024.11-3_all.deb
 8d05a4da8eec7c618a91bc20f55e349b38e02660 259100 
efi-shell-riscv64_2024.11-3_all.deb
 2443a9c3a0e5981b8d2bfaad7f37357c674cf807 254144 efi-shell-x64_2024.11-3_all.deb
 5ce257d4db779ca9fe07aac4e4ffefe5de585f76 2974132 ovmf-ia32_2024.11-3_all.deb
 1c9e28635cbd599a642d982c911a4138e2038164 4689708 ovmf_2024.11-3_all.deb
 39178ecd54db9f459336980a46f666728c04d7ff 4245084 
qemu-efi-aarch64_2024.11-3_all.deb
 07593e5d3d4bdc8533532c785f9f176d1a5886dd 814812 qemu-efi-arm_2024.11-3_all.deb
 957fa8f80f39ccc7f24e366a15a44e43b2edbf02 1590428 
qemu-efi-loongarch64_2024.11-3_all.deb
 ccab2b69c4c8ba10bc849bb5bc93795b34fd9cc8 1406244 
qemu-efi-riscv64_2024.11-3_all.deb
Checksums-Sha256:
 7ca9ef01c41c1700338116c7a742b293a92bb8ed7948a7ffa26acd7e55ae4f28 2627 
edk2_2024.11-3.dsc
 a4743fd35f72b966a9cc0deada31626150cc857c21611aaaed6d4cdb87e2f88e 45016 
edk2_2024.11-3.debian.tar.xz
 40a846a609b9e1de0bc30dc5c99dcae364cbee46af6fb5b3d2ef8c0f1a20c85e 14212 
edk2_2024.11-3_amd64.buildinfo
 707ae16e4cb2a4878c467f813c34f1f182f39c1e4723dc50a44d564fabc9ef81 224728 
efi-shell-aa64_2024.11-3_all.deb
 24c2dcb8c94f39799103e0a5da2f854ac914c76cd11dcb699a7df10c48e6f48f 223896 
efi-shell-arm_2024.11-3_all.deb
 c1d54bbee7a7ead4aa7dfad13b91de294e78451f2e30f7fb886469756b1a3257 241292 
efi-shell-ia32_2024.11-3_all.deb
 b0a906297ef876d6b952677cf5d20f85d986c03857aa1199bfd94f84055611cb 253576 
efi-shell-loongarch64_2024.11-3_all.deb
 c99d7669873d37c6eee7ed4e242041032cea5cb061b6f7bc0f07c535d5680fcd 259100 
efi-shell-riscv64_2024.11-3_all.deb
 6e8d9aa2884d3a858c6517732f2969d0bfd00c07807451ec3f55028e1733df61 254144 
efi-shell-x64_2024.11-3_all.deb
 7c151f3a23bbabd6cd6be15dd1570767496605a86adfc9bb195943bb771e6861 2974132 
ovmf-ia32_2024.11-3_all.deb
 7a0834c27c02f43336c28749908d0c229d5ec0c13338f2bb41b6f5afe71a9a93 4689708 
ovmf_2024.11-3_all.deb
 e1a654c128de26a87de77126c3628662cf814abae52b973d9dd409ab1187844c 4245084 
qemu-efi-aarch64_2024.11-3_all.deb
 a2e49c82ddf44d6304a4075b4239416c58732c6d396d42c4d89d767b5ea077d8 814812 
qemu-efi-arm_2024.11-3_all.deb
 09e8f3b50427d6dc3d4b8144c0942890afef5b19b42b4c55e6ac8a9b4e3913c2 1590428 
qemu-efi-loongarch64_2024.11-3_all.deb
 1f82659c811660bd6ce4a29fd337774c321025cbe6d0a1d63ae2bafa34ce29dd 1406244 
qemu-efi-riscv64_2024.11-3_all.deb
Files:
 4607f619009512ff2c6223bac26e1bfd 2627 misc optional edk2_2024.11-3.dsc
 39cf4cfe014f552e151ce1c8bb747032 45016 misc optional 
edk2_2024.11-3.debian.tar.xz
 deb7834eca8ce8b072b3af67498200fe 14212 misc optional 
edk2_2024.11-3_amd64.buildinfo
 c4d96b15052fb37d4a865ef87f492700 224728 misc optional 
efi-shell-aa64_2024.11-3_all.deb
 bb9b5cdeb361b21180f506568b63f533 223896 misc optional 
efi-shell-arm_2024.11-3_all.deb
 b53a20b0527124387a2f3f18ed9af2f9 241292 misc optional 
efi-shell-ia32_2024.11-3_all.deb
 fbc919c42e83d4aba52b95738d862f79 253576 misc optional 
efi-shell-loongarch64_2024.11-3_all.deb
 40600af825b9feaa7ca75005d45ca6c3 259100 misc optional 
efi-shell-riscv64_2024.11-3_all.deb
 7bd33511d4587788a2866b1f44fa9669 254144 misc optional 
efi-shell-x64_2024.11-3_all.deb
 fb0251a97221ce2cdb34d9df72d9203d 2974132 misc optional 
ovmf-ia32_2024.11-3_all.deb
 3487c6f3cc99e0806f5876ac87d7d121 4689708 misc optional ovmf_2024.11-3_all.deb
 97f5a8b2c791a8b2c1e66ff613ad3ea5 4245084 misc optional 
qemu-efi-aarch64_2024.11-3_all.deb
 58de180f4aab383f3e47827c8434cd93 814812 misc optional 
qemu-efi-arm_2024.11-3_all.deb
 c434aaeb8732b8145048bf8a3065cf5c 1590428 misc optional 
qemu-efi-loongarch64_2024.11-3_all.deb
 44f89fbcf208dcb72b2095194f56b3bb 1406244 misc optional 
qemu-efi-riscv64_2024.11-3_all.deb

-----BEGIN PGP SIGNATURE-----

iIcEARYKAC8WIQQoGlxLiiPDxHQh9i5UW4ZA9GI6WAUCZ2w2IhEcZGFubmZAZGVi
aWFuLm9yZwAKCRBUW4ZA9GI6WBUWAP9rSHB6ZfVRp19F+htTClojKPnqymzm25pd
+IYWAieJCwD/c2BCNdrFKn66kQanVIyWjpgKcvJ0q6FU6JniBMW0nwk=
=LciY
-----END PGP SIGNATURE-----

Attachment: pgpg3wprl0Pqs.pgp
Description: PGP signature


--- End Message ---

Reply via email to