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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 60382E7D274 for ; Tue, 26 Sep 2023 09:55:14 +0000 (UTC) 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=IY+f8S+M/K5LmtAxgY0Z4H5UYX6GHdcLjchjNFWbIYY=; b=46yRYObXrFOg8v 92PU9MBdDxMFvt1ld66JfwcKxDdkC2wi48xWt0KoEc91IGptVhcS/9yCmNF7d+tCeshzNG2jfZLPB v0M9eLWNrWGGXRBgq8nnHI37s9vRpcEfE1Gj7Idb4nNnEFo7JCnaufAeYtvGVXkp0SnMSZQWVo3kJ 6FPx1ZiVr6p3/g7oraeXOORj04bUEOvycVCj4e4dVbCDtrgTjRIclHTTRh1YWKAJ6mjFxmLaDm+/M 5OykZrIRlEXpOL5w1kl1uP99Jg/HHKYA4UA5VBnpugrmJMAQA8UWFjvEMwu74K/y/3EtV9QGk5Fu8 nS6CWbJUlzwjyxoTfIPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ql4mB-00G0Lp-2I; Tue, 26 Sep 2023 09:54:43 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ql4m9-00G0LA-09 for linux-arm-kernel@lists.infradead.org; Tue, 26 Sep 2023 09:54:42 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-53074ee0c2aso11043a12.1 for ; Tue, 26 Sep 2023 02:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695722076; x=1696326876; darn=lists.infradead.org; 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=6RX+RxNThxWlZjWaBBvh6220YGe9sto71QyN0kHdm+4=; b=ffTbKB+ceCK/Yu8XlsTMRhK5TgjjyE8lDF1KNxBQ6cSa0nnbeOY3VkUlu5DTJDCfQX y/d4fdRyzk1QIz0FnVmsOLjeKsE/CB3xDK1ONVwV+HI3Gvx//C7Zl//+gRxbOzl37/SX AWkwyyAxLtKOF+/e5GhaQUHOtimjQIwKfVe7lvOS1SGcDY79pQCqpPBc5e0tAXiYfspy UttD+LvjfNfbJgOwSCHUJE9zCUbdfGmtfSoPT3vqfC3z//SE8YJbT+NRHAp+qNq51FxH q+Z5fYDSVncgv538PURiWuEISvI2UJVlUPsKfwleYZ6zNi1EvLWS1iO4W8Wqdr7anK/3 /WvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695722076; x=1696326876; 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=6RX+RxNThxWlZjWaBBvh6220YGe9sto71QyN0kHdm+4=; b=I7Z6sbB26cxF8uQtaFydJWZMbiu7N08+2IVKKiAvykt2qxLaaZhL4KJhbouX+KUY9c KV9njN//puhMJJJOvWIYhk50TB/cAQE7yRcTHGFqYNqV8QxbpEToCxBb/VIVt89nmxpX n6YfDm8zskq4NdccbrG95/D4ZG4HV7VQ17ZqzVayHZWXJP2x62zHE7zCVoiKWMJ8wY2P VLkKkxHTwb75YHjVTdxXCVOPDbKqKmsyyQknWwCN2tyWMUHeya0SOBEDLxngyyvz4iRx +o93wkuPPiFoyGjlAas0zePdy3F1vyvtt8nqyGuH/lcspjcNxxLZMmYi0ED+BsRomFly mqog== X-Gm-Message-State: AOJu0YyWJhqzWPAKxLP6UUHIXkP2QmHGwzoRqAzLqHZjmQJdl5mu7nlj Po7vRpDvciRVA8ztJ1E/DPuY6Q== X-Google-Smtp-Source: AGHT+IH0oPXZ48Gz2F+rYGnYegliWL0EvgOHsb6Ik8iDn17MeOfSc7/8iYbXOPOHUtU7T66FPETntw== X-Received: by 2002:a50:9fef:0:b0:523:b133:57fe with SMTP id c102-20020a509fef000000b00523b13357femr77612edf.1.1695722076407; Tue, 26 Sep 2023 02:54:36 -0700 (PDT) Received: from google.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id q18-20020adfb192000000b0031f8a59dbeasm1842861wra.62.2023.09.26.02.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 02:54:35 -0700 (PDT) Date: Tue, 26 Sep 2023 09:54:31 +0000 From: Mostafa Saleh To: Jean-Philippe Brucker Cc: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, joro@8bytes.org, robin.murphy@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, dbrazdil@google.com, ryan.roberts@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, iommu@lists.linux.dev Subject: Re: [RFC PATCH 40/45] iommu/arm-smmu-v3-kvm: Add IOMMU ops Message-ID: References: <20230201125328.2186498-1-jean-philippe@linaro.org> <20230201125328.2186498-41-jean-philippe@linaro.org> <20230925171853.GA2068481@myrica> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230925171853.GA2068481@myrica> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230926_025441_084066_98F68221 X-CRM114-Status: GOOD ( 21.79 ) 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 Hi Jean, On Mon, Sep 25, 2023 at 06:18:53PM +0100, Jean-Philippe Brucker wrote: > On Wed, Sep 20, 2023 at 04:27:41PM +0000, Mostafa Saleh wrote: > > > +static void kvm_arm_smmu_domain_free(struct iommu_domain *domain) > > > +{ > > > + int ret; > > > + struct kvm_arm_smmu_domain *kvm_smmu_domain = to_kvm_smmu_domain(domain); > > > + struct arm_smmu_device *smmu = kvm_smmu_domain->smmu; > > > + > > > + if (smmu) { > > > + struct host_arm_smmu_device *host_smmu = smmu_to_host(smmu); > > > + > > > + ret = kvm_call_hyp_nvhe(__pkvm_host_iommu_free_domain, > > > + host_smmu->id, kvm_smmu_domain->id); > > > + /* > > > + * On failure, leak the pgd because it probably hasn't been > > > + * reclaimed by the host. > > > + */ > > > + if (!WARN_ON(ret)) > > > + free_pages(kvm_smmu_domain->pgd, host_smmu->pgd_order); > > I believe this doube-free the pgd in case of attatch_dev fails, as it > > would try to free it their also (in kvm_arm_smmu_domain_finalize). > > > > I think this is right place to free the pgd. > > Since this depends on kvm_smmu_domain->smmu being non-NULL, which is only > true if finalize() succeeded, then we shouldn't get a double-free. Yes, the other free was comming from an experiment I was making to use the IOMMU layer with guest VMs, so this is correct. Sorry about that. > But finalize() does leak kvm_smmu_domain->id if the pgd allocation fails, > I fixed that. Thanks! > Thanks, > Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel