From patchwork Tue Oct 2 14:11:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kleber Sacilotto de Souza X-Patchwork-Id: 977864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Ph0B1DLMz9tjw; Wed, 3 Oct 2018 00:11:22 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1g7LON-0004Bx-Is; Tue, 02 Oct 2018 14:11:15 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1g7LOL-0004Be-21 for kernel-team@lists.ubuntu.com; Tue, 02 Oct 2018 14:11:13 +0000 Received: from mail-wm1-f72.google.com ([209.85.128.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1g7LOK-00009o-Qn for kernel-team@lists.ubuntu.com; Tue, 02 Oct 2018 14:11:12 +0000 Received: by mail-wm1-f72.google.com with SMTP id y203-v6so1757801wmg.9 for ; Tue, 02 Oct 2018 07:11:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=BgAJX9g8TsJge+vaH2yEiVGdQELLJH1kBgjxVTbuuGg=; b=aT03PA9T06oWvSvJP924TkpHQqWwb/qiIyDl2/SU0fvAjwNQLGmr+6Sh/lSjrvw7uF PBOh2a2gtGUEcA5dgPPILOZAKaeRNJuQhZSAREvuipEqXMEZbTv5/A6IvmMN0QSVrTum 1o39WMMwST93EPGXWVusU3aJ4SQKnpVj9KGGA5Zf47N59ubu+llVGobhsWbpa1te12Jh 0Jkl3Uyf5Mqm0sNtV/cQM/oJPcYt9rWuG+0HA1/uPjFOr1tufXnk0HcmFq+56IWg/VpF IHow3lfsbGHntjLjDbCCPLGkw2rQjKjK6MO6EHvVpZKA1UYEi9gT/DfnRgZkc0hWzWwu 32Ug== X-Gm-Message-State: ABuFfohM1n3MoX8ILMGeQ87jUN+njy1CS78ewmwDsVBOfwbPCBTkOl8g tSF3oe9NzlfSTuio9/bdqAU1F0lyHH14DkJ3XHAOTvakCxs3tMn7xBwxbA6LNEunELPI4PMPHPe 8Fqa4JjB8qGbnCYWIcxX6+9VUt7VsLuDixRPPJCEoMA== X-Received: by 2002:adf:eec4:: with SMTP id a4-v6mr11476595wrp.242.1538489472159; Tue, 02 Oct 2018 07:11:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV629LZ+lXLwal5154Ahme3BwKU89nCvps4YZaFYBJ/n/DehkVZ8Qr6GHy4fxPd0+zX5jZeB26g== X-Received: by 2002:adf:eec4:: with SMTP id a4-v6mr11476579wrp.242.1538489471849; Tue, 02 Oct 2018 07:11:11 -0700 (PDT) Received: from localhost ([2a02:8109:98c0:1604:3540:adf5:d839:581a]) by smtp.gmail.com with ESMTPSA id x139-v6sm14137513wme.3.2018.10.02.07.11.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Oct 2018 07:11:11 -0700 (PDT) From: Kleber Sacilotto de Souza To: kernel-team@lists.ubuntu.com Subject: [SRU][Xenial][PATCH 1/1] powerpc/fadump: Return error when fadump registration fails Date: Tue, 2 Oct 2018 16:11:06 +0200 Message-Id: <20181002141106.1646-2-kleber.souza@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002141106.1646-1-kleber.souza@canonical.com> References: <20181002141106.1646-1-kleber.souza@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Michal Suchanek BugLink: https://bugs.launchpad.net/bugs/1795662 - log an error message when registration fails and no error code listed in the switch is returned - translate the hv error code to posix error code and return it from fw_register - return the posix error code from fw_register to the process writing to sysfs - return EEXIST on re-registration - return success on deregistration when fadump is not registered - return ENODEV when no memory is reserved for fadump Signed-off-by: Michal Suchanek Tested-by: Hari Bathini [mpe: Use pr_err() to shrink the error print] Signed-off-by: Michael Ellerman (backported from commit 98b8cd7f75643e0a442d7a4c1cef2c9d53b7e92b) Signed-off-by: Kleber Sacilotto de Souza Acked-by: Stefan Bader --- arch/powerpc/kernel/fadump.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 4e71df4048a9..6c217b931ccb 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -360,9 +360,9 @@ static int __init early_fadump_reserve_mem(char *p) } early_param("fadump_reserve_mem", early_fadump_reserve_mem); -static void register_fw_dump(struct fadump_mem_struct *fdm) +static int register_fw_dump(struct fadump_mem_struct *fdm) { - int rc; + int rc, err; unsigned int wait_time; pr_debug("Registering for firmware-assisted kernel dump...\n"); @@ -379,7 +379,11 @@ static void register_fw_dump(struct fadump_mem_struct *fdm) } while (wait_time); + err = -EIO; switch (rc) { + default: + pr_err("Failed to register. Unknown Error(%d).\n", rc); + break; case -1: printk(KERN_ERR "Failed to register firmware-assisted kernel" " dump. Hardware Error(%d).\n", rc); @@ -387,18 +391,22 @@ static void register_fw_dump(struct fadump_mem_struct *fdm) case -3: printk(KERN_ERR "Failed to register firmware-assisted kernel" " dump. Parameter Error(%d).\n", rc); + err = -EINVAL; break; case -9: printk(KERN_ERR "firmware-assisted kernel dump is already " " registered."); fw_dump.dump_registered = 1; + err = -EEXIST; break; case 0: printk(KERN_INFO "firmware-assisted kernel dump registration" " is successful\n"); fw_dump.dump_registered = 1; + err = 0; break; } + return err; } void crash_fadump(struct pt_regs *regs, const char *str) @@ -997,7 +1005,7 @@ static unsigned long init_fadump_header(unsigned long addr) return addr; } -static void register_fadump(void) +static int register_fadump(void) { unsigned long addr; void *vaddr; @@ -1008,7 +1016,7 @@ static void register_fadump(void) * assisted dump. */ if (!fw_dump.reserve_dump_area_size) - return; + return -ENODEV; ret = fadump_setup_crash_memory_ranges(); if (ret) @@ -1023,7 +1031,7 @@ static void register_fadump(void) fadump_create_elfcore_headers(vaddr); /* register the future kernel dump with firmware. */ - register_fw_dump(&fdm); + return register_fw_dump(&fdm); } static int fadump_unregister_dump(struct fadump_mem_struct *fdm) @@ -1208,7 +1216,6 @@ static ssize_t fadump_register_store(struct kobject *kobj, switch (buf[0]) { case '0': if (fw_dump.dump_registered == 0) { - ret = -EINVAL; goto unlock_out; } /* Un-register Firmware-assisted dump */ @@ -1216,11 +1223,11 @@ static ssize_t fadump_register_store(struct kobject *kobj, break; case '1': if (fw_dump.dump_registered == 1) { - ret = -EINVAL; + ret = -EEXIST; goto unlock_out; } /* Register Firmware-assisted dump */ - register_fadump(); + ret = register_fadump(); break; default: ret = -EINVAL;