From patchwork Mon Aug 1 17:10:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergej Proskurin X-Patchwork-Id: 9254607 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 26F2B6048B for ; Mon, 1 Aug 2016 17:13:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 127532843C for ; Mon, 1 Aug 2016 17:13:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06A38284AE; Mon, 1 Aug 2016 17:13:52 +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 7A9DE2843C for ; Mon, 1 Aug 2016 17:13:50 +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 1bUGkI-0006Wy-LM; Mon, 01 Aug 2016 17:11:18 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUGkE-0006Mg-9v for xen-devel@lists.xenproject.org; Mon, 01 Aug 2016 17:11:14 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 3C/5A-20915-1B28F975; Mon, 01 Aug 2016 17:11:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsXSPJ+BQ3dD0/x wgy3NOhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aLa63sBT2WFc/uv2ZsYPyn3cXIxSEksJFR YsWWo4wQznJGieX/5jB1MXJysAkYSEx5vZIVxBYRUJK4t2oyWJxZoEJi6eO9QDYHh7CAr8SCv UYgJouAqsSOyzogFbwCthInrv5nA7ElBOQkGs7fZwaxOYHifbeXs4DYQgI2Eouv7meewMi9gJ FhFaNGcWpRWWqRrqG5XlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGoHcZgGAH48v TnocYJTmYlER5EwrmhwvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4N3eCJQTLEpNT61Iy8wBhhlM WoKDR0mEtwMkzVtckJhbnJkOkTrFqCglznsRJCEAksgozYNrg4X2JUZZKWFeRqBDhHgKUotyM 0tQ5V8xinMwKgnzGoBM4cnMK4Gb/gpoMRPQ4kT7OSCLSxIRUlINjFt+n2c8J7DtQDN/4NpVR5 41rOb+XPaOL6RyvfiWZ0IW6a5LNqS7i25xmdtvdyTSPbT8YcUkjex+1em11SIWF3K+ye9b2/R m1d4/TKz1TxZGm3mtdvxeUXjb1DF7U69a2lyBNTdVt+0+tHC5W/ZNppeSh3S3rWCRDWE5rTj/ /sM7eyf2pqt8Z1diKc5INNRiLipOBADq5p02aAIAAA== X-Env-Sender: proskurin@sec.in.tum.de X-Msg-Ref: server-8.tower-31.messagelabs.com!1470071472!53510133!1 X-Originating-IP: [131.159.0.8] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14709 invoked from network); 1 Aug 2016 17:11:12 -0000 Received: from mail-out1.informatik.tu-muenchen.de (HELO mail-out1.informatik.tu-muenchen.de) (131.159.0.8) by server-8.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Aug 2016 17:11:12 -0000 Received: from files.sec.in.tum.de (files.sec.in.tum.de [131.159.50.1]) by services.sec.in.tum.de (Postfix) with ESMTP id B737D10100EA0; Mon, 1 Aug 2016 19:11:11 +0200 (CEST) Received: from ker.sec.in.tum.de (ker.sec.in.tum.de [131.159.50.36]) by files.sec.in.tum.de (Postfix) with ESMTP id AADFC4400; Mon, 1 Aug 2016 19:11:11 +0200 (CEST) From: Sergej Proskurin To: xen-devel@lists.xenproject.org Date: Mon, 1 Aug 2016 19:10:26 +0200 Message-Id: <20160801171028.11615-24-proskurin@sec.in.tum.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160801171028.11615-1-proskurin@sec.in.tum.de> References: <20160801171028.11615-1-proskurin@sec.in.tum.de> Cc: Sergej Proskurin , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH v2 23/25] arm/altp2m: Extend libxl to activate altp2m on ARM. 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current implementation allows to set the parameter HVM_PARAM_ALTP2M. This parameter allows further usage of altp2m on ARM. For this, we define an additional, common altp2m field as part of the libxl_domain_type struct. This field can be set on x86 and on ARM systems through the "altp2m" switch in the domain's configuration file (i.e. set altp2m=1). Note, that the old parameter "altp2mhvm" is still valid for x86. Since this commit defines this old parameter as deprecated, libxl will generate a warning during processing. Signed-off-by: Sergej Proskurin --- Cc: Ian Jackson Cc: Wei Liu --- v2: The macro LIBXL_HAVE_ALTP2M is now valid for x86 and ARM. Moved the field altp2m out of info->u.pv.altp2m into the common field info->altp2m, where it can be accessed independent by the underlying architecture (x86 or ARM). Now, altp2m can be activated by the guest control parameter "altp2m". Adopted initialization routines accordingly. --- tools/libxl/libxl.h | 3 ++- tools/libxl/libxl_create.c | 8 +++++--- tools/libxl/libxl_dom.c | 4 ++-- tools/libxl/libxl_types.idl | 4 +++- tools/libxl/xl_cmdimpl.c | 26 +++++++++++++++++++++++++- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 48a43ce..a2cbd34 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -839,7 +839,8 @@ typedef struct libxl__ctx libxl_ctx; /* * LIBXL_HAVE_ALTP2M - * If this is defined, then libxl supports alternate p2m functionality. + * If this is defined, then libxl supports alternate p2m functionality for + * x86 HVM and ARM PV guests. */ #define LIBXL_HAVE_ALTP2M 1 diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index d7db9e9..16d3b52 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -319,7 +319,6 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_defbool_setdefault(&b_info->u.hvm.hpet, true); libxl_defbool_setdefault(&b_info->u.hvm.vpt_align, true); libxl_defbool_setdefault(&b_info->u.hvm.nested_hvm, false); - libxl_defbool_setdefault(&b_info->u.hvm.altp2m, false); libxl_defbool_setdefault(&b_info->u.hvm.usb, false); libxl_defbool_setdefault(&b_info->u.hvm.xen_platform_pci, true); @@ -406,6 +405,9 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_domain_type_to_string(b_info->type)); return ERROR_INVAL; } + + libxl_defbool_setdefault(&b_info->altp2m, false); + return 0; } @@ -901,8 +903,8 @@ static void initiate_domain_create(libxl__egc *egc, if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM && (libxl_defbool_val(d_config->b_info.u.hvm.nested_hvm) && - libxl_defbool_val(d_config->b_info.u.hvm.altp2m))) { - LOG(ERROR, "nestedhvm and altp2mhvm cannot be used together"); + libxl_defbool_val(d_config->b_info.altp2m))) { + LOG(ERROR, "nestedhvm and altp2m cannot be used together"); goto error_out; } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index ec29060..1550ef8 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -291,8 +291,6 @@ static void hvm_set_conf_params(xc_interface *handle, uint32_t domid, libxl_defbool_val(info->u.hvm.vpt_align)); xc_hvm_param_set(handle, domid, HVM_PARAM_NESTEDHVM, libxl_defbool_val(info->u.hvm.nested_hvm)); - xc_hvm_param_set(handle, domid, HVM_PARAM_ALTP2M, - libxl_defbool_val(info->u.hvm.altp2m)); } int libxl__build_pre(libxl__gc *gc, uint32_t domid, @@ -434,6 +432,8 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, #endif } + xc_hvm_param_set(ctx->xch, domid, HVM_PARAM_ALTP2M, libxl_defbool_val(info->altp2m)); + rc = libxl__arch_domain_create(gc, d_config, domid); return rc; diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index ef614be..42e7c95 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -512,7 +512,6 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("mmio_hole_memkb", MemKB), ("timer_mode", libxl_timer_mode), ("nested_hvm", libxl_defbool), - ("altp2m", libxl_defbool), ("smbios_firmware", string), ("acpi_firmware", string), ("hdtype", libxl_hdtype), @@ -561,6 +560,9 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ])), + # Alternate p2m is not bound to any architecture or guest type, as it is + # supported by x86 HVM and ARM PV guests. + ("altp2m", libxl_defbool), ], dir=DIR_IN ) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 51dc7a0..f4a49ee 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1667,7 +1667,12 @@ static void parse_config_data(const char *config_source, xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0); - xlu_cfg_get_defbool(config, "altp2mhvm", &b_info->u.hvm.altp2m, 0); + /* The config parameter "altp2mhvm" is considered deprecated, however + * further considered because of legacy reasons. The config parameter + * "altp2m" shall be used instead. */ + if (!xlu_cfg_get_defbool(config, "altp2mhvm", &b_info->altp2m, 0)) + fprintf(stderr, "WARNING: Specifying \"altp2mhvm\" is deprecated. " + "Please use a \"altp2m\" instead.\n"); xlu_cfg_replace_string(config, "smbios_firmware", &b_info->u.hvm.smbios_firmware, 0); @@ -1727,6 +1732,25 @@ static void parse_config_data(const char *config_source, abort(); } + bool altp2m_support = false; +#if defined(__i386__) || defined(__x86_64__) + /* Alternate p2m support on x86 is available only for HVM guests. */ + if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) + altp2m_support = true; +#elif defined(__arm__) || defined(__aarch64__) + /* Alternate p2m support on ARM is available for all guests. */ + altp2m_support = true; +#endif + + if (altp2m_support) { + /* The config parameter "altp2m" replaces the parameter "altp2mhvm". + * For legacy reasons, both parameters are accepted on x86 HVM guests + * (only "altp2m" is accepted on ARM guests). If both parameters are + * given, it must be considered that the config parameter "altp2m" will + * always have priority over "altp2mhvm". */ + xlu_cfg_get_defbool(config, "altp2m", &b_info->altp2m, 0); + } + if (!xlu_cfg_get_list(config, "ioports", &ioports, &num_ioports, 0)) { b_info->num_ioports = num_ioports; b_info->ioports = calloc(num_ioports, sizeof(*b_info->ioports));