From 5dd25a8ac46fc5075364814ef8d18059f6c2b1a4 Mon Sep 17 00:00:00 2001 From: misaka00251 Date: Tue, 12 Aug 2025 10:33:01 +0800 Subject: [PATCH] Fix build on riscv64 (cherry picked from commit dad73a1a2b6f12a1e9be7292438f49c0ce91be39) --- qt6-qtwebengine.spec | 10 +- riscv-dav1d.patch | 43 ----- riscv-sandbox.patch | 428 ++++++++++++++++++++++++++++++------------- 3 files changed, 303 insertions(+), 178 deletions(-) delete mode 100644 riscv-dav1d.patch diff --git a/qt6-qtwebengine.spec b/qt6-qtwebengine.spec index e2e68a3..e94ee98 100644 --- a/qt6-qtwebengine.spec +++ b/qt6-qtwebengine.spec @@ -38,7 +38,7 @@ Summary: Qt6 - QtWebEngine components Name: qt6-qtwebengine Version: 6.9.1 -Release: 1 +Release: 2 # See LICENSE.GPL LICENSE.LGPL LGPL_EXCEPTION.txt, for details # See also http://qt-project.org/doc/qt-5.0/qtdoc/licensing.html @@ -83,8 +83,7 @@ Patch110: qtwebengine-rtc-dont-use-h264.patch ExclusiveArch: aarch64 x86_64 riscv64 ## Add riscv64 patches -Patch1003: riscv-dav1d.patch -Patch1004: riscv-sandbox.patch +Patch1000: riscv-sandbox.patch BuildRequires: cmake BuildRequires: make @@ -437,7 +436,9 @@ export LDFLAGS="%{build_ldflags} -Wl,--no-keep-memory" -DFEATURE_webengine_system_gbm:BOOL=ON \ -DFEATURE_webengine_v8_context_snapshot:BOOL=ON \ -DFEATURE_webenginedriver:BOOL=ON \ +%ifarch riscv64 -DFEATURE_pdf_v8:BOOL=ON \ +%endif -DQT_BUILD_EXAMPLES:BOOL=%{?examples:ON}%{!?examples:OFF} \ -DQT_INSTALL_EXAMPLES_SOURCES=%{?examples:ON}%{!?examples:OFF} @@ -666,6 +667,9 @@ done %changelog +* Tue Aug 12 2025 misaka00251 - 6.9.1-2 +- Fix build on riscv64 + * Tue Jun 03 2025 Funda Wang - 6.9.1-1 - update to version 6.9.1 diff --git a/riscv-dav1d.patch b/riscv-dav1d.patch deleted file mode 100644 index 6090396..0000000 --- a/riscv-dav1d.patch +++ /dev/null @@ -1,43 +0,0 @@ -Index: chromium/third_party/dav1d/config/linux/riscv64/config.h -=================================================================== ---- /dev/null -+++ chromium/third_party/dav1d/config/linux/riscv64/config.h -@@ -0,0 +1,38 @@ -+/* -+ * Autogenerated by the Meson build system. -+ * Do not edit, your changes will be lost. -+ */ -+ -+#pragma once -+ -+#define ARCH_AARCH64 0 -+ -+#define ARCH_ARM 0 -+ -+#define ARCH_PPC64LE 0 -+ -+#define ARCH_X86 0 -+ -+#define ARCH_X86_32 0 -+ -+#define ARCH_X86_64 0 -+ -+#define CONFIG_16BPC 1 -+ -+#define CONFIG_8BPC 1 -+ -+// #define CONFIG_LOG 1 -- Logging is controlled by Chromium -+ -+#define ENDIANNESS_BIG 0 -+ -+#define HAVE_ASM 0 -+ -+#define HAVE_AS_FUNC 0 -+ -+#define HAVE_CLOCK_GETTIME 1 -+ -+#define HAVE_GETAUXVAL 1 -+ -+#define HAVE_POSIX_MEMALIGN 1 -+ -+#define HAVE_UNISTD_H 1 diff --git a/riscv-sandbox.patch b/riscv-sandbox.patch index 5211d97..5bc5603 100644 --- a/riscv-sandbox.patch +++ b/riscv-sandbox.patch @@ -1,5 +1,5 @@ -diff --git chromium/sandbox/features.gni chromium/sandbox/features.gni -index 8434144..8aa5298 100644 +Index: chromium/sandbox/features.gni +=================================================================== --- chromium/sandbox/features.gni +++ chromium/sandbox/features.gni @@ -9,7 +9,8 @@ @@ -12,8 +12,8 @@ index 8434144..8aa5298 100644 # SSBD (Speculative Store Bypass Disable) is a mitigation of Spectre Variant 4. # As Spectre Variant 4 can be mitigated by site isolation, opt-out SSBD on site -diff --git chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h -index 1d0590b..3bf3cb2 100644 +Index: chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h +=================================================================== --- chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h +++ chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h @@ -56,6 +56,12 @@ @@ -29,11 +29,11 @@ index 1d0590b..3bf3cb2 100644 #else #error "Unsupported architecture" #endif -diff --git chromium/sandbox/linux/bpf_dsl/seccomp_macros.h chromium/sandbox/linux/bpf_dsl/seccomp_macros.h -index 87d5825..cc9b89b 100644 +Index: chromium/sandbox/linux/bpf_dsl/seccomp_macros.h +=================================================================== --- chromium/sandbox/linux/bpf_dsl/seccomp_macros.h +++ chromium/sandbox/linux/bpf_dsl/seccomp_macros.h -@@ -343,6 +343,46 @@ struct regs_struct { +@@ -343,6 +343,48 @@ struct regs_struct { #define SECCOMP_PT_PARM4(_regs) (_regs).regs[3] #define SECCOMP_PT_PARM5(_regs) (_regs).regs[4] #define SECCOMP_PT_PARM6(_regs) (_regs).regs[5] @@ -56,6 +56,7 @@ index 87d5825..cc9b89b 100644 +#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, REG_A0+3) +#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, REG_A0+4) +#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, REG_A0+5) ++#define SECCOMP_PARM7(_ctx) SECCOMP_REG(_ctx, REG_A0+6) + +#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) +#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) @@ -77,24 +78,25 @@ index 87d5825..cc9b89b 100644 +#define SECCOMP_PT_PARM4(_regs) (_regs).regs[REG_A0+3] +#define SECCOMP_PT_PARM5(_regs) (_regs).regs[REG_A0+4] +#define SECCOMP_PT_PARM6(_regs) (_regs).regs[REG_A0+5] ++#define SECCOMP_PT_PARM7(_regs) (_regs).regs[REG_A0+6] #else #error Unsupported target platform -diff --git chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc -index 7bde501..0c26728 100644 +Index: chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc +=================================================================== --- chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc +++ chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc -@@ -59,6 +59,9 @@ bool IsBaselinePolicyAllowed(int sysno) { - #endif +@@ -60,6 +60,9 @@ bool IsBaselinePolicyAllowed(int sysno) #if defined(__mips__) SyscallSets::IsMipsPrivate(sysno) || -+#endif + #endif +#if defined(__riscv) + SyscallSets::IsRiscvPrivate(sysno) || - #endif ++#endif SyscallSets::IsAllowedOperationOnFd(sysno); // clang-format on -@@ -193,7 +196,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, + } +@@ -193,7 +196,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de return RestrictFcntlCommands(); #endif @@ -103,7 +105,7 @@ index 7bde501..0c26728 100644 // fork() is never used as a system call (clone() is used instead), but we // have seen it in fallback code on Android. if (sysno == __NR_fork) { -@@ -255,7 +258,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, +@@ -255,7 +258,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de } #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ @@ -112,7 +114,7 @@ index 7bde501..0c26728 100644 if (sysno == __NR_mmap) return RestrictMmapFlags(); #endif -@@ -276,7 +279,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, +@@ -276,7 +279,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de return RestrictPrctl(); #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ @@ -121,11 +123,20 @@ index 7bde501..0c26728 100644 if (sysno == __NR_socketpair) { // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. static_assert(AF_UNIX == PF_UNIX, -diff --git chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc -index 74112e8..d7c23bf 100644 +@@ -366,7 +369,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de + // Allow creating pipes, but don't allow weird flags to pipe2(). + // O_NOTIFICATION_PIPE (== O_EXCL) can be used to create + // "notification pipes", which are rarely used. +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + if (sysno == __NR_pipe) { + return Allow(); + } +Index: chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc +=================================================================== --- chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc +++ chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc -@@ -37,6 +37,7 @@ +@@ -41,6 +41,7 @@ #if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ !defined(__arm__) && !defined(__aarch64__) && \ @@ -133,17 +144,20 @@ index 74112e8..d7c23bf 100644 !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. -@@ -463,7 +464,7 @@ ResultExpr RestrictPtrace() { +@@ -467,8 +468,10 @@ ResultExpr RestrictPtrace() { #endif return Switch(request) .Cases({ -#if !defined(__aarch64__) +#if !defined(__aarch64__) && !defined(__riscv) PTRACE_GETREGS, PTRACE_GETFPREGS, PTRACE_GET_THREAD_AREA, ++#endif ++#if !defined(__aarch64__) PTRACE_GETREGSET, #endif -diff --git chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc -index 4cde283..aa55880 100644 + #if defined(__arm__) +Index: chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc +=================================================================== --- chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc +++ chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc @@ -103,7 +103,7 @@ bool SyscallSets::IsUmask(int sysno) { @@ -155,7 +169,7 @@ index 4cde283..aa55880 100644 case __NR_access: // EPERM not a valid errno. case __NR_chmod: case __NR_chown: -@@ -136,7 +136,7 @@ bool SyscallSets::IsFileSystem(int sysno) { +@@ -136,7 +136,7 @@ bool SyscallSets::IsFileSystem(int sysno case __NR_faccessat2: case __NR_fchmodat: case __NR_fchownat: // Should be called chownat ? @@ -164,7 +178,7 @@ index 4cde283..aa55880 100644 case __NR_newfstatat: // fstatat(). EPERM not a valid errno. #elif defined(__i386__) || defined(__arm__) || \ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) -@@ -241,7 +241,7 @@ bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { +@@ -241,7 +241,7 @@ bool SyscallSets::IsAllowedFileSystemAcc case __NR_oldfstat: #endif #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ @@ -173,7 +187,7 @@ index 4cde283..aa55880 100644 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 +260,7 @@ bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) { +@@ -260,7 +260,7 @@ bool SyscallSets::IsDeniedFileSystemAcce #if defined(__i386__) || defined(__arm__) case __NR_fchown32: #endif @@ -182,7 +196,7 @@ index 4cde283..aa55880 100644 case __NR_getdents: // EPERM not a valid errno. #endif case __NR_getdents64: // EPERM not a valid errno. -@@ -339,7 +339,7 @@ bool SyscallSets::IsProcessPrivilegeChange(int sysno) { +@@ -339,7 +339,7 @@ bool SyscallSets::IsProcessPrivilegeChan bool SyscallSets::IsProcessGroupOrSession(int sysno) { switch (sysno) { case __NR_setpgid: @@ -191,7 +205,7 @@ index 4cde283..aa55880 100644 case __NR_getpgrp: #endif case __NR_setsid: -@@ -373,7 +373,7 @@ bool SyscallSets::IsAllowedSignalHandling(int sysno) { +@@ -373,7 +373,7 @@ bool SyscallSets::IsAllowedSignalHandlin case __NR_rt_sigqueueinfo: case __NR_rt_sigsuspend: case __NR_rt_tgsigqueueinfo: @@ -200,7 +214,7 @@ index 4cde283..aa55880 100644 case __NR_signalfd: #endif case __NR_signalfd4: -@@ -397,12 +397,12 @@ bool SyscallSets::IsAllowedOperationOnFd(int sysno) { +@@ -397,12 +397,12 @@ bool SyscallSets::IsAllowedOperationOnFd switch (sysno) { case __NR_close: case __NR_dup: @@ -215,7 +229,7 @@ index 4cde283..aa55880 100644 case __NR_shutdown: #endif return true; -@@ -441,7 +441,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) { +@@ -441,7 +441,7 @@ bool SyscallSets::IsAllowedProcessStartO return true; case __NR_clone: // Should be parameter-restricted. case __NR_setns: // Privileged. @@ -224,7 +238,7 @@ index 4cde283..aa55880 100644 case __NR_fork: #endif #if defined(__i386__) || defined(__x86_64__) -@@ -452,7 +452,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) { +@@ -452,7 +452,7 @@ bool SyscallSets::IsAllowedProcessStartO #endif case __NR_set_tid_address: case __NR_unshare: @@ -233,7 +247,7 @@ index 4cde283..aa55880 100644 case __NR_vfork: #endif default: -@@ -477,7 +477,7 @@ bool SyscallSets::IsAllowedFutex(int sysno) { +@@ -477,7 +477,7 @@ bool SyscallSets::IsAllowedFutex(int sys bool SyscallSets::IsAllowedEpoll(int sysno) { switch (sysno) { @@ -242,7 +256,7 @@ index 4cde283..aa55880 100644 case __NR_epoll_create: case __NR_epoll_wait: #endif -@@ -499,7 +499,7 @@ bool SyscallSets::IsAllowedEpoll(int sysno) { +@@ -499,7 +499,7 @@ bool SyscallSets::IsAllowedEpoll(int sys bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { switch (sysno) { #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ @@ -251,7 +265,7 @@ index 4cde283..aa55880 100644 case __NR_accept: case __NR_accept4: case __NR_bind: -@@ -553,7 +553,7 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) { +@@ -554,7 +554,7 @@ bool SyscallSets::IsAllowedAddressSpaceA case __NR_mincore: case __NR_mlockall: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ @@ -260,7 +274,7 @@ index 4cde283..aa55880 100644 case __NR_mmap: #endif #if defined(__i386__) || defined(__arm__) || \ -@@ -586,7 +586,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { +@@ -587,7 +587,7 @@ bool SyscallSets::IsAllowedGeneralIo(int (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) case __NR__llseek: #endif @@ -269,7 +283,7 @@ index 4cde283..aa55880 100644 case __NR_poll: #endif case __NR_ppoll: -@@ -607,7 +607,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { +@@ -608,7 +608,7 @@ bool SyscallSets::IsAllowedGeneralIo(int case __NR_recv: #endif #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ @@ -278,7 +292,7 @@ index 4cde283..aa55880 100644 case __NR_recvfrom: // Could specify source. case __NR_recvmsg: // Could specify source. #endif -@@ -622,7 +622,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { +@@ -623,7 +623,7 @@ bool SyscallSets::IsAllowedGeneralIo(int case __NR_send: #endif #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ @@ -287,7 +301,7 @@ index 4cde283..aa55880 100644 case __NR_sendmsg: // Could specify destination. case __NR_sendto: // Could specify destination. #endif -@@ -671,7 +671,7 @@ bool SyscallSets::IsSeccomp(int sysno) { +@@ -672,7 +672,7 @@ bool SyscallSets::IsSeccomp(int sysno) { bool SyscallSets::IsAllowedBasicScheduler(int sysno) { switch (sysno) { case __NR_sched_yield: @@ -296,7 +310,7 @@ index 4cde283..aa55880 100644 case __NR_pause: #endif case __NR_nanosleep: -@@ -755,7 +755,7 @@ bool SyscallSets::IsNuma(int sysno) { +@@ -756,7 +756,7 @@ bool SyscallSets::IsNuma(int sysno) { case __NR_getcpu: case __NR_mbind: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ @@ -305,7 +319,7 @@ index 4cde283..aa55880 100644 case __NR_migrate_pages: #endif case __NR_move_pages: -@@ -790,7 +790,7 @@ bool SyscallSets::IsGlobalProcessEnvironment(int sysno) { +@@ -791,7 +791,7 @@ bool SyscallSets::IsGlobalProcessEnviron switch (sysno) { case __NR_acct: // Privileged. #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ @@ -314,7 +328,7 @@ index 4cde283..aa55880 100644 case __NR_getrlimit: #endif #if defined(__i386__) || defined(__arm__) -@@ -825,7 +825,7 @@ bool SyscallSets::IsDebug(int sysno) { +@@ -826,7 +826,7 @@ bool SyscallSets::IsDebug(int sysno) { bool SyscallSets::IsGlobalSystemStatus(int sysno) { switch (sysno) { @@ -323,7 +337,7 @@ index 4cde283..aa55880 100644 case __NR__sysctl: case __NR_sysfs: #endif -@@ -843,7 +843,7 @@ bool SyscallSets::IsGlobalSystemStatus(int sysno) { +@@ -844,7 +844,7 @@ bool SyscallSets::IsGlobalSystemStatus(i bool SyscallSets::IsEventFd(int sysno) { switch (sysno) { @@ -332,47 +346,40 @@ index 4cde283..aa55880 100644 case __NR_eventfd: #endif case __NR_eventfd2: -@@ -895,7 +895,8 @@ bool SyscallSets::IsKeyManagement(int sysno) { +@@ -896,6 +896,7 @@ bool SyscallSets::IsKeyManagement(int sy } #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) ++ defined(__riscv) || \ + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) bool SyscallSets::IsSystemVSemaphores(int sysno) { switch (sysno) { - case __NR_semctl: -@@ -915,7 +916,8 @@ bool SyscallSets::IsSystemVSemaphores(int sysno) { +@@ -915,7 +916,7 @@ bool SyscallSets::IsSystemVSemaphores(in + #endif #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) +- defined(__aarch64__) || \ ++ defined(__aarch64__) || defined(__riscv) || \ + (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) { - switch (sysno) { -@@ -931,7 +933,8 @@ bool SyscallSets::IsSystemVSharedMemory(int sysno) { +@@ -932,6 +933,7 @@ bool SyscallSets::IsSystemVSharedMemory( #endif #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) ++ defined(__riscv) || \ + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) bool SyscallSets::IsSystemVMessageQueue(int sysno) { switch (sysno) { - case __NR_msgctl: -@@ -962,7 +965,8 @@ bool SyscallSets::IsSystemVIpc(int sysno) { +@@ -963,6 +965,7 @@ bool SyscallSets::IsSystemVIpc(int sysno bool SyscallSets::IsAnySystemV(int sysno) { #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) ++ defined(__riscv) || \ + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || IsSystemVSharedMemory(sysno); - #elif defined(__i386__) || \ -@@ -999,7 +1003,7 @@ bool SyscallSets::IsAdvancedScheduler(int sysno) { +@@ -1000,7 +1003,7 @@ bool SyscallSets::IsAdvancedScheduler(in bool SyscallSets::IsInotify(int sysno) { switch (sysno) { case __NR_inotify_add_watch: @@ -381,7 +388,7 @@ index 4cde283..aa55880 100644 case __NR_inotify_init: #endif case __NR_inotify_init1: -@@ -1134,7 +1138,7 @@ bool SyscallSets::IsMisc(int sysno) { +@@ -1135,7 +1138,7 @@ bool SyscallSets::IsMisc(int sysno) { #if defined(__x86_64__) case __NR_tuxcall: #endif @@ -390,13 +397,14 @@ index 4cde283..aa55880 100644 case __NR_vserver: #endif return true; -@@ -1169,6 +1173,17 @@ bool SyscallSets::IsArmPrivate(int sysno) { +@@ -1194,6 +1197,18 @@ bool SyscallSets::IsMipsMisc(int sysno) } - #endif // defined(__arm__) + #endif // defined(__mips__) +#if defined(__riscv) +bool SyscallSets::IsRiscvPrivate(int sysno) { + switch (sysno) { ++ case __NR_riscv_hwprobe: + case __NR_riscv_flush_icache: + return true; + default: @@ -405,11 +413,11 @@ index 4cde283..aa55880 100644 +} +#endif // defined(__riscv) + - #if defined(__mips__) - bool SyscallSets::IsMipsPrivate(int sysno) { + bool SyscallSets::IsGoogle3Threading(int sysno) { switch (sysno) { -diff --git chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h -index 9be7b03..41b3605 100644 + case __NR_getitimer: +Index: chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h +=================================================================== --- chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h +++ chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h @@ -52,7 +52,7 @@ class SANDBOX_EXPORT SyscallSets { @@ -456,11 +464,11 @@ index 9be7b03..41b3605 100644 static bool IsGoogle3Threading(int sysno); }; -diff --git chromium/sandbox/linux/seccomp-bpf/syscall.cc chromium/sandbox/linux/seccomp-bpf/syscall.cc -index 02cbb04..61453ec 100644 +Index: chromium/sandbox/linux/seccomp-bpf/syscall.cc +=================================================================== --- chromium/sandbox/linux/seccomp-bpf/syscall.cc +++ chromium/sandbox/linux/seccomp-bpf/syscall.cc -@@ -18,7 +18,7 @@ namespace sandbox { +@@ -23,7 +23,7 @@ namespace sandbox { namespace { #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ @@ -469,7 +477,7 @@ index 02cbb04..61453ec 100644 // Number that's not currently used by any Linux kernel ABIs. const int kInvalidSyscallNumber = 0x351d3; #else -@@ -308,6 +308,28 @@ asm(// We need to be able to tell the kernel exactly where we made a +@@ -313,6 +313,28 @@ asm(// We need to be able to tell the ke "2:ret\n" ".cfi_endproc\n" ".size SyscallAsm, .-SyscallAsm\n" @@ -480,16 +488,16 @@ index 02cbb04..61453ec 100644 + "SyscallAsm:\n" + ".cfi_startproc\n" + "bgez a0,1f\n" -+ "la a0,2f\n" ++ "lla a0,2f\n" + "j 2f\n" + "1:mv a7, a0\n" -+ "ld a0, (t0)\n" -+ "ld a1, 8(t0)\n" -+ "ld a2, 16(t0)\n" -+ "ld a3, 24(t0)\n" -+ "ld a4, 32(t0)\n" -+ "ld a5, 40(t0)\n" -+ "ld a6, 48(t0)\n" ++ "ld a0, (a1)\n" ++ "ld a2, 16(a1)\n" ++ "ld a3, 24(a1)\n" ++ "ld a4, 32(a1)\n" ++ "ld a5, 40(a1)\n" ++ "ld a6, 48(a1)\n" ++ "ld a1, 8(a1)\n" + // Enter the kernel + "scall\n" + "2:ret\n" @@ -498,30 +506,42 @@ index 02cbb04..61453ec 100644 #endif ); // asm -@@ -425,6 +447,18 @@ intptr_t Syscall::Call(int nr, +@@ -324,6 +346,10 @@ intptr_t SyscallAsm(intptr_t nr, const i + extern "C" { + intptr_t SyscallAsm(intptr_t nr, const intptr_t args[8]); + } ++#elif defined(__riscv) ++extern "C" { ++intptr_t SyscallAsm(intptr_t nr, const intptr_t args[7]); ++} + #endif + + } // namespace +@@ -356,6 +382,10 @@ intptr_t Syscall::Call(int nr, + // where that makes sense. + #if defined(__mips__) + const intptr_t args[8] = {p0, p1, p2, p3, p4, p5, p6, p7}; ++#elif defined(__riscv) ++ DCHECK_EQ(p7, 0) << " Support for syscalls with more than seven arguments " ++ "not added for this architecture"; ++ const intptr_t args[7] = {p0, p1, p2, p3, p4, p5, p6}; + #else + DCHECK_EQ(p6, 0) << " Support for syscalls with more than six arguments not " + "added for this architecture"; +@@ -430,6 +460,8 @@ intptr_t Syscall::Call(int nr, ret = inout; } +#elif defined(__riscv) -+ intptr_t ret; -+ { -+ register intptr_t inout __asm__("a0") = nr; -+ register const intptr_t* data __asm__("t0") = args; -+ asm volatile("jal SyscallAsm\n" -+ : "+r"(inout) -+ : "r"(data) -+ : "memory", "a1", "a2", "a3", "a4", "a5", "a6"); -+ ret = inout; -+ } -+ ++ intptr_t ret = SyscallAsm(nr, args); #else #error "Unimplemented architecture" #endif -diff --git chromium/sandbox/linux/services/credentials.cc chromium/sandbox/linux/services/credentials.cc -index a33597c..d4180ac 100644 +Index: chromium/sandbox/linux/services/credentials.cc +=================================================================== --- chromium/sandbox/linux/services/credentials.cc +++ chromium/sandbox/linux/services/credentials.cc -@@ -80,7 +80,7 @@ bool ChrootToSafeEmptyDir() { +@@ -87,7 +87,7 @@ bool ChrootToSafeEmptyDir() { alignas(16) char stack_buf[PTHREAD_STACK_MIN_CONST]; #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ @@ -530,8 +550,8 @@ index a33597c..d4180ac 100644 // The stack grows downward. void* stack = stack_buf + sizeof(stack_buf); #else -diff --git chromium/sandbox/linux/services/syscall_wrappers.cc chromium/sandbox/linux/services/syscall_wrappers.cc -index 7650e98..bb4bd33 100644 +Index: chromium/sandbox/linux/services/syscall_wrappers.cc +=================================================================== --- chromium/sandbox/linux/services/syscall_wrappers.cc +++ chromium/sandbox/linux/services/syscall_wrappers.cc @@ -61,7 +61,7 @@ long sys_clone(unsigned long flags, @@ -543,11 +563,11 @@ index 7650e98..bb4bd33 100644 // CONFIG_CLONE_BACKWARDS defined. return syscall(__NR_clone, flags, child_stack, ptid, tls, ctid); #endif -diff --git chromium/sandbox/linux/syscall_broker/broker_process.cc chromium/sandbox/linux/syscall_broker/broker_process.cc -index c6c1117..779065a 100644 +Index: chromium/sandbox/linux/syscall_broker/broker_process.cc +=================================================================== --- chromium/sandbox/linux/syscall_broker/broker_process.cc +++ chromium/sandbox/linux/syscall_broker/broker_process.cc -@@ -122,44 +122,46 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const { +@@ -122,44 +122,46 @@ bool BrokerProcess::IsSyscallBrokerable( // and are default disabled in Android. So, we should refuse to broker them // to be consistent with the platform's restrictions. switch (sysno) { @@ -601,7 +621,7 @@ index c6c1117..779065a 100644 case __NR_stat: case __NR_lstat: #endif -@@ -169,7 +171,7 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const { +@@ -169,7 +171,7 @@ bool BrokerProcess::IsSyscallBrokerable( #if defined(__NR_fstatat64) case __NR_fstatat64: #endif @@ -610,7 +630,7 @@ index c6c1117..779065a 100644 case __NR_newfstatat: #endif return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT); -@@ -184,7 +186,7 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const { +@@ -184,7 +186,7 @@ bool BrokerProcess::IsSyscallBrokerable( return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT); #endif @@ -619,32 +639,34 @@ index c6c1117..779065a 100644 case __NR_unlink: return !fast_check || policy_->allowed_command_set.test(COMMAND_UNLINK); #endif -diff --git chromium/sandbox/linux/system_headers/linux_seccomp.h chromium/sandbox/linux/system_headers/linux_seccomp.h -index 8690a96..5e34038 100644 +Index: chromium/sandbox/linux/system_headers/linux_seccomp.h +=================================================================== --- chromium/sandbox/linux/system_headers/linux_seccomp.h +++ chromium/sandbox/linux/system_headers/linux_seccomp.h -@@ -38,6 +38,9 @@ - #ifndef EM_AARCH64 +@@ -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 -@@ -70,6 +73,9 @@ - #ifndef AUDIT_ARCH_AARCH64 + #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 -diff --git chromium/sandbox/linux/system_headers/linux_signal.h chromium/sandbox/linux/system_headers/linux_signal.h -index 69ccaf1..2ffe309 100644 + #define PR_SET_SECCOMP 22 +Index: chromium/sandbox/linux/system_headers/linux_signal.h +=================================================================== --- chromium/sandbox/linux/system_headers/linux_signal.h +++ chromium/sandbox/linux/system_headers/linux_signal.h @@ -13,7 +13,7 @@ @@ -656,8 +678,8 @@ index 69ccaf1..2ffe309 100644 #define LINUX_SIGHUP 1 #define LINUX_SIGINT 2 -diff --git chromium/sandbox/linux/system_headers/linux_stat.h chromium/sandbox/linux/system_headers/linux_stat.h -index 3aae8cb..74977ad 100644 +Index: chromium/sandbox/linux/system_headers/linux_stat.h +=================================================================== --- chromium/sandbox/linux/system_headers/linux_stat.h +++ chromium/sandbox/linux/system_headers/linux_stat.h @@ -150,7 +150,7 @@ struct kernel_stat { @@ -669,8 +691,8 @@ index 3aae8cb..74977ad 100644 struct kernel_stat { unsigned long st_dev; unsigned long st_ino; -diff --git chromium/sandbox/linux/system_headers/linux_syscalls.h chromium/sandbox/linux/system_headers/linux_syscalls.h -index 438147b..d6de8c1 100644 +Index: chromium/sandbox/linux/system_headers/linux_syscalls.h +=================================================================== --- chromium/sandbox/linux/system_headers/linux_syscalls.h +++ chromium/sandbox/linux/system_headers/linux_syscalls.h @@ -35,5 +35,9 @@ @@ -683,13 +705,12 @@ index 438147b..d6de8c1 100644 + #endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_ -diff --git chromium/sandbox/linux/system_headers/riscv64_linux_syscalls.h chromium/sandbox/linux/system_headers/riscv64_linux_syscalls.h -new file mode 100644 -index 0000000..7615cd5 +Index: chromium/sandbox/linux/system_headers/riscv64_linux_syscalls.h +=================================================================== --- /dev/null +++ chromium/sandbox/linux/system_headers/riscv64_linux_syscalls.h -@@ -0,0 +1,1222 @@ -+// Copyright 2014 The Chromium Authors. All rights reserved. +@@ -0,0 +1,1290 @@ ++// Copyright 2014 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + @@ -1674,6 +1695,10 @@ index 0000000..7615cd5 +#define __NR_recvmmsg 243 +#endif + ++#if !defined(__NR_riscv_hwprobe) ++#define __NR_riscv_hwprobe 258 ++#endif ++ +#if !defined(__NR_riscv_flush_icache) +#define __NR_riscv_flush_icache 259 +#endif @@ -1910,12 +1935,89 @@ index 0000000..7615cd5 +#define __NR_landlock_restrict_self 446 +#endif + ++#if !defined(__NR_memfd_secret) ++#define __NR_memfd_secret 447 ++#endif ++ ++#if !defined(__NR_process_mrelease) ++#define __NR_process_mrelease 448 ++#endif ++ ++#if !defined(__NR_futex_waitv) ++#define __NR_futex_waitv 449 ++#endif ++ ++#if !defined(__NR_set_mempolicy_home_node) ++#define __NR_set_mempolicy_home_node 450 ++#endif ++ ++#if !defined(__NR_cachestat) ++#define __NR_cachestat 451 ++#endif ++ ++#if !defined(__NR_fchmodat2) ++#define __NR_fchmodat2 452 ++#endif ++ ++#if !defined(__NR_map_shadow_stack) ++#define __NR_map_shadow_stack 453 ++#endif ++ ++#if !defined(__NR_futex_wake) ++#define __NR_futex_wake 454 ++#endif ++ ++#if !defined(__NR_futex_wait) ++#define __NR_futex_wait 455 ++#endif ++ ++#if !defined(__NR_futex_requeue) ++#define __NR_futex_requeue 456 ++#endif ++ ++#if !defined(__NR_statmount) ++#define __NR_statmount 457 ++#endif ++ ++#if !defined(__NR_listmount) ++#define __NR_listmount 458 ++#endif ++ ++#if !defined(__NR_lsm_get_self_attr) ++#define __NR_lsm_get_self_attr 459 ++#endif ++ ++#if !defined(__NR_lsm_set_self_attr) ++#define __NR_lsm_set_self_attr 460 ++#endif ++ ++#if !defined(__NR_lsm_list_modules) ++#define __NR_lsm_list_modules 461 ++#endif ++ ++#if !defined(__NR_mseal) ++#define __NR_mseal 462 ++#endif ++ +#endif // SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_ -diff --git chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc -index df2567f..41e158a 100644 +Index: chromium/sandbox/policy/linux/bpf_cdm_policy_linux.cc +=================================================================== +--- chromium/sandbox/policy/linux/bpf_cdm_policy_linux.cc ++++ chromium/sandbox/policy/linux/bpf_cdm_policy_linux.cc +@@ -33,7 +33,7 @@ ResultExpr CdmProcessPolicy::EvaluateSys + case __NR_ftruncate: + case __NR_fallocate: + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_getrlimit: + #endif + #if defined(__i386__) || defined(__arm__) +Index: chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc +=================================================================== --- chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc +++ chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc -@@ -38,7 +38,7 @@ ResultExpr CrosAmdGpuProcessPolicy::EvaluateSyscall(int sysno) const { +@@ -38,7 +38,7 @@ ResultExpr CrosAmdGpuProcessPolicy::Eval case __NR_sched_setscheduler: case __NR_sysinfo: case __NR_uname: @@ -1924,11 +2026,11 @@ index df2567f..41e158a 100644 case __NR_readlink: case __NR_stat: #endif -diff --git chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc -index ef49a63..3334257 100644 +Index: chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc +=================================================================== --- chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc +++ chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc -@@ -80,7 +80,7 @@ ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const { +@@ -80,7 +80,7 @@ ResultExpr GpuProcessPolicy::EvaluateSys (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) case __NR_ftruncate64: #endif @@ -1937,6 +2039,68 @@ index ef49a63..3334257 100644 case __NR_getdents: #endif case __NR_getdents64: --- -2.43.5 - +Index: chromium/sandbox/policy/linux/bpf_network_policy_linux.cc +=================================================================== +--- chromium/sandbox/policy/linux/bpf_network_policy_linux.cc ++++ chromium/sandbox/policy/linux/bpf_network_policy_linux.cc +@@ -260,7 +260,7 @@ ResultExpr NetworkProcessPolicy::Evaluat + case __NR_fdatasync: + case __NR_fsync: + case __NR_mremap: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_getdents: + #endif + case __NR_getdents64: +Index: chromium/sandbox/policy/linux/bpf_print_compositor_policy_linux.cc +=================================================================== +--- chromium/sandbox/policy/linux/bpf_print_compositor_policy_linux.cc ++++ chromium/sandbox/policy/linux/bpf_print_compositor_policy_linux.cc +@@ -33,7 +33,7 @@ ResultExpr PrintCompositorProcessPolicy: + case __NR_fdatasync: + case __NR_fsync: + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined (__riscv) + case __NR_getrlimit: + #endif + #if defined(__i386__) || defined(__arm__) +Index: chromium/sandbox/policy/linux/bpf_renderer_policy_linux.cc +=================================================================== +--- chromium/sandbox/policy/linux/bpf_renderer_policy_linux.cc ++++ chromium/sandbox/policy/linux/bpf_renderer_policy_linux.cc +@@ -82,7 +82,7 @@ ResultExpr RendererProcessPolicy::Evalua + case __NR_ftruncate64: + #endif + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_getrlimit: + case __NR_setrlimit: + // We allow setrlimit to dynamically adjust the address space limit as +Index: chromium/sandbox/policy/linux/bpf_service_policy_linux.cc +=================================================================== +--- chromium/sandbox/policy/linux/bpf_service_policy_linux.cc ++++ chromium/sandbox/policy/linux/bpf_service_policy_linux.cc +@@ -26,7 +26,7 @@ ResultExpr ServiceProcessPolicy::Evaluat + return RestrictIoctl(); + // Allow the system calls below. + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_getrlimit: + #endif + #if defined(__i386__) || defined(__arm__) +Index: chromium/sandbox/policy/linux/bpf_utility_policy_linux.cc +=================================================================== +--- chromium/sandbox/policy/linux/bpf_utility_policy_linux.cc ++++ chromium/sandbox/policy/linux/bpf_utility_policy_linux.cc +@@ -34,7 +34,7 @@ ResultExpr UtilityProcessPolicy::Evaluat + case __NR_fdatasync: + case __NR_fsync: + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_getrlimit: + #endif + #if defined(__i386__) || defined(__arm__) -- Gitee