[PATCH 15/21] arm64: KVM: Add panic handling

Mark Rutland mark.rutland at arm.com
Mon Nov 16 06:16:29 PST 2015


> diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
> index 06d3e20..cdc2a96 100644
> --- a/arch/arm64/kvm/hyp/switch.c
> +++ b/arch/arm64/kvm/hyp/switch.c
> @@ -140,3 +140,38 @@ int __hyp_text __guest_run(struct kvm_vcpu *vcpu)
>  
>  	return exit_code;
>  }
> +
> +static const char *__hyp_panic_string = "HYP panic:\nPS:%08x PC:%p ESR:%p\nFAR:%p HPFAR:%p PAR:%p\nVCPU:%p\n";

I assume that if [1] goes in we'll update this to match.

> +
> +void __hyp_text __noreturn __hyp_panic(void)
> +{
> +	u64 spsr = read_sysreg(spsr_el2);
> +	u64 elr = read_sysreg(elr_el2);
> +	u64 par = read_sysreg(par_el1);
> +
> +	if (read_sysreg(vttbr_el2)) {
> +		struct kvm_vcpu *vcpu;
> +		struct kvm_cpu_context *host_ctxt;
> +
> +		vcpu = (struct kvm_vcpu *)read_sysreg(tpidr_el2);
> +		host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
> +		__deactivate_traps(vcpu);
> +		__deactivate_vm(vcpu);
> +		__sysreg_restore_state(host_ctxt);
> +
> +		write_sysreg(host_ctxt->gp_regs.sp_el1, sp_el1);

__sysreg_restore_state restores the host sp_el1, no?

> +	}
> +
> +	/* Call panic for real */
> +	while (1) {
> +		unsigned long str_va = (unsigned long)__hyp_panic_string;
> +
> +		str_va -= HYP_PAGE_OFFSET;
> +		str_va += PAGE_OFFSET;
> +		__hyp_do_panic(str_va,
> +			       spsr,  elr,
> +			       read_sysreg(esr_el2),   read_sysreg(far_el2),
> +			       read_sysreg(hpfar_el2), par,
> +			       read_sysreg(tpidr_el2));
> +	}
> +}

I think the while (1) here is confusing.

Can we not jsut declare str_va at the start of the function and get rid
of the loop?

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-November/385199.html



More information about the linux-arm-kernel mailing list