From: Matthew Barnes Date: Thu, 8 Aug 2024 11:57:43 +0000 (+0200) Subject: x86/emul: Fix misaligned IO breakpoint behaviour in PV guests X-Git-Tag: RELEASE-4.17.5~3 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=72db7ba7dbd1287101b9533cd7e4c877f31a0764;p=xen.git x86/emul: Fix misaligned IO breakpoint behaviour in PV guests When hardware breakpoints are configured on misaligned IO ports, the hardware will mask the addresses based on the breakpoint width during comparison. For PV guests, misaligned IO breakpoints do not behave the same way, and therefore yield different results. This patch tweaks the emulation of IO breakpoints for PV guests such that they reproduce the same behaviour as hardware. Fixes: bec9e3205018 ("x86: emulate I/O port access breakpoints") Signed-off-by: Matthew Barnes Reviewed-by: Jan Beulich master commit: 08aacc392d86d4c7dbebdb5e664060ae2af72057 master date: 2024-08-08 13:27:50 +0200 --- diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index e429dfa4f0..f216c26412 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -358,6 +358,8 @@ static unsigned int check_guest_io_breakpoint(struct vcpu *v, case DR_LEN_8: width = 8; break; } + start &= ~(width - 1UL); + if ( (start < (port + len)) && ((start + width) > port) ) match |= 1u << i; }