Commit 7f33565b authored by Alexander Egorenkov's avatar Alexander Egorenkov Committed by Heiko Carstens

s390/uv: de-duplicate checks for Protected Host Virtualization

De-duplicate checks for Protected Host Virtualization in decompressor and
kernel.

Set prot_virt_host=0 in the decompressor in *any* of the following cases
and hand it over to the decompressed kernel:
* No explicit prot_virt=1 is given on the kernel command-line
* Protected Guest Virtualization is enabled
* Hardware support not present
* kdump or stand-alone dump

The decompressed kernel needs to use only is_prot_virt_host() instead of
performing again all checks done by the decompressor.
Signed-off-by: default avatarAlexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 42c89439
......@@ -51,32 +51,34 @@ void uv_query_info(void)
}
#if IS_ENABLED(CONFIG_KVM)
static bool has_uv_sec_stor_limit(void)
void adjust_to_uv_max(unsigned long *vmax)
{
/*
* keep these conditions in line with setup_uv()
*/
if (!is_prot_virt_host())
return false;
if (is_prot_virt_guest())
return false;
if (!test_facility(158))
return false;
return !!uv_info.max_sec_stor_addr;
if (is_prot_virt_host() && uv_info.max_sec_stor_addr)
*vmax = min_t(unsigned long, *vmax, uv_info.max_sec_stor_addr);
}
void adjust_to_uv_max(unsigned long *vmax)
static int is_prot_virt_host_capable(void)
{
if (has_uv_sec_stor_limit())
*vmax = min_t(unsigned long, *vmax, uv_info.max_sec_stor_addr);
/* disable if no prot_virt=1 given on command-line */
if (!is_prot_virt_host())
return 0;
/* disable if protected guest virtualization is enabled */
if (is_prot_virt_guest())
return 0;
/* disable if no hardware support */
if (!test_facility(158))
return 0;
/* disable if kdump */
if (OLDMEM_BASE)
return 0;
/* disable if stand-alone dump */
if (ipl_block_valid && is_ipl_block_dump())
return 0;
return 1;
}
void sanitize_prot_virt_host(void)
{
if (OLDMEM_BASE || (ipl_block_valid && is_ipl_block_dump()))
prot_virt_host = 0;
prot_virt_host = is_prot_virt_host_capable();
}
#endif
......@@ -51,24 +51,9 @@ void __init setup_uv(void)
{
unsigned long uv_stor_base;
/*
* keep these conditions in line with has_uv_sec_stor_limit()
*/
if (!is_prot_virt_host())
return;
if (is_prot_virt_guest()) {
prot_virt_host = 0;
pr_warn("Protected virtualization not available in protected guests.");
return;
}
if (!test_facility(158)) {
prot_virt_host = 0;
pr_warn("Protected virtualization not supported by the hardware.");
return;
}
uv_stor_base = (unsigned long)memblock_alloc_try_nid(
uv_info.uv_base_stor_len, SZ_1M, SZ_2G,
MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment