From patchwork Tue Apr 10 11:25:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balbir Singh X-Patchwork-Id: 896605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40L4bn048wz9s06 for ; Tue, 10 Apr 2018 21:25:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HZDx5zNr"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40L4bm2GWKzDqyH for ; Tue, 10 Apr 2018 21:25:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HZDx5zNr"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com; envelope-from=bsingharora@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HZDx5zNr"; dkim-atps=neutral Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40L4bX60klzDqRV for ; Tue, 10 Apr 2018 21:25:28 +1000 (AEST) Received: by mail-pf0-x243.google.com with SMTP id y69so8037765pfb.5 for ; Tue, 10 Apr 2018 04:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=/nxyBh/GLajZArHAui/KjBbO0ixnzCjOlaj7AKDBBrM=; b=HZDx5zNrHiDigL4jEf6xdqFe5iINSKWUZo9dbDJj+Ej8LXxR+272Wuk4cXYwr80gm0 yxAUFv+cZ0eJmRTSrPY88BA/BwmVBQgxDbUbZ7EVYyiSEQZwQ7zzWyCopqRo/DKUx9jx OewjOsghUaxAOILGtPSPglRn417xoqRO1I5/pA+1i2d2EzNKRlde8Zczy9OlMCnsw6Xb sfgKajt33W5PcsYwdFt5e5pi/Gk8zcaZJhibBR+2UdigUjrIp6IT4ikV4jFUNsfqsfG3 +htPHWoO4zgtqW6Zb7Xx0olZqTkhVvIqOraOm/b4X2wbs9gxTbvqhcVcZ+wxyZYVIJu7 mSqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/nxyBh/GLajZArHAui/KjBbO0ixnzCjOlaj7AKDBBrM=; b=ZBGY/V8URqVG+dFr+XPdNzGokmqfZ23E3tnVpJka8VK3VwYIYS4exrQooa4geGO8P9 7v5iSW9ST8k47KhbeXXEp6Rj7xhbxgWotpRkCtXvmnH14ZOdPYm1gzlJw7V4/YtrI+Qg vuxbS8Re+qwNRM8ecDAWfStGa1Eo3sodkvFtp/RJZYSLNCJSX/VmRiNAa0RMcRV8grwA UTfPohI04HIE5VK1HdfkTqqddDyEloA6Wv38990lOI5fxJz3WQC00ujtlfRkBObT8UT8 b7YfzUVLHIAN/QfPtkxhdRzizkVq/eyDnm3IEXAAPOK3HNOCDOt/TMCF8bGx1QNklNbn UQzQ== X-Gm-Message-State: ALQs6tCD0ofdciIGIXfDAzDLJQIf5Kjy9VqtV56yEhzWSgF6nVTb78Xe rwdqYtj+vQfTYMdlZXu7QNvBHIBf X-Google-Smtp-Source: AIpwx48LpWbj1GScVYu+boPPI4csz15WUAC9zySY5JOr4NPKOuZfZ8rEtI38BaBw9iLYR3qTPEMpxg== X-Received: by 10.99.103.6 with SMTP id b6mr6982916pgc.214.1523359526462; Tue, 10 Apr 2018 04:25:26 -0700 (PDT) Received: from localhost.au.ibm.com (14-202-194-140.static.tpgi.com.au. [14.202.194.140]) by smtp.googlemail.com with ESMTPSA id r81sm5629240pfj.79.2018.04.10.04.25.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Apr 2018 04:25:25 -0700 (PDT) From: Balbir Singh To: skiboot@lists.ozlabs.org, stewart@linux.vnet.ibm.com Date: Tue, 10 Apr 2018 21:25:18 +1000 Message-Id: <20180410112518.18604-1-bsingharora@gmail.com> X-Mailer: git-send-email 2.13.6 Subject: [Skiboot] [PATCH] mambo/mambo_utils.tcl: Inject an MCE at a specified address X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Currently we don't support injecting an MCE on a specific address. This is useful for testing functionality like memcpy_mcsafe() (see https://patchwork.ozlabs.org/cover/893339/) This patch refactors exc_mce into setup_mce and exc_mce. setup_mce is generally useful to setup a MCE context with variables DSISR, SRR1 and DAR. setup_mce supports setting up dsisr as a new function argument. It's useful when we want to set up both the cause and DSIR. The core of the functionality is a routine called inject_mce_ue_on_addr, which takes an addr argument and injects an MCE (load/store with UE) when the specified address is accessed by code. This functionality can easily be enhanced to cover instruction UE's as well. Signed-off-by: Balbir Singh Signed-off-by: Nicholas Piggin --- external/mambo/mambo_utils.tcl | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/external/mambo/mambo_utils.tcl b/external/mambo/mambo_utils.tcl index 7a27f0f4..a9225e3e 100644 --- a/external/mambo/mambo_utils.tcl +++ b/external/mambo/mambo_utils.tcl @@ -442,11 +442,12 @@ proc mce_trigger { args } { # # Default with no arguments is a recoverable i-side TLB multi-hit # Other options: -# d_side=1 cause=0x80 - recoverable d-side SLB multi-hit +# d_side=1 dsisr=0x80 - recoverable d-side SLB multi-hit +# d_side=1 dsisr=0x8000, cause=0x1 - ue error on instruction fetch # d_side=0 cause=0xd - unrecoverable i-side async store timeout (POWER9 only) # d_side=0 cause=0x1 - unrecoverable i-side ifetch # -proc exc_mce { { d_side 0 } { cause 0x5 } { recoverable 1 } } { +proc setup_mce { { d_side 0 } {dsisr 0x5} { cause 0x5 } { recoverable 1 }} { variable SRR1 variable DSISR variable DAR @@ -466,11 +467,10 @@ proc exc_mce { { d_side 0 } { cause 0x5 } { recoverable 1 } } { set msr_ri 0x0 } - # recoverable d-side SLB multihit if { $d_side } { set is_dside 1 - set SRR1_mc_cause 0x0 - set DSISR $cause + set SRR1_mc_cause $cause + set DSISR $dsisr set DAR 0xdeadbeefdeadbeef } else { set is_dside 0 @@ -486,7 +486,10 @@ proc exc_mce { { d_side 0 } { cause 0x5 } { recoverable 1 } } { set SRR1 [expr $SRR1 | ((($SRR1_mc_cause >> 2) & 0x1) << (63-43))] set SRR1 [expr $SRR1 | ((($SRR1_mc_cause >> 1) & 0x1) << (63-44))] set SRR1 [expr $SRR1 | ((($SRR1_mc_cause >> 0) & 0x1) << (63-45))] +} +proc exc_mce { { d_side 0 } {dsisr 0x5} { cause 0x5 } { recoverable 1 }} { + setup_mce $d_side $dsisr $cause $recoverable if { [current_insn] in { "stop" "nap" "sleep" "winkle" } } { # mambo has a quirk that interrupts from idle wake immediately mysim trigger set pc 0x200 "mce_trigger" @@ -526,6 +529,22 @@ proc inject_mce { } { mysim trigger clear pc $pc ; list } +# +# We've stopped at addr and we need to inject the mce and continue +# +proc trigger_mce_ue_addr {args} { + set addr [lindex [lindex $args 0] 1] + mysim trigger clear memory system rw $addr $addr + setup_mce 0x1 0x8000 0x1 0x1 + mysim trigger set pc 0x200 "mce_trigger" + mysim cpu 0 interrupt MachineCheck + mce_trigger +} + +proc inject_mce_ue_on_addr {addr} { + mysim trigger set memory system rw $addr $addr 1 "trigger_mce_ue_addr" +} + # inject and step over one instruction, and repeat. proc inject_mce_step { {nr 1} } { for { set i 0 } { $i < $nr } { incr i 1 } {