From patchwork Fri Jan 15 20:19:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Newbury X-Patchwork-Id: 8044831 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CF4AF9F744 for ; Fri, 15 Jan 2016 22:33:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED5462037E for ; Fri, 15 Jan 2016 22:33:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A33FE20379 for ; Fri, 15 Jan 2016 22:33:03 +0000 (UTC) Received: from localhost ([::1]:49192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKCvX-0000Gp-3m for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 Jan 2016 17:33:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKAtj-00036C-5I for qemu-devel@nongnu.org; Fri, 15 Jan 2016 15:23:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKAte-0001OF-4z for qemu-devel@nongnu.org; Fri, 15 Jan 2016 15:23:03 -0500 Received: from know-smtprelay-omc-5.server.virginmedia.net ([80.0.253.69]:52998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKAtd-0001NG-LL for qemu-devel@nongnu.org; Fri, 15 Jan 2016 15:22:58 -0500 Received: from mail.snewbury.org.uk ([82.22.155.127]) by know-smtprelay-5-imp with bizsmtp id 6LNo1s00A2lBSAS01LNpDj; Fri, 15 Jan 2016 20:22:50 +0000 X-Originating-IP: [82.22.155.127] X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Authority: v=2.1 cv=GKL1ab5K c=1 sm=1 tr=0 a=jwnFyS4gAAFrdRcCDFybKw==:117 a=jwnFyS4gAAFrdRcCDFybKw==:17 a=N1CowNylAAAA:8 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=7aQ_Q-yQQ-AA:10 a=oA0oZaVXStlOvgkSoYsA:9 a=RQrTMfUNYbyq-H76:21 a=ME8zsEdcbpU6HtwF:21 a=QEXdDO2ut3YA:10 a=EO5zs_S6rHpuj4IMrXcA:9 a=EILVL40jIAwA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=snewbury.org.uk; h=mime-version:x-mailer:content-type:content-type:date:date :from:from:subject:subject:message-id; s=eater; t=1452889365; x= 1454703766; bh=vQ2atUCxJYqcN4+0EU9QWpnqNXtUYfYh7RUqpmkiyzI=; b=O W0vJUWbzsYmt3H99MyW98ukX4mQTbI2QweYKTJ//6yXtRsFl9qkKqHMgF1FcYVkV 4zEqF/Ji1oWhv97ZZ/L75hBxNLyR+ehZfdR5BbZrmZ5lMWhUIfXhpIoFY4Jh1RhW X+kCcmeripD3eexSPJYdy4XH1qdV9UpzsB8biAG3Rg= X-Virus-Scanned: amavisd-new at snewbury.org.uk Received: from artifact-33.local (artifact-33.local [192.168.75.106]) (authenticated bits=0) by mail.snewbury.org.uk (8.14.9/8.14.9) with ESMTP id u0FKMiZ0013045 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 15 Jan 2016 20:22:45 GMT Message-ID: <1452889148.10156.12.camel@snewbury.org.uk> From: Steven Newbury To: Qemu-devel@nongnu.org Date: Fri, 15 Jan 2016 20:19:08 +0000 X-Mailer: Evolution 3.19.3 Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.0.253.69 X-Mailman-Approved-At: Fri, 15 Jan 2016 17:30:33 -0500 Cc: mjt@tlsbutkru, Xiao Guangrong Subject: [Qemu-devel] [PATCH] Propagate OEM ID info into other tables when using SLIC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support Windows 7 "Activation", the OEM ID info must match in SLIC and RSDT, and for UEFI, FACP.  The OEM ID from the SLIC is only applied when oemtableid is not specified expliicitly. This was originally based on the patch from Michael Tokarev but has been significantly re-worked, and re-based. Signed-off-by: Steven Newbury ---  hw/acpi/aml-build.c         | 19 ++++++++++++++++---  hw/acpi/core.c              | 11 +++++++++++  hw/i386/acpi-build.c        |  9 ++++++++-  include/hw/acpi/acpi_slic.h | 11 +++++++++++  qemu-options.hx             |  2 ++  5 files changed, 48 insertions(+), 4 deletions(-)  create mode 100644 include/hw/acpi/acpi_slic.h addition).  ETEXI    DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, --  2.6.4 diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 78e1290..bc16dc2 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -29,6 +29,9 @@  #include "qemu/bswap.h"  #include "qemu/bitops.h"  #include "hw/acpi/bios-linker-loader.h" +#include "hw/acpi/acpi_slic.h" + +extern const struct slic_info oem_data;    static GArray *build_alloc_array(void)  { @@ -1435,13 +1438,23 @@ build_header(GArray *linker, GArray *table_data,      memcpy(&h->signature, sig, 4);      h->length = cpu_to_le32(len);      h->revision = rev; -    memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);        if (oem_table_id) {          strncpy((char *)h->oem_table_id, oem_table_id, sizeof(h- >oem_table_id));      } else { -        memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4); -        memcpy(h->oem_table_id + 4, sig, 4); +        /* When including the system SLIC Win7 requires all OEM info to match +        (including sig) in SLIC, RSDT and FACP.  Other tables could match, +        but is unnecessary to pass "Activation". Overriden by above. */ +        if (oem_data.has_slic) { +            memcpy(h->oem_id, &oem_data.oem_id, 6); +            memcpy(h->oem_table_id, &oem_data.oem_table_id, 8); +            if (memcmp(sig, "RSDT", 4) != 0 && memcmp(sig, "FACP", 4) != 0)  +                memcpy(h->oem_table_id + 4, sig, 4); +        } else { +            memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6); +            memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4); +            memcpy(h->oem_table_id + 4, sig, 4); +        }      }        h->oem_revision = cpu_to_le32(1); diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 21e113d..cbef437 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -22,6 +22,7 @@  #include "hw/hw.h"  #include "hw/i386/pc.h"  #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi_slic.h"  #include "hw/nvram/fw_cfg.h"  #include "qemu/config-file.h"  #include "qapi/opts-visitor.h" @@ -29,6 +30,9 @@  #include "qapi-visit.h"  #include "qapi-event.h"   +struct slic_info oem_data; + +  struct acpi_table_header {      uint16_t _length;         /* our length, not actual part of the hdr */                                /* allows easier parsing for fw_cfg clients */ @@ -227,6 +231,13 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,      /* recalculate checksum */      ext_hdr->checksum = acpi_checksum((const char unsigned *)ext_hdr +                                        ACPI_TABLE_PFX_SIZE, acpi_payload_size); + +    /* Copy OEM fields from SLIC for use in all relevant tables +       (oem_id[6] + tableid[4] + tableid(sig)[4] = 14 bytes) */ +    if ((!oem_data.has_slic) && (memcmp(ext_hdr->sig, "SLIC", 4) == 0)) { +       memcpy(&oem_data.oem_id, ext_hdr->oem_id, 14); +       oem_data.has_slic = 1; +    }  }    void acpi_table_add(const QemuOpts *opts, Error **errp) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 78758e2..fbe4f3a 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -55,6 +55,7 @@  #include "hw/timer/hpet.h"    #include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi_slic.h"    #include "qapi/qmp/qint.h"  #include "qom/qom-qobject.h" @@ -122,6 +123,8 @@ typedef struct AcpiBuildPciBusHotplugState {      bool pcihp_bridge_en;  } AcpiBuildPciBusHotplugState;   +extern const struct slic_info oem_data; +  static  int acpi_add_cpu_info(Object *o, void *opaque)  { @@ -2542,7 +2545,11 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)                               true /* fseg memory */);        memcpy(&rsdp->signature, "RSD PTR ", 8); -    memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6); +    if (oem_data.has_slic) { +        memcpy(rsdp->oem_id, &oem_data.oem_id, 6); +    } else { +        memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6); +    }      rsdp->rsdt_physical_address = cpu_to_le32(rsdt);      /* Address to be filled by Guest linker */      bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE, diff --git a/include/hw/acpi/acpi_slic.h b/include/hw/acpi/acpi_slic.h new file mode 100644 index 0000000..bc04a71 --- /dev/null +++ b/include/hw/acpi/acpi_slic.h @@ -0,0 +1,11 @@ +#ifndef QEMU_HW_ACPI_SLIC_H +#define QEMU_HW_ACPI_SLIC_H + +struct slic_info { +    bool has_slic; +    char oem_id[6]; +    char oem_table_id[8]; +}; + +#endif /* !QEMU_HW_ACPI_SLIC_H */ +  \ No newline at end of file diff --git a/qemu-options.hx b/qemu-options.hx index 215d00d..f1488a1 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1472,6 +1472,8 @@ ACPI headers (possible overridden by other options).  For data=, only data  portion of the table is used, all header information is specified in the  command line. +If a SLIC table is supplied to qemu, then the oem_id from the SLIC table +will be copied into the RSDT and FACP tables (this is a Debian