Message ID | eba179acbfdea5a646c5548cb82138c1c3b74aa2.1547153058.git.khalid.aziz@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add support for eXclusive Page Frame Ownership | expand |
On Thu, Jan 10, 2019 at 02:09:39PM -0700, Khalid Aziz wrote: > From: Juerg Haefliger <juerg.haefliger@canonical.com> > > If the page is unmapped by XPFO, a data cache flush results in a fatal > page fault, so let's temporarily map the region, flush the cache, and then > unmap it. > > v6: actually flush in the face of xpfo, and temporarily map the underlying > memory so it can be flushed correctly > > CC: linux-arm-kernel@lists.infradead.org > Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> > Signed-off-by: Tycho Andersen <tycho@docker.com> > Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com> > --- > arch/arm64/mm/flush.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c > index 30695a868107..f12f26b60319 100644 > --- a/arch/arm64/mm/flush.c > +++ b/arch/arm64/mm/flush.c > @@ -20,6 +20,7 @@ > #include <linux/export.h> > #include <linux/mm.h> > #include <linux/pagemap.h> > +#include <linux/xpfo.h> > > #include <asm/cacheflush.h> > #include <asm/cache.h> > @@ -28,9 +29,15 @@ > void sync_icache_aliases(void *kaddr, unsigned long len) > { > unsigned long addr = (unsigned long)kaddr; > + unsigned long num_pages = XPFO_NUM_PAGES(addr, len); > + void *mapping[num_pages]; Does this still compile with -Wvla? It was a bad hack on my part, and we should probably just drop it and come up with something else :) Tycho > if (icache_is_aliasing()) { > + xpfo_temp_map(kaddr, len, mapping, > + sizeof(mapping[0]) * num_pages); > __clean_dcache_area_pou(kaddr, len); > + xpfo_temp_unmap(kaddr, len, mapping, > + sizeof(mapping[0]) * num_pages); > __flush_icache_all(); > } else { > flush_icache_range(addr, addr + len); > -- > 2.17.1 >
On 1/11/19 7:54 AM, Tycho Andersen wrote: > On Thu, Jan 10, 2019 at 02:09:39PM -0700, Khalid Aziz wrote: >> From: Juerg Haefliger <juerg.haefliger@canonical.com> >> >> If the page is unmapped by XPFO, a data cache flush results in a fatal >> page fault, so let's temporarily map the region, flush the cache, and then >> unmap it. >> >> v6: actually flush in the face of xpfo, and temporarily map the underlying >> memory so it can be flushed correctly >> >> CC: linux-arm-kernel@lists.infradead.org >> Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> >> Signed-off-by: Tycho Andersen <tycho@docker.com> >> Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com> >> --- >> arch/arm64/mm/flush.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c >> index 30695a868107..f12f26b60319 100644 >> --- a/arch/arm64/mm/flush.c >> +++ b/arch/arm64/mm/flush.c >> @@ -20,6 +20,7 @@ >> #include <linux/export.h> >> #include <linux/mm.h> >> #include <linux/pagemap.h> >> +#include <linux/xpfo.h> >> >> #include <asm/cacheflush.h> >> #include <asm/cache.h> >> @@ -28,9 +29,15 @@ >> void sync_icache_aliases(void *kaddr, unsigned long len) >> { >> unsigned long addr = (unsigned long)kaddr; >> + unsigned long num_pages = XPFO_NUM_PAGES(addr, len); >> + void *mapping[num_pages]; > > Does this still compile with -Wvla? It was a bad hack on my part, and > we should probably just drop it and come up with something else :) I will make a note of it. I hope someone with better knowledge of arm64 than me can come up with a better solution ;) -- Khalid > > Tycho > >> if (icache_is_aliasing()) { >> + xpfo_temp_map(kaddr, len, mapping, >> + sizeof(mapping[0]) * num_pages); >> __clean_dcache_area_pou(kaddr, len); >> + xpfo_temp_unmap(kaddr, len, mapping, >> + sizeof(mapping[0]) * num_pages); >> __flush_icache_all(); >> } else { >> flush_icache_range(addr, addr + len); >> -- >> 2.17.1 >>
On Fri, Jan 11, 2019 at 11:28:19AM -0700, Khalid Aziz wrote: > On 1/11/19 7:54 AM, Tycho Andersen wrote: > > On Thu, Jan 10, 2019 at 02:09:39PM -0700, Khalid Aziz wrote: > >> From: Juerg Haefliger <juerg.haefliger@canonical.com> > >> > >> If the page is unmapped by XPFO, a data cache flush results in a fatal > >> page fault, so let's temporarily map the region, flush the cache, and then > >> unmap it. > >> > >> v6: actually flush in the face of xpfo, and temporarily map the underlying > >> memory so it can be flushed correctly > >> > >> CC: linux-arm-kernel@lists.infradead.org > >> Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> > >> Signed-off-by: Tycho Andersen <tycho@docker.com> > >> Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com> > >> --- > >> arch/arm64/mm/flush.c | 7 +++++++ > >> 1 file changed, 7 insertions(+) > >> > >> diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c > >> index 30695a868107..f12f26b60319 100644 > >> --- a/arch/arm64/mm/flush.c > >> +++ b/arch/arm64/mm/flush.c > >> @@ -20,6 +20,7 @@ > >> #include <linux/export.h> > >> #include <linux/mm.h> > >> #include <linux/pagemap.h> > >> +#include <linux/xpfo.h> > >> > >> #include <asm/cacheflush.h> > >> #include <asm/cache.h> > >> @@ -28,9 +29,15 @@ > >> void sync_icache_aliases(void *kaddr, unsigned long len) > >> { > >> unsigned long addr = (unsigned long)kaddr; > >> + unsigned long num_pages = XPFO_NUM_PAGES(addr, len); > >> + void *mapping[num_pages]; > > > > Does this still compile with -Wvla? It was a bad hack on my part, and > > we should probably just drop it and come up with something else :) > > I will make a note of it. I hope someone with better knowledge of arm64 > than me can come up with a better solution ;) It's not just arm64, IIRC everywhere I used xpfo_temp_map() has a VLA. I think this is in part because some of these paths don't allow allocation failures, so we can't do a dynamic allocation. Perhaps we need to reserve some memory for each call site? Tycho
On Thu, Jan 10, 2019 at 02:09:39PM -0700, Khalid Aziz wrote: > From: Juerg Haefliger <juerg.haefliger@canonical.com> > > If the page is unmapped by XPFO, a data cache flush results in a fatal > page fault, so let's temporarily map the region, flush the cache, and then > unmap it. > > v6: actually flush in the face of xpfo, and temporarily map the underlying > memory so it can be flushed correctly > > CC: linux-arm-kernel@lists.infradead.org > Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> > Signed-off-by: Tycho Andersen <tycho@docker.com> > Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com> > --- > arch/arm64/mm/flush.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c > index 30695a868107..f12f26b60319 100644 > --- a/arch/arm64/mm/flush.c > +++ b/arch/arm64/mm/flush.c > @@ -20,6 +20,7 @@ > #include <linux/export.h> > #include <linux/mm.h> > #include <linux/pagemap.h> > +#include <linux/xpfo.h> > > #include <asm/cacheflush.h> > #include <asm/cache.h> > @@ -28,9 +29,15 @@ > void sync_icache_aliases(void *kaddr, unsigned long len) > { > unsigned long addr = (unsigned long)kaddr; > + unsigned long num_pages = XPFO_NUM_PAGES(addr, len); Is it possible that the 'len' is more than 32 pages? Or say 1000's of pages? Which would blow away your stack. > + void *mapping[num_pages]; > > if (icache_is_aliasing()) { > + xpfo_temp_map(kaddr, len, mapping, > + sizeof(mapping[0]) * num_pages); > __clean_dcache_area_pou(kaddr, len); > + xpfo_temp_unmap(kaddr, len, mapping, > + sizeof(mapping[0]) * num_pages); > __flush_icache_all(); > } else { > flush_icache_range(addr, addr + len); > -- > 2.17.1 >
diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c index 30695a868107..f12f26b60319 100644 --- a/arch/arm64/mm/flush.c +++ b/arch/arm64/mm/flush.c @@ -20,6 +20,7 @@ #include <linux/export.h> #include <linux/mm.h> #include <linux/pagemap.h> +#include <linux/xpfo.h> #include <asm/cacheflush.h> #include <asm/cache.h> @@ -28,9 +29,15 @@ void sync_icache_aliases(void *kaddr, unsigned long len) { unsigned long addr = (unsigned long)kaddr; + unsigned long num_pages = XPFO_NUM_PAGES(addr, len); + void *mapping[num_pages]; if (icache_is_aliasing()) { + xpfo_temp_map(kaddr, len, mapping, + sizeof(mapping[0]) * num_pages); __clean_dcache_area_pou(kaddr, len); + xpfo_temp_unmap(kaddr, len, mapping, + sizeof(mapping[0]) * num_pages); __flush_icache_all(); } else { flush_icache_range(addr, addr + len);