Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1196609pxb; Fri, 21 Jan 2022 12:02:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwahy3SMGeKr7fysNMQX+hdrDYxGSiWAVsstUjogymRq684kWNnv0veRW/1FdNWwreMDPt5 X-Received: by 2002:a17:902:724c:b0:14a:9df9:6428 with SMTP id c12-20020a170902724c00b0014a9df96428mr5582087pll.87.1642795321983; Fri, 21 Jan 2022 12:02:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642795321; cv=none; d=google.com; s=arc-20160816; b=pOrUqsBv5QczdRyTpcjBEsCl5AZPCaB52GJSUyR2Cr+jtQ7vaWG0u97UY0WP5u2ssu NlNh80zLvVDICs7n8jorxy5iQVuDXRULyyWKrCRyW3TLffN1ZLiO8Zel7AzKN82s83Xf NrIs06dY1bZ7Idys4v4HyHEWWkMox4K/1/E4i4Qns+bJJNTcA6FFTLm96NSqDNVZMirh ZsOWz+DyRaW7+huyqE1yi5QrEmeVLH79fU01Y2lqBLlXKyFhHNN4yIhSyHfZfEh0Eo/K A7HLYGofpFdQBt/J52SOnwB5gExvSEISXTSfn1Z2ncjjjrPkQXNJWh3Avc1pR8NhwWpK GfzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=D0IAhlKzMhVDSvOyrE7WOScz7H0kZ7M7h7y/9jjJAyo=; b=M4xMcd8efnJviYS8FFleS2QmLUwkEAeAJM/4+aHcwZOPpA8Gwe3LQEy+ahcWV6Ka+m 6YrBprC9aN1zQMfJ9cRjXmmQU0LQzojmLT3CZN4+lroj1VVMj4IXnXyzM5vKDmCI0KGN 7Fawo5S0u4kwTiSmx3Umgg6pRp1Nh6QH0r5n/80C5wPfKhbETkT6aWQR011+LDd3Zn4o x4CeAN+CmVFONdWC5wDM7uT192S1hkEYuoIxryTPtP4tZ8Yg2U5jEjqHp/rV1ANUlN1z iOPw8nRcpP5U9dwVqDqstlabvblV86yEjzQO6Y+9jvMMBrId7qVfqZMHgqzFdhD52JZE NxaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B8z1c8Tb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si6949048pgc.513.2022.01.21.12.01.50; Fri, 21 Jan 2022 12:02:01 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B8z1c8Tb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357283AbiASUVW (ORCPT + 99 others); Wed, 19 Jan 2022 15:21:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231146AbiASUVU (ORCPT ); Wed, 19 Jan 2022 15:21:20 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9F11C061574; Wed, 19 Jan 2022 12:21:20 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id w204so3309433pfc.7; Wed, 19 Jan 2022 12:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=D0IAhlKzMhVDSvOyrE7WOScz7H0kZ7M7h7y/9jjJAyo=; b=B8z1c8TbozA4PbYfP8freTXuYQq4JYYeVme3C4wbQqfi3tgQGH4YBUg0HdBcmKhp7o ofAu0L0YRVAqCRBecsdSlMI6v8ikYEelTdACKprfxmIF22aegr+b/r5RqIm79md/BrN9 hgMDa8wMovhEKiKfAi60H1SorCA3cErxVhFtUshtKQXlrcacGz+rn3KIqoEmIgGnsTrL jR0ZzNyck+437UUSzTZCwxO2QRL8XSewL2UUkeOyR7BumpW4KGeibdko/uOisFMYwRtk YEAZ+hf1f480kpSVPK2fb52fC3h2Ny/kIPQAA6sa4izf2rnvyzVPi1LgHDu1V+4g/RL0 8bOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=D0IAhlKzMhVDSvOyrE7WOScz7H0kZ7M7h7y/9jjJAyo=; b=BbBOCVNclF6Ti9dl9ZcM9VOjGR5IyoTF1p+e0yywBz2T0Y6wE9E2DgrqrV9ZL4wi0I 5U+u5i0uRL6bKnUrmWkOUAc4LBcSSt8QfOt90WhkYrjiXCBdaafkUV46Frb9kT8MVJs5 Ya1H+1aKHs4w0taxbmjjSa4uNTgTRzUXjgsYBJ/i8BBY1r1bKHSJ+l20pA4HtvuFZQrq OB3yYUFEPt0RYCWASjS/F1vZDyo4T3eabW2plqiQraSAkRwt+U5IOOdYUxYO4Y3RUhe/ vLQWi1Q2ylyLhq+1Wnb/hi8XXxxglGHsHcqOsockh6QO7oplmgydbeHoKcTtRY61AtBC M+uw== X-Gm-Message-State: AOAM533NuX2xNZrB4Edey8y7IHxw57F4orBqY/y8XATqwjhW26I0mx5Z AxicK3oaaW6lx/ItV1jaRKA6xrkYd8GsYQ== X-Received: by 2002:a63:b24e:: with SMTP id t14mr28937903pgo.381.1642623680041; Wed, 19 Jan 2022 12:21:20 -0800 (PST) Received: from megumi-s.h.riat.re ([103.72.4.142]) by smtp.gmail.com with ESMTPSA id b4sm474346pfl.106.2022.01.19.12.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 12:21:19 -0800 (PST) From: Yanming Liu To: linux-hyperv@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Andrea Parri (Microsoft)" , Andres Beltran , Dexuan Cui , Wei Liu , Stephen Hemminger , Haiyang Zhang , "K. Y. Srinivasan" , Yanming Liu , Michael Kelley Subject: [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size Date: Thu, 20 Jan 2022 04:20:52 +0800 Message-Id: <20220119202052.3006981-1-yanminglr@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer") introduced a notion of maximum packet size in vmbus channel and used that size to initialize a buffer holding all incoming packet along with their vmbus packet header. hv_balloon uses the default maximum packet size VMBUS_DEFAULT_MAX_PKT_SIZE which matches its maximum message size, however vmbus_open expects this size to also include vmbus packet header. This leads to 4096 bytes dm_unballoon_request messages being truncated to 4080 bytes. When the driver tries to read next packet it starts from a wrong read_index, receives garbage and prints a lot of "Unhandled message: type: " in dmesg. Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for the header. Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer") Suggested-by: Michael Kelley (LINUX) Suggested-by: Andrea Parri (Microsoft) Signed-off-by: Yanming Liu --- The patch was "[PATCH v2] hv: account for packet descriptor in maximum packet size". As pointed out by Michael Kelley [1], other hv drivers already overallocate a lot, and hv_balloon is hopefully the only remaining affected driver. It's better to just fix hv_balloon. Patch summary is changed to reflect this new (much smaller) scope. [1] https://lore.kernel.org/linux-hyperv/CY4PR21MB1586D30C6CEC81EFC37A9848D7599@CY4PR21MB1586.namprd21.prod.outlook.com/ drivers/hv/hv_balloon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index ca873a3b98db..f2d05bff4245 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -1660,6 +1660,13 @@ static int balloon_connect_vsp(struct hv_device *dev) unsigned long t; int ret; + /* + * max_pkt_size should be large enough for one vmbus packet header plus + * our receive buffer size. Hyper-V sends messages up to + * HV_HYP_PAGE_SIZE bytes long on balloon channel. + */ + dev->channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2; + ret = vmbus_open(dev->channel, dm_ring_size, dm_ring_size, NULL, 0, balloon_onchannelcallback, dev); if (ret) -- 2.34.1