[1/4] lib: disable /dev/mem access on aarch64
diff mbox series

Message ID 20181115232517.4588-2-leif.lindholm@linaro.org
State Accepted
Headers show
Series
  • various /dev/mem related cleanup
Related show

Commit Message

Leif Lindholm Nov. 15, 2018, 11:25 p.m. UTC
There is no valid use-case for having the /dev/mem interface enabled,
let alone using it, on a multi-user aarch64 system. So turn fwts_mmap/
fwts_munmap into no-ops here.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 src/lib/include/fwts.h  |  3 +++
 src/lib/src/fwts_mmap.c | 13 +++++++++++++
 2 files changed, 16 insertions(+)

Comments

Alex Hung Nov. 16, 2018, 3:09 a.m. UTC | #1
On 2018-11-16 7:25 a.m., Leif Lindholm wrote:
> There is no valid use-case for having the /dev/mem interface enabled,
> let alone using it, on a multi-user aarch64 system. So turn fwts_mmap/
> fwts_munmap into no-ops here.
> 
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  src/lib/include/fwts.h  |  3 +++
>  src/lib/src/fwts_mmap.c | 13 +++++++++++++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
> index 3f343ef2..67d0b8f2 100644
> --- a/src/lib/include/fwts.h
> +++ b/src/lib/include/fwts.h
> @@ -98,6 +98,7 @@
>  #define FWTS_ARCH_INTEL	1
>  #define FWTS_HAS_ACPI	1
>  #define FWTS_HAS_UEFI	1
> +#define FWTS_USE_DEVMEM 1
>  #endif
>  
>  #if defined(__aarch64__)
> @@ -108,11 +109,13 @@
>  
>  #if defined(__s390x__)
>  #define FWTS_ARCH_S390X	1
> +#define FWTS_USE_DEVMEM 1
>  #endif
>  
>  #if defined(__PPC64__)
>  #undef FWTS_HAS_ACPI
>  #undef FWTS_HAS_UEFI
> +#define FWTS_USE_DEVMEM 1
>  #endif
>  
>  /* verision 3-tuple into integer */
> diff --git a/src/lib/src/fwts_mmap.c b/src/lib/src/fwts_mmap.c
> index e28abf87..71c5135d 100644
> --- a/src/lib/src/fwts_mmap.c
> +++ b/src/lib/src/fwts_mmap.c
> @@ -42,6 +42,7 @@ size_t fwts_page_size(void)
>  	return (size_t)(page_size == -1 ? FWTS_DEFAULT_PAGE_SIZE : page_size);
>  }
>  
> +#ifdef FWTS_USE_DEVMEM
>  /*
>   *  fwts_mmap()
>   *	Try and map physical memory from offset address 'start' and length
> @@ -88,3 +89,15 @@ int fwts_munmap(void *mem, const size_t size)
>  
>  	return FWTS_OK;
>  }
> +#else /* FWTS_USE_DEVMEM */
> +void *fwts_mmap(const off_t start __attribute__ ((unused)),
> +		const size_t size __attribute__ ((unused)))
> +{
> +	return FWTS_MAP_FAILED;
> +}
> +
> +int fwts_munmap(void *mem __attribute__ ((unused)),
> +		const size_t size __attribute__ ((unused)))                                                                        {
> +	return FWTS_ERROR;
> +}
> +#endif /* FWTS_USE_DEVMEM */
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Colin King Nov. 16, 2018, 9:03 a.m. UTC | #2
On 15/11/2018 23:25, Leif Lindholm wrote:
> There is no valid use-case for having the /dev/mem interface enabled,
> let alone using it, on a multi-user aarch64 system. So turn fwts_mmap/
> fwts_munmap into no-ops here.
> 
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  src/lib/include/fwts.h  |  3 +++
>  src/lib/src/fwts_mmap.c | 13 +++++++++++++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
> index 3f343ef2..67d0b8f2 100644
> --- a/src/lib/include/fwts.h
> +++ b/src/lib/include/fwts.h
> @@ -98,6 +98,7 @@
>  #define FWTS_ARCH_INTEL	1
>  #define FWTS_HAS_ACPI	1
>  #define FWTS_HAS_UEFI	1
> +#define FWTS_USE_DEVMEM 1
>  #endif
>  
>  #if defined(__aarch64__)
> @@ -108,11 +109,13 @@
>  
>  #if defined(__s390x__)
>  #define FWTS_ARCH_S390X	1
> +#define FWTS_USE_DEVMEM 1
>  #endif
>  
>  #if defined(__PPC64__)
>  #undef FWTS_HAS_ACPI
>  #undef FWTS_HAS_UEFI
> +#define FWTS_USE_DEVMEM 1
>  #endif
>  
>  /* verision 3-tuple into integer */
> diff --git a/src/lib/src/fwts_mmap.c b/src/lib/src/fwts_mmap.c
> index e28abf87..71c5135d 100644
> --- a/src/lib/src/fwts_mmap.c
> +++ b/src/lib/src/fwts_mmap.c
> @@ -42,6 +42,7 @@ size_t fwts_page_size(void)
>  	return (size_t)(page_size == -1 ? FWTS_DEFAULT_PAGE_SIZE : page_size);
>  }
>  
> +#ifdef FWTS_USE_DEVMEM
>  /*
>   *  fwts_mmap()
>   *	Try and map physical memory from offset address 'start' and length
> @@ -88,3 +89,15 @@ int fwts_munmap(void *mem, const size_t size)
>  
>  	return FWTS_OK;
>  }
> +#else /* FWTS_USE_DEVMEM */
> +void *fwts_mmap(const off_t start __attribute__ ((unused)),
> +		const size_t size __attribute__ ((unused)))
> +{
> +	return FWTS_MAP_FAILED;
> +}
> +
> +int fwts_munmap(void *mem __attribute__ ((unused)),
> +		const size_t size __attribute__ ((unused)))                                                                        {
> +	return FWTS_ERROR;
> +}
> +#endif /* FWTS_USE_DEVMEM */
> 

Acked-by: Colin Ian King <colin.king@canonical.com>

Patch
diff mbox series

diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
index 3f343ef2..67d0b8f2 100644
--- a/src/lib/include/fwts.h
+++ b/src/lib/include/fwts.h
@@ -98,6 +98,7 @@ 
 #define FWTS_ARCH_INTEL	1
 #define FWTS_HAS_ACPI	1
 #define FWTS_HAS_UEFI	1
+#define FWTS_USE_DEVMEM 1
 #endif
 
 #if defined(__aarch64__)
@@ -108,11 +109,13 @@ 
 
 #if defined(__s390x__)
 #define FWTS_ARCH_S390X	1
+#define FWTS_USE_DEVMEM 1
 #endif
 
 #if defined(__PPC64__)
 #undef FWTS_HAS_ACPI
 #undef FWTS_HAS_UEFI
+#define FWTS_USE_DEVMEM 1
 #endif
 
 /* verision 3-tuple into integer */
diff --git a/src/lib/src/fwts_mmap.c b/src/lib/src/fwts_mmap.c
index e28abf87..71c5135d 100644
--- a/src/lib/src/fwts_mmap.c
+++ b/src/lib/src/fwts_mmap.c
@@ -42,6 +42,7 @@  size_t fwts_page_size(void)
 	return (size_t)(page_size == -1 ? FWTS_DEFAULT_PAGE_SIZE : page_size);
 }
 
+#ifdef FWTS_USE_DEVMEM
 /*
  *  fwts_mmap()
  *	Try and map physical memory from offset address 'start' and length
@@ -88,3 +89,15 @@  int fwts_munmap(void *mem, const size_t size)
 
 	return FWTS_OK;
 }
+#else /* FWTS_USE_DEVMEM */
+void *fwts_mmap(const off_t start __attribute__ ((unused)),
+		const size_t size __attribute__ ((unused)))
+{
+	return FWTS_MAP_FAILED;
+}
+
+int fwts_munmap(void *mem __attribute__ ((unused)),
+		const size_t size __attribute__ ((unused)))                                                                        {
+	return FWTS_ERROR;
+}
+#endif /* FWTS_USE_DEVMEM */