From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: "Tamas K Lengyel" <tamas@tklengyel.com>,
"Wei Liu" <wei.liu2@citrix.com>,
"Razvan Cojocaru" <rcojocaru@bitdefender.com>,
"George Dunlap" <george.dunlap@eu.citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Jan Beulich" <JBeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 05/14] x86/p2m: Don't overwrite p2m_altp2m_lazy_copy()'s callers p2m pointer
Date: Wed, 21 Nov 2018 13:21:13 +0000 [thread overview]
Message-ID: <1542806482-24030-6-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1542806482-24030-1-git-send-email-andrew.cooper3@citrix.com>
The final parameter to p2m_altp2m_lazy_copy() appears to be unnecessary, and
results in very hard-to-follow code. Have the sole caller set its local p2m
pointer appropriately, and drop the parameter.
With that done, a level of indirection of ap2m can be dropped inside
p2m_altp2m_lazy_copy(). While changing the API, switch it from bool_t to
bool, and drop printing of the altp2m's virtual address, because it is of no
use even when debugging.
No (intended) overall change in behaviour.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
--
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Razvan Cojocaru <rcojocaru@bitdefender.com>
CC: Tamas K Lengyel <tamas@tklengyel.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
---
xen/arch/x86/hvm/hvm.c | 4 +++-
xen/arch/x86/mm/p2m.c | 24 ++++++++++++------------
xen/include/asm-x86/p2m.h | 4 ++--
3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index e2e4204..94fe441 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1760,7 +1760,9 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
if ( ap2m_active )
{
- if ( p2m_altp2m_lazy_copy(curr, gpa, gla, npfec, &p2m) )
+ p2m = p2m_get_altp2m(curr);
+
+ if ( p2m_altp2m_lazy_copy(curr, gpa, gla, npfec) )
{
/* entry was lazily copied from host -- retry */
__put_gfn(hostp2m, gfn);
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index ae9cb20..8b9898a 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2172,23 +2172,23 @@ bool_t p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx)
* indicate that outer handler should handle fault
*/
-bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
- unsigned long gla, struct npfec npfec,
- struct p2m_domain **ap2m)
+bool p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
+ unsigned long gla, struct npfec npfec)
{
struct p2m_domain *hp2m = p2m_get_hostp2m(v->domain);
+ struct p2m_domain *ap2m = p2m_get_altp2m(v);
p2m_type_t p2mt;
p2m_access_t p2ma;
unsigned int page_order;
- gfn_t gfn = _gfn(paddr_to_pfn(gpa));
+ gfn_t gfn = gaddr_to_gfn(gpa);
unsigned long mask;
mfn_t mfn;
int rv;
bool ret;
- *ap2m = p2m_get_altp2m(v);
+ ASSERT(p2m_locked_by_me(hp2m));
- mfn = get_gfn_type_access(*ap2m, gfn_x(gfn), &p2mt, &p2ma,
+ mfn = get_gfn_type_access(ap2m, gfn_x(gfn), &p2mt, &p2ma,
0, &page_order);
/* Entry already present in ap2m? Caller should handle the fault. */
@@ -2216,15 +2216,15 @@ bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
mfn = _mfn(mfn_x(mfn) & mask);
gfn = _gfn(gfn_x(gfn) & mask);
- p2m_lock(*ap2m);
- rv = p2m_set_entry(*ap2m, gfn, mfn, page_order, p2mt, p2ma);
- p2m_unlock(*ap2m);
+ p2m_lock(ap2m);
+ rv = p2m_set_entry(ap2m, gfn, mfn, page_order, p2mt, p2ma);
+ p2m_unlock(ap2m);
if ( rv )
{
gdprintk(XENLOG_ERR,
- "failed to set entry for %#"PRIx64" -> %#"PRIx64" p2m %#"PRIx64"\n",
- gfn_x(gfn), mfn_x(mfn), (unsigned long)*ap2m);
+ "failed to set entry for %#"PRIx64" -> %#"PRIx64"\n",
+ gfn_x(gfn), mfn_x(mfn));
domain_crash(hp2m->domain);
}
@@ -2233,7 +2233,7 @@ bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
put_hp2m:
__put_gfn(hp2m, gfn_x(gfn));
put_ap2m:
- __put_gfn(*ap2m, gfn_x(gfn));
+ __put_gfn(ap2m, gfn_x(gfn));
return ret;
}
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 6d849a5..04c2104 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -868,8 +868,8 @@ void p2m_altp2m_check(struct vcpu *v, uint16_t idx);
void p2m_flush_altp2m(struct domain *d);
/* Alternate p2m paging */
-bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
- unsigned long gla, struct npfec npfec, struct p2m_domain **ap2m);
+bool p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
+ unsigned long gla, struct npfec npfec);
/* Make a specific alternate p2m valid */
int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-11-21 13:21 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 13:21 [PATCH 00/14] XSA-277 followup Andrew Cooper
2018-11-21 13:21 ` [PATCH 01/14] x86/soft-reset: Drop gfn reference after calling get_gfn_query() Andrew Cooper
2018-11-22 14:45 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 02/14] x86/mem-sharing: Don't leave the altp2m lock held when nominating a page Andrew Cooper
2018-11-21 16:56 ` Tamas K Lengyel
2018-11-22 14:46 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 03/14] AMD/IOMMU: Fix multiple reference counting errors Andrew Cooper
2018-11-22 14:51 ` Jan Beulich
2018-11-22 17:46 ` Andrew Cooper
2018-11-23 8:23 ` Jan Beulich
2018-11-23 16:03 ` Andrew Cooper
2018-11-26 9:05 ` Jan Beulich
2019-01-31 15:59 ` Woods, Brian
2018-11-21 13:21 ` [PATCH 04/14] x86/p2m: Fix locking in p2m_altp2m_lazy_copy() Andrew Cooper
2018-11-21 13:59 ` Razvan Cojocaru
2018-11-22 15:01 ` Jan Beulich
2018-12-05 19:53 ` Andrew Cooper
2018-11-21 13:21 ` Andrew Cooper [this message]
2018-11-21 14:07 ` [PATCH 05/14] x86/p2m: Don't overwrite p2m_altp2m_lazy_copy()'s callers p2m pointer Razvan Cojocaru
2018-11-22 15:03 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 06/14] x86/hvm: Make the altp2m locking easier to follow Andrew Cooper
2018-11-21 14:43 ` Razvan Cojocaru
2018-11-22 15:08 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 07/14] x86/p2m: Coding style cleanup Andrew Cooper
2018-11-22 15:12 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 08/14] xen/memory: Drop ARM put_gfn() stub Andrew Cooper
2018-11-22 14:07 ` Julien Grall
2018-11-22 15:15 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 09/14] x86/p2m: Switch the two_gfns infrastructure to using gfn_t Andrew Cooper
2018-11-21 17:06 ` Tamas K Lengyel
2018-11-22 15:17 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 10/14] x86/mm: Switch {get, put}_gfn() " Andrew Cooper
2018-11-21 14:48 ` Razvan Cojocaru
2018-11-21 16:12 ` Paul Durrant
2018-11-22 15:34 ` Jan Beulich
2018-11-23 2:58 ` Tian, Kevin
2018-11-26 15:51 ` Woods, Brian
2018-11-21 13:21 ` [PATCH 11/14] xen/mm: Switch mfn_to_virt()/virt_to_mfn() to using mfn_t Andrew Cooper
2018-11-22 14:32 ` Julien Grall
2018-11-22 15:44 ` Jan Beulich
2018-11-22 15:49 ` Andrew Cooper
2018-11-21 13:21 ` [PATCH 12/14] xen/gnttab: Drop gnttab_create_{shared, status}_page() Andrew Cooper
2018-11-22 14:35 ` Julien Grall
2018-11-22 15:47 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 13/14] xen/gnttab: Simplify gnttab_map_frame() Andrew Cooper
2018-11-22 14:36 ` Julien Grall
2018-11-22 15:48 ` Jan Beulich
2018-11-21 13:21 ` [PATCH 14/14] xen/gnttab: Minor improvements to arch header files Andrew Cooper
2018-11-22 15:51 ` Jan Beulich
2018-11-22 17:56 ` Andrew Cooper
2019-01-30 20:04 ` Julien Grall
2019-01-30 20:05 ` Andrew Cooper
2018-11-21 17:19 ` [PATCH 00/14] XSA-277 followup Tamas K Lengyel
2018-11-21 21:22 ` Andrew Cooper
2018-11-21 22:42 ` Tamas K Lengyel
2018-11-22 0:08 ` Andrew Cooper
2018-11-26 17:48 ` Tamas K Lengyel
2018-11-23 15:46 ` Roger Pau Monné
2019-01-30 18:36 ` Pings for 4.12 " Andrew Cooper
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=1542806482-24030-6-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=george.dunlap@eu.citrix.com \
--cc=rcojocaru@bitdefender.com \
--cc=roger.pau@citrix.com \
--cc=tamas@tklengyel.com \
--cc=wei.liu2@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).