This is an autogenerated patch header for a single-debian-patch file. The
delta against upstream is either kept as a single patch, or maintained
in some VCS, and exported as a single patch instead of more manageable
atomic patches.

--- pmdk-1.11.1.orig/src/Makefile.inc
+++ pmdk-1.11.1/src/Makefile.inc
@@ -149,7 +149,7 @@ ifneq ($(TESTBUILD), 1)
 $(error "$(TESTCMD)" failed)
 endif
 
-ifeq ($(filter $(ARCH), x86_64 aarch64 ppc64),)
+ifeq ($(filter $(ARCH), x86_64 aarch64 ppc64 riscv64),)
 $(error unsupported architecture: $(ARCH))
 endif
 
--- pmdk-1.11.1.orig/src/common/pool_hdr.c
+++ pmdk-1.11.1/src/common/pool_hdr.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: BSD-3-Clause
-/* Copyright 2014-2019, Intel Corporation */
+/* Copyright 2014-2021, Intel Corporation */
 
 /*
  * pool_hdr.c -- pool header utilities
@@ -28,6 +28,10 @@
 #define PMDK_MACHINE PMDK_MACHINE_PPC64
 #define PMDK_MACHINE_CLASS PMDK_MACHINE_CLASS_64
 
+#elif defined(__riscv) && defined(_LP64)
+#define PMDK_MACHINE PMDK_MACHINE_RISCV64
+#define PMDK_MACHINE_CLASS PMDK_MACHINE_CLASS_64
+
 #else
 /* add appropriate definitions here when porting PMDK to another ISA */
 #error unable to recognize ISA at compile time
--- pmdk-1.11.1.orig/src/common/pool_hdr.h
+++ pmdk-1.11.1/src/common/pool_hdr.h
@@ -77,6 +77,7 @@ struct arch_flags {
 #define PMDK_MACHINE_X86_64 62
 #define PMDK_MACHINE_AARCH64 183
 #define PMDK_MACHINE_PPC64 21
+#define PMDK_MACHINE_RISCV64 243
 
 /* possible values of the data field in the above struct */
 #define PMDK_DATA_LE 1 /* 2's complement, little endian */
--- pmdk-1.11.1.orig/src/core/page_size.h
+++ pmdk-1.11.1/src/core/page_size.h
@@ -1,11 +1,12 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
-/* Copyright 2019-2020, Intel Corporation */
+/* Copyright 2019-2021, Intel Corporation */
 /* Copyright 2019, IBM Corporation */
 
 #ifndef PMDK_PAGE_SIZE_H
 #define PMDK_PAGE_SIZE_H
 
-#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__)
+#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__) || \
+	defined(__riscv)
 
 #define PMEM_PAGESIZE 4096
 
--- pmdk-1.11.1.orig/src/core/util.h
+++ pmdk-1.11.1/src/core/util.h
@@ -58,7 +58,8 @@ extern "C" {
 extern unsigned long long Pagesize;
 extern unsigned long long Mmap_align;
 
-#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__)
+#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__) || \
+	defined(__riscv)
 #define CACHELINE_SIZE 64ULL
 #elif defined(__PPC64__)
 #define CACHELINE_SIZE 128ULL
--- pmdk-1.11.1.orig/src/core/valgrind_internal.h
+++ pmdk-1.11.1/src/core/valgrind_internal.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
-/* Copyright 2015-2020, Intel Corporation */
+/* Copyright 2015-2021, Intel Corporation */
 
 /*
  * valgrind_internal.h -- internal definitions for valgrind macros
@@ -8,7 +8,7 @@
 #ifndef PMDK_VALGRIND_INTERNAL_H
 #define PMDK_VALGRIND_INTERNAL_H 1
 
-#if !defined(_WIN32) && !defined(__FreeBSD__)
+#if !defined(_WIN32) && !defined(__FreeBSD__) && !defined(__riscv)
 #ifndef VALGRIND_ENABLED
 #define VALGRIND_ENABLED 1
 #endif
--- pmdk-1.11.1.orig/src/examples/libpmem2/redo/redo.c
+++ pmdk-1.11.1/src/examples/libpmem2/redo/redo.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: BSD-3-Clause
-/* Copyright 2020, Intel Corporation */
+/* Copyright 2020-2021, Intel Corporation */
 
 /*
  * redo.c -- Implementation of simple persistent memory located redo log.
@@ -22,7 +22,8 @@
 #endif
 #include <libpmem2.h>
 
-#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__)
+#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__) || \
+	defined(__riscv)
 #define CACHELINE 64ULL
 #elif defined(__PPC64__)
 #define CACHELINE 128ULL
--- pmdk-1.11.1.orig/src/include/libpmemblk.h
+++ pmdk-1.11.1/src/include/libpmemblk.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
-/* Copyright 2014-2020, Intel Corporation */
+/* Copyright 2014-2021, Intel Corporation */
 
 /*
  * libpmemblk.h -- definitions of libpmemblk entry points
@@ -72,7 +72,8 @@ const wchar_t *pmemblk_check_versionW(un
 /* XXX - unify minimum pool size for both OS-es */
 
 #ifndef _WIN32
-#if defined(__x86_64__) || defined(__M_X64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__M_X64__) || defined(__aarch64__) || \
+	defined(__riscv)
 /* minimum pool size: 16MiB + 4KiB (minimum BTT size + mmap alignment) */
 #define PMEMBLK_MIN_POOL ((size_t)((1u << 20) * 16 + (1u << 10) * 8))
 #elif defined(__PPC64__)
--- /dev/null
+++ pmdk-1.11.1/src/libpmem2/riscv64/flags.inc
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2021, Intel Corporation
+
+#
+# src/libpmem2/riscv64/flags.inc -- flags for libpmem2/riscv64
+#
+
+vpath %.c $(TOP)/src/libpmem2/riscv64
+vpath %.h $(TOP)/src/libpmem2/riscv64
+
+CFLAGS += -Iriscv64
--- /dev/null
+++ pmdk-1.11.1/src/libpmem2/riscv64/init.c
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/* Copyright 2021, Intel Corporation */
+
+#include <string.h>
+
+#include "auto_flush.h"
+#include "out.h"
+#include "pmem2_arch.h"
+#include "rv_cacheops.h"
+
+/*
+ * memory_barrier -- (internal) issue the fence instruction
+ */
+static void
+memory_barrier(void)
+{
+	LOG(15, NULL);
+	riscv_store_memory_barrier();
+}
+
+static void
+noop(const void *addr, size_t len)
+{
+}
+
+/*
+ * pmem2_arch_init -- initialize architecture-specific list of pmem operations
+ */
+void
+pmem2_arch_init(struct pmem2_arch_info *info)
+{
+	LOG(3, NULL);
+
+	info->fence = memory_barrier;
+	info->flush = noop;
+}
--- /dev/null
+++ pmdk-1.11.1/src/libpmem2/riscv64/rv_cacheops.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/* Copyright 2021, Intel Corporation */
+
+#ifndef RISCV64_CACHEOPS_H
+#define RISCV64_CACHEOPS_H
+
+#include <stdlib.h>
+
+static inline void
+riscv_store_memory_barrier(void)
+{
+	asm volatile("fence w,w" : : : "memory");
+}
+#endif
--- /dev/null
+++ pmdk-1.11.1/src/libpmem2/riscv64/sources.inc
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2021, Intel Corporation
+
+#
+# src/libpmem2/riscv64/sources.inc -- list of files for libpmem2/riscv64
+#
+
+LIBPMEM2_ARCH_SOURCE = init.c
--- pmdk-1.11.1.orig/src/test/helgrind-log.supp
+++ pmdk-1.11.1/src/test/helgrind-log.supp
@@ -4,7 +4,7 @@
     fun:*mem*cpy
     ...
     fun:_IO_file_xsputn@@GLIBC*
-    fun:fputs
+    ...
     fun:out_print_func
     fun:out_common
     fun:out_log
@@ -25,7 +25,7 @@
     fun:*mem*cpy
     ...
     fun:_IO_file_xsputn@@GLIBC*
-    fun:fputs
+    ...
     fun:out_print_func
     fun:out_error
     fun:out_err
--- pmdk-1.11.1.orig/src/test/libpmempool_bttdev/TEST11
+++ pmdk-1.11.1/src/test/libpmempool_bttdev/TEST11
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2016-2018, Intel Corporation
+# Copyright 2016-2021, Intel Corporation
 #
 #
 # libpmempool_bttdev/TEST11 -- test for checking btt
@@ -9,8 +9,8 @@
 . ../unittest/unittest.sh
 
 require_test_type medium
-
 require_fs_type any
+require_unlimited_vm
 
 # Valgrind cannot trace more than 32G which is required for this test
 configure_valgrind memcheck force-disable
--- pmdk-1.11.1.orig/src/test/libpmempool_bttdev/TEST3
+++ pmdk-1.11.1/src/test/libpmempool_bttdev/TEST3
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2016-2018, Intel Corporation
+# Copyright 2016-2021, Intel Corporation
 #
 #
 # libpmempool_bttdev/TEST3 -- test for checking btt
@@ -9,8 +9,8 @@
 . ../unittest/unittest.sh
 
 require_test_type medium
-
 require_fs_type any
+require_unlimited_vm
 
 # Valgrind cannot trace more than 32G which is required for this test
 configure_valgrind memcheck force-disable
--- pmdk-1.11.1.orig/src/test/libpmempool_bttdev/TEST4
+++ pmdk-1.11.1/src/test/libpmempool_bttdev/TEST4
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2016-2018, Intel Corporation
+# Copyright 2016-2021, Intel Corporation
 #
 #
 # libpmempool_bttdev/TEST4 -- test for checking btt
@@ -9,8 +9,8 @@
 . ../unittest/unittest.sh
 
 require_test_type medium
-
 require_fs_type any
+require_unlimited_vm
 
 # Valgrind cannot trace more than 32G which is required for this test
 configure_valgrind memcheck force-disable
--- pmdk-1.11.1.orig/src/test/libpmempool_bttdev/TEST5
+++ pmdk-1.11.1/src/test/libpmempool_bttdev/TEST5
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2016-2018, Intel Corporation
+# Copyright 2016-2021, Intel Corporation
 #
 #
 # libpmempool_bttdev/TEST5 -- test for checking btt
@@ -9,8 +9,8 @@
 . ../unittest/unittest.sh
 
 require_test_type medium
-
 require_fs_type any
+require_unlimited_vm
 
 # Valgrind cannot trace more than 32G which is required for this test
 configure_valgrind memcheck force-disable
--- pmdk-1.11.1.orig/src/test/libpmempool_bttdev/TEST6
+++ pmdk-1.11.1/src/test/libpmempool_bttdev/TEST6
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2016-2018, Intel Corporation
+# Copyright 2016-2021, Intel Corporation
 #
 #
 # libpmempool_bttdev/TEST6 -- test for checking btt
@@ -9,8 +9,8 @@
 . ../unittest/unittest.sh
 
 require_test_type medium
-
 require_fs_type any
+require_unlimited_vm
 
 # Valgrind cannot trace more than 32G which is required for this test
 configure_valgrind memcheck force-disable
--- pmdk-1.11.1.orig/src/test/pmem_deep_persist/Makefile
+++ pmdk-1.11.1/src/test/pmem_deep_persist/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2017-2019, Intel Corporation
+# Copyright 2017-2021, Intel Corporation
 
 #
 # src/test/pmem_deep_persist/Makefile -- build pmem_deep_persist test
@@ -23,6 +23,9 @@ OBJS = pmem_deep_persist.o\
 ifeq ($(ARCH), aarch64)
 OBJS += init.o
 endif
+ifeq ($(ARCH), riscv64)
+OBJS += init.o
+endif
 ifeq ($(ARCH), x86_64)
 OBJS += init.o cpu.o
 endif
--- pmdk-1.11.1.orig/src/test/pmem_is_pmem_posix/Makefile
+++ pmdk-1.11.1/src/test/pmem_is_pmem_posix/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2016-2019, Intel Corporation
+# Copyright 2016-2021, Intel Corporation
 
 #
 # src/test/pmem_is_pmem_posix/Makefile -- build pmem_is_pmem_posix unit test
@@ -20,6 +20,9 @@ OBJS = pmem_is_pmem_posix.o\
 ifeq ($(ARCH), aarch64)
 OBJS += init.o
 endif
+ifeq ($(ARCH), riscv64)
+OBJS += init.o
+endif
 ifeq ($(ARCH), x86_64)
 OBJS += init.o cpu.o
 endif
--- pmdk-1.11.1.orig/src/test/pmempool_check/TEST5
+++ pmdk-1.11.1/src/test/pmempool_check/TEST5
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2014-2018, Intel Corporation
+# Copyright 2014-2021, Intel Corporation
 #
 #
 # pmempool_check/TEST5 -- test for checking pools
@@ -9,8 +9,8 @@
 . ../unittest/unittest.sh
 
 require_test_type medium
-
 require_fs_type pmem non-pmem
+require_unlimited_vm
 
 # Valgrind cannot trace more than 32G which is required for this test
 configure_valgrind force-disable
--- pmdk-1.11.1.orig/src/test/pmempool_info/out27.log.match
+++ pmdk-1.11.1/src/test/pmempool_info/out27.log.match
@@ -21,6 +21,7 @@ Class                    : $(*)
 Data                     : $(*)
 $(OPT)Machine                  : AMD X86-64
 $(OPT)Machine                  : Aarch64
+$(OPT)Machine                  : RISCV
 $(OPX)Machine                  : PPC64
 Last shutdown            : clean
 Checksum                 : $(*) [OK]
--- pmdk-1.11.1.orig/src/test/unittest/unittest.sh
+++ pmdk-1.11.1/src/test/unittest/unittest.sh
@@ -1005,8 +1005,13 @@ function check_pools() {
 # This implies requirements for:
 # - overcommit_memory enabled (/proc/sys/vm/overcommit_memory is 0 or 1)
 # - unlimited virtual memory (ulimit -v is unlimited)
+# - big enough virtual memory (sv39 is too small)
 #
 function require_unlimited_vm() {
+	if grep -q "^mmu[[:blank:]]*: sv39" /proc/cpuinfo; then
+		msg "$UNITTEST_NAME: SKIP required: 4+ level virtual memory"
+		exit 0
+	fi
 	$VM_OVERCOMMIT && [ $(ulimit -v) = "unlimited" ] && return
 	msg "$UNITTEST_NAME: SKIP required: overcommit_memory enabled and unlimited virtual memory"
 	exit 0
--- pmdk-1.11.1.orig/src/tools/pmempool/output.c
+++ pmdk-1.11.1/src/tools/pmempool/output.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: BSD-3-Clause
-/* Copyright 2014-2020, Intel Corporation */
+/* Copyright 2014-2021, Intel Corporation */
 
 /*
  * output.c -- definitions of output printing related functions
@@ -726,6 +726,8 @@ out_get_arch_machine_str(uint16_t machin
 		return "Aarch64";
 	case PMDK_MACHINE_PPC64:
 		return "PPC64";
+	case PMDK_MACHINE_RISCV64:
+		return "RISCV";
 	default:
 		break;
 	}
