nested vmx: fix I/O port bitmap indexing arithmetic
PATCH 1/1 nested vmx: fix I/O port bitmap indexing arithmetic
The I/O port bitmap holds 8 ports per element, and hence the port number used when indexing into it should be shifted right by 3 bits, not 4.
---
Jan: I'm not sure if this also needs a fixup similar to what you did in SVM code with commit b1e87805bf.
xen/arch/x86/hvm/vmx/vvmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -2225,7 +2225,7 @@ int nvmx_n2_vmexit_handler(struct cpu_user_regs *regs,__vmread (EXIT_QUALIFICATION , &qual); port = qual >>16 ; bitmap = nvmx->iobitmap[port >>15 ]; -if ( bitmap[(port &0x7fff ) >>4 ] & (1 << (port &0x7 )) ) +if ( bitmap[(port &0x7fff ) >>3 ] & (1 << (port &0x7 )) ) nvcpu->nv_vmexit_pending =1 ;if ( !nvcpu->nv_vmexit_pending )gdprintk (XENLOG_WARNING ,"L0 PIO %x.\n" , port);
Signature · 1 line
1.7.10.4
Matthew Daley wrote on 2013-11-30:
Quoted 23 lines
The I/O port bitmap holds 8 ports per element, and hence the port number used when indexing into it should be shifted right by 3 bits, not 4.
Signed-off-by Matthew Daley <[email protected]>---
Jan: I'm not sure if this also needs a fixup similar to what you did in SVM code with commitb1e87805bf.xen/arch/x86/hvm/vmx/vvmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/hvm/vmx/vvmx.c +1
-1@@ -2225,7 +2225,7 @@ int nvmx_n2_vmexit_handler(struct cpu_user_regs *regs,__vmread (EXIT_QUALIFICATION , &qual); port = qual >>16 ; bitmap = nvmx->iobitmap[port >>15 ]; -if ( bitmap[(port &0x7fff ) >>4 ] & (1 << (port &0x7 )) ) +if ( bitmap[(port &0x7fff ) >>3 ] & (1 << (port &0x7 )) ) nvcpu->nv_vmexit_pending =1 ;if ( !nvcpu->nv_vmexit_pending )
Quoted 1 line
gdprintk(XENLOG_WARNING, "L0 PIO %x.\n", port);
Best regards,
Yang
Acked-by Eddie Dong <[email protected]>
-----Original Message-----
From: Matthew Daley [mailto:[email protected]]
Sent: Saturday, November 30, 2013 6:39 AM
To: [email protected]
Cc: Matthew Daley; Nakajima, Jun; Dong, Eddie; Keir Fraser; Jan Beulich
Subject: [PATCH] nested vmx: fix I/O port bitmap indexing arithmetic
The I/O port bitmap holds 8 ports per element, and hence the port number used when indexing into it should be shifted right by 3 bits, not 4.
---
Jan: I'm not sure if this also needs a fixup similar to what you did in SVM code with commit b1e87805bf.
xen/arch/x86/hvm/vmx/vvmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -2225,7 +2225,7 @@ int nvmx_n2_vmexit_handler(struct cpu_user_regs *regs,__vmread (EXIT_QUALIFICATION , &qual); port = qual >>16 ; bitmap = nvmx->iobitmap[port >>15 ]; -if ( bitmap[(port &0x7fff ) >>4 ] & (1 << (port &0x7 )) ) +if ( bitmap[(port &0x7fff ) >>3 ] & (1 << (port &0x7 )) ) nvcpu->nv_vmexit_pending =1 ;if ( !nvcpu->nv_vmexit_pending )gdprintk (XENLOG_WARNING ,"L0 PIO %x.\n" , port);
--
1.7.10.4
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Matthew Daley
The I/O port bitmap holds 8 ports per element, and hence the port number used when indexing into it should be shifted right by 3 bits, not 4.
Signed-off-by Matthew Daley <[email protected]>---
Jan: I'm not sure if this also needs a fixup similar to what you did in SVM code with commitb1e87805bf.
Yes, definitely. The wrapping behavior is different for VMX though. In fact, I'd prefer the whole fix to be done in one go (unless you tell me that you're not going to find time to do so any time soon).
Jan