Browse Source

rebase to Chromium 101.0.4951.67

Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
Rebecca Chang Swee Fun 1 year ago
parent
commit
b09ffc7feb
73 changed files with 4892 additions and 0 deletions
  1. 1864 0
      0001-sandbox-add-riscv-arch-definition-and-define-syscall.patch
  2. 45 0
      0002-chrome-installer-add-riscv64-as-one-of-the-target-ar.patch
  3. 49 0
      0003-components-update_client-add-riscv64-arch-definition.patch
  4. 26 0
      0004-skia-add-riscv64-architecture-detection.patch
  5. 244 0
      0005-sql-make-VirtualCursor-standard-layout-type.patch
  6. 26 0
      0006-tflite_support-add-cflags-to-resolve-build-issues.patch
  7. 27 0
      0007-tflite_support-fix-absolute-value-function-abs-when-.patch
  8. 27 0
      0008-tflite_support-fix-Wdefaulted-function-deleted-warni.patch
  9. 51 0
      0009-tools-clang-scripts-add-RISCV-as-one-of-the-llvm-tar.patch
  10. 27 0
      0010-tools-clang-script-add-atomic-build-flag-for-native-.patch
  11. 26 0
      0011-tools-clang-scripts-update-clang-triple-for-riscv64.patch
  12. 25 0
      0012-ui-gl-enable-swiftshader-for-riscv64.patch
  13. 87 0
      0013-third_party-dav1d-enable-riscv64-build.patch
  14. 154 0
      0014-third_party-boringssl-update-gn-for-latest-src-tree.patch
  15. 26 0
      0015-third_party-libaom-enable-riscv64-build-as-generic.patch
  16. 26 0
      0016-DEPS-bump-swiftshader-to-latest.patch
  17. 26 0
      0017-DEPS-update-boringssl-to-latest-HEAD.patch
  18. 26 0
      0018-base-process-add-riscv64-arch-definition.patch
  19. 147 0
      0019-DEPS-change-some-third_party-repos-to-fetch-from-dev.patch
  20. 26 0
      0020-DEPS-update-lss-to-latest.patch
  21. 37 0
      0021-DEPS-use-DEPS-to-pull-in-v8-source-tree.patch
  22. 30 0
      0022-DEPS-use-DEPS-to-pull-in-nwjs-forked-repo.patch
  23. 26 0
      0023-DEPS-update-commit-hash-for-ffmpeg.patch
  24. 34 0
      0024-build-config-linux-workaround-for-files-not-found-wi.patch
  25. 48 0
      0025-build-config-compiler-add-build-flags-for-clang.patch
  26. 45 0
      0026-build-config-compiler-set-generic-riscv64-flags.patch
  27. 34 0
      0027-build-toolchain-linux-enable-clang-toolchain-for-ris.patch
  28. 25 0
      0028-build-config-BUILD.gn-add-atomic-build-flag.patch
  29. 26 0
      0029-build-config-compiler-skip-warnings-treated-as-error.patch
  30. 26 0
      0030-build-config-add-v8-target-cpu-for-riscv64.patch
  31. 25 0
      0031-build-toolchain-linux-do-not-use-lld-by-default.patch
  32. 41 0
      0032-reduce-warnings-flag-as-error.patch
  33. 25 0
      0033-build-config-compiler-skip-warning-for-ffmpeg.patch
  34. 30 0
      0034-third_party-libzip-resolve-macro-redefined-issue.patch
  35. 26 0
      0035-third_party-pffft-add-riscv64-arch-detection.patch
  36. 57 0
      0036-BUILD.gn-disable-chrome-related-test.patch
  37. 26 0
      0037-add-workaround-to-avoid-rebuild-sysroot.patch
  38. 36 0
      0038-add-path-to-riscv64-sysroot.patch
  39. 26 0
      0039-pkg-config.py-add-riscv-sysroot-path-to-system_libdi.patch
  40. 42 0
      0040-GN-Wayland-build-overrides.patch
  41. 26 0
      0041-DEPS-update-commit-hash-for-angle.patch
  42. 806 0
      0042-third_party-crashpad-port-for-RISC-V.patch
  43. 115 0
      0043-BUILD.gn-remove-dependency-to-breakpad.patch
  44. 64 0
      0044-tools-perf-chrome_telemetry_build-remove-dependency-.patch
  45. 35 0
      0045-chrome-test-remove-dependency-to-breakpad.patch
  46. 68 0
      0046-content-shell-remove-dependency-to-breakpad.patch
  47. 53 0
      0047-third_party-libvpx-enable-riscv64-build-as-generic.patch
  48. 29 0
      0048-DEPS-update-commit-hash-for-ffmpeg.patch
  49. 26 0
      0049-third_party-breakpad-fix-undefined-reference.patch
  50. 25 0
      0050-build-config-compiler-add-march-for-riscv64.patch
  51. 25 0
      0051-build-config-compiler-add-rpath-link-for-rv64.patch
  52. 0 0
      archive/0001-linux-sysroot-script-to-create-riscv-sysroot-from-De.patch
  53. 0 0
      archive/0002-sandbox-add-riscv-arch-definition-and-define-syscall.patch
  54. 0 0
      archive/0004-skia-add-riscv64.patch
  55. 0 0
      archive/0005-base-allocator-partition_allocator-add-riscv64-suppo.patch
  56. 0 0
      archive/0006-base-process-add-riscv64-arch-definition.patch
  57. 0 0
      archive/0007-remoting-fix-missing-cstring-header.patch
  58. 0 0
      archive/0008-remoting-codec-fix-missing-cmath-header.patch
  59. 0 0
      archive/0009-components-update_client-add-riscv64-arch-definition.patch
  60. 0 0
      archive/0010-build-config-compiler-use_gold-linker-option.patch
  61. 0 0
      archive/0011-build-config-compiler-remove-flags-not-available-in-.patch
  62. 0 0
      archive/0012-build-config-add-atomic-build-flag.patch
  63. 0 0
      archive/0013-build-config-compiler-do-not-use-linker-relaxation.patch
  64. 0 0
      archive/0014-chrome-common-remove-unrar-code.patch
  65. 0 0
      archive/0015-third_party-libaom-add-riscv-target.patch
  66. 0 0
      archive/0016-third_party-libvpx-add-riscv-target.patch
  67. 0 0
      archive/0017-third_party-crashpad-add-support-for-riscv.patch
  68. 0 0
      archive/0018-third_party-lzma_sdk-add-riscv-arch-definition.patch
  69. 0 0
      archive/0019-build-linux-sysroot-create-a-sysroot-for-riscv.patch
  70. 0 0
      archive/0020-build-config-linux-workaround-for-files-not-found-wi.patch
  71. 0 0
      archive/0021-v8-settings.patch
  72. 0 0
      archive/0022-chrome-installer-add-riscv64-as-one-of-the-target-ar.patch
  73. 0 0
      archive/0023-ui-gl-enable-swiftshader-for-riscv64.patch

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

@@ -0,0 +1,1864 @@
+From d28ebcf197fb1f739ed78dea425e159f878df48d Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 15 Jun 2022 08:27:45 +0000
+Subject: [PATCH 01/51] sandbox: add riscv arch definition and define syscall
+
+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/BUILD.gn                        |    5 +
+ 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 |   71 +-
+ .../linux/seccomp-bpf-helpers/syscall_sets.h  |   14 +-
+ sandbox/linux/seccomp-bpf/syscall.cc          |   35 +-
+ sandbox/linux/services/credentials.cc         |    2 +-
+ sandbox/linux/services/syscall_wrappers.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   | 1074 +++++++++++++++++
+ .../linux/bpf_cros_amd_gpu_policy_linux.cc    |    2 +-
+ sandbox/policy/linux/bpf_gpu_policy_linux.cc  |    2 +-
+ 19 files changed, 1251 insertions(+), 54 deletions(-)
+ create mode 100644 sandbox/linux/system_headers/riscv64_linux_syscalls.h
+
+diff --git a/sandbox/features.gni b/sandbox/features.gni
+index ad067ada520b..c9f67f81618f 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/BUILD.gn b/sandbox/linux/BUILD.gn
+index ec24cd81e274..60c60d741bf6 100644
+--- a/sandbox/linux/BUILD.gn
++++ b/sandbox/linux/BUILD.gn
+@@ -292,11 +292,16 @@ if (is_linux || is_chromeos) {
+     cflags = [
+       # For ULLONG_MAX
+       "-std=gnu99",
++      "-fPIE",
+ 
+       # These files have a suspicious comparison.
+       # TODO fix this and re-enable this warning.
+       "-Wno-sign-compare",
+     ]
++
++    ldflags = [
++      "-pie",
++    ]
+   }
+ }
+ 
+diff --git a/sandbox/linux/bpf_dsl/linux_syscall_ranges.h b/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
+index 313511f22e95..104dabde1cc0 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 961a8cf7521e..7c9a0c99e8fb 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 30c15cccb5c1..06c6026a26fa 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 9728d0b52e68..6f6e3984028b 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.
+@@ -438,7 +439,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 b3cf6fc7e86f..39dceabf07c3 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,7 @@ 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:
+@@ -915,7 +915,7 @@ bool SyscallSets::IsSystemVSemaphores(int sysno) {
+ #endif
+ 
+ #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
+-    defined(__aarch64__) ||                                         \
++    defined(__aarch64__) || defined(__riscv) ||                     \
+     (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ // These give a lot of ambient authority and bypass the setuid sandbox.
+ bool SyscallSets::IsSystemVSharedMemory(int sysno) {
+@@ -932,7 +932,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 +964,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 +1002,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 +1140,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 +1175,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 6403f45dc2f7..7110d3f6999c 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,18 +79,21 @@ 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
+ 
+ #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 IsSystemVMessageQueue(int sysno);
+ #endif
+ 
+@@ -117,6 +120,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 2e0e810383b5..37f60d3333e0 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 00b969ee02a7..7fa1a42ca41c 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/services/syscall_wrappers.cc b/sandbox/linux/services/syscall_wrappers.cc
+index f863cd005141..b6d7dac2cab4 100644
+--- a/sandbox/linux/services/syscall_wrappers.cc
++++ b/sandbox/linux/services/syscall_wrappers.cc
+@@ -61,7 +61,7 @@ long sys_clone(unsigned long flags,
+ #if defined(ARCH_CPU_X86_64)
+   return syscall(__NR_clone, flags, child_stack, ptid, ctid, tls);
+ #elif defined(ARCH_CPU_X86) || defined(ARCH_CPU_ARM_FAMILY) || \
+-    defined(ARCH_CPU_MIPS_FAMILY)
++    defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY)
+   // CONFIG_CLONE_BACKWARDS defined.
+   return syscall(__NR_clone, flags, child_stack, ptid, tls, ctid);
+ #endif
+diff --git a/sandbox/linux/syscall_broker/broker_process.cc b/sandbox/linux/syscall_broker/broker_process.cc
+index 7dd4688011f9..11422693463d 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 7d898d84631a..0b144fe30c32 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 74bbb8ef8c74..db6159f754ce 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 5f49a958499e..32ab256cfca4 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 2b78a0cc3b97..968d6f71b586 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 000000000000..f8fcd06bc2f2
+--- /dev/null
++++ b/sandbox/linux/system_headers/riscv64_linux_syscalls.h
+@@ -0,0 +1,1074 @@
++// 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
++
++#if !defined(__NR_faccessat2)
++#define __NR_faccessat2 439
++#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 cd64d06ae39d..1dad48a7caae 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 f8df9dcbd931..4a6287aba2ef 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
+

+ 45 - 0
0002-chrome-installer-add-riscv64-as-one-of-the-target-ar.patch

@@ -0,0 +1,45 @@
+From 616f135a309141a7373094275b4af811f9c51d13 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Fri, 17 Jun 2022 00:29:10 +0000
+Subject: [PATCH 02/51] chrome: installer: add riscv64 as one of the target
+ arch
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ chrome/installer/linux/BUILD.gn | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/chrome/installer/linux/BUILD.gn b/chrome/installer/linux/BUILD.gn
+index 6623fff2ba8a..104b8b5bb135 100644
+--- a/chrome/installer/linux/BUILD.gn
++++ b/chrome/installer/linux/BUILD.gn
+@@ -477,6 +477,8 @@ template("linux_package") {
+       deb_arch = "mipsel"
+     } else if (current_cpu == "mips64el") {
+       deb_arch = "mips64el"
++    } else if (current_cpu == "riscv64") {
++      deb_arch = "riscv64"
+     } else {
+       assert(false, "Linux installer not configured for this architecture.")
+     }
+@@ -526,6 +528,8 @@ template("linux_package") {
+         rpm_arch = "mipsel"
+       } else if (current_cpu == "mips64el") {
+         rpm_arch = "mips64el"
++      } else if (current_cpu == "riscv64") {
++        rpm_arch = "riscv64"
+       } else {
+         assert(false, "Linux installer not configured for this architecture.")
+       }
+@@ -579,6 +583,8 @@ template("linux_package") {
+           snap_arch = "armhf"
+         } else if (current_cpu == "arm64") {
+           snap_arch = "arm64"
++        } else if (current_cpu == "riscv64") {
++          snap_arch = "riscv64"
+         } else {
+           assert(false, "Linux installer not configured for this architecture.")
+         }
+-- 
+2.25.1
+

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

@@ -0,0 +1,49 @@
+From cb298ae5e0b8c7c773482e2710ff0dd76778e51f Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 07:50:43 +0000
+Subject: [PATCH 03/51] 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 6abf11963c85..a00bbb63ac5e 100644
+--- a/components/update_client/update_query_params.cc
++++ b/components/update_client/update_query_params.cc
+@@ -59,6 +59,8 @@ const char kArch[] =
+     "mipsel";
+ #elif defined(__powerpc64__)
+     "ppc64";
++#elif defined(__riscv) && (__riscv_xlen == 64)
++    "riscv64";
+ #else
+ #error "unknown arch"
+ #endif
+@@ -130,6 +132,8 @@ const char* UpdateQueryParams::GetNaclArch() {
+   return "mips64";
+ #elif defined(ARCH_CPU_PPC64)
+   return "ppc64";
++#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 a22f8b85bc0d..969582bf9228 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
+

+ 26 - 0
0004-skia-add-riscv64-architecture-detection.patch

@@ -0,0 +1,26 @@
+From 5598487be6d2fe73e2e45a954321b3a87a1696e2 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 04/51] skia: add riscv64 architecture detection
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ skia/BUILD.gn | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/skia/BUILD.gn b/skia/BUILD.gn
+index 5c3a90ee7fcd..daea4ff50a4b 100644
+--- a/skia/BUILD.gn
++++ b/skia/BUILD.gn
+@@ -809,6 +809,8 @@ skia_source_set("skia_opts") {
+     sources = skia_opts.none_sources
+   } else if (current_cpu == "s390x") {
+     sources = skia_opts.none_sources
++  } else if (current_cpu == "riscv64") {
++    sources = skia_opts.none_sources
+   } else {
+     assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
+   }
+-- 
+2.25.1
+

+ 244 - 0
0005-sql-make-VirtualCursor-standard-layout-type.patch

@@ -0,0 +1,244 @@
+From 067e71f191b6253b4e1101e7e04c2e614d0ed255 Mon Sep 17 00:00:00 2001
+From: Stephan Hartmann <stha09@googlemail.com>
+Date: Fri, 29 Jul 2022 05:08:08 +0000
+Subject: [PATCH 05/51] sql: make VirtualCursor standard layout type
+
+sql::recover::VirtualCursor needs to be a standard layout type, but
+has members of type std::unique_ptr. However, std::unique_ptr is not
+guaranteed to be standard layout. Compiling with clang combined with
+gcc-11 libstdc++ fails because of this. Replace std::unique_ptr with
+raw pointers.
+
+Bug: 1189788
+Change-Id: Ia6dc388cc5ef1c0f2afc75f8ca45b9f12687ca9c
+
+Signed-off-by: Stephan Hartmann <stha09@googlemail.com>
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ sql/recover_module/btree.cc  | 21 +++++++++++++++------
+ sql/recover_module/btree.h   | 17 +++++++++++++----
+ sql/recover_module/cursor.cc | 24 ++++++++++++------------
+ sql/recover_module/cursor.h  |  2 +-
+ sql/recover_module/pager.cc  |  7 +++----
+ sql/recover_module/pager.h   |  5 +++--
+ 6 files changed, 47 insertions(+), 29 deletions(-)
+
+diff --git a/sql/recover_module/btree.cc b/sql/recover_module/btree.cc
+index cc9420e5c05c..62fcaaf79edc 100644
+--- a/sql/recover_module/btree.cc
++++ b/sql/recover_module/btree.cc
+@@ -136,16 +136,25 @@ static_assert(std::is_trivially_destructible<LeafPageDecoder>::value,
+               "Move the destructor to the .cc file if it's non-trival");
+ #endif  // !DCHECK_IS_ON()
+ 
+-LeafPageDecoder::LeafPageDecoder(DatabasePageReader* db_reader) noexcept
+-    : page_id_(db_reader->page_id()),
+-      db_reader_(db_reader),
+-      cell_count_(ComputeCellCount(db_reader)),
+-      next_read_index_(0),
+-      last_record_size_(0) {
++void LeafPageDecoder::Initialize(DatabasePageReader* db_reader) {
++  DCHECK(db_reader);
+   DCHECK(IsOnValidPage(db_reader));
++  page_id_ = db_reader->page_id();
++  db_reader_ = db_reader;
++  cell_count_ = ComputeCellCount(db_reader);
++  next_read_index_ = 0;
++  last_record_size_ = 0;
+   DCHECK(DatabasePageReader::IsValidPageId(page_id_));
+ }
+ 
++void LeafPageDecoder::Reset() {
++  db_reader_ = nullptr;
++  page_id_ = 0;
++  cell_count_ = 0;
++  next_read_index_ = 0;
++  last_record_size_ = 0;
++}
++
+ bool LeafPageDecoder::TryAdvance() {
+   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+   DCHECK(CanAdvance());
+diff --git a/sql/recover_module/btree.h b/sql/recover_module/btree.h
+index eaa087a5c52b..78ce00e057c4 100644
+--- a/sql/recover_module/btree.h
++++ b/sql/recover_module/btree.h
+@@ -103,7 +103,7 @@ class LeafPageDecoder {
+   //
+   // |db_reader| must have been used to read an inner page of a table B-tree.
+   // |db_reader| must outlive this instance.
+-  explicit LeafPageDecoder(DatabasePageReader* db_reader) noexcept;
++  explicit LeafPageDecoder() noexcept = default;
+   ~LeafPageDecoder() noexcept = default;
+ 
+   LeafPageDecoder(const LeafPageDecoder&) = delete;
+@@ -151,6 +151,15 @@ class LeafPageDecoder {
+   // read as long as CanAdvance() returns true.
+   bool TryAdvance();
+ 
++  // Initialize with DatabasePageReader
++  void Initialize(DatabasePageReader* db_reader);
++
++  // Reset internal DatabasePageReader
++  void Reset();
++
++  // True if DatabasePageReader is valid
++  bool IsValid() { return (db_reader_ != nullptr); }
++
+   // True if the given reader may point to an inner page in a table B-tree.
+   //
+   // The last ReadPage() call on |db_reader| must have succeeded.
+@@ -164,14 +173,14 @@ class LeafPageDecoder {
+   static int ComputeCellCount(DatabasePageReader* db_reader);
+ 
+   // The number of the B-tree page this reader is reading.
+-  const int64_t page_id_;
++  int64_t page_id_;
+   // Used to read the tree page.
+   //
+   // Raw pointer usage is acceptable because this instance's owner is expected
+   // to ensure that the DatabasePageReader outlives this.
+-  DatabasePageReader* const db_reader_;
++  DatabasePageReader* db_reader_;
+   // Caches the ComputeCellCount() value for this reader's page.
+-  const int cell_count_ = ComputeCellCount(db_reader_);
++  int cell_count_;
+ 
+   // The reader's cursor state.
+   //
+diff --git a/sql/recover_module/cursor.cc b/sql/recover_module/cursor.cc
+index 4f827edf1b44..240de4999fe5 100644
+--- a/sql/recover_module/cursor.cc
++++ b/sql/recover_module/cursor.cc
+@@ -28,7 +28,7 @@ VirtualCursor::~VirtualCursor() {
+ int VirtualCursor::First() {
+   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+   inner_decoders_.clear();
+-  leaf_decoder_ = nullptr;
++  leaf_decoder_.Reset();
+ 
+   AppendPageDecoder(table_->root_page_id());
+   return Next();
+@@ -38,18 +38,18 @@ int VirtualCursor::Next() {
+   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+   record_reader_.Reset();
+ 
+-  while (!inner_decoders_.empty() || leaf_decoder_.get()) {
+-    if (leaf_decoder_.get()) {
+-      if (!leaf_decoder_->CanAdvance()) {
++  while (!inner_decoders_.empty() || leaf_decoder_.IsValid()) {
++    if (leaf_decoder_.IsValid()) {
++      if (!leaf_decoder_.CanAdvance()) {
+         // The leaf has been exhausted. Remove it from the DFS stack.
+-        leaf_decoder_ = nullptr;
++        leaf_decoder_.Reset();
+         continue;
+       }
+-      if (!leaf_decoder_->TryAdvance())
++      if (!leaf_decoder_.TryAdvance())
+         continue;
+ 
+-      if (!payload_reader_.Initialize(leaf_decoder_->last_record_size(),
+-                                      leaf_decoder_->last_record_offset())) {
++      if (!payload_reader_.Initialize(leaf_decoder_.last_record_size(),
++                                      leaf_decoder_.last_record_offset())) {
+         continue;
+       }
+       if (!record_reader_.Initialize())
+@@ -101,13 +101,13 @@ int VirtualCursor::ReadColumn(int column_index,
+ int64_t VirtualCursor::RowId() {
+   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+   DCHECK(record_reader_.IsInitialized());
+-  DCHECK(leaf_decoder_.get());
+-  return leaf_decoder_->last_record_rowid();
++  DCHECK(leaf_decoder_.IsValid());
++  return leaf_decoder_.last_record_rowid();
+ }
+ 
+ void VirtualCursor::AppendPageDecoder(int page_id) {
+   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+-  DCHECK(leaf_decoder_.get() == nullptr)
++  DCHECK(!leaf_decoder_.IsValid())
+       << __func__
+       << " must only be called when the current path has no leaf decoder";
+ 
+@@ -115,7 +115,7 @@ void VirtualCursor::AppendPageDecoder(int page_id) {
+     return;
+ 
+   if (LeafPageDecoder::IsOnValidPage(&db_reader_)) {
+-    leaf_decoder_ = std::make_unique<LeafPageDecoder>(&db_reader_);
++    leaf_decoder_.Initialize(&db_reader_);
+     return;
+   }
+ 
+diff --git a/sql/recover_module/cursor.h b/sql/recover_module/cursor.h
+index 845b7852648d..cc4e85f83f95 100644
+--- a/sql/recover_module/cursor.h
++++ b/sql/recover_module/cursor.h
+@@ -130,7 +130,7 @@ class VirtualCursor {
+   std::vector<std::unique_ptr<InnerPageDecoder>> inner_decoders_;
+ 
+   // Decodes the leaf page containing records.
+-  std::unique_ptr<LeafPageDecoder> leaf_decoder_;
++  LeafPageDecoder leaf_decoder_;
+ 
+   SEQUENCE_CHECKER(sequence_checker_);
+ };
+diff --git a/sql/recover_module/pager.cc b/sql/recover_module/pager.cc
+index 58e75de27042..5fe96204e56b 100644
+--- a/sql/recover_module/pager.cc
++++ b/sql/recover_module/pager.cc
+@@ -23,8 +23,7 @@ static_assert(DatabasePageReader::kMaxPageId <= std::numeric_limits<int>::max(),
+               "ints are not appropriate for representing page IDs");
+ 
+ DatabasePageReader::DatabasePageReader(VirtualTable* table)
+-    : page_data_(std::make_unique<uint8_t[]>(table->page_size())),
+-      table_(table) {
++    : page_data_(), table_(table) {
+   DCHECK(table != nullptr);
+   DCHECK(IsValidPageSize(table->page_size()));
+ }
+@@ -57,8 +56,8 @@ int DatabasePageReader::ReadPage(int page_id) {
+                     std::numeric_limits<int64_t>::max(),
+                 "The |read_offset| computation above may overflow");
+ 
+-  int sqlite_status =
+-      RawRead(sqlite_file, read_size, read_offset, page_data_.get());
++  int sqlite_status = RawRead(sqlite_file, read_size, read_offset,
++                              const_cast<uint8_t*>(page_data_.data()));
+ 
+   // |page_id_| needs to be set to kInvalidPageId if the read failed.
+   // Otherwise, future ReadPage() calls with the previous |page_id_| value
+diff --git a/sql/recover_module/pager.h b/sql/recover_module/pager.h
+index 07cac3cb9891..646e0223fd78 100644
+--- a/sql/recover_module/pager.h
++++ b/sql/recover_module/pager.h
+@@ -5,6 +5,7 @@
+ #ifndef SQL_RECOVER_MODULE_PAGER_H_
+ #define SQL_RECOVER_MODULE_PAGER_H_
+ 
++#include <array>
+ #include <cstdint>
+ #include <memory>
+ #include <ostream>
+@@ -72,7 +73,7 @@ class DatabasePageReader {
+     DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+     DCHECK_NE(page_id_, kInvalidPageId)
+         << "Successful ReadPage() required before accessing pager state";
+-    return page_data_.get();
++    return page_data_.data();
+   }
+ 
+   // The number of bytes in the page read by the last ReadPage() call.
+@@ -139,7 +140,7 @@ class DatabasePageReader {
+   int page_id_ = kInvalidPageId;
+   // Stores the bytes of the last page successfully read by ReadPage().
+   // The content is undefined if the last call to ReadPage() did not succeed.
+-  const std::unique_ptr<uint8_t[]> page_data_;
++  const std::array<uint8_t, kMaxPageSize> page_data_;
+   // Raw pointer usage is acceptable because this instance's owner is expected
+   // to ensure that the VirtualTable outlives this.
+   const raw_ptr<VirtualTable> table_;
+-- 
+2.25.1
+

+ 26 - 0
0006-tflite_support-add-cflags-to-resolve-build-issues.patch

@@ -0,0 +1,26 @@
+From 32c1cad01d6e97e28927c59368d6c50de8bb8065 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 1 Aug 2022 17:27:10 +0800
+Subject: [PATCH 06/51] tflite_support: add cflags to resolve build issues
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ third_party/tflite_support/BUILD.gn | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/third_party/tflite_support/BUILD.gn b/third_party/tflite_support/BUILD.gn
+index 6d9c6a09d9f2..284ef4c742d2 100644
+--- a/third_party/tflite_support/BUILD.gn
++++ b/third_party/tflite_support/BUILD.gn
+@@ -40,6 +40,8 @@ config("tflite_support_flags") {
+     "-Wno-ignored-attributes",
+     "-Wno-deprecated-declarations",
+     "-Wno-unused-variable",
++    "-Wno-defaulted-function-deleted",
++    "-Wno-absolute-value",
+   ]
+   if (!is_win) {
+     cflags_cc = [ "-frtti" ]
+-- 
+2.25.1
+

+ 27 - 0
0007-tflite_support-fix-absolute-value-function-abs-when-.patch

@@ -0,0 +1,27 @@
+From 9f6c1313fc8e1622b36ed29b6997be817084975b Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 3 Aug 2022 17:19:28 +0800
+Subject: [PATCH 07/51] tflite_support: fix absolute value function 'abs' when
+ argument is floating point
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ .../src/tensorflow_lite_support/cc/task/core/category.h         | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/category.h b/third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/category.h
+index 9fadd6a5cfe8..8dfed71da46d 100644
+--- a/third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/category.h
++++ b/third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/category.h
+@@ -33,7 +33,7 @@ struct Category {
+   friend bool operator==(const Category& lhs, const Category& rhs) {
+     constexpr const double kScoreTolerance = 1e-6;
+     return lhs.class_name == rhs.class_name &&
+-           abs((double)(lhs.score - rhs.score)) <= kScoreTolerance;
++           fabs((double)(lhs.score - rhs.score)) <= kScoreTolerance;
+   }
+ 
+   friend bool operator!=(const Category& lhs, const Category& rhs) {
+-- 
+2.25.1
+

+ 27 - 0
0008-tflite_support-fix-Wdefaulted-function-deleted-warni.patch

@@ -0,0 +1,27 @@
+From b4b311bbbff03e24e4a8aae38c85143c45fac3f9 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Thu, 4 Aug 2022 08:31:48 +0800
+Subject: [PATCH 08/51] tflite_support: fix -Wdefaulted-function-deleted
+ warning
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ .../src/tensorflow_lite_support/cc/task/processor/processor.h   | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/third_party/tflite_support/src/tensorflow_lite_support/cc/task/processor/processor.h b/third_party/tflite_support/src/tensorflow_lite_support/cc/task/processor/processor.h
+index b3c43605ac82..219239f6c2bd 100644
+--- a/third_party/tflite_support/src/tensorflow_lite_support/cc/task/processor/processor.h
++++ b/third_party/tflite_support/src/tensorflow_lite_support/cc/task/processor/processor.h
+@@ -34,7 +34,7 @@ namespace processor {
+ // Shares the common logics to handle tflite_engine and metadata.
+ class Processor {
+  public:
+-  Processor() = default;
++  // Processor() = default;
+   virtual ~Processor() = default;
+ 
+   // Processor is neither copyable nor movable.
+-- 
+2.25.1
+

+ 51 - 0
0009-tools-clang-scripts-add-RISCV-as-one-of-the-llvm-tar.patch

@@ -0,0 +1,51 @@
+From da9353ac4fa80dcc4ce28a7a34e65248069e12d3 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 07:59:07 +0000
+Subject: [PATCH 09/51] tools: clang: scripts: add RISCV as one of the llvm
+ targets to build
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ tools/clang/scripts/build.py  | 5 ++++-
+ tools/clang/scripts/update.py | 2 +-
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/tools/clang/scripts/build.py b/tools/clang/scripts/build.py
+index a68eb85b25a1..299d3755d1a9 100755
+--- a/tools/clang/scripts/build.py
++++ b/tools/clang/scripts/build.py
+@@ -612,7 +612,7 @@ def main():
+   cxxflags = []
+   ldflags = []
+ 
+-  targets = 'AArch64;ARM;Mips;PowerPC;SystemZ;WebAssembly;X86'
++  targets = 'AArch64;ARM;Mips;PowerPC;RISCV;SystemZ;WebAssembly;X86'
+ 
+   projects = 'clang;compiler-rt;lld;clang-tools-extra'
+ 
+@@ -986,6 +986,9 @@ def main():
+     if platform.machine() == 'aarch64':
+       cmake_args.append(
+           '-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-unknown-linux-gnu')
++    elif platform.machine() == 'riscv64':
++      cmake_args.append(
++          '-DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-unknown-linux-gnu')
+     else:
+       cmake_args.append('-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu')
+     cmake_args.append('-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON')
+diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
+index ceeeedc42d9f..8cf820d7d1f5 100755
+--- a/tools/clang/scripts/update.py
++++ b/tools/clang/scripts/update.py
+@@ -36,7 +36,7 @@ import zlib
+ # Reverting problematic clang rolls is safe, though.
+ # This is the output of `git describe` and is usable as a commit-ish.
+ CLANG_REVISION = 'llvmorg-15-init-3677-g8133778d'
+-CLANG_SUB_REVISION = 4
++CLANG_SUB_REVISION = 5
+ 
+ PACKAGE_VERSION = '%s-%s' % (CLANG_REVISION, CLANG_SUB_REVISION)
+ RELEASE_VERSION = '15.0.0'
+-- 
+2.25.1
+

+ 27 - 0
0010-tools-clang-script-add-atomic-build-flag-for-native-.patch

@@ -0,0 +1,27 @@
+From 64fb9d7aa7736438a01fd101b71dfbfef79e07d9 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 25 Jul 2022 10:15:24 +0800
+Subject: [PATCH 10/51] tools: clang: script: add atomic build flag for native
+ build
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ tools/clang/scripts/build.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/tools/clang/scripts/build.py b/tools/clang/scripts/build.py
+index 299d3755d1a9..a8a1fb1a732f 100755
+--- a/tools/clang/scripts/build.py
++++ b/tools/clang/scripts/build.py
+@@ -642,6 +642,8 @@ def main():
+       '-DENABLE_X86_RELAX_RELOCATIONS=NO',
+       # See crbug.com/1126219: Use native symbolizer instead of DIA
+       '-DLLVM_ENABLE_DIA_SDK=OFF',
++      # StarFive: Required for native RISCV build
++      '-DSANITIZER_COMMON_LINK_LIBS=-latomic',
+       # See crbug.com/1205046: don't build scudo (and others we don't need).
+       '-DCOMPILER_RT_SANITIZERS_TO_BUILD=asan;dfsan;msan;hwasan;tsan;cfi',
+       # The default value differs per platform, force it off everywhere.
+-- 
+2.25.1
+

+ 26 - 0
0011-tools-clang-scripts-update-clang-triple-for-riscv64.patch

@@ -0,0 +1,26 @@
+From 73902bbbfdd1e2e8ef748bb20ae3798e39ba69ec Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 3 Aug 2022 08:32:42 +0000
+Subject: [PATCH 11/51] tools: clang: scripts: update clang triple for riscv64
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ tools/clang/scripts/build.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/clang/scripts/build.py b/tools/clang/scripts/build.py
+index a8a1fb1a732f..209d2a132a95 100755
+--- a/tools/clang/scripts/build.py
++++ b/tools/clang/scripts/build.py
+@@ -990,7 +990,7 @@ def main():
+           '-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-unknown-linux-gnu')
+     elif platform.machine() == 'riscv64':
+       cmake_args.append(
+-          '-DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-unknown-linux-gnu')
++          '-DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-linux-gnu')
+     else:
+       cmake_args.append('-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu')
+     cmake_args.append('-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON')
+-- 
+2.25.1
+

+ 25 - 0
0012-ui-gl-enable-swiftshader-for-riscv64.patch

@@ -0,0 +1,25 @@
+From 4261c7ea5e64cd479e1a8a1bcc1870a13a81c862 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Fri, 17 Jun 2022 05:49:33 +0000
+Subject: [PATCH 12/51] ui: gl: enable swiftshader for riscv64
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ ui/gl/features.gni | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/ui/gl/features.gni b/ui/gl/features.gni
+index 1bbc06c62715..3951bc279222 100644
+--- a/ui/gl/features.gni
++++ b/ui/gl/features.gni
+@@ -31,5 +31,6 @@ declare_args() {
+                         (is_mac && use_egl) || is_chromeos_ash || is_fuchsia) &&
+                        (target_cpu == "x86" || target_cpu == "x64" ||
+                         target_cpu == "arm" || target_cpu == "arm64" ||
+-                        target_cpu == "mipsel" || target_cpu == "mips64el")
++                        target_cpu == "mipsel" || target_cpu == "mips64el" ||
++                        target_cpu == "riscv64")
+ }
+-- 
+2.25.1
+

+ 87 - 0
0013-third_party-dav1d-enable-riscv64-build.patch

@@ -0,0 +1,87 @@
+From a0f59dcd1f758d43fa2ab99db08c98dcbdaa11f9 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 07:52:53 +0000
+Subject: [PATCH 13/51] third_party: dav1d: enable riscv64 build
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ third_party/dav1d/BUILD.gn                    |  2 +
+ .../dav1d/config/linux-noasm/riscv64/config.h | 40 +++++++++++++++++++
+ third_party/dav1d/generate_configs.py         |  1 +
+ 3 files changed, 43 insertions(+)
+ create mode 100644 third_party/dav1d/config/linux-noasm/riscv64/config.h
+
+diff --git a/third_party/dav1d/BUILD.gn b/third_party/dav1d/BUILD.gn
+index 933c8f2f566a..9522d4c9151b 100644
+--- a/third_party/dav1d/BUILD.gn
++++ b/third_party/dav1d/BUILD.gn
+@@ -17,6 +17,8 @@ if (is_win) {
+   assert(current_cpu == "x64" && (is_linux || is_chromeos),
+          "Only Linux X64 MSAN is supported")
+   platform_config_root = "config/linux-noasm/$current_cpu"
++} else if (current_cpu == "riscv64") {
++  platform_config_root = "config/linux-noasm/$current_cpu"
+ } else {
+   # Linux configuration files seem to work on Mac, so just reuse them.
+   platform_config_root = "config/linux/$current_cpu"
+diff --git a/third_party/dav1d/config/linux-noasm/riscv64/config.h b/third_party/dav1d/config/linux-noasm/riscv64/config.h
+new file mode 100644
+index 000000000000..04e9f42fc1ed
+--- /dev/null
++++ b/third_party/dav1d/config/linux-noasm/riscv64/config.h
+@@ -0,0 +1,40 @@
++/*
++ * Autogenerated by the Meson build system.
++ * Do not edit, your changes will be lost.
++ */
++
++#pragma once
++
++#define ARCH_AARCH64 0
++
++#define ARCH_ARM 0
++
++#define ARCH_PPC64LE 0
++
++#define ARCH_X86 0
++
++#define ARCH_X86_32 0
++
++#define ARCH_X86_64 0
++
++#define CONFIG_16BPC 1
++
++#define CONFIG_8BPC 1
++
++// #define CONFIG_LOG 1 -- Logging is controlled by Chromium
++
++#define ENDIANNESS_BIG 0
++
++#define HAVE_ASM 0
++
++#define HAVE_CLOCK_GETTIME 1
++
++#define HAVE_DLSYM 1
++
++#define HAVE_POSIX_MEMALIGN 1
++
++// #define HAVE_PTHREAD_GETAFFINITY_NP 1 -- Controlled by Chomium
++
++#define HAVE_UNISTD_H 1
++
++// #define STACK_ALIGNMENT 32 -- Stack alignment is controlled by Chromium
+diff --git a/third_party/dav1d/generate_configs.py b/third_party/dav1d/generate_configs.py
+index fe7717047a25..9379af6c6581 100755
+--- a/third_party/dav1d/generate_configs.py
++++ b/third_party/dav1d/generate_configs.py
+@@ -198,6 +198,7 @@ def main():
+ 
+   GenerateConfig('config/linux/x64', linux_env)
+   GenerateConfig('config/linux-noasm/x64', linux_env, ['-Denable_asm=false'])
++  GenerateConfig('config/linux-noasm/riscv64', linux_env, ['-Denable_asm=false'])
+ 
+   GenerateConfig('config/linux/x86', linux_env,
+                  ['--cross-file', '../crossfiles/linux32.crossfile'])
+-- 
+2.25.1
+

+ 154 - 0
0014-third_party-boringssl-update-gn-for-latest-src-tree.patch

@@ -0,0 +1,154 @@
+From 2c38200c18fb244bd46ae44a48dc2cb8b1335e6a Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 08:00:16 +0000
+Subject: [PATCH 14/51] third_party: boringssl: update gn for latest src tree
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ third_party/boringssl/BUILD.generated.gni | 24 ++++++++++++++++-------
+ 1 file changed, 17 insertions(+), 7 deletions(-)
+
+diff --git a/third_party/boringssl/BUILD.generated.gni b/third_party/boringssl/BUILD.generated.gni
+index 5fe1e0fee093..04a98f7c776a 100644
+--- a/third_party/boringssl/BUILD.generated.gni
++++ b/third_party/boringssl/BUILD.generated.gni
+@@ -10,7 +10,6 @@ crypto_sources = [
+   "src/crypto/asn1/a_bool.c",
+   "src/crypto/asn1/a_d2i_fp.c",
+   "src/crypto/asn1/a_dup.c",
+-  "src/crypto/asn1/a_enum.c",
+   "src/crypto/asn1/a_gentm.c",
+   "src/crypto/asn1/a_i2d_fp.c",
+   "src/crypto/asn1/a_int.c",
+@@ -27,7 +26,6 @@ crypto_sources = [
+   "src/crypto/asn1/asn1_lib.c",
+   "src/crypto/asn1/asn1_par.c",
+   "src/crypto/asn1/asn_pack.c",
+-  "src/crypto/asn1/charmap.h",
+   "src/crypto/asn1/f_int.c",
+   "src/crypto/asn1/f_string.c",
+   "src/crypto/asn1/internal.h",
+@@ -64,7 +62,6 @@ crypto_sources = [
+   "src/crypto/chacha/internal.h",
+   "src/crypto/cipher_extra/cipher_extra.c",
+   "src/crypto/cipher_extra/derive_key.c",
+-  "src/crypto/cipher_extra/e_aesccm.c",
+   "src/crypto/cipher_extra/e_aesctrhmac.c",
+   "src/crypto/cipher_extra/e_aesgcmsiv.c",
+   "src/crypto/cipher_extra/e_chacha20poly1305.c",
+@@ -75,7 +72,6 @@ crypto_sources = [
+   "src/crypto/cipher_extra/e_tls.c",
+   "src/crypto/cipher_extra/internal.h",
+   "src/crypto/cipher_extra/tls_cbc.c",
+-  "src/crypto/cmac/cmac.c",
+   "src/crypto/conf/conf.c",
+   "src/crypto/conf/conf_def.h",
+   "src/crypto/conf/internal.h",
+@@ -110,7 +106,6 @@ crypto_sources = [
+   "src/crypto/engine/engine.c",
+   "src/crypto/err/err.c",
+   "src/crypto/err/internal.h",
+-  "src/crypto/evp/digestsign.c",
+   "src/crypto/evp/evp.c",
+   "src/crypto/evp/evp_asn1.c",
+   "src/crypto/evp/evp_ctx.c",
+@@ -120,6 +115,7 @@ crypto_sources = [
+   "src/crypto/evp/p_ec_asn1.c",
+   "src/crypto/evp/p_ed25519.c",
+   "src/crypto/evp/p_ed25519_asn1.c",
++  "src/crypto/evp/p_hkdf.c",
+   "src/crypto/evp/p_rsa.c",
+   "src/crypto/evp/p_rsa_asn1.c",
+   "src/crypto/evp/p_x25519.c",
+@@ -135,11 +131,12 @@ crypto_sources = [
+   "src/crypto/fipsmodule/bn/rsaz_exp.h",
+   "src/crypto/fipsmodule/cipher/internal.h",
+   "src/crypto/fipsmodule/delocate.h",
++  "src/crypto/fipsmodule/dh/internal.h",
+   "src/crypto/fipsmodule/digest/internal.h",
+   "src/crypto/fipsmodule/digest/md32_common.h",
+   "src/crypto/fipsmodule/ec/internal.h",
+-  "src/crypto/fipsmodule/ec/p256-x86_64-table.h",
+-  "src/crypto/fipsmodule/ec/p256-x86_64.h",
++  "src/crypto/fipsmodule/ec/p256-nistz-table.h",
++  "src/crypto/fipsmodule/ec/p256-nistz.h",
+   "src/crypto/fipsmodule/ec/p256_table.h",
+   "src/crypto/fipsmodule/ecdsa/internal.h",
+   "src/crypto/fipsmodule/fips_shared_support.c",
+@@ -149,6 +146,7 @@ crypto_sources = [
+   "src/crypto/fipsmodule/rand/getrandom_fillin.h",
+   "src/crypto/fipsmodule/rand/internal.h",
+   "src/crypto/fipsmodule/rsa/internal.h",
++  "src/crypto/fipsmodule/service_indicator/internal.h",
+   "src/crypto/fipsmodule/sha/internal.h",
+   "src/crypto/fipsmodule/tls/internal.h",
+   "src/crypto/hkdf/hkdf.c",
+@@ -335,6 +333,7 @@ crypto_headers = [
+   "src/include/openssl/hpke.h",
+   "src/include/openssl/hrss.h",
+   "src/include/openssl/is_boringssl.h",
++  "src/include/openssl/kdf.h",
+   "src/include/openssl/lhash.h",
+   "src/include/openssl/md4.h",
+   "src/include/openssl/md5.h",
+@@ -357,6 +356,7 @@ crypto_headers = [
+   "src/include/openssl/ripemd.h",
+   "src/include/openssl/rsa.h",
+   "src/include/openssl/safestack.h",
++  "src/include/openssl/service_indicator.h",
+   "src/include/openssl/sha.h",
+   "src/include/openssl/siphash.h",
+   "src/include/openssl/span.h",
+@@ -442,10 +442,13 @@ tool_sources = [
+ 
+ crypto_sources_apple_aarch64 = [
+   "apple-aarch64/crypto/chacha/chacha-armv8.S",
++  "apple-aarch64/crypto/cipher_extra/chacha20_poly1305_armv8.S",
+   "apple-aarch64/crypto/fipsmodule/aesv8-armx64.S",
+   "apple-aarch64/crypto/fipsmodule/armv8-mont.S",
+   "apple-aarch64/crypto/fipsmodule/ghash-neon-armv8.S",
+   "apple-aarch64/crypto/fipsmodule/ghashv8-armx64.S",
++  "apple-aarch64/crypto/fipsmodule/p256-armv8-asm.S",
++  "apple-aarch64/crypto/fipsmodule/p256_beeu-armv8-asm.S",
+   "apple-aarch64/crypto/fipsmodule/sha1-armv8.S",
+   "apple-aarch64/crypto/fipsmodule/sha256-armv8.S",
+   "apple-aarch64/crypto/fipsmodule/sha512-armv8.S",
+@@ -507,10 +510,13 @@ crypto_sources_apple_x86_64 = [
+ 
+ crypto_sources_linux_aarch64 = [
+   "linux-aarch64/crypto/chacha/chacha-armv8.S",
++  "linux-aarch64/crypto/cipher_extra/chacha20_poly1305_armv8.S",
+   "linux-aarch64/crypto/fipsmodule/aesv8-armx64.S",
+   "linux-aarch64/crypto/fipsmodule/armv8-mont.S",
+   "linux-aarch64/crypto/fipsmodule/ghash-neon-armv8.S",
+   "linux-aarch64/crypto/fipsmodule/ghashv8-armx64.S",
++  "linux-aarch64/crypto/fipsmodule/p256-armv8-asm.S",
++  "linux-aarch64/crypto/fipsmodule/p256_beeu-armv8-asm.S",
+   "linux-aarch64/crypto/fipsmodule/sha1-armv8.S",
+   "linux-aarch64/crypto/fipsmodule/sha256-armv8.S",
+   "linux-aarch64/crypto/fipsmodule/sha512-armv8.S",
+@@ -581,10 +587,13 @@ crypto_sources_linux_x86_64 = [
+ 
+ crypto_sources_win_aarch64 = [
+   "win-aarch64/crypto/chacha/chacha-armv8.S",
++  "win-aarch64/crypto/cipher_extra/chacha20_poly1305_armv8.S",
+   "win-aarch64/crypto/fipsmodule/aesv8-armx64.S",
+   "win-aarch64/crypto/fipsmodule/armv8-mont.S",
+   "win-aarch64/crypto/fipsmodule/ghash-neon-armv8.S",
+   "win-aarch64/crypto/fipsmodule/ghashv8-armx64.S",
++  "win-aarch64/crypto/fipsmodule/p256-armv8-asm.S",
++  "win-aarch64/crypto/fipsmodule/p256_beeu-armv8-asm.S",
+   "win-aarch64/crypto/fipsmodule/sha1-armv8.S",
+   "win-aarch64/crypto/fipsmodule/sha256-armv8.S",
+   "win-aarch64/crypto/fipsmodule/sha512-armv8.S",
+@@ -637,6 +646,7 @@ fuzzers = [
+   "cert",
+   "client",
+   "decode_client_hello_inner",
++  "der_roundtrip",
+   "dtls_client",
+   "dtls_server",
+   "pkcs12",
+-- 
+2.25.1
+

+ 26 - 0
0015-third_party-libaom-enable-riscv64-build-as-generic.patch

@@ -0,0 +1,26 @@
+From 72dd14286b79a35418c9e33b9dfae48757b87182 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 08:08:09 +0000
+Subject: [PATCH 15/51] third_party: libaom: enable riscv64 build as generic
+
+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 49dbee305c6d..4f5b56c7e7f0 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
+

+ 26 - 0
0016-DEPS-bump-swiftshader-to-latest.patch

@@ -0,0 +1,26 @@
+From 63c08e63eb74423aeea48903105cce7bc33a49a4 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Thu, 23 Jun 2022 15:33:33 +0000
+Subject: [PATCH 16/51] DEPS: bump swiftshader to latest
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ DEPS | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/DEPS b/DEPS
+index a1a0c1061451..338adadd4456 100644
+--- a/DEPS
++++ b/DEPS
+@@ -266,7 +266,7 @@ vars = {
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling SwiftShader
+   # and whatever else without interference from each other.
+-  'swiftshader_revision': 'd01dca1d18d03f055d0dabd99a210b5f666715ed',
++  'swiftshader_revision': '1b159f6cdecba5e29858e50a998951d6c5ef91d3',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling PDFium
+   # and whatever else without interference from each other.
+-- 
+2.25.1
+

+ 26 - 0
0017-DEPS-update-boringssl-to-latest-HEAD.patch

@@ -0,0 +1,26 @@
+From eb292c4748fd9057c27daa3b4f842c2ef775ebf5 Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh <tienhock.loh@starfivetech.com>
+Date: Thu, 11 Aug 2022 07:29:39 +0000
+Subject: [PATCH 17/51] DEPS: update boringssl to latest HEAD
+
+Signed-off-by: Tien Hock Loh <tienhock.loh@starfivetech.com>
+---
+ DEPS | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/DEPS b/DEPS
+index 338adadd4456..f5c8d440c45d 100644
+--- a/DEPS
++++ b/DEPS
+@@ -277,7 +277,7 @@ vars = {
+   #
+   # Note this revision should be updated with
+   # third_party/boringssl/roll_boringssl.py, not roll-dep.
+-  'boringssl_revision': '4d955d20d27bcf3ae71df091ad17d95229a7eb56',
++  'boringssl_revision': '4566bb5fe517f7f141b5fe935c559fc4311af35d',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling google-toolbox-for-mac
+   # and whatever else without interference from each other.
+-- 
+2.25.1
+

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

@@ -0,0 +1,26 @@
+From 290d1d8d0013711895c009bf4d9ab2215f64c664 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 08:03:27 +0000
+Subject: [PATCH 18/51] 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 5d1944bfff1e..4ab5a189f6a1 100644
+--- a/base/process/launch_posix.cc
++++ b/base/process/launch_posix.cc
+@@ -709,7 +709,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
+

+ 147 - 0
0019-DEPS-change-some-third_party-repos-to-fetch-from-dev.patch

@@ -0,0 +1,147 @@
+From ccf0a640af81110d079dce5aa8e7908e5f883389 Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh - swbuildbot <tienhock.loh@starfivetech.com>
+Date: Thu, 11 Aug 2022 07:45:37 +0000
+Subject: [PATCH 19/51] DEPS: change some third_party repos to fetch from
+ development repo
+
+Signed-off-by: Tien Hock Loh - swbuildbot <tienhock.loh@starfivetech.com>
+---
+ DEPS | 29 +++++++++++++++--------------
+ 1 file changed, 15 insertions(+), 14 deletions(-)
+
+diff --git a/DEPS b/DEPS
+index f5c8d440c45d..eeeb06a7a804 100644
+--- a/DEPS
++++ b/DEPS
+@@ -248,13 +248,14 @@ vars = {
+   'nwjs_git': 'https://github.com/nwjs',
+   'pdfium_git': 'https://pdfium.googlesource.com',
+   'quiche_git': 'https://quiche.googlesource.com',
++  'reb_git': 'https://github.com/rebeccasf',
+   'skia_git': 'https://skia.googlesource.com',
+   'swiftshader_git': 'https://swiftshader.googlesource.com',
+   'webrtc_git': 'https://webrtc.googlesource.com',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling Skia
+   # and whatever else without interference from each other.
+-  'skia_revision': 'e3e2fcd24a848352ff4bd8df90891af8c9cdfd05',
++  'skia_revision': '4563280903c72930232692e50e387b35924aae69',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling V8
+   # and whatever else without interference from each other.
+@@ -262,7 +263,7 @@ vars = {
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling ANGLE
+   # and whatever else without interference from each other.
+-  'angle_revision': 'a4d0bfd89577761d09ccfef8826d0eb5e2455181',
++  'angle_revision': 'ed00a14f6501b48d2cf24df1642d49653ddc77ff',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling SwiftShader
+   # and whatever else without interference from each other.
+@@ -270,7 +271,7 @@ vars = {
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling PDFium
+   # and whatever else without interference from each other.
+-  'pdfium_revision': 'f4c62094abe20ade3a29328bc370238b7e7812b2',
++  'pdfium_revision': '460f12789136fd73f28f82be25ba8887d5a3ed2b',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling BoringSSL
+   # and whatever else without interference from each other.
+@@ -369,7 +370,7 @@ vars = {
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling feed
+   # and whatever else without interference from each other.
+-  'dawn_revision': '211e96c6069c66c6d503cfa2b35226c7118c7927',
++  'dawn_revision': '6baaa9b2a4298e7c71555a69aee72a5c63961c2b',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling feed
+   # and whatever else without interference from each other.
+@@ -429,7 +430,7 @@ vars = {
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling feed
+   # and whatever else without interference from each other.
+-  'highway_revision': '424360251cdcfc314cfc528f53c872ecd63af0f0',
++  'highway_revision': '6667b0cd38025d0a0457537e9badcbc6be6e2049',
+ 
+   # If you change this, also update the libc++ revision in
+   # //buildtools/deps_revisions.gni.
+@@ -1023,19 +1024,19 @@ deps = {
+   },
+ 
+   'src/third_party/angle':
+-    Var('chromium_git') + '/angle/angle.git' + '@' +  Var('angle_revision'),
++    Var('reb_git') + '/angle.git' + '@' +  Var('angle_revision'),
+ 
+   'src/third_party/dav1d/libdav1d':
+     Var('chromium_git') + '/external/github.com/videolan/dav1d.git' + '@' + 'b1a5189c9d37c837099ce50852b6ce9597b89b0c',
+ 
+   'src/third_party/dawn':
+-    Var('dawn_git') + '/dawn.git' + '@' +  Var('dawn_revision'),
++    Var('reb_git') + '/dawn.git' + '@' +  Var('dawn_revision'),
+ 
+   'src/third_party/libjxl/src':
+     Var('chromium_git') + '/external/gitlab.com/wg1/jpeg-xl.git' + '@' + Var('libjxl_revision'),
+ 
+   'src/third_party/highway/src':
+-    Var('chromium_git') + '/external/github.com/google/highway.git' + '@' + Var('highway_revision'),
++    Var('reb_git') + '/highway.git' + '@' + Var('highway_revision'),
+ 
+   'src/third_party/glfw/src':
+     Var('chromium_git') + '/external/github.com/glfw/glfw.git@' +  '94773111300fee0453844a4c9407af7e880b4df8',
+@@ -1081,7 +1082,7 @@ deps = {
+   },
+ 
+   'src/third_party/breakpad/breakpad':
+-    Var('chromium_git') + '/breakpad/breakpad.git' + '@' + '08bd844599bf04c71707e8f59a8013a941264695',
++    Var('reb_git') + '/breakpad.git' + '@' + '5f21ccb93d1f34564911c7474124fd0827d71297',
+ 
+   'src/third_party/byte_buddy': {
+       'packages': [
+@@ -1186,7 +1187,7 @@ deps = {
+     Var('chromium_git') + '/external/github.com/google/farmhash.git' + '@' + '816a4ae622e964763ca0862d9dbd19324a1eaf45',
+ 
+   'src/third_party/ffmpeg':
+-    Var('chromium_git') + '/chromium/third_party/ffmpeg.git' + '@' + '574c39cce3231c69bc9a02ac475c27d944bdb113',
++    Var('reb_git') + '/chromium-ffmpeg.git' + '@' + '1a69da082435b0e7b56f5c09e4621c29aae24077',
+ 
+   'src/third_party/flac':
+     Var('chromium_git') + '/chromium/deps/flac.git' + '@' + 'af862024c8c8fa0ae07ced05e89013d881b00596',
+@@ -1529,7 +1530,7 @@ deps = {
+   },
+ 
+   'src/third_party/pdfium':
+-    Var('pdfium_git') + '/pdfium.git' + '@' +  Var('pdfium_revision'),
++    Var('reb_git') + '/pdfium.git' + '@' +  Var('pdfium_revision'),
+ 
+   # Parses Windows PE/COFF executable format.
+   'src/third_party/pefile': {
+@@ -1538,7 +1539,7 @@ deps = {
+   },
+ 
+   'src/third_party/perfetto':
+-    Var('android_git') + '/platform/external/perfetto.git' + '@' + '943905de31ebf8d6a35016a170457dbae3efbecc',
++    Var('reb_git') + '/perfetto.git' + '@' + 'b2b7cb0ad63d66fd035ae359a3dd548ab14abfd8',
+ 
+   'src/third_party/perl': {
+       'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3',
+@@ -1668,7 +1669,7 @@ deps = {
+     Var('chromium_git') + '/external/github.com/google/ruy.git' + '@' + '7ef39c5745a61f43071e699c6a96da41701ae59f',
+ 
+   'src/third_party/skia':
+-    Var('skia_git') + '/skia.git' + '@' +  Var('skia_revision'),
++    Var('reb_git') + '/skia.git' + '@' +  Var('skia_revision'),
+ 
+   'src/third_party/smhasher/src':
+     Var('chromium_git') + '/external/smhasher.git' + '@' + 'e87738e57558e0ec472b2fc3a643b838e5b6e88f',
+@@ -1759,7 +1760,7 @@ deps = {
+     Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + 'a630866d89f74aa95cf3aecd78987637ee195b68',
+ 
+   'src/third_party/webrtc':
+-    Var('webrtc_git') + '/src.git' + '@' + '34e12465a46da3c220eab0489881cd89a4d659d2',
++    Var('reb_git') + '/webrtc.git' + '@' + 'f66ad2fa982e2f8ed53cf552b3e3313768608663',
+ 
+   'src/third_party/libgifcodec':
+      Var('skia_git') + '/libgifcodec' + '@'+  Var('libgifcodec_revision'),
+-- 
+2.25.1
+

+ 26 - 0
0020-DEPS-update-lss-to-latest.patch

@@ -0,0 +1,26 @@
+From b003bc5870111bd3f2c690ae0179668854fb3122 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 20 Jul 2022 06:20:23 +0000
+Subject: [PATCH 20/51] DEPS: update lss to latest
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ DEPS | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/DEPS b/DEPS
+index eeeb06a7a804..0be6053c3f4b 100644
+--- a/DEPS
++++ b/DEPS
+@@ -294,7 +294,7 @@ vars = {
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling lss
+   # and whatever else without interference from each other.
+-  'lss_revision': '92a65a8f5d705d1928874420c8d0d15bde8c89e5',
++  'lss_revision': '3bb68597959611490cd8c1c127564aedef1da27a',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling NaCl
+   # and whatever else without interference from each other.
+-- 
+2.25.1
+

+ 37 - 0
0021-DEPS-use-DEPS-to-pull-in-v8-source-tree.patch

@@ -0,0 +1,37 @@
+From ae85e4121756a0e23ae01eabe1d45afc96d1645c Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 25 Jul 2022 14:45:42 +0800
+Subject: [PATCH 21/51] DEPS: use DEPS to pull in v8 source tree
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ DEPS | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/DEPS b/DEPS
+index 0be6053c3f4b..ec62ba17f53f 100644
+--- a/DEPS
++++ b/DEPS
+@@ -259,7 +259,7 @@ vars = {
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling V8
+   # and whatever else without interference from each other.
+-  'v8_revision': 'e5f13e0cd10e245d822f856d17b347c77ccc7593',
++  'v8_revision': 'e104a918db1ae901f9477a57fa179c26778e639a',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling ANGLE
+   # and whatever else without interference from each other.
+@@ -1826,8 +1826,8 @@ deps = {
+       'condition': 'checkout_mac',
+   },
+ 
+-  #'src/v8':
+-  #  Var('chromium_git') + '/v8/v8.git' + '@' +  Var('v8_revision'),
++  'src/v8':
++    Var('reb_git') + '/v8.git' + '@' +  Var('v8_revision'),
+ 
+   'src-internal': {
+     'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@a911c3b7bc546c3f876a2fe98617f0509e5fc67f',
+-- 
+2.25.1
+

+ 30 - 0
0022-DEPS-use-DEPS-to-pull-in-nwjs-forked-repo.patch

@@ -0,0 +1,30 @@
+From 31f3b0701a9de4c7fe4d2f1234e74825b4a50807 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 25 Jul 2022 15:03:06 +0800
+Subject: [PATCH 22/51] DEPS: use DEPS to pull in nwjs forked repo
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ DEPS | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/DEPS b/DEPS
+index ec62ba17f53f..add99378747a 100644
+--- a/DEPS
++++ b/DEPS
+@@ -1829,6 +1829,12 @@ deps = {
+   'src/v8':
+     Var('reb_git') + '/v8.git' + '@' +  Var('v8_revision'),
+ 
++  'src/content/nw':
++    Var('reb_git') + '/nw.js.git' + '@' + '427c477b9ed73b1a86de8c04d5a9c8c33a904033',
++
++  'src/third_party/node-nw':
++    Var('reb_git') + '/node.git' + '@' + '7542bf436d2425361f1febe93fbffb3330c88fce',
++
+   'src-internal': {
+     'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@a911c3b7bc546c3f876a2fe98617f0509e5fc67f',
+     'condition': 'checkout_src_internal',
+-- 
+2.25.1
+

+ 26 - 0
0023-DEPS-update-commit-hash-for-ffmpeg.patch

@@ -0,0 +1,26 @@
+From 7c9704325f382d401dc5cb5e3f4ad53a3875a926 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Fri, 29 Jul 2022 14:50:36 +0800
+Subject: [PATCH 23/51] DEPS: update commit hash for ffmpeg
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ DEPS | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/DEPS b/DEPS
+index add99378747a..0a16f35dd321 100644
+--- a/DEPS
++++ b/DEPS
+@@ -1187,7 +1187,7 @@ deps = {
+     Var('chromium_git') + '/external/github.com/google/farmhash.git' + '@' + '816a4ae622e964763ca0862d9dbd19324a1eaf45',
+ 
+   'src/third_party/ffmpeg':
+-    Var('reb_git') + '/chromium-ffmpeg.git' + '@' + '1a69da082435b0e7b56f5c09e4621c29aae24077',
++    Var('reb_git') + '/chromium-ffmpeg.git' + '@' + '63c83e8f91ece09847337856ad7b14a1c25d3c77',
+ 
+   'src/third_party/flac':
+     Var('chromium_git') + '/chromium/deps/flac.git' + '@' + 'af862024c8c8fa0ae07ced05e89013d881b00596',
+-- 
+2.25.1
+

+ 34 - 0
0024-build-config-linux-workaround-for-files-not-found-wi.patch

@@ -0,0 +1,34 @@
+From e7fe5c06b208413892eee27f3f74f443fdbea03a Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Fri, 17 Jun 2022 06:06:06 +0000
+Subject: [PATCH 24/51] build: config: linux: workaround for files not found
+ within sysroot
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/config/linux/BUILD.gn | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn
+index b897c9920bc8..0059f66aa010 100644
+--- a/build/config/linux/BUILD.gn
++++ b/build/config/linux/BUILD.gn
+@@ -27,6 +27,15 @@ config("compiler") {
+       asmflags += [ "-mbranch-protection=pac-ret" ]
+     }
+   }
++
++  if (current_cpu == "riscv64") {
++    cflags = []
++    cflags += [ "-I../../build/linux/debian_sid_riscv64-sysroot/usr/include",
++                "-I../../build/linux/debian_sid_riscv64-sysroot/usr/include/riscv64-linux-gnu",
++                "-I../../build/linux/debian_sid_riscv64-sysroot/usr/lib",
++                "-I../../build/linux/debian_sid_riscv64-sysroot/usr/lib/riscv64-linux-gnu",
++    ]
++  }
+ }
+ 
+ # This is included by reference in the //build/config/compiler:runtime_library
+-- 
+2.25.1
+

+ 48 - 0
0025-build-config-compiler-add-build-flags-for-clang.patch

@@ -0,0 +1,48 @@
+From 258032c9f404c8e8aae8878340ebb4abf76d03df Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 25 Jul 2022 14:29:11 +0800
+Subject: [PATCH 25/51] build: config: compiler: add build flags for clang
+
+This will resolve build failure on v8 when using clang.
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/config/compiler/BUILD.gn | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+index 9882b6cb6e1b..ef115d5184c0 100644
+--- a/build/config/compiler/BUILD.gn
++++ b/build/config/compiler/BUILD.gn
+@@ -1523,6 +1523,8 @@ config("default_warnings") {
+       # this as well. http://crbug.com/316352
+       "-Wno-unneeded-internal-declaration",
+       "-Wno-unused-function",
++      "-Wno-invalid-offsetof",
++      "-Wno-range-loop-construct",
+     ]
+ 
+     if (!is_nacl || is_nacl_saigo) {
+@@ -1955,8 +1957,17 @@ config("no_incompatible_pointer_warnings") {
+ # Shared settings for both "optimize" and "optimize_max" configs.
+ # IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+ if (is_win) {
+-  common_optimize_on_cflags = [
+-    "/Ob2",  # Both explicit and auto inlining.
++  common_optimize_on_cflags = []
++  if(is_clang) {
++    common_optimize_on_cflags += [
++      "/Ob2",  # Both explicit and auto inlining.
++    ]
++  } else {
++    common_optimize_on_cflags += [
++      "/Ob3",  # Both explicit and auto inlining.
++    ]
++  }
++  common_optimize_on_cflags += [
+     "/Oy-",  # Disable omitting frame pointers, must be after /O2.
+     "/Zc:inline",  # Remove unreferenced COMDAT (faster links).
+   ]
+-- 
+2.25.1
+

+ 45 - 0
0026-build-config-compiler-set-generic-riscv64-flags.patch

@@ -0,0 +1,45 @@
+From 7f7b0054a48376755cb88ebd5208696681e1603f Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 07:56:35 +0000
+Subject: [PATCH 26/51] build: config: compiler: set generic riscv64 flags
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/config/compiler/BUILD.gn | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+index ef115d5184c0..03ce0777d533 100644
+--- a/build/config/compiler/BUILD.gn
++++ b/build/config/compiler/BUILD.gn
+@@ -1181,6 +1181,17 @@ config("compiler_cpu_abi") {
+         cflags += [ "-m64" ]
+         ldflags += [ "-m64" ]
+       }
++    } else if (current_cpu == "riscv64") {
++      cflags += [
++        "-m64",
++        "--target=riscv64-linux-gnu",
++        "-mno-relax",
++        "-mabi=lp64d",
++      ]
++      ldflags += [
++        "--target=riscv64-linux-gnu",
++        "-mno-relax",
++      ]
+     } else if (current_cpu == "s390x") {
+       cflags += [ "-m64" ]
+       ldflags += [ "-m64" ]
+@@ -1651,7 +1662,8 @@ config("chromium_code") {
+ 
+     if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
+         current_cpu != "s390" && current_cpu != "ppc64" &&
+-        current_cpu != "mips" && current_cpu != "mips64") {
++        current_cpu != "mips" && current_cpu != "mips64" &&
++        current_cpu != "riscv64") {
+       # Non-chromium code is not guaranteed to compile cleanly with
+       # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
+       # disabled, so only do that for Release build.
+-- 
+2.25.1
+

+ 34 - 0
0027-build-toolchain-linux-enable-clang-toolchain-for-ris.patch

@@ -0,0 +1,34 @@
+From aead4720afd4a774cb14520cfb8b581ee78a9c8b Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 08:06:36 +0000
+Subject: [PATCH 27/51] build: toolchain: linux: enable clang toolchain for
+ riscv64
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/toolchain/linux/BUILD.gn | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/build/toolchain/linux/BUILD.gn b/build/toolchain/linux/BUILD.gn
+index bc17e80e6135..64face8eff5c 100644
+--- a/build/toolchain/linux/BUILD.gn
++++ b/build/toolchain/linux/BUILD.gn
+@@ -290,6 +290,15 @@ gcc_toolchain("mips64el") {
+   }
+ }
+ 
++clang_toolchain("clang_riscv64") {
++  enable_linker_map = true
++  toolchain_args = {
++    current_cpu = "riscv64"
++    current_os = "linux"
++    is_clang = true
++  }
++}
++
+ gcc_toolchain("riscv64") {
+   toolprefix = "riscv64-linux-gnu"
+ 
+-- 
+2.25.1
+

+ 25 - 0
0028-build-config-BUILD.gn-add-atomic-build-flag.patch

@@ -0,0 +1,25 @@
+From 576baf66ab6fc43e415e8288522386fef5ea09f8 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 4 Jul 2022 08:57:14 +0000
+Subject: [PATCH 28/51] build: config: BUILD.gn: 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 ac726a32b264..f2aa6faf6369 100644
+--- a/build/config/BUILD.gn
++++ b/build/config/BUILD.gn
+@@ -227,6 +227,7 @@ config("default_libs") {
+       "dl",
+       "pthread",
+       "rt",
++      "atomic",
+     ]
+   }
+ }
+-- 
+2.25.1
+

+ 26 - 0
0029-build-config-compiler-skip-warnings-treated-as-error.patch

@@ -0,0 +1,26 @@
+From 85205e4319766b74a3ab7cce3149991bf5fa127f Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh <tienhock.loh@starfivetech.com>
+Date: Thu, 11 Aug 2022 07:59:13 +0000
+Subject: [PATCH 29/51] build: config: compiler: skip warnings treated as
+ errors in ffmpeg
+
+Signed-off-by: Tien Hock Loh <tienhock.loh@starfivetech.com>
+---
+ build/config/compiler/BUILD.gn | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+index 03ce0777d533..2ba6030cc544 100644
+--- a/build/config/compiler/BUILD.gn
++++ b/build/config/compiler/BUILD.gn
+@@ -1187,6 +1187,7 @@ config("compiler_cpu_abi") {
+         "--target=riscv64-linux-gnu",
+         "-mno-relax",
+         "-mabi=lp64d",
++        "-Wno-error=deprecated-declarations",
+       ]
+       ldflags += [
+         "--target=riscv64-linux-gnu",
+-- 
+2.25.1
+

+ 26 - 0
0030-build-config-add-v8-target-cpu-for-riscv64.patch

@@ -0,0 +1,26 @@
+From a318817c2321b2e0c8a99d519e1fdcbab4f73585 Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh <tienhock.loh@starfivetech.com>
+Date: Thu, 11 Aug 2022 08:05:06 +0000
+Subject: [PATCH 30/51] build: config: add v8 target cpu for riscv64
+
+Signed-off-by: Tien Hock Loh <tienhock.loh@starfivetech.com>
+---
+ build/config/v8_target_cpu.gni | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/build/config/v8_target_cpu.gni b/build/config/v8_target_cpu.gni
+index 305981f3fa53..b5767be5bc93 100644
+--- a/build/config/v8_target_cpu.gni
++++ b/build/config/v8_target_cpu.gni
+@@ -36,6 +36,8 @@ declare_args() {
+ if (v8_target_cpu == "") {
+   if (current_toolchain == "//build/toolchain/linux:clang_x64_v8_arm64") {
+     v8_target_cpu = "arm64"
++  } else if (current_toolchain == "//build/toolchain/linux:clang_x64_v8_riscv64") {
++    v8_target_cpu = "riscv64"
+   } else if (current_toolchain == "//build/toolchain/linux:clang_x86_v8_arm") {
+     v8_target_cpu = "arm"
+   } else if (current_toolchain ==
+-- 
+2.25.1
+

+ 25 - 0
0031-build-toolchain-linux-do-not-use-lld-by-default.patch

@@ -0,0 +1,25 @@
+From c7e20ee170c73c4ab553c4da2d7191aa5b99e1ab Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh <tienhock.loh@starfivetech.com>
+Date: Thu, 11 Aug 2022 08:06:56 +0000
+Subject: [PATCH 31/51] build: toolchain: linux: do not use lld by default
+
+Signed-off-by: Tien Hock Loh <tienhock.loh@starfivetech.com>
+---
+ build/toolchain/linux/BUILD.gn | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/build/toolchain/linux/BUILD.gn b/build/toolchain/linux/BUILD.gn
+index 64face8eff5c..b32804c1752d 100644
+--- a/build/toolchain/linux/BUILD.gn
++++ b/build/toolchain/linux/BUILD.gn
+@@ -168,6 +168,7 @@ clang_v8_toolchain("clang_x64_v8_riscv64") {
+   toolchain_args = {
+     current_cpu = "x64"
+     v8_current_cpu = "riscv64"
++    use_lld = false
+   }
+ }
+ 
+-- 
+2.25.1
+

+ 41 - 0
0032-reduce-warnings-flag-as-error.patch

@@ -0,0 +1,41 @@
+From fe725e323a1db63184cf9765181ecbca04313013 Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh <tienhock.loh@starfivetech.com>
+Date: Thu, 11 Aug 2022 08:07:56 +0000
+Subject: [PATCH 32/51] reduce warnings flag as error
+
+Signed-off-by: Tien Hock Loh <tienhock.loh@starfivetech.com>
+---
+ components/optimization_guide/core/BUILD.gn | 3 +++
+ third_party/tflite_support/BUILD.gn         | 2 ++
+ 2 files changed, 5 insertions(+)
+
+diff --git a/components/optimization_guide/core/BUILD.gn b/components/optimization_guide/core/BUILD.gn
+index 7d044f5a2aa1..652af07e4194 100644
+--- a/components/optimization_guide/core/BUILD.gn
++++ b/components/optimization_guide/core/BUILD.gn
+@@ -7,6 +7,9 @@ if (is_android) {
+ }
+ import("//components/optimization_guide/features.gni")
+ 
++cflags_cc = [ "-Wno-absolute-value" ]
++cflags_cc += [ "-Wno-defaulted-function-deleted" ]
++
+ static_library("bloomfilter") {
+   sources = [
+     "bloom_filter.cc",
+diff --git a/third_party/tflite_support/BUILD.gn b/third_party/tflite_support/BUILD.gn
+index 284ef4c742d2..85161cf563aa 100644
+--- a/third_party/tflite_support/BUILD.gn
++++ b/third_party/tflite_support/BUILD.gn
+@@ -42,6 +42,8 @@ config("tflite_support_flags") {
+     "-Wno-unused-variable",
+     "-Wno-defaulted-function-deleted",
+     "-Wno-absolute-value",
++    "-Wno-defaulted-function-deleted",
++    "-Wno-absolute-value",
+   ]
+   if (!is_win) {
+     cflags_cc = [ "-frtti" ]
+-- 
+2.25.1
+

+ 25 - 0
0033-build-config-compiler-skip-warning-for-ffmpeg.patch

@@ -0,0 +1,25 @@
+From b09d6492e224bfbecebe414b2c53baba11930a51 Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh <tienhock.loh@starfivetech.com>
+Date: Fri, 5 Aug 2022 03:06:18 -0400
+Subject: [PATCH 33/51] build: config: compiler: skip warning for ffmpeg
+
+Signed-off-by: Tien Hock Loh <tienhock.loh@starfivetech.com>
+---
+ build/config/compiler/BUILD.gn | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+index 2ba6030cc544..c2fce9eb8ede 100644
+--- a/build/config/compiler/BUILD.gn
++++ b/build/config/compiler/BUILD.gn
+@@ -1936,6 +1936,7 @@ config("wglobal_constructors") {
+ config("wexit_time_destructors") {
+   if (is_clang) {
+     cflags = [ "-Wexit-time-destructors" ]
++    cflags += [ "-Wno-deprecated-declarations" ]
+   }
+ }
+ 
+-- 
+2.25.1
+

+ 30 - 0
0034-third_party-libzip-resolve-macro-redefined-issue.patch

@@ -0,0 +1,30 @@
+From dc340078649edd82249bf87b993dba23dbcea455 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Tue, 19 Jul 2022 01:12:17 +0000
+Subject: [PATCH 34/51] third_party: libzip: resolve macro redefined issue
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ third_party/libzip/src/lib/compat.h | 8 --------
+ 1 file changed, 8 deletions(-)
+
+diff --git a/third_party/libzip/src/lib/compat.h b/third_party/libzip/src/lib/compat.h
+index d88be1aa344e..2ea8766db7fd 100644
+--- a/third_party/libzip/src/lib/compat.h
++++ b/third_party/libzip/src/lib/compat.h
+@@ -184,12 +184,4 @@ typedef char bool;
+ #endif
+ #endif
+ 
+-#ifndef S_ISDIR
+-#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
+-#endif
+-
+-#ifndef S_ISREG
+-#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
+-#endif
+-
+ #endif /* compat.h */
+-- 
+2.25.1
+

+ 26 - 0
0035-third_party-pffft-add-riscv64-arch-detection.patch

@@ -0,0 +1,26 @@
+From 92adbab5887e02d1b9b3467d4be1f4381c2c2b02 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 20 Jul 2022 00:56:29 +0000
+Subject: [PATCH 35/51] third_party: pffft: add riscv64 arch detection
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ third_party/pffft/BUILD.gn | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/third_party/pffft/BUILD.gn b/third_party/pffft/BUILD.gn
+index 0a1cf7a1f5e1..322c00dbd2da 100644
+--- a/third_party/pffft/BUILD.gn
++++ b/third_party/pffft/BUILD.gn
+@@ -19,7 +19,7 @@ config("common_config") {
+   # PFFFT doesn't support SIMD on some cpus, so build a scalar version.
+   if ((current_cpu == "arm" && !arm_use_neon) || current_cpu == "mipsel" ||
+       current_cpu == "mips64el" || current_cpu == "ppc64" ||
+-      current_cpu == "s390x") {
++      current_cpu == "riscv64" || current_cpu == "s390x") {
+     defines = [ "PFFFT_SIMD_DISABLE" ]
+   }
+ }
+-- 
+2.25.1
+

+ 57 - 0
0036-BUILD.gn-disable-chrome-related-test.patch

@@ -0,0 +1,57 @@
+From 65b603b2d4a7d4d4b2afdb272f58ae377df70446 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 08:02:05 +0000
+Subject: [PATCH 36/51] BUILD.gn: disable chrome related test
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ BUILD.gn | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/BUILD.gn b/BUILD.gn
+index b08f040b11ab..9971e594a5be 100644
+--- a/BUILD.gn
++++ b/BUILD.gn
+@@ -137,7 +137,8 @@ group("gn_all") {
+       "//chrome/test:browser_tests",
+       "//chrome/test:interactive_ui_tests",
+       "//chrome/test:sync_integration_tests",
+-      "//chrome/test/chromedriver:chromedriver_unittests",
++      # Reb's WA
++      # "//chrome/test/chromedriver:chromedriver_unittests",
+       "//components/subresource_filter/tools:subresource_filter_tools",
+       "//components/zucchini:zucchini",
+       "//components/zucchini:zucchini_unittests",
+@@ -541,7 +542,8 @@ group("gn_all") {
+       deps += [
+         "//chrome/test:load_library_perf_tests",
+         "//chrome/test:sync_performance_tests",
+-        "//chrome/test/chromedriver:chromedriver",
++        # Reb's WA
++        # "//chrome/test/chromedriver:chromedriver",
+         "//courgette:courgette",
+         "//courgette:courgette_fuzz",
+         "//courgette:courgette_minimal_tool",
+@@ -1077,7 +1079,8 @@ if (!is_ios) {
+       ]
+       data_deps = [
+         "//chrome:chrome",
+-        "//chrome/test/chromedriver",
++        # Reb's WA
++        # "//chrome/test/chromedriver",
+         "//testing:test_scripts_shared",
+         "//third_party/catapult/third_party/typ",
+       ]
+@@ -1089,7 +1092,8 @@ if (!is_ios) {
+       script = "//testing/scripts/run_wpt_tests.py"
+       data_deps = [
+         "//chrome:chrome",
+-        "//chrome/test/chromedriver",
++        # Reb's WA
++        # "//chrome/test/chromedriver",
+         "//third_party/blink/tools:wpt_tests_isolate",
+         "//tools/imagediff",
+       ]
+-- 
+2.25.1
+

+ 26 - 0
0037-add-workaround-to-avoid-rebuild-sysroot.patch

@@ -0,0 +1,26 @@
+From 33bae85b9b5f83847ca9949a43c9ffcf9d6568e6 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 08:04:54 +0000
+Subject: [PATCH 37/51] add workaround to avoid rebuild sysroot
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/config/posix/BUILD.gn | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/build/config/posix/BUILD.gn b/build/config/posix/BUILD.gn
+index 5d1516387571..78fb9aa2e5c0 100644
+--- a/build/config/posix/BUILD.gn
++++ b/build/config/posix/BUILD.gn
+@@ -28,7 +28,7 @@ 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) {
++    if (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
+-- 
+2.25.1
+

+ 36 - 0
0038-add-path-to-riscv64-sysroot.patch

@@ -0,0 +1,36 @@
+From cb072c1ca121c85743f0623e7d4f30cd02d2663c Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 22 Jun 2022 08:05:49 +0000
+Subject: [PATCH 38/51] 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 18d2d573627c..4f8fa88a50b8 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
+

+ 26 - 0
0039-pkg-config.py-add-riscv-sysroot-path-to-system_libdi.patch

@@ -0,0 +1,26 @@
+From 065b87193f2098ba82e33e6eb1eda17ca275f5b5 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Thu, 14 Jul 2022 06:40:36 +0000
+Subject: [PATCH 39/51] pkg-config.py: add riscv sysroot path to system_libdir
+
+Signed-off-by: Loh Tien Hock <tienhock.loh@starfivetech.com>
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/config/linux/pkg-config.py | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py
+index 5adf70cc3bb3..16ad90ca05e2 100755
+--- a/build/config/linux/pkg-config.py
++++ b/build/config/linux/pkg-config.py
+@@ -61,6 +61,7 @@ def SetConfigPath(options):
+ 
+   libdir = sysroot + '/usr/' + options.system_libdir + '/pkgconfig'
+   libdir += ':' + sysroot + '/usr/share/pkgconfig'
++  libdir += ':' + sysroot + '/usr/' + options.system_libdir + '/riscv64-linux-gnu/pkgconfig'
+   os.environ['PKG_CONFIG_LIBDIR'] = libdir
+   return libdir
+ 
+-- 
+2.25.1
+

+ 42 - 0
0040-GN-Wayland-build-overrides.patch

@@ -0,0 +1,42 @@
+From b0dbabc6c63698586cae1a626789b5108bb7de83 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Fri, 22 Jul 2022 16:24:36 +0800
+Subject: [PATCH 40/51] GN: Wayland build overrides
+
+Introduce //build_overrides/wayland.gni to simplify the management of
+the wayland dependencies in Chromium, ANGLE, and SwiftShader.
+
+Cherry-picked from: commit 3d415c7d0eba78f0b18e2c1fe1e84e4afa7e66e2
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build_overrides/wayland.gni | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+ create mode 100644 build_overrides/wayland.gni
+
+diff --git a/build_overrides/wayland.gni b/build_overrides/wayland.gni
+new file mode 100644
+index 000000000000..0d48c7e31a2e
+--- /dev/null
++++ b/build_overrides/wayland.gni
+@@ -0,0 +1,17 @@
++# Copyright 2022 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.
++
++import("//build/config/ozone.gni")
++
++wayland_gn_dir = "//third_party/wayland"
++
++if (ozone_platform_wayland) {
++  # This defines use_system_libwayland
++  import("$wayland_gn_dir/features.gni")
++} else {
++  use_system_libwayland = false
++}
++
++# Path to Wayland sources
++wayland_dir = "$wayland_gn_dir/src"
+-- 
+2.25.1
+

+ 26 - 0
0041-DEPS-update-commit-hash-for-angle.patch

@@ -0,0 +1,26 @@
+From 767fa17cbaf6e3d485d85b50521b1ba07bfafd53 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Thu, 4 Aug 2022 12:45:21 +0800
+Subject: [PATCH 41/51] DEPS: update commit hash for angle
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ DEPS | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/DEPS b/DEPS
+index 0a16f35dd321..39762f3a2a48 100644
+--- a/DEPS
++++ b/DEPS
+@@ -263,7 +263,7 @@ vars = {
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling ANGLE
+   # and whatever else without interference from each other.
+-  'angle_revision': 'ed00a14f6501b48d2cf24df1642d49653ddc77ff',
++  'angle_revision': '940607349d6aa37b6057f60944338faf9eaa4c37',
+   # Three lines of non-changing comments so that
+   # the commit queue can handle CLs rolling SwiftShader
+   # and whatever else without interference from each other.
+-- 
+2.25.1
+

+ 806 - 0
0042-third_party-crashpad-port-for-RISC-V.patch

@@ -0,0 +1,806 @@
+From 08625f582d2027412e2232090f93acc61a733826 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Wed, 6 Jul 2022 05:16:12 +0000
+Subject: [PATCH 42/51] third_party: crashpad: port for RISC-V
+
+Patch cherry-picked from:
+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         | 54 +++++++++++++
+ .../snapshot/linux/exception_snapshot_linux.h |  3 +
+ .../snapshot/linux/process_reader_linux.cc    |  3 +
+ .../crashpad/snapshot/linux/signal_context.h  | 60 ++++++++++++++
+ .../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, 473 insertions(+), 2 deletions(-)
+
+diff --git a/third_party/crashpad/crashpad/minidump/minidump_context.h b/third_party/crashpad/crashpad/minidump/minidump_context.h
+index 3a3e603cb0d2..cf074d2b8236 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 2f2d90ba4707..ad26739432f5 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 80b312b23c2a..278830085c16 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 78847c11970e..b2a1486dfbbf 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 06d92581330b..616b985a912b 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 < std::size(context.riscv->regs); ++i) {
++      MaybeCaptureMemoryAround(delegate, context.riscv->regs[i]);
++    }
++  } else {
++    for (size_t i = 0; i < std::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 811a7209587d..5b09abdb9676 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 2e29f70398c9..e2f8097e2cae 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 fb23c4679f0a..e120a980448d 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 8464a5a27b2d..ec41216daa90 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 9f46a48977e1..1add07f81af8 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 efc9e5694ea8..c717069b0e71 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
++++ b/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
+@@ -324,6 +324,60 @@ bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
+   return internal::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
+ 
+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 05f6004e11d1..0520af4ce901 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 5711f343a46c..2b3dfeb99732 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 c004f8f6dfab..2291306ca171 100644
+--- a/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
++++ b/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
+@@ -421,6 +421,66 @@ static_assert(offsetof(UContext<ContextTraits64>, mcontext.fpregs) ==
+                   offsetof(ucontext_t, uc_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.
+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 e77bcafa9c6b..2866bb484b5c 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 f279e0adaddb..8c133a7ca909 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 40cd7e7f54a3..aea1ce2047a6 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 557e0d363575..d74dbc1ba168 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 d3f3b2c6953f..007722a29c23 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 7e3f41186f46..9568dc2e24f9 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
+

+ 115 - 0
0043-BUILD.gn-remove-dependency-to-breakpad.patch

@@ -0,0 +1,115 @@
+From 277ffdbdb215c9af6757ffa9ce3466762b95fa41 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Fri, 15 Jul 2022 07:12:43 +0000
+Subject: [PATCH 43/51] BUILD.gn: remove dependency to breakpad
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ BUILD.gn | 36 ------------------------------------
+ 1 file changed, 36 deletions(-)
+
+diff --git a/BUILD.gn b/BUILD.gn
+index 9971e594a5be..72c25f93bbc3 100644
+--- a/BUILD.gn
++++ b/BUILD.gn
+@@ -440,10 +440,6 @@ group("gn_all") {
+ 
+   if (is_linux || is_chromeos || is_android) {
+     deps += [
+-      "//third_party/breakpad:breakpad_unittests",
+-      "//third_party/breakpad:core-2-minidump",
+-      "//third_party/breakpad:generate_test_dump",
+-      "//third_party/breakpad:minidump-2-core",
+       "//tools/dump_process_memory:dump_process",
+       "//tools/memory/partition_allocator:all",
+     ]
+@@ -601,10 +597,6 @@ group("gn_all") {
+       "//mojo:mojo_perftests",
+       "//services/service_manager/public/cpp",
+       "//testing/gmock:gmock_main",
+-      "//third_party/breakpad:dump_syms($host_toolchain)",
+-      "//third_party/breakpad:microdump_stackwalk($host_toolchain)",
+-      "//third_party/breakpad:minidump_dump($host_toolchain)",
+-      "//third_party/breakpad:minidump_stackwalk($host_toolchain)",
+     ]
+ 
+     if (!is_android) {
+@@ -630,9 +622,6 @@ group("gn_all") {
+ 
+   if (is_mac) {
+     deps += [
+-      "//third_party/breakpad:crash_inspector",
+-      "//third_party/breakpad:dump_syms",
+-
+       # The following are accessibility API tools.
+       "//tools/accessibility/inspect:ax_dump_events",
+       "//tools/accessibility/inspect:ax_dump_tree",
+@@ -677,8 +666,6 @@ group("gn_all") {
+         host_os == "win") {
+       deps += [ "//chrome/test/mini_installer:mini_installer_tests" ]
+     }
+-  } else if (!is_android && !is_ios && !is_fuchsia) {
+-    deps += [ "//third_party/breakpad:symupload($host_toolchain)" ]
+   }
+ 
+   if (is_chromecast) {
+@@ -960,7 +947,6 @@ if (is_win) {
+       "//net:net_unittests",
+       "//printing:printing_unittests",
+       "//sql:sql_unittests",
+-      "//third_party/breakpad:symupload($host_toolchain)",
+       "//ui/base:ui_base_unittests",
+       "//ui/gfx:gfx_unittests",
+       "//ui/touch_selection:ui_touch_selection_unittests",
+@@ -987,7 +973,6 @@ if (is_chromeos_ash) {
+       "//ppapi/examples/video_decode",
+       "//sandbox/linux:chrome_sandbox",
+       "//sandbox/linux:sandbox_linux_unittests",
+-      "//third_party/breakpad:minidump_stackwalk($host_toolchain)",
+       "//third_party/dawn/src/dawn/tests:dawn_end2end_tests",
+       "//third_party/dawn/src/dawn/tests:dawn_unittests",
+ 
+@@ -1134,30 +1119,12 @@ if (!is_ios) {
+ 
+     if (is_android) {
+       data_deps += [
+-        "//third_party/breakpad:breakpad_unittests",
+-        "//third_party/breakpad:dump_syms",
+-        "//third_party/breakpad:microdump_stackwalk",
+-        "//third_party/breakpad:minidump_dump",
+-        "//third_party/breakpad:minidump_stackwalk",
+-        "//third_party/breakpad:symupload",
+         "//tools/android/forwarder2",
+       ]
+     } else {
+       data_deps += [ "//content/web_test:web_test_common_mojom_js_data_deps" ]
+     }
+ 
+-    if (!is_win && !is_android) {
+-      data_deps +=
+-          [ "//third_party/breakpad:minidump_stackwalk($host_toolchain)" ]
+-    }
+-
+-    if (is_mac) {
+-      data_deps += [ "//third_party/breakpad:dump_syms($host_toolchain)" ]
+-    }
+-
+-    if (is_linux || is_chromeos) {
+-      data_deps += [ "//third_party/breakpad:dump_syms($host_toolchain)" ]
+-    }
+ 
+     if (is_fuchsia) {
+       data_deps += [
+@@ -1545,9 +1512,6 @@ group("chromium_builder_perf") {
+ 
+     if (is_win) {
+       data_deps += [ "//chrome/installer/mini_installer:mini_installer" ]
+-    } else {
+-      data_deps +=
+-          [ "//third_party/breakpad:minidump_stackwalk($host_toolchain)" ]
+     }
+     if (is_win || is_android) {
+       data_deps += [
+-- 
+2.25.1
+

+ 64 - 0
0044-tools-perf-chrome_telemetry_build-remove-dependency-.patch

@@ -0,0 +1,64 @@
+From 7c2376f86c6778cc7b4b9acb09caefeb5a0096a5 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 18 Jul 2022 01:08:21 +0000
+Subject: [PATCH 44/51] tools: perf: chrome_telemetry_build: remove dependency
+ to breakpad
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ tools/perf/chrome_telemetry_build/BUILD.gn | 18 ------------------
+ 1 file changed, 18 deletions(-)
+
+diff --git a/tools/perf/chrome_telemetry_build/BUILD.gn b/tools/perf/chrome_telemetry_build/BUILD.gn
+index 2d6c25ea2d0b..d782d15bc70e 100644
+--- a/tools/perf/chrome_telemetry_build/BUILD.gn
++++ b/tools/perf/chrome_telemetry_build/BUILD.gn
+@@ -46,8 +46,6 @@ group("telemetry_chrome_test") {
+   }
+ 
+   if (is_linux || is_chromeos) {
+-    data_deps += [ "//third_party/breakpad:dump_syms($host_toolchain)" ]
+-
+     # CrOS currently has issues with the locally compiled version of
+     # crashpad_database_util, so only include it on traditional Linux
+     # platforms.
+@@ -61,7 +59,6 @@ group("telemetry_chrome_test") {
+     data_deps += [
+       "//chrome:chrome_framework",
+       "//chrome:chrome_helper_app_default",
+-      "//third_party/breakpad:dump_syms",
+       "//third_party/crashpad/crashpad/tools:crashpad_database_util",
+     ]
+   }
+@@ -201,7 +198,6 @@ group("telemetry_chrome_test_without_chrome") {
+ 
+   data = [
+     "//build/android/pylib/",  # chromium_config.py uses pylib to look for Java
+-    "//components/crash/content/tools/generate_breakpad_symbols.py",
+     "//tools/perf/chrome_telemetry_build/",
+     "//tools/perf/core/",  # chrome_telemetry_build/ depends on core/
+   ]
+@@ -211,20 +207,6 @@ group("telemetry_chrome_test_without_chrome") {
+     "//tools/metrics:metrics_python_tests",
+   ]
+ 
+-  # Cr-Fuchsia doesn't support breakpad.
+-  if (!is_win && !is_fuchsia) {
+-    data_deps += [
+-      # This is defined for Windows, but is unused by Telemetry on
+-      # Windows, and including it can have issues when cross-compiling
+-      # for Arm-based Windows.
+-      "//third_party/breakpad:dump_syms",
+-
+-      # These explicitly not defined for Windows builds in Breakpad.
+-      "//third_party/breakpad:minidump_dump",
+-      "//third_party/breakpad:minidump_stackwalk",
+-    ]
+-  }
+-
+   if (is_mac) {
+     data += [
+       # Required for the hermetic otool binary, which is required for
+-- 
+2.25.1
+

+ 35 - 0
0045-chrome-test-remove-dependency-to-breakpad.patch

@@ -0,0 +1,35 @@
+From ea9f17b755a42112c4ce9091c0fdc12d4635d904 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 18 Jul 2022 01:15:47 +0000
+Subject: [PATCH 45/51] chrome: test: remove dependency to breakpad
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ chrome/test/BUILD.gn | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
+index a55d15860d58..dfa043daf2bc 100644
+--- a/chrome/test/BUILD.gn
++++ b/chrome/test/BUILD.gn
+@@ -401,7 +401,6 @@ static_library("test_support") {
+     ]
+     public_deps += [
+       "//components/crash/core/app",
+-      "//third_party/breakpad",
+     ]
+   }
+ 
+@@ -9298,9 +9297,6 @@ test("chrome_app_unittests") {
+     "//components/heap_profiling/in_process",
+     "//components/safe_browsing:buildflags",
+   ]
+-  if (!is_fuchsia) {
+-    deps += [ "//third_party/breakpad:client" ]
+-  }
+   if (enable_gwp_asan) {
+     deps += [ "//components/gwp_asan/client" ]
+   }
+-- 
+2.25.1
+

+ 68 - 0
0046-content-shell-remove-dependency-to-breakpad.patch

@@ -0,0 +1,68 @@
+From 20b697d625110386013e5e76b315aa0e70a503e5 Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 18 Jul 2022 01:19:03 +0000
+Subject: [PATCH 46/51] content: shell: remove dependency to breakpad
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ content/shell/BUILD.gn | 13 -------------
+ 1 file changed, 13 deletions(-)
+
+diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn
+index 2f83c8802711..abcf4c69b1ba 100644
+--- a/content/shell/BUILD.gn
++++ b/content/shell/BUILD.gn
+@@ -649,7 +649,6 @@ if (is_mac) {
+     testonly = true
+     info_plist = "app/framework-Info.plist"
+     args = [
+-      "--breakpad=0",
+       "--keystone=0",
+       "--scm=1",
+       "--version",
+@@ -723,7 +722,6 @@ if (is_mac) {
+     testonly = true
+     info_plist = "app/helper-Info.plist"
+     args = [
+-      "--breakpad=0",
+       "--keystone=0",
+       "--scm=0",
+       "--version",
+@@ -859,7 +857,6 @@ group("content_shell_crash_test") {
+     "//third_party/mesa_headers",
+   ]
+   data = [
+-    "//content/shell/tools/breakpad_integration_test.py",
+     "//testing/scripts/content_shell_crash_test.py",
+   ]
+   if (is_mac && !use_system_xcode) {
+@@ -875,26 +872,16 @@ group("content_shell_crash_test") {
+   }
+   if (is_posix) {
+     data += [
+-      "//components/crash/content/tools/generate_breakpad_symbols.py",
+       "//components/crash/content/tools/dmp2minidump.py",
+     ]
+   }
+   if (is_win) {
+     data_deps += [ "//build/win:copy_cdb_to_output" ]
+   }
+-  if (is_posix) {
+-    data_deps += [
+-      "//third_party/breakpad:dump_syms",
+-      "//third_party/breakpad:minidump_stackwalk",
+-    ]
+-  }
+   if (is_android) {
+     data_deps += [
+       "//build/android:devil_chromium_py",
+       "//build/android:test_runner_py",
+-      "//third_party/breakpad:microdump_stackwalk",
+-      "//third_party/breakpad:minidump_dump",
+-      "//third_party/breakpad:symupload",
+       "//tools/android/forwarder2",
+     ]
+   }
+-- 
+2.25.1
+

+ 53 - 0
0047-third_party-libvpx-enable-riscv64-build-as-generic.patch

@@ -0,0 +1,53 @@
+From 3ed9cc1981b7b8978cc5132a6b27dc43ac4a6c2e Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh <tienhock.loh@starfivetech.com>
+Date: Wed, 10 Aug 2022 06:01:53 -0400
+Subject: [PATCH 47/51] third_party: libvpx: enable riscv64 build as generic
+
+Added libvpx as dependency to nwjs and add libvpx
+riscv64 build support.
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Signed-off-by: Tien Hock Loh <tienhock.loh@starfivetech.com>
+---
+ chrome/BUILD.gn             | 1 +
+ third_party/libvpx/BUILD.gn | 5 +++++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
+index 29f9ecf4f288..de2022debd8e 100644
+--- a/chrome/BUILD.gn
++++ b/chrome/BUILD.gn
+@@ -1487,6 +1487,7 @@ group("dependencies") {
+     "//services/tracing/public/cpp",
+     "//third_party/blink/public:blink_devtools_frontend_resources",
+     "//third_party/blink/public:blink_devtools_inspector_resources",
++    "//third_party/libvpx",
+     "//v8:v8_headers",
+   ]
+ 
+diff --git a/third_party/libvpx/BUILD.gn b/third_party/libvpx/BUILD.gn
+index 758aca154073..ee4de99375ac 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
+ }
+@@ -399,6 +401,9 @@ static_library("libvpx") {
+       sources = libvpx_srcs_arm64
+       public_deps = [ ":libvpx_arm64_headers" ]
+     }
++  } else if (current_cpu == "riscv64") {
++    sources = libvpx_srcs_generic
++    public_deps = [ ":libvpx_generic_headers" ]
+   }
+ 
+   configs -= [ "//build/config/compiler:chromium_code" ]
+-- 
+2.25.1
+

+ 29 - 0
0048-DEPS-update-commit-hash-for-ffmpeg.patch

@@ -0,0 +1,29 @@
+From c38f00576e0d8a4912297d6eebc78ca125a098fd Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Fri, 12 Aug 2022 10:44:59 +0800
+Subject: [PATCH 48/51] DEPS: update commit hash for ffmpeg
+
+Regenerate the gni files for ffmpeg and
+fix ffmpeg linking issue at build time.
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ DEPS | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/DEPS b/DEPS
+index 39762f3a2a48..1568b3135dd5 100644
+--- a/DEPS
++++ b/DEPS
+@@ -1187,7 +1187,7 @@ deps = {
+     Var('chromium_git') + '/external/github.com/google/farmhash.git' + '@' + '816a4ae622e964763ca0862d9dbd19324a1eaf45',
+ 
+   'src/third_party/ffmpeg':
+-    Var('reb_git') + '/chromium-ffmpeg.git' + '@' + '63c83e8f91ece09847337856ad7b14a1c25d3c77',
++    Var('reb_git') + '/chromium-ffmpeg.git' + '@' + '54226c9fb8362023b625738519572be1faa079b2',
+ 
+   'src/third_party/flac':
+     Var('chromium_git') + '/chromium/deps/flac.git' + '@' + 'af862024c8c8fa0ae07ced05e89013d881b00596',
+-- 
+2.25.1
+

+ 26 - 0
0049-third_party-breakpad-fix-undefined-reference.patch

@@ -0,0 +1,26 @@
+From 781831c1fa90eaaaefd37847b607a56a92973502 Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh <tienhock.loh@starfivetech.com>
+Date: Fri, 12 Aug 2022 03:28:05 +0000
+Subject: [PATCH 49/51] third_party: breakpad: fix undefined reference
+
+Signed-off-by: Tien Hock Loh <tienhock.loh@starfivetech.com>
+---
+ third_party/breakpad/BUILD.gn | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn
+index 48defa6ef092..9e1f426e756f 100644
+--- a/third_party/breakpad/BUILD.gn
++++ b/third_party/breakpad/BUILD.gn
+@@ -617,6 +617,8 @@ if (is_linux || is_chromeos || is_android) {
+       "breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.h",
+       "breakpad/src/client/linux/minidump_writer/minidump_writer.cc",
+       "breakpad/src/client/linux/minidump_writer/minidump_writer.h",
++      "breakpad/src/client/linux/minidump_writer/pe_file.cc",
++      "breakpad/src/client/linux/minidump_writer/pe_file.h",
+       "breakpad/src/client/linux/minidump_writer/proc_cpuinfo_reader.h",
+       "breakpad/src/client/minidump_file_writer-inl.h",
+       "breakpad/src/client/minidump_file_writer.cc",
+-- 
+2.25.1
+

+ 25 - 0
0050-build-config-compiler-add-march-for-riscv64.patch

@@ -0,0 +1,25 @@
+From 1e5a4cb190d7569be8bf075cc4350b748e647fca Mon Sep 17 00:00:00 2001
+From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+Date: Mon, 15 Aug 2022 10:05:09 +0800
+Subject: [PATCH 50/51] build: config: compiler: add march for riscv64
+
+Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
+---
+ build/config/compiler/BUILD.gn | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+index c2fce9eb8ede..2275a63517df 100644
+--- a/build/config/compiler/BUILD.gn
++++ b/build/config/compiler/BUILD.gn
+@@ -1183,6 +1183,7 @@ config("compiler_cpu_abi") {
+       }
+     } else if (current_cpu == "riscv64") {
+       cflags += [
++        "-march=rv64gc",
+         "-m64",
+         "--target=riscv64-linux-gnu",
+         "-mno-relax",
+-- 
+2.25.1
+

+ 25 - 0
0051-build-config-compiler-add-rpath-link-for-rv64.patch

@@ -0,0 +1,25 @@
+From c9176f9e0294c1e5e7f0642cc4b3a88ede579a53 Mon Sep 17 00:00:00 2001
+From: Tien Hock Loh - swbuildbot <tienhock.loh@starfivetech.com>
+Date: Mon, 15 Aug 2022 05:57:59 +0000
+Subject: [PATCH 51/51] build: config: compiler: add rpath-link for rv64
+
+Signed-off-by: Tien Hock Loh - swbuildbot <tienhock.loh@starfivetech.com>
+---
+ build/config/compiler/BUILD.gn | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+index 2275a63517df..30250910de64 100644
+--- a/build/config/compiler/BUILD.gn
++++ b/build/config/compiler/BUILD.gn
+@@ -1193,6 +1193,7 @@ config("compiler_cpu_abi") {
+       ldflags += [
+         "--target=riscv64-linux-gnu",
+         "-mno-relax",
++        "-Wl,-rpath-link=./lib",
+       ]
+     } else if (current_cpu == "s390x") {
+       cflags += [ "-m64" ]
+-- 
+2.25.1
+

+ 0 - 0
0001-linux-sysroot-script-to-create-riscv-sysroot-from-De.patch → archive/0001-linux-sysroot-script-to-create-riscv-sysroot-from-De.patch


+ 0 - 0
0002-sandbox-add-riscv-arch-definition-and-define-syscall.patch → archive/0002-sandbox-add-riscv-arch-definition-and-define-syscall.patch


+ 0 - 0
0004-skia-add-riscv64.patch → archive/0004-skia-add-riscv64.patch


+ 0 - 0
0005-base-allocator-partition_allocator-add-riscv64-suppo.patch → archive/0005-base-allocator-partition_allocator-add-riscv64-suppo.patch


+ 0 - 0
0006-base-process-add-riscv64-arch-definition.patch → archive/0006-base-process-add-riscv64-arch-definition.patch


+ 0 - 0
0007-remoting-fix-missing-cstring-header.patch → archive/0007-remoting-fix-missing-cstring-header.patch


+ 0 - 0
0008-remoting-codec-fix-missing-cmath-header.patch → archive/0008-remoting-codec-fix-missing-cmath-header.patch


+ 0 - 0
0009-components-update_client-add-riscv64-arch-definition.patch → archive/0009-components-update_client-add-riscv64-arch-definition.patch


+ 0 - 0
0010-build-config-compiler-use_gold-linker-option.patch → archive/0010-build-config-compiler-use_gold-linker-option.patch


+ 0 - 0
0011-build-config-compiler-remove-flags-not-available-in-.patch → archive/0011-build-config-compiler-remove-flags-not-available-in-.patch


+ 0 - 0
0012-build-config-add-atomic-build-flag.patch → archive/0012-build-config-add-atomic-build-flag.patch


+ 0 - 0
0013-build-config-compiler-do-not-use-linker-relaxation.patch → archive/0013-build-config-compiler-do-not-use-linker-relaxation.patch


+ 0 - 0
0014-chrome-common-remove-unrar-code.patch → archive/0014-chrome-common-remove-unrar-code.patch


+ 0 - 0
0015-third_party-libaom-add-riscv-target.patch → archive/0015-third_party-libaom-add-riscv-target.patch


+ 0 - 0
0016-third_party-libvpx-add-riscv-target.patch → archive/0016-third_party-libvpx-add-riscv-target.patch


+ 0 - 0
0017-third_party-crashpad-add-support-for-riscv.patch → archive/0017-third_party-crashpad-add-support-for-riscv.patch


+ 0 - 0
0018-third_party-lzma_sdk-add-riscv-arch-definition.patch → archive/0018-third_party-lzma_sdk-add-riscv-arch-definition.patch


+ 0 - 0
0019-build-linux-sysroot-create-a-sysroot-for-riscv.patch → archive/0019-build-linux-sysroot-create-a-sysroot-for-riscv.patch


+ 0 - 0
0020-build-config-linux-workaround-for-files-not-found-wi.patch → archive/0020-build-config-linux-workaround-for-files-not-found-wi.patch


+ 0 - 0
0021-v8-settings.patch → archive/0021-v8-settings.patch


+ 0 - 0
0022-chrome-installer-add-riscv64-as-one-of-the-target-ar.patch → archive/0022-chrome-installer-add-riscv64-as-one-of-the-target-ar.patch


+ 0 - 0
0023-ui-gl-enable-swiftshader-for-riscv64.patch → archive/0023-ui-gl-enable-swiftshader-for-riscv64.patch