qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 3/3] tcg: Fix expansion of INDEX_op_not_vec
  2019-07-02 15:05 [Qemu-devel] [PULL 0/3] " Richard Henderson
@ 2019-07-02 15:05 ` Richard Henderson
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2019-07-02 15:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

This operation can always be emitted, even if we need to
fall back to xor.  Adjust the assertions to match.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/tcg-op-vec.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c
index c8fdc24f56..6714991bf4 100644
--- a/tcg/tcg-op-vec.c
+++ b/tcg/tcg-op-vec.c
@@ -90,6 +90,9 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list,
         case INDEX_op_bitsel_vec:
             /* These opcodes are mandatory and should not be listed.  */
             g_assert_not_reached();
+        case INDEX_op_not_vec:
+            /* These opcodes have generic expansions using the above.  */
+            g_assert_not_reached();
         default:
             break;
         }
@@ -438,11 +441,14 @@ static bool do_op2(unsigned vece, TCGv_vec r, TCGv_vec a, TCGOpcode opc)
 
 void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a)
 {
+    const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL);
+
     if (!TCG_TARGET_HAS_not_vec || !do_op2(vece, r, a, INDEX_op_not_vec)) {
         TCGv_vec t = tcg_const_ones_vec_matching(r);
         tcg_gen_xor_vec(0, r, a, t);
         tcg_temp_free_vec(t);
     }
+    tcg_swap_vecop_list(hold_list);
 }
 
 void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a)
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue
@ 2019-07-09  7:50 Richard Henderson
  2019-07-09  7:50 ` [Qemu-devel] [PULL 1/3] tcg: Fix mmap lock assert on translation failure Richard Henderson
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Richard Henderson @ 2019-07-09  7:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

For v2, drop the PAGE_EXEC patch that appeared to cause
problems during Peter's testing.


r~


The following changes since commit f34edbc760b0f689deddd175fc08732ecb46665f:

  Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2019-07-08-1' into staging (2019-07-08 17:40:05 +0100)

are available in the Git repository at:

  https://github.com/rth7680/qemu.git tags/pull-tcg-20190709

for you to fetch changes up to 11978f6f58f1d3d66429f7ff897524f693d823ce:

  tcg: Fix expansion of INDEX_op_not_vec (2019-07-09 08:26:11 +0200)

----------------------------------------------------------------
Minor gvec fix for as-yet uncommitted altivec host.
Build fix for riscv host.

----------------------------------------------------------------
Alistair Francis (1):
      tcg/riscv: Fix RISC-VH host build failure

Richard Henderson (1):
      tcg: Fix expansion of INDEX_op_not_vec

 tcg/riscv/tcg-target.inc.c | 4 ++--
 tcg/tcg-op-vec.c           | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PULL 1/3] tcg: Fix mmap lock assert on translation failure
  2019-07-09  7:50 [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Richard Henderson
@ 2019-07-09  7:50 ` Richard Henderson
  2019-07-09  7:50 ` [Qemu-devel] [PULL v2 1/2] tcg/riscv: Fix RISC-VH host build failure Richard Henderson
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2019-07-09  7:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

Check page flags before letting an invalid pc cause a SIGSEGV.

Prepare for eventially validating PROT_EXEC.  The current wrinkle being
that we have a problem with our implementation of signals.  We should
be using a vdso like the kernel, but we instead put the trampoline on
the stack.  In the meantime, let PROT_READ match PROT_EXEC.

Fixes: https://bugs.launchpad.net/qemu/+bug/1832353
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu-all.h                    |  1 +
 include/exec/cpu_ldst_useronly_template.h |  8 +++++--
 accel/tcg/translate-all.c                 | 29 +++++++++++++++++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 536ea58f81..58b8915617 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -259,6 +259,7 @@ int walk_memory_regions(void *, walk_memory_regions_fn);
 int page_get_flags(target_ulong address);
 void page_set_flags(target_ulong start, target_ulong end, int flags);
 int page_check_range(target_ulong start, target_ulong len, int flags);
+void validate_exec_access(CPUArchState *env, target_ulong s, target_ulong l);
 #endif
 
 CPUArchState *cpu_copy(CPUArchState *env);
diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
index bc45e2b8d4..f095415149 100644
--- a/include/exec/cpu_ldst_useronly_template.h
+++ b/include/exec/cpu_ldst_useronly_template.h
@@ -64,7 +64,9 @@
 static inline RES_TYPE
 glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
 {
-#if !defined(CODE_ACCESS)
+#ifdef CODE_ACCESS
+    validate_exec_access(env, ptr, DATA_SIZE);
+#else
     trace_guest_mem_before_exec(
         env_cpu(env), ptr,
         trace_mem_build_info(SHIFT, false, MO_TE, false));
@@ -88,7 +90,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
 static inline int
 glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
 {
-#if !defined(CODE_ACCESS)
+#ifdef CODE_ACCESS
+    validate_exec_access(env, ptr, DATA_SIZE);
+#else
     trace_guest_mem_before_exec(
         env_cpu(env), ptr,
         trace_mem_build_info(SHIFT, true, MO_TE, false));
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 5d1e08b169..1d4a8a260f 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -2600,10 +2600,39 @@ int page_check_range(target_ulong start, target_ulong len, int flags)
                 }
             }
         }
+        /*
+         * FIXME: We place the signal trampoline on the stack,
+         * even when the guest expects that to be in the vdso.
+         * Until we fix that, allow execute on any readable page.
+         */
+        if ((flags & PAGE_EXEC) && !(p->flags & (PAGE_EXEC | PAGE_READ))) {
+            return -1;
+        }
     }
     return 0;
 }
 
+/*
+ * Called for each code read, longjmp out to issue SIGSEGV if the page(s)
+ * do not have execute access.
+ */
+void validate_exec_access(CPUArchState *env,
+                          target_ulong ptr, target_ulong len)
+{
+    if (page_check_range(ptr, len, PAGE_EXEC) < 0) {
+        CPUState *cs = env_cpu(env);
+        CPUClass *cc = CPU_GET_CLASS(cs);
+
+        /* Like tb_gen_code, release the memory lock before cpu_loop_exit.  */
+        assert_memory_lock();
+        mmap_unlock();
+
+        /* This is user-only.  The target must raise an exception.  */
+        cc->tlb_fill(cs, ptr, 0, MMU_INST_FETCH, MMU_USER_IDX, false, 0);
+        g_assert_not_reached();
+    }
+}
+
 /* called from signal handler: invalidate the code and unprotect the
  * page. Return 0 if the fault was not handled, 1 if it was handled,
  * and 2 if it was handled but the caller must cause the TB to be
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PULL v2 1/2] tcg/riscv: Fix RISC-VH host build failure
  2019-07-09  7:50 [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Richard Henderson
  2019-07-09  7:50 ` [Qemu-devel] [PULL 1/3] tcg: Fix mmap lock assert on translation failure Richard Henderson
@ 2019-07-09  7:50 ` Richard Henderson
  2019-07-09  7:50 ` [Qemu-devel] [PULL v2 2/2] tcg: Fix expansion of INDEX_op_not_vec Richard Henderson
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2019-07-09  7:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, Alistair Francis

From: Alistair Francis <alistair.francis@wdc.com>

Commit 269bd5d8 "cpu: Move the softmmu tlb to CPUNegativeOffsetState'
broke the RISC-V host build as there are two variables that are used but
not defined.

This patch renames the undefined variables mask_off and table_off to the
existing (but unused) mask_ofs and table_ofs variables.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <79729cc88ca509e08b5c4aa0aa8a52847af70c0f.1561039316.git.alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/riscv/tcg-target.inc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c
index 1f0ae64aae..3e76bf5738 100644
--- a/tcg/riscv/tcg-target.inc.c
+++ b/tcg/riscv/tcg-target.inc.c
@@ -980,8 +980,8 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl,
     int table_ofs = fast_ofs + offsetof(CPUTLBDescFast, table);
     TCGReg mask_base = TCG_AREG0, table_base = TCG_AREG0;
 
-    tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP0, mask_base, mask_off);
-    tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP1, table_base, table_off);
+    tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP0, mask_base, mask_ofs);
+    tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP1, table_base, table_ofs);
 
     tcg_out_opc_imm(s, OPC_SRLI, TCG_REG_TMP2, addrl,
                     TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PULL v2 2/2] tcg: Fix expansion of INDEX_op_not_vec
  2019-07-09  7:50 [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Richard Henderson
  2019-07-09  7:50 ` [Qemu-devel] [PULL 1/3] tcg: Fix mmap lock assert on translation failure Richard Henderson
  2019-07-09  7:50 ` [Qemu-devel] [PULL v2 1/2] tcg/riscv: Fix RISC-VH host build failure Richard Henderson
@ 2019-07-09  7:50 ` Richard Henderson
  2019-07-09  7:50 ` [Qemu-devel] [PULL 2/3] tcg/riscv: Fix RISC-VH host build failure Richard Henderson
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2019-07-09  7:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

This operation can always be emitted, even if we need to
fall back to xor.  Adjust the assertions to match.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/tcg-op-vec.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c
index c8fdc24f56..6714991bf4 100644
--- a/tcg/tcg-op-vec.c
+++ b/tcg/tcg-op-vec.c
@@ -90,6 +90,9 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list,
         case INDEX_op_bitsel_vec:
             /* These opcodes are mandatory and should not be listed.  */
             g_assert_not_reached();
+        case INDEX_op_not_vec:
+            /* These opcodes have generic expansions using the above.  */
+            g_assert_not_reached();
         default:
             break;
         }
@@ -438,11 +441,14 @@ static bool do_op2(unsigned vece, TCGv_vec r, TCGv_vec a, TCGOpcode opc)
 
 void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a)
 {
+    const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL);
+
     if (!TCG_TARGET_HAS_not_vec || !do_op2(vece, r, a, INDEX_op_not_vec)) {
         TCGv_vec t = tcg_const_ones_vec_matching(r);
         tcg_gen_xor_vec(0, r, a, t);
         tcg_temp_free_vec(t);
     }
+    tcg_swap_vecop_list(hold_list);
 }
 
 void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a)
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PULL 2/3] tcg/riscv: Fix RISC-VH host build failure
  2019-07-09  7:50 [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Richard Henderson
                   ` (2 preceding siblings ...)
  2019-07-09  7:50 ` [Qemu-devel] [PULL v2 2/2] tcg: Fix expansion of INDEX_op_not_vec Richard Henderson
@ 2019-07-09  7:50 ` Richard Henderson
  2019-07-09  7:50 ` [Qemu-devel] [PULL 3/3] tcg: Fix expansion of INDEX_op_not_vec Richard Henderson
  2019-07-09 11:46 ` [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Peter Maydell
  5 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2019-07-09  7:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, Alistair Francis

From: Alistair Francis <alistair.francis@wdc.com>

Commit 269bd5d8 "cpu: Move the softmmu tlb to CPUNegativeOffsetState'
broke the RISC-V host build as there are two variables that are used but
not defined.

This patch renames the undefined variables mask_off and table_off to the
existing (but unused) mask_ofs and table_ofs variables.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <79729cc88ca509e08b5c4aa0aa8a52847af70c0f.1561039316.git.alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/riscv/tcg-target.inc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c
index 1f0ae64aae..3e76bf5738 100644
--- a/tcg/riscv/tcg-target.inc.c
+++ b/tcg/riscv/tcg-target.inc.c
@@ -980,8 +980,8 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl,
     int table_ofs = fast_ofs + offsetof(CPUTLBDescFast, table);
     TCGReg mask_base = TCG_AREG0, table_base = TCG_AREG0;
 
-    tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP0, mask_base, mask_off);
-    tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP1, table_base, table_off);
+    tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP0, mask_base, mask_ofs);
+    tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP1, table_base, table_ofs);
 
     tcg_out_opc_imm(s, OPC_SRLI, TCG_REG_TMP2, addrl,
                     TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PULL 3/3] tcg: Fix expansion of INDEX_op_not_vec
  2019-07-09  7:50 [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Richard Henderson
                   ` (3 preceding siblings ...)
  2019-07-09  7:50 ` [Qemu-devel] [PULL 2/3] tcg/riscv: Fix RISC-VH host build failure Richard Henderson
@ 2019-07-09  7:50 ` Richard Henderson
  2019-07-09 11:46 ` [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Peter Maydell
  5 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2019-07-09  7:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

This operation can always be emitted, even if we need to
fall back to xor.  Adjust the assertions to match.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/tcg-op-vec.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c
index c8fdc24f56..6714991bf4 100644
--- a/tcg/tcg-op-vec.c
+++ b/tcg/tcg-op-vec.c
@@ -90,6 +90,9 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list,
         case INDEX_op_bitsel_vec:
             /* These opcodes are mandatory and should not be listed.  */
             g_assert_not_reached();
+        case INDEX_op_not_vec:
+            /* These opcodes have generic expansions using the above.  */
+            g_assert_not_reached();
         default:
             break;
         }
@@ -438,11 +441,14 @@ static bool do_op2(unsigned vece, TCGv_vec r, TCGv_vec a, TCGOpcode opc)
 
 void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a)
 {
+    const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL);
+
     if (!TCG_TARGET_HAS_not_vec || !do_op2(vece, r, a, INDEX_op_not_vec)) {
         TCGv_vec t = tcg_const_ones_vec_matching(r);
         tcg_gen_xor_vec(0, r, a, t);
         tcg_temp_free_vec(t);
     }
+    tcg_swap_vecop_list(hold_list);
 }
 
 void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a)
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue
  2019-07-09  7:50 [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Richard Henderson
                   ` (4 preceding siblings ...)
  2019-07-09  7:50 ` [Qemu-devel] [PULL 3/3] tcg: Fix expansion of INDEX_op_not_vec Richard Henderson
@ 2019-07-09 11:46 ` Peter Maydell
  5 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2019-07-09 11:46 UTC (permalink / raw)
  To: Richard Henderson; +Cc: QEMU Developers

On Tue, 9 Jul 2019 at 08:50, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> For v2, drop the PAGE_EXEC patch that appeared to cause
> problems during Peter's testing.
>
>
> r~
>
>
> The following changes since commit f34edbc760b0f689deddd175fc08732ecb46665f:
>
>   Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2019-07-08-1' into staging (2019-07-08 17:40:05 +0100)
>
> are available in the Git repository at:
>
>   https://github.com/rth7680/qemu.git tags/pull-tcg-20190709
>
> for you to fetch changes up to 11978f6f58f1d3d66429f7ff897524f693d823ce:
>
>   tcg: Fix expansion of INDEX_op_not_vec (2019-07-09 08:26:11 +0200)
>
> ----------------------------------------------------------------
> Minor gvec fix for as-yet uncommitted altivec host.
> Build fix for riscv host.
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-07-09 11:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-09  7:50 [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Richard Henderson
2019-07-09  7:50 ` [Qemu-devel] [PULL 1/3] tcg: Fix mmap lock assert on translation failure Richard Henderson
2019-07-09  7:50 ` [Qemu-devel] [PULL v2 1/2] tcg/riscv: Fix RISC-VH host build failure Richard Henderson
2019-07-09  7:50 ` [Qemu-devel] [PULL v2 2/2] tcg: Fix expansion of INDEX_op_not_vec Richard Henderson
2019-07-09  7:50 ` [Qemu-devel] [PULL 2/3] tcg/riscv: Fix RISC-VH host build failure Richard Henderson
2019-07-09  7:50 ` [Qemu-devel] [PULL 3/3] tcg: Fix expansion of INDEX_op_not_vec Richard Henderson
2019-07-09 11:46 ` [Qemu-devel] [PULL v2 for-4.1 0/2] tcg patch queue Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2019-07-02 15:05 [Qemu-devel] [PULL 0/3] " Richard Henderson
2019-07-02 15:05 ` [Qemu-devel] [PULL 3/3] tcg: Fix expansion of INDEX_op_not_vec Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).