Commit fe7d7b03 authored by Julien Thierry's avatar Julien Thierry Committed by Christoffer Dall
Browse files

arm/arm64: kvm: Move initialization completion message



KVM is being a bit too optimistic, Hyp mode is said to be initialized
when Hyp segments have only been mapped.

Notify KVM's successful initialization only once it is really fully
initialized.

Signed-off-by: default avatarJulien Thierry <julien.thierry@arm.com>
Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
parent fd6c8c20
Loading
Loading
Loading
Loading
+14 −17
Original line number Original line Diff line number Diff line
@@ -1326,21 +1326,12 @@ static void teardown_hyp_mode(void)
{
{
	int cpu;
	int cpu;


	if (is_kernel_in_hyp_mode())
		return;

	free_hyp_pgds();
	free_hyp_pgds();
	for_each_possible_cpu(cpu)
	for_each_possible_cpu(cpu)
		free_page(per_cpu(kvm_arm_hyp_stack_page, cpu));
		free_page(per_cpu(kvm_arm_hyp_stack_page, cpu));
	hyp_cpu_pm_exit();
	hyp_cpu_pm_exit();
}
}


static int init_vhe_mode(void)
{
	kvm_info("VHE mode initialized successfully\n");
	return 0;
}

/**
/**
 * Inits Hyp-mode on all online CPUs
 * Inits Hyp-mode on all online CPUs
 */
 */
@@ -1421,8 +1412,6 @@ static int init_hyp_mode(void)
		}
		}
	}
	}


	kvm_info("Hyp mode initialized successfully\n");

	return 0;
	return 0;


out_err:
out_err:
@@ -1456,6 +1445,7 @@ int kvm_arch_init(void *opaque)
{
{
	int err;
	int err;
	int ret, cpu;
	int ret, cpu;
	bool in_hyp_mode;


	if (!is_hyp_mode_available()) {
	if (!is_hyp_mode_available()) {
		kvm_err("HYP mode not available\n");
		kvm_err("HYP mode not available\n");
@@ -1474,20 +1464,27 @@ int kvm_arch_init(void *opaque)
	if (err)
	if (err)
		return err;
		return err;


	if (is_kernel_in_hyp_mode())
	in_hyp_mode = is_kernel_in_hyp_mode();
		err = init_vhe_mode();

	else
	if (!in_hyp_mode) {
		err = init_hyp_mode();
		err = init_hyp_mode();
		if (err)
		if (err)
			goto out_err;
			goto out_err;
	}


	err = init_subsystems();
	err = init_subsystems();
	if (err)
	if (err)
		goto out_hyp;
		goto out_hyp;


	if (in_hyp_mode)
		kvm_info("VHE mode initialized successfully\n");
	else
		kvm_info("Hyp mode initialized successfully\n");

	return 0;
	return 0;


out_hyp:
out_hyp:
	if (!in_hyp_mode)
		teardown_hyp_mode();
		teardown_hyp_mode();
out_err:
out_err:
	teardown_common_resources();
	teardown_common_resources();