From nobody Sat Nov 15 12:43:54 2025 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1752008249; cv=none; d=zohomail.com; s=zohoarc; b=DlDOZf8DlKxjmZ62haYqHWeVWirTFP1f70FmQHLfS7mtcuSNub9s38JJmrq6xwJ3Fv8Gxk6Pqbv/wDmpc+1kUzVhDYu50ue2cSTH6HFVNKX4/FnGlzRyqcUYd4SVGITOP+ggYs4QoV1IUVG7VCe0VpNlGnLXOcoQoz3GDCexhkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752008249; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GHvIfEToA34AUrJx/MLc8GOT8YL8A2v7KBo+787ye5o=; b=Qpj1MRQTgD7MTyu41Je5QOcm3OO5VfegHgvdFgM4VroXUrMQM8KRqFckCxbMpVVgfEZkimld/mkXyOzZ+7dvF9Gogwd5rdM9DB8j9civ087OxBIW3fjFqQlCJPsdCmR6sC1IATkf5i7zL1S5D8GJswUrxV48b0sDIr54Fm4m9y8= 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 1752008249687941.3592482961099; Tue, 8 Jul 2025 13:57:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZFKf-0004GC-EX; Tue, 08 Jul 2025 16:54:32 -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 1uZETv-00013l-44 for qemu-devel@nongnu.org; Tue, 08 Jul 2025 16:00:03 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZETr-00035g-9p for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:59:57 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-553dceb342fso4583115e87.0 for ; Tue, 08 Jul 2025 12:59:54 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-454cd4a68ebsm19731255e9.39.2025.07.08.04.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 04:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752004793; x=1752609593; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GHvIfEToA34AUrJx/MLc8GOT8YL8A2v7KBo+787ye5o=; b=qFiHFrQ1widGsfPhAXm+DLkMs75WW19/ihPMhrXjg/4jHcQkFDaOozUEwGMXdRooCP t5RI05J5A2QUfAMs3cvbECENtMcqNXWTgcEkfPI2MHzsQV3ms4goOc8jWEu5HUV0Qmrd KJhdFAlsdnVpVlL79OXcYRArGd3BaJ4tWis2D5J4C0w1cf7onCpXapRMbY66pj96V73t gSDhDStcDl7aVB1zkfFPbUGtK3ab087bF121Nl2+RXnzdgCfXV715C5m/RH3SD5mMoJU Wcqplo7XFQythZRIUZyCEMLfTa0zdutw+uBCA8CtA8vdfXf8n+3kkT7X+5h5f6eAe9XM 2jSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752004793; x=1752609593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GHvIfEToA34AUrJx/MLc8GOT8YL8A2v7KBo+787ye5o=; b=OQvMc5g+EecgWYTP0IpHZgPcaybXMqRFi1FTVUGQP0W2Gz2NFVKToYXP0uIfVhYydP ZQn0OwirTxHB1lzooOCXL7/MebEsKkpuhwRggfbjFqxxp5UZyikfPZCXjOjt0f79+jGr qDzQ7aiV+/lZdQGNH5u9SN4fxRMY6FhcmdNhOpLhtOZvA5YJ6Y9ep9xtDm/LS5dlHek/ HyXtv7PvucO7+9f9DaQp/8aEIxIBT4T6tTv6i8mW+6a2+mwnmNsIe6hJ5eS3Zm7/QO14 73BdMNzaBx4NU6tgQBqjM25FGvgvXuDQ5FhBkhqCfqgUAXdXfS3R00gLT75R0I3U8hjV MNfQ== X-Forwarded-Encrypted: i=1; AJvYcCU1arLvOTr9Vek4VRqMfDlcN6GutTSb9BVMMcbKCw2m1dpni1UKY+djAb1FwuCfUAcbUoSQfhPASA94@nongnu.org X-Gm-Message-State: AOJu0Yz0wdiWHzcLd1eEKfoL0R0eyt0VcPdBAsnhnql0onRQshXwxpZR 5hFbxFdXsE8BA5mvW3h1hjWNta51BrbaeW2Bwmc9adOBBUrxStDbTf/zGtr/rRHryCzwROFaVGV WrTEx X-Gm-Gg: ASbGncu4C++hgy5mALmy0a6PH5tlMgYlGhmfbhnX328Sc3gcVRTfyKSdrPiTKUKDcCr IYBrM62LFzh1JOW5pk5U3AwL8P8/rWyYB1JPdF56mKUdgN2woazPneK6rphPd3/wWMvK52Akahp OTqeDPs9lsAcxIlXeS8hIxNpp9yC9dF8Yms1dE9zJdhxSjZKQVr8jO8hOILTvYAt9ANE9aj8NZQ drX/HV79EjYYCV3gtcgkVW6I22/V2w2dvlfiyI8wxB+MXbSKF2dj9X7ys2VNen4zLepEn/Avo5I DPZ/yDD3ezkrHWWNvuDpN7yrLsLE0aKDvJOE5N7e1pKeA0kbUS+QpL/4pbA5W1INbV/P X-Google-Smtp-Source: AGHT+IG+A4X0nnNLJ5sc21KLUiKDswTMHI3fl5bj3zzRZZnPwB57X4e5Jvn63jQmNfRazRUKGQKb1Q== X-Received: by 2002:a05:6000:400b:b0:3a4:e8c4:7a78 with SMTP id ffacd0b85a97d-3b5ddf02cc6mr1893228f8f.52.1751975562263; Tue, 08 Jul 2025 04:52:42 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Eric Auger Subject: [PATCH v2 1/3] hw/intc/arm_gicv3_dist: Implement GICD_TYPER2 as 0 Date: Tue, 8 Jul 2025 12:52:36 +0100 Message-ID: <20250708115238.667050-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250708115238.667050-1-peter.maydell@linaro.org> References: <20250708115238.667050-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::12e; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x12e.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @linaro.org) X-ZM-MESSAGEID: 1752008250283116600 Content-Type: text/plain; charset="utf-8" The GIC distributor registers GICD_TYPER2 is present when the GICv4.1 is implemented, and RES0 otherwise. QEMU's TCG implementation is only GICv4.0, so this register is RES0. However, since it's reasonable for GICv4.1-aware software to read the register, expecting the zero for GICv3 and GICv4.0, implement the case to avoid it being logged as an invalid guest read. Signed-off-by: Peter Maydell Reviewed-by: Eric Auger Reviewed-by: Richard Henderson --- hw/intc/gicv3_internal.h | 1 + hw/intc/arm_gicv3_dist.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h index bc9f518fe86..fc586524f56 100644 --- a/hw/intc/gicv3_internal.h +++ b/hw/intc/gicv3_internal.h @@ -31,6 +31,7 @@ #define GICD_CTLR 0x0000 #define GICD_TYPER 0x0004 #define GICD_IIDR 0x0008 +#define GICD_TYPER2 0x000C #define GICD_STATUSR 0x0010 #define GICD_SETSPI_NSR 0x0040 #define GICD_CLRSPI_NSR 0x0048 diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c index d8207acb22c..a7d10ed9493 100644 --- a/hw/intc/arm_gicv3_dist.c +++ b/hw/intc/arm_gicv3_dist.c @@ -431,6 +431,15 @@ static bool gicd_readl(GICv3State *s, hwaddr offset, (0xf << 19) | itlinesnumber; return true; } + case GICD_TYPER2: + /* + * This register only exists for GICv4.1, which QEMU doesn't + * currently emulate. On GICv3 and GICv4 it's defined to be RES0. + * We implement as read-zero here to avoid tracing a bad-register-= read + * if GICv4.1-aware software reads this ID register. + */ + *data =3D 0; + return true; case GICD_IIDR: /* We claim to be an ARM r0p0 with a zero ProductID. * This is the same as an r0p0 GIC-500. --=20 2.43.0 From nobody Sat Nov 15 12:43:54 2025 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1752010938; cv=none; d=zohomail.com; s=zohoarc; b=FBb9RNV1ajYrtAxh7JxbWzq1EOaTfD+J40V++pM6v4f++FMSPpenxeGlDF2qQPUxhx1kTzpN/C8EYHHOr0l2xWa5Zk9y6fQwturFiIInwNQFz/DR30tkQ2f5qdtMCC/4waWF9+AfUxB21x1y06Bl1w1psNMg6ll9hPKsHb2fNds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752010938; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gt2m6Pn6JVQPqk/mSrP0CK0ENC9R9D3MSBFUWpA9k1g=; b=EpO3ePlGSCxG4oQs4uWAYeYReydqwq9bKurUn3fJ2Hq7ah3gd9St3YQoaQVdd/UqRm2X3jkpXcLyxvyR/thRIKOCa9Gy/pk4sLB9C4ISnBugC94I5QcdEKAXxlW0yVAuhX9k0f6OdCp+CCfDQM+thjKlsNUJnMHIZ+mLPmJY03U= 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 1752010932989803.5868976370954; Tue, 8 Jul 2025 14:42:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZG4W-0008IJ-HV; Tue, 08 Jul 2025 17:41:53 -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 1uZEx2-0004cB-03 for qemu-devel@nongnu.org; Tue, 08 Jul 2025 16:30:07 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZEwz-00088G-4q for qemu-devel@nongnu.org; Tue, 08 Jul 2025 16:30:03 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-32f3ef6178bso7181571fa.1 for ; Tue, 08 Jul 2025 13:30:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-454cd4a68ebsm19731255e9.39.2025.07.08.04.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 04:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752006599; x=1752611399; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gt2m6Pn6JVQPqk/mSrP0CK0ENC9R9D3MSBFUWpA9k1g=; b=S8e6WaRg1WL26cSSAy/oe3L7anUfVUtEWGXPd0/PuSk2zLfQQM2SmcMkLcBVuMSuQR LbEvvOeJZ4ZZDlsIeKfRFCnmt1Fm1GykTZOZidIzkR1gQ63IcPV5LQpOW1+4n6+XxQjf eisPi/M9fdymjrBwEhqD5k9cSJlZcjyB/yC0OovOJrwPSGls8Xy+u6yVuDDc7x+VdLQ+ P05dRh33hOXGsW3JQWBoPYQT9pLy6A7jP4sTIOZKdmOsDyOqB/RdqAAJHNN6iuNGE1gl qqsKw3ypsA+aIiST+hsvV82bebp7dtCkjKdZLi8OTeKqpjQioiuWaTSdA1cJlSQT/yYT QOXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752006599; x=1752611399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gt2m6Pn6JVQPqk/mSrP0CK0ENC9R9D3MSBFUWpA9k1g=; b=GpeXlt0Rh1VeoEOzIIc6hWgfjigoDewLByx1yPcmxkgFqHLModUzG/WSJWd1BTi5Cc kjtvhT1Xmpy/CIgX8qFcMYlac322y0kNRQlO4+76g/dPypja6VP7ijjuuZ5soyvtH0UB IqMilgg4QJKRDl/jcbik4fXwDAR9548eDZtc8sRme9UpW9V+NrmQ2kBae/QeFMYBEQO5 rmB4Ef9d948/vLGyvz6SSgRlnyKtoZr+0ue3rYwCr5alImpN5SBs5dxhNf28FRCZ+CbW ck8Y46OqKk93qtXWcr0N7Hr9pMo1FRWIXWzEh7cvX85NL/A/1IodV16S6e+o6/R9SBND 6qmw== X-Forwarded-Encrypted: i=1; AJvYcCXDv0nCuHG62vccev9OuAnBfUu3yOYBpuXn7SniSzHzwoakMRFiW3a5djj0fGpLLFcnvsm6u7292xho@nongnu.org X-Gm-Message-State: AOJu0Yy+r1K9roD/9zFwsG5r/HKgTdk9okeLSEdveeGJpmjXDrm7S/N/ WBadEQFIuGGrP5CRwMCjHyqonS6RVojiNo0tsdsUpDTeJGgYvhQhd8FQkQTx8o5pjWshLncwqL3 kA1oC X-Gm-Gg: ASbGncsrMZ2OB+d9f7GtOYauHoWIkpQTzD3MIRX84TfHxsOwCmBKPbi3AvdjxctuJlv qqBUL+l7XsIvHy/sq0N7RUoWjNnXF57OQB+XiGp+vIl7sD1QGjMgAAmukj2gJwN/53oUbLtacQ4 iO5Hb+oNebBf7qYd9CEE3R5LjQYwHKX54mBJgybwtwvxDhAI/M1yYlJBCrNeHk+1bl+0h0+Eqa9 vNies5JI03w169A7y1lzVaNpVCmrdt/ZcDsoLZOAh6hy+Gthe69fz49Gg94j5bS83gM2neSmfjk ZlEQ6FMeSGi16lxsUO0V4JnQ6bLIegzn9qm7ORZ4yslq0Ypeg2tYBKkLbBDlpya9d+n2 X-Google-Smtp-Source: AGHT+IE+L0yyX0pqFiJ3uAV6sFE1o6IeVh74gnbcE4SKwIJoSVN52SpMbF87UHOdIMUbTOSf5tVLwQ== X-Received: by 2002:a05:6000:2209:b0:3a3:7115:5e7a with SMTP id ffacd0b85a97d-3b5ddebd150mr2232338f8f.42.1751975563813; Tue, 08 Jul 2025 04:52:43 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Eric Auger Subject: [PATCH v2 2/3] hw/intc/arm_gicv3_kvm: Migrate GICD_TYPER2 Date: Tue, 8 Jul 2025 12:52:37 +0100 Message-ID: <20250708115238.667050-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250708115238.667050-1-peter.maydell@linaro.org> References: <20250708115238.667050-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::22d; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x22d.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, 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 @linaro.org) X-ZM-MESSAGEID: 1752010940342116600 Content-Type: text/plain; charset="utf-8" The GICD_TYPER2 register is new for GICv4.1. As an ID register, we migrate it so that on the destination the kernel can check that the destination supports the same configuration that the source system had. This avoids confusing behaviour if the user tries to migrate a VM from a GICv3 system to a GICv4.1 system or vice-versa. (In practice the inability to migrate between different CPU types probably already prevented this.) Note that older kernels pre-dating GICv4.1 support in the KVM GIC will just ignore whatever userspace writes to GICD_TYPER2, so migration where the destination is one of those kernels won't have this safety-check. (The reporting of a mismatch will be a bit clunky, because this file currently uses error_abort for all failures to write the data to the kernel. Ideally we would fix this by making them propagate the failure information back up to the post_load hook return value, to cause a migration failure.) Signed-off-by: Peter Maydell Reviewed-by: Eric Auger --- v1->v2: * fix comment missing bracket * fix reset handling so this works on GICv4.1 hosts * move get/put code to be with the other GICD regs --- include/hw/intc/arm_gicv3_common.h | 6 ++++++ hw/intc/arm_gicv3_common.c | 24 ++++++++++++++++++++++++ hw/intc/arm_gicv3_kvm.c | 25 +++++++++++++++++++++++-- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3= _common.h index a3d6a0e5077..bcbcae1fbe7 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -267,6 +267,12 @@ struct GICv3State { GICv3CPUState *gicd_irouter_target[GICV3_MAXIRQ]; uint32_t gicd_nsacr[DIV_ROUND_UP(GICV3_MAXIRQ, 16)]; =20 + /* + * GICv4.1 extended ID information. This is currently only needed + * for migration of a KVM GIC. + */ + uint32_t gicd_typer2; + GICv3CPUState *cpu; /* List of all ITSes connected to this GIC */ GPtrArray *itslist; diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 1cee68193ca..7b09771310e 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -275,6 +275,29 @@ const VMStateDescription vmstate_gicv3_gicd_nmi =3D { } }; =20 +static bool gicv3_typer2_needed(void *opaque) +{ + /* + * GICD_TYPER2 ID register for GICv4.1. Was RES0 for + * GICv3 and GICv4.0; don't migrate if zero for backwards + * compatibility. + */ + GICv3State *cs =3D opaque; + + return cs->gicd_typer2 !=3D 0; +} + +const VMStateDescription vmstate_gicv3_gicd_typer2 =3D { + .name =3D "arm_gicv3/gicd_typer2", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D gicv3_typer2_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(gicd_typer2, GICv3State), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_gicv3 =3D { .name =3D "arm_gicv3", .version_id =3D 1, @@ -304,6 +327,7 @@ static const VMStateDescription vmstate_gicv3 =3D { .subsections =3D (const VMStateDescription * const []) { &vmstate_gicv3_gicd_no_migration_shift_bug, &vmstate_gicv3_gicd_nmi, + &vmstate_gicv3_gicd_typer2, NULL } }; diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 3be3bf6c28d..8e34d08b415 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -405,7 +405,16 @@ static void kvm_arm_gicv3_put(GICv3State *s) } } =20 - /* Distributor state (shared between all CPUs */ + /* Distributor state (shared between all CPUs) */ + + /* + * This ID register is restored so that the kernel can fail + * the write if the migration source is GICv4.1 but the + * destination is not. + */ + reg =3D s->gicd_typer2; + kvm_gicd_access(s, GICD_TYPER2, ®, true); + reg =3D s->gicd_statusr[GICV3_NS]; kvm_gicd_access(s, GICD_STATUSR, ®, true); =20 @@ -572,7 +581,10 @@ static void kvm_arm_gicv3_get(GICv3State *s) } } =20 - /* Distributor state (shared between all CPUs */ + /* Distributor state (shared between all CPUs) */ + + kvm_gicd_access(s, GICD_TYPER2, ®, false); + s->gicd_typer2 =3D reg; =20 kvm_gicd_access(s, GICD_STATUSR, ®, false); s->gicd_statusr[GICV3_NS] =3D reg; @@ -707,6 +719,7 @@ static void kvm_arm_gicv3_reset_hold(Object *obj, Reset= Type type) { GICv3State *s =3D ARM_GICV3_COMMON(obj); KVMARMGICv3Class *kgc =3D KVM_ARM_GICV3_GET_CLASS(s); + uint32_t reg; =20 DPRINTF("Reset\n"); =20 @@ -719,6 +732,14 @@ static void kvm_arm_gicv3_reset_hold(Object *obj, Rese= tType type) return; } =20 + /* + * The reset value of the GICD_TYPER2 ID register should be whatever + * the kernel says it is; otherwise the attempt to put the value + * in kvm_arm_gicv3_put() will fail. + */ + kvm_gicd_access(s, GICD_TYPER2, ®, false); + s->gicd_typer2 =3D reg; + kvm_arm_gicv3_put(s); } =20 --=20 2.43.0 From nobody Sat Nov 15 12:43:54 2025 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1752011035; cv=none; d=zohomail.com; s=zohoarc; b=KP1xlhdvM4K8fmdbM5owNV4+QFF5He1k+tcS0EWxbQmjhvxAAhaLPrFRd0DbxXvyHoQGdBohm7zUiuXXEBlHfV3XiUsVoPhSAt+hFKxLZvuOMOkRvT8wKPL2+qWDYhDPwsjUe/LT6Hgjf6+r326cmZfis3ZXJCVC0cQqgodR+KI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752011035; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VK+7t2j2kymFsc3IeGpMe2sULS+2lCNmhWxaVyDzmrY=; b=bBVX24bLB2R2JeH4p/3xQ+vJ5AxLHBinpAt3xtBqmbOmJnNSgHDSR3zvTyyqgtWzOH9sOekeKqd/4XrE6+uc65Ji5NRh0zsFT8YW61QD1AAu4psiY6oTcdjik76tofZjjdQN3QnfTUTJIOTMpinM3wFIf4xJlj5gen/QD4zHll0= 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 1752011035902234.80422547067474; Tue, 8 Jul 2025 14:43:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZG4g-0000WY-Dm; Tue, 08 Jul 2025 17:42:02 -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 1uZEtC-0003Lr-DO for qemu-devel@nongnu.org; Tue, 08 Jul 2025 16:26:06 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZEtA-0007oY-JU for qemu-devel@nongnu.org; Tue, 08 Jul 2025 16:26:06 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-6097d144923so598064a12.1 for ; Tue, 08 Jul 2025 13:26:04 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-454cd4a68ebsm19731255e9.39.2025.07.08.04.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 04:52:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752006363; x=1752611163; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VK+7t2j2kymFsc3IeGpMe2sULS+2lCNmhWxaVyDzmrY=; b=kuelZM96BGQ4UgIT2GY77PxZOSZR6UHPs8QaOaTLzA2fk8gTStMPyYx9uLVHCrWJwt +trvQtSA11n5PES8BV0HaedThyXYx/X1ybE12VjiA17mb2b+9vJdwxTCFZKYbK9BLaqh a4w7l2qr4/RoJzhSLzfREOBYz6OSI59VaySlYbF+kjhMAujAuWCCO1rgWjtUQmGKptcc YFpsHA1go5SSyV2NnYEMHtB6zWaIyhI+lnslNHD5FFN7xgx4CVmrQCXHFML+7izxVk+f b0F8RXsU4uUVKqRxfEDiPSsaQqSeTJ+e2ygeR52O3wojvdftkGkmR7o/43SAStGpQbmF 3zhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752006363; x=1752611163; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VK+7t2j2kymFsc3IeGpMe2sULS+2lCNmhWxaVyDzmrY=; b=SGQKEOVP9R3NnHhxGRJR5ofeMxmQO0BohaqeI13WMiuhKOlmd3p5sX7d2JeQ1euyDz vGMmSh25FDHRSV+6wUkI89xmmpJnrYljWJHV+bt1xjOt36onWUuCs4+TOoc+hPycONwN axFmwdO0H7q/USUcmm28XWqyu4yG0DjlrjRraYFDAu+f06c7x+0zZ6hZSXvVtKj5srUm oa+Dc/vdzoCw25OwkWbnGftZHwDkBbH8zMaBRS2j+lrpBZifyXSClwNd2LtA7VTf7Bfa a5YCMORBi+J3etdRYCAEdiLYckuXDoX1NIDlTbWKS4/Y99r/7bpFLtxlFk1Mvdlo4KyH tIug== X-Forwarded-Encrypted: i=1; AJvYcCVN+G/FsvaWAvqoVRrKc3VjNCz4kxOdmSfaTJS7mZJ8ObwY7R8pL+VXhEBZYDAtFllcLZribQoQx5ke@nongnu.org X-Gm-Message-State: AOJu0YxHI6fSmXvHcBQpNzzrzcKpIh43rl5IibYLUxM92Gc51C/xe7+r iYyMFKm8dhQ+LJtFgUPSYg4G9xUNLTf9Zl3jd10QRONLYtHIoSz0N0FmOO5nWM2wSqP+ZBhamXX NLCWq X-Gm-Gg: ASbGncugc1Y8YGQyhBsf0gOodB2q80zQewK9dil7egHetwKKZw8ip84nHBvtcl8QKP8 yVqoBWHTmCc7yeYbaSoyO1PYGk54PHRf1COVbgOnTtRmj8fWxXHRkFHzJ+nBj/lOco5mk3n5sKz hppG500qB4xuzbKJWzGkYGd61jvM2W+Zs2Y/+gSL925LcDFVmU+w1DOAeW7hK2N33kfUe+RCfuf C02jSHsNTBMoE2cpUhHRljMbIE39DOiYa639aeOv9tv/5azw0hy8/YUT6ARq1G9Nx4K6XjzLdEW g7yuN2SzYLHglixILpKHeplzPz8mgyE7kt8S32VLMQK1L4VpUuNAhBIjj6AW+XKDCxDi X-Google-Smtp-Source: AGHT+IGALo4sVNBgG4JPDbkGK0xlAvZZ58lvqIhuwe9o8VqKKyz/RfIsQzbeyBd1YX8sRyHbJdn8Wg== X-Received: by 2002:a05:6000:250d:b0:3a5:5136:bd25 with SMTP id ffacd0b85a97d-3b5ddfb8b30mr2465893f8f.1.1751975565039; Tue, 08 Jul 2025 04:52:45 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Eric Auger Subject: [PATCH v2 3/3] hw/intc/arm_gicv3_kvm: Drop DPRINTF macro Date: Tue, 8 Jul 2025 12:52:38 +0100 Message-ID: <20250708115238.667050-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250708115238.667050-1-peter.maydell@linaro.org> References: <20250708115238.667050-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::530; envelope-from=peter.maydell@linaro.org; helo=mail-ed1-x530.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @linaro.org) X-ZM-MESSAGEID: 1752011037130116600 Content-Type: text/plain; charset="utf-8" We don't generally like DPRINTF debug macros, preferring tracepoints. In this case the macro is used in only three places (reset, realize, and in the unlikely event the host kernel doesn't have GICv3 register access support). These don't seem worth converting to tracepoints, so simply delete the macro and its uses. Signed-off-by: Peter Maydell Reviewed-by: Eric Auger Reviewed-by: Richard Henderson --- If anybody needs to debug this code they can add useful tracepoints at that point. I don't think these DPRINTFs will help at all. --- hw/intc/arm_gicv3_kvm.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 8e34d08b415..e118c1b1f04 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -34,14 +34,6 @@ #include "target/arm/cpregs.h" =20 =20 -#ifdef DEBUG_GICV3_KVM -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, "kvm_gicv3: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif - #define TYPE_KVM_ARM_GICV3 "kvm-arm-gicv3" typedef struct KVMARMGICv3Class KVMARMGICv3Class; /* This is reusing the GICv3State typedef from ARM_GICV3_ITS_COMMON */ @@ -721,14 +713,11 @@ static void kvm_arm_gicv3_reset_hold(Object *obj, Res= etType type) KVMARMGICv3Class *kgc =3D KVM_ARM_GICV3_GET_CLASS(s); uint32_t reg; =20 - DPRINTF("Reset\n"); - if (kgc->parent_phases.hold) { kgc->parent_phases.hold(obj, type); } =20 if (s->migration_blocker) { - DPRINTF("Cannot put kernel gic state, no kernel interface\n"); return; } =20 @@ -807,8 +796,6 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Err= or **errp) Error *local_err =3D NULL; int i; =20 - DPRINTF("kvm_arm_gicv3_realize\n"); - kgc->parent_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); --=20 2.43.0