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: 1914480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=d2jICh1d; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qdm3G4Lz1yWy for ; Fri, 22 Mar 2024 02:49:32 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKfI-0004Zm-5d; Thu, 21 Mar 2024 11:49:13 -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 1rnKfC-0004OB-19 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:06 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKey-0001BQ-Bt for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:05 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-41477e77151so1798485e9.2 for ; Thu, 21 Mar 2024 08:48:51 -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=ADojCyKUfvCyfL0EVSGeOo5varVe7cuha3I4/ViWRxi7iEDRsyrj9kodL8n10eiuw9 w7D3O7JltDm7zaN7SqoKj8X6CeRhp2SmDw5VbL/X6JFZR3ayRv3zT0aqXEilyi2d6zR3 628Mw9sGk9WEEJHApxKxdbWTOL3j4wbATSMam5rvKqIZBtGJK4g8t39EP3Kd7mVVLnPD X9MG0pW9LqMl/ypKyB7o9mL8vpq6g1tVW6zvR7OOxH9J34dnDe3XSJg1E1AXKmeLwmky VL3p+22uYDsU9nQEQNaoFZQlWXad0Qd6Duj0yo8VFDsfYJYM7aQH8JPKukc9PdiUks61 sjeA== X-Forwarded-Encrypted: i=1; AJvYcCWqQ4Afs2B0rTreBQmigaSD7NO93Pj2DFfBdUDw14yd09Sj3lMSbgbKEqMszEQFDLOzGyF0XGgNBdyxtstdMMURRYZo X-Gm-Message-State: AOJu0YwWYVyskNu3rHrLBDInkaTeA8JI8rOGCK/0c6XlY92c7k+6Zejn uPdNXTdOgLnwmNRnatuEqphnoigHsSP3ZeCh/xE8jByUMhFoIYAsw9+gUICg3U8= X-Google-Smtp-Source: AGHT+IE92dHNbX39E5CpL6fzghojPWn69hg0rMxVmayS2tpnQqnqbNz6dlTYqB9LpiS/OQbj/28ECQ== 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::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hGGUCLk4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qdc3ZgXz1yWy for ; Fri, 22 Mar 2024 02:49:24 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKf7-0004LD-RW; Thu, 21 Mar 2024 11:49:01 -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 1rnKf7-0004Kh-6x for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:01 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKf5-0001E0-Ju for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:00 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-33ec7e38b84so692843f8f.1 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=BWE4XAKevxdmjlwyNU6SQcLV0W9YszYCfSXDWcriOtuhkx7qBYYFLS9wttoRoTfrLw ViksRmaGc+f1O0L9GAx0qI+8QBhanXeiy0qwPjXFqP2mCIHD5XUkcKw9jSo3llVj46mM vWpuYfEkytvNui+s6lnpSXGb8dLnkm1H+I+0vnzRoUryjVujx/DDm/CQ7CEs5yH+siwg Qnz1XLUqJzFvMNcbJsuPVkYpgcZoUSR4zvb4ydxopAfr/LBugPc9d/M9S2UXhL2oqJlA jP7uYeTCgGkYrgGsu/zambs8RoeKtQaQ7TFJKQZvnSKaZD0o182UQ6KqTNgEhTtQLF1p 6PGw== X-Forwarded-Encrypted: i=1; AJvYcCUiLpUq2hZUT7N46O4pbJ4D7y4vUoqQrfOR2z5jsVwDbNkX+o+1Qi9EDOS5+l/suviSBUyoB0trLEZ4+PqToOFsqsGo X-Gm-Message-State: AOJu0YyBx6mppvZns3bKL5lK5TeXJWfD9ND61ew4cZCRshl1skQRC7Ja dGWOxHxyGPq1c9esnWb3ZOYJbXXJ63fjP0itK7VGhC/6ACCw386oa4HiBWoyMbc= X-Google-Smtp-Source: AGHT+IE8OxZ3cOSBAVlgW9eMWvEy1VRRLSZDeMRQmmPBR4vnwTQ7LCZvczOxtWcLs87HZ5ZefGlaXQ== 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::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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é --- 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: 1914505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=dTeYg3U/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qhf2Z1mz23r9 for ; Fri, 22 Mar 2024 02:52:02 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKfT-0004pl-4t; Thu, 21 Mar 2024 11:49:23 -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-0004cR-IT for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:19 -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 1rnKfF-0001Fs-6E for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:13 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-41478297f78so1422535e9.3 for ; Thu, 21 Mar 2024 08:49:06 -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=AyDo1R5ScqrANMDlrhJ4SSgaiZKHY+W4PLglXcAWxAYFIZ4o07N1tGBSFJQGSlSkez XKHpurk6V4JlPjYEGLvdnDOkHVFno2R+EXjHRsx0mK68Qg0+5bKJk+o8fxZjVuLUNJp2 lIhnX/upLbt/ILL0vJF5k6qWp55/L/+45wp+k1UM8R4jgcW9bMUrgOmKULYrq7sXNAM7 wz6IsKb3B/d1XSzRGqbb3y7M2+6PNES7wS56B71c6bQXCa21GZ+3s4HxpUl4T5kG9a9F WPitFc8+DQRH8NzYGYhs4BVyqWzvAIlvfhCevrxvCoUnR250nJksB/a1gEmrECV3UOmw fJoA== X-Forwarded-Encrypted: i=1; AJvYcCUiXDwgyIb2K80atUEdtQEVidPibligh7W+Zr4/gq0nqztx3gZnbIg7s8zFKpL44/g22lyIXyAvL4IJSGg440p21N38 X-Gm-Message-State: AOJu0Yy2YQjR+yIcuyyqPsSjYY0mienY/rgDULPaglA3HZ1/P6scLShL eQ/cHzPOCq7CxlfR1pc9YP1762UuucoMeIhxJEf+epmnS7ej7ah0iInB8lObnCY= X-Google-Smtp-Source: AGHT+IFAw5OqL09R7bmcyeZ9YyOFejxWkGzyRzgg8/RdS1yUB7jjDdFHJRAFWdetwbNp/D/m0mJFLQ== 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::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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 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: 1914498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NSChZN96; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qgT6hvSz23r9 for ; Fri, 22 Mar 2024 02:51:01 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKfZ-0004yA-2n; 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-0004wn-3o for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49: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 1rnKfQ-0001I2-3E for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:26 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-414701303f7so10795045e9.2 for ; Thu, 21 Mar 2024 08:49:14 -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=G5tbz6ixNx0acAxEt97WtcicNS4U03Zb9AASvPUdGR47pE3vOioq5fnz2Cw4Hh0cGD y6DFVFCwRRxKOrdl6dUfX+c6m66xpQA2EVRBNAqOY8iueFTkEDVZ+083Kti6bIlCs12G 6/ro13IsZQPILWV4dOkDaPwEq7CwGRxWbrq3MvKq2fiLOrKhQMyFPvLQdAVVqyhrzIsn NKCoDEF3RyEcQZWsWaYLVYHK2G42ccGBEpWD8Y47jzrrQQW7cCQsZy0AP2FEtB8nMelZ akQlGfYdlH6wNcc7u+7YZX9AphSmYQWWC+bCej0o2/HFu/0seBzvHfes2PKdPzClzdgu YhQA== X-Forwarded-Encrypted: i=1; AJvYcCUvlXZqO5CvMApfl1FrzpiH3HzZVIRw2FG/N0XpyQyX+50IqPO11wn6Drt0L6AmVAac28WvfylIxFmJJ+HfPZck0KlC X-Gm-Message-State: AOJu0YxbTdjo3vVN7D0ccvQ8lEtxgg2d4e7Z18C7d6fkLLOAL5MBvDD+ jXvn2GInY+xGb7gb2o6ofCjqZZkMaKA5pKorJxr6O0INtGEQc1ePMidzs46ZZfk= X-Google-Smtp-Source: AGHT+IE9dq0aSOWu0+Go+xQwyO48QnvBZANp82mdCGdCe9QTAoKEvhJGXJ1ZX9SQy9dmf8KojLeQuQ== 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::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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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é --- 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: 1914493 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=RMPRmhq5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qg45P3Gz23r9 for ; Fri, 22 Mar 2024 02:50:40 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKfW-0004wP-KF; Thu, 21 Mar 2024 11:49:26 -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 1rnKfV-0004sy-73 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:25 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfS-0001KL-VW for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:24 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-414783a9edcso1162575e9.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=feTM9ce7rIhfogoCbUxXHzge+7qYv7jdz2q2ULTLeZAS8nLn5c3uyjsEeksSI3t6i8 +XFsTv5jd+ZvZIYlFHNuqyIYHDqGBrFzU9WQIQnlBs/6t5AS/nM42fl9ZcdaCV4CSqAn SSWJ2ABC7ZXQMZy4WZATKFr/9snpIKnrDjBGUDyjZFwm8SqJ5LmDj4ZdpUw+rZDMoY6v RP/r5OAFCzQLkfbVyK1qjqEUmJc7nuy6nXehsBX7QIifJUS9kIpL0aob9QWuiGzw0tcd X9+yWjFSR5OlBRZLn6ZDOMXKcclHwWrrDe2Gq+iHrDlxHJZUcGju7WIvxTPWPHBmoHLN TX1A== X-Forwarded-Encrypted: i=1; AJvYcCVX9BOIRh5VrpCyWWZkAqYeYFY2YYiHP62rmMKLSVJZhIs4C30iF09fg2ARVc5FToL6xDEx5mWEM9SlQ4ka0CGbJkic X-Gm-Message-State: AOJu0YyIYB7X/qUEiVgfqbUy7j8WcAdrndOhtWIVjXBjX/PlYQ1HBBD6 Jl9n+KJw2UPZdWK2EhfL6UTzQgs8bzjQx4utC4hFwKSFi7nKacLY/vJWeSJSes0= X-Google-Smtp-Source: AGHT+IHaRpML+lFtx0Jaerd+7WHhCNvHSTUSZtk4r37/FpihaA7lUX+X4kwLJk/HZ/vz/lDBAWX4qw== 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::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Replace qemu_printf() by monitor_printf() / monitor_puts() in monitor. Signed-off-by: Philippe Mathieu-Daudé 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: 1914486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Wku3XQxQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qfd0tznz23r9 for ; Fri, 22 Mar 2024 02:50:17 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKfe-0005A2-5w; 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 1rnKfc-00053U-R9 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:32 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfb-0001My-73 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:32 -0400 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2d23114b19dso16604921fa.3 for ; Thu, 21 Mar 2024 08:49:30 -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=oPAV80K1QblqkEN6wpNNdrmkReD85lpZUBsMByJxC8rvX3CTcSz13EKcoyMe2I8W0z ZFBzdcIUbB2MHpgweeGc4z5Z9vF0uLsaLHEid2L76eSOPI1Rocw51ujApa2Eu+UT6uL4 DfC78hxvTnaxBuQTzYUG8/98ugNk/Ix1atLRHINIsUylMc7jfImQC2gKhDf8L9yJI2nC jlS4pwhRwwSDw2FcaUlJv2VytcBP7zvcRi250cGM8RT48uAy9uVj66H3V+LjJEmU2HQS 1XLlraRRn2iX4k8cxd3zRnRXrsesn1vyNXyfEqmPhE7b1oTQ7huMhkwzXQksm99Z3L6C hcig== X-Forwarded-Encrypted: i=1; AJvYcCVlMZuv6d6fYccTy+9pufEhW3Av7XsCuAeytqLoaBYaAFV7cQkXgZzsifg8kNC9xDbz1smMyKaOGVMgm+sASzIAYqcm X-Gm-Message-State: AOJu0YyreWHG8Sf1bMt8MRraFRzDmM6UFzgznRJlnMQPZd6xg0g7VDQt NohAXJGjUadVrlnr78qp0aCMAA2WwzToGqVY1dMe6swKurfoiHSR26FATN0N2Wk= X-Google-Smtp-Source: AGHT+IFBPR/Pr+XbGKhCvPp0NGCaJSK4lXMlzsD5cUSrTyGZOKbh/UIHZyhyiNbuVk1m7v7sep95ug== 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::233; envelope-from=philmd@linaro.org; helo=mail-lj1-x233.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=rLh1W1Od; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qfv5Gxxz23r9 for ; Fri, 22 Mar 2024 02:50:31 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKfo-0005f7-7Q; Thu, 21 Mar 2024 11:49:44 -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 1rnKfm-0005Qg-7o for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:42 -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 1rnKfi-0001QP-QB for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:41 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-41477e77151so1805325e9.2 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=J00qq/9ikVrCLGEVe/an6D8nPqC1Cl/ylAIRAFH9S/DuUiBpudYRT3NX0bUKiBK3ZZ 0Abq1MhCr3WaPN8Wh3yAu9+7adGmqfvbEjskSFyHvAdGt6AFlPGP5zk2KMVAPegGYQLj Elfx+tBULJQu8l3I2cmh3AWA+ctQ/Adn2deAenSDTKkDjzdYuisywuCyb/NEEIlUDxT6 kinTaOSQSkBHBBRov1xtxvLTmSztFLcUlKqYxNjdyuFcD5fSIAmqy/HVq0GF7cM0KjMy H5l+r7YZg+E4T5eQWfVRycza4sMkKpIvxrBlj8D/iRv2aIlJTL3vYFR8bWZfM7hyXMG4 F9Ig== X-Forwarded-Encrypted: i=1; AJvYcCUz0rm370lHVw1YmIwG4XwFYF/H3hKNKtUWNvjSaFD6hTii6M0wOqZybQhpZZnZflJTcXzUbyzjEKn04LOWfiB6OJGE X-Gm-Message-State: AOJu0YzNRtn6NIe5GrOqH/Z6j2TCklIuxPEjwPXUg3k5d4TWHgpSkb7d WQOznMuRj8td6uJYqE15+YRyGqmrIIvN0SSuMB+mxoKoWFUDgAnPubuDUC8Z9ps= X-Google-Smtp-Source: AGHT+IFw0k53MJIEDoEtj/96Ez8pi/LpbXoIDbS/169t1A8FKaf2xVKWSjv2p94mK18bkZO+A1abiA== 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::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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Keep all HMP commands in monitor.c. Signed-off-by: Philippe Mathieu-Daudé --- 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: 1914485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=UnID0Ae5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qfc0MQ2z23r9 for ; Fri, 22 Mar 2024 02:50:16 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKfx-0006HO-VK; 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 1rnKfu-00068R-Ey for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:50 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfp-0001SM-M9 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:50 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33ddd1624beso740447f8f.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=ij3EejVeP9oKa2AjnTOjJf815s7ySSKRwVrK6LPLv4Py886uHdD855xWUUr/cVX4V/ Y1k9SD9GROS5W+qi6+x0Rwe3fXv2nj+ohRQwFJz/3NJSIDglw//v6xlIkpC7NU425tCi /8BM5jr+glPntWi04hTP48nI4QtJehBKBg/EhUYmK90eqfXX+gF+14+4fDknu3zTIhvR 6KSAea3ipMP3xvKZH7uaINk5DxnOuaitbuVZ3/E+1FeLLNGGfTX23ExDff3UiNbLJ9F3 ux6uLZ+6r85h2rYjL+9g6CcF28tQ8xY2dGO+2rkE/UwyYRClOcGvhwQFm5HQKmxHAtqu 0U1g== X-Forwarded-Encrypted: i=1; AJvYcCVME9P370gn3fTOY/2QlUtY8SNB+hBRttPmGOag/lDwYyeIo55u1/e/7j4gafruw4o8/IxwHeVfOVhUxT74mlFW4Dh2 X-Gm-Message-State: AOJu0YxfiIE4q8N5g+QhGwmlxZhdJAiG1TviT15B2KUl/K1SVOdF8pH7 SpUtoBqgDXFp+itkLnC4D+7kYqLC/w6PabWGWLiAKDthtamhsDm/6fZa7zy0sQY= X-Google-Smtp-Source: AGHT+IH1e8ZCLVrNBKv4WDP5qrb8VyO1+oOpzNQpMrOCWQd/FkIrDa1qMU/yHh886xDnLuyjt3Sv0A== 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::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914491 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=eouEY2oG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qfy4xpNz23r9 for ; Fri, 22 Mar 2024 02:50:34 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKg2-0006To-Hn; Thu, 21 Mar 2024 11:49:58 -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 1rnKfz-0006JI-2S for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:55 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKfx-0001UJ-E8 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:49:54 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-41412411672so8695265e9.3 for ; Thu, 21 Mar 2024 08:49:52 -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=i8Vv4Y602YpSPubWFoz4vbxRSiWkmXBCgF9K0nXqygxCYm9iILB7v5qrGQidlJdMvb R/QeUv38xYRQCS8CgfLdIKRiIYDuFPonX4bJd6JB5W4vlPK19iplLUnYylGxbvM98d8Q GwYRmWVZ9uYV7lJ3TqpEGfSwI+kfCDLIcqetGyhxOyyn+KMYhLd9Y38NvV8ihl4lXaZo qN5fEfWMtPZtHI+6+y6O5ZAOQdOra/1YPEZTyRjc8B1O6uYU5cqn/5wvOCeeC4+iZXG7 ThDGTijnipnKxIPMrJXfbgFTq+6KSLgMetA/8kTphtUoT9aq6ZZSfdriJn3RJClO9peb adzg== X-Forwarded-Encrypted: i=1; AJvYcCXgUKrJ45DDjnuRdh6VCb1ub/e//wInS3nXLNY8dtgyXCnhOiJmpbUgU/QvquO/ni5Re+eyO+UKOQz2T81Sig3eaWT7 X-Gm-Message-State: AOJu0YzLHEh/Trq2leRwPcg22O1MIHVGspaVBCZkX9RWfThT2kffkmWI nAVXA2XtO6DjHPXY/+QmDwG30HN4u8EmSuqLuyVQIXO/Y9JWyV7Saayj4UoDxCo= X-Google-Smtp-Source: AGHT+IH/yAHOFp/p/fI7IC+W6jUuAkkKiFdF0KGxCo9t+wlbViIM7IhRlXMf1UHUz2YzS+/8U1P9pQ== 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::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914490 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Smq9a7zf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qfw6KgYz23r9 for ; Fri, 22 Mar 2024 02:50:32 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKgB-0006w8-DK; Thu, 21 Mar 2024 11:50:07 -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-0006u6-Dm for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:05 -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 1rnKg5-0001WI-J5 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:04 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-41464711dc8so9428915e9.1 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=davJJdhX66Ym/2mmX8MubIFYK+M5bsvYOjCEVAOhvR1ofDCv5lJ/NXF1YN6JfCB913 fNhL3VuKArWBkY3FugqFL0kmlaOPvuCR9sZu6/gSU1v+GzvqWeTkmqsO52RYxrEDHvUO MS+qUu46hH4PlJRk8K/5iAnqJhrdoacC+8pRPkhV3+yMALHSl/vtggwE3/CySDpM72Of EnxjzlYJtNSbnAHOuDHrlXtmN2SM7CbC3veEK57a0SDHLfxVxJybvAjO9R2fyPGthaUt qtBNgOfHFSD16iuJ6lIY8wUMeuczyCoyVKZilIOvIc7po0bm3/4hvFw5NNB0BHr9vva2 ma4Q== X-Forwarded-Encrypted: i=1; AJvYcCXHti7mQn2HlZs7YFd77lCBL40rVXsnZGCc5GFToVHpqRIHfl5l2Ek4oE8AiUvAn2R4HmY2N2WI9EDOwRKMT/yaqicO X-Gm-Message-State: AOJu0YzAizbox166ngjIndTzDV5usBVzNA/E1rpvqpz83lZXReguAWmh U9Y/wrphMtQpOKL/87ISzEgmHtJih27wG8RCl415maGBHopX3viqpQIZyrmqCTY= X-Google-Smtp-Source: AGHT+IEMfDVBlpRWNTf5ioGsw32dNSEF5qiU+jNIsLxuEbzb2sWtRQFXvQmOZ7B5T6Oil1bdznnKXQ== 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::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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=beIQHEzs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qfv6jp5z23rR for ; Fri, 22 Mar 2024 02:50:31 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKgU-0007FI-M9; Thu, 21 Mar 2024 11:50:28 -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-00070p-R9 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:14 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgE-0001kk-9t for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:12 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-414776775d3so2813865e9.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=mq+9qzjHOOGo3I8NNyknCCOV23mezC6SlBHBugpyFUQCMv0asm/3hqrZXFsqeSfTLP lYHna5Cx9RtM3BnGCXo5CIFqU5WRL5FH+uYXckOhlyXFDPslHENjsxZ4NVScgGOrcNXH SbaS1Vf2ZaqheVYvY+7gnvz8CZYSf0pDfHp8EWSFkO6oIylnb5ieZngk8zAxLSx4msa4 tls7E20O4uxBg1smo6hCKs5jiiBkDK6ypin16S6ohN5X3n/qi9Gp6EGCDSFTo6N82Pm1 2eDth2sUODhy31uox1/12uYCCQjNScKMfUDHh7L6lqHlSsqPutZ5FdjnqX4TftLM8WEi S2wA== X-Forwarded-Encrypted: i=1; AJvYcCU7jsud4/a8fUep2+bo0EiGHfAOrAs1DglODaGPx8O8xo00oitFQEgLSqQtprtROZdYVRKzOBE8+G7O9YYZoOYaqpql X-Gm-Message-State: AOJu0YzwP+IRT1EfGV3V7c3LzBZVPkMba2IWRPLuLEZtD5+4Yh1gJSsz v46Rk+zgyGHjLwlCD2JiYplxlSK7lbJbHjrRLlTtFsSOYLFgQUabBJO5cFaMJhI= X-Google-Smtp-Source: AGHT+IECdpN4aGFS4wOtGuEHJ/tngZrGDJvB0eP2LElCYBc2wi28sHD7ORsHzU6O1p3ZiIqxr5lUfA== 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::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=GIJEQf92; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qgY2HsTz23r9 for ; Fri, 22 Mar 2024 02:51:05 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKga-0007d4-JY; 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-0007Dd-QX for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:27 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgM-0001mx-6N for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:20 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-414633f7a52so11074205e9.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=O6dGl4NTAH+mOROJ/e6rxDA7HUzEwxqPCzLac6/MvhbwDq1a63sFJs/SluqS11ugb8 vf9Y5ySDdBcAAnQ/xooXlG0OowghdffJzYGTfDg+FpDb6DLGDtmlkgfbF25U/u+6C782 yCxlcmfLlpv/kI8n3bhwP4q4bm2GRbJdeCKlnNk/y4eNWRK1sfGi3cqT/fxrPxYB/cEc iTk4TOOUnDFkTJxbcILJRwQTF4nBjd1oaOhLkvtwfbJehpqTYnOwirggJIE0mGqDMrUx oKS2DyvSxfl9/FrCD0+uqIv3XXik87gncz9UoAmMrkU+vWXP6M0D/Ukl+StFJ+j6Guu5 LQQQ== X-Forwarded-Encrypted: i=1; AJvYcCW4rgHl24ZCrrV1LaZMA8JomI2ru/NC/lWxhLUrNLhxEn+4cURFMb+2TdhHGK8UF0ZlPCtEPN7d6nUkNtMlqNp41eD+ X-Gm-Message-State: AOJu0Yw9C518J4lIOwCavf4KTjoxvbdr38hKjfYKv+tLYI27kKwgoQw5 vKmqRcUEse+xSW7abqbYIwrEZDTV0M3tBrfEmGhlitRIVuHpBpYdTWpo3T/Yv7s= X-Google-Smtp-Source: AGHT+IEeQPhUy7k5Ot/s/fwB1HmG9WBBgDKW6+YXl8dX+9y6uFk/adnRBaAFqSwIZ5/3x8GqHetqlA== 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::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=eCsgufLg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qgD5Tx5z23r9 for ; Fri, 22 Mar 2024 02:50:48 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKgf-0008BT-9T; Thu, 21 Mar 2024 11:50:37 -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-0007sb-Ms for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:35 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgT-0001rv-Hm for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:34 -0400 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-56bc753f58eso1159800a12.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=NZi+Td9THI1eUcMNNdG0J5MMtXcuQQ8R1xdlFQvgVyfipCfnR9Gct9MndWsXnlrajT Kidv86B3ZBqB/Jc74gq7omF1t8JjrQDfwkDEMno1JrX8C7tjNnXQztqAoDjNrOcZWGDK n+8ALsjXyXtvLyF3OUCvBBGHuPwStrKJXqM29GuOuuQ7AuE13rgLtsft1MPGC6mT6XBK 1/baAH1AtHnKOKnZpfRb9uGUSYkKqJnKZlxlrRviWp3O6VtXUvK9hsa4eBYeGDtGTur9 GRR2yij6Xcyydv2dqk8rIz8L4rSlIf5YuFU+xT7vAMeo8xmONTGItf7B/woMtjahTIT2 eDow== X-Forwarded-Encrypted: i=1; AJvYcCUtZ4i7JZsMGFAwVDXnvJslBRkaM+3VN3pn1o3lGFTFZ/7Uoe45K/NGUoh0a7IAaWUM7vMblTChaTFf2lOCmP6u3EVj X-Gm-Message-State: AOJu0YxFiYKvet4tabY6wpWwlXr+oeizcwBfgiynRDDNYgv/wEcPvxAR ax5bzLtjRgBo75rwI3I9zoaMg044LTUTduZLmYuZ3Uf1ugNwPMS7lyzgFtqmXkI= X-Google-Smtp-Source: AGHT+IEu+Xf3tX08u4bnOa0GpwQBGkGiFM8CfhrUIJD16i3Ya68B9pVMVVLfdtyhWqR3h9YHbWXPyg== 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::52d; envelope-from=philmd@linaro.org; helo=mail-ed1-x52d.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, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=u2rQNocd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0ql34LnQz23r9 for ; Fri, 22 Mar 2024 02:54:07 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKgd-0007wY-7e; 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 1rnKga-0007es-W7 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:33 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgY-0001zh-R4 for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:32 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a44ad785a44so138824866b.3 for ; Thu, 21 Mar 2024 08:50:29 -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=jnegzqJYXVyHJucx+jf2XzUmeVFFFw+rii+1Eyq2GREKMtjTionNk2oJZDUgTjpv+M 7huBFXXN0k1R264JHXSacfkOsVOMYcq3TzOrgjzzqom0AXSP+yC1aIxp0LZGoqQgFScm CTjhRFPAuogKk9YMdLONrBHfEXN0JbUNrmbqDQP/JsgfkeV++LHWFQTWSlH03js2ARHZ TbNW919P9Bpu9mo+uek+Uy4cdl91d8JaWpi2zk/1gTs/i5CUiPMRfvhSujrJ4b2O3lyt deoFBjL7baM7iJSXO93LKJyfcJAdOx5evdU5QmVyrbhzwqfDSQ5gzPOImTHAwtD4Issu agng== X-Forwarded-Encrypted: i=1; AJvYcCUeo0Gs2d2aEGxTrWHbUaGSIIImyoREMzZARgmFG9sjb/9Dqgw+K0calIsZEGr5W/aOmC8UrDFBHxAZN2j1a/VtSXQy X-Gm-Message-State: AOJu0Ywsj75yZBC8qjdTmjkeSAuvGpZfiRVZjvqKrQy/GzDtWlshEEI/ /QVTdVLQ9uChlU+XOpPXYUV5EFVPaIo/Xhc2mEOFtH1AbTtkN2+Z2RJbZ3xr7FE= X-Google-Smtp-Source: AGHT+IE2nkP3/s+ZVl7OIbnsBZ7cJXuE1J4tybtt6Fys94AA+96zHcj+6baTb+fsUqIjIJvE7tyf0Q== 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::632; envelope-from=philmd@linaro.org; helo=mail-ej1-x632.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=en8F9YfV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qjY1NZ3z23r9 for ; Fri, 22 Mar 2024 02:52:49 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKgq-0000gU-Uj; Thu, 21 Mar 2024 11:50: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 1rnKgk-0000Lf-Qs for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:46 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgf-000253-Rb for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:41 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a46ea03c2a5so202389566b.1 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=XBYYM1L2ATf2kNTZgXK0fgYeWWQk+Nr7Dj/e0SncRwfp4SgR40HLtHXXQCwPqS8VG8 ZIB2USqeE/zDZ5BbWV5KxIjkTz0I+2G8IPBg8clfx2/qUxuZuW1V337T0O7E38N6gPAX N3ggxH1y+4vDwg7k6T9Tq5yiC0eFQz3ILqAtN2UGubYKcMsCvVy62ti+NKqx7ry/ZF6U 9rKPQGD1j2zmnm7kntiYDTc3o6IlFP8av839/eKw671xrpQUQaq2mHEWaZBbJHrqdXTf OEWnAG8dd1tavFrz18SKiu0UGUy0xtg+VXaM+Bqip7z/E9IU6A734s9exMdfPxwyt9QX EWbw== X-Forwarded-Encrypted: i=1; AJvYcCVOKgShJza0XJImg8GKE88QcizRkuDXQ0kd5uLvhFktUR6Ansf8KJmbVwDVJaLdGUYpVxgWCrd+UqgHBVnMo/3nwe8D X-Gm-Message-State: AOJu0YzByBEDiXx7k2iKo7D8SFdgfepACdoc1pfTwKIufGCYChkIY32j cSWGEeOd9uKV41ME/pyuVQThYjO8gAZ15jtAwPqqgRF02jPh722OTn2YQ4sPo+vw0S4+aQc3RB+ YZjs= X-Google-Smtp-Source: AGHT+IFRSRO+fdMOTgprlXH0Zd9WRAFvm//y4djnsbaR2xZxibyh6sIRkiLEm5NXNehMk0OBzI8ynw== 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::62b; envelope-from=philmd@linaro.org; helo=mail-ej1-x62b.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=DlfN+nah; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qh72BFtz23r9 for ; Fri, 22 Mar 2024 02:51:35 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKh0-00016s-DP; Thu, 21 Mar 2024 11:51: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 1rnKgt-0000vj-2r for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:52 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgo-00026z-Px for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:49 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-56bc8cfc19fso1009056a12.1 for ; Thu, 21 Mar 2024 08:50:43 -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=II1toR9g6GEYeuGgs6BL/MLBq+WQVDRbI7d1esE8J2rRANSDzDsOlWTS73GXU3fFPP 7HA0A/ZBiVDGuHwX3aqNgls5c7M82Of516KG5JbFYB5gyWgfZq621gtoyCZ9E2FAGlC3 VONnnyFPrwnLewpG26Bbxwn7TCo7A1z8e2uQX4c6vLasaQ9wKHIH7tiYImi2ehswixHq CCfsIGP5hbKC+LCR9p6NpR5vYLowuiVa8ctpHm0Kw0jzT6tPo5zyF4rqeq0kjgeZ0SV8 Gp667dIxnOY8sMU6YB2I8dM/erJUHl+zVZ5aoTLS6VYd1oH8pviI+PPzs81j2W5XoARO 2hHA== X-Forwarded-Encrypted: i=1; AJvYcCX+2CQiuV8Eh7xuMZzHPn7tpndiRFrCR2pJZzuOyiKwKPMYQ1GXa7yWLNkns6YuVKD1KWpzZ4RPfyV3ESZlvOeGY3kd X-Gm-Message-State: AOJu0YyF6NWUB0y1qAMbr7IA0r0wobjA1jHa7p+LKxaruVQiGfJzfzfZ f4kMIHMZgoZzdhFLjs1ihDLW+2GhmfOhiA8mDr28p9+cxAChMLcetrkRA7x4PQg= X-Google-Smtp-Source: AGHT+IFC+603+0zXjXAdG4HWaTIUS/dH/fvyFL+gcZp+Ho3JRr0cQ7lQy0en+QoMITehIBuIBHPe+w== 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::534; envelope-from=philmd@linaro.org; helo=mail-ed1-x534.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=H1qzqjlx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0ql15RX7z23r9 for ; Fri, 22 Mar 2024 02:54:05 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKhd-0001vs-6G; Thu, 21 Mar 2024 11:51:37 -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-000164-PG for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:58 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgt-00028y-4A for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:54 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-56bcede226eso849420a12.1 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=ZjSbmz4E6jtGlmQF0SSmJSmQSCWKtgmsqLcVnlvTzt4dot7ENNO+heY7JbnzFcNIMO iZOxUpgGJgqJoHZyT1kzFsq4zj4XcLp4qWkeo1f9MCWXCj+8obDbnJXxtIaRKh5fNwzn G7DyWHtwqc4DxF3d/4y1I+j/55ntA3NSCZy4nGITm7p/cFi3ys06dqmZpdtdTDlAkvnJ 6fF2QH7EU5ebHe998Fahd0DYiQzaLCBSo7H7zMVERdfEZcQOPOU/M/iAQoPB1JxhTQJW ZZppgB6RFCSpcUOD3jZ4Pk+hifPSfejk1k0ZuK62TMlPcgk8tK1hDfssg0zbtXqRD5gE u9vQ== X-Forwarded-Encrypted: i=1; AJvYcCXtu9j2bnwmtuuR1xfw0eWlrptFGgMt/ViMZiQlCwrCHvdLD8otasaS4rZ4g8lVLSZxr0vYycW5u/25uW/+9iO7P2b5 X-Gm-Message-State: AOJu0YytMO0qYYNBkSWIFrceqIgEeiqESlSLGrNwE/WF+aEdfxuIS4zZ 3DXxdB0pCZcqwRM4qpSVFxKr+nDXghhJZ/wwmO/Hcfzq8NioJTUPz4YB8R9f54o= X-Google-Smtp-Source: AGHT+IG0y8L0mGnPrFKMTIUU0M1hBiRNav6XsB7ffIMx0E+AmGpLpKoEjlnLiJMwx0BhB6oYf9DiRg== 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::52c; envelope-from=philmd@linaro.org; helo=mail-ed1-x52c.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914506 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=bc7Ngyvw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qhk1D1Rz23r9 for ; Fri, 22 Mar 2024 02:52:06 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKhb-0001rf-F0; Thu, 21 Mar 2024 11:51:36 -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-0001Ia-AU for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:51:14 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKh1-0002BK-Rk for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:51:05 -0400 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-56829f41f81so1385613a12.2 for ; Thu, 21 Mar 2024 08:50:58 -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=Nbi2QExn4Pad7lZHYuKK+YwTxQACqZj6RlvthxUqDyC6F+6N+hpsLfm1fEAx5IyOKx 9YOgz2mbtEI+0kUUg5q6EE2f1iGdtlvaIM7LKmPY9oaSqZRswdTubgxzbnUlqRa0CXFd p/zZaKPVdV8bUy/QhUGU3P7iKsqXATJsycez1LVm+IKG1EWxmA9IxGwNjS2rOl2VjsJM vz00Pzl4j/wfE92C2H6MW6o3I2GSqMGZe0ZvvCbQawXar+Ej4nTdegNeNmQ6Rw8vVF8w DbMfw7sPUwvvSO0NFS0Z1zAc7l1Xzow3B9cpn2UY3KYxMmap8HtAK6byzyodszRwwucv sEmA== X-Forwarded-Encrypted: i=1; AJvYcCXgqiBB1Im531bvG6kk80EcyQndx6aDoDNGgkrxpyeBXjI1MDPU6mWP6liM9b/vwplIcn+Ov51c4F7gGBI8pRtJjiJ7 X-Gm-Message-State: AOJu0YyIsgncsoJELlQPz6bsHsMho4QzumBqUfrjBOD795KZb7hno0n+ YpLXDP141pQP15qvq8bVZddhA9VoGW/dlttlW8FB6pfN0FaauZRhQTBpfur//Aw= X-Google-Smtp-Source: AGHT+IGsbdB9bbsTJSPu6jcHuepTNYz1mIqjLhoqi0ukqIZIA1xQFRu3cMrN8SeguMUz5v/WdnNqXg== 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::52a; envelope-from=philmd@linaro.org; helo=mail-ed1-x52a.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914511 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=x2r+5suX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qjG5GqBz23r9 for ; Fri, 22 Mar 2024 02:52:34 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKhy-000341-TC; Thu, 21 Mar 2024 11:51:58 -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 1rnKhM-0001XJ-OP for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:51:24 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKhE-0002D5-Fx for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:51:16 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-56845954ffeso1463725a12.2 for ; Thu, 21 Mar 2024 08:51:05 -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=Qj45NLIFbdk6sTCjjO/Fvc8a9qnMVH3IVI8k9h3Zm8IyvPipuaDNHjb6lxCr9ZChoT lHzGDRinmcUJSkxNoL8j4Jza3ZbTOpqog1uGZrJG9IuB7JbIGm7SMNWIe/fnyKGJ8O9o aA50OXtjr87GZu6Z3ioxKxW4jkHlDz20zqPbMbglszCEJNEItGEXdd5s+AKL5YFAuQBv Sh97ke9Wop68W5BVFUdbLG03HnA1LdgWQ1/Tk5+qKfgWieEOiMS3j07DoFwwbdewHFBf U8oYEc3taCfZjrw4426/ehhDlIUwSA84Uuhv2TRmtw1SjIWzVZzwz6rNyXKocEaSrqeZ Hy9Q== X-Forwarded-Encrypted: i=1; AJvYcCWUsr+k/BD7OufrUlVeKdvvIks1DXCUovC+RAOJ+UWUtbo0W388f7Pa4voLnLI79vzRfs+RzWCGE0KUhmJZQjAR5Xpv X-Gm-Message-State: AOJu0YxQoHK9nQ3+cIIF7c3xhg7K/PEH+qdkKRHXo58tRiIn3xneujKN KefMR51NwgQ9OMLfJRkyYQYDQBpQnC50DbvaClB6RGiNhqiWqDDVo8LI8VjLe38= X-Google-Smtp-Source: AGHT+IHBIEjNNoQWciGMRReYDUJ+2KBY59lWDsKhCAXVV+pZNY4VmyPe+35g936JWxQSLM+SygqP2g== 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::532; envelope-from=philmd@linaro.org; helo=mail-ed1-x532.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NNYMF4P7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qhc3nDNz23r9 for ; Fri, 22 Mar 2024 02:52:00 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKht-0002eQ-M9; Thu, 21 Mar 2024 11:51: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 1rnKhW-0001cq-NB for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:51:32 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKhN-0002Ee-RD for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:51:26 -0400 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2d485886545so21904101fa.2 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=RHR6eVCmU84XuYO76hkzUC1OoAMC0xiDpW6Pg2x5JYfj7xMl0tG6ZtR+85if/Kli9G yTReLLrkDTLnhBfh7KtCA6PECTSUCwboSG8u9YHDvcxvfcnsYadt0HFRT1mPCBJ8aGJR 28t48XTzAMelgStIZ5pRnX06WD+1PHTiVBswquKJoFlA3nZFUIFRGC6KdDcco81Wqv69 GqIKtbBkpzMl787AyV+MWjn0UaJ3G6+PRkKK1xjgEXRSUv88NT52hXI4/9vpaRE6wcbO CWKr0JfsbhbAKT3fzGwAbGggOT15vW2OLYOtXa19DI26EB6PSKLHFJZ6qTT4zoxX4QY1 HbAw== X-Forwarded-Encrypted: i=1; AJvYcCWoKHLDAJjJxwcXUnobxSE2/3VZDyHU86qn0NCCS9B/4cEsW4PkDM0JqChgnFBqwX2GrBrFRMIth5hHOX7knRRfb/TZ X-Gm-Message-State: AOJu0Yy24phvhUSLeJc/IEJ2nXCHgypa2JTE3+tf1spTNVNyJ1NfWCWb 2C2Z5cqAMyWEBTeXs8aE3+XCSrnCVV+r/3WKc0umzX/P/1/zjm2N0E4YuBc8CXQ= X-Google-Smtp-Source: AGHT+IHBplfjpFB1vOCGbIjl6ktfDRjEjyU1MULPF6t37s/XrZTWksZKQ9OFd/03Vz5z4YtjEImoig== 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::22c; envelope-from=philmd@linaro.org; helo=mail-lj1-x22c.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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: 1914510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NmZkXEnc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qjD6CSPz23r9 for ; Fri, 22 Mar 2024 02:52:32 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKhp-0002Uw-NV; 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 1rnKhW-0001cr-Sj for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:51:32 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKhQ-0002GN-NZ for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:51:29 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a471f77bf8eso29567866b.2 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=KnMjCNexiAqm5fgb/WkDJsHv+67dqnOH7WoJG4AVJte6T7sjzXcpxVk6YCEyePPAD0 dpURtlTsEqew3g4fW0hNVMdchUTuru2KTFqPKt+jtiKvhxxG4q2AlZd6g4kzS5KyP4m+ Qp17CJunjx232f0FbEY1/fI/BzVQKd/yrEoCC5016ppYKrqtPJoFUZ9oQOxpYPA74LiT mvKOm1ly8rmV+LNe/FUJWzBgtJEROy+5wDgaWXzbEom8+7cwiaz9AUslEARjBsdxrH5A dkudUvAIWX2sHab7QiN+RvPNo0Ih73Nuqj0VHU10wQP2MEo+QyXKta4YNH0EL0FvD23w aChA== X-Forwarded-Encrypted: i=1; AJvYcCXWQd1Ky/6pQXuM23ROnOCQ+T4AUMgykIN3nvmACYnnYScz7UeM6vqnKLSugL6cgBqAQWPZTOvMCbM239TKP5EOa3Sj X-Gm-Message-State: AOJu0YzZKTng2KjAsL8xM4bxk0Rzg45jM/oL8EDh+niu1Sp0evIdejvK l1A+T2kTfC6xFt4W1ejXgY4giVuvj6zBGON7U8T7Y3j7M5QVqJQ9/93/J84fZN8= X-Google-Smtp-Source: AGHT+IH+u8dh6Dd3IoTEkLrunbmBXAcoyeNE0+4XZ8t2uEGI/1Fk6JyfZva3OYGVZRcd8mLZe7oLuQ== 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::631; envelope-from=philmd@linaro.org; helo=mail-ej1-x631.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.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); }