mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
![Dave Gerlach](/assets/img/avatar_default.png)
Introduce a new "protect-exec" reserved sram area type which is makes use of the the existing functionality provided for the "pool" sram region type for use with the genalloc framework and with the added requirement that it be maintained as read-only and executable while allowing for an arbitrary number of drivers to share the space. This introduces a common way to maintain a region of sram as read-only and executable and also introduces a helper function, sram_exec_copy, which allows for copying data to this protected region while maintaining locking to avoid conflicts between multiple users of the same space. A region of memory that is marked with the "protect-exec" flag in the device tree also has the requirement of providing a page aligned block of memory so that the page attribute manipulation does not affect surrounding regions. Also, selectively enable this only for builds that support set_memory_* calls, for now just ARM, through the use of Kconfig. Signed-off-by: Dave Gerlach <d-gerlach@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
58 lines
1.2 KiB
C
58 lines
1.2 KiB
C
/*
|
|
* Defines for the SRAM driver
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
#ifndef __SRAM_H
|
|
#define __SRAM_H
|
|
|
|
struct sram_partition {
|
|
void __iomem *base;
|
|
|
|
struct gen_pool *pool;
|
|
struct bin_attribute battr;
|
|
struct mutex lock;
|
|
struct list_head list;
|
|
};
|
|
|
|
struct sram_dev {
|
|
struct device *dev;
|
|
void __iomem *virt_base;
|
|
|
|
struct gen_pool *pool;
|
|
struct clk *clk;
|
|
|
|
struct sram_partition *partition;
|
|
u32 partitions;
|
|
};
|
|
|
|
struct sram_reserve {
|
|
struct list_head list;
|
|
u32 start;
|
|
u32 size;
|
|
bool export;
|
|
bool pool;
|
|
bool protect_exec;
|
|
const char *label;
|
|
};
|
|
|
|
#ifdef CONFIG_SRAM_EXEC
|
|
int sram_check_protect_exec(struct sram_dev *sram, struct sram_reserve *block,
|
|
struct sram_partition *part);
|
|
int sram_add_protect_exec(struct sram_partition *part);
|
|
#else
|
|
static inline int sram_check_protect_exec(struct sram_dev *sram,
|
|
struct sram_reserve *block,
|
|
struct sram_partition *part)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline int sram_add_protect_exec(struct sram_partition *part)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
#endif /* CONFIG_SRAM_EXEC */
|
|
#endif /* __SRAM_H */
|