ソースを参照

[uaccess] Add memcmp_user()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11年前
コミット
fffd98bd37

+ 7
- 0
src/arch/i386/include/librm.h ファイルの表示

@@ -88,6 +88,13 @@ UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off,
88 88
 	trivial_memmove_user ( dest, dest_off, src, src_off, len );
89 89
 }
90 90
 
91
+static inline __always_inline int
92
+UACCESS_INLINE ( librm, memcmp_user ) ( userptr_t first, off_t first_off,
93
+					userptr_t second, off_t second_off,
94
+					size_t len ) {
95
+	return trivial_memcmp_user ( first, first_off, second, second_off, len);
96
+}
97
+
91 98
 static inline __always_inline void
92 99
 UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset,
93 100
 					int c, size_t len ) {

+ 7
- 0
src/include/ipxe/efi/efi_uaccess.h ファイルの表示

@@ -76,6 +76,13 @@ UACCESS_INLINE ( efi, memmove_user ) ( userptr_t dest, off_t dest_off,
76 76
 	trivial_memmove_user ( dest, dest_off, src, src_off, len );
77 77
 }
78 78
 
79
+static inline __always_inline int
80
+UACCESS_INLINE ( efi, memcmp_user ) ( userptr_t first, off_t first_off,
81
+				      userptr_t second, off_t second_off,
82
+				      size_t len ) {
83
+	return trivial_memcmp_user ( first, first_off, second, second_off, len);
84
+}
85
+
79 86
 static inline __always_inline void
80 87
 UACCESS_INLINE ( efi, memset_user ) ( userptr_t buffer, off_t offset,
81 88
 					int c, size_t len ) {

+ 6
- 0
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
89 89
 	trivial_memmove_user(dest, dest_off, src, src_off, len);
90 90
 }
91 91
 
92
+static inline __always_inline int
93
+UACCESS_INLINE(linux, memcmp_user)(userptr_t first, off_t first_off, userptr_t second, off_t second_off, size_t len)
94
+{
95
+	return trivial_memcmp_user(first, first_off, second, second_off, len);
96
+}
97
+
92 98
 static inline __always_inline void
93 99
 UACCESS_INLINE(linux, memset_user)(userptr_t buffer, off_t offset, int c, size_t len)
94 100
 {

+ 30
- 0
src/include/ipxe/uaccess.h ファイルの表示

@@ -126,6 +126,23 @@ trivial_memmove_user ( userptr_t dest, off_t dest_off,
126 126
 		  ( ( void * ) src + src_off ), len );
127 127
 }
128 128
 
129
+/**
130
+ * Compare data between user buffers
131
+ *
132
+ * @v first		First buffer
133
+ * @v first_off		First buffer offset
134
+ * @v second		Second buffer
135
+ * @v second_off	Second buffer offset
136
+ * @v len		Length
137
+ * @ret diff		Difference
138
+ */
139
+static inline __always_inline int
140
+trivial_memcmp_user ( userptr_t first, off_t first_off,
141
+		      userptr_t second, off_t second_off, size_t len ) {
142
+	return memcmp ( ( ( void * ) first + first_off ),
143
+			( ( void * ) second + second_off ), len );
144
+}
145
+
129 146
 /**
130 147
  * Fill user buffer with a constant byte
131 148
  *
@@ -333,6 +350,19 @@ copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) {
333 350
 void memmove_user ( userptr_t dest, off_t dest_off,
334 351
 		    userptr_t src, off_t src_off, size_t len );
335 352
 
353
+/**
354
+ * Compare data between user buffers
355
+ *
356
+ * @v first		First buffer
357
+ * @v first_off		First buffer offset
358
+ * @v second		Second buffer
359
+ * @v second_off	Second buffer offset
360
+ * @v len		Length
361
+ * @ret diff		Difference
362
+ */
363
+int memcmp_user ( userptr_t first, off_t first_off,
364
+		  userptr_t second, off_t second_off, size_t len );
365
+
336 366
 /**
337 367
  * Fill user buffer with a constant byte
338 368
  *

読み込み中…
キャンセル
保存