From patchwork Wed Mar 29 18:07:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Schmoll X-Patchwork-Id: 9652167 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 CC1DE602C8 for ; Wed, 29 Mar 2017 18:10:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7967284F9 for ; Wed, 29 Mar 2017 18:10:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A947A2850E; Wed, 29 Mar 2017 18:10:26 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 0EEEE284F9 for ; Wed, 29 Mar 2017 18:10:25 +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 1ctI0Z-00079r-PZ; Wed, 29 Mar 2017 18:07:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctI0Y-00079l-UT for xen-devel@lists.xenproject.org; Wed, 29 Mar 2017 18:07:47 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 95/73-12861-2F7FBD85; Wed, 29 Mar 2017 18:07:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsVyMbThoO7H77c jDD5uFLP4vmUykwOjx+EPV1gCGKNYM/OS8isSWDMefZrHUtCtVLGr/wljA+NTmS5GTg4hgemM EnPeeXYxcnGwCFxikZhw9gsjiCMh8I5F4uyZR6wgVRICMRLTDx9mgbArJZZcPcMG0a0p8aW7C 6xBSGAZk0T3oTawIjYBA4nZKy8yg9giAkoS91ZNZgKxmQVcJLrmNYM1CwvYSBzvXM0OYrMIqE o82N0HVMPBwStgK7FrgzPELnmJXW0XWScw8i1gZFjFqFGcWlSWWqRraKKXVJSZnlGSm5iZo2t oYKyXm1pcnJiempOYVKyXnJ+7iREYKAxAsINxxXbPQ4ySHExKorwnDG9HCPEl5adUZiQWZ8QX leakFh9ilOHgUJLgLfsGlBMsSk1PrUjLzAGGLExagoNHSYR3Bkiat7ggMbc4Mx0idYrRkuPBq V1vmDjmzN4NJD/1H37DJMSSl5+XKiXO++4rUIMASENGaR7cOFhcXWKUlRLmZQQ6UIinILUoN7 MEVf4VozgHo5IwbyPIWp7MvBK4ra+ADmICOkjc5hbIQSWJCCmpBsa4JasP/RP7vXvX+/Ndfq+ eaQdI8fful3QKtThm8E/saeV7D6/1ThYG+9fderXN+PbH/b2yMUavyuPeb7zJMnV20NT2CXWJ VWoVYkk9zxaJb/UMfXk9zce1w+scY4yhzYmmZmHntLidfk/3paywaXn3fKbB6ddp2/QnHpZ7x nCkvGTho6e+rOeVWIozEg21mIuKEwFVdcofpgIAAA== X-Env-Sender: eggi.innovations@gmail.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1490810865!85142217!1 X-Originating-IP: [209.85.128.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47805 invoked from network); 29 Mar 2017 18:07:45 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Mar 2017 18:07:45 -0000 Received: by mail-wr0-f193.google.com with SMTP id k6so3960550wre.3 for ; Wed, 29 Mar 2017 11:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=q5YXGwkuWfmGb7XnUOv/Gef+RX7sTuEVqDlHbP1y268=; b=JxmAVZa/gSTPuUpwV/zvq/dxwW+5VgjjeyflfzwRxDp2+aBF7yS0auYcK2vUNvvcVx YUhf74z3Qo/H9vZk/0wWGcQ02N1lnpC7XJ4IoI3vLCRFqtyc/zMZuLTrM/mge/har830 KEKEEZBInxPXgdzR2abd/srTCGTaVPn0y4JX4me3FMVnzXNqvpHNoR5IBA4uNzvAlKax 4pSeNiyqtVEPx/qaVZhcKhqmPAqhjbyxNhBE067S7rFYPYzgeZAUthBa2S9JKVUyxtKD TrSvUrFFUdrc0ALSQM6ThJqMZQViTojQLlCs4WpCtmq3DXH701ZmEmk1Tl31wTbzhV3B 4hVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=q5YXGwkuWfmGb7XnUOv/Gef+RX7sTuEVqDlHbP1y268=; b=pNME5o8N416CoUE1VTy60YBfhgs8TVbsDPquhMrWiXwF2zYAoWwTww6LmZRT7fVnod R2vCOeRz5tHJ2K5e1BSSdEhGmbIeM9lLgveMMqqD/zMI4V1SGaPqFG9cUCk4EKTDORv6 WmT9bX+apjBaueckEkjq9AodTQKxCyrUWvbLeXKK510DZ9gcMHO1Vg2pms5XaGgUsxNV yWZAVFl6yo8V0sGaoyq+jpgy1oEqll7R3fMMjdMYXNgsxnr6Ekv1p3SLlYCgwEQQj0Qp V2pPaDhWUG8KzSLbB7KJGUlKM1PZX64JV/wTEmcXIbjHiXVk7POvlb5mLxwOqk1Iaoes pjdw== X-Gm-Message-State: AFeK/H3n7L1r0+j29ZBkb9CSMZHIl+3YTISsrOEFbqvic+bVvsRSSxxHeJrrA4FlyBE4lQ== X-Received: by 10.223.134.18 with SMTP id 18mr1627408wrv.190.1490810864770; Wed, 29 Mar 2017 11:07:44 -0700 (PDT) Received: from debian.jacobs-university.de (firewallix.jacobs-university.de. [212.201.44.247]) by smtp.gmail.com with ESMTPSA id m201sm31454wmd.15.2017.03.29.11.07.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Mar 2017 11:07:44 -0700 (PDT) From: Felix Schmoll To: xen-devel@lists.xenproject.org Date: Wed, 29 Mar 2017 20:07:39 +0200 Message-Id: <20170329180739.949-1-eggi.innovations@gmail.com> X-Mailer: git-send-email 2.11.0 Cc: wei.liu2@citrix.com, Felix Schmoll Subject: [Xen-devel] [PATCH] Implement new hypercall to return domain id 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 Minimal implementation of a new hypercall that returns the domain id of the invoking domain with adjustments in libxc. Signed-off-by: Felix Schmoll --- tools/libxc/include/xenctrl.h | 1 + tools/libxc/xc_private.c | 6 ++++++ xen/arch/arm/traps.c | 1 + xen/arch/x86/hvm/hypercall.c | 1 + xen/arch/x86/hypercall.c | 1 + xen/arch/x86/pv/hypercall.c | 1 + xen/common/kernel.c | 6 ++++++ xen/include/public/xen.h | 1 + xen/include/xen/hypercall.h | 3 +++ 9 files changed, 21 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 2d97d36c38..1e152c8a07 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1569,6 +1569,7 @@ int xc_domctl(xc_interface *xch, struct xen_domctl *domctl); int xc_sysctl(xc_interface *xch, struct xen_sysctl *sysctl); int xc_version(xc_interface *xch, int cmd, void *arg); +int xc_domid(xc_interface *xch); int xc_flask_op(xc_interface *xch, xen_flask_op_t *op); diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index 72e6242417..37b11e41a9 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -530,6 +530,12 @@ int xc_version(xc_interface *xch, int cmd, void *arg) return rc; } +int xc_domid(xc_interface *xch) +{ + return xencall0(xch->xcall, __HYPERVISOR_domain_id); +} + + unsigned long xc_make_page_below_4G( xc_interface *xch, uint32_t domid, unsigned long mfn) { diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 614501f761..eddb264f2d 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1297,6 +1297,7 @@ static arm_hypercall_t arm_hypercall_table[] = { HYPERCALL(platform_op, 1), HYPERCALL_ARM(vcpu_op, 3), HYPERCALL(vm_assist, 2), + HYPERCALL(domain_id, 0), }; #ifndef NDEBUG diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index e7238ce293..3d541e01e1 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -132,6 +132,7 @@ static const hypercall_table_t hvm_hypercall_table[] = { COMPAT_CALL(mmuext_op), HYPERCALL(xenpmu_op), COMPAT_CALL(dm_op), + HYPERCALL(domain_id), HYPERCALL(arch_1) }; diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index e30181817a..184741bf16 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -67,6 +67,7 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] = ARGS(tmem_op, 1), ARGS(xenpmu_op, 2), ARGS(dm_op, 3), + ARGS(domain_id, 0), ARGS(mca, 1), ARGS(arch_1, 1), }; diff --git a/xen/arch/x86/pv/hypercall.c b/xen/arch/x86/pv/hypercall.c index 9d29d2f088..f12314b5ca 100644 --- a/xen/arch/x86/pv/hypercall.c +++ b/xen/arch/x86/pv/hypercall.c @@ -79,6 +79,7 @@ static const hypercall_table_t pv_hypercall_table[] = { #endif HYPERCALL(xenpmu_op), COMPAT_CALL(dm_op), + HYPERCALL(domain_id), HYPERCALL(mca), HYPERCALL(arch_1), }; diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 84618715dc..5107aacd06 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -431,6 +431,12 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) return -ENOSYS; } +DO(domain_id)(void) +{ + struct domain *d = current->domain; + return d->domain_id; +} + DO(nmi_op)(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { struct xennmi_callback cb; diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index 91ba8bb48e..3a8c4af281 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -121,6 +121,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); #define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ #define __HYPERVISOR_xenpmu_op 40 #define __HYPERVISOR_dm_op 41 +#define __HYPERVISOR_domain_id 42 /* Architecture-specific hypercall definitions. */ #define __HYPERVISOR_arch_0 48 diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h index cc99aea57d..5c7bc6233e 100644 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -83,6 +83,9 @@ do_xen_version( XEN_GUEST_HANDLE_PARAM(void) arg); extern long +do_domain_id(void); + +extern long do_console_io( int cmd, int count,