Re: [PATCH v5 01/15] genpt: Generic Page Table base API

Jason Gunthorpe
2025-09-19T14:31:07Z

On Fri, Sep 19, 2025 at 08:11:11AM +0000, Tian, Kevin wrote:

> > > > + * item/entry_size
> > > > + * The number of bytes of VA the table translates for.
> > > > + * If the item is a table entry then the next table covers
> > > > + * this size. If the entry is an output address then the
> > >
> > > s/is/translates/
> >
> > Don't follow?
>
> entry is not an address. So I meant:
>
> "If the entry translates to an output address"

Ok

> > Oh, pt_contig_count_lg2 didn't get kdocs because they are internal
> > helpers to build other functions..
> >
> > Like this:
> >
> > /*
> > * If not supplied by the format then contiguous pages are not supported.
> > *
> > * If contiguous pages are supported then the format must also provide
> > * pt_contig_count_lg2() if it supports a single contiguous size per level,
> > * or pt_possible_sizes() if it supports multiple sizes per level.
>
> could be simplified to require the format to always support pt_possible_sizes()
> if contiguous sizes are supported, no matter being a single size or multiple.

I had that once, but it is a little more boiler plate/complex for the
formats to write.

> hmm I didn't find ARM/RISCV defining pt_contig_count_lg2().

static inline unsigned short
armv7s_pt_contig_count_lg2(const struct pt_state *pts)
{
return ilog2(16);
}
#define pt_contig_count_lg2 armv7s_pt_contig_count_lg2

/* Number contigous entries that ARMV8PT_FMT_CONTIG will join at this level */
static inline unsigned short
armv8pt_contig_count_lg2(const struct pt_state *pts)
{
if (PT_GRANULE_SIZE == SZ_4K)
return ilog2(16); /* 64KB, 32MB */
else if (PT_GRANULE_SIZE == SZ_16K && pts->level == 1)
return ilog2(32); /* 1GB */
else if (PT_GRANULE_SIZE == SZ_16K && pts->level == 0)
return ilog2(128); /* 2M */
else if (PT_GRANULE_SIZE == SZ_64K)
return ilog2(32); /* 2M, 16G */
return ilog2(1);
}
#define pt_contig_count_lg2 armv8pt_contig_count_lg2

And I missed switching riscv, fixed it into:

static inline unsigned short
riscvpt_contig_count_lg2(const struct pt_state *pts)
{
if (pts->level == 0 && pts_feature(pts, PT_FEAT_RSICV_SVNAPOT_64K))
return ilog2(16);
return ilog2(1);
}
#define pt_contig_count_lg2 riscvpt_contig_count_lg2

Thanks,
Jason