[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB5276220C7B2C5743DC8364CB8CBA2@BN9PR11MB5276.namprd11.prod.outlook.com>
Date: Wed, 23 Apr 2025 08:05:49 +0000
From: "Tian, Kevin" <kevin.tian@...el.com>
To: Nicolin Chen <nicolinc@...dia.com>
CC: "jgg@...dia.com" <jgg@...dia.com>, "corbet@....net" <corbet@....net>,
"will@...nel.org" <will@...nel.org>, "robin.murphy@....com"
<robin.murphy@....com>, "joro@...tes.org" <joro@...tes.org>,
"thierry.reding@...il.com" <thierry.reding@...il.com>, "vdumpa@...dia.com"
<vdumpa@...dia.com>, "jonathanh@...dia.com" <jonathanh@...dia.com>,
"shuah@...nel.org" <shuah@...nel.org>, "praan@...gle.com" <praan@...gle.com>,
"nathan@...nel.org" <nathan@...nel.org>, "peterz@...radead.org"
<peterz@...radead.org>, "Liu, Yi L" <yi.l.liu@...el.com>,
"jsnitsel@...hat.com" <jsnitsel@...hat.com>, "mshavit@...gle.com"
<mshavit@...gle.com>, "zhangzekun11@...wei.com" <zhangzekun11@...wei.com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>, "linux-doc@...r.kernel.org"
<linux-doc@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "linux-tegra@...r.kernel.org"
<linux-tegra@...r.kernel.org>, "linux-kselftest@...r.kernel.org"
<linux-kselftest@...r.kernel.org>, "patches@...ts.linux.dev"
<patches@...ts.linux.dev>
Subject: RE: [PATCH v1 15/16] iommu/tegra241-cmdqv: Add user-space use support
> From: Nicolin Chen <nicolinc@...dia.com>
> Sent: Tuesday, April 22, 2025 3:14 AM
> On Mon, Apr 21, 2025 at 08:37:40AM +0000, Tian, Kevin wrote:
> > > From: Nicolin Chen <nicolinc@...dia.com>
> > > Sent: Friday, April 11, 2025 2:38 PM
> > >
> > > +
> > > + vcmdq = iommufd_vcmdq_alloc(viommu, struct tegra241_vcmdq,
> > > core);
> > > + if (!vcmdq)
> > > + return ERR_PTR(-ENOMEM);
> > > +
> > > + ret = tegra241_vintf_init_lvcmdq(vintf, arg.vcmdq_id, vcmdq);
> > > + if (ret)
> > > + goto free_vcmdq;
> > > + dev_dbg(cmdqv->dev, "%sallocated\n",
> > > + lvcmdq_error_header(vcmdq, header, 64));
> > > +
> > > + vcmdq->cmdq.q.q_base = q_base & VCMDQ_ADDR;
> > > + vcmdq->cmdq.q.q_base |= arg.vcmdq_log2size;
> >
> > could the queue size be multiple pages? there is no guarantee
> > that the HPA of guest queue would be contiguous :/
>
> It certainly can. VMM must make sure the guest PA are contiguous
> by using huge pages to back the guest RAM space. Kernel has no
> control of this but only has to trust the VMM.
>
> I'm adding a note here:
> /* User space ensures that the queue memory is physically
> contiguous */
>
> And likely something similar in the uAPI header too.
>
It's not a good idea having the kernel trust the VMM. Also I'm not
sure the contiguity is guaranteed all the time with huge page
(e.g. if just using THP).
@Jason?
btw does smmu only read the cmdq or also update some fields
in the queue? If the latter, then it also brings a security hole
as a malicious VMM could violate the contiguity requirement
to instruct the smmu to touch pages which don't belong to
it...
Powered by blists - more mailing lists