From: Nicholas Piggin <npiggin@gmail.com> Date: 2017-05-11 11:24:55
Provide a dt_cpu_ftrs= cmdline option to disable the dt_cpu_ftrs CPU
feature discovery, and fall back to the "cputable" based version.
Also allow control of advertising unknown features to userspace and
with this parameter, and remove the clunky CONFIG option.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Documentation/admin-guide/kernel-parameters.txt | 10 ++++++
arch/powerpc/Kconfig | 5 ---
arch/powerpc/kernel/dt_cpu_ftrs.c | 41 +++++++++++++++++++------
3 files changed, 42 insertions(+), 14 deletions(-)
@@ -867,6 +867,16 @@ dscc4.setup= [NET]+ dt_cpu_ftrs= [PPC]+ Format: {"off" | "known"}+ Control how the dt_cpu_ftrs device-tree binding is+ used for CPU feature discovery and setup (if it+ exists).+ off: Do not use it, fall back to legacy cpu table.+ known: Do not pass through unknown features to guests+ or userspace, only those that the kernel is not aware+ of.+ dump_apple_properties [X86] Dump name and content of EFI device properties on x86 Macs. Useful for driver authors to determine
@@ -707,7 +719,7 @@ static bool __init cpufeatures_process_feature(struct dt_cpu_feature *f)}}-if(!known&&CPU_FEATURE_ENABLE_UNKNOWN){+if(!known&&dt_cpu_ftrs_enable_unknown){if(!feat_try_enable_unknown(f)){pr_info("not enabling: %s (unknown and unsupported by kernel)\n",f->name);
@@ -766,8 +778,6 @@ static int __init fdt_find_cpu_features(unsigned long node, const char *uname,return0;}-staticbool__initdatausing_dt_cpu_ftrs=false;-bool__initdt_cpu_ftrs_in_use(void){returnusing_dt_cpu_ftrs;
@@ -775,6 +785,16 @@ bool __init dt_cpu_ftrs_in_use(void)bool__initdt_cpu_ftrs_init(void*fdt){+if(!using_dt_cpu_ftrs){+/*+*Thisshouldneverhappenbecausethisrunsbefore+*early_praam,howeveriftheinitorderingchanges,+*testifearly_paramhasdisabledthis.+*/+returnfalse;+}+using_dt_cpu_ftrs=false;+/* Setup and verify the FDT, if it fails we just bail */if(!early_init_dt_verify(fdt))returnfalse;
@@ -1027,5 +1047,8 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const charvoid__initdt_cpu_ftrs_scan(void){+if(!using_dt_cpu_ftrs)+return;+of_scan_flat_dt(dt_cpu_ftrs_scan_callback,NULL);}
From: Paul Clarke <hidden> Date: 2017-05-11 13:25:54
On 05/11/2017 06:24 AM, Nicholas Piggin wrote:
Provide a dt_cpu_ftrs= cmdline option to disable the dt_cpu_ftrs CPU
feature discovery, and fall back to the "cputable" based version.
This boat has already sailed, I think, but "ftrs"? Was it too difficult to type "features"? This seems like something that should be easy and intuitive to find and understand.
:-)
PC
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-05-12 03:46:53
Paul Clarke [off-list ref] writes:
On 05/11/2017 06:24 AM, Nicholas Piggin wrote:
quoted
Provide a dt_cpu_ftrs= cmdline option to disable the dt_cpu_ftrs CPU
feature discovery, and fall back to the "cputable" based version.
This boat has already sailed, I think, but "ftrs"?
What you think vowels grow on trees! :)
Was it too difficult to type "features"?
For the command line option we could spell out features.
But should we also expand "dt", and "cpu" ?
device_tree_central_processing_unit_features=off
:P
This seems like something that should be easy and intuitive to find
and understand.
Maybe. Ideally no one will ever use it, certainly not end users, it's
primarily intended for developers doing bring-up.
cheers
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-05-15 09:43:10
Paul Clarke [off-list ref] writes:
On 05/11/2017 10:46 PM, Michael Ellerman wrote:
quoted
Paul Clarke [off-list ref] writes:
quoted
On 05/11/2017 06:24 AM, Nicholas Piggin wrote:
quoted
Provide a dt_cpu_ftrs= cmdline option to disable the dt_cpu_ftrs CPU
feature discovery, and fall back to the "cputable" based version.
This boat has already sailed, I think, but "ftrs"?
What you think vowels grow on trees! :)
At least you're using lower-case, which takes less space. ;-)
quoted
quoted
Was it too difficult to type "features"?
I see "ftrs" and think "footers".
"FTR" - the shouty version - has meant "feature" in the powerpc code
base since at least 2002.
So it may be a crappy abbreviation but it's at least consistent :)
cheers
@@ -775,6 +785,16 @@ bool __init dt_cpu_ftrs_in_use(void)bool__initdt_cpu_ftrs_init(void*fdt){+if(!using_dt_cpu_ftrs){+/*+*Thisshouldneverhappenbecausethisrunsbefore+*early_praam,howeveriftheinitorderingchanges,+*testifearly_paramhasdisabledthis.+*/+returnfalse;+}+using_dt_cpu_ftrs=false;+/* Setup and verify the FDT, if it fails we just bail */if(!early_init_dt_verify(fdt))returnfalse;
...
return true;
Because this runs before early_param(), as you mention,
dt_cpu_ftrs_init() returns true, which means we skip calling
identify_cpu().
So although passing dt_cpu_ftrs=off will skip the later logic, it
doesn't cause us to call identify_cpu() in early_setup() which it
should.
In practice it works because the base CPU spec that we initialise in
dt_cpu_ftrs.c is mostly OK, and skiboot also adds the cpu-version
property which causes us to call identify_cpu() again later, but that's
all a bit fragile IMHO.
So unfortunately I think we need to add logic in dt_cpu_ftrs_init() to
look for dt_cpu_ftrs=off on the command line.
The patch below seems to work, but would appreciate more eyes on it.
cheers
On Thu, 2017-05-11 at 21:24 +1000, Nicholas Piggin wrote:
quoted hunk
Provide a dt_cpu_ftrs= cmdline option to disable the dt_cpu_ftrs CPU
feature discovery, and fall back to the "cputable" based version.
Also allow control of advertising unknown features to userspace and
with this parameter, and remove the clunky CONFIG option.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Documentation/admin-guide/kernel-parameters.txt | 10 ++++++
arch/powerpc/Kconfig | 5 ---
arch/powerpc/kernel/dt_cpu_ftrs.c | 41 +++++++++++++++++++------
3 files changed, 42 insertions(+), 14 deletions(-)
@@ -867,6 +867,16 @@ dscc4.setup= [NET]+ dt_cpu_ftrs= [PPC]+ Format: {"off" | "known"}+ Control how the dt_cpu_ftrs device-tree binding is+ used for CPU feature discovery and setup (if it+ exists).+ off: Do not use it, fall back to legacy cpu table.+ known: Do not pass through unknown features to guests+ or userspace, only those that the kernel is not aware+ of.+ dump_apple_properties [X86] Dump name and content of EFI device properties on x86 Macs. Useful for driver authors to determine
@@ -775,6 +785,16 @@ bool __init dt_cpu_ftrs_in_use(void)bool__initdt_cpu_ftrs_init(void*fdt){+if(!using_dt_cpu_ftrs){+/*+*Thisshouldneverhappenbecausethisrunsbefore+*early_praam,howeveriftheinitorderingchanges,+*testifearly_paramhasdisabledthis.+*/+returnfalse;+}+using_dt_cpu_ftrs=false;+/* Setup and verify the FDT, if it fails we just bail */if(!early_init_dt_verify(fdt))returnfalse;
...
return true;
Because this runs before early_param(), as you mention,
dt_cpu_ftrs_init() returns true, which means we skip calling
identify_cpu().
So although passing dt_cpu_ftrs=off will skip the later logic, it
doesn't cause us to call identify_cpu() in early_setup() which it
should.
In practice it works because the base CPU spec that we initialise in
dt_cpu_ftrs.c is mostly OK, and skiboot also adds the cpu-version
property which causes us to call identify_cpu() again later, but that's
all a bit fragile IMHO.
Yeah that's a huge bug :P Good catch. Possible something would fail on
CPUs that aren't POWER8/9.
So unfortunately I think we need to add logic in dt_cpu_ftrs_init() to
look for dt_cpu_ftrs=off on the command line.
The patch below seems to work, but would appreciate more eyes on it.
I can't find a problem with it, but I don't know how this fdt/prom stuff
all fits together exactly. Why is early_cmdline_parse() using call_prom
for essentially the same thing?
Thanks,
Nick
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-05-30 05:32:54
Nicholas Piggin [off-list ref] writes:
On Mon, 29 May 2017 20:29:49 +1000
Michael Ellerman [off-list ref] wrote:
quoted
Nicholas Piggin [off-list ref] writes:
...
quoted
In practice it works because the base CPU spec that we initialise in
dt_cpu_ftrs.c is mostly OK, and skiboot also adds the cpu-version
property which causes us to call identify_cpu() again later, but that's
all a bit fragile IMHO.
Yeah that's a huge bug :P Good catch. Possible something would fail on
CPUs that aren't POWER8/9.
Yeah I had to hack a bit to make it fail because there's a few fallbacks
that save us - but yeah on something more different it would break.
quoted
So unfortunately I think we need to add logic in dt_cpu_ftrs_init() to
look for dt_cpu_ftrs=off on the command line.
The patch below seems to work, but would appreciate more eyes on it.
I can't find a problem with it, but I don't know how this fdt/prom stuff
all fits together exactly. Why is early_cmdline_parse() using call_prom
for essentially the same thing?
Yeah it's a mess.
early_cmdline_parse() is in prom_init.c, which is *totally* different to
prom.c, confusing much?
prom_init runs while OpenFirmware is still alive, so it calls OF (aka.
prom) for things, whereas prom.c is part of the kernel proper and only
has the flat device tree to use.
I'll squash this in and send a v2.
cheers
From: Michael Ellerman <hidden> Date: 2017-06-01 13:31:06
On Thu, 2017-05-11 at 11:24:41 UTC, Nicholas Piggin wrote:
Provide a dt_cpu_ftrs= cmdline option to disable the dt_cpu_ftrs CPU
feature discovery, and fall back to the "cputable" based version.
Also allow control of advertising unknown features to userspace and
with this parameter, and remove the clunky CONFIG option.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>