From patchwork Tue Mar 15 20:43:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 551445 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp3789453mag; Tue, 15 Mar 2022 13:44:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDh51/OZTfCbUGQncQZjUU2K+3ETHcfJ0e2CuyglnTvvbDmAQe0r4oxz49fB5FdyitfzXz X-Received: by 2002:a81:c40d:0:b0:2ca:287c:6c9b with SMTP id j13-20020a81c40d000000b002ca287c6c9bmr26060943ywi.320.1647377071580; Tue, 15 Mar 2022 13:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647377071; cv=none; d=google.com; s=arc-20160816; b=cd23s98xQEal6kBMOIZ8ZYolcSOcUitHvTYEAG/aQc0iQ9gBGjdxKQSAr6WMwDrvb8 CpDi4LTT6am9jHu6+BAnZRrehumHRuxEaRxmwdHzbBbPp+dPzdQp6vlsi7lpHr/C/AUE 4kcMhVNqcVVujVY9DcN9rWkX0vmWk0BMeHBaEcwznc4s8dSfNm5yFZdsgBiyqeLKoRqW zqyaJ9UheROrD9OPeeZAX8y/h0NP9Jx/zfHMGqfHQgx083l2NPggenlwBxyWkGLWKhS3 84b9/xxRze9a7k4lcaXmwOR9ekBxl+u4itJZzR3GNxg7DOsJHe1JK3AhYFlwWieVcsv9 mOUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=WjoW4TuhrLDh3vJbD36hIEHEEGiSVoyg+GX+kjzhoEI=; b=AnuZGGStR5+Neg4kAwbSkQPx5LCLJjAhexPHt76dycT+T2TkXT8wJFR1/tzDGNbFOx x5GwbQ7+PTA1yjYbYUVuqHHhb9n4TsGo5cBbJdkpndIlGUuDFpvxg04PHjFJBnDxCNV3 hEwKMHEtOwBlrwg7xsvJtyos+EfYMKV+gHAdzIIcYSAkoYg24S+X2ISyihbwdgpflspV /Awj3T3trlvXXVk1UPhOK7Va9VdQ1B1YT+oyJrKdOHBvmVyo94FvlxbheOX9NuQYmp2p kOlhCiiVgZJb9QOD+dYalmZhpNjlVxDbaBcD0d8x2fd+T5trcLkkf6peAb80ejstf4ix i/pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KboKxyOI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g67-20020a813946000000b002d035ccf9cfsi69141ywa.115.2022.03.15.13.44.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Mar 2022 13:44:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KboKxyOI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUE1v-0006QC-2p for patch@linaro.org; Tue, 15 Mar 2022 16:44:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUE0e-0006PB-MM for qemu-devel@nongnu.org; Tue, 15 Mar 2022 16:43:12 -0400 Received: from [2a00:1450:4864:20::433] (port=35523 helo=mail-wr1-x433.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUE0c-0008Fe-SO for qemu-devel@nongnu.org; Tue, 15 Mar 2022 16:43:12 -0400 Received: by mail-wr1-x433.google.com with SMTP id r6so261080wrr.2 for ; Tue, 15 Mar 2022 13:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=WjoW4TuhrLDh3vJbD36hIEHEEGiSVoyg+GX+kjzhoEI=; b=KboKxyOIUCopYWDgAigdTqExkbNXpYShjD/bZX5N9r2fvO+G17d8vYG+95seS6gyeY mxgPtpy3lR3T9UwbUSSQu8GR24GHB54k46peKKypI2VB/4pGGNQ9cA/wK4Aatr3L9Ysm n9ya6KkCYdSNXTLgGsARqrpDkHF0KXx3yw16DdlY8heGzgGv3uWD4sKPIfnAd2hOb49O eTPOfrmrJSXzpGWboOcE5bRnsRJNaFozQKytGd0/MoxkDOPEYceekV7lD42nxOmeAL4z 5fE7/CPDjRIQedwW7TTC1whknIj9MpQftPxAVri1chsp+prbNDsGV3Pb7U01TusCKdkd LsuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=WjoW4TuhrLDh3vJbD36hIEHEEGiSVoyg+GX+kjzhoEI=; b=bL6ulyrRV/Lnfp4plVRQdKOz4bkkThV7GvVctSDIut+l/uaYj0M1fN0ioH1Uh/aQ59 ovm2E2OC22zKt1Yj/8qlVi2e62IzHMeqiliL39LQwpYGsBxKAIaSOgAA+xkeYTBf//2l YAdywzheILZrLpIyGzCsRJBVkvRoI1V91us4RN+8Pc71s8dN265yisaWP7hlnHPPeIbv YzYjLH1uzVcFuR52ILA2DnmmhHYWWiz4LT6ipbP+hshclRO5jXx52Q3CQh1tXvJkM3uo eQtihV+dfpAKjkZad/3grjySwn2AxcZHRguzFSB5PUh9WUULYDMZi8LZT+56qh0e6bSE tduw== X-Gm-Message-State: AOAM532ubZSLPj3xU3JOO3ckeqP7fT3eLDocNzUqeZ1UFFR80iMk642h EbyqttcpzxjueQG5pIlcVBRgnQ== X-Received: by 2002:a05:6000:16ca:b0:1f1:dfd6:723d with SMTP id h10-20020a05600016ca00b001f1dfd6723dmr21281905wrf.127.1647376988881; Tue, 15 Mar 2022 13:43:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h11-20020a05600c414b00b0038c6c3eaee9sm465208wmm.1.2022.03.15.13.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 13:43:08 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 0/2] target/arm: Improve M-profile exception logging Date: Tue, 15 Mar 2022 20:43:04 +0000 Message-Id: <20220315204306.2797684-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::433 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Our current logging for M-profile exceptions has a couple of holes which are particularly confusing for the case of an exception taken immediately out of reset: * we don't log the initial PC/SP loaded from the vector table * we don't log the PC we load from the vector table when we take an exception * we don't log the address for i-side aborts This case is quite common where the user has failed to provide a vector table in their ELF file and QEMU thus loads garbage for the initial PC. At the moment the logging looks like: $ qemu-system-arm [...] -d in_asm,cpu,exec,int Taking exception 3 [Prefetch Abort] on CPU 0 ...with CFSR.IACCVIOL ...BusFault with BFSR.STKERR ...taking pending nonsecure exception 3 ---------------- IN: 0x20000558: 08000079 stmdaeq r0, {r0, r3, r4, r5, r6} After this patchset it looks like: $ qemu-system-arm [...] -d in_asm,cpu,exec,int Loaded reset SP 0x0 PC 0x0 from vector table Loaded reset SP 0xd008f8df PC 0xf000bf00 from vector table Taking exception 3 [Prefetch Abort] on CPU 0 ...at fault address 0xf000bf00 ...with CFSR.IACCVIOL ...BusFault with BFSR.STKERR ...taking pending nonsecure exception 3 ...loading from element 3 of non-secure vector table at 0xc ...loaded new PC 0x20000558 ---------------- IN: 0x20000558: 08000079 stmdaeq r0, {r0, r3, r4, r5, r6} and I think it is somewhat clearer that we loaded a bogus PC from the vector table at reset, faulted at that address, loaded the HardFault entry point which was bogus but at least readable, and started executing code from there. The double-logging of the reset loads is the result of the way we currently reset the CPU twice on QEMU startup. If we ever manage to fix that silliness it'll go away. (Patchset inspired by a stackexchange question: https://stackoverflow.com/questions/71486314/loading-an-elf-file-into-qemu ) thanks -- PMM Peter Maydell (2): target/arm: Log M-profile vector table accesses target/arm: Log fault address for M-profile faults target/arm/cpu.c | 5 +++++ target/arm/m_helper.c | 11 +++++++++++ 2 files changed, 16 insertions(+) Reviewed-by: Philippe Mathieu-Daudé