Skip to contentSkip to conversation

built-in memcmp function uses not-yet implemented opcode

PATCH In review Stefan Berger 2 participants 3 messages Nov 29, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 built-in memcmp function uses not-yet implemented opcode

Keir,

it seems like the acpi/build.c function now uses the gcc built-in
memcmp function. Unfortunately that one seems to generate some code that hits a not-yet implemented/emulated opcode. Instead of implementing emultaion for that opcode I just copied the previously used memcmp function from util.c into the build.c and renamed it to _memcmp to avoid linking problems.

(XEN) a6, This opcode isn't handled yet! (XEN) handle_mmio: failed to decode instruction (XEN) mmio opcode: gpa 0xfed40f00, len 2: f3 a6 (XEN) domain_crash_sync called from platform.c:944

tools/firmware/hvmloader/acpi/build.c +19 -1
diff -r 81c9213b3d39 tools/firmware/hvmloader/acpi/build.c
@@ -32,6 +32,24 @@
 extern unsigned char AmlCode[];
 extern int DsdtLen;
 
+static int
+_memcmp(const void *s1, const void *s2, unsigned n)
+{
+    unsigned i;
+    uint8_t *p1 = (uint8_t *) s1;
+    uint8_t *p2 = (uint8_t *) s2;
+
+    for ( i = 0; i < n; i++ )
+    {
+        if ( p1[i] < p2[i] )
+            return -1;
+        else if ( p1[i] > p2[i] )
+            return 1;
+    }
+
+    return 0;
+}
+
 static void set_checksum(
     void *table, uint32_t checksum_offset, uint32_t length)
 {
@@ -126,7 +144,7 @@
     }
 
     /* TPM TCPA and SSDT. */
-    if ( memcmp((char *)0xFED40F00, tis_did_vid_rid,
+    if (_memcmp((char *)0xFED40F00, tis_did_vid_rid,
                 sizeof(tis_did_vid_rid)) == 0 ) /* Probe for TIS interface. */
     {
         memcpy(&buf[offset], AmlCode_TPM, sizeof(AmlCode_TPM));

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 6 lines · Stefan Berger

it seems like the acpi/build.c function now uses the gcc built-in
memcmp function. Unfortunately that one seems to generate some code that hits a not-yet implemented/emulated opcode. Instead of implementing emultaion for that opcode I just copied the previously used memcmp function from util.c into the build.c and renamed it to _memcmp to avoid linking problems.

There's an easier fix. hvmloader/acpi/Makefile is missing -fno-builtin. I'll apply a patch.

Thanks,
Keir

#2 lore raw

[email protected] wrote on 11/29/2006 02:51:50 AM:

Quoted 4 lines · Stefan Berger
Quoted 3 lines

it seems like the acpi/build.c function now uses the gcc built-in
memcmp function. Unfortunately that one seems to generate some code

that

Quoted 3 lines
Quoted 3 lines

hits a not-yet implemented/emulated opcode. Instead of implementing emultaion for that opcode I just copied the previously used memcmp function from util.c into the build.c and renamed it to _memcmp to

avoid

Quoted 3 lines
Quoted 1 line

linking problems.

There's an easier fix. hvmloader/acpi/Makefile is missing -fno-builtin.

I'll

Quoted 1 line

apply a patch.

I had tried that, but it didn't help, either, and memcmp got linked in. Maybe this fix here is ok?

build.c.new 2006-11-29 00:21:38.000000000 -0500 renamed from build.c 2006-11-29 07:12:51.000000000 -0500 +1 -2
@@ -116,6 +116,7 @@ int construct_secondary_tables(uint8_t *
     struct acpi_20_madt *madt;
     struct acpi_20_tcpa *tcpa;
     static const uint16_t tis_did_vid_rid[] = {0x0001, 0x0001, 0x0001};
+    uint16_t *mem16;
 
     /* MADT. */
     if ( (get_vcpu_nr() > 1) || get_apic_mode() )
@@ -126,8 +127,10 @@ int construct_secondary_tables(uint8_t *
     }
 
     /* TPM TCPA and SSDT. */
-    if ( memcmp((char *)0xFED40F00, tis_did_vid_rid,
-                sizeof(tis_did_vid_rid)) == 0 ) /* Probe for TIS 

interface. */
+ mem16 = (uint16_t *)0xFED40F00;
+ if (mem16[0] == tis_did_vid_rid[0] &&
+ mem16[1] == tis_did_vid_rid[1] &&
+ mem16[2] == tis_did_vid_rid[2])

     {
         memcpy(&buf[offset], AmlCode_TPM, sizeof(AmlCode_TPM));
         table_ptrs[nr_tables++] = (unsigned long)&buf[offset];

Stefan

Quoted 10 lines

Thanks,
Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel