diff --git a/src/arch/i386/include/librm.h b/src/arch/i386/include/librm.h index 801f586b..fc5598eb 100644 --- a/src/arch/i386/include/librm.h +++ b/src/arch/i386/include/librm.h @@ -88,6 +88,13 @@ UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off, trivial_memmove_user ( dest, dest_off, src, src_off, len ); } +static inline __always_inline int +UACCESS_INLINE ( librm, memcmp_user ) ( userptr_t first, off_t first_off, + userptr_t second, off_t second_off, + size_t len ) { + return trivial_memcmp_user ( first, first_off, second, second_off, len); +} + static inline __always_inline void UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { diff --git a/src/include/ipxe/efi/efi_uaccess.h b/src/include/ipxe/efi/efi_uaccess.h index 79c18972..870a089b 100644 --- a/src/include/ipxe/efi/efi_uaccess.h +++ b/src/include/ipxe/efi/efi_uaccess.h @@ -76,6 +76,13 @@ UACCESS_INLINE ( efi, memmove_user ) ( userptr_t dest, off_t dest_off, trivial_memmove_user ( dest, dest_off, src, src_off, len ); } +static inline __always_inline int +UACCESS_INLINE ( efi, memcmp_user ) ( userptr_t first, off_t first_off, + userptr_t second, off_t second_off, + size_t len ) { + return trivial_memcmp_user ( first, first_off, second, second_off, len); +} + static inline __always_inline void UACCESS_INLINE ( efi, memset_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index e4dfdd35..e4d16d9e 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -89,6 +89,12 @@ UACCESS_INLINE(linux, memmove_user)(userptr_t dest, off_t dest_off, userptr_t sr trivial_memmove_user(dest, dest_off, src, src_off, len); } +static inline __always_inline int +UACCESS_INLINE(linux, memcmp_user)(userptr_t first, off_t first_off, userptr_t second, off_t second_off, size_t len) +{ + return trivial_memcmp_user(first, first_off, second, second_off, len); +} + static inline __always_inline void UACCESS_INLINE(linux, memset_user)(userptr_t buffer, off_t offset, int c, size_t len) { diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 95e94367..055bb2ca 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -126,6 +126,23 @@ trivial_memmove_user ( userptr_t dest, off_t dest_off, ( ( void * ) src + src_off ), len ); } +/** + * Compare data between user buffers + * + * @v first First buffer + * @v first_off First buffer offset + * @v second Second buffer + * @v second_off Second buffer offset + * @v len Length + * @ret diff Difference + */ +static inline __always_inline int +trivial_memcmp_user ( userptr_t first, off_t first_off, + userptr_t second, off_t second_off, size_t len ) { + return memcmp ( ( ( void * ) first + first_off ), + ( ( void * ) second + second_off ), len ); +} + /** * Fill user buffer with a constant byte * @@ -333,6 +350,19 @@ copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) { void memmove_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len ); +/** + * Compare data between user buffers + * + * @v first First buffer + * @v first_off First buffer offset + * @v second Second buffer + * @v second_off Second buffer offset + * @v len Length + * @ret diff Difference + */ +int memcmp_user ( userptr_t first, off_t first_off, + userptr_t second, off_t second_off, size_t len ); + /** * Fill user buffer with a constant byte *