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 64059C6FD1C for ; Wed, 22 Mar 2023 10:25:04 +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=K5H2JyxrkBwpykyjGlnuumHiz8j955fEFag/XaYXuXo=; b=gSku0p+kiwd3hU k2JdOMkysplDt5G+/wMdoM6gUnr0wxbHWyGFW5pdyO/sReGv00tMx6aVh8u7+9eUVc900TdetwqHb ZfMt4Y3Tw1qrW7lgSM2H/LYjoDBU9PUWNGgJaO/Jgd0oUGmF9525F4hJbKmW4OQHW5ZBUnLDBn0z3 CUqqTtjTPJdljV+VHdYIg7f6MluvNVIOmKWu8mpyACE7mF816OgvTspgsDWXl06+V8K2UAXdH3XBR aVdg2hhiWrHQKCRF9u9/G9+zDdS8TyQY6qfSe7CcBfRk4QB2botviOMjW7ufd9xFKptFjv9YL7ijt gL/Oka+dchpd9riOANrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pevdT-00FdAm-1a; Wed, 22 Mar 2023 10:24:03 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pevdQ-00Fd9C-37 for linux-arm-kernel@lists.infradead.org; Wed, 22 Mar 2023 10:24:02 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3ed3080d17bso10765e9.0 for ; Wed, 22 Mar 2023 03:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679480635; 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=mcDRlGqb6Azx/x9zIxUH1xj8S/fV5DxJOLYKrwe15TU=; b=b9wczk/RvzcvFUi12dsmCX/dOp168FNB/SofHTHB0xagYDW5bzYNCsxLv8oNlbpPrK ZjD9DO5iSb2Vm2D/61rXC644sDbVjg56fHs/fY+0K8FEb2LHGQGJZH71ZLYSdF4K05a9 4cJVG7d4bcGG8TWLurN45B+JegyERpBhQP5uoNdcwXGJoAaE1ipCg+CE2HstLhaBcLoU 98rMKepuI+GZLDwDZSHRISsqO2IbuMWWiWyRhbSHS0+b1fQGgVC8Q4+FjaLviFbbA+uA 46S8lM2iCvIAQhazV4ySTlQcjLZ2x4XLbLG7zp9qFH3OUFyN9pd8Xq9taLn40wgOvBJh ACNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679480635; 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=mcDRlGqb6Azx/x9zIxUH1xj8S/fV5DxJOLYKrwe15TU=; b=KKrY+Yh0rzHcTS3tTHO4EgWiwxMkgUvTYIQb+novMJsiieApJh8bXgk5FiXTElNaoF COL7mfPnozT5OQ/TgxGL9+3KYxhWiYDZZ2niaZF4DcA0/T3cJwpYVrgBLhQTtsWvpJjk l8dQRamu4EnC3NGghoYn2DwaG8EsIR9rMbfxpiB92INkpVNWHSqAD0fQ1vjHg5BmrSKl t28OrWynxOfdUdAwJNoWSv5cpDB8ETj5Mn6/p5tyddIsOvdl9jn0OOFFXKZZCP/+RiMT CSeHTUJOaAn0zfsSAjs0DxDFEWoKXlkoFzv+jOTS0pmq1xr8jBEVoAROe7FiVRiYa3+P h4mA== X-Gm-Message-State: AO0yUKUxGarfGbcmJesn2nWHpUf8NrUUUiTEd2WaVN9JCPCL7N2uCi/o n4U4FcIces0s+N83eIV/Y+1HcQ== X-Google-Smtp-Source: AK7set/RxnGBHvENZoN3y84D3iy9ZfTLiNg7s6OFbvMVV5PfOCNdV5jQnhbS+sVxArHm8nYHBg02hg== X-Received: by 2002:a05:600c:3d0c:b0:3df:f3cb:e8ce with SMTP id bh12-20020a05600c3d0c00b003dff3cbe8cemr108656wmb.7.1679480635095; Wed, 22 Mar 2023 03:23:55 -0700 (PDT) Received: from google.com (44.232.78.34.bc.googleusercontent.com. [34.78.232.44]) by smtp.gmail.com with ESMTPSA id y16-20020a056000109000b002c56013c07fsm13394867wrw.109.2023.03.22.03.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 03:23:54 -0700 (PDT) Date: Wed, 22 Mar 2023 10:23:50 +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 39/45] iommu/arm-smmu-v3-kvm: Initialize page table configuration Message-ID: References: <20230201125328.2186498-1-jean-philippe@linaro.org> <20230201125328.2186498-40-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230201125328.2186498-40-jean-philippe@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230322_032401_005580_B82283B1 X-CRM114-Status: GOOD ( 26.25 ) 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 Wed, Feb 01, 2023 at 12:53:23PM +0000, Jean-Philippe Brucker wrote: > Prepare the stage-2 I/O page table configuration that will be used by > the hypervisor driver. > > Signed-off-by: Jean-Philippe Brucker > --- > .../iommu/arm/arm-smmu-v3/arm-smmu-v3-kvm.c | 29 +++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kvm.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kvm.c > index 755c77bc0417..55489d56fb5b 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kvm.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kvm.c > @@ -16,6 +16,7 @@ struct host_arm_smmu_device { > struct arm_smmu_device smmu; > pkvm_handle_t id; > u32 boot_gbpa; > + unsigned int pgd_order; > }; > > #define smmu_to_host(_smmu) \ > @@ -192,6 +193,7 @@ static int kvm_arm_smmu_probe(struct platform_device *pdev) > size_t size; > phys_addr_t ioaddr; > struct resource *res; > + struct io_pgtable_cfg cfg; > struct arm_smmu_device *smmu; > struct device *dev = &pdev->dev; > struct host_arm_smmu_device *host_smmu; > @@ -233,6 +235,31 @@ static int kvm_arm_smmu_probe(struct platform_device *pdev) > if (!kvm_arm_smmu_validate_features(smmu)) > return -ENODEV; > > + /* > + * Stage-1 should be easy to support, though we do need to allocate a > + * context descriptor table. > + */ > + cfg = (struct io_pgtable_cfg) { > + .fmt = ARM_64_LPAE_S2, > + .pgsize_bitmap = smmu->pgsize_bitmap, > + .ias = smmu->ias, > + .oas = smmu->oas, > + .coherent_walk = smmu->features & ARM_SMMU_FEAT_COHERENCY, > + }; > + > + /* > + * Choose the page and address size. Compute the PGD size and number of > + * levels as well, so we know how much memory to pre-allocate. > + */ > + ret = io_pgtable_configure(&cfg, &size); size variable is overwritten here with pgd size, while used later on the assumption it still contains the SMMU MMIO size. This looks like it is not intended? > + if (ret) > + return ret; > + > + host_smmu->pgd_order = get_order(size); > + smmu->pgsize_bitmap = cfg.pgsize_bitmap; > + smmu->ias = cfg.ias; > + smmu->oas = cfg.oas; > + > ret = arm_smmu_init_one_queue(smmu, &smmu->cmdq.q, smmu->base, > ARM_SMMU_CMDQ_PROD, ARM_SMMU_CMDQ_CONS, > CMDQ_ENT_DWORDS, "cmdq"); > @@ -253,6 +280,8 @@ static int kvm_arm_smmu_probe(struct platform_device *pdev) > hyp_smmu->mmio_addr = ioaddr; > hyp_smmu->mmio_size = size; > hyp_smmu->features = smmu->features; > + hyp_smmu->iommu.pgtable_cfg = cfg; > + > kvm_arm_smmu_cur++; > > return 0; > -- > 2.39.0 > Thanks, Mostafa _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel