Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp962675imp; Wed, 20 Feb 2019 12:21:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IY0WxjQtuZo7uTIQhyr3DcHEkoyegPtWlMIq53aDkznOt4QeKwoITkjUB+8XbUG6SXV7AKI X-Received: by 2002:a17:902:fa2:: with SMTP id 31mr38791607plz.75.1550694081451; Wed, 20 Feb 2019 12:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550694081; cv=none; d=google.com; s=arc-20160816; b=sQjXk2HTjigYHCxnAOHWls2d3DesjdCwvxu8KPUVNUrX1UODLTjAv0Jxu46LV29rRX /odL886+UgBX76pa3kFfW5iyETcu9nXIZtKyjptuXjyMSfRa+hbUMXAw4K3m9aY2HRyp kBPj5vnu9Dxs3C/jU82DBGUeKZ4eaZCit8aX2OPqxXbkMYqz+W8SQATzz0ifTl1SUndD S+trdGQoKWEJPua3dMFoBxAub9urPCJQ1kMFuzpLh6G644J70lbSwrkqMFpQhMgofIAx BM+OFOlEL6CMv+bs6mfw8GI9t6TbyrtnXzRkuHv+Wk5xAczihXEy5ChZdYL1dGjm4hFW ry0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nEoaALBLcsNsxHnJFDNeJyCL6A1vZHWL3Ev7hoUXOR8=; b=IwLXAuNOWYp6DHYfX3eEXr2srVw/qEjDp4eSo6wda9pQ6e6lF7WDpL0CVnb876kUoK kGhHuEQLgsY316CmhcmDyAYUNFO+erg0Js06O33nrX2vwivykkdpQ+tc4OKgsQJMBPDp iWjFC49EsT8L3jfNeMTv5vWPsi0zlB6OHTwUDeS/atJkyvoCm2gXudhhrdvx6gL2GjZi vKsbSK3/H+C9OZSQHRsZcY/1sP2s9aA4mfP2BXSN4tzUXOOspoitimEg7vX6xCK2bQJJ rZTMk/b90x++fEnQ3ZQnrEix+lBg9wjFcIN3WEdxcRklzqmxCFgX60vyV9jw1Ek0ONj4 cexA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=L7GnQZKk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si14526028plo.118.2019.02.20.12.21.06; Wed, 20 Feb 2019 12:21:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=L7GnQZKk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728126AbfBTUTE (ORCPT + 99 others); Wed, 20 Feb 2019 15:19:04 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:34258 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbfBTUSy (ORCPT ); Wed, 20 Feb 2019 15:18:54 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1KK8VMo087440; Wed, 20 Feb 2019 20:18:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=nEoaALBLcsNsxHnJFDNeJyCL6A1vZHWL3Ev7hoUXOR8=; b=L7GnQZKkBuiZR6S84VaVdAO/PMf0RxkH2Ijy80O0lmcjcqbkn3ABj626knGXcZaDVUIF BDZWhrJlcEoHOpGhhTwFiolKxI76K9L/u8TuTNtXXnddgsuZUbCMZDdVop3NkH9ofrmZ 6s56Y77lgri2vfCxVvz0a9Dye5kPNQzpcJ+7/517VfOVDd4yOxmFEaxPUbYVY3C4pc94 xGbzKEQoKeN4W693bFRat7J9Eqs6C4ISUQgwDNHL6AFYDk7o8HXyVPGhtXBDTQZnhsqA eZJDc/2CZtc9oB5sx3xpxHM+YLbrEsYV8Z5ID7iqZkzZaXRt0LFOc7rBUc+ouprS+exQ Lg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2qp81ec3f4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 20:18:47 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x1KKIkdD020684 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 20:18:46 GMT Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1KKIkfj019110; Wed, 20 Feb 2019 20:18:46 GMT Received: from paddy.lan (/94.61.137.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Feb 2019 12:18:45 -0800 From: Joao Martins To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Ankur Arora , Boris Ostrovsky , Joao Martins , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Juergen Gross , Stefano Stabellini Subject: [PATCH RFC 35/39] xen/xenbus: xen_shim_domain() support Date: Wed, 20 Feb 2019 20:16:05 +0000 Message-Id: <20190220201609.28290-36-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190220201609.28290-1-joao.m.martins@oracle.com> References: <20190220201609.28290-1-joao.m.martins@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9173 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902200138 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ankur Arora Fixup the gnttab unmap_ops (and other data structures) to handle host_addr as an OUT parameter from the call to GNTTABOP_map_grant_ref. Also, allow xenstored to be hosted in XS_LOCAL mode for xen_shim_domain() -- this means that it does not need to acquire xenstore evtchn and pfn externally. Co-developed-by: Joao Martins Signed-off-by: Ankur Arora Signed-off-by: Joao Martins --- drivers/xen/xenbus/xenbus_client.c | 23 +++++++++++++++++------ drivers/xen/xenbus/xenbus_dev_backend.c | 4 ++-- drivers/xen/xenbus/xenbus_dev_frontend.c | 4 ++-- drivers/xen/xenbus/xenbus_probe.c | 8 ++++---- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index ada1c9aa6525..b22149a789d4 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -487,8 +487,11 @@ static int __xenbus_map_ring(struct xenbus_device *dev, "mapping in shared page %d from domain %d", gnt_refs[i], dev->otherend_id); goto fail; - } else + } else { handles[i] = map[i].handle; + if (xen_shim_domain()) + addrs[i] = map[i].host_addr; + } } return GNTST_okay; @@ -498,7 +501,8 @@ static int __xenbus_map_ring(struct xenbus_device *dev, if (handles[i] != INVALID_GRANT_HANDLE) { memset(&unmap[j], 0, sizeof(unmap[j])); gnttab_set_unmap_op(&unmap[j], (phys_addr_t)addrs[i], - GNTMAP_host_map, handles[i]); + !xen_shim_domain()?GNTMAP_host_map:0, + handles[i]); j++; } } @@ -546,7 +550,7 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev, void **vaddr) { struct xenbus_map_node *node; - int err; + int i, err; void *addr; bool leaked = false; struct map_ring_valloc_hvm info = { @@ -572,9 +576,16 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev, &info); err = __xenbus_map_ring(dev, gnt_ref, nr_grefs, node->handles, - info.phys_addrs, GNTMAP_host_map, &leaked); + info.phys_addrs, + !xen_shim_domain() ? GNTMAP_host_map : 0, + &leaked); node->nr_handles = nr_grefs; + if (xen_shim_domain()) { + for (i = 0; i < nr_grefs; i++) + node->hvm.pages[i] = virt_to_page(info.phys_addrs[i]); + } + if (err) goto out_free_ballooned_pages; @@ -882,7 +893,7 @@ int xenbus_unmap_ring(struct xenbus_device *dev, for (i = 0; i < nr_handles; i++) gnttab_set_unmap_op(&unmap[i], vaddrs[i], - GNTMAP_host_map, handles[i]); + !xen_shim_domain()?GNTMAP_host_map:0, handles[i]); if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, i)) BUG(); @@ -926,7 +937,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = { .unmap = xenbus_unmap_ring_vfree_hvm, }; -void __init xenbus_ring_ops_init(void) +void xenbus_ring_ops_init(void) { #ifdef CONFIG_XEN_PV if (!xen_feature(XENFEAT_auto_translated_physmap)) diff --git a/drivers/xen/xenbus/xenbus_dev_backend.c b/drivers/xen/xenbus/xenbus_dev_backend.c index edba5fecde4d..b605c87bff76 100644 --- a/drivers/xen/xenbus/xenbus_dev_backend.c +++ b/drivers/xen/xenbus/xenbus_dev_backend.c @@ -119,11 +119,11 @@ static struct miscdevice xenbus_backend_dev = { .fops = &xenbus_backend_fops, }; -static int __init xenbus_backend_init(void) +int xenbus_backend_init(void) { int err; - if (!xen_initial_domain()) + if (!xen_initial_domain() && !xen_shim_domain()) return -ENODEV; err = misc_register(&xenbus_backend_dev); diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index a4080d04a01c..c6fca6cca6c8 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -680,11 +680,11 @@ static struct miscdevice xenbus_dev = { .fops = &xen_xenbus_fops, }; -static int __init xenbus_frontend_init(void) +static int xenbus_frontend_init(void) { int err; - if (!xen_domain()) + if (!xen_domain() && !xen_shim_domain()) return -ENODEV; err = misc_register(&xenbus_dev); diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 2e0ed46b05e7..bbc405cd01ef 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -693,7 +693,7 @@ EXPORT_SYMBOL_GPL(xenbus_probe); static int __init xenbus_probe_initcall(void) { - if (!xen_domain()) + if (!xen_domain() && !xen_shim_domain()) return -ENODEV; if (xen_initial_domain() || xen_hvm_domain()) @@ -790,7 +790,7 @@ int xenbus_init(void) uint64_t v = 0; xen_store_domain_type = XS_UNKNOWN; - if (!xen_domain()) + if (!xen_domain() && !xen_shim_domain()) return -ENODEV; xenbus_ring_ops_init(); @@ -799,7 +799,7 @@ int xenbus_init(void) xen_store_domain_type = XS_PV; if (xen_hvm_domain()) xen_store_domain_type = XS_HVM; - if (xen_hvm_domain() && xen_initial_domain()) + if ((xen_hvm_domain() && xen_initial_domain()) || xen_shim_domain()) xen_store_domain_type = XS_LOCAL; if (xen_pv_domain() && !xen_start_info->store_evtchn) xen_store_domain_type = XS_LOCAL; @@ -863,7 +863,7 @@ postcore_initcall(xenbus_init); void xenbus_deinit(void) { - if (!xen_domain()) + if (!xen_domain() && !xen_shim_domain()) return; #ifdef CONFIG_XEN_COMPAT_XENFS -- 2.11.0