From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 1/3] x86/paging: Enforce PG_external == PG_translate == PG_refcounts
Date: Tue, 13 Dec 2016 16:54:32 +0000 [thread overview]
Message-ID: <1481648074-11455-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1481648074-11455-1-git-send-email-andrew.cooper3@citrix.com>
Setting PG_refcounts but not PG_translate is not useful.
While adjusting this, make a few other improvements.
* Have paging_enable() unilaterally reject any unknown modes.
* Drop the or'ing of PG_{HAP,SH}_enable. The underlying functions already do
this.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
CC: George Dunlap <george.dunlap@eu.citrix.com>
v2:
* Drop references to logdirty
---
xen/arch/x86/mm/paging.c | 13 +++++++++----
xen/arch/x86/mm/shadow/common.c | 3 +--
xen/include/asm-x86/paging.h | 3 +++
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index 853a035..4437611 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -846,19 +846,24 @@ void paging_final_teardown(struct domain *d)
* creation. */
int paging_enable(struct domain *d, u32 mode)
{
- switch ( mode & (PG_external | PG_translate) )
+ /* Unrecognised paging mode? */
+ if ( mode & ~PG_MASK )
+ return -EINVAL;
+
+ /* All of external|translate|refcounts, or none. */
+ switch ( mode & (PG_external | PG_translate | PG_refcounts) )
{
case 0:
- case PG_external | PG_translate:
+ case PG_external | PG_translate | PG_refcounts:
break;
default:
return -EINVAL;
}
if ( hap_enabled(d) )
- return hap_enable(d, mode | PG_HAP_enable);
+ return hap_enable(d, mode);
else
- return shadow_enable(d, mode | PG_SH_enable);
+ return shadow_enable(d, mode);
}
/* Called from the guest to indicate that a process is being torn down
diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index acb35c2..79bb12e 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -3144,8 +3144,7 @@ int shadow_enable(struct domain *d, u32 mode)
domain_pause(d);
/* Sanity check the arguments */
- if ( shadow_mode_enabled(d) ||
- ((mode & PG_translate) && !(mode & PG_refcounts)) )
+ if ( shadow_mode_enabled(d) )
{
rv = -EINVAL;
goto out_unlocked;
diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h
index f83ed8b..cc29f9b 100644
--- a/xen/include/asm-x86/paging.h
+++ b/xen/include/asm-x86/paging.h
@@ -57,6 +57,9 @@
* requires VT or similar mechanisms */
#define PG_external (XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL << PG_mode_shift)
+/* All paging modes. */
+#define PG_MASK (PG_refcounts | PG_log_dirty | PG_translate | PG_external)
+
#define paging_mode_enabled(_d) (!!(_d)->arch.paging.mode)
#define paging_mode_shadow(_d) (!!((_d)->arch.paging.mode & PG_SH_enable))
#define paging_mode_hap(_d) (!!((_d)->arch.paging.mode & PG_HAP_enable))
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-12-13 16:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-13 16:54 [PATCH v2 0/3] x86: Remove vestigal PV Autotranslate pieces Andrew Cooper
2016-12-13 16:54 ` Andrew Cooper [this message]
2016-12-13 16:54 ` [PATCH 2/3] x86/shadow: Drop all emulation for PV vcpus Andrew Cooper
2016-12-13 16:54 ` [PATCH 3/3] x86/traps: Adjust paged-guest handling in the PV pagefault path Andrew Cooper
2016-12-13 17:02 ` Tim Deegan
2016-12-13 17:19 ` Jan Beulich
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=1481648074-11455-2-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--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).