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=-6.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 5086CC4338F for ; Fri, 30 Jul 2021 12:29:45 +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 1EFBF6024A for ; Fri, 30 Jul 2021 12:29:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1EFBF6024A 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=XjohPsRqWb5WTv5qWw+vRCK+aOiZSlnUfWQl2r30HZg=; b=DxSiu4zeHcAOi3 M3eTD4GCNSZoVAQNogIQZza7PnjPdOg3Ei10geONeJQne+K3LPqicFEoIu4j9lhZb3lBxYX0s7ZHw pUwb/mPqKmr9EceU7fChvikUumNO85eHQU8Tk/w7K+0n37TunyfwbCMmXhKLy7pFQKk4NXBWp35C8 stliJJ0dIJ7fp4NF7HwcW4B0nfwsWWWyIMbWP6DTTCRtdULZBtxC72HLiBP80vCJjqM8xbnxEUR62 D3qN4rRn2lrx6LfWCAD5OcxXbpzLiWqvRrIY3tte/tqqnSh14iY1z8WITgGHTka0uxyuXEjjRd/Rl j8OGPIVUD/RfsdgYtfnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9RbZ-008aeJ-6o; Fri, 30 Jul 2021 12:27:09 +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 1m9RbU-008adU-OD for linux-arm-kernel@lists.infradead.org; Fri, 30 Jul 2021 12:27:06 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B1F66103B; Fri, 30 Jul 2021 12:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627648024; bh=wT4Jmfp7K7e7610QIG6UJIKHHYTDycOajWViNs/FQzc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qOvuP+PZHGEQ6QFN9P+8FzxInej00GZmWtK4vwy+MZHMp1WOGMrViCMD0C4E/22gb MLo9g0h9j0QBO24ETL9yVk+AyNhZxKNKXxTWahTA5VCPHB65mgTEuHclGoqvxNecn5 35Rpc2I2tuELdVK3Zmf8w431pR7IeEuLHZVO1yZ2sGEVlACBETPeYaXCT47Gy4u1ca do/tEe5NT7emIko7C5viwa0FRQ9Lo27DJljdYaZCHS8xYb0RglMeBNuIdFY302g55t llilOsUMxh7gMxsM5V2437OQA72tkzPS28rHXsx8u+qJ0OcWkMXN/UpQzpy19blt9G Wl4B6Bo4b/VRw== Date: Fri, 30 Jul 2021 13:26:59 +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 04/16] KVM: arm64: Add MMIO checking infrastructure Message-ID: <20210730122658.GG23589@willie-the-truck> References: <20210715163159.1480168-1-maz@kernel.org> <20210715163159.1480168-5-maz@kernel.org> <20210727181107.GC19173@willie-the-truck> <8735ryep6d.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8735ryep6d.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_052704_850231_EF1A9CC1 X-CRM114-Status: GOOD ( 18.62 ) 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 10:57:30AM +0100, Marc Zyngier wrote: > On Tue, 27 Jul 2021 19:11:08 +0100, > Will Deacon wrote: > > On Thu, Jul 15, 2021 at 05:31:47PM +0100, Marc Zyngier wrote: > > > +bool kvm_install_ioguard_page(struct kvm_vcpu *vcpu, gpa_t ipa) > > > +{ > > > + struct kvm_mmu_memory_cache *memcache; > > > + struct kvm_memory_slot *memslot; > > > + int ret, idx; > > > + > > > + if (!test_bit(KVM_ARCH_FLAG_MMIO_GUARD, &vcpu->kvm->arch.flags)) > > > + return false; > > > + > > > + /* Must be page-aligned */ > > > + if (ipa & ~PAGE_MASK) > > > + return false; > > > + > > > + /* > > > + * The page cannot be in a memslot. At some point, this will > > > + * have to deal with device mappings though. > > > + */ > > > + idx = srcu_read_lock(&vcpu->kvm->srcu); > > > + memslot = gfn_to_memslot(vcpu->kvm, ipa >> PAGE_SHIFT); > > > + srcu_read_unlock(&vcpu->kvm->srcu, idx); > > > > What does this memslot check achieve? A new memslot could be added after > > you've checked, no? > > If you start allowing S2 annotations to coexist with potential memory > mappings, you're in for trouble. The faulting logic will happily > overwrite the annotation, and that's probably not what you want. I don't disagree, but the check above appears to be racy. > As for new (or moving) memslots, I guess they should be checked > against existing annotations. Something like that, but the devil is in the details as it will need to synchronize with this check somehow. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel