mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-09 02:51:11 +01:00
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Roman Zippel <[email protected]>
Cc: Jessica Yu <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Albert Ou <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Anton Ivanov <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Aurelien Jacquiot <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Cain <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Dave Jiang <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Greentime Hu <[email protected]>
Cc: Greg Ungerer <[email protected]>
Cc: Guan Xuetao <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Ira Weiny <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Jonas Bonn <[email protected]>
Cc: Keith Busch <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Mark Salter <[email protected]>
Cc: Martin KaFai Lau <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Nick Piggin <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Russell King <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Stafford Horne <[email protected]>
Cc: Stefan Kristiansson <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Vincent Chen <[email protected]>
Cc: Vishal Verma <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Yonghong Song <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
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 <[email protected]>, 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;
|
|
}
|