[PATCH v3 01/20] arm64: explicitly mask all exceptions

Julien Thierry julien.thierry at arm.com
Wed Oct 11 09:30:08 PDT 2017


Hi James,

On 05/10/17 20:17, James Morse wrote:
> There are a few places where we want to mask all exceptions. Today we
> do this in a piecemeal fashion, typically we expect the caller to
> have masked irqs and the arch code masks debug exceptions, ignoring
> SError which is probably masked.
> 
> Make it clear that 'mask all exceptions' is the intention by adding
> helpers to do exactly that.
> 
> This will let us unmask SError without having to add 'oh and SError'
> to these paths.
> 
> Signed-off-by: James Morse <james.morse at arm.com>
> 
> ---
> Remove the disable IRQs comment above cpu_die(): we return from idle via
> cpu_resume. This comment is confusing once the local_irq_disable() call
> is changed.
> 
>   arch/arm64/include/asm/assembler.h | 17 +++++++++++
>   arch/arm64/include/asm/daifflags.h | 59 ++++++++++++++++++++++++++++++++++++++
>   arch/arm64/kernel/hibernate.c      |  5 ++--
>   arch/arm64/kernel/machine_kexec.c  |  4 +--
>   arch/arm64/kernel/smp.c            |  9 ++----
>   arch/arm64/kernel/suspend.c        |  7 +++--
>   arch/arm64/kernel/traps.c          |  3 +-
>   arch/arm64/mm/proc.S               |  9 +++---
>   8 files changed, 94 insertions(+), 19 deletions(-)
>   create mode 100644 arch/arm64/include/asm/daifflags.h

[...]

> diff --git a/arch/arm64/include/asm/daifflags.h b/arch/arm64/include/asm/daifflags.h
> new file mode 100644
> index 000000000000..fb40da8e1457
> --- /dev/null
> +++ b/arch/arm64/include/asm/daifflags.h
> @@ -0,0 +1,59 @@
> +/*
> + * Copyright (C) 2017 ARM Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +#ifndef __ASM_DAIFFLAGS_H
> +#define __ASM_DAIFFLAGS_H
> +
> +#include <asm/irqflags.h>
> +#include <linux/irqflags.h>
> +
> +/* Mask/unmask/restore all exceptions, including interrupts. */
> +static inline unsigned long local_mask_daif(void)
> +{
> +	unsigned long flags;
> +	asm volatile(
> +		"mrs	%0, daif		// local_mask_daif\n"
> +		"msr	daifset, #0xf"
> +		: "=r" (flags)
> +		:
> +		: "memory");
> +	trace_hardirqs_off();
> +	return flags;
> +}
> +
nit:
Can we call this local_daif_save? (and maybe a version that only 
disables without saving?)

Also, I was wondering why use 'local' as prefix? Is there gonna be a 
similar set of function for arm that could be called by common code? 
(e.g. drivers?)

Otherwise:
Reviewed-by: Julien Thierry <julien.thierry at arm.com>

Cheers,

-- 
Julien Thierry



More information about the linux-arm-kernel mailing list