On 17/06/19 10:15 PM, Jan Kiszka wrote: > On 17.06.19 16:27, 'Pratyush Yadav' via Jailhouse wrote: >> Hi, >> >> I am writing a driver for a device that accesses some in-memory data >> structures. Right now I'm using page_alloc(&mem_pool, ...) to allocate those >> structures, but I suspect this memory is cacheable, and thus updates to the >> in-memory structures won't necessarily be visible to the device. > > I suspect you mean you write a driver inside Jailhouse, right? Why is that > driver needed in hypervisor space? The driver is for the SMMU (an IOMMU for ARM systems). It is in hypervisor space because the same SMMU can be responsible for multiple cells. > Yes, hypervisor memory, including that which comes from page_alloc, is mapped > cacheable. But why can't you evict the content from cache to RAM when that > device should see it? That's how we generally work. That is what I'm doing right now. I call arch_paging_flush_cpu_caches() whenever there is any update to those structures. But I thought it would be better if the memory was not cacheable to begin with. >> >> There is enum paging_coherent in hypervisor/include/jailhouse/paging.h that >> is passed as an argument to paging_create() that does exactly what I want. >> But there doesn't seem to be any API/memory pool that allocates memory using >> this flag. > > PAGING_COHERENT just means that we flush page table entries along the > construction because the table has been in use already and we will not > perform a full flush after all changes are applied. It says nothing about the > caching attributes of the mapped page(s). > >> >> I tried allocating memory from the remap pool, and then remapped that memory >> to the same address but with PAGING_COHERENT instead. But that causes an >> exception as soon as anything tries to access the memory. >> >> What is the recommended way to allocate coherent memory? >> > > I suspect you mapped back the virtual address of the page, not the physical > one, no? I passed paging_hvirt2phys(virt) as the physical address and (unsigned long)virt as the virtual address to paging_create(). What's wrong with this? > Still, haven the memory cached and flushing caches as needed still sounds > like the better pattern to me. All right. That's what I'm doing right now, so I'll stick with that. > Jan > -- Regards, Pratyush Yadav -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/5c8d8dbe-f842-f7d0-fe90-2161f636b07f%40ti.com. For more options, visit https://groups.google.com/d/optout.
Re: [EXTERNAL] Re: Allocating coherent memory
'Pratyush Yadav' via Jailhouse Mon, 17 Jun 2019 22:49:04 -0700
- Allocating coherent memory 'Pratyush Yadav' via Jailhouse
- Re: Allocating coherent memory Jan Kiszka
- Re: [EXTERNAL] Re: Allocating cohe... 'Pratyush Yadav' via Jailhouse
- Re: [EXTERNAL] Re: Allocating ... Jan Kiszka
