lkml.org 
[lkml]   [2020]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 12/15] kmap: Add stray write protection for device pages
On Tue, Jul 14, 2020 at 12:02:17AM -0700, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
>
> Device managed pages may have additional protections. These protections
> need to be removed prior to valid use by kernel users.
>
> Check for special treatment of device managed pages in kmap and take
> action if needed. We use kmap as an interface for generic kernel code
> because under normal circumstances it would be a bug for general kernel
> code to not use kmap prior to accessing kernel memory. Therefore, this
> should allow any valid kernel users to seamlessly use these pages
> without issues.
>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> ---
> include/linux/highmem.h | 32 +++++++++++++++++++++++++++++++-
> 1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
> index d6e82e3de027..7f809d8d5a94 100644
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -8,6 +8,7 @@
> #include <linux/mm.h>
> #include <linux/uaccess.h>
> #include <linux/hardirq.h>
> +#include <linux/memremap.h>
>
> #include <asm/cacheflush.h>
>
> @@ -31,6 +32,20 @@ static inline void invalidate_kernel_vmap_range(void *vaddr, int size)
>
> #include <asm/kmap_types.h>
>
> +static inline void enable_access(struct page *page)
> +{
> + if (!page_is_access_protected(page))
> + return;
> + dev_access_enable();
> +}
> +
> +static inline void disable_access(struct page *page)
> +{
> + if (!page_is_access_protected(page))
> + return;
> + dev_access_disable();
> +}

So, if I followed along correctly, you're proposing to do a WRMSR per
k{,un}map{_atomic}(), sounds like excellent performance all-round :-(

\
 
 \ /
  Last update: 2020-07-14 10:46    [W:0.116 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site