From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566554972; cv=none; d=zoho.com; s=zohoarc; b=IkJsTgulcnpQXLpYdPEXozUmMCY7sqQ/G++M1aoqMNrYriW1ME5U7QvE6h/pTFUFzCsw38fpSNVIv98X6ikJ2DhWtyQcVTA+ynNamsnTChA5zvzjNrQ1Sk3nd+FRiCNTS6h2iIaPlOlWyeZBlRgEIwR8yUvF0jE1mshBYdHLBPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566554972; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YW+MDeMejLlBPlMAoSbG1eFUHVQOwsKPmLUzp8waVFI=; b=HhbXU0AlF2ydEp0XzfBHbti1T84tGOadGBuCXpPvBrA/8ij/wcr/TtLC41Z5AX4FWUoaL6asS1EmmJW3CQ5lTLAs2MglPoRFs1jrwMz9HpUd5prhdxReyrXthZTIn/7+YppTYCyRh+0CqWX2JZFHc60aTVXue6p7ZoJ6wu4y54k= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1566554972989704.7851733248881; Fri, 23 Aug 2019 03:09:32 -0700 (PDT) Received: from localhost ([::1]:53666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16Vc-0007Zj-UN for importer@patchew.org; Fri, 23 Aug 2019 06:09:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58278) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16U4-0006Gg-4g for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:07:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16U3-0007ud-7r for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:07:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60974) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16U3-0007u0-0s; Fri, 23 Aug 2019 06:07:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 280B57F745; Fri, 23 Aug 2019 10:07:50 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id A94965D6B2; Fri, 23 Aug 2019 10:07:47 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:33 +0200 Message-Id: <20190823100741.9621-2-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Fri, 23 Aug 2019 10:07:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 1/9] s390x/tcg: Use guest_addr_valid() instead of h2g_valid() in probe_write_access() 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If I'm not completely wrong, we are dealing with guest addresses here and not with host addresses. Use the right check. Fixes: c5a7392cfb96 ("s390x/tcg: Provide probe_write_access helper") Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 91ba2e03d9..7819aca15d 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2616,7 +2616,7 @@ void probe_write_access(CPUS390XState *env, uint64_t = addr, uint64_t len, uintptr_t ra) { #ifdef CONFIG_USER_ONLY - if (!h2g_valid(addr) || !h2g_valid(addr + len - 1) || + if (!guest_addr_valid(addr) || !guest_addr_valid(addr + len - 1) || page_check_range(addr, len, PAGE_WRITE) < 0) { s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); } --=20 2.21.0 From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566555128; cv=none; d=zoho.com; s=zohoarc; b=fky0ADumUe8pObkAmQhv37fe3fOn+N9jXS8vJhEDuaX3JEft1LjipE5JMabTGp3ViFiOBNkF+gOmtPPIMR+Zwfz+mzGXGipIvt/vMBov2kUfhOFwcWYoN4aawriqthfv4dg/tD02M1him7AiWAnY3VpnQ4UlB57z2s7FxDG+qME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566555128; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9Lx+D9yr1aE7DaMoRZSP3jgiRBEnjLft/1bhOc4T7hU=; b=FNypyqXrbM05NMmF6FbTxITR9Absgyiuh6VqzWwJ9HXeLP9CT2/h/eL7y4D8YyIfskBgdfkFDrcV1PeUDv9QwJJ/PtTG3L2Drs09HVSMWduVbudY+tL8E0EmnlERY4sFtJC8Q2y374XnaC37Wa14zLqnzX3D5DKjveXuQfBi748= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1566555128431206.25001957189977; Fri, 23 Aug 2019 03:12:08 -0700 (PDT) Received: from localhost ([::1]:53700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16Y9-0003MU-0e for importer@patchew.org; Fri, 23 Aug 2019 06:12:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58314) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16U8-0006KX-Q5 for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:07:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16U7-0007yb-Ge for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:07:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49290) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16U7-0007yI-BL; Fri, 23 Aug 2019 06:07:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9EEF6307D915; Fri, 23 Aug 2019 10:07:54 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7063A5D6B2; Fri, 23 Aug 2019 10:07:50 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:34 +0200 Message-Id: <20190823100741.9621-3-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 23 Aug 2019 10:07:54 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 2/9] s390x/tcg: Fix length calculation in probe_write_access() 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Hm,, how did that "-" slip in (-TAGRET_PAGE_SIZE would be correct). This currently makes us exceed one page in a single probe_write() call, essentially leaving some memory unchecked. Fixes: c5a7392cfb96 ("s390x/tcg: Provide probe_write_access helper") Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 7819aca15d..4b43440e89 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2623,7 +2623,7 @@ void probe_write_access(CPUS390XState *env, uint64_t = addr, uint64_t len, #else /* test the actual access, not just any access to the page due to LAP = */ while (len) { - const uint64_t pagelen =3D -(addr | -TARGET_PAGE_MASK); + const uint64_t pagelen =3D -(addr | TARGET_PAGE_MASK); const uint64_t curlen =3D MIN(pagelen, len); =20 probe_write(env, addr, curlen, cpu_mmu_index(env, false), ra); --=20 2.21.0 From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566555090; cv=none; d=zoho.com; s=zohoarc; b=MJQu/7Zj/fHTlElF6Cn0dCYt7Iz0jglU63nI8XRlIOhzBk9Ahe/52QQGIG1eHU8B05OBfl72jOfNQyQwr9SX6GN1Fy8jsrv+4rF82+VWJO2lVjrFLxWi781uzgG8zPSjoo4HYI8n8Jk1OjGAyLMLS2sgqwB7H/a67zjhGK3FQIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566555090; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=udMvG5eghxJA6GZj0TyuGjBtegzTnrR2tKJ+dr0BKXM=; b=iXeRVDji4papFicQNTX6VnxstBzYYsBq1Z8zbJM6W5YcG6tLNszneJZPYOqiDOctCYJosa8nu18V5RL9KYpAeBLKs5vkBtivF7bnOUKCKSBcaRLVnAGTyqqrJ2Km4iMBq1kvbSQYwgyuzRBdFq1VbuCWbn9IHRJd+jU2+oK+FVI= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1566555090129154.0599298336001; Fri, 23 Aug 2019 03:11:30 -0700 (PDT) Received: from localhost ([::1]:53690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16XY-0002XV-Fz for importer@patchew.org; Fri, 23 Aug 2019 06:11:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58343) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16UD-0006QR-IJ for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16UC-00083W-Ay for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45542) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16UC-00082j-2b; Fri, 23 Aug 2019 06:08:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D7EF3064FCF; Fri, 23 Aug 2019 10:07:59 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id E77485D6B2; Fri, 23 Aug 2019 10:07:54 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:35 +0200 Message-Id: <20190823100741.9621-4-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 23 Aug 2019 10:07:59 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 3/9] tcg: Factor out CONFIG_USER_ONLY probe_write() from s390x code 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Factor it out, we'll do some further changes/extensions to both probe_write() implementations soon. Make sure to allow "size =3D 0". Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- accel/tcg/user-exec.c | 16 ++++++++++++++++ include/exec/exec-all.h | 4 ++-- target/s390x/mem_helper.c | 7 ------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 897d1571c4..322d49c9b8 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -188,6 +188,22 @@ static inline int handle_cpu_signal(uintptr_t pc, sigi= nfo_t *info, g_assert_not_reached(); } =20 +void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_i= dx, + uintptr_t retaddr) +{ + CPUState *cpu =3D env_cpu(env); + CPUClass *cc; + + if (!guest_addr_valid(addr) || + (size > 0 && !guest_addr_valid(addr + size - 1)) || + page_check_range(addr, size, PAGE_WRITE) < 0) { + cc =3D CPU_GET_CLASS(cpu); + cc->tlb_fill(cpu, addr, size, MMU_DATA_STORE, MMU_USER_IDX, false, + retaddr); + g_assert_not_reached(); + } +} + #if defined(__i386__) =20 #if defined(__NetBSD__) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 135aeaab0d..cbcc85add3 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -260,8 +260,6 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulon= g vaddr, void tlb_set_page(CPUState *cpu, target_ulong vaddr, hwaddr paddr, int prot, int mmu_idx, target_ulong size); -void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_i= dx, - uintptr_t retaddr); #else static inline void tlb_init(CPUState *cpu) { @@ -312,6 +310,8 @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(= CPUState *cpu, { } #endif +void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_i= dx, + uintptr_t retaddr); =20 #define CODE_GEN_ALIGN 16 /* must be >=3D of the size of a icach= e line */ =20 diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 4b43440e89..fdff60ce5d 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2615,12 +2615,6 @@ uint32_t HELPER(cu42)(CPUS390XState *env, uint32_t r= 1, uint32_t r2, uint32_t m3) void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len, uintptr_t ra) { -#ifdef CONFIG_USER_ONLY - if (!guest_addr_valid(addr) || !guest_addr_valid(addr + len - 1) || - page_check_range(addr, len, PAGE_WRITE) < 0) { - s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); - } -#else /* test the actual access, not just any access to the page due to LAP = */ while (len) { const uint64_t pagelen =3D -(addr | TARGET_PAGE_MASK); @@ -2630,7 +2624,6 @@ void probe_write_access(CPUS390XState *env, uint64_t = addr, uint64_t len, addr =3D wrap_address(env, addr + curlen); len -=3D curlen; } -#endif } =20 void HELPER(probe_write_access)(CPUS390XState *env, uint64_t addr, uint64_= t len) --=20 2.21.0 From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566554983; cv=none; d=zoho.com; s=zohoarc; b=W0Ydvw4f4TvPujae6mFE2t4CuVz19zGVpOjxrJ7bf0uj5D6KhzSB/zWbHYV9DINbWgsLy1l+ULiyTbVr6WfmxIpwa4o4i7OoB8f/ZWl+spO8fs6N1NyA0WGShqKD/rnrMy0OjpQgvCiP6ZT7Uh2mfxpURaNmsGjfo5QDbuKVJJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566554983; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QF+G5v/gNkiH/OE7FxMOf2TSRKTgFwwiG/ueKZGyLnk=; b=RlY8sZfBqgEBFKb8YSmhtEbw2cxq4oIJs6Gw+aDGul3gU85KS4eDHT4VnUnZMZeNc/cZqLZcqFEGyIW9N00uxS3qy4rJXLoGrm68dbl1cOlcnGmNnaEpOLXKwyvIzRY77p36L8yUs5SOWgeHLFocalBKyXJtbbcbyccF0wVkUPw= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1566554983061581.9894348624514; Fri, 23 Aug 2019 03:09:43 -0700 (PDT) Received: from localhost ([::1]:53670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16Vp-0007xO-T3 for importer@patchew.org; Fri, 23 Aug 2019 06:09:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58373) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16UG-0006Tl-6O for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16UF-00085w-2y for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39010) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16UE-00085H-Tn; Fri, 23 Aug 2019 06:08:03 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 28E7A87648; Fri, 23 Aug 2019 10:08:02 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7CF55D6B2; Fri, 23 Aug 2019 10:07:59 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:36 +0200 Message-Id: <20190823100741.9621-5-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 23 Aug 2019 10:08:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 4/9] tcg: Enforce single page access in probe_write() for !CONFIG_USER_ONLY 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" While the CONFIG_USER_ONLY variant can handle multiple pages (no MMU), the !CONFIG_USER_ONLY variant can't and won't. We'll want to convert probe_write() to return a host address (similar to tlb_vaddr_to_host()) soon. This only works on page granularity. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- accel/tcg/cputlb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index bb9897b25a..4b49ccb58a 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1064,6 +1064,8 @@ void probe_write(CPUArchState *env, target_ulong addr= , int size, int mmu_idx, uintptr_t index =3D tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); =20 + g_assert(-(addr | TARGET_PAGE_MASK) >=3D size); + if (!tlb_hit(tlb_addr_write(entry), addr)) { /* TLB entry is for a different page */ if (!VICTIM_TLB_HIT(addr_write, addr)) { --=20 2.21.0 From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566555104; cv=none; d=zoho.com; s=zohoarc; b=fBsTC9PiOY7YeEPMV64qlDqcTB7YBj+6/kzugWw5CvWA7/4voiOtEIxlyUmjkL30wyNJpRmsu4RTzrj3qFm/uGW19q3exxvJpkx6T7w9ljILfsrovZCtxZ+GIG7csfDRkYaDkgadXFORq/63cIPDXc/hTn+C/34g7TwTMvg3l08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566555104; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KyfoInRXjK8YoJE0oAMj3/VBhUN1ApPpdo3Y8rgb2gY=; b=dPDXw8VXyIUfapgG8R2YuscqZP6SXrxhhEX7X5/O37Vprdd3BoXg7OpDIAVxHWJIPwu55Q0vN38/JNLLWQSrvGlpQeJshmlMfZIAMSiKj1cLZNMebfBuKhRWcCutkIpXL+HfJz4996YaYC7z6sz/gRDz6A+4zb7XOIsDq0ivSkw= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1566555104777709.5009889831908; Fri, 23 Aug 2019 03:11:44 -0700 (PDT) Received: from localhost ([::1]:53699 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16Xl-0002sF-7N for importer@patchew.org; Fri, 23 Aug 2019 06:11:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58444) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16UM-0006dG-T7 for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16UL-0008Ar-Cb for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41934) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16UL-0008A8-6S; Fri, 23 Aug 2019 06:08:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BBC0309B688; Fri, 23 Aug 2019 10:08:08 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 732065D6B2; Fri, 23 Aug 2019 10:08:02 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:37 +0200 Message-Id: <20190823100741.9621-6-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 23 Aug 2019 10:08:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 5/9] mips/tcg: Call probe_write() for CONFIG_USER_ONLY as well 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's call it also for CONFIG_USER_ONLY. While at it, add a FIXME and get rid of one local variable. MIPS code probably needs a bigger refactoring in regards of ensure_writable_pages(), similar to s390x, so for example, watchpoints can be handled reliably later. The actually accessed addresses should be probed only, not full pages. Signed-off-by: David Hildenbrand --- target/mips/op_helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index f88a3ab904..221e8bb1d7 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -4536,16 +4536,14 @@ static inline void ensure_writable_pages(CPUMIPSSta= te *env, int mmu_idx, uintptr_t retaddr) { -#if !defined(CONFIG_USER_ONLY) - target_ulong page_addr; + /* FIXME: Probe the actual accesses (pass and use a size) */ if (unlikely(MSA_PAGESPAN(addr))) { /* first page */ probe_write(env, addr, 0, mmu_idx, retaddr); /* second page */ - page_addr =3D (addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; - probe_write(env, page_addr, 0, mmu_idx, retaddr); + addr =3D (addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + probe_write(env, addr, 0, mmu_idx, retaddr); } -#endif } =20 void helper_msa_st_b(CPUMIPSState *env, uint32_t wd, --=20 2.21.0 From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566555227; cv=none; d=zoho.com; s=zohoarc; b=Wk+JMfUpdhDSReg9UPekGfFMoRh/9/+5hGNFFN3ymoJpg6ffU8jFNUE4SeL1XPg/Trw6vgKZ5x+ju393Folmk81IBB0bNhWE84f/4mhEe8l+qitJn9qf56jXt5JsIYAD+q+QepzbG8f6OHBzYhQ2t7Dvq3fwkkHsM9fXPEO9phg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566555227; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Rcm/onq6DxZ5A+bUSxfmPnizcVZrIN8T1146WtqDVhw=; b=Cu1AutPt5Hgk5lRkyIwxkRuYkiZ+S/Q15XHDlEBxVZVoxjISrUoksLaVi0O5H2pnKcN0M46AeBFlAlfdTu/795vDpgRKOWVIUAnWqTQqO2fGubHCyPSgdm8tYI9wZf85ziOrId+EFAXviQLfhIxliBUCd/HIh5aB46MSWm+gBf4= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1566555227894113.22629746468613; Fri, 23 Aug 2019 03:13:47 -0700 (PDT) Received: from localhost ([::1]:53738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16Zm-0005G7-Qx for importer@patchew.org; Fri, 23 Aug 2019 06:13:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58478) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16UP-0006gm-7A for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16UO-0008DU-6d for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38630) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16UN-0008Cq-WF; Fri, 23 Aug 2019 06:08:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44A773099F76; Fri, 23 Aug 2019 10:08:11 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id C40785D6B2; Fri, 23 Aug 2019 10:08:08 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:38 +0200 Message-Id: <20190823100741.9621-7-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 23 Aug 2019 10:08:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 6/9] hppa/tcg: Call probe_write() also for CONFIG_USER_ONLY 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We now have a variant for CONFIG_USER_ONLY as well. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/hppa/op_helper.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index df0f1361ef..f0516e81f1 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -137,9 +137,7 @@ static void do_stby_e(CPUHPPAState *env, target_ulong a= ddr, target_ureg val, default: /* Nothing is stored, but protection is checked and the cacheline is marked dirty. */ -#ifndef CONFIG_USER_ONLY probe_write(env, addr, 0, cpu_mmu_index(env, 0), ra); -#endif break; } } --=20 2.21.0 From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566555346; cv=none; d=zoho.com; s=zohoarc; b=eB7G/cU6ts2ATmkh9QWxnbdjEx8CoHv5ESf/9dHrI7oTPNzxyBxHirUbWdt3lidwYxD1nPiNgz4fGNQgRELOWcmKnxfZQ0m/pYoxPMChw2sJwRu7TFpzfMC0So+b58b5OgXYXb17SWAn0uUZsAKxQpn5aCvveSOjSgZfP7CYJ74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566555346; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=xiueyh1clbcZKbijsEGnBSTwBrp3j/mO2Ggx2v8C3Cc=; b=ecf+Bcx3YE/rRvk2mTGwIW+9kvnVuIXbXdq3uk1WPggh43l3rZDcS+HCgu5cGYm0eVh5bnqTTEE77/tnX9zhucjDbMPKbUkSkrFaiwGqt0TLSOQC6ZPLrrhtCT1Ixrf2sGSFgVEuocMaqzaMe846hmZeTXscS1/1943Zl42M23c= ARC-Authentication-Results: i=1; mx.zoho.com; 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 156655534629457.78330602138658; Fri, 23 Aug 2019 03:15:46 -0700 (PDT) Received: from localhost ([::1]:53758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16bb-0007gP-NZ for importer@patchew.org; Fri, 23 Aug 2019 06:15:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58519) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16US-0006kG-01 for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16UQ-0008Fr-VV for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58276) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16UQ-0008FM-PZ; Fri, 23 Aug 2019 06:08:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A43F59465; Fri, 23 Aug 2019 10:08:14 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D93F5D6B2; Fri, 23 Aug 2019 10:08:11 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:39 +0200 Message-Id: <20190823100741.9621-8-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 23 Aug 2019 10:08:14 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 7/9] s390x/tcg: Pass a size to probe_write() in do_csst() 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" ... and also call it for CONFIG_USER_ONLY. This function probably will also need some refactoring in regards to probing, however, we'll have to come back to that later, once cleaning up the other mem helpers. The alignment check always makes sure that the write access falls into a single page. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index fdff60ce5d..29fcce426e 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1443,9 +1443,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t = r3, uint64_t a1, } =20 /* Sanity check writability of the store address. */ -#ifndef CONFIG_USER_ONLY - probe_write(env, a2, 0, mem_idx, ra); -#endif + probe_write(env, a2, 1 << sc, mem_idx, ra); =20 /* * Note that the compare-and-swap is atomic, and the store is atomic, --=20 2.21.0 From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566555545; cv=none; d=zoho.com; s=zohoarc; b=ear5M6u23WUWOIDKqFQ0999cYyyCv3z0qGk2V4xxl8eLfgaJD0rURzYfH8r0/blhp1cQn8E5IhbzA7MzJze9UOSD3NTB3NMDl9V7Gu+hvVDvIr6wrx5uRRff0ugX6aWZ07tudrSQUhOyCAo+/kqmpZN+SRa08t79AceV2PcrHxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566555545; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VKQa6pZZJLA6NvzewpbYaAG0QEFSey4tH/TN8e1yakk=; b=EGXS6uCmOmcJZQ+bCAA9IuHUR5e18OgumAVCMimSaRGIFRKBujOk/8fGyoSvq34cEFwnqqO3x9+9gQpDFW7MGfU1Smk4MfneiJteTO0bhjPsRAT+WZOjAhRqpgIyMb/mtX6cgIbKDGIMF5NQD1gbhS21VSIq3Ji/RRzJlnM6FTc= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1566555545263681.8064951973895; Fri, 23 Aug 2019 03:19:05 -0700 (PDT) Received: from localhost ([::1]:53784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16et-0002zD-Hw for importer@patchew.org; Fri, 23 Aug 2019 06:19:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58553) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16UV-0006oO-41 for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16UT-0008Ht-Q1 for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37010) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16UT-0008HN-IM; Fri, 23 Aug 2019 06:08:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C78F285536; Fri, 23 Aug 2019 10:08:16 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53B685D6B2; Fri, 23 Aug 2019 10:08:14 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:40 +0200 Message-Id: <20190823100741.9621-9-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 23 Aug 2019 10:08:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 8/9] exec.c: Factor out core logic of check_watchpoint() 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We want to perform the same checks in probe_write() to trigger a cpu exit before doing any modifications. We'll have to pass a PC. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- exec.c | 23 +++++++++++++++++------ include/hw/core/cpu.h | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index 1df966d17a..d233a4250b 100644 --- a/exec.c +++ b/exec.c @@ -2810,12 +2810,10 @@ static const MemoryRegionOps notdirty_mem_ops =3D { }, }; =20 -/* Generate a debug exception if a watchpoint has been hit. */ -static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int fl= ags) +void cpu_check_watchpoint(CPUState *cpu, vaddr vaddr, int len, + MemTxAttrs attrs, int flags, uintptr_t ra) { - CPUState *cpu =3D current_cpu; CPUClass *cc =3D CPU_GET_CLASS(cpu); - target_ulong vaddr; CPUWatchpoint *wp; =20 assert(tcg_enabled()); @@ -2826,7 +2824,7 @@ static void check_watchpoint(int offset, int len, Mem= TxAttrs attrs, int flags) cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); return; } - vaddr =3D (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; + vaddr =3D cc->adjust_watchpoint_address(cpu, vaddr, len); QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (cpu_watchpoint_address_matches(wp, vaddr, len) @@ -2851,11 +2849,14 @@ static void check_watchpoint(int offset, int len, M= emTxAttrs attrs, int flags) if (wp->flags & BP_STOP_BEFORE_ACCESS) { cpu->exception_index =3D EXCP_DEBUG; mmap_unlock(); - cpu_loop_exit(cpu); + cpu_loop_exit_restore(cpu, ra); } else { /* Force execution of one insn next time. */ cpu->cflags_next_tb =3D 1 | curr_cflags(); mmap_unlock(); + if (ra) { + cpu_restore_state(cpu, ra, true); + } cpu_loop_exit_noexc(cpu); } } @@ -2865,6 +2866,16 @@ static void check_watchpoint(int offset, int len, Me= mTxAttrs attrs, int flags) } } =20 +/* Generate a debug exception if a watchpoint has been hit. */ +static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int fl= ags) +{ + CPUState *cpu =3D current_cpu; + vaddr vaddr; + + vaddr =3D (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; + cpu_check_watchpoint(cpu, vaddr, len, attrs, flags, 0); +} + /* Watchpoint access routines. Watchpoints are inserted using TLB tricks, so these check for a hit then pass through to the normal out-of-line phys routines. */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 77fca95a40..3a2d76b32c 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1070,6 +1070,8 @@ static inline bool cpu_breakpoint_test(CPUState *cpu,= vaddr pc, int mask) return false; } =20 +void cpu_check_watchpoint(CPUState *cpu, vaddr vaddr, int len, + MemTxAttrs attrs, int flags, uintptr_t ra); int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, int flags, CPUWatchpoint **watchpoint); int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, --=20 2.21.0 From nobody Fri May 3 11:25:54 2024 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566555236; cv=none; d=zoho.com; s=zohoarc; b=KrQ9VoTCZUCe36YDnb+u+oANYQL4QIrdcUnjuGwH9NXonWYZC7Dyap7iwrelz/rQItrODTLIjZecUMeplzcaENojOxwrvBjAk+JvGQvZvHoi9tE0IPtxQcYa/Fs0FlUQm5+bKLsJo8G9nCiEXhl+cIB7qeIAvBghtBTnp6uMv3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566555236; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9DkzO5EVo5Zpvnn/CcsbtVx6IuoXeMOH5OJNuQ0luyE=; b=i8JQr71ytqbZixPwuaeaS/rJX9ltOKOiW552kmxn0lMzLS+YL1wUdQGOJamIYGTgWd7lYB8JD0jRhzK0U3CiLUupIxSkVc5IUsPJKMpmLIAk/N2as0Tmee4hW/vj7OiRN2NeXYvQ4KdkTCGZFLJxDCr+/DEf/vKVSGJOY3J2op4= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1566555236370645.4353799066032; Fri, 23 Aug 2019 03:13:56 -0700 (PDT) Received: from localhost ([::1]:53740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16Zv-0005Z8-6y for importer@patchew.org; Fri, 23 Aug 2019 06:13:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58584) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16UX-0006s8-Pc for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16UW-0008KE-Kg for qemu-devel@nongnu.org; Fri, 23 Aug 2019 06:08:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59531) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i16UW-0008Jl-FF; Fri, 23 Aug 2019 06:08:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B71BC30832DC; Fri, 23 Aug 2019 10:08:19 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C9B85D6B2; Fri, 23 Aug 2019 10:08:16 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 23 Aug 2019 12:07:41 +0200 Message-Id: <20190823100741.9621-10-david@redhat.com> In-Reply-To: <20190823100741.9621-1-david@redhat.com> References: <20190823100741.9621-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 23 Aug 2019 10:08:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 9/9] tcg: Check for watchpoints 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: Thomas Huth , Riku Voipio , Eduardo Habkost , David Hildenbrand , Aleksandar Rikalo , Cornelia Huck , Richard Henderson , Aleksandar Markovic , qemu-s390x@nongnu.org, Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's check for write watchpoints. We'll want to do something similar for probe_read() in the future (once we introduce that). Suggested-by: Richard Henderson Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- accel/tcg/cputlb.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 4b49ccb58a..8382ac2fc2 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1063,6 +1063,7 @@ void probe_write(CPUArchState *env, target_ulong addr= , int size, int mmu_idx, { uintptr_t index =3D tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); + target_ulong tlb_addr; =20 g_assert(-(addr | TARGET_PAGE_MASK) >=3D size); =20 @@ -1071,8 +1072,23 @@ void probe_write(CPUArchState *env, target_ulong add= r, int size, int mmu_idx, if (!VICTIM_TLB_HIT(addr_write, addr)) { tlb_fill(env_cpu(env), addr, size, MMU_DATA_STORE, mmu_idx, retaddr); + /* TLB resize via tlb_fill may have moved the entry. */ + entry =3D tlb_entry(env, mmu_idx, addr); } } + + if (!size) { + return; + } + tlb_addr =3D tlb_addr_write(entry); + + /* Watchpoints for this entry only apply if TLB_MMIO was set. */ + if (tlb_addr & TLB_MMIO) { + MemTxAttrs attrs =3D env_tlb(env)->d[mmu_idx].iotlb[index].attrs; + + cpu_check_watchpoint(env_cpu(env), addr, size, attrs, BP_MEM_WRITE, + retaddr); + } } =20 void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, --=20 2.21.0