x86/asm: ELF metadata for simple cases
PATCH 1/1 x86/asm: ELF metadata for simple cases
This is generally good practice, and necessary for livepatch binary diffing to work.
With this, livepatching of the SVM entry path works. The only complication is with svm_stgi_label which is only used by oprofile to guestimate (not completely correctly) when an NMI hit guest context.
Livepatching of VMX is still an open question, because the logic doesn't form anything remotely resembling functions. Both code fragments jump into each other so need to be updated in tandem. Also, both code fragment entries need trampolines in the case that patching actually occurs. For now, just treat it as a single function.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Ross Lagerwall <[email protected]>
--- xen/arch/x86/clear_page.S | 3 +++ xen/arch/x86/copy_page.S | 3 +++ xen/arch/x86/hvm/svm/entry.S | 3 +++ xen/arch/x86/hvm/vmx/entry.S | 3 +++ 4 files changed, 12 insertions(+)
xen/arch/x86/clear_page.S +3 -0
@@ -16,3 +16,6 @@ ENTRY(clear_page_sse2) sfence ret + + .type clear_page_sse2, @function + .size clear_page_sse2, . - clear_page_sse2
xen/arch/x86/copy_page.S +3 -0
@@ -41,3 +41,6 @@ ENTRY(copy_page_sse2) sfence ret + + .type copy_page_sse2, @function + .size copy_page_sse2, . - copy_page_sse2
xen/arch/x86/hvm/svm/entry.S +3 -0
@@ -142,3 +142,6 @@ GLOBAL(svm_stgi_label) sti call do_softirq jmp .Lsvm_do_resume + + .type svm_asm_do_resume, @function + .size svm_asm_do_resume, . - svm_asm_do_resume
xen/arch/x86/hvm/vmx/entry.S +3 -0
@@ -150,3 +150,6 @@ ENTRY(vmx_asm_do_vmentry) sti call do_softirq jmp .Lvmx_do_vmentry + + .type vmx_asm_vmexit_handler, @function + .size vmx_asm_vmexit_handler, . - vmx_asm_vmexit_handler
Signature · 1 line
2.30.2
Quoted 13 lines
From: Andrew Cooper <[email protected]>
Sent: Monday, February 20, 2023 11:04 AM
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Ross Lagerwall <[email protected]>
Subject: [PATCH] x86/asm: ELF metadata for simple cases
This is generally good practice, and necessary for livepatch binary diffing to
work.With this, livepatching of the SVM entry path works. The only complication is with
svm_stgi_labelwhich is only used by oprofile to guestimate (not completely correctly) when an NMI hit guest context.
Quoted 5 lines
Livepatching of VMX is still an open question, because the logic doesn't form anything remotely resembling functions. Both code fragments jump into each other so need to be updated in tandem. Also, both code fragment entries need trampolines in the case that patching actually occurs. For now, just treat it as a single function.
If it is treated as two functions and both functions are always included in the live patch, would that work?
Quoted 20 lines
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Ross Lagerwall <[email protected]>
---
xen/arch/x86/clear_page.S | 3 +++ xen/arch/x86/copy_page.S | 3 +++xen/arch/x86/hvm/svm/entry.S| 3 +++xen/arch/x86/hvm/vmx/entry.S| 3 +++4 files changed, 12 insertions(+)xen/arch/x86/clear_page.S +0
-0@@ -16,3 +16,6 @@ ENTRY(clear_page_sse2)
Quoted 6 lines
sfence
ret
+
+ .typeclear_page_sse2, @function
+ .sizeclear_page_sse2, . -clear_page_sse2
Would it be worth wrapping this pattern in a macro?
Ross
Quoted 11 lines · Ross Lagerwall
Quoted 9 lines
xen/arch/x86/clear_page.S +0
-0@@ -16,3 +16,6 @@ ENTRY(clear_page_sse2)
sfence
ret
+
+ .typeclear_page_sse2, @function
+ .sizeclear_page_sse2, . -clear_page_sse2Would it be worth wrapping this pattern in a macro?
Funny you should ask this: Yes, certainly, but we can't quite agree what shape that macro (or really set of macros) is to take. Hence we did agree on this minimalistic approach as an intermediate solution.
Jan
Quoted 13 lines · Ross Lagerwall
Quoted 13 lines
From: Andrew Cooper <[email protected]>
Sent: Monday, February 20, 2023 11:04 AM
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Ross Lagerwall <[email protected]>
Subject: [PATCH] x86/asm: ELF metadata for simple cases
This is generally good practice, and necessary for livepatch binary diffing to
work.With this, livepatching of the SVM entry path works. The only complication is with
svm_stgi_labelwhich is only used by oprofile to guestimate (not completely correctly) when an NMI hit guest context.
Quoted 7 lines
Quoted 5 lines
Livepatching of VMX is still an open question, because the logic doesn't form anything remotely resembling functions. Both code fragments jump into each other so need to be updated in tandem. Also, both code fragment entries need trampolines in the case that patching actually occurs. For now, just treat it as a single function.
If it is treated as two functions and both functions are always included in the live patch, would that work?
I think so, but only because the first jumped-to label in vmx_asm_do_vmentry is beyond the trampoline.
But I guess the question is how to tie the two symbols together. We don't want to be hardcoding this in livepatch-build-tools IMO.
Perhaps we want a CONFIG_LIVEPATCH build of Xen to include a section/note/something identifying "grouped symbols", meaning "if there's a delta in one, include all even if they haven't changed" ?
I'm getting the distinct impression that we're going to need it it for the PV entry/exit paths too.
~Andrew
Quoted 7 lines · Andrew Cooper
This is generally good practice, and necessary for livepatch binary diffing to work.
With this, livepatching of the SVM entry path works. The only complication is with
svm_stgi_labelwhich is only used by oprofile to guestimate (not completely correctly) when an NMI hit guest context.
Quoted 5 lines
Livepatching of VMX is still an open question, because the logic doesn't form anything remotely resembling functions. Both code fragments jump into each other so need to be updated in tandem. Also, both code fragment entries need trampolines in the case that patching actually occurs. For now, just treat it as a single function.
I agree.
Quoted 1 line
Signed-off-by Andrew Cooper <[email protected]>