From nobody Wed Nov 27 14:36:58 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=1698844664; cv=none; d=zohomail.com; s=zohoarc; b=NLQQ9irOt2NM9SpWpwZZHpy7mI2TbOfPclV+ZEOsO+Epoe1bl7Dgruzp1/210aPbFxMLLpYuW+EwIDN/xJZZb7yKa0t3Siu6C+BYV7AwU0B9oThhl6XdpGHyDA4qucNJNeyAH51EoPv0O0gQajiOmgCQTMBkBe2SnMfJDDNkPmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698844664; 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=lFF+xz1moS0zKHI0k5mkW8skLO8foQZJd4bTPswPJb4=; b=b+xlIO4Rgzl0ZnNwPjUsztCOIWJ4rvVyH69XheVad+s8vHTcN2+JuJh29VSziJZwTrbWdHhmTZa23K0Gs38Tj39jtCoZpuO5WzK+rzXEEdfP+6cJ020VgsQZ7Ics4GTmTC5NRT1FWMandjaMnkSrnHwCT4b396HOKSVeZGhf7zc= 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 1698844664299159.6676110355486; Wed, 1 Nov 2023 06:17:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyB5T-0000IU-Q7; Wed, 01 Nov 2023 09:16:47 -0400 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 1qyB5I-0000HP-Ef for qemu-devel@nongnu.org; Wed, 01 Nov 2023 09:16:38 -0400 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyB5F-0003dl-TK for qemu-devel@nongnu.org; Wed, 01 Nov 2023 09:16:35 -0400 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1ea82246069so4327607fac.3 for ; Wed, 01 Nov 2023 06:16:33 -0700 (PDT) Received: from mnissler.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id y6-20020a056870e3c600b001d4d8efa7f9sm238148oad.4.2023.11.01.06.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 06:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1698844593; x=1699449393; 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=lFF+xz1moS0zKHI0k5mkW8skLO8foQZJd4bTPswPJb4=; b=v0xO01kQPc1YETflmiX9dyr/+2eH37vK04DYWpTgcuh/aWc4+zqS9yYVdMpOQgb2wj SjvyFGqi6ViJfq1nGADwwLt2pOuK56YCyEhvg/A3EyyEoE9YeVd8T7iKJaBcceI7VNuH Oh+QlZ2m7tFDrO1pM9wwopXJTSwxMAhYucsxll1Lsl/kmPlp96jXGjowsPSaIb9uN8xy xzwc2RQ4t+kkGcAHY6S2fHh7iIem6y5bxxg3w1rGb5rYymjEX0czTOCNwQCRYSlK31e+ 5/MzdG3ma/LXm4Cf5zsrK6ZksfVoHfOpeP7oiLg2+cG6mgsRbUWB/G/QDOZ3zAjRzFnp V9uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698844593; x=1699449393; 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=lFF+xz1moS0zKHI0k5mkW8skLO8foQZJd4bTPswPJb4=; b=rHno3A10K/bY19XIYxVAL78bObn0O7mVT8irN8V9gg8ZOwtRr3mANQ9SMXZaRVYRXk V27uJLRa0mbVLxQ4jOei/f0nSPwDf2YwzOW0BVhjHh997ZJbDHnFSqfJEDOPSV7gQhTA IsL7A/JGnrcmT3IcCT//2MLdsra1sMhwVMXh6Q9tmkrya3dHNSIk5gK/dfv1WZkEqJ/f jf4bsp1qlu5/w7zGPHanl3rUmpBJiKC0rjVCjMZKsiR1gsPJJaIOAX7ZRN2oY0EKp3gn Ei03XhvAz4777VW6JA2BhfsEucg9Vg99uoOyASqc9OSVJ7tcf5aFn+ddW4au+XKrDeG8 8nag== X-Gm-Message-State: AOJu0YyOs9HQFwvIHB41+N6Th7szu2rN7thMk7B4SFdqxUAq3fquLNYf vG8oS5Ouw+f3K0SYSo332+mT6A== X-Google-Smtp-Source: AGHT+IGAEwmbBU+noDaEflmAuWhFDJ9kbaPWu1NsDUtoclcAcxDU1Z0Wg7ARq94m/WMDhlxJ0aps6w== X-Received: by 2002:a05:6870:4202:b0:1ea:7bd1:c48d with SMTP id u2-20020a056870420200b001ea7bd1c48dmr21140574oac.49.1698844592343; Wed, 01 Nov 2023 06:16:32 -0700 (PDT) From: Mattias Nissler To: stefanha@redhat.com, jag.raman@oracle.com, qemu-devel@nongnu.org, peterx@redhat.com Cc: john.levon@nutanix.com, David Hildenbrand , Marcel Apfelbaum , Paolo Bonzini , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Elena Ufimtseva , Richard Henderson , Mattias Nissler Subject: [PATCH v6 5/5] vfio-user: Fix config space access byte order Date: Wed, 1 Nov 2023 06:16:11 -0700 Message-Id: <20231101131611.775299-6-mnissler@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231101131611.775299-1-mnissler@rivosinc.com> References: <20231101131611.775299-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=2001:4860:4864:20::35; envelope-from=mnissler@rivosinc.com; helo=mail-oa1-x35.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: 1698844665556100001 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 Reviewed-by: Jagannathan Raman --- 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 9f5e385668..46a2036bd1 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