KVM: arm64: timers: Fix percpu address space issues in kvm_timer_hyp_init()
Subsystems (6)
PATCH 1/3 KVM: arm64: timers: Fix percpu address space issues in kvm_timer_hyp_init()
Cast return value from kvm_get_running_vcpus() in the __percpu address space to the generic address space via uintptr_t [1] to fix a couple of:
arch_timer.c:1395:66: warning: incorrect type in argument 2 (different address spaces)
arch_timer.c:1395:66: expected void *vcpu_info
arch_timer.c:1395:66: got struct kvm_vcpu *[noderef] __percpu *
sparse warnings.
There were no changes in the resulting object files.
[1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name
--- arch/arm64/kvm/arch_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/arch_timer.c +2 -2
@@ -1392,7 +1392,7 @@ int __init kvm_timer_hyp_init(bool has_gic)if (has_gic) { err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;
@@ -1416,7 +1416,7 @@ int __init kvm_timer_hyp_init(bool has_gic)if (has_gic) { err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_ptimer_irq;
Signature · 1 line
2.42.0
PATCH 2/3 irqchip/gic: Correct declaration of *percpu_base pointer in union gic_base
percpu_base is used in various percpu functions that expect variable in __percpu address space. Correct the declaration of percpu_base to
void __iomem * __percpu *percpu_base;
to declare the variable as __percpu pointer.
The patch fixes several sparse warnings:
irq-gic.c:1172:44: warning: incorrect type in assignment (different address spaces)
irq-gic.c:1172:44: expected void [noderef] __percpu *[noderef] __iomem *percpu_base
irq-gic.c:1172:44: got void [noderef] __iomem *[noderef] __percpu *
...
irq-gic.c:1184:26: warning: incorrect type in initializer (different address spaces)
irq-gic.c:1184:26: expected void const [noderef] __percpu *__vpp_verify
irq-gic.c:1184:26: got void [noderef] __percpu *[noderef] __iomem *
...
irq-gic.c:1184:71: warning: incorrect type in assignment (different address spaces)
irq-gic.c:1184:71: expected void [noderef] __percpu *
irq-gic.c:1184:71: got void [noderef] __iomem *
...
irq-gic.c:1231:43: warning: incorrect type in argument 1 (different address spaces)
irq-gic.c:1231:43: expected void [noderef] __percpu *__pdata
irq-gic.c:1231:43: got void [noderef] __percpu *[noderef] __iomem *percpu_base
There were no changes in the resulting object files.
--- drivers/irqchip/irq-gic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic.c +1 -1
@@ -64,7 +64,7 @@ static void gic_check_cpu_features(void)union gic_base {void __iomem *common_base; -void __percpu *__iomem *percpu_base; +void __iomem *__percpu *percpu_base; };struct gic_chip_data {
Signature · 1 line
2.42.0
Re: [PATCH 2/3] irqchip/gic: Correct declaration of *percpu_base pointer in union gic_base
Quoted 40 lines · Uros Bizjak
percpu_baseis used in various percpu functions that expect variable in__percpuaddress space. Correct the declaration ofpercpu_basetovoid
__iomem*__percpu*percpu_base;to declare the variable as
__percpupointer.The patch fixes several sparse warnings:
irq-gic.c:1172:44: warning: incorrect type in assignment (different address spaces)
irq-gic.c:1172:44: expected void [noderef]__percpu*[noderef]__iomem*percpu_base
irq-gic.c:1172:44: got void [noderef]__iomem*[noderef]__percpu*
...
irq-gic.c:1184:26: warning: incorrect type in initializer (different address spaces)
irq-gic.c:1184:26: expected void const [noderef]__percpu*__vpp_verify
irq-gic.c:1184:26: got void [noderef]__percpu*[noderef]__iomem*
...
irq-gic.c:1184:71: warning: incorrect type in assignment (different address spaces)
irq-gic.c:1184:71: expected void [noderef]__percpu*
irq-gic.c:1184:71: got void [noderef]__iomem*
...
irq-gic.c:1231:43: warning: incorrect type in argument 1 (different address spaces)
irq-gic.c:1231:43: expected void [noderef]__percpu*__pdata
irq-gic.c:1231:43: got void [noderef]__percpu*[noderef]__iomem*percpu_baseThere were no changes in the resulting object files.
Signed-off-by Uros Bizjak <[email protected]>Cc Marc Zyngier <[email protected]>Cc Thomas Gleixner <[email protected]>--- drivers/irqchip/irq-gic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/irqchip/irq-gic.c +0
-0
drivers/irqchip/irq-gic.c static void gic_check_cpu_features(void) · line 70
Quoted 8 lines
drivers/irqchip/irq-gic.c +1
-1@@ -64,7 +64,7 @@ static void gic_check_cpu_features(void)union gic_base {void __iomem *common_base; -void __percpu *__iomem *percpu_base; +void __iomem *__percpu *percpu_base; };struct gic_chip_data {
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
[tip: irq/urgent] irqchip/gic: Correct declaration of *percpu_base pointer in union gic_base
In reply to Uros BizjakThe following commit has been merged into the irq/urgent branch of tip:
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: a1855f1b7c33642c9f7a01991fb763342a312e9b Gitweb: https://git.kernel.org/tip/a1855f1b7c33642c9f7a01991fb763342a312e9b Author: Uros Bizjak <[email protected]> AuthorDate: Fri, 13 Dec 2024 15:57:53 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Fri, 13 Dec 2024 18:11:52 +01:00
irqchip/gic: Correct declaration of *percpu_base pointer in union gic_base
percpu_base is used in various percpu functions that expect variable in __percpu address space. Correct the declaration of percpu_base to
void __iomem * __percpu *percpu_base;
to declare the variable as __percpu pointer.
The patch fixes several sparse warnings:
irq-gic.c:1172:44: warning: incorrect type in assignment (different address spaces)
irq-gic.c:1172:44: expected void [noderef] __percpu *[noderef] __iomem *percpu_base
irq-gic.c:1172:44: got void [noderef] __iomem *[noderef] __percpu *
...
irq-gic.c:1231:43: warning: incorrect type in argument 1 (different address spaces)
irq-gic.c:1231:43: expected void [noderef] __percpu *__pdata
irq-gic.c:1231:43: got void [noderef] __percpu *[noderef] __iomem *percpu_base
There were no changes in the resulting object files.
--- drivers/irqchip/irq-gic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic.c +1 -1
@@ -64,7 +64,7 @@ static void gic_check_cpu_features(void)union gic_base {void __iomem *common_base; -void __percpu *__iomem *percpu_base; +void __iomem *__percpu *percpu_base; };struct gic_chip_data {
PATCH 3/3 mailbox: zynqmp: Remove invalid __percpu annotation in zynqmp_ipi_probe()
In reply to Uros Bizjakstruct zynqmp_ipi_pdata __percpu *pdata is not a per-cpu variable, so it shoul not be annotated with __percpu annotation.
Remove invalid __percpu annotation to fix several
zynqmp-ipi-mailbox.c:920:15: warning: incorrect type in assignment (different address spaces)
zynqmp-ipi-mailbox.c:920:15: expected struct zynqmp_ipi_pdata [noderef] __percpu *pdata
zynqmp-ipi-mailbox.c:920:15: got void *
zynqmp-ipi-mailbox.c:927:56: warning: incorrect type in argument 3 (different address spaces)
zynqmp-ipi-mailbox.c:927:56: expected unsigned int [usertype] *out_value
zynqmp-ipi-mailbox.c:927:56: got unsigned int [noderef] __percpu *
...
and several
drivers/mailbox/zynqmp-ipi-mailbox.c:924:9: warning: dereference of noderef expression
...
sparse warnings.
There were no changes in the resulting object files.
--- drivers/mailbox/zynqmp-ipi-mailbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/zynqmp-ipi-mailbox.c +1 -1
@@ -905,7 +905,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct device_node *nc, *np = pdev->dev.of_node; -struct zynqmp_ipi_pdata __percpu *pdata; +struct zynqmp_ipi_pdata *pdata;struct of_phandle_args out_irq;struct zynqmp_ipi_mbox *mbox;int num_mboxes, ret = -EINVAL ;
Signature · 1 line
2.42.0
Michal Simek
maintainerRe: [PATCH 3/3] mailbox: zynqmp: Remove invalid __percpu annotation in zynqmp_ipi_probe()
Quoted 2 lines · Uros Bizjak
struct
zynqmp_ipi_pdata__percpu*pdata is not a per-cpu variable, so it shoul not be annotated with__percpuannotation.
typo here.
Quoted 32 lines
Remove invalid
__percpuannotation to fix severalzynqmp-ipi-mailbox.c:920:15: warning: incorrect type in assignment (different address spaces)
zynqmp-ipi-mailbox.c:920:15: expected structzynqmp_ipi_pdata[noderef]__percpu*pdata
zynqmp-ipi-mailbox.c:920:15: got void *
zynqmp-ipi-mailbox.c:927:56: warning: incorrect type in argument 3 (different address spaces)
zynqmp-ipi-mailbox.c:927:56: expected unsigned int [usertype]*out_value
zynqmp-ipi-mailbox.c:927:56: got unsigned int [noderef]__percpu*
...and several
drivers/mailbox/zynqmp-ipi-mailbox.c:924:9: warning: dereference of noderef expression
...sparse warnings.
There were no changes in the resulting object files.
Signed-off-by Uros Bizjak <[email protected]>Cc Jassi Brar <[email protected]>Cc Michal Simek <[email protected]>--- drivers/mailbox/zynqmp-ipi-mailbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mailbox/zynqmp-ipi-mailbox.c +0
-0
drivers/mailbox/zynqmp-ipi-mailbox.c static int zynqmp_ipi_probe(struct platform_device *pdev) · line 911
Quoted 8 lines
drivers/mailbox/zynqmp-ipi-mailbox.c +1
-1@@ -905,7 +905,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct device_node *nc, *np = pdev->dev.of_node; -struct zynqmp_ipi_pdata __percpu *pdata; +struct zynqmp_ipi_pdata *pdata;struct of_phandle_args out_irq;struct zynqmp_ipi_mbox *mbox;int num_mboxes, ret = -EINVAL ;
Feel free to also find commit which introduced this issue and add Fixes and cc: stable to v2.
Thanks,
Michal
Marc Zyngier
maintainerQuoted 41 lines · Uros Bizjak
Cast return value from
kvm_get_running_vcpus()in the__percpuaddress space to the generic address space viauintptr_t[1] to fix a couple of:arch_timer.c:1395:66: warning: incorrect type in argument 2 (different address spaces)
arch_timer.c:1395:66: expected void*vcpu_info
arch_timer.c:1395:66: got structkvm_vcpu*[noderef]__percpu*sparse warnings.
There were no changes in the resulting object files.
[1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name
Signed-off-by Uros Bizjak <[email protected]>Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc Joey Gouly <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Zenghui Yu <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kvm/arch_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kvm/arch_timer.c +1
-1@@ -1392,7 +1392,7 @@ int __init kvm_timer_hyp_init(bool has_gic)if (has_gic) { err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;
arch/arm64/kvm/arch_timer.c int __init kvm_timer_hyp_init(bool has_gic) · line 1422
Quoted 8 lines
arch/arm64/kvm/arch_timer.c +1
-1@@ -1416,7 +1416,7 @@ int __init kvm_timer_hyp_init(bool has_gic)if (has_gic) { err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_ptimer_irq;
I think the fix is worse than the current code, because there is no real semantics behind the pointer being passed to irq_set_vcpu_affinity(). All that is required is that it is a non-NULL pointer.
I expect the following hack to work just as well and not suffer from any sparse indigestion. Untested though.
M.
arch/arm64/kvm/arch_timer.c +2 -4
@@ -1391,8 +1391,7 @@ int __init kvm_timer_hyp_init(bool has_gic) }if (has_gic) { - err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + err =irq_set_vcpu_affinity (host_vtimer_irq, info);if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;
@@ -1415,8 +1414,7 @@ int __init kvm_timer_hyp_init(bool has_gic) }if (has_gic) { - err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + err =irq_set_vcpu_affinity (host_ptimer_irq, info);if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_ptimer_irq;
Signature · 1 line
Without deviation from the norm, progress is not possible.
Uros Bizjak
Acked-byQuoted 58 lines · Marc Zyngier
Quoted 41 lines · Uros Bizjak
Cast return value from
kvm_get_running_vcpus()in the__percpuaddress space to the generic address space viauintptr_t[1] to fix a couple of:arch_timer.c:1395:66: warning: incorrect type in argument 2 (different address spaces)
arch_timer.c:1395:66: expected void*vcpu_info
arch_timer.c:1395:66: got structkvm_vcpu*[noderef]__percpu*sparse warnings.
There were no changes in the resulting object files.
[1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name
Signed-off-by Uros Bizjak <[email protected]>Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc Joey Gouly <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Zenghui Yu <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kvm/arch_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kvm/arch_timer.c +1
-1@@ -1392,7 +1392,7 @@ int __init kvm_timer_hyp_init(bool has_gic)if (has_gic) { err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;arch/arm64/kvm/arch_timer.c int __init kvm_timer_hyp_init(bool has_gic) · line 1422
Quoted 8 lines
arch/arm64/kvm/arch_timer.c +1
-1@@ -1416,7 +1416,7 @@ int __init kvm_timer_hyp_init(bool has_gic)if (has_gic) { err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_ptimer_irq;I think the fix is worse than the current code, because there is no real semantics behind the pointer being passed to
irq_set_vcpu_affinity(). All that is required is that it is a non-NULL pointer.
Quoted 2 lines
I expect the following hack to work just as well and not suffer from any sparse indigestion. Untested though.
The proposed hack also fixes sparse warnings and fixes my percpu checker errors, but as a functional change, I have no means of testing the proposed change on a target processor. So, I can just give:
from a percpu checker perspective.
Thanks,
Uros.
Quoted 45 lines · Marc Zyngier
Quoted 42 lines · Uros Bizjak
Cast return value from
kvm_get_running_vcpus()in the__percpuaddress space to the generic address space viauintptr_t[1] to fix a couple of:arch_timer.c:1395:66: warning: incorrect type in argument 2 (different address spaces)
arch_timer.c:1395:66: expected void*vcpu_info
arch_timer.c:1395:66: got structkvm_vcpu*[noderef]__percpu*sparse warnings.
There were no changes in the resulting object files.
[1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name
Signed-off-by Uros Bizjak <[email protected]>Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc Joey Gouly <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Zenghui Yu <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kvm/arch_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kvm/arch_timer.c +1
-1@@ -1392,7 +1392,7 @@ int __init kvm_timer_hyp_init(bool has_gic)if (has_gic) { err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;@@ -1416,7 +1416,7 @@ int __init kvm_timer_hyp_init(bool has_gic)
Quoted 12 lines
arch/arm64/kvm/arch_timer.c int __init kvm_timer_hyp_init(bool has_gic) · line 1422
Quoted 7 lines
arch/arm64/kvm/arch_timer.c +1
-1if (has_gic) { err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_ptimer_irq;I think the fix is worse than the current code, because there is no real semantics behind the pointer being passed to
irq_set_vcpu_affinity(). All that is required is that it is a non-NULL pointer.
If this is the case, we can just remove dependence on the pointer in the called function.
Something like in the attached patch.
Uros.
Quoted 31 lines
I expect the following hack to work just as well and not suffer from any sparse indigestion. Untested though.
M.arch/arm64/kvm/arch_timer.c +2
-5@@ -1391,8 +1391,7 @@ int __init kvm_timer_hyp_init(bool has_gic) }if (has_gic) { - err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + err =irq_set_vcpu_affinity (host_vtimer_irq, info);if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;@@ -1415,8 +1414,7 @@ int __init kvm_timer_hyp_init(bool has_gic) }if (has_gic) { - err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + err =irq_set_vcpu_affinity (host_ptimer_irq, info);if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_ptimer_irq; --
Quoted 1 line
Without deviation from the norm, progress is not possible.
arch/arm64/kvm/arch_timer.c +5 -9
@@ -1238,12 +1238,10 @@ void kvm_arm_timer_write_sysreg(struct kvm_vcpu *vcpu, } } -static int timer_irq_set_vcpu_affinity (struct irq_data *d,void *vcpu) +static int timer_irq_set_vcpu_affinity (struct irq_data *d, +void __always_unused *vcpu) { -if (vcpu) -irqd_set_forwarded_to_vcpu (d); -else -irqd_clr_forwarded_to_vcpu (d); +irqd_set_forwarded_to_vcpu (d);return 0 ; }
@@ -1391,8 +1389,7 @@ int __init kvm_timer_hyp_init(bool has_gic) }if (has_gic) { - err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + err =irq_set_vcpu_affinity (host_vtimer_irq,NULL );if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;
@@ -1415,8 +1412,7 @@ int __init kvm_timer_hyp_init(bool has_gic) }if (has_gic) { - err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + err =irq_set_vcpu_affinity (host_ptimer_irq,NULL );if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_ptimer_irq;
Marc Zyngier
maintainerQuoted 60 lines · Uros Bizjak
Quoted 45 lines · Marc Zyngier
Quoted 42 lines · Uros Bizjak
Cast return value from
kvm_get_running_vcpus()in the__percpuaddress space to the generic address space viauintptr_t[1] to fix a couple of:arch_timer.c:1395:66: warning: incorrect type in argument 2 (different address spaces)
arch_timer.c:1395:66: expected void*vcpu_info
arch_timer.c:1395:66: got structkvm_vcpu*[noderef]__percpu*sparse warnings.
There were no changes in the resulting object files.
[1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name
Signed-off-by Uros Bizjak <[email protected]>Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc Joey Gouly <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Zenghui Yu <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kvm/arch_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kvm/arch_timer.c +1
-1@@ -1392,7 +1392,7 @@ int __init kvm_timer_hyp_init(bool has_gic)if (has_gic) { err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;@@ -1416,7 +1416,7 @@ int __init kvm_timer_hyp_init(bool has_gic)Quoted 12 lines
arch/arm64/kvm/arch_timer.c int __init kvm_timer_hyp_init(bool has_gic) · line 1418
Quoted 7 lines
arch/arm64/kvm/arch_timer.c +1
-1if (has_gic) { err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + (void *)(uintptr_t )kvm_get_running_vcpus ());if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_ptimer_irq;I think the fix is worse than the current code, because there is no real semantics behind the pointer being passed to
irq_set_vcpu_affinity(). All that is required is that it is a non-NULL pointer.
Quoted 2 lines
If this is the case, we can just remove dependence on the pointer in the called function.
No, we can't.
Quoted 2 lines
Something like in the attached patch.
[...]
Quoted 31 lines
arch/arm64/kvm/arch_timer.c +4
-7@@ -1238,12 +1238,10 @@ void kvm_arm_timer_write_sysreg(struct kvm_vcpu *vcpu, } } -static int timer_irq_set_vcpu_affinity (struct irq_data *d,void *vcpu) +static int timer_irq_set_vcpu_affinity (struct irq_data *d, +void __always_unused *vcpu) { -if (vcpu) -irqd_set_forwarded_to_vcpu (d); -else -irqd_clr_forwarded_to_vcpu (d); +irqd_set_forwarded_to_vcpu (d);return 0 ; }@@ -1391,8 +1389,7 @@ int __init kvm_timer_hyp_init(bool has_gic) }if (has_gic) { - err =irq_set_vcpu_affinity (host_vtimer_irq, -kvm_get_running_vcpus ()); + err =irq_set_vcpu_affinity (host_vtimer_irq,NULL );if (err) {kvm_err ("kvm_arch_timer: error setting vcpu affinity\n" ); goto out_free_vtimer_irq;
arch/arm64/kvm/arch_timer.c int __init kvm_timer_hyp_init(bool has_gic) · line 1415
Quoted 6 lines
arch/arm64/kvm/arch_timer.c +1
-2@@ -1415,8 +1412,7 @@ int __init kvm_timer_hyp_init(bool has_gic) }if (has_gic) { - err =irq_set_vcpu_affinity (host_ptimer_irq, -kvm_get_running_vcpus ()); + err =irq_set_vcpu_affinity (host_ptimer_irq,NULL );
And now you breaking everything by ignoring the semantics of irq_set_vcpu_affinity(), which uses a NULL pointer to *stop* the forwarding.
Congratulations, KVM doesn't work anymore, except on systems such as the Apple stuff (which are the only systems requiring the timer_irq_set_vcpu_affinity() hack). Just look at what the irqchips are implementing to convince yourself.
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.