Fix arm64 issues highlighted by sparse and smatch
Subsystems (7)
cover Fix arm64 issues highlighted by sparse and smatch
Hi all,
After the static checking talk at kernel summit, I felt empowered to go and run sparse and smatch over the arm64 defconfig. As I anticipated, this spotted a few issues in the arch code, so I've fixed up the ones that aren't just noise in this series. Most are simply incorrect address space annotations, but fixing these is useful for spotting real issues in the future.
I don't think any of these fix critical bugs, but they all deserve to be addressed. I tagged the compat watchpoint fix for stable, as that code has been broken since we merged the architecture port.
Cheers,
Will
--->8
Will Deacon (11):
KVM: ARM/arm64: fix non-const declaration of function returning const
KVM: ARM/arm64: fix broken __percpu annotation
KVM: ARM/arm64: avoid returning negative error code as bool
KVM: ARM/arm64: return -EFAULT if copy_from_user fails in
set_timer_reg
KVM: vgic: return int instead of bool when checking I/O ranges
KVM: vgic: declare probe function pointer as const
irqchip: gic: make gic_default_routable_irq_domain_ops static
irqchip: gic-v3: declare rdist as __percpu pointer to __iomem pointer
arm64: ptrace: fix compat hardware watchpoint reporting
arm64: ptrace: fix compat reg getter/setter return values
arm64: perf: don't rely on layout of pt_regs when grabbing sp or pc
arch/arm/include/asm/kvm_host.h | 2 +- arch/arm/kvm/arm.c | 2 +- arch/arm/kvm/coproc.c | 2 +- arch/arm/kvm/guest.c | 2 +- arch/arm64/include/asm/hw_breakpoint.h | 1 - arch/arm64/include/asm/kvm_host.h | 4 ++-- arch/arm64/kernel/perf_regs.c | 6 ++++++ arch/arm64/kernel/ptrace.c | 13 +++++++++---- arch/arm64/kvm/guest.c | 2 +- arch/arm64/kvm/sys_regs.c | 2 +- drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- virt/kvm/arm/vgic.c | 6 +++--- 13 files changed, 28 insertions(+), 18 deletions(-)
Signature · 1 line
2.1.0.rc1
PATCH 1/11 KVM: ARM/arm64: fix non-const declaration of function returning const
Sparse kicks up about a type mismatch for kvm_target_cpu:
arch/arm64/kvm/guest.c:271:25: error: symbol 'kvm_target_cpu' redeclared with different type (originally declared at ./arch/arm64/include/asm/kvm_host.h:45) - different modifiers
so fix this by adding the missing const attribute to the function declaration.
--- arch/arm/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/kvm_host.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/kvm_host.h +1 -1
@@ -42,7 +42,7 @@struct kvm_vcpu ;u32 *kvm_vcpu_reg (struct kvm_vcpu *vcpu,u8 reg_num,u32 mode); -int kvm_target_cpu (void ); +int __attribute_const__ kvm_target_cpu(void);int kvm_reset_vcpu (struct kvm_vcpu *vcpu);void kvm_reset_coprocs (struct kvm_vcpu *vcpu);
arch/arm64/include/asm/kvm_host.h +1 -1
@@ -42,7 +42,7 @@#define KVM_VCPU_MAX_FEATURES 3struct kvm_vcpu ; -int kvm_target_cpu (void ); +int __attribute_const__ kvm_target_cpu(void);int kvm_reset_vcpu (struct kvm_vcpu *vcpu);int kvm_arch_dev_ioctl_check_extension (long ext);
Signature · 1 line
2.1.0.rc1
PATCH 1/11 KVM: ARM/arm64: fix non-const declaration of function returning const
Quoted 10 lines · Will Deacon
Sparse kicks up about a type mismatch for
kvm_target_cpu:
arch/arm64/kvm/guest.c:271:25: error: symbol 'kvm_target_cpu' redeclared with different type (originally declared at./arch/arm64/include/asm/kvm_host.h:45) - different modifiersso fix this by adding the missing const attribute to the function declaration.
Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
M.
Quoted 32 lines
--- arch/arm/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/kvm_host.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/arm/include/asm/kvm_host.h +1
-1@@ -42,7 +42,7 @@struct kvm_vcpu ;u32 *kvm_vcpu_reg (struct kvm_vcpu *vcpu,u8 reg_num,u32 mode); -int kvm_target_cpu (void ); +int __attribute_const__ kvm_target_cpu(void);int kvm_reset_vcpu (struct kvm_vcpu *vcpu);void kvm_reset_coprocs (struct kvm_vcpu *vcpu);arch/arm64/include/asm/kvm_host.h +1
-1@@ -42,7 +42,7 @@#define KVM_VCPU_MAX_FEATURES 3struct kvm_vcpu ; -int kvm_target_cpu (void ); +int __attribute_const__ kvm_target_cpu(void);int kvm_reset_vcpu (struct kvm_vcpu *vcpu);int kvm_arch_dev_ioctl_check_extension (long ext);
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 1/11 KVM: ARM/arm64: fix non-const declaration of function returning const
In reply to Will DeaconQuoted 10 lines · Will Deacon
Sparse kicks up about a type mismatch for
kvm_target_cpu:
arch/arm64/kvm/guest.c:271:25: error: symbol 'kvm_target_cpu' redeclared with different type (originally declared at./arch/arm64/include/asm/kvm_host.h:45) - different modifiersso fix this by adding the missing const attribute to the function declaration.
Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
PATCH 2/11 KVM: ARM/arm64: fix broken __percpu annotation
In reply to Will DeaconRunning sparse results in a bunch of noisy address space mismatches thanks to the broken __percpu annotation on kvm_get_running_vcpus.
This function returns a pcpu pointer to a pointer, not a pointer to a pcpu pointer. This patch fixes the annotation, which kills the warnings from sparse.
--- arch/arm/kvm/arm.c | 2 +- arch/arm64/include/asm/kvm_host.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/kvm/arm.c +1 -1
@@ -82,7 +82,7 @@ struct kvm_vcpu *kvm_arm_get_running_vcpu(void)/** * kvm_arm_get_running_vcpus - get the per-CPU array of currently running vcpus. */ -struct kvm_vcpu __percpu **kvm_get_running_vcpus (void ) +struct kvm_vcpu *__percpu *kvm_get_running_vcpus (void ) {return &kvm_arm_running_vcpu; }
arch/arm64/include/asm/kvm_host.h +1 -1
@@ -193,7 +193,7 @@ static inline int kvm_test_age_hva(struct kvm *kvm, unsigned long hva) }struct kvm_vcpu *kvm_arm_get_running_vcpu (void ); -struct kvm_vcpu __percpu **kvm_get_running_vcpus (void ); +struct kvm_vcpu *__percpu *kvm_get_running_vcpus (void );u64 kvm_call_hyp (void *hypfn, ...);
Signature · 1 line
2.1.0.rc1
PATCH 2/11 KVM: ARM/arm64: fix broken __percpu annotation
Quoted 10 lines · Will Deacon
Running sparse results in a bunch of noisy address space mismatches thanks to the broken
__percpuannotation onkvm_get_running_vcpus.This function returns a pcpu pointer to a pointer, not a pointer to a pcpu pointer. This patch fixes the annotation, which kills the warnings from sparse.
Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
M..
Quoted 32 lines
--- arch/arm/kvm/arm.c | 2 +- arch/arm64/include/asm/kvm_host.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/arm/kvm/arm.c +1
-1@@ -82,7 +82,7 @@ struct kvm_vcpu *kvm_arm_get_running_vcpu(void)/** * kvm_arm_get_running_vcpus - get the per-CPU array of currently running vcpus. */ -struct kvm_vcpu __percpu **kvm_get_running_vcpus (void ) +struct kvm_vcpu *__percpu *kvm_get_running_vcpus (void ) {return &kvm_arm_running_vcpu; }arch/arm64/include/asm/kvm_host.h +1
-1@@ -193,7 +193,7 @@ static inline int kvm_test_age_hva(struct kvm *kvm, unsigned long hva) }struct kvm_vcpu *kvm_arm_get_running_vcpu (void ); -struct kvm_vcpu __percpu **kvm_get_running_vcpus (void ); +struct kvm_vcpu *__percpu *kvm_get_running_vcpus (void );u64 kvm_call_hyp (void *hypfn, ...);
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 3/11 KVM: ARM/arm64: avoid returning negative error code as bool
In reply to Will Deaconis_valid_cache returns true if the specified cache is valid. Unfortunately, if the parameter passed it out of range, we return -ENOENT, which ends up as true leading to potential hilarity.
This patch returns false on the failure path instead.
--- arch/arm/kvm/coproc.c | 2 +- arch/arm64/kvm/sys_regs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/kvm/coproc.c +1 -1
@@ -791,7 +791,7 @@ static bool is_valid_cache(u32 val)u32 level, ctype;if (val >=CSSELR_MAX ) -return -ENOENT ; +return false;/* Bottom bit is Instruction or Data bit. Next 3 bits are level. */ level = (val >>1 );
arch/arm64/kvm/sys_regs.c +1 -1
@@ -1218,7 +1218,7 @@ static bool is_valid_cache(u32 val)u32 level, ctype;if (val >=CSSELR_MAX ) -return -ENOENT ; +return false;/* Bottom bit is Instruction or Data bit. Next 3 bits are level. */ level = (val >>1 );
Signature · 1 line
2.1.0.rc1
PATCH 3/11 KVM: ARM/arm64: avoid returning negative error code as bool
Quoted 9 lines · Will Deacon
is_valid_cachereturns true if the specified cache is valid. Unfortunately, if the parameter passed it out of range, we return-ENOENT, which ends up as true leading to potential hilarity.This patch returns false on the failure path instead.
Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
With a brown paper bag on:
M.
Quoted 32 lines
--- arch/arm/kvm/coproc.c | 2 +- arch/arm64/kvm/sys_regs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/arm/kvm/coproc.c +1
-1@@ -791,7 +791,7 @@ static bool is_valid_cache(u32 val)u32 level, ctype;if (val >=CSSELR_MAX ) -return -ENOENT ; +return false;/* Bottom bit is Instruction or Data bit. Next 3 bits are level. */ level = (val >>1 );arch/arm64/kvm/sys_regs.c +1
-1@@ -1218,7 +1218,7 @@ static bool is_valid_cache(u32 val)u32 level, ctype;if (val >=CSSELR_MAX ) -return -ENOENT ; +return false;/* Bottom bit is Instruction or Data bit. Next 3 bits are level. */ level = (val >>1 );
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 3/11 KVM: ARM/arm64: avoid returning negative error code as bool
In reply to Will DeaconQuoted 9 lines · Will Deacon
is_valid_cachereturns true if the specified cache is valid. Unfortunately, if the parameter passed it out of range, we return-ENOENT, which ends up as true leading to potential hilarity.This patch returns false on the failure path instead.
Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
nice one!
PATCH 4/11 KVM: ARM/arm64: return -EFAULT if copy_from_user fails in set_timer_reg
In reply to Will DeaconWe currently return the number of bytes not copied if set_timer_reg fails, which is almost certainly not what userspace would like.
This patch returns -EFAULT instead.
--- arch/arm/kvm/guest.c | 2 +- arch/arm64/kvm/guest.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/kvm/guest.c +1 -1
@@ -163,7 +163,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) ret =copy_from_user (&val, uaddr,KVM_REG_SIZE (reg->id));if (ret !=0 ) -return ret; +return -EFAULT ;return kvm_arm_timer_set_reg (vcpu, reg->id, val); }
arch/arm64/kvm/guest.c +1 -1
@@ -174,7 +174,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) ret =copy_from_user (&val, uaddr,KVM_REG_SIZE (reg->id));if (ret !=0 ) -return ret; +return -EFAULT ;return kvm_arm_timer_set_reg (vcpu, reg->id, val); }
Signature · 1 line
2.1.0.rc1
PATCH 4/11 KVM: ARM/arm64: return -EFAULT if copy_from_user fails in set_timer_reg
Quoted 8 lines · Will Deacon
We currently return the number of bytes not copied if
set_timer_regfails, which is almost certainly not what userspace would like.This patch returns
-EFAULTinstead.Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
M.
Quoted 32 lines
--- arch/arm/kvm/guest.c | 2 +- arch/arm64/kvm/guest.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/arm/kvm/guest.c +1
-1@@ -163,7 +163,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) ret =copy_from_user (&val, uaddr,KVM_REG_SIZE (reg->id));if (ret !=0 ) -return ret; +return -EFAULT ;return kvm_arm_timer_set_reg (vcpu, reg->id, val); }arch/arm64/kvm/guest.c +1
-1@@ -174,7 +174,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) ret =copy_from_user (&val, uaddr,KVM_REG_SIZE (reg->id));if (ret !=0 ) -return ret; +return -EFAULT ;return kvm_arm_timer_set_reg (vcpu, reg->id, val); }
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 4/11 KVM: ARM/arm64: return -EFAULT if copy_from_user fails in set_timer_reg
In reply to Will DeaconQuoted 8 lines · Will Deacon
We currently return the number of bytes not copied if
set_timer_regfails, which is almost certainly not what userspace would like.This patch returns
-EFAULTinstead.Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
PATCH 5/11 KVM: vgic: return int instead of bool when checking I/O ranges
In reply to Will Deaconvgic_ioaddr_overlap claims to return a bool, but in reality it returns an int. Shut sparse up by fixing the type signature.
--- virt/kvm/arm/vgic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/arm/vgic.c +1 -1
@@ -1690,7 +1690,7 @@ out:return ret; } -static bool vgic_ioaddr_overlap (struct kvm *kvm) +static int vgic_ioaddr_overlap (struct kvm *kvm) {phys_addr_t dist = kvm->arch.vgic.vgic_dist_base;phys_addr_t cpu = kvm->arch.vgic.vgic_cpu_base;
Signature · 1 line
2.1.0.rc1
PATCH 5/11 KVM: vgic: return int instead of bool when checking I/O ranges
Quoted 6 lines · Will Deacon
vgic_ioaddr_overlapclaims to return a bool, but in reality it returns an int. Shut sparse up by fixing the type signature.Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
M.
Quoted 18 lines
--- virt/kvm/arm/vgic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)virt/kvm/arm/vgic.c +1
-1@@ -1690,7 +1690,7 @@ out:return ret; } -static bool vgic_ioaddr_overlap (struct kvm *kvm) +static int vgic_ioaddr_overlap (struct kvm *kvm) {phys_addr_t dist = kvm->arch.vgic.vgic_dist_base;phys_addr_t cpu = kvm->arch.vgic.vgic_cpu_base;
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 5/11 KVM: vgic: return int instead of bool when checking I/O ranges
In reply to Will DeaconQuoted 6 lines · Will Deacon
vgic_ioaddr_overlapclaims to return a bool, but in reality it returns an int. Shut sparse up by fixing the type signature.Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
PATCH 6/11 KVM: vgic: declare probe function pointer as const
In reply to Will DeaconWe extract the vgic probe function from the of_device_id data pointer, which is const. Kill the sparse warning by ensuring that the local function pointer is also marked as const.
--- virt/kvm/arm/vgic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
virt/kvm/arm/vgic.c +2 -2
@@ -1557,8 +1557,8 @@ static const struct of_device_id vgic_ids[] = {int kvm_vgic_hyp_init (void ) {const struct of_device_id *matched_id; -int (*vgic_probe)(struct device_node *,const struct vgic_ops **, -const struct vgic_params **); +const int (*vgic_probe)(struct device_node *,const struct vgic_ops **, +const struct vgic_params **);struct device_node *vgic_node;int ret;
Signature · 1 line
2.1.0.rc1
PATCH 6/11 KVM: vgic: declare probe function pointer as const
Quoted 6 lines · Will Deacon
We extract the vgic probe function from the
of_device_iddata pointer, which is const. Kill the sparse warning by ensuring that the local function pointer is also marked as const.Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
M.
Quoted 20 lines
--- virt/kvm/arm/vgic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)virt/kvm/arm/vgic.c +2
-2@@ -1557,8 +1557,8 @@ static const struct of_device_id vgic_ids[] = {int kvm_vgic_hyp_init (void ) {const struct of_device_id *matched_id; -int (*vgic_probe)(struct device_node *,const struct vgic_ops **, -const struct vgic_params **); +const int (*vgic_probe)(struct device_node *,const struct vgic_ops **, +const struct vgic_params **);struct device_node *vgic_node;int ret;
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 6/11 KVM: vgic: declare probe function pointer as const
In reply to Will DeaconQuoted 6 lines · Will Deacon
We extract the vgic probe function from the
of_device_iddata pointer, which is const. Kill the sparse warning by ensuring that the local function pointer is also marked as const.Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
PATCH 7/11 irqchip: gic: make gic_default_routable_irq_domain_ops static
In reply to Will DeaconThe internal irq domain ops for the GIC are not used directly anywhere else, so make them static. This gets rid of a sparse warning on the file.
--- drivers/irqchip/irq-gic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic.c +1 -1
@@ -867,7 +867,7 @@ static int gic_routable_irq_domain_xlate(struct irq_domain *d,return 0 ; } -const struct irq_domain_ops gic_default_routable_irq_domain_ops = { +static const struct irq_domain_ops gic_default_routable_irq_domain_ops = { .map = gic_routable_irq_domain_map, .unmap = gic_routable_irq_domain_unmap, .xlate = gic_routable_irq_domain_xlate,
Signature · 1 line
2.1.0.rc1
PATCH 7/11 irqchip: gic: make gic_default_routable_irq_domain_ops static
Quoted 7 lines · Will Deacon
The internal irq domain ops for the GIC are not used directly anywhere else, so make them static. This gets rid of a sparse warning on the file.
Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
M.
Quoted 18 lines
--- drivers/irqchip/irq-gic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/irqchip/irq-gic.c +1
-1@@ -867,7 +867,7 @@ static int gic_routable_irq_domain_xlate(struct irq_domain *d,return 0 ; } -const struct irq_domain_ops gic_default_routable_irq_domain_ops = { +static const struct irq_domain_ops gic_default_routable_irq_domain_ops = { .map = gic_routable_irq_domain_map, .unmap = gic_routable_irq_domain_unmap, .xlate = gic_routable_irq_domain_xlate,
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 8/11 irqchip: gic-v3: declare rdist as __percpu pointer to __iomem pointer
In reply to Will DeaconThe __percpu __iomem annotations on the rdist base are contradictory and confuse static checkers such as sparse.
This patch fixes the anotations so that rdist is described as a __percpu pointer to an __iomem pointer.
--- drivers/irqchip/irq-gic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +1 -1
@@ -36,7 +36,7 @@struct gic_chip_data {void __iomem *dist_base;void __iomem **redist_base; -void __percpu __iomem **rdist; +void __iomem *__percpu *rdist;struct irq_domain *domain;u64 redist_stride;u32 redist_regions;
Signature · 1 line
2.1.0.rc1
PATCH 8/11 irqchip: gic-v3: declare rdist as __percpu pointer to __iomem pointer
Quoted 9 lines · Will Deacon
The
__percpu__iomemannotations on the rdist base are contradictory and confuse static checkers such as sparse.This patch fixes the anotations so that rdist is described as a
__percpupointer to an__iomempointer.Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>
M.
Quoted 18 lines
--- drivers/irqchip/irq-gic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/irqchip/irq-gic-v3.c +1
-1@@ -36,7 +36,7 @@struct gic_chip_data {void __iomem *dist_base;void __iomem **redist_base; -void __percpu __iomem **rdist; +void __iomem *__percpu *rdist;struct irq_domain *domain;u64 redist_stride;u32 redist_regions;
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 9/11 arm64: ptrace: fix compat hardware watchpoint reporting
In reply to Will DeaconI'm not sure what I was on when I wrote this, but when iterating over the hardware watchpoint array (hbp_watch_array), our index is off by ARM_MAX_BRP, so we walk off the end of our thread_struct...
... except, a dodgy condition in the loop means that it never executes at all (bp cannot be NULL).
This patch fixes the code so that we remove the bp check and use the correct index for accessing the watchpoint structures.
--- arch/arm64/include/asm/hw_breakpoint.h | 1 - arch/arm64/kernel/ptrace.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/hw_breakpoint.h +0 -1
@@ -79,7 +79,6 @@ static inline void decode_ctrl_reg(u32 reg,*/ #define ARM_MAX_BRP 16#define ARM_MAX_WRP 16 -#define ARM_MAX_HBP_SLOTS (ARM_MAX_BRP + ARM_MAX_WRP)/* Virtual debug register bases. */ #define AARCH64_DBG_REG_BVR 0
arch/arm64/kernel/ptrace.c +2 -1
@@ -87,7 +87,8 @@ static void ptrace_hbptriggered(struct perf_event *bp,break ; } } -for (i =ARM_MAX_BRP ; i <ARM_MAX_HBP_SLOTS && !bp; ++i) { + +for (i =0 ; i <ARM_MAX_WRP ; ++i) {if (current->thread.debug.hbp_watch[i] == bp) { info.si_errno = -((i <<1 ) +1 );break ;
Signature · 1 line
2.1.0.rc1
PATCH 10/11 arm64: ptrace: fix compat reg getter/setter return values
In reply to Will Deaconcopy_{to,from}_user return the number of bytes remaining on failure, not an error code.
This patch returns -EFAULT when the copy operation didn't complete, rather than expose the number of bytes not copied directly to userspace.
--- arch/arm64/kernel/ptrace.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm64/kernel/ptrace.c +7 -3
@@ -663,8 +663,10 @@ static int compat_gpr_get(struct task_struct *target, kbuf +=sizeof (reg); }else { ret =copy_to_user (ubuf, ®,sizeof (reg)); -if (ret) +if (ret) { + ret = -EFAULT ;break ; + } ubuf +=sizeof (reg); }
@@ -702,8 +704,10 @@ static int compat_gpr_set(struct task_struct *target, kbuf +=sizeof (reg); }else { ret =copy_from_user (®, ubuf,sizeof (reg)); -if (ret) -return ret; +if (ret) { + ret = -EFAULT ; +break ; + } ubuf +=sizeof (reg); }
Signature · 1 line
2.1.0.rc1
PATCH 11/11 arm64: perf: don't rely on layout of pt_regs when grabbing sp or pc
In reply to Will DeaconThe current perf_regs code relies on sp and pc sitting just off the end of the pt_regs->regs array. This is ugly and fragile, so this patch checks for these register explicitly and returns the appropriate field.
--- arch/arm64/kernel/perf_regs.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/kernel/perf_regs.c +6 -0
@@ -24,6 +24,12 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)return regs->compat_lr; } +if ((u32 )idx ==PERF_REG_ARM64_SP ) +return regs->sp; + +if ((u32 )idx ==PERF_REG_ARM64_PC ) +return regs->pc; +return regs->regs[idx]; }
Signature · 1 line
2.1.0.rc1
PATCH 11/11 arm64: perf: don't rely on layout of pt_regs when grabbing sp or pc
Hi Will,
Quoted 3 lines · Will Deacon
The current
perf_regscode relies on sp and pc sitting just off the end of thept_regs->regsarray. This is ugly and fragile, so this patch checks for these register explicitly and returns the appropriate field.
That is correct but costs you some code to test the index.
Jean
Quoted 27 lines
Cc Jean Pihet <[email protected]>Signed-off-by Will Deacon <[email protected]>--- arch/arm64/kernel/perf_regs.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm64/kernel/perf_regs.c +6
-1@@ -24,6 +24,12 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)return regs->compat_lr; } +if ((u32 )idx ==PERF_REG_ARM64_SP ) +return regs->sp; + +if ((u32 )idx ==PERF_REG_ARM64_PC ) +return regs->pc; +return regs->regs[idx]; } --2.1.0.rc1
cover Fix arm64 issues highlighted by sparse and smatch
In reply to Will DeaconQuoted 9 lines · Will Deacon
Hi all,
After the static checking talk at kernel summit, I felt empowered to go and run sparse and smatch over the arm64 defconfig. As I anticipated, this spotted a few issues in the arch code, so I've fixed up the ones that aren't just noise in this series. Most are simply incorrect address space annotations, but fixing these is useful for spotting real issues in the future.
Quoted 4 lines
I don't think any of these fix critical bugs, but they all deserve to be addressed. I tagged the compat watchpoint fix for stable, as that code has been broken since we merged the architecture port.
Thanks for these!
Do you want me to queue the kvm ones or did you have other plans to upstream this entire series as one?
Also, do you consider these fixes for 3.17 (what about cc for stable in that case), or for 3.18?
-Christoffer
cover Fix arm64 issues highlighted by sparse and smatch
Hi Christoffer,
Quoted 10 lines · Christoffer Dall
Quoted 9 lines · Will Deacon
Hi all,
After the static checking talk at kernel summit, I felt empowered to go and run sparse and smatch over the arm64 defconfig. As I anticipated, this spotted a few issues in the arch code, so I've fixed up the ones that aren't just noise in this series. Most are simply incorrect address space annotations, but fixing these is useful for spotting real issues in the future.
Quoted 7 lines
Quoted 4 lines
I don't think any of these fix critical bugs, but they all deserve to be addressed. I tagged the compat watchpoint fix for stable, as that code has been broken since we merged the architecture port.
Do you want me to queue the kvm ones or did you have other plans to upstream this entire series as one?
They're all independent, so please take the kvm ones via your tree. I can send a separate pull if you prefer? Jason -- would you like an irqchip-specific pull for those?
Quoted 2 lines
Also, do you consider these fixes for 3.17 (what about cc for stable in that case), or for 3.18?
The only one I CC'd stable for was the compat ptrace watchpoint patch, because that's something that we've been getting wrong and will cause breakage with a 32-bit GDB. I don't consider the others urgent (i.e. happy if you wait until 3.18).
Cheers,
Will
Christoffer Dall
Appliedcover Fix arm64 issues highlighted by sparse and smatch
Quoted 25 lines · Will Deacon
Hi Christoffer,
Quoted 10 lines · Christoffer Dall
Quoted 9 lines · Will Deacon
Hi all,
After the static checking talk at kernel summit, I felt empowered to go and run sparse and smatch over the arm64 defconfig. As I anticipated, this spotted a few issues in the arch code, so I've fixed up the ones that aren't just noise in this series. Most are simply incorrect address space annotations, but fixing these is useful for spotting real issues in the future.
Quoted 7 lines
Quoted 4 lines
I don't think any of these fix critical bugs, but they all deserve to be addressed. I tagged the compat watchpoint fix for stable, as that code has been broken since we merged the architecture port.
Do you want me to queue the kvm ones or did you have other plans to upstream this entire series as one?
They're all independent, so please take the kvm ones via your tree. I can send a separate pull if you prefer? Jason -- would you like an irqchip-specific pull for those?
Quoted 8 lines
Quoted 2 lines
Also, do you consider these fixes for 3.17 (what about cc for stable in that case), or for 3.18?
The only one I CC'd stable for was the compat ptrace watchpoint patch, because that's something that we've been getting wrong and will cause breakage with a 32-bit GDB. I don't consider the others urgent (i.e. happy if you wait until 3.18).
Applied to queue, thanks.
-Christoffer
Jason Cooper
Appliedcover Fix arm64 issues highlighted by sparse and smatch
In reply to Will DeaconQuoted 23 lines · Will Deacon
Hi all,
After the static checking talk at kernel summit, I felt empowered to go and run sparse and smatch over the arm64 defconfig. As I anticipated, this spotted a few issues in the arch code, so I've fixed up the ones that aren't just noise in this series. Most are simply incorrect address space annotations, but fixing these is useful for spotting real issues in the future.
I don't think any of these fix critical bugs, but they all deserve to be addressed. I tagged the compat watchpoint fix for stable, as that code has been broken since we merged the architecture port.
Cheers,
Will
Cc Christoffer Dall <[email protected]>Cc Marc Zyngier <[email protected]>Cc Catalin Marinas <[email protected]>Cc Jason Cooper <[email protected]>Cc Jean Pihet <[email protected]>
Quoted 8 lines
--->8
Will Deacon (11):
irqchip: gic: makegic_default_routable_irq_domain_opsstatic
irqchip: gic-v3: declare rdist as__percpupointer to__iomempointerdrivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic.c | 2 +-
Applied to irqchip/urgent (yes, not urgent, but intended for the -rc's) with Marc's Ack's
thx,
Jason.