From patchwork Thu Feb 18 18:52:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vrabel X-Patchwork-Id: 8353561 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 63B439FC55 for ; Thu, 18 Feb 2016 18:55:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB6D9203A0 for ; Thu, 18 Feb 2016 18:55:09 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10BBE20397 for ; Thu, 18 Feb 2016 18:55:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aWTgi-0002Vq-Lj; Thu, 18 Feb 2016 18:52:28 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aWTgg-0002UI-Ng for xen-devel@lists.xenproject.org; Thu, 18 Feb 2016 18:52:26 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 8A/01-02994-6E216C65; Thu, 18 Feb 2016 18:52:22 +0000 X-Env-Sender: prvs=84994b707=david.vrabel@citrix.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1455821540!23150309!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64715 invoked from network); 18 Feb 2016 18:52:22 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 18 Feb 2016 18:52:22 -0000 X-IronPort-AV: E=Sophos;i="5.22,466,1449532800"; d="scan'208";a="332704078" From: David Vrabel To: Date: Thu, 18 Feb 2016 18:52:06 +0000 Message-ID: <1455821530-4263-2-git-send-email-david.vrabel@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455821530-4263-1-git-send-email-david.vrabel@citrix.com> References: <1455821530-4263-1-git-send-email-david.vrabel@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , David Vrabel , Jan Beulich Subject: [Xen-devel] [PATCHv1 1/5] domctl: Add op to get/set generic numeric parameters X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add XEN_DOMCTL_param to get/set generic numeric parameters for a domain. This should reduce the number of specialized domctls that need to be added. Signed-off-by: David Vrabel --- xen/arch/x86/domctl.c | 14 ++++++++++++++ xen/common/domctl.c | 11 +++++++++++ xen/include/public/domctl.h | 21 +++++++++++++++++++++ xen/include/xen/domain.h | 3 +++ 4 files changed, 49 insertions(+) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 55aecdc..3a3ebbf 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1408,6 +1408,20 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) #undef c } +int arch_domctl_param(struct domain *d, uint32_t param, bool_t set, + uint64_t *value) +{ + uint64_t new_value = *value; + + switch ( param ) + { + default: + return -EINVAL; + } + + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 22fa5d5..54c51ba 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -1186,6 +1186,17 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) copyback = 1; break; + case XEN_DOMCTL_param: + { + uint32_t param = op->u.param.param & ~XEN_DOMCTL_PARAM_SET; + bool_t set = !!(op->u.param.param & XEN_DOMCTL_PARAM_SET); + + ret = arch_domctl_param(d, param, set, &op->u.param.value); + if ( ret == 0 ) + copyback = 1; + break; + } + default: ret = arch_do_domctl(op, d, u_domctl); break; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a934318..330b3e7 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1092,6 +1092,25 @@ struct xen_domctl_psr_cat_op { typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t); +/* + * Get/set a per-domain numeric parameter. + * + * If bit 31 of @param is set, the original value is returned and the + * new value is written. If bit 31 is clear, the value is returned. + * + * Not all parameters are valid for all architectures or domain types. + */ +#define XEN_DOMCTL_PARAM_SET (1u << 31) + +struct xen_domctl_param { + /* IN */ + uint32_t param; + /* IN/OUT */ + uint64_t value; +}; +typedef struct xen_domctl_param xen_domctl_param; +DEFINE_XEN_GUEST_HANDLE(xen_domctl_param); + struct xen_domctl { uint32_t cmd; #define XEN_DOMCTL_createdomain 1 @@ -1169,6 +1188,7 @@ struct xen_domctl { #define XEN_DOMCTL_monitor_op 77 #define XEN_DOMCTL_psr_cat_op 78 #define XEN_DOMCTL_soft_reset 79 +#define XEN_DOMCTL_param 80 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 @@ -1231,6 +1251,7 @@ struct xen_domctl { struct xen_domctl_psr_cmt_op psr_cmt_op; struct xen_domctl_monitor_op monitor_op; struct xen_domctl_psr_cat_op psr_cat_op; + struct xen_domctl_param param; uint8_t pad[128]; } u; }; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index a1a6f25..a8a6d7d 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -77,6 +77,9 @@ void arch_dump_domain_info(struct domain *d); int arch_vcpu_reset(struct vcpu *); +int arch_domctl_param(struct domain *d, uint32_t param, bool_t set, + uint64_t *value); + extern spinlock_t vcpu_alloc_lock; bool_t domctl_lock_acquire(void); void domctl_lock_release(void);