From nobody Mon Sep 29 07:33:52 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551442548139201.51976637257928; Fri, 1 Mar 2019 04:15:48 -0800 (PST) Received: from localhost ([127.0.0.1]:36562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzh4o-0003dA-1i for importer@patchew.org; Fri, 01 Mar 2019 07:15:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzglG-0003ow-Kc for qemu-devel@nongnu.org; Fri, 01 Mar 2019 06:55:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzglF-0006zL-O3 for qemu-devel@nongnu.org; Fri, 01 Mar 2019 06:55:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15840) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzglF-0006yw-Hb; Fri, 01 Mar 2019 06:55:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA2B789C41; Fri, 1 Mar 2019 11:55:28 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-149.ams2.redhat.com [10.36.117.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id 012F55C1B5; Fri, 1 Mar 2019 11:55:23 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 1 Mar 2019 12:54:08 +0100 Message-Id: <20190301115413.27153-28-david@redhat.com> In-Reply-To: <20190301115413.27153-1-david@redhat.com> References: <20190301115413.27153-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 01 Mar 2019 11:55:28 +0000 (UTC) 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 v2 27/32] s390x/tcg: Provide probe_write helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , David Hildenbrand , Thomas Huth , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of checking e.g. the first access on every touched page, we should check the actual access, otherwise we might get false positives when Low Address Protection (LAP) is active. As probe_write() can only deal with accesses to one page, we have to loop. Use i64 for the length, although not needed - easier to reuse TCG temps we already have in the translation functions where this will be used. Also allow it to be used from other helpers. Signed-off-by: David Hildenbrand --- target/s390x/helper.h | 1 + target/s390x/internal.h | 2 ++ target/s390x/mem_helper.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 577edb384f..e2710f4fb3 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -123,6 +123,7 @@ DEF_HELPER_4(cu42, i32, env, i32, i32, i32) DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32) DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env) DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env) +DEF_HELPER_FLAGS_3(probe_write_access, TCG_CALL_NO_WG, void, env, i64, i64) =20 /* =3D=3D=3D Vector Support Instructions =3D=3D=3D */ DEF_HELPER_FLAGS_4(vll, TCG_CALL_NO_WG, void, env, ptr, i64, i64) diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 7baf0e2404..848d6c36d0 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -386,6 +386,8 @@ void ioinst_handle_sal(S390CPU *cpu, uint64_t reg1, uin= tptr_t ra); =20 /* mem_helper.c */ target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr); +void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len, + uintptr_t ra); =20 =20 /* mmu_helper.c */ diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index a506d9ef99..efd5256ebf 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2623,3 +2623,24 @@ uint32_t HELPER(cu42)(CPUS390XState *env, uint32_t r= 1, uint32_t r2, uint32_t m3) return convert_unicode(env, r1, r2, m3, GETPC(), decode_utf32, encode_utf16); } + +void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len, + uintptr_t ra) +{ +#ifndef CONFIG_USER_ONLY + /* test the actual access, not just any access to the page due to LAP = */ + while (len) { + uint64_t curlen =3D MIN(TARGET_PAGE_SIZE - (addr % TARGET_PAGE_SIZ= E), + len); + + probe_write(env, addr, curlen, cpu_mmu_index(env, false), ra); + addr =3D wrap_address(env, addr + curlen); + len -=3D curlen; + } +#endif +} + +void HELPER(probe_write_access)(CPUS390XState *env, uint64_t addr, uint64_= t len) +{ + probe_write_access(env, addr, len, GETPC()); +} --=20 2.17.2