Skip to content

Allow calls in alternatives

Heiko Stuebner linux-riscv 6 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 posting 2/25 patches 36 repliesIn review
  2. v5 Latest12 patches 1 replyApplied 12/12
  3. v4 posting 1/212 patches 22 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v314 patches27 repliesSuperseded
v213 patches34 repliesSuperseded
v17 patches43 repliesSuperseded

Changes in v5 from the cover letter

- while people reporting nits for v4 mentioned that it wouldn't be necessary to respin for each, the number of them the series received waranted a respin I think
- split riscv_insn_insert_utype_itype_imm parameters into separate utype + itype u32 pointer (Andrew)
- use u32 instead of unsigned int in riscv_instruction_at (Jess)
- rename instruction params in riscv_alternative_fix_auipc_jalr make their content obvious (Andrew)
- standardize on insn for instruction-related variables (Conor)
- make comment about ra register check more explicit (Conor)

Patches in v5 All 12 applied

#Subject and filesSizeRepliesApplied
1/12RISC-V: fix funct4 definition for c.jalr in parse_asm.harch/riscv/include/asm/parse_asm.h+1 -10 repliesApplied
2/12RISC-V: add prefix to all constants/macros in parse_asm.harch/riscv/include/asm/parse_asm.h arch/riscv/kernel/kgdb.c+117 -1170 repliesApplied
3/12RISC-V: detach funct-values from their offsetarch/riscv/include/asm/parse_asm.h+59 -410 repliesApplied
4/12RISC-V: add ebreak instructions to definitionsarch/riscv/include/asm/parse_asm.h+6 -00 repliesApplied
5/12RISC-V: add auipc elements to parse_asm headerarch/riscv/include/asm/parse_asm.h+3 -00 repliesApplied
6/12RISC-V: Move riscv_insn_is_* macros into a common headerarch/riscv/include/asm/parse_asm.h arch/riscv/kernel/kgdb.c arch/riscv/kernel/probes/simulate-insn.h+55 -620 repliesApplied
7/12RISC-V: rename parse_asm.h to insn.harch/riscv/include/asm/insn.h arch/riscv/kernel/kgdb.c arch/riscv/kernel/probes/simulate-insn.h+2 -20 repliesApplied
8/12RISC-V: kprobes: use central defined funct3 constantsarch/riscv/kernel/probes/simulate-insn.c+6 -130 repliesApplied
9/12RISC-V: add U-type imm parsing to insn.h headerarch/riscv/include/asm/insn.h+13 -00 repliesApplied
10/12RISC-V: add rd reg parsing to insn.h headerarch/riscv/include/asm/insn.h+5 -00 repliesApplied
11/12RISC-V: add helpers for handling immediates in U-type and I-type pairsarch/riscv/include/asm/insn.h+48 -00 repliesApplied
12/12RISC-V: fix auipc-jalr addresses in patched alternativesarch/riscv/include/asm/alternative.h arch/riscv/kernel/alternative.c arch/riscv/kernel/cpufeature.c+63 -10 repliesApplied

Reviews trailers per patch

All 12 patches have a Reviewed-by or Acked-by.

PatchConor DooleyAndrew JonesLad Prabhakar
1/12R-b R-b
2/12R-b R-b R-b
3/12R-b R-b R-b
4/12R-b R-b R-b
5/12R-b R-b R-b
6/12R-b R-b R-b
7/12R-b R-b R-b
8/12R-b R-b R-b
9/12R-b R-b R-b
10/12R-b R-b R-b
11/12R-b R-b R-b
12/12R-b R-b R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v5 thread

Cover letter [PATCH v5 00/12] Allow calls in alternatives

From: Heiko Stuebner <[email protected]>

This series is split out of my work on optimizing string functions and provides the basics to:

- actually allowing calls in alternatives
Function calls use auipc + jalr to reach those 32bit relative addresses but when they're compiled the offset will be wrong as alternatives live in a different section. So when the patch gets applied the address will point to the wrong location.

So similar to arm64 the target addresses need to be updated.

This is probably also helpful for other things needing more complex code in alternatives.

For v2 I got into some sort of cleanup spree for the general instruction parsing that already existed. A number of places do their own instruction parsing and I tried consolidating some of them.

Noteable, the kvm parts still do, but I had to stop somewhere :-)

The series is based on

commit 51094a24b85e ("Merge tag 'hardening-v6.2-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux")

from Fri Dec 23 12:00:24 2022 -0800 right now, this is the most current commit during the merge window and seems to include most or all riscv changes for the 6.2 merge-window, so the series should apply cleanly once 6.2-rc1 is out.

changes since v4:
- while people reporting nits for v4 mentioned that it wouldn't be necessary to respin for each, the number of them the series received waranted a respin I think
- split riscv_insn_insert_utype_itype_imm parameters into separate utype + itype u32 pointer (Andrew)
- use u32 instead of unsigned int in riscv_instruction_at (Jess)
- rename instruction params in riscv_alternative_fix_auipc_jalr make their content obvious (Andrew)
- standardize on insn for instruction-related variables (Conor)
- make comment about ra register check more explicit (Conor)

changes since v3:
- separate allowing calls in alternatives from string work
- move the immediate handling for auipc+jalr into the insn.h header This allows other parts of the kernel to reuse this, instead of duplicating the code in a number or areas
- adjust the riscv_alternative_fix_auipc_jalr function to be called from a central _fix_offsets function, so that other offsets can get fixed from the same loop in the future (jal, etc)

I've removed Conor's Reviewed-by: from that last patch, as it changed so much since v3.

changes since v2:
- add patch fixing the c.jalr funct4 value
- reword some commit messages
- fix position of auipc addition patch (earlier)
- fix compile errors from patch-reordering gone wrong (worked at the end of v2, but compiling individual patches caused issues) - patches are now tested individually
- limit Zbb variants for GNU as for now
(LLVM support for .option arch is still under review)
- prevent str-functions from getting optimized to builtin-variants

changes since v1:
- a number of generalizations/cleanups for instruction parsing
- use accessor function to access instructions (Emil)
- actually patch the correct location when having more than one instruction in an alternative block
- string function cleanups (comments etc) (Conor)
- move zbb extension above s* extensions in cpu.c lists

changes since rfc:
- make Zbb code actually work
- drop some unneeded patches
- a lot of cleanups

Heiko Stuebner (12):
RISC-V: fix funct4 definition for c.jalr in parse_asm.h
RISC-V: add prefix to all constants/macros in parse_asm.h
RISC-V: detach funct-values from their offset
RISC-V: add ebreak instructions to definitions
RISC-V: add auipc elements to parse_asm header
RISC-V: Move riscv_insn_is_* macros into a common header
RISC-V: rename parse_asm.h to insn.h
RISC-V: kprobes: use central defined funct3 constants
RISC-V: add U-type imm parsing to insn.h header
RISC-V: add rd reg parsing to insn.h header
RISC-V: add helpers for handling immediates in U-type and I-type pairs
RISC-V: fix auipc-jalr addresses in patched alternatives

 arch/riscv/include/asm/alternative.h     |   3 +
 arch/riscv/include/asm/insn.h            | 340 +++++++++++++++++++++++
 arch/riscv/include/asm/parse_asm.h       | 219 ---------------
 arch/riscv/kernel/alternative.c          |  56 ++++
 arch/riscv/kernel/cpufeature.c           |   5 +-
 arch/riscv/kernel/kgdb.c                 |  63 ++---
 arch/riscv/kernel/probes/simulate-insn.c |  19 +-
 arch/riscv/kernel/probes/simulate-insn.h |  26 +-
 8 files changed, 436 insertions(+), 295 deletions(-)
 create mode 100644 arch/riscv/include/asm/insn.h
 delete mode 100644 arch/riscv/include/asm/parse_asm.h
Signature · 7 lines
2.35.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv