xref: /kernel/linux/linux-5.10/arch/s390/boot/uv.c (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci#include <asm/uv.h>
38c2ecf20Sopenharmony_ci#include <asm/facility.h>
48c2ecf20Sopenharmony_ci#include <asm/sections.h>
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci/* will be used in arch/s390/kernel/uv.c */
78c2ecf20Sopenharmony_ci#ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
88c2ecf20Sopenharmony_ciint __bootdata_preserved(prot_virt_guest);
98c2ecf20Sopenharmony_ci#endif
108c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_KVM)
118c2ecf20Sopenharmony_ciint __bootdata_preserved(prot_virt_host);
128c2ecf20Sopenharmony_ci#endif
138c2ecf20Sopenharmony_cistruct uv_info __bootdata_preserved(uv_info);
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_civoid uv_query_info(void)
168c2ecf20Sopenharmony_ci{
178c2ecf20Sopenharmony_ci	struct uv_cb_qui uvcb = {
188c2ecf20Sopenharmony_ci		.header.cmd = UVC_CMD_QUI,
198c2ecf20Sopenharmony_ci		.header.len = sizeof(uvcb)
208c2ecf20Sopenharmony_ci	};
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci	if (!test_facility(158))
238c2ecf20Sopenharmony_ci		return;
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	/* rc==0x100 means that there is additional data we do not process */
268c2ecf20Sopenharmony_ci	if (uv_call(0, (uint64_t)&uvcb) && uvcb.header.rc != 0x100)
278c2ecf20Sopenharmony_ci		return;
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	if (IS_ENABLED(CONFIG_KVM)) {
308c2ecf20Sopenharmony_ci		memcpy(uv_info.inst_calls_list, uvcb.inst_calls_list, sizeof(uv_info.inst_calls_list));
318c2ecf20Sopenharmony_ci		uv_info.uv_base_stor_len = uvcb.uv_base_stor_len;
328c2ecf20Sopenharmony_ci		uv_info.guest_base_stor_len = uvcb.conf_base_phys_stor_len;
338c2ecf20Sopenharmony_ci		uv_info.guest_virt_base_stor_len = uvcb.conf_base_virt_stor_len;
348c2ecf20Sopenharmony_ci		uv_info.guest_virt_var_stor_len = uvcb.conf_virt_var_stor_len;
358c2ecf20Sopenharmony_ci		uv_info.guest_cpu_stor_len = uvcb.cpu_stor_len;
368c2ecf20Sopenharmony_ci		uv_info.max_sec_stor_addr = ALIGN(uvcb.max_guest_stor_addr, PAGE_SIZE);
378c2ecf20Sopenharmony_ci		uv_info.max_num_sec_conf = uvcb.max_num_sec_conf;
388c2ecf20Sopenharmony_ci		uv_info.max_guest_cpu_id = uvcb.max_guest_cpu_id;
398c2ecf20Sopenharmony_ci		uv_info.uv_feature_indications = uvcb.uv_feature_indications;
408c2ecf20Sopenharmony_ci	}
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
438c2ecf20Sopenharmony_ci	if (test_bit_inv(BIT_UVC_CMD_SET_SHARED_ACCESS, (unsigned long *)uvcb.inst_calls_list) &&
448c2ecf20Sopenharmony_ci	    test_bit_inv(BIT_UVC_CMD_REMOVE_SHARED_ACCESS, (unsigned long *)uvcb.inst_calls_list))
458c2ecf20Sopenharmony_ci		prot_virt_guest = 1;
468c2ecf20Sopenharmony_ci#endif
478c2ecf20Sopenharmony_ci}
48