[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] x86/alternatives: fix .init section reference in _apply_alternatives()



commit 4be1fef1e6572c2be0bd378902ffb62a6e73faeb
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Tue Apr 9 14:50:46 2024 +0200
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Apr 9 14:05:59 2024 +0100

    x86/alternatives: fix .init section reference in _apply_alternatives()
    
    The code in _apply_alternatives() will unconditionally attempt to read
    __initdata_cf_clobber_{start,end} when called as part of applying 
alternatives
    to a livepatch payload when Xen is using IBT.
    
    That leads to a page-fault as __initdata_cf_clobber_{start,end} living in
    .init section will have been unmapped by the time a livepatch gets loaded.
    
    Fix by adding a check that limits the clobbering of endbr64 instructions to
    boot time only.
    
    Fixes: 37ed5da851b8 ('x86/altcall: Optimise away endbr64 instruction where 
possible')
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/alternative.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
index 21af0e8258..2e7ba6e0b8 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -326,7 +326,7 @@ static void init_or_livepatch _apply_alternatives(struct 
alt_instr *start,
      * Clobber endbr64 instructions now that altcall has finished optimising
      * all indirect branches to direct ones.
      */
-    if ( force && cpu_has_xen_ibt )
+    if ( force && cpu_has_xen_ibt && system_state < SYS_STATE_active )
     {
         void *const *val;
         unsigned int clobbered = 0;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.