Thread (13 messages) flat view 13 messages, 5 authors, 2021-11-25

Re: [PATCH 20/22] x86,word-at-a-time: Remove .fixup usage

From: Josh Poimboeuf <hidden>
Date: 2021-11-13 05:35:11
Also in: linux-toolchains, lkml, llvm

On Fri, Nov 12, 2021 at 10:33:36AM +0100, Peter Zijlstra wrote:
On Thu, Nov 11, 2021 at 05:50:03PM -0800, Josh Poimboeuf wrote:
quoted
Hm, I think there is actually a livepatch problem here.
I suspected as much, because I couldn't find any code dealing with it
when I looked in a hurry.. :/
quoted
Some ideas to fix:
quoted
c) Update the reliable stacktrace code to mark the stack unreliable if
   it has a function with ".cold" in the name?
Why not simply match func.cold as func in the transition thing? Then
func won't get patched as long as it (or it's .cold part) is in use.
This seems like the natural thing to do.
Well yes, you're basically hinting at my first two options a and b:

a) Add a field to 'klp_func' which allows the patch module to specify a
   function's .cold counterpart?

b) Detect such cold counterparts in klp_enable_patch()?  Presumably it
   would require searching kallsyms for "<func>.cold", which is somewhat
   problematic as there might be duplicates.

It's basically a two-step process:  1) match func to .cold if it exists;
2) check for both in klp_check_stack_func().  The above two options are
proposals for the 1st step.  The 2nd step was implied.

I think something like that is probably the way to go, but the question
is where to match func to .cold:

  - patch creation;
  - klp_init_object_loaded(); or
  - klp_check_stack_func().

I think the main problem with matching them in the kernel is that you
can't disambiguate duplicate ".cold" symbols without disassembling the
function.  Duplicates are rare but they do exist.

Matching them at patch creation time (option a) may work best.  At least
with kpatch-build, the tooling already knows about .cold functions, so
explicitly matching them in new klp_func.{cold_name,cold_sympos} fields
would be trivial.

I don't know about other patch creation tooling, but I'd imagine they
also need to know about .cold functions, unless they have that
optimization disabled.  Because the func and its .cold counterpart
always need to be patched together.

-- 
Josh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help