[PATCH v4 4/4] tests: check KVM ioctl commands decoding

Dmitry V. Levin ldv at altlinux.org
Thu Dec 7 18:01:03 UTC 2017


On Fri, Dec 08, 2017 at 12:15:37AM +0900, Masatake YAMATO wrote:
[...]
> I read this through. Other than assembly language code in code(),
> it looks good for me.
> 
> I don't understand what is done in code().
> I compiled .c file having only code() and run objdump -d:
> What I got is
> 
>     0000000000000000 <code>:
>        0:	55                   	push   %rbp
>        1:	48 89 e5             	mov    %rsp,%rbp
>        4:	ba f8 03 00 d8       	mov    $0xd80003f8,%edx
>        9:	b0 0a                	mov    $0xa,%al
>        b:	ee                   	out    %al,(%dx)
>        c:	f4                   	hlt    
>        d:	90                   	nop
>        e:	5d                   	pop    %rbp
>        f:	c3                   	retq

It looks slightly different in the real test,
most likely because gcc optimized it:

$ objdump -d ioctl_kvm_run.o | sed -n '/<code>/,/^$/p'
0000000000000000 <code>:
   0:	ba f8 03 00 d8       	mov    $0xd80003f8,%edx
   5:	b0 0a                	mov    $0xa,%al
   7:	ee                   	out    %al,(%dx)
   8:	f4                   	hlt    
   9:	c3                   	retq   
   a:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)

Anyway, the difference is not important as long as "out" and "hlt"
are there.

> I find no add operator in the output. So I guess what this
> code does is different fron what the original code does:
> 
> 	const uint8_t code[] = {
> 		0xba, 0xf8, 0x03, /* mov $0x3f8, %dx */
> 		0x00, 0xd8,       /* add %bl, %al */
> 		0x04, '0',        /* add $'0', %al */
> 
> The code executed by kvm is not important here. However,
> I wondher what the intent is.

I've just simplified the code a bit.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20171207/a1945050/attachment.bin>


More information about the Strace-devel mailing list