From nobody Sun Nov 24 08:29:17 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=quarantine dis=none) header.from=buaa.edu.cn ARC-Seal: i=1; a=rsa-sha256; t=1723644576; cv=none; d=zohomail.com; s=zohoarc; b=Dc6tt3yq6jZTldjpoB6CEztgQdsHoW/48+5Lm24ielmmux4YuCz4zoasOIjtcAkFc2pT8b+OmArXpgzPEK+cSu7y4ZLYKfCmNEieORSDRwyZG+ENs5xvpCvCoCwxG+MyE0xxYus9EC5hm3QS1FfzGgsoPDJ05wU61ms3xx3C5BA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723644576; 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=emLaVKASARpJE/jzq2vtaV8x0Qsgu6jmAqCVcMc0hAM=; b=OOQbm5AxaveZdiQ2JL5zUkBx+M6WwvAXioI0KzYHYfGUZVLYovse0gzTjBSnG6H6TJvBiR6d5TTiWzcJd8jTl7Sx57O+NoRnuzc73Q8DMSfCQtZ3aOUsmWfjciVJ8wifDEliv6VtRkVVUiRTCU2r+oQ+dmzgFovf0bTGXHogJqg= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1723644576254792.9515503118339; Wed, 14 Aug 2024 07:09:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1seEg2-0007aD-41; Wed, 14 Aug 2024 10:08:38 -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 1seEA8-0005nT-Ub for qemu-devel@nongnu.org; Wed, 14 Aug 2024 09:35:41 -0400 Received: from azure-sdnproxy.icoremail.net ([52.237.72.81]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1seEA5-0003s1-As for qemu-devel@nongnu.org; Wed, 14 Aug 2024 09:35:40 -0400 Received: from gp-VMware-Virtual-Platform.localdomain (unknown [139.227.253.190]) by coremail-app1 (Coremail) with SMTP id OCz+CgBXv7uZsrxmjP5bAA--.5830S2; Wed, 14 Aug 2024 21:35:23 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=buaa.edu.cn; s=buaa; h=Received:From:To:Cc:Subject:Date: Message-ID:MIME-Version:Content-Transfer-Encoding; bh=emLaVKASAR pJE/jzq2vtaV8x0Qsgu6jmAqCVcMc0hAM=; b=lpyHEmGxw8lLf0K3RxKWrkUvYI 93pXhJ61Ztr6Kv4bV8sV5df+VuLKdjG05Om7KdRabqw9OBjET893Q9BLHYSl4++7 cYf8ItcNq+SdmJoFebAVpZ9aI+MSqwwTZjqkKLO8OLmBU5QkbzwuMHpordfWO8qK 11RFxAHhY9CAJYWu4= From: peng guo To: jonathan.cameron@huawei.com, fan.ni@samsung.com Cc: qemu-devel@nongnu.org, peng guo Subject: [PATCH] hw/cxl: fixed the determination of illegal physical addresses Date: Wed, 14 Aug 2024 21:35:18 +0800 Message-ID: <20240814133518.23393-1-engguopeng@buaa.edu.cn> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: OCz+CgBXv7uZsrxmjP5bAA--.5830S2 X-Coremail-Antisp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ass (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=52.237.72.81; envelope-from=engguopeng@buaa.edu.cn; helo=azure-sdnproxy.icoremail.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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-Mailman-Approved-At: Wed, 14 Aug 2024 10:08:34 -0400 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 @buaa.edu.cn) X-ZM-MESSAGEID: 1723644579114116600 Content-Type: text/plain; charset="utf-8" When physical address range in the input payload of scan media command exceeds static_mem_size but does not exceed the sum of static and dynamic memory, the scan media mailbox command unexpectedly returns an invalid inpu= t. It is handled differently depending on whether dynamic memory is present or not.If dynamic memory exists, check whether the address range of the=20 request exceeds the range of static memory and dynamic memory.If dynamic=20 memory does not exist, then check whether the address range of the request=20 exceeds the static memory size. Fixes: d61cc5b6a8d3 ("hw/cxl: Add get scan media capabilities cmd support") Signed-off-by: peng guo --- hw/cxl/cxl-mailbox-utils.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 3ebbd32e10..b23c6b9b0b 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1943,11 +1943,12 @@ static CXLRetCode cmd_media_scan_media(const struct= cxl_cmd *cmd, } query_length =3D ldq_le_p(&in->length) * CXL_CACHE_LINE_SIZE; =20 - if (query_start + query_length > cxl_dstate->static_mem_size) { - return CXL_MBOX_INVALID_PA; - } - if (ct3d->dc.num_regions && query_start + query_length >=3D + if (ct3d->dc.num_regions) { + if (query_start + query_length >=3D cxl_dstate->static_mem_size + ct3d->dc.total_capacity) { + return CXL_MBOX_INVALID_PA; + } + } else if (query_start + query_length > cxl_dstate->static_mem_size) { return CXL_MBOX_INVALID_PA; } =20 --=20 2.43.0