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=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 79177C4338F for ; Fri, 30 Jul 2021 12:40:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 4405860F0F for ; Fri, 30 Jul 2021 12:40:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4405860F0F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=30KevZH3clbhYlQrC3iXW3do6nLvebpr+XdmmeZ0PpY=; b=F4UGYNJ7Pm2ZB5 xdkq0DBYEK9WNoa/k4bLp7B9WxK2jZTuXVtM96n29uX4JVChosvhb7D23GSMdlYHVDXWZvXeEjKIn a0wLjJlrRPOZdj/fpvQD/vp44dj+m2/kaPRw2W6gDLtZbYP2rz8tz6TLv3NIjcI2Zch2Hn6HKDswo TgJsYCCcr49v3OuOhaBCAa8rwYivBRljoiPoqhs9tRfTh3YHTRTY03g2ToyAIhUUjA0RlzpEokITk w6D48Pk8H4veb2HqRSZkb1whHBsvl694ZgYmGJC3Scw8us58V+EHq2oIdY75g/fvRMWZTyodg0kB3 7GnhMUdGAjm82fMEWHiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9RmY-008cQ4-GW; Fri, 30 Jul 2021 12:38:30 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9RmU-008cP6-Mt for linux-arm-kernel@lists.infradead.org; Fri, 30 Jul 2021 12:38:28 +0000 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-Disposition: inline In-Reply-To: <87y29qd9hb.wl-maz@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210730_053826_837989_B7EA45C2 X-CRM114-Status: GOOD ( 29.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel