All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Stuebner <heiko@sntech.de>
To: linux-riscv@lists.infradead.org, palmer@dabbelt.com
Cc: christoph.muellner@vrull.eu, prabhakar.csengg@gmail.com,
	conor@kernel.org, philipp.tomsich@vrull.eu,
	ajones@ventanamicro.com, heiko@sntech.de,
	emil.renner.berthing@canonical.com, jszhang@kernel.org,
	Heiko Stuebner <heiko.stuebner@vrull.eu>
Subject: [PATCH v4 00/12] Allow calls in alternatives
Date: Wed,  7 Dec 2022 19:08:09 +0100	[thread overview]
Message-ID: <20221207180821.2479987-1-heiko@sntech.de> (raw)

From: Heiko Stuebner <heiko.stuebner@vrull.eu>

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 v6.1-rc7 right now.

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            | 339 +++++++++++++++++++++++
 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, 435 insertions(+), 295 deletions(-)
 create mode 100644 arch/riscv/include/asm/insn.h
 delete mode 100644 arch/riscv/include/asm/parse_asm.h

-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2022-12-07 18:08 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 18:08 Heiko Stuebner [this message]
2022-12-07 18:08 ` [PATCH v4 01/12] RISC-V: fix funct4 definition for c.jalr in parse_asm.h Heiko Stuebner
2022-12-10 12:34   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 02/12] RISC-V: add prefix to all constants/macros " Heiko Stuebner
2022-12-10 12:45   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 03/12] RISC-V: detach funct-values from their offset Heiko Stuebner
2022-12-10 22:16   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 04/12] RISC-V: add ebreak instructions to definitions Heiko Stuebner
2022-12-10 23:08   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 05/12] RISC-V: add auipc elements to parse_asm header Heiko Stuebner
2022-12-10 23:28   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 06/12] RISC-V: Move riscv_insn_is_* macros into a common header Heiko Stuebner
2022-12-11 17:32   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 07/12] RISC-V: rename parse_asm.h to insn.h Heiko Stuebner
2022-12-11 17:33   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 08/12] RISC-V: kprobes: use central defined funct3 constants Heiko Stuebner
2022-12-11 17:34   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 09/12] RISC-V: add U-type imm parsing to insn.h header Heiko Stuebner
2022-12-11 17:36   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 10/12] RISC-V: add rd reg " Heiko Stuebner
2022-12-11 17:41   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 11/12] RISC-V: add helpers for handling immediates in U-type and I-type pairs Heiko Stuebner
2022-12-07 20:07   ` Conor Dooley
2022-12-07 22:43     ` Heiko Stuebner
2022-12-08 14:38   ` Andrew Jones
2022-12-22 13:46     ` Heiko Stübner
2022-12-11 20:45   ` Lad, Prabhakar
2022-12-07 18:08 ` [PATCH v4 12/12] RISC-V: fix auipc-jalr addresses in patched alternatives Heiko Stuebner
2022-12-07 20:48   ` Conor Dooley
2022-12-07 22:00     ` Jessica Clarke
2022-12-07 22:04       ` Conor Dooley
2022-12-07 22:37     ` Heiko Stuebner
2022-12-08  5:03       ` Conor.Dooley
2022-12-08 14:47   ` Andrew Jones
2022-12-11 20:49   ` Lad, Prabhakar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221207180821.2479987-1-heiko@sntech.de \
    --to=heiko@sntech.de \
    --cc=ajones@ventanamicro.com \
    --cc=christoph.muellner@vrull.eu \
    --cc=conor@kernel.org \
    --cc=emil.renner.berthing@canonical.com \
    --cc=heiko.stuebner@vrull.eu \
    --cc=jszhang@kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=prabhakar.csengg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.