alternative.h (ff689fd21cb13098305bae3f8d0c0065df2e2fc1) alternative.h (a35707c3d850dda0ceefb75b1b3bd191921d5765)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2021 Sifive.
4 */
5
6#ifndef __ASM_ALTERNATIVE_H
7#define __ASM_ALTERNATIVE_H
8

--- 7 unchanged lines hidden (view full) ---

16
17#include <linux/init.h>
18#include <linux/types.h>
19#include <linux/stddef.h>
20#include <asm/hwcap.h>
21
22#define RISCV_ALTERNATIVES_BOOT 0 /* alternatives applied during regular boot */
23#define RISCV_ALTERNATIVES_MODULE 1 /* alternatives applied during module-init */
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2021 Sifive.
4 */
5
6#ifndef __ASM_ALTERNATIVE_H
7#define __ASM_ALTERNATIVE_H
8

--- 7 unchanged lines hidden (view full) ---

16
17#include <linux/init.h>
18#include <linux/types.h>
19#include <linux/stddef.h>
20#include <asm/hwcap.h>
21
22#define RISCV_ALTERNATIVES_BOOT 0 /* alternatives applied during regular boot */
23#define RISCV_ALTERNATIVES_MODULE 1 /* alternatives applied during module-init */
24#define RISCV_ALTERNATIVES_EARLY_BOOT 2 /* alternatives applied before mmu start */
24
25void __init apply_boot_alternatives(void);
25
26void __init apply_boot_alternatives(void);
27void __init apply_early_boot_alternatives(void);
26void apply_module_alternatives(void *start, size_t length);
27
28struct alt_entry {
29 void *old_ptr; /* address of original instruciton or data */
30 void *alt_ptr; /* address of replacement instruction or data */
31 unsigned long vendor_id; /* cpu vendor id */
32 unsigned long alt_len; /* The replacement size */
33 unsigned int errata_id; /* The errata id */
34} __packed;
35
36struct errata_checkfunc_id {
37 unsigned long vendor_id;
38 bool (*func)(struct alt_entry *alt);
39};
40
41void sifive_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
42 unsigned long archid, unsigned long impid,
43 unsigned int stage);
28void apply_module_alternatives(void *start, size_t length);
29
30struct alt_entry {
31 void *old_ptr; /* address of original instruciton or data */
32 void *alt_ptr; /* address of replacement instruction or data */
33 unsigned long vendor_id; /* cpu vendor id */
34 unsigned long alt_len; /* The replacement size */
35 unsigned int errata_id; /* The errata id */
36} __packed;
37
38struct errata_checkfunc_id {
39 unsigned long vendor_id;
40 bool (*func)(struct alt_entry *alt);
41};
42
43void sifive_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
44 unsigned long archid, unsigned long impid,
45 unsigned int stage);
46void thead_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
47 unsigned long archid, unsigned long impid,
48 unsigned int stage);
44
45void riscv_cpufeature_patch_func(struct alt_entry *begin, struct alt_entry *end,
46 unsigned int stage);
47
48#else /* CONFIG_RISCV_ALTERNATIVE */
49
50static inline void apply_boot_alternatives(void) { }
49
50void riscv_cpufeature_patch_func(struct alt_entry *begin, struct alt_entry *end,
51 unsigned int stage);
52
53#else /* CONFIG_RISCV_ALTERNATIVE */
54
55static inline void apply_boot_alternatives(void) { }
56static inline void apply_early_boot_alternatives(void) { }
51static inline void apply_module_alternatives(void *start, size_t length) { }
52
53#endif /* CONFIG_RISCV_ALTERNATIVE */
54
55#endif
56#endif
57static inline void apply_module_alternatives(void *start, size_t length) { }
58
59#endif /* CONFIG_RISCV_ALTERNATIVE */
60
61#endif
62#endif