diff mbox series

[v3,08/21] bsd-user: Tidy VERIFY_READ/VERIFY_WRITE

Message ID 20210115224645.1196742-9-richard.henderson@linaro.org
State Superseded
Headers show
Series target-arm: Implement ARMv8.5-MemTag, user mode | expand

Commit Message

Richard Henderson Jan. 15, 2021, 10:46 p.m. UTC
These constants are only ever used with access_ok, and friends.
Rather than translating them to PAGE_* bits, let them equal
the PAGE_* bits to begin.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 bsd-user/qemu.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

-- 
2.25.1

Comments

Warner Losh Jan. 16, 2021, 4:28 p.m. UTC | #1
On Fri, Jan 15, 2021 at 3:56 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> These constants are only ever used with access_ok, and friends.

> Rather than translating them to PAGE_* bits, let them equal

> the PAGE_* bits to begin.

>

> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

>


This looks OK to me.

Reviewed-by: Warner Losh <imp@bsdimp.com>



> ---

>  bsd-user/qemu.h | 9 ++++-----

>  1 file changed, 4 insertions(+), 5 deletions(-)

>

> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h

> index f8bb1e5459..4076adabd0 100644

> --- a/bsd-user/qemu.h

> +++ b/bsd-user/qemu.h

> @@ -218,13 +218,12 @@ extern unsigned long x86_stack_size;

>

>  /* user access */

>

> -#define VERIFY_READ 0

> -#define VERIFY_WRITE 1 /* implies read access */

> +#define VERIFY_READ  PAGE_READ

> +#define VERIFY_WRITE (PAGE_READ | PAGE_WRITE)

>

> -static inline int access_ok(int type, abi_ulong addr, abi_ulong size)

> +static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)

>  {

> -    return page_check_range((target_ulong)addr, size,

> -                            (type == VERIFY_READ) ? PAGE_READ :

> (PAGE_READ | PAGE_WRITE)) == 0;

> +    return page_check_range((target_ulong)addr, size, type) == 0;

>  }

>

>  /* NOTE __get_user and __put_user use host pointers and don't check

> access. */

> --

>
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 15, 2021 at 3:56 PM Richard Henderson &lt;<a href="mailto:richard.henderson@linaro.org">richard.henderson@linaro.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">These constants are only ever used with access_ok, and friends.<br>
Rather than translating them to PAGE_* bits, let them equal<br>
the PAGE_* bits to begin.<br>
<br>
Reviewed-by: Peter Maydell &lt;<a href="mailto:peter.maydell@linaro.org" target="_blank">peter.maydell@linaro.org</a>&gt;<br>

Signed-off-by: Richard Henderson &lt;<a href="mailto:richard.henderson@linaro.org" target="_blank">richard.henderson@linaro.org</a>&gt;<br></blockquote><div><br></div><div>This looks OK to me.</div><div><br></div><div>Reviewed-by: Warner Losh &lt;<a href="mailto:imp@bsdimp.com">imp@bsdimp.com</a>&gt;</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

---<br>
 bsd-user/qemu.h | 9 ++++-----<br>
 1 file changed, 4 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h<br>
index f8bb1e5459..4076adabd0 100644<br>
--- a/bsd-user/qemu.h<br>
+++ b/bsd-user/qemu.h<br>
@@ -218,13 +218,12 @@ extern unsigned long x86_stack_size;<br>
<br>
 /* user access */<br>
<br>
-#define VERIFY_READ 0<br>
-#define VERIFY_WRITE 1 /* implies read access */<br>
+#define VERIFY_READ  PAGE_READ<br>
+#define VERIFY_WRITE (PAGE_READ | PAGE_WRITE)<br>
<br>
-static inline int access_ok(int type, abi_ulong addr, abi_ulong size)<br>
+static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)<br>
 {<br>
-    return page_check_range((target_ulong)addr, size,<br>
-                            (type == VERIFY_READ) ? PAGE_READ : (PAGE_READ | PAGE_WRITE)) == 0;<br>
+    return page_check_range((target_ulong)addr, size, type) == 0;<br>
 }<br>
<br>
 /* NOTE __get_user and __put_user use host pointers and don&#39;t check access. */<br>
-- <br></blockquote><div><br></div><div><br></div><div> </div></div></div>
diff mbox series

Patch

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index f8bb1e5459..4076adabd0 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -218,13 +218,12 @@  extern unsigned long x86_stack_size;
 
 /* user access */
 
-#define VERIFY_READ 0
-#define VERIFY_WRITE 1 /* implies read access */
+#define VERIFY_READ  PAGE_READ
+#define VERIFY_WRITE (PAGE_READ | PAGE_WRITE)
 
-static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
+static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)
 {
-    return page_check_range((target_ulong)addr, size,
-                            (type == VERIFY_READ) ? PAGE_READ : (PAGE_READ | PAGE_WRITE)) == 0;
+    return page_check_range((target_ulong)addr, size, type) == 0;
 }
 
 /* NOTE __get_user and __put_user use host pointers and don't check access. */