From nobody Sat Nov 23 22:34:14 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=1728678693; cv=none; d=zohomail.com; s=zohoarc; b=ZS2wObCCshnDqMt0iLTyad1jts9ph2Q8FabAyQ/yEV6VDKHySeCGe47V9kbgaYc7rQpLI0KHVz7cjX3Z7Q/Y7kl2ChUFcg1kkO0dlYeauUiBahHF9RuWr9CtSOq2r6tK0h1EDV03/hXI/go+gXzuqYIyMv+f6A83Svse+Kd8mmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728678693; 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=Rz6vGoXtQ8OGPE036yHF1biqczt6VgPMUWgroJxMWJ8=; b=Vfhv4Tr1sv2V6zpdDAhqwjPmx7pgGcTaKpghnYDBXoibZOJZhVZmt/DVme/KX1SZSTN450fwxXgbDJqN7ViRaWF7kLMXIm1/gjaP8xuzMPhmErwhQL16a4F/BeLqGIlrX8TV/+ndDbe2xAwCeTk+4JSfShpKiy9UC7a9/zJ9Wmk= 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 1728678693216982.0681806369786; Fri, 11 Oct 2024 13:31:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szMHq-0008KB-Ox; Fri, 11 Oct 2024 16:30:58 -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 1szMHX-00089O-R9 for qemu-devel@nongnu.org; Fri, 11 Oct 2024 16:30:49 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1szMHW-0000na-62 for qemu-devel@nongnu.org; Fri, 11 Oct 2024 16:30:39 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-20bb39d97d1so22778115ad.2 for ; Fri, 11 Oct 2024 13:30:37 -0700 (PDT) Received: from fan.. ([2601:646:8f03:9fee:fa84:fdda:e412:45e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c312f49sm27345205ad.233.2024.10.11.13.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 13:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728678636; x=1729283436; 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=Rz6vGoXtQ8OGPE036yHF1biqczt6VgPMUWgroJxMWJ8=; b=JhzMvFiAv1OrypWPhelAqMxGrPCM7VSIEPq9CwexY8DbLjds3skAO10VqqtwvmRYhY CsPaem+QRI4lNtZFuwTINMC3942aF5VwpMQQubYyqUqqT8ITc6z8xD6gXie5K94N1MZg tOj46h0VJNUte5iY4xNnVoLbxC2jlwzjv8AysAMJ1O6uS1Y37lkZ4ANNC38WZIK3dKDt BNc+F/EssSm516SOvgPBgEp0QlyUepgxIWXcRWS93GFxQGjYUSE9fUeqrIwrMsE4ukdl fPqpTyEeJgk4LixmvLT86bjIQBnRCMVeLy5mzwxvYc3N+8uunoa5SLNWKpD8waunozvq 0kbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728678636; x=1729283436; 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=Rz6vGoXtQ8OGPE036yHF1biqczt6VgPMUWgroJxMWJ8=; b=ejEdpzfS9piaflAhQCweJg3AeOoUgP1SVgWPjJiqwxmJJvW4SH3e5oXy/wGZXGuXfO TLAKyq5czxLVunL4Z+TZuHQVZC9URLlvYeFpaHvUu1gUdqww7jqB3B+cZfEZpRW7OvuV fKbSE3Y0DTDNpJvaKnzIX1QvkNAQxyBdxTt8qAtEfdMA0B/U20SqLXfRmeAI7OkwOSme 7+Z/NfeZGVsOysOBQr57qcZ2yw5NHDMtYbpQ44Tm9FBPugm/JVXhukA7JejItYpWZEz/ XBmDswTwHfnTdp01oo7luP8WQeMU3fnLlmyo6MVjdJ4uI7bO5skAhS4miIAcV8lR1u2M l8gg== X-Gm-Message-State: AOJu0Yzdwa3X3b8WjCZHSTdzavRENorOz9n84T+7cR8kWYld/Nq1Qywb yct6oWjaJzZtBrK1BXJO7aiWsk6ZDlHhMxWttj1/VwPmXhIF5Q7pu6BrKA== X-Google-Smtp-Source: AGHT+IFuAwHAP0t7894mcawPGcyqy5qcL9EKa1mT3PbzMHJnT9sHJW+BxDiletBdOS9DigBb/ji5eQ== X-Received: by 2002:a17:902:e74b:b0:20c:8daf:8530 with SMTP id d9443c01a7336-20ca144a5femr60890855ad.7.1728678636358; Fri, 11 Oct 2024 13:30:36 -0700 (PDT) From: nifan.cxl@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, linux-cxl@vger.kernel.org, ira.weiny@intel.com, dan.j.williams@intel.com, a.manzanares@samsung.com, dave@stgolabs.net, nmtadam.samsung@gmail.com, nifan.cxl@gmail.com, Fan Ni Subject: [QEMU RFC] hw/mem/cxl_type3: add guard to avoid event log overflow during a DC extent add/release request Date: Fri, 11 Oct 2024 13:24:50 -0700 Message-ID: <20241011202929.11611-2-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::633; envelope-from=nifan.cxl@gmail.com; helo=mail-pl1-x633.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: 1728678695371116600 Content-Type: text/plain; charset="utf-8" From: Fan Ni One DC extent add/release request can take multiple DC extents. For each extent in the request, one DC event record will be generated and isnerted into the event log. All the event records for the request will be grouped with the More flag (see CXL spec r3.1, Table 8-168 and 8-170). If an overflow happens during the process, the yet-to-insert records will get lost, leaving the device in a situation where it notifies the host only part of the extents involved, and the host never surfacing the extents received and waiting for the remaining extents. Add a check in qmp_cxl_process_dynamic_capacity_prescriptive and ensure the event log does not overflow during the process. Currently we check the number of extents involved with the event overflow threshold, do we need to tight the check and compare with the remaining spot available in the event log? Signed-off-by: Fan Ni --- hw/cxl/cxl-events.c | 2 -- hw/mem/cxl_type3.c | 7 +++++++ include/hw/cxl/cxl_events.h | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index 12dee2e467..05d8aae627 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -16,8 +16,6 @@ #include "hw/cxl/cxl.h" #include "hw/cxl/cxl_events.h" =20 -/* Artificial limit on the number of events a log can hold */ -#define CXL_TEST_EVENT_OVERFLOW 8 =20 static void reset_overflow(CXLEventLog *log) { diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 3d7289fa84..32668df365 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -2015,6 +2015,13 @@ static void qmp_cxl_process_dynamic_capacity_prescri= ptive(const char *path, num_extents++; } =20 + if (num_extents > CXL_TEST_EVENT_OVERFLOW) { + error_setg(errp, + "at most %d extents allowed in one add/release request", + CXL_TEST_EVENT_OVERFLOW); + return; + } + /* Create extent list for event being passed to host */ i =3D 0; list =3D records; diff --git a/include/hw/cxl/cxl_events.h b/include/hw/cxl/cxl_events.h index 38cadaa0f3..2a6b57e3e6 100644 --- a/include/hw/cxl/cxl_events.h +++ b/include/hw/cxl/cxl_events.h @@ -12,6 +12,9 @@ =20 #include "qemu/uuid.h" =20 +/* Artificial limit on the number of events a log can hold */ +#define CXL_TEST_EVENT_OVERFLOW 8 + /* * CXL r3.1 section 8.2.9.2.2: Get Event Records (Opcode 0100h); Table 8-52 * --=20 2.43.0