diff mbox

[kvm-unit-tests] realmode: test AAM, XLAT, SALC

Message ID 1368089617-11098-1-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paolo Bonzini May 9, 2013, 8:53 a.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 x86/realmode.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

Comments

Gleb Natapov May 9, 2013, 9:13 a.m. UTC | #1
On Thu, May 09, 2013 at 10:53:37AM +0200, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  x86/realmode.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/x86/realmode.c b/x86/realmode.c
> index 91c93a9..35ace08 100644
> --- a/x86/realmode.c
> +++ b/x86/realmode.c
> @@ -1391,6 +1391,43 @@ static void test_aad(void)
>      report("aad", R_AX, outregs.eax == 0x123400d4);
>  }
>  
> +static void test_aam(void)
> +{
> +    MK_INSN(aam, "aam");
> +
> +    inregs.eax = 0x76543210;
> +    exec_in_big_real_mode(&insn_aam);
> +    report("aam", R_AX, outregs.eax == 0x76540106);
> +}
> +
> +static void test_xlat(void)
> +{
> +    MK_INSN(xlat, "xlat");
> +    u8 table[256];
> +    int i;
> +
> +    for (i = 0; i < 256; i++) {
> +        table[i] = i + 1;
> +    }
> +
> +    inregs.eax = 0x89abcdef;
> +    inregs.ebx = (u32)table;
> +    exec_in_big_real_mode(&insn_xlat);
> +    report("xlat", R_AX, outregs.eax == 0x89abcdf0);
> +}
> +
> +static void test_salc(void)
> +{
> +    MK_INSN(clc_salc, "clc; .byte 0xd6");
> +    MK_INSN(stc_salc, "stc; .byte 0xd6");
Heh, who uses that?

> +
> +    inregs.eax = 0x12345678;
> +    exec_in_big_real_mode(&insn_clc_salc);
> +    report("salc (1)", R_AX, outregs.eax == 0x12345600);
> +    exec_in_big_real_mode(&insn_stc_salc);
> +    report("salc (2)", R_AX, outregs.eax == 0x123456ff);
> +}
> +
>  static void test_fninit(void)
>  {
>  	u16 fcw = -1, fsw = -1;
> @@ -1443,6 +1480,9 @@ void realmode_start(void)
>  	test_movzx_movsx();
>  	test_bswap();
>  	test_aad();
> +	test_aam();
> +	test_xlat();
> +	test_salc();
>  	test_fninit();
>  
>  	exit(0);
> -- 
> 1.8.1.4

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini May 9, 2013, 9:18 a.m. UTC | #2
Il 09/05/2013 11:13, Gleb Natapov ha scritto:
> On Thu, May 09, 2013 at 10:53:37AM +0200, Paolo Bonzini wrote:
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  x86/realmode.c | 40 ++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 40 insertions(+)
>>
>> diff --git a/x86/realmode.c b/x86/realmode.c
>> index 91c93a9..35ace08 100644
>> --- a/x86/realmode.c
>> +++ b/x86/realmode.c
>> @@ -1391,6 +1391,43 @@ static void test_aad(void)
>>      report("aad", R_AX, outregs.eax == 0x123400d4);
>>  }
>>  
>> +static void test_aam(void)
>> +{
>> +    MK_INSN(aam, "aam");
>> +
>> +    inregs.eax = 0x76543210;
>> +    exec_in_big_real_mode(&insn_aam);
>> +    report("aam", R_AX, outregs.eax == 0x76540106);
>> +}
>> +
>> +static void test_xlat(void)
>> +{
>> +    MK_INSN(xlat, "xlat");
>> +    u8 table[256];
>> +    int i;
>> +
>> +    for (i = 0; i < 256; i++) {
>> +        table[i] = i + 1;
>> +    }
>> +
>> +    inregs.eax = 0x89abcdef;
>> +    inregs.ebx = (u32)table;
>> +    exec_in_big_real_mode(&insn_xlat);
>> +    report("xlat", R_AX, outregs.eax == 0x89abcdf0);
>> +}
>> +
>> +static void test_salc(void)
>> +{
>> +    MK_INSN(clc_salc, "clc; .byte 0xd6");
>> +    MK_INSN(stc_salc, "stc; .byte 0xd6");
> Heh, who uses that?

Some real-mode programs do.  Plus, the "N" in the opcode table looked
really bad. :)

Paolo

>> +
>> +    inregs.eax = 0x12345678;
>> +    exec_in_big_real_mode(&insn_clc_salc);
>> +    report("salc (1)", R_AX, outregs.eax == 0x12345600);
>> +    exec_in_big_real_mode(&insn_stc_salc);
>> +    report("salc (2)", R_AX, outregs.eax == 0x123456ff);
>> +}
>> +
>>  static void test_fninit(void)
>>  {
>>  	u16 fcw = -1, fsw = -1;
>> @@ -1443,6 +1480,9 @@ void realmode_start(void)
>>  	test_movzx_movsx();
>>  	test_bswap();
>>  	test_aad();
>> +	test_aam();
>> +	test_xlat();
>> +	test_salc();
>>  	test_fninit();
>>  
>>  	exit(0);
>> -- 
>> 1.8.1.4
> 
> --
> 			Gleb.
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov May 9, 2013, 9:20 a.m. UTC | #3
On Thu, May 09, 2013 at 11:18:07AM +0200, Paolo Bonzini wrote:
> Il 09/05/2013 11:13, Gleb Natapov ha scritto:
> > On Thu, May 09, 2013 at 10:53:37AM +0200, Paolo Bonzini wrote:
> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >> ---
> >>  x86/realmode.c | 40 ++++++++++++++++++++++++++++++++++++++++
> >>  1 file changed, 40 insertions(+)
> >>
> >> diff --git a/x86/realmode.c b/x86/realmode.c
> >> index 91c93a9..35ace08 100644
> >> --- a/x86/realmode.c
> >> +++ b/x86/realmode.c
> >> @@ -1391,6 +1391,43 @@ static void test_aad(void)
> >>      report("aad", R_AX, outregs.eax == 0x123400d4);
> >>  }
> >>  
> >> +static void test_aam(void)
> >> +{
> >> +    MK_INSN(aam, "aam");
> >> +
> >> +    inregs.eax = 0x76543210;
> >> +    exec_in_big_real_mode(&insn_aam);
> >> +    report("aam", R_AX, outregs.eax == 0x76540106);
> >> +}
> >> +
> >> +static void test_xlat(void)
> >> +{
> >> +    MK_INSN(xlat, "xlat");
> >> +    u8 table[256];
> >> +    int i;
> >> +
> >> +    for (i = 0; i < 256; i++) {
> >> +        table[i] = i + 1;
> >> +    }
> >> +
> >> +    inregs.eax = 0x89abcdef;
> >> +    inregs.ebx = (u32)table;
> >> +    exec_in_big_real_mode(&insn_xlat);
> >> +    report("xlat", R_AX, outregs.eax == 0x89abcdf0);
> >> +}
> >> +
> >> +static void test_salc(void)
> >> +{
> >> +    MK_INSN(clc_salc, "clc; .byte 0xd6");
> >> +    MK_INSN(stc_salc, "stc; .byte 0xd6");
> > Heh, who uses that?
> 
> Some real-mode programs do.  Plus, the "N" in the opcode table looked
> really bad. :)
> 
Ah, I thought sgabios use that one too.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov May 9, 2013, noon UTC | #4
On Thu, May 09, 2013 at 10:53:37AM +0200, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Applied, thanks.

> ---
>  x86/realmode.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/x86/realmode.c b/x86/realmode.c
> index 91c93a9..35ace08 100644
> --- a/x86/realmode.c
> +++ b/x86/realmode.c
> @@ -1391,6 +1391,43 @@ static void test_aad(void)
>      report("aad", R_AX, outregs.eax == 0x123400d4);
>  }
>  
> +static void test_aam(void)
> +{
> +    MK_INSN(aam, "aam");
> +
> +    inregs.eax = 0x76543210;
> +    exec_in_big_real_mode(&insn_aam);
> +    report("aam", R_AX, outregs.eax == 0x76540106);
> +}
> +
> +static void test_xlat(void)
> +{
> +    MK_INSN(xlat, "xlat");
> +    u8 table[256];
> +    int i;
> +
> +    for (i = 0; i < 256; i++) {
> +        table[i] = i + 1;
> +    }
> +
> +    inregs.eax = 0x89abcdef;
> +    inregs.ebx = (u32)table;
> +    exec_in_big_real_mode(&insn_xlat);
> +    report("xlat", R_AX, outregs.eax == 0x89abcdf0);
> +}
> +
> +static void test_salc(void)
> +{
> +    MK_INSN(clc_salc, "clc; .byte 0xd6");
> +    MK_INSN(stc_salc, "stc; .byte 0xd6");
> +
> +    inregs.eax = 0x12345678;
> +    exec_in_big_real_mode(&insn_clc_salc);
> +    report("salc (1)", R_AX, outregs.eax == 0x12345600);
> +    exec_in_big_real_mode(&insn_stc_salc);
> +    report("salc (2)", R_AX, outregs.eax == 0x123456ff);
> +}
> +
>  static void test_fninit(void)
>  {
>  	u16 fcw = -1, fsw = -1;
> @@ -1443,6 +1480,9 @@ void realmode_start(void)
>  	test_movzx_movsx();
>  	test_bswap();
>  	test_aad();
> +	test_aam();
> +	test_xlat();
> +	test_salc();
>  	test_fninit();
>  
>  	exit(0);
> -- 
> 1.8.1.4

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/x86/realmode.c b/x86/realmode.c
index 91c93a9..35ace08 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1391,6 +1391,43 @@  static void test_aad(void)
     report("aad", R_AX, outregs.eax == 0x123400d4);
 }
 
+static void test_aam(void)
+{
+    MK_INSN(aam, "aam");
+
+    inregs.eax = 0x76543210;
+    exec_in_big_real_mode(&insn_aam);
+    report("aam", R_AX, outregs.eax == 0x76540106);
+}
+
+static void test_xlat(void)
+{
+    MK_INSN(xlat, "xlat");
+    u8 table[256];
+    int i;
+
+    for (i = 0; i < 256; i++) {
+        table[i] = i + 1;
+    }
+
+    inregs.eax = 0x89abcdef;
+    inregs.ebx = (u32)table;
+    exec_in_big_real_mode(&insn_xlat);
+    report("xlat", R_AX, outregs.eax == 0x89abcdf0);
+}
+
+static void test_salc(void)
+{
+    MK_INSN(clc_salc, "clc; .byte 0xd6");
+    MK_INSN(stc_salc, "stc; .byte 0xd6");
+
+    inregs.eax = 0x12345678;
+    exec_in_big_real_mode(&insn_clc_salc);
+    report("salc (1)", R_AX, outregs.eax == 0x12345600);
+    exec_in_big_real_mode(&insn_stc_salc);
+    report("salc (2)", R_AX, outregs.eax == 0x123456ff);
+}
+
 static void test_fninit(void)
 {
 	u16 fcw = -1, fsw = -1;
@@ -1443,6 +1480,9 @@  void realmode_start(void)
 	test_movzx_movsx();
 	test_bswap();
 	test_aad();
+	test_aam();
+	test_xlat();
+	test_salc();
 	test_fninit();
 
 	exit(0);