From patchwork Mon Feb 17 01:47:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1238936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48LRhP2VwFz9sRJ for ; Mon, 17 Feb 2020 12:48:05 +1100 (AEDT) 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.a=rsa-sha256 header.s=20161025 header.b=axNq2rvn; 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 48LRhN39KRzDqd3 for ; Mon, 17 Feb 2020 12:48:04 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=oohall@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.a=rsa-sha256 header.s=20161025 header.b=axNq2rvn; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48LRhF30gGzDqX2 for ; Mon, 17 Feb 2020 12:47:57 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id j15so8201754pgm.6 for ; Sun, 16 Feb 2020 17:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=D7J2GNzF+ibiicm/VTeLjijc9/86ZoQMcXnuf3vYA54=; b=axNq2rvnYQSRH6mJef2ke8yZRJnpfE2XE3dWuARTxsei3+bxRYzs7PI4oXpPqjisbz KRSwZrgPmXGpHUvh8AKtyHIHVpXuqY9UmviN3bOYQbvJTJq9rYOCiGPow+bqKFgbO29x t2ZwFfeJ/eF7D0cFiweqQebsuFCQMfyGUQKdB/284FwelemlFtYiDZravrE1K70FhMXs +U1C8OTKgtHcrfzGleFZIRfwIjtUgtpy7OZY9UzsYqChiw91DSvmEMidDO4C/Q1uGTw9 SXxGij32oa4bDoiBOawnQoEf8eehgPv1QSIRNUY4iwhut9gYhyDeRkPY/3LZoYYZ4kGA y2oQ== 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:mime-version :content-transfer-encoding; bh=D7J2GNzF+ibiicm/VTeLjijc9/86ZoQMcXnuf3vYA54=; b=S2bAgkOGSDRsGg1fjkzHIfxmF5o5Dj9TuqucdxM7tNbXJJoZTAGfCCsYQZ0puKvtZS YFTXJ6QFp2AOX+5ysnATImyJUvLefGl/M7ZekYCUryVVgXkH/FI/cBdNTtAzy2fuskCF br+Kgjkbd7VIKOU2kM6Vp8QVYOq2Zr/moU9xMghQ0utXgRw/cLHR4aeOJgBEf2Sv1zlo DXkSARKAjo0ZWIo7MPxv/AksjMGEvlJJvPbHdNgYHll9Jv95IWnRfi0RXZ5GyP519rQ7 INHFEu3lG9zmj2LcH/DU2SThO2ZbgD3quQnb51YfTkvD5TuxPhH0Xv65UgbUr7eoNjoH Ci2w== X-Gm-Message-State: APjAAAU0Tlfq8XMaFeRER4NGz5PP2y08e851cE5ttLI7BW7q26OsdjVY 3ALOTpnVThQqurk0GZIrYUgFYqnP X-Google-Smtp-Source: APXvYqxCowFKjOahVmqrUJ7+tPm9VLJ3ZnFtPMHqf2Kenmj+HAJ9de38JpnudQKFmUCvP5gjaP1Jnw== X-Received: by 2002:a63:5807:: with SMTP id m7mr14218686pgb.83.1581904074019; Sun, 16 Feb 2020 17:47:54 -0800 (PST) Received: from wafer.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id q4sm14733746pfl.175.2020.02.16.17.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 17:47:53 -0800 (PST) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Mon, 17 Feb 2020 12:47:41 +1100 Message-Id: <20200217014741.27984-1-oohall@gmail.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Subject: [Skiboot] [PATCH] powerpc/xmon: Fix whitespace handling in getstring() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The ls (lookup symbol) and zr (reboot) commands use xmon's getstring() helper to read a string argument from the xmon prompt. This function skips over leading whitespace, but doesn't check if the first "non-whitespace" character is a newline which causes some odd behaviour ( indicates a the enter key was pressed): 0:mon> ls printk printk: c0000000001680c4 0:mon> ls printk Symbol ' printk' not found. 0:mon> With commit 2d9b332d99b ("powerpc/xmon: Allow passing an argument to ppc_md.restart()") we have a similar problem with the zr command. Previously zr took no arguments so "zr would trigger a reboot. With that patch applied a second newline needs to be sent in order for the reboot to occur. Fix this by checking if the leading whitespace ended on a newline: 0:mon> ls Symbol '' not found. Fixes: 2d9b332d99b ("powerpc/xmon: Allow passing an argument to ppc_md.restart()") Reported-by: Michael Ellerman Signed-off-by: Oliver O'Halloran --- arch/powerpc/xmon/xmon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index e8c84d26..0ec9640 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -3435,6 +3435,11 @@ getstring(char *s, int size) int c; c = skipbl(); + if (c == '\n') { + *s = 0; + return; + } + do { if( size > 1 ){ *s++ = c;