[PATCH] tcg: Fix returned type in alloc_code_gen_buffer_splitwx_memfd()

Shaobo Song posted 1 patch 1 year, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220624150216.3627-1-shnusongshaobo@gmail.com
Maintainers: Richard Henderson <richard.henderson@linaro.org>
tcg/region.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tcg: Fix returned type in alloc_code_gen_buffer_splitwx_memfd()
Posted by Shaobo Song 1 year, 11 months ago
 This fixes a bug in POSIX-compliant environments. Since we had allocated 
 a buffer named 'tcg-jit' with read-write access protections we need a int 
 type to combine these access flags and return it, whereas we had inexplicably 
 return a bool type. It may cause an unnecessary protection change in 
 tcg_region_init().

Signed-off-by: Shaobo Song <shnusongshaobo@gmail.com>
---
 tcg/region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tcg/region.c b/tcg/region.c
index 71ea81d671..88d6bb273f 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -548,7 +548,7 @@ static int alloc_code_gen_buffer_anon(size_t size, int prot,
 #ifdef CONFIG_POSIX
 #include "qemu/memfd.h"
 
-static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
+static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
 {
     void *buf_rw = NULL, *buf_rx = MAP_FAILED;
     int fd = -1;
-- 
2.25.1
Re: [PATCH] tcg: Fix returned type in alloc_code_gen_buffer_splitwx_memfd()
Posted by Richard Henderson 1 year, 11 months ago
On 6/24/22 20:32, Shaobo Song wrote:
>   This fixes a bug in POSIX-compliant environments. Since we had allocated
>   a buffer named 'tcg-jit' with read-write access protections we need a int
>   type to combine these access flags and return it, whereas we had inexplicably
>   return a bool type. It may cause an unnecessary protection change in
>   tcg_region_init().
> 
> Signed-off-by: Shaobo Song <shnusongshaobo@gmail.com>
> ---
>   tcg/region.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tcg/region.c b/tcg/region.c
> index 71ea81d671..88d6bb273f 100644
> --- a/tcg/region.c
> +++ b/tcg/region.c
> @@ -548,7 +548,7 @@ static int alloc_code_gen_buffer_anon(size_t size, int prot,
>   #ifdef CONFIG_POSIX
>   #include "qemu/memfd.h"
>   
> -static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
> +static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
>   {
>       void *buf_rw = NULL, *buf_rx = MAP_FAILED;
>       int fd = -1;

Thanks, queued to tcg-next.


r~
Re: [PATCH] tcg: Fix returned type in alloc_code_gen_buffer_splitwx_memfd()
Posted by Alex Bennée 1 year, 11 months ago
Shaobo Song <shnusongshaobo@gmail.com> writes:

>  This fixes a bug in POSIX-compliant environments. Since we had allocated 
>  a buffer named 'tcg-jit' with read-write access protections we need a int 
>  type to combine these access flags and return it, whereas we had inexplicably 
>  return a bool type. It may cause an unnecessary protection change in 
>  tcg_region_init().
>
> Signed-off-by: Shaobo Song <shnusongshaobo@gmail.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée