2019-05-29 14:12:41 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2011-10-31 23:48:07 +00:00
|
|
|
/*
|
2012-09-19 21:22:02 +00:00
|
|
|
* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
|
2011-10-31 23:48:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Support for user memory access from kernel. This will
|
|
|
|
* probably be inlined for performance at some point, but
|
|
|
|
* for ease of debug, and to a lesser degree for code size,
|
|
|
|
* we implement here as subroutines.
|
|
|
|
*/
|
|
|
|
#include <linux/types.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2020-06-09 04:32:38 +00:00
|
|
|
#include <linux/pgtable.h>
|
2011-10-31 23:48:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For clear_user(), exploit previously defined copy_to_user function
|
|
|
|
* and the fact that we've got a handy zero page defined in kernel/head.S
|
|
|
|
*
|
|
|
|
* dczero here would be even faster.
|
|
|
|
*/
|
|
|
|
__kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count)
|
|
|
|
{
|
|
|
|
long uncleared;
|
|
|
|
|
|
|
|
while (count > PAGE_SIZE) {
|
2017-05-03 03:44:16 +00:00
|
|
|
uncleared = raw_copy_to_user(dest, &empty_zero_page, PAGE_SIZE);
|
2011-10-31 23:48:07 +00:00
|
|
|
if (uncleared)
|
|
|
|
return count - (PAGE_SIZE - uncleared);
|
|
|
|
count -= PAGE_SIZE;
|
|
|
|
dest += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
if (count)
|
2017-05-03 03:44:16 +00:00
|
|
|
count = raw_copy_to_user(dest, &empty_zero_page, count);
|
2011-10-31 23:48:07 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|