# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/chromium/hotfix-riscv64-support.patch.riscv64 # Copyright (C) 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- --- chromium-151.0.7922.71/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc.vanilla +++ chromium-151.0.7922.71/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc @@ -160,6 +160,25 @@ return Allow(); #endif +#if defined(ARCH_CPU_RISCV64) + // Two RISC-V specific syscalls that no generic syscall set covers, so + // without them the renderers die with SIGSYS: + // + // riscv_hwprobe(2) is called by glibc while resolving its ifuncs, which + // happens in every child process before any renderer code runs. + // riscv_flush_icache(2) is called after V8 emits code, whenever glibc + // cannot invalidate the icache with a plain fence.i from user space. +#if !defined(__NR_riscv_hwprobe) +#define __NR_riscv_hwprobe 258 +#endif +#if !defined(__NR_riscv_flush_icache) +#define __NR_riscv_flush_icache 259 +#endif + if (sysno == __NR_riscv_hwprobe || sysno == __NR_riscv_flush_icache) { + return Allow(); + } +#endif + // V8 uses PKU (a.k.a. MPK / PKEY) for protecting code spaces. if (sysno == __NR_pkey_alloc) { return RestrictPkeyAllocFlags(); @@ -260,7 +260,7 @@ // TODO(crbug.com/40528912): should i386 really be in this list? #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + defined(__aarch64__) || defined(ARCH_CPU_RISCV64) if (sysno == __NR_mmap) return RestrictMmapFlags(); #endif --- chromium-151.0.7922.71/sandbox/linux/syscall_broker/broker_process.cc.vanilla +++ chromium-151.0.7922.71/sandbox/linux/syscall_broker/broker_process.cc @@ -119,44 +119,46 @@ // and are default disabled in Android. So, we should refuse to broker them // to be consistent with the platform's restrictions. switch (sysno) { -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) && !BUILDFLAG(IS_ANDROID) case __NR_access: #endif case __NR_faccessat: case __NR_faccessat2: return !fast_check || policy_->allowed_command_set.test(COMMAND_ACCESS); -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) && !BUILDFLAG(IS_ANDROID) case __NR_mkdir: #endif case __NR_mkdirat: return !fast_check || policy_->allowed_command_set.test(COMMAND_MKDIR); -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) && !BUILDFLAG(IS_ANDROID) case __NR_open: #endif case __NR_openat: return !fast_check || policy_->allowed_command_set.test(COMMAND_OPEN); -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) && !BUILDFLAG(IS_ANDROID) case __NR_readlink: #endif case __NR_readlinkat: return !fast_check || policy_->allowed_command_set.test(COMMAND_READLINK); -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) && !BUILDFLAG(IS_ANDROID) case __NR_rename: #endif +#if !defined(ARCH_CPU_RISCV64) case __NR_renameat: +#endif case __NR_renameat2: return !fast_check || policy_->allowed_command_set.test(COMMAND_RENAME); -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) && !BUILDFLAG(IS_ANDROID) case __NR_rmdir: return !fast_check || policy_->allowed_command_set.test(COMMAND_RMDIR); #endif -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) && !BUILDFLAG(IS_ANDROID) case __NR_stat: case __NR_lstat: #endif @@ -166,7 +166,7 @@ #if defined(__NR_fstatat64) case __NR_fstatat64: #endif -#if defined(__x86_64__) || defined(__aarch64__) +#if defined(__x86_64__) || defined(__aarch64__) || defined(ARCH_CPU_RISCV64) case __NR_newfstatat: #endif return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT); @@ -181,7 +181,7 @@ return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT); #endif -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) && !BUILDFLAG(IS_ANDROID) case __NR_unlink: return !fast_check || policy_->allowed_command_set.test(COMMAND_UNLINK); #endif --- chromium-151.0.7922.71/sandbox/linux/services/credentials.cc.vanilla +++ chromium-151.0.7922.71/sandbox/linux/services/credentials.cc @@ -85,7 +85,7 @@ alignas(16) std::array stack_buf; #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ - defined(ARCH_CPU_MIPS_FAMILY) + defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY) // SAFETY: This is the `stack` argument of `clone(2)`. Because the stack grows // downward on these architectures, this is the topmost address of the memory // space for the stack, and the address will not be dereferenced. --- chromium-151.0.7922.71/sandbox/features.gni.vanilla +++ chromium-151.0.7922.71/sandbox/features.gni @@ -9,4 +9,5 @@ use_seccomp_bpf = (is_linux || is_chromeos || is_android) && (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm" || current_cpu == "arm64" || - current_cpu == "mipsel" || current_cpu == "mips64el") + current_cpu == "mipsel" || current_cpu == "mips64el" || + current_cpu == "riscv64") --- chromium-151.0.7922.71/sandbox/linux/system_headers/linux_signal.h.vanilla +++ chromium-151.0.7922.71/sandbox/linux/system_headers/linux_signal.h @@ -13,7 +13,8 @@ // (not undefined, but defined different values and in different memory // layouts). So, fill the gap here. #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__aarch64__) + defined(__aarch64__) || \ + (defined(__riscv) && (__riscv_xlen == 64)) #define LINUX_SIGHUP 1 #define LINUX_SIGINT 2 --- chromium-151.0.7922.71/sandbox/linux/system_headers/linux_stat.h.vanilla +++ chromium-151.0.7922.71/sandbox/linux/system_headers/linux_stat.h @@ -150,7 +150,7 @@ int st_blocks; int st_pad4[14]; }; -#elif defined(__aarch64__) +#elif defined(__aarch64__) || defined(ARCH_CPU_RISCV64) struct kernel_stat { unsigned long st_dev; unsigned long st_ino; --- chromium-151.0.7922.71/sandbox/policy/linux/bpf_print_compositor_policy_linux.cc.vanilla +++ chromium-151.0.7922.71/sandbox/policy/linux/bpf_print_compositor_policy_linux.cc @@ -33,7 +33,7 @@ case __NR_fdatasync: case __NR_fsync: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + defined(__aarch64__) || defined(ARCH_CPU_RISCV64) case __NR_getrlimit: #endif #if defined(__i386__) || defined(__arm__) --- chromium-151.0.7922.71/sandbox/policy/linux/bpf_cdm_policy_linux.cc.vanilla +++ chromium-151.0.7922.71/sandbox/policy/linux/bpf_cdm_policy_linux.cc @@ -33,7 +33,7 @@ case __NR_ftruncate: case __NR_fallocate: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + defined(__aarch64__) || defined(ARCH_CPU_RISCV64) case __NR_getrlimit: #endif #if defined(__i386__) || defined(__arm__) --- chromium-151.0.7922.71/sandbox/policy/linux/bpf_renderer_policy_linux.cc.vanilla +++ chromium-151.0.7922.71/sandbox/policy/linux/bpf_renderer_policy_linux.cc @@ -86,7 +86,7 @@ case __NR_ftruncate64: #endif #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + defined(__aarch64__) || defined(ARCH_CPU_RISCV64) case __NR_getrlimit: case __NR_setrlimit: // We allow setrlimit to dynamically adjust the address space limit as --- chromium-151.0.7922.71/sandbox/policy/linux/bpf_network_policy_linux.cc.vanilla +++ chromium-151.0.7922.71/sandbox/policy/linux/bpf_network_policy_linux.cc @@ -264,7 +264,7 @@ case __NR_fdatasync: case __NR_fsync: case __NR_mremap: -#if !defined(__aarch64__) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) case __NR_getdents: #endif case __NR_getdents64: --- chromium-151.0.7922.71/sandbox/policy/linux/bpf_utility_policy_linux.cc.vanilla +++ chromium-151.0.7922.71/sandbox/policy/linux/bpf_utility_policy_linux.cc @@ -34,7 +34,7 @@ case __NR_fdatasync: case __NR_fsync: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + defined(__aarch64__) || defined(ARCH_CPU_RISCV64) case __NR_getrlimit: #endif #if defined(__i386__) || defined(__arm__) --- chromium-151.0.7922.71/sandbox/policy/linux/bpf_service_policy_linux.cc.vanilla +++ chromium-151.0.7922.71/sandbox/policy/linux/bpf_service_policy_linux.cc @@ -26,7 +26,7 @@ return RestrictIoctl(); // Allow the system calls below. #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + defined(__aarch64__) || defined(ARCH_CPU_RISCV64) case __NR_getrlimit: #endif #if defined(__i386__) || defined(__arm__) --- chromium-151.0.7922.71/sandbox/policy/linux/bpf_gpu_policy_linux.cc.vanilla +++ chromium-151.0.7922.71/sandbox/policy/linux/bpf_gpu_policy_linux.cc @@ -74,7 +74,7 @@ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) case __NR_ftruncate64: #endif -#if !defined(__aarch64__) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) case __NR_getdents: #endif case __NR_getdents64: --- chromium-151.0.7922.71/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc.vanilla +++ chromium-151.0.7922.71/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc @@ -39,7 +39,7 @@ case __NR_sched_setscheduler: case __NR_sysinfo: case __NR_uname: -#if !defined(__aarch64__) +#if !defined(__aarch64__) && !defined(ARCH_CPU_RISCV64) case __NR_readlink: case __NR_stat: #endif --- chromium-151.0.7922.71/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc.vanilla +++ chromium-151.0.7922.71/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc @@ -44,11 +44,9 @@ #endif #if BUILDFLAG(IS_LINUX) && !defined(__arm__) && !defined(__aarch64__) && \ - !defined(PTRACE_GET_THREAD_AREA) + !defined(ARCH_CPU_RISCV64) && !defined(PTRACE_GET_THREAD_AREA) // Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance // the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA. -// asm/ptrace-abi.h doesn't exist on arm32 and PTRACE_GET_THREAD_AREA isn't -// defined on aarch64, so don't try to include this on those platforms. #include #endif @@ -484,7 +485,10 @@ return Switch(request) .Cases({ #if !defined(__aarch64__) - PTRACE_GETREGS, PTRACE_GETFPREGS, PTRACE_GET_THREAD_AREA, + PTRACE_GETREGS, PTRACE_GETFPREGS, +#if !defined(ARCH_CPU_RISCV64) + PTRACE_GET_THREAD_AREA, +#endif PTRACE_GETREGSET, #endif #if defined(__arm__) @@ -529,7 +535,7 @@ break; #endif #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__mips__) || defined(__aarch64__) + defined(__mips__) || defined(__aarch64__) || defined(ARCH_CPU_RISCV64) case __NR_sendto: // Could specify destination. argIndex = 3; break; --- chromium-151.0.7922.71/sandbox/linux/system_headers/linux_seccomp.h.vanilla +++ chromium-151.0.7922.71/sandbox/linux/system_headers/linux_seccomp.h @@ -39,6 +39,10 @@ #define EM_AARCH64 183 #endif +#ifndef EM_RISCV +#define EM_RISCV 243 +#endif + #ifndef __AUDIT_ARCH_64BIT #define __AUDIT_ARCH_64BIT 0x80000000 #endif @@ -71,6 +75,10 @@ #define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) #endif +#ifndef AUDIT_ARCH_RISCV64 +#define AUDIT_ARCH_RISCV64 (EM_RISCV | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) +#endif + // For prctl.h #ifndef PR_SET_SECCOMP #define PR_SET_SECCOMP 22 --- chromium-151.0.7922.71/sandbox/linux/bpf_dsl/seccomp_macros.h.vanilla +++ chromium-151.0.7922.71/sandbox/linux/bpf_dsl/seccomp_macros.h @@ -343,6 +343,78 @@ #define SECCOMP_PT_PARM4(_regs) (_regs).regs[3] #define SECCOMP_PT_PARM5(_regs) (_regs).regs[4] #define SECCOMP_PT_PARM6(_regs) (_regs).regs[5] + +#elif defined(ARCH_CPU_RISCV64) +struct regs_struct { + unsigned long pc; + unsigned long ra; + unsigned long sp; + unsigned long gp; + unsigned long tp; + unsigned long t0; + unsigned long t1; + unsigned long t2; + unsigned long s0; + unsigned long s1; + unsigned long a0; + unsigned long a1; + unsigned long a2; + unsigned long a3; + unsigned long a4; + unsigned long a5; + unsigned long a6; + unsigned long a7; + unsigned long s2; + unsigned long s3; + unsigned long s4; + unsigned long s5; + unsigned long s6; + unsigned long s7; + unsigned long s8; + unsigned long s9; + unsigned long s10; + unsigned long s11; + unsigned long t3; + unsigned long t4; + unsigned long t5; + unsigned long t6; +}; + +#define SECCOMP_ARCH AUDIT_ARCH_RISCV64 + +#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg]) + +#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, 10) +#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, 17) +#define SECCOMP_IP(_ctx) SECCOMP_REG(_ctx, 0) +#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, 10) +#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, 11) +#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, 12) +#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, 13) +#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, 14) +#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, 15) + +#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) +#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) +#define SECCOMP_IP_MSB_IDX \ + (offsetof(struct arch_seccomp_data, instruction_pointer) + 4) +#define SECCOMP_IP_LSB_IDX \ + (offsetof(struct arch_seccomp_data, instruction_pointer) + 0) +#define SECCOMP_ARG_MSB_IDX(nr) \ + (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4) +#define SECCOMP_ARG_LSB_IDX(nr) \ + (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0) + +#define SECCOMP_PT_RESULT(_regs) (_regs).a0 +#define SECCOMP_PT_SYSCALL(_regs) (_regs).a7 +#define SECCOMP_PT_IP(_regs) (_regs).pc +#define SECCOMP_PT_PARM1(_regs) (_regs).a0 +#define SECCOMP_PT_PARM2(_regs) (_regs).a1 +#define SECCOMP_PT_PARM3(_regs) (_regs).a2 +#define SECCOMP_PT_PARM4(_regs) (_regs).a3 +#define SECCOMP_PT_PARM5(_regs) (_regs).a4 +#define SECCOMP_PT_PARM6(_regs) (_regs).a5 + #else #error Unsupported target platform --- chromium-151.0.7922.71/sandbox/linux/seccomp-bpf/syscall.cc.vanilla +++ chromium-151.0.7922.71/sandbox/linux/seccomp-bpf/syscall.cc @@ -19,7 +19,7 @@ namespace { #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ - defined(ARCH_CPU_MIPS_FAMILY) + defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY) // Number that's not currently used by any Linux kernel ABIs. const int kInvalidSyscallNumber = 0x351d3; #else @@ -309,6 +309,26 @@ "2:ret\n" ".cfi_endproc\n" ".size SyscallAsm, .-SyscallAsm\n" +#elif defined(ARCH_CPU_RISCV64) + ".text\n" + ".align 2\n" + ".type SyscallAsm, @function\n" + "SyscallAsm:\n" + ".cfi_startproc\n" + "bge a0, zero, 1f\n" + "lla a0, 2f\n" + "j 2f\n" + "1:ld a5, 40(a6)\n" + "ld a4, 32(a6)\n" + "ld a3, 24(a6)\n" + "ld a2, 16(a6)\n" + "ld a1, 8(a6)\n" + "mv a7, a0\n" + "ld a0, 0(a6)\n" + "ecall\n" + "2:ret\n" + ".cfi_endproc\n" + ".size SyscallAsm, .-SyscallAsm\n" #endif ); // asm @@ -426,6 +457,18 @@ ret = inout; } +#elif defined(ARCH_CPU_RISCV64) + intptr_t ret; + { + register intptr_t inout __asm__("a0") = nr; + register const intptr_t* data __asm__("a6") = args; + asm volatile("jal ra, SyscallAsm\n" + : "=r"(inout) + : "0"(inout), "r"(data) + : "memory", "a1", "a2", "a3", "a4", "a5", "a7", "ra"); + ret = inout; + } + #else #error "Unimplemented architecture" #endif --- chromium-151.0.7922.71/sandbox/linux/bpf_dsl/linux_syscall_ranges.h.vanilla +++ chromium-151.0.7922.71/sandbox/linux/bpf_dsl/linux_syscall_ranges.h @@ -49,8 +49,8 @@ #define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + __NR_64_Linux_syscalls) #define MAX_SYSCALL MAX_PUBLIC_SYSCALL -#elif defined(__aarch64__) +#elif defined(__aarch64__) || defined(ARCH_CPU_RISCV64) #include #define MIN_SYSCALL 0u #define MAX_PUBLIC_SYSCALL __NR_syscalls --- chromium-151.0.7922.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc.vanilla +++ chromium-151.0.7922.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc @@ -103,7 +103,7 @@ // Both EPERM and ENOENT are valid errno unless otherwise noted in comment. bool SyscallSets::IsFileSystem(int sysno) { switch (sysno) { -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_access: // EPERM not a valid errno. case __NR_chmod: case __NR_chown: @@ -129,14 +129,14 @@ #endif case __NR_ustat: // Same as above. Deprecated. case __NR_utimes: -#endif // !defined(__aarch64__) +#endif // !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_execve: case __NR_faccessat: // EPERM not a valid errno. case __NR_faccessat2: case __NR_fchmodat: case __NR_fchownat: // Should be called chownat ? -#if defined(__x86_64__) || defined(__aarch64__) +#if defined(__x86_64__) || (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_newfstatat: // fstatat(). EPERM not a valid errno. #elif defined(__i386__) || defined(__arm__) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) @@ -161,7 +161,9 @@ #endif case __NR_openat: case __NR_readlinkat: +#if !defined(ARCH_CPU_RISCV64) case __NR_renameat: +#endif case __NR_renameat2: #if defined(__i386__) || defined(__arm__) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) @@ -241,7 +246,7 @@ case __NR_oldfstat: #endif #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_sync_file_range: // EPERM not a valid errno. #elif defined(__arm__) case __NR_arm_sync_file_range: // EPERM not a valid errno. @@ -260,7 +265,7 @@ #if defined(__i386__) || defined(__arm__) case __NR_fchown32: #endif -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_getdents: // EPERM not a valid errno. #endif case __NR_getdents64: // EPERM not a valid errno. @@ -339,7 +344,7 @@ bool SyscallSets::IsProcessGroupOrSession(int sysno) { switch (sysno) { case __NR_setpgid: -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_getpgrp: #endif case __NR_setsid: @@ -373,7 +378,7 @@ case __NR_rt_sigqueueinfo: case __NR_rt_sigsuspend: case __NR_rt_tgsigqueueinfo: -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_signalfd: #endif case __NR_signalfd4: @@ -397,12 +402,12 @@ switch (sysno) { case __NR_close: case __NR_dup: -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_dup2: #endif case __NR_dup3: #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ - defined(__aarch64__) + (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_shutdown: #endif return true; @@ -441,7 +446,7 @@ return true; case __NR_clone: // Should be parameter-restricted. case __NR_setns: // Privileged. -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_fork: #endif #if defined(__i386__) || defined(__x86_64__) @@ -452,7 +457,7 @@ #endif case __NR_set_tid_address: case __NR_unshare: -#if !defined(__mips__) && !defined(__aarch64__) +#if !defined(__mips__) && !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_vfork: #endif default: @@ -477,7 +482,7 @@ bool SyscallSets::IsAllowedEpoll(int sysno) { switch (sysno) { -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_epoll_create: case __NR_epoll_wait: #endif @@ -499,7 +504,7 @@ bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { switch (sysno) { #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ - defined(__aarch64__) + (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_accept: case __NR_accept4: case __NR_bind: @@ -554,7 +559,7 @@ case __NR_mincore: case __NR_mlockall: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_mmap: #endif #if defined(__i386__) || defined(__arm__) || \ @@ -587,7 +592,7 @@ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) case __NR__llseek: #endif -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_poll: #endif case __NR_ppoll: @@ -608,7 +613,7 @@ case __NR_recv: #endif #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ - defined(__aarch64__) + (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_recvfrom: // Could specify source. case __NR_recvmsg: // Could specify source. #endif @@ -642,7 +647,7 @@ case __NR_send: #endif #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__mips__) || defined(__aarch64__) + defined(__mips__) || (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_sendmsg: // Could specify destination. case __NR_sendto: // Could specify destination. #endif @@ -659,7 +664,7 @@ case __NR_send: #endif #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__mips__) || defined(__aarch64__) + defined(__mips__) || (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_sendmsg: // Could specify destination. case __NR_sendto: // Could specify destination. #endif @@ -693,7 +698,7 @@ bool SyscallSets::IsAllowedBasicScheduler(int sysno) { switch (sysno) { case __NR_sched_yield: -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_pause: #endif case __NR_nanosleep: @@ -777,7 +782,7 @@ case __NR_getcpu: case __NR_mbind: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_migrate_pages: #endif case __NR_move_pages: @@ -812,7 +817,7 @@ switch (sysno) { case __NR_acct: // Privileged. #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ - defined(__aarch64__) + (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_getrlimit: #endif #if defined(__i386__) || defined(__arm__) @@ -847,7 +852,7 @@ bool SyscallSets::IsGlobalSystemStatus(int sysno) { switch (sysno) { -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR__sysctl: case __NR_sysfs: #endif @@ -865,7 +870,7 @@ bool SyscallSets::IsEventFd(int sysno) { switch (sysno) { -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_eventfd: #endif case __NR_eventfd2: @@ -916,7 +921,7 @@ } } -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +#if defined(__x86_64__) || defined(__arm__) || (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) bool SyscallSets::IsSystemVSemaphores(int sysno) { switch (sysno) { @@ -936,7 +941,7 @@ #endif #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__aarch64__) || \ + (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) // These give a lot of ambient authority and bypass the setuid sandbox. bool SyscallSets::IsSystemVSharedMemory(int sysno) { @@ -952,7 +957,7 @@ } #endif -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +#if defined(__x86_64__) || defined(__arm__) || (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) bool SyscallSets::IsSystemVMessageQueue(int sysno) { switch (sysno) { @@ -983,7 +988,7 @@ #endif bool SyscallSets::IsAnySystemV(int sysno) { -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +#if defined(__x86_64__) || defined(__arm__) || (defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || IsSystemVSharedMemory(sysno); @@ -1021,7 +1026,7 @@ bool SyscallSets::IsInotify(int sysno) { switch (sysno) { case __NR_inotify_add_watch: -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_inotify_init: #endif case __NR_inotify_init1: @@ -1156,7 +1161,7 @@ #if defined(__x86_64__) case __NR_tuxcall: #endif -#if !defined(__aarch64__) +#if !(defined(__aarch64__) || defined(ARCH_CPU_RISCV64)) case __NR_vserver: #endif return true; --- chromium-151.0.7922.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h.vanilla +++ chromium-151.0.7922.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h @@ -80,17 +80,19 @@ static bool IsAsyncIo(int sysno); static bool IsKeyManagement(int sysno); #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ + defined(ARCH_CPU_RISCV64) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) static bool IsSystemVSemaphores(int sysno); #endif #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__aarch64__) || \ + defined(__aarch64__) || defined(ARCH_CPU_RISCV64) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) // These give a lot of ambient authority and bypass the setuid sandbox. static bool IsSystemVSharedMemory(int sysno); #endif #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ + defined(ARCH_CPU_RISCV64) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) static bool IsSystemVMessageQueue(int sysno); #endif --- chromium-151.0.7922.71/third_party/swiftshader/src/Reactor/BUILD.gn.vanilla +++ chromium-151.0.7922.71/third_party/swiftshader/src/Reactor/BUILD.gn @@ -308,7 +308,11 @@ if (supports_llvm) { swiftshader_source_set("swiftshader_llvm_reactor") { - llvm_dir = "../../third_party/llvm-10.0" + if (current_cpu == "riscv64" || current_cpu == "loong64") { + llvm_dir = "../../third_party/llvm-16.0" + } else { + llvm_dir = "../../third_party/llvm-10.0" + } deps = [ ":swiftshader_reactor_base", --- chromium-151.0.7922.71/third_party/webrtc/rtc_base/platform_thread_types.cc.vanilla +++ chromium-151.0.7922.71/third_party/webrtc/rtc_base/platform_thread_types.cc @@ -16,7 +16,7 @@ #include #include -#if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) +#if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && !defined(__riscv) #include #endif #endif