Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4599918pxv; Tue, 27 Jul 2021 11:14:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0zVJP2IrX4Bui7U3P9dmGJvE/lEq/ew3iSkJ/lI9fguDkt425GRRVWCm1VLVxShKD0Ke4 X-Received: by 2002:a05:6e02:190d:: with SMTP id w13mr18265510ilu.53.1627409681187; Tue, 27 Jul 2021 11:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627409681; cv=none; d=google.com; s=arc-20160816; b=hxj8qxH424QwsqriEiQe0WehI5DJGpM+KblXczJ651eduncY/UrPh5i1Hfx8dGqFam R5dEzyyblggHilmWEgLCaLhfXBlIUhsMUXAqJIepi+jfbbVWRSYcZvF0Owkttje+diZD webtpfqun3KDwpy1QgGBcIqD24MJdmA1wrOG8Y2N1u76WQrtCGY+p4TW2Qu9+XcTCTtb sgU9wHv1/SANDAfmD/87nMSD3a7y48huOO8ZzGZ5avA4aki9AU7dLEVdtUh8A5+/NnPd d/zaOx6k/+Jo+DqvWzRlXo3lKOQlJPumCOzsxE0bzUFaTH/BTqhN6sSiNh58N58DrcmX PJsw== 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=shaXX6uKk71j6mzZIODONYPcEd7ZwJhNckCi6rOk3Ag=; b=p5wN56IcPTxEZoUMMLpTgx/RSaUZN5oZCSmDlcwxiG9Z4jxg8NnwJ/7TwGTx6wsJWP avgl+MIkMf/0bMXdbt4z5vCgzdePen3KzZKmykxUEom3OiMY6ZJtYj+5xRSeo41NZmqk 5Gfnyzm70Zs/c6+kvQl6AJlCJYf8ZRQrZkV/bfBqSojRSz7ixcV94Q0lEYYtIoj778Zh GiYFcWleT47WOSaNpzHpCi7c4KHD8bxMisXW4QM4xrWoZJONwn1Mre6ZDBKNsCIbk2/m 7NLHQ5QVzYd6v7NyeR9XvZJs6HcRz7RzC57uNUAyTkIdCDYAy5IX5JwBujKifZ/poEVP zRFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cpxx1nir; 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 q14si4088656ils.147.2021.07.27.11.14.29; Tue, 27 Jul 2021 11:14:41 -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=cpxx1nir; 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 S232002AbhG0SMJ (ORCPT + 99 others); Tue, 27 Jul 2021 14:12:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:54902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbhG0SMJ (ORCPT ); Tue, 27 Jul 2021 14:12:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD3946056B; Tue, 27 Jul 2021 18:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627409529; bh=fUgkuFB9VQtgL1VRh8fF7edi9U2ibRcCUZV2oZL57h8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cpxx1nirtagKB64kip87dBNB4SjfC/kG0WM5+aseu385nTOwDTylRCPPxcHHEKwf4 S/qfl0CnSLCp9sK+uhtUVArERHSiTR7kkyPKN3sq91+Zg5hJSy5mlTys4lOcf64vbg Uzt9HkAx8h1hcXSUxH2ZVPiwZInxVvvWK6Yd2+f2RvEJSo7d4I04xtqexTPdTbtzSq 6pPq1ijZab66hHRoS6BHWS/xdQG0UfWek6Cq3yLNt+lx7b1GmqOeo3uT4+9QhCTbuj obYyb3hXWK+0f4QnJlejAIT2PVix0kDbobIpTmsJqi74OX4pei/3hFhpxQmVgnTisi P/T7JGHLrHYog== Date: Tue, 27 Jul 2021 19:12:04 +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 12/16] mm/ioremap: Add arch-specific callbacks on ioremap/iounmap calls Message-ID: <20210727181203.GG19173@willie-the-truck> References: <20210715163159.1480168-1-maz@kernel.org> <20210715163159.1480168-13-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210715163159.1480168-13-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 Thu, Jul 15, 2021 at 05:31:55PM +0100, Marc Zyngier wrote: > Add a pair of hooks (ioremap_page_range_hook/iounmap_page_range_hook) > that can be implemented by an architecture. > > Signed-off-by: Marc Zyngier > --- > include/linux/io.h | 3 +++ > mm/ioremap.c | 13 ++++++++++++- > mm/vmalloc.c | 8 ++++++++ > 3 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/include/linux/io.h b/include/linux/io.h > index 9595151d800d..0ffc265f114c 100644 > --- a/include/linux/io.h > +++ b/include/linux/io.h > @@ -21,6 +21,9 @@ void __ioread32_copy(void *to, const void __iomem *from, size_t count); > void __iowrite64_copy(void __iomem *to, const void *from, size_t count); > > #ifdef CONFIG_MMU > +void ioremap_page_range_hook(unsigned long addr, unsigned long end, > + phys_addr_t phys_addr, pgprot_t prot); > +void iounmap_page_range_hook(phys_addr_t phys_addr, size_t size); > int ioremap_page_range(unsigned long addr, unsigned long end, > phys_addr_t phys_addr, pgprot_t prot); > #else Can we avoid these hooks by instead not registering the regions proactively in the guest and moving that logic to a fault handler which runs off the back of the injected data abort? From there, we could check if the faulting IPA is a memory address and register it as MMIO if not. Dunno, you've spent more time than me thinking about this, but just wondering if you'd had a crack at doing it that way, as it _seems_ simpler to my naive brain. Will