From: Guo Ren <guoren@kernel.org>
To: "Heiko Stübner" <heiko@sntech.de>
Cc: Palmer Dabbelt <palmer@rivosinc.com>,
linux-riscv <linux-riscv@lists.infradead.org>,
Guo Ren <guoren@linux.alibaba.com>
Subject: Re: [RFC PATCH 2/4] riscv: Cleanup ERRATA_THEAD_PBMT for rv32 svpbmt compile
Date: Sun, 10 Jul 2022 00:24:10 +0800 [thread overview]
Message-ID: <CAJF2gTT7oGq9N64vubNHaiO7BpSZPqf0a4dQDkW+SXiPiqaFpw@mail.gmail.com> (raw)
In-Reply-To: <3498257.R56niFO833@diego>
On Fri, Jul 8, 2022 at 4:51 PM Heiko Stübner <heiko@sntech.de> wrote:
>
> Hi Guo,
>
> Am Dienstag, 5. Juli 2022, 12:05:21 CEST schrieb guoren@kernel.org:
> > From: Guo Ren <guoren@linux.alibaba.com>
> >
> > Make compile cleaner and don't reference the THEAD_PBMT data struct when
> > CONFIG_ERRATA_THEAD_PBMT=y. Next, we could cleanly make svpbmt to
> > support rv32.
> >
> > Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> > Signed-off-by: Guo Ren <guoren@kernel.org>
> > ---
> > arch/riscv/include/asm/errata_list.h | 11 ++++++++++-
> > 1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h
> > index 416ead0f9a65..47175d91773d 100644
> > --- a/arch/riscv/include/asm/errata_list.h
> > +++ b/arch/riscv/include/asm/errata_list.h
> > @@ -47,6 +47,8 @@ asm(ALTERNATIVE("sfence.vma %0", "sfence.vma", SIFIVE_VENDOR_ID, \
> > * in the default case.
> > */
> > #define ALT_SVPBMT_SHIFT 61
> > +
> > +#ifdef CONFIG_ERRATA_THEAD_PBMT
>
> I don't really think that is necessary and actually makes the code
> more complex than needed.
>
> Each alternative-entry already has the dependency on
> CONFIG_* ... i.e. CONFIG_RISCV_ISA_SVPBMT and CONFIG_ERRATA_THEAD_PBMT
>
> When you look at alternative-macros.h you'll see this translating to the
> enable argument in ALT_NEW_CONTENT.
>
> So only when that is active is the alternative section added to the build.
> I.e. that translates to:
>
> .if IS_ENABLED(CONFIG_ERRATA_THEAD_PBMT)
> .pushsection .alternative, "a"
> ...
>
> So when CONFIG_ERRATA_THEAD_PBMT is disabled the whole alternative
> part never gets added already, so there shouldn't be any need to make the
> source more complicated.
No, we need this for rv32 compile.
➜ linux git:(rv32svpbmt_v2_tmp) make ARCH=riscv
CROSS_COMPILE=riscv32-buildroot-linux-gnu- EXTRA_CFLAGS+=-g
O=../build-rv32/ -skj all
In file included from
/home/guoren/source/kernel/linux/arch/riscv/include/asm/pgtable.h:15,
from
/home/guoren/source/kernel/linux/include/linux/pgtable.h:6,
from /home/guoren/source/kernel/linux/include/linux/mm.h:29,
from
/home/guoren/source/kernel/linux/arch/riscv/kernel/asm-offsets.c:10:
/home/guoren/source/kernel/linux/arch/riscv/include/asm/errata_list.h:50:
warning: "ALT_SVPBMT_SHIFT" redefined
50 | #define ALT_SVPBMT_SHIFT (__riscv_xlen-3)
|
/home/guoren/source/kernel/linux/arch/riscv/include/asm/errata_list.h:49:
note: this is the location of the previous definition
49 | #define ALT_SVPBMT_SHIFT 61
|
/home/guoren/source/kernel/linux/arch/riscv/include/asm/pgtable-bits.h:
In function ‘riscv_page_mtmask’:
/home/guoren/source/kernel/linux/arch/riscv/include/asm/pgtable-bits.h:43:18:
error: ‘_PAGE_MTMASK_THEAD’ undeclared (first use in this function)
43 | ALT_SVPBMT(val, _PAGE_MTMASK);
| ^~~~~~~~~~~~
/home/guoren/source/kernel/linux/arch/riscv/include/asm/errata_list.h:61:9:
note: in definition of macro ‘ALT_SVPBMT’
61 | "I"(prot##_THEAD >> ALT_THEAD_PBMT_SHIFT), \
| ^~~~
/home/guoren/source/kernel/linux/arch/riscv/include/asm/pgtable-bits.h:43:18:
note: each undeclared identifier is reported only once for each
function it appears in
43 | ALT_SVPBMT(val, _PAGE_MTMASK);
| ^~~~~~~~~~~~
/home/guoren/source/kernel/linux/arch/riscv/include/asm/errata_list.h:61:9:
note: in definition of macro ‘ALT_SVPBMT’
61 | "I"(prot##_THEAD >> ALT_THEAD_PBMT_SHIFT), \
| ^~~~
/home/guoren/source/kernel/linux/arch/riscv/include/asm/pgtable-bits.h:
In function ‘riscv_page_nocache’:
/home/guoren/source/kernel/linux/arch/riscv/include/asm/pgtable-bits.h:51:18:
error: ‘_PAGE_NOCACHE_THEAD’ undeclared (first use in this function)
51 | ALT_SVPBMT(val, _PAGE_NOCACHE);
| ^~~~~~~~~~~~~
/home/guoren/source/kernel/linux/arch/riscv/include/asm/errata_list.h:61:9:
note: in definition of macro ‘ALT_SVPBMT’
61 | "I"(prot##_THEAD >> ALT_THEAD_PBMT_SHIFT), \
| ^~~~
/home/guoren/source/kernel/linux/arch/riscv/include/asm/pgtable-bits.h:
In function ‘riscv_page_io’:
/home/guoren/source/kernel/linux/arch/riscv/include/asm/pgtable-bits.h:59:18:
error: ‘_PAGE_IO_THEAD’ undeclared (first use in this function)
59 | ALT_SVPBMT(val, _PAGE_IO);
| ^~~~~~~~
/home/guoren/source/kernel/linux/arch/riscv/include/asm/errata_list.h:61:9:
note: in definition of macro ‘ALT_SVPBMT’
61 | "I"(prot##_THEAD >> ALT_THEAD_PBMT_SHIFT), \
| ^~~~
make[2]: *** [/home/guoren/source/kernel/linux/scripts/Makefile.build:117:
arch/riscv/kernel/asm-offsets.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [/home/guoren/source/kernel/linux/Makefile:1200: prepare0] Error 2
make[1]: Target 'all' not remade because of errors.
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'all' not remade because of errors.
>
>
> Heiko
>
> > #define ALT_THEAD_PBMT_SHIFT 59
> > #define ALT_SVPBMT(_val, prot) \
> > asm(ALTERNATIVE_2("li %0, 0\t\nnop", \
> > @@ -60,7 +62,6 @@ asm(ALTERNATIVE_2("li %0, 0\t\nnop", \
> > "I"(ALT_SVPBMT_SHIFT), \
> > "I"(ALT_THEAD_PBMT_SHIFT))
> >
> > -#ifdef CONFIG_ERRATA_THEAD_PBMT
> > /*
> > * IO/NOCACHE memory types are handled together with svpbmt,
> > * so on T-Head chips, check if no other memory type is set,
> > @@ -90,6 +91,14 @@ asm volatile(ALTERNATIVE( \
> > "I"(ALT_THEAD_PBMT_SHIFT) \
> > : "t3")
> > #else
> > +#define ALT_SVPBMT(_val, prot) \
> > +asm(ALTERNATIVE("li %0, 0\t\nnop", \
> > + "li %0, %1\t\nslli %0,%0,%2", 0, \
> > + CPUFEATURE_SVPBMT, CONFIG_RISCV_ISA_SVPBMT) \
> > + : "=r"(_val) \
> > + : "I"(prot##_SVPBMT >> ALT_SVPBMT_SHIFT), \
> > + "I"(ALT_SVPBMT_SHIFT))
> > +
> > #define ALT_THEAD_PMA(_val)
> > #endif
> >
> >
>
>
>
>
--
Best Regards
Guo Ren
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2022-07-09 16:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-05 10:05 [RFC PATCH 0/4] Proof of concept for rv32 svpbmt support guoren
2022-07-05 10:05 ` [RFC PATCH 1/4] riscv: Optimize satp_mode data type guoren
2022-07-05 17:26 ` Christoph Hellwig
2022-07-05 23:45 ` Guo Ren
2022-07-05 10:05 ` [RFC PATCH 2/4] riscv: Cleanup ERRATA_THEAD_PBMT for rv32 svpbmt compile guoren
2022-07-08 8:50 ` Heiko Stübner
2022-07-09 16:24 ` Guo Ren [this message]
2022-07-10 2:25 ` Guo Ren
2022-07-05 10:05 ` [RFC PATCH 3/4] riscv: pgtable: Move svpbmt into the common pgtable-bits.h guoren
2022-07-08 6:10 ` Guo Ren
2022-07-08 9:03 ` Heiko Stübner
2022-07-08 9:49 ` Guo Ren
2022-07-05 10:05 ` [RFC PATCH 4/4] riscv: Change rv32p34 to rv32p31 for svpbmt guoren
2022-07-05 17:22 ` [RFC PATCH 0/4] Proof of concept for rv32 svpbmt support Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJF2gTT7oGq9N64vubNHaiO7BpSZPqf0a4dQDkW+SXiPiqaFpw@mail.gmail.com \
--to=guoren@kernel.org \
--cc=guoren@linux.alibaba.com \
--cc=heiko@sntech.de \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@rivosinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).