* [PATCH] x86/mm: slightly simplify mod_l1_entry()
@ 2016-02-17 16:10 Jan Beulich
2016-02-17 17:41 ` Andrew Cooper
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2016-02-17 16:10 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Keir Fraser
[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]
Re-order code to simplify error cleanup.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -1873,38 +1873,32 @@ static int mod_l1_entry(l1_pgentry_t *pl
{
/* Translate foreign guest addresses. */
struct page_info *page = NULL;
- if ( paging_mode_translate(pg_dom) )
- {
- page = get_page_from_gfn(pg_dom, l1e_get_pfn(nl1e), NULL, P2M_ALLOC);
- if ( !page )
- return -EINVAL;
- nl1e = l1e_from_pfn(page_to_mfn(page), l1e_get_flags(nl1e));
- }
if ( unlikely(l1e_get_flags(nl1e) & l1_disallow_mask(pt_dom)) )
{
MEM_LOG("Bad L1 flags %x",
l1e_get_flags(nl1e) & l1_disallow_mask(pt_dom));
- if ( page )
- put_page(page);
return -EINVAL;
}
+ if ( paging_mode_translate(pg_dom) )
+ {
+ page = get_page_from_gfn(pg_dom, l1e_get_pfn(nl1e), NULL, P2M_ALLOC);
+ if ( !page )
+ return -EINVAL;
+ nl1e = l1e_from_pfn(page_to_mfn(page), l1e_get_flags(nl1e));
+ }
+
/* Fast path for identical mapping, r/w, presence, and cachability. */
if ( !l1e_has_changed(ol1e, nl1e,
PAGE_CACHE_ATTRS | _PAGE_RW | _PAGE_PRESENT) )
{
adjust_guest_l1e(nl1e, pt_dom);
- if ( UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu,
- preserve_ad) )
- {
- if ( page )
- put_page(page);
- return 0;
- }
+ rc = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu,
+ preserve_ad);
if ( page )
put_page(page);
- return -EBUSY;
+ return rc ? 0 : -EBUSY;
}
switch ( rc = get_page_from_l1e(nl1e, pt_dom, pg_dom) )
[-- Attachment #2: x86-mm-mod-L1-simplify.patch --]
[-- Type: text/plain, Size: 2078 bytes --]
x86/mm: slightly simplify mod_l1_entry()
Re-order code to simplify error cleanup.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -1873,38 +1873,32 @@ static int mod_l1_entry(l1_pgentry_t *pl
{
/* Translate foreign guest addresses. */
struct page_info *page = NULL;
- if ( paging_mode_translate(pg_dom) )
- {
- page = get_page_from_gfn(pg_dom, l1e_get_pfn(nl1e), NULL, P2M_ALLOC);
- if ( !page )
- return -EINVAL;
- nl1e = l1e_from_pfn(page_to_mfn(page), l1e_get_flags(nl1e));
- }
if ( unlikely(l1e_get_flags(nl1e) & l1_disallow_mask(pt_dom)) )
{
MEM_LOG("Bad L1 flags %x",
l1e_get_flags(nl1e) & l1_disallow_mask(pt_dom));
- if ( page )
- put_page(page);
return -EINVAL;
}
+ if ( paging_mode_translate(pg_dom) )
+ {
+ page = get_page_from_gfn(pg_dom, l1e_get_pfn(nl1e), NULL, P2M_ALLOC);
+ if ( !page )
+ return -EINVAL;
+ nl1e = l1e_from_pfn(page_to_mfn(page), l1e_get_flags(nl1e));
+ }
+
/* Fast path for identical mapping, r/w, presence, and cachability. */
if ( !l1e_has_changed(ol1e, nl1e,
PAGE_CACHE_ATTRS | _PAGE_RW | _PAGE_PRESENT) )
{
adjust_guest_l1e(nl1e, pt_dom);
- if ( UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu,
- preserve_ad) )
- {
- if ( page )
- put_page(page);
- return 0;
- }
+ rc = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu,
+ preserve_ad);
if ( page )
put_page(page);
- return -EBUSY;
+ return rc ? 0 : -EBUSY;
}
switch ( rc = get_page_from_l1e(nl1e, pt_dom, pg_dom) )
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] x86/mm: slightly simplify mod_l1_entry()
2016-02-17 16:10 [PATCH] x86/mm: slightly simplify mod_l1_entry() Jan Beulich
@ 2016-02-17 17:41 ` Andrew Cooper
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2016-02-17 17:41 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Keir Fraser
On 17/02/16 16:10, Jan Beulich wrote:
> Re-order code to simplify error cleanup.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-17 17:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-17 16:10 [PATCH] x86/mm: slightly simplify mod_l1_entry() Jan Beulich
2016-02-17 17:41 ` Andrew Cooper
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).