riscv: Ensure isa-ext static keys are writable
Subsystems (2)
PATCH 1/1 riscv: Ensure isa-ext static keys are writable
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit 8eb060e10185 ("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key to cpu_relax(), which kvm uses.
--- arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/cpufeature.c +1 -1
@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/**
Signature · 1 line
2.37.1
Quoted 11 lines · Andrew Jones
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")
Hey Drew,
How about adding:
Thanks,
Conor.
Quoted 18 lines
Signed-off-by Andrew Jones <[email protected]>--- arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +1
-1@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/**
Quoted 11 lines · Conor.Dooley at microchip.com
Quoted 10 lines · Andrew Jones
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.
Quoted 8 lines
Quoted 1 line
Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")Hey Drew,
How about adding:Reported-by Ron Economos <[email protected]>Reported-by Anup Patel <[email protected]>Reported-by Conor Dooley <[email protected]>
Sure, should I repost or can those be picked up when/if the patch is picked up?
Thanks,
drew
Quoted 22 lines
Thanks,
Conor.Quoted 18 lines
Signed-off-by Andrew Jones <[email protected]>--- arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +1
-1@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/**
Quoted 17 lines · Andrew Jones
Quoted 16 lines · Conor.Dooley at microchip.com
Quoted 11 lines · Andrew Jones
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")Hey Drew,
How about adding:
Quoted 6 lines
Quoted 3 lines
Reported-by Ron Economos <[email protected]>Reported-by Anup Patel <[email protected]>Reported-by Conor Dooley <[email protected]>Sure, should I repost or can those be picked up when/if the patch is picked up?
Oh god no, don't repost for that alone.
Sorry, should've specified.
Conor.
Quoted 31 lines
Thanks,
drewQuoted 17 lines
Thanks,
Conor.Quoted 13 lines
Signed-off-by Andrew Jones <[email protected]>--- arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +0
-0@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly;Quoted 5 lines
arch/riscv/kernel/cpufeature.c unsigned long elf_hwcap __read_mostly; · line 34
Quoted 5 lines
arch/riscv/kernel/cpufeature.c +1
-1-__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys,RISCV_ISA_EXT_KEY_MAX ); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys,RISCV_ISA_EXT_KEY_MAX );EXPORT_SYMBOL (riscv_isa_ext_keys);/** _______________________________________________
linux-riscv mailing list
linux-riscv at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 7 lines · Andrew Jones
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
Quoted 7 lines
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")Signed-off-by Andrew Jones <[email protected]>
Thanks for the fix!
Still got issues booting mainline on my D1, but this is no longer one of them :)
Quoted 20 lines
--- arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +1
-2@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/** -- 2.37.1
Quoted 21 lines · Andrew Jones
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")Signed-off-by Andrew Jones <[email protected]>--- arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +0
-0
arch/riscv/kernel/cpufeature.c unsigned long elf_hwcap __read_mostly; · line 34
Quoted 8 lines
arch/riscv/kernel/cpufeature.c +1
-1@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/**
Works good on HiFive Unmatched.
Quoted 34 lines · Andrew Jones
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")Signed-off-by Andrew Jones <[email protected]>--- arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +1
-2@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/** -- 2.37.1
Quoted 4 lines
--
kvm-riscv mailing list
kvm-riscv at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
Thanks for the quick fix. Tested with kvm guests booting in Qemu.
Signature · 2 lines
Regards, Atish
Palmer Dabbelt
maintainerQuoted 35 lines · atishp at atishpatra.org
Quoted 34 lines · Andrew Jones
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")Signed-off-by Andrew Jones <[email protected]>--- arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +1
-2@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/** -- 2.37.1
Quoted 8 lines
Quoted 4 lines
--
kvm-riscv mailing list
kvm-riscv at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscvThanks for the quick fix. Tested with kvm guests booting in Qemu.
Tested-by Atish Patra <[email protected]>
Thanks, I hadn't realized how static keys work but looks like having them as __ro_after_init was always bogus. Sorry to break stuff, looks like I should be loading some module (probably KVM, as it's in the defconfig) during testing.
This is on fixes, I'm planning on sending it up later this week.
Jisheng Zhang
Reviewed-byQuoted 36 lines · Palmer Dabbelt
Quoted 35 lines · atishp at atishpatra.org
Quoted 34 lines · Andrew Jones
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.Quoted 1 line
Quoted 1 line
Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")Signed-off-by Andrew Jones <[email protected]>Quoted 1 line
Quoted 1 line
---
arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +1
-2@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/** -- 2.37.1
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
--
kvm-riscv mailing list
kvm-riscv at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscvThanks for the quick fix. Tested with kvm guests booting in Qemu.
Tested-by Atish Patra <[email protected]>
Thanks for catching the bug in my code.
Quoted 3 lines
Thanks, I hadn't realized how static keys work but looks like having them as
__ro_after_initwas always bogus. Sorry to break stuff, looks like I should be
Sorry for breaking the static isa extension key usage in modules. It's a good idea to make them readonly, but need to cope with the usage in module properly. This may be a good improvement item.
Quoted 3 lines
loading some module (probably KVM, as it's in the defconfig) during testing.
This is on fixes, I'm planning on sending it up later this week.
Quoted 51 lines · Jisheng Zhang
Quoted 36 lines · Palmer Dabbelt
Quoted 35 lines · atishp at atishpatra.org
Quoted 34 lines · Andrew Jones
riscv_isa_ext_keys[] is an array of static keys used in the unified ISA extension framework. The keys added to this array may be used anywhere, including in modules. Ensure the keys remain writable by placing them in the data section.
The need to change riscv_isa_ext_keys[]'s section was found when the kvm module started failing to load. Commit
8eb060e10185("arch/riscv:
add Zihintpause support") adds a static branch check for a newly added isa-ext key tocpu_relax(), which kvm uses.Quoted 1 line
Quoted 1 line
Fixes c360cbec3511 ("riscv: introduce unified static key mechanism for ISA extensions")Signed-off-by Andrew Jones <[email protected]>Quoted 1 line
Quoted 1 line
---
arch/riscv/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpufeature.c +1
-2@@ -28,7 +28,7 @@ unsigned long elf_hwcap __read_mostly;/* Host ISA bitmap */ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; -__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX); +DEFINE_STATIC_KEY_ARRAY_FALSE (riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);EXPORT_SYMBOL (riscv_isa_ext_keys);/** -- 2.37.1
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
--
kvm-riscv mailing list
kvm-riscv at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscvThanks for the quick fix. Tested with kvm guests booting in Qemu.
Tested-by Atish Patra <[email protected]>Reviewed-by Jisheng Zhang <[email protected]>Thanks for catching the bug in my code.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Thanks, I hadn't realized how static keys work but looks like having them as
__ro_after_initwas always bogus. Sorry to break stuff, looks like I should beSorry for breaking the static isa extension key usage in modules. It's a good idea to make them readonly, but need to cope with the usage in module properly. This may be a good improvement item.
While some static keys do use __ro_after_init, they're almost all locally defined (static __ro_after_init). I see a few instances of __read_mostly global static key definitions, though. That may make sense for riscv_isa_ext_keys[] as well.
Thanks,
drew