From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AB9D32F757 for ; Thu, 26 Mar 2026 22:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774562619; cv=none; b=r/CSGGjgnLVBScpKIXmMyLxKpCicKQcuw97eWDw9uiM+FATkbEh2OdMGg3CuzLzqWYEiaSOWH81zzFviKmLBNqs0G89ZM5WW7NIQjvFGlCDSEcJadsuVGD0RHCMPVgFXlPM9QkAdpQelRHJWzQNf7DucOQtzl9ZDZDUpSJO/oRE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774562619; c=relaxed/simple; bh=/0I5PlNTDmo42F78lIX7rXVUcj3Vn1T+pJs/PmebPl4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YCtKRMr9j9mAxA+njbVkkOSLG5UCK2SDQxj/nrfPeDqyuUJb7pkdqPAPK9ttFIOKEGIe6954P9HTofAwllQ+gBrEO3AXMmKWOkqxi2v3Xp6oXs/CF/J0JeEoGu6vIBmT6H47dfooC5dWIuB3zbmLQYghsQpkQ/u4n3kDyUcm3z8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HheJeDSZ; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=eiPjsoJz; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HheJeDSZ"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="eiPjsoJz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774562617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Lpgob1tvHT4IKRz9W+hPWJKbEluQbBFuXgVxhpqe0s0=; b=HheJeDSZXc+D2HUtSd8Ne+tBU418qwkpfwGl5vY29faBCl10gqqdA3rbsG87WwS9Ef50PI 5n3ZFahDU6x9KhqFl1x7OASUwTCYsk45NDP7nc2NmJky/1SiBTokdg+a8fxSZH+nnOpX8b 0iWFGrTdHIXiyQi47kW6ywaQnJqIhuQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-4Zroaa9rMJCIBepVCKDDPw-1; Thu, 26 Mar 2026 18:03:34 -0400 X-MC-Unique: 4Zroaa9rMJCIBepVCKDDPw-1 X-Mimecast-MFC-AGG-ID: 4Zroaa9rMJCIBepVCKDDPw_1774562614 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4852ccff333so12987985e9.2 for ; Thu, 26 Mar 2026 15:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1774562613; x=1775167413; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Lpgob1tvHT4IKRz9W+hPWJKbEluQbBFuXgVxhpqe0s0=; b=eiPjsoJz10dXgxEAcpTuDqkDtqydJOTYGojrrxbVhxYA0GcO12tv70RlsMbeWavyvs wE7k8Pvrq/4CJagj9Wmt+KO8n1ZGCNNM6LrqoxiweOqf9a+3yyQyw72sU95EmiEN8Oz1 WLGHBUBUBZuJJ05cxVdYhZWM89XueTwqnbmLmqhfrlq0JfohgYb2DnlosWotj6YfUrWK TZsMi5I7AYxzQsVi9ug32CUIaeLakfh2U/TKBUvPi8ILfUW1ktDqnvPjTXxDQf4aJXMS oAptCpjHe9/YGN6sMcbKo2+MEqJHB5bhwYOzYaJF75fgffd8NU3kf1oNNYbTrnuAc8bw 1FDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774562613; x=1775167413; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lpgob1tvHT4IKRz9W+hPWJKbEluQbBFuXgVxhpqe0s0=; b=MqOiAZk8jOwK3GOWoV5yt3VxOYECrUc9DUriNhYwhND/DAzdSEiAaWF3zFr+mdot7U 9kurysgL70ZkaRRDUinQYJ82x7Mw9emUbguBc5CNBopDx3xKSdS2cVC3MdOL+hIjcrVq TCMh6pec/6EdQiDycyqWT6dyXFBfUZ5H22gr457hz8kDM6CbPhz1OMUfxfUq/N0WNoaK 8xMHl3tHRn8gEnWMxqxNI7/7Vkz6GkbinOL9yxed2uR24VbZt+9/ZjGDm+ZZb6dtt3f1 t9RW/coNg5LQguA0KcdZdwYm9qSdJhRCo2lzGfvYdJ+OqEl+K0u85IoBt/8HQkdQpIo9 Ot5w== X-Gm-Message-State: AOJu0Yya1Vbja1HmywwKZPeiP/auEulIwb4nKzFdrfdb05ZbLa+QO49I McH3yoFSwmDZE+dUuFBL326bKMSDO2/AwiyV1ogtr2mIC7TTIK1EJuwA8euAhqQDy0aty0ltrOj KikPlB+CgrPy5DzGDhopRhjTZqh/AZPlx1eIGXrYl58lbd3qrAOVpTxqyHinVS7jbXg== X-Gm-Gg: ATEYQzxRpxJmm3Q6sxY7r69yHgrfz0ynysYG2R2Ch2tcCIu7SpXMz5x+QZYYzUFzChm yyseLKM4OzqCjNAGzedLdwZYOlMmjttr2j2LCK8vM7MaSDVdEsn7wHsiavv80qsI57ifVEF+W23 GomJiK9pBNqT+8nIE6cjFNAkSTstZjUiUC4b0VzfWzlypjPiO7KlbO5cKyh9km5UzU8N1/TD+FM CBl3WDQ7FlFeQ3XmOg081Tfcj+8ntnQXk70saY3Rt5TVuZopK0mEET8lHqGbtSZEiHCgeE94G9i inRNO83RKt/MrFewcR9PwLbYy7LKiTUx/FX0loU9N8Y/j6YCeTKWaEWjlw0OUz9UdppsVEWUMGy 4AM/NjE5+C0KSLGL4 X-Received: by 2002:a05:600c:3d87:b0:487:1114:d42f with SMTP id 5b1f17b1804b1-48727d59da0mr4643825e9.1.1774562613593; Thu, 26 Mar 2026 15:03:33 -0700 (PDT) X-Received: by 2002:a05:600c:3d87:b0:487:1114:d42f with SMTP id 5b1f17b1804b1-48727d59da0mr4643465e9.1.1774562613107; Thu, 26 Mar 2026 15:03:33 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1525:da00:3ac2:1a22:72ff:4256]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48722c9f58fsm90811505e9.11.2026.03.26.15.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 15:03:32 -0700 (PDT) Date: Thu, 26 Mar 2026 18:03:28 -0400 From: "Michael S. Tsirkin" To: Simon Horman Cc: linux-kernel@vger.kernel.org, Omar Elghoul , Srikanth Aithal , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Vishwanath Seshagiri , netdev@vger.kernel.org, virtualization@lists.linux.dev, bpf@vger.kernel.org Subject: Re: [PATCH net-next] virtio_net: sync RX buffer before reading the header Message-ID: <20260326180313-mutt-send-email-mst@kernel.org> References: <20260326181736.GV111839@horms.kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260326181736.GV111839@horms.kernel.org> On Thu, Mar 26, 2026 at 06:17:36PM +0000, Simon Horman wrote: > On Tue, Mar 24, 2026 at 11:15:54AM -0400, Michael S. Tsirkin wrote: > > receive_buf() reads the virtio header through buf before > > page_pool_dma_sync_for_cpu() runs in receive_small() or > > receive_mergeable(). The header buffer is thus unsynchronized at the > > point where flags and, for mergeable buffers, num_buffers are consumed. > > > > Omar Elghoul reported that on s390x Secure Execution this showed up as > > greatly reduced virtio-net performance together with "bad gso" and > > "bad csum" messages in dmesg. This is because with SE sync actually > > copies data, so the header is uninitialized. > > > > Move the sync into receive_buf() so the > > header is synchronized before any access through buf. > > > > Tool use: Cursor with GPT-5.4 drafted the initial code move from prompt: > > "in drivers/net/virtio_net.c, move page_pool_dma_sync_for_cpu on receive > > path to before memory is accessed through buf". > > The result and the commit log were reviewed and edited manually. > > > > Fixes: 168b61da6871 ("virtio_net: add page_pool support for buffer allocation") > > Hi Michael, > > The hash for a patch with that subject in net-next appears to be 24fbd3967f3f. Thanks, will fix in the next version. > > Reported-by: Omar Elghoul > > Tested-by: Srikanth Aithal > > Tested-by: Omar Elghoul > > Link: https://lore.kernel.org/r/20260323150136.14452-1-oelghoul@linux.ibm.com > > Signed-off-by: Michael S. Tsirkin > > ...