From patchwork Sat Jun 30 19:50:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10498395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C205960284 for ; Sat, 30 Jun 2018 19:51:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3D4628ADD for ; Sat, 30 Jun 2018 19:51:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 934F728DC9; Sat, 30 Jun 2018 19:51:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2809828ADD for ; Sat, 30 Jun 2018 19:50:59 +0000 (UTC) Received: from localhost ([::1]:47818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZLtb-0004na-Al for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Jun 2018 15:50:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZLsr-0004SH-FW for qemu-devel@nongnu.org; Sat, 30 Jun 2018 15:50:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZLsq-0005rJ-Hd for qemu-devel@nongnu.org; Sat, 30 Jun 2018 15:50:13 -0400 Received: from mail-yb0-x244.google.com ([2607:f8b0:4002:c09::244]:38723) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZLso-0005mb-DG; Sat, 30 Jun 2018 15:50:10 -0400 Received: by mail-yb0-x244.google.com with SMTP id i9-v6so167316ybo.5; Sat, 30 Jun 2018 12:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=uevaR0c3s5khKIL7C5+toq2rbeGGbh0vvyRBNQUT5II=; b=cuUiFeZGAwYqULPE1UxyypXwWx121F81Hqg+yFfjJGISlpsWzXBHHITzuNX4J1YICJ XtkU2flxrW9+/7EUanMMccVYQdC5EF4cWm6mYknWPrL9iHmQVJpb8MV4/dNIjgmjqVDO i8q9zCIaJbZo64PxrvGY4zjNfmH95xritf8x1LGUs4x9NDyf+JW/FyHViMALekjUhH9t 55gd25LnjkMWcDBkQ95zbYd13Lo779AaB2FuVIYKoxNa0KvszeN/hVbugeeKDwh1XuFN 01W4s02wFudQyqdezIHf4tE7jZ1m5P5eIBKyRU1gC5u4xLIeTPGqbsXhGD95FtcKksHX ZMsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=uevaR0c3s5khKIL7C5+toq2rbeGGbh0vvyRBNQUT5II=; b=H+kLa6K6uuff724IuPtUbYh9LN0GImeeZOmrEuW+AGOx9I/5SZZUF2iW8wFjU7+wHJ usrZkidmC6uwTeF8VBo+oBDfFVYQTQJ1V5EpBU7WpQSmy+nGzC3zFWhpk560NgDFuQqq l+lsL5nL+Ki12HXKDurYwgdhOcNW0bb6rEGeoez3YALBuIZzZ7n1hXxGirV1MjSoO/o2 c9KakTLcJwpjIqP3tg6jS2ytUjx/2QrkEBCxNFxDcBPYyfvRgfo86B8T+a2FrmATxAEh vR8YqzQKkcNL11aiJds9aF75FpQm4EYHT7U43q4yKTeoNTiw00unpPq4iWErAxnyBYgB QIsw== X-Gm-Message-State: APt69E2Mc5sBmv2Us2mHLx8qhWff1YT+cqgJr/q1aRwWMSA+P3gSHg2t fj7/wQZp9hPFV48mMH6a/U3hH9GPBeRB3em8nhY= X-Google-Smtp-Source: ADUXVKKIYyLVHaK92mU9E7sxiDD7nQIrLoCN8sarx2pbCsIDk9lBa7mwRX7xoQrXEVXV6aXycf0pZrXEUBpblieKG1A= X-Received: by 2002:a25:7045:: with SMTP id l66-v6mr10110554ybc.278.1530388209701; Sat, 30 Jun 2018 12:50:09 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:620b:0:0:0:0:0 with HTTP; Sat, 30 Jun 2018 12:50:09 -0700 (PDT) In-Reply-To: References: <20180620130619.11362-1-peter.maydell@linaro.org> <20180620130619.11362-2-peter.maydell@linaro.org> From: Max Filippov Date: Sat, 30 Jun 2018 12:50:09 -0700 Message-ID: To: Peter Maydell X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c09::244 Subject: Re: [Qemu-devel] [PATCH 1/3] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE 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: Patch Tracking , Laurent Vivier , qemu-devel , qemu-arm , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Sat, Jun 30, 2018 at 12:42 PM, Max Filippov wrote: > On Sat, Jun 30, 2018 at 12:20 PM, Max Filippov wrote: >> Hi Peter, >> >> On Wed, Jun 20, 2018 at 6:06 AM, Peter Maydell wrote: >>> Add support for MMU protection regions that are smaller than >>> TARGET_PAGE_SIZE. We do this by marking the TLB entry for those >>> pages with a flag TLB_RECHECK. This flag causes us to always >>> take the slow-path for accesses. In the slow path we can then >>> special case them to always call tlb_fill() again, so we have >>> the correct information for the exact address being accessed. >>> >>> This change allows us to handle reading and writing from small >>> regions; we cannot deal with execution from the small region. >>> >>> Signed-off-by: Peter Maydell >>> --- >>> accel/tcg/softmmu_template.h | 24 ++++--- >>> include/exec/cpu-all.h | 5 +- >>> accel/tcg/cputlb.c | 131 +++++++++++++++++++++++++++++------ >>> 3 files changed, 130 insertions(+), 30 deletions(-) >> >> I'm observing the following failure with xtensa tests: >> >> (qemu) qemu: fatal: Unable to handle guest executing from RAM within a >> small MPU region at 0xd0000804 >> >> Bisection points to this patch. Any idea what happened? > > Ok, I think I've found the issue: the following check in the > get_page_addr_code does not work correctly when -1 is in the > addr_code in the QEMU TLB: > > if (unlikely(env->tlb_table[mmu_idx][index].addr_code & TLB_RECHECK)) > > tlb_set_page_with_attrs sets addr_code to -1 in the TLB entry > when the translation is not executable. Looks like it can be fixed with the following: || memory_region_is_romd(section->mr)) { diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index eebe97dabb75..633cffe9ed74 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -692,16 +692,16 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, if (prot & PAGE_READ) { tn.addr_read = address; } else { - tn.addr_read = -1; + tn.addr_read = TLB_INVALID_MASK; } if (prot & PAGE_EXEC) { tn.addr_code = code_address; } else { - tn.addr_code = -1; + tn.addr_code = TLB_INVALID_MASK; } - tn.addr_write = -1; + tn.addr_write = TLB_INVALID_MASK; if (prot & PAGE_WRITE) { if ((memory_region_is_ram(section->mr) && section->readonly)