Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp264138rdd; Wed, 22 Nov 2023 15:37:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHznb8AbcP696D3z/DIGnMcKaNa8tYQYHycO8/tHbjfylUqyuS1D1+bI7DvJYhfQoVoihzA X-Received: by 2002:a17:90b:4d8b:b0:27e:277:3015 with SMTP id oj11-20020a17090b4d8b00b0027e02773015mr4522545pjb.16.1700696261673; Wed, 22 Nov 2023 15:37:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700696261; cv=none; d=google.com; s=arc-20160816; b=gUnqPyCAY7QtzqIo5bkkEIbYrKMNqsHmEJ+GiSJKYaITOadz5Pm9OlA4hwM6/eJab8 YXBZ0WHDlCydpW9qJw9aQqmmk7L0+O6EcCy2hKCcuIYAvnQBbzoRyDhHIancnbbv3Sgz Sn7udJKcsRiNYhxebnZnaCKF4KaG8COKC+wflg2rGV0Sx1wK0RdDrS1XLVDANOkEPFz5 idhXAuFRZ1dVul2sTcW3BGJIPdVzsfnwPEDaGOpiYHhRzAldNO0DlH7zPLC9I1Cbm/rK dT5VeePW62A9ja5z48VqihtdmCRRJFS6OIEaHpL1McA8HVA8pMxbK1sV+Zm67yBil4Nt 17Gg== 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:dkim-signature:date; bh=PXyWegmwCnXnOPFvQ6LT5Yd+ik2iCdUmtXvgYfqocuM=; fh=yT+A6FPEZlMOuSm5kJ2iVXd4DHLGSAFlICh4O+Gupjo=; b=fpJBR8Cn04LwG3DHJU+vW53C7QIcn4W9RLoBiv+RU8s78lTCgIQa4X8FYq8ucuAoqJ AZ2vs47AeGfmoRsH19YJWII8cx6WjuGul1jTadpHp+W668kXrS1qkD0R82gzyBa/hTFh SVsE8b0Tsz3nV3nDb7+pOUEpbo33DuRO7eJQ4XjBDEYjN0Zt7DPlwYYxeI0UsMvkQZyw 2maatom6tC/5ISZ+9zk7SiLB0PAuXYRphXZEGpL0U8sZ1C6Qm7DWTbnEbJrX1ByobLs/ ZYxo94r04T/EEnbvNX76gKi110XvdWw4tcPnKuKnHkJKwXcSFd1L+k2bn5V1HadYsL+U acnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=e4pm5gE3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id u4-20020a170902e80400b001cf5cc12c86si485468plg.246.2023.11.22.15.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 15:37:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=e4pm5gE3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5C834808002A; Wed, 22 Nov 2023 15:36:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231817AbjKVXgJ (ORCPT + 99 others); Wed, 22 Nov 2023 18:36:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231594AbjKVXgI (ORCPT ); Wed, 22 Nov 2023 18:36:08 -0500 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [IPv6:2001:41d0:1004:224b::b6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 635141B3 for ; Wed, 22 Nov 2023 15:36:04 -0800 (PST) Date: Wed, 22 Nov 2023 23:35:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700696162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PXyWegmwCnXnOPFvQ6LT5Yd+ik2iCdUmtXvgYfqocuM=; b=e4pm5gE3C8oJZdXhVRFH6B7ru6llu+TZOT2vj+rXc1A8XJ/IzaHkbbHIXWc/cKv42uWKbQ Lv+4Edhcgo35m59DoNtbxqh6HwTcWq7482blb85/acmgy7R7sBHRgCqBB8AY+KQ44fZcpn xOvVYVFoyPrW/OtqEgeifOUQ/uFxH7A= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sebastian Ene Cc: will@kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vdonnefort@google.com, qperret@google.com, smostafa@google.com Subject: Re: [PATCH v3 10/10] arm64: ptdump: Add support for guest stage-2 pagetables dumping Message-ID: References: <20231115171639.2852644-2-sebastianene@google.com> <20231115171639.2852644-12-sebastianene@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231115171639.2852644-12-sebastianene@google.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 15:36:30 -0800 (PST) On Wed, Nov 15, 2023 at 05:16:40PM +0000, Sebastian Ene wrote: > +struct ptdump_registered_guest { > + struct list_head reg_list; > + struct ptdump_info info; > + struct kvm_pgtable_snapshot snapshot; > + rwlock_t *lock; > +}; Why can't we just store a pointer directly to struct kvm in ::private? Also, shouldn't you take a reference on struct kvm when the file is opened to protect against VM teardown? > +static LIST_HEAD(ptdump_guest_list); > +static DEFINE_MUTEX(ptdump_list_lock); What is the list for? > static phys_addr_t ptdump_host_pa(void *addr) > { > return __pa(addr); > @@ -757,6 +768,63 @@ static void stage2_ptdump_walk(struct seq_file *s, struct ptdump_info *info) > kvm_pgtable_walk(pgtable, start_ipa, end_ipa, &walker); > } > > +static void guest_stage2_ptdump_walk(struct seq_file *s, > + struct ptdump_info *info) > +{ > + struct ptdump_info_file_priv *f_priv = > + container_of(info, struct ptdump_info_file_priv, info); > + struct ptdump_registered_guest *guest = info->priv; > + > + f_priv->file_priv = &guest->snapshot; > + > + read_lock(guest->lock); > + stage2_ptdump_walk(s, info); > + read_unlock(guest->lock); Taking the mmu lock for read allows other table walkers to add new mappings and adjust the granularity of existing ones. Should this instead take the mmu lock for write? > +} > + > +int ptdump_register_guest_stage2(struct kvm *kvm) > +{ > + struct ptdump_registered_guest *guest; > + struct kvm_s2_mmu *mmu = &kvm->arch.mmu; > + struct kvm_pgtable *pgt = mmu->pgt; > + > + guest = kzalloc(sizeof(struct ptdump_registered_guest), GFP_KERNEL); You want GFP_KERNEL_ACCOUNT here. -- Thanks, Oliver