From 5432e15521d5ce5a7d3f26bf78674cbaa9d73d1f Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 7 Jan 2020 14:51:19 +0100 Subject: arch: Add RISC-V 64-bit support Signed-off-by: Andreas Schwab [PM: minor macro shuffling in seccomp.h.in] Signed-off-by: Paul Moore --- tools/scmp_arch_detect.c | 3 +++ tools/scmp_bpf_disasm.c | 2 ++ tools/scmp_bpf_sim.c | 2 ++ tools/util.c | 2 ++ tools/util.h | 7 +++++++ 5 files changed, 16 insertions(+) (limited to 'tools') diff --git a/tools/scmp_arch_detect.c b/tools/scmp_arch_detect.c index ad43f2d..b844a68 100644 --- a/tools/scmp_arch_detect.c +++ b/tools/scmp_arch_detect.c @@ -120,6 +120,9 @@ int main(int argc, char *argv[]) case SCMP_ARCH_S390X: printf("s390x\n"); break; + case SCMP_ARCH_RISCV64: + printf("riscv64\n"); + break; default: printf("unknown\n"); } diff --git a/tools/scmp_bpf_disasm.c b/tools/scmp_bpf_disasm.c index 27fba9a..5c914b4 100644 --- a/tools/scmp_bpf_disasm.c +++ b/tools/scmp_bpf_disasm.c @@ -508,6 +508,8 @@ int main(int argc, char *argv[]) arch = AUDIT_ARCH_S390; else if (strcmp(optarg, "s390x") == 0) arch = AUDIT_ARCH_S390X; + else if (strcmp(optarg, "riscv64") == 0) + arch = AUDIT_ARCH_RISCV64; else exit_usage(argv[0]); break; diff --git a/tools/scmp_bpf_sim.c b/tools/scmp_bpf_sim.c index 4d30822..a381314 100644 --- a/tools/scmp_bpf_sim.c +++ b/tools/scmp_bpf_sim.c @@ -285,6 +285,8 @@ int main(int argc, char *argv[]) arch = AUDIT_ARCH_S390; else if (strcmp(optarg, "s390x") == 0) arch = AUDIT_ARCH_S390X; + else if (strcmp(optarg, "riscv64") == 0) + arch = AUDIT_ARCH_RISCV64; else exit_fault(EINVAL); break; diff --git a/tools/util.c b/tools/util.c index 7122335..741b2a2 100644 --- a/tools/util.c +++ b/tools/util.c @@ -78,6 +78,8 @@ #define ARCH_NATIVE AUDIT_ARCH_S390X #elif __s390__ #define ARCH_NATIVE AUDIT_ARCH_S390 +#elif __riscv && __riscv_xlen == 64 +#define ARCH_NATIVE AUDIT_ARCH_RISCV64 #else #error the simulator code needs to know about your machine type #endif diff --git a/tools/util.h b/tools/util.h index 08c4839..6c2ca33 100644 --- a/tools/util.h +++ b/tools/util.h @@ -72,6 +72,13 @@ #define AUDIT_ARCH_PPC64LE (EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) #endif +#ifndef AUDIT_ARCH_RISCV64 +#ifndef EM_RISCV +#define EM_RISCV 243 +#endif /* EM_RISCV */ +#define AUDIT_ARCH_RISCV64 (EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#endif /* AUDIT_ARCH_RISCV64 */ + extern uint32_t arch; uint16_t ttoh16(uint32_t arch, uint16_t val); -- cgit v1.2.1