Skip to content

Commit

Permalink
s390/cpacf: Rework cpacf_pcc() to return condition code
Browse files Browse the repository at this point in the history
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 <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Link: https://lore.kernel.org/r/20250514090955.72370-2-freude@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
  • Loading branch information
Harald Freudenberger authored and Heiko Carstens committed May 17, 2025
1 parent 3919600 commit e3bcd0f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions arch/s390/include/asm/cpacf.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,18 +649,30 @@ static inline void cpacf_trng(u8 *ucbuf, unsigned long ucbuf_len,
* instruction
* @func: the function code passed to PCC; see CPACF_KM_xxx defines
* @param: address of parameter block; see POP for details on each func
*
* Returns the condition code, this is
* 0 - cc code 0 (normal completion)
* 1 - cc code 1 (protected key wkvp mismatch or src operand out of range)
* 2 - cc code 2 (something invalid, scalar multiply infinity, ...)
* Condition code 3 (partial completion) is handled within the asm code
* and never returned.
*/
static inline void cpacf_pcc(unsigned long func, void *param)
static inline int cpacf_pcc(unsigned long func, void *param)
{
int cc;

asm volatile(
" lgr 0,%[fc]\n"
" lgr 1,%[pba]\n"
"0: .insn rre,%[opc] << 16,0,0\n" /* PCC opcode */
" brc 1,0b\n" /* handle partial completion */
:
CC_IPM(cc)
: CC_OUT(cc, cc)
: [fc] "d" (func), [pba] "d" ((unsigned long)param),
[opc] "i" (CPACF_PCC)
: "cc", "memory", "0", "1");
: CC_CLOBBER_LIST("memory", "0", "1"));

return CC_TRANSFORM(cc);
}

/**
Expand Down

0 comments on commit e3bcd0f

Please sign in to comment.