From nobody Thu Apr 18 07:58:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580995530698380.23311195512974; Thu, 6 Feb 2020 05:25:30 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1izh9N-0002d7-TV; Thu, 06 Feb 2020 13:24:57 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1izh9M-0002d1-Id for xen-devel@lists.xenproject.org; Thu, 06 Feb 2020 13:24:56 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 104f0be0-48e4-11ea-af84-12813bfff9fa; Thu, 06 Feb 2020 13:24:55 +0000 (UTC) X-Inumbo-ID: 104f0be0-48e4-11ea-af84-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580995495; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SUR2Zch0NanS6XPGioB/JRHlNkzk34eiNHO6q5hOpDA=; b=Pgxnk2Ir250+E+fzEft8BkX0FV2VMz/B2qfNGpRm4nSkVKw9IGikAHLE O0z8LFFZxnqaiZyu8C/oh48pD4u5ZEUA2gWaWpIVt7qO9pTjtR9WprJnB vwVcfEkyZNCIpeATyCcBRBGv8kl66g7jHZdjk+L68bFTIhQvTbt5eqdd/ c=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of Andrew.Cooper3@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="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@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 ip4:168.245.78.127 ~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="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: vaTvcHxxAOMneLmIx6goDm19Dsy2EktZ2AY/wpSu3Abucy+dMWhnpOASN0sSOkIBrEOaUCpWiB WVTDDhPfg1BZ6KoDXRRIR9fKZavnj+85DS6ha1Cy6r58X8h6GEKo1+2RIb6bRC5GgOfDY1xL7z TnDFYe5N749/Aw+jzzPoWBTkrn13L4CUBkQd21qAkE7n4Zc264JbCXrMwpR9Enezsd+FgEsYvq yPOrPBCL1BX94buwJpku5rhiMpnNMyzVVLrworzcZikfkOacwNfCjAsH/aTX7lJR9LxFVH7TMM /r4= X-SBRS: 2.7 X-MesageID: 12414507 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.70,409,1574139600"; d="scan'208";a="12414507" From: Andrew Cooper To: Xen-devel Date: Thu, 6 Feb 2020 13:24:52 +0000 Message-ID: <20200206132452.11802-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen/hvm: Fix handling of obsolete HVM_PARAMs 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: Tamas K Lengyel , Wei Liu , Razvan Cojocaru , Andrew Cooper , Jan Beulich , Ian Jackson , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The local xc_hvm_param_deprecated_check() in libxc tries to guess Xen's behaviour for the MEMORY_EVENT params, but is wrong for the get side, where Xen would return 0 (which is also a bug). Delete the helper. In Xen, perform the checks in hvm_allow_set_param(), rather than hvm_set_param(), and actually implement checks on the get side so the hypercall doesn't return successfully with 0 as an answer. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Acked-by: Wei Liu --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Ian Jackson CC: Razvan Cojocaru CC: Tamas K Lengyel Tamas: You introduced xc_hvm_param_deprecated_check() in 0a246b41ca while introducing XEN_DOMCTL_monitor_op. Do you recall why? --- tools/libxc/xc_domain.c | 28 ++-------------------------- xen/arch/x86/hvm/hvm.c | 25 ++++++++++++++----------- xen/include/public/hvm/params.h | 18 ++++++++---------- 3 files changed, 24 insertions(+), 47 deletions(-) diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index e544218d2e..71829c2bce 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -1441,31 +1441,10 @@ int xc_domain_send_trigger(xc_interface *xch, return do_domctl(xch, &domctl); } =20 -static inline int xc_hvm_param_deprecated_check(uint32_t param) -{ - switch ( param ) - { - case HVM_PARAM_MEMORY_EVENT_CR0: - case HVM_PARAM_MEMORY_EVENT_CR3: - case HVM_PARAM_MEMORY_EVENT_CR4: - case HVM_PARAM_MEMORY_EVENT_INT3: - case HVM_PARAM_MEMORY_EVENT_SINGLE_STEP: - case HVM_PARAM_MEMORY_EVENT_MSR: - return -EOPNOTSUPP; - default: - break; - }; - - return 0; -} - int xc_hvm_param_set(xc_interface *handle, uint32_t dom, uint32_t param, u= int64_t value) { DECLARE_HYPERCALL_BUFFER(xen_hvm_param_t, arg); - int rc =3D xc_hvm_param_deprecated_check(param); - - if ( rc ) - return rc; + int rc; =20 arg =3D xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg)); if ( arg =3D=3D NULL ) @@ -1484,10 +1463,7 @@ int xc_hvm_param_set(xc_interface *handle, uint32_t = dom, uint32_t param, uint64_ int xc_hvm_param_get(xc_interface *handle, uint32_t dom, uint32_t param, u= int64_t *value) { DECLARE_HYPERCALL_BUFFER(xen_hvm_param_t, arg); - int rc =3D xc_hvm_param_deprecated_check(param); - - if ( rc ) - return rc; + int rc; =20 arg =3D xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg)); if ( arg =3D=3D NULL ) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 00a9e70b7c..93795dab92 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4105,8 +4105,14 @@ static int hvm_allow_set_param(struct domain *d, break; /* The following parameters are deprecated. */ case HVM_PARAM_DM_DOMAIN: + case HVM_PARAM_MEMORY_EVENT_CR0: + case HVM_PARAM_MEMORY_EVENT_CR3: + case HVM_PARAM_MEMORY_EVENT_CR4: + case HVM_PARAM_MEMORY_EVENT_INT3: + case HVM_PARAM_MEMORY_EVENT_SINGLE_STEP: case HVM_PARAM_BUFIOREQ_EVTCHN: - rc =3D -EPERM; + case HVM_PARAM_MEMORY_EVENT_MSR: + rc =3D -EINVAL; break; /* * The following parameters must not be set by the guest @@ -4221,15 +4227,6 @@ static int hvm_set_param(struct domain *d, uint32_t = index, uint64_t value) case HVM_PARAM_ACPI_IOPORTS_LOCATION: rc =3D pmtimer_change_ioport(d, value); break; - case HVM_PARAM_MEMORY_EVENT_CR0: - case HVM_PARAM_MEMORY_EVENT_CR3: - case HVM_PARAM_MEMORY_EVENT_CR4: - case HVM_PARAM_MEMORY_EVENT_INT3: - case HVM_PARAM_MEMORY_EVENT_SINGLE_STEP: - case HVM_PARAM_MEMORY_EVENT_MSR: - /* Deprecated */ - rc =3D -EOPNOTSUPP; - break; case HVM_PARAM_NESTEDHVM: rc =3D xsm_hvm_param_nested(XSM_PRIV, d); if ( rc ) @@ -4411,8 +4408,14 @@ static int hvm_allow_get_param(struct domain *d, break; /* The following parameters are deprecated. */ case HVM_PARAM_DM_DOMAIN: + case HVM_PARAM_MEMORY_EVENT_CR0: + case HVM_PARAM_MEMORY_EVENT_CR3: + case HVM_PARAM_MEMORY_EVENT_CR4: + case HVM_PARAM_MEMORY_EVENT_INT3: + case HVM_PARAM_MEMORY_EVENT_SINGLE_STEP: case HVM_PARAM_BUFIOREQ_EVTCHN: - rc =3D -ENODATA; + case HVM_PARAM_MEMORY_EVENT_MSR: + rc =3D -EINVAL; break; /* The remaining parameters should not be read by the guest. */ default: diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/param= s.h index 36832e4b94..68293e314e 100644 --- a/xen/include/public/hvm/params.h +++ b/xen/include/public/hvm/params.h @@ -28,8 +28,14 @@ /* These parameters are deprecated and their meaning is undefined. */ #if defined(__XEN__) || defined(__XEN_TOOLS__) =20 -#define HVM_PARAM_DM_DOMAIN 13 -#define HVM_PARAM_BUFIOREQ_EVTCHN 26 +#define HVM_PARAM_DM_DOMAIN 13 +#define HVM_PARAM_MEMORY_EVENT_CR0 20 +#define HVM_PARAM_MEMORY_EVENT_CR3 21 +#define HVM_PARAM_MEMORY_EVENT_CR4 22 +#define HVM_PARAM_MEMORY_EVENT_INT3 23 +#define HVM_PARAM_MEMORY_EVENT_SINGLE_STEP 25 +#define HVM_PARAM_BUFIOREQ_EVTCHN 26 +#define HVM_PARAM_MEMORY_EVENT_MSR 30 =20 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ =20 @@ -227,14 +233,6 @@ */ #define HVM_PARAM_ACPI_IOPORTS_LOCATION 19 =20 -/* Deprecated */ -#define HVM_PARAM_MEMORY_EVENT_CR0 20 -#define HVM_PARAM_MEMORY_EVENT_CR3 21 -#define HVM_PARAM_MEMORY_EVENT_CR4 22 -#define HVM_PARAM_MEMORY_EVENT_INT3 23 -#define HVM_PARAM_MEMORY_EVENT_SINGLE_STEP 25 -#define HVM_PARAM_MEMORY_EVENT_MSR 30 - /* Boolean: Enable nestedhvm (hvm only) */ #define HVM_PARAM_NESTEDHVM 24 =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel