Message ID | 20231025051430.493079-2-ethan84@andestech.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Support RISC-V IOPMP | expand |
On 25.10.23 07:14, Ethan Chen wrote: > IOMMU have size information during translation. > Can you add some more information why we would want this and how the backend can do "better" things with the size at hand? Note that I was not CCed on the cover letter. > Signed-off-by: Ethan Chen <ethan84@andestech.com> > --- > include/exec/memory.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 9087d02769..5520b7c8c0 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -396,6 +396,25 @@ struct IOMMUMemoryRegionClass { > */ > IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr, > IOMMUAccessFlags flag, int iommu_idx); > + /** > + * @translate_size: > + * > + * Return a TLB entry that contains a given address and size. > + * > + * @iommu: the IOMMUMemoryRegion > + * > + * @hwaddr: address to be translated within the memory region > + * > + * @size: size to indicate the scope of the entire transaction > + * > + * @flag: requested access permission > + * > + * @iommu_idx: IOMMU index for the translation > + */ > + IOMMUTLBEntry (*translate_size)(IOMMUMemoryRegion *iommu, hwaddr addr, > + hwaddr size, IOMMUAccessFlags flag, > + int iommu_idx); > + > /** > * @get_min_page_size: > *
On Wed, Oct 25, 2023 at 04:56:22PM +0200, David Hildenbrand wrote: > On 25.10.23 07:14, Ethan Chen wrote: > > IOMMU have size information during translation. > > > > Can you add some more information why we would want this and how the backend > can do "better" things with the size at hand? > With size information, IOMMU can reject a memory access which is patially in valid region. Currently translation function limit memory access size with a mask, so the valid part of access will success. My target is to detect partially hit and reject whole access. Translation function cannot detect partially hit because it lacks size information. > Note that I was not CCed on the cover letter. > > > Signed-off-by: Ethan Chen <ethan84@andestech.com> > > --- > > include/exec/memory.h | 19 +++++++++++++++++++ > > 1 file changed, 19 insertions(+) > > > > diff --git a/include/exec/memory.h b/include/exec/memory.h > > index 9087d02769..5520b7c8c0 100644 > > --- a/include/exec/memory.h > > +++ b/include/exec/memory.h > > @@ -396,6 +396,25 @@ struct IOMMUMemoryRegionClass { > > */ > > IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr, > > IOMMUAccessFlags flag, int iommu_idx); > > + /** > > + * @translate_size: > > + * > > + * Return a TLB entry that contains a given address and size. > > + * > > + * @iommu: the IOMMUMemoryRegion > > + * > > + * @hwaddr: address to be translated within the memory region > > + * > > + * @size: size to indicate the scope of the entire transaction > > + * > > + * @flag: requested access permission > > + * > > + * @iommu_idx: IOMMU index for the translation > > + */ > > + IOMMUTLBEntry (*translate_size)(IOMMUMemoryRegion *iommu, hwaddr addr, > > + hwaddr size, IOMMUAccessFlags flag, > > + int iommu_idx); > > + > > /** > > * @get_min_page_size: > > * > > -- > Cheers, > > David / dhildenb > Thanks, Ethan Chen
On 26.10.23 09:14, Ethan Chen wrote: > On Wed, Oct 25, 2023 at 04:56:22PM +0200, David Hildenbrand wrote: >> On 25.10.23 07:14, Ethan Chen wrote: >>> IOMMU have size information during translation. >>> >> >> Can you add some more information why we would want this and how the backend >> can do "better" things with the size at hand? >> > With size information, IOMMU can reject a memory access which is patially in > valid region. > > Currently translation function limit memory access size with a mask, so the > valid part of access will success. My target is to detect partially hit and > reject whole access. Translation function cannot detect partially hit because > it lacks size information. Thanks; please add some of that to the patch description.
diff --git a/include/exec/memory.h b/include/exec/memory.h index 9087d02769..5520b7c8c0 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -396,6 +396,25 @@ struct IOMMUMemoryRegionClass { */ IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr, IOMMUAccessFlags flag, int iommu_idx); + /** + * @translate_size: + * + * Return a TLB entry that contains a given address and size. + * + * @iommu: the IOMMUMemoryRegion + * + * @hwaddr: address to be translated within the memory region + * + * @size: size to indicate the scope of the entire transaction + * + * @flag: requested access permission + * + * @iommu_idx: IOMMU index for the translation + */ + IOMMUTLBEntry (*translate_size)(IOMMUMemoryRegion *iommu, hwaddr addr, + hwaddr size, IOMMUAccessFlags flag, + int iommu_idx); + /** * @get_min_page_size: *
IOMMU have size information during translation. Signed-off-by: Ethan Chen <ethan84@andestech.com> --- include/exec/memory.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)