xen/pvh: trap access to IO port range 0xcf8-0xcfb
PATCH 1/1 xen/pvh: trap access to IO port range 0xcf8-0xcfb
This is needed so Xen can properly trap 4 byte accesses to 0xcf8 in order to keep consistency with accesses to 0xcfc.
--- xen/arch/x86/setup.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
xen/arch/x86/setup.c +7 -1
@@ -1527,7 +1527,7 @@ static int __hwdom_init io_bitmap_cb(unsigned long s, unsigned long e, void __hwdom_init setup_io_bitmap(struct domain *d) { -int rc; +int rc, i;ASSERT (is_hardware_domain (d));if (has_hvm_container_domain (d) )
@@ -1535,6 +1535,12 @@ 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 the range 0xcf8-0xcfb in order +* to intercept 4 byte accesses. +*/ +for ( i =0xcf8 ; i <0xcfc ; i++ ) +__set_bit (i, d->arch.hvm_domain.io_bitmap); } }
Signature · 7 lines
1.9.5 (Apple Git-50.3) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
xen/arch/x86/setup.c static int __hwdom_init io_bitmap_cb(unsigned long s, · line 1531
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 08.05.15 at 12:00, <[email protected]> wrote:
xen/arch/x86/setup.c +1
-1@@ -1527,7 +1527,7 @@ static int __hwdom_init io_bitmap_cb(unsigned long s,unsigned long e, void __hwdom_init setup_io_bitmap(struct domain *d) { - int rc; + int rc, i;
The new variable ought to be of unsigned type and could go into the more narrow scope it's needed in.
xen/arch/x86/setup.c void __hwdom_init setup_io_bitmap(struct domain *d) · line 1543
Quoted 10 lines
xen/arch/x86/setup.c +6
-0@@ -1535,6 +1535,12 @@ 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 the range 0xcf8-0xcfb in order +* to intercept 4 byte accesses. +*/ +for ( i =0xcf8 ; i <0xcfc ; i++ ) +__set_bit (i, d->arch.hvm_domain.io_bitmap);
To achieve what the comment says you'd really only need to set any one of the four bits.
Jan
El 08/05/15 a les 12.18, Jan Beulich ha escrit:
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 08.05.15 at 12:00, <[email protected]> wrote:
xen/arch/x86/setup.c +0
-0@@ -1527,7 +1527,7 @@ static int __hwdom_init io_bitmap_cb(unsigned long s, unsigned long e,
Quoted 7 lines
xen/arch/x86/setup.c static int __hwdom_init io_bitmap_cb(unsigned long s, unsigned long e, · line 1530
Quoted 4 lines
xen/arch/x86/setup.c +1
-1void __hwdom_init setup_io_bitmap(struct domain *d) { -int rc; +int rc, i;The new variable ought to be of unsigned type and could go into the more narrow scope it's needed in.
Why of type unsigned? __set_bit expects an int.
Quoted 5 lines
Quoted 5 lines
xen/arch/x86/setup.c +1
-0@@ -1535,6 +1535,12 @@ 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); +/*
Quoted 8 lines
xen/arch/x86/setup.c void __hwdom_init setup_io_bitmap(struct domain *d) · line 1543
Quoted 5 lines
xen/arch/x86/setup.c +5
-0+* NB: we need to trap accesses to the range 0xcf8-0xcfb in order +* to intercept 4 byte accesses. +*/ +for ( i =0xcf8 ; i <0xcfc ; i++ ) +__set_bit (i, d->arch.hvm_domain.io_bitmap);To achieve what the comment says you'd really only need to set any one of the four bits.
Indeed, but I think it's more clear this way, the effect is exactly the same. If you prefer I can only set 0xcf8 and we can get rid of the extra i variable.
Roger.
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 08.05.15 at 12:22, <[email protected]> wrote:
El 08/05/15 a les 12.18, Jan Beulich ha escrit:
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 08.05.15 at 12:00, <[email protected]> wrote:
xen/arch/x86/setup.c +0
-0@@ -1527,7 +1527,7 @@ static int __hwdom_init io_bitmap_cb(unsigned long s, unsigned long e,Quoted 7 lines
xen/arch/x86/setup.c static int __hwdom_init io_bitmap_cb(unsigned long s, unsigned long e, · line 1530
Quoted 4 lines
xen/arch/x86/setup.c +1
-1void __hwdom_init setup_io_bitmap(struct domain *d) { -int rc; +int rc, i;The new variable ought to be of unsigned type and could go into the more narrow scope it's needed in.
Quoted 1 line
Why of type unsigned?
__set_bitexpects an int.
This doesn't matter as long as the value fits in both an int and an unsigned int. (I also - sadly only now - realized that your other patch used plain int in a similar case where it should have been unsigned, along with a more complex ASSERT() expression than really necessary.)
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
xen/arch/x86/setup.c +1
-0@@ -1535,6 +1535,12 @@ 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); +/* Quoted 8 lines
xen/arch/x86/setup.c void __hwdom_init setup_io_bitmap(struct domain *d) · line 1543
Quoted 5 lines
xen/arch/x86/setup.c +5
-0+* NB: we need to trap accesses to the range 0xcf8-0xcfb in order +* to intercept 4 byte accesses. +*/ +for ( i =0xcf8 ; i <0xcfc ; i++ ) +__set_bit (i, d->arch.hvm_domain.io_bitmap);To achieve what the comment says you'd really only need to set any one of the four bits.
Quoted 3 lines
Indeed, but I think it's more clear this way, the effect is exactly the same. If you prefer I can only set
0xcf8and we can get rid of the extra i variable.
I think that would be the preferable solution.
Jan