p***@xen.org
2018-11-04 05:02:32 UTC
commit a14ca73359ec7b47c1b81b3ad88ef17baf6ebdfb
Author: Jan Beulich <***@suse.com>
AuthorDate: Fri Oct 26 15:18:52 2018 +0200
Commit: Jan Beulich <***@suse.com>
CommitDate: Fri Oct 26 15:18:52 2018 +0200
x86: restrict HVMOP_pagetable_dying to current
This is not used (and probably was never meant to be) by the tool stack.
Limiting it to the current domain in particular allows to eliminate a
bogus use of vCPU 0 in pagetable_dying().
Remove the now unnecessary domain/vCPU parameters from the wrapper/hook
functions at the same time.
Signed-off-by: Jan Beulich <***@suse.com>
Reviewed-by: Wei Liu <***@citrix.com>
Acked-by: George Dunlap <***@citrix.com>
Acked-by: Andrew Cooper <***@citrix.com>
---
xen/arch/x86/hvm/hvm.c | 6 ++++--
xen/arch/x86/mm/paging.c | 9 ++++-----
xen/arch/x86/mm/shadow/multi.c | 6 ++++--
xen/include/asm-x86/paging.h | 10 ++++++----
4 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 56a8de8034..225c62f8ba 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4920,10 +4920,12 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
return -ESRCH;
rc = -EINVAL;
- if ( is_hvm_domain(d) && paging_mode_shadow(d) )
+ if ( unlikely(d != current->domain) )
+ rc = -EOPNOTSUPP;
+ else if ( is_hvm_domain(d) && paging_mode_shadow(d) )
rc = xsm_hvm_param(XSM_TARGET, d, op);
if ( !rc )
- pagetable_dying(d, a.gpa);
+ pagetable_dying(a.gpa);
rcu_unlock_domain(d);
break;
diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index f32a60188a..d5836eb688 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -851,15 +851,14 @@ int paging_enable(struct domain *d, u32 mode)
/* Called from the guest to indicate that a process is being torn down
* and therefore its pagetables will soon be discarded */
-void pagetable_dying(struct domain *d, paddr_t gpa)
+void pagetable_dying(paddr_t gpa)
{
#ifdef CONFIG_SHADOW_PAGING
- struct vcpu *v;
+ struct vcpu *curr = current;
- ASSERT(paging_mode_shadow(d));
+ ASSERT(paging_mode_shadow(curr->domain));
- v = d->vcpu[0];
- v->arch.paging.mode->shadow.pagetable_dying(v, gpa);
+ curr->arch.paging.mode->shadow.pagetable_dying(gpa);
#else
BUG();
#endif
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 5cb216f0db..669c3f2c5e 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -4525,8 +4525,9 @@ int sh_remove_l3_shadow(struct domain *d, mfn_t sl4mfn, mfn_t sl3mfn)
* and in the meantime we unhook its top-level user-mode entries. */
#if GUEST_PAGING_LEVELS == 3
-static void sh_pagetable_dying(struct vcpu *v, paddr_t gpa)
+static void sh_pagetable_dying(paddr_t gpa)
{
+ struct vcpu *v = current;
struct domain *d = v->domain;
int i = 0;
int flush = 0;
@@ -4604,8 +4605,9 @@ out_put_gfn:
put_gfn(d, l3gfn);
}
#else
-static void sh_pagetable_dying(struct vcpu *v, paddr_t gpa)
+static void sh_pagetable_dying(paddr_t gpa)
{
+ struct vcpu *v = current;
struct domain *d = v->domain;
mfn_t smfn, gmfn;
p2m_type_t p2mt;
diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h
index b51e1709d3..dd0d6b5159 100644
--- a/xen/include/asm-x86/paging.h
+++ b/xen/include/asm-x86/paging.h
@@ -95,7 +95,7 @@ struct shadow_paging_mode {
void (*destroy_monitor_table )(struct vcpu *v, mfn_t mmfn);
int (*guess_wrmap )(struct vcpu *v,
unsigned long vaddr, mfn_t gmfn);
- void (*pagetable_dying )(struct vcpu *v, paddr_t gpa);
+ void (*pagetable_dying )(paddr_t gpa);
void (*trace_emul_write_val )(const void *ptr, unsigned long vaddr,
const void *src, unsigned int bytes);
#endif
@@ -343,9 +343,11 @@ void paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
l1_pgentry_t *p, l1_pgentry_t new,
unsigned int level);
-/* Called from the guest to indicate that the a process is being
- * torn down and its pagetables will soon be discarded */
-void pagetable_dying(struct domain *d, paddr_t gpa);
+/*
+ * Called from the guest to indicate that the a process is being
+ * torn down and its pagetables will soon be discarded.
+ */
+void pagetable_dying(paddr_t gpa);
/* Print paging-assistance info to the console */
void paging_dump_domain_info(struct domain *d);
--
generated by git-patchbot for /home/xen/git/xen.git#master
Author: Jan Beulich <***@suse.com>
AuthorDate: Fri Oct 26 15:18:52 2018 +0200
Commit: Jan Beulich <***@suse.com>
CommitDate: Fri Oct 26 15:18:52 2018 +0200
x86: restrict HVMOP_pagetable_dying to current
This is not used (and probably was never meant to be) by the tool stack.
Limiting it to the current domain in particular allows to eliminate a
bogus use of vCPU 0 in pagetable_dying().
Remove the now unnecessary domain/vCPU parameters from the wrapper/hook
functions at the same time.
Signed-off-by: Jan Beulich <***@suse.com>
Reviewed-by: Wei Liu <***@citrix.com>
Acked-by: George Dunlap <***@citrix.com>
Acked-by: Andrew Cooper <***@citrix.com>
---
xen/arch/x86/hvm/hvm.c | 6 ++++--
xen/arch/x86/mm/paging.c | 9 ++++-----
xen/arch/x86/mm/shadow/multi.c | 6 ++++--
xen/include/asm-x86/paging.h | 10 ++++++----
4 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 56a8de8034..225c62f8ba 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4920,10 +4920,12 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
return -ESRCH;
rc = -EINVAL;
- if ( is_hvm_domain(d) && paging_mode_shadow(d) )
+ if ( unlikely(d != current->domain) )
+ rc = -EOPNOTSUPP;
+ else if ( is_hvm_domain(d) && paging_mode_shadow(d) )
rc = xsm_hvm_param(XSM_TARGET, d, op);
if ( !rc )
- pagetable_dying(d, a.gpa);
+ pagetable_dying(a.gpa);
rcu_unlock_domain(d);
break;
diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index f32a60188a..d5836eb688 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -851,15 +851,14 @@ int paging_enable(struct domain *d, u32 mode)
/* Called from the guest to indicate that a process is being torn down
* and therefore its pagetables will soon be discarded */
-void pagetable_dying(struct domain *d, paddr_t gpa)
+void pagetable_dying(paddr_t gpa)
{
#ifdef CONFIG_SHADOW_PAGING
- struct vcpu *v;
+ struct vcpu *curr = current;
- ASSERT(paging_mode_shadow(d));
+ ASSERT(paging_mode_shadow(curr->domain));
- v = d->vcpu[0];
- v->arch.paging.mode->shadow.pagetable_dying(v, gpa);
+ curr->arch.paging.mode->shadow.pagetable_dying(gpa);
#else
BUG();
#endif
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 5cb216f0db..669c3f2c5e 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -4525,8 +4525,9 @@ int sh_remove_l3_shadow(struct domain *d, mfn_t sl4mfn, mfn_t sl3mfn)
* and in the meantime we unhook its top-level user-mode entries. */
#if GUEST_PAGING_LEVELS == 3
-static void sh_pagetable_dying(struct vcpu *v, paddr_t gpa)
+static void sh_pagetable_dying(paddr_t gpa)
{
+ struct vcpu *v = current;
struct domain *d = v->domain;
int i = 0;
int flush = 0;
@@ -4604,8 +4605,9 @@ out_put_gfn:
put_gfn(d, l3gfn);
}
#else
-static void sh_pagetable_dying(struct vcpu *v, paddr_t gpa)
+static void sh_pagetable_dying(paddr_t gpa)
{
+ struct vcpu *v = current;
struct domain *d = v->domain;
mfn_t smfn, gmfn;
p2m_type_t p2mt;
diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h
index b51e1709d3..dd0d6b5159 100644
--- a/xen/include/asm-x86/paging.h
+++ b/xen/include/asm-x86/paging.h
@@ -95,7 +95,7 @@ struct shadow_paging_mode {
void (*destroy_monitor_table )(struct vcpu *v, mfn_t mmfn);
int (*guess_wrmap )(struct vcpu *v,
unsigned long vaddr, mfn_t gmfn);
- void (*pagetable_dying )(struct vcpu *v, paddr_t gpa);
+ void (*pagetable_dying )(paddr_t gpa);
void (*trace_emul_write_val )(const void *ptr, unsigned long vaddr,
const void *src, unsigned int bytes);
#endif
@@ -343,9 +343,11 @@ void paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
l1_pgentry_t *p, l1_pgentry_t new,
unsigned int level);
-/* Called from the guest to indicate that the a process is being
- * torn down and its pagetables will soon be discarded */
-void pagetable_dying(struct domain *d, paddr_t gpa);
+/*
+ * Called from the guest to indicate that the a process is being
+ * torn down and its pagetables will soon be discarded.
+ */
+void pagetable_dying(paddr_t gpa);
/* Print paging-assistance info to the console */
void paging_dump_domain_info(struct domain *d);
--
generated by git-patchbot for /home/xen/git/xen.git#master