-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from sterling-teng/linux-6.6.y
LoongArch: Add kernel livepatching support
- Loading branch information
Showing
56 changed files
with
2,019 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
|
||
#ifndef _ORC_HEADER_H | ||
#define _ORC_HEADER_H | ||
|
||
#include <linux/types.h> | ||
#include <linux/compiler.h> | ||
#include <asm/orc_hash.h> | ||
|
||
/* | ||
* The header is currently a 20-byte hash of the ORC entry definition; see | ||
* scripts/orc_hash.sh. | ||
*/ | ||
#define ORC_HEADER \ | ||
__used __section(".orc_header") __aligned(4) \ | ||
static const u8 orc_header[] = { ORC_HASH } | ||
|
||
#endif /* _ORC_HEADER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
#ifndef _ORC_LOOKUP_H | ||
#define _ORC_LOOKUP_H | ||
|
||
/* | ||
* This is a lookup table for speeding up access to the .orc_unwind table. | ||
* Given an input address offset, the corresponding lookup table entry | ||
* specifies a subset of the .orc_unwind table to search. | ||
* | ||
* Each block represents the end of the previous range and the start of the | ||
* next range. An extra block is added to give the last range an end. | ||
* | ||
* The block size should be a power of 2 to avoid a costly 'div' instruction. | ||
* | ||
* A block size of 256 was chosen because it roughly doubles unwinder | ||
* performance while only adding ~5% to the ORC data footprint. | ||
*/ | ||
#define LOOKUP_BLOCK_ORDER 8 | ||
#define LOOKUP_BLOCK_SIZE (1 << LOOKUP_BLOCK_ORDER) | ||
|
||
#ifndef LINKER_SCRIPT | ||
|
||
extern unsigned int orc_lookup[]; | ||
extern unsigned int orc_lookup_end[]; | ||
|
||
#define LOOKUP_START_IP (unsigned long)_stext | ||
#define LOOKUP_STOP_IP (unsigned long)_etext | ||
|
||
#endif /* LINKER_SCRIPT */ | ||
|
||
#endif /* _ORC_LOOKUP_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
#ifndef _ORC_TYPES_H | ||
#define _ORC_TYPES_H | ||
|
||
#include <linux/types.h> | ||
|
||
/* | ||
* The ORC_REG_* registers are base registers which are used to find other | ||
* registers on the stack. | ||
* | ||
* ORC_REG_PREV_SP, also known as DWARF Call Frame Address (CFA), is the | ||
* address of the previous frame: the caller's SP before it called the current | ||
* function. | ||
* | ||
* ORC_REG_UNDEFINED means the corresponding register's value didn't change in | ||
* the current frame. | ||
* | ||
* The most commonly used base registers are SP and FP -- which the previous SP | ||
* is usually based on -- and PREV_SP and UNDEFINED -- which the previous FP is | ||
* usually based on. | ||
* | ||
* The rest of the base registers are needed for special cases like entry code | ||
* and GCC realigned stacks. | ||
*/ | ||
#define ORC_REG_UNDEFINED 0 | ||
#define ORC_REG_PREV_SP 1 | ||
#define ORC_REG_SP 2 | ||
#define ORC_REG_FP 3 | ||
#define ORC_REG_MAX 4 | ||
|
||
#define ORC_TYPE_UNDEFINED 0 | ||
#define ORC_TYPE_END_OF_STACK 1 | ||
#define ORC_TYPE_CALL 2 | ||
#define ORC_TYPE_REGS 3 | ||
#define ORC_TYPE_REGS_PARTIAL 4 | ||
|
||
#ifndef __ASSEMBLY__ | ||
/* | ||
* This struct is more or less a vastly simplified version of the DWARF Call | ||
* Frame Information standard. It contains only the necessary parts of DWARF | ||
* CFI, simplified for ease of access by the in-kernel unwinder. It tells the | ||
* unwinder how to find the previous SP and FP (and sometimes entry regs) on | ||
* the stack for a given code address. Each instance of the struct corresponds | ||
* to one or more code locations. | ||
*/ | ||
struct orc_entry { | ||
s16 sp_offset; | ||
s16 fp_offset; | ||
s16 ra_offset; | ||
unsigned int sp_reg:4; | ||
unsigned int fp_reg:4; | ||
unsigned int ra_reg:4; | ||
unsigned int type:3; | ||
unsigned int signal:1; | ||
}; | ||
#endif /* __ASSEMBLY__ */ | ||
|
||
#endif /* _ORC_TYPES_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _ASM_LOONGARCH_UNWIND_HINTS_H | ||
#define _ASM_LOONGARCH_UNWIND_HINTS_H | ||
|
||
#include <linux/objtool.h> | ||
#include <asm/orc_types.h> | ||
|
||
#ifdef __ASSEMBLY__ | ||
|
||
.macro UNWIND_HINT_UNDEFINED | ||
UNWIND_HINT type=UNWIND_HINT_TYPE_UNDEFINED | ||
.endm | ||
|
||
.macro UNWIND_HINT_END_OF_STACK | ||
UNWIND_HINT type=UNWIND_HINT_TYPE_END_OF_STACK | ||
.endm | ||
|
||
.macro UNWIND_HINT_REGS | ||
UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_REGS | ||
.endm | ||
|
||
.macro UNWIND_HINT_FUNC | ||
UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_CALL | ||
.endm | ||
|
||
#endif /* __ASSEMBLY__ */ | ||
|
||
#endif /* _ASM_LOONGARCH_UNWIND_HINTS_H */ |
Oops, something went wrong.