From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB40A48787 for ; Mon, 8 Apr 2024 07:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712562293; cv=none; b=V6fIqdPd3tE0A9fAeY4ftIjfxDbn8lOspMGUC+96zv4SddZr1HP37RBsYPMnqLGE3p2kZLOzMeumrA1vC0L3JvTao30zVkKtuUPj7xSrsuN3C4fbabilu573lClChvr6Flt+72aN18a3DFqJp6nJyuV5JZdxFFzhmo+yF/IxvGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712562293; c=relaxed/simple; bh=BhqydDivTl/yVN07GOY6+fkzNmn/QBlqiaQuLEzkW4k=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=FpnMlIDaEGZm+9EOULdymZJ2TPKuPttP3vsKuc3odgAuMWVY+5WhFO81BhASMLYw68G3453ffepEXaT9+dxbT0F92rDvfMjE8rvOxGjgG2FYGjrI7xZu4qOcsnhLIRaGcsk9G02ov1I4959gM8Kjc+LOMTztOdx9g0AQ/rkoS5E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sSXmtDiU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sSXmtDiU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F9C1C433C7; Mon, 8 Apr 2024 07:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712562293; bh=BhqydDivTl/yVN07GOY6+fkzNmn/QBlqiaQuLEzkW4k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=sSXmtDiUfYmXbpTTsCZGBwkf+cKn2HfeSNCySp2LoD/16rriFuKX1Qpewoqbp8k4u FYcFk5EuTmSfhSbPmLfva8E9eZ+8FmcU55cZMHza5SPDbVhe1sbAMF6EFaLq1YcUy6 NQVl9OQw6D5leRTrQnH4QlSH1mGoy1Dzvp0diuucgULeu/MR7kQgw07UO2oJY3Wyob jEaPEiBzvXF5UVGajxkNPrcEpeIqxwjpvulAI21GWq08pI1qJLSXp4pAJeRgCMNMzI y/u0ZHoXT5PmECo82HWOG2BK4Z2Y6ki01JXjeXuMNuXJl9ruagY2UZYQVcnLm1rb13 QT8R1vnbb1C7A== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rtjgR-002Ohb-8K; Mon, 08 Apr 2024 08:44:51 +0100 Date: Mon, 08 Apr 2024 08:44:50 +0100 Message-ID: <8634rwti19.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvmarm@lists.linux.dev, will@kernel.org, qperret@google.com, seanjc@google.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, philmd@linaro.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, mark.rutland@arm.com, broonie@kernel.org, joey.gouly@arm.com, rananta@google.com Subject: Re: [PATCH v1 04/44] KVM: arm64: Avoid BUG-ing from the host abort path In-Reply-To: <20240327173531.1379685-5-tabba@google.com> References: <20240327173531.1379685-1-tabba@google.com> <20240327173531.1379685-5-tabba@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, kvmarm@lists.linux.dev, will@kernel.org, qperret@google.com, seanjc@google.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, philmd@linaro.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, mark.rutland@arm.com, broonie@kernel.org, joey.gouly@arm.com, rananta@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 27 Mar 2024 17:34:51 +0000, Fuad Tabba wrote: > > From: Quentin Perret > > Under certain circumstances __get_fault_info() may resolve the faulting > address using the AT instruction. Given that this is being done outside > of the host lock critical section, it is racy and the resolution via AT > may fail. We currently BUG() in this situation, which is obviously less > than ideal. Moving the address resolution to the critical section may > have a performance impact, so let's keep it where it is, but bail out > and return to the host to try a second time. > > Signed-off-by: Quentin Perret > Signed-off-by: Fuad Tabba > --- > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > index 861c76021a25..d48990eae1ef 100644 > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > @@ -533,7 +533,15 @@ void handle_host_mem_abort(struct kvm_cpu_context *host_ctxt) > int ret = 0; > > esr = read_sysreg_el2(SYS_ESR); > - BUG_ON(!__get_fault_info(esr, &fault)); > + if (!__get_fault_info(esr, &fault)) { > + /* Setting the address to an invalid value for use in tracing. */ > + addr = (u64)-1; If this is relating to tracing, can this instead be added together with the tracing itself? > + /* > + * We've presumably raced with a page-table change which caused > + * AT to fail, try again. > + */ > + return; > + } > > addr = (fault.hpfar_el2 & HPFAR_MASK) << 8; > ret = host_stage2_idmap(addr); Thanks, M. -- Without deviation from the norm, progress is not possible.