From patchwork Wed Jun 30 18:31:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 468712 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp606726jao; Wed, 30 Jun 2021 11:32:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzo2VE+2Sve1mioy3EQuxB6Z5KV4SDqxDOACmybIBW+BiBHXAWhRVJnYijN0TPqpQIxdP5l X-Received: by 2002:a17:907:16a2:: with SMTP id hc34mr1553553ejc.351.1625077971983; Wed, 30 Jun 2021 11:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625077971; cv=none; d=google.com; s=arc-20160816; b=n+/XBOFM6t8UJawpnpHICGOTWYGQay0ryuivNCWDtrUiZ0QrMOpr5H1bpPFtc/4ljv XKuUQjj6R1SqEzdItvqQhll+1LkA9Uff8M/9HGl+9wqAFlFzxqbmrsHC0fONFWqq0mdS VRypRjy+u6lpv8VqBfBF9Rknv9Asv6IVpkjzisgctmpEXG/ENbLDNTF3/35mQLq+3Unq sychgfZZW/dP6rVCtAkMG2AcR6mT/phzPB5J8nntvkFcWnR8HckbGFf+BsAMkmf2S4Tu GlGtko40tzGXjQuuyhvUmc5xY5lGRtFIrrCKNWlD7oHAfjLyxQgUxfISGIkuDeR3Owcs Fqww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=CYAA0gCcixaZvejCGIEmqi8brwY1zVT0feeRzB35ZxQ=; b=elPmoL9w1dPMbS8M6by5z5oQ5p3q7bKWiDHAJmUNAM3cZaorDHKjdD8A8Helch4bWG IwvEx8A07s8SDXxi/meZ2UhVBRoZhfsjsfhC3aRkJW3mCYtbRrZ++SqylxUQgw1dndOq ko/PJQ2I/VrbtGy6hKS+a7NatMGNWBD45/OY27CpTpIDfOJuOkKEJ4F5+iJhCrvBfnaA lhhyvX2Dcqs3XBXD/BVhwfaczYwjO+RmZGziV52psl7EzwIswmAWkzoLkZcND2fHmGH7 nsUgYSYccjqIYjz1lD0K7JGzYfBzuL/bHbKPTMsgLLADPHVR9ggDtDtJgbrLDYTy/j5i flEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oti2FHeC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q6si19658263edd.96.2021.06.30.11.32.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jun 2021 11:32:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oti2FHeC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyf10-00058F-TH for patch@linaro.org; Wed, 30 Jun 2021 14:32:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyf0j-00055S-JV for qemu-devel@nongnu.org; Wed, 30 Jun 2021 14:32:33 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:38586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyf0g-0001xN-Ml for qemu-devel@nongnu.org; Wed, 30 Jun 2021 14:32:33 -0400 Received: by mail-pg1-x534.google.com with SMTP id h4so3185397pgp.5 for ; Wed, 30 Jun 2021 11:32:29 -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 :mime-version:content-transfer-encoding; bh=CYAA0gCcixaZvejCGIEmqi8brwY1zVT0feeRzB35ZxQ=; b=oti2FHeChbI1wdzzHQpYrI5qRwC97GMusq3vx1fF+wKn3/9cNBzNADp8l9JErDQ8O1 7opXMsZRYEIV77sxm1NE/A0fm+G32LUzvC1UGZhwDV0QEHVQLkTHeyON3TCbx7zRJ75d lxOAp2SST30XuVGm3sqQnUwm4qRHnTy0uCg4JcmkahrgdzPGKarNq67W/KMp80/oQVn3 T4I4ytDBS2csvNQYORLHLQfO2xnQzFS1JmKjGZ1Vz3rl0fDinYyVZEIUHz9FdfAm+fql l72IECWa4tVXRy134jMqphdejHuP6atAED3QklzpmZDxf2rjrQm/X/Auy0NbcNPsIc3p cK6g== 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:mime-version:content-transfer-encoding; bh=CYAA0gCcixaZvejCGIEmqi8brwY1zVT0feeRzB35ZxQ=; b=drpEM36Xbqbd626B185L6KV+EQE30E82PWgCepaPIDD5CcpSa92kN1Y+vNyn2pOL9r i+9O3d+IX/T5gvs3UuTsm/tIOTPE5h6Jb92SHgFbpRB6W5O3OZBWa48vfXoFpPgQ+E1w PW2z2FkX46AM45baZ8hoZPb5yBGCUJK/ohm2X2SfIoDI8lUJiJDv6w1WVLOuVTyWkgmO dQf67ywXTSH8G9s+lf/ppEpRwj9gaOqvSegtB1IGE5T5Kcdj5GfKwP8jGKbsnWMhC+lG tOr/vTkFTWkV3eO8pn3mYnylOA/WCfisv6+QiP2O4Dcv9LJ0ke/KuBIXrE+8Wq81w2M/ lGSA== X-Gm-Message-State: AOAM530oqOQGBKea+fPbj5xfMS9GKMo+q2YsB/mZGsCQ+/JYSSve5Rna GSdmiUSzj+lqTm37vYp3+TK3c+qg3vbDig== X-Received: by 2002:a63:230c:: with SMTP id j12mr3607238pgj.382.1625077948664; Wed, 30 Jun 2021 11:32:28 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id m18sm23909517pff.88.2021.06.30.11.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 11:32:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 01/28] accel/tcg: Introduce translator_use_goto_tb Date: Wed, 30 Jun 2021 11:31:59 -0700 Message-Id: <20210630183226.3290849-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210630183226.3290849-1-richard.henderson@linaro.org> References: <20210630183226.3290849-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Max Filippov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add a generic version of the common use_goto_tb test. Various targets avoid the page crossing test for CONFIG_USER_ONLY, but that is wrong: mmap and mprotect can change page permissions. Reviewed-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/exec/translator.h | 10 ++++++++++ accel/tcg/translator.c | 11 +++++++++++ 2 files changed, 21 insertions(+) -- 2.25.1 diff --git a/include/exec/translator.h b/include/exec/translator.h index 24232ead41..dd9c06d40d 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -145,6 +145,16 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, void translator_loop_temp_check(DisasContextBase *db); +/** + * translator_use_goto_tb + * @db: Disassembly context + * @dest: target pc of the goto + * + * Return true if goto_tb is allowed between the current TB + * and the destination PC. + */ +bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest); + /* * Translator Load Functions * diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 1d32732198..59804af37b 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -31,6 +31,17 @@ void translator_loop_temp_check(DisasContextBase *db) } } +bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest) +{ + /* Suppress goto_tb in the case of single-steping. */ + if (db->singlestep_enabled || singlestep) { + return false; + } + + /* Check for the dest on the same page as the start of the TB. */ + return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0; +} + void translator_loop(const TranslatorOps *ops, DisasContextBase *db, CPUState *cpu, TranslationBlock *tb, int max_insns) {