From patchwork Sat May 12 05:02:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135639 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1760414lji; Fri, 11 May 2018 22:14:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrb1IkRvrO8M0XaUa9VkQX84JBRNjGEvmRhoGFnKj/iAaUPKhA4bwTjy880P15YDOXA552t X-Received: by 2002:ac8:d1:: with SMTP id d17-v6mr822559qtg.356.1526102057033; Fri, 11 May 2018 22:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526102057; cv=none; d=google.com; s=arc-20160816; b=DHiPmKV8cBkirkEz2odAYg7bmSzrC3ZElcmwNjodHfhyH9LEEx7y8eMfbLuKRh5s7Y hO8rsWuMGcMgycGPab59voiHIWnkcsVbPG3+ExEfFAGEBXzKYept8/XFHM6//l9nEy8H +StD48Tlu7EbTfgFZHoLajBAb16cBo4nYzBuikCpGcsIlQsGYyZ3NTa+E966YVX3K8R+ F5AAFe4a9m1dScg9Yz510ooUzt7vIZOaSAKnrPzJNuQk5jjwDYQbxqHl8e3H6Iqp0HVv 14S0WgaWpRPWvfZY15yC81cGV2T954nVKFZsFH9HFN73Sdl35DjbUVepGkXKwcec6UNS GBiw== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=0mECzgDVo12qmCSM432Ob3SIFDVRUdbq2Ys26U/zmIE=; b=fMlU3rDsNahz/VinkNX7n+cDJl1VC7hb2Ct7pFR2uK6HFRSBZqwIHte3i4n8jhb/tC wQlvFNqtTQE2NyC7E4B53u7gNOQNUkUc8HWc+4biNSglAnIiSLMtSxzlCRpXxjwynLVb jKB752+zDxYeKjJ0JzNgO2Bh6seoTMmpdyKCO17d20IlDHscd050cifYXqB64jMHZTqj wM2eBqRXzORtKPt7Y8F3SJJA3NnIM2IR4iddn7JHWu3rfJiw6Y7xYD8ONIuQbyLueAQ9 M2a8d2O9fPOtWOUkJAMU6nf50wpJuOx26F2440m7bxeWatDGy2Yvgm+/scuI8UvqS8GT NYMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UoiYZNKJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h12-v6si1406826qte.291.2018.05.11.22.14.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 11 May 2018 22:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UoiYZNKJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHMrI-0008Sz-BV for patch@linaro.org; Sat, 12 May 2018 01:14:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHMgS-00042c-HT for qemu-devel@nongnu.org; Sat, 12 May 2018 01:03:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHMgR-0008NF-Q2 for qemu-devel@nongnu.org; Sat, 12 May 2018 01:03:04 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:38189) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fHMgR-0008N5-LB for qemu-devel@nongnu.org; Sat, 12 May 2018 01:03:03 -0400 Received: by mail-pl0-x241.google.com with SMTP id c11-v6so4380232plr.5 for ; Fri, 11 May 2018 22:03:03 -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=0mECzgDVo12qmCSM432Ob3SIFDVRUdbq2Ys26U/zmIE=; b=UoiYZNKJXEhOeYi5bknN/SOO73/sVaiuhsla8R24GvCN0k89SA3w7/CTxSF26wXjcT PQv9QmldA8xD+bkWlosUm/j4ifVnHnFsokrfS/4c2X+xCPnahIigAUAhASMd0aI74w8y 0etSLBZvBVTCw13MKcz8Hu3OksFMcSdGaedac= 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=0mECzgDVo12qmCSM432Ob3SIFDVRUdbq2Ys26U/zmIE=; b=M9uaDpWqSm5LIn2Aomwbo398KWxFwj2AFWgJG9bq+esvj0hVmxnISuEq0UmrYPZjAn QSWUnZYeWjpiQXCO8zWHBb9UCxwgmCCcPnr2jczhg8IE74IU8JvFzrbBcZXLa8DkuVIE IP1aDEg5H79Q3Xk4xWQ34vYvMaO8V1BvjLeVcPBvK3hCy0Mn1Y6IMoUseYnY7RQCAGWE APQTc/ReHSt6aNvLHGKtyK59v3qrgnxCXaChPH1/lFDasv9ddPlaki8kX0lIFmVdZAGQ ri38P7niDQBO9Oc5GovbJcNOr7EEQ6LpQVyPU+O112i3kJdq+tVliA75KUUoN5s3Cbxd AigQ== X-Gm-Message-State: ALKqPwfCVYYpsgF61Mk03P9HQE1turfIwiRWkSeW/EE9JIlsLscbk0kE bMYja1wG/5+4aMQyVYAQzK/zB3ASIFk= X-Received: by 2002:a17:902:82c3:: with SMTP id u3-v6mr1002638plz.83.1526101382367; Fri, 11 May 2018 22:03:02 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id x124-v6sm8999945pfx.72.2018.05.11.22.03.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 22:03:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 11 May 2018 22:02:49 -0700 Message-Id: <20180512050250.12774-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180512050250.12774-1-richard.henderson@linaro.org> References: <20180512050250.12774-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH 8/9] target/m68k: Improve ending TB at page boundaries 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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than limit total TB size to PAGE-32 bytes, end the TB when near the end of a page. This should provide proper semantics of SIGSEGV when executing near the end of a page. Signed-off-by: Richard Henderson --- target/m68k/translate.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) -- 2.17.0 diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 0ab9ab1148..069558bc28 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -6105,9 +6105,25 @@ static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) disas_m68k_insn(cpu->env_ptr, dc); dc->base.pc_next = dc->pc; - if (dc->base.is_jmp == DISAS_NEXT - && dc->pc - dc->base.pc_first >= TARGET_PAGE_SIZE - 32) { - dc->base.is_jmp = DISAS_TOO_MANY; + if (dc->base.is_jmp == DISAS_NEXT) { + /* Stop translation when the next insn might touch a new page. + * This ensures that prefetch aborts at the right place. + * + * We cannot determine the size of the next insn without + * completely decoding it. However, the maximum insn size + * is 32 bytes, so end if we do not have that much remaining. + * This may produce several small TBs at the end of each page, + * but they will all be linked with goto_tb. + * + * ??? ColdFire maximum is 4 bytes; MC68000's maximum is also + * smaller than MC68020's. + */ + target_ulong start_page_offset + = dc->pc - (dc->base.pc_first & TARGET_PAGE_MASK); + + if (start_page_offset >= TARGET_PAGE_SIZE - 32) { + dc->base.is_jmp = DISAS_TOO_MANY; + } } }