From patchwork Fri Nov 1 13:20:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13859355 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 A5DE4175B1 for ; Fri, 1 Nov 2024 13:20:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730467244; cv=none; b=mWVSf0C/BZ3ROeK/GBERjsxq+sj29Z2tZIUCTnSlDcBPJDdJjJ0mFLjyKLXJyrc25fMjDwicM9iA48hKTGBNg6CU9qzWwTEx4Ykcz9uBgk4WBKBd9JPgIEf568/OVJfrkZySazjZlGfVaKfGoHu/Le+eoiteqMn507gREphmuKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730467244; c=relaxed/simple; bh=mDPTTDGcZN3w6bEegimMtNX73MN6RCDSorwA0tQfKgk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BrJkyJZ9PbqT9wzivQkMR53X9VXwlrwbqDjR1R7WXFVP1+mUb8xiGHbDKN/tsvDUlMtGNZAkfIJ/jQg2Og2WKiAKLNHuK9yF8bwEkHGYd+qVFlTvCJwJPrCDqBsMhUnQK+fDScrfxFRFLgoD89jEMpY7eN/gYmTgvzgwb87BuEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Xg1dB4k3nz6K6Vb; Fri, 1 Nov 2024 21:18:06 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 2CA3C1400D3; Fri, 1 Nov 2024 21:20:38 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.19.247) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 1 Nov 2024 14:20:37 +0100 From: Jonathan Cameron To: , , CC: Fan Ni , Subject: [PATCH qemu 1/2] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info Date: Fri, 1 Nov 2024 13:20:04 +0000 Message-ID: <20241101132005.26633-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101132005.26633-1-Jonathan.Cameron@huawei.com> References: <20241101132005.26633-1-Jonathan.Cameron@huawei.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: lhrpeml100012.china.huawei.com (7.191.174.184) To frapeml500008.china.huawei.com (7.182.85.71) 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 Signed-off-by: Jonathan Cameron --- 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 5f63099724..8bb0d2dd29 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 struct cxl_cmd *cmd, } QEMU_PACKED *fw_info; QEMU_BUILD_BUG_ON(sizeof(*fw_info) != 0x50); - 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; }