From patchwork Tue Oct 1 14:57:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11169011 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B5181920 for ; Tue, 1 Oct 2019 15:04:08 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 475022168B for ; Tue, 1 Oct 2019 15:04:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="PEyfqoL0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 475022168B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iFJfO-000581-Pa; Tue, 01 Oct 2019 15:02:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iFJaZ-0004OE-GA for xen-devel@lists.xenproject.org; Tue, 01 Oct 2019 14:57:19 +0000 X-Inumbo-ID: c3263fec-e45b-11e9-b588-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by localhost (Halon) with ESMTPS id c3263fec-e45b-11e9-b588-bc764e2007e4; Tue, 01 Oct 2019 14:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1569941838; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qUeO4+yJpm+ZEItf2jxtpPKt7p08qKHXSsAp1VS6gng=; b=PEyfqoL04HnMy4hRutPHGSyWmkyu3daE4G8uevxUe24tswICSd5OQy+J uj9vusy5Z2gFzMLEIRkrPDEMG5yoQScY+13MlCxnpqo7SyV7zjs77IpPg OCHKuH86519nMMhRx0+HwOGMQnrkGDj11asC7r7ToynWdcaC0CyXlCOHo Q=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: i+dlpgJiYn98uf/k4hHENFNoc19oJnNtSVdTPyZ30NfDMVCjXjWjElSpYWMctrmDZVL2r3w3FN JwRRJOeJQJ/UOl5+P+4vjDopP/gEJC02KL6Krxj+ePQ9XK2igqAj0XGX9BgFY/ywb2YYjWZDyN RV/EPD9pRroSG/jkL6a7FHiwYbagzKoQ90K/fpLIJUWwEWp+knjMyN+rWCJPGULbMYsmFhsZJw lP02hehDcjgrOTLLon/ZCUJjrZCh2eTwnxEYE8rsx3OAZMRNz2mG+j5Zef5oT/eIIl7OXvy/Bs cbU= X-SBRS: 2.7 X-MesageID: 6557828 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,571,1559534400"; d="scan'208";a="6557828" From: Paul Durrant To: Date: Tue, 1 Oct 2019 15:57:13 +0100 Message-ID: <20191001145714.556-2-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20191001145714.556-1-paul.durrant@citrix.com> References: <20191001145714.556-1-paul.durrant@citrix.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 01 Oct 2019 15:02:16 +0000 Subject: [Xen-devel] [PATCH-for-4.13 v2 1/2] libxl: replace 'enabled' with 'unknown' in libxl_passthrough enumeration X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Juergen Gross , Paul Durrant , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This is mostly a cosmetic patch to avoid the default enumeration value being 'enabled'. The only non-cosmetic parts are in xl_parse.c where it now becomes necessary to explicitly parse the 'enabled' value for xl.cfg 'passthrough' option, and error on the value 'unknown', because there is no longer a direct mapping between valid xl.cfg values and the enumeration. Suggested-by: Ian Jackson Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross v2: - new in v2 --- tools/libxl/libxl_create.c | 4 ++-- tools/libxl/libxl_types.idl | 2 +- tools/xl/xl_parse.c | 26 +++++++++++++++----------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index b58e030376..5f2972bc03 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -64,7 +64,7 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, c_info->ssidref = SECINITSID_DOMU; if (info.cap_hvm_directio && - (c_info->passthrough == LIBXL_PASSTHROUGH_ENABLED)) { + (c_info->passthrough == LIBXL_PASSTHROUGH_UNKNOWN)) { c_info->passthrough = ((c_info->type == LIBXL_DOMAIN_TYPE_PV) || !info.cap_iommu_hap_pt_share) ? LIBXL_PASSTHROUGH_SYNC_PT : LIBXL_PASSTHROUGH_SHARE_PT; @@ -586,7 +586,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off; } - assert(info->passthrough != LIBXL_PASSTHROUGH_ENABLED); + assert(info->passthrough != LIBXL_PASSTHROUGH_UNKNOWN); LOG(DETAIL, "passthrough: %s", libxl_passthrough_to_string(info->passthrough)); diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 54ac685f50..3ac9494b80 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -264,7 +264,7 @@ libxl_vkb_backend = Enumeration("vkb_backend", [ ]) libxl_passthrough = Enumeration("passthrough", [ - (0, "enabled"), + (0, "unknown"), (1, "disabled"), (2, "sync_pt"), (3, "share_pt"), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index c2e61b680f..03a2c54dd2 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1512,23 +1512,27 @@ void parse_config_data(const char *config_source, if (xlu_cfg_get_string(config, "passthrough", &buf, 0)) { c_info->passthrough = (d_config->num_pcidevs || d_config->num_dtdevs) - ? LIBXL_PASSTHROUGH_ENABLED : LIBXL_PASSTHROUGH_DISABLED; + ? LIBXL_PASSTHROUGH_UNKNOWN : LIBXL_PASSTHROUGH_DISABLED; } else { - libxl_passthrough o; + if (!strcasecmp("enabled", buf)) + c_info->passthrough = LIBXL_PASSTHROUGH_UNKNOWN; + else { + libxl_passthrough o; - e = libxl_passthrough_from_string(buf, &o); - if (e) { - fprintf(stderr, - "ERROR: unknown passthrough option '%s'\n", - buf); - exit(-ERROR_FAIL); - } + e = libxl_passthrough_from_string(buf, &o); + if (e || !strcasecmp("unknown", buf)) { + fprintf(stderr, + "ERROR: unknown passthrough option '%s'\n", + buf); + exit(-ERROR_FAIL); + } - c_info->passthrough = o; + c_info->passthrough = o; + } } switch (c_info->passthrough) { - case LIBXL_PASSTHROUGH_ENABLED: + case LIBXL_PASSTHROUGH_UNKNOWN: /* * Choose a suitable default. libxl would also do this but * choosing here allows the code calculating 'iommu_memkb' From patchwork Tue Oct 1 14:57:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11169009 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46D6B1747 for ; Tue, 1 Oct 2019 15:04:08 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FFBE20679 for ; Tue, 1 Oct 2019 15:04:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="IRbJkyg/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FFBE20679 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iFJfP-00058D-Bc; Tue, 01 Oct 2019 15:02:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iFJae-0004Ok-GM for xen-devel@lists.xenproject.org; Tue, 01 Oct 2019 14:57:24 +0000 X-Inumbo-ID: c4100ac8-e45b-11e9-b588-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by localhost (Halon) with ESMTPS id c4100ac8-e45b-11e9-b588-bc764e2007e4; Tue, 01 Oct 2019 14:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1569941839; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5GIZbrW/7UHOKzPnQwF1sYeQLthDe/gD90GMyjCPdmA=; b=IRbJkyg/wlMNUY0iKIqJ867fsKhgZTF2xjOEgbscc4lbwSxrtFpq4EhB SQHjzlesjrBxL3WjkVMVRNcFYFO/OJw393zAwwjW3IaT+ZO0ff0lGe4MO ONKEQNUqXfpR6qWKvwl3gN5zbZW3CbjmTawsASyLMh/PoOYpMCb1MJiaQ s=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: OSGpm651Otu5wXR8ZPAaipv5MhhxGpJLMigU5Nx5Nj3fEtvpwyTRB1owgELfZmY1OoEphXfA2+ aKCWd96+NkMSNWz3eEp9xCeyd5nAWZ3gJ5gsIc8KVJ+uiHGNmYbgMo6png1zmCxcWCOzAwSNyv tbdBX2SMAtxaxKaxyBOR5Oz5RSN6uM/XZZOF+FNZXyRXQO1AMPOSj9eF1j+pbqx4FrbStzjLWA qktBUsSqSZ3rrCugf4a3fHdZQjwHI3nL5xLRajBb9J1tfa9+7fLxihd3ehe+CvWPkxZO4CNstu Dbw= X-SBRS: 2.7 X-MesageID: 6557830 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,571,1559534400"; d="scan'208";a="6557830" From: Paul Durrant To: Date: Tue, 1 Oct 2019 15:57:14 +0100 Message-ID: <20191001145714.556-3-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20191001145714.556-1-paul.durrant@citrix.com> References: <20191001145714.556-1-paul.durrant@citrix.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 01 Oct 2019 15:02:16 +0000 Subject: [Xen-devel] [PATCH-for-4.13 v2 2/2] libxl: choose an appropriate default for passthrough... X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Juergen Gross , Paul Durrant , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" ...if there is no IOMMU or it is globally disabled. Without this patch, the following assertion may be hit: xl: libxl_create.c:589: libxl__domain_make: Assertion `info->passthrough != LIBXL_PASSTHROUGH_UNKNOWN' failed. This is because libxl__domain_create_info_setdefault() currently only sets an appropriate value for 'passthrough' in the case that 'cap_hvm_directio' is true, which is not the case unless an IOMMU is present and enabled in the system. This is normally masked by xl choosing a default value, but that will not happen if xl is not used (e.g. when using libvirt) or when a stub domain is being created. Signed-off-by: Paul Durrant --- Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross v2: - re-base --- tools/libxl/libxl_create.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 5f2972bc03..62e13f3e7c 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -68,7 +68,11 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, c_info->passthrough = ((c_info->type == LIBXL_DOMAIN_TYPE_PV) || !info.cap_iommu_hap_pt_share) ? LIBXL_PASSTHROUGH_SYNC_PT : LIBXL_PASSTHROUGH_SHARE_PT; - } + } else if (!info.cap_hvm_directio) + c_info->passthrough = LIBXL_PASSTHROUGH_DISABLED; + + /* An explicit setting should now have been chosen */ + assert(c_info->passthrough != LIBXL_PASSTHROUGH_UNKNOWN); return 0; }