Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1162261pxa; Thu, 13 Aug 2020 02:03:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqMbfEYTptW78Ry2SojyDj+WS4KLlH35QvxrdZbpgE9NUI4i0jBBrFdAkuOuHD0H8aJVJy X-Received: by 2002:a17:906:3b4e:: with SMTP id h14mr3975954ejf.546.1597309426539; Thu, 13 Aug 2020 02:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597309426; cv=none; d=google.com; s=arc-20160816; b=iPq+f4/EoBi9o6OfzhIov2UWE333pzPVq3XMepx8dkt8+BMgSiJNnEXudO80wpbWHo FsV9+VaTtrOxpsleDVftaXD3Ht5iEGVbVyY4ApahB9wZe/+fNZR0TY9cata+Vdg6ZV80 PL9uCFKwtyHiaiyZhen01BxBJx0IMcXlFMQtq1N2/HCfzdvM/cJhFJM29YhJWaf/WOvW ufQJ2fZ1IieVud+e3p+O6Zr9Fbe4Wd9f15skRYZVYcoo2gNntCiCzqLHqct4FXEUhnBr JMxFw8hC5LMAsz1m1GXuy9ocSMYowWoYafjrJ98f0P9eatfmFGLmgwpdDThLDfoMMEq5 bKJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nkTNyYRkgbYaz12fQ06lSjHZCH+igEZHF1ZLr68a4Pc=; b=tT8CZxd7VRYgTgkWicrJQ0Fls/Rtae02gvUku4El4FWWYUAcPge01wthBbHDPZARCE a0NRKbhC5RqHnNMEASlu+/KBp4MY98+c1VhhWEwxs253InoB3FR+jsgLxTKE/VUU9nQ1 cKbBu6Ugm6gmZ6lPqJ5USC3akawcwBsYgoezWOPthVkncpwPqB0XGHn+x1PDwXBExtkT xCYAVBKfFf7tiCu675ORBnZAlRGKiebwH4A/yQd4mjX0hGibFG2l28QZ6TuAmC93E7ZP pdkZZRcqlIyIv1bVs6sIF/oq8K/zfRaglxmCiyB00n8KsX/Jhl+gI3l/ybxw0Y6LABtI zNVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=St0rjCN4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si3656272edi.81.2020.08.13.02.03.23; Thu, 13 Aug 2020 02:03:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=St0rjCN4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbgHMJC5 (ORCPT + 99 others); Thu, 13 Aug 2020 05:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726100AbgHMJC4 (ORCPT ); Thu, 13 Aug 2020 05:02:56 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D816C061757 for ; Thu, 13 Aug 2020 02:02:56 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id a15so4530746wrh.10 for ; Thu, 13 Aug 2020 02:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nkTNyYRkgbYaz12fQ06lSjHZCH+igEZHF1ZLr68a4Pc=; b=St0rjCN4LjocFxkWL2JKEHSwd9frPy+F8cEY6fwOY2zb573Puar+J4dmOX93BYgyr4 QLGDtaiyyIz0FvAKSb8GN8ZbpWHiGNprjhz1Azjgak+uuZ43kGqUHpeCIc+ovidTTnlR iA15WOt0WKozh7jPYU6yMYAHNrrTm6e+C4Dgk6Q9N6W767i1ZsctFf1BPk5xx4ZWDBcu siZ9A5zErf8C/BWkoG5NvGhe8XbjPdjkKxPlyWeDxnReShIuryID17YQLM9h+nIDWU35 9YBsm8mnKeiwZvDsr6kZKWSK1iiFbvZywmlGMjZ7Kql4rbCqTNW8q+V4ixmve26d8ola rpiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nkTNyYRkgbYaz12fQ06lSjHZCH+igEZHF1ZLr68a4Pc=; b=k4LUItJ6KUXsrY9rBxi3PTBU3aBptv4o5+PKWfRoXb1DOuxlkgTEvSHPuuuSsV9h4b 2naDdzBH71X7FpVtfewsFQlkElUa8umC3dOC3X1cTlYth0H/6LTtzHrErRq/qfdt5OqR xS/jaxeSy6J/l0H9MRb4m0q+ub6ZCe8aP0oQhoRwOcmzgKgUUyKZI40bwAjz90909g+7 Hg+w75A9F4cNlUvEWYM1QI8fUa5fJtLM+SwKIlMQipdfIlZ1WO55AClW2syqDSdhDcgQ Hxv2lz7Nt9ppx0Am1tniyGO9fznkcQTu8K7idFQn0WtooEj2HKZRAh9QeRLhhU4zK6R5 8cOg== X-Gm-Message-State: AOAM530A4wCkmgVSK8clPbOqmkfDQEEVCLyyxPIeYcnG/BkT/GgNM+8q WQ/dgZOG4OnTmtvFht1h42kDXUMgNt2sEesFw26DS894Wv4= X-Received: by 2002:adf:f186:: with SMTP id h6mr3187988wro.144.1597309374980; Thu, 13 Aug 2020 02:02:54 -0700 (PDT) MIME-Version: 1.0 References: <20200812234758.3563-1-atish.patra@wdc.com> <20200812234758.3563-10-atish.patra@wdc.com> In-Reply-To: <20200812234758.3563-10-atish.patra@wdc.com> From: Anup Patel Date: Thu, 13 Aug 2020 14:32:43 +0530 Message-ID: Subject: Re: [PATCH v5 9/9] RISC-V: Add page table dump support for uefi To: Atish Patra Cc: "linux-kernel@vger.kernel.org List" , Albert Ou , Alistair Francis , Andrew Morton , Anup Patel , Ard Biesheuvel , Arvind Sankar , Borislav Petkov , Greentime Hu , Ingo Molnar , Kees Cook , linux-efi , linux-riscv , fwts-devel@lists.ubuntu.com, Mao Han , Masahiro Yamada , Michal Simek , Mike Rapoport , Nick Desaulniers , Palmer Dabbelt , Paul Walmsley , Steven Price , Waiman Long , Will Deacon , Daniel Schaefer , "abner.chang@hpe.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 13, 2020 at 5:18 AM Atish Patra wrote: > > Extend the current page table dump support in RISC-V to include efi > pages as well. > > Here is the output of efi runtime page table mappings. > > ---[ UEFI runtime start ]--- > 0x0000000020002000-0x0000000020003000 0x00000000be732000 4K PTE D A . . . W R V > 0x0000000020018000-0x0000000020019000 0x00000000be738000 4K PTE D A . . . W R V > 0x000000002002c000-0x000000002002d000 0x00000000be73c000 4K PTE D A . . . W R V > 0x0000000020031000-0x0000000020032000 0x00000000bff61000 4K PTE D A . . X W R V > ---[ UEFI runtime end ]--- > > Signed-off-by: Atish Patra > --- > arch/riscv/mm/ptdump.c | 48 ++++++++++++++++++++++++++++++++++++------ > 1 file changed, 42 insertions(+), 6 deletions(-) > > diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c > index 0831c2e61a8f..ace74dec7492 100644 > --- a/arch/riscv/mm/ptdump.c > +++ b/arch/riscv/mm/ptdump.c > @@ -3,6 +3,7 @@ > * Copyright (C) 2019 SiFive > */ > > +#include > #include > #include > #include > @@ -49,6 +50,14 @@ struct addr_marker { > const char *name; > }; > > +/* Private information for debugfs */ > +struct ptd_mm_info { > + struct mm_struct *mm; > + const struct addr_marker *markers; > + unsigned long base_addr; > + unsigned long end; > +}; > + > static struct addr_marker address_markers[] = { > #ifdef CONFIG_KASAN > {KASAN_SHADOW_START, "Kasan shadow start"}, > @@ -68,6 +77,28 @@ static struct addr_marker address_markers[] = { > {-1, NULL}, > }; > > +static struct ptd_mm_info kernel_ptd_info = { > + .mm = &init_mm, > + .markers = address_markers, > + .base_addr = KERN_VIRT_START, > + .end = ULONG_MAX, > +}; > + > +#ifdef CONFIG_EFI > +static struct addr_marker efi_addr_markers[] = { > + { 0, "UEFI runtime start" }, > + { SZ_1G, "UEFI runtime end" }, > + { -1, NULL } > +}; > + > +static struct ptd_mm_info efi_ptd_info = { > + .mm = &efi_mm, > + .markers = efi_addr_markers, > + .base_addr = 0, > + .end = SZ_2G, > +}; > +#endif > + > /* Page Table Entry */ > struct prot_bits { > u64 mask; > @@ -245,22 +276,22 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, > } > } > > -static void ptdump_walk(struct seq_file *s) > +static void ptdump_walk(struct seq_file *s, struct ptd_mm_info *pinfo) > { > struct pg_state st = { > .seq = s, > - .marker = address_markers, > + .marker = pinfo->markers, > .level = -1, > .ptdump = { > .note_page = note_page, > .range = (struct ptdump_range[]) { > - {KERN_VIRT_START, ULONG_MAX}, > + {pinfo->base_addr, pinfo->end}, > {0, 0} > } > } > }; > > - ptdump_walk_pgd(&st.ptdump, &init_mm, NULL); > + ptdump_walk_pgd(&st.ptdump, pinfo->mm, NULL); > } > > void ptdump_check_wx(void) > @@ -293,7 +324,7 @@ void ptdump_check_wx(void) > > static int ptdump_show(struct seq_file *m, void *v) > { > - ptdump_walk(m); > + ptdump_walk(m, m->private); > > return 0; > } > @@ -308,8 +339,13 @@ static int ptdump_init(void) > for (j = 0; j < ARRAY_SIZE(pte_bits); j++) > pg_level[i].mask |= pte_bits[j].mask; > > - debugfs_create_file("kernel_page_tables", 0400, NULL, NULL, > + debugfs_create_file("kernel_page_tables", 0400, NULL, &kernel_ptd_info, > &ptdump_fops); > +#ifdef CONFIG_EFI > + if (efi_enabled(EFI_RUNTIME_SERVICES)) > + debugfs_create_file("efi_page_tables", 0400, NULL, &efi_ptd_info, > + &ptdump_fops); > +#endif > > return 0; > } > -- > 2.24.0 > Looks good to me. Reviewed-by: Anup Patel Regards, Anup