• Heiko Carstens's avatar
    s390/ap: get rid of register asm · b9639b31
    Heiko Carstens authored
    
    
    Using register asm statements has been proven to be very error prone,
    especially when using code instrumentation where gcc may add function
    calls, which clobbers register contents in an unexpected way.
    
    Therefore get rid of register asm statements in ap code. There are also
    potential bugs, depending on inline decisions of the compiler.
    
    E.g. for:
    
    static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info)
    {
    	register unsigned long reg0 asm ("0") = qid;
    	register struct ap_queue_status reg1 asm ("1");
    	register unsigned long reg2 asm ("2");
    
    	asm volatile(".long 0xb2af0000"         /* PQAP(TAPQ) */
    		     : "=d" (reg1), "=d" (reg2)
    		     : "d" (reg0)
    		     : "cc");
    	if (info)
    		*info = reg2;
    	return reg1;
    }
    
    In case of KCOV the "if (info)" line could cause a generated function
    call, which could clobber the contents of both reg2, and reg1.
    
    Similar can happen in case of KASAN for the "*info = reg2" line.
    
    Even though compilers will likely inline the function and optimize
    things away, this is not guaranteed.
    
    To get rid of this bug class, simply get rid of register asm constructs.
    
    Note: The inline function ap_dqap() will be handled in a
    separate patch because this one requires an addressing of the
    odd register of a register pair (which is done with %N[xxx] in
    the assembler code) and that's currently not supported by clang.
    Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
    Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
    Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
    b9639b31
ap.h 12.6 KB