Skip to content

Commit b00be77

Browse files
frankjaaborntraeger
authored andcommitted
s390/mm: Add missing secure storage access fixups for donated memory
There are special cases where secure storage access exceptions happen in a kernel context for pages that don't have the PG_arch_1 bit set. That bit is set for non-exported guest secure storage (memory) but is absent on storage donated to the Ultravisor since the kernel isn't allowed to export donated pages. Prior to this patch we would try to export the page by calling arch_make_folio_accessible() which would instantly return since the arch bit is absent signifying that the page was already exported and no further action is necessary. This leads to secure storage access exception loops which can never be resolved. With this patch we unconditionally try to export and if that fails we fixup. Fixes: 084ea4d ("s390/mm: add (non)secure page access exceptions handlers") Reported-by: Heiko Carstens <[email protected]> Suggested-by: Heiko Carstens <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Tested-by: Christian Borntraeger <[email protected]> Signed-off-by: Janosch Frank <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
1 parent f303406 commit b00be77

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

arch/s390/mm/fault.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,17 @@ void do_secure_storage_access(struct pt_regs *regs)
441441
folio = phys_to_folio(addr);
442442
if (unlikely(!folio_try_get(folio)))
443443
return;
444-
rc = arch_make_folio_accessible(folio);
444+
rc = uv_convert_from_secure(folio_to_phys(folio));
445+
if (!rc)
446+
clear_bit(PG_arch_1, &folio->flags.f);
445447
folio_put(folio);
448+
/*
449+
* There are some valid fixup types for kernel
450+
* accesses to donated secure memory. zeropad is one
451+
* of them.
452+
*/
446453
if (rc)
447-
BUG();
454+
return handle_fault_error_nolock(regs, 0);
448455
} else {
449456
if (faulthandler_disabled())
450457
return handle_fault_error_nolock(regs, 0);

0 commit comments

Comments
 (0)