From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xen.org
Cc: andre.przywara@arm.com, Julien Grall <julien.grall@arm.com>,
sstabellini@kernel.org,
Ross Lagerwall <ross.lagerwall@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v3 9/9] xen/arm: mm: Use memory flags for modify_xen_mappings rather than custom one
Date: Mon, 2 Oct 2017 18:31:50 +0100 [thread overview]
Message-ID: <20171002173150.5404-10-julien.grall@arm.com> (raw)
In-Reply-To: <20171002173150.5404-1-julien.grall@arm.com>
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>
---
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
arch_livepatch_secure is now the same as on x86. It might be
possible to combine both, but I left that alone for now.
Changes in v3:
- Add Stefano's reviewed-by
Changes in v2:
- Add Andre's reviewed-by
---
xen/arch/arm/livepatch.c | 6 +++---
xen/arch/arm/mm.c | 5 ++---
xen/include/asm-arm/page.h | 11 -----------
3 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c
index 3e53524365..279d52cc6c 100644
--- a/xen/arch/arm/livepatch.c
+++ b/xen/arch/arm/livepatch.c
@@ -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:
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 57afedf0be..705bdd9cce 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -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);
}
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index e2b3e402d0..e4be83a7bc 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -96,17 +96,6 @@
#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.
*
* These are valid in the MemAttr[3:0] field of an LPAE stage 2 page
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-10-02 17:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-02 17:31 [PATCH v3 0/9] xen/arm: Memory subsystem clean-up Julien Grall
2017-10-02 17:31 ` [PATCH v3 1/9] xen/arm: page: Use ARMv8 naming to improve readability Julien Grall
2017-10-02 17:31 ` [PATCH v3 2/9] xen/arm: page: Clean-up the definition of MAIRVAL Julien Grall
2017-10-02 17:31 ` [PATCH v3 3/9] xen/arm: mm: Rename and clarify AP[1] in the stage-1 page table Julien Grall
2017-10-02 17:31 ` [PATCH v3 4/9] xen/arm: Switch to SYS_STATE_boot just after end_boot_allocator() Julien Grall
2017-10-02 17:31 ` [PATCH v3 5/9] xen/arm: mm: Rename 'ai' into 'flags' in create_xen_entries Julien Grall
2017-10-02 17:31 ` [PATCH v3 6/9] xen/arm: page: Describe the layout of flags used to update page tables Julien Grall
2017-10-02 17:31 ` [PATCH v3 7/9] xen/arm: mm: Embed permission in the flags Julien Grall
2017-10-09 12:34 ` Julien Grall
2017-10-02 17:31 ` [PATCH v3 8/9] xen/arm: mm: Handle permission flags when adding a new mapping Julien Grall
2017-10-02 17:31 ` Julien Grall [this message]
2017-10-02 18:14 ` [PATCH v3 9/9] xen/arm: mm: Use memory flags for modify_xen_mappings rather than custom one Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171002173150.5404-10-julien.grall@arm.com \
--to=julien.grall@arm.com \
--cc=andre.przywara@arm.com \
--cc=konrad.wilk@oracle.com \
--cc=ross.lagerwall@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).