Return-path: Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJAlD-0000xU-80 for kexec@lists.infradead.org; Fri, 18 Sep 2020 07:24:48 +0000 Received: by mail-wr1-x442.google.com with SMTP id z1so4531875wrt.3 for ; Fri, 18 Sep 2020 00:24:45 -0700 (PDT) Subject: Re: [PATCH] arm64: Add purgatory printing References: <20200917193835.30910-1-matthias.bgg@kernel.org> From: Matthias Brugger Message-ID: Date: Fri, 18 Sep 2020 09:24:42 +0200 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Geoff Levand , matthias.bgg@kernel.org, kexec@lists.infradead.org, horms@verge.net.au Cc: Matthias Brugger Hi Geoff, On 18/09/2020 04:04, Geoff Levand wrote: > Hi Matthias, > > On 9/17/20 12:38 PM, matthias.bgg@kernel.org wrote: > Add option to allow purgatory printing on arm64 hardware >> by passing the console name which should be used. > >> +static uint64_t find_purgatory_sink(const char *console) >> +{ >> + int fd, ret; >> + char folder[255], device[255], mem[255]; >> + struct stat sb; >> + char buffer[18]; >> + uint64_t iomem = 0x0; >> + >> + if (!console) >> + return 0; >> + >> + sprintf(device, "/sys/class/tty/%s", console); >> + if (!stat(folder, &sb) == 0 && S_ISDIR(sb.st_mode)) { >> + fprintf(stderr, "kexec: %s: No valid console found for %s\n", >> + __func__, device); >> + return 0; >> + } >> + >> + sprintf(mem, "%s%s", device, "/iomem_base"); >> + printf("console memory read from %s\n", mem); >> + >> + fd = open(mem, O_RDONLY); >> + if (fd < 0) { >> + fprintf(stderr, "kexec: %s: No able to open %s\n", >> + __func__, mem); >> + return 0; >> + } >> + >> + memset(buffer, '\0', sizeof(char) * 18); > > I think I'd like to just see 'memset(buffer, 0, sizeof(buffer));'. > >> + ret = read(fd, buffer, 18); > > And 'ret = read(fd, buffer, sizeof(buffer));'. > You are correct, I'll add it to v2. Thanks for the quick review! Matthias >> + if (ret < 0) { >> + fprintf(stderr, "kexec: %s: not able to read fd\n", __func__); >> + close(fd); >> + return 0; >> + } >> + >> + sscanf(buffer, "%lx", &iomem); >> + printf("console memory is at %#lx\n", iomem); >> + >> + close(fd); >> + return iomem; >> +} >> + > > Otherwise, looks OK. > > -Geoff > _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec