From nobody Mon May 13 18:06:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1661231298; cv=none; d=zohomail.com; s=zohoarc; b=HqUgm1A0MKfFVKYq63eOdxoMRbcLDK3T3heJdfT8fD/ysCVulfxf2qKPfyBZrrOa3dPxBmDjfx0TQh7SUKSqI0yV7sdHxu19cQO1Ky0vjER2CQw31m+T8nssJUggDPdVi7RduQ7D2aKBT/UGRNbPfDlb3ltFLD/6fNP2qZ3LV6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661231298; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=mh6VD9+NmPpNJNVxmmFo/NsX15XKX/3v0VM+jweJJVA=; b=PuVXq8a3wbFxU7xsf02xFtHZFccheiAkDXRCp2DJfCcCAP8ZXbiQMM5vOneo12/xtp86RSFFj6n1FkyYdRGDuy9tHe8fNnPea4UaWxZz1rERqszATi7aKzTx4ETHKUJLz58t9f8+WylT/sYtXyf+2RazC77OhkdFJIbRGjNxDE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661231297969364.82917985693314; Mon, 22 Aug 2022 22:08:17 -0700 (PDT) Received: from localhost ([::1]:59318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQM9A-0004NY-4N for importer@patchew.org; Tue, 23 Aug 2022 01:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQM8K-0003i7-VM for qemu-devel@nongnu.org; Tue, 23 Aug 2022 01:07:24 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:45021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQM8I-0006YM-K2 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 01:07:24 -0400 Received: by mail-pj1-x1032.google.com with SMTP id r15-20020a17090a1bcf00b001fabf42a11cso13481704pjr.3 for ; Mon, 22 Aug 2022 22:07:21 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:c3f1:b74f:5edd:63af]) by smtp.gmail.com with ESMTPSA id q5-20020aa79825000000b005364c8786b7sm5712930pfl.215.2022.08.22.22.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 22:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=mh6VD9+NmPpNJNVxmmFo/NsX15XKX/3v0VM+jweJJVA=; b=M+AEXl79MhJWUiZ2Iry+QGsl8aqT0HGou8ajKhZmP0p83PWu3lVYEJAHGzl0R4XuD0 3Pi3lQ2cfg8DgQglwIOTqAMQKnLBOyTL/PP07I38xebUPLzBxNX4h/5y/KC4GasXiTo8 omRC/ls8iPxieXGJbohLGAXeUMoNtL3R/0jAiJaG+JI39/TkPOqcw0Ok/p8z2EMvVfjk v4RUPzXJkRQza66sjTxWUtg0phCuUsGKj7hKYV4g6iK8b6xw8lyIlAWvLFq+QEpWiyhW GyrDviNhEDhSOHApuD2G5JE8b2LxKUDEaGjDegyF30JLtC4J9qa3UgaY3xuEIkMj3pr7 IVtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=mh6VD9+NmPpNJNVxmmFo/NsX15XKX/3v0VM+jweJJVA=; b=feQrQbmf1gCDZNv72/UPb0rougATK5XhHvJKXbKogLcyKshGwa1px2SXaqCcc4V/ua Ayi0eeZrMKUH6QfwSr6jZA2me58cGJEVHxZCKShl/YLZ4Mm2dbzXVi2cA86koUtqKCHY jKhEKp3JzH/RLJMFvjPkrqQq1wkwnrh+CRI4Jdu/8bTNqettSiDHJUyCM8Tp9CL2d7SJ 1cHj+y4xK/ImrtI2reF+k7ilrDdgs0GPmH7iwRVaMT2+LzpTE1bjZRftCyolzj8qun8Z Yij7bgzWTfhb47A7Ji1SZuoxl3TIEZIt3mqMxlQmimvIZj415x4bw4rdJpKGhfTUAXKJ Fj/Q== X-Gm-Message-State: ACgBeo1nhkHzvMwQlRAyBDNsP8WPfhCqVgIp1JJ1pqnS8jNmjjceax+u AFzItE1XAL5L/+PN53m2g+Xpfdbu9DLZXA== X-Google-Smtp-Source: AA6agR41teQ6d0ieL5ZVocX1XNbwRa+D2FQOppR7pEZZyKUYzWaUbMymS4EiUlUTgHVvhuZWjv70AQ== X-Received: by 2002:a17:903:110f:b0:171:3afa:e688 with SMTP id n15-20020a170903110f00b001713afae688mr23169761plh.162.1661231240822; Mon, 22 Aug 2022 22:07:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mrolnik@gmail.com Subject: [PATCH] target/avr: Support probe argument to tlb_fill Date: Mon, 22 Aug 2022 22:07:18 -0700 Message-Id: <20220823050718.1930676-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1661231300550100001 Content-Type: text/plain; charset="utf-8" While there are no target-specific nonfaulting probes, generic code may grow some uses at some point. Note that the attrs argument was incorrect -- it should have been MEMTXATTRS_UNSPECIFIED. Just use the simpler interface. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/avr/helper.c | 46 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/target/avr/helper.c b/target/avr/helper.c index db76452f9a..82284f8997 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -102,38 +102,50 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, in= t size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - int prot =3D 0; - MemTxAttrs attrs =3D {}; + int prot, page_size =3D TARGET_PAGE_SIZE; uint32_t paddr; =20 address &=3D TARGET_PAGE_MASK; =20 if (mmu_idx =3D=3D MMU_CODE_IDX) { - /* access to code in flash */ + /* Access to code in flash. */ paddr =3D OFFSET_CODE + address; prot =3D PAGE_READ | PAGE_EXEC; - if (paddr + TARGET_PAGE_SIZE > OFFSET_DATA) { + if (paddr >=3D OFFSET_DATA) { + /* + * This should not be possible via any architectural operation= s. + * There is certainly not an exception that we can deliver. + * Accept probing that might come from generic code. + */ + if (probe) { + return false; + } error_report("execution left flash memory"); abort(); } - } else if (address < NUMBER_OF_CPU_REGISTERS + NUMBER_OF_IO_REGISTERS)= { - /* - * access to CPU registers, exit and rebuilt this TB to use full a= ccess - * incase it touches specially handled registers like SREG or SP - */ - AVRCPU *cpu =3D AVR_CPU(cs); - CPUAVRState *env =3D &cpu->env; - env->fullacc =3D 1; - cpu_loop_exit_restore(cs, retaddr); } else { - /* access to memory. nothing special */ + /* Access to memory. */ paddr =3D OFFSET_DATA + address; prot =3D PAGE_READ | PAGE_WRITE; + if (address < NUMBER_OF_CPU_REGISTERS + NUMBER_OF_IO_REGISTERS) { + /* + * Access to CPU registers, exit and rebuilt this TB to use + * full access in case it touches specially handled registers + * like SREG or SP. For probing, set page_size =3D 1, in order + * to force tlb_fill to be called for the next access. + */ + if (probe) { + page_size =3D 1; + } else { + AVRCPU *cpu =3D AVR_CPU(cs); + CPUAVRState *env =3D &cpu->env; + env->fullacc =3D 1; + cpu_loop_exit_restore(cs, retaddr); + } + } } =20 - tlb_set_page_with_attrs(cs, address, paddr, attrs, prot, - mmu_idx, TARGET_PAGE_SIZE); - + tlb_set_page(cs, address, paddr, prot, mmu_idx, page_size); return true; } =20 --=20 2.34.1