Merge branch 'uaccess-work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel...
[muen/linux.git] / include / linux / uio.h
index 243e2362fe1a8a1ea8b0480c362d10c679d4ea95..342d2dc225b95b51e36d0f9a8a37c990e69f4d74 100644 (file)
@@ -144,6 +144,27 @@ bool copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter *i)
                return _copy_from_iter_full_nocache(addr, bytes, i);
 }
 
+#ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
+/*
+ * Note, users like pmem that depend on the stricter semantics of
+ * copy_from_iter_flushcache() than copy_from_iter_nocache() must check for
+ * IS_ENABLED(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) before assuming that the
+ * destination is flushed from the cache on return.
+ */
+size_t _copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i);
+#else
+#define _copy_from_iter_flushcache _copy_from_iter_nocache
+#endif
+
+static __always_inline __must_check
+size_t copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i)
+{
+       if (unlikely(!check_copy_size(addr, bytes, false)))
+               return bytes;
+       else
+               return _copy_from_iter_flushcache(addr, bytes, i);
+}
+
 size_t iov_iter_zero(size_t bytes, struct iov_iter *);
 unsigned long iov_iter_alignment(const struct iov_iter *i);
 unsigned long iov_iter_gap_alignment(const struct iov_iter *i);