From patchwork Mon Jul 8 06:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=WhDZgAtL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZhp6KP2z1xpd for ; Mon, 8 Jul 2024 16:58:34 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiIA-0008CA-FV; Mon, 08 Jul 2024 02:56:06 -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 1sQiI9-00086T-6v for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:05 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiI5-0001nX-7o for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:03 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2bfdae7997aso1927320a91.2 for ; Sun, 07 Jul 2024 23:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421757; x=1721026557; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=UaPFfT+leH++H8fthM/ZJoF5CcBN0CIUxVYvtNppWVI=; b=WhDZgAtLwWpxEHvOGGTGFrjYr+Bgfpn//cXtdQ4SA9e96qoFSUs02GvvRJtW75p1LV 0SwDbPGDrbhyXCGBApQVF1yLpOUaJeU035K7H1HJBT3Dv+2/Wt4LmRDE+JGXL5KJJt1B 5fMd9dMXJ0ToEMAVHYLbPEHnUSkgsUj4IyAi3MDOylTlIKM+66+2+Lcrc4yPLVZQayDF 3A+r2ghJOjwLKdLIXlgfcd2Qdkwb8ZIHdahYpnSI/AAscWSnx+OHKPmt5LLgD++E5uDs eALMxs2nhCURTMvSHfwqRlnD6qPyD0cPJTRqWGhdvW0iEAIUNZoaVTfPh0GUkj/06zZ9 BArg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421757; x=1721026557; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UaPFfT+leH++H8fthM/ZJoF5CcBN0CIUxVYvtNppWVI=; b=frEhuw1VeSKOrg7DAbe1OXPCOphTmOOZiBCBir4aD3thArx5VTisuGD+xz31U1Q3uA St6M2gNNl3Uo6YpOPpkLv3/HUwx3mPWB6HsIiqfGpPl9eopbvrcNRtOWbKQIM7Spx0OX /nPKD2NUVlpbfRNRdhslMeZszgJ8UBFcrEMlLt0eirBJGQ45WZr92zW/oLnngIojxwYH vxyEFGN0I9YPodfLge2Q4GnX1mkyl3CXdEz3Q6q/+zRUSpROOU7ZWFmmDOPJHC6D+rUR qzVLqBaNy+T1I9Y8gWxIUXF7bG01x4mUB85W+FHFtJyk2IKvvM5RqnNM5podqkfYi4a1 uubw== X-Forwarded-Encrypted: i=1; AJvYcCVkYZ3VzxJY48b0xlX9ltm9ruf8mFvJ6pXeNQCxCFUKfrmQ2YU+zXuszL54u6HgmEtX4mc4Bk4LabXlW5kXBx9Zj3X3 X-Gm-Message-State: AOJu0Yz9CB3bm8ecEPlxFWDglH6rrPJMy7NFEI/2gvO+lZ04jwOBxQsY TOB5W4OR9Ecf8UsQacVwTI7iIzBIyAMJjSwQKxRcn0Kh8m0yRkVAp2moUtrIMLU= X-Google-Smtp-Source: AGHT+IFYGr3yln/+vkC8c4wuU02zkUuJv0AQykl/zlen2nQtgSYYTijPjewoiwEJtSC9clBwrdPHDA== X-Received: by 2002:a17:90a:c582:b0:2c8:452d:e634 with SMTP id 98e67ed59e1d1-2c99c890807mr5397148a91.45.1720421757292; Sun, 07 Jul 2024 23:55:57 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2c99a95b572sm7393441a91.18.2024.07.07.23.55.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:55:57 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:12 +0900 Subject: [PATCH v3 1/9] spapr: Free stdout path MIME-Version: 1.0 Message-Id: <20240708-san-v3-1-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::1036; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1036.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_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org This fixes LeakSanitizer warnings. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin --- hw/ppc/spapr_vof.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr_vof.c b/hw/ppc/spapr_vof.c index 09f29be0b9de..c02eaacfed0b 100644 --- a/hw/ppc/spapr_vof.c +++ b/hw/ppc/spapr_vof.c @@ -28,7 +28,7 @@ target_ulong spapr_h_vof_client(PowerPCCPU *cpu, SpaprMachineState *spapr, void spapr_vof_client_dt_finalize(SpaprMachineState *spapr, void *fdt) { - char *stdout_path = spapr_vio_stdout_path(spapr->vio_bus); + g_autofree char *stdout_path = spapr_vio_stdout_path(spapr->vio_bus); vof_build_dt(fdt, spapr->vof); From patchwork Mon Jul 8 06:55:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=LmjHWBlO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZfk6fVHz1xpd for ; Mon, 8 Jul 2024 16:56:46 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiID-0008MV-3B; Mon, 08 Jul 2024 02:56:10 -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 1sQiIB-0008F7-48 for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:07 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiI8-0001om-Ut for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:06 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1fb1c69e936so16648365ad.3 for ; Sun, 07 Jul 2024 23:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421763; x=1721026563; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vIEfURKz+p1ePfxL4ZyEDkPLusmBWgHYvO+HKUIo2A4=; b=LmjHWBlO0E68jEEnjnYdjJw9uvaMgZFhlu7gNIeq5sw54fwmP8EsPWe0gT9I6dxSzX Uf3NX9t7DJMRxfYQRF1zPvx5klkbH1kVo+YuJYcQYpbUOeFE4m7uDAv7opwK0Rx8/wY0 SqWSJCA/2YwhdHFuk+KyAmInJBhBOyks/7n9JXhqE72nUEPpwsAt/Z5MWqyP/lxiGj5a XuXuLSn/qBievx9QPUP72JBlMwfZQGCmRZB2/buGGvM6Wrv53LqbMqDcvDw4k9tNHBOQ nL8Z23ylDe/bRELvMRI5WyN/ySP5rjLbZS2N/H2NlNlbgbLNh+KK4Bx0Cnt9EdDrZ6gL B+bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421763; x=1721026563; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vIEfURKz+p1ePfxL4ZyEDkPLusmBWgHYvO+HKUIo2A4=; b=EErBNjBlxHnY96Cbxv3EqS0y9nZuYvn9iV/GcSopy98qGAez0H7WSOT0gaEaE8F1O0 62TVCSzzJnd7TtJS03LxNKryiftc/og2sUZvC5Ool2ubvtyVvVBTsDcHj3ZNUEQ0w+ae ZyakoUCffREkDsPIKqESIv80wYWAI+Q5kFbYfNm0qwBncpdpcJiwhxkCkln8sKVHnN42 NpiK3bnizxZHmPtDyoQHSqrsPQqVk9IOWDlvTjojCRiUYJBObPm00GN3G8f49RL6pSLD CfOx+YxWG8LcaUYHtPpUQKc14DN4ZPu3LCj+lO9pHSsbs8+dhx+73OTZ2XVE5/Sh56Vm UqRg== X-Forwarded-Encrypted: i=1; AJvYcCWET0Hctauzq0/FjQAuzON4ifEPFO30ts3cU0g9CeFjqa1oYwYadsmlkPHUm7MmEeLuCSywq1xsvXDsZ4qyD3HAyr5Y X-Gm-Message-State: AOJu0Yy9R92CBERsuOt5uE3SqCKQzQSodmwnyHO9HtGsCh355QCJBqU5 w3h4RJZo2Bs/3w0/Fg9bAJl8vW4pA2P6QNCNtydDkjkVVtS3qYIv8an+cqO+3L0= X-Google-Smtp-Source: AGHT+IHaHLFdVS3j6x0yV/mu2NdS069vJVNaVFKSSEeJYUo+CXcbTb/uvUGc5zl46xXmYEn41lnNAQ== X-Received: by 2002:a17:902:cec4:b0:1fb:72b4:8766 with SMTP id d9443c01a7336-1fb72b4898emr28292685ad.49.1720421763375; Sun, 07 Jul 2024 23:56:03 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fb438a7890sm57605205ad.185.2024.07.07.23.55.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:56:03 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:13 +0900 Subject: [PATCH v3 2/9] ppc/vof: Fix unaligned FDT property access MIME-Version: 1.0 Message-Id: <20240708-san-v3-2-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki , Peter Maydell X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::62f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62f.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_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org FDT properties are aligned by 4 bytes, not 8 bytes. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Reviewed-by: Michael S. Tsirkin --- hw/ppc/vof.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c index e3b430a81f4f..b5b6514d79fc 100644 --- a/hw/ppc/vof.c +++ b/hw/ppc/vof.c @@ -646,7 +646,7 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base) mem0_reg = fdt_getprop(fdt, offset, "reg", &proplen); g_assert(mem0_reg && proplen == sizeof(uint32_t) * (ac + sc)); if (sc == 2) { - mem0_end = be64_to_cpu(*(uint64_t *)(mem0_reg + sizeof(uint32_t) * ac)); + mem0_end = ldq_be_p(mem0_reg + sizeof(uint32_t) * ac); } else { mem0_end = be32_to_cpu(*(uint32_t *)(mem0_reg + sizeof(uint32_t) * ac)); } From patchwork Mon Jul 8 06:55:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=oyMsnlPm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZfK2Kbwz1xpd for ; Mon, 8 Jul 2024 16:56:25 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiIO-0000UX-80; Mon, 08 Jul 2024 02:56:20 -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 1sQiIL-0000JD-L9 for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:17 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiII-0001q4-4B for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:16 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-70b0013cf33so2235464b3a.2 for ; Sun, 07 Jul 2024 23:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421770; x=1721026570; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dYsCw1FmqSn/YuppQ6AhBdpL7b5hTddKWxjDOuy7dBs=; b=oyMsnlPmLQtNJLkmP55dvZl1kcbPpJMT5UANwbJO7TdlwwE+ma1zHDhTBM7o2lJVWG /Xd1WpMAO5LQ5plbqETRc8/9wN427dFQrsOxqRhAglRku4eqbmhpsyK2iwRQUoLEdCVo STytmkgkcG7aYf+JVHuk5NJCUSmdSBc2ywuknuLujksdkfFZWAHUr25I1Bo89aMzZiMe 8ScHw6aaO8OgysgxK1OlGNSILxnzeUh+pQjmOIRZgms4SYNV5HWy/bSKByfYXJmp6To5 oYD7uPZpqFWZ7+6RfEOv/T1M01GNJYKQVdVZGBvRyasdVxIEMX5LxFkg4nhosGsOYs2+ enSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421770; x=1721026570; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dYsCw1FmqSn/YuppQ6AhBdpL7b5hTddKWxjDOuy7dBs=; b=tTRt5LO+zNh+ohIAdY0v+2D8j3+wojvmheQja7CPwzrnDtk6Bpv1zmbxRWBU43zWzY YRiqtLUUOSod9UA9gQY5S2oNfFNa3DOAblT1yVBJO/AprN5S3nDsb0bFHvCa6y4b6qYf BLx9bGEtRcqR+XFL+JIv1OAM3/0j6A8tEo3x/HPWD6ZPBPZkXlErpIZraKZ4lZVgZ45Y EoJ1fXsCMsR3rmYasDA1bsrVAU+bLc+Sks8NcF//sLTFlAofOrlqiEqzn5wVwuPFk/w/ eGCsoIYMZnSfOVKsSm/gOTf6VyTUQMSRucul7Pc4YtmkJu7Otf3F9oBIFE5kUvfxBL7p Vxig== X-Forwarded-Encrypted: i=1; AJvYcCWH4njlDWqcpbYkUzrdcASRVjXyP1Kt7rU5oMjgAKKMIQmLOcHUKIOHF7wSSRWJpyRR+XxXfoObrCM5Zm3w/BlF9d5M X-Gm-Message-State: AOJu0YwVs2Jf9Od1eZ2x/XoOMe9Xx6mB6SrMIYR3P9oNhnhmtdaSSbOu xCv/k1KqVhMFSl7C5IU/280OADiA9ohBMG1Dx5a8p6r8nJtF4pd0f4sNytGEpuU= X-Google-Smtp-Source: AGHT+IHfgbo/reFIOcNODiDMFxa4Po7UHW8YYN/I4KGCJzL8ZmEaHuGkly4b2a/dS/pDNoFvPtU0xg== X-Received: by 2002:a05:6a20:244c:b0:1c0:eb46:96f7 with SMTP id adf61e73a8af0-1c0eb46973emr2272534637.61.1720421769497; Sun, 07 Jul 2024 23:56:09 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fb111382f5sm95501885ad.175.2024.07.07.23.56.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:56:09 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:14 +0900 Subject: [PATCH v3 3/9] migration: Free removed SaveStateEntry MIME-Version: 1.0 Message-Id: <20240708-san-v3-3-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::432; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x432.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_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org This fixes LeakSanitizer warnings. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin --- migration/savevm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index deb57833f8a8..85958d7b09cd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -874,6 +874,8 @@ int vmstate_replace_hack_for_ppc(VMStateIf *obj, int instance_id, if (se) { savevm_state_handler_remove(se); + g_free(se->compat); + g_free(se); } return vmstate_register(obj, instance_id, vmsd, opaque); } From patchwork Mon Jul 8 06:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=WbcPQOoi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZfy31Shz1xpd for ; Mon, 8 Jul 2024 16:56:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiIa-0001Fx-OQ; Mon, 08 Jul 2024 02:56:33 -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 1sQiIP-0000ae-B0 for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:21 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiIL-0001qr-DO for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:20 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1fb0d88fd25so22345895ad.0 for ; Sun, 07 Jul 2024 23:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421775; x=1721026575; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ChRWheJjblqVP5q7+vXrOZ0CV+wipm1YZa2EmXXOkpw=; b=WbcPQOoiOMsaor48S+cvkvH82+Z8fYBS0IxHLoz9wn8U3rLu1bkDrniGb8N6yW7vRg Cg0l/XAwoFGsCeanGGonUV6erfY3kqcP4Iq9b+Iqp4vKk7lVh9bD3f7dapWvIbCTbPJt ECK2Zzqaci5jJAw6A6d0xWnQifp1TmnUt+CIJ0Fg3KXXY32VVvC8SUQEVDt2+kqFks+7 IEaTDY1CGpwRXtzAf7lj42i9b3bzEn5TllfG3/Obdsw12BL0UYKrX2zaU5VHJIv4iBRw QW+/UFatQCxPDrl95OQ9S1VjZnQlqMfKVGd2mawKvnFeNA/5FrX98omnx9U/BA3RZ4a0 7l3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421775; x=1721026575; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ChRWheJjblqVP5q7+vXrOZ0CV+wipm1YZa2EmXXOkpw=; b=HmT7NsxLiod+7QiFHc6i1DlZVvMpi2TOcrZwZ2KO+IH8MKu+7jwETK3Mpu4wJaFTGu iXgAHarBJrPimyi/cnZZdZysaf/H8FJmwh6SL6pE1Qxq2+4dzy3bYyKQ9eXzVmvFkX9n HvuQQRba6pJ40mCgp4Gif6YGAXozJu0vAEuhFCoRy6/i5T62hD4cRwoMdXNDH1Rb4Bau Ia2ChFwAqEL090Y+ZBdOsX3xT5raFcFec87aF7dvXR6zXXYGIXC3QCl5LvPB2BoLsXQd DnxjXgR/YpkZd+VX+wXldthkCAjXBnnuOziOyu/3golAMIxStK8vfubfjJvW7qF+uxaE NTZQ== X-Forwarded-Encrypted: i=1; AJvYcCVCTxBwosET2LFP/ziKpIZvPTiraCff8EHI7IzELYH6r6DMMu76R7dux/u1aWSZRGLTbbALRmhurLUitM2c1sYyWHb8 X-Gm-Message-State: AOJu0YxRuikdV37UO6h1Dk6WGhhXGUjsOT5yGXgvou2cAQxSqwAET4VU /tjiOH0SDsj5S9lq8I/qUr4vBx1p2jv+B3FKYorMGLasYQeUL1uEeM9azrn8dFJA97q3+UBlDrn h3I4= X-Google-Smtp-Source: AGHT+IEVqu/8DsEhzBCxZKr1jWnPsEYZhX59/+YkowLt6y09KqyZz3Mfs436iKNSVuV3e2T20/W0hA== X-Received: by 2002:a17:902:dacd:b0:1fa:ce44:1cb3 with SMTP id d9443c01a7336-1fb36c3a357mr192999235ad.0.1720421775458; Sun, 07 Jul 2024 23:56:15 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fb5962888csm43274235ad.61.2024.07.07.23.56.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:56:15 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:15 +0900 Subject: [PATCH v3 4/9] memory: Do not refer to "memory region's reference count" MIME-Version: 1.0 Message-Id: <20240708-san-v3-4-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::62c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62c.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_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now MemoryRegions do have their own reference counts, but they will not be used when their owners are not themselves. However, the documentation of memory_region_ref() says it adds "1 to a memory region's reference count", which is confusing. Avoid referring to "memory region's reference count" and just say: "Add a reference to a memory region". Make a similar change to memory_region_unref() too. Signed-off-by: Akihiko Odaki --- include/exec/memory.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index c26ede33d21e..a5af05864274 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1243,7 +1243,7 @@ void memory_region_init(MemoryRegion *mr, uint64_t size); /** - * memory_region_ref: Add 1 to a memory region's reference count + * memory_region_ref: Add a reference to a memory region * * Whenever memory regions are accessed outside the BQL, they need to be * preserved against hot-unplug. MemoryRegions actually do not have their @@ -1260,7 +1260,7 @@ void memory_region_init(MemoryRegion *mr, void memory_region_ref(MemoryRegion *mr); /** - * memory_region_unref: Remove 1 to a memory region's reference count + * memory_region_unref: Remove a reference to a memory region * * Whenever memory regions are accessed outside the BQL, they need to be * preserved against hot-unplug. MemoryRegions actually do not have their From patchwork Mon Jul 8 06:55:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=j2HT0RAU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZhQ72mmz1xpd for ; Mon, 8 Jul 2024 16:58:14 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiIb-0001IY-BQ; Mon, 08 Jul 2024 02:56:35 -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 1sQiIS-0000pP-TU for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:26 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiIR-0001tY-5f for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:24 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1fb3037b47dso20035965ad.2 for ; Sun, 07 Jul 2024 23:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421782; x=1721026582; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/jMKYGPTJJ9yGUeaxRp22EHnHqtIFtM17jmMaxbQ8UI=; b=j2HT0RAUbZZxKB10/HMcBMSXEQj+NeEX6239LW8mgwDmiN7hZoBMAaZvflHpD7tDcX PsyB1miAT6eGi7+Ph6IclKthRarD6fK64kWVgxUJZeS8FxaMb4J4E08TxliKSqTE+6mF pFy259RJTz9ieNe7HWJtQj2r6eGMI13pSw7i7oxrpE3iTNzUXpBogEALEgsalCMMv1SA IBEgmFFX4mEVIhjBMBAEHpHqd223dHU+a0CSXEH6/4yjZfOPG7pDYueq4iq1Hb6aMpex OX4xm2+KOwic4yn+WpuW6F8zP7zOQEYMWSvcXMhgg/I4MD0O7x+pAziY07NMsd1SkPt7 gN3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421782; x=1721026582; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/jMKYGPTJJ9yGUeaxRp22EHnHqtIFtM17jmMaxbQ8UI=; b=u/FOrFeCGuOqVsH31lpGticN8r30sruTa88XanPSF67zj15zPSFJAuwCWIbxC1T2Xg TSouNOXdRq6U8TrDCAGYkKSbG+3CQ7TvnvTEe1eMews2VYV6mjH+3Po3RL9UqyWtuQ/z xhcN3W7JN8EpUTtoUe3xOjuNst3Byqp86KN7ThOwn+bYuPxzBLTGnajioG3jf8J3t9WM mWHB+QQda1snkP31QMlPGiv+bugmH7L1eH2378stXtkNNdabSdskLi73Rms5vStOr4nS 8TdL5NTezWHViZwy6jbG/fpr3UcgZEAnpukufKjsOokM+NsPRdr4O/dcdRlxQ6kwHwlC rX+g== X-Forwarded-Encrypted: i=1; AJvYcCV7WHHUfP+0BfxKYHyvjRleATZ5hcwAlpq8v8Wq70rwVzcWIqZkG00QR4deUzwejk5qoOgEvLBsW5AWGHJlg1ANNK1m X-Gm-Message-State: AOJu0Yyhi6GQlyz2uxt9hIpAec6U46EhWN2ycj8V76xPiO6RSrC0nEO/ QXmGUMhXXcG2CtCWzDcIlwQZRbd+4gcLpATdUwoTmREVAB459eC0DNQdVxe3Oa4= X-Google-Smtp-Source: AGHT+IHM55HaZNNo61Hs7ynNHCbQVGIhDn1FJn7IXBZtorbAel5T9LcyEgQlWQGY2x96E9xCEU8/mA== X-Received: by 2002:a17:902:f64f:b0:1fb:6260:8eab with SMTP id d9443c01a7336-1fb62609109mr30287365ad.64.1720421781978; Sun, 07 Jul 2024 23:56:21 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fb1fb30ba3sm85254985ad.89.2024.07.07.23.56.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:56:21 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:16 +0900 Subject: [PATCH v3 5/9] memory: Refer to docs/devel/memory.rst for "owner" MIME-Version: 1.0 Message-Id: <20240708-san-v3-5-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::634; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x634.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_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org memory_region_ref() and memory_region_unref() used to have their own descriptions of "owner", but they are somewhat out-of-date and misleading. In particular, they say "whenever memory regions are accessed outside the BQL, they need to be preserved against hot-unplug", but protecting against hot-unplug is not mandatory if it is known that they will never be hot-unplugged. They also say "MemoryRegions actually do not have their own reference count", but they actually do. They just will not be used unless their owners are not themselves. Refer to docs/devel/memory.rst as the single source of truth instead of maintaining duplicate descriptions of "owner". Signed-off-by: Akihiko Odaki --- include/exec/memory.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index a5af05864274..e1bd29550c15 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1245,15 +1245,8 @@ void memory_region_init(MemoryRegion *mr, /** * memory_region_ref: Add a reference to a memory region * - * Whenever memory regions are accessed outside the BQL, they need to be - * preserved against hot-unplug. MemoryRegions actually do not have their - * own reference count; they piggyback on a QOM object, their "owner". * This function adds a reference to the owner. - * - * All MemoryRegions must have an owner if they can disappear, even if the - * device they belong to operates exclusively under the BQL. This is because - * the region could be returned at any time by memory_region_find, and this - * is usually under guest control. + * See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion */ @@ -1262,10 +1255,8 @@ void memory_region_ref(MemoryRegion *mr); /** * memory_region_unref: Remove a reference to a memory region * - * Whenever memory regions are accessed outside the BQL, they need to be - * preserved against hot-unplug. MemoryRegions actually do not have their - * own reference count; they piggyback on a QOM object, their "owner". * This function removes a reference to the owner and possibly destroys it. + * See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion */ From patchwork Mon Jul 8 06:55:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=TSL/ASzM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZhk4F2wz1xpd for ; Mon, 8 Jul 2024 16:58:30 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiIi-0001WZ-1K; Mon, 08 Jul 2024 02:56:40 -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 1sQiIc-0001Ml-VS for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:35 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiIW-0001uv-Vs for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:34 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1f65a3abd01so24858965ad.3 for ; Sun, 07 Jul 2024 23:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421788; x=1721026588; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RbcvfQTicnHYs0Rl8hdXG4yng/OPRtHTnYekAJzWw5c=; b=TSL/ASzMfySzCdwkGj+k0PF/nYjATDQ7OrzcqaH4avIcejerekELQ/8B+A39YkvZei xuSKgJXfZ7iWRb9sF4YPQpCa9pjCthOVegb98HNIOrznew/UhJnh4OUNslXx++ou6kuR tVhEElipNaoQY/5kDVQ0EevmqUTTOAxzhwW+p9gg+Uu4izJJrJ5gX2pdjU3yKXvB11vW Scv7zLLi/TqpkE9mlYm2ScpY3RrSq7NO7ozpi+Snsdq+jp+3m45iQJv2XallwicjM2MB 5yTVlQVUg/EQ+GuR6kAS+v5HpsGEQd+UFXvpgD3PGVlR6hpzfgM/Wozw6FKoWKCqJ1Pp wtSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421788; x=1721026588; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RbcvfQTicnHYs0Rl8hdXG4yng/OPRtHTnYekAJzWw5c=; b=nu6NUk4MfiPiFpy12LkV3AFUpOvaJMR6VMSIWhWoyRnWt2Adf804dws1z+ywVqjqC3 vR0KkSEJkQr3yQUy555xOQELIYvSxC9zo344s8gEBG6yxtSswXG6LagrkQ0ovPP052FO Vvn6OAwRZ+fUOog3pG33KPUX+gDjS2x74lHrsbnawstmk4gNw6Myu+VBnNBCX8qlFbZv hlQKhnxPdf0DJ0ZKMtfXYvJxUf3wDGCbANoWTrXl74M9jDvYvWOXFtz/Yy1H+on9EwrF bZmQ0CqXcK/2IKgzquEV7jGGtTKU5FJaCWUafLZK5UR4G4xCAyr2WhvHrNEHssUOHN1u s79A== X-Forwarded-Encrypted: i=1; AJvYcCWKL+b/GJ6L+j3qf7QlmrSUjpnkZq8pJwoM9B5FFYZkH9YnNAW3BRLpu0aXI/b0wplWxsuOOv0II1p9WhGUpAst59ja X-Gm-Message-State: AOJu0YyqZZIC7O5OBSdUfoV3HczdS1RmIll4/uL/pEum/Xe+lGEQd6+4 fluX5Aq8bNdnhubxP9iY0l3glEmrdhNeHheLdNhMrzF6H8h0yzBrw6kudbco21w= X-Google-Smtp-Source: AGHT+IF224MSkQyCWG97UaqlAKurNwMnUliBvemXdWNeaeRytihyIwE176LqgTxQEVJaVP5Ugh784g== X-Received: by 2002:a17:902:e743:b0:1fb:7978:6b3 with SMTP id d9443c01a7336-1fb79780b8amr47259865ad.25.1720421787844; Sun, 07 Jul 2024 23:56:27 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fb48c6a5c3sm53740695ad.13.2024.07.07.23.56.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:56:27 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:17 +0900 Subject: [PATCH v3 6/9] memory: Clarify that owner may be missing MIME-Version: 1.0 Message-Id: <20240708-san-v3-6-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::635; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x635.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_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org A memory region may not have an owner, and memory_region_ref() and memory_region_unref() do nothing for such. Signed-off-by: Akihiko Odaki --- include/exec/memory.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index e1bd29550c15..847c84c86db0 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1245,7 +1245,7 @@ void memory_region_init(MemoryRegion *mr, /** * memory_region_ref: Add a reference to a memory region * - * This function adds a reference to the owner. + * This function adds a reference to the owner if present. * See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion @@ -1255,8 +1255,8 @@ void memory_region_ref(MemoryRegion *mr); /** * memory_region_unref: Remove a reference to a memory region * - * This function removes a reference to the owner and possibly destroys it. - * See docs/devel/memory.rst to know about owner. + * This function removes a reference to the owner and possibly destroys it if + * present. See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion */ From patchwork Mon Jul 8 06:55:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957831 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=O4pOfXWL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZj94VPgz1xpd for ; Mon, 8 Jul 2024 16:58:53 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiIo-00021u-2K; Mon, 08 Jul 2024 02:56:46 -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 1sQiIi-0001bm-QJ for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:42 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiIg-0001vP-7v for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:40 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1fb72eb3143so7931565ad.1 for ; Sun, 07 Jul 2024 23:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421794; x=1721026594; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qHDn+thxMw3Ig31uqjhcKUOYvBIP2g0Rv0XxZxkAcRk=; b=O4pOfXWL8hN7msyyNnqEvOs1mQuA/Z+LKsIIRCbTXFrhbFHXDRbaTQ+jKmu0oTv9Zh yQ1emaP7n20aSphm5LfTHfbLOPveEClm9u4w9ZhGvGqZ/HGpFwCGPoDB7SXc2KDZY3N3 GqOdnkv39J+eaAY9hieX5kj/ODJX+VzSVjhF0X23QTGW7ga9Mf2VA8gdTZZO8NpZGa/R hl4TskKTWXcHqA8GErcRnjFgdNZOiTu2U7lxl6I9Nzi38t3YK1Mw7WFH2Ag9L+gyDA03 kGcWeN328wvefQSuyVoVy7RO2t4ZIrQzT2PHwClqyKThs3+Viglb9brmdA4WRoXHYUx1 N+dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421794; x=1721026594; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qHDn+thxMw3Ig31uqjhcKUOYvBIP2g0Rv0XxZxkAcRk=; b=KNhY+VlNLNjNLeKIIW9B/W13JEsUUsUt7uTgSVZgBrZnmj3S+xj7YZCHn8FEcGn1i5 qjdCgVCWsGW7J5aSNCzJ3UUu9p2cflE1opWTb4v4rmhNTLwhp1dM/jHnB9UvMCdUOHKB gt/JpNkMUWQWVzVs/D92JbBJ4YATZcM3iNbNsRNL/kRsqhl9wwjvlhRM63ZXoltD5fUz NKg0Bfa8okwPCXTiPyYMCjW2vIHWY3VA4Ixk6B0SUAozEJAW9lTalSuRaVaNjJOKZZ3V PYvqGIxxnOzsOGRVBDW/W5kFc0W2BcRl4H3QUmr/OHg/7LSqBuU9z0kR9xGcQcQPkM7a VntQ== X-Forwarded-Encrypted: i=1; AJvYcCW04z65noOcNqY2++5OcyZ2EqJrVB0rsHExoxLFK89NBNMHQwJ54SRI/z50Ez0Br1SwvEjhh2YNGlybKqqzJQPa0JTp X-Gm-Message-State: AOJu0YwKncBvLjv4dY3IBWiZyyOmShgGxGJbLx7X9TiDHeI+KojP9LED FG3mJTwXfT7p2k6CtaR5LGtYCT9S9KbVm/Yvv+uL+LTrJBRIEbC2IZ3klXneRgo= X-Google-Smtp-Source: AGHT+IFFXUzW/PXAi/sF+7aaq6lUaFYcUV7YW/MQrCOgfEn9qAauNV8DpVYWlT7DWjVM1fpKaopkMA== X-Received: by 2002:a17:902:ecc8:b0:1fb:6ea1:6e with SMTP id d9443c01a7336-1fb6ea1039dmr85708215ad.9.1720421793886; Sun, 07 Jul 2024 23:56:33 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fb67ee6f31sm34281675ad.292.2024.07.07.23.56.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:56:33 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:18 +0900 Subject: [PATCH v3 7/9] memory: Clarify owner must not call memory_region_ref() MIME-Version: 1.0 Message-Id: <20240708-san-v3-7-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::62a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62a.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_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Akihiko Odaki --- include/exec/memory.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 847c84c86db0..32bb430acdc4 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1246,6 +1246,7 @@ void memory_region_init(MemoryRegion *mr, * memory_region_ref: Add a reference to a memory region * * This function adds a reference to the owner if present. + * The owner must not call this function as it results in a circular reference. * See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion From patchwork Mon Jul 8 06:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=DVN8qqyo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZh03nvrz1xpd for ; Mon, 8 Jul 2024 16:57:52 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiIp-00029A-Am; Mon, 08 Jul 2024 02:56: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 1sQiIo-00023o-Dt for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:46 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiIk-0001wO-JE for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:46 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-761e0f371f5so2205529a12.1 for ; Sun, 07 Jul 2024 23:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421800; x=1721026600; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tLjKua6/1Hq2H1WMYp9C0UeVmJOmPJCabCtwzxYyu/w=; b=DVN8qqyoedF0LwyM5e6XliCbYOd7wEqHOrZuUXy2nsJGEkFSn/7Rx7uB0It69yFUKF ZT1+saYscXc/yduH+61iKXb1AW+fEgSz7JXNL+2CvIam5smUjxLjxihHf2OjyERf7SRk dyrevOjqoTJXEiyO+9QEGIOOI+EdURNBKn0cZLAZVFirA/WE2w7I3TVTvHsZtzrqyTqL wk1KUkJzQ++lxmCnv6uuIUwaozD9uml+w0LJwrMkvp/aVBNstvOya15I+s+UHNKLqu/z ppTX5i7KeyCaMPjAvMfo/jioC/f0w5QrKK5pv543px/dR9t81FOSfl5IjwwjjZMGoyze 7BDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421800; x=1721026600; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tLjKua6/1Hq2H1WMYp9C0UeVmJOmPJCabCtwzxYyu/w=; b=Hbrctq+zB/4lz4VUYBgzfsNMq1c6c3mW9tsFvdOSNPisd+AykOw0sLXp67UnU1Iys+ 5wsq7IuoImwQXGcfJROX95gDqH+bCQHFjreiA5cZd+v5hRoMUmNlUTxbJXHUSpJnHOxi KO7xazy+LlWh1wTrsBin49YMlgJizoCt3Lx1KBYrpvvLMrGFhijcT7VxH0L/JGNyRSXu 1xNNweddAulVIE8kLs/khHTSBks54qqHj4dxcp8W5f3yg7SaY7QcBI0nmSOgz5uIxRxB Hw7OVv854LSAY06nMtVV2jRqZfc4mPfEwEuWuJe2rRvaO6ikGnQm3hsMEt9qAnPKtJZd uqBA== X-Forwarded-Encrypted: i=1; AJvYcCXMWXL8aSptOS7maKWoeTKhak4BzLsKHWGQDkIfbpxrzl/p2a4eZAgk/OBX7KX7zcQqCKs8h84rPZj6pWpEmMnxlmsM X-Gm-Message-State: AOJu0Yw+eB8VHSalIW2zsjKIhgWssLUIGotlQ61ZMrvusnAuPDpLgr1M 5/unN936ns9GwybxUKLiQ+ovwzNzYLH7qGsEl128PeGX0lgTEps1EM1HomSHX8E= X-Google-Smtp-Source: AGHT+IGimfWqqHnSqOntC/f3ozquovyx9nC2f2NQCfqeGesCHlONjh70lg+bYJV2RrwbgWKdHUVV5g== X-Received: by 2002:a05:6a20:a123:b0:1c0:eba5:e19d with SMTP id adf61e73a8af0-1c0eba5e35bmr7575031637.18.1720421800288; Sun, 07 Jul 2024 23:56:40 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-72c6d1f77bcsm14717594a12.79.2024.07.07.23.56.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:56:40 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:19 +0900 Subject: [PATCH v3 8/9] memory: Do not create circular reference with subregion MIME-Version: 1.0 Message-Id: <20240708-san-v3-8-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::52c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52c.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_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org memory_region_update_container_subregions() calls memory_region_ref() on behalf of the owner of the container. memory_region_ref() must not be called if the owner of the container also owns the subregion. Signed-off-by: Akihiko Odaki Reviewed-by: Michael S. Tsirkin --- system/memory.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/system/memory.c b/system/memory.c index 2d6952136066..09c98042e443 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2625,7 +2625,10 @@ static void memory_region_update_container_subregions(MemoryRegion *subregion) memory_region_transaction_begin(); - memory_region_ref(subregion); + if (mr->owner != subregion->owner) { + memory_region_ref(subregion); + } + QTAILQ_FOREACH(other, &mr->subregions, subregions_link) { if (subregion->priority >= other->priority) { QTAILQ_INSERT_BEFORE(other, subregion, subregions_link); @@ -2683,7 +2686,11 @@ void memory_region_del_subregion(MemoryRegion *mr, assert(alias->mapped_via_alias >= 0); } QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link); - memory_region_unref(subregion); + + if (mr->owner != subregion->owner) { + memory_region_unref(subregion); + } + memory_region_update_pending |= mr->enabled && subregion->enabled; memory_region_transaction_commit(); } From patchwork Mon Jul 8 06:55:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1957829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=CVHIBlG6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHZhw0Bs9z1xpd for ; Mon, 8 Jul 2024 16:58:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQiJ1-0003N1-SX; Mon, 08 Jul 2024 02:57:00 -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 1sQiIs-0002VM-Qf for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:50 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQiIp-0001xb-Qg for qemu-ppc@nongnu.org; Mon, 08 Jul 2024 02:56:50 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-767506e1136so1653026a12.0 for ; Sun, 07 Jul 2024 23:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720421806; x=1721026606; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MN/3EfVBXv6jlnRXRpQP7cJiMDwiSYrMczZXVrsioJo=; b=CVHIBlG6ZYWbm6eW/FFo4zw6tgCIxUd4I8YE1vobOK1hismy1p1kXvIXr7+y804g+Y T2vGjxo9c0D14yqxSYy7X/N/h8uh5gZfmxPI2+YUMkA9TTGoXzGFzuc6sTcXIuN5atRj 5a59DXKScNUlUk1VYgMi/zM+c1Yn7ab8XT5OnaZDcpsEvTJ7RAaMSgssCNVV9nDAXZG4 pt1wEW80x4oMjAsgfnIhHjubT9YGgtHPr9llmoeHAnf9QKopChZmBiuqwHJrnAuUyRar XzjBXFgCJapN7GzFfREuHC0X9BpfKqI3Q77MVec0FMrqxnqlQR5m6n+3nXI0pqYjjpcE Q80g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720421806; x=1721026606; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MN/3EfVBXv6jlnRXRpQP7cJiMDwiSYrMczZXVrsioJo=; b=J/7xSgzqjG+JVN/r9vfIb3LBRNvpKeGsW6hZw/4Nvhaci6qsSqXO/DvdwlQeIFSjAd Nv3Xsm0L31apcYDN4rkikJPpFyOl3XoajOQVmJsv2m28c089oaACBNvYoR3K1qedUiy0 fgWhZQsrtkhFJHQ1SkCi4kbNYTe/3ciV6Z99Qtrcj6+Nvv3iGGG8j+pa8oLiPQgxbh/S Dm/xmwf5sGTWIcmK5cNpGoTzsWoy0wXsZ8JFsXMyQmtdqhhyL7sJFc3HEuJKMvkWKED+ Izq3Rrx5OgypFjErITGpETHabmHRxuA6IIRPK7l1dZUIx77c1Q1bIss/hlX4BjkyWEyA aBVw== X-Forwarded-Encrypted: i=1; AJvYcCXhnOAAP90CXK8puiej2AMKynS6P1/jNVGDDZwg6KBLICGVrKHBRCyGhYKD4MRDiBAuDmhf1RomKEkJgCPP/gC6e2wV X-Gm-Message-State: AOJu0Yyvd3eYY1Z+0QePUWxUgX26EZppZ+KP/MxuNFUwXOIQm7NDs9P/ cQgZrYzOTgPC8gx3gwZ2XgrKMeVcpfq9GKKTquzlpXn3oO4ms/gMiwP4nc1LDpc= X-Google-Smtp-Source: AGHT+IHP6b2+9XmIFVTQc3FtbQmi+g9ayoGwvJXvh/X9w5iLuVeTzCzpwSPN6ELi+UNELouIc67xUg== X-Received: by 2002:a05:6a20:cfa3:b0:1bd:2c3d:ccae with SMTP id adf61e73a8af0-1c0cd203e34mr14896527637.29.1720421806264; Sun, 07 Jul 2024 23:56:46 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-70b27349696sm2284625b3a.75.2024.07.07.23.56.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jul 2024 23:56:46 -0700 (PDT) From: Akihiko Odaki Date: Mon, 08 Jul 2024 15:55:20 +0900 Subject: [PATCH v3 9/9] tests/qtest: Delete previous boot file MIME-Version: 1.0 Message-Id: <20240708-san-v3-9-b03f671c40c6@daynix.com> References: <20240708-san-v3-0-b03f671c40c6@daynix.com> In-Reply-To: <20240708-san-v3-0-b03f671c40c6@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::52b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52b.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_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org A test run may create boot files several times. Delete the previous boot file before creating a new one. Signed-off-by: Akihiko Odaki Reviewed-by: Michael S. Tsirkin Acked-by: Thomas Huth --- tests/qtest/migration-test.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 70b606b88864..6c06100d91e2 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -144,12 +144,23 @@ static char *bootpath; #include "tests/migration/ppc64/a-b-kernel.h" #include "tests/migration/s390x/a-b-bios.h" +static void bootfile_delete(void) +{ + unlink(bootpath); + g_free(bootpath); + bootpath = NULL; +} + static void bootfile_create(char *dir, bool suspend_me) { const char *arch = qtest_get_arch(); unsigned char *content; size_t len; + if (bootpath) { + bootfile_delete(); + } + bootpath = g_strdup_printf("%s/bootsect", dir); if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { /* the assembled x86 boot sector should be exactly one sector large */ @@ -177,13 +188,6 @@ static void bootfile_create(char *dir, bool suspend_me) fclose(bootfile); } -static void bootfile_delete(void) -{ - unlink(bootpath); - g_free(bootpath); - bootpath = NULL; -} - /* * Wait for some output in the serial output file, * we get an 'A' followed by an endless string of 'B's