From patchwork Wed Aug 30 12:52:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 9929545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F241603B4 for ; Wed, 30 Aug 2017 12:55:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FA0F28557 for ; Wed, 30 Aug 2017 12:55:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2466E2856B; Wed, 30 Aug 2017 12:55:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6011828557 for ; Wed, 30 Aug 2017 12:55:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dn2U9-00046c-OW; Wed, 30 Aug 2017 12:52:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dn2U8-00046W-FD for xen-devel@lists.xen.org; Wed, 30 Aug 2017 12:52:44 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 73/EA-03128-B15B6A95; Wed, 30 Aug 2017 12:52:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsWyU9JRQldq67J Ig3krTC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozZ706wFhw1rWhefIWlgfGSThcjJ4eEgJ/E x4WvmUBsNgEDiVObFrGA2CICshKru+awdzFycTALrGOUWHCimxEkISwQK7HgxyOgIg4OFgFVi TdPRUDCvAKeEv3bPzBBzJSTuHmukxkiLihxcuYTsJnMAhISB1+8AIsLCahJHO3axQJRny6x+s UPtgmMPLOQtMxC0rKAkWkVo3pxalFZapGuqV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5 yfu4mRmCIMADBDsbpl/0PMUpyMCmJ8u5bvSxSiC8pP6UyI7E4I76oNCe1+BCjDAeHkgTvD5Cc YFFqempFWmYOMFhh0hIcPEoivCxrgNK8xQWJucWZ6RCpU4yKUuK8rSB9AiCJjNI8uDZYhFxil JUS5mUEOkSIpyC1KDezBFX+FaM4B6OSMO89kCk8mXklcNNfAS1mAloc67UUZHFJIkJKqoGxBh jx6eI68+yC3Nf2TNzFo8tgLNMzfebOzkXFM2dMZYvcPJUtvmpaWOxaUfMMJYNL55dvU9G3Mdv e3CVqrcKtP2v3u4csFS3tk6Ki1iYfefd0R/PDXsUJB1V++d64s+6XQf/WnkNHtrw3rlM+ZZ+Y cGm1zqOCr9lmB2VeNqoYPX+9XqAmeYkSS3FGoqEWc1FxIgAt8hLEiwIAAA== X-Env-Sender: prvs=408b39968=igor.druzhinin@citrix.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1504097562!74423854!1 X-Originating-IP: [185.25.65.24] X-SpamReason: No, hits=0.0 required=7.0 tests=received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4453 invoked from network); 30 Aug 2017 12:52:42 -0000 Received: from smtp.eu.citrix.com (HELO SMTP.EU.CITRIX.COM) (185.25.65.24) by server-13.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 30 Aug 2017 12:52:42 -0000 X-IronPort-AV: E=Sophos;i="5.41,448,1498521600"; d="scan'208";a="51802270" From: Igor Druzhinin To: Date: Wed, 30 Aug 2017 13:52:24 +0100 Message-ID: <1504097544-20648-1-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-ClientProxiedBy: FTLPEX02CAS02.citrite.net (10.13.99.123) To AMSPEX02CL03.citrite.net (10.69.22.127) Cc: Igor Druzhinin , wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v5] hvmloader, libxl: use the correct ACPI settings depending on device model X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP We need to choose ACPI tables properly depending on the device model version we are running. Previously, this decision was made by BIOS type specific code in hvmloader, e.g. always load QEMU traditional specific tables if it's ROMBIOS and always load QEMU Xen specific tables if it's SeaBIOS. This change saves this behavior (for compatibility) but adds an additional way (xenstore key) to specify the correct device model if we happen to run a non-default one. Toolstack bit makes use of it. The enforcement of BIOS type depending on QEMU version will be lifted later when the rest of ROMBIOS compatibility fixes are in place. Signed-off-by: Igor Druzhinin Reviewed-by: Paul Durrant Acked-by: Wei Liu Reviewed-by: Roger Pau Monné --- Changes in v5: * various refinements Changes in v4: * Use V1 port location unconditionally as modern versions of Qemu-trad use it anyway * Change confusing comments in ioreq.h Changes in v3: * move ACPI table externs into util.h Changes in v2: * fix insufficient allocation size of localent --- tools/firmware/hvmloader/ovmf.c | 3 --- tools/firmware/hvmloader/rombios.c | 3 --- tools/firmware/hvmloader/seabios.c | 3 --- tools/firmware/hvmloader/util.c | 17 +++++++++++++++++ tools/firmware/hvmloader/util.h | 3 +++ tools/libxl/libxl_create.c | 4 +++- xen/include/public/hvm/ioreq.h | 9 +++++++-- 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/tools/firmware/hvmloader/ovmf.c b/tools/firmware/hvmloader/ovmf.c index 4ff7f1d..a17a11c 100644 --- a/tools/firmware/hvmloader/ovmf.c +++ b/tools/firmware/hvmloader/ovmf.c @@ -41,9 +41,6 @@ #define LOWCHUNK_MAXOFFSET 0x0000FFFF #define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000 -extern unsigned char dsdt_anycpu_qemu_xen[]; -extern int dsdt_anycpu_qemu_xen_len; - #define OVMF_INFO_MAX_TABLES 4 struct ovmf_info { char signature[14]; /* XenHVMOVMF\0\0\0\0 */ diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c index 56b39b7..c736fd9 100644 --- a/tools/firmware/hvmloader/rombios.c +++ b/tools/firmware/hvmloader/rombios.c @@ -42,9 +42,6 @@ #define ROMBIOS_MAXOFFSET 0x0000FFFF #define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) -extern unsigned char dsdt_anycpu[], dsdt_15cpu[]; -extern int dsdt_anycpu_len, dsdt_15cpu_len; - static void rombios_setup_e820(void) { /* diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c index 870576a..801516d 100644 --- a/tools/firmware/hvmloader/seabios.c +++ b/tools/firmware/hvmloader/seabios.c @@ -29,9 +29,6 @@ #include #include -extern unsigned char dsdt_anycpu_qemu_xen[]; -extern int dsdt_anycpu_qemu_xen_len; - struct seabios_info { char signature[14]; /* XenHVMSeaBIOS\0 */ uint8_t length; /* Length of this struct */ diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index db5f240..ab5448b 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -897,6 +897,23 @@ void hvmloader_acpi_build_tables(struct acpi_config *config, /* Allocate and initialise the acpi info area. */ mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1); + /* If the device model is specified switch to the corresponding tables */ + s = xenstore_read("platform/device-model", ""); + if ( !strncmp(s, "qemu_xen_traditional", 21) ) + { + config->dsdt_anycpu = dsdt_anycpu; + config->dsdt_anycpu_len = dsdt_anycpu_len; + config->dsdt_15cpu = dsdt_15cpu; + config->dsdt_15cpu_len = dsdt_15cpu_len; + } + else if ( !strncmp(s, "qemu_xen", 9) ) + { + config->dsdt_anycpu = dsdt_anycpu_qemu_xen; + config->dsdt_anycpu_len = dsdt_anycpu_qemu_xen_len; + config->dsdt_15cpu = NULL; + config->dsdt_15cpu_len = 0; + } + config->lapic_base_address = LAPIC_BASE_ADDRESS; config->lapic_id = acpi_lapic_id; config->ioapic_base_address = ioapic_base_address; diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 6062f0b..2ef854e 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -276,6 +276,9 @@ extern struct e820map memory_map; bool check_overlap(uint64_t start, uint64_t size, uint64_t reserved_start, uint64_t reserved_size); +extern const unsigned char dsdt_anycpu_qemu_xen[], dsdt_anycpu[], dsdt_15cpu[]; +extern const int dsdt_anycpu_qemu_xen_len, dsdt_anycpu_len, dsdt_15cpu_len; + struct acpi_config; void hvmloader_acpi_build_tables(struct acpi_config *config, unsigned int physical); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 1158303..4f13b69 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -451,7 +451,7 @@ int libxl__domain_build(libxl__gc *gc, vments[4] = "start_time"; vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); - localents = libxl__calloc(gc, 11, sizeof(char *)); + localents = libxl__calloc(gc, 13, sizeof(char *)); i = 0; localents[i++] = "platform/acpi"; localents[i++] = libxl__acpi_defbool_val(info) ? "1" : "0"; @@ -472,6 +472,8 @@ int libxl__domain_build(libxl__gc *gc, info->u.hvm.mmio_hole_memkb << 10); } } + localents[i++] = "platform/device-model"; + localents[i++] = (char *)libxl_device_model_version_to_string(info->device_model_version); break; case LIBXL_DOMAIN_TYPE_PV: diff --git a/xen/include/public/hvm/ioreq.h b/xen/include/public/hvm/ioreq.h index 2e5809b..d309d12 100644 --- a/xen/include/public/hvm/ioreq.h +++ b/xen/include/public/hvm/ioreq.h @@ -103,14 +103,19 @@ typedef struct buffered_iopage buffered_iopage_t; * version number in HVM_PARAM_ACPI_IOPORTS_LOCATION. */ -/* Version 0 (default): Traditional Xen locations. */ +/* + * Version 0 (default): Traditional (obsolete) Xen locations. + * + * These are now only used for compatibility with VMs migrated + * from older Xen versions. + */ #define ACPI_PM1A_EVT_BLK_ADDRESS_V0 0x1f40 #define ACPI_PM1A_CNT_BLK_ADDRESS_V0 (ACPI_PM1A_EVT_BLK_ADDRESS_V0 + 0x04) #define ACPI_PM_TMR_BLK_ADDRESS_V0 (ACPI_PM1A_EVT_BLK_ADDRESS_V0 + 0x08) #define ACPI_GPE0_BLK_ADDRESS_V0 (ACPI_PM_TMR_BLK_ADDRESS_V0 + 0x20) #define ACPI_GPE0_BLK_LEN_V0 0x08 -/* Version 1: Locations preferred by modern Qemu. */ +/* Version 1: Locations preferred by modern Qemu (including Qemu-trad). */ #define ACPI_PM1A_EVT_BLK_ADDRESS_V1 0xb000 #define ACPI_PM1A_CNT_BLK_ADDRESS_V1 (ACPI_PM1A_EVT_BLK_ADDRESS_V1 + 0x04) #define ACPI_PM_TMR_BLK_ADDRESS_V1 (ACPI_PM1A_EVT_BLK_ADDRESS_V1 + 0x08)