Skip to content

Commit

Permalink
Add LoongArch64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
pbatard committed Jan 29, 2025
1 parent 40fbaca commit 78ea180
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ env:
GCC5_ARM_PREFIX: arm-linux-gnueabi-
GCC5_AARCH64_PREFIX: aarch64-linux-gnu-
GCC5_RISCV64_PREFIX: riscv64-linux-gnu-
GCC5_LOONGARCH64_PREFIX: loongarch64-unknown-linux-gnu-

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
TARGET_TYPE: [ia32, x64, aa64, arm, riscv64]
TARGET_TYPE: [ia32, x64, aa64, arm, riscv64, loongarch64]
include:
- TARGET_TYPE: x64
TARGET_ARCH: X64
Expand All @@ -40,6 +41,9 @@ jobs:
- TARGET_TYPE: riscv64
TARGET_ARCH: RISCV64
TARGET_PKGS: gcc-riscv64-linux-gnu
- TARGET_TYPE: loongarch64
TARGET_ARCH: LOONGARCH64
TARGET_PKGS: gcc-multilib

steps:
- name: Check out repository
Expand All @@ -61,12 +65,17 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -y --no-install-recommends install python3-setuptools uuid-dev ${{ matrix.TARGET_PKGS }}
if [[ "${{ matrix.TARGET_ARCH }}" == "LOONGARCH64" ]]; then
curl -L -O https://github.com/loongson/build-tools/releases/download/2024.11.01/x86_64-cross-tools-loongarch64-binutils_2.43.1-gcc_14.2.0-glibc_2.40.tar.xz
tar -xJf x86_64-cross-tools-loongarch64-binutils_2.43.1-gcc_14.2.0-glibc_2.40.tar.xz
echo "$PWD/cross-tools/bin" >> "$GITHUB_PATH"
fi
- name: Set up EDK2
run: |
# We must patch EDK2's OpenSSL module to be able to import/export certificates and keys
patch --binary -d edk2 -p1 -i ../Add-extra-PKCS-encoding-and-decoding-to-OpensslLibFull.patch
# And we must patch OpenSSL itself to fix ARM and RISCV64 compilation
# And we must patch OpenSSL itself to fix ARM, RISCV64 and LOONGARCH compilation
if [ -f OpenSSL-submodule-fixes-for-${{ matrix.TARGET_ARCH }}-compilation.patch ]; then
patch -d edk2/CryptoPkg/Library/OpensslLib/openssl -p1 -i ../../../../../OpenSSL-submodule-fixes-for-${{ matrix.TARGET_ARCH }}-compilation.patch
fi
Expand Down
Binary file modified Mosby.nsh
Binary file not shown.
4 changes: 2 additions & 2 deletions MosbyPkg.dsc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## @file
# MSSB Application
#
# Copyright (c) 2024, Pete Batard <[email protected]>
# Copyright (c) 2024-2025, Pete Batard <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
Expand All @@ -12,7 +12,7 @@
PLATFORM_GUID = 8F782584-E305-4360-B11B-A92C6380D1D6
PLATFORM_VERSION = 1.0
DSC_SPECIFICATION = 0x00010005
SUPPORTED_ARCHITECTURES = IA32|X64|EBC|ARM|AARCH64|RISCV64
SUPPORTED_ARCHITECTURES = IA32|X64|EBC|ARM|AARCH64|RISCV64|LOONGARCH64
OUTPUT_DIRECTORY = Build
BUILD_TARGETS = DEBUG|RELEASE|NOOPT
SKUID_IDENTIFIER = DEFAULT
Expand Down
26 changes: 26 additions & 0 deletions OpenSSL-submodule-fixes-for-LOONGARCH64-compilation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 16f95d56d81712f763728b20290ca7ba7434590f Mon Sep 17 00:00:00 2001
From: Pete Batard <[email protected]>
Date: Wed, 29 Jan 2025 11:21:24 +0000
Subject: [PATCH] OpenSSL submodule fixes for LOONGARCH64 compilation

* left shift was generating references to __ashlti3 which we don't have.
---
crypto/ec/curve448/f_generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/ec/curve448/f_generic.c b/crypto/ec/curve448/f_generic.c
index 4c571810d3..3084d82319 100644
--- a/crypto/ec/curve448/f_generic.c
+++ b/crypto/ec/curve448/f_generic.c
@@ -80,7 +80,7 @@ mask_t gf_deserialize(gf x, const uint8_t serial[SER_BYTES], int with_hibit,
sj = serial[j];
if (j == nbytes - 1)
sj &= ~hi_nmask;
- buffer |= ((dword_t) sj) << fill;
+ ((uint8_t*)&buffer)[j] = sj;
fill += 8;
j++;
}
--
2.45.2.windows.1

2 changes: 2 additions & 0 deletions src/mosby.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#define ARCH_EXT L"arm"
#elif defined(_M_RISCV64) || (defined (__riscv) && (__riscv_xlen == 64))
#define ARCH_EXT L"riscv64"
#elif defined (_M_LOONGARCH64) || defined (__loongarch64)
#define ARCH_EXT L"loongarch64"
#else
# error Unsupported architecture
#endif
Expand Down

0 comments on commit 78ea180

Please sign in to comment.