From: Jan Beulich <jbeulich@suse.com> To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org> Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>, "Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>, "George Dunlap" <george.dunlap@citrix.com>, "Tim Deegan" <tim@xen.org> Subject: [PATCH v4 3/3] x86/shadow: streamline shadow_get_page_from_l1e() Date: Fri, 23 Apr 2021 12:54:04 +0200 [thread overview] Message-ID: <a73a6dd7-0cca-9ffe-e27e-39671c16e74c@suse.com> (raw) In-Reply-To: <3e7ad009-f062-d58a-9380-103ce1573a73@suse.com> Trying get_page_from_l1e() up to three times isn't helpful; in debug builds it may lead to log messages making things look as if there was a problem somewhere. And there's no need to have more than one try: The function can only possibly succeed for one domain passed as 3rd argument (unless the page is an MMIO one to which both have access, but MMIO pages should be "got" by specifying the requesting domain anyway). Re-arrange things so just the one call gets made which has a chance of succeeding. The code could in principle be arranged such that there's only a single call to get_page_from_l1e(), but the conditional would become pretty complex then and hence hard to follow / understand / adjust. The redundant (with shadow_mode_refcounts()) shadow_mode_translate() gets dropped. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Tim Deegan <tim@xen.org> --- v5: Integrate into series. Re-base. --- a/xen/arch/x86/mm/shadow/set.c +++ b/xen/arch/x86/mm/shadow/set.c @@ -109,40 +109,36 @@ shadow_get_page_from_l1e(shadow_l1e_t sl if ( pg && page_refcounting_suppressed(pg) ) return 0; - res = get_page_from_l1e(sl1e, d, d); + if ( owner == dom_io ) + owner = NULL; /* * If a privileged domain is attempting to install a map of a page it does * not own, we let it succeed anyway. */ - if ( unlikely(res < 0) && - !shadow_mode_translate(d) && - owner && (d != owner) ) + if ( owner && (d != owner) && + !(res = xsm_priv_mapping(XSM_TARGET, d, owner)) ) { - res = xsm_priv_mapping(XSM_TARGET, d, owner); - if ( !res ) - { - res = get_page_from_l1e(sl1e, d, owner); - SHADOW_PRINTK("privileged %pd installs map of mfn %"PRI_mfn" owned by %pd: %s\n", - d, mfn_x(mfn), owner, - res >= 0 ? "success" : "failed"); - } + res = get_page_from_l1e(sl1e, d, owner); + SHADOW_PRINTK("privileged %pd installs map of %pd's mfn %"PRI_mfn": %s\n", + d, owner, mfn_x(mfn), + res >= 0 ? "success" : "failed"); } - /* Okay, it might still be a grant mapping PTE. Try it. */ - if ( unlikely(res < 0) && - (type == p2m_grant_map_rw || - (type == p2m_grant_map_ro && - !(shadow_l1e_get_flags(sl1e) & _PAGE_RW))) ) + else if ( owner && + (type == p2m_grant_map_rw || + (type == p2m_grant_map_ro && + !(shadow_l1e_get_flags(sl1e) & _PAGE_RW))) ) { /* * It's a grant mapping. The grant table implementation will * already have checked that we're supposed to have access, so * we can just grab a reference directly. */ - if ( owner ) - res = get_page_from_l1e(sl1e, d, owner); + res = get_page_from_l1e(sl1e, d, owner); } + else + res = get_page_from_l1e(sl1e, d, d); if ( unlikely(res < 0) ) {
next prev parent reply other threads:[~2021-04-23 10:54 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-22 10:55 [PATCH v3 0/2] VMX: apic access page handling adjustments Jan Beulich 2021-02-22 10:56 ` [PATCH v3 1/2][4.15] VMX: delay p2m insertion of APIC access page Jan Beulich 2021-02-22 11:25 ` Ian Jackson 2021-02-22 14:05 ` Jan Beulich 2021-02-22 17:17 ` Ian Jackson 2021-02-22 12:15 ` Roger Pau Monné 2021-02-25 8:44 ` Jan Beulich 2021-02-26 7:06 ` Tian, Kevin 2021-02-22 10:57 ` [PATCH v3 2/2] VMX: use a single, global " Jan Beulich 2021-03-01 2:34 ` Tian, Kevin 2021-03-01 8:18 ` Jan Beulich 2021-04-12 10:40 ` [PATCH v4] " Jan Beulich 2021-04-12 15:31 ` Roger Pau Monné 2021-04-13 9:24 ` Jan Beulich 2021-04-13 10:18 ` Roger Pau Monné 2021-04-13 12:03 ` Jan Beulich 2021-04-13 13:03 ` Roger Pau Monné 2021-04-17 19:24 ` Tim Deegan 2021-04-19 11:25 ` Jan Beulich 2021-04-22 7:42 ` Tim Deegan 2021-04-22 9:38 ` Jan Beulich 2021-04-22 15:05 ` Tim Deegan 2021-04-23 10:51 ` [PATCH v4 0/3] VMX APIC access page and shadow adjustments Jan Beulich 2021-04-23 10:52 ` [PATCH v4 1/3] VMX: use a single, global APIC access page Jan Beulich 2021-04-23 14:17 ` Roger Pau Monné 2021-04-23 14:42 ` Jan Beulich 2021-04-26 17:55 ` Tim Deegan 2021-04-25 1:27 ` Tian, Kevin 2021-04-26 17:53 ` Tim Deegan 2021-04-23 10:53 ` [PATCH v4 2/3] x86/shadow: re-use variables in shadow_get_page_from_l1e() Jan Beulich 2021-04-23 10:54 ` Jan Beulich [this message] 2021-04-23 11:00 ` Really v5 (was: [PATCH v4 0/3] VMX APIC access page and shadow adjustments) 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=a73a6dd7-0cca-9ffe-e27e-39671c16e74c@suse.com \ --to=jbeulich@suse.com \ --cc=andrew.cooper3@citrix.com \ --cc=george.dunlap@citrix.com \ --cc=roger.pau@citrix.com \ --cc=tim@xen.org \ --cc=wl@xen.org \ --cc=xen-devel@lists.xenproject.org \ --subject='Re: [PATCH v4 3/3] x86/shadow: streamline shadow_get_page_from_l1e()' \ /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
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).