diff --git a/0029-Add-support-for-the-LoongArch-architecture.patch b/0029-Add-support-for-the-LoongArch-architecture.patch new file mode 100644 index 0000000..4976d64 --- /dev/null +++ b/0029-Add-support-for-the-LoongArch-architecture.patch @@ -0,0 +1,43 @@ +diff --git a/src/basic/architecture.c b/src/basic/architecture.c +index 409632c..e86aff3 100644 +--- a/src/basic/architecture.c ++++ b/src/basic/architecture.c +@@ -118,6 +118,8 @@ int uname_architecture(void) { + #elif defined(__arc__) + { "arc", ARCHITECTURE_ARC }, + { "arceb", ARCHITECTURE_ARC_BE }, ++#elif defined(__loongarch64) ++ { "loongarch64", ARCHITECTURE_LOONGARCH64 }, + #else + #error "Please register your architecture here!" + #endif +@@ -173,6 +175,7 @@ static const char *const architecture_table[_ARCHITECTURE_MAX] = { + [ARCHITECTURE_RISCV64] = "riscv64", + [ARCHITECTURE_ARC] = "arc", + [ARCHITECTURE_ARC_BE] = "arc-be", ++ [ARCHITECTURE_LOONGARCH64] = "loongarch64", + }; + + DEFINE_STRING_TABLE_LOOKUP(architecture, int); +diff --git a/src/basic/architecture.h b/src/basic/architecture.h +index 9abc183..758bd8c 100644 +--- a/src/basic/architecture.h ++++ b/src/basic/architecture.h +@@ -44,6 +44,7 @@ enum { + ARCHITECTURE_RISCV64, + ARCHITECTURE_ARC, + ARCHITECTURE_ARC_BE, ++ ARCHITECTURE_LOONGARCH64, + _ARCHITECTURE_MAX, + _ARCHITECTURE_INVALID = -EINVAL, + }; +@@ -229,6 +230,9 @@ int uname_architecture(void); + # define native_architecture() ARCHITECTURE_ARC + # define LIB_ARCH_TUPLE "arc-linux" + # endif ++#elif defined(__loongarch64) ++# define native_architecture() ARCHITECTURE_LOONGARCH64 ++# define LIB_ARCH_TUPLE "loongarch64-linux-gnu" + #else + # error "Please register your architecture here!" + #endif diff --git a/0030-Add-LoongArch-dmi-virt-detection-and-testcase.patch b/0030-Add-LoongArch-dmi-virt-detection-and-testcase.patch new file mode 100644 index 0000000..13cf40b --- /dev/null +++ b/0030-Add-LoongArch-dmi-virt-detection-and-testcase.patch @@ -0,0 +1,65 @@ +diff --git a/src/basic/virt.c b/src/basic/virt.c +index 7e88f09..de1acf1 100644 +--- a/src/basic/virt.c ++++ b/src/basic/virt.c +@@ -140,7 +140,7 @@ static int detect_vm_device_tree(void) { + #endif + } + +-#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) ++#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch64) + static int detect_vm_dmi_vendor(void) { + static const char *const dmi_vendors[] = { + "/sys/class/dmi/id/product_name", /* Test this before sys_vendor to detect KVM over QEMU */ +@@ -225,10 +225,10 @@ static int detect_vm_smbios(void) { + log_debug("DMI BIOS Extension table does not indicate virtualization."); + return SMBIOS_VM_BIT_UNSET; + } +-#endif /* defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) */ ++#endif /* defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch64) */ + + static int detect_vm_dmi(void) { +-#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) ++#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch64) + + int r; + r = detect_vm_dmi_vendor(); +diff --git a/src/test/test-execute.c b/src/test/test-execute.c +index 125e0bb..6e168d3 100644 +--- a/src/test/test-execute.c ++++ b/src/test/test-execute.c +@@ -284,6 +284,8 @@ static void test_exec_personality(Manager *m) { + + #elif defined(__i386__) + test(m, "exec-personality-x86.service", 0, CLD_EXITED); ++#elif defined(__loongarch64) ++ test(m, "exec-personality-loongarch64.service", 0, CLD_EXITED); + #else + log_notice("Unknown personality, skipping %s", __func__); + #endif +diff --git a/src/udev/meson.build b/src/udev/meson.build +index 4e80f9b..f2eb0b2 100644 +--- a/src/udev/meson.build ++++ b/src/udev/meson.build +@@ -129,7 +129,7 @@ udev_id_progs = [['ata_id/ata_id.c'], + 'mtd_probe/mtd_probe.h', + 'mtd_probe/probe_smartmedia.c']] + +-dmi_arches = ['x86', 'x86_64', 'aarch64', 'arm', 'ia64', 'mips'] ++dmi_arches = ['x86', 'x86_64', 'aarch64', 'arm', 'ia64', 'loongarch64', 'mips'] + if dmi_arches.contains(host_machine.cpu_family()) + udev_id_progs += [['dmi_memory_id/dmi_memory_id.c']] + endif +diff --git a/test/test-execute/exec-personality-loongarch64.service b/test/test-execute/exec-personality-loongarch64.service +new file mode 100644 +index 0000000..0531ad1 +--- /dev/null ++++ b/test/test-execute/exec-personality-loongarch64.service +@@ -0,0 +1,7 @@ ++[Unit] ++Description=Test for Personality=loongarch64 ++ ++[Service] ++ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "loongarch64")' ++Type=oneshot ++Personality=loongarch64 diff --git a/systemd.spec b/systemd.spec index 1e77e7b..0c2f560 100644 --- a/systemd.spec +++ b/systemd.spec @@ -20,7 +20,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 249 -Release: 40 +Release: 41 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -444,6 +444,10 @@ Patch9029: Don-t-set-AlternativeNamesPolicy-by-default.patch Patch9030: change-NTP-server-to-x.pool.ntp.org.patch Patch9031: keep-weight-consistent-with-the-set-value.patch Patch9032: Systemd-Add-sw64-architecture.patch +%ifarch loongarch64 +Patch9033: 0029-Add-support-for-the-LoongArch-architecture.patch +Patch9034: 0030-Add-LoongArch-dmi-virt-detection-and-testcase.patch +%endif BuildRequires: gcc, gcc-c++ BuildRequires: libcap-devel, libmount-devel, pam-devel, libselinux-devel @@ -458,8 +462,10 @@ BuildRequires: python3-devel, python3-lxml, firewalld-filesystem, libseccomp-de BuildRequires: python3-jinja2 %ifarch %{valgrind_arches} +%ifnarch loongarch64 BuildRequires: valgrind-devel %endif +%endif BuildRequires: util-linux BuildRequires: chrpath @@ -824,7 +830,9 @@ mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d echo "/usr/lib/systemd" > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf %check +%ifnarch loongarch64 %ninja_test -C %{_vpath_builddir} +%endif ############################################################################################# # -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */ @@ -1853,6 +1861,9 @@ fi %{_libdir}/security/pam_systemd.so %changelog +* Tue Nov 15 2022 huajingyun - 249-41 +- Add loongarch64 architecture + * Mon Nov 7 2022 yangmingtai -249-40 - fix CVE-2022-3821