Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3060110rwl; Mon, 27 Mar 2023 08:43:47 -0700 (PDT) X-Google-Smtp-Source: AKy350bWvS8IOXNUM76BjGGxFtU4IQp6H4hwuI1jLaeFXMl+rxCBJPvUojWhgUXwiT90aprODDiu X-Received: by 2002:a17:906:4ed5:b0:8af:2a97:91d4 with SMTP id i21-20020a1709064ed500b008af2a9791d4mr12740304ejv.14.1679931826834; Mon, 27 Mar 2023 08:43:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679931826; cv=pass; d=google.com; s=arc-20160816; b=X3WdzZgMVzvCPdmMUjAAFXMhxxmBExkZ86LSaFShpd6SL2NntfWy0+1TKeTq8Oo4Co Qe6C7MZ2/PL+6TrBj6o5gefAyMry9dRC3L31tuHMbxUb5o3gDODmElwaDyHWicb0fM+O RLENimWDABf+k8OTTweF0SulhlAIjybyaTI0u0tLOnal3QzvfMwRrGTonl0oO54LRVTQ wCMMiwzTWnY6Ns4GDU2xlLDvexfZ6SaRWBUlHqrFUW4Ppob8z0/Z7JiPz80u3G96aWvA VmJ1kWBNpCqmK7izo1BSqP2v0R2PXGePbKUFmhOk1qOx+pAfzCMo7EbqR5R/OMn8jXci fNOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:content-language:references:cc:to:subject:from :user-agent:date:message-id:dkim-signature; bh=tET5XWsbzJc25vRwP7iQ1JD35iIyc4moy2SuPeyqit4=; b=jcVC7K/I8B7FN4Z/ioMCAF8VyEHs8X/D2kpx5Woe3r8zALya4QKq9Ofa4ZPREbvKeq uCF54wHZoeGJblbFxET8ujYjkRJ/FIKm7W4/CuC+rQ6nOtcTZ+/cOpY/OE8u0m0uIq83 GaC/baJC4DodVXTRy1Apyd3df2K36wEFG9++UDgzr8VG99/dfDOpLrj/n7uFnYR8kb8w cjm3jWjCW1Oat3l3svMZeA9zbVAKnZ0Yon46cUX2DNjnHmPGTWD0b6B52k5k0AgkjusU 8+ABOtMYRDqbHZmS/xl23oHTXK07t8907jBr9a6AKfV1w2g071dqUyX8mHYHl/kaccMh Hv7w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=UHOjdg5p; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a17090699d300b009448c4f30basi2685122ejn.700.2023.03.27.08.43.17; Mon, 27 Mar 2023 08:43:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=UHOjdg5p; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232662AbjC0Piu (ORCPT + 99 others); Mon, 27 Mar 2023 11:38:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232056AbjC0Pis (ORCPT ); Mon, 27 Mar 2023 11:38:48 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2045.outbound.protection.outlook.com [40.107.22.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5E4FC2; Mon, 27 Mar 2023 08:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mE8b7ZaNb7Nq7AODYOmb0kNCBtdxlRgUhU+rstvQ/YvDuMfIIKy8BHApX841ybEdIdETvk6WFRXbW3X2D/uz6BG9UV91wSs0WVWeKzZ4Z+YhJQTcDo7jnq3Oj762L3wB42bvQkxFeKgu92gZt6IDTgTBhO9bVNvhGcyNfjfGsug88yboicxSPMyusO2L0ZGj5Y5SeYjK7dchlnCDda1qCAhU+Mn5MryGk0d8TeRwLa2eFruTcsXMZAN2RETo2xOqRzi2eoa8Fin3UJRpsWb/uz61EOJg0eFzr8FzAgzUF2/+6nUZ2F3Aa0JeyrI21EZxHnrEMC5xTVxugOtCQBTuDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tET5XWsbzJc25vRwP7iQ1JD35iIyc4moy2SuPeyqit4=; b=FQOOKmy4atVPDutH6T1dVFvCFx/1WXBOBaZTBhOc5sJWLTYDq6pNqm4OR7LBFIo6L8RN55S+CtaOhGLNeYRxKWS8em4yoT93fIJWUnFg5dXtXfE4WR3rFtYSOmtZNM8TE19sPva9AXZnk3HgxQ73wKe+6TwmKszQPICGM1wowcSCce2ki3IQdrVIInlcdrzNqpLslkwiGxvMRGxRodMS4s2OVEEIuCln2QMfyELKj31RFZ+5g7oSrjU2IG7aFzlSHV4/x218MuI/JZbAlJeh+uVkLfcSurxs98l/RxpuDebgPdgMXGeHZbwv0YSLdoA5rCgv8NanKXvM99KJGY1dTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tET5XWsbzJc25vRwP7iQ1JD35iIyc4moy2SuPeyqit4=; b=UHOjdg5pxLhvF4LnWsIsPcO1jvtfkLKitskbrq9N6gOos4pxB3+ellqe5fimcFxlHjoHWmosenaEy3BeTiZZvDGCqfdkoxmbuJnJTjKU+5P3NJFxDgX/fOMuhEGdF3NCCXEIMMRC9rs9fM/fUa0U3JGvXTRQ1TVARnIur2uNqdfUDBTHGy/TZGs+oJ7hgLNeBk4F0d5nIalxlCwVEiuC29eo6k7rv6q2qm2uag5if5snekKCnrfen7mAAdebPfGGC3IvAb/i6dJFprf33oBVYvosa1M2Ef93BNfeHiuuRYB5uNTbjTd7qeY3i9VnN4ph/QK9nRDcuH2XTJ/ZFIs9fQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PAWPR04MB9957.eurprd04.prod.outlook.com (2603:10a6:102:385::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Mon, 27 Mar 2023 15:38:43 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.029; Mon, 27 Mar 2023 15:38:43 +0000 Message-ID: <89653286-f05e-1fc1-b6bf-265b7ecaad0d@suse.com> Date: Mon, 27 Mar 2023 17:38:44 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 From: Jan Beulich Subject: Re: [PATCH 1/2] xen/netback: don't do grant copy across page boundary To: Juergen Gross Cc: Wei Liu , Paul Durrant , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , xen-devel@lists.xenproject.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org References: <20230327083646.18690-1-jgross@suse.com> <20230327083646.18690-2-jgross@suse.com> <59d90811-bc68-83cd-b7e5-7a8c2e2370d9@suse.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR2P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::10) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PAWPR04MB9957:EE_ X-MS-Office365-Filtering-Correlation-Id: af957ac7-806d-4413-a7ab-08db2ed958aa X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7NYbhtp4z21cSgB3y8FAXYG09iXZFSOA3SL+yW2Rl/kFVLiA9z0vjqtGg4ke2n0iFwcBmJwFYcODeC0x3ck7bzdk5pC8Xk+Ic40C+wUta1mSzOJ/JfBvW43bfFLTU3LfwA6MSlRw7GFTQFwcCk353v8jAEAuuZColXhTiAVVCoVSDjwaNTOt+bvvaYDLufim0OlSCP5B3q+GqOLO6IhkwnLtoTFNar+mMSNrFBssw9PzfdO77FOaXHkaY7P9jMEiYqt3sDaWXZiavVSUpsR/kBTBOkgMFVE1/W0h1kEjOlyOVYBt1aGucvJ+kbykz3FldJcomMMAzpqmZjFHt8gWw1qFjpg9pSZg3QLznu1UotZTqvzqI3WkfV+vkInUTZMH7qd0WrtrqAPOJcmsK04AIXeFcsFprPACrGEFyyzKSbDElaMmfzj/VAzCHsU+s8G4T0mT8ippS3WQHIQmrAiIEz/lb2lNP2J6SAwTxGdMiqHUEaeKbVlhdyfFqGUZK/g2TFJkwkzx/+QlQ7J94Q0wscn+mmWUkfelVWeNGcKAIPP9HZhlJ1kMhfxVpGW74jDy+FIaCfWovSfSRiNZXtLuQFAqmIcelnnHMokmATJydpkpY4fSTAHcvuk+/FUDjlptyb0raj0ty/3/AOm7tDvEVQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(366004)(396003)(376002)(346002)(39860400002)(451199021)(478600001)(31686004)(54906003)(6636002)(2616005)(316002)(37006003)(6512007)(6506007)(26005)(6486002)(66946007)(53546011)(66476007)(66556008)(8676002)(4326008)(31696002)(186003)(86362001)(41300700001)(8936002)(83380400001)(2906002)(36756003)(6862004)(38100700002)(5660300002)(7416002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SjJmUXkvMitGSnp5MWpzb2VYNWJFT25lOWlWMVd0Rk9PT20wMnZLOHBKUzBj?= =?utf-8?B?YUYySkJzU3AxQ01LVFFLdFJXVEFkSnFCSXpnREV3VHBmNytXbDBhenhBYnVl?= =?utf-8?B?SW9GZW12a3duOTcvSzhXVVRJT0laRDI3TEZLOVZmS3RiRjdRMUh2eWNHVUJB?= =?utf-8?B?bFVabWc2YmIvb3RJQU4zQUZvcmdLRGdmdUs0MURBYktOblc0Z0s3bEJrVG9V?= =?utf-8?B?c0xaOTNIL3BHNXNBeElFS0x4WDA4bDFqT3NNQVhNaTc3MkhkOUJZL1cweTYv?= =?utf-8?B?NnNCYlAwZ2FNU3ZqdzdJYnFLd0hkQkFENGk0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?PFh92a7o8F/Ou5JVU18zlTIm9?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: af957ac7-806d-4413-a7ab-08db2ed958aa X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2023 15:38:43.7533 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IL5DYqZ47DtvKirvgABQT+AeYJkIsO9JxFX7hgsjR8nrD9zzfbUCTWkiGuovdgbxSn0eEoLbtsZiFI1fVQI5vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9957 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.03.2023 12:07, Juergen Gross wrote: > On 27.03.23 11:49, Jan Beulich wrote: >> On 27.03.2023 10:36, Juergen Gross wrote: >>> @@ -413,6 +418,13 @@ static void xenvif_get_requests(struct xenvif_queue *queue, >>> cop->dest.u.gmfn = virt_to_gfn(skb->data + skb_headlen(skb) >>> - data_len); >>> >>> + /* Don't cross local page boundary! */ >>> + if (cop->dest.offset + amount > XEN_PAGE_SIZE) { >>> + amount = XEN_PAGE_SIZE - cop->dest.offset; >>> + XENVIF_TX_CB(skb)->split_mask |= 1U << copy_count(skb); >> >> Maybe worthwhile to add a BUILD_BUG_ON() somewhere to make sure this >> shift won't grow too large a shift count. The number of slots accepted >> could conceivably be grown past XEN_NETBK_LEGACY_SLOTS_MAX (i.e. >> XEN_NETIF_NR_SLOTS_MIN) at some point. > > This is basically impossible due to the size restriction of struct > xenvif_tx_cb. If its size became a problem, it might simply take a level of indirection to overcome the limitation. >>> @@ -420,7 +432,8 @@ static void xenvif_get_requests(struct xenvif_queue *queue, >>> pending_idx = queue->pending_ring[index]; >>> callback_param(queue, pending_idx).ctx = NULL; >>> copy_pending_idx(skb, copy_count(skb)) = pending_idx; >>> - copy_count(skb)++; >>> + if (!split) >>> + copy_count(skb)++; >>> >>> cop++; >>> data_len -= amount; >>> @@ -441,7 +454,8 @@ static void xenvif_get_requests(struct xenvif_queue *queue, >>> nr_slots--; >>> } else { >>> /* The copy op partially covered the tx_request. >>> - * The remainder will be mapped. >>> + * The remainder will be mapped or copied in the next >>> + * iteration. >>> */ >>> txp->offset += amount; >>> txp->size -= amount; >>> @@ -539,6 +553,13 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, >>> pending_idx = copy_pending_idx(skb, i); >>> >>> newerr = (*gopp_copy)->status; >>> + >>> + /* Split copies need to be handled together. */ >>> + if (XENVIF_TX_CB(skb)->split_mask & (1U << i)) { >>> + (*gopp_copy)++; >>> + if (!newerr) >>> + newerr = (*gopp_copy)->status; >>> + } >> >> It isn't guaranteed that a slot may be split only once, is it? Assuming a > > I think it is guaranteed. > > No slot can cover more than XEN_PAGE_SIZE bytes due to the grants being > restricted to that size. There is no way how such a data packet could cross > 2 page boundaries. > > In the end the problem isn't the copies for the linear area not crossing > multiple page boundaries, but the copies for a single request slot not > doing so. And this can't happen IMO. You're thinking of only well-formed requests. What about said request providing a large size with only tiny fragments? xenvif_get_requests() will happily process such, creating bogus grant-copy ops. But them failing once submitted to Xen will be only after damage may already have occurred (from bogus updates of internal state; the logic altogether is too involved for me to be convinced that nothing bad can happen). Interestingly (as I realize now) the shifts you add are not be at risk of turning UB in this case, as the shift count won't go beyond 16. >> near-64k packet with all tiny non-primary slots, that'll cause those tiny >> slots to all be mapped, but due to >> >> if (ret >= XEN_NETBK_LEGACY_SLOTS_MAX - 1 && data_len < txreq.size) >> data_len = txreq.size; >> >> will, afaict, cause a lot of copying for the primary slot. Therefore I >> think you need a loop here, not just an if(). Plus tx_copy_ops[]'es >> dimension also looks to need further growing to accommodate this. Or >> maybe not - at least the extreme example given would still be fine; more >> generally packets being limited to below 64k means 2*16 slots would >> suffice at one end of the scale, while 2*MAX_PENDING_REQS would at the >> other end (all tiny, including the primary slot). What I haven't fully >> convinced myself of is whether there might be cases in the middle which >> are yet worse. > > See above reasoning. I think it is okay, but maybe I'm missing something. Well, the main thing I'm missing is a "primary request fits in a page" check, even more so with the new copying logic that the commit referenced by Fixes: introduced into xenvif_get_requests(). Jan