Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,18 @@ fi
AM_CONDITIONAL(USE_RISCV, test x$use_riscv = xyes)
AC_MSG_RESULT($use_riscv)

withval=""
AC_MSG_CHECKING(whether to include loongarch64 processor support)
AC_ARG_WITH(loongarch64,
AS_HELP_STRING([--with-loongarch64],[enable LoongArch64 processor support]),
use_loongarch64=$withval,
use_loongarch64=no)
if test x$use_loongarch64 != xno ; then
AC_DEFINE(WITH_LOONGARCH64,1,[Define if you want to enable LoongArch64 processor support.])
fi
AM_CONDITIONAL(USE_LOONGARCH64, test x$use_loongarch64 = xyes)
AC_MSG_RESULT($use_loongarch64)

withval=""
AC_MSG_CHECKING(whether to use apparmor)
AC_ARG_WITH(apparmor,
Expand Down
13 changes: 13 additions & 0 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ endif
if USE_RISCV
BUILT_SOURCES += riscv64_tables.h riscv32_tables.h
endif
if USE_LOONGARCH64
BUILT_SOURCES += loongarch64_tables.h
endif
noinst_PROGRAMS = gen_actiontabs_h gen_errtabs_h gen_fieldtabs_h \
gen_flagtabs_h gen_fstypetabs_h gen_ftypetabs_h gen_i386_tables_h \
gen_machinetabs_h gen_msg_typetabs_h gen_optabs_h \
Expand All @@ -71,6 +74,9 @@ endif
if USE_RISCV
noinst_PROGRAMS += gen_riscv64_tables_h gen_riscv32_tables_h
endif
if USE_LOONGARCH64
noinst_PROGRAMS += gen_loongarch64_tables_h
endif
include $(top_srcdir)/lib/gen_tables.mk

gen_actiontabs_h_SOURCES = gen_tables.c gen_tables.h actiontab.h
Expand Down Expand Up @@ -104,6 +110,13 @@ riscv32_tables.h: gen_riscv32_tables_h Makefile
./gen_riscv32_tables_h --lowercase --i2s --s2i riscv32_syscall > $@
endif

if USE_LOONGARCH64
gen_loongarch64_tables_h_SOURCES = gen_tables.c gen_tables.h loongarch64_table.h
gen_loongarch64_tables_h_CFLAGS = '-DTABLE_H="loongarch64_table.h"'
loongarch64_tables.h: gen_loongarch64_tables_h Makefile
./gen_loongarch64_tables_h --lowercase --i2s --s2i loongarch64_syscall > $@
endif

gen_errtabs_h_SOURCES = gen_tables.c gen_tables.h errtab.h
gen_errtabs_h_CFLAGS = '-DTABLE_H="errtab.h"'
errtabs.h: gen_errtabs_h Makefile
Expand Down
3 changes: 3 additions & 0 deletions lib/libaudit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,8 @@ int audit_determine_machine(const char *arch)
machine = MACH_ARM;
else if (bits == ~__AUDIT_ARCH_64BIT && machine == MACH_RISCV64)
machine = MACH_RISCV32;
else if (bits == ~__AUDIT_ARCH_64BIT && machine == MACH_LOONGARCH64)
return -6; /* loongarch64 has no 32-bit variant */

/* Check for errors - return -6
* We don't allow 32 bit machines to specify 64 bit. */
Expand Down Expand Up @@ -1490,6 +1492,7 @@ int audit_determine_machine(const char *arch)
case MACH_S390X: /* fallthrough */
case MACH_IO_URING:
case MACH_RISCV64: /* fallthrough */
case MACH_LOONGARCH64: /* 64 bit only */
break;
case MACH_PPC64LE: /* 64 bit only */
if (bits && bits != __AUDIT_ARCH_64BIT)
Expand Down
3 changes: 2 additions & 1 deletion lib/libaudit.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ typedef enum {
MACH_PPC64LE,
MACH_IO_URING,
MACH_RISCV32,
MACH_RISCV64
MACH_RISCV64,
MACH_LOONGARCH64
} machine_t;

/* These are the valid audit failure tunable enum values */
Expand Down
15 changes: 15 additions & 0 deletions lib/lookup_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#include "riscv64_tables.h"
#include "riscv32_tables.h"
#endif
#ifdef WITH_LOONGARCH64
#include "loongarch64_tables.h"
#endif
#include "i386_tables.h"
#include "ppc_tables.h"
#include "s390_tables.h"
Expand Down Expand Up @@ -94,6 +97,9 @@ static const struct int_transtab elftab[] = {
{ MACH_RISCV32, AUDIT_ARCH_RISCV32 },
{ MACH_RISCV64, AUDIT_ARCH_RISCV64 },
#endif
#ifdef WITH_LOONGARCH64
{ MACH_LOONGARCH64, AUDIT_ARCH_LOONGARCH64 },
#endif
};
#define AUDIT_ELF_NAMES (sizeof(elftab)/sizeof(elftab[0]))

Expand Down Expand Up @@ -173,6 +179,11 @@ int audit_name_to_syscall(const char *sc, int machine)
found = riscv32_syscall_s2i(sc, &res);
break;
#endif
#ifdef WITH_LOONGARCH64
case MACH_LOONGARCH64:
found = loongarch64_syscall_s2i(sc, &res);
break;
#endif
#endif
case MACH_IO_URING:
return audit_name_to_uringop(sc);
Expand Down Expand Up @@ -225,6 +236,10 @@ const char *audit_syscall_to_name(int sc, int machine)
return riscv64_syscall_i2s(sc);
case MACH_RISCV32:
return riscv32_syscall_i2s(sc);
#endif
#ifdef WITH_LOONGARCH64
case MACH_LOONGARCH64:
return loongarch64_syscall_i2s(sc);
#endif
case MACH_IO_URING:
return audit_uringop_to_name(sc);
Expand Down
Loading