浏览代码

rebase patchset to 9fc37dca35728

Detailed update on the patchset:
- SwiftShader patch landed in upstream, removed from the list.
- Clean up some patches to be upstream-ready.
- Need to re-evaluate the validity of the patches, move to archive
folder for further build check.

Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
Rebecca Chang Swee Fun 2 年之前
父节点
当前提交
11324cbb74
共有 31 个文件被更改,包括 4005 次插入37721 次删除
  1. 1819 0
      0001-sandbox-add-riscv-arch-definition-and-define-syscall.patch
  2. 2 2
      0002-sandbox-linux-pass-fPIE-to-compiler.patch
  3. 2 2
      0003-skia-add-riscv64.patch
  4. 19 18
      0004-base-allocator-partition_allocator-add-riscv64-suppo.patch
  5. 26 0
      0005-base-process-add-riscv64-arch-definition.patch
  6. 2 2
      0006-remoting-fix-missing-cstring-header.patch
  7. 2 2
      0007-remoting-codec-fix-missing-cmath-header.patch
  8. 0 36
      0008-build-config-sysroot.gni-add-path-to-riscv64-sysroot.patch
  9. 49 0
      0008-components-update_client-add-riscv64-arch-definition.patch
  10. 4 4
      0009-build-config-compiler-use_gold-linker-option.patch
  11. 8 8
      0010-build-config-compiler-remove-flags-not-available-in-.patch
  12. 0 36
      0010-build-config-posix-do-not-recompile-sysroot.patch
  13. 25 0
      0011-build-config-add-atomic-build-flag.patch
  14. 4 4
      0012-build-config-compiler-set-generic-riscv64-flags.patch
  15. 7 3
      0013-chrome-common-remove-unrar-code.patch
  16. 26 0
      0014-third_party-libaom-add-riscv-target.patch
  17. 35 0
      0015-third_party-libvpx-add-riscv-target.patch
  18. 808 0
      0016-third_party-crashpad-add-support-for-riscv.patch
  19. 4 4
      0017-third_party-lzma_sdk-add-riscv-arch-definition.patch
  20. 1104 0
      0018-build-linux-sysroot-create-a-sysroot-for-riscv.patch
  21. 4 12
      README.md
  22. 4 4
      archive/0001-BUILD.gn-disable-printing-unittests.patch
  23. 8 8
      archive/0001-BUILD.gn-remove-libjpeg-turbo.patch
  24. 26 34
      archive/0001-breakpad-temporarily-disable-it.patch
  25. 2 2
      archive/0001-build-config-make-sure-target_cpu-is-honored-in-tool.patch
  26. 2 2
      archive/0001-build-gn_run_binary.py-do-not-run-binary-from.patch
  27. 2 2
      archive/0001-media-gpu-disable-tests.patch
  28. 7 7
      archive/0001-media-media_options-disable-dav1d-decoder.patch
  29. 2 2
      archive/0001-third_party-widevine-define-WIDEVINE_CDM_VERSION_STR.patch
  30. 2 2
      archive/0001-third_party-zlib-do-not-mangle-zlib.patch
  31. 0 37525
      third_party/0001-third-party-swiftshader.patch

+ 1819 - 0
0001-sandbox-add-riscv-arch-definition-and-define-syscall.patch

@@ -0,0 +1,1819 @@
+From 980d6f734be71176b619309ed76641846479927d Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 30 Mar 2022 06:38:26 +0000
+Subject: [PATCH 01/18] sandbox: add riscv arch definition and define syscall
+ header
+
+Credit to work contributed in Github.
+https://github.com/felixonmars/archriscv-packages/tree/master/chromium
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ sandbox/features.gni                          |    3 +-
+ sandbox/linux/bpf_dsl/linux_syscall_ranges.h  |    6 +
+ sandbox/linux/bpf_dsl/seccomp_macros.h        |   41 +
+ .../seccomp-bpf-helpers/baseline_policy.cc    |    9 +-
+ .../syscall_parameters_restrictions.cc        |    3 +-
+ .../linux/seccomp-bpf-helpers/syscall_sets.cc |   73 +-
+ .../linux/seccomp-bpf-helpers/syscall_sets.h  |   11 +-
+ sandbox/linux/seccomp-bpf/syscall.cc          |   35 +-
+ sandbox/linux/services/credentials.cc         |    2 +-
+ .../linux/syscall_broker/broker_process.cc    |   20 +-
+ sandbox/linux/system_headers/linux_seccomp.h  |    8 +
+ sandbox/linux/system_headers/linux_signal.h   |    2 +-
+ sandbox/linux/system_headers/linux_stat.h     |    2 +-
+ sandbox/linux/system_headers/linux_syscalls.h |    4 +
+ .../system_headers/riscv64_linux_syscalls.h   | 1070 +++++++++++++++++
+ .../linux/bpf_cros_amd_gpu_policy_linux.cc    |    2 +-
+ sandbox/policy/linux/bpf_gpu_policy_linux.cc  |    2 +-
+ 17 files changed, 1241 insertions(+), 52 deletions(-)
+ create mode 100644 sandbox/linux/system_headers/riscv64_linux_syscalls.h
+
+diff --git a/sandbox/features.gni b/sandbox/features.gni
+index ad067ada520b5..c9f67f81618f6 100644
+--- a/sandbox/features.gni
++++ b/sandbox/features.gni
+@@ -9,7 +9,8 @@
+ 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")
+ 
+ # 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 a/sandbox/linux/bpf_dsl/linux_syscall_ranges.h b/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
+index 313511f22e95a..104dabde1cc0a 100644
+--- a/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
++++ b/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
+@@ -56,6 +56,12 @@
+ #define MAX_PUBLIC_SYSCALL __NR_syscalls
+ #define MAX_SYSCALL MAX_PUBLIC_SYSCALL
+ 
++#elif defined(__riscv) && (__riscv_xlen == 64)
++
++#define MIN_SYSCALL 0u
++#define MAX_PUBLIC_SYSCALL 1024u
++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL
++
+ #else
+ #error "Unsupported architecture"
+ #endif
+diff --git a/sandbox/linux/bpf_dsl/seccomp_macros.h b/sandbox/linux/bpf_dsl/seccomp_macros.h
+index 961a8cf7521ee..7c9a0c99e8fbe 100644
+--- a/sandbox/linux/bpf_dsl/seccomp_macros.h
++++ b/sandbox/linux/bpf_dsl/seccomp_macros.h
+@@ -343,6 +343,47 @@ 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]
++
++#elif defined(__riscv) && (__riscv_xlen == 64)
++struct regs_struct {
++  unsigned long regs[32];
++};
++
++#define SECCOMP_ARCH AUDIT_ARCH_RISCV64
++
++#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg])
++
++#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, REG_A0)
++#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, REG_A0+7)
++#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.__gregs[REG_PC]
++#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, REG_A0)
++#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, REG_A0+1)
++#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, REG_A0+2)
++#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_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).regs[REG_A0]
++#define SECCOMP_PT_SYSCALL(_regs) (_regs).regs[REG_A0+7]
++#define SECCOMP_PT_IP(_regs) (_regs).regs[REG_PC]
++#define SECCOMP_PT_PARM1(_regs) (_regs).regs[REG_A0]
++#define SECCOMP_PT_PARM2(_regs) (_regs).regs[REG_A0+1]
++#define SECCOMP_PT_PARM3(_regs) (_regs).regs[REG_A0+2]
++#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]
++
+ #else
+ #error Unsupported target platform
+ 
+diff --git a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
+index 30c15cccb5c1f..06c6026a26fa2 100644
+--- a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
++++ b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
+@@ -60,6 +60,9 @@ bool IsBaselinePolicyAllowed(int sysno) {
+ #endif
+ #if defined(__mips__)
+          SyscallSets::IsMipsPrivate(sysno) ||
++#endif
++#if defined(__riscv)
++         SyscallSets::IsRiscvPrivate(sysno) ||
+ #endif
+          SyscallSets::IsAllowedOperationOnFd(sysno);
+   // clang-format on
+@@ -198,7 +201,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
+     return RestrictFcntlCommands();
+ #endif
+ 
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+   // 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) {
+@@ -253,7 +256,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
+   }
+ 
+ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+   if (sysno == __NR_mmap)
+     return RestrictMmapFlags();
+ #endif
+@@ -274,7 +277,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
+     return RestrictPrctl();
+ 
+ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+   if (sysno == __NR_socketpair) {
+     // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen.
+     static_assert(AF_UNIX == PF_UNIX,
+diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+index 7feff3f49323a..80205c10dd0b4 100644
+--- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
++++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+@@ -37,6 +37,7 @@
+ 
+ #if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
+     !defined(__arm__) && !defined(__aarch64__) &&             \
++    !defined(__riscv) &&                                      \
+     !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.
+@@ -443,7 +444,7 @@ ResultExpr RestrictPtrace() {
+ #endif
+   return Switch(request)
+       .CASES((
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+                  PTRACE_GETREGS, PTRACE_GETFPREGS, PTRACE_GET_THREAD_AREA,
+                  PTRACE_GETREGSET,
+ #endif
+diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+index b3cf6fc7e86fd..906b798b5c04e 100644
+--- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
++++ b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+@@ -103,7 +103,7 @@ bool SyscallSets::IsUmask(int sysno) {
+ // 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(__riscv)
+     case __NR_access:  // EPERM not a valid errno.
+     case __NR_chmod:
+     case __NR_chown:
+@@ -136,7 +136,7 @@ bool SyscallSets::IsFileSystem(int sysno) {
+     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(__riscv)
+     case __NR_newfstatat:  // fstatat(). EPERM not a valid errno.
+ #elif defined(__i386__) || defined(__arm__) || \
+     (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+@@ -226,7 +226,7 @@ bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) {
+     case __NR_oldfstat:
+ #endif
+ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_sync_file_range:  // EPERM not a valid errno.
+ #elif defined(__arm__)
+     case __NR_arm_sync_file_range:  // EPERM not a valid errno.
+@@ -245,7 +245,7 @@ bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) {
+ #if defined(__i386__) || defined(__arm__)
+     case __NR_fchown32:
+ #endif
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) || defined(__riscv)
+     case __NR_getdents:    // EPERM not a valid errno.
+ #endif
+     case __NR_getdents64:  // EPERM not a valid errno.
+@@ -324,7 +324,7 @@ bool SyscallSets::IsProcessPrivilegeChange(int sysno) {
+ bool SyscallSets::IsProcessGroupOrSession(int sysno) {
+   switch (sysno) {
+     case __NR_setpgid:
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_getpgrp:
+ #endif
+     case __NR_setsid:
+@@ -358,7 +358,7 @@ bool SyscallSets::IsAllowedSignalHandling(int sysno) {
+     case __NR_rt_sigqueueinfo:
+     case __NR_rt_sigsuspend:
+     case __NR_rt_tgsigqueueinfo:
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_signalfd:
+ #endif
+     case __NR_signalfd4:
+@@ -382,12 +382,12 @@ bool SyscallSets::IsAllowedOperationOnFd(int sysno) {
+   switch (sysno) {
+     case __NR_close:
+     case __NR_dup:
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_dup2:
+ #endif
+     case __NR_dup3:
+ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_shutdown:
+ #endif
+       return true;
+@@ -426,7 +426,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
+       return true;
+     case __NR_clone:  // Should be parameter-restricted.
+     case __NR_setns:  // Privileged.
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_fork:
+ #endif
+ #if defined(__i386__) || defined(__x86_64__)
+@@ -437,7 +437,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
+ #endif
+     case __NR_set_tid_address:
+     case __NR_unshare:
+-#if !defined(__mips__) && !defined(__aarch64__)
++#if !defined(__mips__) && !defined(__aarch64__) && !defined(__riscv)
+     case __NR_vfork:
+ #endif
+     default:
+@@ -462,7 +462,7 @@ bool SyscallSets::IsAllowedFutex(int sysno) {
+ 
+ bool SyscallSets::IsAllowedEpoll(int sysno) {
+   switch (sysno) {
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_epoll_create:
+     case __NR_epoll_wait:
+ #endif
+@@ -483,14 +483,14 @@ bool SyscallSets::IsAllowedEpoll(int sysno) {
+ 
+ bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) {
+   switch (sysno) {
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_pipe:
+ #endif
+     case __NR_pipe2:
+       return true;
+     default:
+ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_socketpair:  // We will want to inspect its argument.
+ #endif
+       return false;
+@@ -500,7 +500,7 @@ bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) {
+ bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) {
+   switch (sysno) {
+ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_accept:
+     case __NR_accept4:
+     case __NR_bind:
+@@ -554,7 +554,7 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
+     case __NR_mincore:
+     case __NR_mlockall:
+ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_mmap:
+ #endif
+ #if defined(__i386__) || defined(__arm__) || \
+@@ -587,7 +587,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) {
+     (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+     case __NR__llseek:
+ #endif
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_poll:
+ #endif
+     case __NR_ppoll:
+@@ -608,7 +608,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) {
+     case __NR_recv:
+ #endif
+ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_recvfrom:  // Could specify source.
+     case __NR_recvmsg:   // Could specify source.
+ #endif
+@@ -623,7 +623,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) {
+     case __NR_send:
+ #endif
+ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_sendmsg:  // Could specify destination.
+     case __NR_sendto:   // Could specify destination.
+ #endif
+@@ -672,7 +672,7 @@ bool SyscallSets::IsSeccomp(int sysno) {
+ bool SyscallSets::IsAllowedBasicScheduler(int sysno) {
+   switch (sysno) {
+     case __NR_sched_yield:
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_pause:
+ #endif
+     case __NR_nanosleep:
+@@ -756,7 +756,7 @@ bool SyscallSets::IsNuma(int sysno) {
+     case __NR_getcpu:
+     case __NR_mbind:
+ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_migrate_pages:
+ #endif
+     case __NR_move_pages:
+@@ -791,7 +791,7 @@ bool SyscallSets::IsGlobalProcessEnvironment(int sysno) {
+   switch (sysno) {
+     case __NR_acct:  // Privileged.
+ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+     case __NR_getrlimit:
+ #endif
+ #if defined(__i386__) || defined(__arm__)
+@@ -826,7 +826,7 @@ bool SyscallSets::IsDebug(int sysno) {
+ 
+ bool SyscallSets::IsGlobalSystemStatus(int sysno) {
+   switch (sysno) {
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR__sysctl:
+     case __NR_sysfs:
+ #endif
+@@ -844,7 +844,7 @@ bool SyscallSets::IsGlobalSystemStatus(int sysno) {
+ 
+ bool SyscallSets::IsEventFd(int sysno) {
+   switch (sysno) {
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_eventfd:
+ #endif
+     case __NR_eventfd2:
+@@ -896,7 +896,8 @@ bool SyscallSets::IsKeyManagement(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)
+ bool SyscallSets::IsSystemVSemaphores(int sysno) {
+   switch (sysno) {
+     case __NR_semctl:
+@@ -916,7 +917,8 @@ bool SyscallSets::IsSystemVSemaphores(int sysno) {
+ 
+ #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)
+ // These give a lot of ambient authority and bypass the setuid sandbox.
+ bool SyscallSets::IsSystemVSharedMemory(int sysno) {
+   switch (sysno) {
+@@ -932,7 +934,8 @@ bool SyscallSets::IsSystemVSharedMemory(int sysno) {
+ #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)
+ bool SyscallSets::IsSystemVMessageQueue(int sysno) {
+   switch (sysno) {
+     case __NR_msgctl:
+@@ -963,7 +966,8 @@ 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)
+   return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) ||
+          IsSystemVSharedMemory(sysno);
+ #elif defined(__i386__) || \
+@@ -1000,7 +1004,7 @@ bool SyscallSets::IsAdvancedScheduler(int sysno) {
+ bool SyscallSets::IsInotify(int sysno) {
+   switch (sysno) {
+     case __NR_inotify_add_watch:
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_inotify_init:
+ #endif
+     case __NR_inotify_init1:
+@@ -1138,7 +1142,7 @@ bool SyscallSets::IsMisc(int sysno) {
+ #if defined(__x86_64__)
+     case __NR_tuxcall:
+ #endif
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_vserver:
+ #endif
+       return true;
+@@ -1173,6 +1177,17 @@ bool SyscallSets::IsArmPrivate(int sysno) {
+ }
+ #endif  // defined(__arm__)
+ 
++#if defined(__riscv)
++bool SyscallSets::IsRiscvPrivate(int sysno) {
++  switch (sysno) {
++    case __NR_riscv_flush_icache:
++      return true;
++    default:
++      return false;
++  }
++}
++#endif  // defined(__riscv)
++
+ #if defined(__mips__)
+ bool SyscallSets::IsMipsPrivate(int sysno) {
+   switch (sysno) {
+diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
+index 6403f45dc2f78..dd7cb8ca17ecf 100644
+--- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
++++ b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
+@@ -52,7 +52,7 @@ class SANDBOX_EXPORT SyscallSets {
+ #endif
+ 
+ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
+-    defined(__aarch64__)
++    defined(__aarch64__) || defined(__riscv)
+   static bool IsNetworkSocketInformation(int sysno);
+ #endif
+ 
+@@ -79,12 +79,14 @@ class SANDBOX_EXPORT SyscallSets {
+   static bool IsAsyncIo(int sysno);
+   static bool IsKeyManagement(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)
+   static bool IsSystemVSemaphores(int sysno);
+ #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)
+   // These give a lot of ambient authority and bypass the setuid sandbox.
+   static bool IsSystemVSharedMemory(int sysno);
+ #endif
+@@ -117,6 +119,9 @@ class SANDBOX_EXPORT SyscallSets {
+   static bool IsMipsPrivate(int sysno);
+   static bool IsMipsMisc(int sysno);
+ #endif  // defined(__mips__)
++#if defined(__riscv)
++  static bool IsRiscvPrivate(int sysno);
++#endif
+ };
+ 
+ }  // namespace sandbox.
+diff --git a/sandbox/linux/seccomp-bpf/syscall.cc b/sandbox/linux/seccomp-bpf/syscall.cc
+index 2e0e810383b58..37f60d3333e0d 100644
+--- a/sandbox/linux/seccomp-bpf/syscall.cc
++++ b/sandbox/linux/seccomp-bpf/syscall.cc
+@@ -18,7 +18,7 @@ namespace sandbox {
+ 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
+@@ -308,6 +308,28 @@ asm(// We need to be able to tell the kernel exactly where we made a
+     "2:ret\n"
+     ".cfi_endproc\n"
+     ".size SyscallAsm, .-SyscallAsm\n"
++#elif defined(__riscv)
++    ".text\n"
++    ".align 2\n"
++    ".type SyscallAsm, %function\n"
++    "SyscallAsm:\n"
++    ".cfi_startproc\n"
++    "bgez a0,1f\n"
++    "la 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"
++    // Enter the kernel
++    "scall\n"
++    "2:ret\n"
++    ".cfi_endproc\n"
++    ".size SyscallAsm, .-SyscallAsm\n"
+ #endif
+     );  // asm
+ 
+@@ -424,6 +446,17 @@ intptr_t Syscall::Call(int nr,
+                  : "memory", "x1", "x2", "x3", "x4", "x5", "x8", "x30");
+     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;
++  }
+ 
+ #else
+ #error "Unimplemented architecture"
+diff --git a/sandbox/linux/services/credentials.cc b/sandbox/linux/services/credentials.cc
+index 00b969ee02a7e..7fa1a42ca41cc 100644
+--- a/sandbox/linux/services/credentials.cc
++++ b/sandbox/linux/services/credentials.cc
+@@ -80,7 +80,7 @@ bool ChrootToSafeEmptyDir() {
+   pid_t pid = -1;
+   alignas(16) char stack_buf[PTHREAD_STACK_MIN];
+ #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)
+   // The stack grows downward.
+   void* stack = stack_buf + sizeof(stack_buf);
+ #else
+diff --git a/sandbox/linux/syscall_broker/broker_process.cc b/sandbox/linux/syscall_broker/broker_process.cc
+index 7dd4688011f9e..6feb09aeedf2b 100644
+--- a/sandbox/linux/syscall_broker/broker_process.cc
++++ b/sandbox/linux/syscall_broker/broker_process.cc
+@@ -117,44 +117,46 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const {
+   // 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__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
+     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__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
+     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__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
+     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__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
+     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__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
+     case __NR_rename:
+ #endif
++#ifdef __NR_renameat:
+     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__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
+     case __NR_rmdir:
+       return !fast_check || policy_->allowed_command_set.test(COMMAND_RMDIR);
+ #endif
+ 
+-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
++#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
+     case __NR_stat:
+     case __NR_lstat:
+ #endif
+@@ -164,7 +166,7 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const {
+ #if defined(__NR_fstatat64)
+     case __NR_fstatat64:
+ #endif
+-#if defined(__x86_64__) || defined(__aarch64__)
++#if defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)
+     case __NR_newfstatat:
+ #endif
+       return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT);
+@@ -179,7 +181,7 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const {
+       return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT);
+ #endif
+ 
+-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
++#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
+     case __NR_unlink:
+       return !fast_check || policy_->allowed_command_set.test(COMMAND_UNLINK);
+ #endif
+diff --git a/sandbox/linux/system_headers/linux_seccomp.h b/sandbox/linux/system_headers/linux_seccomp.h
+index 7d898d84631ae..0b144fe30c329 100644
+--- a/sandbox/linux/system_headers/linux_seccomp.h
++++ b/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
+diff --git a/sandbox/linux/system_headers/linux_signal.h b/sandbox/linux/system_headers/linux_signal.h
+index 74bbb8ef8c740..db6159f754ce1 100644
+--- a/sandbox/linux/system_headers/linux_signal.h
++++ b/sandbox/linux/system_headers/linux_signal.h
+@@ -13,7 +13,7 @@
+ // (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)
+ 
+ #define LINUX_SIGHUP 1
+ #define LINUX_SIGINT 2
+diff --git a/sandbox/linux/system_headers/linux_stat.h b/sandbox/linux/system_headers/linux_stat.h
+index 5f49a958499ee..32ab256cfca45 100644
+--- a/sandbox/linux/system_headers/linux_stat.h
++++ b/sandbox/linux/system_headers/linux_stat.h
+@@ -150,7 +150,7 @@ struct kernel_stat {
+   int st_blocks;
+   int st_pad4[14];
+ };
+-#elif defined(__aarch64__)
++#elif defined(__aarch64__) || defined(__riscv)
+ struct kernel_stat {
+   unsigned long st_dev;
+   unsigned long st_ino;
+diff --git a/sandbox/linux/system_headers/linux_syscalls.h b/sandbox/linux/system_headers/linux_syscalls.h
+index 2b78a0cc3b974..968d6f71b5862 100644
+--- a/sandbox/linux/system_headers/linux_syscalls.h
++++ b/sandbox/linux/system_headers/linux_syscalls.h
+@@ -35,5 +35,9 @@
+ #include "sandbox/linux/system_headers/arm64_linux_syscalls.h"
+ #endif
+ 
++#if defined(__riscv) && __riscv_xlen == 64
++#include "sandbox/linux/system_headers/riscv64_linux_syscalls.h"
++#endif
++
+ #endif  // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
+ 
+diff --git a/sandbox/linux/system_headers/riscv64_linux_syscalls.h b/sandbox/linux/system_headers/riscv64_linux_syscalls.h
+new file mode 100644
+index 0000000000000..23533617a91b7
+--- /dev/null
++++ b/sandbox/linux/system_headers/riscv64_linux_syscalls.h
+@@ -0,0 +1,1070 @@
++// Copyright 2014 The Chromium Authors. All rights reserved.
++// Use of this source code is governed by a BSD-style license that can be
++// found in the LICENSE file.
++
++#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_
++#define SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_
++
++#include <asm-generic/unistd.h>
++
++#if !defined(__NR_io_setup)
++#define __NR_io_setup 0
++#endif
++
++#if !defined(__NR_io_destroy)
++#define __NR_io_destroy 1
++#endif
++
++#if !defined(__NR_io_submit)
++#define __NR_io_submit 2
++#endif
++
++#if !defined(__NR_io_cancel)
++#define __NR_io_cancel 3
++#endif
++
++#if !defined(__NR_io_getevents)
++#define __NR_io_getevents 4
++#endif
++
++#if !defined(__NR_setxattr)
++#define __NR_setxattr 5
++#endif
++
++#if !defined(__NR_lsetxattr)
++#define __NR_lsetxattr 6
++#endif
++
++#if !defined(__NR_fsetxattr)
++#define __NR_fsetxattr 7
++#endif
++
++#if !defined(__NR_getxattr)
++#define __NR_getxattr 8
++#endif
++
++#if !defined(__NR_lgetxattr)
++#define __NR_lgetxattr 9
++#endif
++
++#if !defined(__NR_fgetxattr)
++#define __NR_fgetxattr 10
++#endif
++
++#if !defined(__NR_listxattr)
++#define __NR_listxattr 11
++#endif
++
++#if !defined(__NR_llistxattr)
++#define __NR_llistxattr 12
++#endif
++
++#if !defined(__NR_flistxattr)
++#define __NR_flistxattr 13
++#endif
++
++#if !defined(__NR_removexattr)
++#define __NR_removexattr 14
++#endif
++
++#if !defined(__NR_lremovexattr)
++#define __NR_lremovexattr 15
++#endif
++
++#if !defined(__NR_fremovexattr)
++#define __NR_fremovexattr 16
++#endif
++
++#if !defined(__NR_getcwd)
++#define __NR_getcwd 17
++#endif
++
++#if !defined(__NR_lookup_dcookie)
++#define __NR_lookup_dcookie 18
++#endif
++
++#if !defined(__NR_eventfd2)
++#define __NR_eventfd2 19
++#endif
++
++#if !defined(__NR_epoll_create1)
++#define __NR_epoll_create1 20
++#endif
++
++#if !defined(__NR_epoll_ctl)
++#define __NR_epoll_ctl 21
++#endif
++
++#if !defined(__NR_epoll_pwait)
++#define __NR_epoll_pwait 22
++#endif
++
++#if !defined(__NR_dup)
++#define __NR_dup 23
++#endif
++
++#if !defined(__NR_dup3)
++#define __NR_dup3 24
++#endif
++
++#if !defined(__NR_fcntl)
++#define __NR_fcntl 25
++#endif
++
++#if !defined(__NR_inotify_init1)
++#define __NR_inotify_init1 26
++#endif
++
++#if !defined(__NR_inotify_add_watch)
++#define __NR_inotify_add_watch 27
++#endif
++
++#if !defined(__NR_inotify_rm_watch)
++#define __NR_inotify_rm_watch 28
++#endif
++
++#if !defined(__NR_ioctl)
++#define __NR_ioctl 29
++#endif
++
++#if !defined(__NR_ioprio_set)
++#define __NR_ioprio_set 30
++#endif
++
++#if !defined(__NR_ioprio_get)
++#define __NR_ioprio_get 31
++#endif
++
++#if !defined(__NR_flock)
++#define __NR_flock 32
++#endif
++
++#if !defined(__NR_mknodat)
++#define __NR_mknodat 33
++#endif
++
++#if !defined(__NR_mkdirat)
++#define __NR_mkdirat 34
++#endif
++
++#if !defined(__NR_unlinkat)
++#define __NR_unlinkat 35
++#endif
++
++#if !defined(__NR_symlinkat)
++#define __NR_symlinkat 36
++#endif
++
++#if !defined(__NR_linkat)
++#define __NR_linkat 37
++#endif
++
++#if !defined(__NR_renameat)
++#define __NR_renameat 38
++#endif
++
++#if !defined(__NR_umount2)
++#define __NR_umount2 39
++#endif
++
++#if !defined(__NR_mount)
++#define __NR_mount 40
++#endif
++
++#if !defined(__NR_pivot_root)
++#define __NR_pivot_root 41
++#endif
++
++#if !defined(__NR_nfsservctl)
++#define __NR_nfsservctl 42
++#endif
++
++#if !defined(__NR_statfs)
++#define __NR_statfs 43
++#endif
++
++#if !defined(__NR_fstatfs)
++#define __NR_fstatfs 44
++#endif
++
++#if !defined(__NR_truncate)
++#define __NR_truncate 45
++#endif
++
++#if !defined(__NR_ftruncate)
++#define __NR_ftruncate 46
++#endif
++
++#if !defined(__NR_fallocate)
++#define __NR_fallocate 47
++#endif
++
++#if !defined(__NR_faccessat)
++#define __NR_faccessat 48
++#endif
++
++#if !defined(__NR_chdir)
++#define __NR_chdir 49
++#endif
++
++#if !defined(__NR_fchdir)
++#define __NR_fchdir 50
++#endif
++
++#if !defined(__NR_chroot)
++#define __NR_chroot 51
++#endif
++
++#if !defined(__NR_fchmod)
++#define __NR_fchmod 52
++#endif
++
++#if !defined(__NR_fchmodat)
++#define __NR_fchmodat 53
++#endif
++
++#if !defined(__NR_fchownat)
++#define __NR_fchownat 54
++#endif
++
++#if !defined(__NR_fchown)
++#define __NR_fchown 55
++#endif
++
++#if !defined(__NR_openat)
++#define __NR_openat 56
++#endif
++
++#if !defined(__NR_close)
++#define __NR_close 57
++#endif
++
++#if !defined(__NR_vhangup)
++#define __NR_vhangup 58
++#endif
++
++#if !defined(__NR_pipe2)
++#define __NR_pipe2 59
++#endif
++
++#if !defined(__NR_quotactl)
++#define __NR_quotactl 60
++#endif
++
++#if !defined(__NR_getdents64)
++#define __NR_getdents64 61
++#endif
++
++#if !defined(__NR_lseek)
++#define __NR_lseek 62
++#endif
++
++#if !defined(__NR_read)
++#define __NR_read 63
++#endif
++
++#if !defined(__NR_write)
++#define __NR_write 64
++#endif
++
++#if !defined(__NR_readv)
++#define __NR_readv 65
++#endif
++
++#if !defined(__NR_writev)
++#define __NR_writev 66
++#endif
++
++#if !defined(__NR_pread64)
++#define __NR_pread64 67
++#endif
++
++#if !defined(__NR_pwrite64)
++#define __NR_pwrite64 68
++#endif
++
++#if !defined(__NR_preadv)
++#define __NR_preadv 69
++#endif
++
++#if !defined(__NR_pwritev)
++#define __NR_pwritev 70
++#endif
++
++#if !defined(__NR_sendfile)
++#define __NR_sendfile 71
++#endif
++
++#if !defined(__NR_pselect6)
++#define __NR_pselect6 72
++#endif
++
++#if !defined(__NR_ppoll)
++#define __NR_ppoll 73
++#endif
++
++#if !defined(__NR_signalfd4)
++#define __NR_signalfd4 74
++#endif
++
++#if !defined(__NR_vmsplice)
++#define __NR_vmsplice 75
++#endif
++
++#if !defined(__NR_splice)
++#define __NR_splice 76
++#endif
++
++#if !defined(__NR_tee)
++#define __NR_tee 77
++#endif
++
++#if !defined(__NR_readlinkat)
++#define __NR_readlinkat 78
++#endif
++
++#if !defined(__NR_newfstatat)
++#define __NR_newfstatat 79
++#endif
++
++#if !defined(__NR_fstat)
++#define __NR_fstat 80
++#endif
++
++#if !defined(__NR_sync)
++#define __NR_sync 81
++#endif
++
++#if !defined(__NR_fsync)
++#define __NR_fsync 82
++#endif
++
++#if !defined(__NR_fdatasync)
++#define __NR_fdatasync 83
++#endif
++
++#if !defined(__NR_sync_file_range)
++#define __NR_sync_file_range 84
++#endif
++
++#if !defined(__NR_timerfd_create)
++#define __NR_timerfd_create 85
++#endif
++
++#if !defined(__NR_timerfd_settime)
++#define __NR_timerfd_settime 86
++#endif
++
++#if !defined(__NR_timerfd_gettime)
++#define __NR_timerfd_gettime 87
++#endif
++
++#if !defined(__NR_utimensat)
++#define __NR_utimensat 88
++#endif
++
++#if !defined(__NR_acct)
++#define __NR_acct 89
++#endif
++
++#if !defined(__NR_capget)
++#define __NR_capget 90
++#endif
++
++#if !defined(__NR_capset)
++#define __NR_capset 91
++#endif
++
++#if !defined(__NR_personality)
++#define __NR_personality 92
++#endif
++
++#if !defined(__NR_exit)
++#define __NR_exit 93
++#endif
++
++#if !defined(__NR_exit_group)
++#define __NR_exit_group 94
++#endif
++
++#if !defined(__NR_waitid)
++#define __NR_waitid 95
++#endif
++
++#if !defined(__NR_set_tid_address)
++#define __NR_set_tid_address 96
++#endif
++
++#if !defined(__NR_unshare)
++#define __NR_unshare 97
++#endif
++
++#if !defined(__NR_futex)
++#define __NR_futex 98
++#endif
++
++#if !defined(__NR_set_robust_list)
++#define __NR_set_robust_list 99
++#endif
++
++#if !defined(__NR_get_robust_list)
++#define __NR_get_robust_list 100
++#endif
++
++#if !defined(__NR_nanosleep)
++#define __NR_nanosleep 101
++#endif
++
++#if !defined(__NR_getitimer)
++#define __NR_getitimer 102
++#endif
++
++#if !defined(__NR_setitimer)
++#define __NR_setitimer 103
++#endif
++
++#if !defined(__NR_kexec_load)
++#define __NR_kexec_load 104
++#endif
++
++#if !defined(__NR_init_module)
++#define __NR_init_module 105
++#endif
++
++#if !defined(__NR_delete_module)
++#define __NR_delete_module 106
++#endif
++
++#if !defined(__NR_timer_create)
++#define __NR_timer_create 107
++#endif
++
++#if !defined(__NR_timer_gettime)
++#define __NR_timer_gettime 108
++#endif
++
++#if !defined(__NR_timer_getoverrun)
++#define __NR_timer_getoverrun 109
++#endif
++
++#if !defined(__NR_timer_settime)
++#define __NR_timer_settime 110
++#endif
++
++#if !defined(__NR_timer_delete)
++#define __NR_timer_delete 111
++#endif
++
++#if !defined(__NR_clock_settime)
++#define __NR_clock_settime 112
++#endif
++
++#if !defined(__NR_clock_gettime)
++#define __NR_clock_gettime 113
++#endif
++
++#if !defined(__NR_clock_getres)
++#define __NR_clock_getres 114
++#endif
++
++#if !defined(__NR_clock_nanosleep)
++#define __NR_clock_nanosleep 115
++#endif
++
++#if !defined(__NR_syslog)
++#define __NR_syslog 116
++#endif
++
++#if !defined(__NR_ptrace)
++#define __NR_ptrace 117
++#endif
++
++#if !defined(__NR_sched_setparam)
++#define __NR_sched_setparam 118
++#endif
++
++#if !defined(__NR_sched_setscheduler)
++#define __NR_sched_setscheduler 119
++#endif
++
++#if !defined(__NR_sched_getscheduler)
++#define __NR_sched_getscheduler 120
++#endif
++
++#if !defined(__NR_sched_getparam)
++#define __NR_sched_getparam 121
++#endif
++
++#if !defined(__NR_sched_setaffinity)
++#define __NR_sched_setaffinity 122
++#endif
++
++#if !defined(__NR_sched_getaffinity)
++#define __NR_sched_getaffinity 123
++#endif
++
++#if !defined(__NR_sched_yield)
++#define __NR_sched_yield 124
++#endif
++
++#if !defined(__NR_sched_get_priority_max)
++#define __NR_sched_get_priority_max 125
++#endif
++
++#if !defined(__NR_sched_get_priority_min)
++#define __NR_sched_get_priority_min 126
++#endif
++
++#if !defined(__NR_sched_rr_get_interval)
++#define __NR_sched_rr_get_interval 127
++#endif
++
++#if !defined(__NR_restart_syscall)
++#define __NR_restart_syscall 128
++#endif
++
++#if !defined(__NR_kill)
++#define __NR_kill 129
++#endif
++
++#if !defined(__NR_tkill)
++#define __NR_tkill 130
++#endif
++
++#if !defined(__NR_tgkill)
++#define __NR_tgkill 131
++#endif
++
++#if !defined(__NR_sigaltstack)
++#define __NR_sigaltstack 132
++#endif
++
++#if !defined(__NR_rt_sigsuspend)
++#define __NR_rt_sigsuspend 133
++#endif
++
++#if !defined(__NR_rt_sigaction)
++#define __NR_rt_sigaction 134
++#endif
++
++#if !defined(__NR_rt_sigprocmask)
++#define __NR_rt_sigprocmask 135
++#endif
++
++#if !defined(__NR_rt_sigpending)
++#define __NR_rt_sigpending 136
++#endif
++
++#if !defined(__NR_rt_sigtimedwait)
++#define __NR_rt_sigtimedwait 137
++#endif
++
++#if !defined(__NR_rt_sigqueueinfo)
++#define __NR_rt_sigqueueinfo 138
++#endif
++
++#if !defined(__NR_rt_sigreturn)
++#define __NR_rt_sigreturn 139
++#endif
++
++#if !defined(__NR_setpriority)
++#define __NR_setpriority 140
++#endif
++
++#if !defined(__NR_getpriority)
++#define __NR_getpriority 141
++#endif
++
++#if !defined(__NR_reboot)
++#define __NR_reboot 142
++#endif
++
++#if !defined(__NR_setregid)
++#define __NR_setregid 143
++#endif
++
++#if !defined(__NR_setgid)
++#define __NR_setgid 144
++#endif
++
++#if !defined(__NR_setreuid)
++#define __NR_setreuid 145
++#endif
++
++#if !defined(__NR_setuid)
++#define __NR_setuid 146
++#endif
++
++#if !defined(__NR_setresuid)
++#define __NR_setresuid 147
++#endif
++
++#if !defined(__NR_getresuid)
++#define __NR_getresuid 148
++#endif
++
++#if !defined(__NR_setresgid)
++#define __NR_setresgid 149
++#endif
++
++#if !defined(__NR_getresgid)
++#define __NR_getresgid 150
++#endif
++
++#if !defined(__NR_setfsuid)
++#define __NR_setfsuid 151
++#endif
++
++#if !defined(__NR_setfsgid)
++#define __NR_setfsgid 152
++#endif
++
++#if !defined(__NR_times)
++#define __NR_times 153
++#endif
++
++#if !defined(__NR_setpgid)
++#define __NR_setpgid 154
++#endif
++
++#if !defined(__NR_getpgid)
++#define __NR_getpgid 155
++#endif
++
++#if !defined(__NR_getsid)
++#define __NR_getsid 156
++#endif
++
++#if !defined(__NR_setsid)
++#define __NR_setsid 157
++#endif
++
++#if !defined(__NR_getgroups)
++#define __NR_getgroups 158
++#endif
++
++#if !defined(__NR_setgroups)
++#define __NR_setgroups 159
++#endif
++
++#if !defined(__NR_uname)
++#define __NR_uname 160
++#endif
++
++#if !defined(__NR_sethostname)
++#define __NR_sethostname 161
++#endif
++
++#if !defined(__NR_setdomainname)
++#define __NR_setdomainname 162
++#endif
++
++#if !defined(__NR_getrlimit)
++#define __NR_getrlimit 163
++#endif
++
++#if !defined(__NR_setrlimit)
++#define __NR_setrlimit 164
++#endif
++
++#if !defined(__NR_getrusage)
++#define __NR_getrusage 165
++#endif
++
++#if !defined(__NR_umask)
++#define __NR_umask 166
++#endif
++
++#if !defined(__NR_prctl)
++#define __NR_prctl 167
++#endif
++
++#if !defined(__NR_getcpu)
++#define __NR_getcpu 168
++#endif
++
++#if !defined(__NR_gettimeofday)
++#define __NR_gettimeofday 169
++#endif
++
++#if !defined(__NR_settimeofday)
++#define __NR_settimeofday 170
++#endif
++
++#if !defined(__NR_adjtimex)
++#define __NR_adjtimex 171
++#endif
++
++#if !defined(__NR_getpid)
++#define __NR_getpid 172
++#endif
++
++#if !defined(__NR_getppid)
++#define __NR_getppid 173
++#endif
++
++#if !defined(__NR_getuid)
++#define __NR_getuid 174
++#endif
++
++#if !defined(__NR_geteuid)
++#define __NR_geteuid 175
++#endif
++
++#if !defined(__NR_getgid)
++#define __NR_getgid 176
++#endif
++
++#if !defined(__NR_getegid)
++#define __NR_getegid 177
++#endif
++
++#if !defined(__NR_gettid)
++#define __NR_gettid 178
++#endif
++
++#if !defined(__NR_sysinfo)
++#define __NR_sysinfo 179
++#endif
++
++#if !defined(__NR_mq_open)
++#define __NR_mq_open 180
++#endif
++
++#if !defined(__NR_mq_unlink)
++#define __NR_mq_unlink 181
++#endif
++
++#if !defined(__NR_mq_timedsend)
++#define __NR_mq_timedsend 182
++#endif
++
++#if !defined(__NR_mq_timedreceive)
++#define __NR_mq_timedreceive 183
++#endif
++
++#if !defined(__NR_mq_notify)
++#define __NR_mq_notify 184
++#endif
++
++#if !defined(__NR_mq_getsetattr)
++#define __NR_mq_getsetattr 185
++#endif
++
++#if !defined(__NR_msgget)
++#define __NR_msgget 186
++#endif
++
++#if !defined(__NR_msgctl)
++#define __NR_msgctl 187
++#endif
++
++#if !defined(__NR_msgrcv)
++#define __NR_msgrcv 188
++#endif
++
++#if !defined(__NR_msgsnd)
++#define __NR_msgsnd 189
++#endif
++
++#if !defined(__NR_semget)
++#define __NR_semget 190
++#endif
++
++#if !defined(__NR_semctl)
++#define __NR_semctl 191
++#endif
++
++#if !defined(__NR_semtimedop)
++#define __NR_semtimedop 192
++#endif
++
++#if !defined(__NR_semop)
++#define __NR_semop 193
++#endif
++
++#if !defined(__NR_shmget)
++#define __NR_shmget 194
++#endif
++
++#if !defined(__NR_shmctl)
++#define __NR_shmctl 195
++#endif
++
++#if !defined(__NR_shmat)
++#define __NR_shmat 196
++#endif
++
++#if !defined(__NR_shmdt)
++#define __NR_shmdt 197
++#endif
++
++#if !defined(__NR_socket)
++#define __NR_socket 198
++#endif
++
++#if !defined(__NR_socketpair)
++#define __NR_socketpair 199
++#endif
++
++#if !defined(__NR_bind)
++#define __NR_bind 200
++#endif
++
++#if !defined(__NR_listen)
++#define __NR_listen 201
++#endif
++
++#if !defined(__NR_accept)
++#define __NR_accept 202
++#endif
++
++#if !defined(__NR_connect)
++#define __NR_connect 203
++#endif
++
++#if !defined(__NR_getsockname)
++#define __NR_getsockname 204
++#endif
++
++#if !defined(__NR_getpeername)
++#define __NR_getpeername 205
++#endif
++
++#if !defined(__NR_sendto)
++#define __NR_sendto 206
++#endif
++
++#if !defined(__NR_recvfrom)
++#define __NR_recvfrom 207
++#endif
++
++#if !defined(__NR_setsockopt)
++#define __NR_setsockopt 208
++#endif
++
++#if !defined(__NR_getsockopt)
++#define __NR_getsockopt 209
++#endif
++
++#if !defined(__NR_shutdown)
++#define __NR_shutdown 210
++#endif
++
++#if !defined(__NR_sendmsg)
++#define __NR_sendmsg 211
++#endif
++
++#if !defined(__NR_recvmsg)
++#define __NR_recvmsg 212
++#endif
++
++#if !defined(__NR_readahead)
++#define __NR_readahead 213
++#endif
++
++#if !defined(__NR_brk)
++#define __NR_brk 214
++#endif
++
++#if !defined(__NR_munmap)
++#define __NR_munmap 215
++#endif
++
++#if !defined(__NR_mremap)
++#define __NR_mremap 216
++#endif
++
++#if !defined(__NR_add_key)
++#define __NR_add_key 217
++#endif
++
++#if !defined(__NR_request_key)
++#define __NR_request_key 218
++#endif
++
++#if !defined(__NR_keyctl)
++#define __NR_keyctl 219
++#endif
++
++#if !defined(__NR_clone)
++#define __NR_clone 220
++#endif
++
++#if !defined(__NR_execve)
++#define __NR_execve 221
++#endif
++
++#if !defined(__NR_mmap)
++#define __NR_mmap 222
++#endif
++
++#if !defined(__NR_fadvise64)
++#define __NR_fadvise64 223
++#endif
++
++#if !defined(__NR_swapon)
++#define __NR_swapon 224
++#endif
++
++#if !defined(__NR_swapoff)
++#define __NR_swapoff 225
++#endif
++
++#if !defined(__NR_mprotect)
++#define __NR_mprotect 226
++#endif
++
++#if !defined(__NR_msync)
++#define __NR_msync 227
++#endif
++
++#if !defined(__NR_mlock)
++#define __NR_mlock 228
++#endif
++
++#if !defined(__NR_munlock)
++#define __NR_munlock 229
++#endif
++
++#if !defined(__NR_mlockall)
++#define __NR_mlockall 230
++#endif
++
++#if !defined(__NR_munlockall)
++#define __NR_munlockall 231
++#endif
++
++#if !defined(__NR_mincore)
++#define __NR_mincore 232
++#endif
++
++#if !defined(__NR_madvise)
++#define __NR_madvise 233
++#endif
++
++#if !defined(__NR_remap_file_pages)
++#define __NR_remap_file_pages 234
++#endif
++
++#if !defined(__NR_mbind)
++#define __NR_mbind 235
++#endif
++
++#if !defined(__NR_get_mempolicy)
++#define __NR_get_mempolicy 236
++#endif
++
++#if !defined(__NR_set_mempolicy)
++#define __NR_set_mempolicy 237
++#endif
++
++#if !defined(__NR_migrate_pages)
++#define __NR_migrate_pages 238
++#endif
++
++#if !defined(__NR_move_pages)
++#define __NR_move_pages 239
++#endif
++
++#if !defined(__NR_rt_tgsigqueueinfo)
++#define __NR_rt_tgsigqueueinfo 240
++#endif
++
++#if !defined(__NR_perf_event_open)
++#define __NR_perf_event_open 241
++#endif
++
++#if !defined(__NR_accept4)
++#define __NR_accept4 242
++#endif
++
++#if !defined(__NR_recvmmsg)
++#define __NR_recvmmsg 243
++#endif
++
++#if !defined(__NR_riscv_flush_icache)
++#define __NR_riscv_flush_icache 259
++#endif
++
++#if !defined(__NR_wait4)
++#define __NR_wait4 260
++#endif
++
++#if !defined(__NR_prlimit64)
++#define __NR_prlimit64 261
++#endif
++
++#if !defined(__NR_fanotify_init)
++#define __NR_fanotify_init 262
++#endif
++
++#if !defined(__NR_fanotify_mark)
++#define __NR_fanotify_mark 263
++#endif
++
++#if !defined(__NR_name_to_handle_at)
++#define __NR_name_to_handle_at 264
++#endif
++
++#if !defined(__NR_open_by_handle_at)
++#define __NR_open_by_handle_at 265
++#endif
++
++#if !defined(__NR_clock_adjtime)
++#define __NR_clock_adjtime 266
++#endif
++
++#if !defined(__NR_syncfs)
++#define __NR_syncfs 267
++#endif
++
++#if !defined(__NR_setns)
++#define __NR_setns 268
++#endif
++
++#if !defined(__NR_sendmmsg)
++#define __NR_sendmmsg 269
++#endif
++
++#if !defined(__NR_process_vm_readv)
++#define __NR_process_vm_readv 270
++#endif
++
++#if !defined(__NR_process_vm_writev)
++#define __NR_process_vm_writev 271
++#endif
++
++#if !defined(__NR_kcmp)
++#define __NR_kcmp 272
++#endif
++
++#if !defined(__NR_finit_module)
++#define __NR_finit_module 273
++#endif
++
++#if !defined(__NR_sched_setattr)
++#define __NR_sched_setattr 274
++#endif
++
++#if !defined(__NR_sched_getattr)
++#define __NR_sched_getattr 275
++#endif
++
++#if !defined(__NR_renameat2)
++#define __NR_renameat2 276
++#endif
++
++#if !defined(__NR_seccomp)
++#define __NR_seccomp 277
++#endif
++
++#if !defined(__NR_getrandom)
++#define __NR_getrandom 278
++#endif
++
++#if !defined(__NR_memfd_create)
++#define __NR_memfd_create 279
++#endif
++
++#endif  // SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_
+diff --git a/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc b/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc
+index cd64d06ae39d7..1dad48a7caaed 100644
+--- a/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc
++++ b/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc
+@@ -38,7 +38,7 @@ ResultExpr CrosAmdGpuProcessPolicy::EvaluateSyscall(int sysno) const {
+     case __NR_sched_setscheduler:
+     case __NR_sysinfo:
+     case __NR_uname:
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_readlink:
+     case __NR_stat:
+ #endif
+diff --git a/sandbox/policy/linux/bpf_gpu_policy_linux.cc b/sandbox/policy/linux/bpf_gpu_policy_linux.cc
+index f8df9dcbd9310..4a6287aba2ef5 100644
+--- a/sandbox/policy/linux/bpf_gpu_policy_linux.cc
++++ b/sandbox/policy/linux/bpf_gpu_policy_linux.cc
+@@ -73,7 +73,7 @@ ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const {
+     (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+     case __NR_ftruncate64:
+ #endif
+-#if !defined(__aarch64__)
++#if !defined(__aarch64__) && !defined(__riscv)
+     case __NR_getdents:
+ #endif
+     case __NR_getdents64:
+-- 
+2.25.1
+

+ 2 - 2
0001-sandbox-linux-pass-fPIE-to-compiler.patch → 0002-sandbox-linux-pass-fPIE-to-compiler.patch

@@ -1,7 +1,7 @@
-From 4f8d5c9ad42cd600e10a02182cbab1193fb8480d Mon Sep 17 00:00:00 2001
+From 906b510df263ee0e7a80cff465435d02874cad18 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Thu, 13 Jan 2022 03:50:24 +0000
-Subject: [PATCH 01/21] sandbox: linux: pass -fPIE to compiler
+Subject: [PATCH 02/18] sandbox: linux: pass -fPIE to compiler
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---

+ 2 - 2
0007-skia-add-riscv64.patch → 0003-skia-add-riscv64.patch

@@ -1,7 +1,7 @@
-From 0ea7a288297465ce376db2aee1498fbea0e2545c Mon Sep 17 00:00:00 2001
+From dcb03e933a6e08edcd70ac63a07cd368ba9575d5 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Fri, 14 Jan 2022 01:04:19 +0000
-Subject: [PATCH 07/21] skia: add riscv64
+Subject: [PATCH 03/18] skia: add riscv64
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---

+ 19 - 18
0015-base-add-riscv64-support.patch → 0004-base-allocator-partition_allocator-add-riscv64-suppo.patch

@@ -1,29 +1,30 @@
-From 55530bda5fd6f0a097e32749af3a2d9af792bd11 Mon Sep 17 00:00:00 2001
+From 9b70be10cb461976d6d02922a5d36ae5476720ab Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
-Date: Fri, 14 Jan 2022 07:19:01 +0000
-Subject: [PATCH 15/21] base: add riscv64 support
+Date: Tue, 5 Apr 2022 02:22:48 +0000
+Subject: [PATCH 04/18] base: allocator: partition_allocator: add riscv64
+ support
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---
- base/BUILD.gn                                 |  3 ++
+ base/allocator/partition_allocator/BUILD.gn   |  3 ++
  .../stack/asm/riscv64/push_registers_asm.cc   | 51 +++++++++++++++++++
  2 files changed, 54 insertions(+)
  create mode 100644 base/allocator/partition_allocator/starscan/stack/asm/riscv64/push_registers_asm.cc
 
-diff --git a/base/BUILD.gn b/base/BUILD.gn
-index 4b4eb78065434..a079370d93dbd 100644
---- a/base/BUILD.gn
-+++ b/base/BUILD.gn
-@@ -2119,6 +2119,9 @@ mixed_component("base") {
-       } else if (current_cpu == "arm64") {
-         defines += [ "PA_PCSCAN_STACK_SUPPORTED" ]
-         sources += [ "allocator/partition_allocator/starscan/stack/asm/arm64/push_registers_asm.cc" ]
-+      } else if (current_cpu == "riscv64") {
-+        defines += [ "PA_PCSCAN_STACK_SUPPORTED" ]
-+        sources += [ "allocator/partition_allocator/starscan/stack/asm/riscv64/push_registers_asm.cc" ]
-       } else {
-         # To support a trampoline for another arch, please refer to v8/src/heap/base.
-       }
+diff --git a/base/allocator/partition_allocator/BUILD.gn b/base/allocator/partition_allocator/BUILD.gn
+index 907f3435d5b2c..444ffd18ae32f 100644
+--- a/base/allocator/partition_allocator/BUILD.gn
++++ b/base/allocator/partition_allocator/BUILD.gn
+@@ -160,6 +160,9 @@ target(partition_alloc_target_type, "partition_alloc") {
+   } else if (current_cpu == "arm64") {
+     defines += [ "PA_PCSCAN_STACK_SUPPORTED" ]
+     sources += [ "starscan/stack/asm/arm64/push_registers_asm.cc" ]
++  } else if (current_cpu == "riscv64") {
++    defines += [ "PA_PCSCAN_STACK_SUPPORTED" ]
++    sources += [ "allocator/partition_allocator/starscan/stack/asm/riscv64/push_registers_asm.cc" ]
+   } else {
+     # To support a trampoline for another arch, please refer to v8/src/heap/base.
+   }
 diff --git a/base/allocator/partition_allocator/starscan/stack/asm/riscv64/push_registers_asm.cc b/base/allocator/partition_allocator/starscan/stack/asm/riscv64/push_registers_asm.cc
 new file mode 100644
 index 0000000000000..2d90aab182988

+ 26 - 0
0005-base-process-add-riscv64-arch-definition.patch

@@ -0,0 +1,26 @@
+From 5926c534338961fd9b431ca00bba3b0abd4f85ba Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 30 Mar 2022 05:44:17 +0000
+Subject: [PATCH 05/18] base: process: add riscv64 arch definition
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ base/process/launch_posix.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc
+index 5130a0baa2c7d..add3ca595da80 100644
+--- a/base/process/launch_posix.cc
++++ b/base/process/launch_posix.cc
+@@ -707,7 +707,7 @@ NOINLINE pid_t CloneAndLongjmpInChild(unsigned long flags,
+   alignas(16) char stack_buf[PTHREAD_STACK_MIN];
+ #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) ||   \
+     defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_S390_FAMILY) || \
+-    defined(ARCH_CPU_PPC64_FAMILY)
++    defined(ARCH_CPU_PPC64_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY)
+   // The stack grows downward.
+   void* stack = stack_buf + sizeof(stack_buf);
+ #else
+-- 
+2.25.1
+

+ 2 - 2
0005-remoting-fix-missing-cstring-header.patch → 0006-remoting-fix-missing-cstring-header.patch

@@ -1,7 +1,7 @@
-From a4362673d7e8b4d57fbfcf7f176fc6ddcf82ec07 Mon Sep 17 00:00:00 2001
+From af73ddaaeb31c115b77bf372095f611ff88e8b48 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Thu, 13 Jan 2022 09:44:47 +0000
-Subject: [PATCH 05/21] remoting: fix missing cstring header
+Subject: [PATCH 06/18] remoting: fix missing cstring header
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---

+ 2 - 2
0006-remoting-codec-fix-missing-cmath-header.patch → 0007-remoting-codec-fix-missing-cmath-header.patch

@@ -1,7 +1,7 @@
-From bf5cc6ce5c47055e3dc52bfa459e861ae12a4f8f Mon Sep 17 00:00:00 2001
+From 7ac90a17331f7deb62c7f52988f400957ce29e64 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Thu, 13 Jan 2022 09:48:12 +0000
-Subject: [PATCH 06/21] remoting: codec: fix missing cmath header
+Subject: [PATCH 07/18] remoting: codec: fix missing cmath header
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---

+ 0 - 36
0008-build-config-sysroot.gni-add-path-to-riscv64-sysroot.patch

@@ -1,36 +0,0 @@
-From af6aebb4c9d7ed96571e97441ded89b34c67a327 Mon Sep 17 00:00:00 2001
-From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
-Date: Fri, 14 Jan 2022 02:31:49 +0000
-Subject: [PATCH 08/21] build: config: sysroot.gni: add path to riscv64 sysroot
-
-Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
----
- build/config/sysroot.gni | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni
-index 18d2d573627c8..4f8fa88a50b86 100644
---- a/build/config/sysroot.gni
-+++ b/build/config/sysroot.gni
-@@ -23,7 +23,8 @@ declare_args() {
-   # is empty, default sysroot is calculated.
-   use_sysroot = 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"
- }
- 
- if (sysroot == "") {
-@@ -50,6 +51,8 @@ if (sysroot == "") {
-       sysroot = "$target_sysroot_dir/debian_sid_arm-sysroot"
-     } else if (current_cpu == "arm64") {
-       sysroot = "$target_sysroot_dir/debian_sid_arm64-sysroot"
-+    } else if (current_cpu == "riscv64") {
-+      sysroot = "$target_sysroot_dir/debian_sid_riscv64-sysroot"
-     } else {
-       assert(false, "No linux sysroot for cpu: $target_cpu")
-     }
--- 
-2.25.1
-

+ 49 - 0
0008-components-update_client-add-riscv64-arch-definition.patch

@@ -0,0 +1,49 @@
+From c9cd7b934cd2fe7583a9fa5e671559d99cfc3249 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Tue, 5 Apr 2022 02:27:27 +0000
+Subject: [PATCH 08/18] components: update_client: add riscv64 arch definition
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ components/update_client/update_query_params.cc | 4 ++++
+ components/update_client/update_query_params.h  | 2 +-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/components/update_client/update_query_params.cc b/components/update_client/update_query_params.cc
+index a36b56d307976..4b2cf052246d4 100644
+--- a/components/update_client/update_query_params.cc
++++ b/components/update_client/update_query_params.cc
+@@ -63,6 +63,8 @@ const char kArch[] =
+     "loong32";
+ #elif defined(__loongarch64)
+     "loong64";
++#elif defined(__riscv) && (__riscv_xlen == 64)
++    "riscv64";
+ #else
+ #error "unknown arch"
+ #endif
+@@ -138,6 +140,8 @@ const char* UpdateQueryParams::GetNaclArch() {
+   return "loong32";
+ #elif defined(ARCH_CPU_LOONG64)
+   return "loong64";
++#elif defined(ARCH_CPU_RISCV64)
++  return "riscv64";
+ #else
+ // NOTE: when adding new values here, please remember to update the
+ // comment in the .h file about possible return values from this function.
+diff --git a/components/update_client/update_query_params.h b/components/update_client/update_query_params.h
+index a22f8b85bc0d9..969582bf92289 100644
+--- a/components/update_client/update_query_params.h
++++ b/components/update_client/update_query_params.h
+@@ -44,7 +44,7 @@ class UpdateQueryParams {
+   // Returns the value we use for the "nacl_arch" parameter. Note that this may
+   // be different from the "arch" parameter above (e.g. one may be 32-bit and
+   // the other 64-bit). Possible return values include: "x86-32", "x86-64",
+-  // "arm", "mips32", and "ppc64".
++  // "arm", "mips32", "ppc64", and "riscv64".
+   static const char* GetNaclArch();
+ 
+   // Returns the current version of Chrome/Chromium.
+-- 
+2.25.1
+

+ 4 - 4
0017-build-config-compiler-use_gold-linker-option.patch → 0009-build-config-compiler-use_gold-linker-option.patch

@@ -1,7 +1,7 @@
-From d593966fb993cc332c94ba73cfcbc98bf62eb22c Mon Sep 17 00:00:00 2001
+From 113b3389d4a9b3f596810a6d0b6e581cdc354e41 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Mon, 17 Jan 2022 04:48:24 +0000
-Subject: [PATCH 17/21] build: config: compiler: use_gold linker option
+Subject: [PATCH 09/18] build: config: compiler: use_gold linker option
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---
@@ -9,10 +9,10 @@ Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni
-index 9d25c10587c7a..5b8e946bbebd2 100644
+index 590bfc5da5ebb..4664363ab1a6a 100644
 --- a/build/config/compiler/compiler.gni
 +++ b/build/config/compiler/compiler.gni
-@@ -230,7 +230,7 @@ declare_args() {
+@@ -229,7 +229,7 @@ declare_args() {
               (((is_linux || is_chromeos_lacros) &&
                 (current_cpu == "x64" || current_cpu == "x86" ||
                  current_cpu == "arm" || current_cpu == "arm64" ||

+ 8 - 8
0020-build-config-compiler-remove-flags-not-available-in-.patch → 0010-build-config-compiler-remove-flags-not-available-in-.patch

@@ -1,7 +1,7 @@
-From 0bd78278a33511057888656d3221f552fc09c70a Mon Sep 17 00:00:00 2001
+From 1c5f889f1b11f01e66869eb99cab5e9a45894519 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Mon, 17 Jan 2022 08:15:52 +0000
-Subject: [PATCH 20/21] build: config: compiler: remove flags not available in
+Subject: [PATCH 10/18] build: config: compiler: remove flags not available in
  custom clang
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
@@ -10,10 +10,10 @@ Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  1 file changed, 13 deletions(-)
 
 diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
-index 9af6b9b08eb02..e227fdb641504 100644
+index a58b27f1a4ff3..2c8cfdaf3fee2 100644
 --- a/build/config/compiler/BUILD.gn
 +++ b/build/config/compiler/BUILD.gn
-@@ -349,7 +349,6 @@ config("compiler") {
+@@ -348,7 +348,6 @@ config("compiler") {
      }
  
      if (use_lld) {
@@ -21,7 +21,7 @@ index 9af6b9b08eb02..e227fdb641504 100644
        if (lld_path != "") {
          ldflags += [ "-B$lld_path" ]
        }
-@@ -482,10 +481,6 @@ config("compiler") {
+@@ -481,10 +480,6 @@ config("compiler") {
      #}
    }
  
@@ -32,7 +32,7 @@ index 9af6b9b08eb02..e227fdb641504 100644
    if (is_linux || is_chromeos) {
      cflags += [ "-pthread" ]
      # Do not use the -pthread ldflag here since it becomes a no-op
-@@ -496,8 +491,6 @@ config("compiler") {
+@@ -495,8 +490,6 @@ config("compiler") {
    # Clang-specific compiler flags setup.
    # ------------------------------------
    if (is_clang) {
@@ -41,7 +41,7 @@ index 9af6b9b08eb02..e227fdb641504 100644
      # Enable -fmerge-all-constants. This used to be the default in clang
      # for over a decade. It makes clang non-conforming, but is fairly safe
      # in practice and saves some binary size. We might want to consider
-@@ -515,8 +508,6 @@ config("compiler") {
+@@ -514,8 +507,6 @@ config("compiler") {
        # On Windows, we call the linker directly, instead of calling it through
        # the driver.
        ldflags += [ "--color-diagnostics" ]
@@ -50,7 +50,7 @@ index 9af6b9b08eb02..e227fdb641504 100644
      }
    }
  
-@@ -754,10 +745,6 @@ config("compiler") {
+@@ -753,10 +744,6 @@ config("compiler") {
    if (use_lld && !enable_call_graph_profile_sort) {
      if (is_win) {
        ldflags += [ "/call-graph-profile-sort:no" ]

+ 0 - 36
0010-build-config-posix-do-not-recompile-sysroot.patch

@@ -1,36 +0,0 @@
-From 5b54cebde869c74e2784d0b84d4fb8c471e05eb2 Mon Sep 17 00:00:00 2001
-From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
-Date: Fri, 14 Jan 2022 04:17:31 +0000
-Subject: [PATCH 10/21] build: config: posix: do not recompile sysroot
-
-Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
----
- build/config/posix/BUILD.gn | 12 ------------
- 1 file changed, 12 deletions(-)
-
-diff --git a/build/config/posix/BUILD.gn b/build/config/posix/BUILD.gn
-index 5d15163875717..3e0ded398ced3 100644
---- a/build/config/posix/BUILD.gn
-+++ b/build/config/posix/BUILD.gn
-@@ -28,18 +28,6 @@ config("runtime_library") {
-   if (!is_apple && sysroot != "" && current_os != "zos") {
-     # Pass the sysroot to all C compiler variants, the assembler, and linker.
-     sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
--    if (is_linux || is_chromeos) {
--      # This is here so that all files get recompiled after a sysroot roll and
--      # when turning the sysroot on or off. (defines are passed via the command
--      # line, and build system rebuilds things when their commandline
--      # changes). Nothing should ever read this define.
--      sysroot_hash =
--          exec_script("//build/linux/sysroot_scripts/install-sysroot.py",
--                      [ "--print-hash=$current_cpu" ],
--                      "trim string",
--                      [ "//build/linux/sysroot_scripts/sysroots.json" ])
--      defines += [ "CR_SYSROOT_HASH=$sysroot_hash" ]
--    }
-     asmflags += sysroot_flags
-     ldflags += sysroot_flags
- 
--- 
-2.25.1
-

+ 25 - 0
0011-build-config-add-atomic-build-flag.patch

@@ -0,0 +1,25 @@
+From d0971334579208f77a8d17b5e706d52463e0bbfc Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 30 Mar 2022 05:43:35 +0000
+Subject: [PATCH 11/18] build: config: add atomic build flag
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/config/BUILD.gn | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn
+index 79f1b1aebe9a5..627b01b3c9859 100644
+--- a/build/config/BUILD.gn
++++ b/build/config/BUILD.gn
+@@ -223,6 +223,7 @@ config("default_libs") {
+       "dl",
+       "pthread",
+       "rt",
++      "atomic",
+     ]
+   }
+ }
+-- 
+2.25.1
+

+ 4 - 4
0011-build-config-compiler-set-generic-riscv64-flags.patch → 0012-build-config-compiler-set-generic-riscv64-flags.patch

@@ -1,7 +1,7 @@
-From 46ae096bcc8291c6254f2a3d26860435b855a864 Mon Sep 17 00:00:00 2001
+From f6669b0988f1e40e2cfa0b58fb1e2bccd2af42ab Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Fri, 14 Jan 2022 05:06:56 +0000
-Subject: [PATCH 11/21] build: config: compiler: set generic riscv64 flags
+Subject: [PATCH 12/18] build: config: compiler: set generic riscv64 flags
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---
@@ -9,10 +9,10 @@ Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  1 file changed, 6 insertions(+)
 
 diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
-index 0becd54d0728d..9af6b9b08eb02 100644
+index 2c8cfdaf3fee2..8b751c25f2229 100644
 --- a/build/config/compiler/BUILD.gn
 +++ b/build/config/compiler/BUILD.gn
-@@ -1171,6 +1171,12 @@ config("compiler_cpu_abi") {
+@@ -1157,6 +1157,12 @@ config("compiler_cpu_abi") {
          cflags += [ "-m64" ]
          ldflags += [ "-m64" ]
        }

+ 7 - 3
0003-chrome-common-remove-unrar-code.patch → 0013-chrome-common-remove-unrar-code.patch

@@ -1,9 +1,13 @@
-From b23cd494cf595e793e55107710630d1579af4dfa Mon Sep 17 00:00:00 2001
+From 34238a406f7c1d40b18b782faf5b1c2855f44107 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Thu, 13 Jan 2022 08:57:34 +0000
-Subject: [PATCH 03/21] chrome: common: remove unrar code
+Subject: [PATCH 13/18] chrome: common: remove unrar code
 
-unrar code is non-free.
+Upstream-status: Inappropriate
+
+unrar code is non-free. This might not be suitable for
+distributing as third_party. Hence we disabled it from
+our build.
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---

+ 26 - 0
0014-third_party-libaom-add-riscv-target.patch

@@ -0,0 +1,26 @@
+From cc46f13f10f3ddb0f3bb28d331cbd31dc0f3d397 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 30 Mar 2022 11:24:25 +0000
+Subject: [PATCH 14/18] third_party: libaom: add riscv target
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ third_party/libaom/BUILD.gn | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/third_party/libaom/BUILD.gn b/third_party/libaom/BUILD.gn
+index 49dbee305c6d5..4f5b56c7e7f0e 100644
+--- a/third_party/libaom/BUILD.gn
++++ b/third_party/libaom/BUILD.gn
+@@ -36,6 +36,8 @@ if (current_cpu == "x86") {
+   } else {
+     cpu_arch_full = "arm"
+   }
++} else if (current_cpu == "riscv64") {
++  cpu_arch_full = "generic"
+ } else {
+   cpu_arch_full = current_cpu
+ }
+-- 
+2.25.1
+

+ 35 - 0
0015-third_party-libvpx-add-riscv-target.patch

@@ -0,0 +1,35 @@
+From 855953bb289158cdd372eb138990d1bca4ca851d Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 30 Mar 2022 11:26:18 +0000
+Subject: [PATCH 15/18] third_party: libvpx: add riscv target
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ third_party/libvpx/BUILD.gn | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/third_party/libvpx/BUILD.gn b/third_party/libvpx/BUILD.gn
+index 758aca1540734..e7f9895ea48a1 100644
+--- a/third_party/libvpx/BUILD.gn
++++ b/third_party/libvpx/BUILD.gn
+@@ -35,6 +35,8 @@ if (current_cpu == "x86") {
+   } else {
+     cpu_arch_full = current_cpu
+   }
++} else if (current_cpu == "riscv64") {
++  cpu_arch_full = "generic"
+ } else {
+   cpu_arch_full = current_cpu
+ }
+@@ -360,7 +362,7 @@ static_library("libvpx") {
+     configs += [ "//build/config/compiler:optimize_max" ]
+   }
+ 
+-  if (is_nacl) {
++  if (is_nacl || current_cpu == "riscv64") {
+     sources = libvpx_srcs_generic
+     public_deps = [ ":libvpx_generic_headers" ]
+   } else if (current_cpu == "x86") {
+-- 
+2.25.1
+

+ 808 - 0
0016-third_party-crashpad-add-support-for-riscv.patch

@@ -0,0 +1,808 @@
+From d95a14331f87a8a389d35cc896a6ab30206b3f9f Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Thu, 31 Mar 2022 00:35:10 +0000
+Subject: [PATCH 16/18] third_party: crashpad: add support for riscv
+
+Credit to work contributed in Github.
+https://github.com/felixonmars/archriscv-packages/tree/master/chromium
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ .../crashpad/minidump/minidump_context.h      | 35 +++++++++
+ .../minidump/minidump_context_writer.cc       | 44 +++++++++++
+ .../minidump/minidump_context_writer.h        | 41 ++++++++++
+ .../minidump/minidump_misc_info_writer.cc     |  4 +
+ .../crashpad/snapshot/capture_memory.cc       | 10 +++
+ .../crashpad/snapshot/cpu_architecture.h      |  8 +-
+ .../crashpad/crashpad/snapshot/cpu_context.cc |  2 +
+ .../crashpad/crashpad/snapshot/cpu_context.h  | 16 ++++
+ .../snapshot/linux/cpu_context_linux.cc       | 24 ++++++
+ .../snapshot/linux/cpu_context_linux.h        | 16 ++++
+ .../linux/exception_snapshot_linux.cc         | 55 +++++++++++++
+ .../snapshot/linux/exception_snapshot_linux.h |  3 +
+ .../snapshot/linux/process_reader_linux.cc    |  3 +
+ .../crashpad/snapshot/linux/signal_context.h  | 61 +++++++++++++++
+ .../snapshot/linux/system_snapshot_linux.cc   | 12 +++
+ .../snapshot/linux/thread_snapshot_linux.cc   | 16 ++++
+ .../snapshot/linux/thread_snapshot_linux.h    |  3 +
+ .../crashpad/crashpad/util/linux/ptracer.cc   | 44 +++++++++++
+ .../crashpad/util/linux/thread_info.h         | 78 ++++++++++++++++++-
+ .../util/net/http_transport_libcurl.cc        |  2 +
+ 20 files changed, 475 insertions(+), 2 deletions(-)
+
+diff --git a/third_party/crashpad/crashpad/minidump/minidump_context.h b/third_party/crashpad/crashpad/minidump/minidump_context.h
+index 3a3e603cb0d2d..cf074d2b8236b 100644
+--- a/third_party/crashpad/crashpad/minidump/minidump_context.h
++++ b/third_party/crashpad/crashpad/minidump/minidump_context.h
+@@ -592,6 +592,41 @@ struct MinidumpContextMIPS64 {
+   uint64_t fir;
+ };
+ 
++//! \brief 64bit RISC-V-specifc flags for MinidumpContextRISCV64::context_flags.
++//! Based on minidump_cpu_riscv64.h from breakpad
++enum MinidumpContextRISCV64Flags : uint32_t {
++  //! \brief Identifies the context structure as RISCV64.
++  kMinidumpContextRISCV64 = 0x00080000,
++
++  //! \brief Indicates the validity of integer registers.
++  //!
++  //! Registers `x1`-`x31` and pc are valid.
++  kMinidumpContextRISCV64Integer = kMinidumpContextRISCV64 | 0x00000002,
++
++  //! \brief Indicates the validity of floating point registers.
++  //!
++  //! Floating point registers `f0`-`f31`, and `fcsr` are valid
++  kMinidumpContextRISCV64FloatingPoint = kMinidumpContextRISCV64 | 0x00000004,
++
++  //! \brief Indicates the validity of all registers.
++  kMinidumpContextRISCV64All = kMinidumpContextRISCV64Integer |
++                              kMinidumpContextRISCV64FloatingPoint,
++};
++
++//! \brief A 64bit RISCV CPU context (register state) carried in a minidump file.
++struct MinidumpContextRISCV64 {
++  uint64_t context_flags;
++
++  //! \brief General purpose registers.
++  uint64_t regs[32];
++
++  //! \brief FPU registers.
++  uint64_t fpregs[32];
++
++  //! \brief FPU status register.
++  uint64_t fcsr;
++};
++
+ }  // namespace crashpad
+ 
+ #endif  // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
+diff --git a/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc b/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
+index 2f2d90ba47071..ad26739432f51 100644
+--- a/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
++++ b/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
+@@ -102,6 +102,13 @@ MinidumpContextWriter::CreateFromSnapshot(const CPUContext* context_snapshot) {
+       break;
+     }
+ 
++    case kCPUArchitectureRISCV64: {
++      context = std::make_unique<MinidumpContextRISCV64Writer>();
++      reinterpret_cast<MinidumpContextRISCV64Writer*>(context.get())
++          ->InitializeFromSnapshot(context_snapshot->riscv64);
++      break;
++    }
++
+     default: {
+       LOG(ERROR) << "unknown context architecture "
+                  << context_snapshot->architecture;
+@@ -454,4 +461,41 @@ size_t MinidumpContextMIPS64Writer::ContextSize() const {
+   return sizeof(context_);
+ }
+ 
++MinidumpContextRISCV64Writer::MinidumpContextRISCV64Writer()
++    : MinidumpContextWriter(), context_() {
++  context_.context_flags = kMinidumpContextRISCV64;
++}
++
++MinidumpContextRISCV64Writer::~MinidumpContextRISCV64Writer() = default;
++
++void MinidumpContextRISCV64Writer::InitializeFromSnapshot(
++    const CPUContextRISCV64* context_snapshot) {
++  DCHECK_EQ(state(), kStateMutable);
++  DCHECK_EQ(context_.context_flags, kMinidumpContextRISCV64);
++
++  context_.context_flags = kMinidumpContextRISCV64All;
++
++  static_assert(sizeof(context_.regs) == sizeof(context_snapshot->regs),
++                "GPRs size mismatch");
++  memcpy(context_.regs, context_snapshot->regs, sizeof(context_.regs));
++
++  static_assert(sizeof(context_.fpregs) == sizeof(context_snapshot->fpregs),
++                "FPRs size mismatch");
++  memcpy(context_.fpregs,
++         context_snapshot->fpregs,
++         sizeof(context_.fpregs));
++  context_.fcsr = context_snapshot->fcsr;
++}
++
++bool MinidumpContextRISCV64Writer::WriteObject(
++    FileWriterInterface* file_writer) {
++  DCHECK_EQ(state(), kStateWritable);
++  return file_writer->Write(&context_, sizeof(context_));
++}
++
++size_t MinidumpContextRISCV64Writer::ContextSize() const {
++  DCHECK_GE(state(), kStateFrozen);
++  return sizeof(context_);
++}
++
+ }  // namespace crashpad
+diff --git a/third_party/crashpad/crashpad/minidump/minidump_context_writer.h b/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
+index 80b312b23c2a4..278830085c162 100644
+--- a/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
++++ b/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
+@@ -330,6 +330,47 @@ class MinidumpContextMIPS64Writer final : public MinidumpContextWriter {
+   MinidumpContextMIPS64 context_;
+ };
+ 
++//! \brief The writer for a MinidumpContextRISCV64 structure in a minidump file.
++class MinidumpContextRISCV64Writer final : public MinidumpContextWriter {
++ public:
++  MinidumpContextRISCV64Writer();
++  ~MinidumpContextRISCV64Writer() override;
++
++  MinidumpContextRISCV64Writer(const MinidumpContextRISCV64Writer&) = delete;
++  void operator=(const MinidumpContextRISCV64Writer&) = delete;
++
++  //! \brief Initializes the MinidumpContextRISCV based on \a context_snapshot.
++  //!
++  //! \param[in] context_snapshot The context snapshot to use as source data.
++  //!
++  //! \note Valid in #kStateMutable. No mutation of context() may be done before
++  //!     calling this method, and it is not normally necessary to alter
++  //!     context() after calling this method.
++  void InitializeFromSnapshot(const CPUContextRISCV64* context_snapshot);
++
++  //! \brief Returns a pointer to the context structure that this object will
++  //!     write.
++  //!
++  //! \attention This returns a non-`const` pointer to this object’s private
++  //!     data so that a caller can populate the context structure directly.
++  //!     This is done because providing setter interfaces to each field in the
++  //!     context structure would be unwieldy and cumbersome. Care must be taken
++  //!     to populate the context structure correctly. The context structure
++  //!     must only be modified while this object is in the #kStateMutable
++  //!     state.
++  MinidumpContextRISCV64* context() { return &context_; }
++
++ protected:
++  // MinidumpWritable:
++  bool WriteObject(FileWriterInterface* file_writer) override;
++
++  // MinidumpContextWriter:
++  size_t ContextSize() const override;
++
++ private:
++  MinidumpContextRISCV64 context_;
++};
++
+ }  // namespace crashpad
+ 
+ #endif  // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_WRITER_H_
+diff --git a/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc b/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
+index 78847c11970e5..b2a1486dfbbf0 100644
+--- a/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
++++ b/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
+@@ -135,6 +135,10 @@ std::string MinidumpMiscInfoDebugBuildString() {
+   static constexpr char kCPU[] = "mips";
+ #elif defined(ARCH_CPU_MIPS64EL)
+   static constexpr char kCPU[] = "mips64";
++#elif defined(ARCH_CPU_RISCV)
++  static constexpr char kCPU[] = "riscv";
++#elif defined(ARCH_CPU_RISCV64)
++  static constexpr char kCPU[] = "riscv64";
+ #else
+ #error define kCPU for this CPU
+ #endif
+diff --git a/third_party/crashpad/crashpad/snapshot/capture_memory.cc b/third_party/crashpad/crashpad/snapshot/capture_memory.cc
+index 06d92581330bf..a8b52d11b9b53 100644
+--- a/third_party/crashpad/crashpad/snapshot/capture_memory.cc
++++ b/third_party/crashpad/crashpad/snapshot/capture_memory.cc
+@@ -112,6 +112,16 @@ void CaptureMemory::PointedToByContext(const CPUContext& context,
+   for (size_t i = 0; i < std::size(context.mipsel->regs); ++i) {
+     MaybeCaptureMemoryAround(delegate, context.mipsel->regs[i]);
+   }
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++  if (context.architecture == kCPUArchitectureRISCV) {
++    for (size_t i = 0; i < base::size(context.riscv->regs); ++i) {
++      MaybeCaptureMemoryAround(delegate, context.riscv->regs[i]);
++    }
++  } else {
++    for (size_t i = 0; i < base::size(context.riscv64->regs); ++i) {
++      MaybeCaptureMemoryAround(delegate, context.riscv64->regs[i]);
++    }
++  }
+ #else
+ #error Port.
+ #endif
+diff --git a/third_party/crashpad/crashpad/snapshot/cpu_architecture.h b/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
+index 811a7209587d2..5b09abdb96761 100644
+--- a/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
++++ b/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
+@@ -43,7 +43,13 @@ enum CPUArchitecture {
+   kCPUArchitectureMIPSEL,
+ 
+   //! \brief 64-bit MIPSEL.
+-  kCPUArchitectureMIPS64EL
++  kCPUArchitectureMIPS64EL,
++
++  //! \brief 32-bit RISCV.
++  kCPUArchitectureRISCV,
++
++  //! \brief 64-bit RISCV.
++  kCPUArchitectureRISCV64
+ };
+ 
+ }  // namespace crashpad
+diff --git a/third_party/crashpad/crashpad/snapshot/cpu_context.cc b/third_party/crashpad/crashpad/snapshot/cpu_context.cc
+index 2e29f70398c9f..e2f8097e2cae1 100644
+--- a/third_party/crashpad/crashpad/snapshot/cpu_context.cc
++++ b/third_party/crashpad/crashpad/snapshot/cpu_context.cc
+@@ -197,10 +197,12 @@ bool CPUContext::Is64Bit() const {
+     case kCPUArchitectureX86_64:
+     case kCPUArchitectureARM64:
+     case kCPUArchitectureMIPS64EL:
++    case kCPUArchitectureRISCV64:
+       return true;
+     case kCPUArchitectureX86:
+     case kCPUArchitectureARM:
+     case kCPUArchitectureMIPSEL:
++    case kCPUArchitectureRISCV:
+       return false;
+     default:
+       NOTREACHED();
+diff --git a/third_party/crashpad/crashpad/snapshot/cpu_context.h b/third_party/crashpad/crashpad/snapshot/cpu_context.h
+index fb23c4679f0af..e120a980448d6 100644
+--- a/third_party/crashpad/crashpad/snapshot/cpu_context.h
++++ b/third_party/crashpad/crashpad/snapshot/cpu_context.h
+@@ -352,6 +352,20 @@ struct CPUContextMIPS64 {
+   uint64_t fir;
+ };
+ 
++//! \brief A context structure carrying RISC CPU state.
++struct CPUContextRISCV {
++  uint32_t regs[32];
++  uint64_t fpregs[32];
++  uint32_t fcsr;
++};
++
++//! \brief A context structure carrying RISC64 CPU state.
++struct CPUContextRISCV64 {
++  uint64_t regs[32];
++  uint64_t fpregs[32];
++  uint32_t fcsr;
++};
++
+ //! \brief A context structure capable of carrying the context of any supported
+ //!     CPU architecture.
+ struct CPUContext {
+@@ -382,6 +396,8 @@ struct CPUContext {
+     CPUContextARM64* arm64;
+     CPUContextMIPS* mipsel;
+     CPUContextMIPS64* mips64;
++    CPUContextRISCV* riscv;
++    CPUContextRISCV64* riscv64;
+   };
+ };
+ 
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc b/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
+index 8464a5a27b2dc..ec41216daa902 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
++++ b/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
+@@ -266,6 +266,30 @@ void InitializeCPUContextARM64_OnlyFPSIMD(
+   context->fpcr = float_context.fpcr;
+ }
+ 
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++
++template <typename Traits>
++void InitializeCPUContextRISCV(
++    const typename Traits::SignalThreadContext& thread_context,
++    const typename Traits::SignalFloatContext& float_context,
++    typename Traits::CPUContext* context) {
++  static_assert(sizeof(context->regs) == sizeof(thread_context),
++                "registers size mismatch");
++  static_assert(sizeof(context->fpregs) == sizeof(float_context.f),
++                "fp registers size mismatch");
++  memcpy(&context->regs, &thread_context, sizeof(context->regs));
++  memcpy(&context->fpregs, &float_context, sizeof(context->fpregs));
++  context->fcsr = float_context.fcsr;
++}
++template void InitializeCPUContextRISCV<ContextTraits32>(
++    const ContextTraits32::SignalThreadContext& thread_context,
++    const ContextTraits32::SignalFloatContext& float_context,
++    ContextTraits32::CPUContext* context);
++template void InitializeCPUContextRISCV<ContextTraits64>(
++    const ContextTraits64::SignalThreadContext& thread_context,
++    const ContextTraits64::SignalFloatContext& float_context,
++    ContextTraits64::CPUContext* context);
++
+ #endif  // ARCH_CPU_X86_FAMILY
+ 
+ }  // namespace internal
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h b/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
+index 9f46a48977e12..1add07f81af88 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
++++ b/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
+@@ -174,6 +174,22 @@ void InitializeCPUContextMIPS(
+ 
+ #endif  // ARCH_CPU_MIPS_FAMILY || DOXYGEN
+ 
++#if defined(ARCH_CPU_RISCV_FAMILY) || DOXYGEN
++
++//! \brief Initializes a CPUContextRISCV structure from native context
++//!     structures on Linux.
++//!
++//! \param[in] thread_context The native thread context.
++//! \param[in] float_context The native float context.
++//! \param[out] context The CPUContextRISCV structure to initialize.
++template <typename Traits>
++void InitializeCPUContextRISCV(
++    const typename Traits::SignalThreadContext& thread_context,
++    const typename Traits::SignalFloatContext& float_context,
++    typename Traits::CPUContext* context);
++
++#endif  // ARCH_CPU_RISCV_FAMILY || DOXYGEN
++
+ }  // namespace internal
+ }  // namespace crashpad
+ 
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc b/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
+index efc9e5694ea8b..3d57d96756208 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
++++ b/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
+@@ -325,6 +325,61 @@ bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
+       reader, context_address, context_.mips64);
+ }
+ 
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++
++template <typename Traits>
++static bool ReadContext(ProcessReaderLinux* reader,
++                        LinuxVMAddress context_address,
++                        typename Traits::CPUContext* dest_context) {
++  const ProcessMemory* memory = reader->Memory();
++
++  LinuxVMAddress gregs_address = context_address +
++                                 offsetof(UContext<Traits>, mcontext) +
++                                 offsetof(typename Traits::MContext, gregs);
++
++  typename Traits::SignalThreadContext thread_context;
++  if (!memory->Read(gregs_address, sizeof(thread_context), &thread_context)) {
++    LOG(ERROR) << "Couldn't read gregs";
++    return false;
++  }
++
++  LinuxVMAddress fpregs_address = context_address +
++                                  offsetof(UContext<Traits>, mcontext) +
++                                  offsetof(typename Traits::MContext, fpregs);
++
++  typename Traits::SignalFloatContext fp_context;
++  if (!memory->Read(fpregs_address, sizeof(fp_context), &fp_context)) {
++    LOG(ERROR) << "Couldn't read fpregs";
++    return false;
++  }
++
++  InitializeCPUContextRISCV<Traits>(thread_context, fp_context, dest_context);
++
++  return true;
++}
++
++template <>
++bool ExceptionSnapshotLinux::ReadContext<ContextTraits32>(
++    ProcessReaderLinux* reader,
++    LinuxVMAddress context_address) {
++  context_.architecture = kCPUArchitectureRISCV;
++  context_.riscv = &context_union_.riscv;
++
++  return internal::ReadContext<ContextTraits32>(
++      reader, context_address, context_.riscv);
++}
++
++template <>
++bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
++    ProcessReaderLinux* reader,
++    LinuxVMAddress context_address) {
++  context_.architecture = kCPUArchitectureRISCV64;
++  context_.riscv64 = &context_union_.riscv64;
++
++  return internal::ReadContext<ContextTraits64>(
++      reader, context_address, context_.riscv64);
++}
++
+ #endif  // ARCH_CPU_X86_FAMILY
+ 
+ bool ExceptionSnapshotLinux::Initialize(
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h b/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
+index 05f6004e11d1e..0520af4ce9019 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
++++ b/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
+@@ -89,6 +89,9 @@ class ExceptionSnapshotLinux final : public ExceptionSnapshot {
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+     CPUContextMIPS mipsel;
+     CPUContextMIPS64 mips64;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++    CPUContextRISCV riscv;
++    CPUContextRISCV64 riscv64;
+ #endif
+   } context_union_;
+   CPUContext context_;
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc b/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
+index 5711f343a46c4..abbb1662c3e0a 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
++++ b/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
+@@ -108,6 +108,9 @@ void ProcessReaderLinux::Thread::InitializeStack(ProcessReaderLinux* reader) {
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+   stack_pointer = reader->Is64Bit() ? thread_info.thread_context.t64.regs[29]
+                                     : thread_info.thread_context.t32.regs[29];
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++  stack_pointer = reader->Is64Bit() ? thread_info.thread_context.t64.sp
++                                    : thread_info.thread_context.t32.sp;
+ #else
+ #error Port.
+ #endif
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/signal_context.h b/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
+index c004f8f6dfab6..6aa9ee38f5b04 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
++++ b/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
+@@ -422,6 +422,67 @@ static_assert(offsetof(UContext<ContextTraits64>, mcontext.fpregs) ==
+               "context offset mismatch");
+ #endif
+ 
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++
++struct MContext32 {
++  uint32_t gregs[32];
++  uint64_t fpregs[32];
++  unsigned int fcsr;
++};
++
++struct MContext64 {
++  uint64_t gregs[32];
++  uint64_t fpregs[32];
++  unsigned int fcsr;
++};
++
++struct ContextTraits32 : public Traits32 {
++  using MContext = MContext32;
++  using SignalThreadContext = ThreadContext::t32_t;
++  using SignalFloatContext = FloatContext::f32_t;
++  using CPUContext = CPUContextRISCV;
++};
++
++struct ContextTraits64 : public Traits64 {
++  using MContext = MContext64;
++  using SignalThreadContext = ThreadContext::t64_t;
++  using SignalFloatContext = FloatContext::f64_t;
++  using CPUContext = CPUContextRISCV64;
++};
++
++template <typename Traits>
++struct UContext {
++  typename Traits::ULong flags;
++  typename Traits::Address link;
++  SignalStack<Traits> stack;
++  Sigset<Traits> sigmask;
++  char padding[128 - sizeof(sigmask)];
++  typename Traits::Char_64Only padding2[8];
++  typename Traits::MContext mcontext;
++};
++
++#if defined(ARCH_CPU_RISCV)
++static_assert(offsetof(UContext<ContextTraits32>, mcontext) ==
++                  offsetof(ucontext_t, uc_mcontext),
++              "context offset mismatch");
++static_assert(offsetof(UContext<ContextTraits32>, mcontext.gregs) ==
++                  offsetof(ucontext_t, uc_mcontext.__gregs),
++              "context offset mismatch");
++static_assert(offsetof(UContext<ContextTraits32>, mcontext.fpregs) ==
++                  offsetof(ucontext_t, uc_mcontext.__fpregs),
++              "context offset mismatch");
++#elif defined(ARCH_CPU_RISCV64)
++static_assert(offsetof(UContext<ContextTraits64>, mcontext) ==
++                  offsetof(ucontext_t, uc_mcontext),
++              "context offset mismatch");
++static_assert(offsetof(UContext<ContextTraits64>, mcontext.gregs) ==
++                  offsetof(ucontext_t, uc_mcontext.__gregs),
++              "context offset mismatch");
++static_assert(offsetof(UContext<ContextTraits64>, mcontext.fpregs) ==
++                  offsetof(ucontext_t, uc_mcontext.__fpregs),
++              "context offset mismatch");
++#endif
++
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86_FAMILY
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc b/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
+index e77bcafa9c6b5..55564ae4aeaf5 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
++++ b/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
+@@ -205,6 +205,9 @@ CPUArchitecture SystemSnapshotLinux::GetCPUArchitecture() const {
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+   return process_reader_->Is64Bit() ? kCPUArchitectureMIPS64EL
+                                     : kCPUArchitectureMIPSEL;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++  return process_reader_->Is64Bit() ? kCPUArchitectureRISCV64
++                                    : kCPUArchitectureRISCV;
+ #else
+ #error port to your architecture
+ #endif
+@@ -220,6 +223,9 @@ uint32_t SystemSnapshotLinux::CPURevision() const {
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+   // Not implementable on MIPS
+   return 0;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++  // Not implementable on RISCV
++  return 0;
+ #else
+ #error port to your architecture
+ #endif
+@@ -240,6 +246,9 @@ std::string SystemSnapshotLinux::CPUVendor() const {
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+   // Not implementable on MIPS
+   return std::string();
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++  // Not implementable on RISCV
++  return std::string();
+ #else
+ #error port to your architecture
+ #endif
+@@ -373,6 +382,9 @@ bool SystemSnapshotLinux::NXEnabled() const {
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+   // Not implementable on MIPS
+   return false;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++  // Not implementable on RISCV
++  return false;
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86_FAMILY
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc b/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
+index f279e0adaddba..8c133a7ca909f 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
++++ b/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
+@@ -189,6 +189,22 @@ bool ThreadSnapshotLinux::Initialize(
+         thread.thread_info.float_context.f32,
+         context_.mipsel);
+   }
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++  if (process_reader->Is64Bit()) {
++    context_.architecture = kCPUArchitectureRISCV64;
++    context_.riscv64 = &context_union_.riscv64;
++    InitializeCPUContextRISCV<ContextTraits64>(
++	thread.thread_info.thread_context.t64,
++	thread.thread_info.float_context.f64,
++	context_.riscv64);
++  } else {
++    context_.architecture = kCPUArchitectureRISCV;
++    context_.riscv = &context_union_.riscv;
++    InitializeCPUContextRISCV<ContextTraits32>(
++	thread.thread_info.thread_context.t32,
++	thread.thread_info.float_context.f32,
++	context_.riscv);
++  }
+ #else
+ #error Port.
+ #endif
+diff --git a/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h b/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
+index 40cd7e7f54a39..aea1ce2047a6b 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
++++ b/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
+@@ -73,6 +73,9 @@ class ThreadSnapshotLinux final : public ThreadSnapshot {
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+     CPUContextMIPS mipsel;
+     CPUContextMIPS64 mips64;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++    CPUContextRISCV riscv;
++    CPUContextRISCV64 riscv64;
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86_FAMILY
+diff --git a/third_party/crashpad/crashpad/util/linux/ptracer.cc b/third_party/crashpad/crashpad/util/linux/ptracer.cc
+index 557e0d3635752..d74dbc1ba1688 100644
+--- a/third_party/crashpad/crashpad/util/linux/ptracer.cc
++++ b/third_party/crashpad/crashpad/util/linux/ptracer.cc
+@@ -397,6 +397,50 @@ bool GetThreadArea64(pid_t tid,
+   *address = FromPointerCast<LinuxVMAddress>(result);
+   return true;
+ }
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++
++template <typename Destination>
++bool GetRegisterSet(pid_t tid, int set, Destination* dest, bool can_log) {
++  iovec iov;
++  iov.iov_base = dest;
++  iov.iov_len = sizeof(*dest);
++  if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast<void*>(set), &iov) != 0) {
++    PLOG_IF(ERROR, can_log) << "ptrace";
++    return false;
++  }
++  if (iov.iov_len != sizeof(*dest)) {
++    LOG_IF(ERROR, can_log) << "Unexpected registers size";
++    return false;
++  }
++  return true;
++}
++
++bool GetFloatingPointRegisters32(pid_t tid,
++                                 FloatContext* context,
++                                 bool can_log) {
++  return false;
++}
++
++bool GetFloatingPointRegisters64(pid_t tid,
++                                 FloatContext* context,
++                                 bool can_log) {
++  return GetRegisterSet(tid, NT_PRFPREG, &context->f64.f, can_log);
++}
++
++bool GetThreadArea32(pid_t tid,
++                     const ThreadContext& context,
++                     LinuxVMAddress* address,
++                     bool can_log) {
++  return false;
++}
++
++bool GetThreadArea64(pid_t tid,
++                     const ThreadContext& context,
++                     LinuxVMAddress* address,
++                     bool can_log) {
++  *address = context.t64.tp;
++  return true;
++}
+ 
+ #else
+ #error Port.
+diff --git a/third_party/crashpad/crashpad/util/linux/thread_info.h b/third_party/crashpad/crashpad/util/linux/thread_info.h
+index d3f3b2c6953fa..6a649dc3d7ac7 100644
+--- a/third_party/crashpad/crashpad/util/linux/thread_info.h
++++ b/third_party/crashpad/crashpad/util/linux/thread_info.h
+@@ -79,6 +79,40 @@ union ThreadContext {
+     uint32_t cp0_status;
+     uint32_t cp0_cause;
+     uint32_t padding1_;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++    // Reflects user_regs_struct in asm/ptrace.h.
++    uint32_t pc;
++    uint32_t ra;
++    uint32_t sp;
++    uint32_t gp;
++    uint32_t tp;
++    uint32_t t0;
++    uint32_t t1;
++    uint32_t t2;
++    uint32_t s0;
++    uint32_t s1;
++    uint32_t a0;
++    uint32_t a1;
++    uint32_t a2;
++    uint32_t a3;
++    uint32_t a4;
++    uint32_t a5;
++    uint32_t a6;
++    uint32_t a7;
++    uint32_t s2;
++    uint32_t s3;
++    uint32_t s4;
++    uint32_t s5;
++    uint32_t s6;
++    uint32_t s7;
++    uint32_t s8;
++    uint32_t s9;
++    uint32_t s10;
++    uint32_t s11;
++    uint32_t t3;
++    uint32_t t4;
++    uint32_t t5;
++    uint32_t t6;
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86_FAMILY
+@@ -132,6 +166,40 @@ union ThreadContext {
+     uint64_t cp0_badvaddr;
+     uint64_t cp0_status;
+     uint64_t cp0_cause;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++    // Reflects user_regs_struct in asm/ptrace.h.
++    uint64_t pc;
++    uint64_t ra;
++    uint64_t sp;
++    uint64_t gp;
++    uint64_t tp;
++    uint64_t t0;
++    uint64_t t1;
++    uint64_t t2;
++    uint64_t s0;
++    uint64_t s1;
++    uint64_t a0;
++    uint64_t a1;
++    uint64_t a2;
++    uint64_t a3;
++    uint64_t a4;
++    uint64_t a5;
++    uint64_t a6;
++    uint64_t a7;
++    uint64_t s2;
++    uint64_t s3;
++    uint64_t s4;
++    uint64_t s5;
++    uint64_t s6;
++    uint64_t s7;
++    uint64_t s8;
++    uint64_t s9;
++    uint64_t s10;
++    uint64_t s11;
++    uint64_t t3;
++    uint64_t t4;
++    uint64_t t5;
++    uint64_t t6;
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86_FAMILY
+@@ -143,11 +211,12 @@ union ThreadContext {
+   using NativeThreadContext = user_regs;
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+ // No appropriate NativeThreadsContext type available for MIPS
++#elif defined(ARCH_CPU_RISCV_FAMILY)
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64
+ 
+-#if !defined(ARCH_CPU_MIPS_FAMILY)
++#if !defined(ARCH_CPU_MIPS_FAMILY) && !defined(ARCH_CPU_RISCV_FAMILY)
+ #if defined(ARCH_CPU_32_BITS)
+   static_assert(sizeof(t32_t) == sizeof(NativeThreadContext), "Size mismatch");
+ #else  // ARCH_CPU_64_BITS
+@@ -218,6 +287,9 @@ union FloatContext {
+     } fpregs[32];
+     uint32_t fpcsr;
+     uint32_t fpu_id;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++    uint64_t f[32];
++    uint32_t fcsr;
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86_FAMILY
+@@ -252,6 +324,9 @@ union FloatContext {
+     double fpregs[32];
+     uint32_t fpcsr;
+     uint32_t fpu_id;
++#elif defined(ARCH_CPU_RISCV_FAMILY)
++    uint64_t f[32];
++    uint32_t fcsr;
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86_FAMILY
+@@ -281,6 +356,7 @@ union FloatContext {
+   static_assert(sizeof(f64) == sizeof(user_fpsimd_struct), "Size mismatch");
+ #elif defined(ARCH_CPU_MIPS_FAMILY)
+ // No appropriate floating point context native type for available MIPS.
++#elif defined(ARCH_CPU_RISCV_FAMILY)
+ #else
+ #error Port.
+ #endif  // ARCH_CPU_X86
+diff --git a/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc b/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
+index 7e3f41186f462..9568dc2e24f97 100644
+--- a/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
++++ b/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
+@@ -237,6 +237,8 @@ std::string UserAgent() {
+ #elif defined(ARCH_CPU_BIG_ENDIAN)
+     static constexpr char arch[] = "aarch64_be";
+ #endif
++#elif defined(ARCH_CPU_RISCV64)
++    static constexpr char arch[] = "riscv64";
+ #else
+ #error Port
+ #endif
+-- 
+2.25.1
+

+ 4 - 4
0012-third_party-lzma_sdk-add-riscv-arch-definition.patch → 0017-third_party-lzma_sdk-add-riscv-arch-definition.patch

@@ -1,7 +1,7 @@
-From 66bc1bd92b113ce450611e2b0cb4f1e4b7310f16 Mon Sep 17 00:00:00 2001
+From 1d07d1083a701b124791de2aa86ad6b53276c3d4 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Fri, 14 Jan 2022 05:07:31 +0000
-Subject: [PATCH 12/21] third_party: lzma_sdk: add riscv arch definition
+Subject: [PATCH 17/18] third_party: lzma_sdk: add riscv arch definition
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---
@@ -9,14 +9,14 @@ Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  1 file changed, 7 insertions(+)
 
 diff --git a/third_party/lzma_sdk/CpuArch.h b/third_party/lzma_sdk/CpuArch.h
-index bd429388024d7..3fed7b3797e90 100644
+index bd429388024d7..5a6306641b92f 100644
 --- a/third_party/lzma_sdk/CpuArch.h
 +++ b/third_party/lzma_sdk/CpuArch.h
 @@ -107,6 +107,13 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
  #endif
  
  
-+#if defined(__riscv) || (__riscv_xlen == 64)
++#if defined(__riscv) && (__riscv_xlen == 64)
 +  #define MY_CPU_NAME "riscv64"
 +  #define MY_CPU_64BIT
 +  #define MY_CPU_LE

+ 1104 - 0
0018-build-linux-sysroot-create-a-sysroot-for-riscv.patch

@@ -0,0 +1,1104 @@
+From 9740d7b669043e20142482f1e451c42e44ee2766 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Tue, 5 Apr 2022 06:40:16 +0000
+Subject: [PATCH 18/18] build: linux: sysroot: create a sysroot for riscv
+
+Upstream-status: Unidentified
+
+Since riscv is not an official port in Debian, this might not be
+able to upstream.
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/config/posix/BUILD.gn                   |  12 -
+ build/config/sysroot.gni                      |   5 +-
+ .../debian-ports-archive-2022.gpg             | Bin 0 -> 1210 bytes
+ .../sysroot-builder-riscv64.sh                | 588 ++++++++++++++++++
+ .../sysroot-creator-riscv64.sh                | 400 ++++++++++++
+ 5 files changed, 992 insertions(+), 13 deletions(-)
+ create mode 100644 build/linux/sysroot_scripts/debian-ports-archive-2022.gpg
+ create mode 100755 build/linux/sysroot_scripts/sysroot-builder-riscv64.sh
+ create mode 100755 build/linux/sysroot_scripts/sysroot-creator-riscv64.sh
+
+diff --git a/build/config/posix/BUILD.gn b/build/config/posix/BUILD.gn
+index 5d15163875717..3e0ded398ced3 100644
+--- a/build/config/posix/BUILD.gn
++++ b/build/config/posix/BUILD.gn
+@@ -28,18 +28,6 @@ config("runtime_library") {
+   if (!is_apple && sysroot != "" && current_os != "zos") {
+     # Pass the sysroot to all C compiler variants, the assembler, and linker.
+     sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
+-    if (is_linux || is_chromeos) {
+-      # This is here so that all files get recompiled after a sysroot roll and
+-      # when turning the sysroot on or off. (defines are passed via the command
+-      # line, and build system rebuilds things when their commandline
+-      # changes). Nothing should ever read this define.
+-      sysroot_hash =
+-          exec_script("//build/linux/sysroot_scripts/install-sysroot.py",
+-                      [ "--print-hash=$current_cpu" ],
+-                      "trim string",
+-                      [ "//build/linux/sysroot_scripts/sysroots.json" ])
+-      defines += [ "CR_SYSROOT_HASH=$sysroot_hash" ]
+-    }
+     asmflags += sysroot_flags
+     ldflags += sysroot_flags
+ 
+diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni
+index cbcf0a3f09615..aaf1b21baf5f7 100644
+--- a/build/config/sysroot.gni
++++ b/build/config/sysroot.gni
+@@ -23,7 +23,8 @@ declare_args() {
+   # is empty, default sysroot is calculated.
+   use_sysroot = 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"
+ }
+ 
+ if (sysroot == "") {
+@@ -50,6 +51,8 @@ if (sysroot == "") {
+       sysroot = "$target_sysroot_dir/debian_bullseye_arm-sysroot"
+     } else if (current_cpu == "arm64") {
+       sysroot = "$target_sysroot_dir/debian_bullseye_arm64-sysroot"
++    } else if (current_cpu == "riscv64") {
++      sysroot = "$target_sysroot_dir/debian_sid_riscv64-sysroot"
+     } else {
+       assert(false, "No linux sysroot for cpu: $target_cpu")
+     }
+diff --git a/build/linux/sysroot_scripts/debian-ports-archive-2022.gpg b/build/linux/sysroot_scripts/debian-ports-archive-2022.gpg
+new file mode 100644
+index 0000000000000000000000000000000000000000..946d514f68f75bf1035d3c2fec23be503bcaa7de
+GIT binary patch
+literal 1210
+zcmV;r1V#Iq0u2OT`-isy5CFX&gr2KN<iC3NKjKXSf#TTjm+=kmq;H8*cck8*9X4Ny
+z$uTg6SpzoPR)&h1IDe2W!ug=bbT++nGuhzYnVPO;_6%7*XzzKZaHt|$K>m94Nd<p?
+z|5QU>d+VlNCb*dZjQHg|t7oNC+@8OhGsvhjVFz-oqj3UkCZ8Eq(N@y2$KJxGW3j74
+zV36~q(PbY90ZTh0;046Ekk!SucYoHzuB$!@arn!b1x7ffCGu?~xpH;3rnbNsFM`+J
+zMIjL{5r8BNNbfPEq?e;qApDDwB7l4$oVIpEj04Xp?QEETGbPp4=cm{8Uszr(Og0Nr
+zqMQKYohL`1hup>L8d&x@+^&)_>1ENsGp1)nv&mK_jGxt&cyXY+#D)%S4f0@D3FM@7
+z3V1$RsbHI#?W2fQ41aMPMXmL?r%Xkeicrl+u8}$%i?9ga(V9^2|MF0}<~%)2;hd3e
+zKlZrTM_VCp(sD7CqF4`WURB??O{aaSWt`0FD7Y>rKPx&g+=qIv*=ej<cqgO&z^BC@
+zS5y^LPUUBZd*KZX4?o!rLuf78H*A5@MoS@H=^~njX+MG$BHv2pQub6G>+Wi9F)Ec}
+zp+s=)26mw;auSFp;L|i#LtEL!z91C6gtL3(Y(_l)kQt$!#Bp58bwc+AR{^eofl7Lo
+z`!1Lt(iUXdDLnuY0RRECRYYZCX<=?4P;YW{b09%-V`yo1WgtOybZ>28bZKKCQ)y>z
+zX>MmAOJ#W=C^9fIGASTDW^{0EVRLk4azJoza&&VoZDDhCWpXZLWnyVzZZ2<fXFiDn
+zPy`bJ3IIA5Aq30E3ShbIZzFnNTMOt?QBPg-67~fGU;Br*0viJb2?O31fC38%1QiMi
+z2n7}b0|5X69svRufB*^!5a?1-PhIm8_67(L0FApGI%0TlFf#s^R&9KJAEk|G%nNhM
+ztZ(BCz^290)D8w1_L^HlT&zMSPS;C2i5xot35$Uy>cASU=7-o<oXr8BtFDeQ_rruT
+zG*MhWOe;0?-qnBhVd^S6&Dy~$cJFw1VJi8#MJ1VH_W4_1o~5=SBp9GE$Ovg&P`;m@
+z@MU(p+3@WjKSH6vik&^rwTLJ7nz<+7LN?@IdP{WcGr==H9Q|`j!><J7IwOQoYruZa
+zlrFvfQ>O}1=P+SqwopNCZdZdc#+ebWmyaRKb;dgyi>RzfdCTyG$IUE^?m?2Az~>l0
+zd&z|kG6R}PfY%;KH+%9JDq#=c<yEzF2JYv5W39%{6NsNFEAsr5<{DowWuVgy)n*+f
+z5+m595pn)kfuNdrpC^N-N1k#$xZ8)iieVwBbOgVYnegAeez;g1*03EU&%RAoB#EGk
+z!j)qAlNOA|S6iGi1|xfW29dL<Q+zKx!vvEgVs8THQ6DHD5(c8-98c+vGG}wlD91B8
+z8?S5iGtavOoHtN1=uRRu-s6|XSxFReLd8$Cw?ZZnZq$>y=!}46xHery{3VEv-wYt9
+zOjq@MUta10RIH^9WK`+Og$(oIaFmE?5NK!Ok3M@mhVybBY-K~oCud(;>!u%`XV7n1
+YXx^}TJV%j3zJt}E_<gtaMn?Bg9P=nExc~qF
+
+literal 0
+HcmV?d00001
+
+diff --git a/build/linux/sysroot_scripts/sysroot-builder-riscv64.sh b/build/linux/sysroot_scripts/sysroot-builder-riscv64.sh
+new file mode 100755
+index 0000000000000..34cfe5a370428
+--- /dev/null
++++ b/build/linux/sysroot_scripts/sysroot-builder-riscv64.sh
+@@ -0,0 +1,588 @@
++# Copyright 2014 The Chromium Authors. All rights reserved.
++# Use of this source code is governed by a BSD-style license that can be
++# found in the LICENSE file.
++#
++# This script should not be run directly but sourced by the other
++# scripts (e.g. sysroot-creator-sid.sh).  Its up to the parent scripts
++# to define certain environment variables: e.g.
++#  DISTRO=debian
++#  DIST=sid
++#  # Similar in syntax to /etc/apt/sources.list
++#  APT_SOURCES_LIST="http://ftp.us.debian.org/debian/ sid main"
++#  KEYRING_FILE=debian-archive-sid-stable.gpg
++#  DEBIAN_PACKAGES="gcc libz libssl"
++
++#@ This script builds Debian/Ubuntu sysroot images for building Google Chrome.
++#@
++#@  Generally this script is invoked as:
++#@  sysroot-creator-<flavour>.sh <mode> <args>*
++#@  Available modes are shown below.
++#@
++#@ List of modes:
++
++######################################################################
++# Config
++######################################################################
++
++set -o nounset
++set -o errexit
++
++SCRIPT_DIR=$(cd $(dirname $0) && pwd)
++
++if [ -z "${DIST:-}" ]; then
++  echo "error: DIST not defined"
++  exit 1
++fi
++
++if [ -z "${KEYRING_FILE:-}" ]; then
++  echo "error: KEYRING_FILE not defined"
++  exit 1
++fi
++
++if [ -z "${DEBIAN_PACKAGES:-}" ]; then
++  echo "error: DEBIAN_PACKAGES not defined"
++  exit 1
++fi
++
++readonly HAS_ARCH_RISCV64=${HAS_ARCH_RISCV64:=0}
++
++readonly REQUIRED_TOOLS="curl xzcat"
++
++######################################################################
++# Package Config
++######################################################################
++
++readonly PACKAGES_EXT=xz
++readonly RELEASE_FILE="Release"
++readonly RELEASE_FILE_GPG="Release.gpg"
++
++readonly DEBIAN_DEP_LIST_RISCV64="generated_package_lists/${DIST}.riscv64"
++
++
++######################################################################
++# Helper
++######################################################################
++
++Banner() {
++  echo "######################################################################"
++  echo $*
++  echo "######################################################################"
++}
++
++
++SubBanner() {
++  echo "----------------------------------------------------------------------"
++  echo $*
++  echo "----------------------------------------------------------------------"
++}
++
++
++Usage() {
++  egrep "^#@" "${BASH_SOURCE[0]}" | cut --bytes=3-
++}
++
++
++DownloadOrCopyNonUniqueFilename() {
++  # Use this function instead of DownloadOrCopy when the url uniquely
++  # identifies the file, but the filename (excluding the directory)
++  # does not.
++  local url="$1"
++  local dest="$2"
++
++  local hash="$(echo "$url" | sha256sum | cut -d' ' -f1)"
++
++  DownloadOrCopy "${url}" "${dest}.${hash}"
++  # cp the file to prevent having to redownload it, but mv it to the
++  # final location so that it's atomic.
++  cp "${dest}.${hash}" "${dest}.$$"
++  mv "${dest}.$$" "${dest}"
++}
++
++DownloadOrCopy() {
++  if [ -f "$2" ] ; then
++    echo "$2 already in place"
++    return
++  fi
++
++  HTTP=0
++  echo "$1" | grep -Eqs '^https?://' && HTTP=1
++  if [ "$HTTP" = "1" ]; then
++    SubBanner "downloading from $1 -> $2"
++    # Appending the "$$" shell pid is necessary here to prevent concurrent
++    # instances of sysroot-creator.sh from trying to write to the same file.
++    local temp_file="${2}.partial.$$"
++    # curl --retry doesn't retry when the page gives a 4XX error, so we need to
++    # manually rerun.
++    for i in {1..10}; do
++      # --create-dirs is added in case there are slashes in the filename, as can
++      # happen with the "debian/security" release class.
++      local http_code=$(curl -L "$1" --create-dirs -o "${temp_file}" \
++                        -w "%{http_code}")
++      if [ ${http_code} -eq 200 ]; then
++        break
++      fi
++      echo "Bad HTTP code ${http_code} when downloading $1"
++      rm -f "${temp_file}"
++      sleep $i
++    done
++    if [ ! -f "${temp_file}" ]; then
++      exit 1
++    fi
++    mv "${temp_file}" $2
++  else
++    SubBanner "copying from $1"
++    cp "$1" "$2"
++  fi
++}
++
++
++SetEnvironmentVariables() {
++  case $1 in
++    *Riscv*)
++      ARCH=RISCV64
++      ;;
++    *)
++      echo "ERROR: Unable to determine architecture based on: $1"
++      exit 1
++      ;;
++  esac
++  ARCH_LOWER=$(echo $ARCH | tr '[:upper:]' '[:lower:]')
++}
++
++
++# some sanity checks to make sure this script is run from the right place
++# with the right tools
++SanityCheck() {
++  Banner "Sanity Checks"
++
++  local chrome_dir=$(cd "${SCRIPT_DIR}/../../.." && pwd)
++  BUILD_DIR="${chrome_dir}/out/sysroot-build/${DIST}"
++  mkdir -p ${BUILD_DIR}
++  echo "Using build directory: ${BUILD_DIR}"
++
++  for tool in ${REQUIRED_TOOLS} ; do
++    if ! which ${tool} > /dev/null ; then
++      echo "Required binary $tool not found."
++      echo "Exiting."
++      exit 1
++    fi
++  done
++
++  # This is where the staging sysroot is.
++  INSTALL_ROOT="${BUILD_DIR}/${DIST}_${ARCH_LOWER}_staging"
++  TARBALL="${BUILD_DIR}/${DISTRO}_${DIST}_${ARCH_LOWER}_sysroot.tar.xz"
++
++  if ! mkdir -p "${INSTALL_ROOT}" ; then
++    echo "ERROR: ${INSTALL_ROOT} can't be created."
++    exit 1
++  fi
++}
++
++
++ChangeDirectory() {
++  # Change directory to where this script is.
++  cd ${SCRIPT_DIR}
++}
++
++
++ClearInstallDir() {
++  Banner "Clearing dirs in ${INSTALL_ROOT}"
++  rm -rf ${INSTALL_ROOT}/*
++}
++
++
++CreateTarBall() {
++  Banner "Creating tarball ${TARBALL}"
++  tar -I "xz -9 -T0" -cf ${TARBALL} -C ${INSTALL_ROOT} .
++}
++
++ExtractPackageXz() {
++  local src_file="$1"
++  local dst_file="$2"
++  local repo="$3"
++  xzcat "${src_file}" | egrep '^(Package:|Filename:|SHA256:) ' |
++    sed "s|Filename: |Filename: ${repo}|" > "${dst_file}"
++}
++
++GeneratePackageListDist() {
++  local arch="$1"
++  set -- $2
++  local repo="$1"
++  local dist="$2"
++  local repo_name="$3"
++
++  TMP_PACKAGE_LIST="${BUILD_DIR}/Packages.${dist}_${repo_name}_${arch}"
++  local repo_basedir="${repo}/dists/${dist}"
++  local package_list="${BUILD_DIR}/Packages.${dist}_${repo_name}_${arch}.${PACKAGES_EXT}"
++  local package_file_arch="${repo_name}/binary-${arch}/Packages.${PACKAGES_EXT}"
++  local package_list_arch="${repo_basedir}/${package_file_arch}"
++
++  DownloadOrCopyNonUniqueFilename "${package_list_arch}" "${package_list}"
++  VerifyPackageListing "${package_file_arch}" "${package_list}" ${repo} ${dist}
++  ExtractPackageXz "${package_list}" "${TMP_PACKAGE_LIST}" ${repo}
++}
++
++GeneratePackageListCommon() {
++  local output_file="$1"
++  local arch="$2"
++  local packages="$3"
++
++  local dists="${DIST} ${DIST_UPDATES:-}"
++
++  local list_base="${BUILD_DIR}/Packages.${DIST}_${arch}"
++  > "${list_base}"  # Create (or truncate) a zero-length file.
++  echo "${APT_SOURCES_LIST}" | while read source; do
++    GeneratePackageListDist "${arch}" "${source}"
++    cat "${TMP_PACKAGE_LIST}" | ./merge-package-lists.py "${list_base}"
++  done
++
++  GeneratePackageList "${list_base}" "${output_file}" "${packages}"
++}
++
++GeneratePackageListRiscv64() {
++  GeneratePackageListCommon "$1" riscv64 "${DEBIAN_PACKAGES}
++  ${DEBIAN_PACKAGES_RISCV64:=}"
++}
++
++StripChecksumsFromPackageList() {
++  local package_file="$1"
++  sed -i 's/ [a-f0-9]\{64\}$//' "$package_file"
++}
++
++######################################################################
++#
++######################################################################
++
++HacksAndPatchesCommon() {
++  local arch=$1
++  local os=$2
++  local strip=$3
++  Banner "Misc Hacks & Patches"
++  # these are linker scripts with absolute pathnames in them
++  # which we rewrite here
++  lscripts="${INSTALL_ROOT}/usr/lib/${arch}-${os}/libpthread.so \
++            ${INSTALL_ROOT}/usr/lib/${arch}-${os}/libc.so"
++
++  # Rewrite linker scripts
++  sed -i -e 's|/usr/lib/${arch}-${os}/||g'  ${lscripts}
++  sed -i -e 's|/lib/${arch}-${os}/||g' ${lscripts}
++
++  # Unversion libdbus and libxkbcommon symbols.  This is required because
++  # libdbus-1-3 and libxkbcommon0 switched from unversioned symbols to versioned
++  # ones, and we must still support distros using the unversioned library.  This
++  # hack can be removed once support for Ubuntu Trusty and Debian Jessie are
++  # dropped.
++  ${strip} -R .gnu.version_d -R .gnu.version \
++    "${INSTALL_ROOT}/lib/${arch}-${os}/libdbus-1.so.3"
++  cp "${SCRIPT_DIR}/libdbus-1-3-symbols" \
++    "${INSTALL_ROOT}/debian/libdbus-1-3/DEBIAN/symbols"
++
++  ${strip} -R .gnu.version_d -R .gnu.version \
++    "${INSTALL_ROOT}/usr/lib/${arch}-${os}/libxkbcommon.so.0.0.0"
++  cp "${SCRIPT_DIR}/libxkbcommon0-symbols" \
++    "${INSTALL_ROOT}/debian/libxkbcommon0/DEBIAN/symbols"
++
++  # libxcomposite1 is missing a symbols file.
++  cp "${SCRIPT_DIR}/libxcomposite1-symbols" \
++    "${INSTALL_ROOT}/debian/libxcomposite1/DEBIAN/symbols"
++
++  # Shared objects depending on libdbus-1.so.3 have unsatisfied undefined
++  # versioned symbols. To avoid LLD --no-allow-shlib-undefined errors, rewrite
++  # DT_NEEDED entries from libdbus-1.so.3 to a different string. LLD will
++  # suppress --no-allow-shlib-undefined diagnostics for such shared objects.
++  set +e
++  for f in "${INSTALL_ROOT}/lib/${arch}-${os}"/*.so \
++           "${INSTALL_ROOT}/usr/lib/${arch}-${os}"/*.so; do
++    echo "$f" | grep -q 'libdbus-1.so$' && continue
++    # In a dependent shared object, the only occurrence of "libdbus-1.so.3" is
++    # the string referenced by the DT_NEEDED entry.
++    offset=$(LANG=C grep -abo libdbus-1.so.3 "$f")
++    [ -n "$offset" ] || continue
++    echo -n 'libdbus-1.so.0' | dd of="$f" conv=notrunc bs=1 \
++      seek="$(echo -n "$offset" | cut -d : -f 1)" status=none
++  done
++  set -e
++
++  # Avoid requiring unsupported glibc versions.
++  "${SCRIPT_DIR}/reversion_glibc.py" \
++    "${INSTALL_ROOT}/lib/${arch}-${os}/libc.so.6"
++  "${SCRIPT_DIR}/reversion_glibc.py" \
++    "${INSTALL_ROOT}/lib/${arch}-${os}/libm.so.6"
++
++  # fcntl64() was introduced in glibc 2.28.  Make sure to use fcntl() instead.
++  local fcntl_h="${INSTALL_ROOT}/usr/include/fcntl.h"
++  sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' \
++      "${fcntl_h}"
++
++  # __GLIBC_MINOR__ is used as a feature test macro.  Replace it with the
++  # earliest supported version of glibc (2.17, https://crbug.com/376567).
++  local features_h="${INSTALL_ROOT}/usr/include/features.h"
++  sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "${features_h}"
++
++  # This is for chrome's ./build/linux/pkg-config-wrapper
++  # which overwrites PKG_CONFIG_LIBDIR internally
++  SubBanner "Move pkgconfig scripts"
++  mkdir -p ${INSTALL_ROOT}/usr/lib/pkgconfig
++  mv ${INSTALL_ROOT}/usr/lib/${arch}-${os}/pkgconfig/* \
++      ${INSTALL_ROOT}/usr/lib/pkgconfig
++}
++
++
++HacksAndPatchesRiscv64() {
++  HacksAndPatchesCommon riscv64 linux-gnu riscv64-linux-gnu-strip
++}
++
++
++InstallIntoSysroot() {
++  Banner "Install Libs And Headers Into Jail"
++
++  mkdir -p ${BUILD_DIR}/debian-packages
++  # The /debian directory is an implementation detail that's used to cd into
++  # when running dpkg-shlibdeps.
++  mkdir -p ${INSTALL_ROOT}/debian
++  # An empty control file is necessary to run dpkg-shlibdeps.
++  touch ${INSTALL_ROOT}/debian/control
++  while (( "$#" )); do
++    local file="$1"
++    local package="${BUILD_DIR}/debian-packages/${file##*/}"
++    shift
++    local sha256sum="$1"
++    shift
++    if [ "${#sha256sum}" -ne "64" ]; then
++      echo "Bad sha256sum from package list"
++      # exit 1
++    fi
++
++    Banner "Installing $(basename ${file})"
++    DownloadOrCopy ${file} ${package}
++    if [ ! -s "${package}" ] ; then
++      echo
++      echo "ERROR: bad package ${package}"
++      exit 1
++    fi
++    echo "${sha256sum}  ${package}" | sha256sum --quiet -c
++
++    SubBanner "Extracting to ${INSTALL_ROOT}"
++    dpkg-deb -x ${package} ${INSTALL_ROOT}
++
++    base_package=$(dpkg-deb --field ${package} Package)
++    mkdir -p ${INSTALL_ROOT}/debian/${base_package}/DEBIAN
++    dpkg-deb -e ${package} ${INSTALL_ROOT}/debian/${base_package}/DEBIAN
++  done
++
++  # Prune /usr/share, leaving only pkgconfig.
++  ls -d ${INSTALL_ROOT}/usr/share/* | grep -v "/pkgconfig$" | xargs rm -r
++}
++
++
++CleanupJailSymlinks() {
++  Banner "Jail symlink cleanup"
++
++  SAVEDPWD=$(pwd)
++  cd ${INSTALL_ROOT}
++  local libdirs="lib usr/lib"
++  libdirs="${libdirs} lib64"
++
++  find $libdirs -type l -printf '%p %l\n' | while read link target; do
++    # skip links with non-absolute paths
++    echo "${target}" | grep -qs ^/ || continue
++    echo "${link}: ${target}"
++    # Relativize the symlink.
++    prefix=$(echo "${link}" | sed -e 's/[^/]//g' | sed -e 's|/|../|g')
++    ln -snfv "${prefix}${target}" "${link}"
++  done
++
++  find $libdirs -type l -printf '%p %l\n' | while read link target; do
++    # Make sure we catch new bad links.
++    if [ ! -r "${link}" ]; then
++      echo "ERROR: FOUND BAD LINK ${link}"
++      ls -l ${link}
++      exit 1
++    fi
++  done
++  cd "$SAVEDPWD"
++}
++
++
++VerifyLibraryDepsCommon() {
++  local arch=$1
++  local os=$2
++  local find_dirs=(
++    "${INSTALL_ROOT}/lib/"
++    "${INSTALL_ROOT}/lib/${arch}-${os}/"
++    "${INSTALL_ROOT}/usr/lib/${arch}-${os}/"
++  )
++  local needed_libs="$(
++    find ${find_dirs[*]} -name "*\.so*" -type f -exec file {} \; | \
++      grep ': ELF' | sed 's/^\(.*\): .*$/\1/' | xargs readelf -d | \
++      grep NEEDED | sort | uniq | sed 's/^.*Shared library: \[\(.*\)\]$/\1/g')"
++  local all_libs="$(find ${find_dirs[*]} -printf '%f\n')"
++  # Ignore missing libdbus-1.so.0
++  all_libs+="$(echo -e '\nlibdbus-1.so.0')"
++  local missing_libs="$(grep -vFxf <(echo "${all_libs}") \
++    <(echo "${needed_libs}"))"
++  if [ ! -z "${missing_libs}" ]; then
++    echo "Missing libraries:"
++    echo "${missing_libs}"
++    exit 1
++  fi
++}
++
++VerifyLibraryDepsRiscv64() {
++  VerifyLibraryDepsCommon riscv64 linux-gnu
++}
++
++#@
++#@ BuildSysrootRiscv64
++#@
++#@    Build everything and package it
++BuildSysrootRiscv64() {
++  if [ "$HAS_ARCH_RISCV64" = "0" ]; then
++    return
++  fi
++  ClearInstallDir
++  local package_file="${DEBIAN_DEP_LIST_RISCV64}"
++  # GeneratePackageListRiscv64 "$package_file"
++  local files_and_sha256sums="$(cat ${package_file})"
++  StripChecksumsFromPackageList "$package_file"
++  InstallIntoSysroot ${files_and_sha256sums}
++  CleanupJailSymlinks
++  HacksAndPatchesRiscv64
++  VerifyLibraryDepsRiscv64
++  CreateTarBall
++}
++
++#
++# CheckForDebianGPGKeyring
++#
++#     Make sure the Debian GPG keys exist. Otherwise print a helpful message.
++#
++CheckForDebianGPGKeyring() {
++  if [ ! -e "$KEYRING_FILE" ]; then
++    echo "KEYRING_FILE not found: ${KEYRING_FILE}"
++    echo "Debian GPG keys missing. Install the debian-archive-keyring package."
++    exit 1
++  fi
++}
++
++#
++# VerifyPackageListing
++#
++#     Verifies the downloaded Packages.xz file has the right checksums.
++#
++VerifyPackageListing() {
++  local file_path="$1"
++  local output_file="$2"
++  local repo="$3"
++  local dist="$4"
++
++  local repo_basedir="${repo}/dists/${dist}"
++  local release_list="${repo_basedir}/${RELEASE_FILE}"
++  local release_list_gpg="${repo_basedir}/${RELEASE_FILE_GPG}"
++
++  local release_file="${BUILD_DIR}/${dist}-${RELEASE_FILE}"
++  local release_file_gpg="${BUILD_DIR}/${dist}-${RELEASE_FILE_GPG}"
++
++  CheckForDebianGPGKeyring
++
++  DownloadOrCopyNonUniqueFilename ${release_list} ${release_file}
++  DownloadOrCopyNonUniqueFilename ${release_list_gpg} ${release_file_gpg}
++  echo "Verifying: ${release_file} with ${release_file_gpg}"
++  set -x
++  gpgv --keyring "${KEYRING_FILE}" "${release_file_gpg}" "${release_file}"
++  set +x
++
++  echo "Verifying: ${output_file}"
++  local sha256sum=$(grep -E "${file_path}\$|:\$" "${release_file}" | \
++    grep "SHA256:" -A 1 | xargs echo | awk '{print $2;}')
++
++  if [ "${#sha256sum}" -ne "64" ]; then
++    echo "Bad sha256sum from ${release_list}"
++    exit 1
++  fi
++
++  echo "${sha256sum}  ${output_file}" | sha256sum --quiet -c
++}
++
++#
++# GeneratePackageList
++#
++#     Looks up package names in ${BUILD_DIR}/Packages and write list of URLs
++#     to output file.
++#
++GeneratePackageList() {
++  local input_file="$1"
++  local output_file="$2"
++  echo "Updating: ${output_file} from ${input_file}"
++  /bin/rm -f "${output_file}"
++  shift
++  shift
++  for pkg in $@ ; do
++    local pkg_full=$(grep -A 1 " ${pkg}\$" "$input_file" | \
++      egrep "debian-ports/.*" | sed 's/.*Filename: //')
++    if [ -z "${pkg_full}" ]; then
++        echo "ERROR: missing package: $pkg"
++        exit 1
++    fi
++    local sha256sum=$(grep -A 4 " ${pkg}\$" "$input_file" | \
++      grep ^SHA256: | sed 's/^SHA256: //')
++    if [ "${#sha256sum}" -ne "64" ]; then
++      echo "Bad sha256sum from Packages"
++      exit 1
++    fi
++    echo $pkg_full $sha256sum >> "$output_file"
++  done
++  # sort -o does an in-place sort of this file
++  sort "$output_file" -o "$output_file"
++}
++
++#@
++#@ PrintArchitectures
++#@
++#@    Prints supported architectures.
++PrintArchitectures() {
++  if [ "$HAS_ARCH_RISCV64" = "1" ]; then
++    echo Riscv64
++  fi
++}
++
++#@
++#@ PrintDistro
++#@
++#@    Prints distro.  eg: ubuntu
++PrintDistro() {
++  echo ${DISTRO}
++}
++
++#@
++#@ DumpRelease
++#@
++#@    Prints disto release.  eg: jessie
++PrintRelease() {
++  echo ${DIST}
++}
++
++RunCommand() {
++  SetEnvironmentVariables "$1"
++  SanityCheck
++  "$@"
++}
++
++if [ $# -eq 0 ] ; then
++  echo "ERROR: you must specify a mode on the commandline"
++  echo
++  Usage
++  exit 1
++elif [ "$(type -t $1)" != "function" ]; then
++  echo "ERROR: unknown function '$1'." >&2
++  echo "For help, try:"
++  echo "    $0 help"
++  exit 1
++else
++  ChangeDirectory
++  if echo $1 | grep -qs --regexp='\(^Print\)\|\(All$\)'; then
++    "$@"
++  else
++    RunCommand "$@"
++  fi
++fi
+diff --git a/build/linux/sysroot_scripts/sysroot-creator-riscv64.sh b/build/linux/sysroot_scripts/sysroot-creator-riscv64.sh
+new file mode 100755
+index 0000000000000..aa4a34c04988e
+--- /dev/null
++++ b/build/linux/sysroot_scripts/sysroot-creator-riscv64.sh
+@@ -0,0 +1,400 @@
++#!/bin/bash
++# Copyright 2017 The Chromium Authors. All rights reserved.
++# Use of this source code is governed by a BSD-style license that can be
++# found in the LICENSE file.
++
++SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
++
++DISTRO=debian
++DIST=sid
++
++# Keep the "experimental" repo before the "sid" repo.  There are some packages
++# that are currently only available in experimental like libgtk-4-1, but if it
++# were to be placed first, experimental (unreleased) versions of other packages
++# like libc6 would take precedence over the sid (released) versions.  While this
++# may be useful for certain kinds of development, the standard sysroots should
++# continue to be shipped only with released packages.
++# Also keep "stretch" before "sid".  For now, it's needed to bring back
++# libgnome-keyring-dev which has since been deprecated and removed from sid.
++# It will be needed until gnome keyring is removed (http://crbug.com/466975 and
++# http://crbug.com/355223).
++ARCHIVE_URL="http://ftp.ports.debian.org/debian-ports"
++APT_SOURCES_LIST="${ARCHIVE_URL}/ unstable main
++${ARCHIVE_URL}/ experimental main
++${ARCHIVE_URL}/ sid main"
++
++# gpg keyring file generated using generate_debian_archive_unstable.sh
++KEYRING_FILE="/etc/apt/trusted.gpg.d/debian-ports-archive-2022.gpg"
++
++HAS_ARCH_RISCV64=1
++
++# Sysroot packages: these are the packages needed to build chrome.
++# NOTE: When DEBIAN_PACKAGES is modified, the packagelist files must be updated
++# by running this script in GeneratePackageList mode.
++# comerr-dev
++# krb5-multidev
++# libappindicator-dev libappindicator1 libappindicator3-1 libappindicator3-dev
++# libffi6 libffi7
++# libgcc1
++# libgnome-keyring-dev libgnome-keyring0
++# libindicator3-7 libindicator7
++# libpango-1.0-0 libpango1.0-dev
++# libpangox-1.0-0
++DEBIAN_PACKAGES="\
++  libasound2
++  libasound2-dev
++  libasyncns0
++  libatk-bridge2.0-0
++  libatk-bridge2.0-dev
++  libatk1.0-0
++  libatk1.0-dev
++  libatomic1
++  libatspi2.0-0
++  libatspi2.0-dev
++  libattr1
++  libaudit1
++  libavahi-client3
++  libavahi-common3
++  libblkid-dev
++  libblkid1
++  libbluetooth-dev
++  libbluetooth3
++  libbrotli-dev
++  libbrotli1
++  libbsd0
++  libc6
++  libc6-dev
++  libcairo-gobject2
++  libcairo-script-interpreter2
++  libcairo2
++  libcairo2-dev
++  libcap-dev
++  libcap-ng0
++  libcap2
++  libcloudproviders0
++  libcolord2
++  libcom-err2
++  libcups2
++  libcups2-dev
++  libcupsimage2
++  libcupsimage2-dev
++  libdatrie-dev
++  libcurl3-gnutls
++  libcurl4-gnutls-dev
++  libdatrie1
++  libdb5.3
++  libdbus-1-3
++  libdbus-1-dev
++  libdbus-glib-1-2
++  libdbusmenu-glib-dev
++  libdbusmenu-glib4
++  libdbusmenu-gtk3-4
++  libdbusmenu-gtk4
++  libdeflate-dev
++  libdeflate0
++  libdrm-amdgpu1
++  libdrm-dev
++  libdrm-nouveau2
++  libdrm-radeon1
++  libdrm2
++  libegl-dev
++  libegl1
++  libegl1-mesa
++  libegl1-mesa-dev
++  libelf-dev
++  libelf1
++  libepoxy-dev
++  libepoxy0
++  libevdev-dev
++  libevdev2
++  libevent-2.1-7
++  libexpat1
++  libexpat1-dev
++  libffi-dev
++  libffi8
++  libflac-dev
++  libflac8
++  libfontconfig-dev
++  libfontconfig1
++  libfreetype-dev
++  libfreetype6
++  libfribidi-dev
++  libfribidi0
++  libgbm-dev
++  libgbm1
++  libgcc-10-dev
++  libgcc-s1
++  libgcrypt20
++  libgcrypt20-dev
++  libgdk-pixbuf-2.0-0
++  libgdk-pixbuf-2.0-dev
++  libgl-dev
++  libgl1
++  libgl1-mesa-dev
++  libgl1-mesa-glx
++  libglapi-mesa
++  libgles-dev
++  libgles1
++  libgles2
++  libglib2.0-0
++  libglib2.0-dev
++  libglvnd-dev
++  libglvnd0
++  libglx-dev
++  libglx0
++  libgmp10
++  libgnutls-dane0
++  libgnutls-openssl27
++  libgnutls28-dev
++  libgnutls30
++  libgnutlsxx28
++  libgomp1
++  libgpg-error-dev
++  libgpg-error0
++  libgraphene-1.0-0
++  libgraphene-1.0-dev
++  libgraphite2-3
++  libgraphite2-dev
++  libgssapi-krb5-2
++  libgssrpc4
++  libgtk-3-0
++  libgtk-3-dev
++  libgtk2.0-0
++  libgudev-1.0-0
++  libharfbuzz-dev
++  libharfbuzz-gobject0
++  libharfbuzz-icu0
++  libharfbuzz0b
++  libhogweed6
++  libice6
++  libicu-le-hb0
++  libicu67
++  libidl-2-0
++  libidn12
++  libidn2-0
++  libinput-dev
++  libinput10
++  libjbig-dev
++  libjbig0
++  libjpeg62-turbo
++  libjpeg62-turbo-dev
++  libjson-glib-1.0-0
++  libjsoncpp-dev
++  libjsoncpp25
++  libk5crypto3
++  libkadm5clnt-mit12
++  libkadm5srv-mit12
++  libkdb5-10
++  libkeyutils1
++  libkrb5-3
++  libkrb5-dev
++  libkrb5support0
++  liblcms2-2
++  libldap-2.5-0
++  libltdl7
++  liblz4-1
++  liblzma5
++  liblzo2-2
++  libmd0
++  libminizip-dev
++  libminizip1
++  libmount-dev
++  libmount1
++  libmtdev1
++  libncurses-dev
++  libncurses6
++  libncursesw6
++  libnettle8
++  libnghttp2-14
++  libnsl2
++  libnspr4
++  libnspr4-dev
++  libnss-db
++  libnss3
++  libnss3-dev
++  libogg-dev
++  libogg0
++  libopengl0
++  libopus-dev
++  libopus0
++  libp11-kit0
++  libpam0g
++  libpam0g-dev
++  libpangocairo-1.0-0
++  libpangoft2-1.0-0
++  libpangoxft-1.0-0
++  libpci-dev
++  libpci3
++  libpciaccess0
++  libpcre16-3
++  libpcre2-16-0
++  libpcre2-32-0
++  libpcre2-8-0
++  libpcre2-dev
++  libpcre2-posix3
++  libpcre3
++  libpcre3-dev
++  libpcre32-3
++  libpcrecpp0v5
++  libpipewire-0.3-0
++  libpipewire-0.3-dev
++  libpixman-1-0
++  libpixman-1-dev
++  libpng-dev
++  libpng16-16
++  libpsl5
++  libpthread-stubs0-dev
++  libpulse-dev
++  libpulse-mainloop-glib0
++  libpulse0
++  libre2-9
++  libre2-dev
++  librest-0.7-0
++  librtmp1
++  libsasl2-2
++  libselinux1
++  libselinux1-dev
++  libsepol2
++  libsepol-dev
++  libsm6
++  libsnappy-dev
++  libsnappy1v5
++  libsndfile1
++  libsoup-gnome2.4-1
++  libsoup2.4-1
++  libspa-0.2-dev
++  libspeechd-dev
++  libspeechd2
++  libsqlite3-0
++  libssh2-1
++  libssl-dev
++  libssl1.1
++  libstdc++-10-dev
++  libstdc++6
++  libsystemd0
++  libtasn1-6
++  libthai-dev
++  libthai0
++  libtiff-dev
++  libtiff5
++  libtiffxx5
++  libtinfo6
++  libtirpc3
++  libudev-dev
++  libudev1
++  libunbound8
++  libunistring2
++  libutempter-dev
++  libutempter0
++  libuuid1
++  libva-dev
++  libva-drm2
++  libva-glx2
++  libva-wayland2
++  libva-x11-2
++  libva2
++  libvorbis0a
++  libvorbisenc2
++  libvulkan-dev
++  libvulkan1
++  libwacom9
++  libwayland-client0
++  libwayland-cursor0
++  libwayland-dev
++  libwayland-egl1
++  libwayland-egl1-mesa
++  libwayland-server0
++  libwebp-dev
++  libwebp7
++  libwebpdemux2
++  libwebpmux3
++  libwrap0
++  libx11-6
++  libx11-dev
++  libx11-xcb-dev
++  libx11-xcb1
++  libxau-dev
++  libxau6
++  libxcb-dri2-0
++  libxcb-dri2-0-dev
++  libxcb-dri3-0
++  libxcb-dri3-dev
++  libxcb-glx0
++  libxcb-glx0-dev
++  libxcb-present-dev
++  libxcb-present0
++  libxcb-render0
++  libxcb-render0-dev
++  libxcb-shm0
++  libxcb-shm0-dev
++  libxcb-sync1
++  libxcb-xfixes0
++  libxcb1
++  libxcb1-dev
++  libxcomposite-dev
++  libxcomposite1
++  libxcursor-dev
++  libxcursor1
++  libxdamage-dev
++  libxdamage1
++  libxdmcp-dev
++  libxdmcp6
++  libxext-dev
++  libxext6
++  libxfixes-dev
++  libxfixes3
++  libxft-dev
++  libxft2
++  libxi-dev
++  libxi6
++  libxinerama-dev
++  libxinerama1
++  libxkbcommon-dev
++  libxkbcommon0
++  libxml2
++  libxml2-dev
++  libxrandr-dev
++  libxrandr2
++  libxrender-dev
++  libxrender1
++  libxshmfence-dev
++  libxshmfence1
++  libxslt1-dev
++  libxslt1.1
++  libxss-dev
++  libxss1
++  libxt-dev
++  libxt6
++  libxtst-dev
++  libxtst6
++  libxxf86vm-dev
++  libxxf86vm1
++  libzstd1
++  linux-libc-dev
++  mesa-common-dev
++  shared-mime-info
++  uuid-dev
++  wayland-protocols
++  x11proto-core-dev
++  x11proto-dev
++  x11proto-input-dev
++  x11proto-kb-dev
++  x11proto-randr-dev
++  x11proto-record-dev
++  x11proto-render-dev
++  x11proto-scrnsaver-dev
++  x11proto-xext-dev
++  x11proto-xinerama-dev
++  zlib1g
++  zlib1g-dev
++"
++
++DEBIAN_PACKAGES_RISCV64="
++  libasan6
++  libgmp10
++  libgtk-4-1
++  libgtk-4-dev
++  libthai0
++"
++
++. "${SCRIPT_DIR}/sysroot-builder-riscv64.sh"
+-- 
+2.25.1
+

+ 4 - 12
README.md

@@ -73,7 +73,7 @@ solutions = [
 4. Checkout to specific commits where the patchset are based on.
 ```
 $ cd ~/chromium/src
-$ git checkout d02d5bc22b059
+$ git checkout 9fc37dca35728
 
 ```
 
@@ -124,15 +124,7 @@ $ cd ~/chromium/src
 $ git am <patch>
 ```
 
-8. Update swiftshader's dependencies.
-```
-$ cd third_party/swiftshader
-$ ./third_party/update-spirvtools.sh
-$ ./third_party/update-spirvheaders.sh
-$ ./third_party/update-marl.sh
-```
-
-9. Apply the patches in the untracked folder. This is due to third_party components are not tracked under the same git history.
+8. Apply the patches in the untracked folder. This is due to third_party components are not tracked under the same git history.
 
 NOTE: There is no script to help in this yet. So we have to run patch command manually in the respective folders.
 
@@ -142,7 +134,7 @@ $ cd third_party/<component>
 $ patch -p1 < ~/riscv64-chromium-patch/third_party/XXX.patch
 ```
 
-10. Setup ffmpeg.
+9. Setup ffmpeg.
 ```
 $ cd third_party/ffmpeg
 $ ./chromium/scripts/build_ffmpeg.py linux riscv64
@@ -150,7 +142,7 @@ $ ./chromium/scripts/generate_gn.py
 $ ./chromium/scripts/copy_config.sh
 ```
 
-11. Run the build and start resolving build issues.
+10. Run the build and start resolving build issues.
 ```
 $ autoninja -C out/riscv64 chrome
 ```

+ 4 - 4
0009-BUILD.gn-disable-printing-unittests.patch → archive/0001-BUILD.gn-disable-printing-unittests.patch

@@ -1,7 +1,7 @@
-From 8598515eb3ab065207a46ad4ec279328838554d7 Mon Sep 17 00:00:00 2001
+From 26d3a6cc2b01da7475e79231725caf245f8c65fe Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Fri, 14 Jan 2022 02:40:23 +0000
-Subject: [PATCH 09/21] BUILD.gn: disable printing unittests
+Subject: [PATCH] BUILD.gn: disable printing unittests
 
 Depends on cups-config in sysroot.
 Currently sysroot does not include cups-config.
@@ -12,10 +12,10 @@ Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  1 file changed, 4 deletions(-)
 
 diff --git a/BUILD.gn b/BUILD.gn
-index 8045dc8809750..21d17e9c88fc3 100644
+index 73aefc2325553..f3bb841e5419a 100644
 --- a/BUILD.gn
 +++ b/BUILD.gn
-@@ -268,10 +268,6 @@ group("gn_all") {
+@@ -282,10 +282,6 @@ group("gn_all") {
  
    deps += root_extra_deps
  

+ 8 - 8
0014-BUILD.gn-remove-libjpeg-turbo.patch → archive/0001-BUILD.gn-remove-libjpeg-turbo.patch

@@ -1,7 +1,7 @@
-From 833b9aa306cddebc85956f32a79db032df9cf300 Mon Sep 17 00:00:00 2001
+From 1b78e8e37881b715f828b52bc61ab0cc725b38a9 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
-Date: Fri, 14 Jan 2022 07:17:39 +0000
-Subject: [PATCH 14/21] BUILD.gn: remove libjpeg-turbo
+Date: Tue, 5 Apr 2022 01:53:24 +0000
+Subject: [PATCH] BUILD.gn: remove libjpeg-turbo
 
 riscv64 is not supported in libjpeg-turbo.
 
@@ -11,10 +11,10 @@ Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  1 file changed, 2 deletions(-)
 
 diff --git a/BUILD.gn b/BUILD.gn
-index 21d17e9c88fc3..31ac925dbe1b6 100644
+index f3bb841e5419a..d480858dff71a 100644
 --- a/BUILD.gn
 +++ b/BUILD.gn
-@@ -730,7 +730,6 @@ group("gn_all") {
+@@ -753,7 +753,6 @@ group("gn_all") {
        "//third_party/angle:libEGL",
        "//third_party/angle:libGLESv2",
        "//third_party/leveldatabase:leveldb_test_targets",
@@ -22,9 +22,9 @@ index 21d17e9c88fc3..31ac925dbe1b6 100644
        "//third_party/opus:opus_compare",
        "//third_party/opus:opus_demo",
        "//third_party/opus:test_opus_api",
-@@ -752,7 +751,6 @@ group("gn_all") {
-       if (enable_nacl) {
-         deps += [ "//native_client/src/trusted/platform_qualify:vcpuid" ]
+@@ -768,7 +767,6 @@ group("gn_all") {
+       if (!is_android) {
+         deps += [ "//chrome/test:load_library_perf_tests" ]
        }
 -      deps += [ "//third_party/libjpeg_turbo:simd_asm" ]
      }

+ 26 - 34
0018-breakpad-temporarily-disable-it.patch → archive/0001-breakpad-temporarily-disable-it.patch

@@ -1,12 +1,12 @@
-From cfaab11bccc1c8e55b42cc91d7429b4ee5e74c89 Mon Sep 17 00:00:00 2001
+From 5a5ea15181d5e18528a2c4486454c9dcf244c87e Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
-Date: Tue, 15 Feb 2022 06:06:40 +0000
-Subject: [PATCH 18/21] breakpad: temporarily disable it
+Date: Tue, 5 Apr 2022 02:25:00 +0000
+Subject: [PATCH] breakpad: temporarily disable it
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---
  BUILD.gn                                   |   38 +-
- chrome/BUILD.gn                            |    6 -
+ chrome/BUILD.gn                            |    5 -
  chrome/test/BUILD.gn                       |    4 -
  components/crash/content/browser/BUILD.gn  |    9 -
  components/crash/core/app/BUILD.gn         |   14 -
@@ -17,14 +17,14 @@ Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  remoting/host/setup/BUILD.gn               |    1 -
  third_party/breakpad/BUILD.gn              | 1146 --------------------
  tools/perf/chrome_telemetry_build/BUILD.gn |   17 -
- 12 files changed, 1 insertion(+), 1258 deletions(-)
+ 12 files changed, 1 insertion(+), 1257 deletions(-)
  delete mode 100644 third_party/breakpad/BUILD.gn
 
 diff --git a/BUILD.gn b/BUILD.gn
-index 31ac925dbe1b6..f88524c8c1435 100644
+index d480858dff71a..e31a9006e2eff 100644
 --- a/BUILD.gn
 +++ b/BUILD.gn
-@@ -434,10 +434,6 @@ group("gn_all") {
+@@ -449,10 +449,6 @@ group("gn_all") {
  
    if (is_linux || is_chromeos || is_android) {
      deps += [
@@ -35,7 +35,7 @@ index 31ac925dbe1b6..f88524c8c1435 100644
        "//tools/dump_process_memory:dump_process",
        "//tools/memory/partition_allocator:all",
      ]
-@@ -594,10 +590,6 @@ group("gn_all") {
+@@ -618,10 +614,6 @@ group("gn_all") {
        "//mojo:mojo_perftests",
        "//services/service_manager/public/cpp",
        "//testing/gmock:gmock_main",
@@ -46,7 +46,7 @@ index 31ac925dbe1b6..f88524c8c1435 100644
      ]
  
      if (!is_android) {
-@@ -623,9 +615,6 @@ group("gn_all") {
+@@ -647,9 +639,6 @@ group("gn_all") {
  
    if (is_mac) {
      deps += [
@@ -56,7 +56,7 @@ index 31ac925dbe1b6..f88524c8c1435 100644
        # The following are accessibility API tools.
        "//tools/accessibility/inspect:ax_dump_events",
        "//tools/accessibility/inspect:ax_dump_tree",
-@@ -670,8 +659,6 @@ group("gn_all") {
+@@ -693,8 +682,6 @@ group("gn_all") {
          host_os == "win") {
        deps += [ "//chrome/test/mini_installer:mini_installer_tests" ]
      }
@@ -65,7 +65,7 @@ index 31ac925dbe1b6..f88524c8c1435 100644
    }
  
    if (is_chromecast) {
-@@ -951,7 +938,6 @@ if (is_win) {
+@@ -966,7 +953,6 @@ if (is_win) {
        "//net:net_unittests",
        "//printing:printing_unittests",
        "//sql:sql_unittests",
@@ -73,7 +73,7 @@ index 31ac925dbe1b6..f88524c8c1435 100644
        "//ui/base:ui_base_unittests",
        "//ui/gfx:gfx_unittests",
        "//ui/touch_selection:ui_touch_selection_unittests",
-@@ -978,7 +964,6 @@ if (is_chromeos_ash) {
+@@ -993,7 +979,6 @@ if (is_chromeos_ash) {
        "//ppapi/examples/video_decode",
        "//sandbox/linux:chrome_sandbox",
        "//sandbox/linux:sandbox_linux_unittests",
@@ -81,7 +81,7 @@ index 31ac925dbe1b6..f88524c8c1435 100644
        "//third_party/dawn/src/dawn/tests:dawn_end2end_tests",
        "//third_party/dawn/src/dawn/tests:dawn_unittests",
  
-@@ -1123,31 +1108,12 @@ if (!is_ios) {
+@@ -1138,31 +1123,12 @@ if (!is_ios) {
  
      if (is_android) {
        data_deps += [
@@ -113,7 +113,7 @@ index 31ac925dbe1b6..f88524c8c1435 100644
      if (is_fuchsia) {
        data_deps += [
          "//build/config/fuchsia:deployment_resources",
-@@ -1526,10 +1492,8 @@ group("chromium_builder_perf") {
+@@ -1548,10 +1514,8 @@ group("chromium_builder_perf") {
  
      if (is_win) {
        data_deps += [ "//chrome/installer/mini_installer:mini_installer" ]
@@ -126,7 +126,7 @@ index 31ac925dbe1b6..f88524c8c1435 100644
        data_deps += [
          "//components:components_perftests",
 diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
-index 6a696e816a185..63471a722295c 100644
+index 6b8f8778d1700..d750cbd7a4402 100644
 --- a/chrome/BUILD.gn
 +++ b/chrome/BUILD.gn
 @@ -202,8 +202,6 @@ if (!is_android && !is_mac) {
@@ -162,19 +162,11 @@ index 6a696e816a185..63471a722295c 100644
        "--keystone=0",
        "--scm=1",
        "--branding",
-@@ -1307,7 +1302,6 @@ if (is_win) {
-         "//components/crash/core/app:chrome_crashpad_handler",
-         "//third_party/angle:libEGL",
-         "//third_party/angle:libGLESv2",
--        "//third_party/breakpad:dump_syms",
-         "//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
-         "//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
-         "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan",
 diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
-index 76f3c753e508a..d93a17bb977c1 100644
+index acde6777c6bc6..fac0628eb5a17 100644
 --- a/chrome/test/BUILD.gn
 +++ b/chrome/test/BUILD.gn
-@@ -399,7 +399,6 @@ static_library("test_support") {
+@@ -404,7 +404,6 @@ static_library("test_support") {
      ]
      public_deps += [
        "//components/crash/core/app",
@@ -182,7 +174,7 @@ index 76f3c753e508a..d93a17bb977c1 100644
      ]
    }
  
-@@ -9296,9 +9295,6 @@ test("chrome_app_unittests") {
+@@ -9435,9 +9434,6 @@ test("chrome_app_unittests") {
      "//components/heap_profiling/in_process",
      "//components/safe_browsing:buildflags",
    ]
@@ -309,10 +301,10 @@ index 31a7822c7ee9a..7de416b4ec498 100644
    }
  
 diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn
-index ae7cae154474d..7d89f3d82b4a0 100644
+index 603832550746d..0aacdf8bc6389 100644
 --- a/content/shell/BUILD.gn
 +++ b/content/shell/BUILD.gn
-@@ -651,7 +651,6 @@ if (is_mac) {
+@@ -653,7 +653,6 @@ if (is_mac) {
      testonly = true
      info_plist = "app/framework-Info.plist"
      args = [
@@ -320,7 +312,7 @@ index ae7cae154474d..7d89f3d82b4a0 100644
        "--keystone=0",
        "--scm=1",
        "--version",
-@@ -725,7 +724,6 @@ if (is_mac) {
+@@ -727,7 +726,6 @@ if (is_mac) {
      testonly = true
      info_plist = "app/helper-Info.plist"
      args = [
@@ -328,7 +320,7 @@ index ae7cae154474d..7d89f3d82b4a0 100644
        "--keystone=0",
        "--scm=0",
        "--version",
-@@ -884,19 +882,10 @@ group("content_shell_crash_test") {
+@@ -886,19 +884,10 @@ group("content_shell_crash_test") {
    if (is_win) {
      data_deps += [ "//build/win:copy_cdb_to_output" ]
    }
@@ -349,7 +341,7 @@ index ae7cae154474d..7d89f3d82b4a0 100644
      ]
    }
 diff --git a/remoting/base/BUILD.gn b/remoting/base/BUILD.gn
-index f3af132e9f0c3..a91aaaaf88f38 100644
+index 9e43e4274c873..38deff3d6d751 100644
 --- a/remoting/base/BUILD.gn
 +++ b/remoting/base/BUILD.gn
 @@ -256,7 +256,6 @@ static_library("test_support") {
@@ -374,7 +366,7 @@ index 14da0a2b67c96..4abcfd75918d8 100644
      "//remoting/host/base",
 diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn
 deleted file mode 100644
-index da663f2dd9b4a..0000000000000
+index 48defa6ef092c..0000000000000
 --- a/third_party/breakpad/BUILD.gn
 +++ /dev/null
 @@ -1,1146 +0,0 @@
@@ -459,7 +451,7 @@ index da663f2dd9b4a..0000000000000
 -# {micro,mini}dump_stackwalk and minidump_dump are tool-type executables
 -# that do not build on Windows.
 -if (!is_win) {
--  if (current_toolchain == host_toolchain) {
+-  if (current_toolchain == host_toolchain || target_os == "mac") {
 -    # Contains the code shared by both {micro,mini}dump_stackwalk.
 -    static_library("stackwalk_common") {
 -      sources = [
@@ -659,7 +651,7 @@ index da663f2dd9b4a..0000000000000
 -# Mac --------------------------------------------------------------------------
 -
 -if (is_mac) {
--  if (current_toolchain == host_toolchain) {
+-  if (current_toolchain == host_toolchain || target_os != "ios") {
 -    source_set("common") {
 -      sources = [
 -        "breakpad/src/common/dwarf/bytereader.cc",

+ 2 - 2
0016-build-config-make-sure-target_cpu-is-honored-in-tool.patch → archive/0001-build-config-make-sure-target_cpu-is-honored-in-tool.patch

@@ -1,7 +1,7 @@
-From a0672ff0b3d2e2b26378ba9f84997165cd133a77 Mon Sep 17 00:00:00 2001
+From 41a39ad79244bcbd710e496a3bdab94d0309ce85 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Fri, 14 Jan 2022 07:30:10 +0000
-Subject: [PATCH 16/21] build: config: make sure target_cpu is honored in
+Subject: [PATCH] build: config: make sure target_cpu is honored in
  toolchain settings
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>

+ 2 - 2
0021-build-gn_run_binary.py-do-not-run-binary-from.patch → archive/0001-build-gn_run_binary.py-do-not-run-binary-from.patch

@@ -1,7 +1,7 @@
-From 7cb03c28659afc015141337440098ac0afec449a Mon Sep 17 00:00:00 2001
+From a2522cb27a828a7cd37ae553eb21d10764acf316 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Wed, 19 Jan 2022 05:48:04 +0000
-Subject: [PATCH 21/21] build: gn_run_binary.py: do not run binary from ./
+Subject: [PATCH] build: gn_run_binary.py: do not run binary from ./
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---

+ 2 - 2
0013-media-gpu-disable-tests.patch → archive/0001-media-gpu-disable-tests.patch

@@ -1,7 +1,7 @@
-From 256e69acbdadc608f198cc727d96dc5f607e58da Mon Sep 17 00:00:00 2001
+From 89d89e36b1fe1505c19e634faedfebf74279c1d0 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Fri, 14 Jan 2022 07:16:30 +0000
-Subject: [PATCH 13/21] media: gpu: disable tests
+Subject: [PATCH] media: gpu: disable tests
 
 Unable to assert "enable_av1_decoder".
 

+ 7 - 7
0019-media-media_options-disable-dav1d-decoder.patch → archive/0001-media-media_options-disable-dav1d-decoder.patch

@@ -1,7 +1,7 @@
-From 709f9e81fc71ae3d3f1b4850db91a38b1a9a3a87 Mon Sep 17 00:00:00 2001
+From 5282570bdd05f688bbc7f31d6a8cd3716f84a48b Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Fri, 14 Jan 2022 09:07:44 +0000
-Subject: [PATCH 19/21] media: media_options: disable dav1d decoder
+Subject: [PATCH] media: media_options: disable dav1d decoder
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---
@@ -22,7 +22,7 @@ Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  delete mode 100644 third_party/dav1d/BUILD.gn
 
 diff --git a/media/BUILD.gn b/media/BUILD.gn
-index e1683ef9e76ef..7d34fe24bd32f 100644
+index 01e0910666e86..e716c6604f546 100644
 --- a/media/BUILD.gn
 +++ b/media/BUILD.gn
 @@ -26,7 +26,6 @@ buildflag_header("media_buildflags") {
@@ -126,7 +126,7 @@ index 676a02b8ad3a0..541b7ffca7f92 100644
  #include "testing/gmock/include/gmock/gmock.h"
  
 diff --git a/media/gpu/video_decode_accelerator_tests.cc b/media/gpu/video_decode_accelerator_tests.cc
-index bce49fb05f659..1d122ce1c0624 100644
+index a6b95fef61746..636cb8fc38eda 100644
 --- a/media/gpu/video_decode_accelerator_tests.cc
 +++ b/media/gpu/video_decode_accelerator_tests.cc
 @@ -29,9 +29,7 @@
@@ -141,7 +141,7 @@ index bce49fb05f659..1d122ce1c0624 100644
  #endif
  
 diff --git a/media/media_options.gni b/media/media_options.gni
-index 1b2af27c5079d..55316f6f124d8 100644
+index 1b9eec3e63996..5a35f4960dffb 100644
 --- a/media/media_options.gni
 +++ b/media/media_options.gni
 @@ -74,7 +74,7 @@ declare_args() {
@@ -154,7 +154,7 @@ index 1b2af27c5079d..55316f6f124d8 100644
    # Enable browser managed persistent metadata storage for EME persistent
    # session and persistent usage record session.
 diff --git a/media/renderers/default_decoder_factory.cc b/media/renderers/default_decoder_factory.cc
-index f077e56c7eccc..a3b7917d07a06 100644
+index 430ec53038a84..7cfe5d072e759 100644
 --- a/media/renderers/default_decoder_factory.cc
 +++ b/media/renderers/default_decoder_factory.cc
 @@ -26,10 +26,6 @@
@@ -184,7 +184,7 @@ index 4afe60de61139..afad5ee5acfbf 100644
  #include "media/filters/ffmpeg_audio_decoder.h"
  #include "media/filters/ffmpeg_demuxer.h"
 diff --git a/media/video/software_video_encoder_test.cc b/media/video/software_video_encoder_test.cc
-index 21d7ccc59cd93..a72ec4aeb9562 100644
+index 4c8e81626dd78..e234ef927c33f 100644
 --- a/media/video/software_video_encoder_test.cc
 +++ b/media/video/software_video_encoder_test.cc
 @@ -43,9 +43,6 @@

+ 2 - 2
0004-third_party-widevine-define-WIDEVINE_CDM_VERSION_STR.patch → archive/0001-third_party-widevine-define-WIDEVINE_CDM_VERSION_STR.patch

@@ -1,7 +1,7 @@
-From 562ea279e3b0af137a08e0811cb7c9e9826bf3ab Mon Sep 17 00:00:00 2001
+From e10182c0a7811b7db6d77183df3c6befb299b527 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Thu, 13 Jan 2022 09:11:17 +0000
-Subject: [PATCH 04/21] third_party: widevine: define
+Subject: [PATCH] third_party: widevine: define
  WIDEVINE_CDM_VERSION_STRING
 
 Port over from Fedora's patch list.

+ 2 - 2
0002-third_party-zlib-do-not-mangle-zlib.patch → archive/0001-third_party-zlib-do-not-mangle-zlib.patch

@@ -1,7 +1,7 @@
-From 616b0bd3e38cd4accdf74bed4ce1a2d683d57637 Mon Sep 17 00:00:00 2001
+From 1960ae0d483def599b1d8372f0514c89842e2843 Mon Sep 17 00:00:00 2001
 From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 Date: Thu, 13 Jan 2022 08:51:04 +0000
-Subject: [PATCH 02/21] third_party: zlib: do not mangle zlib
+Subject: [PATCH] third_party: zlib: do not mangle zlib
 
 Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
 ---

文件差异内容过多而无法显示
+ 0 - 37525
third_party/0001-third-party-swiftshader.patch


部分文件因为文件数量过多而无法显示