Skip to contentSkip to conversation

tcg: Fix returned type in alloc_code_gen_buffer_splitwx_memfd()

PATCH In review Shaobo Song 3 participants 3 messages Jun 24, 2022 – Jun 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcg: Fix returned type in alloc_code_gen_buffer_splitwx_memfd()

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().

---
 tcg/region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/region.c +1 -1
index 71ea81d671..88d6bb273f 100644
@@ -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;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Shaobo Song

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().

Signature · 1 line
Alex Bennée
#2 lore raw
In reply to Shaobo Song
Quoted 16 lines · Shaobo Song

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().

---
  tcg/region.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tcg/region.c +0 -0
index 71ea81d671..88d6bb273f 100644

tcg/region.c static int alloc_code_gen_buffer_anon(size_t size, int prot, · line 554

Quoted 8 lines
tcg/region.c +1 -1
@@ -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~