ce450ebf61
Patch series "sort out the flush_icache_range mess", v2.
flush_icache_range is mostly used for kernel address, except for the
following cases:
- the nommu brk and mmap implementations
- the read_code helper that is only used for binfmt_flat,
binfmt_elf_fdpic, and binfmt_aout including the broken
ia32 compat version
- binfmt_flat itself
none of which really are used by a typical MMU enabled kernel, as a.out
can only be build for alpha and m68k to start with.
But strangely enough commit ae92ef8a44
("PATCH] flush icache in
correct context") added a "set_fs(KERNEL_DS)" around the
flush_icache_range call in the module loader, because apparently m68k
assumed user pointers.
This series first cleans up the cacheflush implementations, largely by
switching as much as possible to the asm-generic version after a few
preparations, then moves the misnamed current flush_icache_user_range to
a new name, to finally introduce a real flush_icache_user_range to be
used for the above use cases to flush the instruction cache for a
userspace address range. The last patch then drops the set_fs in the
module code and moves it into the m68k implementation.
This patch (of 29):
The arguments passed look bogus, try to fix them to something that seems
to make sense.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Aurelien Jacquiot <jacquiot.aurelien@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Cain <bcain@codeaurora.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chris Zankel <chris@zankel.net>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greentime Hu <green.hu@gmail.com>
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmerdabbelt@google.com>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Richard Weinberger <richard@nod.at>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vincent Chen <deanbo422@gmail.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yonghong Song <yhs@fb.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Link: http://lkml.kernel.org/r/20200515143646.3857579-1-hch@lst.de
Link: http://lkml.kernel.org/r/20200515143646.3857579-2-hch@lst.de
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
166 lines
3.6 KiB
C
166 lines
3.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* linux/arch/arm/kernel/fiq.c
|
|
*
|
|
* Copyright (C) 1998 Russell King
|
|
* Copyright (C) 1998, 1999 Phil Blundell
|
|
*
|
|
* FIQ support written by Philip Blundell <philb@gnu.org>, 1998.
|
|
*
|
|
* FIQ support re-written by Russell King to be more generic
|
|
*
|
|
* We now properly support a method by which the FIQ handlers can
|
|
* be stacked onto the vector. We still do not support sharing
|
|
* the FIQ vector itself.
|
|
*
|
|
* Operation is as follows:
|
|
* 1. Owner A claims FIQ:
|
|
* - default_fiq relinquishes control.
|
|
* 2. Owner A:
|
|
* - inserts code.
|
|
* - sets any registers,
|
|
* - enables FIQ.
|
|
* 3. Owner B claims FIQ:
|
|
* - if owner A has a relinquish function.
|
|
* - disable FIQs.
|
|
* - saves any registers.
|
|
* - returns zero.
|
|
* 4. Owner B:
|
|
* - inserts code.
|
|
* - sets any registers,
|
|
* - enables FIQ.
|
|
* 5. Owner B releases FIQ:
|
|
* - Owner A is asked to reacquire FIQ:
|
|
* - inserts code.
|
|
* - restores saved registers.
|
|
* - enables FIQ.
|
|
* 6. Goto 3
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/cp15.h>
|
|
#include <asm/fiq.h>
|
|
#include <asm/irq.h>
|
|
#include <asm/traps.h>
|
|
|
|
#define FIQ_OFFSET ({ \
|
|
extern void *vector_fiq_offset; \
|
|
(unsigned)&vector_fiq_offset; \
|
|
})
|
|
|
|
static unsigned long dfl_fiq_insn;
|
|
static struct pt_regs dfl_fiq_regs;
|
|
|
|
/* Default reacquire function
|
|
* - we always relinquish FIQ control
|
|
* - we always reacquire FIQ control
|
|
*/
|
|
static int fiq_def_op(void *ref, int relinquish)
|
|
{
|
|
if (!relinquish) {
|
|
/* Restore default handler and registers */
|
|
local_fiq_disable();
|
|
set_fiq_regs(&dfl_fiq_regs);
|
|
set_fiq_handler(&dfl_fiq_insn, sizeof(dfl_fiq_insn));
|
|
local_fiq_enable();
|
|
|
|
/* FIXME: notify irq controller to standard enable FIQs */
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct fiq_handler default_owner = {
|
|
.name = "default",
|
|
.fiq_op = fiq_def_op,
|
|
};
|
|
|
|
static struct fiq_handler *current_fiq = &default_owner;
|
|
|
|
int show_fiq_list(struct seq_file *p, int prec)
|
|
{
|
|
if (current_fiq != &default_owner)
|
|
seq_printf(p, "%*s: %s\n", prec, "FIQ",
|
|
current_fiq->name);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void set_fiq_handler(void *start, unsigned int length)
|
|
{
|
|
void *base = vectors_page;
|
|
unsigned offset = FIQ_OFFSET;
|
|
|
|
memcpy(base + offset, start, length);
|
|
if (!cache_is_vipt_nonaliasing())
|
|
flush_icache_range((unsigned long)base + offset,
|
|
(unsigned long)base + offset + length);
|
|
flush_icache_range(0xffff0000 + offset, 0xffff0000 + offset + length);
|
|
}
|
|
|
|
int claim_fiq(struct fiq_handler *f)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (current_fiq) {
|
|
ret = -EBUSY;
|
|
|
|
if (current_fiq->fiq_op != NULL)
|
|
ret = current_fiq->fiq_op(current_fiq->dev_id, 1);
|
|
}
|
|
|
|
if (!ret) {
|
|
f->next = current_fiq;
|
|
current_fiq = f;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
void release_fiq(struct fiq_handler *f)
|
|
{
|
|
if (current_fiq != f) {
|
|
pr_err("%s FIQ trying to release %s FIQ\n",
|
|
f->name, current_fiq->name);
|
|
dump_stack();
|
|
return;
|
|
}
|
|
|
|
do
|
|
current_fiq = current_fiq->next;
|
|
while (current_fiq->fiq_op(current_fiq->dev_id, 0));
|
|
}
|
|
|
|
static int fiq_start;
|
|
|
|
void enable_fiq(int fiq)
|
|
{
|
|
enable_irq(fiq + fiq_start);
|
|
}
|
|
|
|
void disable_fiq(int fiq)
|
|
{
|
|
disable_irq(fiq + fiq_start);
|
|
}
|
|
|
|
EXPORT_SYMBOL(set_fiq_handler);
|
|
EXPORT_SYMBOL(__set_fiq_regs); /* defined in fiqasm.S */
|
|
EXPORT_SYMBOL(__get_fiq_regs); /* defined in fiqasm.S */
|
|
EXPORT_SYMBOL(claim_fiq);
|
|
EXPORT_SYMBOL(release_fiq);
|
|
EXPORT_SYMBOL(enable_fiq);
|
|
EXPORT_SYMBOL(disable_fiq);
|
|
|
|
void __init init_FIQ(int start)
|
|
{
|
|
unsigned offset = FIQ_OFFSET;
|
|
dfl_fiq_insn = *(unsigned long *)(0xffff0000 + offset);
|
|
get_fiq_regs(&dfl_fiq_regs);
|
|
fiq_start = start;
|
|
}
|