From nobody Sun Dec 22 05:53:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1707725289; cv=none; d=zohomail.com; s=zohoarc; b=kl3G2KEhmxA4X9T0ggDdKHRAQIjdne97rfY780tfVfIDbD1TC3H7yjfBq03SujkXiHxN1LBX18sPcwJI6oA/UXWtf41320gKGQAeijgWBm+RQ33XbxeweGNIJcDsOpbV4YS2dJLcfHKKJya2PDkpsyHsIwFpFlLwggq3IKvmvk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707725289; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ew/3DuAeSXfD+s12gqctkm5cvqR42b2Xn6oAkbLXiwg=; b=X2jCQVOuwJPuw2zVgI+mJDgcIZLHB696VwYifU5vZbZTtmfwtelPisbEY+PzWvLDsiwxg8F9A7FvrUKq/MA+LFYr5ZuIprSBJUFe4ffiRSi498NMTNPhXLiUngyq8eqlR0sU3oE4P2YkJXZMY5weKjNHuaPp/PzpGJ7So8gYrrU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707725289509162.40862941871126; Mon, 12 Feb 2024 00:08:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZRL5-0000ry-77; Mon, 12 Feb 2024 03:06:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZRL2-0000qg-KE for qemu-devel@nongnu.org; Mon, 12 Feb 2024 03:06:52 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZRL1-00081g-3E for qemu-devel@nongnu.org; Mon, 12 Feb 2024 03:06:52 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d73066880eso27078245ad.3 for ; Mon, 12 Feb 2024 00:06:50 -0800 (PST) Received: from mnissler.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id s13-20020a17090330cd00b001d9fc53514esm5404649plc.66.2024.02.12.00.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 00:06:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1707725209; x=1708330009; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ew/3DuAeSXfD+s12gqctkm5cvqR42b2Xn6oAkbLXiwg=; b=O8YDie9T30EmyJKAqjXx3YFGMuyQTF715nG6kcheH6U5PpIkHnNZBsENyL7RAtNmAb ncbmcTzCm3/u8hkmCHWHW4Plr2hBBOGCCkvTXYd398V5tRmPSoAserDXZwnivJwGZXGg n3mTSKQR/gmWre3rap6T3dCXFXodUokze97AeyOVV2hOhl1evXaYnWNQyammQcZasjaA TmGsW1ay8Q+wQrRgHR2upWZCfh9+9w1VbVcXkVytOsAtP1fjGaOEWqzQessNtq9QPT3a SNMjMtZ5ta+aipISvMR/uuAAy0PqrM/nD0PsiuY7hWb2WFPOBM1zAvAfMw9nFKmyxGGn n+Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707725209; x=1708330009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ew/3DuAeSXfD+s12gqctkm5cvqR42b2Xn6oAkbLXiwg=; b=Nb6P8eHPTLj+rZHglNrtHNWnfgref+KXWLguVt+YHWpf92HLUDyuq6PHGf/eclvrxT 9JtOEtDiRqG0+BJPcv+wl/NNsd3Qc/IUVuaMQB1a1Vj9vQ+5cZLu2/Pd0Y2TRcpo4Q0V 3yCeHdu3z7DGoIiZTv6/RtV7cuBFLh1rqhC6UARgAz2SB1IksMpDUhnV6L+5grT6OqJh AQAHh2qBvb7r61kW9IGOs4oEl8/DlKzNmpsnsnbJmjZF5Wwmw80Gya7kqnSFBl1ry/3n bw3794Q0h3N4esvp7yDjTrH6p80v009IjujTE9S3aRn2xcsRnDzIoYjNQhs+rQdqkgU4 grDg== X-Gm-Message-State: AOJu0YwWh/NEM43kAIURAPn19qFci8AuEjW2d4H12aDQ19r8RTt0ut9d kLFEB82NNur111orsCbcXdRb5MV03TXDDWqebSEBgp8lNvzf4obvw5Ltd4eZO87+TW/4zX+HZQM N0E4= X-Google-Smtp-Source: AGHT+IEl4hd5nYeWoOW0rQZJxOwWUxhImiEnWmaqZxHWAiwQtzSYK62NTyYjl9fPi1aUz9dLoN1ogA== X-Received: by 2002:a17:902:e80e:b0:1da:1780:8b49 with SMTP id u14-20020a170902e80e00b001da17808b49mr8297253plg.0.1707725209681; Mon, 12 Feb 2024 00:06:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUcieEq3f6eopbH00fxz5JHZU/cQ9I/IW/F5couJmVwRVbZaETUUVIYbGkVYF69XE4+iswUdQUiSvuI0dY4jGNjkuTW7RbyetOlbxeEhMacKFHJdfSKh0Ya7j9yMaUuv5JEVbQ/W6U8fiszJLqo5ZSaD/seE9Gp5Z51fnNIZp0jbuP4QO2BZ9EO7CWiZ11SGmsXV4fnTLffXRryMiqzzashscStZ2fzw3tvIjE1ctrAOQe9+wHwfpxWpSViFrZmQZlghq46zBPOgZ6XtPoz7a6HWMrBSif/+0HRASRtzP4gRcFSoXIl6VgqL6jeXc9AmbdhJzlACSTx4Mb9ojKfWXncI29hHbS/mx93CLZWuUDDYNmxnamFyPS//CuTcFCHDg== From: Mattias Nissler To: qemu-devel@nongnu.org, jag.raman@oracle.com, peterx@redhat.com, stefanha@redhat.com Cc: Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , john.levon@nutanix.com, David Hildenbrand , Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , Elena Ufimtseva , Mattias Nissler Subject: [PATCH v7 5/5] vfio-user: Fix config space access byte order Date: Mon, 12 Feb 2024 00:06:17 -0800 Message-Id: <20240212080617.2559498-6-mnissler@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240212080617.2559498-1-mnissler@rivosinc.com> References: <20240212080617.2559498-1-mnissler@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=mnissler@rivosinc.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707725290396100007 Content-Type: text/plain; charset="utf-8" PCI config space is little-endian, so on a big-endian host we need to perform byte swaps for values as they are passed to and received from the generic PCI config space access machinery. Signed-off-by: Mattias Nissler --- hw/remote/vfio-user-obj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c index a15e291c9a..0e93d7a7b4 100644 --- a/hw/remote/vfio-user-obj.c +++ b/hw/remote/vfio-user-obj.c @@ -281,7 +281,7 @@ static ssize_t vfu_object_cfg_access(vfu_ctx_t *vfu_ctx= , char * const buf, while (bytes > 0) { len =3D (bytes > pci_access_width) ? pci_access_width : bytes; if (is_write) { - memcpy(&val, ptr, len); + val =3D ldn_le_p(ptr, len); pci_host_config_write_common(o->pci_dev, offset, pci_config_size(o->pci_dev), val, len); @@ -289,7 +289,7 @@ static ssize_t vfu_object_cfg_access(vfu_ctx_t *vfu_ctx= , char * const buf, } else { val =3D pci_host_config_read_common(o->pci_dev, offset, pci_config_size(o->pci_dev),= len); - memcpy(ptr, &val, len); + stn_le_p(ptr, len, val); trace_vfu_cfg_read(offset, val); } offset +=3D len; --=20 2.34.1