Skip to content

Commit e3bcd0f

Browse files
hfreudehcahca
authored andcommitted
s390/cpacf: Rework cpacf_pcc() to return condition code
Some of the pcc sub-functions have a protected key as input and thus may run into the situation that this key may be invalid for example due to live guest migration to another physical hardware. Rework the inline assembler function cpacf_pcc() to return the condition code (cc) as return value: 0 - cc code 0 (normal completion) 1 - cc code 1 (prot key wkvp mismatch or src op out of range) 2 - cc code 2 (something invalid, scalar multiply infinity, ...) Note that cc 3 (partial completion) is handled within the asm code and never returned. Signed-off-by: Harald Freudenberger <[email protected]> Reviewed-by: Holger Dengler <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]>
1 parent 3919600 commit e3bcd0f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

arch/s390/include/asm/cpacf.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,18 +649,30 @@ static inline void cpacf_trng(u8 *ucbuf, unsigned long ucbuf_len,
649649
* instruction
650650
* @func: the function code passed to PCC; see CPACF_KM_xxx defines
651651
* @param: address of parameter block; see POP for details on each func
652+
*
653+
* Returns the condition code, this is
654+
* 0 - cc code 0 (normal completion)
655+
* 1 - cc code 1 (protected key wkvp mismatch or src operand out of range)
656+
* 2 - cc code 2 (something invalid, scalar multiply infinity, ...)
657+
* Condition code 3 (partial completion) is handled within the asm code
658+
* and never returned.
652659
*/
653-
static inline void cpacf_pcc(unsigned long func, void *param)
660+
static inline int cpacf_pcc(unsigned long func, void *param)
654661
{
662+
int cc;
663+
655664
asm volatile(
656665
" lgr 0,%[fc]\n"
657666
" lgr 1,%[pba]\n"
658667
"0: .insn rre,%[opc] << 16,0,0\n" /* PCC opcode */
659668
" brc 1,0b\n" /* handle partial completion */
660-
:
669+
CC_IPM(cc)
670+
: CC_OUT(cc, cc)
661671
: [fc] "d" (func), [pba] "d" ((unsigned long)param),
662672
[opc] "i" (CPACF_PCC)
663-
: "cc", "memory", "0", "1");
673+
: CC_CLOBBER_LIST("memory", "0", "1"));
674+
675+
return CC_TRANSFORM(cc);
664676
}
665677

666678
/**

0 commit comments

Comments
 (0)