x86/pvh: trap access to sensitive IO ports
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 20 May 2015 11:27:23 +0000 (13:27 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 20 May 2015 11:27:23 +0000 (13:27 +0200)
This is needed so Xen can properly trap 4 byte accesses to 0xcf8 in order to
keep consistency with accesses to 0xcfc.

The access to RTC ports also needs to be trapped in order to keep
consistency, this includes RTC_PORT(0) and RTC_PORT(1) (0x70 and 0x71
respectively).

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/setup.c

index cd333f904b52ff4836ba61e5c8a5df0c4bf74725..2cc91851a9b31145ac1d12274a3acce623aec365 100644 (file)
@@ -49,6 +49,7 @@
 #include <xen/cpu.h>
 #include <asm/nmi.h>
 #include <asm/alternative.h>
+#include <asm/mc146818rtc.h>
 
 /* opt_nosmp: If true, secondary processors are ignored. */
 static bool_t __initdata opt_nosmp;
@@ -1534,6 +1535,16 @@ void __hwdom_init setup_io_bitmap(struct domain *d)
         rc = rangeset_report_ranges(d->arch.ioport_caps, 0, 0x10000,
                                     io_bitmap_cb, d);
         BUG_ON(rc);
+        /*
+         * NB: we need to trap accesses to 0xcf8 in order to intercept
+         * 4 byte accesses, that need to be handled by Xen in order to
+         * keep consistency.
+         * Access to 1 byte RTC ports also needs to be trapped in order
+         * to keep consistency with PV.
+         */
+        __set_bit(0xcf8, d->arch.hvm_domain.io_bitmap);
+        __set_bit(RTC_PORT(0), d->arch.hvm_domain.io_bitmap);
+        __set_bit(RTC_PORT(1), d->arch.hvm_domain.io_bitmap);
     }
 }