mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
xen/arm: mm: Use memory flags for modify_xen_mappings rather than custom one
This will help to consolidate the page-table code and avoid different path depending on the action to perform. Signed-off-by: Julien Grall <julien.grall@arm.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
This commit is contained in:
1 parent
6b88beed40
commit
e2dfe4a037
3 files changed
+5
-17
No files matched your search
@@ -146,15 +146,15 @@ int arch_livepatch_secure(const void *va, unsigned int pages, enum va_type type)
|
||||
switch ( type )
|
||||
{
|
||||
case LIVEPATCH_VA_RX:
|
||||
flags = PTE_RO; /* R set, NX clear */
|
||||
flags = PAGE_HYPERVISOR_RX;
|
||||
break;
|
||||
|
||||
case LIVEPATCH_VA_RW:
|
||||
flags = PTE_NX; /* R clear, NX set */
|
||||
flags = PAGE_HYPERVISOR_RW;
|
||||
break;
|
||||
|
||||
case LIVEPATCH_VA_RO:
|
||||
flags = PTE_NX | PTE_RO; /* R set, NX set */
|
||||
flags = PAGE_HYPERVISOR_RO;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+2
-3
@@ -1041,8 +1041,8 @@ static int create_xen_entries(enum xenmap_operation op,
|
||||
else
|
||||
{
|
||||
pte = *entry;
|
||||
pte.pt.ro = PTE_RO_MASK(flags);
|
||||
pte.pt.xn = PTE_NX_MASK(flags);
|
||||
pte.pt.ro = PAGE_RO_MASK(flags);
|
||||
pte.pt.xn = PAGE_XN_MASK(flags);
|
||||
if ( !pte.pt.ro && !pte.pt.xn )
|
||||
{
|
||||
printk("%s: Incorrect combination for addr=%lx\n",
|
||||
@@ -1085,7 +1085,6 @@ int destroy_xen_mappings(unsigned long v, unsigned long e)
|
||||
|
||||
int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags)
|
||||
{
|
||||
ASSERT((flags & (PTE_NX | PTE_RO)) == flags);
|
||||
return create_xen_entries(MODIFY, s, INVALID_MFN, (e - s) >> PAGE_SHIFT,
|
||||
flags);
|
||||
}
|
||||
|
||||
@@ -95,17 +95,6 @@
|
||||
#define PAGE_HYPERVISOR_NOCACHE (_PAGE_DEVICE|MT_DEVICE_nGnRE)
|
||||
#define PAGE_HYPERVISOR_WC (_PAGE_DEVICE|MT_NORMAL_NC)
|
||||
|
||||
/*
|
||||
* Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be
|
||||
* used with modify_xen_mappings.
|
||||
*/
|
||||
#define _PTE_NX_BIT 0U
|
||||
#define _PTE_RO_BIT 1U
|
||||
#define PTE_NX (1U << _PTE_NX_BIT)
|
||||
#define PTE_RO (1U << _PTE_RO_BIT)
|
||||
#define PTE_NX_MASK(x) (((x) >> _PTE_NX_BIT) & 0x1U)
|
||||
#define PTE_RO_MASK(x) (((x) >> _PTE_RO_BIT) & 0x1U)
|
||||
|
||||
/*
|
||||
* Stage 2 Memory Type.
|
||||
*
|
||||
|
||||