From patchwork Thu Mar 21 15:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781562 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900037wrj; Thu, 21 Mar 2024 08:49:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUrgZL+VzZMrOr34Zf4mFGb4fpnOz64lrYQMJtF5lvNuMKWSnmDOsK5srWbFdzsr6Dma82aJPLNSN2p5I2XzzdD X-Google-Smtp-Source: AGHT+IFrFNBf6D8d+FtvVPh/M9EQWmVm3cfssH6/XlQXh8Z2PKigKJQnpSRMh1wy5g0mfriSIx3M X-Received: by 2002:ac8:5991:0:b0:430:9768:d0cd with SMTP id e17-20020ac85991000000b004309768d0cdmr5019545qte.56.1711036169901; Thu, 21 Mar 2024 08:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036169; cv=none; d=google.com; s=arc-20160816; b=uEjVRc9fOg02n9+qxxqMowikmsxApkXSCFEFJofBswl+6tUi0rzIc/FBbKYu6ILDx+ tjNJ17l2aIUn/5Ru1ENx+Jy/fI34EUfL3q/lnnuNjm5NIa3eWE5TAAAKAxrpM6OfGaC8 wXX+MVzX3kmN7XtiHmjAyJl0B0iVqezubMoG3/bZYwjW5w540Zq9NyuvLUGAaOQOn2nQ Fs3OpY3h2Xe82xSpGKOH4kuZhtkO3BbH17D5KWXQMdsnpBUI2xY2ToCvNrV7M90vWYnm rZ9gxe6n+covMoJcz510pNKYKLXvgjci0ginXp9OYsVvLE2VQ+kdayavHPOKfDheZYbC PhBg== 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=bTgCkgY7q586A21zu0JSDs5UTTpVyxNoAlIlHHAmSdk=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=P+VTuBzqhWRcIUVl/BLfZk47U+uHSQ3UtW7nGk+KtrSgLZdH80Vm/X45x40fI3M5qK glyKpM0HGHrJ7GMwPlz5HCzvR8f3i7Pyeedmpqqww3nUMnu3Ai/+Is6Lzc0fmOqxwWxu pUfXbJuj6AM8gy6WJY0xsg+3VUy9G4l5XTk69Cp3pMkB5XuDvLM+uZyN8EiqP1sDVk4j x5t+gwZrax2y5CJaE9NURb5dk2zg56tbvNrw8IHYcXY6zIV7pGeEXyhp4W6tQfyRgAa2 8BNhrASXbwpdeMCm14sI7NnycI+7eWqwBxiXFWJ//hV2EOPKAqsQoKHqCAUOhNbYkamJ jhYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d2jICh1d; 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 g1-20020ac85d41000000b00430cfc1c074si9436821qtx.304.2024.03.21.08.49.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:49:29 -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=d2jICh1d; 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 1rnKf3-0004Jn-AN; Thu, 21 Mar 2024 11:48:57 -0400 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 1rnKf1-0004JT-Iq for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:48:55 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKez-0001BU-Lb for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:48:55 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-41466e01965so7931095e9.3 for ; Thu, 21 Mar 2024 08:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036131; x=1711640931; darn=nongnu.org; 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=bTgCkgY7q586A21zu0JSDs5UTTpVyxNoAlIlHHAmSdk=; b=d2jICh1dd4XIjkMWk8imYmpKT9o4rOLdhDCls43AAKP3nsU9riB59s0ZTYeXFMY9dj FS0F7q8MMIxsR1dvd7n4pvSj0PORqRshsN9wiYCNwyNHME3hGoGIiPVX9FPF16X3kPFI 2ZE1ORKaloEMfv6+/wfpA5EurTUEeMDAzfRseHysj8mG+ujmy/HO8rMIH+TAOBZNx+05 Mb6RHetRCj2peiAKX/IgH5Y0YGZBHmKyD0OgqwgJ8v1Xc+n65CuYLzPX8SPJPvypByrE 8ag0DPjWoSYpDGROeS2Mza34EuAYjYeLurz4Y0a4kcLHqeAQP/7gNoSbCf/lyKS/g/Fi rkZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036131; x=1711640931; 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=bTgCkgY7q586A21zu0JSDs5UTTpVyxNoAlIlHHAmSdk=; b=xNNcF7V1MkV/6pw6mzeZzTncyizEb5mwLZh+xWh3Mj2ympw0c4TIj/OszloDtK70Uo HB4va3NVTswdObdhPii8EXrPG6qdDcpQC1dZxEH/fOWXUEqFHiTK4qvKpxDNI7TDh6BI TWDFlYlyeNufNqApNoy97g23ZtnYztz+iXfbaGsysaCSXdy7iZX8fd69dBbNuxDdavMg MH6dif4zXBo5pFtrKEvOiI4wpu8dvpMqVP0THSZ9eA5i8pmOv0nyzV6Sf/wZs4SiqNP6 14S6s4MxStkPIafBNtx5sOusZ3ifsYxwX9957dGVxHFMWljeptz25xKM+BhOUfMeFQjh tRTg== X-Gm-Message-State: AOJu0YxXup4WrKglA2WXN3pzkJEdO+Ma02hwniCCktgtIuMcuHukaZAw CCx5ivDF5GIrYLpPji7HOk3gDjcWEmqdhaiHWi+ajZhE7CPe7s2W/pXLLFKpaRjfeGiJevSAGUa wCKs= X-Received: by 2002:a05:600c:3514:b0:414:63c4:c40d with SMTP id h20-20020a05600c351400b0041463c4c40dmr6529657wmq.40.1711036130799; Thu, 21 Mar 2024 08:48:50 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id t6-20020a05600c198600b004131310a29fsm141401wmq.15.2024.03.21.08.48.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:48:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.0? 01/21] host/atomic128: Include missing 'qemu/atomic.h' header Date: Thu, 21 Mar 2024 16:48:17 +0100 Message-ID: <20240321154838.95771-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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 qatomic_cmpxchg__nocheck(), qatomic_read__nocheck(), qatomic_set__nocheck() are defined in "qemu/atomic.h". Include it in order to avoid: In file included from include/exec/helper-proto.h:10: In file included from include/exec/helper-proto-common.h:10: In file included from include/qemu/atomic128.h:61: In file included from host/include/aarch64/host/atomic128-cas.h:16: host/include/generic/host/atomic128-cas.h:23:11: error: call to undeclared function 'qatomic_cmpxchg__nocheck'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] r.i = qatomic_cmpxchg__nocheck(ptr_align, c.i, n.i); ^ Signed-off-by: Philippe Mathieu-Daudé --- host/include/generic/host/atomic128-cas.h | 2 ++ host/include/generic/host/atomic128-ldst.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/host/include/generic/host/atomic128-cas.h b/host/include/generic/host/atomic128-cas.h index 6b40cc2271..4824f14659 100644 --- a/host/include/generic/host/atomic128-cas.h +++ b/host/include/generic/host/atomic128-cas.h @@ -11,6 +11,8 @@ #ifndef HOST_ATOMIC128_CAS_H #define HOST_ATOMIC128_CAS_H +#include "qemu/atomic.h" + #if defined(CONFIG_ATOMIC128) static inline Int128 ATTRIBUTE_ATOMIC128_OPT atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) diff --git a/host/include/generic/host/atomic128-ldst.h b/host/include/generic/host/atomic128-ldst.h index 691e6a8531..12e4aca2da 100644 --- a/host/include/generic/host/atomic128-ldst.h +++ b/host/include/generic/host/atomic128-ldst.h @@ -11,6 +11,8 @@ #ifndef HOST_ATOMIC128_LDST_H #define HOST_ATOMIC128_LDST_H +#include "qemu/atomic.h" + #if defined(CONFIG_ATOMIC128) # define HAVE_ATOMIC128_RO 1 # define HAVE_ATOMIC128_RW 1 From patchwork Thu Mar 21 15:48:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781564 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900259wrj; Thu, 21 Mar 2024 08:50:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXZq682RItW7QOYqEb4NERnizdgCwyb0aafbG9wAzRtHN4DDTFdL3esH3AC+z36LMgrSb70+gbnuh4II2uADr/P X-Google-Smtp-Source: AGHT+IHqpaS0P0E2L5QKdJALT41i2eXvtV15JjNLBuo8Lo1CL81Mxg+g2I5WgMiaT4gtJn5d7epA X-Received: by 2002:a05:620a:3b8d:b0:78a:1001:c8e7 with SMTP id ye13-20020a05620a3b8d00b0078a1001c8e7mr9483957qkn.11.1711036202386; Thu, 21 Mar 2024 08:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036202; cv=none; d=google.com; s=arc-20160816; b=hTOSCMxMdeXP47t63lTotf+a/+8ETLkPBb61xaXU4qWHqgVFTSxZkqIvONJ5hY1AHt GEKPi/FeTQW87gZ+9TgF0leE45SfzHi6W3h75ODJ8u5c+bEj5vR0gz9djdYBaBPOg3lr EVbwi6sUtNb9R6KM5iNwIghtrWPb/yOLTp2ovXFiPiCBvfS5G39/5HTZH5yItS0DEKmF DKufl8fiZV6UXut9umYAuOMz2oKuO8oB5wpcLjuQleJiqpvrfPKX9IHo8rfaenRLmnMB moeB4yCOzhD0UKT616bt+jxDpffzGQSIc9Z2bl/YmRcS//yLPjazuk08nfwpPsj6NPtX 3xag== 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=5Sy5z7ZUuxRw4c3lSjW3Xq5biFR0WjXf8NhA+2yd6fg=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=V0VTKvu4oUDJJlDElMv7R4GsWMUgvp6TRvSowyLGsltIAyYc84QiDT6mDYytQAccl0 qllVtFSaYjfWFQPzAUONIudeiqPLvP8OGr7Jf1rYgr33gWTNwtxYpTo8D00rUYSkDwxZ mq8h3D4BHwC4nbwZCfvor6/iVd5h2iIwXmc88zD1Sx1qc8q2cmBK5mRhnOY0oDD8mL2v lUfG8lDdYQE78OAb8tstesQAbLbGx93CxW3q/Vdu/Z2aUjauaiVy+6j/DocnJcmAYWfK 9gghNANpHH1J9CXrqNlJCb68jtzTD+ZHqY5Cb2zvdLNNXucmtvIFYP4tDNJh5QI9/ntd TwWA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hGGUCLk4; 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 h1-20020ae9ec01000000b0078a168f9126si5276815qkg.412.2024.03.21.08.50.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:50:02 -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=hGGUCLk4; 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 1rnKfS-0004mz-K1; Thu, 21 Mar 2024 11:49:22 -0400 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 1rnKfQ-0004dh-1r for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:20 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKf6-0001E8-3V for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:14 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-41412411622so8240865e9.2 for ; Thu, 21 Mar 2024 08:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036138; x=1711640938; darn=nongnu.org; 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=5Sy5z7ZUuxRw4c3lSjW3Xq5biFR0WjXf8NhA+2yd6fg=; b=hGGUCLk4YhgeywHrCiCGHXS0S7AA7K1n+23mB6egJKReHEUzZxpAu6/q0bKjpz4c23 J7hp7QmWP4o775Y9SSU25qeFmYFXLNDJ9/4bf/RedcAlE5qwYM/Wwq/5OSGIDoemGmZP PdSiB5NYODdAOBVT42wvUrLC1k0llhR1DkmPcxFNW97D2tm5nNx+YGiZiuuvm1142m+S Ss+O0vQpxufpHz9ITGwrGSNiQRY7+oEgf5GWVuobxqZmKP+CWhFd0Ixumtzi58IQPQYZ IFqMj+jVXCDGghqjSk+ZDzUC5zHlaFjyv18jmtA98KVTMi5lHtxZSaUZvAz+qlVeuotg OYGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036138; x=1711640938; 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=5Sy5z7ZUuxRw4c3lSjW3Xq5biFR0WjXf8NhA+2yd6fg=; b=EurLKRE/h821SXPdlFKP86sW0HniHc5Ea5M9ttM6pxsJoBC+fQt+HuK3WfkMcsHOt6 LrRFB5MlxnePH4Yujza9e7ZG4N1kgJojXNfbBRekzwn+aNiUvWm+BCwvMC9MoC6CNi3G 8dSz5xPASzy4b3KkXxi6S5l1E2tMIG4M7TemCU3P13n2cEcwqL9bGC8gUd7+kk430Sga rq0dgemoPREDxm+vCVNjOhJLSDns87tqIh3L2VJ35ifQZGv5Sof4SPLFlA0gM5uhIZ+X TDXmlsl+0JLFhw3mUa8dpBNXjEt66x3ks4WyE12G2B0UTGkjiRBQB+Xk+gO8crZhdeyt ldyw== X-Gm-Message-State: AOJu0YzWK9uuX3flTLtyQ4fSxIdtp94REcqRNRwRKGgJFZ5wOcYr02kW J/aW/1mvxrU7LDPU0zxIyzqGB8OBTCcjbZU1b25A9U/+92RqJEhq8uh86JiHrYqmL3rAtfjU1yy Yg88= X-Received: by 2002:adf:ffc2:0:b0:33e:75e4:d410 with SMTP id x2-20020adfffc2000000b0033e75e4d410mr1795606wrs.22.1711036138214; Thu, 21 Mar 2024 08:48:58 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id dd15-20020a0560001e8f00b0033ce727e728sm17477813wrb.94.2024.03.21.08.48.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:48:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 02/21] hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h Date: Thu, 21 Mar 2024 16:48:18 +0100 Message-ID: <20240321154838.95771-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 Commit fd3f7d24d4 ("include/hw/core: Remove i386 conditional on fake_user_interrupt") remove the need to check on NEED_CPU_H. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/core/tcg-cpu-ops.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index bf8ff8e3ee..88857eb921 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -49,7 +49,6 @@ struct TCGCPUOps { /** @debug_excp_handler: Callback for handling debug exceptions */ void (*debug_excp_handler)(CPUState *cpu); -#ifdef NEED_CPU_H #ifdef CONFIG_USER_ONLY /** * @fake_user_interrupt: Callback for 'fake exception' handling. @@ -174,7 +173,6 @@ struct TCGCPUOps { */ bool (*need_replay_interrupt)(int interrupt_request); #endif /* !CONFIG_USER_ONLY */ -#endif /* NEED_CPU_H */ }; From patchwork Thu Mar 21 15:48:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781565 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900283wrj; Thu, 21 Mar 2024 08:50:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUHpum+sMBlUg3dfuMk/BFQN0NtyYn32fz31ysQRnRh3pfB1JMOS0T4U6oO5ZwKhaL63X5wYvxoZm192VpWYGc+ X-Google-Smtp-Source: AGHT+IHXtKpdTG12+YsWT6MSFrwOjMgNanOcFD5c0EEAKALF1MURKWsstLqdlmtMIOxPpAsDJT0u X-Received: by 2002:a05:622a:11d3:b0:430:f900:6c01 with SMTP id n19-20020a05622a11d300b00430f9006c01mr2439782qtk.45.1711036204776; Thu, 21 Mar 2024 08:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036204; cv=none; d=google.com; s=arc-20160816; b=r8Gk5dDX2+1cB0aHObzkJhOjug4LkSBxeBRHPh+AHpXnQz8RnY73pGcXAKv5k01HR+ uBcmlLQFAE6CaTxKVEODNX4ZKf9vBDuS94QlIsn393CCBFrFB86FPm3LWwZ9w44Hujaf fPsFEuMVyOx5lI/EQ7SpMTkPeP7/ouTyu3LDJOg7tCuimdZt8HdyUQzA3+FikvqyLAUo tkRyqj10H2crxXW3OyA8Lv8Pz6DyNlHKt7VHrqmZoa+c2+87HMEoqPPrs4RuMxsIdu0J nCJ99Hnfzos1pDBkfGQdUya9Q+hJfrm0hUZds+wB0vupp212yYCNu32r1QUFv2QoAPHa CwJQ== 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=3Uml8evcLi9xkWgCFD8gP1/OkUGdeyARM6PHY5ELWBs=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=cfIqLP29REJ0D0o320s+Dg3xZYDAJ8XWT1jJzUn20gMqh8isHxzGK29r1GFD5heQXi yuFfVpo9FAuNGze4KwfwRlIE9Wj+Rsvtew/zi1TJPYGi4JeRdfYXTU8yuHxEnauPSP4d 676ML2i/t1hbKbdHTFsH3hQfPBLnESC94sqFd4hYl6/A/VmAVrdiXG6fqqhN32YDV+kF 1L1QwFy4c74Zywo9xDalTrEGxwQJhVpw+Ah/a4yh8xpZu3LK6wX7FviS1p8er48kYtJF f42DjfGalNXwi9Onc4IcZkfPziYn/FN+i9BVufVXL9PX7HoDMOO4NiHg1Xr0URAwQl4X eZQA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="dTeYg3U/"; 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 t2-20020a05622a148200b0042f212bb553si15436355qtx.273.2024.03.21.08.50.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:50:04 -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="dTeYg3U/"; 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 1rnKfU-0004sm-JY; Thu, 21 Mar 2024 11:49:24 -0400 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 1rnKfQ-0004ds-64 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:20 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfH-0001Fv-GA for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:16 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4146feb33e1so8759355e9.2 for ; Thu, 21 Mar 2024 08:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036146; x=1711640946; darn=nongnu.org; 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=3Uml8evcLi9xkWgCFD8gP1/OkUGdeyARM6PHY5ELWBs=; b=dTeYg3U/cwhEnshK10ojj7HgizCwdzRaO+SjS/8d4AHMV3Gtg7H+hwp+TiM90wlYkN N87nFIjtmoj9i9u67lWZjOjcKW992T9kuu2q01UebM1RMpc/1ECcFip9tLk+NodTiTi7 QpH/nfdl+2Bv6j6d8YgKPbS6xre3d2K2j/QYlqQwe4mhuyxbWEZSSbT/C22ZLRxXdS51 zIXx5x6BgqDN7zNuig46DeWiWHVhh0mRn9cvKMdQDYIRKad3x3OtxuutvsJ69lmIJxVm BODuy1ALwcsIX6RUGHO3QXpDUHnDaTPvJ9lc8ALGk+QO33/TsuDtAS0w2DSTF4i5WU4J x0QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036146; x=1711640946; 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=3Uml8evcLi9xkWgCFD8gP1/OkUGdeyARM6PHY5ELWBs=; b=hPOL1bx49Ij/+y4Rk5VdRsrp4qwwZQ2s2MIIlGfpuNCqHvQwBSUzhgJnKafZW0iZ3T lySVn+VFg/IqOYFb3lkgBlIoLqOb/0T9M7YMFiS7JMK/w1zczSf7imC9/JgTUd3Ft854 OIN9jzr0QkCeBaR5R/LqGMBNmk3d6LQnbniROu+OvE9MFip0hctFNng8Bs3JaYJpyac7 ymjNmAEEf2BLsiCoGgObI5S0ffK98C+brjBEHO5i18jedglTN0E86Mt0UywHZaq6ZO1I gpE0CMm3/onHmhwIcIvq4sckTM/VBzT+9LtDr3in7WDDsyxC3nLFEhOjyfpMOqOQ4Juu vXNQ== X-Gm-Message-State: AOJu0YyTHM9i2ha5IqtiKr41MONfRzC7d5f0TXwdhG6+5fZLIb3Tyxv+ aITxQuetXHxPLIxQZo25Fre/Td40vYBNAfsIcRhtY4niGHKzU17rPaT7N5ucssKZsPIBOyDqgc+ w2D0= X-Received: by 2002:a05:600c:4ecf:b0:413:ee4c:57e4 with SMTP id g15-20020a05600c4ecf00b00413ee4c57e4mr7568498wmq.8.1711036145816; Thu, 21 Mar 2024 08:49:05 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id fc12-20020a05600c524c00b0041477d83499sm136619wmb.16.2024.03.21.08.49.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:49:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 03/21] target/i386: Move APIC related code to cpu-apic.c Date: Thu, 21 Mar 2024 16:48:19 +0100 Message-ID: <20240321154838.95771-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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=unavailable 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 Move APIC related code split in cpu-sysemu.c and monitor.c to cpu-apic.c. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Zhao Liu --- target/i386/cpu-apic.c | 112 +++++++++++++++++++++++++++++++++++++++ target/i386/cpu-sysemu.c | 77 --------------------------- target/i386/monitor.c | 25 --------- target/i386/meson.build | 1 + 4 files changed, 113 insertions(+), 102 deletions(-) create mode 100644 target/i386/cpu-apic.c diff --git a/target/i386/cpu-apic.c b/target/i386/cpu-apic.c new file mode 100644 index 0000000000..d397ec94dc --- /dev/null +++ b/target/i386/cpu-apic.c @@ -0,0 +1,112 @@ +/* + * QEMU x86 CPU <-> APIC + * + * Copyright (c) 2003-2004 Fabrice Bellard + * + * SPDX-License-Identifier: MIT + */ + +#include "qemu/osdep.h" +#include "qapi/qmp/qdict.h" +#include "qapi/error.h" +#include "monitor/monitor.h" +#include "monitor/hmp-target.h" +#include "sysemu/hw_accel.h" +#include "sysemu/kvm.h" +#include "sysemu/xen.h" +#include "exec/address-spaces.h" +#include "hw/qdev-properties.h" +#include "hw/i386/apic_internal.h" +#include "cpu-internal.h" + +APICCommonClass *apic_get_class(Error **errp) +{ + const char *apic_type = "apic"; + + /* TODO: in-kernel irqchip for hvf */ + if (kvm_enabled()) { + if (!kvm_irqchip_in_kernel()) { + error_setg(errp, "KVM does not support userspace APIC"); + return NULL; + } + apic_type = "kvm-apic"; + } else if (xen_enabled()) { + apic_type = "xen-apic"; + } else if (whpx_apic_in_platform()) { + apic_type = "whpx-apic"; + } + + return APIC_COMMON_CLASS(object_class_by_name(apic_type)); +} + +void x86_cpu_apic_create(X86CPU *cpu, Error **errp) +{ + APICCommonState *apic; + APICCommonClass *apic_class = apic_get_class(errp); + + if (!apic_class) { + return; + } + + cpu->apic_state = DEVICE(object_new_with_class(OBJECT_CLASS(apic_class))); + object_property_add_child(OBJECT(cpu), "lapic", + OBJECT(cpu->apic_state)); + object_unref(OBJECT(cpu->apic_state)); + + /* TODO: convert to link<> */ + apic = APIC_COMMON(cpu->apic_state); + apic->cpu = cpu; + apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE; + + /* + * apic_common_set_id needs to check if the CPU has x2APIC + * feature in case APIC ID >= 255, so we need to set apic->cpu + * before setting APIC ID + */ + qdev_prop_set_uint32(cpu->apic_state, "id", cpu->apic_id); +} + +void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) +{ + APICCommonState *apic; + static bool apic_mmio_map_once; + + if (cpu->apic_state == NULL) { + return; + } + qdev_realize(DEVICE(cpu->apic_state), NULL, errp); + + /* Map APIC MMIO area */ + apic = APIC_COMMON(cpu->apic_state); + if (!apic_mmio_map_once) { + memory_region_add_subregion_overlap(get_system_memory(), + apic->apicbase & + MSR_IA32_APICBASE_BASE, + &apic->io_memory, + 0x1000); + apic_mmio_map_once = true; + } +} + +void hmp_info_local_apic(Monitor *mon, const QDict *qdict) +{ + CPUState *cs; + + if (qdict_haskey(qdict, "apic-id")) { + int id = qdict_get_try_int(qdict, "apic-id", 0); + + cs = cpu_by_arch_id(id); + if (cs) { + cpu_synchronize_state(cs); + } + } else { + cs = mon_get_cpu(mon); + } + + + if (!cs) { + monitor_printf(mon, "No CPU available\n"); + return; + } + x86_cpu_dump_local_apic_state(cs, CPU_DUMP_FPU); +} diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c index 3f9093d285..227ac021f6 100644 --- a/target/i386/cpu-sysemu.c +++ b/target/i386/cpu-sysemu.c @@ -19,19 +19,12 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "sysemu/kvm.h" -#include "sysemu/xen.h" -#include "sysemu/whpx.h" #include "qapi/error.h" #include "qapi/qapi-visit-run-state.h" #include "qapi/qmp/qdict.h" #include "qapi/qobject-input-visitor.h" #include "qom/qom-qobject.h" #include "qapi/qapi-commands-machine-target.h" -#include "hw/qdev-properties.h" - -#include "exec/address-spaces.h" -#include "hw/i386/apic_internal.h" #include "cpu-internal.h" @@ -273,75 +266,6 @@ void x86_cpu_machine_reset_cb(void *opaque) cpu_reset(CPU(cpu)); } -APICCommonClass *apic_get_class(Error **errp) -{ - const char *apic_type = "apic"; - - /* TODO: in-kernel irqchip for hvf */ - if (kvm_enabled()) { - if (!kvm_irqchip_in_kernel()) { - error_setg(errp, "KVM does not support userspace APIC"); - return NULL; - } - apic_type = "kvm-apic"; - } else if (xen_enabled()) { - apic_type = "xen-apic"; - } else if (whpx_apic_in_platform()) { - apic_type = "whpx-apic"; - } - - return APIC_COMMON_CLASS(object_class_by_name(apic_type)); -} - -void x86_cpu_apic_create(X86CPU *cpu, Error **errp) -{ - APICCommonState *apic; - APICCommonClass *apic_class = apic_get_class(errp); - - if (!apic_class) { - return; - } - - cpu->apic_state = DEVICE(object_new_with_class(OBJECT_CLASS(apic_class))); - object_property_add_child(OBJECT(cpu), "lapic", - OBJECT(cpu->apic_state)); - object_unref(OBJECT(cpu->apic_state)); - - /* TODO: convert to link<> */ - apic = APIC_COMMON(cpu->apic_state); - apic->cpu = cpu; - apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE; - - /* - * apic_common_set_id needs to check if the CPU has x2APIC - * feature in case APIC ID >= 255, so we need to set apic->cpu - * before setting APIC ID - */ - qdev_prop_set_uint32(cpu->apic_state, "id", cpu->apic_id); -} - -void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) -{ - APICCommonState *apic; - static bool apic_mmio_map_once; - - if (cpu->apic_state == NULL) { - return; - } - qdev_realize(DEVICE(cpu->apic_state), NULL, errp); - - /* Map APIC MMIO area */ - apic = APIC_COMMON(cpu->apic_state); - if (!apic_mmio_map_once) { - memory_region_add_subregion_overlap(get_system_memory(), - apic->apicbase & - MSR_IA32_APICBASE_BASE, - &apic->io_memory, - 0x1000); - apic_mmio_map_once = true; - } -} - GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs) { X86CPU *cpu = X86_CPU(cs); @@ -385,4 +309,3 @@ void x86_cpu_get_crash_info_qom(Object *obj, Visitor *v, errp); qapi_free_GuestPanicInformation(panic_info); } - diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 3a281dab02..2d766b2637 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -28,8 +28,6 @@ #include "monitor/hmp-target.h" #include "monitor/hmp.h" #include "qapi/qmp/qdict.h" -#include "sysemu/hw_accel.h" -#include "sysemu/kvm.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qapi-commands-misc.h" @@ -647,26 +645,3 @@ const MonitorDef *target_monitor_defs(void) { return monitor_defs; } - -void hmp_info_local_apic(Monitor *mon, const QDict *qdict) -{ - CPUState *cs; - - if (qdict_haskey(qdict, "apic-id")) { - int id = qdict_get_try_int(qdict, "apic-id", 0); - - cs = cpu_by_arch_id(id); - if (cs) { - cpu_synchronize_state(cs); - } - } else { - cs = mon_get_cpu(mon); - } - - - if (!cs) { - monitor_printf(mon, "No CPU available\n"); - return; - } - x86_cpu_dump_local_apic_state(cs, CPU_DUMP_FPU); -} diff --git a/target/i386/meson.build b/target/i386/meson.build index 7c74bfa859..ba8dc68a34 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -18,6 +18,7 @@ i386_system_ss.add(files( 'arch_memory_mapping.c', 'machine.c', 'monitor.c', + 'cpu-apic.c', 'cpu-sysemu.c', )) i386_system_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-sysemu-stub.c')) From patchwork Thu Mar 21 15:48:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781563 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900095wrj; Thu, 21 Mar 2024 08:49:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4lEGVdo4F2YbXtpqyNzeYbLzfT7LyhwoKAJ5fgbBOJEBFYXqZwaFukOfJdIGsIi5oXkv+TxgNiEoRk0SKgHg6 X-Google-Smtp-Source: AGHT+IHZ2tSKc/dhKfpyc0NZVRKv3di2Iap1Xw7CUOUHGt82DDIkgz329Vi6AbkhrNPgtB74xLSN X-Received: by 2002:a05:6214:21e3:b0:68f:f859:ee06 with SMTP id p3-20020a05621421e300b0068ff859ee06mr5202341qvj.12.1711036176254; Thu, 21 Mar 2024 08:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036176; cv=none; d=google.com; s=arc-20160816; b=A+Y1+9J/83pPkNQPgPOA0H9zC6pdXK/OkMBDsFcn8gCZI8Su7Av/rKH/QAb3HQcARm hVViIV7xCP3fGu5i8LNqRGeQ9ealWCK2vnL+dIAVljLAASKH7mGQh88aRExfLDaj9uCq vN/O5A5o0SaUGUsyi+TaSRr6EcmWgYxWOVieu68foAByGIgsqxFJ6JYP5p8dTRT2cWtS 89NLpZUlK9/E2steiIjdi/e7hRrTPOuyoGpcqWuLgt0IbwQc2yzulv3vI8/ey11IXzTv Ij7gH1RLiEkK31MR2HsQi2kP7L6SkRs8bolQx/EscdjKMAuRf11oeC26SwxbYC2X7O/u eHUQ== 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=kPB7wPRU4EbQ/PHDSaLSRsBSA5jdN0249I6tKdnInr4=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=d+NwlDCZsWssmg0WLjnX8+4kOHmAZx2eIPS+7fB3Y83ASrf/0xQfz45t2LPQBcM5jy 1ybsxHCOMO8pwQUCWF0QZbRsmrehJz12ISm7mSqL9Am0xgVmxzmbPztHoYS0mM88TWHD gPGONVz/gQO1qdRQfb9VKOdXdbXKEoOcE6j+3HfYtKU0gNbwMuv5xwlm2bOLVPlSR+eL EqsXWEoVGAzdQg9PD8272xnYhdGSAEpC2GoAq17cPI8gxmxk5EZ1tndul6l0AvbEntgF QEgJAR7whUMLNv632bVWJ4H5jXp2dMQltgKaxrvw0+SLJzzATtZdmVEARHA7KHkIet9X U1qw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NSChZN96; 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 gi11-20020a056214248b00b006916700d754si21102qvb.312.2024.03.21.08.49.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:49:36 -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=NSChZN96; 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 1rnKfX-0004wz-CL; Thu, 21 Mar 2024 11:49:27 -0400 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 1rnKfW-0004wN-J9 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:26 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfQ-0001I7-4O for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:26 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-414701303f7so10795125e9.2 for ; Thu, 21 Mar 2024 08:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036154; x=1711640954; darn=nongnu.org; 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=kPB7wPRU4EbQ/PHDSaLSRsBSA5jdN0249I6tKdnInr4=; b=NSChZN961vxgCuV3mTkiixFDOA1rj37FIovTLzqyRyd00VEr7/qwPh0879jruYTUGE YJeVdnolDOcu9zdydkK4teZwO9CkOZa2X7bx4m2WBhpkH0iPguOTEsQgm+Sd5xcE2ugF kFqoUztLIVhm1WXNvxSaprgTv35JQEOHmkXtj5Y46vywpVhivrim1iuyO3RlwjCIq5zk DrJ6X8SY55MlNKTxpiZqbWXSdn0qMdqn34o8CN7V0TpjWG9fUyMybxgMZ0WjxGKHs0/z pST3rVICGourwktefcE8pdF3+dVbTOWKTw2J/nTUrd7z0RuAX16N5qHPeitTGRoXhQYj JWkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036154; x=1711640954; 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=kPB7wPRU4EbQ/PHDSaLSRsBSA5jdN0249I6tKdnInr4=; b=ug8ailcDliMbboFUxvS06IWW4ExY0r+WUem5OXdif8Y3IzhDmtNhff+lN6quy5PJre axrybCGgOGzxT3H/Us8tPuHiGzG1KpkKRleLzbMcJsUrOLbgxrHYMUhDX1IKnI3XSHKi qPhNzl/FRUVEbr9WioskpY+MFrbknCTFmhTIY579GOX+cQP6+nBF1BxJeHI9mcvbNgS4 kZZLSXtPOhjdOWK7/YveDai9+69SRu30ghyDOKG/aFGXido15Ejrr1Z0IEypRBag4Tv6 dvY5QtE4lOCw5764iAPS3rxCkHfbfUKW9UJr/RJ2Uh+DScfgFM2KruCjgo1L6EuhbRiN oqDA== X-Gm-Message-State: AOJu0YzGlLA446nmbipX0mSFMIS3NmUfxVFDP/8RURkYY76TcCOXkbsc 9RRSbNPtwTQdZD16mN9bRK/GGdB/c04R/YgOrSA5VopbIwlXYbaUSHLufUG2xnMXOSEHEKTGy8y vFDI= X-Received: by 2002:a05:600c:19d2:b0:413:ee55:8bba with SMTP id u18-20020a05600c19d200b00413ee558bbamr2321713wmq.4.1711036153865; Thu, 21 Mar 2024 08:49:13 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id q14-20020a05600c46ce00b004140a757256sm5997663wmo.31.2024.03.21.08.49.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:49:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 04/21] target/i386: Extract x86_dump_mmu() from hmp_info_tlb() Date: Thu, 21 Mar 2024 16:48:20 +0100 Message-ID: <20240321154838.95771-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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 hmp_info_tlb() is specific to tcg/system, move it to target/i386/tcg/sysemu/hmp-cmds.c, along with the functions it depend on (except addr_canonical() which is exposed in "cpu.h"). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/i386/cpu.h | 7 ++ target/i386/mmu.c | 231 ++++++++++++++++++++++++++++++++++++++++ target/i386/monitor.c | 215 ------------------------------------- target/i386/meson.build | 1 + 4 files changed, 239 insertions(+), 215 deletions(-) create mode 100644 target/i386/mmu.c diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 952174bb6f..055c5b99de 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2342,6 +2342,13 @@ static inline int cpu_mmu_index_kernel(CPUX86State *env) return mmu_index_base + mmu_index_32; } +#if !defined(CONFIG_USER_ONLY) +void x86_dump_mmu(Monitor *mon, CPUX86State *env); + +/* Perform linear address sign extension */ +hwaddr addr_canonical(CPUArchState *env, hwaddr addr); +#endif + #define CC_DST (env->cc_dst) #define CC_SRC (env->cc_src) #define CC_SRC2 (env->cc_src2) diff --git a/target/i386/mmu.c b/target/i386/mmu.c new file mode 100644 index 0000000000..da9b2263b4 --- /dev/null +++ b/target/i386/mmu.c @@ -0,0 +1,231 @@ +/* + * QEMU x86 MMU monitor commands + * + * Copyright (c) 2003-2004 Fabrice Bellard + * + * SPDX-License-Identifier: MIT + */ + +#include "qemu/osdep.h" +#include "monitor/monitor.h" +#include "monitor/hmp-target.h" +#include "cpu.h" + +hwaddr addr_canonical(CPUArchState *env, hwaddr addr) +{ +#ifdef TARGET_X86_64 + if (env->cr[4] & CR4_LA57_MASK) { + if (addr & (1ULL << 56)) { + addr |= (hwaddr)-(1LL << 57); + } + } else { + if (addr & (1ULL << 47)) { + addr |= (hwaddr)-(1LL << 48); + } + } +#endif + return addr; +} + +static void print_pte(Monitor *mon, CPUArchState *env, hwaddr addr, + hwaddr pte, hwaddr mask) +{ + addr = addr_canonical(env, addr); + + monitor_printf(mon, HWADDR_FMT_plx ": " HWADDR_FMT_plx + " %c%c%c%c%c%c%c%c%c\n", + addr, + pte & mask, + pte & PG_NX_MASK ? 'X' : '-', + pte & PG_GLOBAL_MASK ? 'G' : '-', + pte & PG_PSE_MASK ? 'P' : '-', + pte & PG_DIRTY_MASK ? 'D' : '-', + pte & PG_ACCESSED_MASK ? 'A' : '-', + pte & PG_PCD_MASK ? 'C' : '-', + pte & PG_PWT_MASK ? 'T' : '-', + pte & PG_USER_MASK ? 'U' : '-', + pte & PG_RW_MASK ? 'W' : '-'); +} + +static void tlb_info_32(Monitor *mon, CPUArchState *env) +{ + unsigned int l1, l2; + uint32_t pgd, pde, pte; + + pgd = env->cr[3] & ~0xfff; + for(l1 = 0; l1 < 1024; l1++) { + cpu_physical_memory_read(pgd + l1 * 4, &pde, 4); + pde = le32_to_cpu(pde); + if (pde & PG_PRESENT_MASK) { + if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { + /* 4M pages */ + print_pte(mon, env, (l1 << 22), pde, ~((1 << 21) - 1)); + } else { + for(l2 = 0; l2 < 1024; l2++) { + cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4); + pte = le32_to_cpu(pte); + if (pte & PG_PRESENT_MASK) { + print_pte(mon, env, (l1 << 22) + (l2 << 12), + pte & ~PG_PSE_MASK, + ~0xfff); + } + } + } + } + } +} + +static void tlb_info_pae32(Monitor *mon, CPUArchState *env) +{ + unsigned int l1, l2, l3; + uint64_t pdpe, pde, pte; + uint64_t pdp_addr, pd_addr, pt_addr; + + pdp_addr = env->cr[3] & ~0x1f; + for (l1 = 0; l1 < 4; l1++) { + cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8); + pdpe = le64_to_cpu(pdpe); + if (pdpe & PG_PRESENT_MASK) { + pd_addr = pdpe & 0x3fffffffff000ULL; + for (l2 = 0; l2 < 512; l2++) { + cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8); + pde = le64_to_cpu(pde); + if (pde & PG_PRESENT_MASK) { + if (pde & PG_PSE_MASK) { + /* 2M pages with PAE, CR4.PSE is ignored */ + print_pte(mon, env, (l1 << 30) + (l2 << 21), pde, + ~((hwaddr)(1 << 20) - 1)); + } else { + pt_addr = pde & 0x3fffffffff000ULL; + for (l3 = 0; l3 < 512; l3++) { + cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8); + pte = le64_to_cpu(pte); + if (pte & PG_PRESENT_MASK) { + print_pte(mon, env, (l1 << 30) + (l2 << 21) + + (l3 << 12), + pte & ~PG_PSE_MASK, + ~(hwaddr)0xfff); + } + } + } + } + } + } + } +} + +#ifdef TARGET_X86_64 +static void tlb_info_la48(Monitor *mon, CPUArchState *env, + uint64_t l0, uint64_t pml4_addr) +{ + uint64_t l1, l2, l3, l4; + uint64_t pml4e, pdpe, pde, pte; + uint64_t pdp_addr, pd_addr, pt_addr; + + for (l1 = 0; l1 < 512; l1++) { + cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8); + pml4e = le64_to_cpu(pml4e); + if (!(pml4e & PG_PRESENT_MASK)) { + continue; + } + + pdp_addr = pml4e & 0x3fffffffff000ULL; + for (l2 = 0; l2 < 512; l2++) { + cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8); + pdpe = le64_to_cpu(pdpe); + if (!(pdpe & PG_PRESENT_MASK)) { + continue; + } + + if (pdpe & PG_PSE_MASK) { + /* 1G pages, CR4.PSE is ignored */ + print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30), + pdpe, 0x3ffffc0000000ULL); + continue; + } + + pd_addr = pdpe & 0x3fffffffff000ULL; + for (l3 = 0; l3 < 512; l3++) { + cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8); + pde = le64_to_cpu(pde); + if (!(pde & PG_PRESENT_MASK)) { + continue; + } + + if (pde & PG_PSE_MASK) { + /* 2M pages, CR4.PSE is ignored */ + print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30) + + (l3 << 21), pde, 0x3ffffffe00000ULL); + continue; + } + + pt_addr = pde & 0x3fffffffff000ULL; + for (l4 = 0; l4 < 512; l4++) { + cpu_physical_memory_read(pt_addr + + l4 * 8, + &pte, 8); + pte = le64_to_cpu(pte); + if (pte & PG_PRESENT_MASK) { + print_pte(mon, env, (l0 << 48) + (l1 << 39) + + (l2 << 30) + (l3 << 21) + (l4 << 12), + pte & ~PG_PSE_MASK, 0x3fffffffff000ULL); + } + } + } + } + } +} + +static void tlb_info_la57(Monitor *mon, CPUArchState *env) +{ + uint64_t l0; + uint64_t pml5e; + uint64_t pml5_addr; + + pml5_addr = env->cr[3] & 0x3fffffffff000ULL; + for (l0 = 0; l0 < 512; l0++) { + cpu_physical_memory_read(pml5_addr + l0 * 8, &pml5e, 8); + pml5e = le64_to_cpu(pml5e); + if (pml5e & PG_PRESENT_MASK) { + tlb_info_la48(mon, env, l0, pml5e & 0x3fffffffff000ULL); + } + } +} +#endif /* TARGET_X86_64 */ + +void x86_dump_mmu(Monitor *mon, CPUX86State *env) +{ + if (!(env->cr[0] & CR0_PG_MASK)) { + monitor_printf(mon, "PG disabled\n"); + return; + } + if (env->cr[4] & CR4_PAE_MASK) { +#ifdef TARGET_X86_64 + if (env->hflags & HF_LMA_MASK) { + if (env->cr[4] & CR4_LA57_MASK) { + tlb_info_la57(mon, env); + } else { + tlb_info_la48(mon, env, 0, env->cr[3] & 0x3fffffffff000ULL); + } + } else +#endif + { + tlb_info_pae32(mon, env); + } + } else { + tlb_info_32(mon, env); + } +} + +void hmp_info_tlb(Monitor *mon, const QDict *qdict) +{ + CPUArchState *env; + + env = mon_get_cpu_env(mon); + if (!env) { + monitor_printf(mon, "No CPU available\n"); + return; + } + + x86_dump_mmu(mon, env); +} diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 2d766b2637..fa155ac3c9 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -32,221 +32,6 @@ #include "qapi/qapi-commands-misc-target.h" #include "qapi/qapi-commands-misc.h" -/* Perform linear address sign extension */ -static hwaddr addr_canonical(CPUArchState *env, hwaddr addr) -{ -#ifdef TARGET_X86_64 - if (env->cr[4] & CR4_LA57_MASK) { - if (addr & (1ULL << 56)) { - addr |= (hwaddr)-(1LL << 57); - } - } else { - if (addr & (1ULL << 47)) { - addr |= (hwaddr)-(1LL << 48); - } - } -#endif - return addr; -} - -static void print_pte(Monitor *mon, CPUArchState *env, hwaddr addr, - hwaddr pte, hwaddr mask) -{ - addr = addr_canonical(env, addr); - - monitor_printf(mon, HWADDR_FMT_plx ": " HWADDR_FMT_plx - " %c%c%c%c%c%c%c%c%c\n", - addr, - pte & mask, - pte & PG_NX_MASK ? 'X' : '-', - pte & PG_GLOBAL_MASK ? 'G' : '-', - pte & PG_PSE_MASK ? 'P' : '-', - pte & PG_DIRTY_MASK ? 'D' : '-', - pte & PG_ACCESSED_MASK ? 'A' : '-', - pte & PG_PCD_MASK ? 'C' : '-', - pte & PG_PWT_MASK ? 'T' : '-', - pte & PG_USER_MASK ? 'U' : '-', - pte & PG_RW_MASK ? 'W' : '-'); -} - -static void tlb_info_32(Monitor *mon, CPUArchState *env) -{ - unsigned int l1, l2; - uint32_t pgd, pde, pte; - - pgd = env->cr[3] & ~0xfff; - for(l1 = 0; l1 < 1024; l1++) { - cpu_physical_memory_read(pgd + l1 * 4, &pde, 4); - pde = le32_to_cpu(pde); - if (pde & PG_PRESENT_MASK) { - if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { - /* 4M pages */ - print_pte(mon, env, (l1 << 22), pde, ~((1 << 21) - 1)); - } else { - for(l2 = 0; l2 < 1024; l2++) { - cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4); - pte = le32_to_cpu(pte); - if (pte & PG_PRESENT_MASK) { - print_pte(mon, env, (l1 << 22) + (l2 << 12), - pte & ~PG_PSE_MASK, - ~0xfff); - } - } - } - } - } -} - -static void tlb_info_pae32(Monitor *mon, CPUArchState *env) -{ - unsigned int l1, l2, l3; - uint64_t pdpe, pde, pte; - uint64_t pdp_addr, pd_addr, pt_addr; - - pdp_addr = env->cr[3] & ~0x1f; - for (l1 = 0; l1 < 4; l1++) { - cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8); - pdpe = le64_to_cpu(pdpe); - if (pdpe & PG_PRESENT_MASK) { - pd_addr = pdpe & 0x3fffffffff000ULL; - for (l2 = 0; l2 < 512; l2++) { - cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8); - pde = le64_to_cpu(pde); - if (pde & PG_PRESENT_MASK) { - if (pde & PG_PSE_MASK) { - /* 2M pages with PAE, CR4.PSE is ignored */ - print_pte(mon, env, (l1 << 30) + (l2 << 21), pde, - ~((hwaddr)(1 << 20) - 1)); - } else { - pt_addr = pde & 0x3fffffffff000ULL; - for (l3 = 0; l3 < 512; l3++) { - cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8); - pte = le64_to_cpu(pte); - if (pte & PG_PRESENT_MASK) { - print_pte(mon, env, (l1 << 30) + (l2 << 21) - + (l3 << 12), - pte & ~PG_PSE_MASK, - ~(hwaddr)0xfff); - } - } - } - } - } - } - } -} - -#ifdef TARGET_X86_64 -static void tlb_info_la48(Monitor *mon, CPUArchState *env, - uint64_t l0, uint64_t pml4_addr) -{ - uint64_t l1, l2, l3, l4; - uint64_t pml4e, pdpe, pde, pte; - uint64_t pdp_addr, pd_addr, pt_addr; - - for (l1 = 0; l1 < 512; l1++) { - cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8); - pml4e = le64_to_cpu(pml4e); - if (!(pml4e & PG_PRESENT_MASK)) { - continue; - } - - pdp_addr = pml4e & 0x3fffffffff000ULL; - for (l2 = 0; l2 < 512; l2++) { - cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8); - pdpe = le64_to_cpu(pdpe); - if (!(pdpe & PG_PRESENT_MASK)) { - continue; - } - - if (pdpe & PG_PSE_MASK) { - /* 1G pages, CR4.PSE is ignored */ - print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30), - pdpe, 0x3ffffc0000000ULL); - continue; - } - - pd_addr = pdpe & 0x3fffffffff000ULL; - for (l3 = 0; l3 < 512; l3++) { - cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8); - pde = le64_to_cpu(pde); - if (!(pde & PG_PRESENT_MASK)) { - continue; - } - - if (pde & PG_PSE_MASK) { - /* 2M pages, CR4.PSE is ignored */ - print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30) + - (l3 << 21), pde, 0x3ffffffe00000ULL); - continue; - } - - pt_addr = pde & 0x3fffffffff000ULL; - for (l4 = 0; l4 < 512; l4++) { - cpu_physical_memory_read(pt_addr - + l4 * 8, - &pte, 8); - pte = le64_to_cpu(pte); - if (pte & PG_PRESENT_MASK) { - print_pte(mon, env, (l0 << 48) + (l1 << 39) + - (l2 << 30) + (l3 << 21) + (l4 << 12), - pte & ~PG_PSE_MASK, 0x3fffffffff000ULL); - } - } - } - } - } -} - -static void tlb_info_la57(Monitor *mon, CPUArchState *env) -{ - uint64_t l0; - uint64_t pml5e; - uint64_t pml5_addr; - - pml5_addr = env->cr[3] & 0x3fffffffff000ULL; - for (l0 = 0; l0 < 512; l0++) { - cpu_physical_memory_read(pml5_addr + l0 * 8, &pml5e, 8); - pml5e = le64_to_cpu(pml5e); - if (pml5e & PG_PRESENT_MASK) { - tlb_info_la48(mon, env, l0, pml5e & 0x3fffffffff000ULL); - } - } -} -#endif /* TARGET_X86_64 */ - -void hmp_info_tlb(Monitor *mon, const QDict *qdict) -{ - CPUArchState *env; - - env = mon_get_cpu_env(mon); - if (!env) { - monitor_printf(mon, "No CPU available\n"); - return; - } - - if (!(env->cr[0] & CR0_PG_MASK)) { - monitor_printf(mon, "PG disabled\n"); - return; - } - if (env->cr[4] & CR4_PAE_MASK) { -#ifdef TARGET_X86_64 - if (env->hflags & HF_LMA_MASK) { - if (env->cr[4] & CR4_LA57_MASK) { - tlb_info_la57(mon, env); - } else { - tlb_info_la48(mon, env, 0, env->cr[3] & 0x3fffffffff000ULL); - } - } else -#endif - { - tlb_info_pae32(mon, env); - } - } else { - tlb_info_32(mon, env); - } -} - static void mem_print(Monitor *mon, CPUArchState *env, hwaddr *pstart, int *plast_prot, hwaddr end, int prot) diff --git a/target/i386/meson.build b/target/i386/meson.build index ba8dc68a34..6c6f383e2e 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -18,6 +18,7 @@ i386_system_ss.add(files( 'arch_memory_mapping.c', 'machine.c', 'monitor.c', + 'mmu.c', 'cpu-apic.c', 'cpu-sysemu.c', )) From patchwork Thu Mar 21 15:48:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781578 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901771wrj; Thu, 21 Mar 2024 08:53:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXPqAqmeQSaBianD//nMqNLPG0Nimdnn3REy4bPayyMSW+OSBKOdtttg5gMHX6HfyEgnH2Z/3uW0m2e1HxIT80j X-Google-Smtp-Source: AGHT+IFcw3TyxnNNbUDY4O3uTcYqxovo6iqbixm9wegNpfc1rHc0JvMIhleMfpyaldwbIHr0EMzm X-Received: by 2002:a5d:47ac:0:b0:341:9087:8a4 with SMTP id 12-20020a5d47ac000000b00341908708a4mr5413756wrb.13.1711036388325; Thu, 21 Mar 2024 08:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036388; cv=none; d=google.com; s=arc-20160816; b=Ow/EyffMNTOTLO7yb7bLj8bHlRlIinK9+FBo0oj/DT1HZCOqKRCYOlkywlPDGu8s6e mpXpFBVHJ7VgZvBBCof6gTtyMnLJJWBMi4m9IRdPCfHixoqhBER5Yk5QX0XfPA6bl4FQ 8YpwobOSYi9B8rszvJ1893IJ6sO78HzQF+bayA0/+IEr7n2HSLqt3VZ8irPOrtTs3PTE UOzckdI3l/r1Loh31cM2fd3dZ06gs+6Kx29GOliVZ7KoCGxNKHLyQqjV5mjmWzFiFJ9w jRSjt6DD9FOaPMnzWHX1G0OSjGHG0HUPr8Q4HcVeKNtYLXgxeIgMBttjM2E+JYEzkH5X 1mMQ== 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=jOvH0FD2iTYACKTsXepOOjEUMYdyz3d2ohX/Qxb33cM=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=xdODdNqEIrEzHkJi6uSwvUKqWpX7v9fAd64jjBQMDVSnJmfTrLHSp1yE2jyZhUHZYE y5kN6ibAu41XYIRJY5rn+XYTF1Nv1CsSP+X1iBaNXP/OzM9P+zhr6T47eBRk5+BeQ8ad Teh4Jc4JVumDvQ+mhHQp8LdwCrRXAr1mz44GbGfuZmFKICONK/Az/XoRkxzOJUZVnel3 CNbqXl4rMZPHDe1UbjY+y72ze70nDLhQqlGv+V2pTgfABZ3ph4Zmx1Ln7A34GUCSNMpn lMhq4kVh8eiGUklafml9WfgaTKeM6rOUNdNO9JnYqbqjB/qZ17SsmSbaiFxMaXmp+piu x9Kw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RMPRmhq5; 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 k17-20020adff5d1000000b0033b80d76451si8531981wrp.654.2024.03.21.08.53.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:53:08 -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=RMPRmhq5; 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 1rnKfZ-0004yE-Dx; Thu, 21 Mar 2024 11:49:29 -0400 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 1rnKfX-0004v6-0I for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:27 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfT-0001KR-6A for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:25 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-414783a9edcso1162645e9.0 for ; Thu, 21 Mar 2024 08:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036161; x=1711640961; darn=nongnu.org; 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=jOvH0FD2iTYACKTsXepOOjEUMYdyz3d2ohX/Qxb33cM=; b=RMPRmhq5D02gZqUNSF/0sZBodbh/FXvpWO0DJV9nM4TstkqpcQH2H/rexVPCBhlr5D 0ioiL83RIUhqcFks/F/V6vrcc/PW7yQWyhZXwN7ylGJ0QWK/zfTXaYjkdgk7vZM2a79j 5z+53hHQZRkAt/wcOpox/L4WOvbbnK6fJVmnlEjjflRrKxconx6xZE49W+uOpg6BPz1T NI3a54o2A7MZOnoFCvpcxpSpqYf0VIWblKOXzEjjW6yvGuqfitIpYjjUiJSoHoO4Wc0p 9TcnwVukXB+lkrR8SzTa5ShC0qqTWvERXZ7r9FC45wC4imq8SvO2fZaB/17ToNjn1A8/ 5jSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036161; x=1711640961; 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=jOvH0FD2iTYACKTsXepOOjEUMYdyz3d2ohX/Qxb33cM=; b=IHOjZxqcJosEDtquIQTd3LiTs2BWhlqB5NfX2DL+G52b3kwmes9XENBPewkofj9+0s 5fZAhsj2IiQ41F2q9c4mmr4eNpn9Zz3AWjimpV0hG8uSqQq7xAwzXtS+LTAq8Rv7ME2z CK4IM4TKdRKwPcrc01MukUpaLlNmRqzTWonIJ8FfNl9lCrP2vCdIJ74r7TtPRF+t84aV J8WPwUE8Jp8clHnzIwXlaDGtNXint0tI1j9t1q7xSDiywRn+zNyfBIECmd+OxvPYF55b bU63qP6H2ZoLQFhR1rjFb+w3COr7hekcW1AY91kO/OVgdsYkciQOCK2ojeKV2Cp/RM8G c8gg== X-Gm-Message-State: AOJu0YyqQ2i0rD+P5cGEh/E0g4uAyvprm0OIhaJ/W9fOKqH+oUcgeJXw h6ItZ3fbBJgwga9bf8dWCrkLY7a5XTNxeBzx+VMXhlhXIjfw3k0dmfQcfnH6y7IXCsPYZgR61Uh +le8= X-Received: by 2002:a05:600c:5486:b0:413:2c11:f795 with SMTP id iv6-20020a05600c548600b004132c11f795mr4116109wmb.39.1711036161419; Thu, 21 Mar 2024 08:49:21 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id iv20-20020a05600c549400b004146bce65f4sm5887932wmb.13.2024.03.21.08.49.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:49:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor Date: Thu, 21 Mar 2024 16:48:21 +0100 Message-ID: <20240321154838.95771-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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=unavailable 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 Replace qemu_printf() by monitor_printf() / monitor_puts() in monitor. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Markus Armbruster --- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 126 +++++++++++++++++++++--------------------- target/m68k/monitor.c | 4 +- 3 files changed, 67 insertions(+), 65 deletions(-) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 346427e144..4e4307956d 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -620,6 +620,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu(CPUM68KState *env); +void dump_mmu(Monitor *mon, CPUM68KState *env); #endif diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 1a475f082a..310e26dfa1 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -25,7 +25,7 @@ #include "exec/helper-proto.h" #include "gdbstub/helpers.h" #include "fpu/softfloat.h" -#include "qemu/qemu-print.h" +#include "monitor/monitor.h" #define SIGNBIT (1u << 31) @@ -455,28 +455,30 @@ void m68k_switch_sp(CPUM68KState *env) #if !defined(CONFIG_USER_ONLY) /* MMU: 68040 only */ -static void print_address_zone(uint32_t logical, uint32_t physical, +static void print_address_zone(Monitor *mon, + uint32_t logical, uint32_t physical, uint32_t size, int attr) { - qemu_printf("%08x - %08x -> %08x - %08x %c ", - logical, logical + size - 1, - physical, physical + size - 1, - attr & 4 ? 'W' : '-'); + monitor_printf(mon, "%08x - %08x -> %08x - %08x %c ", + logical, logical + size - 1, + physical, physical + size - 1, + attr & 4 ? 'W' : '-'); size >>= 10; if (size < 1024) { - qemu_printf("(%d KiB)\n", size); + monitor_printf(mon, "(%d KiB)\n", size); } else { size >>= 10; if (size < 1024) { - qemu_printf("(%d MiB)\n", size); + monitor_printf(mon, "(%d MiB)\n", size); } else { size >>= 10; - qemu_printf("(%d GiB)\n", size); + monitor_printf(mon, "(%d GiB)\n", size); } } } -static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) +static void dump_address_map(Monitor *mon, CPUM68KState *env, + uint32_t root_pointer) { int i, j, k; int tic_size, tic_shift; @@ -545,7 +547,7 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) if (first_logical != 0xffffffff) { size = last_logical + (1 << tic_shift) - first_logical; - print_address_zone(first_logical, + print_address_zone(mon, first_logical, first_physical, size, last_attr); } first_logical = logical; @@ -556,125 +558,125 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) } if (first_logical != logical || (attr & 4) != (last_attr & 4)) { size = logical + (1 << tic_shift) - first_logical; - print_address_zone(first_logical, first_physical, size, last_attr); + print_address_zone(mon, first_logical, first_physical, size, last_attr); } } #define DUMP_CACHEFLAGS(a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU: /* cacheable, write-through */ \ - qemu_printf("T"); \ + monitor_puts(mon, "T"); \ break; \ case M68K_DESC_CM_COPYBK: /* cacheable, copyback */ \ - qemu_printf("C"); \ + monitor_puts(mon, "C"); \ break; \ case M68K_DESC_CM_SERIAL: /* noncachable, serialized */ \ - qemu_printf("S"); \ + monitor_puts(mon, "S"); \ break; \ case M68K_DESC_CM_NCACHE: /* noncachable */ \ - qemu_printf("N"); \ + monitor_puts(mon, "N"); \ break; \ } -static void dump_ttr(uint32_t ttr) +static void dump_ttr(Monitor *mon, uint32_t ttr) { if ((ttr & M68K_TTR_ENABLED) == 0) { - qemu_printf("disabled\n"); + monitor_puts(mon, "disabled\n"); return; } - qemu_printf("Base: 0x%08x Mask: 0x%08x Control: ", - ttr & M68K_TTR_ADDR_BASE, - (ttr & M68K_TTR_ADDR_MASK) << M68K_TTR_ADDR_MASK_SHIFT); + monitor_printf(mon, "Base: 0x%08x Mask: 0x%08x Control: ", + ttr & M68K_TTR_ADDR_BASE, + (ttr & M68K_TTR_ADDR_MASK) << M68K_TTR_ADDR_MASK_SHIFT); switch (ttr & M68K_TTR_SFIELD) { case M68K_TTR_SFIELD_USER: - qemu_printf("U"); + monitor_puts(mon, "U"); break; case M68K_TTR_SFIELD_SUPER: - qemu_printf("S"); + monitor_puts(mon, "S"); break; default: - qemu_printf("*"); + monitor_puts(mon, "*"); break; } DUMP_CACHEFLAGS(ttr); if (ttr & M68K_DESC_WRITEPROT) { - qemu_printf("R"); + monitor_puts(mon, "R"); } else { - qemu_printf("W"); + monitor_puts(mon, "W"); } - qemu_printf(" U: %d\n", (ttr & M68K_DESC_USERATTR) >> + monitor_printf(mon, " U: %d\n", (ttr & M68K_DESC_USERATTR) >> M68K_DESC_USERATTR_SHIFT); } -void dump_mmu(CPUM68KState *env) +void dump_mmu(Monitor *mon, CPUM68KState *env) { if ((env->mmu.tcr & M68K_TCR_ENABLED) == 0) { - qemu_printf("Translation disabled\n"); + monitor_puts(mon, "Translation disabled\n"); return; } - qemu_printf("Page Size: "); + monitor_puts(mon, "Page Size: "); if (env->mmu.tcr & M68K_TCR_PAGE_8K) { - qemu_printf("8kB\n"); + monitor_puts(mon, "8kB\n"); } else { - qemu_printf("4kB\n"); + monitor_puts(mon, "4kB\n"); } - qemu_printf("MMUSR: "); + monitor_puts(mon, "MMUSR: "); if (env->mmu.mmusr & M68K_MMU_B_040) { - qemu_printf("BUS ERROR\n"); + monitor_puts(mon, "BUS ERROR\n"); } else { - qemu_printf("Phy=%08x Flags: ", env->mmu.mmusr & 0xfffff000); + monitor_printf(mon, "Phy=%08x Flags: ", env->mmu.mmusr & 0xfffff000); /* flags found on the page descriptor */ if (env->mmu.mmusr & M68K_MMU_G_040) { - qemu_printf("G"); /* Global */ + monitor_puts(mon, "G"); /* Global */ } else { - qemu_printf("."); + monitor_puts(mon, "."); } if (env->mmu.mmusr & M68K_MMU_S_040) { - qemu_printf("S"); /* Supervisor */ + monitor_puts(mon, "S"); /* Supervisor */ } else { - qemu_printf("."); + monitor_puts(mon, "."); } if (env->mmu.mmusr & M68K_MMU_M_040) { - qemu_printf("M"); /* Modified */ + monitor_puts(mon, "M"); /* Modified */ } else { - qemu_printf("."); + monitor_puts(mon, "."); } if (env->mmu.mmusr & M68K_MMU_WP_040) { - qemu_printf("W"); /* Write protect */ + monitor_puts(mon, "W"); /* Write protect */ } else { - qemu_printf("."); + monitor_puts(mon, "."); } if (env->mmu.mmusr & M68K_MMU_T_040) { - qemu_printf("T"); /* Transparent */ + monitor_puts(mon, "T"); /* Transparent */ } else { - qemu_printf("."); + monitor_puts(mon, "."); } if (env->mmu.mmusr & M68K_MMU_R_040) { - qemu_printf("R"); /* Resident */ + monitor_puts(mon, "R"); /* Resident */ } else { - qemu_printf("."); + monitor_puts(mon, "."); } - qemu_printf(" Cache: "); + monitor_puts(mon, " Cache: "); DUMP_CACHEFLAGS(env->mmu.mmusr); - qemu_printf(" U: %d\n", (env->mmu.mmusr >> 8) & 3); - qemu_printf("\n"); + monitor_printf(mon, " U: %d\n", (env->mmu.mmusr >> 8) & 3); + monitor_puts(mon, "\n"); } - qemu_printf("ITTR0: "); - dump_ttr(env->mmu.ttr[M68K_ITTR0]); - qemu_printf("ITTR1: "); - dump_ttr(env->mmu.ttr[M68K_ITTR1]); - qemu_printf("DTTR0: "); - dump_ttr(env->mmu.ttr[M68K_DTTR0]); - qemu_printf("DTTR1: "); - dump_ttr(env->mmu.ttr[M68K_DTTR1]); + monitor_puts(mon, "ITTR0: "); + dump_ttr(mon, env->mmu.ttr[M68K_ITTR0]); + monitor_puts(mon, "ITTR1: "); + dump_ttr(mon, env->mmu.ttr[M68K_ITTR1]); + monitor_puts(mon, "DTTR0: "); + dump_ttr(mon, env->mmu.ttr[M68K_DTTR0]); + monitor_puts(mon, "DTTR1: "); + dump_ttr(mon, env->mmu.ttr[M68K_DTTR1]); - qemu_printf("SRP: 0x%08x\n", env->mmu.srp); - dump_address_map(env, env->mmu.srp); + monitor_printf(mon, "SRP: 0x%08x\n", env->mmu.srp); + dump_address_map(mon, env, env->mmu.srp); - qemu_printf("URP: 0x%08x\n", env->mmu.urp); - dump_address_map(env, env->mmu.urp); + monitor_printf(mon, "URP: 0x%08x\n", env->mmu.urp); + dump_address_map(mon, env, env->mmu.urp); } static int check_TTR(uint32_t ttr, int *prot, target_ulong addr, diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c index 2bdf6acae0..623c6ab635 100644 --- a/target/m68k/monitor.c +++ b/target/m68k/monitor.c @@ -15,11 +15,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) CPUArchState *env1 = mon_get_cpu_env(mon); if (!env1) { - monitor_printf(mon, "No CPU available\n"); + monitor_puts(mon, "No CPU available\n"); return; } - dump_mmu(env1); + dump_mmu(mon, env1); } static const MonitorDef monitor_defs[] = { From patchwork Thu Mar 21 15:48:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781568 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900520wrj; Thu, 21 Mar 2024 08:50:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVvDHZfbobEdhamU+X2dwKxNGi2v47kLDg2YiZN1aHY67g8boO3wHU4YGRKbo7LP3WH+kVwtmi2L3tUM9wR1zRI X-Google-Smtp-Source: AGHT+IHDzmkvg49YEhEMWSBgQcRLmuQHYhrkeae8Oaf8nql+4zaaflIveZlfAqmkgBbzb84TPq/E X-Received: by 2002:a05:600c:4452:b0:414:92e:3b81 with SMTP id v18-20020a05600c445200b00414092e3b81mr11895216wmn.3.1711036239053; Thu, 21 Mar 2024 08:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036239; cv=none; d=google.com; s=arc-20160816; b=aU2cNkfKbicFb0X91Tbfmhea0ucS5tG/Q/Vbz7pcCHIkV6S7a3Pyqlste7CTzN+lRd gAgYvW/kaqvBMTkHjXTw2/Gb4eqRX8QbKaDSj9xomAvrb+jR8QZCpLbYMAXqwCma6Ewv t2XK1OXvyuHXIrRqPGrQwSOeFpVebzU4BcaVD5HXW/vY34tp7E+toKoxYYZVhK/KOAwZ fPl6mLpL6wQ7i9xHw3CfI/QgSMhDYeCRK9iferAHpyp1yfLpZs4txNbZZy8NIlB+qLiI qK3K6gOjflsE63J+OI+rexKyoJkxwL79b/+REZSMZFOwJMVEKCCiJbjMY3L4LUqy5ytY eKOA== 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=xtEYan//81EtbsPaWQKotnbuaiGDwRNY8wJpHHZftjo=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=QQR4vD1T9P9CvButoRCRuGaEYdryPL5A69xmhnhhloLj1LwPFHtAi+hx6gtxeXo+/3 4OX4jBcklB+4lWae5X7gtUvKHCd8AGkySvg9Qw1MfC7ImliVwzmRfIk9njo67PBkjDYC ikFN1TuPVHZFtzMhcCZCPu2ERiaKHrAs2dlS4MTp22Ds73yC2YS+LmgAMLnuI/nQn8+h HOlTTxFBK2/i2OTeYGrplw6Pwx5lHS5In6Sniq7y6HO3PCB4//+AXkSpz0WdxaUq3mHP LDlJ09Jia5n0gvW3pxF4A/AtvlifRR9r1rwP90RBcCWz1PFquZy7EYMnwtky2P++Jt8b aBlg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wku3XQxQ; 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 bd12-20020a05600c1f0c00b004146a2192f9si2474573wmb.16.2024.03.21.08.50.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:50:39 -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=Wku3XQxQ; 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 1rnKfe-0005BI-KT; Thu, 21 Mar 2024 11:49:34 -0400 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 1rnKfd-00053b-1K for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:33 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfb-0001N5-HG for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:32 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d23114b19dso16605011fa.3 for ; Thu, 21 Mar 2024 08:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036169; x=1711640969; darn=nongnu.org; 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=xtEYan//81EtbsPaWQKotnbuaiGDwRNY8wJpHHZftjo=; b=Wku3XQxQuTrrTfU9SDHTMjvCfVXwMkDhw3/xkTzDRd48qF3Zg815r3L7suIfL7LlDV sNJKsNRRrwj5Kufu+to1kWwCH8XtBG5WsUZlqSwqNa2/L1dc/E+M5cT7EUu8qmxTf6j+ cYt3BmdirCA+JZHRscApikUwbOVezz7A3dMIUz2yzp2LksfBOPt3yv74zhx4JKf6tDZW PgONOU4+DanuuPjNBDq66xMR9OEDyhZsLck/+JDC0DOktmwtj7OoXGw6Wd9v1EdUZhpP imKme1FjA0pPpVCW6huY/6+vo6J8uLI3yzM2jcNtZG/LQC5VzaLdbHb9NBHKZBJQK1vR 1PzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036169; x=1711640969; 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=xtEYan//81EtbsPaWQKotnbuaiGDwRNY8wJpHHZftjo=; b=IXX1phTFj3KslVpL2oBgts91Kclcm7IRCt0jbTsXACR1bwgaXwAC3ThAPbj0Xmh5FN kr1SsdmeGomNbfHGA5++JXlcPMSpE6dZme2Bfzw16NHeh1mYKxU34ofI2J1dBH3UApbw 2eyLmyZ61rOpZwZPyiNKbP8exogEirnXd2hPWemMeh3Jc1xvE8Myw13mpcREScXu8u+j 9KRNAjt2im45sWjr6uPyRlQM0WxRWF0nRPvFU9tp0Jd5xh61EqYfr1e/751M5KWhIWTx Xk8/9KbXuFgSFmhfbHdNc/jC1YjPDVMSuxAUTE9cOWFd8jvIB2cl53UbOD+bn1TWrrUe Kd8g== X-Gm-Message-State: AOJu0YxX/cqW+LrjYUiqVxst2xMwnomgXqUtyOCqYPfjv7TUizGr78eH EJibdLGUjTifkQH6YhvZSIctwRpJtir/8pLKEASp/vgJ9ThLdn4Q4SJ98oBVaetGIYovoUUrRKl I/DU= X-Received: by 2002:a2e:9c50:0:b0:2d4:6c08:5f94 with SMTP id t16-20020a2e9c50000000b002d46c085f94mr15024512ljj.37.1711036168978; Thu, 21 Mar 2024 08:49:28 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id r14-20020a05600c35ce00b004146aac1d2asm5952403wmq.27.2024.03.21.08.49.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:49:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 06/21] target/m68k: Have dump_ttr() take a @description argument Date: Thu, 21 Mar 2024 16:48:22 +0100 Message-ID: <20240321154838.95771-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=philmd@linaro.org; helo=mail-lj1-x234.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=unavailable 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 Slightly simplify dump_mmu() by passing the description as argument to dump_ttr(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/m68k/helper.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 310e26dfa1..cf9d83e47e 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -578,8 +578,9 @@ static void dump_address_map(Monitor *mon, CPUM68KState *env, break; \ } -static void dump_ttr(Monitor *mon, uint32_t ttr) +static void dump_ttr(Monitor *mon, const char *desc, uint32_t ttr) { + monitor_printf(mon, "%s: ", desc); if ((ttr & M68K_TTR_ENABLED) == 0) { monitor_puts(mon, "disabled\n"); return; @@ -663,14 +664,10 @@ void dump_mmu(Monitor *mon, CPUM68KState *env) monitor_puts(mon, "\n"); } - monitor_puts(mon, "ITTR0: "); - dump_ttr(mon, env->mmu.ttr[M68K_ITTR0]); - monitor_puts(mon, "ITTR1: "); - dump_ttr(mon, env->mmu.ttr[M68K_ITTR1]); - monitor_puts(mon, "DTTR0: "); - dump_ttr(mon, env->mmu.ttr[M68K_DTTR0]); - monitor_puts(mon, "DTTR1: "); - dump_ttr(mon, env->mmu.ttr[M68K_DTTR1]); + dump_ttr(mon, "ITTR0", env->mmu.ttr[M68K_ITTR0]); + dump_ttr(mon, "ITTR1", env->mmu.ttr[M68K_ITTR1]); + dump_ttr(mon, "DTTR0", env->mmu.ttr[M68K_DTTR0]); + dump_ttr(mon, "DTTR1", env->mmu.ttr[M68K_DTTR1]); monitor_printf(mon, "SRP: 0x%08x\n", env->mmu.srp); dump_address_map(mon, env, env->mmu.srp); From patchwork Thu Mar 21 15:48:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781569 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900570wrj; Thu, 21 Mar 2024 08:50:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXyxHBFjg8Pros8WlpVD8OLH02MP4RPaMJ1uccxodEnQ3AQF5XpD5BMkt7C4wBdCtCMmVoMyCJHBxuI+CHQDQSl X-Google-Smtp-Source: AGHT+IEr+4w4bdpw/w796T470wa6RkLaG3v4SvXrQouME2qVjGpO8nTjz+El2xBOkxD6t9YLdhrW X-Received: by 2002:a05:6000:402b:b0:341:a6ad:5723 with SMTP id cp43-20020a056000402b00b00341a6ad5723mr2716992wrb.21.1711036247105; Thu, 21 Mar 2024 08:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036247; cv=none; d=google.com; s=arc-20160816; b=O0oIlTigywWX0sW91boct3f/lCEptvK1QN57t+0d01zpUm5QtVNbcMoRQKXwShPJmB RXO/ycx6sq0pXXNX7fB2t79QFWuxi4pExNC+us5xakUmlbYmlFxWT7Ci7ktsChlVxZWI kThiFL4PKnE+qh9eiMMgtbl37FpXy7BrHUFAVUD91Yrr2D+Nkh7rnaJZtrU2Q4AUzRVi jzQ9y0fYv9OYecV+AhosnOskjGyhuHHGieShrNTpaME4hZ0cXIImJvAsjbcn9rhv7hbU zkZMj1m8g9HpruSzPdjJXzS9pIN3JdMWTnJhXeJDxQBVut1G6GVBQwjBkKzYdDtgdSXt SYjw== 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=sC//v5zJC26L5oJBPuaKUrq0r2OoFOjOzcD/UQcspDw=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=SRoTi5N00ZWG8DeyXGca5Fg6JBQMIy864IfOM+Blc01AoLXk07UH4dMFWY7XYYel4d 55Cm0WT9M5J5ZbORYnwUHHaZU2XtlI3Y4APEIiixBaQ8JO9XzkKaihVL+aZuVKegZH0+ aWRE8/RYhikqcyRSbwbkVpoMS2JYxE5thq8XxPKB+xu2hxCDMgHxxbATtqp07UKnsd5K H2qOW5ME/WRz+jxnlBK7kko2V3r9HkmuC8mNjste2faL5HBnWLTs4qnddh/QCGG6MB7L 0Zrctr3k1Ww3WQ7HuAQeEkUoZgMJ8cQrMfSYxgB9U+zOD3lGixrC/KMG25UdEZ0455sp anVw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rLh1W1Od; 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 r14-20020adff70e000000b0033e7427a6a7si2349333wrp.20.2024.03.21.08.50.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:50:47 -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=rLh1W1Od; 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 1rnKfp-0005jT-44; Thu, 21 Mar 2024 11:49:45 -0400 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 1rnKfn-0005WT-5f for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:43 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfi-0001QX-QF for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:42 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-41466e01965so7937905e9.3 for ; Thu, 21 Mar 2024 08:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036176; x=1711640976; darn=nongnu.org; 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=sC//v5zJC26L5oJBPuaKUrq0r2OoFOjOzcD/UQcspDw=; b=rLh1W1Od7zUegQVnLB1jrDqxPHf1d6D5npeVhFkEp4oLnUq7aY65Y9e34KL6Vba1NU ULgytPFa7qlfesSywN4X3umHx9JBRaYygYG9mB4zGnwA0pAfiFDcTqz26gl2o4Hphngi Kcu8+nTlKw7lvK3oKfS58nyNUzRExYdmr9UX2q0LmAC2xnmGtK15YqQZ2owCXHqu9tiL nbehf3VitkANQBlMH9dJHVkWYHHI0aH0iBIizLWJllL7XzMXDC7jaCgM4Lf65aQrN4Rm dNPFJIU/4A/+wRIrkvEkGmYJmD6WKperO/3qnJs4TU/vu64ZZNVqQaztmfzuVKvFQpe/ bqkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036176; x=1711640976; 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=sC//v5zJC26L5oJBPuaKUrq0r2OoFOjOzcD/UQcspDw=; b=Jrx9GS0qbfbN32Vb564s4HnpAHwtnSNLXFxQ/bxo61mUgGlskZ2bb8bF3JVCxHxKGO 5bqDkNy5p96jQp2NKbUpRWcTpT2X1ov3/xOgFa42+WV1KcybWfNDvhL1a0rJ1pG07nJh RAMQqOYxwVZfQSu3hseGWw5l0KL/6QH7ctbmbmYHUekzReV9xialY94GbFpV2JvdH7FB AYe/p/8RgZubbpKAzLmvrwRLCRg6zQsVNJoB9lHSf47v0HZAf6YEhAdRJE2ky76KXNX2 PsTSBXEKCmSnjm2fBxLgwP8ppae+c8Nr3cYMq1B/TrNL2R4wAg8cmclmlcPdC8z17qzT nvhQ== X-Gm-Message-State: AOJu0YyoJWU7CbA32iwvvA+YhRVnsTXtiyeMdsL+pkIpbSkzLJIEMtFq aw2C/Q1ie41roGM7hjK6PzY7dKN6ivbh/txPUNUQPs8ujBE0o6O9jwY1MmPcY4gE4GqMELqsVXU V+Eo= X-Received: by 2002:a05:600c:3b19:b0:414:f50:3587 with SMTP id m25-20020a05600c3b1900b004140f503587mr9936764wms.8.1711036176449; Thu, 21 Mar 2024 08:49:36 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id e13-20020a05600c4e4d00b004146750314csm6021722wmq.3.2024.03.21.08.49.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:49:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 07/21] target/m68k: Move MMU monitor commands from helper.c to monitor.c Date: Thu, 21 Mar 2024 16:48:23 +0100 Message-ID: <20240321154838.95771-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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=unavailable 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 Keep all HMP commands in monitor.c. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/m68k/cpu.h | 3 +- target/m68k/helper.c | 222 ----------------------------------------- target/m68k/monitor.c | 223 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 223 insertions(+), 225 deletions(-) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 4e4307956d..0c2a9fa717 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -589,6 +589,7 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); +void m68k_dump_mmu(Monitor *mon, CPUM68KState *env); #endif #include "exec/cpu-all.h" @@ -620,6 +621,4 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu(Monitor *mon, CPUM68KState *env); - #endif diff --git a/target/m68k/helper.c b/target/m68k/helper.c index cf9d83e47e..bd833aed5d 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -25,7 +25,6 @@ #include "exec/helper-proto.h" #include "gdbstub/helpers.h" #include "fpu/softfloat.h" -#include "monitor/monitor.h" #define SIGNBIT (1u << 31) @@ -455,227 +454,6 @@ void m68k_switch_sp(CPUM68KState *env) #if !defined(CONFIG_USER_ONLY) /* MMU: 68040 only */ -static void print_address_zone(Monitor *mon, - uint32_t logical, uint32_t physical, - uint32_t size, int attr) -{ - monitor_printf(mon, "%08x - %08x -> %08x - %08x %c ", - logical, logical + size - 1, - physical, physical + size - 1, - attr & 4 ? 'W' : '-'); - size >>= 10; - if (size < 1024) { - monitor_printf(mon, "(%d KiB)\n", size); - } else { - size >>= 10; - if (size < 1024) { - monitor_printf(mon, "(%d MiB)\n", size); - } else { - size >>= 10; - monitor_printf(mon, "(%d GiB)\n", size); - } - } -} - -static void dump_address_map(Monitor *mon, CPUM68KState *env, - uint32_t root_pointer) -{ - int i, j, k; - int tic_size, tic_shift; - uint32_t tib_mask; - uint32_t tia, tib, tic; - uint32_t logical = 0xffffffff, physical = 0xffffffff; - uint32_t first_logical = 0xffffffff, first_physical = 0xffffffff; - uint32_t last_logical, last_physical; - int32_t size; - int last_attr = -1, attr = -1; - CPUState *cs = env_cpu(env); - MemTxResult txres; - - if (env->mmu.tcr & M68K_TCR_PAGE_8K) { - /* 8k page */ - tic_size = 32; - tic_shift = 13; - tib_mask = M68K_8K_PAGE_MASK; - } else { - /* 4k page */ - tic_size = 64; - tic_shift = 12; - tib_mask = M68K_4K_PAGE_MASK; - } - for (i = 0; i < M68K_ROOT_POINTER_ENTRIES; i++) { - tia = address_space_ldl(cs->as, M68K_POINTER_BASE(root_pointer) + i * 4, - MEMTXATTRS_UNSPECIFIED, &txres); - if (txres != MEMTX_OK || !M68K_UDT_VALID(tia)) { - continue; - } - for (j = 0; j < M68K_ROOT_POINTER_ENTRIES; j++) { - tib = address_space_ldl(cs->as, M68K_POINTER_BASE(tia) + j * 4, - MEMTXATTRS_UNSPECIFIED, &txres); - if (txres != MEMTX_OK || !M68K_UDT_VALID(tib)) { - continue; - } - for (k = 0; k < tic_size; k++) { - tic = address_space_ldl(cs->as, (tib & tib_mask) + k * 4, - MEMTXATTRS_UNSPECIFIED, &txres); - if (txres != MEMTX_OK || !M68K_PDT_VALID(tic)) { - continue; - } - if (M68K_PDT_INDIRECT(tic)) { - tic = address_space_ldl(cs->as, M68K_INDIRECT_POINTER(tic), - MEMTXATTRS_UNSPECIFIED, &txres); - if (txres != MEMTX_OK) { - continue; - } - } - - last_logical = logical; - logical = (i << M68K_TTS_ROOT_SHIFT) | - (j << M68K_TTS_POINTER_SHIFT) | - (k << tic_shift); - - last_physical = physical; - physical = tic & ~((1 << tic_shift) - 1); - - last_attr = attr; - attr = tic & ((1 << tic_shift) - 1); - - if ((logical != (last_logical + (1 << tic_shift))) || - (physical != (last_physical + (1 << tic_shift))) || - (attr & 4) != (last_attr & 4)) { - - if (first_logical != 0xffffffff) { - size = last_logical + (1 << tic_shift) - - first_logical; - print_address_zone(mon, first_logical, - first_physical, size, last_attr); - } - first_logical = logical; - first_physical = physical; - } - } - } - } - if (first_logical != logical || (attr & 4) != (last_attr & 4)) { - size = logical + (1 << tic_shift) - first_logical; - print_address_zone(mon, first_logical, first_physical, size, last_attr); - } -} - -#define DUMP_CACHEFLAGS(a) \ - switch (a & M68K_DESC_CACHEMODE) { \ - case M68K_DESC_CM_WRTHRU: /* cacheable, write-through */ \ - monitor_puts(mon, "T"); \ - break; \ - case M68K_DESC_CM_COPYBK: /* cacheable, copyback */ \ - monitor_puts(mon, "C"); \ - break; \ - case M68K_DESC_CM_SERIAL: /* noncachable, serialized */ \ - monitor_puts(mon, "S"); \ - break; \ - case M68K_DESC_CM_NCACHE: /* noncachable */ \ - monitor_puts(mon, "N"); \ - break; \ - } - -static void dump_ttr(Monitor *mon, const char *desc, uint32_t ttr) -{ - monitor_printf(mon, "%s: ", desc); - if ((ttr & M68K_TTR_ENABLED) == 0) { - monitor_puts(mon, "disabled\n"); - return; - } - monitor_printf(mon, "Base: 0x%08x Mask: 0x%08x Control: ", - ttr & M68K_TTR_ADDR_BASE, - (ttr & M68K_TTR_ADDR_MASK) << M68K_TTR_ADDR_MASK_SHIFT); - switch (ttr & M68K_TTR_SFIELD) { - case M68K_TTR_SFIELD_USER: - monitor_puts(mon, "U"); - break; - case M68K_TTR_SFIELD_SUPER: - monitor_puts(mon, "S"); - break; - default: - monitor_puts(mon, "*"); - break; - } - DUMP_CACHEFLAGS(ttr); - if (ttr & M68K_DESC_WRITEPROT) { - monitor_puts(mon, "R"); - } else { - monitor_puts(mon, "W"); - } - monitor_printf(mon, " U: %d\n", (ttr & M68K_DESC_USERATTR) >> - M68K_DESC_USERATTR_SHIFT); -} - -void dump_mmu(Monitor *mon, CPUM68KState *env) -{ - if ((env->mmu.tcr & M68K_TCR_ENABLED) == 0) { - monitor_puts(mon, "Translation disabled\n"); - return; - } - monitor_puts(mon, "Page Size: "); - if (env->mmu.tcr & M68K_TCR_PAGE_8K) { - monitor_puts(mon, "8kB\n"); - } else { - monitor_puts(mon, "4kB\n"); - } - - monitor_puts(mon, "MMUSR: "); - if (env->mmu.mmusr & M68K_MMU_B_040) { - monitor_puts(mon, "BUS ERROR\n"); - } else { - monitor_printf(mon, "Phy=%08x Flags: ", env->mmu.mmusr & 0xfffff000); - /* flags found on the page descriptor */ - if (env->mmu.mmusr & M68K_MMU_G_040) { - monitor_puts(mon, "G"); /* Global */ - } else { - monitor_puts(mon, "."); - } - if (env->mmu.mmusr & M68K_MMU_S_040) { - monitor_puts(mon, "S"); /* Supervisor */ - } else { - monitor_puts(mon, "."); - } - if (env->mmu.mmusr & M68K_MMU_M_040) { - monitor_puts(mon, "M"); /* Modified */ - } else { - monitor_puts(mon, "."); - } - if (env->mmu.mmusr & M68K_MMU_WP_040) { - monitor_puts(mon, "W"); /* Write protect */ - } else { - monitor_puts(mon, "."); - } - if (env->mmu.mmusr & M68K_MMU_T_040) { - monitor_puts(mon, "T"); /* Transparent */ - } else { - monitor_puts(mon, "."); - } - if (env->mmu.mmusr & M68K_MMU_R_040) { - monitor_puts(mon, "R"); /* Resident */ - } else { - monitor_puts(mon, "."); - } - monitor_puts(mon, " Cache: "); - DUMP_CACHEFLAGS(env->mmu.mmusr); - monitor_printf(mon, " U: %d\n", (env->mmu.mmusr >> 8) & 3); - monitor_puts(mon, "\n"); - } - - dump_ttr(mon, "ITTR0", env->mmu.ttr[M68K_ITTR0]); - dump_ttr(mon, "ITTR1", env->mmu.ttr[M68K_ITTR1]); - dump_ttr(mon, "DTTR0", env->mmu.ttr[M68K_DTTR0]); - dump_ttr(mon, "DTTR1", env->mmu.ttr[M68K_DTTR1]); - - monitor_printf(mon, "SRP: 0x%08x\n", env->mmu.srp); - dump_address_map(mon, env, env->mmu.srp); - - monitor_printf(mon, "URP: 0x%08x\n", env->mmu.urp); - dump_address_map(mon, env, env->mmu.urp); -} - static int check_TTR(uint32_t ttr, int *prot, target_ulong addr, int access_type) { diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c index 623c6ab635..c225846540 100644 --- a/target/m68k/monitor.c +++ b/target/m68k/monitor.c @@ -10,6 +10,227 @@ #include "monitor/hmp-target.h" #include "monitor/monitor.h" +static void print_address_zone(Monitor *mon, + uint32_t logical, uint32_t physical, + uint32_t size, int attr) +{ + monitor_printf(mon, "%08x - %08x -> %08x - %08x %c ", + logical, logical + size - 1, + physical, physical + size - 1, + attr & 4 ? 'W' : '-'); + size >>= 10; + if (size < 1024) { + monitor_printf(mon, "(%d KiB)\n", size); + } else { + size >>= 10; + if (size < 1024) { + monitor_printf(mon, "(%d MiB)\n", size); + } else { + size >>= 10; + monitor_printf(mon, "(%d GiB)\n", size); + } + } +} + +static void dump_address_map(Monitor *mon, CPUM68KState *env, + uint32_t root_pointer) +{ + int i, j, k; + int tic_size, tic_shift; + uint32_t tib_mask; + uint32_t tia, tib, tic; + uint32_t logical = 0xffffffff, physical = 0xffffffff; + uint32_t first_logical = 0xffffffff, first_physical = 0xffffffff; + uint32_t last_logical, last_physical; + int32_t size; + int last_attr = -1, attr = -1; + CPUState *cs = env_cpu(env); + MemTxResult txres; + + if (env->mmu.tcr & M68K_TCR_PAGE_8K) { + /* 8k page */ + tic_size = 32; + tic_shift = 13; + tib_mask = M68K_8K_PAGE_MASK; + } else { + /* 4k page */ + tic_size = 64; + tic_shift = 12; + tib_mask = M68K_4K_PAGE_MASK; + } + for (i = 0; i < M68K_ROOT_POINTER_ENTRIES; i++) { + tia = address_space_ldl(cs->as, M68K_POINTER_BASE(root_pointer) + i * 4, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK || !M68K_UDT_VALID(tia)) { + continue; + } + for (j = 0; j < M68K_ROOT_POINTER_ENTRIES; j++) { + tib = address_space_ldl(cs->as, M68K_POINTER_BASE(tia) + j * 4, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK || !M68K_UDT_VALID(tib)) { + continue; + } + for (k = 0; k < tic_size; k++) { + tic = address_space_ldl(cs->as, (tib & tib_mask) + k * 4, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK || !M68K_PDT_VALID(tic)) { + continue; + } + if (M68K_PDT_INDIRECT(tic)) { + tic = address_space_ldl(cs->as, M68K_INDIRECT_POINTER(tic), + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK) { + continue; + } + } + + last_logical = logical; + logical = (i << M68K_TTS_ROOT_SHIFT) | + (j << M68K_TTS_POINTER_SHIFT) | + (k << tic_shift); + + last_physical = physical; + physical = tic & ~((1 << tic_shift) - 1); + + last_attr = attr; + attr = tic & ((1 << tic_shift) - 1); + + if ((logical != (last_logical + (1 << tic_shift))) || + (physical != (last_physical + (1 << tic_shift))) || + (attr & 4) != (last_attr & 4)) { + + if (first_logical != 0xffffffff) { + size = last_logical + (1 << tic_shift) - + first_logical; + print_address_zone(mon, first_logical, + first_physical, size, last_attr); + } + first_logical = logical; + first_physical = physical; + } + } + } + } + if (first_logical != logical || (attr & 4) != (last_attr & 4)) { + size = logical + (1 << tic_shift) - first_logical; + print_address_zone(mon, first_logical, first_physical, size, last_attr); + } +} + +#define DUMP_CACHEFLAGS(a) \ + switch (a & M68K_DESC_CACHEMODE) { \ + case M68K_DESC_CM_WRTHRU: /* cacheable, write-through */ \ + monitor_puts(mon, "T"); \ + break; \ + case M68K_DESC_CM_COPYBK: /* cacheable, copyback */ \ + monitor_puts(mon, "C"); \ + break; \ + case M68K_DESC_CM_SERIAL: /* noncachable, serialized */ \ + monitor_puts(mon, "S"); \ + break; \ + case M68K_DESC_CM_NCACHE: /* noncachable */ \ + monitor_puts(mon, "N"); \ + break; \ + } + +static void dump_ttr(Monitor *mon, const char *desc, uint32_t ttr) +{ + monitor_printf(mon, "%s: ", desc); + if ((ttr & M68K_TTR_ENABLED) == 0) { + monitor_puts(mon, "disabled\n"); + return; + } + monitor_printf(mon, "Base: 0x%08x Mask: 0x%08x Control: ", + ttr & M68K_TTR_ADDR_BASE, + (ttr & M68K_TTR_ADDR_MASK) << M68K_TTR_ADDR_MASK_SHIFT); + switch (ttr & M68K_TTR_SFIELD) { + case M68K_TTR_SFIELD_USER: + monitor_puts(mon, "U"); + break; + case M68K_TTR_SFIELD_SUPER: + monitor_puts(mon, "S"); + break; + default: + monitor_puts(mon, "*"); + break; + } + DUMP_CACHEFLAGS(ttr); + if (ttr & M68K_DESC_WRITEPROT) { + monitor_puts(mon, "R"); + } else { + monitor_puts(mon, "W"); + } + monitor_printf(mon, " U: %d\n", (ttr & M68K_DESC_USERATTR) >> + M68K_DESC_USERATTR_SHIFT); +} + +void m68k_dump_mmu(Monitor *mon, CPUM68KState *env) +{ + if ((env->mmu.tcr & M68K_TCR_ENABLED) == 0) { + monitor_puts(mon, "Translation disabled\n"); + return; + } + monitor_puts(mon, "Page Size: "); + if (env->mmu.tcr & M68K_TCR_PAGE_8K) { + monitor_puts(mon, "8kB\n"); + } else { + monitor_puts(mon, "4kB\n"); + } + + monitor_puts(mon, "MMUSR: "); + if (env->mmu.mmusr & M68K_MMU_B_040) { + monitor_puts(mon, "BUS ERROR\n"); + } else { + monitor_printf(mon, "Phy=%08x Flags: ", env->mmu.mmusr & 0xfffff000); + /* flags found on the page descriptor */ + if (env->mmu.mmusr & M68K_MMU_G_040) { + monitor_puts(mon, "G"); /* Global */ + } else { + monitor_puts(mon, "."); + } + if (env->mmu.mmusr & M68K_MMU_S_040) { + monitor_puts(mon, "S"); /* Supervisor */ + } else { + monitor_puts(mon, "."); + } + if (env->mmu.mmusr & M68K_MMU_M_040) { + monitor_puts(mon, "M"); /* Modified */ + } else { + monitor_puts(mon, "."); + } + if (env->mmu.mmusr & M68K_MMU_WP_040) { + monitor_puts(mon, "W"); /* Write protect */ + } else { + monitor_puts(mon, "."); + } + if (env->mmu.mmusr & M68K_MMU_T_040) { + monitor_puts(mon, "T"); /* Transparent */ + } else { + monitor_puts(mon, "."); + } + if (env->mmu.mmusr & M68K_MMU_R_040) { + monitor_puts(mon, "R"); /* Resident */ + } else { + monitor_puts(mon, "."); + } + monitor_puts(mon, " Cache: "); + DUMP_CACHEFLAGS(env->mmu.mmusr); + monitor_printf(mon, " U: %d\n", (env->mmu.mmusr >> 8) & 3); + monitor_puts(mon, "\n"); + } + + dump_ttr(mon, "ITTR0", env->mmu.ttr[M68K_ITTR0]); + dump_ttr(mon, "ITTR1", env->mmu.ttr[M68K_ITTR1]); + dump_ttr(mon, "DTTR0", env->mmu.ttr[M68K_DTTR0]); + dump_ttr(mon, "DTTR1", env->mmu.ttr[M68K_DTTR1]); + + monitor_printf(mon, "SRP: 0x%08x\n", env->mmu.srp); + dump_address_map(mon, env, env->mmu.srp); + + monitor_printf(mon, "URP: 0x%08x\n", env->mmu.urp); + dump_address_map(mon, env, env->mmu.urp); +} + void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env1 = mon_get_cpu_env(mon); @@ -19,7 +240,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) return; } - dump_mmu(mon, env1); + m68k_dump_mmu(mon, env1); } static const MonitorDef monitor_defs[] = { From patchwork Thu Mar 21 15:48:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781566 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900269wrj; Thu, 21 Mar 2024 08:50:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMGuDbbGKcxsYiBw/PU2RZJyfl1zRQew9hYNYVEqJM7xSekf5s5FtlLVIJWcVp8s8d9a8NOp9DolFVQ4kzYkyW X-Google-Smtp-Source: AGHT+IE6CwzCa0MFeRVTBXVCsZvN4oYtiQpmggkwzuKqXOdMNFA/Ij0opFXD6aqkfQ5FuMD0GhrG X-Received: by 2002:a05:622a:1189:b0:430:adb9:b438 with SMTP id m9-20020a05622a118900b00430adb9b438mr2831785qtk.30.1711036203359; Thu, 21 Mar 2024 08:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036203; cv=none; d=google.com; s=arc-20160816; b=ziYnvrJNL2ixDQtgsZ23kGrglMX7L+dZOlBlnTwqenNsB1vmJC9TSNeDHPkRyHM+Gt H88Vojyk291QVTybFknKR7khEIUAP+BmiWcU5iR5xkrMTYwtoec58RYfn7h86xUkhfef fZkaAwUbi01z3zf31HyoG68Pk14m9b8eGasuj1ZpmL9t9gotRYIUj682mFouJ/iYAEg7 EhLbS/ZExaNAKmxWHlL+Yf6BM8vKXkz9KQv3K43bcAj3daJ7IelQc4Lyx/x8cSHPZ4FB 7nju9gRygeYWbSCZGkJOSIVS3JNP0nS74c0MIo+3fbE3YUz4yaGIhxWD7CY4dYVTWqgx 4O4A== 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=ixdOqShX9KqafF5GwQuaCwGyEwXeRiDzckfnzkN3U94=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=GZwfyfBk0g5Ust5OThpE0pufRF8YTVidkgqhuRgcZa380wgcbesQ+hyGzu9vBFJBRs /VS4QL7TF6aTzmboPhIdPSjb79/EApIIIZpfKLbmglr6aUjrN48p8YSufABwzycwRlfu f0q+Vx6i6O1qw0iA/ZybfvVsvWIhzHnk1iRtZ9+TiEc7cHIW04o1S0FhT8zib+gQV7hp IE7o/kwvZ0wLshJfysT8lzpa02sznGkOm5uGTCjGCkd+VSwR/1qzNEu1gioIoo4uyIm3 p9Rku2AtP2YgSFWhORTTn+E88TaXSwaSjY0K05//KH5i9Xuf6m66QSn0LTJjRCeoNgN7 sCyg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UnID0Ae5; 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 p19-20020a05622a049300b00430c047d336si11478054qtx.526.2024.03.21.08.50.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:50:03 -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=UnID0Ae5; 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 1rnKfx-0006E8-3Q; Thu, 21 Mar 2024 11:49:53 -0400 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 1rnKfs-000634-9m for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:48 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfq-0001SO-FJ for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:48 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4146e9e45c8so10115745e9.1 for ; Thu, 21 Mar 2024 08:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036184; x=1711640984; darn=nongnu.org; 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=ixdOqShX9KqafF5GwQuaCwGyEwXeRiDzckfnzkN3U94=; b=UnID0Ae5MKyY/fyy2cT6RVtXoxlZIiT1eHYasi+L/YHRmrlqdj0FlTcA20DE5NiKkn YTpJeDk7uEOjqFQWqcLHdmLRVwFx4OiXzqUjgxxDsIfuqjTMNrkbLVfKokjZp9nZ/Gsg ybg60pfuoJK4V9nH1+roAteeBwDReeBVQJ5DDo0LdtZd1x46D0ZDzqdFBDaWBH4OzQPB oCiiIWP3ebeTz9A9ut9YeFjwAyxQnGA+V4UEvJhzkwT+MzL45hAkmXKsOHuNup1d1N9V iE+NvN0II3+7hSaGUskMbCbs8vX8ygDZVJW9e+Rwb399yyFjNnZ4S952QZOVbUK/TH60 jlcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036184; x=1711640984; 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=ixdOqShX9KqafF5GwQuaCwGyEwXeRiDzckfnzkN3U94=; b=Rj8mnlCoofCudkCFmMuW09eYcDWJsU1XHcoUz/d2617hvDxChejLJ3xHN25iY/ZCZ9 snHm3U6xbeiORdS2EasazAzpAEhJvubghg2k82iw4hd7ovwlrM5qyVfQwDpnsu89WesV Tmd60mxj1jpPOiBomUCsTYLVRYuBtrxuaZFDWcPt2e182Y5hyBmIQ8z3AYODfsTcmzyv NhINQajiyEfjxmVLOURZz5Tn8O41viU/FGVrFaOrcxJjpaNOrV3KvzsyQngpIQmaw4JU Ocj/s6rfFI6aweJX4AheKEoEyGSSL7Z8YK9FStuziqkBrOBsUXLir26NMnnhJXmM1WD2 ltEA== X-Gm-Message-State: AOJu0YzsqLy5fxB6L9HbqkGo31ENoQtdFSZwkQey3h4N/PoMXIAzUpOL aAc5ol3ohEzENUReoBU4srOBHYrMXVZEuS/KC48SWhKioY8YtwBVQOb9e6OhFjAQAL45vY43cVX 8ObU= X-Received: by 2002:a5d:52d1:0:b0:33e:6a81:d8b9 with SMTP id r17-20020a5d52d1000000b0033e6a81d8b9mr2590546wrv.20.1711036184109; Thu, 21 Mar 2024 08:49:44 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id o9-20020adfe809000000b0033ec6ebf878sm17419893wrm.93.2024.03.21.08.49.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:49:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 08/21] target/microblaze: Prefix MMU API with 'mb_' Date: Thu, 21 Mar 2024 16:48:24 +0100 Message-ID: <20240321154838.95771-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 MicroBlaze MMU API is exposed in "mmu.h". In order to avoid name clashing with other targets, prefix the API with 'mb_'. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias --- target/microblaze/mmu.h | 10 +++++----- target/microblaze/cpu.c | 2 +- target/microblaze/helper.c | 4 ++-- target/microblaze/mmu.c | 14 +++++++------- target/microblaze/op_helper.c | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/target/microblaze/mmu.h b/target/microblaze/mmu.h index 1068bd2d52..5b51e0a9c6 100644 --- a/target/microblaze/mmu.h +++ b/target/microblaze/mmu.h @@ -85,10 +85,10 @@ typedef struct { } err; } MicroBlazeMMULookup; -unsigned int mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu, - target_ulong vaddr, MMUAccessType rw, int mmu_idx); -uint32_t mmu_read(CPUMBState *env, bool ea, uint32_t rn); -void mmu_write(CPUMBState *env, bool ea, uint32_t rn, uint32_t v); -void mmu_init(MicroBlazeMMU *mmu); +unsigned int mb_mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu, + target_ulong vaddr, MMUAccessType rw, int mmu_idx); +uint32_t mb_mmu_read(CPUMBState *env, bool ea, uint32_t rn); +void mb_mmu_write(CPUMBState *env, bool ea, uint32_t rn, uint32_t v); +void mb_mmu_init(MicroBlazeMMU *mmu); #endif diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 96c2b71f7f..59bfb5c45d 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -205,7 +205,7 @@ static void mb_cpu_reset_hold(Object *obj) mb_cpu_write_msr(env, MSR_EE | MSR_IE | MSR_VM | MSR_UM); #else mb_cpu_write_msr(env, 0); - mmu_init(&env->mmu); + mb_mmu_init(&env->mmu); #endif } diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index d25c9eb4d3..961687bae7 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -57,7 +57,7 @@ bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size, return true; } - hit = mmu_translate(cpu, &lu, address, access_type, mmu_idx); + hit = mb_mmu_translate(cpu, &lu, address, access_type, mmu_idx); if (likely(hit)) { uint32_t vaddr = address & TARGET_PAGE_MASK; uint32_t paddr = lu.paddr + vaddr - lu.vaddr; @@ -238,7 +238,7 @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, attrs->secure = mb_cpu_access_is_secure(cpu, MMU_DATA_LOAD); if (mmu_idx != MMU_NOMMU_IDX) { - hit = mmu_translate(cpu, &lu, addr, 0, 0); + hit = mb_mmu_translate(cpu, &lu, addr, 0, 0); if (hit) { vaddr = addr & TARGET_PAGE_MASK; paddr = lu.paddr + vaddr - lu.vaddr; diff --git a/target/microblaze/mmu.c b/target/microblaze/mmu.c index 234006634e..5fb8ee8418 100644 --- a/target/microblaze/mmu.c +++ b/target/microblaze/mmu.c @@ -74,8 +74,8 @@ static void mmu_change_pid(CPUMBState *env, unsigned int newpid) } /* rw - 0 = read, 1 = write, 2 = fetch. */ -unsigned int mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu, - target_ulong vaddr, MMUAccessType rw, int mmu_idx) +unsigned int mb_mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu, + target_ulong vaddr, MMUAccessType rw, int mmu_idx) { MicroBlazeMMU *mmu = &cpu->env.mmu; unsigned int i, hit = 0; @@ -175,7 +175,7 @@ done: } /* Writes/reads to the MMU's special regs end up here. */ -uint32_t mmu_read(CPUMBState *env, bool ext, uint32_t rn) +uint32_t mb_mmu_read(CPUMBState *env, bool ext, uint32_t rn) { MicroBlazeCPU *cpu = env_archcpu(env); unsigned int i; @@ -228,7 +228,7 @@ uint32_t mmu_read(CPUMBState *env, bool ext, uint32_t rn) return r; } -void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) +void mb_mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) { MicroBlazeCPU *cpu = env_archcpu(env); uint64_t tmp64; @@ -304,8 +304,8 @@ void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) return; } - hit = mmu_translate(cpu, &lu, v & TLB_EPN_MASK, - 0, cpu_mmu_index(env_cpu(env), false)); + hit = mb_mmu_translate(cpu, &lu, v & TLB_EPN_MASK, + 0, cpu_mmu_index(env_cpu(env), false)); if (hit) { env->mmu.regs[MMU_R_TLBX] = lu.idx; } else { @@ -319,7 +319,7 @@ void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) } } -void mmu_init(MicroBlazeMMU *mmu) +void mb_mmu_init(MicroBlazeMMU *mmu) { int i; for (i = 0; i < ARRAY_SIZE(mmu->regs); i++) { diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c index f6378030b7..58475a3af5 100644 --- a/target/microblaze/op_helper.c +++ b/target/microblaze/op_helper.c @@ -386,12 +386,12 @@ void helper_stackprot(CPUMBState *env, target_ulong addr) /* Writes/reads to the MMU's special regs end up here. */ uint32_t helper_mmu_read(CPUMBState *env, uint32_t ext, uint32_t rn) { - return mmu_read(env, ext, rn); + return mb_mmu_read(env, ext, rn); } void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v) { - mmu_write(env, ext, rn, v); + mb_mmu_write(env, ext, rn, v); } void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, From patchwork Thu Mar 21 15:48:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781567 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900481wrj; Thu, 21 Mar 2024 08:50:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUkncAvP1/3ecl/lIIXaQIijRgEQ7v9ykbXidz2RDLWWwGTIzl+H7bUYceSZox7X8OotpTYEh7aDnxdc0PVl737 X-Google-Smtp-Source: AGHT+IGNcOgOIRhMqsrJCjR0fb1BIOZUzKIx/i1MJXNYN2sXtxutBP1lnUl2/BtU8S0rmAund4Po X-Received: by 2002:a05:6000:36c:b0:33e:d227:6708 with SMTP id f12-20020a056000036c00b0033ed2276708mr4264491wrf.63.1711036231549; Thu, 21 Mar 2024 08:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036231; cv=none; d=google.com; s=arc-20160816; b=aN1+NWDH3bXeEd0oBcYh/gjpXZItCHRMqkEqb9Dt6YUj9T7sWFq/iIluti/X4Rv29z WdPRkPi8J7KnUNNeDtD53aeiE8UYQnkjJa/2VOTh4GosIeV82k9u1P9yRdU8948x7Crx OVNb2Z7lF/CyJK+Pn3sssEWpQ8yO7A1ZIc4ZF9YQXwfCj/0AbbSZta97WHZXWGiiqEii pm5H62YnuM2Ew6TTXndArzxNRmhJPb2sUnK/0Zvbkb8v23NwWmT0+bsQi7pedK/lxydi 0R6svcFvbCs1HhxkGY8TQq2aYxlCJvzfltEmNFt6dhJB8Y2CdeL8u6EUVv4QgDaz23ov nD0g== 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=/ByGtnAj40FIgzzc5+9YA5mVdDA+/CNg+MM7X/H831Q=; fh=81LkYeqFCwFGXorwOD0SYkLarUYOalk3AqJBgUYZgWc=; b=K6XorlynqIq+s9AfKsa5AlcXjdAij6G1/lt6PlaVwJxbFw9ZEsSS4pbSNjF2Bb6Ivt 7o2OWPhVl1YhG0MGHMlb8j1BFfRL8Mc9mKeOGYYykwm7o24c6XTcBzqcC/8XcT9NlCDo DDzHKfWn8lUrg0AlS2ALGK5bo4NCo8R+pr3JznTbvPjSOIkAv5bOtnkjGXbRz7bJbkOg xsPGA4Yzz0jwL5bNA2iVlWk/J6X4+ereXhgVz9ssZsn5Nf1OKL6GP9F98hl8frLJDiUR nPwjIElZSqTm/7W+xIuStELvpHY90HY+4UnVbSvvzvBMjFqluEoohVy5CqCeKKyVY1Xp EU1Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eouEY2oG; 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 w17-20020adfee51000000b0033ec8a546f5si8457575wro.34.2024.03.21.08.50.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:50:31 -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=eouEY2oG; 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 1rnKg3-0006V3-Bq; Thu, 21 Mar 2024 11:49:59 -0400 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 1rnKg1-0006Oq-DS for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:57 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfy-0001UM-P8 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:49:56 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-414700cffd6so8776605e9.1 for ; Thu, 21 Mar 2024 08:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036192; x=1711640992; darn=nongnu.org; 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=/ByGtnAj40FIgzzc5+9YA5mVdDA+/CNg+MM7X/H831Q=; b=eouEY2oGgzd5llVOOxZvaytQsD+HTpAg69ASK6D8w7e17YeBjS7YfBi15/2szVz9Gu vywRw+Te3UkA9J+IbhNtZaO5kMxaLvpN2ufnwQ4cspPC5r0i+3vYoXqkVy1tct8vTxlk XWEOFEkfGGJ5IEO+zjbeaS1g7Dn/lNJoFtWfmnq5hblBJTvsVCeIJpmX49sjIySItBRF UeWLmOMqSxMvsZtZn36NngJ9U3ZJFkATujAhzos83/skqcaAJOUAWazoAY87cisTVT8s bg+dCPeyJTOuo7rPgHLia2elJ/OfUoh4xy2X4428nlJXNg1A67ETnzmICgQVlDrg6FyW UgqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036192; x=1711640992; 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=/ByGtnAj40FIgzzc5+9YA5mVdDA+/CNg+MM7X/H831Q=; b=iXTVruPlFy201zBkx2ZBLdXQ0pWM3y99H/I819yL02G12UkE8nnrUVU4sY61dj9jyR AuVHZSZp1VRAGkTz6nIPQNI6ZbYSwFMe+De1hHvo/SXY8tluxG/+nUjnnanxLXP3eSKh 77SiNovsXJ+vo/m92DNSqiJ9+/rCqtLkTa5yFeyBiZJV4mk6FF/emawIjbV6ulbwCCeZ mxYqrL/5SzCAVWUqF87fV6WkrUsBFuiRpSFlsDqTMjWcgVp1Tjojxm24v7t4SdWleI2o bHuaJS1Uj1Cv9MsBEASMmA3RXQe0x4RxtxSaiv5kDQVoUveffN5wmkvmSHbNdK5aEwfg hQBg== X-Gm-Message-State: AOJu0YwuxpidNh+KLXxq9LApeWwjAtnSmNvegJnpCc8UQuYTVP60NUv9 RkigaCDObHgwMDcSasNK48vVq3u7zVnTmGKs9C0lHtSQ9xKayNUxVIvWC52kSsPM8udU/qy8YDn Mf9E= X-Received: by 2002:a05:600c:a4b:b0:414:85f:1f72 with SMTP id c11-20020a05600c0a4b00b00414085f1f72mr4265147wmq.6.1711036191940; Thu, 21 Mar 2024 08:49:51 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id g8-20020a05600c4ec800b0041408451874sm5958377wmq.17.2024.03.21.08.49.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:49:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Aurelien Jarno , Aleksandar Rikalo Subject: [PATCH-for-9.1 09/21] target/mips: Prefix MMU API with 'mips_' Date: Thu, 21 Mar 2024 16:48:25 +0100 Message-ID: <20240321154838.95771-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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=unavailable 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 MIPS MMU API declared in tcg-internal.h has public linkage. In order to avoid name clashing with other targets, prefix the API with 'mips_'. Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/tcg-internal.h | 2 +- target/mips/cpu.c | 2 +- target/mips/tcg/sysemu/tlb_helper.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target/mips/tcg/tcg-internal.h b/target/mips/tcg/tcg-internal.h index aef032c48d..2dc9d9100f 100644 --- a/target/mips/tcg/tcg-internal.h +++ b/target/mips/tcg/tcg-internal.h @@ -43,7 +43,7 @@ void do_raise_exception(CPUMIPSState *env, void mips_cpu_do_interrupt(CPUState *cpu); bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req); -void mmu_init(CPUMIPSState *env, const mips_def_t *def); +void mips_mmu_init(CPUMIPSState *env, const mips_def_t *def); void update_pagemask(CPUMIPSState *env, target_ulong arg1, int32_t *pagemask); diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 8d8f690a53..8acf691b0b 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -485,7 +485,7 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp) env->exception_base = (int32_t)0xBFC00000; #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) - mmu_init(env, env->cpu_model); + mips_mmu_init(env, env->cpu_model); #endif fpu_init(env, env->cpu_model); mvp_init(env); diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_helper.c index 119eae771e..0167b1162f 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -464,7 +464,7 @@ static void r4k_mmu_init(CPUMIPSState *env, const mips_def_t *def) env->tlb->helper_tlbinvf = r4k_helper_tlbinvf; } -void mmu_init(CPUMIPSState *env, const mips_def_t *def) +void mips_mmu_init(CPUMIPSState *env, const mips_def_t *def) { env->tlb = g_malloc0(sizeof(CPUMIPSTLBContext)); From patchwork Thu Mar 21 15:48:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781570 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900620wrj; Thu, 21 Mar 2024 08:50:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVA4t0N6Hf2CkXa+7AGMUH0LBHcvnTdlOsZtTbYPCR7woJdrPrK0OLt6Qqceu7pm/j9LCGopQB0D5rt82AIOjmN X-Google-Smtp-Source: AGHT+IFns9HSW5aWJ4GD1//Q1ziefJsAFGX1oEOpYFuV3BI+FxeKIK03qqSr7uc0QhOVBXKT9ZGt X-Received: by 2002:a05:651c:1a0b:b0:2d4:9873:dc2d with SMTP id by11-20020a05651c1a0b00b002d49873dc2dmr4212425ljb.17.1711036252629; Thu, 21 Mar 2024 08:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036252; cv=none; d=google.com; s=arc-20160816; b=g84ChOrJATEaYJATeayiUy1E5z65aM5k0/FMA9fOvRyAIT4JI8cPTaDnIhDXYNaxPb WkXz7bD+UiaTLkIp0dViBDMud13pICrKlrGYUVwjbQ9dj02OGlx//tihxhdTczZlfHIZ r+9LL8wPZ8EhmCaEfYKdcozDzWFKS1rOjlLZhPRAL7TT451T94yzY59TJLB7xFt7DVw6 +qGqQjW5dK8UINzhVBhrPwDhl6zMQYOMfM2JcDTwy+5XRn2sKYUCzl+rwJ9KDbXOAPZr tXzMCU+LqnJXy9f9mLmQi/yKycez+2U7EZRiuBjftEC/c1EcMaQ9yKc69uw5EsRg1nx1 hFew== 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=QNyIdceODiq/qXWOadWFMGnL31bcMZmdSI8jHE35wz0=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=tpuwD/W+kWxZoDVzykVypPxIShPCbGFM1+dtlDLm81LwLwjI6Z7OtbBaf/PI9gyr27 5iOQ+SI2o3c3DMFOmiC3lkt4STagPDwR6/u3LPiM9RmE9xvwEP7HxKZItP6Rs801VzN2 OXgI3tomJmPK6qu+gjFhPil0WojO4dYMMI4DJdLD8GNDPofF6qLqRYAbw+0nExU11uUb sYmphpr/3dQS91fGSPdZKfzl+7jmSQdI43fMOV3ecp0gWkvnZcECCIRtwEtbLzvh5dgN lge1rNo8fjLI70o0MUQx3PGDuJ/BVjMFWtfIChUDN+wGhZGHfPpYCj7+U/dovopm6opL mzbQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Smq9a7zf; 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 c7-20020a5d63c7000000b0033e77b4f0dcsi8580586wrw.577.2024.03.21.08.50.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:50:52 -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=Smq9a7zf; 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 1rnKgC-0006wv-5Y; Thu, 21 Mar 2024 11:50:08 -0400 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 1rnKg9-0006uB-E5 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:05 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKg5-0001WM-Io for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:04 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-414689ba80eso9363545e9.2 for ; Thu, 21 Mar 2024 08:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036200; x=1711641000; darn=nongnu.org; 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=QNyIdceODiq/qXWOadWFMGnL31bcMZmdSI8jHE35wz0=; b=Smq9a7zfKTqK+KhZXshSHRabhcw0GtHOyVn4Z/GJUMC/E+Qckk4GtJ8g7cTvQXwmSI BxwLKPD5NDmBzCJgXgStUdjEM/UeWsT2jSwYHkXsMIeEYTnr9/tGvJqvLHZPIaWrlOQK twgLZAUbzroHkMLG+Qv6uwNV7q5AQL58sZ7OY8IHsNkpAIqujiiDaqkhIkI1Uyy4K8OO iZBAcJfQQspILjhhQr3bdG8/AegAxO5egpoxDlEP1kJBkNVzhZKlOspCWund8PBW+ZXT stTUpYc5usgkzAZW+Sfw9qodR56lqCHW0mMQgjHZKs12AQyCePnWL50KpRwSjFRD/+yS Ibsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036200; x=1711641000; 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=QNyIdceODiq/qXWOadWFMGnL31bcMZmdSI8jHE35wz0=; b=IrWLXTrECYDREiZWUG1phDpm0r1cvUGI0HnCPGrkWZXYmTfqnZV2APuk9BlJ2RzBtx FLILgTxqKsgE5vWVY+wauChFesihH+oTQBAEYF9ijTqVWEK0Xp8SGlwrgRbd6jU3n9pp PmHDJCD6TQOIBsb8YwdTkmSEt2UqCfBbqNxxs1xJmz304oqxgLOeLyYE9rxbe4M6HuB3 v84fenbTkSxuM7mliCNo+zEd6hXMaVviipuuma3MmZlWI0fTs3YzAopij4fRow6FvGcm nCNVSitoVR/UUGD+4KHTNNwWG7RMsAjCO0v5f/BrfY4nch2Ayqwd9d7Z5kJw8c63cN8h jg1A== X-Gm-Message-State: AOJu0YwXUVMPeCnHDf7l0eYNUrS8SJkHaFPfusEVbJj3VC9obpMjkfi7 NOfTIW0CKaPBv5r1quFhFIQ2g0g6ILv9sLeLBkvRFpWkPCsKPnK02cAufFiT4Mqtp8c/FUKh0wh tn6Q= X-Received: by 2002:a05:600c:3b90:b0:413:2f8e:dd0b with SMTP id n16-20020a05600c3b9000b004132f8edd0bmr4127988wms.26.1711036199798; Thu, 21 Mar 2024 08:49:59 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id q18-20020adff792000000b0033ec9b26b7asm17495211wrp.25.2024.03.21.08.49.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:49:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 10/21] target/nios2: Prefix MMU API with 'nios2_' Date: Thu, 21 Mar 2024 16:48:26 +0100 Message-ID: <20240321154838.95771-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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 Nios2 MMU API is exposed in "mmu.h". In order to avoid name clashing with other targets, prefix the API with 'nios2_'. Signed-off-by: Philippe Mathieu-Daudé --- target/nios2/mmu.h | 11 +++++------ target/nios2/cpu.c | 2 +- target/nios2/helper.c | 4 ++-- target/nios2/mmu.c | 7 +++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/target/nios2/mmu.h b/target/nios2/mmu.h index 5b085900fb..5b16a5facf 100644 --- a/target/nios2/mmu.h +++ b/target/nios2/mmu.h @@ -42,11 +42,10 @@ typedef struct Nios2MMULookup { int prot; } Nios2MMULookup; -void mmu_flip_um(CPUNios2State *env, unsigned int um); -unsigned int mmu_translate(CPUNios2State *env, - Nios2MMULookup *lu, - target_ulong vaddr, int rw, int mmu_idx); -void mmu_write(CPUNios2State *env, uint32_t rn, uint32_t v); -void mmu_init(CPUNios2State *env); +void nios2_mmu_flip_um(CPUNios2State *env, unsigned int um); +unsigned int nios2_mmu_translate(CPUNios2State *env, Nios2MMULookup *lu, + target_ulong vaddr, int rw, int mmu_idx); +void nios2_mmu_write(CPUNios2State *env, uint32_t rn, uint32_t v); +void nios2_mmu_init(CPUNios2State *env); #endif /* NIOS2_MMU_H */ diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 679aff5730..d2a9a0d4f1 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -113,7 +113,7 @@ static void nios2_cpu_initfn(Object *obj) #if !defined(CONFIG_USER_ONLY) Nios2CPU *cpu = NIOS2_CPU(obj); - mmu_init(&cpu->env); + nios2_mmu_init(&cpu->env); #endif } diff --git a/target/nios2/helper.c b/target/nios2/helper.c index ac57121afc..2b6bdfbc55 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -268,7 +268,7 @@ hwaddr nios2_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) unsigned int hit; if (cpu->mmu_present && (addr < 0xC0000000)) { - hit = mmu_translate(env, &lu, addr, 0, 0); + hit = nios2_mmu_translate(env, &lu, addr, 0, 0); if (hit) { vaddr = addr & TARGET_PAGE_MASK; paddr = lu.paddr + vaddr - lu.vaddr; @@ -335,7 +335,7 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } /* Virtual page. */ - hit = mmu_translate(env, &lu, address, access_type, mmu_idx); + hit = nios2_mmu_translate(env, &lu, address, access_type, mmu_idx); if (hit) { vaddr = address & TARGET_PAGE_MASK; paddr = lu.paddr + vaddr - lu.vaddr; diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index d9b690b78e..272bd9fc6a 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -28,9 +28,8 @@ /* rw - 0 = read, 1 = write, 2 = fetch. */ -unsigned int mmu_translate(CPUNios2State *env, - Nios2MMULookup *lu, - target_ulong vaddr, int rw, int mmu_idx) +unsigned int nios2_mmu_translate(CPUNios2State *env, Nios2MMULookup *lu, + target_ulong vaddr, int rw, int mmu_idx) { Nios2CPU *cpu = env_archcpu(env); int pid = FIELD_EX32(env->mmu.tlbmisc_wr, CR_TLBMISC, PID); @@ -180,7 +179,7 @@ void helper_mmu_write_pteaddr(CPUNios2State *env, uint32_t v) env->mmu.pteaddr_wr = v; } -void mmu_init(CPUNios2State *env) +void nios2_mmu_init(CPUNios2State *env) { Nios2CPU *cpu = env_archcpu(env); Nios2MMU *mmu = &env->mmu; From patchwork Thu Mar 21 15:48:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781575 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901260wrj; Thu, 21 Mar 2024 08:52:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3sTEQlE/v49c5V3q2TqZItyYcMKMPV+PXvjbodkLsy6H7YZKX1OtpyH5zITSS4xEOn1DvSnG18Fpd+ePKRZQP X-Google-Smtp-Source: AGHT+IGJV1imgEgdhufE1NG959bN+SsWjZyp6BGjARMWiDztkcSZ9Vexuriq3eVSAulssTNp0sg8 X-Received: by 2002:adf:fec9:0:b0:341:84ec:fff8 with SMTP id q9-20020adffec9000000b0034184ecfff8mr1812187wrs.20.1711036326451; Thu, 21 Mar 2024 08:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036326; cv=none; d=google.com; s=arc-20160816; b=GKVF1j4eeGs7zz+5RrtuCQt8XxwrRF56rxfFdaiOqMObtm+mTeIospKH74gyD++257 k1Y2dSCCBwKW67NxrhCVOZcKFEw3LHDfE5ZWrc2oUH86SxMcZm9BKH8OhrIiaBZP38Yi XzZZkXc78bvuOCLoVaHddFLY/qCCrfjvUtGAcxQ2GlH1a1L6g8L4B4cQa7NeRTKCHftR lbgtSp5QWhru7UxjrRs2gi4R7ypWyqW3TpAH+jDnunWg6VtuBIV3ocVR+W+MyPNRT+8+ Ksy2q+nJEnv4gDKzNUuDpA6ilWPs9VivWffP0fUP8v6zLqWd1zrB7wTwCoNzUyXTZi89 irOw== 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=kaYDCoOXgjCF3J0hi/NBXkeoqt0AB2bCPsQIdEK8J3A=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=Wyr3966xZEaJIjBpoKad/bCnJykLWzd7t4oRscpbrAboOCSWArtX9I8eOnQtR/LSx3 dsexpDBjc+UbnpTkN6efwUPMsaul9iZVPFPi3L6AeAiglbBMH4OeLzATdyc9zLruxX1d IKagwfszTbf0VK822x6tkrB4T6RvqI6FgFxXUvzWetRxI1knPZZoNRU84GN1RZf0an1c zCDbFrsY87A1QF92BRCzSTeHFfQ6ruJaFrqppR7H9AYKjFd4Z6SbVc4OvPebGEJqkUCC SnYRfn/nPda/IM7wcyqk2Kom1RjMqXJjKhASium8qSB9ZuT5mvB+Svq+POfqko8X7CAi cecw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=beIQHEzs; 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 m8-20020a5d6a08000000b0033e9b918413si8507212wru.1037.2024.03.21.08.52.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:52:06 -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=beIQHEzs; 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 1rnKgZ-0007Qd-9V; Thu, 21 Mar 2024 11:50:31 -0400 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 1rnKgH-00070o-Qf for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:14 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgE-0001ko-9V for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:12 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-414776775d3so2813905e9.3 for ; Thu, 21 Mar 2024 08:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036207; x=1711641007; darn=nongnu.org; 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=kaYDCoOXgjCF3J0hi/NBXkeoqt0AB2bCPsQIdEK8J3A=; b=beIQHEzsMkZHTnO66WKDRpglA39EuEcATRPxx/Fj3DZJu4HCENmfm51036hrCVrwE8 AsAlRaA8tzvgRTYQfnoIer1h0cieAy4hhSTKS0DRoovqnJfuSPYjvtekA4GtDS9zs26n diolqu7sCCrxGs08ZAFhIb+U1tniflycdUlG2pSsNQUOUe2OssgFBC+Y1gtsdy6QwRla gkuR2XZZmDXvTN98qNJIj/t+LOWrmJBERq6L4sqS2uQlRRjXUGrluzsRWya/vRmU4xdn 3cQElUiPEdBCj94BdGVPCG0TtLcxrOH+XyCEG806Ng4/NOvSByKXUCI74yfJwMqNAIcr HaLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036207; x=1711641007; 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=kaYDCoOXgjCF3J0hi/NBXkeoqt0AB2bCPsQIdEK8J3A=; b=XPueGN7nIHd+ReadXcacNWzyHF4T8KUqmOSvgRQaZogb5gWi1J08woWS4MT4Yl2zeb 4uU4gCAHl1sJSibG9Ptc5GHKXcbkxhC+JJNve6Mb1o/XT4nYxDSeAhJRh70Z2X+EbfJn Y+lS96rb9aCMFpR6Ob2f5xhF3OT2evvuCDzlYlsWfjfrEGJlSBBjt8c0tziB8/u2tPy/ 7cm02IsiOKiOmWZm9QanTjLqOANZOKSEOds/sqiixJ9UTKx+5xz0PdVj2cXiYCWFMU2r d+45c4iGv45tEOmyQTSgyU154LLpna/xrrKJYBI/TKkY1Xao8geNFA8a1OFH3q4A/dzk 4F7A== X-Gm-Message-State: AOJu0YxR8CpVeCrBdXr9YBNTnhVDxxnYJx3YH9zynwbWLfAV5gI/I3Kp iB+wjO4KB3oKmZUuYrfuHO9/Ge9Gr7nhLhtQJPE8qX9bfNq3jPbmGsfh/AoDmLinUBvidfULXRl mlas= X-Received: by 2002:a05:600c:1c20:b0:414:645c:33cd with SMTP id j32-20020a05600c1c2000b00414645c33cdmr1714797wms.32.1711036207350; Thu, 21 Mar 2024 08:50:07 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id n18-20020a05600c501200b004146bdce3fesm5885327wmr.4.2024.03.21.08.50.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 11/21] target/nios2: Move monitor commands to monitor.c Date: Thu, 21 Mar 2024 16:48:27 +0100 Message-ID: <20240321154838.95771-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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 Move 'info tlb' monitor commands to monitor.c, rename dump_mmu() as nios2_info_mmu(). Signed-off-by: Philippe Mathieu-Daudé --- target/nios2/cpu.h | 2 +- target/nios2/mmu.c | 27 --------------------------- target/nios2/monitor.c | 28 +++++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 4164a3432e..27e835cf40 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -250,7 +250,7 @@ static inline void nios2_update_crs(CPUNios2State *env) void nios2_tcg_init(void); void nios2_cpu_do_interrupt(CPUState *cs); -void dump_mmu(CPUNios2State *env); +void nios2_info_mmu(Monitor *mon, CPUNios2State *env); void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags); G_NORETURN void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 272bd9fc6a..278eba1b0a 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -19,7 +19,6 @@ */ #include "qemu/osdep.h" -#include "qemu/qemu-print.h" #include "cpu.h" #include "exec/exec-all.h" #include "mmu.h" @@ -187,29 +186,3 @@ void nios2_mmu_init(CPUNios2State *env) mmu->tlb_entry_mask = (cpu->tlb_num_entries / cpu->tlb_num_ways) - 1; mmu->tlb = g_new0(Nios2TLBEntry, cpu->tlb_num_entries); } - -void dump_mmu(CPUNios2State *env) -{ - Nios2CPU *cpu = env_archcpu(env); - int i; - - qemu_printf("MMU: ways %d, entries %d, pid bits %d\n", - cpu->tlb_num_ways, cpu->tlb_num_entries, - cpu->pid_num_bits); - - for (i = 0; i < cpu->tlb_num_entries; i++) { - Nios2TLBEntry *entry = &env->mmu.tlb[i]; - qemu_printf("TLB[%d] = %08X %08X %c VPN %05X " - "PID %02X %c PFN %05X %c%c%c%c\n", - i, entry->tag, entry->data, - (entry->tag & (1 << 10)) ? 'V' : '-', - entry->tag >> 12, - entry->tag & ((1 << cpu->pid_num_bits) - 1), - (entry->tag & (1 << 11)) ? 'G' : '-', - FIELD_EX32(entry->data, CR_TLBACC, PFN), - (entry->data & CR_TLBACC_C) ? 'C' : '-', - (entry->data & CR_TLBACC_R) ? 'R' : '-', - (entry->data & CR_TLBACC_W) ? 'W' : '-', - (entry->data & CR_TLBACC_X) ? 'X' : '-'); - } -} diff --git a/target/nios2/monitor.c b/target/nios2/monitor.c index 0152dec3fa..c6043769e4 100644 --- a/target/nios2/monitor.c +++ b/target/nios2/monitor.c @@ -22,14 +22,40 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "monitor/monitor.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" +void nios2_info_mmu(Monitor *mon, CPUNios2State *env) +{ + Nios2CPU *cpu = env_archcpu(env); + + qemu_printf("MMU: ways %d, entries %d, pid bits %d\n", + cpu->tlb_num_ways, cpu->tlb_num_entries, + cpu->pid_num_bits); + + for (int i = 0; i < cpu->tlb_num_entries; i++) { + Nios2TLBEntry *entry = &env->mmu.tlb[i]; + qemu_printf("TLB[%d] = %08X %08X %c VPN %05X " + "PID %02X %c PFN %05X %c%c%c%c\n", + i, entry->tag, entry->data, + (entry->tag & (1 << 10)) ? 'V' : '-', + entry->tag >> 12, + entry->tag & ((1 << cpu->pid_num_bits) - 1), + (entry->tag & (1 << 11)) ? 'G' : '-', + FIELD_EX32(entry->data, CR_TLBACC, PFN), + (entry->data & CR_TLBACC_C) ? 'C' : '-', + (entry->data & CR_TLBACC_R) ? 'R' : '-', + (entry->data & CR_TLBACC_W) ? 'W' : '-', + (entry->data & CR_TLBACC_X) ? 'X' : '-'); + } +} + void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env1 = mon_get_cpu_env(mon); - dump_mmu(env1); + nios2_info_mmu(mon, env1); } From patchwork Thu Mar 21 15:48:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781580 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901862wrj; Thu, 21 Mar 2024 08:53:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWcXZWfECnCznMr7PBS+UINnppa/Qslyu18ae0wt8vFq5diDwCx2+d2+pnwnrGb5d9GYUczMY027qifgL9hwdUY X-Google-Smtp-Source: AGHT+IEzF+b/uxw70vUqL2cj/UE2JrYsdt0eon38P4lTp2o+hzw3bEO9EshwyQCr+2fV0QZ3fiX2 X-Received: by 2002:a2e:a366:0:b0:2d4:3078:ef3d with SMTP id i6-20020a2ea366000000b002d43078ef3dmr2332998ljn.1.1711036401730; Thu, 21 Mar 2024 08:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036401; cv=none; d=google.com; s=arc-20160816; b=fWOjh0tizTSVXPFDPJqA1FWGIA2PgLQ56OSZStt5ls87fobmpLOgk1K2775+S+EeQO 7GTfqypQRvgNdzEHFDhrGeZxGhtlGTpOPJ/EN2wNSLXG4wJ//VKq0e2M54ko6P26z+28 xh+xzrJ/Y7PuCNR09/8hg4Ymc4taXL8bwOjXyswxRSMV8VVuxJ9IHB1Jt6dV0Fidc4E+ hTqZmSMz6igzm9B3MkqKWB9cbnH3UIv74hVcF/3gFgyIGBZF8CWZK56h9UBxTINVVA5m fcS1LfRQXQ7Pak6o6BtUmtgXQLXgbfhJRHFlfJdrfjjFnirW65iIQkJW1NOZ81MSoEzS /F5Q== 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=4LWS7xvFoegnF0mSZFeKjpH3HSq3m0fIT12twQQtV6g=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=tqsQVNiTb9euwJObJbxscYbdiVFqZOOe4cyJRG5RfyK81+VS2er2JAw92IyfSlPd1Z 5vI1/NwzYu1idSOss0GgGtU2eq7ZeD2/zOvULoBJm+fqRouN5sjmG5KYodnMNaJqdDeW Xlo4kqpsh4zUUsaqlUQQWLPsPttu2yAkjjQfy/pBAI0x/j6BI1vsrUy3ARHn9LWSZVNc gD4TS0XEbhShGeB8nW6GvHCp9eWCSjJglLzuPVI7fQF8VB4jrMuM4Dh4oNmMa7RZeDXs tbBVR4oawP9L5OFh1HVxqPHA61oZKHE/+DenodJTaDa2mdzkeS3XpOCrj1bjqG88U0In xr+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GIJEQf92; 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 x2-20020a05600c21c200b00412db208a10si56637wmj.189.2024.03.21.08.53.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:53:21 -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=GIJEQf92; 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 1rnKgZ-0007Vl-WB; Thu, 21 Mar 2024 11:50:32 -0400 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 1rnKgT-0007D7-Pr for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:27 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgM-0001nA-79 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:20 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-414633f7a52so11074275e9.0 for ; Thu, 21 Mar 2024 08:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036215; x=1711641015; darn=nongnu.org; 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=4LWS7xvFoegnF0mSZFeKjpH3HSq3m0fIT12twQQtV6g=; b=GIJEQf922Ov9ko0AHycgKkxdholgPW4TsZEYJIp/JtC+udhgtiBLppSC6DU9/YiIV8 Moj4MlkPnPNxe9jAlF3mFtTcnwmjQNYFcPx+iHLDJ60Zl3YD1o52r8KyVGCcBW3sxfDh iiEkt3eNlNl9gSanFoiAPZB/S7+3J6oQxI2Zv7XqdPg09yDUlcCDyXZYf5dZ40lSbmuI BuaCPDmfnmbhvL0uWvQPU820GE3d0i/lXJ8tQ12q7VJD1v14R8mxLbyxjm66gTf2oXr3 03Lk2CVMV5RyOjX6aCKLR/ur2E7Naet5SfMCaBkCcdoTRjimWet7TUqjMkZ11jlrdyxd FnJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036215; x=1711641015; 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=4LWS7xvFoegnF0mSZFeKjpH3HSq3m0fIT12twQQtV6g=; b=w5qgDKXdBE2VNFwDtTI/jIS0T5R/MqIn6xd5UMxt6zFPUbMle7UsDjVoT+h4PxYp6T tAxXnKHmQoam3T82IJsBwDTt+hfqij1ffHhoTNY9agP3Jha3qOCdm5PdhY9V/cHM+NIS lM/lAzQCqL6y9phjMxiAFBm/vcUwjHUVQuwjimSSJIqmWGJ9KDr8dE+l2cTaHMdN6rr0 IvYgYTsrOWQxbE1xmZZJRvtSHiDqtEjkLd3qcouOmgYAGAc8+lm0C6l66L9/70ka0FPD Q1ibQ8D9GAJUKuQIAPDms6eFNQy8miNl2WxrIQPXlgMTf0kDbuzyKru3ss4rklPa5Cfj VG4A== X-Gm-Message-State: AOJu0Yz/0RrWgw75hp2556XG4QchdwrLuBr/uWXLTFQkilfccwVmT3rf juS6LenuKZpw58A5G0J7LENAWGZEBt62xQoXBYoKqJA50p0oFjAvZOpnFQfT18IUIvaizueo/g8 hS18= X-Received: by 2002:a05:600c:4e8f:b0:414:1fc:2ef3 with SMTP id f15-20020a05600c4e8f00b0041401fc2ef3mr2378590wmq.29.1711036215092; Thu, 21 Mar 2024 08:50:15 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id iv13-20020a05600c548d00b0041463334822sm134735wmb.26.2024.03.21.08.50.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 12/21] target/nios2: Replace qemu_printf() by monitor_printf() in monitor Date: Thu, 21 Mar 2024 16:48:28 +0100 Message-ID: <20240321154838.95771-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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=unavailable 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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster --- target/nios2/monitor.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/target/nios2/monitor.c b/target/nios2/monitor.c index c6043769e4..983c16d7f8 100644 --- a/target/nios2/monitor.c +++ b/target/nios2/monitor.c @@ -22,7 +22,6 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "qemu/qemu-print.h" #include "cpu.h" #include "monitor/monitor.h" #include "monitor/hmp-target.h" @@ -32,24 +31,24 @@ void nios2_info_mmu(Monitor *mon, CPUNios2State *env) { Nios2CPU *cpu = env_archcpu(env); - qemu_printf("MMU: ways %d, entries %d, pid bits %d\n", - cpu->tlb_num_ways, cpu->tlb_num_entries, - cpu->pid_num_bits); + monitor_printf(mon, "MMU: ways %d, entries %d, pid bits %d\n", + cpu->tlb_num_ways, cpu->tlb_num_entries, + cpu->pid_num_bits); for (int i = 0; i < cpu->tlb_num_entries; i++) { Nios2TLBEntry *entry = &env->mmu.tlb[i]; - qemu_printf("TLB[%d] = %08X %08X %c VPN %05X " - "PID %02X %c PFN %05X %c%c%c%c\n", - i, entry->tag, entry->data, - (entry->tag & (1 << 10)) ? 'V' : '-', - entry->tag >> 12, - entry->tag & ((1 << cpu->pid_num_bits) - 1), - (entry->tag & (1 << 11)) ? 'G' : '-', - FIELD_EX32(entry->data, CR_TLBACC, PFN), - (entry->data & CR_TLBACC_C) ? 'C' : '-', - (entry->data & CR_TLBACC_R) ? 'R' : '-', - (entry->data & CR_TLBACC_W) ? 'W' : '-', - (entry->data & CR_TLBACC_X) ? 'X' : '-'); + monitor_printf(mon, "TLB[%d] = %08X %08X %c VPN %05X " + "PID %02X %c PFN %05X %c%c%c%c\n", + i, entry->tag, entry->data, + (entry->tag & (1 << 10)) ? 'V' : '-', + entry->tag >> 12, + entry->tag & ((1 << cpu->pid_num_bits) - 1), + (entry->tag & (1 << 11)) ? 'G' : '-', + FIELD_EX32(entry->data, CR_TLBACC, PFN), + (entry->data & CR_TLBACC_C) ? 'C' : '-', + (entry->data & CR_TLBACC_R) ? 'R' : '-', + (entry->data & CR_TLBACC_W) ? 'W' : '-', + (entry->data & CR_TLBACC_X) ? 'X' : '-'); } } From patchwork Thu Mar 21 15:48:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781582 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp902111wrj; Thu, 21 Mar 2024 08:53:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLF2D+jniiQQ70iWohsrfJSULVinTEiFbmxC2tmkPlIqjCnmDlnMFoiOZ8UF3DhJLFa1Xl15KMh6d78esYbGxm X-Google-Smtp-Source: AGHT+IEuI//HCU3cIXltxVlH6CSDke/W3/DdZCQeZ2C2iPHNeNJw50aJMTex5PhFDG7L5GwYPsyT X-Received: by 2002:a2e:86c7:0:b0:2d6:9b54:b5df with SMTP id n7-20020a2e86c7000000b002d69b54b5dfmr2198214ljj.31.1711036434633; Thu, 21 Mar 2024 08:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036434; cv=none; d=google.com; s=arc-20160816; b=qaT0GLgfeZgRWBY+LEJLIG7bwYrt1q5G23EZNO/iUzDF75jIPTmzZtFNAnH9dYlYWk V4GUC2Z/HmBNEh9ncWekoRV8q2OCWfjZ5FOAF8NXYED/gziUnkceLdZYD0eJVEXWhgn0 t7AVQ4117g+BWVZEZ2dU/mWkoYVJoM4MVfirhan7n2tGA8BINfELaqOi07AP+gGVaqH7 Rb5C44tNJnAwFi/6AhEKucarJpas5EVsyUj7NE3YC5AXDa+LlNbTIA00T1757Iu1fKRj /GRjvFAL9LnmfIJaXXmf4OOdWXj654X8WwO1/AExI8Iu1/Nvpe+WD2kcYKJaBe47aMre HGhw== 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=D3sd7YoSjS7p83F+7iO1jGEskdO0c4OapH9Z6R07/q8=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=SK3dJQIp4ZX8EAIp5wlpvH9NdJRCRZYbuuK52jpSLVdlkx/D7/6awsnJjURHTDyUG4 oap+Nb3Q7ez+KiRtxs0x38u4F7WpT7cpqYNwzvs8+zneKba8F7qhRLFjuVjehpfPtmob PqdR0ZlJ74mYx9dyCVQX/X+3bwaHEsDnKYUyK+EZafpORYWCGmzdcNJJXFlSVHQOytK/ 5jCoBbDcorNPX4ipWZmQqYVzBJh2NYy1jTNGPJuipyY5ND8NucPEyilzEKjCe59K/3Cc BS0O/0tELqHII+dQdAASiPkZiLtwTM64DX9JFuALK6RgjxoE600vrdDQcle+QGors7cj nEag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eCsgufLg; 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 ay5-20020a05600c1e0500b0041462750cffsi2439050wmb.105.2024.03.21.08.53.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:53:54 -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=eCsgufLg; 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 1rnKgd-0007wp-E0; Thu, 21 Mar 2024 11:50:35 -0400 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 1rnKgb-0007ic-Dr for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:33 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgX-0001sl-KM for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:33 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-56bc753f58eso1159807a12.3 for ; Thu, 21 Mar 2024 08:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036222; x=1711641022; darn=nongnu.org; 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=D3sd7YoSjS7p83F+7iO1jGEskdO0c4OapH9Z6R07/q8=; b=eCsgufLgZmATej3m07R3dQOAj47nga20ZLUqwl0uUR32UmuLZxwwa3Aoji3Z9V9rG6 UCyGXFhxAUD9lqCgVhJtZfkTg7RgWw4nz5I7gj5QngL+GNl7PigX188qLQFHovSdBKyj 11Uiu8/dCTQfZ8ALaZZxl0yO5kzkLgy0x9ZeQpmbb9I+QJPvVNqyTXOqoLSmgpclpLs6 6gRVyJLktejXcyJnSMsmkI7AV9bzv2kJr1C6QbhXLI/aMT8TssilK7HTsBMk1y4+T4fU Zk6xz7Fho1T7fCk/96GPBSmX6AF5lHTy/0RPoVgIGWhY6WkIN2DbXEcP8/ZTg9F+mdpl krYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036222; x=1711641022; 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=D3sd7YoSjS7p83F+7iO1jGEskdO0c4OapH9Z6R07/q8=; b=LjQploP2PHwPSA1hj5F0GJRVqpfNl2lz017L+5fg8uNiLb/o+47XRkuVaoha87TbSz vKSMcTjg+MtzbG1rlGz1ojdeuNsT+5Oq3pr1G1Ij44mtr4ioo5rggAtH1G92ouuNIZRg J068yt6PwKMw8KG/v4YK55lLbXPKbFdTgD3JX4Vrmlo325X59jnxhERoQ9YWPMK9vXhw 9AJMrkdfr7xcKvqYLQPtZz45PFnKx58x6zf2PPNqo+RMxmEWd1I7rjfc7DGHqUDwc1Y8 fvvC01eyVPZCmQ1T1vaI0gbCMpQVqcU2GdCRVbQ5HB5pza7Vqs5tTSm7Yf83Jqpiu/sc 9CTg== X-Gm-Message-State: AOJu0Yz4iuJc9D7wXy7lxOGFDPbc/PJYl90dl1Iy5XcEZFq/bMCNhcI2 JdDjwozMp8reDKJUuR8J3f3zS40AgaG2SWSY3kd2icoSedpKnGxIbmyvfqYOlAvIuBsW73FegCs HVZ4= X-Received: by 2002:a05:6402:e83:b0:568:b46c:c4ba with SMTP id h3-20020a0564020e8300b00568b46cc4bamr4264429eda.30.1711036222254; Thu, 21 Mar 2024 08:50:22 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id ew3-20020a056402538300b0056b2c5c58d2sm16219edb.21.2024.03.21.08.50.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 13/21] target/ppc: Replace qemu_printf() by monitor_printf() in monitor Date: Thu, 21 Mar 2024 16:48:29 +0100 Message-ID: <20240321154838.95771-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=philmd@linaro.org; helo=mail-ed1-x530.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 Replace qemu_printf() by monitor_printf() / monitor_puts() in monitor. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster --- target/ppc/cpu.h | 2 +- target/ppc/mmu_common.c | 147 +++++++++++++++++++------------------- target/ppc/ppc-qmp-cmds.c | 2 +- 3 files changed, 77 insertions(+), 74 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 67e6b2effd..52ac667470 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -2982,7 +2982,7 @@ static inline bool ppc_interrupts_little_endian(PowerPCCPU *cpu, bool hv) } #endif -void dump_mmu(CPUPPCState *env); +void ppc_dump_mmu(Monitor *mon, CPUPPCState *env); void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len); void ppc_store_vscr(CPUPPCState *env, uint32_t vscr); diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 751403f1c8..ba8e91b949 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -32,6 +32,7 @@ #include "internal.h" #include "mmu-book3s-v3.h" #include "mmu-radix64.h" +#include "monitor/monitor.h" /* #define DUMP_PAGE_TABLES */ @@ -924,21 +925,21 @@ static const char *book3e_tsize_to_str[32] = { "1T", "2T" }; -static void mmubooke_dump_mmu(CPUPPCState *env) +static void mmubooke_dump_mmu(Monitor *mon, CPUPPCState *env) { ppcemb_tlb_t *entry; int i; #ifdef CONFIG_KVM if (kvm_enabled() && !env->kvm_sw_tlb) { - qemu_printf("Cannot access KVM TLB\n"); + monitor_puts(mon, "Cannot access KVM TLB\n"); return; } #endif - qemu_printf("\nTLB:\n"); - qemu_printf("Effective Physical Size PID Prot " - "Attr\n"); + monitor_puts(mon, "\nTLB:\n"); + monitor_puts(mon, "Effective Physical Size PID Prot " + "Attr\n"); entry = &env->tlb.tlbe[0]; for (i = 0; i < env->nb_tlb; i++, entry++) { @@ -962,22 +963,22 @@ static void mmubooke_dump_mmu(CPUPPCState *env) } else { snprintf(size_buf, sizeof(size_buf), "%3" PRId64 "k", size / KiB); } - qemu_printf("0x%016" PRIx64 " 0x%016" PRIx64 " %s %-5u %08x %08x\n", - (uint64_t)ea, (uint64_t)pa, size_buf, (uint32_t)entry->PID, - entry->prot, entry->attr); + monitor_printf(mon, "0x%016" PRIx64 " 0x%016" PRIx64 " %s %-5u %08x %08x\n", + (uint64_t)ea, (uint64_t)pa, size_buf, (uint32_t)entry->PID, + entry->prot, entry->attr); } } -static void mmubooke206_dump_one_tlb(CPUPPCState *env, int tlbn, int offset, - int tlbsize) +static void mmubooke206_dump_one_tlb(Monitor *mon, CPUPPCState *env, + int tlbn, int offset, int tlbsize) { ppcmas_tlb_t *entry; int i; - qemu_printf("\nTLB%d:\n", tlbn); - qemu_printf("Effective Physical Size TID TS SRWX" - " URWX WIMGE U0123\n"); + monitor_printf(mon, "\nTLB%d:\n", tlbn); + monitor_puts(mon, "Effective Physical Size TID TS SRWX" + " URWX WIMGE U0123\n"); entry = &env->tlb.tlbm[offset]; for (i = 0; i < tlbsize; i++, entry++) { @@ -993,38 +994,38 @@ static void mmubooke206_dump_one_tlb(CPUPPCState *env, int tlbn, int offset, ea = entry->mas2 & ~(size - 1); pa = entry->mas7_3 & ~(size - 1); - qemu_printf("0x%016" PRIx64 " 0x%016" PRIx64 " %4s %-5u %1u S%c%c%c" - " U%c%c%c %c%c%c%c%c U%c%c%c%c\n", - (uint64_t)ea, (uint64_t)pa, - book3e_tsize_to_str[tsize], - (entry->mas1 & MAS1_TID_MASK) >> MAS1_TID_SHIFT, - (entry->mas1 & MAS1_TS) >> MAS1_TS_SHIFT, - entry->mas7_3 & MAS3_SR ? 'R' : '-', - entry->mas7_3 & MAS3_SW ? 'W' : '-', - entry->mas7_3 & MAS3_SX ? 'X' : '-', - entry->mas7_3 & MAS3_UR ? 'R' : '-', - entry->mas7_3 & MAS3_UW ? 'W' : '-', - entry->mas7_3 & MAS3_UX ? 'X' : '-', - entry->mas2 & MAS2_W ? 'W' : '-', - entry->mas2 & MAS2_I ? 'I' : '-', - entry->mas2 & MAS2_M ? 'M' : '-', - entry->mas2 & MAS2_G ? 'G' : '-', - entry->mas2 & MAS2_E ? 'E' : '-', - entry->mas7_3 & MAS3_U0 ? '0' : '-', - entry->mas7_3 & MAS3_U1 ? '1' : '-', - entry->mas7_3 & MAS3_U2 ? '2' : '-', - entry->mas7_3 & MAS3_U3 ? '3' : '-'); + monitor_printf(mon, "0x%016" PRIx64 " 0x%016" PRIx64 " %4s %-5u %1u S%c%c%c" + " U%c%c%c %c%c%c%c%c U%c%c%c%c\n", + (uint64_t)ea, (uint64_t)pa, + book3e_tsize_to_str[tsize], + (entry->mas1 & MAS1_TID_MASK) >> MAS1_TID_SHIFT, + (entry->mas1 & MAS1_TS) >> MAS1_TS_SHIFT, + entry->mas7_3 & MAS3_SR ? 'R' : '-', + entry->mas7_3 & MAS3_SW ? 'W' : '-', + entry->mas7_3 & MAS3_SX ? 'X' : '-', + entry->mas7_3 & MAS3_UR ? 'R' : '-', + entry->mas7_3 & MAS3_UW ? 'W' : '-', + entry->mas7_3 & MAS3_UX ? 'X' : '-', + entry->mas2 & MAS2_W ? 'W' : '-', + entry->mas2 & MAS2_I ? 'I' : '-', + entry->mas2 & MAS2_M ? 'M' : '-', + entry->mas2 & MAS2_G ? 'G' : '-', + entry->mas2 & MAS2_E ? 'E' : '-', + entry->mas7_3 & MAS3_U0 ? '0' : '-', + entry->mas7_3 & MAS3_U1 ? '1' : '-', + entry->mas7_3 & MAS3_U2 ? '2' : '-', + entry->mas7_3 & MAS3_U3 ? '3' : '-'); } } -static void mmubooke206_dump_mmu(CPUPPCState *env) +static void mmubooke206_dump_mmu(Monitor *mon, CPUPPCState *env) { int offset = 0; int i; #ifdef CONFIG_KVM if (kvm_enabled() && !env->kvm_sw_tlb) { - qemu_printf("Cannot access KVM TLB\n"); + monitor_puts(mon, "Cannot access KVM TLB\n"); return; } #endif @@ -1036,12 +1037,12 @@ static void mmubooke206_dump_mmu(CPUPPCState *env) continue; } - mmubooke206_dump_one_tlb(env, i, offset, size); + mmubooke206_dump_one_tlb(mon, env, i, offset, size); offset += size; } } -static void mmu6xx_dump_BATs(CPUPPCState *env, int type) +static void mmu6xx_dump_BATs(Monitor *mon, CPUPPCState *env, int type) { target_ulong *BATlt, *BATut, *BATu, *BATl; target_ulong BEPIl, BEPIu, bl; @@ -1064,51 +1065,53 @@ static void mmu6xx_dump_BATs(CPUPPCState *env, int type) BEPIu = *BATu & 0xF0000000; BEPIl = *BATu & 0x0FFE0000; bl = (*BATu & 0x00001FFC) << 15; - qemu_printf("%s BAT%d BATu " TARGET_FMT_lx - " BATl " TARGET_FMT_lx "\n\t" TARGET_FMT_lx " " - TARGET_FMT_lx " " TARGET_FMT_lx "\n", - type == ACCESS_CODE ? "code" : "data", i, - *BATu, *BATl, BEPIu, BEPIl, bl); + monitor_printf(mon, "%s BAT%d BATu " TARGET_FMT_lx + " BATl " TARGET_FMT_lx "\n\t" TARGET_FMT_lx " " + TARGET_FMT_lx " " TARGET_FMT_lx "\n", + type == ACCESS_CODE ? "code" : "data", i, + *BATu, *BATl, BEPIu, BEPIl, bl); } } -static void mmu6xx_dump_mmu(CPUPPCState *env) +static void mmu6xx_dump_mmu(Monitor *mon, CPUPPCState *env) { PowerPCCPU *cpu = env_archcpu(env); ppc6xx_tlb_t *tlb; target_ulong sr; int type, way, entry, i; - qemu_printf("HTAB base = 0x%"HWADDR_PRIx"\n", ppc_hash32_hpt_base(cpu)); - qemu_printf("HTAB mask = 0x%"HWADDR_PRIx"\n", ppc_hash32_hpt_mask(cpu)); + monitor_printf(mon, "HTAB base = 0x%"HWADDR_PRIx"\n", + ppc_hash32_hpt_base(cpu)); + monitor_printf(mon, "HTAB mask = 0x%"HWADDR_PRIx"\n", + ppc_hash32_hpt_mask(cpu)); - qemu_printf("\nSegment registers:\n"); + monitor_puts(mon, "\nSegment registers:\n"); for (i = 0; i < 32; i++) { sr = env->sr[i]; if (sr & 0x80000000) { - qemu_printf("%02d T=%d Ks=%d Kp=%d BUID=0x%03x " - "CNTLR_SPEC=0x%05x\n", i, - sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0, - sr & 0x20000000 ? 1 : 0, (uint32_t)((sr >> 20) & 0x1FF), - (uint32_t)(sr & 0xFFFFF)); + monitor_printf(mon, "%02d T=%d Ks=%d Kp=%d BUID=0x%03x " + "CNTLR_SPEC=0x%05x\n", i, + sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0, + sr & 0x20000000 ? 1 : 0, (uint32_t)((sr >> 20) & 0x1FF), + (uint32_t)(sr & 0xFFFFF)); } else { - qemu_printf("%02d T=%d Ks=%d Kp=%d N=%d VSID=0x%06x\n", i, - sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0, - sr & 0x20000000 ? 1 : 0, sr & 0x10000000 ? 1 : 0, - (uint32_t)(sr & 0x00FFFFFF)); + monitor_printf(mon, "%02d T=%d Ks=%d Kp=%d N=%d VSID=0x%06x\n", i, + sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0, + sr & 0x20000000 ? 1 : 0, sr & 0x10000000 ? 1 : 0, + (uint32_t)(sr & 0x00FFFFFF)); } } - qemu_printf("\nBATs:\n"); - mmu6xx_dump_BATs(env, ACCESS_INT); - mmu6xx_dump_BATs(env, ACCESS_CODE); + monitor_puts(mon, "\nBATs:\n"); + mmu6xx_dump_BATs(mon, env, ACCESS_INT); + mmu6xx_dump_BATs(mon, env, ACCESS_CODE); if (env->id_tlbs != 1) { - qemu_printf("ERROR: 6xx MMU should have separated TLB" - " for code and data\n"); + monitor_puts(mon, "ERROR: 6xx MMU should have separated TLB" + " for code and data\n"); } - qemu_printf("\nTLBs [EPN EPN + SIZE]\n"); + monitor_puts(mon, "\nTLBs [EPN EPN + SIZE]\n"); for (type = 0; type < 2; type++) { for (way = 0; way < env->nb_ways; way++) { @@ -1117,28 +1120,28 @@ static void mmu6xx_dump_mmu(CPUPPCState *env) entry++) { tlb = &env->tlb.tlb6[entry]; - qemu_printf("%s TLB %02d/%02d way:%d %s [" - TARGET_FMT_lx " " TARGET_FMT_lx "]\n", - type ? "code" : "data", entry % env->nb_tlb, - env->nb_tlb, way, - pte_is_valid(tlb->pte0) ? "valid" : "inval", - tlb->EPN, tlb->EPN + TARGET_PAGE_SIZE); + monitor_printf(mon, "%s TLB %02d/%02d way:%d %s [" + TARGET_FMT_lx " " TARGET_FMT_lx "]\n", + type ? "code" : "data", entry % env->nb_tlb, + env->nb_tlb, way, + pte_is_valid(tlb->pte0) ? "valid" : "inval", + tlb->EPN, tlb->EPN + TARGET_PAGE_SIZE); } } } } -void dump_mmu(CPUPPCState *env) +void ppc_dump_mmu(Monitor *mon, CPUPPCState *env) { switch (env->mmu_model) { case POWERPC_MMU_BOOKE: - mmubooke_dump_mmu(env); + mmubooke_dump_mmu(mon, env); break; case POWERPC_MMU_BOOKE206: - mmubooke206_dump_mmu(env); + mmubooke206_dump_mmu(mon, env); break; case POWERPC_MMU_SOFT_6xx: - mmu6xx_dump_mmu(env); + mmu6xx_dump_mmu(mon, env); break; #if defined(TARGET_PPC64) case POWERPC_MMU_64B: diff --git a/target/ppc/ppc-qmp-cmds.c b/target/ppc/ppc-qmp-cmds.c index a25d86a8d1..e798c30f91 100644 --- a/target/ppc/ppc-qmp-cmds.c +++ b/target/ppc/ppc-qmp-cmds.c @@ -88,7 +88,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu(env1); + ppc_dump_mmu(mon, env1); } const MonitorDef monitor_defs[] = { From patchwork Thu Mar 21 15:48:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781572 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901059wrj; Thu, 21 Mar 2024 08:51:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+Si0aZSPlG+3Eq5nuud/s6x9M41bOo7XGMTc5YVOQChX+iuy0Q82qsqaS1QhyX2gsxtgOTj+mujLvgZlBT4SV X-Google-Smtp-Source: AGHT+IHdU0EdIOBpjtrBrO0sPdLiyPnyTiIUKL6Z2j25D/x4Exw+GXrXivWfRXGVGa2z2RliWfiB X-Received: by 2002:a05:6000:1946:b0:33e:7c3f:ee0f with SMTP id e6-20020a056000194600b0033e7c3fee0fmr2072105wry.28.1711036302620; Thu, 21 Mar 2024 08:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036302; cv=none; d=google.com; s=arc-20160816; b=wj2DVeIjAtDgNreUZszZlRzazVTXjB1mkOh0Vowa8Sqy10p9onD4rGKMO1JK2OUk0d ES6mJGybmomDAJ/pIWIinkS+Nn6NB1KAoSVFgPDhyN7eLPu59dyCSc04JQ6yfphaXmFc o0bppGU6Z67faDTuSNKRwwJOfCGeJqAC7ZALN+qplaYt8lGSxxEyucXV3jb2ySRUZKcd qMeU4AKrY5+DiOgXsacGAPX5LWwFaPUnlZJT5b0q+96A3GcsURMfP1C3SAuu50vWwJI/ t2Cwz6fWKv56OU/+4TvicWXz4vUZoMnTM9iFWLv2HOGTrf65tfJHPrWmO7Dxb6Y8y3a+ UFiw== 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=2zDd1vJ1m0kg+6reKiJJAv3Gd7RU3RjeGbW9KAoTqqc=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=usYqAjZ5pTOzPHw8BV8Ba9cOgE9jtwJ9EQxTF3dR/wNSdHRAJtvhH6XJsFtoucnjYE YXNgK/GMIirbLfom65CqGrlI9uSpJ19drbXnOfRNWaqSEulBasSgg46ChcLQbQgWSGJO EXnPOYhLFP1hR3UHZ+NQWJWqFOPWar+Q3PloPL9kjGs/JAE/1Ovsa4JFg313KzHZegRh 2yHkBaYQZs/NbgK2uSTbz9OJ5Dq+yHBa6SSupuSFuH4NCb1YbYHYOwvqrLZX1lsaKiY9 Z3jsYBoyySgg9Xs/KiLkyti0iHMXgnJEC1O66gfjeGO96ecUbRcpW/eL+kr//NkWJ092 rlyQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u2rQNocd; 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 m16-20020a5d6a10000000b0033ec3f42bcasi8638366wru.823.2024.03.21.08.51.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:51:42 -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=u2rQNocd; 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 1rnKgg-0008Eb-00; Thu, 21 Mar 2024 11:50:38 -0400 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 1rnKgc-0007sa-NG for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:35 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgY-000201-RX for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:34 -0400 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-568a53d2ce0so1551729a12.0 for ; Thu, 21 Mar 2024 08:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036229; x=1711641029; darn=nongnu.org; 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=2zDd1vJ1m0kg+6reKiJJAv3Gd7RU3RjeGbW9KAoTqqc=; b=u2rQNocduOI+t1ABSpdjW3mvJpfffGYmGgPrJVlFVeDA3vtsDLVcP5Cxx93Tr7L9qz hTNbCMpaZ8cvsb/UbkofxlsdwT3hdM+rwC4+61rTStbUCPyniEOZIPeqTStEzlN6OM5T vTrY7zF8tGoLmWPFpo67vXHHMTQOCBgE7bfWVwyeJ05NDA4370uH+HAdvNwi0FqlVP3/ okWJcwPgn5lEC3tu/ADITvHQtCkkL7sx58fnHs5rVQth2bBcDzFur8DtMqyMvUljBu8+ aZbFK/ew7Z8NBibcoevMEh5Cm4gDB4qwCNH1Ty6GXCe3FDrVHaNEpoLhs52dFqFttGyd bZSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036229; x=1711641029; 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=2zDd1vJ1m0kg+6reKiJJAv3Gd7RU3RjeGbW9KAoTqqc=; b=Ku5ToJc+3RH/nEmi4KPjO1DX4PjhO6joE6GvCrCFq9jeTjaKq5ZhhRxMk4wVbXNqgF TG5dfBO7M3MVMog6hbKMMalqpN87AfMld7yQxk9JrkANfq3rjtFEKyIdt0AfQBxzkqb4 ivxOfnZn3AloBsRxBF96C3o5kOnpyPtrnpQFhzASXRL4BTqA50m3STQX1mAlrIvG3cgW yexsqRxv+AVJW6k+UMByxRvZG+LVYDGSS0qF6Px2H/beQ4tOz9SAhu5619uGGIkwBE5t BCDsELUuACPQX5WprHsghYIGnrzxsdXDsA3wVGqNbelOmTVgzSiopFGP6atKWL7IfS9Q yjUw== X-Gm-Message-State: AOJu0YwefEHyTM4H5oQO4DI0PgTkoizOBsKTnM34o0GYM301Ldwq7QIU vS1QjvkqbhL/DtTztTSkycLkxHrxLMuDWAQPeUxWbKOXYi7KsRXVF4dKppPigTG4jgQYw/6MQ01 6/RA= X-Received: by 2002:a17:906:a44c:b0:a47:e19:81c7 with SMTP id cb12-20020a170906a44c00b00a470e1981c7mr1678931ejb.21.1711036228996; Thu, 21 Mar 2024 08:50:28 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id o26-20020a17090637da00b00a46e68a1fa0sm54362ejc.53.2024.03.21.08.50.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 14/21] target/sh4: Extract sh4_dump_mmu() from hmp_info_tlb() Date: Thu, 21 Mar 2024 16:48:30 +0100 Message-ID: <20240321154838.95771-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=philmd@linaro.org; helo=mail-ed1-x529.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=unavailable 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 Extract sh4_dump_mmu() from hmp_info_tlb(), replacing monitor_printf(FIXED_STRING_WITHOUT_FORMAT) by monitor_puts(). Signed-off-by: Philippe Mathieu-Daudé --- target/sh4/cpu.h | 2 ++ target/sh4/monitor.c | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 9211da6bde..4e2e9ffd66 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -385,4 +385,6 @@ static inline void cpu_get_tb_cpu_state(CPUSH4State *env, vaddr *pc, #endif } +void sh4_dump_mmu(Monitor *mon, CPUSH4State *env); + #endif /* SH4_CPU_H */ diff --git a/target/sh4/monitor.c b/target/sh4/monitor.c index 2da6a5426e..1befb42b07 100644 --- a/target/sh4/monitor.c +++ b/target/sh4/monitor.c @@ -39,20 +39,28 @@ static void print_tlb(Monitor *mon, int idx, tlb_t *tlb) tlb->d, tlb->wt); } +void sh4_dump_mmu(Monitor *mon, CPUSH4State *env) +{ + int i; + + monitor_puts(mon, "ITLB:\n"); + for (i = 0 ; i < ITLB_SIZE ; i++) { + print_tlb (mon, i, &env->itlb[i]); + } + monitor_puts(mon, "UTLB:\n"); + for (i = 0 ; i < UTLB_SIZE ; i++) { + print_tlb (mon, i, &env->utlb[i]); + } +} + void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env = mon_get_cpu_env(mon); - int i; if (!env) { monitor_printf(mon, "No CPU available\n"); return; } - monitor_printf (mon, "ITLB:\n"); - for (i = 0 ; i < ITLB_SIZE ; i++) - print_tlb (mon, i, &env->itlb[i]); - monitor_printf (mon, "UTLB:\n"); - for (i = 0 ; i < UTLB_SIZE ; i++) - print_tlb (mon, i, &env->utlb[i]); + sh4_dump_mmu(mon, env); } From patchwork Thu Mar 21 15:48:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781571 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp900631wrj; Thu, 21 Mar 2024 08:50:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVom3i8oVTlN5y1OE0f1WV/0lPD/8ewojEvssaCu+P4r+11Dt8+bw4vvWX+wmYyxT1zUrjAC+Vp1xFabCLd96p5 X-Google-Smtp-Source: AGHT+IGpbJfGlvzfbQBPUAvPl/MDzI95SZwA/VVoY2wCvrHDoQbMhv604oTc+/0pIMLoJBnEp54j X-Received: by 2002:a5d:6204:0:b0:33e:764b:ab17 with SMTP id y4-20020a5d6204000000b0033e764bab17mr2851272wru.14.1711036253886; Thu, 21 Mar 2024 08:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036253; cv=none; d=google.com; s=arc-20160816; b=CIQBfYwnLSy8R/Foy8ufsXxo+wzE/DGXmk/lRvhyNSRBXFlcJgaqI+NVgOn/F7p6fy isAz9cpAQVuJA3RtPLJqSrhLYPtB8NJIvI950M3BVpKOLl25RS3/zSnGvVmWFVAyq1r0 cTdT/bLTU1vKbguo/B0THRoMv5GC+4u8oAv4oQTl43EhmgsCLxlzDX8RWFe+VLpSJiXX RTNwJGSGDjQZI+V8ckFRkk87RPM/q3cWrfKioUfubn7lAHhgIRhBTYPX5avT4ZvlpQt3 lK+8RV2YUw/S755VqGkiQg12YZK5uOqQSdCDa1n+XxeK1yo16rQ4obD70P2eso5OkTHY EM9g== 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=3j55vDhtvgXvqb+wl9u2AW0u4cGKkyngFQ2jp+MBRmU=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=icU9709J6VLt4dse38i+zu4V7BwiwoB6xjOPXJlKlkpJQ+rcuSUCsbsG+NYyY58dVm puKU7+pN92IJPydI5AMVWnbX6hGyO7wp681nxB9jIC1XllyjiGPtdL4EmXyQSah4ajhY 7fPpa2vqrQMWQ86j65FF3LF7/N1xYmyD9U5AQm1mR7bEW2/yX0x9JAv9N30A5pTj+1Ix QIUllpbfKcHetgvRZQT4QYLKBjWPYNk4tfXw9qkQNhjvapWLWiFMPVmHEsQhpPHgE438 9H/nFvNYBP4XxCQxseh7mcaoWgoAsbSRFOwBQ2kqZ9UdqcpS3lhKcyGrGOxK+smOWio8 EYIA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=en8F9YfV; 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 m16-20020a5d6a10000000b0033ec3f42bcasi8637545wru.823.2024.03.21.08.50.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:50:53 -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=en8F9YfV; 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 1rnKgp-0000Um-U0; Thu, 21 Mar 2024 11:50:47 -0400 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 1rnKgj-0000Hd-O2 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:41 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgf-00025C-Ut for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:40 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a4707502aafso204994466b.0 for ; Thu, 21 Mar 2024 08:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036236; x=1711641036; darn=nongnu.org; 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=3j55vDhtvgXvqb+wl9u2AW0u4cGKkyngFQ2jp+MBRmU=; b=en8F9YfVAR5zJfwlRf6vkTDvTDCov1zpNGD37XpiLrHoGTBZcSSMXgegF9trq9NjrO a5d13c6sIEN1pUkcHvSTmaoipJ/cC40n++c8rIaj7l9b0v94xr0GHfY1iWsKX+dwd8mj HEqeVfBD18c86P/eGGX6JnwKrenP6uh3bEXougSc5EfxV1z6Epp1E/4/+aE7EEMfQyrt ih+f26vdxEAvPlKWYRJMKRXCBypC6DA+UTHu2KxAUltw0T4Jmt7YbA1VOnfXME1NKA6e WqX7eu7CcAN56JXfkE462k2W79QINbO5CNiAG7Eg2zibbvHCN9QpNsQrNr+FC183guc/ 4Exw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036236; x=1711641036; 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=3j55vDhtvgXvqb+wl9u2AW0u4cGKkyngFQ2jp+MBRmU=; b=gyCEZWbyzJ+c4ddUVvG8X9Xg7u1piCBCD5koZdcODF6tbLg4ZbbP9SrwUuOBMOTS/5 Kzc+V3L/p3PkPt+DpF0y9fjmiIH6bpb5MZJs4iMh+Mue98FZlleRFht4zR5qoCaLiFWu 3Vd/jjIyzyGSZuzxmwwo+SZ5tteVEi4GXh7aoRa0ZQapfQ0bfRPcECv+5RXvlOXk29HG R1z2reEhMB3OzbEyH6mE5/cmx4bHPPjdWP/mn0P0V8HXQpgNK88sqtMa0tJBTJFvoFS2 J+JoKxxGLTIQnjx78T99ljocf/P6KwBkr895hIXt3JH3tpiNO3k0LGGNn8UOMjbi/kYE RNCw== X-Gm-Message-State: AOJu0YyF0ODRg+pJ42kvlZPLNGBob1ZtunNHjvAgKYmH7/lQWrn3DU7L 3V5EVg9VPo8vdt+EXjNG+46Y8HUADbTAPB84bHkNVvnp6+it2TyiAX+6yZYSuZ2pxnaZrjkqrwd 8w9g= X-Received: by 2002:a17:906:a48:b0:a46:2b8b:e381 with SMTP id x8-20020a1709060a4800b00a462b8be381mr2607800ejf.8.1711036235960; Thu, 21 Mar 2024 08:50:35 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id c14-20020a170906340e00b00a46baa4723asm48238ejb.119.2024.03.21.08.50.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.0? 15/21] target/sparc: Fix string format errors when DEBUG_MMU is defined Date: Thu, 21 Mar 2024 16:48:31 +0100 Message-ID: <20240321154838.95771-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=philmd@linaro.org; helo=mail-ej1-x636.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 Fix when building with DEBUG_MMU: target/sparc/ldst_helper.c:245:72: error: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] DPRINTF_MMU("auto demap entry [%d] %lx->%lx\n", i, vaddr, ~~~ ^~~~~ %llx target/sparc/ldst_helper.c:1736:60: error: no member named 'immuregs' in 'struct CPUArchState' PRIx64 "\n", reg, oldreg, env->immuregs[reg]); ~~~ ^ target/sparc/ldst_helper.c:1820:60: error: no member named 'dmmuregs' in 'struct CPUArchState' PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]); ~~~ ^ Fixes: 96df2bc99f ("target-sparc: use SparcV9MMU type for sparc64 I/D-MMUs") Signed-off-by: Philippe Mathieu-Daudé --- target/sparc/ldst_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index e581bb42ac..064390d1d4 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -242,8 +242,8 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb, if (new_vaddr == vaddr || (new_vaddr < vaddr + size && vaddr < new_vaddr + new_size)) { - DPRINTF_MMU("auto demap entry [%d] %lx->%lx\n", i, vaddr, - new_vaddr); + DPRINTF_MMU("auto demap entry [%d] %"PRIx64"->%"PRIx64"\n", + i, vaddr, new_vaddr); replace_tlb_entry(&tlb[i], tlb_tag, tlb_tte, env1); return; } @@ -1733,7 +1733,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, if (oldreg != env->immu.mmuregs[reg]) { DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016" - PRIx64 "\n", reg, oldreg, env->immuregs[reg]); + PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]); } #ifdef DEBUG_MMU dump_mmu(env); @@ -1817,7 +1817,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, if (oldreg != env->dmmu.mmuregs[reg]) { DPRINTF_MMU("dmmu change reg[%d]: 0x%016" PRIx64 " -> 0x%016" - PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]); + PRIx64 "\n", reg, oldreg, env->dmmu.mmuregs[reg]); } #ifdef DEBUG_MMU dump_mmu(env); From patchwork Thu Mar 21 15:48:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781574 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901184wrj; Thu, 21 Mar 2024 08:51:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW63vRQCaN3xPeBl8aP/SF/gy9X9cUGV7mS7usVYagxgfUBAuPgO/wZiBJdRYSFtUaq8CGccFBlS3CSo0J5ZXKQ X-Google-Smtp-Source: AGHT+IGCzGPiI9hmEHnxdJrXSsnHW8S4QG2gojNUZjY7hSC1Z149E214ayWN957mK1S0f6plA5wn X-Received: by 2002:a05:6000:188c:b0:341:abd4:a6e8 with SMTP id a12-20020a056000188c00b00341abd4a6e8mr1678654wri.60.1711036317297; Thu, 21 Mar 2024 08:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036317; cv=none; d=google.com; s=arc-20160816; b=nko1KaG2qOuupCcpgFm8jNGa8gVdgEvFjDsOIvfreluM5x7ZZjqTq6pdXWBm1MUEFL rMcsiPi8BpCb/AAN1KqWPicVuLEGpE6BRVTsutY94jVxBFYmKFdbHOCP9B4ptBZvlg3m mR17BAKqXH2oEnbq81dnPhPJUZmUa1NixfO6vKfPAHpt4q92BLy5n3FL/2cdJu7UZBpu rMVQiloEwc/kTA0+mwt9vJxl9ZaRAab5gP3vhApUTWVnE2yTenq6P6i3n9zPJjQ4+3u0 ruBY17l6mVyGU++KvDsfgBH2drIR4QgLqYh9p3GN11iylV2xe03ntbcBPUG9OCheiAdX U7hA== 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=nqft4MZU81mkCnglNplHbu0cFdrcwFTH3/wy+rtkBXE=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=oRdgHrfDmZmN9V26vsQA8PqfGbjid02h4Wjb/F7Zj/zuf+aY7+O6xjBp3IKYqlOtop tkC/Y+Fs+ACGseYlrrRbDnd8OzhSOMN1qo14JAFvOC2V5qfMkwcDAaQDTddznwvPzRh7 mTg0d3+qGjWcirWToYWwcaYzcsv5zfB4ih3zY8XIbT6opE/J3nf5nNWhenFw75jQnLFT WYq7ukJW2wx6WlWJdPBA8HzC5Au1X2sQRfXYcc4uJx1nqadGbQAtPfp4E6Nk4nKQsung IS0WccnNe3vQlX9fRNylBtiD/Kep1HBecvqTzM8PO1s25/qYs0HZ1F8pVPOvaDS1tLwN VoVQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DlfN+nah; 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 c5-20020adfef45000000b0034192047282si2580054wrp.253.2024.03.21.08.51.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:51:57 -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=DlfN+nah; 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 1rnKhY-0001Z0-2W; Thu, 21 Mar 2024 11:51:33 -0400 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 1rnKgt-0000wR-BH for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:52 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgp-000278-10 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:49 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a46dec5d00cso156135466b.0 for ; Thu, 21 Mar 2024 08:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036243; x=1711641043; darn=nongnu.org; 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=nqft4MZU81mkCnglNplHbu0cFdrcwFTH3/wy+rtkBXE=; b=DlfN+nahn/vEBs4KpwZ654fRF4kZiWGzvaJlXAeYe9PkOQqLcVUwy0DRiINmfjkXNM xZozK4V2nYcmOpmF9LUDmouB/XoYklfTFC2+jGYiCZC8+msvxQFPF6C2m8MUXda+0jDE 2k+K66jzqglvlxfIphRhUFieLMi6EMGoS1uPCHXAbfxSZU/wPW0Qkh+KPGl9ugSfHi9D zrC61cHZQV3XY+xTMoMVT/Ua48LMmgWNrceygVKZnbg/HK4b0Vaoo+yZGtUcYFWVswvy xkmXA9qziLe4jCkqYSA9QgVLgQhWrqqMDS0ZE6DC2mCd1IvllyMiURmYXRv/NHMrFQjD zCCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036243; x=1711641043; 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=nqft4MZU81mkCnglNplHbu0cFdrcwFTH3/wy+rtkBXE=; b=Wyhck7enh8p536mWDLAEpuAH0I69Vh/32e0xBy3iKdmNbRxqa2xNuM+WEDr6rzVC9S 0xTUvYjatOBVxcbNFAxbgm/G0WLoEPvhZaiKZAEm37BRX4knuxHVoXOEpkclcn3FD3Cc mUy58Ga4P1fJkyiAWFz9r6YXbmLTkQdcCXFW3B+/crSIGjfKs8TKh40ExPYV2sKxH/eO 0JcgmY3RAaOyLkTzGXi0tfJosgQNmrZ5Nz0F0bBVAV1yWrOhsbdFjgiJMUzNMiXr09es WuQKecngPMAyIDMYKu46RyQUSB2iUN3VKgyV32pPmWsf7OBRM9XYy1OTXBI61llENXxO SiyQ== X-Gm-Message-State: AOJu0Yzn4cDnc/yNqgwAZU/LgFrWFW6Garktofugd/wGevni0j0abOXh Hz5PH/RYW1H1ZzeO8vz114Zmt+n1XzTc+aGxxf5NS3qqoVstTDsVtwkcItpja338pXa6yrmLttR zZUM= X-Received: by 2002:a17:906:cecc:b0:a46:1f6d:3047 with SMTP id si12-20020a170906cecc00b00a461f6d3047mr1899905ejb.4.1711036242798; Thu, 21 Mar 2024 08:50:42 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id g27-20020a170906395b00b00a466fccbe96sm48234eje.122.2024.03.21.08.50.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 16/21] target/sparc: Replace qemu_printf() by monitor_printf() in monitor Date: Thu, 21 Mar 2024 16:48:32 +0100 Message-ID: <20240321154838.95771-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=philmd@linaro.org; helo=mail-ej1-x62a.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=unavailable 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 Replace qemu_printf() by monitor_printf() in monitor.c. Rename dump_mmu() as sparc_dump_mmu(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster --- target/sparc/cpu.h | 2 +- target/sparc/ldst_helper.c | 18 +++---- target/sparc/mmu_helper.c | 102 ++++++++++++++++++------------------- target/sparc/monitor.c | 2 +- 4 files changed, 62 insertions(+), 62 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index f3cdd17c62..55589c8ae4 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -601,7 +601,7 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev); -void dump_mmu(CPUSPARCState *env); +void sparc_dump_mmu(Monitor *mon, CPUSPARCState *env); #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr, diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 064390d1d4..44f8b2bb7a 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -195,7 +195,7 @@ static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr, replace_tlb_entry(&tlb[i], 0, 0, env1); #ifdef DEBUG_MMU DPRINTF_MMU("%s demap invalidated entry [%02u]\n", strmmu, i); - dump_mmu(env1); + sparc_dump_mmu(env1); #endif } } @@ -257,7 +257,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb, replace_tlb_entry(&tlb[i], tlb_tag, tlb_tte, env1); #ifdef DEBUG_MMU DPRINTF_MMU("%s lru replaced invalid entry [%i]\n", strmmu, i); - dump_mmu(env1); + sparc_dump_mmu(env1); #endif return; } @@ -276,7 +276,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb, #ifdef DEBUG_MMU DPRINTF_MMU("%s lru replaced unlocked %s entry [%i]\n", strmmu, (replace_used ? "used" : "unused"), i); - dump_mmu(env1); + sparc_dump_mmu(env1); #endif return; } @@ -995,7 +995,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val, break; } #ifdef DEBUG_MMU - dump_mmu(env); + sparc_dump_mmu(env); #endif } break; @@ -1050,7 +1050,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val, reg, oldreg, env->mmuregs[reg]); } #ifdef DEBUG_MMU - dump_mmu(env); + sparc_dump_mmu(env); #endif } break; @@ -1736,7 +1736,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]); } #ifdef DEBUG_MMU - dump_mmu(env); + sparc_dump_mmu(env); #endif return; } @@ -1760,7 +1760,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, } #ifdef DEBUG_MMU DPRINTF_MMU("immu data access replaced entry [%i]\n", i); - dump_mmu(env); + sparc_dump_mmu(env); #endif return; } @@ -1820,7 +1820,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, PRIx64 "\n", reg, oldreg, env->dmmu.mmuregs[reg]); } #ifdef DEBUG_MMU - dump_mmu(env); + sparc_dump_mmu(env); #endif return; } @@ -1842,7 +1842,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, } #ifdef DEBUG_MMU DPRINTF_MMU("dmmu data access replaced entry [%i]\n", i); - dump_mmu(env); + sparc_dump_mmu(env); #endif return; } diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index ad1591d9fd..f325c9a4cc 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -21,7 +21,7 @@ #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" -#include "qemu/qemu-print.h" +#include "monitor/monitor.h" #include "trace.h" /* Sparc MMU emulation */ @@ -344,7 +344,7 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev) return 0; } -void dump_mmu(CPUSPARCState *env) +void sparc_dump_mmu(Monitor *mon, CPUSPARCState *env) { CPUState *cs = env_cpu(env); target_ulong va, va1, va2; @@ -352,29 +352,29 @@ void dump_mmu(CPUSPARCState *env) hwaddr pa; uint32_t pde; - qemu_printf("Root ptr: " HWADDR_FMT_plx ", ctx: %d\n", - (hwaddr)env->mmuregs[1] << 4, env->mmuregs[2]); + monitor_printf(mon, "Root ptr: " HWADDR_FMT_plx ", ctx: %d\n", + (hwaddr)env->mmuregs[1] << 4, env->mmuregs[2]); for (n = 0, va = 0; n < 256; n++, va += 16 * 1024 * 1024) { pde = mmu_probe(env, va, 2); if (pde) { pa = cpu_get_phys_page_debug(cs, va); - qemu_printf("VA: " TARGET_FMT_lx ", PA: " HWADDR_FMT_plx - " PDE: " TARGET_FMT_lx "\n", va, pa, pde); + monitor_printf(mon, "VA: " TARGET_FMT_lx ", PA: " HWADDR_FMT_plx + " PDE: " TARGET_FMT_lx "\n", va, pa, pde); for (m = 0, va1 = va; m < 64; m++, va1 += 256 * 1024) { pde = mmu_probe(env, va1, 1); if (pde) { pa = cpu_get_phys_page_debug(cs, va1); - qemu_printf(" VA: " TARGET_FMT_lx ", PA: " - HWADDR_FMT_plx " PDE: " TARGET_FMT_lx "\n", - va1, pa, pde); + monitor_printf(mon, " VA: " TARGET_FMT_lx ", PA: " + HWADDR_FMT_plx " PDE: " TARGET_FMT_lx "\n", + va1, pa, pde); for (o = 0, va2 = va1; o < 64; o++, va2 += 4 * 1024) { pde = mmu_probe(env, va2, 0); if (pde) { pa = cpu_get_phys_page_debug(cs, va2); - qemu_printf(" VA: " TARGET_FMT_lx ", PA: " - HWADDR_FMT_plx " PTE: " - TARGET_FMT_lx "\n", - va2, pa, pde); + monitor_printf(mon, " VA: " TARGET_FMT_lx ", PA: " + HWADDR_FMT_plx " PTE: " + TARGET_FMT_lx "\n", + va2, pa, pde); } } } @@ -777,21 +777,21 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, cpu_loop_exit_restore(cs, retaddr); } -void dump_mmu(CPUSPARCState *env) +void sparc_dump_mmu(Monitor *mon, CPUSPARCState *env) { unsigned int i; const char *mask; - qemu_printf("MMU contexts: Primary: %" PRId64 ", Secondary: %" - PRId64 "\n", - env->dmmu.mmu_primary_context, - env->dmmu.mmu_secondary_context); - qemu_printf("DMMU Tag Access: %" PRIx64 ", TSB Tag Target: %" PRIx64 - "\n", env->dmmu.tag_access, env->dmmu.tsb_tag_target); + monitor_printf(mon, "MMU contexts: Primary: %" PRId64 ", Secondary: %" + PRId64 "\n", + env->dmmu.mmu_primary_context, + env->dmmu.mmu_secondary_context); + monitor_printf(mon, "DMMU Tag Access: %" PRIx64 ", TSB Tag Target: %" PRIx64 + "\n", env->dmmu.tag_access, env->dmmu.tsb_tag_target); if ((env->lsu & DMMU_E) == 0) { - qemu_printf("DMMU disabled\n"); + monitor_printf(mon, "DMMU disabled\n"); } else { - qemu_printf("DMMU dump\n"); + monitor_printf(mon, "DMMU dump\n"); for (i = 0; i < 64; i++) { switch (TTE_PGSIZE(env->dtlb[i].tte)) { default: @@ -809,28 +809,28 @@ void dump_mmu(CPUSPARCState *env) break; } if (TTE_IS_VALID(env->dtlb[i].tte)) { - qemu_printf("[%02u] VA: %" PRIx64 ", PA: %llx" - ", %s, %s, %s, %s, ie %s, ctx %" PRId64 " %s\n", - i, - env->dtlb[i].tag & (uint64_t)~0x1fffULL, - TTE_PA(env->dtlb[i].tte), - mask, - TTE_IS_PRIV(env->dtlb[i].tte) ? "priv" : "user", - TTE_IS_W_OK(env->dtlb[i].tte) ? "RW" : "RO", - TTE_IS_LOCKED(env->dtlb[i].tte) ? - "locked" : "unlocked", - TTE_IS_IE(env->dtlb[i].tte) ? - "yes" : "no", - env->dtlb[i].tag & (uint64_t)0x1fffULL, - TTE_IS_GLOBAL(env->dtlb[i].tte) ? - "global" : "local"); + monitor_printf(mon, "[%02u] VA: %" PRIx64 ", PA: %llx" + ", %s, %s, %s, %s, ie %s, ctx %" PRId64 " %s\n", + i, + env->dtlb[i].tag & (uint64_t)~0x1fffULL, + TTE_PA(env->dtlb[i].tte), + mask, + TTE_IS_PRIV(env->dtlb[i].tte) ? "priv" : "user", + TTE_IS_W_OK(env->dtlb[i].tte) ? "RW" : "RO", + TTE_IS_LOCKED(env->dtlb[i].tte) ? + "locked" : "unlocked", + TTE_IS_IE(env->dtlb[i].tte) ? + "yes" : "no", + env->dtlb[i].tag & (uint64_t)0x1fffULL, + TTE_IS_GLOBAL(env->dtlb[i].tte) ? + "global" : "local"); } } } if ((env->lsu & IMMU_E) == 0) { - qemu_printf("IMMU disabled\n"); + monitor_printf(mon, "IMMU disabled\n"); } else { - qemu_printf("IMMU dump\n"); + monitor_printf(mon, "IMMU dump\n"); for (i = 0; i < 64; i++) { switch (TTE_PGSIZE(env->itlb[i].tte)) { default: @@ -848,18 +848,18 @@ void dump_mmu(CPUSPARCState *env) break; } if (TTE_IS_VALID(env->itlb[i].tte)) { - qemu_printf("[%02u] VA: %" PRIx64 ", PA: %llx" - ", %s, %s, %s, ctx %" PRId64 " %s\n", - i, - env->itlb[i].tag & (uint64_t)~0x1fffULL, - TTE_PA(env->itlb[i].tte), - mask, - TTE_IS_PRIV(env->itlb[i].tte) ? "priv" : "user", - TTE_IS_LOCKED(env->itlb[i].tte) ? - "locked" : "unlocked", - env->itlb[i].tag & (uint64_t)0x1fffULL, - TTE_IS_GLOBAL(env->itlb[i].tte) ? - "global" : "local"); + monitor_printf(mon, "[%02u] VA: %" PRIx64 ", PA: %llx" + ", %s, %s, %s, ctx %" PRId64 " %s\n", + i, + env->itlb[i].tag & (uint64_t)~0x1fffULL, + TTE_PA(env->itlb[i].tte), + mask, + TTE_IS_PRIV(env->itlb[i].tte) ? "priv" : "user", + TTE_IS_LOCKED(env->itlb[i].tte) ? + "locked" : "unlocked", + env->itlb[i].tag & (uint64_t)0x1fffULL, + TTE_IS_GLOBAL(env->itlb[i].tte) ? + "global" : "local"); } } } diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c index 73f15aa272..4fcdf75932 100644 --- a/target/sparc/monitor.c +++ b/target/sparc/monitor.c @@ -36,7 +36,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu(env1); + sparc_dump_mmu(mon, env1); } #ifndef TARGET_SPARC64 From patchwork Thu Mar 21 15:48:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781576 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901282wrj; Thu, 21 Mar 2024 08:52:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXBYieQNZ9jrcUWffGKWpjbJSr1agX+u6zXI3JWz/RBRy5Bkx8dhyWN1rxdnXVtNazwxY4AmRVN+2jXgJRfT5Yq X-Google-Smtp-Source: AGHT+IGjtwdM4AIlQkii0Xd0pqAqnKnFRHzzAtLUqh+Hb45Rlf0I5AxfOr1/2PHGe+EemnfnlOwy X-Received: by 2002:a5d:5886:0:b0:33e:19ae:3716 with SMTP id n6-20020a5d5886000000b0033e19ae3716mr4894707wrf.11.1711036327935; Thu, 21 Mar 2024 08:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036327; cv=none; d=google.com; s=arc-20160816; b=XU+N4jtl2N1R9jmTu+32ML8FhWKwU481wUQt50Bau8Ylkd06KwIOr56sNClhWZjWxv o/+OI0yRxp3+NTEq/HWDoaP9amwjcUpXQ1n6Jzes1cieRUTGjvdPgrdAYpMVWu9zrD3z M6AoIVoPqaD8IRcGO5Xb66LHXPoUp9s3jedcWCeipvG6r52YWhKkMLPIOIFqaaYAi9Xb NTSO3Ll/tjDF1HQotgWw72vk92l87FB3TirVAhepwKZRt2WE/eThk8L6PTXpydFlU0tC DdoYJYzjbWOTDuqDWlWEQQ1z0BWMRxWg/YlFu07qL39zUwnmjLeDZbcaX5hVHZmK2SOE A5ng== 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=HBTm7fX0XnajgMEHRoXg20PUgOsEK5tp5uuFAd0ZnLA=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=IfaH0FmeKq5ILoql3z8Rac+yh2thjTlZxtO38vtpTk8o5zTViYdcLTtGMiQnEEScnH J36DhABJ1WfLQbldvu2OizZtDyFbYJSpk4JqvpLvurLOSNar7JnSheok7as0z34/HX+q vM6qWe+1OXgh7/kiPp0zvZUxGHAqymG2ypTPuQUaGpfR43JmqAh0JF8BZa0C6vIbhUPO fDQnKKjena2oBO1xuegKvwdwHbXyh1afSIaxuK5TjT/f0bqiHNWO+yM9yVcGY2zMAJ3z prHDtqg+7FoxD9QyGfy3KaVN3ZUcO7gW6Px6BiYWeIne4D8Ym+JWrbgTaOkX/6E1kkeI l86Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1qzqjlx; 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 j11-20020a5d464b000000b0033cf4d9aab6si8743315wrs.868.2024.03.21.08.52.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:52:07 -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=H1qzqjlx; 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 1rnKhq-0002Qw-S9; Thu, 21 Mar 2024 11:51:50 -0400 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 1rnKgy-000165-P1 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:57 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgu-000299-IS for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:50:54 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-56bc753f58eso1160596a12.3 for ; Thu, 21 Mar 2024 08:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036249; x=1711641049; darn=nongnu.org; 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=HBTm7fX0XnajgMEHRoXg20PUgOsEK5tp5uuFAd0ZnLA=; b=H1qzqjlxkFgeWoyQSFcTFl3TEpIWfvk9T4J1EQEwiTf0GuSzHlYQtWdNpZW40t9ZEo I6Oi62JeJe+extwbnPA2gvgFiPUsaOiE/2HoiqIU5AL1msL6rFuT9q1xHm9qd22hlmwH E0X80XzKOGgxRx2tJ5hwxLe4OxkgYdwvXcNngYX4jET7zCBKeQO0Pw/JgJr9MpVGikxk Rsw6blJCj5VxuOsN3EB6hjCEoyDcgnR+0Xmc8KUcgiKtduXfZ8eFzVlgf0/kUyrg4CjC rYEgs/tjkJvJ3xUR56XSestV8IVGeKCeWzvOMmZb4q04h9edFUD3fgr3ShkNdWbcKdDC yKrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036249; x=1711641049; 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=HBTm7fX0XnajgMEHRoXg20PUgOsEK5tp5uuFAd0ZnLA=; b=mNk0+3kveJ9HxWOYUzGsg2kBpGIxC0i5j6o0CWe/saWeGJ0ABKQh5bN1EPBRcIE+xC sPOAMuxlvxPgddxvxNdRv4ckhIeFiX14XvHgx5GVwgeVh4M+spX6tEXYcLDO3eUDCqU7 uGEAqjxRRTqaHmHpY3MngkhcIk5SGZQkBdql44aCVjg2Zhq3EGi+0YRIN324qe1vj7LQ oyXI1cSHzjZXZhQ/nmARzDZdtFACkksNFN3hDcSx40KKNaeRQv/uuPyeyItv71OnAFh7 1QCdnrvC44RbKVzla681PlbI1I4C2MyD/qiryx9P7kvE1IoU3yxn0k1Zjv5+PaN8VQFX 4gMA== X-Gm-Message-State: AOJu0Yzb8YtSUSqEHCaNzVSX76kMLR/wwYd+hb3lLiw5Fejt2KdUl2+2 AW7BmGo5ndlhs4I822baTS97TjoIQTRq+BHxR+8c8Li6VzHWWnRFNFZKkQWSEsMA3f7/8U38Fvm Sc5A= X-Received: by 2002:a05:6402:159a:b0:568:9fc9:ec72 with SMTP id ij26-20020a056402159a00b005689fc9ec72mr3999872edb.35.1711036249579; Thu, 21 Mar 2024 08:50:49 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id l9-20020a056402028900b00568d4cf3288sm17978edv.7.2024.03.21.08.50.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 17/21] target/xtensa: Prefix MMU API with 'xtensa_' Date: Thu, 21 Mar 2024 16:48:33 +0100 Message-ID: <20240321154838.95771-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=philmd@linaro.org; helo=mail-ed1-x530.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=unavailable 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 In order to extract the MMU API to a new "mmu.h" header, prefix it with the target name. Signed-off-by: Philippe Mathieu-Daudé --- target/xtensa/cpu.h | 4 ++-- target/xtensa/cpu.c | 2 +- target/xtensa/mmu_helper.c | 41 +++++++++++++++++++++----------------- target/xtensa/monitor.c | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 6b8d0636d2..b2cfc78e9d 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -692,8 +692,8 @@ static inline int xtensa_get_cring(const CPUXtensaState *env) int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access); -void reset_mmu(CPUXtensaState *env); -void dump_mmu(CPUXtensaState *env); +void xtensa_reset_mmu(CPUXtensaState *env); +void xtensa_dump_mmu(CPUXtensaState *env); static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env) { diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 875cf843c9..ae0c4aab24 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -130,7 +130,7 @@ static void xtensa_cpu_reset_hold(Object *obj) env->exclusive_addr = -1; #ifndef CONFIG_USER_ONLY - reset_mmu(env); + xtensa_reset_mmu(env); cs->halted = env->runstall; #endif set_no_signaling_nans(!dfpu, &env->fp_status); diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index 47063b0a57..31ee3fa957 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -139,7 +139,8 @@ static uint32_t xtensa_tlb_get_addr_mask(const CPUXtensaState *env, * Get bit mask for the 'VPN without index' field. * See ISA, 4.6.5.6, data format for RxTLB0 */ -static uint32_t get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way) +static uint32_t xtensa_get_vpn_mask(const CPUXtensaState *env, bool dtlb, + uint32_t way) { if (way < 4) { bool is32 = (dtlb ? @@ -168,9 +169,10 @@ static uint32_t get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way) * Split virtual address into VPN (with index) and entry index * for the given TLB way */ -static void split_tlb_entry_spec_way(const CPUXtensaState *env, uint32_t v, - bool dtlb, uint32_t *vpn, - uint32_t wi, uint32_t *ei) +static void xtensa_split_tlb_entry_spec_way(const CPUXtensaState *env, + uint32_t v, + bool dtlb, uint32_t *vpn, + uint32_t wi, uint32_t *ei) { bool varway56 = dtlb ? env->config->dtlb.varway56 : @@ -224,13 +226,15 @@ static void split_tlb_entry_spec_way(const CPUXtensaState *env, uint32_t v, * Split TLB address into TLB way, entry index and VPN (with index). * See ISA, 4.6.5.5 - 4.6.5.8 for the TLB addressing format */ -static bool split_tlb_entry_spec(CPUXtensaState *env, uint32_t v, bool dtlb, - uint32_t *vpn, uint32_t *wi, uint32_t *ei) +static bool xtensa_split_tlb_entry_spec(CPUXtensaState *env, + uint32_t v, bool dtlb, + uint32_t *vpn, uint32_t *wi, + uint32_t *ei) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { *wi = v & (dtlb ? 0xf : 0x7); if (*wi < (dtlb ? env->config->dtlb.nways : env->config->itlb.nways)) { - split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei); + xtensa_split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei); return true; } else { return false; @@ -254,14 +258,14 @@ static xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env, bool dtlb, env->itlb[wi] + ei; } -static xtensa_tlb_entry *get_tlb_entry(CPUXtensaState *env, +static xtensa_tlb_entry *xtensa_get_tlb_entry(CPUXtensaState *env, uint32_t v, bool dtlb, uint32_t *pwi) { uint32_t vpn; uint32_t wi; uint32_t ei; - if (split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { + if (xtensa_split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { if (pwi) { *pwi = wi; } @@ -405,7 +409,7 @@ static void reset_tlb_region_way0(CPUXtensaState *env, } } -void reset_mmu(CPUXtensaState *env) +void xtensa_reset_mmu(CPUXtensaState *env) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { env->sregs[RASID] = 0x04030201; @@ -470,7 +474,7 @@ static int xtensa_tlb_lookup(const CPUXtensaState *env, for (wi = 0; wi < tlb->nways; ++wi) { uint32_t vpn; uint32_t ei; - split_tlb_entry_spec_way(env, addr, dtlb, &vpn, wi, &ei); + xtensa_split_tlb_entry_spec_way(env, addr, dtlb, &vpn, wi, &ei); if (entry[wi][ei].vaddr == vpn && entry[wi][ei].asid) { unsigned ring = get_ring(env, entry[wi][ei].asid); if (ring < 4) { @@ -493,10 +497,11 @@ uint32_t HELPER(rtlb0)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { uint32_t wi; - const xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, &wi); + const xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, &wi); if (entry) { - return (entry->vaddr & get_vpn_mask(env, dtlb, wi)) | entry->asid; + return (entry->vaddr & xtensa_get_vpn_mask(env, dtlb, wi)) + | entry->asid; } else { return 0; } @@ -507,7 +512,7 @@ uint32_t HELPER(rtlb0)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) uint32_t HELPER(rtlb1)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) { - const xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, NULL); + const xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, NULL); if (entry) { return entry->paddr | entry->attr; @@ -520,7 +525,7 @@ void HELPER(itlb)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { uint32_t wi; - xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, &wi); + xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, &wi); if (entry && entry->variable && entry->asid) { tlb_flush_page(env_cpu(env), entry->vaddr); entry->asid = 0; @@ -559,7 +564,7 @@ void HELPER(wtlb)(CPUXtensaState *env, uint32_t p, uint32_t v, uint32_t dtlb) uint32_t vpn; uint32_t wi; uint32_t ei; - if (split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { + if (xtensa_split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, p); } } @@ -818,7 +823,7 @@ static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb, may_lookup_pt && get_pte(env, vaddr, &pte)) { ring = (pte >> 4) & 0x3; wi = 0; - split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei); + xtensa_split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei); if (update_tlb) { wi = ++env->autorefill_idx & 0x3; @@ -1192,7 +1197,7 @@ static void dump_mpu(CPUXtensaState *env, } } -void dump_mmu(CPUXtensaState *env) +void xtensa_dump_mmu(CPUXtensaState *env) { if (xtensa_option_bits_enabled(env->config, XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c index fbf60d5553..ce1b791a5c 100644 --- a/target/xtensa/monitor.c +++ b/target/xtensa/monitor.c @@ -35,5 +35,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu(env1); + xtensa_dump_mmu(env1); } From patchwork Thu Mar 21 15:48:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781577 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901392wrj; Thu, 21 Mar 2024 08:52:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVwLRkKkzuncApPeuZfPpxBXxY5LVONWy9cz+i0n7W+MSp1I6g34SiAtvFBil8EAY6sdXzSqPLGzuRi6NdwqwDf X-Google-Smtp-Source: AGHT+IGqty4+ED1uESMKT5UdBNrLK1YWVpMrX6iTFhxf5OseRVG58mEYpy66Z9P3FulWIq7yyJET X-Received: by 2002:a05:600c:4f44:b0:414:f60:5d6a with SMTP id m4-20020a05600c4f4400b004140f605d6amr4101456wmq.0.1711036340230; Thu, 21 Mar 2024 08:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036340; cv=none; d=google.com; s=arc-20160816; b=LatnKw9tIxoOPnsAEnEFPY8+5GPhiZZ9GG5pvOvUxBLRGBFKekxX686z2lRcmu8hU7 4FVgdI01MKWBAY9eC5KNYDE/CUHWY3gm8sw4za/DuS6cdQhP8siC2P4jbaULS7RhNE8s tzyOlU8erSYV6CKrh/nz44LUOYEynMU1scQde3jlMrOqUWbZZ0WsXQ7/vJDLI7M9WYjT fng6jXqYYFzuLee5kk5xaWAeVaqgd6ZVWkDIorOJ0GfCCUpXJuqhSu9wRMBIELfUsPES FVEtfO9wC6mN7hc3fOETnJgBSMRwRoLlvPF1SAFJRwBI0P63cM+hf8UqYyOAHobgf43a QwYQ== 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=6V+xghT+3/f8uj28Yzv/QHtJ2W3P/5E37yCGvs4rFKA=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=B8uYugXxnIxDfHzjrCTMovOBqDLwhqBQfwQ2FPpS5ACzOs34lLBSCzs0rFG3pyF5kJ SQJtUfKi5f8giU/XYtEWc1YIyEW1+I14vI6RY0KsyzMJ2W0z2fFgt5EwLwSA2diffW+x p4boP5fP/MmgA55p7RRuls7eClFixAIshpe7KWGINXiZNJnbQmefsomawIq+XoCP3NF0 OHh7pdVrUplYij8vK418AHzqBpA6kBUEHfktRpHnZZJhTLjfHP4DSAASGN3Ye3M29o9A 4BDD8HFAa85lnO9+fbn7rzrGau7QvL0y7SSm1fMJw7PH6xOcLAhgnBXwaWl4nclVh91j DAKA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bc7Ngyvw; 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 f10-20020adffcca000000b0033e7377bd2bsi8469729wrs.878.2024.03.21.08.52.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:52:20 -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=bc7Ngyvw; 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 1rnKhw-0002lI-Ng; Thu, 21 Mar 2024 11:51:56 -0400 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 1rnKhE-0001IZ-AJ for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:51:14 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKh1-0002Be-Rk for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:51:05 -0400 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-563c595f968so1504610a12.0 for ; Thu, 21 Mar 2024 08:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036257; x=1711641057; darn=nongnu.org; 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=6V+xghT+3/f8uj28Yzv/QHtJ2W3P/5E37yCGvs4rFKA=; b=bc7NgyvwRODroOste0D284t74pstl1r/4ZsoBKQbV+F4eMGhr1kcgxuymyxdmHdIuU qakkddK1x0+6IujEIVIgwnEMAKrFDYEO/8iRZC/zEgh/8Uv8ndz6FH9+d6Nj0YQ/DqkB PZDmcpmVbETiANqJKdQFzHJZOlwunvqZ7BUj7gEaLVFJ2hYBe7941xnH6lVO+rO+aMY+ 4mCbjjh9FJ0upuFFFmtRizaSy7w3MrJiGbK8NwaWEVLxnysWAvXjgmbU87EYvlxL6z/L RLtzsZ/b7VM6e+pVbOCnkemhheyfFM67E30MMrnVW4yT2+BXBpKYYiF+mUwpIytBB/2I IUHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036257; x=1711641057; 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=6V+xghT+3/f8uj28Yzv/QHtJ2W3P/5E37yCGvs4rFKA=; b=Z0NC4KjryyMBSj/CHU8Vm0Dkec9bZyzwG9CRDKKRv697Af1BHH7MzBo7KbKzyc9/1g 3sPU5Vmi/+M9nh9mIunwg3EB8Szdrh9on8ZDulRD0U5QA8B6B5deE0TSWHCM0sceh/VO aqxxDbb6OfA7y9qzSJBViIpEDhCauVZ4StpC96/jUwKUFxiBW6rVAsE2pIDJvSxzajZu qbk/Ba4VEIhW8NGSl41DqRzB86lLvmC0x8M2+l6bt6ejrS5SsEzM4uSrZBJouGNHgvrR DxicKHGjDA4YKao9Y2jM4uA+zxiGBcysH5eh5VA1S/1/ohWQBuTSx/t5E3UP56L0GY6Q t7Rg== X-Gm-Message-State: AOJu0Yye/9qBB5ZWBtD8iMIJoOCHOqdyVEbsU+wnlArroGZC5K/L13Qd 81Vqndvyb27E8prOsyuEdzNqUshw+9XjKhBcK94lxwRPzoehk9avSh/L5PQ0v84AwRftDsUf2vZ 910k= X-Received: by 2002:a05:6402:e83:b0:568:b46c:c4ba with SMTP id h3-20020a0564020e8300b00568b46cc4bamr4265530eda.30.1711036257015; Thu, 21 Mar 2024 08:50:57 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id z9-20020a05640235c900b00568a08a9aacsm14611edc.22.2024.03.21.08.50.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 18/21] target/xtensa: Extract MMU API to new mmu.c/mmu.h files Date: Thu, 21 Mar 2024 16:48:34 +0100 Message-ID: <20240321154838.95771-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=philmd@linaro.org; helo=mail-ed1-x52f.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=unavailable 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 Extract the MMU API and expose it via "mmu.h" so we can reuse the methods in target/xtensa/ files. Signed-off-by: Philippe Mathieu-Daudé --- target/xtensa/cpu.h | 32 +- target/xtensa/mmu.h | 95 ++++ target/xtensa/mmu.c | 889 ++++++++++++++++++++++++++++++++++++ target/xtensa/mmu_helper.c | 892 +------------------------------------ target/xtensa/meson.build | 1 + 5 files changed, 991 insertions(+), 918 deletions(-) create mode 100644 target/xtensa/mmu.h create mode 100644 target/xtensa/mmu.c diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index b2cfc78e9d..b67ee987f3 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -34,6 +34,10 @@ #include "hw/clock.h" #include "xtensa-isa.h" +typedef struct CPUArchState CPUXtensaState; + +#include "mmu.h" + /* Xtensa processors have a weak memory model */ #define TCG_GUEST_DEFAULT_MO (0) @@ -309,28 +313,6 @@ typedef enum { INTTYPE_MAX } interrupt_type; -typedef struct CPUArchState CPUXtensaState; - -typedef struct xtensa_tlb_entry { - uint32_t vaddr; - uint32_t paddr; - uint8_t asid; - uint8_t attr; - bool variable; -} xtensa_tlb_entry; - -typedef struct xtensa_tlb { - unsigned nways; - const unsigned way_size[10]; - bool varway56; - unsigned nrefillentries; -} xtensa_tlb; - -typedef struct xtensa_mpu_entry { - uint32_t vaddr; - uint32_t attr; -} xtensa_mpu_entry; - typedef struct XtensaGdbReg { int targno; unsigned flags; @@ -689,12 +671,6 @@ static inline int xtensa_get_cring(const CPUXtensaState *env) } #ifndef CONFIG_USER_ONLY -int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, - uint32_t vaddr, int is_write, int mmu_idx, - uint32_t *paddr, uint32_t *page_size, unsigned *access); -void xtensa_reset_mmu(CPUXtensaState *env); -void xtensa_dump_mmu(CPUXtensaState *env); - static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env) { return env->system_er; diff --git a/target/xtensa/mmu.h b/target/xtensa/mmu.h new file mode 100644 index 0000000000..3e1d2c03ea --- /dev/null +++ b/target/xtensa/mmu.h @@ -0,0 +1,95 @@ +/* + * Xtensa MMU/MPU helpers + * + * SPDX-FileCopyrightText: 2011 - 2019, Max Filippov, Open Source and Linux Lab. + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef TARGET_XTENSA_MMU_H +#define TARGET_XTENSA_MMU_H + +#include "cpu.h" + +typedef struct xtensa_tlb_entry { + uint32_t vaddr; + uint32_t paddr; + uint8_t asid; + uint8_t attr; + bool variable; +} xtensa_tlb_entry; + +typedef struct xtensa_tlb { + unsigned nways; + const unsigned way_size[10]; + bool varway56; + unsigned nrefillentries; +} xtensa_tlb; + +typedef struct xtensa_mpu_entry { + uint32_t vaddr; + uint32_t attr; +} xtensa_mpu_entry; + +#define XTENSA_MPU_SEGMENT_MASK 0x0000001f +#define XTENSA_MPU_ACC_RIGHTS_MASK 0x00000f00 +#define XTENSA_MPU_ACC_RIGHTS_SHIFT 8 +#define XTENSA_MPU_MEM_TYPE_MASK 0x001ff000 +#define XTENSA_MPU_MEM_TYPE_SHIFT 12 +#define XTENSA_MPU_ATTR_MASK 0x001fff00 + +#define XTENSA_MPU_PROBE_B 0x40000000 +#define XTENSA_MPU_PROBE_V 0x80000000 + +#define XTENSA_MPU_SYSTEM_TYPE_DEVICE 0x0001 +#define XTENSA_MPU_SYSTEM_TYPE_NC 0x0002 +#define XTENSA_MPU_SYSTEM_TYPE_C 0x0003 +#define XTENSA_MPU_SYSTEM_TYPE_MASK 0x0003 + +#define XTENSA_MPU_TYPE_SYS_C 0x0010 +#define XTENSA_MPU_TYPE_SYS_W 0x0020 +#define XTENSA_MPU_TYPE_SYS_R 0x0040 +#define XTENSA_MPU_TYPE_CPU_C 0x0100 +#define XTENSA_MPU_TYPE_CPU_W 0x0200 +#define XTENSA_MPU_TYPE_CPU_R 0x0400 +#define XTENSA_MPU_TYPE_CPU_CACHE 0x0800 +#define XTENSA_MPU_TYPE_B 0x1000 +#define XTENSA_MPU_TYPE_INT 0x2000 + +unsigned mmu_attr_to_access(uint32_t attr); +unsigned mpu_attr_to_access(uint32_t attr, unsigned ring); +unsigned mpu_attr_to_cpu_cache(uint32_t attr); +unsigned mpu_attr_to_type(uint32_t attr); + +unsigned region_attr_to_access(uint32_t attr); +unsigned cacheattr_attr_to_access(uint32_t attr); + +xtensa_tlb_entry *xtensa_get_tlb_entry(CPUXtensaState *env, + uint32_t v, bool dtlb, uint32_t *pwi); +xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env, bool dtlb, + unsigned wi, unsigned ei); +void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb, + unsigned wi, unsigned ei, + uint32_t vpn, uint32_t pte); + +uint32_t xtensa_tlb_get_addr_mask(const CPUXtensaState *env, bool dtlb, + uint32_t way); +uint32_t xtensa_get_vpn_mask(const CPUXtensaState *env, bool dtlb, + uint32_t way); + +bool xtensa_split_tlb_entry_spec(CPUXtensaState *env, uint32_t v, bool dtlb, + uint32_t *vpn, uint32_t *wi, uint32_t *ei); + +int xtensa_tlb_lookup(const CPUXtensaState *env, uint32_t addr, bool dtlb, + uint32_t *pwi, uint32_t *pei, uint8_t *pring); +int xtensa_mpu_lookup(const xtensa_mpu_entry *entry, unsigned n, + uint32_t vaddr, unsigned *segment); + +int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, + uint32_t vaddr, int is_write, int mmu_idx, + uint32_t *paddr, uint32_t *page_size, + unsigned *access); + +void xtensa_reset_mmu(CPUXtensaState *env); +void xtensa_dump_mmu(CPUXtensaState *env); + +#endif diff --git a/target/xtensa/mmu.c b/target/xtensa/mmu.c new file mode 100644 index 0000000000..4f17fb2980 --- /dev/null +++ b/target/xtensa/mmu.c @@ -0,0 +1,889 @@ +/* + * Copyright (c) 2011 - 2019, Max Filippov, Open Source and Linux Lab. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Open Source and Linux Lab nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/host-utils.h" +#include "exec/exec-all.h" +#include "cpu.h" +#include "mmu.h" + +static uint32_t get_page_size(const CPUXtensaState *env, + bool dtlb, uint32_t way) +{ + uint32_t tlbcfg = env->sregs[dtlb ? DTLBCFG : ITLBCFG]; + + switch (way) { + case 4: + return (tlbcfg >> 16) & 0x3; + + case 5: + return (tlbcfg >> 20) & 0x1; + + case 6: + return (tlbcfg >> 24) & 0x1; + + default: + return 0; + } +} + +/*! + * Get bit mask for the virtual address bits translated by the TLB way + */ +uint32_t xtensa_tlb_get_addr_mask(const CPUXtensaState *env, + bool dtlb, uint32_t way) +{ + if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { + bool varway56 = dtlb ? + env->config->dtlb.varway56 : + env->config->itlb.varway56; + + switch (way) { + case 4: + return 0xfff00000 << get_page_size(env, dtlb, way) * 2; + + case 5: + if (varway56) { + return 0xf8000000 << get_page_size(env, dtlb, way); + } else { + return 0xf8000000; + } + + case 6: + if (varway56) { + return 0xf0000000 << (1 - get_page_size(env, dtlb, way)); + } else { + return 0xf0000000; + } + + default: + return 0xfffff000; + } + } else { + return REGION_PAGE_MASK; + } +} + +/*! + * Get bit mask for the 'VPN without index' field. + * See ISA, 4.6.5.6, data format for RxTLB0 + */ +uint32_t xtensa_get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way) +{ + if (way < 4) { + bool is32 = (dtlb ? + env->config->dtlb.nrefillentries : + env->config->itlb.nrefillentries) == 32; + return is32 ? 0xffff8000 : 0xffffc000; + } else if (way == 4) { + return xtensa_tlb_get_addr_mask(env, dtlb, way) << 2; + } else if (way <= 6) { + uint32_t mask = xtensa_tlb_get_addr_mask(env, dtlb, way); + bool varway56 = dtlb ? + env->config->dtlb.varway56 : + env->config->itlb.varway56; + + if (varway56) { + return mask << (way == 5 ? 2 : 3); + } else { + return mask << 1; + } + } else { + return 0xfffff000; + } +} + +/*! + * Split virtual address into VPN (with index) and entry index + * for the given TLB way + */ +static void xtensa_split_tlb_entry_spec_way(const CPUXtensaState *env, + uint32_t v, + bool dtlb, uint32_t *vpn, + uint32_t wi, uint32_t *ei) +{ + bool varway56 = dtlb ? + env->config->dtlb.varway56 : + env->config->itlb.varway56; + + if (!dtlb) { + wi &= 7; + } + + if (wi < 4) { + bool is32 = (dtlb ? + env->config->dtlb.nrefillentries : + env->config->itlb.nrefillentries) == 32; + *ei = (v >> 12) & (is32 ? 0x7 : 0x3); + } else { + switch (wi) { + case 4: + { + uint32_t eibase = 20 + get_page_size(env, dtlb, wi) * 2; + *ei = (v >> eibase) & 0x3; + } + break; + + case 5: + if (varway56) { + uint32_t eibase = 27 + get_page_size(env, dtlb, wi); + *ei = (v >> eibase) & 0x3; + } else { + *ei = (v >> 27) & 0x1; + } + break; + + case 6: + if (varway56) { + uint32_t eibase = 29 - get_page_size(env, dtlb, wi); + *ei = (v >> eibase) & 0x7; + } else { + *ei = (v >> 28) & 0x1; + } + break; + + default: + *ei = 0; + break; + } + } + *vpn = v & xtensa_tlb_get_addr_mask(env, dtlb, wi); +} + +/*! + * Split TLB address into TLB way, entry index and VPN (with index). + * See ISA, 4.6.5.5 - 4.6.5.8 for the TLB addressing format + */ +bool xtensa_split_tlb_entry_spec(CPUXtensaState *env, uint32_t v, bool dtlb, + uint32_t *vpn, uint32_t *wi, uint32_t *ei) +{ + if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { + *wi = v & (dtlb ? 0xf : 0x7); + if (*wi < (dtlb ? env->config->dtlb.nways : env->config->itlb.nways)) { + xtensa_split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei); + return true; + } else { + return false; + } + } else { + *vpn = v & REGION_PAGE_MASK; + *wi = 0; + *ei = (v >> 29) & 0x7; + return true; + } +} + +xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env, bool dtlb, + unsigned wi, unsigned ei) +{ + const xtensa_tlb *tlb = dtlb ? &env->config->dtlb : &env->config->itlb; + + assert(wi < tlb->nways && ei < tlb->way_size[wi]); + return dtlb ? + env->dtlb[wi] + ei : + env->itlb[wi] + ei; +} + +xtensa_tlb_entry *xtensa_get_tlb_entry(CPUXtensaState *env, uint32_t v, + bool dtlb, uint32_t *pwi) +{ + uint32_t vpn; + uint32_t wi; + uint32_t ei; + + if (xtensa_split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { + if (pwi) { + *pwi = wi; + } + return xtensa_tlb_get_entry(env, dtlb, wi, ei); + } else { + return NULL; + } +} + +static void xtensa_tlb_set_entry_mmu(const CPUXtensaState *env, + xtensa_tlb_entry *entry, bool dtlb, + unsigned wi, unsigned ei, uint32_t vpn, + uint32_t pte) +{ + entry->vaddr = vpn; + entry->paddr = pte & xtensa_tlb_get_addr_mask(env, dtlb, wi); + entry->asid = (env->sregs[RASID] >> ((pte >> 1) & 0x18)) & 0xff; + entry->attr = pte & 0xf; +} + +void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb, + unsigned wi, unsigned ei, + uint32_t vpn, uint32_t pte) +{ + CPUState *cs = env_cpu(env); + xtensa_tlb_entry *entry = xtensa_tlb_get_entry(env, dtlb, wi, ei); + + if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { + if (entry->variable) { + if (entry->asid) { + tlb_flush_page(cs, entry->vaddr); + } + xtensa_tlb_set_entry_mmu(env, entry, dtlb, wi, ei, vpn, pte); + tlb_flush_page(cs, entry->vaddr); + } else { + qemu_log_mask(LOG_GUEST_ERROR, + "%s %d, %d, %d trying to set immutable entry\n", + __func__, dtlb, wi, ei); + } + } else { + tlb_flush_page(cs, entry->vaddr); + if (xtensa_option_enabled(env->config, + XTENSA_OPTION_REGION_TRANSLATION)) { + entry->paddr = pte & REGION_PAGE_MASK; + } + entry->attr = pte & 0xf; + } +} + +hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) +{ + XtensaCPU *cpu = XTENSA_CPU(cs); + uint32_t paddr; + uint32_t page_size; + unsigned access; + + if (xtensa_get_physical_addr(&cpu->env, false, addr, 0, 0, + &paddr, &page_size, &access) == 0) { + return paddr; + } + if (xtensa_get_physical_addr(&cpu->env, false, addr, 2, 0, + &paddr, &page_size, &access) == 0) { + return paddr; + } + return ~0; +} + +static void reset_tlb_mmu_all_ways(CPUXtensaState *env, const xtensa_tlb *tlb, + xtensa_tlb_entry entry[][MAX_TLB_WAY_SIZE]) +{ + unsigned wi, ei; + + for (wi = 0; wi < tlb->nways; ++wi) { + for (ei = 0; ei < tlb->way_size[wi]; ++ei) { + entry[wi][ei].asid = 0; + entry[wi][ei].variable = true; + } + } +} + +static void reset_tlb_mmu_ways56(CPUXtensaState *env, const xtensa_tlb *tlb, + xtensa_tlb_entry entry[][MAX_TLB_WAY_SIZE]) +{ + if (!tlb->varway56) { + static const xtensa_tlb_entry way5[] = { + { + .vaddr = 0xd0000000, + .paddr = 0, + .asid = 1, + .attr = 7, + .variable = false, + }, { + .vaddr = 0xd8000000, + .paddr = 0, + .asid = 1, + .attr = 3, + .variable = false, + } + }; + static const xtensa_tlb_entry way6[] = { + { + .vaddr = 0xe0000000, + .paddr = 0xf0000000, + .asid = 1, + .attr = 7, + .variable = false, + }, { + .vaddr = 0xf0000000, + .paddr = 0xf0000000, + .asid = 1, + .attr = 3, + .variable = false, + } + }; + memcpy(entry[5], way5, sizeof(way5)); + memcpy(entry[6], way6, sizeof(way6)); + } else { + uint32_t ei; + for (ei = 0; ei < 8; ++ei) { + entry[6][ei].vaddr = ei << 29; + entry[6][ei].paddr = ei << 29; + entry[6][ei].asid = 1; + entry[6][ei].attr = 3; + } + } +} + +static void reset_tlb_region_way0(CPUXtensaState *env, + xtensa_tlb_entry entry[][MAX_TLB_WAY_SIZE]) +{ + unsigned ei; + + for (ei = 0; ei < 8; ++ei) { + entry[0][ei].vaddr = ei << 29; + entry[0][ei].paddr = ei << 29; + entry[0][ei].asid = 1; + entry[0][ei].attr = 2; + entry[0][ei].variable = true; + } +} + +void xtensa_reset_mmu(CPUXtensaState *env) +{ + if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { + env->sregs[RASID] = 0x04030201; + env->sregs[ITLBCFG] = 0; + env->sregs[DTLBCFG] = 0; + env->autorefill_idx = 0; + reset_tlb_mmu_all_ways(env, &env->config->itlb, env->itlb); + reset_tlb_mmu_all_ways(env, &env->config->dtlb, env->dtlb); + reset_tlb_mmu_ways56(env, &env->config->itlb, env->itlb); + reset_tlb_mmu_ways56(env, &env->config->dtlb, env->dtlb); + } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { + unsigned i; + + env->sregs[MPUENB] = 0; + env->sregs[MPUCFG] = env->config->n_mpu_fg_segments; + env->sregs[CACHEADRDIS] = 0; + assert(env->config->n_mpu_bg_segments > 0 && + env->config->mpu_bg[0].vaddr == 0); + for (i = 1; i < env->config->n_mpu_bg_segments; ++i) { + assert(env->config->mpu_bg[i].vaddr >= + env->config->mpu_bg[i - 1].vaddr); + } + } else { + env->sregs[CACHEATTR] = 0x22222222; + reset_tlb_region_way0(env, env->itlb); + reset_tlb_region_way0(env, env->dtlb); + } +} + +static unsigned get_ring(const CPUXtensaState *env, uint8_t asid) +{ + unsigned i; + for (i = 0; i < 4; ++i) { + if (((env->sregs[RASID] >> i * 8) & 0xff) == asid) { + return i; + } + } + return 0xff; +} + +/*! + * Lookup xtensa TLB for the given virtual address. + * See ISA, 4.6.2.2 + * + * \param pwi: [out] way index + * \param pei: [out] entry index + * \param pring: [out] access ring + * \return 0 if ok, exception cause code otherwise + */ +int xtensa_tlb_lookup(const CPUXtensaState *env, uint32_t addr, bool dtlb, + uint32_t *pwi, uint32_t *pei, uint8_t *pring) +{ + const xtensa_tlb *tlb = dtlb ? + &env->config->dtlb : &env->config->itlb; + const xtensa_tlb_entry (*entry)[MAX_TLB_WAY_SIZE] = dtlb ? + env->dtlb : env->itlb; + + int nhits = 0; + unsigned wi; + + for (wi = 0; wi < tlb->nways; ++wi) { + uint32_t vpn; + uint32_t ei; + xtensa_split_tlb_entry_spec_way(env, addr, dtlb, &vpn, wi, &ei); + if (entry[wi][ei].vaddr == vpn && entry[wi][ei].asid) { + unsigned ring = get_ring(env, entry[wi][ei].asid); + if (ring < 4) { + if (++nhits > 1) { + return dtlb ? + LOAD_STORE_TLB_MULTI_HIT_CAUSE : + INST_TLB_MULTI_HIT_CAUSE; + } + *pwi = wi; + *pei = ei; + *pring = ring; + } + } + } + return nhits ? 0 : + (dtlb ? LOAD_STORE_TLB_MISS_CAUSE : INST_TLB_MISS_CAUSE); +} + +/*! + * Convert MMU ATTR to PAGE_{READ,WRITE,EXEC} mask. + * See ISA, 4.6.5.10 + */ +unsigned mmu_attr_to_access(uint32_t attr) +{ + unsigned access = 0; + + if (attr < 12) { + access |= PAGE_READ; + if (attr & 0x1) { + access |= PAGE_EXEC; + } + if (attr & 0x2) { + access |= PAGE_WRITE; + } + + switch (attr & 0xc) { + case 0: + access |= PAGE_CACHE_BYPASS; + break; + + case 4: + access |= PAGE_CACHE_WB; + break; + + case 8: + access |= PAGE_CACHE_WT; + break; + } + } else if (attr == 13) { + access |= PAGE_READ | PAGE_WRITE | PAGE_CACHE_ISOLATE; + } + return access; +} + +/*! + * Convert region protection ATTR to PAGE_{READ,WRITE,EXEC} mask. + * See ISA, 4.6.3.3 + */ +unsigned region_attr_to_access(uint32_t attr) +{ + static const unsigned access[16] = { + [0] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_WT, + [1] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WT, + [2] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS, + [3] = PAGE_EXEC | PAGE_CACHE_WB, + [4] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WB, + [5] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WB, + [14] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_ISOLATE, + }; + + return access[attr & 0xf]; +} + +/*! + * Convert cacheattr to PAGE_{READ,WRITE,EXEC} mask. + * See ISA, A.2.14 The Cache Attribute Register + */ +unsigned cacheattr_attr_to_access(uint32_t attr) +{ + static const unsigned access[16] = { + [0] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_WT, + [1] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WT, + [2] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS, + [3] = PAGE_EXEC | PAGE_CACHE_WB, + [4] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WB, + [14] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_ISOLATE, + }; + + return access[attr & 0xf]; +} + +struct attr_pattern { + uint32_t mask; + uint32_t value; +}; + +static int attr_pattern_match(uint32_t attr, + const struct attr_pattern *pattern, + size_t n) +{ + size_t i; + + for (i = 0; i < n; ++i) { + if ((attr & pattern[i].mask) == pattern[i].value) { + return 1; + } + } + return 0; +} + +unsigned mpu_attr_to_cpu_cache(uint32_t attr) +{ + static const struct attr_pattern cpu_c[] = { + { .mask = 0x18f, .value = 0x089 }, + { .mask = 0x188, .value = 0x080 }, + { .mask = 0x180, .value = 0x180 }, + }; + + unsigned type = 0; + + if (attr_pattern_match(attr, cpu_c, ARRAY_SIZE(cpu_c))) { + type |= XTENSA_MPU_TYPE_CPU_CACHE; + if (attr & 0x10) { + type |= XTENSA_MPU_TYPE_CPU_C; + } + if (attr & 0x20) { + type |= XTENSA_MPU_TYPE_CPU_W; + } + if (attr & 0x40) { + type |= XTENSA_MPU_TYPE_CPU_R; + } + } + return type; +} + +unsigned mpu_attr_to_type(uint32_t attr) +{ + static const struct attr_pattern device_type[] = { + { .mask = 0x1f6, .value = 0x000 }, + { .mask = 0x1f6, .value = 0x006 }, + }; + static const struct attr_pattern sys_nc_type[] = { + { .mask = 0x1fe, .value = 0x018 }, + { .mask = 0x1fe, .value = 0x01e }, + { .mask = 0x18f, .value = 0x089 }, + }; + static const struct attr_pattern sys_c_type[] = { + { .mask = 0x1f8, .value = 0x010 }, + { .mask = 0x188, .value = 0x080 }, + { .mask = 0x1f0, .value = 0x030 }, + { .mask = 0x180, .value = 0x180 }, + }; + static const struct attr_pattern b[] = { + { .mask = 0x1f7, .value = 0x001 }, + { .mask = 0x1f7, .value = 0x007 }, + { .mask = 0x1ff, .value = 0x019 }, + { .mask = 0x1ff, .value = 0x01f }, + }; + + unsigned type = 0; + + attr = (attr & XTENSA_MPU_MEM_TYPE_MASK) >> XTENSA_MPU_MEM_TYPE_SHIFT; + if (attr_pattern_match(attr, device_type, ARRAY_SIZE(device_type))) { + type |= XTENSA_MPU_SYSTEM_TYPE_DEVICE; + if (attr & 0x80) { + type |= XTENSA_MPU_TYPE_INT; + } + } + if (attr_pattern_match(attr, sys_nc_type, ARRAY_SIZE(sys_nc_type))) { + type |= XTENSA_MPU_SYSTEM_TYPE_NC; + } + if (attr_pattern_match(attr, sys_c_type, ARRAY_SIZE(sys_c_type))) { + type |= XTENSA_MPU_SYSTEM_TYPE_C; + if (attr & 0x1) { + type |= XTENSA_MPU_TYPE_SYS_C; + } + if (attr & 0x2) { + type |= XTENSA_MPU_TYPE_SYS_W; + } + if (attr & 0x4) { + type |= XTENSA_MPU_TYPE_SYS_R; + } + } + if (attr_pattern_match(attr, b, ARRAY_SIZE(b))) { + type |= XTENSA_MPU_TYPE_B; + } + type |= mpu_attr_to_cpu_cache(attr); + + return type; +} + +unsigned mpu_attr_to_access(uint32_t attr, unsigned ring) +{ + static const unsigned access[2][16] = { + [0] = { + [4] = PAGE_READ, + [5] = PAGE_READ | PAGE_EXEC, + [6] = PAGE_READ | PAGE_WRITE, + [7] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, + [8] = PAGE_WRITE, + [9] = PAGE_READ | PAGE_WRITE, + [10] = PAGE_READ | PAGE_WRITE, + [11] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, + [12] = PAGE_READ, + [13] = PAGE_READ | PAGE_EXEC, + [14] = PAGE_READ | PAGE_WRITE, + [15] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, + }, + [1] = { + [8] = PAGE_WRITE, + [9] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, + [10] = PAGE_READ, + [11] = PAGE_READ | PAGE_EXEC, + [12] = PAGE_READ, + [13] = PAGE_READ | PAGE_EXEC, + [14] = PAGE_READ | PAGE_WRITE, + [15] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, + }, + }; + unsigned rv; + unsigned type; + + type = mpu_attr_to_cpu_cache(attr); + rv = access[ring != 0][(attr & XTENSA_MPU_ACC_RIGHTS_MASK) >> + XTENSA_MPU_ACC_RIGHTS_SHIFT]; + + if (type & XTENSA_MPU_TYPE_CPU_CACHE) { + rv |= (type & XTENSA_MPU_TYPE_CPU_C) ? PAGE_CACHE_WB : PAGE_CACHE_WT; + } else { + rv |= PAGE_CACHE_BYPASS; + } + return rv; +} + +static bool is_access_granted(unsigned access, int is_write) +{ + switch (is_write) { + case 0: + return access & PAGE_READ; + + case 1: + return access & PAGE_WRITE; + + case 2: + return access & PAGE_EXEC; + + default: + return 0; + } +} + +static bool get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte); + +static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb, + uint32_t vaddr, int is_write, int mmu_idx, + uint32_t *paddr, uint32_t *page_size, + unsigned *access, bool may_lookup_pt) +{ + bool dtlb = is_write != 2; + uint32_t wi; + uint32_t ei; + uint8_t ring; + uint32_t vpn; + uint32_t pte; + const xtensa_tlb_entry *entry = NULL; + xtensa_tlb_entry tmp_entry; + int ret = xtensa_tlb_lookup(env, vaddr, dtlb, &wi, &ei, &ring); + + if ((ret == INST_TLB_MISS_CAUSE || ret == LOAD_STORE_TLB_MISS_CAUSE) && + may_lookup_pt && get_pte(env, vaddr, &pte)) { + ring = (pte >> 4) & 0x3; + wi = 0; + xtensa_split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei); + + if (update_tlb) { + wi = ++env->autorefill_idx & 0x3; + xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, pte); + env->sregs[EXCVADDR] = vaddr; + qemu_log_mask(CPU_LOG_MMU, "%s: autorefill(%08x): %08x -> %08x\n", + __func__, vaddr, vpn, pte); + } else { + xtensa_tlb_set_entry_mmu(env, &tmp_entry, dtlb, wi, ei, vpn, pte); + entry = &tmp_entry; + } + ret = 0; + } + if (ret != 0) { + return ret; + } + + if (entry == NULL) { + entry = xtensa_tlb_get_entry(env, dtlb, wi, ei); + } + + if (ring < mmu_idx) { + return dtlb ? + LOAD_STORE_PRIVILEGE_CAUSE : + INST_FETCH_PRIVILEGE_CAUSE; + } + + *access = mmu_attr_to_access(entry->attr) & + ~(dtlb ? PAGE_EXEC : PAGE_READ | PAGE_WRITE); + if (!is_access_granted(*access, is_write)) { + return dtlb ? + (is_write ? + STORE_PROHIBITED_CAUSE : + LOAD_PROHIBITED_CAUSE) : + INST_FETCH_PROHIBITED_CAUSE; + } + + *paddr = entry->paddr | (vaddr & ~xtensa_tlb_get_addr_mask(env, dtlb, wi)); + *page_size = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1; + + return 0; +} + +static bool get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte) +{ + CPUState *cs = env_cpu(env); + uint32_t paddr; + uint32_t page_size; + unsigned access; + uint32_t pt_vaddr = + (env->sregs[PTEVADDR] | (vaddr >> 10)) & 0xfffffffc; + int ret = get_physical_addr_mmu(env, false, pt_vaddr, 0, 0, + &paddr, &page_size, &access, false); + + if (ret == 0) { + qemu_log_mask(CPU_LOG_MMU, + "%s: autorefill(%08x): PTE va = %08x, pa = %08x\n", + __func__, vaddr, pt_vaddr, paddr); + } else { + qemu_log_mask(CPU_LOG_MMU, + "%s: autorefill(%08x): PTE va = %08x, failed (%d)\n", + __func__, vaddr, pt_vaddr, ret); + } + + if (ret == 0) { + MemTxResult result; + + *pte = address_space_ldl(cs->as, paddr, MEMTXATTRS_UNSPECIFIED, + &result); + if (result != MEMTX_OK) { + qemu_log_mask(CPU_LOG_MMU, + "%s: couldn't load PTE: transaction failed (%u)\n", + __func__, (unsigned)result); + ret = 1; + } + } + return ret == 0; +} + +static int get_physical_addr_region(CPUXtensaState *env, + uint32_t vaddr, int is_write, int mmu_idx, + uint32_t *paddr, uint32_t *page_size, + unsigned *access) +{ + bool dtlb = is_write != 2; + uint32_t wi = 0; + uint32_t ei = (vaddr >> 29) & 0x7; + const xtensa_tlb_entry *entry = + xtensa_tlb_get_entry(env, dtlb, wi, ei); + + *access = region_attr_to_access(entry->attr); + if (!is_access_granted(*access, is_write)) { + return dtlb ? + (is_write ? + STORE_PROHIBITED_CAUSE : + LOAD_PROHIBITED_CAUSE) : + INST_FETCH_PROHIBITED_CAUSE; + } + + *paddr = entry->paddr | (vaddr & ~REGION_PAGE_MASK); + *page_size = ~REGION_PAGE_MASK + 1; + + return 0; +} + +int xtensa_mpu_lookup(const xtensa_mpu_entry *entry, unsigned n, + uint32_t vaddr, unsigned *segment) +{ + unsigned nhits = 0; + unsigned i; + + for (i = 0; i < n; ++i) { + if (vaddr >= entry[i].vaddr && + (i == n - 1 || vaddr < entry[i + 1].vaddr)) { + if (nhits++) { + break; + } + *segment = i; + } + } + return nhits; +} + +static int get_physical_addr_mpu(CPUXtensaState *env, + uint32_t vaddr, int is_write, int mmu_idx, + uint32_t *paddr, uint32_t *page_size, + unsigned *access) +{ + unsigned nhits; + unsigned segment; + uint32_t attr; + + nhits = xtensa_mpu_lookup(env->mpu_fg, env->config->n_mpu_fg_segments, + vaddr, &segment); + if (nhits > 1) { + return is_write < 2 ? + LOAD_STORE_TLB_MULTI_HIT_CAUSE : + INST_TLB_MULTI_HIT_CAUSE; + } else if (nhits == 1 && (env->sregs[MPUENB] & (1u << segment))) { + attr = env->mpu_fg[segment].attr; + } else { + xtensa_mpu_lookup(env->config->mpu_bg, + env->config->n_mpu_bg_segments, + vaddr, &segment); + attr = env->config->mpu_bg[segment].attr; + } + + *access = mpu_attr_to_access(attr, mmu_idx); + if (!is_access_granted(*access, is_write)) { + return is_write < 2 ? + (is_write ? + STORE_PROHIBITED_CAUSE : + LOAD_PROHIBITED_CAUSE) : + INST_FETCH_PROHIBITED_CAUSE; + } + *paddr = vaddr; + *page_size = env->config->mpu_align; + return 0; +} + +/*! + * Convert virtual address to physical addr. + * MMU may issue pagewalk and change xtensa autorefill TLB way entry. + * + * \return 0 if ok, exception cause code otherwise + */ +int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, + uint32_t vaddr, int is_write, int mmu_idx, + uint32_t *paddr, uint32_t *page_size, + unsigned *access) +{ + if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { + return get_physical_addr_mmu(env, update_tlb, + vaddr, is_write, mmu_idx, paddr, + page_size, access, true); + } else if (xtensa_option_bits_enabled(env->config, + XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | + XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION))) { + return get_physical_addr_region(env, vaddr, is_write, mmu_idx, + paddr, page_size, access); + } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { + return get_physical_addr_mpu(env, vaddr, is_write, mmu_idx, + paddr, page_size, access); + } else { + *paddr = vaddr; + *page_size = TARGET_PAGE_SIZE; + *access = cacheattr_attr_to_access(env->sregs[CACHEATTR] >> + ((vaddr & 0xe0000000) >> 27)); + return 0; + } +} diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index 31ee3fa957..8be8d79dcd 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -26,38 +26,12 @@ */ #include "qemu/osdep.h" -#include "qemu/log.h" #include "qemu/qemu-print.h" #include "qemu/units.h" -#include "cpu.h" #include "exec/helper-proto.h" -#include "qemu/host-utils.h" #include "exec/exec-all.h" - -#define XTENSA_MPU_SEGMENT_MASK 0x0000001f -#define XTENSA_MPU_ACC_RIGHTS_MASK 0x00000f00 -#define XTENSA_MPU_ACC_RIGHTS_SHIFT 8 -#define XTENSA_MPU_MEM_TYPE_MASK 0x001ff000 -#define XTENSA_MPU_MEM_TYPE_SHIFT 12 -#define XTENSA_MPU_ATTR_MASK 0x001fff00 - -#define XTENSA_MPU_PROBE_B 0x40000000 -#define XTENSA_MPU_PROBE_V 0x80000000 - -#define XTENSA_MPU_SYSTEM_TYPE_DEVICE 0x0001 -#define XTENSA_MPU_SYSTEM_TYPE_NC 0x0002 -#define XTENSA_MPU_SYSTEM_TYPE_C 0x0003 -#define XTENSA_MPU_SYSTEM_TYPE_MASK 0x0003 - -#define XTENSA_MPU_TYPE_SYS_C 0x0010 -#define XTENSA_MPU_TYPE_SYS_W 0x0020 -#define XTENSA_MPU_TYPE_SYS_R 0x0040 -#define XTENSA_MPU_TYPE_CPU_C 0x0100 -#define XTENSA_MPU_TYPE_CPU_W 0x0200 -#define XTENSA_MPU_TYPE_CPU_R 0x0400 -#define XTENSA_MPU_TYPE_CPU_CACHE 0x0800 -#define XTENSA_MPU_TYPE_B 0x1000 -#define XTENSA_MPU_TYPE_INT 0x2000 +#include "cpu.h" +#include "mmu.h" void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr) { @@ -78,421 +52,6 @@ void HELPER(wsr_rasid)(CPUXtensaState *env, uint32_t v) } } -static uint32_t get_page_size(const CPUXtensaState *env, - bool dtlb, uint32_t way) -{ - uint32_t tlbcfg = env->sregs[dtlb ? DTLBCFG : ITLBCFG]; - - switch (way) { - case 4: - return (tlbcfg >> 16) & 0x3; - - case 5: - return (tlbcfg >> 20) & 0x1; - - case 6: - return (tlbcfg >> 24) & 0x1; - - default: - return 0; - } -} - -/*! - * Get bit mask for the virtual address bits translated by the TLB way - */ -static uint32_t xtensa_tlb_get_addr_mask(const CPUXtensaState *env, - bool dtlb, uint32_t way) -{ - if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { - bool varway56 = dtlb ? - env->config->dtlb.varway56 : - env->config->itlb.varway56; - - switch (way) { - case 4: - return 0xfff00000 << get_page_size(env, dtlb, way) * 2; - - case 5: - if (varway56) { - return 0xf8000000 << get_page_size(env, dtlb, way); - } else { - return 0xf8000000; - } - - case 6: - if (varway56) { - return 0xf0000000 << (1 - get_page_size(env, dtlb, way)); - } else { - return 0xf0000000; - } - - default: - return 0xfffff000; - } - } else { - return REGION_PAGE_MASK; - } -} - -/*! - * Get bit mask for the 'VPN without index' field. - * See ISA, 4.6.5.6, data format for RxTLB0 - */ -static uint32_t xtensa_get_vpn_mask(const CPUXtensaState *env, bool dtlb, - uint32_t way) -{ - if (way < 4) { - bool is32 = (dtlb ? - env->config->dtlb.nrefillentries : - env->config->itlb.nrefillentries) == 32; - return is32 ? 0xffff8000 : 0xffffc000; - } else if (way == 4) { - return xtensa_tlb_get_addr_mask(env, dtlb, way) << 2; - } else if (way <= 6) { - uint32_t mask = xtensa_tlb_get_addr_mask(env, dtlb, way); - bool varway56 = dtlb ? - env->config->dtlb.varway56 : - env->config->itlb.varway56; - - if (varway56) { - return mask << (way == 5 ? 2 : 3); - } else { - return mask << 1; - } - } else { - return 0xfffff000; - } -} - -/*! - * Split virtual address into VPN (with index) and entry index - * for the given TLB way - */ -static void xtensa_split_tlb_entry_spec_way(const CPUXtensaState *env, - uint32_t v, - bool dtlb, uint32_t *vpn, - uint32_t wi, uint32_t *ei) -{ - bool varway56 = dtlb ? - env->config->dtlb.varway56 : - env->config->itlb.varway56; - - if (!dtlb) { - wi &= 7; - } - - if (wi < 4) { - bool is32 = (dtlb ? - env->config->dtlb.nrefillentries : - env->config->itlb.nrefillentries) == 32; - *ei = (v >> 12) & (is32 ? 0x7 : 0x3); - } else { - switch (wi) { - case 4: - { - uint32_t eibase = 20 + get_page_size(env, dtlb, wi) * 2; - *ei = (v >> eibase) & 0x3; - } - break; - - case 5: - if (varway56) { - uint32_t eibase = 27 + get_page_size(env, dtlb, wi); - *ei = (v >> eibase) & 0x3; - } else { - *ei = (v >> 27) & 0x1; - } - break; - - case 6: - if (varway56) { - uint32_t eibase = 29 - get_page_size(env, dtlb, wi); - *ei = (v >> eibase) & 0x7; - } else { - *ei = (v >> 28) & 0x1; - } - break; - - default: - *ei = 0; - break; - } - } - *vpn = v & xtensa_tlb_get_addr_mask(env, dtlb, wi); -} - -/*! - * Split TLB address into TLB way, entry index and VPN (with index). - * See ISA, 4.6.5.5 - 4.6.5.8 for the TLB addressing format - */ -static bool xtensa_split_tlb_entry_spec(CPUXtensaState *env, - uint32_t v, bool dtlb, - uint32_t *vpn, uint32_t *wi, - uint32_t *ei) -{ - if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { - *wi = v & (dtlb ? 0xf : 0x7); - if (*wi < (dtlb ? env->config->dtlb.nways : env->config->itlb.nways)) { - xtensa_split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei); - return true; - } else { - return false; - } - } else { - *vpn = v & REGION_PAGE_MASK; - *wi = 0; - *ei = (v >> 29) & 0x7; - return true; - } -} - -static xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env, bool dtlb, - unsigned wi, unsigned ei) -{ - const xtensa_tlb *tlb = dtlb ? &env->config->dtlb : &env->config->itlb; - - assert(wi < tlb->nways && ei < tlb->way_size[wi]); - return dtlb ? - env->dtlb[wi] + ei : - env->itlb[wi] + ei; -} - -static xtensa_tlb_entry *xtensa_get_tlb_entry(CPUXtensaState *env, - uint32_t v, bool dtlb, uint32_t *pwi) -{ - uint32_t vpn; - uint32_t wi; - uint32_t ei; - - if (xtensa_split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { - if (pwi) { - *pwi = wi; - } - return xtensa_tlb_get_entry(env, dtlb, wi, ei); - } else { - return NULL; - } -} - -static void xtensa_tlb_set_entry_mmu(const CPUXtensaState *env, - xtensa_tlb_entry *entry, bool dtlb, - unsigned wi, unsigned ei, uint32_t vpn, - uint32_t pte) -{ - entry->vaddr = vpn; - entry->paddr = pte & xtensa_tlb_get_addr_mask(env, dtlb, wi); - entry->asid = (env->sregs[RASID] >> ((pte >> 1) & 0x18)) & 0xff; - entry->attr = pte & 0xf; -} - -static void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb, - unsigned wi, unsigned ei, - uint32_t vpn, uint32_t pte) -{ - CPUState *cs = env_cpu(env); - xtensa_tlb_entry *entry = xtensa_tlb_get_entry(env, dtlb, wi, ei); - - if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { - if (entry->variable) { - if (entry->asid) { - tlb_flush_page(cs, entry->vaddr); - } - xtensa_tlb_set_entry_mmu(env, entry, dtlb, wi, ei, vpn, pte); - tlb_flush_page(cs, entry->vaddr); - } else { - qemu_log_mask(LOG_GUEST_ERROR, - "%s %d, %d, %d trying to set immutable entry\n", - __func__, dtlb, wi, ei); - } - } else { - tlb_flush_page(cs, entry->vaddr); - if (xtensa_option_enabled(env->config, - XTENSA_OPTION_REGION_TRANSLATION)) { - entry->paddr = pte & REGION_PAGE_MASK; - } - entry->attr = pte & 0xf; - } -} - -hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) -{ - XtensaCPU *cpu = XTENSA_CPU(cs); - uint32_t paddr; - uint32_t page_size; - unsigned access; - - if (xtensa_get_physical_addr(&cpu->env, false, addr, 0, 0, - &paddr, &page_size, &access) == 0) { - return paddr; - } - if (xtensa_get_physical_addr(&cpu->env, false, addr, 2, 0, - &paddr, &page_size, &access) == 0) { - return paddr; - } - return ~0; -} - -static void reset_tlb_mmu_all_ways(CPUXtensaState *env, - const xtensa_tlb *tlb, - xtensa_tlb_entry entry[][MAX_TLB_WAY_SIZE]) -{ - unsigned wi, ei; - - for (wi = 0; wi < tlb->nways; ++wi) { - for (ei = 0; ei < tlb->way_size[wi]; ++ei) { - entry[wi][ei].asid = 0; - entry[wi][ei].variable = true; - } - } -} - -static void reset_tlb_mmu_ways56(CPUXtensaState *env, - const xtensa_tlb *tlb, - xtensa_tlb_entry entry[][MAX_TLB_WAY_SIZE]) -{ - if (!tlb->varway56) { - static const xtensa_tlb_entry way5[] = { - { - .vaddr = 0xd0000000, - .paddr = 0, - .asid = 1, - .attr = 7, - .variable = false, - }, { - .vaddr = 0xd8000000, - .paddr = 0, - .asid = 1, - .attr = 3, - .variable = false, - } - }; - static const xtensa_tlb_entry way6[] = { - { - .vaddr = 0xe0000000, - .paddr = 0xf0000000, - .asid = 1, - .attr = 7, - .variable = false, - }, { - .vaddr = 0xf0000000, - .paddr = 0xf0000000, - .asid = 1, - .attr = 3, - .variable = false, - } - }; - memcpy(entry[5], way5, sizeof(way5)); - memcpy(entry[6], way6, sizeof(way6)); - } else { - uint32_t ei; - for (ei = 0; ei < 8; ++ei) { - entry[6][ei].vaddr = ei << 29; - entry[6][ei].paddr = ei << 29; - entry[6][ei].asid = 1; - entry[6][ei].attr = 3; - } - } -} - -static void reset_tlb_region_way0(CPUXtensaState *env, - xtensa_tlb_entry entry[][MAX_TLB_WAY_SIZE]) -{ - unsigned ei; - - for (ei = 0; ei < 8; ++ei) { - entry[0][ei].vaddr = ei << 29; - entry[0][ei].paddr = ei << 29; - entry[0][ei].asid = 1; - entry[0][ei].attr = 2; - entry[0][ei].variable = true; - } -} - -void xtensa_reset_mmu(CPUXtensaState *env) -{ - if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { - env->sregs[RASID] = 0x04030201; - env->sregs[ITLBCFG] = 0; - env->sregs[DTLBCFG] = 0; - env->autorefill_idx = 0; - reset_tlb_mmu_all_ways(env, &env->config->itlb, env->itlb); - reset_tlb_mmu_all_ways(env, &env->config->dtlb, env->dtlb); - reset_tlb_mmu_ways56(env, &env->config->itlb, env->itlb); - reset_tlb_mmu_ways56(env, &env->config->dtlb, env->dtlb); - } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { - unsigned i; - - env->sregs[MPUENB] = 0; - env->sregs[MPUCFG] = env->config->n_mpu_fg_segments; - env->sregs[CACHEADRDIS] = 0; - assert(env->config->n_mpu_bg_segments > 0 && - env->config->mpu_bg[0].vaddr == 0); - for (i = 1; i < env->config->n_mpu_bg_segments; ++i) { - assert(env->config->mpu_bg[i].vaddr >= - env->config->mpu_bg[i - 1].vaddr); - } - } else { - env->sregs[CACHEATTR] = 0x22222222; - reset_tlb_region_way0(env, env->itlb); - reset_tlb_region_way0(env, env->dtlb); - } -} - -static unsigned get_ring(const CPUXtensaState *env, uint8_t asid) -{ - unsigned i; - for (i = 0; i < 4; ++i) { - if (((env->sregs[RASID] >> i * 8) & 0xff) == asid) { - return i; - } - } - return 0xff; -} - -/*! - * Lookup xtensa TLB for the given virtual address. - * See ISA, 4.6.2.2 - * - * \param pwi: [out] way index - * \param pei: [out] entry index - * \param pring: [out] access ring - * \return 0 if ok, exception cause code otherwise - */ -static int xtensa_tlb_lookup(const CPUXtensaState *env, - uint32_t addr, bool dtlb, - uint32_t *pwi, uint32_t *pei, uint8_t *pring) -{ - const xtensa_tlb *tlb = dtlb ? - &env->config->dtlb : &env->config->itlb; - const xtensa_tlb_entry (*entry)[MAX_TLB_WAY_SIZE] = dtlb ? - env->dtlb : env->itlb; - - int nhits = 0; - unsigned wi; - - for (wi = 0; wi < tlb->nways; ++wi) { - uint32_t vpn; - uint32_t ei; - xtensa_split_tlb_entry_spec_way(env, addr, dtlb, &vpn, wi, &ei); - if (entry[wi][ei].vaddr == vpn && entry[wi][ei].asid) { - unsigned ring = get_ring(env, entry[wi][ei].asid); - if (ring < 4) { - if (++nhits > 1) { - return dtlb ? - LOAD_STORE_TLB_MULTI_HIT_CAUSE : - INST_TLB_MULTI_HIT_CAUSE; - } - *pwi = wi; - *pei = ei; - *pring = ring; - } - } - } - return nhits ? 0 : - (dtlb ? LOAD_STORE_TLB_MISS_CAUSE : INST_TLB_MISS_CAUSE); -} - uint32_t HELPER(rtlb0)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { @@ -569,384 +128,6 @@ void HELPER(wtlb)(CPUXtensaState *env, uint32_t p, uint32_t v, uint32_t dtlb) } } -/*! - * Convert MMU ATTR to PAGE_{READ,WRITE,EXEC} mask. - * See ISA, 4.6.5.10 - */ -static unsigned mmu_attr_to_access(uint32_t attr) -{ - unsigned access = 0; - - if (attr < 12) { - access |= PAGE_READ; - if (attr & 0x1) { - access |= PAGE_EXEC; - } - if (attr & 0x2) { - access |= PAGE_WRITE; - } - - switch (attr & 0xc) { - case 0: - access |= PAGE_CACHE_BYPASS; - break; - - case 4: - access |= PAGE_CACHE_WB; - break; - - case 8: - access |= PAGE_CACHE_WT; - break; - } - } else if (attr == 13) { - access |= PAGE_READ | PAGE_WRITE | PAGE_CACHE_ISOLATE; - } - return access; -} - -/*! - * Convert region protection ATTR to PAGE_{READ,WRITE,EXEC} mask. - * See ISA, 4.6.3.3 - */ -static unsigned region_attr_to_access(uint32_t attr) -{ - static const unsigned access[16] = { - [0] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_WT, - [1] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WT, - [2] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS, - [3] = PAGE_EXEC | PAGE_CACHE_WB, - [4] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WB, - [5] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WB, - [14] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_ISOLATE, - }; - - return access[attr & 0xf]; -} - -/*! - * Convert cacheattr to PAGE_{READ,WRITE,EXEC} mask. - * See ISA, A.2.14 The Cache Attribute Register - */ -static unsigned cacheattr_attr_to_access(uint32_t attr) -{ - static const unsigned access[16] = { - [0] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_WT, - [1] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WT, - [2] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS, - [3] = PAGE_EXEC | PAGE_CACHE_WB, - [4] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WB, - [14] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_ISOLATE, - }; - - return access[attr & 0xf]; -} - -struct attr_pattern { - uint32_t mask; - uint32_t value; -}; - -static int attr_pattern_match(uint32_t attr, - const struct attr_pattern *pattern, - size_t n) -{ - size_t i; - - for (i = 0; i < n; ++i) { - if ((attr & pattern[i].mask) == pattern[i].value) { - return 1; - } - } - return 0; -} - -static unsigned mpu_attr_to_cpu_cache(uint32_t attr) -{ - static const struct attr_pattern cpu_c[] = { - { .mask = 0x18f, .value = 0x089 }, - { .mask = 0x188, .value = 0x080 }, - { .mask = 0x180, .value = 0x180 }, - }; - - unsigned type = 0; - - if (attr_pattern_match(attr, cpu_c, ARRAY_SIZE(cpu_c))) { - type |= XTENSA_MPU_TYPE_CPU_CACHE; - if (attr & 0x10) { - type |= XTENSA_MPU_TYPE_CPU_C; - } - if (attr & 0x20) { - type |= XTENSA_MPU_TYPE_CPU_W; - } - if (attr & 0x40) { - type |= XTENSA_MPU_TYPE_CPU_R; - } - } - return type; -} - -static unsigned mpu_attr_to_type(uint32_t attr) -{ - static const struct attr_pattern device_type[] = { - { .mask = 0x1f6, .value = 0x000 }, - { .mask = 0x1f6, .value = 0x006 }, - }; - static const struct attr_pattern sys_nc_type[] = { - { .mask = 0x1fe, .value = 0x018 }, - { .mask = 0x1fe, .value = 0x01e }, - { .mask = 0x18f, .value = 0x089 }, - }; - static const struct attr_pattern sys_c_type[] = { - { .mask = 0x1f8, .value = 0x010 }, - { .mask = 0x188, .value = 0x080 }, - { .mask = 0x1f0, .value = 0x030 }, - { .mask = 0x180, .value = 0x180 }, - }; - static const struct attr_pattern b[] = { - { .mask = 0x1f7, .value = 0x001 }, - { .mask = 0x1f7, .value = 0x007 }, - { .mask = 0x1ff, .value = 0x019 }, - { .mask = 0x1ff, .value = 0x01f }, - }; - - unsigned type = 0; - - attr = (attr & XTENSA_MPU_MEM_TYPE_MASK) >> XTENSA_MPU_MEM_TYPE_SHIFT; - if (attr_pattern_match(attr, device_type, ARRAY_SIZE(device_type))) { - type |= XTENSA_MPU_SYSTEM_TYPE_DEVICE; - if (attr & 0x80) { - type |= XTENSA_MPU_TYPE_INT; - } - } - if (attr_pattern_match(attr, sys_nc_type, ARRAY_SIZE(sys_nc_type))) { - type |= XTENSA_MPU_SYSTEM_TYPE_NC; - } - if (attr_pattern_match(attr, sys_c_type, ARRAY_SIZE(sys_c_type))) { - type |= XTENSA_MPU_SYSTEM_TYPE_C; - if (attr & 0x1) { - type |= XTENSA_MPU_TYPE_SYS_C; - } - if (attr & 0x2) { - type |= XTENSA_MPU_TYPE_SYS_W; - } - if (attr & 0x4) { - type |= XTENSA_MPU_TYPE_SYS_R; - } - } - if (attr_pattern_match(attr, b, ARRAY_SIZE(b))) { - type |= XTENSA_MPU_TYPE_B; - } - type |= mpu_attr_to_cpu_cache(attr); - - return type; -} - -static unsigned mpu_attr_to_access(uint32_t attr, unsigned ring) -{ - static const unsigned access[2][16] = { - [0] = { - [4] = PAGE_READ, - [5] = PAGE_READ | PAGE_EXEC, - [6] = PAGE_READ | PAGE_WRITE, - [7] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, - [8] = PAGE_WRITE, - [9] = PAGE_READ | PAGE_WRITE, - [10] = PAGE_READ | PAGE_WRITE, - [11] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, - [12] = PAGE_READ, - [13] = PAGE_READ | PAGE_EXEC, - [14] = PAGE_READ | PAGE_WRITE, - [15] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, - }, - [1] = { - [8] = PAGE_WRITE, - [9] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, - [10] = PAGE_READ, - [11] = PAGE_READ | PAGE_EXEC, - [12] = PAGE_READ, - [13] = PAGE_READ | PAGE_EXEC, - [14] = PAGE_READ | PAGE_WRITE, - [15] = PAGE_READ | PAGE_WRITE | PAGE_EXEC, - }, - }; - unsigned rv; - unsigned type; - - type = mpu_attr_to_cpu_cache(attr); - rv = access[ring != 0][(attr & XTENSA_MPU_ACC_RIGHTS_MASK) >> - XTENSA_MPU_ACC_RIGHTS_SHIFT]; - - if (type & XTENSA_MPU_TYPE_CPU_CACHE) { - rv |= (type & XTENSA_MPU_TYPE_CPU_C) ? PAGE_CACHE_WB : PAGE_CACHE_WT; - } else { - rv |= PAGE_CACHE_BYPASS; - } - return rv; -} - -static bool is_access_granted(unsigned access, int is_write) -{ - switch (is_write) { - case 0: - return access & PAGE_READ; - - case 1: - return access & PAGE_WRITE; - - case 2: - return access & PAGE_EXEC; - - default: - return 0; - } -} - -static bool get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte); - -static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb, - uint32_t vaddr, int is_write, int mmu_idx, - uint32_t *paddr, uint32_t *page_size, - unsigned *access, bool may_lookup_pt) -{ - bool dtlb = is_write != 2; - uint32_t wi; - uint32_t ei; - uint8_t ring; - uint32_t vpn; - uint32_t pte; - const xtensa_tlb_entry *entry = NULL; - xtensa_tlb_entry tmp_entry; - int ret = xtensa_tlb_lookup(env, vaddr, dtlb, &wi, &ei, &ring); - - if ((ret == INST_TLB_MISS_CAUSE || ret == LOAD_STORE_TLB_MISS_CAUSE) && - may_lookup_pt && get_pte(env, vaddr, &pte)) { - ring = (pte >> 4) & 0x3; - wi = 0; - xtensa_split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei); - - if (update_tlb) { - wi = ++env->autorefill_idx & 0x3; - xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, pte); - env->sregs[EXCVADDR] = vaddr; - qemu_log_mask(CPU_LOG_MMU, "%s: autorefill(%08x): %08x -> %08x\n", - __func__, vaddr, vpn, pte); - } else { - xtensa_tlb_set_entry_mmu(env, &tmp_entry, dtlb, wi, ei, vpn, pte); - entry = &tmp_entry; - } - ret = 0; - } - if (ret != 0) { - return ret; - } - - if (entry == NULL) { - entry = xtensa_tlb_get_entry(env, dtlb, wi, ei); - } - - if (ring < mmu_idx) { - return dtlb ? - LOAD_STORE_PRIVILEGE_CAUSE : - INST_FETCH_PRIVILEGE_CAUSE; - } - - *access = mmu_attr_to_access(entry->attr) & - ~(dtlb ? PAGE_EXEC : PAGE_READ | PAGE_WRITE); - if (!is_access_granted(*access, is_write)) { - return dtlb ? - (is_write ? - STORE_PROHIBITED_CAUSE : - LOAD_PROHIBITED_CAUSE) : - INST_FETCH_PROHIBITED_CAUSE; - } - - *paddr = entry->paddr | (vaddr & ~xtensa_tlb_get_addr_mask(env, dtlb, wi)); - *page_size = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1; - - return 0; -} - -static bool get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte) -{ - CPUState *cs = env_cpu(env); - uint32_t paddr; - uint32_t page_size; - unsigned access; - uint32_t pt_vaddr = - (env->sregs[PTEVADDR] | (vaddr >> 10)) & 0xfffffffc; - int ret = get_physical_addr_mmu(env, false, pt_vaddr, 0, 0, - &paddr, &page_size, &access, false); - - if (ret == 0) { - qemu_log_mask(CPU_LOG_MMU, - "%s: autorefill(%08x): PTE va = %08x, pa = %08x\n", - __func__, vaddr, pt_vaddr, paddr); - } else { - qemu_log_mask(CPU_LOG_MMU, - "%s: autorefill(%08x): PTE va = %08x, failed (%d)\n", - __func__, vaddr, pt_vaddr, ret); - } - - if (ret == 0) { - MemTxResult result; - - *pte = address_space_ldl(cs->as, paddr, MEMTXATTRS_UNSPECIFIED, - &result); - if (result != MEMTX_OK) { - qemu_log_mask(CPU_LOG_MMU, - "%s: couldn't load PTE: transaction failed (%u)\n", - __func__, (unsigned)result); - ret = 1; - } - } - return ret == 0; -} - -static int get_physical_addr_region(CPUXtensaState *env, - uint32_t vaddr, int is_write, int mmu_idx, - uint32_t *paddr, uint32_t *page_size, - unsigned *access) -{ - bool dtlb = is_write != 2; - uint32_t wi = 0; - uint32_t ei = (vaddr >> 29) & 0x7; - const xtensa_tlb_entry *entry = - xtensa_tlb_get_entry(env, dtlb, wi, ei); - - *access = region_attr_to_access(entry->attr); - if (!is_access_granted(*access, is_write)) { - return dtlb ? - (is_write ? - STORE_PROHIBITED_CAUSE : - LOAD_PROHIBITED_CAUSE) : - INST_FETCH_PROHIBITED_CAUSE; - } - - *paddr = entry->paddr | (vaddr & ~REGION_PAGE_MASK); - *page_size = ~REGION_PAGE_MASK + 1; - - return 0; -} - -static int xtensa_mpu_lookup(const xtensa_mpu_entry *entry, unsigned n, - uint32_t vaddr, unsigned *segment) -{ - unsigned nhits = 0; - unsigned i; - - for (i = 0; i < n; ++i) { - if (vaddr >= entry[i].vaddr && - (i == n - 1 || vaddr < entry[i + 1].vaddr)) { - if (nhits++) { - break; - } - *segment = i; - } - } - return nhits; -} - void HELPER(wsr_mpuenb)(CPUXtensaState *env, uint32_t v) { v &= (2u << (env->config->n_mpu_fg_segments - 1)) - 1; @@ -1013,75 +194,6 @@ uint32_t HELPER(pptlb)(CPUXtensaState *env, uint32_t v) } } -static int get_physical_addr_mpu(CPUXtensaState *env, - uint32_t vaddr, int is_write, int mmu_idx, - uint32_t *paddr, uint32_t *page_size, - unsigned *access) -{ - unsigned nhits; - unsigned segment; - uint32_t attr; - - nhits = xtensa_mpu_lookup(env->mpu_fg, env->config->n_mpu_fg_segments, - vaddr, &segment); - if (nhits > 1) { - return is_write < 2 ? - LOAD_STORE_TLB_MULTI_HIT_CAUSE : - INST_TLB_MULTI_HIT_CAUSE; - } else if (nhits == 1 && (env->sregs[MPUENB] & (1u << segment))) { - attr = env->mpu_fg[segment].attr; - } else { - xtensa_mpu_lookup(env->config->mpu_bg, - env->config->n_mpu_bg_segments, - vaddr, &segment); - attr = env->config->mpu_bg[segment].attr; - } - - *access = mpu_attr_to_access(attr, mmu_idx); - if (!is_access_granted(*access, is_write)) { - return is_write < 2 ? - (is_write ? - STORE_PROHIBITED_CAUSE : - LOAD_PROHIBITED_CAUSE) : - INST_FETCH_PROHIBITED_CAUSE; - } - *paddr = vaddr; - *page_size = env->config->mpu_align; - return 0; -} - -/*! - * Convert virtual address to physical addr. - * MMU may issue pagewalk and change xtensa autorefill TLB way entry. - * - * \return 0 if ok, exception cause code otherwise - */ -int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, - uint32_t vaddr, int is_write, int mmu_idx, - uint32_t *paddr, uint32_t *page_size, - unsigned *access) -{ - if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { - return get_physical_addr_mmu(env, update_tlb, - vaddr, is_write, mmu_idx, paddr, - page_size, access, true); - } else if (xtensa_option_bits_enabled(env->config, - XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | - XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION))) { - return get_physical_addr_region(env, vaddr, is_write, mmu_idx, - paddr, page_size, access); - } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { - return get_physical_addr_mpu(env, vaddr, is_write, mmu_idx, - paddr, page_size, access); - } else { - *paddr = vaddr; - *page_size = TARGET_PAGE_SIZE; - *access = cacheattr_attr_to_access(env->sregs[CACHEATTR] >> - ((vaddr & 0xe0000000) >> 27)); - return 0; - } -} - static void dump_tlb(CPUXtensaState *env, bool dtlb) { unsigned wi, ei; diff --git a/target/xtensa/meson.build b/target/xtensa/meson.build index f8d60101e3..46010c35c4 100644 --- a/target/xtensa/meson.build +++ b/target/xtensa/meson.build @@ -18,6 +18,7 @@ xtensa_ss.add(files( xtensa_system_ss = ss.source_set() xtensa_system_ss.add(files( 'dbg_helper.c', + 'mmu.c', 'mmu_helper.c', 'monitor.c', 'xtensa-semi.c', From patchwork Thu Mar 21 15:48:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781573 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901178wrj; Thu, 21 Mar 2024 08:51:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVvMjvwTqaWSx0lRyCqbs6bcbcLjhppG8U3P7zDt9XYE3Y8fG/I9Z6Dl7D+b3pUh0XpQ9ek0RQCUmEZ4tCSARay X-Google-Smtp-Source: AGHT+IHzkv1nMKBh8PCKD0ZVIgOew5kbj9cUrzJnS293AkacVk/F2kzN50kSFJcCEA9XvWzEGNf/ X-Received: by 2002:a05:6512:54e:b0:513:64d7:afb5 with SMTP id h14-20020a056512054e00b0051364d7afb5mr6242760lfl.57.1711036316379; Thu, 21 Mar 2024 08:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036316; cv=none; d=google.com; s=arc-20160816; b=o/p8RAHKGqyn5kAT3wCt0YGoQDkCTJwgahTFLw+EytVzHYloJL1BrcapOIRR2Cen3+ BB/WBBowCqsdxOT4ZayfkwIo0kWtdyenXX3KLr8rBWlrSDUD7YwAGmuLfaHrJxUjqoUK 5QfqVhR9MxE31q8g5OJvMYSJFBgA2Da6oS51ThRunm9hHX49sYENw797OmxqAKaTy3Hq Fzd9dP7ZXumkegAp+HrYhZpLFB8F/zhF3+x10B6R67AivBGpF77qe0K9ZHUN75pDP6Y7 Wruxf7ztG8rCdlRoRnPyc3Dgfn3yhQL+P09dezei5Q/hAKIVWRoHPTLtX6XLQSyNMAuT Eijg== 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=Ie3mfp1m/rRKvj+8OELX2ynuCGg82V7qLs9kfFYvM/A=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=rw/UEFoX8lSV4k6bDo4iAfIAJWwN/sQu/24wdhXRRWXa9W8r0HIj7TojSdhCK7vCNJ BiFnTA6iDtiNbgkiN88+KiMNI25p+Bz0eaBopAxqbBMv0IbvnMe2vKnHe+oFJT6ICW2k s748cetRzqyPCe5xy72mKHIG3e4VYIVERnBD2uksrm2tM4FbAjGpgTXbdERhSL2Wuqw7 bdoirBbotO/cTmuUEgVWQO+QtFJI7ShXgYDzfMf7iDFp+6lth6D3r4mjpC/WJ2cDyjAR 0PLWBOIPo1+lHQjVMJ0Ulxx+LkoaUVYiJUKh2rWRuaW2D5UCRSge1C0l7Cp9Q6I7EuIm LPqQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x2r+5suX; 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 b8-20020a05600c4a8800b0041440a806bfsi2389170wmp.92.2024.03.21.08.51.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:51:56 -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=x2r+5suX; 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 1rnKhp-0002N6-2b; Thu, 21 Mar 2024 11:51:49 -0400 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 1rnKhW-0001cp-MV for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:51:31 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKhO-0002DG-Ir for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:51:27 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a471f86dcd3so27479766b.2 for ; Thu, 21 Mar 2024 08:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036264; x=1711641064; darn=nongnu.org; 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=Ie3mfp1m/rRKvj+8OELX2ynuCGg82V7qLs9kfFYvM/A=; b=x2r+5suXYj2OJFynwLooTTT/G1/nFqtcu6I19wZwOk6fJjz9M8vEXYlv+fbrMK4jG6 QjudyUBsGu+u8Ycfu4qiAPOB5yL4ndbkg/zj8S3YZ9pVW/WeEFcIJxV2fbqqyCdbo1QO ojOKKvSX/a24RoTMiGY43EDNSynqPsdoJhRB5kuHsXLBb3r04q+HFmuB+P8JuAd/dgqe w5d00MmZW/kA0T2gmuAWU7XOTKXHux2GDkm1JjGyShFTAwv/W42+5S+o6cpUT9AtTg/P rtgdfQyIcnBUKXXFbLBCzB01pNbrx/bJmblJgCPYxTKJ1q7/5eOO3c7EcijqRKJa9Wo7 XztA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036264; x=1711641064; 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=Ie3mfp1m/rRKvj+8OELX2ynuCGg82V7qLs9kfFYvM/A=; b=oEQxE7OwCeJCb6OfE7IlEIB+AxeFyeQUpkQwP7y1vBtORM7n/G+Uw8M5ThtWNLBzN2 jG3PgDQ8qsTYg4KLwWBCi8bxqCrXt77KJKg34xfqXMAhvTnjAPrwXMQLLvN74L2GLBl1 dOvFgxX6uElkrpnN5vT+evYUF9x0nw+vIS6+IPkOuTq7LTZUGsDu+2O11BXLidaTlASn uJcPvS1UbeZxe9Aj3mVHlYQ1LRTSERJ8+3n4KrQgpZctw8bWwEc9diuzW5D2fvxTrgeB qvyJvfBwOZ6xmC7u0Bfp0n5Kc4kyPMp0OPCAVmZmTx5GPt29J9IVgcVAEK178ZocfKNe eZSw== X-Gm-Message-State: AOJu0Yzhxjgqqz8D82AuvklJh7b6CbkThzGOarX/KG5gv7p7dcT2i0K4 sVx+jztk/OVZstlDaYVswe5MQVWQV9PMyWtKurH3LHxxbjo1JGYiIHoRjV44So1ZAzZbgkohUok hhPE= X-Received: by 2002:a17:906:119b:b0:a46:d776:645a with SMTP id n27-20020a170906119b00b00a46d776645amr6338524eja.52.1711036263951; Thu, 21 Mar 2024 08:51:03 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id c5-20020a170906694500b00a4131367204sm55036ejs.80.2024.03.21.08.51.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:51:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 19/21] target/xtensa: Simplify dump_mpu() and dump_tlb() Date: Thu, 21 Mar 2024 16:48:35 +0100 Message-ID: <20240321154838.95771-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=philmd@linaro.org; helo=mail-ej1-x634.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=unavailable 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 Remove few qemu_printf() calls in xtensa_dump_mmu() by slightly reworking dump_mpu() and dump_tlb(). Signed-off-by: Philippe Mathieu-Daudé --- target/xtensa/mmu_helper.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index 8be8d79dcd..3b4f53feb0 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -203,6 +203,7 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb) xtensa_option_enabled(env->config, XTENSA_OPTION_MMU) ? mmu_attr_to_access : region_attr_to_access; + qemu_printf("%s:\n", dtlb ? "DTLB" : "IBLB"); for (wi = 0; wi < conf->nways; ++wi) { uint32_t sz = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1; const char *sz_text; @@ -252,11 +253,12 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb) } } -static void dump_mpu(CPUXtensaState *env, +static void dump_mpu(CPUXtensaState *env, const char *map_desc, const xtensa_mpu_entry *entry, unsigned n) { unsigned i; + qemu_printf("%s map:\n", map_desc); qemu_printf("\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n" "\t%s ---------- ---------- ----- ----- ------------- ---------\n", env ? "En" : " ", @@ -316,15 +318,15 @@ void xtensa_dump_mmu(CPUXtensaState *env) XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION) | XTENSA_OPTION_BIT(XTENSA_OPTION_MMU))) { - qemu_printf("ITLB:\n"); dump_tlb(env, false); - qemu_printf("\nDTLB:\n"); + qemu_printf("\n"); dump_tlb(env, true); } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { - qemu_printf("Foreground map:\n"); - dump_mpu(env, env->mpu_fg, env->config->n_mpu_fg_segments); - qemu_printf("\nBackground map:\n"); - dump_mpu(NULL, env->config->mpu_bg, env->config->n_mpu_bg_segments); + dump_mpu(env, "Foreground", + env->mpu_fg, env->config->n_mpu_fg_segments); + qemu_printf("\n"); + dump_mpu(NULL, "Background", + env->config->mpu_bg, env->config->n_mpu_bg_segments); } else { qemu_printf("No TLB for this CPU core\n"); } From patchwork Thu Mar 21 15:48:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781579 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901770wrj; Thu, 21 Mar 2024 08:53:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXhsbi9GW7xQD5WapJE04FWsh9f+OGhGxYDtg3Y/2d4bvh5kBP29xFNf5+tfrr+yyy7/Ey6R+8tJfhGieZ4290i X-Google-Smtp-Source: AGHT+IEeBXRfNTjZAcPT6F5RRFOe+uNowcKpvqsAiPqWDDmzDkloxOiyyrmajCbosRQrFJAlToyE X-Received: by 2002:adf:ed49:0:b0:33d:2180:30e8 with SMTP id u9-20020adfed49000000b0033d218030e8mr2537701wro.25.1711036388400; Thu, 21 Mar 2024 08:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036388; cv=none; d=google.com; s=arc-20160816; b=OEX363ZNIVr8KXTueTpTXgMl4k6eYt+fY6OeXgxr8aya1HkDt/sK/J2IWjgpdd7YXk 7/0YaS7dPKR95NtqTlKVVl1A+HHFgjSdQOzg7DmL2PQue6v7nTRLcUeOvpOI/lsnZvLH hMikC5D1q1VKdddGjkSTKnCDdP3PmVgzsJ7sGUvpJ9G5B/aA+MA3I7hPg2EneDlfxCDi Inwu31Hfd4tE0+pi+q2Rw61do0zfgdNquxjvkQlbUGvxXFs6K5YsiuGE6rOJGmKF8c93 4nKK+1fSo4TnJLIVH+Dgr0wljHxMrX12n+56CFhwzo/nIwGRymxBOxna7U3Zx1RuC/DX 2uFg== 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=8h5t/FA85YtkYkt5jLzh3FCMifcHYByW2n7FfuuxlSE=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=IcAHv1qEK8O9K4GNZ+eLChFbMbQKgxAE8pAmp+oQCVMEAyzzZBZ06bMbafarRXSyFK 7kBKl8n70cjPLeT1Od6XbS2xcmUgywweXSG/aWWLnHPjEnpxZl6A4O7LiZTUcppWJmDd hBXHNwr27dzo1plStQ14AFBnEYfiUU0UlstuLPMqOcCdj9Oxp6ckObWd5mXW2p8cEB/N Ii86KslOJuK4kPzasjDYXyZRoDzTbVqMWvDzBnqbWT60LIL8Oc1yHF40MU2vy5AAhwz6 290i7zn2rmYtKed9KVulGnSXDtuszELrkwIhqf1/1mjNq4zzX6pM+hjlo+2rNKyffyYA f9EQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NNYMF4P7; 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 b6-20020a5d4d86000000b0033e7e36160fsi8498447wru.477.2024.03.21.08.53.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:53:08 -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=NNYMF4P7; 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 1rnKhz-00037x-FX; Thu, 21 Mar 2024 11:51:59 -0400 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 1rnKhS-0001Yy-UM for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:51:28 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKhM-0002Eh-2A for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:51:23 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d28051376eso23474901fa.0 for ; Thu, 21 Mar 2024 08:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036271; x=1711641071; darn=nongnu.org; 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=8h5t/FA85YtkYkt5jLzh3FCMifcHYByW2n7FfuuxlSE=; b=NNYMF4P7+0rvbRQgPuHTkgYYjjr3wzT8Pwm5/SX0I5LzCQUzHnvQRSelseRfjOM9rR YZy2egRi6XFPab6IxMJ+G+SuFdRX650D42N+VpwXspDOZ5EaPi7slK9K7AMjaivNyANd Ut1y+Oy4NpXutPUUh8S3Zm03LBUGEHUXk54l3p3eIb3nk1cywN4QTYStAhtCip0mFxfi Qm9FAIUD7kwDZMfZ5ejDLVWhG57ryZBOeFNV0g9ZLZEjn2X+lJO1D6NOIvltQz0MUlNy 6I0QS8nNKR3FEAUZWy2YGQDpyqAo5IyJcGtGOHdlzRtG46/ExozC6CEN5aMbKvVjvtoa aEQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036271; x=1711641071; 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=8h5t/FA85YtkYkt5jLzh3FCMifcHYByW2n7FfuuxlSE=; b=TA9baR6rnEgrR/uegMHNecd/Zf5rleyiIklaKFK4OVOvmTJf3mfA6h/3m2RuBz/g3u JLwX0NAkc5HkHCT844BT48LU4kdLnh095pLoyHxz5n80bqbPKDiqQqV0CWwnqgA30+oM BdX+926TpFCbFeNEae+WabxjRhaFZMgmWJAeDK/QMXwEBhez7NpjdEhapJCHVXa5J0Md ZzRB9mEMtfEmYLYF0JD0TB4qAZKcjvhKGXoNz5XwXAoeLuIilZPxc5WzLExTUflL/2W5 gf9HTbFR2MapviPeFHjhOmGhUoZ4nNyr7HSTr4JEt3omEO2HtZ8iaE6xmhlkUreQpBMC lPzg== X-Gm-Message-State: AOJu0YzrvYpWjkjT/YmYgt3fvK34YkROPgirKXV13uE/OQ69zhkrfoE9 083TuL43oxFs97teh8yq5kIWQ/G3QNjyyR7Skunw+1M386/g02AM+DtTpVau3TuhO5GDhcYbl0K ggKw= X-Received: by 2002:a05:651c:87:b0:2d4:714b:4c5d with SMTP id 7-20020a05651c008700b002d4714b4c5dmr2030881ljq.44.1711036270926; Thu, 21 Mar 2024 08:51:10 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id e7-20020a170906314700b00a46e3669dd3sm48752eje.128.2024.03.21.08.51.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:51:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 20/21] target/xtensa: Move monitor commands to monitor.c Date: Thu, 21 Mar 2024 16:48:36 +0100 Message-ID: <20240321154838.95771-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=philmd@linaro.org; helo=mail-lj1-x234.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 Signed-off-by: Philippe Mathieu-Daudé --- target/xtensa/mmu_helper.c | 140 ------------------------------------ target/xtensa/monitor.c | 144 ++++++++++++++++++++++++++++++++++++- 2 files changed, 143 insertions(+), 141 deletions(-) diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index 3b4f53feb0..892730f0f0 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -26,8 +26,6 @@ */ #include "qemu/osdep.h" -#include "qemu/qemu-print.h" -#include "qemu/units.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "cpu.h" @@ -193,141 +191,3 @@ uint32_t HELPER(pptlb)(CPUXtensaState *env, uint32_t v) return env->config->mpu_bg[bg_segment].attr | segment; } } - -static void dump_tlb(CPUXtensaState *env, bool dtlb) -{ - unsigned wi, ei; - const xtensa_tlb *conf = - dtlb ? &env->config->dtlb : &env->config->itlb; - unsigned (*attr_to_access)(uint32_t) = - xtensa_option_enabled(env->config, XTENSA_OPTION_MMU) ? - mmu_attr_to_access : region_attr_to_access; - - qemu_printf("%s:\n", dtlb ? "DTLB" : "IBLB"); - for (wi = 0; wi < conf->nways; ++wi) { - uint32_t sz = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1; - const char *sz_text; - bool print_header = true; - - if (sz >= 0x100000) { - sz /= MiB; - sz_text = "MB"; - } else { - sz /= KiB; - sz_text = "KB"; - } - - for (ei = 0; ei < conf->way_size[wi]; ++ei) { - const xtensa_tlb_entry *entry = - xtensa_tlb_get_entry(env, dtlb, wi, ei); - - if (entry->asid) { - static const char * const cache_text[8] = { - [PAGE_CACHE_BYPASS >> PAGE_CACHE_SHIFT] = "Bypass", - [PAGE_CACHE_WT >> PAGE_CACHE_SHIFT] = "WT", - [PAGE_CACHE_WB >> PAGE_CACHE_SHIFT] = "WB", - [PAGE_CACHE_ISOLATE >> PAGE_CACHE_SHIFT] = "Isolate", - }; - unsigned access = attr_to_access(entry->attr); - unsigned cache_idx = (access & PAGE_CACHE_MASK) >> - PAGE_CACHE_SHIFT; - - if (print_header) { - print_header = false; - qemu_printf("Way %u (%d %s)\n", wi, sz, sz_text); - qemu_printf("\tVaddr Paddr ASID Attr RWX Cache\n" - "\t---------- ---------- ---- ---- --- -------\n"); - } - qemu_printf("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %s\n", - entry->vaddr, - entry->paddr, - entry->asid, - entry->attr, - (access & PAGE_READ) ? 'R' : '-', - (access & PAGE_WRITE) ? 'W' : '-', - (access & PAGE_EXEC) ? 'X' : '-', - cache_text[cache_idx] ? - cache_text[cache_idx] : "Invalid"); - } - } - } -} - -static void dump_mpu(CPUXtensaState *env, const char *map_desc, - const xtensa_mpu_entry *entry, unsigned n) -{ - unsigned i; - - qemu_printf("%s map:\n", map_desc); - qemu_printf("\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n" - "\t%s ---------- ---------- ----- ----- ------------- ---------\n", - env ? "En" : " ", - env ? "--" : " "); - - for (i = 0; i < n; ++i) { - uint32_t attr = entry[i].attr; - unsigned access0 = mpu_attr_to_access(attr, 0); - unsigned access1 = mpu_attr_to_access(attr, 1); - unsigned type = mpu_attr_to_type(attr); - char cpu_cache = (type & XTENSA_MPU_TYPE_CPU_CACHE) ? '-' : ' '; - - qemu_printf("\t %c 0x%08x 0x%08x %c%c%c %c%c%c ", - env ? - ((env->sregs[MPUENB] & (1u << i)) ? '+' : '-') : ' ', - entry[i].vaddr, attr, - (access0 & PAGE_READ) ? 'R' : '-', - (access0 & PAGE_WRITE) ? 'W' : '-', - (access0 & PAGE_EXEC) ? 'X' : '-', - (access1 & PAGE_READ) ? 'R' : '-', - (access1 & PAGE_WRITE) ? 'W' : '-', - (access1 & PAGE_EXEC) ? 'X' : '-'); - - switch (type & XTENSA_MPU_SYSTEM_TYPE_MASK) { - case XTENSA_MPU_SYSTEM_TYPE_DEVICE: - qemu_printf("Device %cB %3s\n", - (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', - (type & XTENSA_MPU_TYPE_INT) ? "int" : ""); - break; - case XTENSA_MPU_SYSTEM_TYPE_NC: - qemu_printf("Sys NC %cB %c%c%c\n", - (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', - (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); - break; - case XTENSA_MPU_SYSTEM_TYPE_C: - qemu_printf("Sys C %c%c%c %c%c%c\n", - (type & XTENSA_MPU_TYPE_SYS_R) ? 'R' : '-', - (type & XTENSA_MPU_TYPE_SYS_W) ? 'W' : '-', - (type & XTENSA_MPU_TYPE_SYS_C) ? 'C' : '-', - (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); - break; - default: - qemu_printf("Unknown\n"); - break; - } - } -} - -void xtensa_dump_mmu(CPUXtensaState *env) -{ - if (xtensa_option_bits_enabled(env->config, - XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | - XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION) | - XTENSA_OPTION_BIT(XTENSA_OPTION_MMU))) { - - dump_tlb(env, false); - qemu_printf("\n"); - dump_tlb(env, true); - } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { - dump_mpu(env, "Foreground", - env->mpu_fg, env->config->n_mpu_fg_segments); - qemu_printf("\n"); - dump_mpu(NULL, "Background", - env->config->mpu_bg, env->config->n_mpu_bg_segments); - } else { - qemu_printf("No TLB for this CPU core\n"); - } -} diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c index ce1b791a5c..9ba068d624 100644 --- a/target/xtensa/monitor.c +++ b/target/xtensa/monitor.c @@ -22,10 +22,152 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "cpu.h" +#include "qemu/qemu-print.h" +#include "qemu/units.h" #include "monitor/monitor.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" +#include "cpu.h" +#include "mmu.h" + + +static void dump_tlb(CPUXtensaState *env, bool dtlb) +{ + unsigned wi, ei; + const xtensa_tlb *conf = + dtlb ? &env->config->dtlb : &env->config->itlb; + unsigned (*attr_to_access)(uint32_t) = + xtensa_option_enabled(env->config, XTENSA_OPTION_MMU) ? + mmu_attr_to_access : region_attr_to_access; + + qemu_printf("%s:\n", dtlb ? "DTLB" : "IBLB"); + for (wi = 0; wi < conf->nways; ++wi) { + uint32_t sz = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1; + const char *sz_text; + bool print_header = true; + + if (sz >= 0x100000) { + sz /= MiB; + sz_text = "MB"; + } else { + sz /= KiB; + sz_text = "KB"; + } + + for (ei = 0; ei < conf->way_size[wi]; ++ei) { + const xtensa_tlb_entry *entry = + xtensa_tlb_get_entry(env, dtlb, wi, ei); + + if (entry->asid) { + static const char * const cache_text[8] = { + [PAGE_CACHE_BYPASS >> PAGE_CACHE_SHIFT] = "Bypass", + [PAGE_CACHE_WT >> PAGE_CACHE_SHIFT] = "WT", + [PAGE_CACHE_WB >> PAGE_CACHE_SHIFT] = "WB", + [PAGE_CACHE_ISOLATE >> PAGE_CACHE_SHIFT] = "Isolate", + }; + unsigned access = attr_to_access(entry->attr); + unsigned cache_idx = (access & PAGE_CACHE_MASK) >> + PAGE_CACHE_SHIFT; + + if (print_header) { + print_header = false; + qemu_printf("Way %u (%d %s)\n", wi, sz, sz_text); + qemu_printf("\tVaddr Paddr ASID Attr RWX Cache\n" + "\t---------- ---------- ---- ---- --- -------\n"); + } + qemu_printf("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %s\n", + entry->vaddr, + entry->paddr, + entry->asid, + entry->attr, + (access & PAGE_READ) ? 'R' : '-', + (access & PAGE_WRITE) ? 'W' : '-', + (access & PAGE_EXEC) ? 'X' : '-', + cache_text[cache_idx] ? + cache_text[cache_idx] : "Invalid"); + } + } + } +} + +static void dump_mpu(CPUXtensaState *env, const char *map_desc, + const xtensa_mpu_entry *entry, unsigned n) +{ + unsigned i; + + qemu_printf("%s map:\n", map_desc); + qemu_printf("\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n" + "\t%s ---------- ---------- ----- ----- ------------- ---------\n", + env ? "En" : " ", + env ? "--" : " "); + + for (i = 0; i < n; ++i) { + uint32_t attr = entry[i].attr; + unsigned access0 = mpu_attr_to_access(attr, 0); + unsigned access1 = mpu_attr_to_access(attr, 1); + unsigned type = mpu_attr_to_type(attr); + char cpu_cache = (type & XTENSA_MPU_TYPE_CPU_CACHE) ? '-' : ' '; + + qemu_printf("\t %c 0x%08x 0x%08x %c%c%c %c%c%c ", + env ? + ((env->sregs[MPUENB] & (1u << i)) ? '+' : '-') : ' ', + entry[i].vaddr, attr, + (access0 & PAGE_READ) ? 'R' : '-', + (access0 & PAGE_WRITE) ? 'W' : '-', + (access0 & PAGE_EXEC) ? 'X' : '-', + (access1 & PAGE_READ) ? 'R' : '-', + (access1 & PAGE_WRITE) ? 'W' : '-', + (access1 & PAGE_EXEC) ? 'X' : '-'); + + switch (type & XTENSA_MPU_SYSTEM_TYPE_MASK) { + case XTENSA_MPU_SYSTEM_TYPE_DEVICE: + qemu_printf("Device %cB %3s\n", + (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', + (type & XTENSA_MPU_TYPE_INT) ? "int" : ""); + break; + case XTENSA_MPU_SYSTEM_TYPE_NC: + qemu_printf("Sys NC %cB %c%c%c\n", + (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', + (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); + break; + case XTENSA_MPU_SYSTEM_TYPE_C: + qemu_printf("Sys C %c%c%c %c%c%c\n", + (type & XTENSA_MPU_TYPE_SYS_R) ? 'R' : '-', + (type & XTENSA_MPU_TYPE_SYS_W) ? 'W' : '-', + (type & XTENSA_MPU_TYPE_SYS_C) ? 'C' : '-', + (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); + break; + default: + qemu_printf("Unknown\n"); + break; + } + } +} + +void xtensa_dump_mmu(CPUXtensaState *env) +{ + if (xtensa_option_bits_enabled(env->config, + XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | + XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION) | + XTENSA_OPTION_BIT(XTENSA_OPTION_MMU))) { + + dump_tlb(env, false); + qemu_printf("\n"); + dump_tlb(env, true); + } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { + dump_mpu(env, "Foreground", + env->mpu_fg, env->config->n_mpu_fg_segments); + qemu_printf("\n"); + dump_mpu(NULL, "Background", + env->config->mpu_bg, env->config->n_mpu_bg_segments); + } else { + qemu_printf("No TLB for this CPU core\n"); + } +} void hmp_info_tlb(Monitor *mon, const QDict *qdict) { From patchwork Thu Mar 21 15:48:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 781581 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp901963wrj; Thu, 21 Mar 2024 08:53:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV23u8mpd7ikh0dO/Bc7xIZ796MVrJzVEb70gQgGxqM2F4gnMZAgAwJV0b0GJEU25mu/o+0Rfu/HrPUiKMZH9zi X-Google-Smtp-Source: AGHT+IGTMFsY4h3GQM+iWKizWQpkZpjufgrSU2YApzW6CpBFuANMjCTPpjfSgENp13X6wsORkcOs X-Received: by 2002:a5d:6890:0:b0:33c:ec8f:7b51 with SMTP id h16-20020a5d6890000000b0033cec8f7b51mr15693353wru.16.1711036413202; Thu, 21 Mar 2024 08:53:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711036413; cv=none; d=google.com; s=arc-20160816; b=vIYeiF55NiaMLkJW7seIdShamyBmmnOPjJlOhLFA9Z/I6RuZbOP1X/aNvMqoUlKhY9 9/L9BnMxsLRlSm1/jkpFuemBtU3nxex6xysy1yh4/fKAaWXNRaRFeznX3G+tMpGajm8d yGtSo+hgXC3Z46+KRFprYDmk9IyEeysgGaMXAFkCtBbBqzf6yld8kdjlud0m0dcAwfZ6 03/er/uEMZvDQY+PcV7oJAQGasXZwbeQ0zazhUkKIgsK8ytploAsPxHavB47INbsFFBR d26jlCYaTvJVktmy/pRWabmCU2JXG0eW3hdraD8tQC5aMSudfmzF7nGLTmeJ+lLsyxR8 QWug== 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=rEjVeypd0HsLhHx5I6xlQvUNDrlh1OFz+E3SoDVtuhE=; fh=T6rKnw5qbXdIf08MbaczezOCfCSVJgQaY05KIUhs/sE=; b=fuDIPSXTSi/JVa1fvxWjZ2AuQ0dmreg6dwf4HQm+z1lOapXWu4A0V50QFLxHuMAows eCs4Xj00FmERyd4gOBDY/v2s1NRivsuxl+5vOaVYoaTA//myHCzvRxL6SO0REwT7EZRU H+cCpT7vjpmZvXZh9UZAgv4ddfV3qe+pMMnlahvICVvPCb9YS0mqtYVIGpVnDae10ABK 2g0Y8qJz5cb224Ft1+ZXmKa6EhF4ym6fcnfGk0ggXs1tjninLlm4bUzqqt28WK9DDZH7 0g9XvHtb/UXaE3DY+qzGV2u0YcFNjh12ettaF8x2ZAu13E33h6I+u6tfcCfEkpOqBrhw WOzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NmZkXEnc; 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 dy5-20020a0560000e4500b0033ecb0625f0si8512993wrb.329.2024.03.21.08.53.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2024 08:53:33 -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=NmZkXEnc; 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 1rnKi0-0003Ln-EH; Thu, 21 Mar 2024 11:52:00 -0400 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 1rnKhX-0001ep-Vf for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:51:32 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKhT-0002GQ-LJ for qemu-devel@nongnu.org; Thu, 21 Mar 2024 11:51:30 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a468226e135so139422066b.0 for ; Thu, 21 Mar 2024 08:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036278; x=1711641078; darn=nongnu.org; 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=rEjVeypd0HsLhHx5I6xlQvUNDrlh1OFz+E3SoDVtuhE=; b=NmZkXEncfPpTqDjB2tOcVtpg183Dh5+IAGmXqzPJg1fXEqkzsEc19g/aJFF36sx1lR nJny4steUB+wcYfYpsxsVLDqvIyj1aOVKyOZpjR0YsrTiOE4qWG6i8iaxSJsomEPxeO+ 12ogRM9UEmFn5VhhqaSBIpbIy5W/dBd1xWVQmGCZj9EbafNU23k5LBVFgmH46J56+FD2 dbcRueyceq82Zgv0XwEV+wjZuO8yXSgVlhLwMCs3xEu5jHw5CyGOabHZDTWPFhdrsrd5 +u1UhjghO3fzs4uw4lgoq/iNSd2WiOdosL6ofMGb+crq39iDnSBtgOLX+JljMT9VL39p JWJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036278; x=1711641078; 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=rEjVeypd0HsLhHx5I6xlQvUNDrlh1OFz+E3SoDVtuhE=; b=IvnyXmHpFoHrCgfPeftfVAZRkh8cgpmdUsIfJjNBt+P3LEQeMd2+O3iV8g86i5Qg/W 9qk/tcrXz0jzwOjMqEHnuy5x0fK85zaeZ7Z16uSx7ISvGjre6/Zphq6SC7pISrbrjctq sUC4SMKFWOWG0qozvbyLj1QrQbD3VCTcjBHl9fVnEiRCyWbVDSkBR53VkYyGkOyLNQIN of5N4nFyexlzDILeepBOrqKv3roW1HzV9QHEcPO8m42JKTxPCcaevmfiAYVLd/yJ//Q8 2PLtA1yme+ynmheBqIVflmEeHKgAoc5yD2CAGLiV7Jnl5SvWDptFDTDW+RFwhF14nsCZ 6YNw== X-Gm-Message-State: AOJu0Yx5ARsJCGrKqk8dcEo+0GD/1Xgg7LXKjJTvYAQeLu8Cv2+8h4WI H4cvRepCHAJw5iHPnvuA6WmZ+7/Oi+USzdmksRDvvRiWYpMT7GVdlGK7v0nfFSyXRey81za9zPZ drYY= X-Received: by 2002:a17:906:2dd1:b0:a46:ddba:56ee with SMTP id h17-20020a1709062dd100b00a46ddba56eemr6252093eji.4.1711036277914; Thu, 21 Mar 2024 08:51:17 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id la8-20020a170906ad8800b00a46e92e583bsm48071ejb.149.2024.03.21.08.51.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:51:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 21/21] target/xtensa: Replace qemu_printf() by monitor_printf() in monitor Date: Thu, 21 Mar 2024 16:48:37 +0100 Message-ID: <20240321154838.95771-22-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=philmd@linaro.org; helo=mail-ej1-x635.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=unavailable 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 Replace qemu_printf() by monitor_printf() / monitor_puts() in monitor. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster --- target/xtensa/mmu.h | 2 +- target/xtensa/monitor.c | 117 ++++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 58 deletions(-) diff --git a/target/xtensa/mmu.h b/target/xtensa/mmu.h index 3e1d2c03ea..ef7504e16e 100644 --- a/target/xtensa/mmu.h +++ b/target/xtensa/mmu.h @@ -90,6 +90,6 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, unsigned *access); void xtensa_reset_mmu(CPUXtensaState *env); -void xtensa_dump_mmu(CPUXtensaState *env); +void xtensa_dump_mmu(Monitor *mon, CPUXtensaState *env); #endif diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c index 9ba068d624..1c3dc85ea1 100644 --- a/target/xtensa/monitor.c +++ b/target/xtensa/monitor.c @@ -22,7 +22,6 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "qemu/qemu-print.h" #include "qemu/units.h" #include "monitor/monitor.h" #include "monitor/hmp-target.h" @@ -31,7 +30,7 @@ #include "mmu.h" -static void dump_tlb(CPUXtensaState *env, bool dtlb) +static void dump_tlb(Monitor *mon, CPUXtensaState *env, bool dtlb) { unsigned wi, ei; const xtensa_tlb *conf = @@ -40,7 +39,7 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb) xtensa_option_enabled(env->config, XTENSA_OPTION_MMU) ? mmu_attr_to_access : region_attr_to_access; - qemu_printf("%s:\n", dtlb ? "DTLB" : "IBLB"); + monitor_puts(mon, dtlb ? "DTLB\n" : "IBLB\n"); for (wi = 0; wi < conf->nways; ++wi) { uint32_t sz = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1; const char *sz_text; @@ -71,35 +70,39 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb) if (print_header) { print_header = false; - qemu_printf("Way %u (%d %s)\n", wi, sz, sz_text); - qemu_printf("\tVaddr Paddr ASID Attr RWX Cache\n" - "\t---------- ---------- ---- ---- --- -------\n"); + monitor_printf(mon, + "Way %u (%d %s)\n", wi, sz, sz_text); + monitor_puts(mon, + "\tVaddr Paddr ASID Attr RWX Cache\n" + "\t---------- ---------- ---- ---- --- -------\n"); } - qemu_printf("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %s\n", - entry->vaddr, - entry->paddr, - entry->asid, - entry->attr, - (access & PAGE_READ) ? 'R' : '-', - (access & PAGE_WRITE) ? 'W' : '-', - (access & PAGE_EXEC) ? 'X' : '-', - cache_text[cache_idx] ? - cache_text[cache_idx] : "Invalid"); + monitor_printf(mon, + "\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %s\n", + entry->vaddr, + entry->paddr, + entry->asid, + entry->attr, + (access & PAGE_READ) ? 'R' : '-', + (access & PAGE_WRITE) ? 'W' : '-', + (access & PAGE_EXEC) ? 'X' : '-', + cache_text[cache_idx] ? + cache_text[cache_idx] : "Invalid"); } } } } -static void dump_mpu(CPUXtensaState *env, const char *map_desc, +static void dump_mpu(Monitor *mon, CPUXtensaState *env, const char *map_desc, const xtensa_mpu_entry *entry, unsigned n) { unsigned i; - qemu_printf("%s map:\n", map_desc); - qemu_printf("\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n" - "\t%s ---------- ---------- ----- ----- ------------- ---------\n", - env ? "En" : " ", - env ? "--" : " "); + monitor_printf(mon, "%s map:\n", map_desc); + monitor_printf(mon, + "\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n" + "\t%s ---------- ---------- ----- ----- ------------- ---------\n", + env ? "En" : " ", + env ? "--" : " "); for (i = 0; i < n; ++i) { uint32_t attr = entry[i].attr; @@ -108,64 +111,64 @@ static void dump_mpu(CPUXtensaState *env, const char *map_desc, unsigned type = mpu_attr_to_type(attr); char cpu_cache = (type & XTENSA_MPU_TYPE_CPU_CACHE) ? '-' : ' '; - qemu_printf("\t %c 0x%08x 0x%08x %c%c%c %c%c%c ", - env ? - ((env->sregs[MPUENB] & (1u << i)) ? '+' : '-') : ' ', - entry[i].vaddr, attr, - (access0 & PAGE_READ) ? 'R' : '-', - (access0 & PAGE_WRITE) ? 'W' : '-', - (access0 & PAGE_EXEC) ? 'X' : '-', - (access1 & PAGE_READ) ? 'R' : '-', - (access1 & PAGE_WRITE) ? 'W' : '-', - (access1 & PAGE_EXEC) ? 'X' : '-'); + monitor_printf(mon, "\t %c 0x%08x 0x%08x %c%c%c %c%c%c ", + env ? + ((env->sregs[MPUENB] & (1u << i)) ? '+' : '-') : ' ', + entry[i].vaddr, attr, + (access0 & PAGE_READ) ? 'R' : '-', + (access0 & PAGE_WRITE) ? 'W' : '-', + (access0 & PAGE_EXEC) ? 'X' : '-', + (access1 & PAGE_READ) ? 'R' : '-', + (access1 & PAGE_WRITE) ? 'W' : '-', + (access1 & PAGE_EXEC) ? 'X' : '-'); switch (type & XTENSA_MPU_SYSTEM_TYPE_MASK) { case XTENSA_MPU_SYSTEM_TYPE_DEVICE: - qemu_printf("Device %cB %3s\n", - (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', - (type & XTENSA_MPU_TYPE_INT) ? "int" : ""); + monitor_printf(mon, "Device %cB %3s\n", + (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', + (type & XTENSA_MPU_TYPE_INT) ? "int" : ""); break; case XTENSA_MPU_SYSTEM_TYPE_NC: - qemu_printf("Sys NC %cB %c%c%c\n", - (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', - (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); + monitor_printf(mon, "Sys NC %cB %c%c%c\n", + (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', + (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); break; case XTENSA_MPU_SYSTEM_TYPE_C: - qemu_printf("Sys C %c%c%c %c%c%c\n", - (type & XTENSA_MPU_TYPE_SYS_R) ? 'R' : '-', - (type & XTENSA_MPU_TYPE_SYS_W) ? 'W' : '-', - (type & XTENSA_MPU_TYPE_SYS_C) ? 'C' : '-', - (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); + monitor_printf(mon, "Sys C %c%c%c %c%c%c\n", + (type & XTENSA_MPU_TYPE_SYS_R) ? 'R' : '-', + (type & XTENSA_MPU_TYPE_SYS_W) ? 'W' : '-', + (type & XTENSA_MPU_TYPE_SYS_C) ? 'C' : '-', + (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); break; default: - qemu_printf("Unknown\n"); + monitor_puts(mon, "Unknown\n"); break; } } } -void xtensa_dump_mmu(CPUXtensaState *env) +void xtensa_dump_mmu(Monitor *mon, CPUXtensaState *env) { if (xtensa_option_bits_enabled(env->config, XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION) | XTENSA_OPTION_BIT(XTENSA_OPTION_MMU))) { - dump_tlb(env, false); - qemu_printf("\n"); - dump_tlb(env, true); + dump_tlb(mon, env, false); + monitor_puts(mon, "\n"); + dump_tlb(mon, env, true); } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { - dump_mpu(env, "Foreground", + dump_mpu(mon, env, "Foreground", env->mpu_fg, env->config->n_mpu_fg_segments); - qemu_printf("\n"); - dump_mpu(NULL, "Background", + monitor_puts(mon, "\n"); + dump_mpu(mon, NULL, "Background", env->config->mpu_bg, env->config->n_mpu_bg_segments); } else { - qemu_printf("No TLB for this CPU core\n"); + monitor_puts(mon, "No TLB for this CPU core\n"); } } @@ -177,5 +180,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) monitor_printf(mon, "No CPU available\n"); return; } - xtensa_dump_mmu(env1); + xtensa_dump_mmu(mon, env1); }