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 4B23ACE7AA8 for ; Mon, 25 Sep 2023 17:19:24 +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=GaXkmB/NSBs9aTfsfN9sSpz3OlawBDWqHkLS7XVUcoA=; b=J0m5fx6nQI4zmh WtOXzUriIEOgQjhaVdkLTBg+j6z5Q5Wby6hTzk7vAWgjUC9AOGgH1Oj5FU1bwBK1foSL+C2WoMbEU bRKc0gzoz8hgcmFN/nw7nBqTqleXhK+MywgyHykR3MnKK/ufxrnLECOgst9pBbEkczkMuDja8iGbw zfTxfjN2p2VaLkH3jhBSH/ZUslm+CYkZXPRF1mYu9ocbbR9MhlUBa01Cp6EGFCv6y3lHWsu0h2Exr 1XYCP8g02Ybx4ILz0FHFqeAmC2Ozt166ZXCCoUFjCPA+JK4hDvDvYJJhyv3Pa4He3Ay2P74/WPMFO t6qhHXnQdrLqvz3HRKCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkpEW-00EjqA-2m; Mon, 25 Sep 2023 17:18:56 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkpEU-00EjpL-2d for linux-arm-kernel@lists.infradead.org; Mon, 25 Sep 2023 17:18:56 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31fa15f4cc6so6682830f8f.2 for ; Mon, 25 Sep 2023 10:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695662328; x=1696267128; 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=+tciPN/nxlvJ0kD/I8pIzAtOjgHRjqQjNn6wevcTJGg=; b=UMIimIXrKz3l5KklGuUTPvxE4Mgr58hnIMo+k1CsLYw1tXZLHXxXIPX9vpTCDbzDyP A8sEuU7xRxzrS4UyaT5i70Yknv6YEwbclse2dHa6RW4wFSmuSANTQOrP4REijB7tZmEF xo2x2GoI+9i6Kvj613VsknjBaFCVEfN7F2Uq1WWt/QIH1eMLsvugUj9kKRfBFefvinyw JD3Oiuo7+1aj0sB4i+aSLUCOGy4ZObEigSsmXH6Qc5/dq9bXe9mWWz4jObTcDdDPTM+m 9GXyg35rVBJpx/IleLMtzeKRcBfqC/NomUCHgtfmm70eY+B5uvPpdnkIrCld9sMeMPJu 8+cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695662328; x=1696267128; 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=+tciPN/nxlvJ0kD/I8pIzAtOjgHRjqQjNn6wevcTJGg=; b=qHWM7t5XzLClFVA61gh2zVazfMlnL6jcnKXb76WkW4Y1MV4bPMsiP0P+knE8BScecO woQbODhz5n+vzE5tarCiLUnEgdVKB/8MD/3S3zTExLulmpPJyNp1ZaJ4kZkv5heHZAsM vCmqIpIaAZ06qiOqt+aW6G7OQeGryij0lGor3AfQ/Lk7Ru9rBmRYGupGBG84DcJAoTTi Mpt7DkglSWIxIKntscbzqfFOYA3Mh4CO1SRU7UCKCzjD3VqOMwhci9EnalvptnDMnW3+ OZ2KETKAPV95dAqYQcF3jbRBGGEEW11XEFRt5lhpmbLHPokQfR8aZHD37w+ptVMklhib rHww== X-Gm-Message-State: AOJu0YzGSBeNAyyiudarz5cZhmLt0fRHRtamGUPf6VCF1pokpTXBnXnw la/C8aKx1phpu+2m+Rd2Hnw9IQ== X-Google-Smtp-Source: AGHT+IGqhtUhSeoHDeBBUcu7FhFEX2xileNPxVaKSeBdM/QI+UNynZlC0Y4NrgOPfhgrgwDOmSC0uQ== X-Received: by 2002:a05:6000:1a54:b0:31f:8999:c3fe with SMTP id t20-20020a0560001a5400b0031f8999c3femr5751965wry.69.1695662328188; Mon, 25 Sep 2023 10:18:48 -0700 (PDT) Received: from myrica ([2a02:c7c:7290:b00:fd32:2b31:6755:400c]) by smtp.gmail.com with ESMTPSA id m16-20020a056000009000b0031c71693449sm12449193wrx.1.2023.09.25.10.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 10:18:47 -0700 (PDT) Date: Mon, 25 Sep 2023 18:18:53 +0100 From: Jean-Philippe Brucker To: Mostafa Saleh 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: <20230925171853.GA2068481@myrica> References: <20230201125328.2186498-1-jean-philippe@linaro.org> <20230201125328.2186498-41-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230925_101854_854160_7FB2C20C X-CRM114-Status: GOOD ( 16.66 ) 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, 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. But finalize() does leak kvm_smmu_domain->id if the pgd allocation fails, I fixed that. Thanks, Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel