subtree updates

meta-raspberrypi: 40283f583b..ca11a291ee:
  Martin Schuessler (1):
        omxplayer: remove hardcoded tune and arch from Makefile

poky: 111b7173fe..50d272863d:
  Adrian Bunk (3):
        wireless-regdb: Add recipe
        go: Upgrade 1.12.5 -> 1.12.6
        libxslt: Fix CVE-2019-11068

  Alexander Kanavin (7):
        vala: upgrade 0.44.3 -> 0.44.5
        libnewt: merge libnewt-python recipe into the main recipe
        epiphany: update to 3.32.3
        btrfs-tools: update to 5.1.1
        createrepo-c: upgrade 0.14.0 -> 0.14.2
        librepo: upgrade 1.10.2 -> 1.10.3
        libmodulemd: upgrade 2.4.0 -> 2.5.0

  Alistair Francis (6):
        libffi: Add RISC-V support
        opensbi: Initial commit of OpenSBI
        qemuriscv64: Add the QEMU RISC-V 64-bit machine
        linux-yocto: Mark qemuriscv64 as compatible
        qemuriscv: Build uImage for RISC-V machines
        qemuriscv64: Fix QB_OPT_APPEND overwrite

  Anuj Mittal (1):
        runtime/cases/logrotate: make test more reliable

  Ayoub Zaki (1):
        kernel-fitimage: introduce FIT_HASH_ALG

  Changqing Li (1):
        gcc-runtime: fix C++ header mapping for n32/x32 tune

  Chee Yang Lee (1):
        wic/bootimg-efi: allow multiple initrd

  Chen Qi (2):
        manifest.py: fix test_SDK_manifest_entries
        target-sdk-provides-dummy: add libperl.so.5 to DUMMY_PROVIDES

  Chris PeBenito (1):
        volatile-binds: Change cp to use -a instead of -p.

  Denys Dmytriyenko (2):
        mtd-utils: upgrade 2.0.2 -> 2.1.0+
        mtd-utils: add "jffs" and "ubifs" PACKAGECONFIG options

  He Zhe (1):
        kernel: qemuarmv5: Update machine overrides of KERNEL_DEVICETREE

  Joe Slater (1):
        parted: change device manager check in ptest

  Joshua Watt (1):
        python3: Disable PGO for reproducible builds

  Kai Kang (3):
        systemd-conf: not configure network for nfs root
        rng-tools: 6.6 -> 6.7
        qemu: disable capstone for 32-bit mips with multilib

  Lei Maohui (1):
        openssl: Fix a build bug on aarch64BE.

  Martin Jansa (4):
        buildhistory: show time spent writting buildhistory
        base.bbclass: define PACKAGECONFIG_CONFARGS before only sometimes appending to it
        serf: stop scons trying to create directories in hosts rootfs
        bitbake: tests/utils.py: add one more test cases for bb.utils.vercmp_string

  Matt Madison (1):
        apt: fix permissions on apt-daily script for systemd

  Mingli Yu (1):
        bitbake: add iconv to HOSTTOOLS

  Pierre Le Magourou (4):
        cve-update-db: New recipe to update CVE database
        cve-check: Remove dependency to cve-check-tool-native
        cve-check: Manage CVE_PRODUCT with more than one name
        cve-check: Consider CVE that affects versions with less than operator

  Ricardo Ribalda Delgado (4):
        dpkg: Use less as pager
        meson: Fix native patch to python3
        rootfs: Fix dependency for every dpkg run
        python3: python3: Fix build error x86->x86

  Richard Purdie (7):
        libxcrypt: Switch to disable obsolete APIs
        libxcrypt-compat: Add recipe to build the obsolete APIs
        uninative-tarball: Add libxcrypt-compat
        openssh: Add missing DEPENDS on virtual/crypt
        lttng-tools: Filter ptest output to remove random tmp directories
        cmake: Clarify comment in cmake toolchain file
        uninative: Update to 2.6 release

  Robert Yang (2):
        linux-dummy: Add do_compile_kernelmodules
        make-mod-scripts: Depends on bison-native

  Ross Burton (7):
        insane: improve buildpath warning messages
        insane: remove empty test that does nothing
        binconfig: don't try to fix up .la files
        libsdl2: use binconfig-disabled
        glib-2.0: fix host path appearing in gsocketclient-slow test script
        oeqa/logparser: ignore test failure commentary
        python: make 'python' install everything instead of just the interpretter

  Stefano Babic (1):
        systat: systemd never enables the service

  Tim Orling (4):
        perl-rdepends.txt: more ptest dependencies fixes
        libxml-sax-perl: upgrade 1.00 -> 1.02
        libmodule-build-perl: move from meta-perl
        libmodule-build-perl: upgrade 0.4224 -> 0.4229; enable ptest

  Yi Zhao (2):
        shadow: fix configure error with dash
        less: upgrade 550 -> 551

  Zang Ruochen (9):
        lighttpd: Upgrade 1.4.53 -> 1.4.54
        libevent:upgrade 2.1.8 -> 2.1.10
        libevdev:upgrade 1.6.0 -> 1.7.0
        gnutls:upgrade 3.6.7 -> 3.6.8
        gnupg:upgrade 2.2.15 -> 2.2.16
        curl:upgrade 7.64.1 -> 7.65.1
        lttng-ust:upgrade 2.10.3 -> 2.10.4
        xkeyboard:upgrade 2.26 -> 2.27
        gobject-introspection:upgrade 1.60.1 -> 1.60.2

Change-Id: I3df401c6822e1c5c2ee9cff57c7264fe31c6d22d
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/poky/meta/recipes-support/curl/curl_7.64.1.bb b/poky/meta/recipes-support/curl/curl_7.65.1.bb
similarity index 95%
rename from poky/meta/recipes-support/curl/curl_7.64.1.bb
rename to poky/meta/recipes-support/curl/curl_7.65.1.bb
index 47c28be..e7bfe6c 100644
--- a/poky/meta/recipes-support/curl/curl_7.64.1.bb
+++ b/poky/meta/recipes-support/curl/curl_7.65.1.bb
@@ -9,8 +9,8 @@
            file://0001-replace-krb5-config-with-pkg-config.patch \
 "
 
-SRC_URI[md5sum] = "790c101927845208a9d7e8c429ddd1b2"
-SRC_URI[sha256sum] = "4cc7c738b35250d0680f29e93e0820c4cb40035f43514ea3ec8d60322d41a45d"
+SRC_URI[md5sum] = "03ca3fa53ac4d791be66e30ba75b56ea"
+SRC_URI[sha256sum] = "cbd36df60c49e461011b4f3064cff1184bdc9969a55e9608bf5cadec4686e3f7"
 
 CVE_PRODUCT = "curl libcurl"
 inherit autotools pkgconfig binconfig multilib_header
diff --git a/poky/meta/recipes-support/gnupg/gnupg_2.2.15.bb b/poky/meta/recipes-support/gnupg/gnupg_2.2.16.bb
similarity index 92%
rename from poky/meta/recipes-support/gnupg/gnupg_2.2.15.bb
rename to poky/meta/recipes-support/gnupg/gnupg_2.2.16.bb
index 06a2573..cb7c6c5 100644
--- a/poky/meta/recipes-support/gnupg/gnupg_2.2.15.bb
+++ b/poky/meta/recipes-support/gnupg/gnupg_2.2.16.bb
@@ -20,8 +20,8 @@
                                 file://relocate.patch"
 
 
-SRC_URI[md5sum] = "3ab87e377aa0af2f463649515bf66508"
-SRC_URI[sha256sum] = "cb8ce298d7b36558ffc48aec961b14c830ff1783eef7a623411188b5e0f5d454"
+SRC_URI[md5sum] = "d90e186df1c06845880ea58a318f070b"
+SRC_URI[sha256sum] = "6cbe8d454bf5dc204621eed3016d721b66298fa95363395bb8eeceb1d2fd14cb"
 
 EXTRA_OECONF = "--disable-ldap \
 		--disable-ccid-driver \
diff --git a/poky/meta/recipes-support/gnutls/gnutls_3.6.7.bb b/poky/meta/recipes-support/gnutls/gnutls_3.6.8.bb
similarity index 93%
rename from poky/meta/recipes-support/gnutls/gnutls_3.6.7.bb
rename to poky/meta/recipes-support/gnutls/gnutls_3.6.8.bb
index b27526a..6c6c520 100644
--- a/poky/meta/recipes-support/gnutls/gnutls_3.6.7.bb
+++ b/poky/meta/recipes-support/gnutls/gnutls_3.6.8.bb
@@ -21,8 +21,8 @@
            file://arm_eabi.patch \
 "
 
-SRC_URI[md5sum] = "c4ac669c500df939d4fbfea722367929"
-SRC_URI[sha256sum] = "5b3409ad5aaf239808730d1ee12fdcd148c0be00262c7edf157af655a8a188e2"
+SRC_URI[md5sum] = "9dcf0aa45d1a42e1b3ca5d39ec7c61a8"
+SRC_URI[sha256sum] = "aa81944e5635de981171772857e72be231a7e0f559ae0292d2737de475383e83"
 
 inherit autotools texinfo pkgconfig gettext lib_package gtk-doc
 
diff --git a/poky/meta/recipes-support/libevdev/libevdev_1.6.0.bb b/poky/meta/recipes-support/libevdev/libevdev_1.7.0.bb
similarity index 74%
rename from poky/meta/recipes-support/libevdev/libevdev_1.6.0.bb
rename to poky/meta/recipes-support/libevdev/libevdev_1.7.0.bb
index 12cf519..abd6f38 100644
--- a/poky/meta/recipes-support/libevdev/libevdev_1.6.0.bb
+++ b/poky/meta/recipes-support/libevdev/libevdev_1.7.0.bb
@@ -8,7 +8,7 @@
 
 SRC_URI = "http://www.freedesktop.org/software/libevdev/${BP}.tar.xz"
 
-SRC_URI[md5sum] = "154b24f01425c4c82fdc3e11f2c13af6"
-SRC_URI[sha256sum] = "f5005c865987d980cc1279b9ec6131b06a89fd9892f649f2a68262b8786ef814"
+SRC_URI[md5sum] = "fabe87d8d7d7f7cdb4a26e5dc99fc517"
+SRC_URI[sha256sum] = "11dbe1f2b1d03a51f3e9a196757a75c3a999042ce34cf1fdc00a2363e5a2e369"
 
 inherit autotools pkgconfig
diff --git a/poky/meta/recipes-support/libevent/libevent/0001-test-fix-32bit-linux-regress.patch b/poky/meta/recipes-support/libevent/libevent/0001-test-fix-32bit-linux-regress.patch
deleted file mode 100644
index 36d0820..0000000
--- a/poky/meta/recipes-support/libevent/libevent/0001-test-fix-32bit-linux-regress.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 69a3813c513c84e02212250c3d5b8a02ecefa698 Mon Sep 17 00:00:00 2001
-From: Mingli Yu <Mingli.Yu@windriver.com>
-Date: Mon, 15 Jan 2018 08:00:33 +0000
-Subject: [PATCH] test: fix 32bit linux regress
-
-This patch comes from https://github.com/libevent/libevent.git,
-the commit is 63c4bf78d6af3c6ff46d2e8e4b53dd9f577a9ca9
-
-Upstream-Status: Backport
-
-Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
----
- configure.ac        | 1 +
- test/regress_util.c | 2 ++
- 2 files changed, 3 insertions(+)
-
-diff --git a/configure.ac b/configure.ac
-index 7528d37..e64cb1f 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -663,6 +663,7 @@ AC_CHECK_SIZEOF(short)
- AC_CHECK_SIZEOF(size_t)
- AC_CHECK_SIZEOF(void *)
- AC_CHECK_SIZEOF(off_t)
-+AC_CHECK_SIZEOF(time_t)
- 
- AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t, struct addrinfo, struct sockaddr_storage], , ,
- [#define _GNU_SOURCE
-diff --git a/test/regress_util.c b/test/regress_util.c
-index ef6a148..0c7eafb 100644
---- a/test/regress_util.c
-+++ b/test/regress_util.c
-@@ -1412,10 +1412,12 @@ static struct date_rfc1123_case {
- 	{  1289433600, "Thu, 11 Nov 2010 00:00:00 GMT"},
- 	{  1323648000, "Mon, 12 Dec 2011 00:00:00 GMT"},
- #ifndef _WIN32
-+#if EVENT__SIZEOF_TIME_T > 4
- 	/** In win32 case we have max   "23:59:59 January 18, 2038, UTC" for time32 */
- 	{  4294967296, "Sun, 07 Feb 2106 06:28:16 GMT"} /* 2^32 */,
- 	/** In win32 case we have max "23:59:59, December 31, 3000, UTC" for time64 */
- 	{253402300799, "Fri, 31 Dec 9999 23:59:59 GMT"} /* long long future no one can imagine */,
-+#endif /* time_t != 32bit */
- 	{  1456704000, "Mon, 29 Feb 2016 00:00:00 GMT"} /* leap year */,
- #endif
- 	{  1435708800, "Wed, 01 Jul 2015 00:00:00 GMT"} /* leap second */,
--- 
-2.13.3
-
diff --git a/poky/meta/recipes-support/libevent/libevent_2.1.8.bb b/poky/meta/recipes-support/libevent/libevent_2.1.10.bb
similarity index 84%
rename from poky/meta/recipes-support/libevent/libevent_2.1.8.bb
rename to poky/meta/recipes-support/libevent/libevent_2.1.10.bb
index 0f91e05..81ceb1c 100644
--- a/poky/meta/recipes-support/libevent/libevent_2.1.8.bb
+++ b/poky/meta/recipes-support/libevent/libevent_2.1.10.bb
@@ -9,12 +9,11 @@
 SRC_URI = " \
     https://github.com/libevent/libevent/releases/download/release-${PV}-stable/${BP}-stable.tar.gz \
     file://Makefile-missing-test-dir.patch \
-    file://0001-test-fix-32bit-linux-regress.patch \
     file://run-ptest \
 "
 
-SRC_URI[md5sum] = "f3eeaed018542963b7d2416ef1135ecc"
-SRC_URI[sha256sum] = "965cc5a8bb46ce4199a47e9b2c9e1cae3b137e8356ffdad6d94d3b9069b71dc2"
+SRC_URI[md5sum] = "999caf86f52943af2363bc8077f00167"
+SRC_URI[sha256sum] = "e864af41a336bb11dab1a23f32993afe963c1f69618bd9292b89ecf6904845b0"
 
 UPSTREAM_CHECK_URI = "http://libevent.org/"
 
diff --git a/poky/meta/recipes-support/libffi/libffi/0001-New-RISC-V-port-281.patch b/poky/meta/recipes-support/libffi/libffi/0001-New-RISC-V-port-281.patch
new file mode 100644
index 0000000..589c4d3
--- /dev/null
+++ b/poky/meta/recipes-support/libffi/libffi/0001-New-RISC-V-port-281.patch
@@ -0,0 +1,827 @@
+From 8ac73103bf12ce4f776940cb17f3ced15a362f23 Mon Sep 17 00:00:00 2001
+From: Stef O'Rear <sorear2@gmail.com>
+Date: Sun, 11 Mar 2018 05:55:15 -0700
+Subject: [PATCH] New RISC-V port (#281)
+
+* Add RISC-V support
+
+This patch adds support for the RISC-V architecture (https://riscv.org).
+
+This patch has been tested using QEMU user-mode emulation and GCC 7.2.0
+in the following configurations:
+
+* -march=rv32imac -mabi=ilp32
+* -march=rv32g -mabi=ilp32d
+* -march=rv64imac -mabi=lp64
+* -march=rv64g -mabi=lp64d
+
+The ABI currently can be found at
+https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md .
+
+* Add RISC-V to README
+
+* RISC-V: fix configure.host
+
+Upstream-Status: Backport [https://github.com/libffi/libffi/commit/3840d49aaa831d649b1597518a2903dfed0d57f3]
+Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
+---
+ Makefile.am           |   4 +
+ configure.ac          |   5 +
+ src/riscv/ffi.c       | 445 ++++++++++++++++++++++++++++++++++++++++++
+ src/riscv/ffitarget.h |  68 +++++++
+ src/riscv/sysv.S      | 214 ++++++++++++++++++++
+ 5 files changed, 736 insertions(+)
+ create mode 100644 src/riscv/ffi.c
+ create mode 100644 src/riscv/ffitarget.h
+ create mode 100644 src/riscv/sysv.S
+
+diff --git a/Makefile.am b/Makefile.am
+index 0e40451..3837650 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -32,6 +32,7 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj			\
+ 	 src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S	\
+ 	 src/powerpc/aix_closure.S src/powerpc/darwin_closure.S		\
+ 	 src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h		\
++	 src/riscv/ffi.c src/riscv/ffitarget.h src/riscv/sysv.S		\
+ 	 src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h		\
+ 	 src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h src/sh64/ffi.c	\
+ 	 src/sh64/sysv.S src/sh64/ffitarget.h src/sparc/v8.S		\
+@@ -122,6 +123,9 @@ endif
+ if MIPS
+ nodist_libffi_la_SOURCES += src/mips/ffi.c src/mips/o32.S src/mips/n32.S
+ endif
++if RISCV
++nodist_libffi_la_SOURCES += src/riscv/ffi.c src/riscv/sysv.S
++endif
+ if BFIN
+ nodist_libffi_la_SOURCES += src/bfin/ffi.c src/bfin/sysv.S
+ endif
+diff --git a/configure.ac b/configure.ac
+index ce30853..33375aa 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -226,6 +226,10 @@ case "$host" in
+ 	TARGET=MIPS; TARGETDIR=mips
+ 	;;
+ 
++  riscv*-*-*)
++	TARGET=RISCV; TARGETDIR=riscv
++	;;
++
+   nios2*-linux*)
+ 	TARGET=NIOS2; TARGETDIR=nios2
+ 	;;
+@@ -298,6 +302,7 @@ if test $TARGETDIR = unknown; then
+ fi
+ 
+ AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
++AM_CONDITIONAL(RISCV, test x$TARGET = xRISCV)
+ AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN)
+ AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
+ AM_CONDITIONAL(X86, test x$TARGET = xX86)
+diff --git a/src/riscv/ffi.c b/src/riscv/ffi.c
+new file mode 100644
+index 0000000..b744fdd
+--- /dev/null
++++ b/src/riscv/ffi.c
+@@ -0,0 +1,445 @@
++/* -----------------------------------------------------------------------
++   ffi.c - Copyright (c) 2015 Michael Knyszek <mknyszek@berkeley.edu>
++                         2015 Andrew Waterman <waterman@cs.berkeley.edu>
++                         2018 Stef O'Rear <sorear2@gmail.com>
++   Based on MIPS N32/64 port
++
++   RISC-V Foreign Function Interface
++
++   Permission is hereby granted, free of charge, to any person obtaining
++   a copy of this software and associated documentation files (the
++   ``Software''), to deal in the Software without restriction, including
++   without limitation the rights to use, copy, modify, merge, publish,
++   distribute, sublicense, and/or sell copies of the Software, and to
++   permit persons to whom the Software is furnished to do so, subject to
++   the following conditions:
++
++   The above copyright notice and this permission notice shall be included
++   in all copies or substantial portions of the Software.
++
++   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
++   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++   DEALINGS IN THE SOFTWARE.
++   ----------------------------------------------------------------------- */
++
++#include <ffi.h>
++#include <ffi_common.h>
++
++#include <stdlib.h>
++#include <stdint.h>
++
++#if __riscv_float_abi_double
++#define ABI_FLEN 64
++#define ABI_FLOAT double
++#elif __riscv_float_abi_single
++#define ABI_FLEN 32
++#define ABI_FLOAT float
++#endif
++
++#define NARGREG 8
++#define STKALIGN 16
++#define MAXCOPYARG (2 * sizeof(double))
++
++typedef struct call_context
++{
++#if ABI_FLEN
++    ABI_FLOAT fa[8];
++#endif
++    size_t a[8];
++    /* used by the assembly code to in-place construct its own stack frame */
++    char frame[16];
++} call_context;
++
++typedef struct call_builder
++{
++    call_context *aregs;
++    int used_integer;
++    int used_float;
++    size_t *used_stack;
++} call_builder;
++
++/* integer (not pointer) less than ABI XLEN */
++/* FFI_TYPE_INT does not appear to be used */
++#if __SIZEOF_POINTER__ == 8
++#define IS_INT(type) ((type) >= FFI_TYPE_UINT8 && (type) <= FFI_TYPE_SINT64)
++#else
++#define IS_INT(type) ((type) >= FFI_TYPE_UINT8 && (type) <= FFI_TYPE_SINT32)
++#endif
++
++#if ABI_FLEN
++typedef struct {
++    char as_elements, type1, offset2, type2;
++} float_struct_info;
++
++#if ABI_FLEN >= 64
++#define IS_FLOAT(type) ((type) >= FFI_TYPE_FLOAT && (type) <= FFI_TYPE_DOUBLE)
++#else
++#define IS_FLOAT(type) ((type) == FFI_TYPE_FLOAT)
++#endif
++
++static ffi_type **flatten_struct(ffi_type *in, ffi_type **out, ffi_type **out_end) {
++    int i;
++    if (out == out_end) return out;
++    if (in->type != FFI_TYPE_STRUCT) {
++        *(out++) = in;
++    } else {
++        for (i = 0; in->elements[i]; i++)
++            out = flatten_struct(in->elements[i], out, out_end);
++    }
++    return out;
++}
++
++/* Structs with at most two fields after flattening, one of which is of
++   floating point type, are passed in multiple registers if sufficient
++   registers are available. */
++static float_struct_info struct_passed_as_elements(call_builder *cb, ffi_type *top) {
++    float_struct_info ret = {0, 0, 0, 0};
++    ffi_type *fields[3];
++    int num_floats, num_ints;
++    int num_fields = flatten_struct(top, fields, fields + 3) - fields;
++
++    if (num_fields == 1) {
++        if (IS_FLOAT(fields[0]->type)) {
++            ret.as_elements = 1;
++            ret.type1 = fields[0]->type;
++        }
++    } else if (num_fields == 2) {
++        num_floats = IS_FLOAT(fields[0]->type) + IS_FLOAT(fields[1]->type);
++        num_ints = IS_INT(fields[0]->type) + IS_INT(fields[1]->type);
++        if (num_floats == 0 || num_floats + num_ints != 2)
++            return ret;
++        if (cb->used_float + num_floats > NARGREG || cb->used_integer + (2 - num_floats) > NARGREG)
++            return ret;
++        if (!IS_FLOAT(fields[0]->type) && !IS_FLOAT(fields[1]->type))
++            return ret;
++
++        ret.type1 = fields[0]->type;
++        ret.type2 = fields[1]->type;
++        ret.offset2 = ALIGN(fields[0]->size, fields[1]->alignment);
++        ret.as_elements = 1;
++    }
++
++    return ret;
++}
++#endif
++
++/* allocates a single register, float register, or XLEN-sized stack slot to a datum */
++static void marshal_atom(call_builder *cb, int type, void *data) {
++    size_t value = 0;
++    switch (type) {
++        case FFI_TYPE_UINT8: value = *(uint8_t *)data; break;
++        case FFI_TYPE_SINT8: value = *(int8_t *)data; break;
++        case FFI_TYPE_UINT16: value = *(uint16_t *)data; break;
++        case FFI_TYPE_SINT16: value = *(int16_t *)data; break;
++        /* 32-bit quantities are always sign-extended in the ABI */
++        case FFI_TYPE_UINT32: value = *(int32_t *)data; break;
++        case FFI_TYPE_SINT32: value = *(int32_t *)data; break;
++#if __SIZEOF_POINTER__ == 8
++        case FFI_TYPE_UINT64: value = *(uint64_t *)data; break;
++        case FFI_TYPE_SINT64: value = *(int64_t *)data; break;
++#endif
++        case FFI_TYPE_POINTER: value = *(size_t *)data; break;
++
++        /* float values may be recoded in an implementation-defined way
++           by hardware conforming to 2.1 or earlier, so use asm to
++           reinterpret floats as doubles */
++#if ABI_FLEN >= 32
++        case FFI_TYPE_FLOAT:
++            asm("" : "=f"(cb->aregs->fa[cb->used_float++]) : "0"(*(float *)data));
++            return;
++#endif
++#if ABI_FLEN >= 64
++        case FFI_TYPE_DOUBLE:
++            asm("" : "=f"(cb->aregs->fa[cb->used_float++]) : "0"(*(double *)data));
++            return;
++#endif
++        default: FFI_ASSERT(0); break;
++    }
++
++    if (cb->used_integer == NARGREG) {
++        *cb->used_stack++ = value;
++    } else {
++        cb->aregs->a[cb->used_integer++] = value;
++    }
++}
++
++static void unmarshal_atom(call_builder *cb, int type, void *data) {
++    size_t value;
++    switch (type) {
++#if ABI_FLEN >= 32
++        case FFI_TYPE_FLOAT:
++            asm("" : "=f"(*(float *)data) : "0"(cb->aregs->fa[cb->used_float++]));
++            return;
++#endif
++#if ABI_FLEN >= 64
++        case FFI_TYPE_DOUBLE:
++            asm("" : "=f"(*(double *)data) : "0"(cb->aregs->fa[cb->used_float++]));
++            return;
++#endif
++    }
++
++    if (cb->used_integer == NARGREG) {
++        value = *cb->used_stack++;
++    } else {
++        value = cb->aregs->a[cb->used_integer++];
++    }
++
++    switch (type) {
++        case FFI_TYPE_UINT8: *(uint8_t *)data = value; break;
++        case FFI_TYPE_SINT8: *(uint8_t *)data = value; break;
++        case FFI_TYPE_UINT16: *(uint16_t *)data = value; break;
++        case FFI_TYPE_SINT16: *(uint16_t *)data = value; break;
++        case FFI_TYPE_UINT32: *(uint32_t *)data = value; break;
++        case FFI_TYPE_SINT32: *(uint32_t *)data = value; break;
++#if __SIZEOF_POINTER__ == 8
++        case FFI_TYPE_UINT64: *(uint64_t *)data = value; break;
++        case FFI_TYPE_SINT64: *(uint64_t *)data = value; break;
++#endif
++        case FFI_TYPE_POINTER: *(size_t *)data = value; break;
++        default: FFI_ASSERT(0); break;
++    }
++}
++
++/* adds an argument to a call, or a not by reference return value */
++static void marshal(call_builder *cb, ffi_type *type, int var, void *data) {
++    size_t realign[2];
++
++#if ABI_FLEN
++    if (!var && type->type == FFI_TYPE_STRUCT) {
++        float_struct_info fsi = struct_passed_as_elements(cb, type);
++        if (fsi.as_elements) {
++            marshal_atom(cb, fsi.type1, data);
++            if (fsi.offset2)
++                marshal_atom(cb, fsi.type2, ((char*)data) + fsi.offset2);
++            return;
++        }
++    }
++
++    if (!var && cb->used_float < NARGREG && IS_FLOAT(type->type)) {
++        marshal_atom(cb, type->type, data);
++        return;
++    }
++#endif
++
++    if (type->size > 2 * __SIZEOF_POINTER__) {
++        /* pass by reference */
++        marshal_atom(cb, FFI_TYPE_POINTER, &data);
++    } else if (IS_INT(type->type) || type->type == FFI_TYPE_POINTER) {
++        marshal_atom(cb, type->type, data);
++    } else {
++        /* overlong integers, soft-float floats, and structs without special
++           float handling are treated identically from this point on */
++
++        /* variadics are aligned even in registers */
++        if (type->alignment > __SIZEOF_POINTER__) {
++            if (var)
++                cb->used_integer = ALIGN(cb->used_integer, 2);
++            cb->used_stack = (size_t *)ALIGN(cb->used_stack, 2*__SIZEOF_POINTER__);
++        }
++
++        memcpy(realign, data, type->size);
++        if (type->size > 0)
++            marshal_atom(cb, FFI_TYPE_POINTER, realign);
++        if (type->size > __SIZEOF_POINTER__)
++            marshal_atom(cb, FFI_TYPE_POINTER, realign + 1);
++    }
++}
++
++/* for arguments passed by reference returns the pointer, otherwise the arg is copied (up to MAXCOPYARG bytes) */
++static void *unmarshal(call_builder *cb, ffi_type *type, int var, void *data) {
++    size_t realign[2];
++    void *pointer;
++
++#if ABI_FLEN
++    if (!var && type->type == FFI_TYPE_STRUCT) {
++        float_struct_info fsi = struct_passed_as_elements(cb, type);
++        if (fsi.as_elements) {
++            unmarshal_atom(cb, fsi.type1, data);
++            if (fsi.offset2)
++                unmarshal_atom(cb, fsi.type2, ((char*)data) + fsi.offset2);
++            return data;
++        }
++    }
++
++    if (!var && cb->used_float < NARGREG && IS_FLOAT(type->type)) {
++        unmarshal_atom(cb, type->type, data);
++        return data;
++    }
++#endif
++
++    if (type->size > 2 * __SIZEOF_POINTER__) {
++        /* pass by reference */
++        unmarshal_atom(cb, FFI_TYPE_POINTER, (char*)&pointer);
++        return pointer;
++    } else if (IS_INT(type->type) || type->type == FFI_TYPE_POINTER) {
++        unmarshal_atom(cb, type->type, data);
++        return data;
++    } else {
++        /* overlong integers, soft-float floats, and structs without special
++           float handling are treated identically from this point on */
++
++        /* variadics are aligned even in registers */
++        if (type->alignment > __SIZEOF_POINTER__) {
++            if (var)
++                cb->used_integer = ALIGN(cb->used_integer, 2);
++            cb->used_stack = (size_t *)ALIGN(cb->used_stack, 2*__SIZEOF_POINTER__);
++        }
++
++        if (type->size > 0)
++            unmarshal_atom(cb, FFI_TYPE_POINTER, realign);
++        if (type->size > __SIZEOF_POINTER__)
++            unmarshal_atom(cb, FFI_TYPE_POINTER, realign + 1);
++        memcpy(data, realign, type->size);
++        return data;
++    }
++}
++
++static int passed_by_ref(call_builder *cb, ffi_type *type, int var) {
++#if ABI_FLEN
++    if (!var && type->type == FFI_TYPE_STRUCT) {
++        float_struct_info fsi = struct_passed_as_elements(cb, type);
++        if (fsi.as_elements) return 0;
++    }
++#endif
++
++    return type->size > 2 * __SIZEOF_POINTER__;
++}
++
++/* Perform machine dependent cif processing */
++ffi_status ffi_prep_cif_machdep(ffi_cif *cif) {
++    cif->riscv_nfixedargs = cif->nargs;
++    return FFI_OK;
++}
++
++/* Perform machine dependent cif processing when we have a variadic function */
++
++ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, unsigned int ntotalargs) {
++    cif->riscv_nfixedargs = nfixedargs;
++    return FFI_OK;
++}
++
++/* Low level routine for calling functions */
++extern void ffi_call_asm(void *stack, struct call_context *regs, void (*fn)(void)) FFI_HIDDEN;
++
++void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
++{
++    /* this is a conservative estimate, assuming a complex return value and
++       that all remaining arguments are long long / __int128 */
++    size_t arg_bytes = cif->nargs <= 3 ? 0 :
++        ALIGN(2 * sizeof(size_t) * (cif->nargs - 3), STKALIGN);
++    size_t rval_bytes = 0;
++    if (rvalue == NULL && cif->rtype->size > 2*__SIZEOF_POINTER__)
++        rval_bytes = ALIGN(cif->rtype->size, STKALIGN);
++    size_t alloc_size = arg_bytes + rval_bytes + sizeof(call_context);
++
++    /* the assembly code will deallocate all stack data at lower addresses
++       than the argument region, so we need to allocate the frame and the
++       return value after the arguments in a single allocation */
++    size_t alloc_base;
++    /* Argument region must be 16-byte aligned */
++    if (_Alignof(max_align_t) >= STKALIGN) {
++        /* since sizeof long double is normally 16, the compiler will
++           guarantee alloca alignment to at least that much */
++        alloc_base = (size_t)alloca(alloc_size);
++    } else {
++        alloc_base = ALIGN(alloca(alloc_size + STKALIGN - 1), STKALIGN);
++    }
++
++    if (rval_bytes)
++        rvalue = (void*)(alloc_base + arg_bytes);
++
++    call_builder cb;
++    cb.used_float = cb.used_integer = 0;
++    cb.aregs = (call_context*)(alloc_base + arg_bytes + rval_bytes);
++    cb.used_stack = (void*)alloc_base;
++
++    int return_by_ref = passed_by_ref(&cb, cif->rtype, 0);
++    if (return_by_ref)
++        marshal(&cb, &ffi_type_pointer, 0, &rvalue);
++
++    int i;
++    for (i = 0; i < cif->nargs; i++)
++        marshal(&cb, cif->arg_types[i], i >= cif->riscv_nfixedargs, avalue[i]);
++
++    ffi_call_asm((void*)alloc_base, cb.aregs, fn);
++
++    cb.used_float = cb.used_integer = 0;
++    if (!return_by_ref && rvalue)
++        unmarshal(&cb, cif->rtype, 0, rvalue);
++}
++
++extern void ffi_closure_asm(void) FFI_HIDDEN;
++
++ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void (*fun)(ffi_cif*,void*,void**,void*), void *user_data, void *codeloc)
++{
++    uint32_t *tramp = (uint32_t *) &closure->tramp[0];
++    uint64_t fn = (uint64_t) (uintptr_t) ffi_closure_asm;
++
++    if (cif->abi <= FFI_FIRST_ABI || cif->abi >= FFI_LAST_ABI)
++        return FFI_BAD_ABI;
++
++    /* we will call ffi_closure_inner with codeloc, not closure, but as long
++       as the memory is readable it should work */
++
++    tramp[0] = 0x00000317; /* auipc t1, 0 (i.e. t0 <- codeloc) */
++#if __SIZEOF_POINTER__ == 8
++    tramp[1] = 0x01033383; /* ld t2, 16(t1) */
++#else
++    tramp[1] = 0x01032383; /* lw t2, 16(t1) */
++#endif
++    tramp[2] = 0x00038067; /* jr t2 */
++    tramp[3] = 0x00000013; /* nop */
++    tramp[4] = fn;
++    tramp[5] = fn >> 32;
++
++    closure->cif = cif;
++    closure->fun = fun;
++    closure->user_data = user_data;
++
++    __builtin___clear_cache(codeloc, codeloc + FFI_TRAMPOLINE_SIZE);
++
++    return FFI_OK;
++}
++
++/* Called by the assembly code with aregs pointing to saved argument registers
++   and stack pointing to the stacked arguments.  Return values passed in
++   registers will be reloaded from aregs. */
++void FFI_HIDDEN ffi_closure_inner(size_t *stack, call_context *aregs, ffi_closure *closure) {
++    ffi_cif *cif = closure->cif;
++    void **avalue = alloca(cif->nargs * sizeof(void*));
++    /* storage for arguments which will be copied by unmarshal().  We could
++       theoretically avoid the copies in many cases and use at most 128 bytes
++       of memory, but allocating disjoint storage for each argument is
++       simpler. */
++    char *astorage = alloca(cif->nargs * MAXCOPYARG);
++    void *rvalue;
++    call_builder cb;
++    int return_by_ref;
++    int i;
++
++    cb.aregs = aregs;
++    cb.used_integer = cb.used_float = 0;
++    cb.used_stack = stack;
++
++    return_by_ref = passed_by_ref(&cb, cif->rtype, 0);
++    if (return_by_ref)
++        unmarshal(&cb, &ffi_type_pointer, 0, &rvalue);
++    else
++        rvalue = alloca(cif->rtype->size);
++
++    for (i = 0; i < cif->nargs; i++)
++        avalue[i] = unmarshal(&cb, cif->arg_types[i],
++            i >= cif->riscv_nfixedargs, astorage + i*MAXCOPYARG);
++
++    (closure->fun)(cif, rvalue, avalue, closure->user_data);
++
++    if (!return_by_ref && cif->rtype->type != FFI_TYPE_VOID) {
++        cb.used_integer = cb.used_float = 0;
++        marshal(&cb, cif->rtype, 0, rvalue);
++    }
++}
+diff --git a/src/riscv/ffitarget.h b/src/riscv/ffitarget.h
+new file mode 100644
+index 0000000..fcaa899
+--- /dev/null
++++ b/src/riscv/ffitarget.h
+@@ -0,0 +1,68 @@
++/* -----------------------------------------------------------------*-C-*-
++   ffitarget.h - 2014 Michael Knyszek
++
++   Target configuration macros for RISC-V.
++
++   Permission is hereby granted, free of charge, to any person obtaining
++   a copy of this software and associated documentation files (the
++   ``Software''), to deal in the Software without restriction, including
++   without limitation the rights to use, copy, modify, merge, publish,
++   distribute, sublicense, and/or sell copies of the Software, and to
++   permit persons to whom the Software is furnished to do so, subject to
++   the following conditions:
++
++   The above copyright notice and this permission notice shall be included
++   in all copies or substantial portions of the Software.
++
++   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
++   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++   DEALINGS IN THE SOFTWARE.
++
++   ----------------------------------------------------------------------- */
++
++#ifndef LIBFFI_TARGET_H
++#define LIBFFI_TARGET_H
++
++#ifndef LIBFFI_H
++#error "Please do not include ffitarget.h directly into your source.  Use ffi.h instead."
++#endif
++
++#ifndef __riscv
++#error "libffi was configured for a RISC-V target but this does not appear to be a RISC-V compiler."
++#endif
++
++#ifndef LIBFFI_ASM
++
++typedef unsigned long ffi_arg;
++typedef   signed long ffi_sarg;
++
++/* FFI_UNUSED_NN and riscv_unused are to maintain ABI compatibility with a
++   distributed Berkeley patch from 2014, and can be removed at SONAME bump */
++typedef enum ffi_abi {
++    FFI_FIRST_ABI = 0,
++    FFI_SYSV,
++    FFI_UNUSED_1,
++    FFI_UNUSED_2,
++    FFI_UNUSED_3,
++    FFI_LAST_ABI,
++
++    FFI_DEFAULT_ABI = FFI_SYSV
++} ffi_abi;
++
++#endif /* LIBFFI_ASM */
++
++/* ---- Definitions for closures ----------------------------------------- */
++
++#define FFI_CLOSURES 1
++#define FFI_TRAMPOLINE_SIZE 24
++#define FFI_NATIVE_RAW_API 0
++#define FFI_EXTRA_CIF_FIELDS unsigned riscv_nfixedargs; unsigned riscv_unused;
++#define FFI_TARGET_SPECIFIC_VARIADIC
++
++#endif
++
+diff --git a/src/riscv/sysv.S b/src/riscv/sysv.S
+new file mode 100644
+index 0000000..2d09865
+--- /dev/null
++++ b/src/riscv/sysv.S
+@@ -0,0 +1,214 @@
++/* -----------------------------------------------------------------------
++   ffi.c - Copyright (c) 2015 Michael Knyszek <mknyszek@berkeley.edu>
++                         2015 Andrew Waterman <waterman@cs.berkeley.edu>
++                         2018 Stef O'Rear <sorear2@gmail.com>
++
++   RISC-V Foreign Function Interface
++
++   Permission is hereby granted, free of charge, to any person obtaining
++   a copy of this software and associated documentation files (the
++   ``Software''), to deal in the Software without restriction, including
++   without limitation the rights to use, copy, modify, merge, publish,
++   distribute, sublicense, and/or sell copies of the Software, and to
++   permit persons to whom the Software is furnished to do so, subject to
++   the following conditions:
++
++   The above copyright notice and this permission notice shall be included
++   in all copies or substantial portions of the Software.
++
++   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
++   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++   DEALINGS IN THE SOFTWARE.
++   ----------------------------------------------------------------------- */
++
++#define LIBFFI_ASM
++#include <fficonfig.h>
++#include <ffi.h>
++
++/* Define aliases so that we can handle all ABIs uniformly */
++
++#if __SIZEOF_POINTER__ == 8
++#define PTRS 8
++#define LARG ld
++#define SARG sd
++#else
++#define PTRS 4
++#define LARG lw
++#define SARG sw
++#endif
++
++#if __riscv_float_abi_double
++#define FLTS 8
++#define FLARG fld
++#define FSARG fsd
++#elif __riscv_float_abi_single
++#define FLTS 4
++#define FLARG flw
++#define FSARG fsw
++#else
++#define FLTS 0
++#endif
++
++#define fp s0
++
++    .text
++    .globl  ffi_call_asm
++    .type   ffi_call_asm, @function
++    .hidden ffi_call_asm
++/*
++  struct call_context {
++      floatreg fa[8];
++      intreg a[8];
++      intreg pad[rv32 ? 2 : 0];
++      intreg save_fp, save_ra;
++  }
++  void ffi_call_asm(size_t *stackargs, struct call_context *regargs,
++      void (*fn)(void));
++*/
++
++#define FRAME_LEN (8 * FLTS + 8 * PTRS + 16)
++
++ffi_call_asm:
++    .cfi_startproc
++
++    /*
++      We are NOT going to set up an ordinary stack frame.  In order to pass
++      the stacked args to the called function, we adjust our stack pointer to
++      a0, which is in the _caller's_ alloca area.  We establish our own stack
++      frame at the end of the call_context.
++
++      Anything below the arguments will be freed at this point, although we
++      preserve the call_context so that it can be read back in the caller.
++    */
++
++    .cfi_def_cfa 11, FRAME_LEN # interim CFA based on a1
++    SARG    fp, FRAME_LEN - 2*PTRS(a1)
++    .cfi_offset 8, -2*PTRS
++    SARG    ra, FRAME_LEN - 1*PTRS(a1)
++    .cfi_offset 1, -1*PTRS
++
++    addi    fp, a1, FRAME_LEN
++    mv      sp, a0
++    .cfi_def_cfa 8, 0 # our frame is fully set up
++
++    # Load arguments
++    mv      t1, a2
++
++#if FLTS
++    FLARG   fa0, -FRAME_LEN+0*FLTS(fp)
++    FLARG   fa1, -FRAME_LEN+1*FLTS(fp)
++    FLARG   fa2, -FRAME_LEN+2*FLTS(fp)
++    FLARG   fa3, -FRAME_LEN+3*FLTS(fp)
++    FLARG   fa4, -FRAME_LEN+4*FLTS(fp)
++    FLARG   fa5, -FRAME_LEN+5*FLTS(fp)
++    FLARG   fa6, -FRAME_LEN+6*FLTS(fp)
++    FLARG   fa7, -FRAME_LEN+7*FLTS(fp)
++#endif
++
++    LARG    a0, -FRAME_LEN+8*FLTS+0*PTRS(fp)
++    LARG    a1, -FRAME_LEN+8*FLTS+1*PTRS(fp)
++    LARG    a2, -FRAME_LEN+8*FLTS+2*PTRS(fp)
++    LARG    a3, -FRAME_LEN+8*FLTS+3*PTRS(fp)
++    LARG    a4, -FRAME_LEN+8*FLTS+4*PTRS(fp)
++    LARG    a5, -FRAME_LEN+8*FLTS+5*PTRS(fp)
++    LARG    a6, -FRAME_LEN+8*FLTS+6*PTRS(fp)
++    LARG    a7, -FRAME_LEN+8*FLTS+7*PTRS(fp)
++
++    /* Call */
++    jalr    t1
++
++    /* Save return values - only a0/a1 (fa0/fa1) are used */
++#if FLTS
++    FSARG   fa0, -FRAME_LEN+0*FLTS(fp)
++    FSARG   fa1, -FRAME_LEN+1*FLTS(fp)
++#endif
++
++    SARG    a0, -FRAME_LEN+8*FLTS+0*PTRS(fp)
++    SARG    a1, -FRAME_LEN+8*FLTS+1*PTRS(fp)
++
++    /* Restore and return */
++    addi    sp, fp, -FRAME_LEN
++    .cfi_def_cfa 2, FRAME_LEN
++    LARG    ra, -1*PTRS(fp)
++    .cfi_restore 1
++    LARG    fp, -2*PTRS(fp)
++    .cfi_restore 8
++    ret
++    .cfi_endproc
++    .size   ffi_call_asm, .-ffi_call_asm
++
++
++/*
++  ffi_closure_asm. Expects address of the passed-in ffi_closure in t1.
++  void ffi_closure_inner(size_t *stackargs, struct call_context *regargs,
++      ffi_closure *closure);
++*/
++
++    .globl ffi_closure_asm
++    .hidden ffi_closure_asm
++    .type ffi_closure_asm, @function
++ffi_closure_asm:
++    .cfi_startproc
++
++    addi    sp,  sp, -FRAME_LEN
++    .cfi_def_cfa_offset FRAME_LEN
++
++    /* make a frame */
++    SARG    fp, FRAME_LEN - 2*PTRS(sp)
++    .cfi_offset 8, -2*PTRS
++    SARG    ra, FRAME_LEN - 1*PTRS(sp)
++    .cfi_offset 1, -1*PTRS
++    addi    fp, sp, FRAME_LEN
++
++    /* save arguments */
++#if FLTS
++    FSARG   fa0, 0*FLTS(sp)
++    FSARG   fa1, 1*FLTS(sp)
++    FSARG   fa2, 2*FLTS(sp)
++    FSARG   fa3, 3*FLTS(sp)
++    FSARG   fa4, 4*FLTS(sp)
++    FSARG   fa5, 5*FLTS(sp)
++    FSARG   fa6, 6*FLTS(sp)
++    FSARG   fa7, 7*FLTS(sp)
++#endif
++
++    SARG    a0, 8*FLTS+0*PTRS(sp)
++    SARG    a1, 8*FLTS+1*PTRS(sp)
++    SARG    a2, 8*FLTS+2*PTRS(sp)
++    SARG    a3, 8*FLTS+3*PTRS(sp)
++    SARG    a4, 8*FLTS+4*PTRS(sp)
++    SARG    a5, 8*FLTS+5*PTRS(sp)
++    SARG    a6, 8*FLTS+6*PTRS(sp)
++    SARG    a7, 8*FLTS+7*PTRS(sp)
++
++    /* enter C */
++    addi    a0, sp, FRAME_LEN
++    mv      a1, sp
++    mv      a2, t1
++
++    call    ffi_closure_inner
++
++    /* return values */
++#if FLTS
++    FLARG   fa0, 0*FLTS(sp)
++    FLARG   fa1, 1*FLTS(sp)
++#endif
++
++    LARG    a0, 8*FLTS+0*PTRS(sp)
++    LARG    a1, 8*FLTS+1*PTRS(sp)
++
++    /* restore and return */
++    LARG    ra, FRAME_LEN-1*PTRS(sp)
++    .cfi_restore 1
++    LARG    fp, FRAME_LEN-2*PTRS(sp)
++    .cfi_restore 8
++    addi    sp, sp, FRAME_LEN
++    .cfi_def_cfa_offset 0
++    ret
++    .cfi_endproc
++    .size ffi_closure_asm, .-ffi_closure_asm
diff --git a/poky/meta/recipes-support/libffi/libffi_3.2.1.bb b/poky/meta/recipes-support/libffi/libffi_3.2.1.bb
index a0b1fcd..792a114 100644
--- a/poky/meta/recipes-support/libffi/libffi_3.2.1.bb
+++ b/poky/meta/recipes-support/libffi/libffi_3.2.1.bb
@@ -12,10 +12,11 @@
 
 SRC_URI = "ftp://sourceware.org/pub/libffi/${BP}.tar.gz \
            file://not-win32.patch \
-	   file://0001-mips-Use-compiler-internal-define-for-linux.patch \
+           file://0001-mips-Use-compiler-internal-define-for-linux.patch \
            file://0001-mips-fix-MIPS-softfloat-build-issue.patch \
            file://0001-libffi-Support-musl-x32-build.patch \
-	   "
+           file://0001-New-RISC-V-port-281.patch \
+           "
 
 SRC_URI[md5sum] = "83b89587607e3eb65c70d361f13bab43"
 SRC_URI[sha256sum] = "d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37"
diff --git a/poky/meta/recipes-support/libxslt/files/0001-Fix-security-framework-bypass.patch b/poky/meta/recipes-support/libxslt/files/0001-Fix-security-framework-bypass.patch
new file mode 100644
index 0000000..89b647d
--- /dev/null
+++ b/poky/meta/recipes-support/libxslt/files/0001-Fix-security-framework-bypass.patch
@@ -0,0 +1,124 @@
+From e03553605b45c88f0b4b2980adfbbb8f6fca2fd6 Mon Sep 17 00:00:00 2001
+From: Nick Wellnhofer <wellnhofer@aevum.de>
+Date: Sun, 24 Mar 2019 09:51:39 +0100
+Subject: Fix security framework bypass
+
+xsltCheckRead and xsltCheckWrite return -1 in case of error but callers
+don't check for this condition and allow access. With a specially
+crafted URL, xsltCheckRead could be tricked into returning an error
+because of a supposedly invalid URL that would still be loaded
+succesfully later on.
+
+Fixes #12.
+
+Thanks to Felix Wilhelm for the report.
+
+Signed-off-by: Adrian Bunk <bunk@stusta.de>
+Upstream-Status: Backport
+CVE: CVE-2019-11068
+---
+ libxslt/documents.c | 18 ++++++++++--------
+ libxslt/imports.c   |  9 +++++----
+ libxslt/transform.c |  9 +++++----
+ libxslt/xslt.c      |  9 +++++----
+ 4 files changed, 25 insertions(+), 20 deletions(-)
+
+diff --git a/libxslt/documents.c b/libxslt/documents.c
+index 3f3a7312..4aad11bb 100644
+--- a/libxslt/documents.c
++++ b/libxslt/documents.c
+@@ -296,10 +296,11 @@ xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) {
+ 	int res;
+ 
+ 	res = xsltCheckRead(ctxt->sec, ctxt, URI);
+-	if (res == 0) {
+-	    xsltTransformError(ctxt, NULL, NULL,
+-		 "xsltLoadDocument: read rights for %s denied\n",
+-			     URI);
++	if (res <= 0) {
++            if (res == 0)
++                xsltTransformError(ctxt, NULL, NULL,
++                     "xsltLoadDocument: read rights for %s denied\n",
++                                 URI);
+ 	    return(NULL);
+ 	}
+     }
+@@ -372,10 +373,11 @@ xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) {
+ 	int res;
+ 
+ 	res = xsltCheckRead(sec, NULL, URI);
+-	if (res == 0) {
+-	    xsltTransformError(NULL, NULL, NULL,
+-		 "xsltLoadStyleDocument: read rights for %s denied\n",
+-			     URI);
++	if (res <= 0) {
++            if (res == 0)
++                xsltTransformError(NULL, NULL, NULL,
++                     "xsltLoadStyleDocument: read rights for %s denied\n",
++                                 URI);
+ 	    return(NULL);
+ 	}
+     }
+diff --git a/libxslt/imports.c b/libxslt/imports.c
+index 874870cc..3783b247 100644
+--- a/libxslt/imports.c
++++ b/libxslt/imports.c
+@@ -130,10 +130,11 @@ xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) {
+ 	int secres;
+ 
+ 	secres = xsltCheckRead(sec, NULL, URI);
+-	if (secres == 0) {
+-	    xsltTransformError(NULL, NULL, NULL,
+-		 "xsl:import: read rights for %s denied\n",
+-			     URI);
++	if (secres <= 0) {
++            if (secres == 0)
++                xsltTransformError(NULL, NULL, NULL,
++                     "xsl:import: read rights for %s denied\n",
++                                 URI);
+ 	    goto error;
+ 	}
+     }
+diff --git a/libxslt/transform.c b/libxslt/transform.c
+index 13793914..0636dbd0 100644
+--- a/libxslt/transform.c
++++ b/libxslt/transform.c
+@@ -3493,10 +3493,11 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
+      */
+     if (ctxt->sec != NULL) {
+ 	ret = xsltCheckWrite(ctxt->sec, ctxt, filename);
+-	if (ret == 0) {
+-	    xsltTransformError(ctxt, NULL, inst,
+-		 "xsltDocumentElem: write rights for %s denied\n",
+-			     filename);
++	if (ret <= 0) {
++            if (ret == 0)
++                xsltTransformError(ctxt, NULL, inst,
++                     "xsltDocumentElem: write rights for %s denied\n",
++                                 filename);
+ 	    xmlFree(URL);
+ 	    xmlFree(filename);
+ 	    return;
+diff --git a/libxslt/xslt.c b/libxslt/xslt.c
+index 780a5ad7..a234eb79 100644
+--- a/libxslt/xslt.c
++++ b/libxslt/xslt.c
+@@ -6763,10 +6763,11 @@ xsltParseStylesheetFile(const xmlChar* filename) {
+ 	int res;
+ 
+ 	res = xsltCheckRead(sec, NULL, filename);
+-	if (res == 0) {
+-	    xsltTransformError(NULL, NULL, NULL,
+-		 "xsltParseStylesheetFile: read rights for %s denied\n",
+-			     filename);
++	if (res <= 0) {
++            if (res == 0)
++                xsltTransformError(NULL, NULL, NULL,
++                     "xsltParseStylesheetFile: read rights for %s denied\n",
++                                 filename);
+ 	    return(NULL);
+ 	}
+     }
+-- 
+2.20.1
+
diff --git a/poky/meta/recipes-support/libxslt/libxslt_1.1.33.bb b/poky/meta/recipes-support/libxslt/libxslt_1.1.33.bb
index 462eccf..6320a82 100644
--- a/poky/meta/recipes-support/libxslt/libxslt_1.1.33.bb
+++ b/poky/meta/recipes-support/libxslt/libxslt_1.1.33.bb
@@ -8,7 +8,9 @@
 SECTION = "libs"
 DEPENDS = "libxml2"
 
-SRC_URI = "http://xmlsoft.org/sources/libxslt-${PV}.tar.gz"
+SRC_URI = "http://xmlsoft.org/sources/libxslt-${PV}.tar.gz \
+           file://0001-Fix-security-framework-bypass.patch \
+"
 
 SRC_URI[md5sum] = "b3bd254a03e46d58f8ad1e4559cd2c2f"
 SRC_URI[sha256sum] = "8e36605144409df979cab43d835002f63988f3dc94d5d3537c12796db90e38c8"
diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch b/poky/meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch
deleted file mode 100644
index 06d1d94..0000000
--- a/poky/meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-From 06ba71887f667d45dd231a782a2751f36e8fe025 Mon Sep 17 00:00:00 2001
-From: Christopher Larson <chris_larson@mentor.com>
-Date: Mon, 15 Feb 2016 15:59:58 -0700
-Subject: [PATCH 1/4] If the libc is lacking argp, use libargp
-
-Patch pulled from Gentoo:
-
-    On glibc systems, argp is provided by libc.  However, on
-    uclibc and other systems which lack argp in their C library,
-    argp might be provided by a stand alone library, libargp.
-    This patch adds tests to the build system to find who provides
-    argp.
-
-    X-Gentoo-Bug: 292191
-    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=292191
-    Reported-by: Ed Wildgoose <gentoo@wildgooses.com>
-    Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-
-Upstream-Status: Pending
-Signed-off-by: Christopher Larson <chris_larson@mentor.com>
----
- configure.ac | 22 ++++++++++++++++++++++
- 1 file changed, 22 insertions(+)
-
-diff --git a/configure.ac b/configure.ac
-index 4e799dc..c4a5dd8 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -135,6 +135,28 @@ AS_IF(
- 	]
- )
- 
-+dnl First check if we have argp available from libc
-+AC_LINK_IFELSE(
-+	[AC_LANG_PROGRAM(
-+		[#include <argp.h>],
-+		[int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;]
-+		)],
-+	[libc_has_argp="true"],
-+	[libc_has_argp="false"]
-+)
-+
-+dnl If libc doesn't provide argp, then test for libargp
-+if test "$libc_has_argp" = "false" ; then
-+	AC_MSG_WARN("libc does not have argp")
-+	AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"])
-+
-+	if test "$have_argp" = "false"; then
-+		AC_MSG_ERROR("no libargp found")
-+	else
-+		LIBS+=" -largp"
-+	fi
-+fi
-+
- dnl -----------------
- dnl Configure options
- dnl -----------------
--- 
-2.7.4
-
diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/0001-configure.ac-fix-typo.patch b/poky/meta/recipes-support/rng-tools/rng-tools/0001-configure.ac-fix-typo.patch
deleted file mode 100644
index d4d28a0..0000000
--- a/poky/meta/recipes-support/rng-tools/rng-tools/0001-configure.ac-fix-typo.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 99b0efebd765803203686d89bc4f995bcb103e78 Mon Sep 17 00:00:00 2001
-From: Hongxu Jia <hongxu.jia@windriver.com>
-Date: Sat, 10 Nov 2018 09:53:19 +0800
-Subject: [PATCH] configure.ac: fix typo
-
-Upstream-Status: Submitted [https://github.com/nhorman/rng-tools.git]
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
----
- configure.ac | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/configure.ac b/configure.ac
-index 4e799dc..0251928 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -62,7 +62,7 @@ AS_IF([test $target_cpu = powerpc64le], [AC_DEFINE([HAVE_DARN],1,[Enable DARN])]
- AM_CONDITIONAL([JITTER], [false])
- 
- AC_ARG_ENABLE(jitterentropy,
--	AS_HELP_STRING([--disable-jitterntropy | --enable-jitterentropy=<path>],
-+	AS_HELP_STRING([--disable-jitterentropy | --enable-jitterentropy=<path>],
- 	[Disable jitterentropy source, or specify its location]),
- 	[if [ test -d $enable_jitterentropy ]; then
- 		export LDFLAGS+=-L$enable_jitterentropy;
--- 
-2.7.4
-
diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/0002-Add-argument-to-control-the-libargp-dependency.patch b/poky/meta/recipes-support/rng-tools/rng-tools/0002-Add-argument-to-control-the-libargp-dependency.patch
deleted file mode 100644
index be60fe9..0000000
--- a/poky/meta/recipes-support/rng-tools/rng-tools/0002-Add-argument-to-control-the-libargp-dependency.patch
+++ /dev/null
@@ -1,95 +0,0 @@
-From 711e2f76890e3c5b08f64859d9fd913ddbec7d50 Mon Sep 17 00:00:00 2001
-From: Christopher Larson <chris_larson@mentor.com>
-Date: Mon, 22 Oct 2018 15:26:47 +0800
-Subject: [PATCH 2/4] Add argument to control the libargp dependency
-
-This ensures that the builds are always deterministic. If the argument isn't
-passed, the default behavior is to use libargp if the libc doesn't have argp.
-
-Upstream-Status: Pending
-Signed-off-by: Christopher Larson <chris_larson@mentor.com>
-
-Rebase to 6.6
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
----
- configure.ac | 55 ++++++++++++++++++++++++++++++++++++-------------------
- 1 file changed, 36 insertions(+), 19 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index c4a5dd8..dd1c30f 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -40,6 +40,13 @@ AC_ARG_WITH([nistbeacon],
- 	[with_nistbeacon=check]
- )
- 
-+AC_ARG_WITH([libargp],
-+	AS_HELP_STRING([--without-libargp],
-+		[Disable libargp support. Systems whose libc lacks argp can use libargp instead. (Default: check if libc lacks argp)]),
-+	[with_libargp=$withval],
-+	[with_libargp=check]
-+)
-+
- dnl Make sure anyone changing configure.ac/Makefile.am has a clue
- AM_MAINTAINER_MODE
- AM_PROG_AS
-@@ -135,27 +142,37 @@ AS_IF(
- 	]
- )
- 
--dnl First check if we have argp available from libc
--AC_LINK_IFELSE(
--	[AC_LANG_PROGRAM(
--		[#include <argp.h>],
--		[int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;]
--		)],
--	[libc_has_argp="true"],
--	[libc_has_argp="false"]
-+dnl Determine if we need libargp: either user requested, or libc has no argp
-+AS_IF(
-+	[test "x$with_libargp" != "xyes"],
-+	[
-+		AC_LINK_IFELSE(
-+			[AC_LANG_PROGRAM(
-+				[#include <argp.h>],
-+				[int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;]
-+				)],
-+			[need_libargp=no],
-+			[need_libargp=yes
-+			 if test "x$with_libargp" = "xno"; then
-+				AC_MSG_FAILURE([libargp disabled and libc does not have argp])
-+			 fi]
-+		)
-+	],
-+	[need_libargp=yes],
- )
- 
--dnl If libc doesn't provide argp, then test for libargp
--if test "$libc_has_argp" = "false" ; then
--	AC_MSG_WARN("libc does not have argp")
--	AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"])
--
--	if test "$have_argp" = "false"; then
--		AC_MSG_ERROR("no libargp found")
--	else
--		LIBS+=" -largp"
--	fi
--fi
-+dnl Check for libargp
-+AS_IF(
-+	[test "x$need_libargp" = "xyes"],
-+	[
-+		AC_CHECK_LIB(
-+			[argp],
-+			[argp_parse],
-+			[LIBS="$LIBS -largp"],
-+			[AC_MSG_FAILURE([libargp not found])]
-+		)
-+	]
-+)
- 
- dnl -----------------
- dnl Configure options
--- 
-2.7.4
-
diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/fix-rngd-fail-to-stop.patch b/poky/meta/recipes-support/rng-tools/rng-tools/fix-rngd-fail-to-stop.patch
new file mode 100644
index 0000000..58cf3f9
--- /dev/null
+++ b/poky/meta/recipes-support/rng-tools/rng-tools/fix-rngd-fail-to-stop.patch
@@ -0,0 +1,25 @@
+It fails to stop rngd. It just shows warnings when stop rngd such as by:
+
+$ systemctl stop rngd.service
+
+but stalls shutdown untill daemon rngd is killed.
+
+Backport patch to fix the issue.
+
+Upstream-Status: Backport [https://bugzilla.redhat.com/show_bug.cgi?id=1690364#c8]
+
+Signed-off-by: Kai Kang <kai.kang@windriver.com>
+---
+diff --git a/rngd_jitter.c b/rngd_jitter.c
+index 54070ae..7a69bf9 100644
+--- a/rngd_jitter.c
++++ b/rngd_jitter.c
+@@ -280,7 +280,7 @@ static void *thread_entropy_task(void *data)
+ 
+ 		/* Write to pipe */
+ 		written = 0;
+-		while(written != me->buf_sz) {
++		while(me->active && written != me->buf_sz) {
+ 			message(LOG_DAEMON|LOG_DEBUG, "Writing to pipe\n");
+ 			ret = write(me->pipe_fd, &tmpbuf[written], me->buf_sz - written);
+ 			message(LOG_DAEMON|LOG_DEBUG, "DONE Writing to pipe with return %ld\n", ret);
diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch b/poky/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch
deleted file mode 100644
index 614adab..0000000
--- a/poky/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From d8b1bb8edd99b2898720b4f10d292a67d532db48 Mon Sep 17 00:00:00 2001
-From: "Francisco Blas Izquierdo Riera (klondike)" <klondike@gentoo.org>
-Date: Mon, 22 Oct 2018 15:29:36 +0800
-Subject: [PATCH 4/4] Fix assemby textrels on rdrand_asm.S on PIC x86
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This patch updates the fixes in the assembly in rdrand_asm.S in
-sys-apps/rng-tools-5 so it won't generate textrels on PIC systems.
-The main fixes are in the use of leal in SETPTR for such systems, the rest is
-the usual PIC support stuff.
-
-This should fix Gentoo bug #469962 and help fix #518210
-
-This patch is released under the GPLv2 or a higher version license as is the
-original file as long as the author and the tester are credited.
-
-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=469962
-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=518210
-Signed-off-by: Francisco Blas Izquierdo Riera (klondike) <klondike@gentoo.org>
-Reported-by: cilly <cilly@cilly.mine.nu>
-Reported-by: Manuel Rüger <mrueg@gentoo.org>
-Tested-by: Anthony Basile <blueness@gentoo.org>
-
-Upstream-Status: Pending
----
- rdrand_asm.S | 27 +++++++++++++++++++++++++++
- 1 file changed, 27 insertions(+)
-
-diff --git a/rdrand_asm.S b/rdrand_asm.S
-index b5d260a..7811cf2 100644
---- a/rdrand_asm.S
-+++ b/rdrand_asm.S
-@@ -2,6 +2,7 @@
-  * Copyright (c) 2011-2014, Intel Corporation
-  * Authors: Fenghua Yu <fenghua.yu@intel.com>,
-  *          H. Peter Anvin <hpa@linux.intel.com>
-+ * PIC code by: Francisco Blas Izquierdo Riera (klondike) <klondike@gentoo.org>
-  *
-  * This program is free software; you can redistribute it and/or modify it
-  * under the terms and conditions of the GNU General Public License,
-@@ -172,7 +173,19 @@ ENTRY(x86_rdseed_or_rdrand_bytes)
- 	jmp	4b
- ENDPROC(x86_rdseed_or_rdrand_bytes)
- 
-+#if defined(__PIC__)
-+#define INIT_PIC() \
-+	pushl	%ebx ; \
-+	call    __x86.get_pc_thunk.bx ; \
-+	addl    $_GLOBAL_OFFSET_TABLE_, %ebx
-+#define END_PIC() \
-+	popl	%ebx
-+#define SETPTR(var,ptr) leal (var)@GOTOFF(%ebx),ptr
-+#else
-+#define INIT_PIC()
-+#define END_PIC()
- #define SETPTR(var,ptr)	movl $(var),ptr
-+#endif
- #define PTR0	%eax
- #define PTR1	%edx
- #define PTR2	%ecx
-@@ -188,6 +201,7 @@ ENTRY(x86_aes_mangle)
- 	movl	8(%ebp), %eax
- 	movl	12(%ebp), %edx
- 	push	%esi
-+	INIT_PIC()
- #endif
- 	movl	$512, CTR3	/* Number of rounds */
- 	
-@@ -278,6 +292,7 @@ offset = offset + 16
- 	movdqa	%xmm7, (7*16)(PTR1)
- 
- #ifdef __i386__
-+	END_PIC()
- 	pop	%esi
- 	pop	%ebp
- #endif
-@@ -292,6 +307,7 @@ ENTRY(x86_aes_expand_key)
- 	push	%ebp
- 	mov	%esp, %ebp
- 	movl	8(%ebp), %eax
-+	INIT_PIC()
- #endif
- 
- 	SETPTR(aes_round_keys, PTR1)
-@@ -321,6 +337,7 @@ ENTRY(x86_aes_expand_key)
- 	call	1f
- 
- #ifdef __i386__
-+	END_PIC()
- 	pop	%ebp
- #endif
- 	ret
-@@ -341,6 +358,16 @@ ENTRY(x86_aes_expand_key)
- 
- ENDPROC(x86_aes_expand_key)
- 
-+#if defined(__i386__) && defined(__PIC__)
-+	.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
-+	.globl	__x86.get_pc_thunk.bx
-+	.hidden	__x86.get_pc_thunk.bx
-+	.type	__x86.get_pc_thunk.bx, @function
-+__x86.get_pc_thunk.bx:
-+	movl	(%esp), %ebx
-+	ret
-+#endif
-+
- 	.bss
- 	.balign 64
- aes_round_keys:
--- 
-2.7.4
-
diff --git a/poky/meta/recipes-support/rng-tools/rng-tools/underquote.patch b/poky/meta/recipes-support/rng-tools/rng-tools/underquote.patch
deleted file mode 100644
index aa4bbcb..0000000
--- a/poky/meta/recipes-support/rng-tools/rng-tools/underquote.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 03fe7efa1bc04a83fb9b6787998e7baa7ee90646 Mon Sep 17 00:00:00 2001
-From: Richard Purdie <richard.purdie@linuxfoundation.org>
-Date: Mon, 22 Oct 2018 15:27:41 +0800
-Subject: [PATCH 3/4] Fix underquoted m4 entry. This causes a failure if gcrypt
- isn't present:
-
-| configure: libgcrypt support disabled
-| ../rng-tools-5/configure: line 4345: ac_fn_c_try_link: command not found
-| configure: error: in `/media/build1/poky/build/tmp/work/i586-poky-linux/rng-tools/5-r0/build':
-
-RP
-2016/2/16
-
-Upstream-Status: Pending
-
-Rebase to 6.6
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
----
- configure.ac | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index dd1c30f..88d2be3 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -124,7 +124,7 @@ AS_IF(
- 	[test "x$with_libgcrypt" != "xno"],
- 	[
- 		AC_CHECK_HEADER([gcrypt.h],
--			AC_CHECK_LIB(
-+			[AC_CHECK_LIB(
- 				[gcrypt],
- 				[gcry_check_version], ,
- 				[
-@@ -133,7 +133,7 @@ AS_IF(
- 						AC_MSG_NOTICE([libgcrypt support disabled])
- 					fi
- 				]
--			),
-+			)],
- 			[if test "x$with_libgcrypt" != "xcheck"; then
- 				AC_MSG_FAILURE([libgcrypt headers not found]); else
- 				AC_MSG_NOTICE([libgcrypt support disabled])
--- 
-2.7.4
-
diff --git a/poky/meta/recipes-support/rng-tools/rng-tools_6.6.bb b/poky/meta/recipes-support/rng-tools/rng-tools_6.7.bb
similarity index 84%
rename from poky/meta/recipes-support/rng-tools/rng-tools_6.6.bb
rename to poky/meta/recipes-support/rng-tools/rng-tools_6.7.bb
index b0afa4b..aeb558b 100644
--- a/poky/meta/recipes-support/rng-tools/rng-tools_6.6.bb
+++ b/poky/meta/recipes-support/rng-tools/rng-tools_6.7.bb
@@ -10,16 +10,12 @@
 
 SRC_URI = "\
     git://github.com/nhorman/rng-tools.git \
-    file://0001-If-the-libc-is-lacking-argp-use-libargp.patch \
-    file://0002-Add-argument-to-control-the-libargp-dependency.patch \
-    file://underquote.patch \
-    file://rng-tools-5-fix-textrels-on-PIC-x86.patch \
-    file://0001-configure.ac-fix-typo.patch \
+    file://fix-rngd-fail-to-stop.patch \
     file://init \
     file://default \
     file://rngd.service \
 "
-SRCREV = "4ebc21d6f387bb7b4b3f6badc429e27b21c0a6ee"
+SRCREV = "9fc873c5af0e392632e6b736938b811f7ca97251"
 
 S = "${WORKDIR}/git"
 
@@ -31,6 +27,7 @@
 PACKAGECONFIG[libargp] = "--with-libargp,--without-libargp,argp-standalone,"
 PACKAGECONFIG[libgcrypt] = "--with-libgcrypt,--without-libgcrypt,libgcrypt,"
 PACKAGECONFIG[libjitterentropy] = "--enable-jitterentropy,--disable-jitterentropy,libjitterentropy"
+PACKAGECONFIG[libp11] = "--with-pkcs11,--without-pkcs11,libp11 openssl"
 PACKAGECONFIG[nistbeacon] = "--with-nistbeacon,--without-nistbeacon,curl libxml2 openssl"
 
 INITSCRIPT_NAME = "rng-tools"
diff --git a/poky/meta/recipes-support/serf/serf/SConstruct.stop.creating.directories.without.sandbox-install.prefix.patch b/poky/meta/recipes-support/serf/serf/SConstruct.stop.creating.directories.without.sandbox-install.prefix.patch
new file mode 100644
index 0000000..91640d6
--- /dev/null
+++ b/poky/meta/recipes-support/serf/serf/SConstruct.stop.creating.directories.without.sandbox-install.prefix.patch
@@ -0,0 +1,71 @@
+stop scons trying to create directories in hosts rootfs
+
+* since 1522f09a4d serf: cleanup recipe
+  serf.do_install fails in builds with multilib enabled (with
+  libdir=/usr/lib64 on host where /usr/lib64 doesn't exist)
+
+DEBUG: Executing shell function do_install
+scons: Reading SConscript files ...
+PermissionError: [Errno 13] Permission denied: '/usr/lib64':
+  File "TOPDIR/BUILD/work/qemux86-signage-linux/serf/1.3.9-r0/serf-1.3.9/SConstruct", line 158:
+    ENV = os.environ,
+  File "/TOPDIR/BUILD/work/qemux86-signage-linux/serf/1.3.9-r0/recipe-sysroot-native/usr/bin/../../usr/lib/python3.7/site-packages/SCons/Environment.py", line 965:
+    variables.Update(self)
+  File "/TOPDIR/BUILD/work/qemux86-signage-linux/serf/1.3.9-r0/recipe-sysroot-native/usr/bin/../../usr/lib/python3.7/site-packages/SCons/Variables/__init__.py", line 227:
+    option.validator(option.key, env.subst('${%s}'%option.key), env)
+  File "TOPDIR/BUILD/work/qemux86-signage-linux/serf/1.3.9-r0/serf-1.3.9/SConstruct", line 60:
+    return PathVariable.PathIsDirCreate(key, val, env)
+  File "/TOPDIR/BUILD/work/qemux86-signage-linux/serf/1.3.9-r0/recipe-sysroot-native/usr/bin/../../usr/lib/python3.7/site-packages/SCons/Variables/PathVariable.py", line 101:
+    os.makedirs(val)
+  File "TOPDIR/BUILD/work/qemux86-signage-linux/serf/1.3.9-r0/recipe-sysroot-native/usr/lib/python3.7/os.py", line 221:
+    mkdir(name, mode)
+ERROR: scons install execution failed.
+
+* I don't know how exactly --install-sandbox is supposed to work but
+  in this case it's trying to mkdir /usr/lib64 on the host rootfs
+  which is clearly wrong and if I set LIBDIR together with
+  --install-sandbox then the install paths are prefixed with $D twice
+  in some cases (not for includedir and empty libdir at the end).
+  So in the end I think it was an issue caused by the custom path
+  validator in serf's SConstruct, removing that stops touching host
+  and the installed paths (including the paths inside libserf*.pc)
+  look correct
+
+Upstream-Status: Pending
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+
+--- serf-1.3.9/SConstruct	2019-06-18 15:49:19.968961108 +0000
++++ serf-1.3.9b/SConstruct	2019-06-18 18:53:21.412337151 +0000
+@@ -51,17 +51,6 @@
+     """
+     return (key, '%s' % (help), default, None, lambda val: _converter(val))
+ 
+-# Custom path validator, creates directory when a specified option is set.
+-# To be used to ensure a PREFIX directory is only created when installing.
+-def createPathIsDirCreateWithTarget(target):
+-  def my_validator(key, val, env):
+-    build_targets = (map(str, BUILD_TARGETS))
+-    if target in build_targets:
+-      return PathVariable.PathIsDirCreate(key, val, env)
+-    else:
+-      return PathVariable.PathAccept(key, val, env)
+-  return my_validator
+-
+ # default directories
+ if sys.platform == 'win32':
+   default_incdir='..'
+@@ -77,11 +66,11 @@
+   PathVariable('PREFIX',
+                'Directory to install under',
+                default_prefix,
+-               createPathIsDirCreateWithTarget('install')),
++               PathVariable.PathAccept),
+   PathVariable('LIBDIR',
+                'Directory to install architecture dependent libraries under',
+                default_libdir,
+-               createPathIsDirCreateWithTarget('install')),
++               PathVariable.PathAccept),
+   PathVariable('APR',
+                "Path to apr-1-config, or to APR's install area",
+                default_incdir,
diff --git a/poky/meta/recipes-support/serf/serf_1.3.9.bb b/poky/meta/recipes-support/serf/serf_1.3.9.bb
index 92cd5ca..dd4133a 100644
--- a/poky/meta/recipes-support/serf/serf_1.3.9.bb
+++ b/poky/meta/recipes-support/serf/serf_1.3.9.bb
@@ -6,6 +6,7 @@
            file://0002-SConstruct-Fix-path-quoting-for-.def-generator.patch \
            file://0003-gen_def.patch \
            file://0004-Follow-up-to-r1811083-fix-building-with-scons-3.0.0-.patch \
+           file://SConstruct.stop.creating.directories.without.sandbox-install.prefix.patch \
            "
 
 SRC_URI[md5sum] = "370a6340ff20366ab088012cd13f2b57"