From patchwork Wed Feb 22 02:00:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655652 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp444264wrb; Tue, 21 Feb 2023 18:01:56 -0800 (PST) X-Google-Smtp-Source: AK7set+uY7FkV8RkcAydxKjygtmxlG1KTTCGb/1ydxhMgsPeKjLO5x04ulSSz7yCeiACd3AearoK X-Received: by 2002:ac2:4a9e:0:b0:4d8:6b96:dae8 with SMTP id l30-20020ac24a9e000000b004d86b96dae8mr2218593lfp.43.1677031316100; Tue, 21 Feb 2023 18:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677031316; cv=none; d=google.com; s=arc-20160816; b=OpZs42eYR34wXQREQNW/SIiMrr6Oi/9KPfZAXE1IgHhPwhJOJHySD2oWWxzrVAPMrJ QhDAEq7h+CXMOE1xnJdmoR/xa1RKIqFZrF0tvWI3Rcajv1QrKL7WVfbYiVqxs+KQ+xL3 dXLpKb42+3jXPXsL1pag5UxigpTxGFMMEgdPsO427InPFXqKV1S+y3CysPKuF1sKduUX tNg/mCtdx7UW+u0DOF+Je4JRrfrFSKmOecBlfBnPYPxCkrzSNQi2IMnAgqp7I01ZqK7C jNQFW+/xnkodkDQRBwoXVwX9i6cU5bkfgIQiGkXl5vlRtTiFLVDi8jbYsda6z3yUNs9N NBfg== 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=u2u3DT2AzHXHFHdlv6D/sLlqMwrF59knHyoLRdcOb+2pkikf2o92ZljlM1KLyUa/ET CBLfKZzhoqiUevfHtN0ia7MwJ3n9g+S6TQE1Sz3DNMsWldDGR7oWeNeHLKqYLXD8KdUW 8HcavZTKNGDvsYbLsfaQANnZ6tDTha8nh3svbm2C4Vx8CFYW1guf/OEA7YVs8n029Ibn l3Ly+0nFRuMMtZimcR+SX9DXXiQGD2/NInLOBX3jevNN7UXm01V8yhjnj5QUk8x1kI+0 6tdb4fnT/77BJZ8cl+a6P3AUb/rFHQ/dmLNU7hP78uNE1TMBp/+OLR+kEojnAS7q7fyL yuPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEBfDQSy; 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 d7-20020ac244c7000000b0049f54cb6253si9226162lfm.250.2023.02.21.18.01.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Feb 2023 18:01:56 -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=aEBfDQSy; 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 1pUeQs-00032m-Rh; Tue, 21 Feb 2023 21:00:34 -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 1pUeQp-00032D-J0 for qemu-devel@nongnu.org; Tue, 21 Feb 2023 21:00:31 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUeQn-00013C-Vy for qemu-devel@nongnu.org; Tue, 21 Feb 2023 21:00:31 -0500 Received: by mail-pl1-x629.google.com with SMTP id ko13so7785068plb.13 for ; Tue, 21 Feb 2023 18:00:29 -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=aEBfDQSyrYtobx8mlTuoJz7N2Sq/XYrHSVsHFCtoeIDUxKtH2fEtfso7pxE1H+/hN/ JX4YsKQrD/fQJ9lfSYAmK2OwX1r1BlvpQFxNAlMWZH/DO9gAqQDZ4FJjBJFWaTfQkyG3 AdGofU4T+bn1S1TRpAmhjfU5zgrc2OnB3nRkTJ+RGer832RbVJbIgi52m3NaeIBZsYJo 3LW4ac2ileLOxW3PXfYKBIRmN7JDOiFxxgjoAcFNgeanv7GajJZoJUa5OCfPUmDiVNTP yQkD4gFVoPb6w2ppojz4UN5UqX/GjSGPzUQL8E6crDUFj02VvuWZ3eybtC4PewPiPfOm NYlA== 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=YuZPeFAN934/8CA2ajMCqtsEa3DpOZtuMCxgxtbIkSlorZYzscfp2UzMvOwU4KfcZI LIVKMGGaDizdpt3DCBArTXpS5H9+uhdS6m8APlDZuAjNZGqcEP9ttdhZeJGOUFo/vrOU 2cXifxVeUB4hfVNDOf7U/aWR29+NvJYq+MpgMGAR3EzcXkSrx717aah0LLJttglr9H3S 65+yhHtRBXUOjlpyaf2K+uMoq8s7EhLkb9ZotZzSUfQfwbLVndcixoK+/Cj+7DPSE3kJ EiI01U/Nfs8/870src8sTQdo+BJwnpTdZhKYWIGzJfc9TjTPHwrTzRE/X8G5BqCYSymN 82Hg== X-Gm-Message-State: AO0yUKVPyySWYuEvVKn/P/amgnf/F2NFcDkZOr7xVkwZTxaIe8AvipXD 2xca82WtlFEEG6wd/cb8zbcT1fR/nC43amZgEHU= X-Received: by 2002:a17:903:284d:b0:19a:9943:17fe with SMTP id kq13-20020a170903284d00b0019a994317femr5976457plb.50.1677031227989; Tue, 21 Feb 2023 18:00:27 -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 2-20020a170902c10200b00189743ed3b6sm91468pli.64.2023.02.21.18.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 18:00:27 -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 v2 1/8] accel/tcg: Allow the second page of an instruction to be MMIO Date: Tue, 21 Feb 2023 16:00:16 -1000 Message-Id: <20230222020023.904232-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222020023.904232-1-richard.henderson@linaro.org> References: <20230222020023.904232-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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);