qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>, Riku Voipio <riku.voipio@iki.fi>,
	Eduardo Habkost <ehabkost@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	Aleksandar Rikalo <arikalo@wavecomp.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Aleksandar Markovic <amarkovic@wavecomp.com>,
	qemu-s390x@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v2 4/7] tcg: Enforce single page access in probe_write()
Date: Mon, 26 Aug 2019 09:51:09 +0200	[thread overview]
Message-ID: <20190826075112.25637-5-david@redhat.com> (raw)
In-Reply-To: <20190826075112.25637-1-david@redhat.com>

Let's enforce the interface restriction.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 accel/tcg/cputlb.c    | 2 ++
 accel/tcg/user-exec.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 7fc7aa9482..09fe4cdcc4 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1088,6 +1088,8 @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx,
     CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr);
     target_ulong tlb_addr = tlb_addr_write(entry);
 
+    g_assert(-(addr | TARGET_PAGE_MASK) >= size);
+
     if (unlikely(!tlb_hit(tlb_addr, addr))) {
         if (!VICTIM_TLB_HIT(addr_write, addr)) {
             tlb_fill(env_cpu(env), addr, size, MMU_DATA_STORE,
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 68f4425cbc..b25a342eaa 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -194,6 +194,8 @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx,
     CPUState *cpu = env_cpu(env);
     CPUClass *cc;
 
+    g_assert(-(addr | TARGET_PAGE_MASK) >= size);
+
     if (!guest_addr_valid(addr) ||
         page_check_range(addr, size, PAGE_WRITE) < 0) {
         cc = CPU_GET_CLASS(cpu);
-- 
2.21.0



  parent reply	other threads:[~2019-08-26  7:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26  7:51 [Qemu-devel] [PATCH v2 0/7] tcg: probe_write() refactorings David Hildenbrand
2019-08-26  7:51 ` [Qemu-devel] [PATCH v2 1/7] s390x/tcg: Use guest_addr_valid() instead of h2g_valid() in probe_write_access() David Hildenbrand
2019-08-28  7:15   ` Cornelia Huck
2019-08-26  7:51 ` [Qemu-devel] [PATCH v2 2/7] s390x/tcg: Fix length calculation " David Hildenbrand
2019-08-28  7:19   ` Cornelia Huck
2019-08-26  7:51 ` [Qemu-devel] [PATCH v2 3/7] tcg: Factor out CONFIG_USER_ONLY probe_write() from s390x code David Hildenbrand
2019-08-26 14:22   ` Richard Henderson
2019-08-26  7:51 ` David Hildenbrand [this message]
2019-08-26 14:22   ` [Qemu-devel] [PATCH v2 4/7] tcg: Enforce single page access in probe_write() Richard Henderson
2019-08-26  7:51 ` [Qemu-devel] [PATCH v2 5/7] mips/tcg: Call probe_write() for CONFIG_USER_ONLY as well David Hildenbrand
2019-08-28 23:07   ` Richard Henderson
2019-08-29  8:10   ` Aleksandar Markovic
2019-08-26  7:51 ` [Qemu-devel] [PATCH v2 6/7] hppa/tcg: Call probe_write() also for CONFIG_USER_ONLY David Hildenbrand
2019-08-26  7:51 ` [Qemu-devel] [PATCH v2 7/7] s390x/tcg: Pass a size to probe_write() in do_csst() David Hildenbrand
2019-08-27 16:09 ` [Qemu-devel] [qemu-s390x] [PATCH v2 0/7] tcg: probe_write() refactorings David Hildenbrand
2019-08-27 16:58   ` Richard Henderson
2019-08-29 16:16     ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190826075112.25637-5-david@redhat.com \
    --to=david@redhat.com \
    --cc=amarkovic@wavecomp.com \
    --cc=arikalo@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=cohuck@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).