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>,
"Tim Deegan" <tim@xen.org>,
"George Dunlap" <george.dunlap@citrix.com>
Subject: [PATCH v2 1/3] x86/shadow: move dm-mmio handling code in sh_page_fault()
Date: Mon, 23 Jan 2023 15:26:57 +0100 [thread overview]
Message-ID: <5d8a938e-cb4a-a989-1849-d702cd25d890@suse.com> (raw)
In-Reply-To: <0e682cd4-3cc0-461d-ee53-13a894797f17@suse.com>
Do away with the partly mis-named "mmio" label there, which really is
only about emulated MMIO. Move the code to the place where the sole
"goto" was. Re-order steps slightly: Assertion first, perfc increment
outside of the locked region, and "gpa" calculation closer to the first
use of the variable. Also make the HVM conditional cover the entire
if(), as p2m_mmio_dm isn't applicable to PV; specifically get_gfn()
won't ever return this type for PV domains.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: New.
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -2588,13 +2588,33 @@ static int cf_check sh_page_fault(
goto emulate;
}
+#ifdef CONFIG_HVM
+
/* Need to hand off device-model MMIO to the device model */
if ( p2mt == p2m_mmio_dm )
{
+ ASSERT(is_hvm_vcpu(v));
+ if ( !guest_mode(regs) )
+ goto not_a_shadow_fault;
+
+ sh_audit_gw(v, &gw);
gpa = guest_walk_to_gpa(&gw);
- goto mmio;
+ SHADOW_PRINTK("mmio %#"PRIpaddr"\n", gpa);
+ shadow_audit_tables(v);
+ sh_reset_early_unshadow(v);
+
+ paging_unlock(d);
+ put_gfn(d, gfn_x(gfn));
+
+ perfc_incr(shadow_fault_mmio);
+ trace_shadow_gen(TRC_SHADOW_MMIO, va);
+
+ return handle_mmio_with_translation(va, gpa >> PAGE_SHIFT, access)
+ ? EXCRET_fault_fixed : 0;
}
+#endif /* CONFIG_HVM */
+
/* Ignore attempts to write to read-only memory. */
if ( p2m_is_readonly(p2mt) && (ft == ft_demand_write) )
goto emulate_readonly; /* skip over the instruction */
@@ -2867,25 +2887,6 @@ static int cf_check sh_page_fault(
return EXCRET_fault_fixed;
#endif /* CONFIG_HVM */
- mmio:
- if ( !guest_mode(regs) )
- goto not_a_shadow_fault;
-#ifdef CONFIG_HVM
- ASSERT(is_hvm_vcpu(v));
- perfc_incr(shadow_fault_mmio);
- sh_audit_gw(v, &gw);
- SHADOW_PRINTK("mmio %#"PRIpaddr"\n", gpa);
- shadow_audit_tables(v);
- sh_reset_early_unshadow(v);
- paging_unlock(d);
- put_gfn(d, gfn_x(gfn));
- trace_shadow_gen(TRC_SHADOW_MMIO, va);
- return (handle_mmio_with_translation(va, gpa >> PAGE_SHIFT, access)
- ? EXCRET_fault_fixed : 0);
-#else
- BUG();
-#endif
-
not_a_shadow_fault:
sh_audit_gw(v, &gw);
SHADOW_PRINTK("not a shadow fault\n");
next prev parent reply other threads:[~2023-01-23 14:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-23 14:25 [PATCH v2 0/3] x86/shadow: sh_page_fault() adjustments Jan Beulich
2023-01-23 14:26 ` Jan Beulich [this message]
2023-01-23 15:08 ` [PATCH v2 1/3] x86/shadow: move dm-mmio handling code in sh_page_fault() Jan Beulich
2023-02-24 16:37 ` Andrew Cooper
2023-01-23 14:27 ` [PATCH v2 2/3] x86/shadow: mark more of sh_page_fault() HVM-only Jan Beulich
2023-02-24 16:39 ` Andrew Cooper
2023-01-23 14:27 ` [PATCH v2 3/3] x86/shadow: drop dead code from HVM-only sh_page_fault() pieces Jan Beulich
2023-02-24 16:40 ` 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=5d8a938e-cb4a-a989-1849-d702cd25d890@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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.