From nobody Mon Feb 9 14:04:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528786452954566.0230735831424; Mon, 11 Jun 2018 23:54:12 -0700 (PDT) Received: from localhost ([::1]:53248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSdBl-0000l8-4w for importer@patchew.org; Tue, 12 Jun 2018 02:53:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSd3i-0002eE-9f for qemu-devel@nongnu.org; Tue, 12 Jun 2018 02:45:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSd3g-0001mq-Vc for qemu-devel@nongnu.org; Tue, 12 Jun 2018 02:45:38 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:48851) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSd3g-0001gk-16; Tue, 12 Jun 2018 02:45:36 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 414gPN2Fncz9s2g; Tue, 12 Jun 2018 16:45:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1528785928; bh=jprKaXT2PMjjPEW5fbDYVlV4GGuLvJykXztnU5/Wgto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KrjE4zc/Y8Ogd77Ga6RoVBx0S05ZzdGbp90oDdzlvIUyrfRTqN2YmcchOE6ayQ11n iRwbzwOfPT95GA2855jrctXFoufKbM6h8CTeSNHelpjK7dsrK6Z5w0urymFTs33WVu yzDkgP+yUOAr4Ww/P16V7rtaU9KKED/QTSiD4MAg= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 12 Jun 2018 16:44:35 +1000 Message-Id: <20180612064503.14282-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612064503.14282-1-david@gibson.dropbear.id.au> References: <20180612064503.14282-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 05/33] target/ppc: Use proper logging function for possible guest errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Thomas Huth , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth fprintf() and qemu_log_separate() are frowned upon these days for printing logging information in QEMU. Accessing the wrong SPRs indicates wrong guest behaviour in most cases, and we've got a proper way to log such situations, which is the qemu_log_mask(LOG_GUEST_ERROR, ...) function. So use this function now for logging the bad SPR accesses instead. Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Greg Kurz Reviewed-by: Alistair Francis Signed-off-by: David Gibson --- target/ppc/translate.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index b28e8b91d3..8ba8f67dc5 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3933,13 +3933,9 @@ static inline void gen_op_mfspr(DisasContext *ctx) * allowing userland application to read the PVR */ if (sprn !=3D SPR_PVR) { - fprintf(stderr, "Trying to read privileged spr %d (0x%03x)= at " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next = - 4); - if (qemu_log_separate()) { - qemu_log("Trying to read privileged spr %d (0x%03x) at= " - TARGET_FMT_lx "\n", sprn, sprn, - ctx->base.pc_next - 4); - } + qemu_log_mask(LOG_GUEST_ERROR, "Trying to read privileged = spr " + "%d (0x%03x) at " TARGET_FMT_lx "\n", sprn, = sprn, + ctx->base.pc_next - 4); } gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG); } @@ -3951,12 +3947,9 @@ static inline void gen_op_mfspr(DisasContext *ctx) return; } /* Not defined */ - fprintf(stderr, "Trying to read invalid spr %d (0x%03x) at " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4); - if (qemu_log_separate()) { - qemu_log("Trying to read invalid spr %d (0x%03x) at " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4= ); - } + qemu_log_mask(LOG_GUEST_ERROR, + "Trying to read invalid spr %d (0x%03x) at " + TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - = 4); =20 /* The behaviour depends on MSR:PR and SPR# bit 0x10, * it can generate a priv, a hv emu or a no-op @@ -4097,12 +4090,9 @@ static void gen_mtspr(DisasContext *ctx) (*write_cb)(ctx, sprn, rS(ctx->opcode)); } else { /* Privilege exception */ - fprintf(stderr, "Trying to write privileged spr %d (0x%03x) at= " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4); - if (qemu_log_separate()) { - qemu_log("Trying to write privileged spr %d (0x%03x) at " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next= - 4); - } + qemu_log_mask(LOG_GUEST_ERROR, "Trying to write privileged spr= " + "%d (0x%03x) at " TARGET_FMT_lx "\n", sprn, sprn, + ctx->base.pc_next - 4); gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG); } } else { @@ -4114,12 +4104,9 @@ static void gen_mtspr(DisasContext *ctx) } =20 /* Not defined */ - if (qemu_log_separate()) { - qemu_log("Trying to write invalid spr %d (0x%03x) at " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4= ); - } - fprintf(stderr, "Trying to write invalid spr %d (0x%03x) at " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4); + qemu_log_mask(LOG_GUEST_ERROR, + "Trying to write invalid spr %d (0x%03x) at " + TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - = 4); =20 =20 /* The behaviour depends on MSR:PR and SPR# bit 0x10, --=20 2.17.1