From patchwork Mon Feb 20 03:23:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655039 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1179931wrc; Sun, 19 Feb 2023 19:25:07 -0800 (PST) X-Google-Smtp-Source: AK7set8+tWn9tfw571lzz7IDjzctIhA9WAmpwtLzzF5VuAAF8zuTSaqhJXc7sPk7Dm7tAERDZ5PH X-Received: by 2002:ac8:7d8d:0:b0:3b9:a641:aa66 with SMTP id c13-20020ac87d8d000000b003b9a641aa66mr11053305qtd.15.1676863507045; Sun, 19 Feb 2023 19:25:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676863507; cv=none; d=google.com; s=arc-20160816; b=Svhk/OKQ2ouE0K+n62gE/JCOF3ZR/vYWQKQB1F5maex3sdnCexgpEYHny/zWGBxLbd OCTLilrLTHVytkqks7xAemvhQNyhjeIi+qD1c3iifMg+v3u02oVcZM8Pe1rKIeTqUwxt iHDKzJztIgz2JVtIMIbmVq/wpwpGnopvmJhqP91A93cH+sC9vpKz5elP4OolB1mJTTlU +YZtOn4mHI3U8ajcIv6D1A5+pdetd6vOX+mxUWydSipKhUx0lZZkwuM3o6t5jkw2P03P Ze5jQpnNxMxvXFKPztPi2RhN5zVQEvEjVEAoW4v0UM1L4sAfsaUMG5m52Gy0PvhIcnLr s/Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=gmPWamcS039ttvGx+0lkOqlpPNASpmKk9ydxcZXcCPQ=; b=SpWg2EqJtXvToL8XrFc4Kz1Pe81nWEVk3IqDMDATdCxuQz0j3F0nOr81ZFDn7YlVz8 oocGWiztYF868TqkKaSYIGgUTPz73aj/MIQYoPRuWVgMZhM4x6Q1lQIaEKMLNpYC9Q4r 31m09qoh/Y8Qwc+vFIWd/flcZRD0JHgO4PFLSVE/C4NZpWdZgSskoNUGGYoc+LGmEBb5 zqIVm6jVQISjOA1IPswQHxiQgEqoOWxnuqaE4e7HT40Om0VFT+FUs8yuUjX4b74InmoZ 2SFf2vBENGDimpSgtGv9CY1ZIlN5rkiJUz9VmjgEqivQ7z1+aNT+g4soo0B1i6nCNwYX WxYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NqcROCFo; 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 6-20020ac84e86000000b003b82eb6578esi9325616qtp.138.2023.02.19.19.25.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Feb 2023 19:25:07 -0800 (PST) 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=NqcROCFo; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pTwmN-00019i-Bf; Sun, 19 Feb 2023 22:23:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTwmL-00018v-7z for qemu-devel@nongnu.org; Sun, 19 Feb 2023 22:23:49 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pTwmJ-0005px-O4 for qemu-devel@nongnu.org; Sun, 19 Feb 2023 22:23:48 -0500 Received: by mail-pj1-x102f.google.com with SMTP id e13so1903631pjt.4 for ; Sun, 19 Feb 2023 19:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gmPWamcS039ttvGx+0lkOqlpPNASpmKk9ydxcZXcCPQ=; b=NqcROCFoPy2d/NxUlGPdbaV3r1FHLet8VoX4MJnu0AjqJPDI5ChfBjIkP9/2sFqYEg OH9aNk+6QNLg0IVH38vdfLwjMXoVAhn8l6T725mlINHdXpVZSXFYeY788DCW9OqWwbXT QwvSWLNwEFgTfpDfrXIvcqnt3vwaSNwbeYIF9I9obPApQRrulukmBaeV35uGr8zl+cBB pSQvacDZ2dCLU792gYRYJHAxx7Rz0CxdRc4XokGKne5zva4zZKpIiAt/ka8Rp8eFF5fX 98sGX5RqdEP94mLrSfhQobQFx/r56jx3VtHOZ5kVUe2JS/RZItRoAvDAROZDp3Qnr5zj VpBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gmPWamcS039ttvGx+0lkOqlpPNASpmKk9ydxcZXcCPQ=; b=fi5Yt/dGcIV5XIrOl0YYJn6GUAZDNVwRgKWfMTlimug/mCETHJP6sxpYSj3d1//5Th /mK38u6yYFUMn1GzWMi5rYGcGOddyd3aWoEE4x8MkyYp49K75PjdMbHkjej11Gac4YlQ ElW9VyNYkCY94e7SEsmThOiAbqVMc/0rM69xY9zFZomkPRfMSrBaUQMuNDz4m5/SdCJ/ GcCeIGzwlJNvYsZzqYj1YKUkKpqeHuGYNf92RiXNcAQO/5Hltn1HwUpPTGfHTUjk5aTF UdZK7ViqcSQdprqgkykzXXJtTqI2b+SNW1ZxyDgRfJCq4MQn/XS7wKooi3N8yFPpumoL izlg== X-Gm-Message-State: AO0yUKUeIjNRm2JbqJJnlXQ6mS68fezwnThANToIwff5YRySy0rQo3Qn IJyaFB5YSWKuZ70jHoH3nJsUbWHqG3LsIbxF7io= X-Received: by 2002:a17:902:d4c3:b0:19c:17d1:28a4 with SMTP id o3-20020a170902d4c300b0019c17d128a4mr412493plg.67.1676863426206; Sun, 19 Feb 2023 19:23:46 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id l11-20020a170902d34b00b00198e1bc9d83sm6621302plk.266.2023.02.19.19.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 19:23:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Sid Manning , =?utf-8?q?J?= =?utf-8?q?=C3=B8rgen_Hansen?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 1/7] accel/tcg: Allow the second page of an instruction to be MMIO Date: Sun, 19 Feb 2023 17:23:32 -1000 Message-Id: <20230220032338.5619-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220032338.5619-1-richard.henderson@linaro.org> References: <20230220032338.5619-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org If an instruction straddles a page boundary, and the first page was ram, but the second page was MMIO, we would abort. Handle this as if both pages are MMIO, by setting the ram_addr_t for the first page to -1. Reported-by: Sid Manning Reported-by: Jørgen Hansen Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- accel/tcg/translator.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index ef5193c67e..1cf404ced0 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -176,8 +176,16 @@ static void *translator_access(CPUArchState *env, DisasContextBase *db, if (host == NULL) { tb_page_addr_t phys_page = get_page_addr_code_hostp(env, base, &db->host_addr[1]); - /* We cannot handle MMIO as second page. */ - assert(phys_page != -1); + + /* + * If the second page is MMIO, treat as if the first page + * was MMIO as well, so that we do not cache the TB. + */ + if (unlikely(phys_page == -1)) { + tb_set_page_addr0(tb, -1); + return NULL; + } + tb_set_page_addr1(tb, phys_page); #ifdef CONFIG_USER_ONLY page_protect(end);