Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1301195rwr; Thu, 20 Apr 2023 12:55:05 -0700 (PDT) X-Google-Smtp-Source: AKy350Z26HRe4zw8iqDfD72TZ/9H88X1hKnXasfA0mPfaCjdEL0qy9jpkToFsbOnfDtSRVgiD0Qm X-Received: by 2002:a17:902:db11:b0:1a6:8405:f709 with SMTP id m17-20020a170902db1100b001a68405f709mr3334004plx.20.1682020504971; Thu, 20 Apr 2023 12:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682020504; cv=none; d=google.com; s=arc-20160816; b=C6usAuGfU2k0AvQ39nZyWfR4XA14MmUs0YNkAFA6HNhVpltlx5rMkU2ZiLNf4oymTP rlaUlxD+eBUwR5VNhWi2dQ31GcevWG75VWT+jy6WHlsXNKVHh6IfJTiGXJVmyuVFn2Ix aQpW7ThXQN2YiH3Z/vVpIU+Br9QkurrbwH71FLHoaVj5kEcRqevwqA6yb88dA/jb13+K vCm0g2bLn3hQz1G0B6pm/OKGlKT7Hf4yYUNlB9Gw1JLMFkmIIXn6d05ZQLgzwgI3Gmy4 tsQu8G16MieE1hRhX+DWpzPVpqJfcY8KMg23elAEb8Ucwj7g47rVtVUUoRUHVY8UgbO3 /J6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Pfv2B7nnglGPY5lKeYYJGgG41JxY4YTi9gYldIZZ2FA=; b=k0kibNWvcuUmqVRffPuCq+pj9o/nlRX4MianmgEs2i7/zZLad+jKsA2eAXTFpNk3JQ wLTMq5WccNo6G2KCKQKZNsGGtxGBCgRR1TTVLuJiJu1JFmeGCVBKUJaMEqX3rntZq/Pt y8Mx0MY4oXBT+NxionIZj0Q7s6nAUtJe7MF8PM8STJKFtqcNtOLxaotUvkbW/YXpzswu rCwksPghct7bJxv7JHq6AAVesliSf0CT/oMhQmxOvl3hOa+/2VSJy2uFw3xu3ucFgmOQ 8Dxbkdd7U7tjkbJXCF1okziExBLnfod/bIE65qrrEeBhoa/j/NzMPbDBihNmdchMWodM 2+AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MYgjyypq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170903228900b0019f28eff6f9si1428260plh.502.2023.04.20.12.54.50; Thu, 20 Apr 2023 12:55:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MYgjyypq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232094AbjDTTmt (ORCPT + 99 others); Thu, 20 Apr 2023 15:42:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjDTTmr (ORCPT ); Thu, 20 Apr 2023 15:42:47 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E9244BA; Thu, 20 Apr 2023 12:42:45 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f17fdb520dso9511895e9.3; Thu, 20 Apr 2023 12:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682019764; x=1684611764; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Pfv2B7nnglGPY5lKeYYJGgG41JxY4YTi9gYldIZZ2FA=; b=MYgjyypqswmQG6YtHr/gj3invlgUzYkrg/aPTuFdvQHZPL/YO5i4PF32XnyH1ZTGQz b734vWMYMbVsbbO/M9Wal3nSfPgVsr/VlA1Dm+srAgGFmF6Lp0bnhVphG5TcywnqlxEN otaG9qzSCRigVoIglNcR4SbSXcfghPUb5gc1+7NJi53TmMDnoeaSS5N3K/ZZKyvKhMOv my1Eafov4Ugs+psmIfSzuTUTr7xCxd+xW3qLejMV+2Hr7Qjwm/CzXTt6GkSmEByoLwgT dJD5ky+Ow1cBOXG8ZlV7MdBSFET0Faa917sHxhy0dYFJroREl5QPGJjugg/sG4kskK5K ewTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682019764; x=1684611764; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Pfv2B7nnglGPY5lKeYYJGgG41JxY4YTi9gYldIZZ2FA=; b=Npo0KEOQCoEnwE3SDwCBtmG5piRswqWvgtMhOPpm7euyhVQC4LhklMB1yUaApUVwjJ 2BtZierjRNqrojUguWyVSXvXfIqYEtoYauLQl+JFnLJDqNzvd6J7YTAoIIQ/1s0XACOa FgyPz/T+8E5l/L0jD4Z1j/gQJCltG0PMkdV0qNdFnYn53BB82r76u2e875eOeGG5iY4E uWZJDtRdUyt7riZnEahN1ORokgufXojDZ/pDy3Io4gyDHr+9yST9yRCHXpii9lY4kJpp wUbizt1u+xyKLtcMTjIZ+MviPu9Ehznd/ww1wC3CXYSlKJLTjd0UBMbc/zSE2aNswIwv BIrw== X-Gm-Message-State: AAQBX9d73hK/sxvXns9RAutivFvvQNQc70hzbe6KazddYqiY2nEUFvhX /bDV+5rJyBmNzDgJw0E7YKU= X-Received: by 2002:a7b:ca43:0:b0:3eb:3945:d405 with SMTP id m3-20020a7bca43000000b003eb3945d405mr34247wml.38.1682019764130; Thu, 20 Apr 2023 12:42:44 -0700 (PDT) Received: from localhost (host86-156-84-164.range86-156.btcentralplus.com. [86.156.84.164]) by smtp.gmail.com with ESMTPSA id j32-20020a05600c1c2000b003f173987ec2sm6257438wms.22.2023.04.20.12.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 12:42:43 -0700 (PDT) Date: Thu, 20 Apr 2023 20:42:42 +0100 From: Lorenzo Stoakes To: Atish Patra Cc: linux-kernel@vger.kernel.org, Rajnesh Kanwal , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Christoph Hellwig , Conor Dooley , Greg Kroah-Hartman , Guo Ren , Heiko Stuebner , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Mayuresh Chitale , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Uladzislau Rezki Subject: Re: [RFC 01/48] mm/vmalloc: Introduce arch hooks to notify ioremap/unmap changes Message-ID: References: <20230419221716.3603068-1-atishp@rivosinc.com> <20230419221716.3603068-2-atishp@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230419221716.3603068-2-atishp@rivosinc.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I'm a vmalloc reviewer too now -next/mm-unstable get_maintainer.pl should say so, but forgivable because perhaps you ran against another tree but FYI for future I'd appreciate a cc- :) On Wed, Apr 19, 2023 at 03:16:29PM -0700, Atish Patra wrote: > From: Rajnesh Kanwal > > In virtualization, the guest may need notify the host about the ioremap > regions. This is a common usecase in confidential computing where the > host only provides MMIO emulation for the regions specified by the guest. > > Add a pair if arch specific callbacks to track the ioremapped regions. Nit: typo if -> of. > > This patch is based on pkvm patches. A generic arch config can be added > similar to pkvm if this is going to be the final solution. The device > authorization/filtering approach is very different from this and we > may prefer that one as it provides more flexibility in terms of which > devices are allowed for the confidential guests. So it's an RFC that assumes existing patches are already applied or do you mean something else here? What do I need to do to get to a vmalloc.c with your patch applied? I guess this is pretty nitty since your changes are small here but be good to know! > > Signed-off-by: Rajnesh Kanwal > Signed-off-by: Atish Patra > --- > mm/vmalloc.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index bef6cf2..023630e 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -304,6 +304,14 @@ static int vmap_range_noflush(unsigned long addr, unsigned long end, > return err; > } > > +__weak void ioremap_phys_range_hook(phys_addr_t phys_addr, size_t size, pgprot_t prot) > +{ > +} > + > +__weak void iounmap_phys_range_hook(phys_addr_t phys_addr, size_t size) > +{ > +} > + I'm not sure if this is for efficiency by using a weak reference, however, and perhaps a nit, but I'd prefer an arch_*() that's defined in a header somewhere, as it does hide the call paths quite effectively. > int ioremap_page_range(unsigned long addr, unsigned long end, > phys_addr_t phys_addr, pgprot_t prot) > { > @@ -315,6 +323,10 @@ int ioremap_page_range(unsigned long addr, unsigned long end, > if (!err) > kmsan_ioremap_page_range(addr, end, phys_addr, prot, > ioremap_max_page_shift); > + > + if (!err) > + ioremap_phys_range_hook(phys_addr, end - addr, prot); > + > return err; > } > > @@ -2772,6 +2784,10 @@ void vunmap(const void *addr) > addr); > return; > } > + > + if (vm->flags & VM_IOREMAP) > + iounmap_phys_range_hook(vm->phys_addr, get_vm_area_size(vm)); > + There are places other than ioremap_page_range() that can set VM_IOREMAP, e.g. vmap_pfn(), so this may trigger with addresses other than those specified in the original hook. Is this intended? > kfree(vm); > } > EXPORT_SYMBOL(vunmap); > -- > 2.25.1 >