From nobody Sat Apr 5 01:14:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1567529066; cv=none; d=zoho.com; s=zohoarc; b=N+Nyb88UsQyPEhBw3joJdAYx5B9e3jOhdH85K8m+vqN19fOMB3WhUQ/01xQRti7fVHTBbq5vu1sTIa778RdxlUDXflAOuqN84sn3NSQLVnFzTVwujdcgoWanUjd+fHYXKJWasPnbbir+Jj/YZnMgVPAKnvxQLjF845Y/w+K4nLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567529066; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=C13i/X6uJZDwcnVhjZoMCIfnOZdw0d+2p6DUGgXSKUw=; b=F7xil37bpl3AM8xBdp9GQgfsV1hicigY38i9pUF3s1NuVvaowrnKAthTS/+oT0rPNz0i0bbmAdBvO81tEIX68ul+EK1BJInUAjymHEzCf9YKB0EcuMXM6UTCmif1RF1Y3RArxmFjjsb7d5hKJveDI3/5fhLR7njg40nnrJPtuEU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156752906643758.548052261675934; Tue, 3 Sep 2019 09:44:26 -0700 (PDT) Received: from localhost ([::1]:49204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Bup-0006sU-6R for importer@patchew.org; Tue, 03 Sep 2019 12:44:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37460) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5BNF-0001hJ-7j for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5BND-00042T-Hk for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:41 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:44179) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5BND-00041P-Bt for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:39 -0400 Received: by mail-pg1-x52b.google.com with SMTP id i18so9387712pgl.11 for ; Tue, 03 Sep 2019 09:09:39 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id 127sm28089711pfy.56.2019.09.03.09.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 09:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C13i/X6uJZDwcnVhjZoMCIfnOZdw0d+2p6DUGgXSKUw=; b=uPGdGnGVygXv9BzXdeIe2EVY6OOzHRjNpUxhXHc8ddGvW6GmqKQ6eP78f/wLS/7Fno uNeN+Wqo2Sj02wkqFurAy80j/2A4aSMOzP+I7EscwNgucUiXHNXjmv68ohFYOBkXQXaJ tUirD72KsiddYIr6Kx9jiv439MvO/2H53tc55/RYu7VpaPzSAA7jTbvDjvs3FHT4pHqD 0NH8FvSUkRvZ3VxbVtaAw4Mijt/OQcnR5q1J/AKjo1P04PTrVNYxX87qsweu4jAleXGe SnV9boh8y7Z/w5zup6CbNzV27JO8yKy7RREgH4fH4CtQQ+afjRSpQYwsw9UsAaZ2/UEE AA1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C13i/X6uJZDwcnVhjZoMCIfnOZdw0d+2p6DUGgXSKUw=; b=tcx0mV2utUcjZxoYZqsjjQfofH4yIW1NBnGL6eriCFpy78Ap3UtcQbYUzxQFuDc4yO HCU0OhRop1/zhsXlWPITFo6DIwjY7bN6VzxXIHKKWF3Pu+LFYmXwPUrD1ebyZWKhph+3 Y51piLimDYnq+kP5DcU2+Pvrj9Kj/ykNlh+O2oLUCx+7z0iWqJanfZugX/8kKHWgtLb8 BbTvx8WH6gAIRP/4SJyypf//XKgVMfiE+bIgpyXpKv9xzfL0ebxYrjI/sTkN3dyvR0dG Nok3aZAl2D0S1kV3GN4EsAZ0anyoj/6h2lSTKDaXr+AmyNN7cl7BlPCPTXKxx234jYf9 yRVw== X-Gm-Message-State: APjAAAVCbNE31TmgkzMtmalfgN4lWyA7bp0KjsbvL5UOLbM60BVvsbZ9 1L+VtDJdJviGM+w7VeuvpHuix5gbrUw= X-Google-Smtp-Source: APXvYqyJm+SSzZFuHximgAJkHKJS/eH9RTK3SGsDSfl3ti93BL1/Nzu9NnTgdww10O9117I1XcXTLQ== X-Received: by 2002:a62:e205:: with SMTP id a5mr41561506pfi.137.1567526978092; Tue, 03 Sep 2019 09:09:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 09:08:53 -0700 Message-Id: <20190903160858.5296-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903160858.5296-1-richard.henderson@linaro.org> References: <20190903160858.5296-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52b Subject: [Qemu-devel] [PATCH 31/36] tcg: Enforce single page access in probe_write() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's enforce the interface restriction. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Message-Id: <20190826075112.25637-5-david@redhat.com> Signed-off-by: Richard Henderson --- 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 010c4c6e3c..707adf7631 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 =3D tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr =3D tlb_addr_write(entry); =20 + g_assert(-(addr | TARGET_PAGE_MASK) >=3D 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 86e6827201..625c33f893 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -191,6 +191,8 @@ static inline int handle_cpu_signal(uintptr_t pc, sigin= fo_t *info, void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_i= dx, uintptr_t retaddr) { + g_assert(-(addr | TARGET_PAGE_MASK) >=3D size); + if (!guest_addr_valid(addr) || page_check_range(addr, size, PAGE_WRITE) < 0) { CPUState *cpu =3D env_cpu(env); --=20 2.17.1