From nobody Sat Nov 23 22:52:46 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1728406057; cv=none; d=zohomail.com; s=zohoarc; b=NMeMb6700Q/qhKvvOQpua7yCy2hNTKe3x0D+HTJMvtIoMtVn4a4CJp+Ne1YEIKbsE4yYEVeMEwP/F64JymgiWCMA7QH2uJEV8EHAkcsfcDM54h4UfjLyZm53T/tfwazdDj8Bvr1ZzuIxLAASpcfY2+KSxaRNINL0q0S6bbs835A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728406057; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VZ6DCcUZIpjkjbo+HdIBkZWSoiW8VwPF5vcnXRm5F/c=; b=Got9M9rMb5okzpRayva+nsF/PCJwDE4tpHDXtGCmKnyTHDwl6WM+5dRTAj1BNaE1vaMpEmVjxfWltmzxiL5nSAZNrLXUFSW2JW93S5jtURjg0448FTZeeMzLzHhwDiyngCmjYeZs+R605aTyGn4IW2f6m7t65fOwO9N5D8Fyzu8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728406057925929.778587583235; Tue, 8 Oct 2024 09:47:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1syDMK-00037q-Oe; Tue, 08 Oct 2024 12:46:52 -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 1syDMJ-00037f-CD for qemu-devel@nongnu.org; Tue, 08 Oct 2024 12:46:51 -0400 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1syDMH-00036H-J0 for qemu-devel@nongnu.org; Tue, 08 Oct 2024 12:46:50 -0400 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-6e129c01b04so47389687b3.1 for ; Tue, 08 Oct 2024 09:46:47 -0700 (PDT) Received: from fan.. ([50.205.20.42]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e2d9387db8sm14978437b3.59.2024.10.08.09.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 09:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728406006; x=1729010806; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VZ6DCcUZIpjkjbo+HdIBkZWSoiW8VwPF5vcnXRm5F/c=; b=LKHGJKPD3V1+JKK7RczKP01Ob+2VKCbqsxuh8eDSXj40Q7NnHFycBaq3DSoCSMJR1j tTBFCz7q9Zr0JFnmofDqTOEjpxkxIDf6DBdVGzl2Sz50knwjh8cGTvkakNi5eUf4m5yY RDPXcZ1iOGrSIr0yKFf7InOETZtvwIk72aDXlkNy/1UEMootZl+zmbTD4SIYVTzH/RvA 76ww4Q/d35ybPLSBCqSGp55WgQ0sRNQ1il17QS0O0sZUtjQfCz3gzSa2oiHLe7T/9MLo dWlZZDrTY68fL06u1lNwVV5zp84yQDXzcZ+/arIfz6TEcCGmsC7EzBcoXE7g6Yr01uAr Jb0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728406006; x=1729010806; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VZ6DCcUZIpjkjbo+HdIBkZWSoiW8VwPF5vcnXRm5F/c=; b=WE4EpTP1PanqEmRhlLSl24cGewnTwNy9DRxEJNrPtOMHzd0B//f2dEfaC7rVV2lXK6 smPaa8zgEx7vV3GAjMSeRoFK6AlhGFzR0tl2Tmkrq9yOqTUhVcRifEiG/U+9Xe7qGF9N rMa8NptRiraidiz60HCkEPaBWqPlRBHSOqqegLpMY91eBVV1NtvJvE3j0qbeGX/84K8C 0DTB8b2UrcRnYQc+siC/PyF/PPbPmyssAn6xGX9oCUOd2oyYqubhrJ/i1Q2XHOecYfT8 ZNhpwbJALTfXX2ODFZsOBZMlWxXmHloefLHVQg56hRQBvE4L3AygdgE61T932N6IO41P hB8g== X-Gm-Message-State: AOJu0YwJ2g8mwgPqxOxzN94t8HBoALXRAXsr67bkmtd/2svTKqPczd5q s1rOHKPZUtVxiYdff5uqhlGgMpSuv1aDLNHHTvH/q0I0YEWrCLbF11JLAA== X-Google-Smtp-Source: AGHT+IHIAkPgWXq889nUNPQVkfBDdMNYDtX2A5WPUAZtxx3p+5qTBrz4vYbkueDHvb3dy+IAHwcXnA== X-Received: by 2002:a05:690c:2d03:b0:6b1:61e0:5359 with SMTP id 00721157ae682-6e2c723f257mr103013247b3.21.1728406006535; Tue, 08 Oct 2024 09:46:46 -0700 (PDT) From: nifan.cxl@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, linux-cxl@vger.kernel.org, a.manzanares@samsung.com, dave@stgolabs.net, nmtadam.samsung@gmail.com, abhi.n@samsung.com, alok.rathore@samsung.com, Fan Ni Subject: [QEMU PATCH] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info Date: Tue, 8 Oct 2024 09:44:47 -0700 Message-ID: <20241008164624.78608-1-nifan.cxl@gmail.com> X-Mailer: git-send-email 2.43.0 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::112f; envelope-from=nifan.cxl@gmail.com; helo=mail-yw1-x112f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @gmail.com) X-ZM-MESSAGEID: 1728406058787116600 Content-Type: text/plain; charset="utf-8" From: Fan Ni In the function cmd_firmware_update_get_info for handling Get FW info command (0x0200h), the vmem, pmem and DC capacity size check were incorrect. The size should be aligned to 256MiB, not smaller than 256MiB. Signed-off-by: Fan Ni Reviewed-by: Davidlohr Bueso --- hw/cxl/cxl-mailbox-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 9258e48f95..c82ad50ac8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -649,9 +649,9 @@ static CXLRetCode cmd_firmware_update_get_info(const st= ruct cxl_cmd *cmd, } QEMU_PACKED *fw_info; QEMU_BUILD_BUG_ON(sizeof(*fw_info) !=3D 0x50); =20 - if ((cxl_dstate->vmem_size < CXL_CAPACITY_MULTIPLIER) || - (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER) || - (ct3d->dc.total_capacity < CXL_CAPACITY_MULTIPLIER)) { + if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER))= || + (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER))= || + (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER= ))) { return CXL_MBOX_INTERNAL_ERROR; } =20 --=20 2.43.0