Skip to contentSkip to conversation

Test case of emulating multibyte NOP

PATCH In review Arthur Chunqi Li 2 participants 9 messages Jun 5, 2013 – Jun 6, 2013 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Test case of emulating multibyte NOP

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +24 -0
index 981be08..e103ca6 100644
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
 	report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
+static void test_nopl(void)
+{
+	MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+	MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+	MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+	MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop
+	MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 5 bytes nop
+	MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 6 bytes nop
+	MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); // 7 bytes nop
+	MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 8 bytes nop
+	MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 9 bytes nop
+	exec_in_big_real_mode(&insn_nopl1);
+	exec_in_big_real_mode(&insn_nopl2);
+	exec_in_big_real_mode(&insn_nopl3);
+	exec_in_big_real_mode(&insn_nopl4);
+	exec_in_big_real_mode(&insn_nopl5);
+	exec_in_big_real_mode(&insn_nopl6);
+	exec_in_big_real_mode(&insn_nopl7);
+	exec_in_big_real_mode(&insn_nopl8);
+	exec_in_big_real_mode(&insn_nopl9);
+	report("nopl", 0, 1);
+}
+
 void realmode_start(void)
 {
 	test_null();
@@ -1548,6 +1571,7 @@ void realmode_start(void)
 	test_xlat();
 	test_salc();
 	test_fninit();
+	test_nopl();
 
 	exit(0);
 }
Signature · 1 line
1.7.9.5
#1 lore raw

This time the email is perfect :)

Quoted 12 lines · Arthur Chunqi Li

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +0 -0
index 981be08..e103ca6 100644

x86/realmode.c static void test_fninit(void) · line 1512

Quoted 9 lines
x86/realmode.c +6 -0
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
 	report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
+static void test_nopl(void)
+{
+	MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+	MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+	MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+	MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop

But all nops below that are not supported in 16 bit mode. You can disassemble realmode.elf in 16bit node (objdump -z -d -mi8086 x86/realmode.elf) and check yourself. Lets not complicate things for now and test only those that are easy to test.

Quoted 30 lines
x86/realmode.c +18 -0
+	MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 5 bytes nop
+	MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 6 bytes nop
+	MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); // 7 bytes nop
+	MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 8 bytes nop
+	MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 9 bytes nop
+	exec_in_big_real_mode(&insn_nopl1);
+	exec_in_big_real_mode(&insn_nopl2);
+	exec_in_big_real_mode(&insn_nopl3);
+	exec_in_big_real_mode(&insn_nopl4);
+	exec_in_big_real_mode(&insn_nopl5);
+	exec_in_big_real_mode(&insn_nopl6);
+	exec_in_big_real_mode(&insn_nopl7);
+	exec_in_big_real_mode(&insn_nopl8);
+	exec_in_big_real_mode(&insn_nopl9);
+	report("nopl", 0, 1);
+}
+
 void realmode_start(void)
 {
 	test_null();
@@ -1548,6 +1571,7 @@ void realmode_start(void)
 	test_xlat();
 	test_salc();
 	test_fninit();
+	test_nopl();
 
 	exit(0);
 }
Signature · 1 line
1.7.9.5

--
Gleb.

#2 lore raw
Quoted 18 lines · Gleb Natapov

This time the email is perfect :)

Quoted 15 lines · Arthur Chunqi Li

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +0 -0
index 981be08..e103ca6 100644
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
      report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
Quoted 10 lines

x86/realmode.c static void test_fninit(void) · line 1512

Quoted 6 lines
x86/realmode.c +6 -0
+static void test_nopl(void)
+{
+     MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+     MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+     MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+     MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop

But all nops below that are not supported in 16 bit mode. You can disassemble realmode.elf in 16bit node (objdump -z -d -mi8086 x86/realmode.elf) and check yourself. Lets not complicate things for now and test only those that are easy to test.

Yes. But what if a 7-bytes nop runs in 16bit mode? Just the same as
https://bugzilla.redhat.com/show_bug.cgi?id=967652

DR6=00000000ffff0ff0 DR7=0000000000000400 EFER=0000000000000500
Code=00 00 e9 50 ff ff ff 00 00 00 00 85 d2 74 20 45 31 c0 31 c9 <0f> 1f 80 00 00 00 00 0f b6 04 31 41 83 c0 01 88 04 39 48 83 c1 01 41 39 d0 75 ec 48 89 f8

The error code is "0f 1f 80 00 00 00 00", which is a 7-bytes nop. Will the emulator runs well in that case when booting RHEL5.9 64-bit?

Arthur

Quoted 34 lines
Quoted 30 lines
x86/realmode.c +18 -1
+     MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 5 bytes nop
+     MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 6 bytes nop
+     MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); // 7 bytes nop
+     MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 8 bytes nop
+     MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 9 bytes nop
+     exec_in_big_real_mode(&insn_nopl1);
+     exec_in_big_real_mode(&insn_nopl2);
+     exec_in_big_real_mode(&insn_nopl3);
+     exec_in_big_real_mode(&insn_nopl4);
+     exec_in_big_real_mode(&insn_nopl5);
+     exec_in_big_real_mode(&insn_nopl6);
+     exec_in_big_real_mode(&insn_nopl7);
+     exec_in_big_real_mode(&insn_nopl8);
+     exec_in_big_real_mode(&insn_nopl9);
+     report("nopl", 0, 1);
+}
+
 void realmode_start(void)
 {
      test_null();
@@ -1548,6 +1571,7 @@ void realmode_start(void)
      test_xlat();
      test_salc();
      test_fninit();
+     test_nopl();
 
      exit(0);
 }
--
Quoted 1 line

1.7.9.5

--
Gleb.

#3 lore raw
Quoted 29 lines · 李春奇
Quoted 18 lines · Gleb Natapov

This time the email is perfect :)

Quoted 15 lines · Arthur Chunqi Li

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +0 -0
index 981be08..e103ca6 100644
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
      report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
Quoted 10 lines

x86/realmode.c static void test_fninit(void) · line 1512

Quoted 6 lines
x86/realmode.c +6 -0
+static void test_nopl(void)
+{
+     MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+     MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+     MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+     MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop

But all nops below that are not supported in 16 bit mode. You can disassemble realmode.elf in 16bit node (objdump -z -d -mi8086 x86/realmode.elf) and check yourself. Lets not complicate things for now and test only those that are easy to test.

Quoted 3 lines

Yes. But what if a 7-bytes nop runs in 16bit mode? Just the same as
https://bugzilla.redhat.com/show_bug.cgi?id=967652

It cannot. In 16 bit mode it is decoded as two instructions:

       0f 1f 80 00 00          nopw   0x0(%bx,%si)
       00 00                   add    %al,(%bx,%si)
Quoted 6 lines

DR6=00000000ffff0ff0 DR7=0000000000000400 EFER=0000000000000500
Code=00 00 e9 50 ff ff ff 00 00 00 00 85 d2 74 20 45 31 c0 31 c9 <0f> 1f 80 00 00 00 00 0f b6 04 31 41 83 c0 01 88 04 39 48 83 c1 01 41 39 d0 75 ec 48 89 f8

Quoted 40 lines

The error code is "0f 1f 80 00 00 00 00", which is a 7-bytes nop. Will the emulator runs well in that case when booting RHEL5.9 64-bit?

Arthur

Quoted 34 lines
Quoted 30 lines
x86/realmode.c +18 -1
+     MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 5 bytes nop
+     MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 6 bytes nop
+     MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); // 7 bytes nop
+     MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 8 bytes nop
+     MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 9 bytes nop
+     exec_in_big_real_mode(&insn_nopl1);
+     exec_in_big_real_mode(&insn_nopl2);
+     exec_in_big_real_mode(&insn_nopl3);
+     exec_in_big_real_mode(&insn_nopl4);
+     exec_in_big_real_mode(&insn_nopl5);
+     exec_in_big_real_mode(&insn_nopl6);
+     exec_in_big_real_mode(&insn_nopl7);
+     exec_in_big_real_mode(&insn_nopl8);
+     exec_in_big_real_mode(&insn_nopl9);
+     report("nopl", 0, 1);
+}
+
 void realmode_start(void)
 {
      test_null();
@@ -1548,6 +1571,7 @@ void realmode_start(void)
      test_xlat();
      test_salc();
      test_fninit();
+     test_nopl();
 
      exit(0);
 }
--
Quoted 1 line

1.7.9.5

--
Gleb.

--
Gleb.

#4 lore raw
Quoted 30 lines · Gleb Natapov
Quoted 29 lines · 李春奇
Quoted 28 lines · Gleb Natapov

This time the email is perfect :)

Quoted 12 lines · Arthur Chunqi Li

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +0 -0
index 981be08..e103ca6 100644

x86/realmode.c static void test_fninit(void) · line 1512

Quoted 9 lines
x86/realmode.c +6 -0
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
      report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
+static void test_nopl(void)
+{
+     MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+     MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+     MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+     MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop

But all nops below that are not supported in 16 bit mode. You can disassemble realmode.elf in 16bit node (objdump -z -d -mi8086 x86/realmode.elf) and check yourself. Lets not complicate things for now and test only those that are easy to test.

Quoted 7 lines
Quoted 3 lines

Yes. But what if a 7-bytes nop runs in 16bit mode? Just the same as
https://bugzilla.redhat.com/show_bug.cgi?id=967652

It cannot. In 16 bit mode it is decoded as two instructions:

       0f 1f 80 00 00          nopw   0x0(%bx,%si)
       00 00                   add    %al,(%bx,%si)

OK, I will just test the first four nop instructions. Should I commit another patch?

Arthur.

Quoted 49 lines
Quoted 6 lines

DR6=00000000ffff0ff0 DR7=0000000000000400 EFER=0000000000000500
Code=00 00 e9 50 ff ff ff 00 00 00 00 85 d2 74 20 45 31 c0 31 c9 <0f> 1f 80 00 00 00 00 0f b6 04 31 41 83 c0 01 88 04 39 48 83 c1 01 41 39 d0 75 ec 48 89 f8

Quoted 40 lines

The error code is "0f 1f 80 00 00 00 00", which is a 7-bytes nop. Will the emulator runs well in that case when booting RHEL5.9 64-bit?

Arthur

Quoted 34 lines
Quoted 30 lines
x86/realmode.c +18 -1
+     MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 5 bytes nop
+     MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 6 bytes nop
+     MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); // 7 bytes nop
+     MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 8 bytes nop
+     MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 9 bytes nop
+     exec_in_big_real_mode(&insn_nopl1);
+     exec_in_big_real_mode(&insn_nopl2);
+     exec_in_big_real_mode(&insn_nopl3);
+     exec_in_big_real_mode(&insn_nopl4);
+     exec_in_big_real_mode(&insn_nopl5);
+     exec_in_big_real_mode(&insn_nopl6);
+     exec_in_big_real_mode(&insn_nopl7);
+     exec_in_big_real_mode(&insn_nopl8);
+     exec_in_big_real_mode(&insn_nopl9);
+     report("nopl", 0, 1);
+}
+
 void realmode_start(void)
 {
      test_null();
@@ -1548,6 +1571,7 @@ void realmode_start(void)
      test_xlat();
      test_salc();
      test_fninit();
+     test_nopl();
 
      exit(0);
 }
--
Quoted 1 line

1.7.9.5

--
Gleb.

--
Gleb.

#5 lore raw
Quoted 34 lines · 李春奇
Quoted 33 lines · Gleb Natapov
Quoted 32 lines · 李春奇
Quoted 18 lines · Gleb Natapov

This time the email is perfect :)

Quoted 15 lines · Arthur Chunqi Li

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +0 -0
index 981be08..e103ca6 100644
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
      report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
Quoted 10 lines

x86/realmode.c static void test_fninit(void) · line 1512

Quoted 6 lines
x86/realmode.c +6 -0
+static void test_nopl(void)
+{
+     MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+     MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+     MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+     MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop

But all nops below that are not supported in 16 bit mode. You can disassemble realmode.elf in 16bit node (objdump -z -d -mi8086 x86/realmode.elf) and check yourself. Lets not complicate things for now and test only those that are easy to test.

Yes. But what if a 7-bytes nop runs in 16bit mode? Just the same as
https://bugzilla.redhat.com/show_bug.cgi?id=967652

Quoted 7 lines
Quoted 4 lines

It cannot. In 16 bit mode it is decoded as two instructions:

       0f 1f 80 00 00          nopw   0x0(%bx,%si)
       00 00                   add    %al,(%bx,%si)

OK, I will just test the first four nop instructions. Should I commit another patch?

Yes, all others will have to go into emulator.c.

Quoted 51 lines

Arthur.

Quoted 49 lines
Quoted 6 lines

DR6=00000000ffff0ff0 DR7=0000000000000400 EFER=0000000000000500
Code=00 00 e9 50 ff ff ff 00 00 00 00 85 d2 74 20 45 31 c0 31 c9 <0f> 1f 80 00 00 00 00 0f b6 04 31 41 83 c0 01 88 04 39 48 83 c1 01 41 39 d0 75 ec 48 89 f8

Quoted 40 lines

The error code is "0f 1f 80 00 00 00 00", which is a 7-bytes nop. Will the emulator runs well in that case when booting RHEL5.9 64-bit?

Arthur

Quoted 34 lines
Quoted 30 lines
x86/realmode.c +18 -1
+     MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 5 bytes nop
+     MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 6 bytes nop
+     MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); // 7 bytes nop
+     MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 8 bytes nop
+     MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 9 bytes nop
+     exec_in_big_real_mode(&insn_nopl1);
+     exec_in_big_real_mode(&insn_nopl2);
+     exec_in_big_real_mode(&insn_nopl3);
+     exec_in_big_real_mode(&insn_nopl4);
+     exec_in_big_real_mode(&insn_nopl5);
+     exec_in_big_real_mode(&insn_nopl6);
+     exec_in_big_real_mode(&insn_nopl7);
+     exec_in_big_real_mode(&insn_nopl8);
+     exec_in_big_real_mode(&insn_nopl9);
+     report("nopl", 0, 1);
+}
+
 void realmode_start(void)
 {
      test_null();
@@ -1548,6 +1571,7 @@ void realmode_start(void)
      test_xlat();
      test_salc();
      test_fninit();
+     test_nopl();
 
      exit(0);
 }
--
Quoted 1 line

1.7.9.5

--
Gleb.

--
Gleb.

--
Gleb.

#6 lore raw
Quoted 35 lines · Gleb Natapov
Quoted 34 lines · 李春奇
Quoted 33 lines · Gleb Natapov
Quoted 32 lines · 李春奇
Quoted 18 lines · Gleb Natapov

This time the email is perfect :)

Quoted 15 lines · Arthur Chunqi Li

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +0 -0
index 981be08..e103ca6 100644
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
      report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
Quoted 10 lines

x86/realmode.c static void test_fninit(void) · line 1512

Quoted 6 lines
x86/realmode.c +6 -0
+static void test_nopl(void)
+{
+     MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+     MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+     MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+     MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop

But all nops below that are not supported in 16 bit mode. You can disassemble realmode.elf in 16bit node (objdump -z -d -mi8086 x86/realmode.elf) and check yourself. Lets not complicate things for now and test only those that are easy to test.

Yes. But what if a 7-bytes nop runs in 16bit mode? Just the same as
https://bugzilla.redhat.com/show_bug.cgi?id=967652

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

It cannot. In 16 bit mode it is decoded as two instructions:

       0f 1f 80 00 00          nopw   0x0(%bx,%si)
       00 00                   add    %al,(%bx,%si)

OK, I will just test the first four nop instructions. Should I commit another patch?

Yes, all others will have to go into emulator.c.

You mean I need also add another test for nopl5~nop9 in emulator.c with the "trick" emulator mode?
I will commit a modified one for realmode.c since some other works should be done in emulator.c.

Quoted 50 lines
Quoted 50 lines

Arthur.

Quoted 47 lines
Quoted 46 lines

DR6=00000000ffff0ff0 DR7=0000000000000400 EFER=0000000000000500
Code=00 00 e9 50 ff ff ff 00 00 00 00 85 d2 74 20 45 31 c0 31 c9 <0f> 1f 80 00 00 00 00 0f b6 04 31 41 83 c0 01 88 04 39 48 83 c1 01 41 39 d0 75 ec 48 89 f8

The error code is "0f 1f 80 00 00 00 00", which is a 7-bytes nop. Will the emulator runs well in that case when booting RHEL5.9 64-bit?

Arthur

Quoted 34 lines
Quoted 30 lines
x86/realmode.c +18 -1
+     MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 5 bytes nop
+     MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 6 bytes nop
+     MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); // 7 bytes nop
+     MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 8 bytes nop
+     MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 9 bytes nop
+     exec_in_big_real_mode(&insn_nopl1);
+     exec_in_big_real_mode(&insn_nopl2);
+     exec_in_big_real_mode(&insn_nopl3);
+     exec_in_big_real_mode(&insn_nopl4);
+     exec_in_big_real_mode(&insn_nopl5);
+     exec_in_big_real_mode(&insn_nopl6);
+     exec_in_big_real_mode(&insn_nopl7);
+     exec_in_big_real_mode(&insn_nopl8);
+     exec_in_big_real_mode(&insn_nopl9);
+     report("nopl", 0, 1);
+}
+
 void realmode_start(void)
 {
      test_null();
@@ -1548,6 +1571,7 @@ void realmode_start(void)
      test_xlat();
      test_salc();
      test_fninit();
+     test_nopl();
 
      exit(0);
 }
--
Quoted 1 line

1.7.9.5

--
Gleb.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

--
Gleb.

--
Gleb.

--
Arthur Chunqi Li
Department of Computer Science
School of EECS
Peking University
Beijing, China

#7 lore raw
Quoted 40 lines · On Thu, Jun 6, 2013 at 3:17 PM, 李春奇 <Arthur Chunqi Li> <[email protected]> wrote:
Quoted 39 lines · Gleb Natapov
Quoted 38 lines · 李春奇
Quoted 37 lines · Gleb Natapov
Quoted 29 lines · 李春奇
Quoted 18 lines · Gleb Natapov

This time the email is perfect :)

Quoted 15 lines · Arthur Chunqi Li

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +0 -0
index 981be08..e103ca6 100644
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
      report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
Quoted 10 lines

x86/realmode.c static void test_fninit(void) · line 1512

Quoted 6 lines
x86/realmode.c +6 -0
+static void test_nopl(void)
+{
+     MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+     MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+     MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+     MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop

But all nops below that are not supported in 16 bit mode. You can disassemble realmode.elf in 16bit node (objdump -z -d -mi8086 x86/realmode.elf) and check yourself. Lets not complicate things for now and test only those that are easy to test.

Quoted 3 lines

Yes. But what if a 7-bytes nop runs in 16bit mode? Just the same as
https://bugzilla.redhat.com/show_bug.cgi?id=967652

It cannot. In 16 bit mode it is decoded as two instructions:

       0f 1f 80 00 00          nopw   0x0(%bx,%si)
       00 00                   add    %al,(%bx,%si)
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

OK, I will just test the first four nop instructions. Should I commit another patch?

Yes, all others will have to go into emulator.c.

You mean I need also add another test for nopl5~nop9 in emulator.c with the "trick" emulator mode?
I will commit a modified one for realmode.c since some other works should be done in emulator.c.

Since we need to place some relevant codes in emulator.c, why don't we place all the tests in emulator.c?

Arthur.

Quoted 59 lines
Quoted 51 lines
Quoted 51 lines

Arthur.

Quoted 47 lines
Quoted 46 lines

DR6=00000000ffff0ff0 DR7=0000000000000400 EFER=0000000000000500
Code=00 00 e9 50 ff ff ff 00 00 00 00 85 d2 74 20 45 31 c0 31 c9 <0f> 1f 80 00 00 00 00 0f b6 04 31 41 83 c0 01 88 04 39 48 83 c1 01 41 39 d0 75 ec 48 89 f8

The error code is "0f 1f 80 00 00 00 00", which is a 7-bytes nop. Will the emulator runs well in that case when booting RHEL5.9 64-bit?

Arthur

Quoted 34 lines
Quoted 30 lines
x86/realmode.c +18 -1
+     MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 5 bytes nop
+     MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); // 6 bytes nop
+     MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); // 7 bytes nop
+     MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 8 bytes nop
+     MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); // 9 bytes nop
+     exec_in_big_real_mode(&insn_nopl1);
+     exec_in_big_real_mode(&insn_nopl2);
+     exec_in_big_real_mode(&insn_nopl3);
+     exec_in_big_real_mode(&insn_nopl4);
+     exec_in_big_real_mode(&insn_nopl5);
+     exec_in_big_real_mode(&insn_nopl6);
+     exec_in_big_real_mode(&insn_nopl7);
+     exec_in_big_real_mode(&insn_nopl8);
+     exec_in_big_real_mode(&insn_nopl9);
+     report("nopl", 0, 1);
+}
+
 void realmode_start(void)
 {
      test_null();
@@ -1548,6 +1571,7 @@ void realmode_start(void)
      test_xlat();
      test_salc();
      test_fninit();
+     test_nopl();
 
      exit(0);
 }
--
Quoted 1 line

1.7.9.5

--
Gleb.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

--
Gleb.

--
Gleb.

Quoted 6 lines

--
Arthur Chunqi Li
Department of Computer Science
School of EECS
Peking University
Beijing, China

--
Arthur Chunqi Li
Department of Computer Science
School of EECS
Peking University
Beijing, China

#8 lore raw
Quoted 44 lines · 李春奇
Quoted 43 lines · On Thu, Jun 6, 2013 at 3:17 PM, 李春奇 <Arthur Chunqi Li> <[email protected]> wrote:
Quoted 42 lines · Gleb Natapov
Quoted 41 lines · 李春奇
Quoted 30 lines · Gleb Natapov
Quoted 29 lines · 李春奇
Quoted 28 lines · Gleb Natapov

This time the email is perfect :)

Quoted 12 lines · Arthur Chunqi Li

Add multibyte NOP test case to kvm-unit-tests. This version adds test cases into x86/realmode.c. This can test one of bugs when booting RHEL5.9 64-bit.

---
 x86/realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
x86/realmode.c +0 -0
index 981be08..e103ca6 100644

x86/realmode.c static void test_fninit(void) · line 1512

Quoted 9 lines
x86/realmode.c +6 -0
@@ -1504,6 +1504,29 @@ static void test_fninit(void)
      report("fninit", 0, fsw == 0 && (fcw & 0x103f) == 0x003f);
 }
 
+static void test_nopl(void)
+{
+     MK_INSN(nopl1, ".byte 0x90\n\r"); // 1 byte nop
+     MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); // 2 bytes nop
+     MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); // 3 bytes nop
+     MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); // 4 bytes nop

But all nops below that are not supported in 16 bit mode. You can disassemble realmode.elf in 16bit node (objdump -z -d -mi8086 x86/realmode.elf) and check yourself. Lets not complicate things for now and test only those that are easy to test.

Quoted 7 lines
Quoted 3 lines

Yes. But what if a 7-bytes nop runs in 16bit mode? Just the same as
https://bugzilla.redhat.com/show_bug.cgi?id=967652

It cannot. In 16 bit mode it is decoded as two instructions:

       0f 1f 80 00 00          nopw   0x0(%bx,%si)
       00 00                   add    %al,(%bx,%si)

OK, I will just test the first four nop instructions. Should I commit another patch?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yes, all others will have to go into emulator.c.

You mean I need also add another test for nopl5~nop9 in emulator.c with the "trick" emulator mode?
I will commit a modified one for realmode.c since some other works should be done in emulator.c.

Since we need to place some relevant codes in emulator.c, why don't we place all the tests in emulator.c?

We can place those 4 in both. I do not always run all tests so it is nice to cover as much as possible in both.

--
Gleb.