From patchwork Mon Feb 12 07:37:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 772044 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp2108086wre; Mon, 12 Feb 2024 05:19:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXC8n5Si87GseMNuP2MMAVOzpzstVusF7w/r4zYTgAjXTXnHaQcpYtfZdMBVQwri0x5CU8ks/Nqf2JocNCtQHsv X-Google-Smtp-Source: AGHT+IF0bFDFRPsgrxZ5g6OlCjGJWQlQitNzLaTmSw+SIqds5gn8xmg6KkE9YDMMpNK7xEoD3ysi X-Received: by 2002:a2e:7d11:0:b0:2d0:b46a:1a65 with SMTP id y17-20020a2e7d11000000b002d0b46a1a65mr4360949ljc.20.1707743961368; Mon, 12 Feb 2024 05:19:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707743961; cv=none; d=google.com; s=arc-20160816; b=SfiBOJHfgcWIpwOP4zu93qj4Hw/PqZk65i+K7xQUmBc3yWL5MPyqD0rpdhvXlI+YgB r+AQSIXTwODIcFHfv9PKTDF0RaSqBxz3RJo+hxwFME6f1uVMdS4nwV3yjPcXLyPXVsvd knihBVgREX6UGe38pE/yz8vQFIqiU1R0DW3WeFp/aY41iHvy+5HkkJSPohH3/fF5xWbA EAayIPfGXUk6DACFZSQ8FKFwPlTUwXIyCYGzNee0LfUXq5f9RdA53Jbfi1rbhPLkZkC9 VsWyWVLyQTBtry4CPck7sPBz9Hylkw23j096LjcxPLJUvpwAfDLVJv6zTvCxXeLU0FqL piEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=YYzK2WBNMyfFeAQa2ns8DhDgZJmXnsGZWwxnrt+2OBU=; fh=/Ie0JXR3GiDVi3PX6SyPhO5mfCxOkXdGViNFZhW53Ug=; b=yFhIroFQSTOKKbjWU9Kpgu/UnzCEzsFp3lcNs1zArud7fbUxLvVG01rgG9KEqCYDHv jkvzhukc0rPHVKh93uCmmkzrIkBkuAZn6DXo/xdkm7rd/EGMgKHahmhDB8+7/8SnaPFd uNlGxzMtoiO85WuuWwpsIlDCISwIep0xOjsbU3dCy/lHTDzQ8sPDHy9ud9DIfPdcqDsK h5grzTxC8kSeMGnQnEJ9MCUgBgC4qMTW44Sat6Yzy4gFd/KYLYsgBFd0PBxeRD9e0CKH rnEUXT+RqxhmkG+cvhqc+WLZPRCIS9kFpd213CpWqdWi53gp9qccVICVAYec5BRNj5dq w7/Q==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yMvHc9GC; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=1; AJvYcCWLDMhzleTl1BgGknIuieKN6X8dIemnZRsTDvn3owOmDxR1HyhksWAI00RJcmOk83yaW0FlvW9W8rN016pyTMgERMO7iBGW8mJ1TTKV0GFT5ngT3+35PzYICLPnqj2ucrrtkw2sxrWFa/wZY5LIsB5yxfsHs4EJfro5Ac6golajhP2ZYZesNotvZRT5lCugrX5zBvaJr1VH4KzJTHCpoVOHxL43Ih2uQJmHB1MvLbm9ULGkheMQq3TJMSP0UaA6PUAEwanAII73AHkmeapL2f+Jn/BcJv+uK3stz3c1woc3QWYBp/r/h+vlAlPHHd2iC9WQn+TM6Isrfebqu1wcC05OanAlmQNrZseAwF/WCkcVrq9Bffz2NQXOiovD7A2wuapZLK3UyTyULUrRzFqE/v/aGPaqLVjPcg7l3UAYjTxyifhWW7jnwEd20Mx8FzzcIjaRm0LDIXI1R4EU2EyA0hPjiXtbr+l22wwQWrg0d3AM8Yh0TPIy1rqmL0iHsgFgAH1g3qmRxLA7TR4YSvVsXnVZ508jTE1WwAejphzyDhDn/nTKMrMitpQ34Oayfo/Mb/gs8JRXn3pCEWDAXRWPJDyk/F9Z7h4Wob3ctrTivz+ZX85P+MNLRfojWrLxHkKlysIKFwsQijmIGXWaWxWyELnkQkLLbPDIyWaHaauh+YuEwkN/LGUbUcsRkXu/jTrouJGASvpof9n0rI6VtwC313bt1EaOCpvX7o3CxRkL1siNi8ZGuuY51d8P2pjKjuZMOysuuVN0ABGXZfw5Un9SOr1nJEIrM7ao5AGFEV04zG9xX8w1vwojzxVg4I1+5KeOf0ZPoj4nxQQQloT39HF3l+tGJSkQb9DsSemKjKFfmrIMaJCx0pj8y2JZe75xtWNRRVQH8FJEyHTFaommYnJCnYi7PobZ/6YDXzaDXbubtsqXNKHjmh7ytgKRg7oqoMUeRmHYrn 6pAZJ22NMXkwwF/dx5S1aWfsO/fwt15hISc+w86fxDd78QqoqebqBzcovAqw== Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id d32-20020a056402402000b00561d9eb3b66si128451eda.150.2024.02.12.05.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:19:21 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yMvHc9GC; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5AF3987ECE; Mon, 12 Feb 2024 14:19:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="yMvHc9GC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A30987EBD; Mon, 12 Feb 2024 08:37:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BA43487C80 for ; Mon, 12 Feb 2024 08:37:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dmitry.baryshkov@linaro.org Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2cf206e4d56so39688451fa.3 for ; Sun, 11 Feb 2024 23:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707723429; x=1708328229; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=YYzK2WBNMyfFeAQa2ns8DhDgZJmXnsGZWwxnrt+2OBU=; b=yMvHc9GCbpACKpAIKqeThR7MwSnRtNS7/bF7XOrOaq4PctCiFKZ5ky87fFlRjuTPIc 6XhQt2e4kFpyab8wHZj9pxebRNIqIER0klP/zbIWiag/GCG74rVvao1H/ym1LbH8rqha i/iQTk0rWQjn+P42t+QjYFDLDSWkvpXLFxTW7Uw6aZLrMfPaawyBGoEvWLsl65uqRZjs jU8+wEt7nKusWYC2A8JAL0SGPdrDp7VqngH/wl+O/BnMRwavZMuwOMYGPFkqk45vr8cY uAaPaSwhoShORE3e6e92OhlTdvYk/UN7I0NJWmu7wpRoND29qvd3JRjRAQPq4dv1xkYp XLsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707723429; x=1708328229; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YYzK2WBNMyfFeAQa2ns8DhDgZJmXnsGZWwxnrt+2OBU=; b=sGGvBa8El7F0nXvsDbxm7PvAu4Z+2OCU8zojW84ilou+9EX+GbT/v6KdDNf8r6kHXt 8hflrSHHk8WiYBGohQzyGTJLnzB05TUQEQ8V/LXEY2ASI4dBsNyUOkxe3G2XDzvKfvwv FwMRXMAGAGzGV4+JYXa9QNpCpXzYf4TwCUKe5tBguM4chjTaPvTkOgUKvl0A456cSXEc onN9Xs2LNOL7+hDCvsG6te9Ykz3y33z1a1O6WB24NItiHn4tnV53hqHcEp6upEaNsVh8 ti0WvlFidaf7EZ2vl/zAh7FHtOaEDD3epxwBCpALAsVVgu9XTUXpjWxlvFSZhXFvuOrk GEfw== X-Gm-Message-State: AOJu0YzntfhbSumRpUVa3w3jSq8K36X+C99aNdYpsBlYYsTItziLQrwO pV+75b+Xx8QlJRh1jR1DPzmnWePio40z3F023fVqRU+DJITt64et3KkcyKAGetnIMr7dABiErKp n X-Received: by 2002:a2e:8216:0:b0:2d0:cce1:f0a8 with SMTP id w22-20020a2e8216000000b002d0cce1f0a8mr3621768ljg.1.1707723428853; Sun, 11 Feb 2024 23:37:08 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVpmYGMEgTSrbDQIHY59sv4wF/AMJuWkTPI8wboNQWvbOaoSV0e1VsSke70gXc9/pwCwcgK/YcgjXBj1rmTvp2h4Bs= Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id n10-20020a05651c000a00b002d0cd6bfd62sm1310552lja.136.2024.02.11.23.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 23:37:08 -0800 (PST) From: Dmitry Baryshkov To: u-boot@lists.denx.de, Bin Meng Subject: [PATCH] virtio: fix get_config / set_config for legacy VirtIO targets Date: Mon, 12 Feb 2024 09:37:08 +0200 Message-Id: <20240212073708.4161197-1-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 12 Feb 2024 14:19:09 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The functions virtio_pci_get_config() and virtio_pci_set_config() don't take the offset into account when reading the config space. For example this manifests when U-Boot tries to read the MAC address of the VirtIO networking device. It reads 6 equa bytes instead of the proper addess. Fix those functions by taking the offset in the config space into account. Fixes: 4135e10732a0 ("virtio: Add virtio over pci transport driver") Signed-off-by: Dmitry Baryshkov --- drivers/virtio/virtio_pci_legacy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c index cf5dfb17a94d..aa89604ae84d 100644 --- a/drivers/virtio/virtio_pci_legacy.c +++ b/drivers/virtio/virtio_pci_legacy.c @@ -107,7 +107,7 @@ static int virtio_pci_get_config(struct udevice *udev, unsigned int offset, int i; for (i = 0; i < len; i++) - ptr[i] = ioread8(ioaddr + i); + ptr[i] = ioread8(ioaddr + offset + i); return 0; } @@ -121,7 +121,7 @@ static int virtio_pci_set_config(struct udevice *udev, unsigned int offset, int i; for (i = 0; i < len; i++) - iowrite8(ptr[i], ioaddr + i); + iowrite8(ptr[i], ioaddr + offset + i); return 0; }