Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2554103ybk; Tue, 12 May 2020 02:15:42 -0700 (PDT) X-Google-Smtp-Source: APiQypLX+ZULIf6PiCI1kjhDmgxnQyi9psqK8ZQv+62LzDKuPmC5cxDBfGNuzm/UzCTh9OcHHJ3P X-Received: by 2002:a17:906:b253:: with SMTP id ce19mr17478368ejb.341.1589274941998; Tue, 12 May 2020 02:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589274941; cv=none; d=google.com; s=arc-20160816; b=fFZ/mzrMAkYoPgt61i0CV8tCpsGN5LZY0L62vvrhZlvUyEVspUwPGxp4GZQcLCADPq mcVirZ72HlWkW3RsZHrbRuvwX4SGfRUA5R4s73c/0e2NPUSK+1gj0f3mAnqGWy0Uy09r GbGsxCb+pHgEPBVCWGBv83Q04HgtrNfqabrrbqpvCmv58/7exCxF0zOErseLG+rk45H/ BQa3erT+2eO8zYwWvt/Ebo25oU4dYRml7luw+0Q2mMVkx8XpFXT7Uz/3WMI3sPEHccYV rWClkOE+QXw48I7Nd0IAGYDobYr8WEW6bs+Di/hb+7J2/jwv7kPGiUvgiC7x1kpBZuU+ ZRpQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=4b+c1fTMBwQ/jF7DxdkfJXeVefpTtTZ7Ht4HQ0/06UU=; b=agX8Ba4wBCcY2kIzMWJhXvMnnq0G+gGKQbZ39+YAonKjv4BE1WKKCZBnHGKFRat53t VFIgfXYBdTxc0mb3xhE3LzJTu9J2aqhTLhireJpI+IHpt5OEM2I3PEiJKayiDVbyW6Y4 4lM/iOBbJSBqUBMhgAHyAP43ksnA91BiUysP6hG3SbSGPE5UHUre1gxueC0N8xkl8LWN bbdJqyqdB9T/XZjiOAF7gE1p89PNq3YZb5gA7tOlAbmXjxUT92288qgnPSJ1ayYaJXkD 2adtrDv+AYEVzImu4KvbYJvLsVhl0JZ4qXnQtrQsyZXiRy14E07EgyA4+N+cpOugknMs gWJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o18si4140939edi.508.2020.05.12.02.15.18; Tue, 12 May 2020 02:15:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729135AbgELJNa (ORCPT + 99 others); Tue, 12 May 2020 05:13:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:53538 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgELJNa (ORCPT ); Tue, 12 May 2020 05:13:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CFD8EAC6C; Tue, 12 May 2020 09:13:31 +0000 (UTC) Subject: Re: [PATCH 1/2] xen/xenbus: avoid large structs and arrays on the stack To: Boris Ostrovsky , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Cc: Stefano Stabellini , Arnd Bergmann References: <20200511073151.19043-1-jgross@suse.com> <20200511073151.19043-2-jgross@suse.com> <965e1d65-3a0c-3a71-ca58-2b5c04f98bce@oracle.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: Date: Tue, 12 May 2020 11:13:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <965e1d65-3a0c-3a71-ca58-2b5c04f98bce@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.05.20 20:01, Boris Ostrovsky wrote: > On 5/11/20 3:31 AM, Juergen Gross wrote: >> >> static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev, > > > I wonder whether we can drop valloc/vfree from xenbus_ring_ops' names. I can do that. > > >> + struct map_ring_valloc *info, >> grant_ref_t *gnt_ref, >> unsigned int nr_grefs, >> void **vaddr) >> { >> - struct xenbus_map_node *node; >> + struct xenbus_map_node *node = info->node; >> int err; >> void *addr; >> bool leaked = false; >> - struct map_ring_valloc_hvm info = { >> - .idx = 0, >> - }; >> unsigned int nr_pages = XENBUS_PAGES(nr_grefs); >> >> - if (nr_grefs > XENBUS_MAX_RING_GRANTS) >> - return -EINVAL; >> - >> - *vaddr = NULL; >> - >> - node = kzalloc(sizeof(*node), GFP_KERNEL); >> - if (!node) >> - return -ENOMEM; >> - >> err = alloc_xenballooned_pages(nr_pages, node->hvm.pages); >> if (err) >> goto out_err; >> >> gnttab_foreach_grant(node->hvm.pages, nr_grefs, >> xenbus_map_ring_setup_grant_hvm, >> - &info); >> + info); >> >> err = __xenbus_map_ring(dev, gnt_ref, nr_grefs, node->handles, >> - info.phys_addrs, GNTMAP_host_map, &leaked); >> + info, GNTMAP_host_map, &leaked); >> node->nr_handles = nr_grefs; >> >> if (err) >> @@ -641,11 +654,13 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev, >> spin_unlock(&xenbus_valloc_lock); >> >> *vaddr = addr; >> + info->node = NULL; > > > Is this so that xenbus_map_ring_valloc() doesn't free it accidentally? Yes. Juergen