Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6909725pxv; Fri, 30 Jul 2021 05:39:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4hYQRusW8Ys4vkutiNsBdtXDvvbiHGcmwv84VKiZtPSqIA4yNWfOovGnEaNxME6vzt4vw X-Received: by 2002:a05:6638:25c7:: with SMTP id u7mr2014290jat.26.1627648760698; Fri, 30 Jul 2021 05:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627648760; cv=none; d=google.com; s=arc-20160816; b=Xu2vSgoTMxK/LqwNSvVziGL9gWGipYwDzZlYWyOXIaFAOFsmhkbo+ATf77qB7HZ6lT rHCtLeE1s9M7CUIriLXwe/e0+hTII5mCCk3JyunTVX8Qg84BDrpN7hIlU1Lw8AvNMdDC fVJa9LG4yjEj7qtmUpCOKmrTqqRDhp5Soes6IyuDGNMrZSo5/MMILo/HWqwxeKBXsiaV zoSsyGkM49TFf9diwC+0K0CVcc0U2mOMIhVCzJV+XaD0pXKFU4/HTxkPHur/GQv6CWB3 lX4/IvJaRNVLAL1CTTqVnDbJ1vU9WC0266TH/WaUhCBygciaLRPMhVTfT32c0A5i6Pzy sYtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6utKLmaLGvy6CdUq9hIQAbxfiyW45kYrr8xV8ZviBfw=; b=yOvYBcfnIUBf+3yVcVgTkrtgqULAwBViVm9pI/42E6MPEpfRwxlQkYyjEePkkSh1rA gS4psxfmWbtAxqVj6lWVOE1Le9MwPsf+rpomPtRdkXrevYCkzasn4y4EL94FxFH8qGVQ pS+fZrKD967ry70mC3L47s3/Q+ImPXVCo88CgoQ7w6hrazRZMUws8DCxyixNlEKvfglL WaL2+TnEEkXsJjzL4GWtP+SeeUQduUokJPHyS66EYLq4nDWhQBpbQUDQFQmJ1RmgAuY5 0GUl0jgt143fee+zdxSGNwDoOd6L5yt6y22lJg1OV6rmUmiBieCb1w8CO9X3wxadW4oZ tc/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gvoj29gJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m25si1640502jah.26.2021.07.30.05.39.09; Fri, 30 Jul 2021 05:39:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gvoj29gJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238847AbhG3Mib (ORCPT + 99 others); Fri, 30 Jul 2021 08:38:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:54994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238723AbhG3Mia (ORCPT ); Fri, 30 Jul 2021 08:38:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 387E560527; Fri, 30 Jul 2021 12:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627648706; bh=o6XJinuY1CMi7OTgS2kgmVPjGGg7c5qp+9A1WHaEJeA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gvoj29gJx02m2wpzcfnFS/kvmf3bt/1JtnNfvnmVMt0Lx2mLv077D9LYeQ8y72IH0 xK7eY6PADSRu2OsCVvpOgpjAhzPFWY1mHS734NAu8xlCOZninU5TDITouDswtHyKSw P3JBAGxK/A/RaI5GJ88s2JjmWV8wTvJD6GeSneGoOy+h0sFgdzdEt0TZb8xSe3HOm4 u2tfhCEiq9PMqvLkaFdD+G0Kjszw5bHG2+spn+Tz2kk6wnn/xPpOOad0XKW61WJQmM jjnwoQbbY/tYqJkEJptW8MQeCiH/J8O2mrj8RAvRIoylG5xwq5hgQ3fOsk1ILcWfee PDCgxrH809nqg== Date: Fri, 30 Jul 2021 13:38:21 +0100 From: Will Deacon To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, qperret@google.com, dbrazdil@google.com, Srivatsa Vaddagiri , Shanker R Donthineni , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com Subject: Re: [PATCH 05/16] KVM: arm64: Plumb MMIO checking into the fault handling Message-ID: <20210730123820.GA23756@willie-the-truck> References: <20210715163159.1480168-1-maz@kernel.org> <20210715163159.1480168-6-maz@kernel.org> <20210727181120.GD19173@willie-the-truck> <87y29qd9hb.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y29qd9hb.wl-maz@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 28, 2021 at 11:21:52AM +0100, Marc Zyngier wrote: > On Tue, 27 Jul 2021 19:11:21 +0100, > Will Deacon wrote: > > > > On Thu, Jul 15, 2021 at 05:31:48PM +0100, Marc Zyngier wrote: > > > Plumb the MMIO checking code into the MMIO fault handling code. > > > Nothing allows a region to be registered yet, so there should be > > > no funtional change either. > > > > Typo: functional > > > > > Signed-off-by: Marc Zyngier > > > --- > > > arch/arm64/kvm/mmio.c | 10 ++++++++++ > > > 1 file changed, 10 insertions(+) > > > > > > diff --git a/arch/arm64/kvm/mmio.c b/arch/arm64/kvm/mmio.c > > > index 3dd38a151d2a..fd5747279d27 100644 > > > --- a/arch/arm64/kvm/mmio.c > > > +++ b/arch/arm64/kvm/mmio.c > > > @@ -6,6 +6,7 @@ > > > > > > #include > > > #include > > > +#include > > > #include > > > > > > #include "trace.h" > > > @@ -130,6 +131,10 @@ int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa) > > > int len; > > > u8 data_buf[8]; > > > > > > + /* Check failed? Return to the guest for debriefing... */ > > > + if (!kvm_check_ioguard_page(vcpu, fault_ipa)) > > > + return 1; > > > + > > > /* > > > * No valid syndrome? Ask userspace for help if it has > > > * volunteered to do so, and bail out otherwise. > > > @@ -156,6 +161,11 @@ int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa) > > > len = kvm_vcpu_dabt_get_as(vcpu); > > > rt = kvm_vcpu_dabt_get_rd(vcpu); > > > > > > + /* If we cross a page boundary, check that too... */ > > > + if (((fault_ipa + len - 1) & PAGE_MASK) != (fault_ipa & PAGE_MASK) && > > > + !kvm_check_ioguard_page(vcpu, fault_ipa + len - 1)) > > > + return 1; > > > + > > > > I find this a little odd as the checks straddle the invalid syndrome check, > > meaning that the relative priorities of KVM_ARCH_FLAG_MMIO_GUARD and > > KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER are unclear. > > Good point. And the combination of both flags on its own is odd. Maybe > KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER should be ignored or deemed > incompatible with the MMIO guard feature. > > The lack of syndrome information means that we cannot really test for > the boundaries of the access (len is invalid), so I'd be tempted to > inject an abort in this case. > > Thoughts? I agree. Probably worth rejecting both flags anyway so the VMM knows what it's getting, but injecting an abort into the guest if we don't have sufficient syndrom information to triage it safely feels like the right thing to do. Will