From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55F22C433DF for ; Sun, 26 Jul 2020 13:40:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 222552065F for ; Sun, 26 Jul 2020 13:40:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Gq0tRQwu"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="CC0MZfoJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 222552065F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Subject:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IlQGrwWS5otuwT99qIgoND6oPaTzsCeTaVrUuJjyU1E=; b=Gq0tRQwu8Wp69tmVyK4Xbpcsy /s581QxeSlFhmUUYuA2T6o3LcqFxU4KED9Xb8Zm4zBr6QbAacEwEpOj7z8zXL+AVakPahPwSWnt7m +Ax4sDNm3gYRo7xxnqLeq2I2RGKag8sdM2CPgvw71T5EIeEfC+wvOUVoJ63lOr27yrWXUQIYjpQoH tIYpvSbYojcnSapn8arfO9qCpM3BmJzbHlgH4PvwosacJJYhZ41KkL/NHtm9ArWxgrelhr/ZsSKOx BOoTosqufDxSYpNN1SwRDRc8YNnI8w832GsSe1LUhn4ZsGqpjIrJxA9118G0cG4LOUNm9DwTFqqQZ 2I23+NkEQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzgrW-0005hj-63; Sun, 26 Jul 2020 13:38:46 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzgrS-0005hA-Uc for linux-arm-kernel@lists.infradead.org; Sun, 26 Jul 2020 13:38:43 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7F0762065F; Sun, 26 Jul 2020 13:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595770721; bh=1XM8W5lC/bCqZJ1ZaSXYFBFXTKlsRW1n0ONiwaxojGo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CC0MZfoJmBZb/U4uu4yv8ixiDNhwX4L5UY0I/+TF7bq/ZeP/2NRm27yCUd17Fq0fd X0LsbEgGet+MwNJjBpIsLezCyoUJHu1225rpTHsqDPtWzRjDC0OQmwXouytLOeQvgu aX8HNebzN1OT9DSHUL1qJhubErrCXTJj98aPXlpQ= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jzgrP-00F2Mh-A3; Sun, 26 Jul 2020 14:38:40 +0100 Date: Sun, 26 Jul 2020 14:38:38 +0100 Message-ID: <87r1sywg4h.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Subject: Re: [PATCH 6/7] KVM: arm64: Handle stage-2 faults on stage-1 page-table walks earlier In-Reply-To: <20200724143506.17772-7-will@kernel.org> References: <20200724143506.17772-1-will@kernel.org> <20200724143506.17772-7-will@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/26.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, qperret@google.com, james.morse@arm.com, suzuki.poulose@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200726_093843_122298_E9379829 X-CRM114-Status: GOOD ( 25.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Suzuki Poulose , Quentin Perret , James Morse , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 24 Jul 2020 15:35:05 +0100, Will Deacon wrote: > > Stage-2 faults on stage-1 page-table walks can occur on both the I-side > and the D-side. It is IMPLEMENTATATION DEFINED whether they are reported > as reads or writes and, in the case that they are generated by an AT > instruction, they are reported with the CM bit set. > > All of this deeply confuses the logic in kvm_handle_guest_abort(); > userspace may or may not see the fault, depending on whether it occurs > on the data or the instruction side, and an AT instruction may be skipped > if the translation tables are held in a read-only memslot. Yuk, that's indeed ugly. Well spotted. I guess the saving grace is that a S2 trap caused by an ATS1 instruction will be reported as S1PTW+CM, while the fault caused by a CMO is reported as *either* S1PTW *or* CM, but never both. > > Move the handling of stage-2 faults on stage-1 page-table walks earlier > so that they consistently result in either a data or an instruction abort > being re-injected back to the guest. The instruction abort seems to be happening as the side effect of executing outside of a memslot, not really because of a S1PTW. I wonder whether these S1PTW faults should be classified as external aborts instead (because putting your page tables outside of a memslot seems a bit bonkers). > > Cc: Marc Zyngier > Cc: Quentin Perret > Signed-off-by: Will Deacon > --- > arch/arm64/kvm/mmu.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index adb933ecd177..9e72e7f4a2c2 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -2124,6 +2124,11 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run) > goto out; > } > > + if (kvm_vcpu_dabt_iss1tw(vcpu)) { > + ret = -ENXIO; > + goto out; > + } > + > /* > * Check for a cache maintenance operation. Since we > * ended-up here, we know it is outside of any memory > @@ -2157,11 +2162,6 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run) > goto out_unlock; > } > > - if (kvm_vcpu_dabt_iss1tw(vcpu)) { > - ret = -ENXIO; > - goto out; > - } > - > ret = io_mem_abort(vcpu, run, fault_ipa); > goto out_unlock; > } > -- > 2.28.0.rc0.142.g3c755180ce-goog > > Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel