From patchwork Tue Jul 25 19:55:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 9863161 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 355276038F for ; Tue, 25 Jul 2017 19:59:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37A5F28711 for ; Tue, 25 Jul 2017 19:59:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C89628717; Tue, 25 Jul 2017 19:59:02 +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 2150728727 for ; Tue, 25 Jul 2017 19:59:00 +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 1da5vp-0006ne-KN; Tue, 25 Jul 2017 19:55:49 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1da5vo-0006nY-0d for xen-devel@lists.xen.org; Tue, 25 Jul 2017 19:55:48 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 14/EF-01996-342A7795; Tue, 25 Jul 2017 19:55:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkkeJIrShJLcpLzFFi42LZKekooeu0qDz S4M8JdYslHxezODB6HN39mymAMYo1My8pvyKBNePztZ3sBc3aFa0dk1kbGA8rdzFyckgI+En8 X7mOGcRmEzCQOLVpEQuILSIgK7G6aw47iM0sMI1RonOyEYgtLBAr0bLkNRuIzSKgKtH4egNYD a+Ap8SRz9fZIWbKSdw818kMEReUODnzCQvEHAmJgy9egMWFBNQkjnbtAopzANWnS5z9njmBkW cWko5ZSDoWMDKtYlQvTi0qSy3SNdVLKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZLzs/dxAg MEAYg2MH4pd/5EKMkB5OSKO833fJIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8XxYA5QSLUtNT K9Iyc4ChCpOW4OBREuFVXgiU5i0uSMwtzkyHSJ1iNOZ4NeH/NyaOpu8fvzMJseTl56VKifPKg JQKgJRmlObBDYLF0CVGWSlhXkag04R4ClKLcjNLUOVfMYpzMCoJ8+qCTOHJzCuB2/cK6BQmoF PmzCgFOaUkESEl1cCov37d3PBzjxkcPp7bub+1bGrLr/4F/O9eTgi00L/z+Xn++97jE6InrHV 59XHmbikmt1T3skRmO/lo50Bm/ofZh4//XLuwn3P7DT817ZfsDsKxX4KnTzHY+oHzxxzds3Gz +//8//xopl3LtXITk8crThpNlttx1KG5blZzeUGZTWb6X2fz5LZ3SizFGYmGWsxFxYkAmHf/P JwCAAA= X-Env-Sender: prvs=372944400=igor.druzhinin@citrix.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1501012546!101596972!1 X-Originating-IP: [185.25.65.24] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61426 invoked from network); 25 Jul 2017 19:55:46 -0000 Received: from smtp.eu.citrix.com (HELO SMTP.EU.CITRIX.COM) (185.25.65.24) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 25 Jul 2017 19:55:46 -0000 X-IronPort-AV: E=Sophos;i="5.40,412,1496102400"; d="scan'208";a="49922513" From: Igor Druzhinin To: Date: Tue, 25 Jul 2017 20:55:30 +0100 Message-ID: <1501012530-31792-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 AMSPEX02CL01.citrite.net (10.69.22.125) Cc: Igor Druzhinin , ian.jackson@eu.citrix.com, wei.liu2@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com Subject: [Xen-devel] [PATCH v2] 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 and ACPI IO port location 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 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. Signed-off-by: Igor Druzhinin Reviewed-by: Paul Durrant --- Changes in v2: * fix insufficient allocation size of localent --- tools/firmware/hvmloader/hvmloader.c | 2 -- tools/firmware/hvmloader/ovmf.c | 2 ++ tools/firmware/hvmloader/rombios.c | 2 ++ tools/firmware/hvmloader/seabios.c | 3 +++ tools/firmware/hvmloader/util.c | 24 ++++++++++++++++++++++++ tools/libxl/libxl_create.c | 4 +++- 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index f603f68..db11ab1 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -405,8 +405,6 @@ int main(void) } acpi_enable_sci(); - - hvm_param_set(HVM_PARAM_ACPI_IOPORTS_LOCATION, 1); } init_vm86_tss(); diff --git a/tools/firmware/hvmloader/ovmf.c b/tools/firmware/hvmloader/ovmf.c index 4ff7f1d..ebadc64 100644 --- a/tools/firmware/hvmloader/ovmf.c +++ b/tools/firmware/hvmloader/ovmf.c @@ -127,6 +127,8 @@ static void ovmf_acpi_build_tables(void) .dsdt_15cpu_len = 0 }; + hvm_param_set(HVM_PARAM_ACPI_IOPORTS_LOCATION, 1); + hvmloader_acpi_build_tables(&config, ACPI_PHYSICAL_ADDRESS); } diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c index 56b39b7..31a7c65 100644 --- a/tools/firmware/hvmloader/rombios.c +++ b/tools/firmware/hvmloader/rombios.c @@ -181,6 +181,8 @@ static void rombios_acpi_build_tables(void) .dsdt_15cpu_len = dsdt_15cpu_len, }; + hvm_param_set(HVM_PARAM_ACPI_IOPORTS_LOCATION, 0); + hvmloader_acpi_build_tables(&config, ACPI_PHYSICAL_ADDRESS); } diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c index 870576a..5878eff 100644 --- a/tools/firmware/hvmloader/seabios.c +++ b/tools/firmware/hvmloader/seabios.c @@ -28,6 +28,7 @@ #include #include +#include extern unsigned char dsdt_anycpu_qemu_xen[]; extern int dsdt_anycpu_qemu_xen_len; @@ -99,6 +100,8 @@ static void seabios_acpi_build_tables(void) .dsdt_15cpu_len = 0, }; + hvm_param_set(HVM_PARAM_ACPI_IOPORTS_LOCATION, 1); + hvmloader_acpi_build_tables(&config, rsdp); add_table(rsdp); } diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index db5f240..45b777c 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -31,6 +31,9 @@ #include #include +extern unsigned char dsdt_anycpu_qemu_xen[], dsdt_anycpu[], dsdt_15cpu[]; +extern int dsdt_anycpu_qemu_xen_len, dsdt_anycpu_len, dsdt_15cpu_len; + /* * Check whether there exists overlap in the specified memory range. * Returns true if exists, else returns false. @@ -897,6 +900,27 @@ 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; + + hvm_param_set(HVM_PARAM_ACPI_IOPORTS_LOCATION, 0); + } + 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; + + hvm_param_set(HVM_PARAM_ACPI_IOPORTS_LOCATION, 1); + } + config->lapic_base_address = LAPIC_BASE_ADDRESS; config->lapic_id = acpi_lapic_id; config->ioapic_base_address = ioapic_base_address; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 1158303..1d24209 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: