On 2/20/23 19:38, Michael Roth wrote: > From: Brijesh Singh <brijesh.singh@xxxxxxx> > > The snp_lookup_page_in_rmptable() can be used by the host to read the RMP > entry for a given page. The RMP entry format is documented in AMD PPR, see > https://bugzilla.kernel.org/attachment.cgi?id=296015. > > Co-developed-by: Ashish Kalra <ashish.kalra@xxxxxxx> > Signed-off-by: Ashish Kalra <ashish.kalra@xxxxxxx> > Signed-off-by: Brijesh Singh <brijesh.singh@xxxxxxx> > Signed-off-by: Michael Roth <michael.roth@xxxxxxx> > --- > +/* > + * Return 1 if the RMP entry is assigned, 0 if it exists but is not assigned, > + * and -errno if there is no corresponding RMP entry. > + */ Hmm IMHO the kernel's idiomatic way is to return 0 on "success" and I'd assume the more intuitive expectation of success here if the entry is assigned? The various callers seem to differ though so I guess it depends on context. Some however don't distinguish their "failure" from an ERR and maybe they should, at least for the purposes of the various printks? > +int snp_lookup_rmpentry(u64 pfn, int *level) > +{ > + struct rmpentry *e; > + > + e = __snp_lookup_rmpentry(pfn, level); > + if (IS_ERR(e)) > + return PTR_ERR(e); > + > + return !!rmpentry_assigned(e); > +} > +EXPORT_SYMBOL_GPL(snp_lookup_rmpentry);