mbox series

[v2,0/2] Fix arm64 CONFIG_CMDLINE handling and remove CMDLINE_EXTEND

Message ID 20210303134927.18975-1-will@kernel.org
Headers show
Series Fix arm64 CONFIG_CMDLINE handling and remove CMDLINE_EXTEND | expand

Message

Will Deacon March 3, 2021, 1:49 p.m. UTC
Hi again,

This is version two of the series I previously posted here:

	https://lore.kernel.org/r/20210225125921.13147-1-will@kernel.org

The main change since v1 is that, rather than "fix" the FDT code to
follow the documented behaviour for CMDLINE_EXTEND, I've opted to remove
the thing entirely for arm64 while a less ambiguous and generic
replacement is developed, probably based on either [1] or [2].

I've left the first-patch as-is so that it's easier to incorporate
whatever ends up replacing CMDLINE_EXTEND in future.

Cheers,

Will

[1] https://patchwork.ozlabs.org/project/linuxppc-dev/cover/cover.1554195798.git.christophe.leroy@c-s.fr/
[2] https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20190319232448.45964-2-danielwa@cisco.com/

--->8

Cc: Max Uvarov <muvarov@gmail.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Doug Anderson <dianders@chromium.org>
Cc: Tyler Hicks <tyhicks@linux.microsoft.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: <kernel-team@android.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: <devicetree@vger.kernel.org>

Will Deacon (2):
  arm64: cpufeatures: Fix handling of CONFIG_CMDLINE for idreg overrides
  arm64: Drop support for CMDLINE_EXTEND

 arch/arm64/Kconfig                 |  6 -----
 arch/arm64/kernel/idreg-override.c | 43 ++++++++++++++++--------------
 2 files changed, 23 insertions(+), 26 deletions(-)

Comments

Rob Herring March 3, 2021, 10:30 p.m. UTC | #1
On Wed, Mar 3, 2021 at 7:50 AM Will Deacon <will@kernel.org> wrote:
>

> The built-in kernel commandline (CONFIG_CMDLINE) can be configured in

> three different ways:

>

>   1. CMDLINE_FORCE: Use CONFIG_CMDLINE instead of any bootloader args

>   2. CMDLINE_EXTEND: Append the bootloader args to CONFIG_CMDLINE

>   3. CMDLINE_FROM_BOOTLOADER: Only use CONFIG_CMDLINE if there aren't

>      any bootloader args.

>

> The early cmdline parsing to detect idreg overrides gets (2) and (3)

> slightly wrong: in the case of (2) the bootloader args are parsed first

> and in the case of (3) the CMDLINE is always parsed.

>

> Fix these issues by moving the bootargs parsing out into a helper

> function and following the same logic as that used by the EFI stub.

>

> Reviewed-by: Marc Zyngier <maz@kernel.org>

> Fixes: 33200303553d ("arm64: cpufeature: Add an early command-line cpufeature override facility")

> Signed-off-by: Will Deacon <will@kernel.org>

> ---

>  arch/arm64/kernel/idreg-override.c | 44 +++++++++++++++++-------------

>  1 file changed, 25 insertions(+), 19 deletions(-)


It bothers me a bit having command line handling here. It means how
the command line is assembled in 2 places. I guess if we get rid of
ambiguous 'extend' then it's better, but perhaps a better
implementation would be an api get a specific command line parameter.
The main downside would be searching the DT again for each parameter
if we can't store any data in between calls, but there's ways around
that. PowerPC also needs similar functionality in
disabled_on_cmdline().

Anyways, that's all beyond the scope of this.

Rob
Will Deacon March 4, 2021, 9:33 a.m. UTC | #2
On Wed, Mar 03, 2021 at 04:30:21PM -0600, Rob Herring wrote:
> On Wed, Mar 3, 2021 at 7:50 AM Will Deacon <will@kernel.org> wrote:

> >

> > The built-in kernel commandline (CONFIG_CMDLINE) can be configured in

> > three different ways:

> >

> >   1. CMDLINE_FORCE: Use CONFIG_CMDLINE instead of any bootloader args

> >   2. CMDLINE_EXTEND: Append the bootloader args to CONFIG_CMDLINE

> >   3. CMDLINE_FROM_BOOTLOADER: Only use CONFIG_CMDLINE if there aren't

> >      any bootloader args.

> >

> > The early cmdline parsing to detect idreg overrides gets (2) and (3)

> > slightly wrong: in the case of (2) the bootloader args are parsed first

> > and in the case of (3) the CMDLINE is always parsed.

> >

> > Fix these issues by moving the bootargs parsing out into a helper

> > function and following the same logic as that used by the EFI stub.

> >

> > Reviewed-by: Marc Zyngier <maz@kernel.org>

> > Fixes: 33200303553d ("arm64: cpufeature: Add an early command-line cpufeature override facility")

> > Signed-off-by: Will Deacon <will@kernel.org>

> > ---

> >  arch/arm64/kernel/idreg-override.c | 44 +++++++++++++++++-------------

> >  1 file changed, 25 insertions(+), 19 deletions(-)

> 

> It bothers me a bit having command line handling here. It means how

> the command line is assembled in 2 places.


It's more than 2 places, it's also done in the EFI stub; see efi_pe_entry()
in drivers/firmware/efi/libstub/efi-stub.c. That's why I'm pushing on this,
because at the moment the command-line reported by /proc/cmdline doesn't
match the command-line that was parsed there because they stitch it together
in opposite orders when CMDLINE_EXTEND is used.

> I guess if we get rid of ambiguous 'extend' then it's better, but perhaps

> a better implementation would be an api get a specific command line

> parameter.  The main downside would be searching the DT again for each

> parameter if we can't store any data in between calls, but there's ways

> around that. PowerPC also needs similar functionality in

> disabled_on_cmdline().


Christophe's patches at least aim to put the assembling all in one place,
although we'll have to see whether or not it can be used in the EFI stub
environment.

Will
Will Deacon March 8, 2021, 2:40 p.m. UTC | #3
On Wed, 3 Mar 2021 13:49:25 +0000, Will Deacon wrote:
> This is version two of the series I previously posted here:

> 

> 	https://lore.kernel.org/r/20210225125921.13147-1-will@kernel.org

> 

> The main change since v1 is that, rather than "fix" the FDT code to

> follow the documented behaviour for CMDLINE_EXTEND, I've opted to remove

> the thing entirely for arm64 while a less ambiguous and generic

> replacement is developed, probably based on either [1] or [2].

> 

> [...]


Applied to arm64 (for-next/fixes), thanks!

[1/2] arm64: cpufeatures: Fix handling of CONFIG_CMDLINE for idreg overrides
      https://git.kernel.org/arm64/c/df304c2d0dfd
[2/2] arm64: Drop support for CMDLINE_EXTEND
      https://git.kernel.org/arm64/c/cae118b6acc3

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev