From nobody Sun Sep 28 16:28:05 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=1756381148; cv=none; d=zohomail.com; s=zohoarc; b=T5Plqcsi29HNqH8DW3wgtZuAhFIal8WB21m52xVi9AAmDNJC7Q2IHxPWpcDbJ8Ggr38hQeEXRc6lSHQV6OnkLknLxsVSv1G6TzWopCa86vZIbAyTTix7q177blTSRGh5TMrlSPb0Z31NC38qrb53H6V+kINnWi2Vf2BTqZbPpJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381148; h=Content-Transfer-Encoding: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:Cc; bh=5NYkoNij4e1g8y7W2fjcFu3t+VJEH8mC1LfM/lquNuQ=; b=LD17LCrENDZbeTnvVXxYxuqkEzynSnfkI6DGfWbYh2L5sMydnCyObfAlL8LxCT/JmdweKegYStoy7ekWq393Zxvze+ZHY6/OcVuQicEZLR78LTwjJODH8WbLTxOGiYQkXrPqMd6H+Uhi02Dk+xvx2o2ZgL0uB+ZDJgMM+hrqWwg= 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 1756381148002392.76888503782504; Thu, 28 Aug 2025 04:39:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uratz-0003Ge-FZ; Thu, 28 Aug 2025 07:34: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 1uratp-0003BO-VB for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:39 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratn-0005bW-L1 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:37 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45a1b066b5eso4390635e9.1 for ; Thu, 28 Aug 2025 04:34:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380874; x=1756985674; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5NYkoNij4e1g8y7W2fjcFu3t+VJEH8mC1LfM/lquNuQ=; b=ZNEhQp7HsTjcUVE1yzF0pPWeV6PW6W1Ku+1OZR3uuntRigR71C7zAYWi8/RCGNfRnW RHXCPFWVHRShgRwD3sngqcFDvpdxpWMr0u/uQ4NOYIfIX18npxf9kazT/hUKynDi8pMQ tyoCzuC5xOxIkPAikJYwMo5bkYNfQbaiOA9Sn19oYq14+2gzY9hiiNshmf5RH9iUZBxf XwLgfJeUZHXdXhfPapbaac0LYa76tRG0m2q/NFzMgvDn5o4mloS7ISZvrwxISLxs6Zhz vTk0TsCaUXR4k+/UsXzidVEw0bw3j9S4YZN7O2zPGzAQXbCURX19k+hKmvBIHB/0S2Yt QWhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380874; x=1756985674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5NYkoNij4e1g8y7W2fjcFu3t+VJEH8mC1LfM/lquNuQ=; b=BGNWsmnI2aDwBaPiXHe314iX7AbtoEdkvY8qXbvGnlItpxyzLRuNbojIZ0A67EMod5 TK6jcUU/HnHUHTtaqjNQO99y60Gy59Be7QV4DDMBsGgM+0VYf5JVUiQBIN4jT5SOMjRI qm1574Q4mNAncvgzfmvuZ98D3ld2leWZjORy31DhSNaSSGTZ+H/I77x8fpF1Hppi/mX+ /MhFizlGdbUXWbG7K2/Rcqa+9Up85/JXzTjGhCfJdr4TmeL7dkFGYMx1k0ifOvoYAYjg q7U9pa8qY5EYo75pK/H3UBGandXw6azo9k1gL5NsOQ2y/0y+ZZIHCyaScyaEXy7gRzic T3kw== X-Gm-Message-State: AOJu0Yz0w7LyqT3Wa6JxTTHSqLPGTFb8sSxGKrnRUakU59gFvl9e/4VD 7au7mlXYg2zogSTLnTg56uXFY96Fn28iY6Rt9tuEMOH+aqyjPSXzwarwo1r5Og17tbO5mSxoyzo nYsNN X-Gm-Gg: ASbGncs78pegISWxJf5OgIjrLMnVB3Nr2eUR09Skq8WuM/O6nc32+WkxY5Z+zNFWjZx ngFerbQzkAAlK5LsgOMp0RePt5EJDPTUsqRF/vO5YmUEOGp43nvd5ag7RFC/ElkH9Z5RrGezRJL XfN0G1zyL318uyYtLn1uO5lPe9Ut0PLr6mxAvEgelaUdBOa9gO6g9tu9eOjb8i+lW8gHOwZpzwf kjMzmnUrQw0Wt+l1lZe1RcVGATEp12bsDwRIxNRUH4xYrBw06LEXv+xKwAR2eRRh97Ed9WoIBHO bk4vlCfhcJGchj0c9NeGnPf89ssjN5xaxTu/i1qIn+ENfpeN/0FBlfep9r4kScrMRGpf/8lgxV+ 0c9No+6p1uwpNcPftoeoNoARkJpbNloYghWrJJE4= X-Google-Smtp-Source: AGHT+IFHeICz5Ipcyh6m2s5kfYPyoZ3DWx8Dr0vpfoFKBwHEKcTKybSqPzBfR3V3+Qpf4Qbw4SnAuw== X-Received: by 2002:a05:600c:1d26:b0:45b:7c20:5709 with SMTP id 5b1f17b1804b1-45b7c205c14mr14202225e9.12.1756380873937; Thu, 28 Aug 2025 04:34:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/32] target/arm: Clean up of register field definitions Date: Thu, 28 Aug 2025 12:33:58 +0100 Message-ID: <20250828113430.3214314-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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: 1756381151033124100 Content-Type: text/plain; charset="utf-8" From: Gustavo Romero Clean up the definitions of NSW and NSA fields in the VTCR register. These two fields are already defined properly using FIELD() so they are actually duplications. Also, define the NSW and NSA fields in the VSTCR register using FIELD() and remove their definitions based on VTCR fields. Signed-off-by: Gustavo Romero Message-id: 20250725014755.2122579-1-gustavo.romero@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/internals.h | 8 +++----- target/arm/ptw.c | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 1b3d0244fd6..3f86b070447 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -113,11 +113,6 @@ FIELD(DBGWCR, WT, 20, 1) FIELD(DBGWCR, MASK, 24, 5) FIELD(DBGWCR, SSCE, 29, 1) =20 -#define VTCR_NSW (1u << 29) -#define VTCR_NSA (1u << 30) -#define VSTCR_SW VTCR_NSW -#define VSTCR_SA VTCR_NSA - /* Bit definitions for CPACR (AArch32 only) */ FIELD(CPACR, CP10, 20, 2) FIELD(CPACR, CP11, 22, 2) @@ -220,6 +215,9 @@ FIELD(VTCR, NSA, 30, 1) FIELD(VTCR, DS, 32, 1) FIELD(VTCR, SL2, 33, 1) =20 +FIELD(VSTCR, SW, 29, 1) +FIELD(VSTCR, SA, 30, 1) + #define HCRX_ENAS0 (1ULL << 0) #define HCRX_ENALS (1ULL << 1) #define HCRX_ENASR (1ULL << 2) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 561bf2678e5..ed5c728eab6 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -193,9 +193,9 @@ static ARMMMUIdx ptw_idx_for_stage_2(CPUARMState *env, = ARMMMUIdx stage2idx) return ARMMMUIdx_Phys_Realm; case ARMSS_Secure: if (stage2idx =3D=3D ARMMMUIdx_Stage2_S) { - s2walk_secure =3D !(env->cp15.vstcr_el2 & VSTCR_SW); + s2walk_secure =3D !(env->cp15.vstcr_el2 & R_VSTCR_SW_MASK); } else { - s2walk_secure =3D !(env->cp15.vtcr_el2 & VTCR_NSW); + s2walk_secure =3D !(env->cp15.vtcr_el2 & R_VTCR_NSW_MASK); } return s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS; default: @@ -3372,9 +3372,9 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, */ if (in_space =3D=3D ARMSS_Secure) { result->f.attrs.secure =3D - !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) + !(env->cp15.vstcr_el2 & (R_VSTCR_SA_MASK | R_VSTCR_SW_MASK)) && (ipa_secure - || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))); + || !(env->cp15.vtcr_el2 & (R_VTCR_NSA_MASK | R_VTCR_NSW_MA= SK))); result->f.attrs.space =3D arm_secure_to_space(result->f.attrs.secu= re); } =20 --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381058; cv=none; d=zohomail.com; s=zohoarc; b=cF+ZIFZznAS90+Eh1p8A7GK5S0POA52p0zp9sbctnFUWjNM1m/Y72hbY3tRaLrkpwvrZT9dyvYmvMCbq6jpdLCfs6huRulq6RLWj/qSJb3kCNPCd7QVIrFtGqA36cIoy3eOoDyAJyz7hRUpw2Fa5x/GgCodRgxtFIrDEzmR9FGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381058; h=Content-Transfer-Encoding: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:Cc; bh=g+Lwtf9Dc+UeK2oirT2wByiuRWQQHV3LBajiD+TT9Lo=; b=ZV/V97VeAnxQW9snpClrDYP8Uy3G0NJ7mhbIa8qVJSTiLT01ZvhYa+ILXkzRnghPCrnQ41D78hxmCMMDasPJrDMcp7SgJHT8bVC4urXnMswUV0DZmRbgz6+nZePkvOiKAfoiYiHpJQyguZxeKpSHVxmVuwEGfjLO+XYz5nSktG4= 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 1756381058683193.8040261168528; Thu, 28 Aug 2025 04:37:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uratz-0003F0-B1; Thu, 28 Aug 2025 07:34: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 1uratr-0003Cz-MP for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:39 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratp-0005c9-EH for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:39 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3c854b644c1so580118f8f.3 for ; Thu, 28 Aug 2025 04:34:36 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380875; x=1756985675; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=g+Lwtf9Dc+UeK2oirT2wByiuRWQQHV3LBajiD+TT9Lo=; b=vuhfuTZQq83XwNSJuBG9+09UzP86FIPFCeuRumrYK7bEIXhDq+qinJQk2s9bkytuB7 LNmeN7z11VhnD8Fo8UadpESWZxJPktWSFwIIjtLGUBOeZeUnwebz0x3WI0QGXZJRlekX jo3KV7UxPu9Wb2de02gxoHg3aY0sMJW3VEZAlTAM5qrH6nJq2gObFRlUYr2kWuhdkKu/ Zf8DVdf7hNxcs91U2WOe5ODFBGqSPSuhcuOLq7EFEc3Z3+f4TCzbLbnA4pwMyT9nTJEG NhXvJs6t63wlLv1rN6e+3sNuzG1uAqSTOCD6Cb1pKc0NWMoVRD76ETgXFZRyXV56PbuR O6hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380875; x=1756985675; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g+Lwtf9Dc+UeK2oirT2wByiuRWQQHV3LBajiD+TT9Lo=; b=S3heykD0woJl6UEOfVGIbFiX4GHJS1k7C68gFSxXT/YQhM66Qxl72gZuCiT4HS3ygm 7RWBPTpJd5Yz8hCoO+1K8RbNxHlxI7mhD/1FE8SqMRi8UbIivMziHJt7AW7yStgfMPJF 2MX7JYD8kAlR6Y2Dhy02tYg0d2ZPdl3NB8CYJizpPVU99fkK9zgc4hifgPzAaMNIdqRZ kx2ss0ikpOHdkqDs3rX2qxd47DuhlE+nnxnlV5LHOYRGpojHNrb0Y+3EV8CaH0g5Ca2X LGnAKzCoJdk22d+QfCG34MhjxUGl9EyukhNY3pIaFl1zRcLnxBo08fEb4YKcO3ZcEc++ zHbw== X-Gm-Message-State: AOJu0YzY25+ut8TkTDb2vsU6c8nLe+NlH99l/iimJOYMxItVfYSlCC6U akiyE6aq9I25CxJaLH3h0bIXstJOI7rUzGUjMRxbXv0gkgujD+nqHqu8XIzQiBQ+si3kNaup8ma QC/7b X-Gm-Gg: ASbGncu00lT58DDow7QyORnKIF5mFVYmy064NH7qkkx/4VgOvFcRnG4INlqWlK2+M4L KmFkzgh87R1yFvS7J7C47HPHRZE8uUokx3F0FLb8If8T7E5vj9zdbLdmigLykLfnLNYixeCqKmY +mfUVsfUTsbHcgDAvh0qdb71Hv8spYd3gl05Y5Es3FO3bugFcCgppy/8IrL/piCb62JIlJOK6NU DuJBJbj2tZArJIK0LIOU8n+IVTCtDOsToEiTdlbxavpU1smdb3nRr20Y5uOBCPxxnYpXu/zCAHz Hngy8SKjWsqL7rq1DRAQqlrE6aAuZpfbc6d6HHEq5XEpTRWCPec3JRI8DFco49/iHRxaAdlcy+5 b+9oB2t/2shU1XXK4N9i8wdUSfNAtDAiQUPvT7W8= X-Google-Smtp-Source: AGHT+IEm8Nwu7YjSNPM2yT7tmqkI82DwZY7HTuf7JD/zCCDMhHFj5jI3OGHE5Rjw2pDvhd5ICWuamg== X-Received: by 2002:a05:6000:647:b0:3cc:a43e:722e with SMTP id ffacd0b85a97d-3cca43e747cmr3304121f8f.24.1756380874983; Thu, 28 Aug 2025 04:34:34 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/32] tests/functional/test_aarch64_device_passthrough: update image Date: Thu, 28 Aug 2025 12:33:59 +0100 Message-ID: <20250828113430.3214314-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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: 1756381059969124100 Content-Type: text/plain; charset="utf-8" From: Pierrick Bouvier TF-A needs to be patched to enable support for FEAT_TCR2 and FEAT_SCTLR2. This new image contains updated firmware. Signed-off-by: Pierrick Bouvier Signed-off-by: Richard Henderson Message-id: 20250727074202.83141-2-richard.henderson@linaro.org Message-ID: <20250719035838.2284029-2-pierrick.bouvier@linaro.org> Signed-off-by: Peter Maydell --- .../aarch64/test_device_passthrough.py | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/functional/aarch64/test_device_passthrough.py b/tests/fu= nctional/aarch64/test_device_passthrough.py index 1f3f158a9ff..17437784bbe 100755 --- a/tests/functional/aarch64/test_device_passthrough.py +++ b/tests/functional/aarch64/test_device_passthrough.py @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later =20 -import os +from os.path import join =20 from qemu_test import QemuSystemTest, Asset from qemu_test import exec_command, wait_for_console_pattern @@ -77,15 +77,16 @@ =20 class Aarch64DevicePassthrough(QemuSystemTest): =20 - # https://github.com/pbo-linaro/qemu-linux-stack + # https://github.com/pbo-linaro/qemu-linux-stack/tree/device_passthrou= gh + # $ ./build.sh && ./archive_artifacts.sh out.tar.xz # # Linux kernel is compiled with defconfig + # IOMMUFD + VFIO_DEVICE_CDEV + ARM_SMMU_V3_IOMMUFD # https://docs.kernel.org/driver-api/vfio.html#vfio-device-cde ASSET_DEVICE_PASSTHROUGH_STACK =3D Asset( - ('https://fileserver.linaro.org/s/fx5DXxBYme8dw2G/' - 'download/device_passthrough.tar.xz'), - '812750b664d61c2986f2b149939ae28cafbd60d53e9c7e4b16e97143845e196d= ') + ('https://github.com/pbo-linaro/qemu-linux-stack/' + 'releases/download/build/device_passthrough-c3fb84a.tar.xz'), + '15ac2b02bed0c0ea8e3e007de0bcfdaf6fd51c1ba98213f841dc7d01d6f72f04= ') =20 # This tests the device passthrough implementation, by booting a VM # supporting it with two nvme disks attached, and launching a nested VM @@ -96,16 +97,16 @@ def test_aarch64_device_passthrough(self): =20 self.vm.set_console() =20 - stack_path_tar_gz =3D self.ASSET_DEVICE_PASSTHROUGH_STACK.fetch() - self.archive_extract(stack_path_tar_gz, format=3D"tar") + stack_path_tar =3D self.ASSET_DEVICE_PASSTHROUGH_STACK.fetch() + self.archive_extract(stack_path_tar, format=3D"tar") =20 stack =3D self.scratch_file('out') - kernel =3D os.path.join(stack, 'Image.gz') - rootfs_host =3D os.path.join(stack, 'host.ext4') - disk_vfio =3D os.path.join(stack, 'disk_vfio') - disk_iommufd =3D os.path.join(stack, 'disk_iommufd') - guest_cmd =3D os.path.join(stack, 'guest.sh') - nested_guest_cmd =3D os.path.join(stack, 'nested_guest.sh') + kernel =3D join(stack, 'Image.gz') + rootfs_host =3D join(stack, 'host.ext4') + disk_vfio =3D join(stack, 'disk_vfio') + disk_iommufd =3D join(stack, 'disk_iommufd') + guest_cmd =3D join(stack, 'guest.sh') + nested_guest_cmd =3D join(stack, 'nested_guest.sh') # we generate two random disks with open(disk_vfio, "wb") as d: d.write(randbytes(512)) with open(disk_iommufd, "wb") as d: d.write(randbytes(1024)) --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380973; cv=none; d=zohomail.com; s=zohoarc; b=bCLT94ifU0q87iFvKyB9bWyEkyMb7SlpRG7raWpJWvZ7zvEeJLqYBCYJVqaj2ZN1yBIaDWbxe9vxc3PtzetsQZTa1TwfsQLlRTPyosqo66TCDAQ0k6nydU8xkxAd+p+iWYnOmAfQGThzRrXZouUEGiwXEW9AE366uwP80et/hrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380973; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=xU6DtKahST/Q0lK7j2pNj1bQhcUnlvAusucbHEq/Suw=; b=is54kKoc1RxZBZgbttLy6n+mrNZFB5dY/Wh4444DDSv5SnP9+EZIFu3Q4mCWCWdAhNS8aPsDlb9twRtnkVaT793VjHPClu9xX+I+aJLaEjEf2IcrhzZInVsU8knIpT74VNhpzrTWkt3TQ5kPCMhBBwxozg11g6AIqt7hV9GQ2bY= 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 17563809739111023.6291157238585; Thu, 28 Aug 2025 04:36:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau0-0003IL-Ak; Thu, 28 Aug 2025 07:34:48 -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 1urats-0003DX-8v for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:40 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratp-0005cd-Su for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:40 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45b55ed86b9so4327445e9.0 for ; Thu, 28 Aug 2025 04:34:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380876; x=1756985676; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xU6DtKahST/Q0lK7j2pNj1bQhcUnlvAusucbHEq/Suw=; b=oGmBplU/TCmeTYzJ5gSMDo9+2m9mbDIGD2sMjH7BLSdmzADduGBUSOKMqEjoyBvUop Q3uyoFBqxsA7qK2h9exMmDysAedu30aT+am+RWNzQMn6DwLtXqLi6UXEzBfUHtQi4/Qk Lpj3rlb7EH5Ld601pm8IiM3vrvygB33rd1BjGfP39RVHLDsmNTOdau/LPJw4sg6Bmd+p nH6uYq11W4bjx+Z3dSTaL+q8PNXkpCRC6Z8UDgNSnTvo0tkp+yE9VsB48bmlNY7BDKFB ru04d8oabQ37UpbFCigF1iQW/L070WLHJ1jdsawNZAHs5WU5W2iK36dLRPgXCb0XV74v jA0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380876; x=1756985676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xU6DtKahST/Q0lK7j2pNj1bQhcUnlvAusucbHEq/Suw=; b=DzA3KM9VxtO8Pw7uQNp7bFL/eBeb7thmBjE2QL0lDzCYqK92bBmPHe/7i3uNengCXK Vaenf4e0YOTPzFtIdZCWMjHk8Sng/CLZER+babvTaUChoeWNbzs2b9a6rGAPjuNWbZp8 v4USfwFc66kVbYFPtyq4DQyXSEhNEcwlVOkDmBMuYnr7PgjW81xZD4khB6g3ixoYfayd prDETJYziTWeXdOUxyuH0XHRqb5HWX0XpVCAICm552pAm+cXaWbgoTrM/FFGD+hlS6m2 bBcX2lzbN1de/dY70EeEYQFtf6j3ysajXqT4AKNfCd1nocrUdKPylIaQcCF+GEn7TcHZ HKVA== X-Gm-Message-State: AOJu0Yzh9EuntVb5cPHyeFDjBdFBA8KvTB2HtxAMZDxspeQ7ggwjtTZW Ylmq7Mw7tWfFRyGjQymaiqcb6C8Qdk4ogxBBSEygVNE8eE9XJWC/dedfItkK15oYNbJcZVb8GtS PaSSk X-Gm-Gg: ASbGncuEPFLAqbjl/i4niRjRWK08DCe5/qW8JHCyIkBTYCijABnrJHsaamUwRZZAmCT 3ky/E9oYelNAtzFGiwwtxDrRks3EFodLipUgEn5OCkoqjva1oyGKnpzKjLwS7hbrviifDMIfcdI DvWc4p8ddpGfrQuDod4cee5S+TwRtN0xM4cOVyF5K4/NCPTBm2KSdKsSIJcYyG+L9M0zeRy6rxH iMIu1sQxe+Bth5XM/qUggVg4ujYBaHfn8AwLMy6XWXFLleaMndr/zyiQFhJmd9TKXv0QR1bWbfw t19ZOr3OKUunNR+RP8NCZzJJ4ejTFwzOpGd4ToFyJtRb1vSdMGLvINuy6ATfypC0DlTbpCyBm1K dE3sYrM0+hDrvRkRVmong7RNm07Z8A+AX7aTaRK8= X-Google-Smtp-Source: AGHT+IHRzSwqnkK1HXoQDxf2SbRGNPONMFRQ60xXTHLZOo4yrxuhrDCAAh+8+PU6bfotOzsmOTM6lQ== X-Received: by 2002:a05:600c:3104:b0:45b:47e1:ef6d with SMTP id 5b1f17b1804b1-45b517e0364mr173136375e9.36.1756380876094; Thu, 28 Aug 2025 04:34:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/32] tests/functional/test_aarch64_rme: update image Date: Thu, 28 Aug 2025 12:34:00 +0100 Message-ID: <20250828113430.3214314-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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: 1756380976696116600 From: Pierrick Bouvier TF-A needs to be patched to enable support for FEAT_TCR2 and FEAT_SCTLR2. This new image contains updated firmware. Signed-off-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20250727074202.83141-3-richard.henderson@linaro.org Message-ID: <20250719035838.2284029-3-pierrick.bouvier@linaro.org> [PMM: switch to os.makedirs(..., exist_ok=3DTrue) to improve robustness when re-run after test was cancelled midway] Signed-off-by: Peter Maydell --- tests/functional/aarch64/test_rme_sbsaref.py | 64 ++++++++------- tests/functional/aarch64/test_rme_virt.py | 85 +++++++------------- 2 files changed, 66 insertions(+), 83 deletions(-) diff --git a/tests/functional/aarch64/test_rme_sbsaref.py b/tests/functiona= l/aarch64/test_rme_sbsaref.py index 100f1c7738b..ca892e0a8c9 100755 --- a/tests/functional/aarch64/test_rme_sbsaref.py +++ b/tests/functional/aarch64/test_rme_sbsaref.py @@ -10,21 +10,23 @@ # SPDX-License-Identifier: GPL-2.0-or-later =20 import os +from os.path import join +import shutil =20 from qemu_test import QemuSystemTest, Asset, wait_for_console_pattern from qemu_test import exec_command_and_wait_for_pattern -from test_rme_virt import test_realms_guest =20 =20 class Aarch64RMESbsaRefMachine(QemuSystemTest): =20 - # Stack is built with OP-TEE build environment from those instructions: + # Stack is inspired from: # https://linaro.atlassian.net/wiki/spaces/QEMU/pages/29051027459/ - # https://github.com/pbo-linaro/qemu-rme-stack + # https://github.com/pbo-linaro/qemu-linux-stack/tree/rme_sbsa_release + # ./build.sh && ./archive_artifacts.sh out.tar.xz ASSET_RME_STACK_SBSA =3D Asset( - ('https://fileserver.linaro.org/s/KJyeBxL82mz2r7F/' - 'download/rme-stack-op-tee-4.2.0-cca-v4-sbsa.tar.gz'), - 'dd9ab28ec869bdf3b5376116cb3689103b43433fd5c4bca0f4a8d8b3c104999e= ') + ('https://github.com/pbo-linaro/qemu-linux-stack/' + 'releases/download/build/rme_sbsa_release-a7f02cf.tar.xz'), + '27d8400b11befb828d6db0cab97e7ae102d0992c928d3dfbf38b24b6cf6c324c= ') =20 # This tests the FEAT_RME cpu implementation, by booting a VM supporti= ng it, # and launching a nested VM using it. @@ -35,35 +37,41 @@ def test_aarch64_rme_sbsaref(self): =20 self.vm.set_console() =20 - stack_path_tar_gz =3D self.ASSET_RME_STACK_SBSA.fetch() - self.archive_extract(stack_path_tar_gz, format=3D"tar") + stack_path_tar =3D self.ASSET_RME_STACK_SBSA.fetch() + self.archive_extract(stack_path_tar, format=3D"tar") =20 - rme_stack =3D self.scratch_file('rme-stack-op-tee-4.2.0-cca-v4-sbs= a') - pflash0 =3D os.path.join(rme_stack, 'images', 'SBSA_FLASH0.fd') - pflash1 =3D os.path.join(rme_stack, 'images', 'SBSA_FLASH1.fd') - virtual =3D os.path.join(rme_stack, 'images', 'disks', 'virtual') - drive =3D os.path.join(rme_stack, 'out-br', 'images', 'rootfs.ext4= ') + rme_stack =3D self.scratch_file('.') + pflash0 =3D join(rme_stack, 'out', 'SBSA_FLASH0.fd') + pflash1 =3D join(rme_stack, 'out', 'SBSA_FLASH1.fd') + rootfs =3D join(rme_stack, 'out', 'host.ext4') =20 - self.vm.add_args('-cpu', 'max,x-rme=3Don,pauth-impdef=3Don') + efi =3D join(rme_stack, 'out', 'EFI') + os.makedirs(efi, exist_ok=3DTrue) + shutil.copyfile(join(rme_stack, 'out', 'Image'), join(efi, 'Image'= )) + with open(join(efi, 'startup.nsh'), 'w') as startup: + startup.write('fs0:Image nokaslr root=3D/dev/vda rw init=3D/in= it --' + ' /host/out/lkvm run --realm' + ' -m 256m' + ' --restricted_mem' + ' --kernel /host/out/Image' + ' --disk /host/out/guest.ext4' + ' --params "root=3D/dev/vda rw init=3D/init"') + + self.vm.add_args('-cpu', 'max,x-rme=3Don') + self.vm.add_args('-smp', '2') self.vm.add_args('-m', '2G') self.vm.add_args('-M', 'sbsa-ref') self.vm.add_args('-drive', f'file=3D{pflash0},format=3Draw,if=3Dpf= lash') self.vm.add_args('-drive', f'file=3D{pflash1},format=3Draw,if=3Dpf= lash') - self.vm.add_args('-drive', f'file=3Dfat:rw:{virtual},format=3Draw') - self.vm.add_args('-drive', f'format=3Draw,if=3Dnone,file=3D{drive}= ,id=3Dhd0') - self.vm.add_args('-device', 'virtio-blk-pci,drive=3Dhd0') - self.vm.add_args('-device', 'virtio-9p-pci,fsdev=3Dshr0,mount_tag= =3Dshr0') - self.vm.add_args('-fsdev', f'local,security_model=3Dnone,path=3D{r= me_stack},id=3Dshr0') - self.vm.add_args('-device', 'virtio-net-pci,netdev=3Dnet0') - self.vm.add_args('-netdev', 'user,id=3Dnet0') - + self.vm.add_args('-drive', f'file=3Dfat:rw:{efi},format=3Draw') + self.vm.add_args('-drive', f'format=3Draw,file=3D{rootfs},if=3Dvir= tio') + self.vm.add_args('-virtfs', + f'local,path=3D{rme_stack}/,mount_tag=3Dhost,' + 'security_model=3Dmapped,readonly=3Doff') self.vm.launch() - # Wait for host VM boot to complete. - wait_for_console_pattern(self, 'Welcome to Buildroot', - failure_message=3D'Synchronous Exception = at') - exec_command_and_wait_for_pattern(self, 'root', '#') - - test_realms_guest(self) + # Wait for host and guest VM boot to complete. + wait_for_console_pattern(self, 'root@guest', + failure_message=3D'Kernel panic') =20 if __name__ =3D=3D '__main__': QemuSystemTest.main() diff --git a/tests/functional/aarch64/test_rme_virt.py b/tests/functional/a= arch64/test_rme_virt.py index 8452d27928f..bb603aaa26c 100755 --- a/tests/functional/aarch64/test_rme_virt.py +++ b/tests/functional/aarch64/test_rme_virt.py @@ -9,50 +9,22 @@ # # SPDX-License-Identifier: GPL-2.0-or-later =20 -import os +from os.path import join =20 from qemu_test import QemuSystemTest, Asset from qemu_test import exec_command, wait_for_console_pattern from qemu_test import exec_command_and_wait_for_pattern =20 -def test_realms_guest(test_rme_instance): - - # Boot the (nested) guest VM - exec_command(test_rme_instance, - 'qemu-system-aarch64 -M virt,gic-version=3D3 ' - '-cpu host -enable-kvm -m 512M ' - '-M confidential-guest-support=3Drme0 ' - '-object rme-guest,id=3Drme0 ' - '-device virtio-net-pci,netdev=3Dnet0,romfile=3D ' - '-netdev user,id=3Dnet0 ' - '-kernel /mnt/out/bin/Image ' - '-initrd /mnt/out-br/images/rootfs.cpio ' - '-serial stdio') - # Detect Realm activation during (nested) guest boot. - wait_for_console_pattern(test_rme_instance, - 'SMC_RMI_REALM_ACTIVATE') - # Wait for (nested) guest boot to complete. - wait_for_console_pattern(test_rme_instance, - 'Welcome to Buildroot') - exec_command_and_wait_for_pattern(test_rme_instance, 'root', '#') - # query (nested) guest cca report - exec_command(test_rme_instance, 'cca-workload-attestation report') - wait_for_console_pattern(test_rme_instance, - '"cca-platform-hash-algo-id": "sha-256"') - wait_for_console_pattern(test_rme_instance, - '"cca-realm-hash-algo-id": "sha-512"') - wait_for_console_pattern(test_rme_instance, - '"cca-realm-public-key-hash-algo-id": "sha-25= 6"') - class Aarch64RMEVirtMachine(QemuSystemTest): =20 - # Stack is built with OP-TEE build environment from those instructions: + # Stack is inspired from: # https://linaro.atlassian.net/wiki/spaces/QEMU/pages/29051027459/ - # https://github.com/pbo-linaro/qemu-rme-stack + # https://github.com/pbo-linaro/qemu-linux-stack/tree/rme_release + # ./build.sh && ./archive_artifacts.sh out.tar.xz ASSET_RME_STACK_VIRT =3D Asset( - ('https://fileserver.linaro.org/s/iaRsNDJp2CXHMSJ/' - 'download/rme-stack-op-tee-4.2.0-cca-v4-qemu_v8.tar.gz'), - '1851adc232b094384d8b879b9a2cfff07ef3d6205032b85e9b3a4a9ae6b0b7ad= ') + ('https://github.com/pbo-linaro/qemu-linux-stack/' + 'releases/download/build/rme_release-86101e5.tar.xz'), + 'e42fef8439badb52a071ac446fc33cff4cb7d61314c7a28fdbe61a11e1faad3a= ') =20 # This tests the FEAT_RME cpu implementation, by booting a VM supporti= ng it, # and launching a nested VM using it. @@ -63,15 +35,16 @@ def test_aarch64_rme_virt(self): =20 self.vm.set_console() =20 - stack_path_tar_gz =3D self.ASSET_RME_STACK_VIRT.fetch() - self.archive_extract(stack_path_tar_gz, format=3D"tar") + stack_path_tar =3D self.ASSET_RME_STACK_VIRT.fetch() + self.archive_extract(stack_path_tar, format=3D"tar") =20 - rme_stack =3D self.scratch_file('rme-stack-op-tee-4.2.0-cca-v4-qem= u_v8') - kernel =3D os.path.join(rme_stack, 'out', 'bin', 'Image') - bios =3D os.path.join(rme_stack, 'out', 'bin', 'flash.bin') - drive =3D os.path.join(rme_stack, 'out-br', 'images', 'rootfs.ext4= ') + rme_stack =3D self.scratch_file('.') + kernel =3D join(rme_stack, 'out', 'Image') + bios =3D join(rme_stack, 'out', 'flash.bin') + rootfs =3D join(rme_stack, 'out', 'host.ext4') =20 - self.vm.add_args('-cpu', 'max,x-rme=3Don,pauth-impdef=3Don') + self.vm.add_args('-cpu', 'max,x-rme=3Don') + self.vm.add_args('-smp', '2') self.vm.add_args('-m', '2G') self.vm.add_args('-M', 'virt,acpi=3Doff,' 'virtualization=3Don,' @@ -79,23 +52,25 @@ def test_aarch64_rme_virt(self): 'gic-version=3D3') self.vm.add_args('-bios', bios) self.vm.add_args('-kernel', kernel) - self.vm.add_args('-drive', f'format=3Draw,if=3Dnone,file=3D{drive}= ,id=3Dhd0') - self.vm.add_args('-device', 'virtio-blk-pci,drive=3Dhd0') - self.vm.add_args('-device', 'virtio-9p-device,fsdev=3Dshr0,mount_t= ag=3Dshr0') - self.vm.add_args('-fsdev', f'local,security_model=3Dnone,path=3D{r= me_stack},id=3Dshr0') - self.vm.add_args('-device', 'virtio-net-pci,netdev=3Dnet0') - self.vm.add_args('-netdev', 'user,id=3Dnet0') + self.vm.add_args('-drive', f'format=3Draw,file=3D{rootfs},if=3Dvir= tio') + self.vm.add_args('-virtfs', + f'local,path=3D{rme_stack}/,mount_tag=3Dhost,' + 'security_model=3Dmapped,readonly=3Doff') # We need to add nokaslr to avoid triggering this sporadic bug: # https://gitlab.com/qemu-project/qemu/-/issues/2823 - self.vm.add_args('-append', 'root=3D/dev/vda nokaslr') + self.vm.add_args('-append', + 'nokaslr root=3D/dev/vda rw init=3D/init --' + ' /host/out/lkvm run --realm' + ' -m 256m' + ' --restricted_mem' + ' --kernel /host/out/Image' + ' --disk /host/out/guest.ext4' + ' --params "root=3D/dev/vda rw init=3D/init"') =20 self.vm.launch() - # Wait for host VM boot to complete. - wait_for_console_pattern(self, 'Welcome to Buildroot', - failure_message=3D'Synchronous Exception = at') - exec_command_and_wait_for_pattern(self, 'root', '#') - - test_realms_guest(self) + # Wait for host and guest VM boot to complete. + wait_for_console_pattern(self, 'root@guest', + failure_message=3D'Kernel panic') =20 if __name__ =3D=3D '__main__': QemuSystemTest.main() --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381000; cv=none; d=zohomail.com; s=zohoarc; b=Sj5V19ZicaDPwiVTXdkGfvb6BxoyVexX1vgsW1NQP0pDBgZTHO19FutXZ4JKPKoyh52dPx3RMRuXDmhERLUnoAV+jOyS5onA7RDyvpCjKPrv6SU98zdvjJHtPqUFXKoBK8+4hy0yQrqU0KiI1Am7RsL/bYE6Jtvd+81nIE8ahWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381000; h=Content-Transfer-Encoding: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:Cc; bh=n8ApJz7RXENElQplzIs6M0aQR9sbG/YlsiM6m/0WkJo=; b=F34XhgCn9sl0bifbk4JNq8Lo6efhjGYMzp5raex/Jy8IP4dQkaTNjedJ0Z6Uv2ElablJAkUx+W5E67Se+R1RUXMR7v1d3Z+ZsolqTYAMY5S3xytxwtoZFa/gsEe9L9Xp/DkNTR+hrKjGciwECxetxvbCjpznnEB3vo+k0Na/8Lw= 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 175638100092478.7861018469747; Thu, 28 Aug 2025 04:36:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau1-0003IP-Dh; Thu, 28 Aug 2025 07:34:49 -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 1uratu-0003EG-1L for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:43 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratr-0005dE-MV for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:41 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3c68ac7e18aso530932f8f.2 for ; Thu, 28 Aug 2025 04:34:39 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380878; x=1756985678; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=n8ApJz7RXENElQplzIs6M0aQR9sbG/YlsiM6m/0WkJo=; b=LnS3hImseAeeWbebIeo8Ya+eXsCxnCAw2LHHowXp12G+l1NLazr9obT2XILHcfXSO9 r90Hn7nSLLxGsStlOr2zt/63fX8N9+HAL3w0M8qCCLMdbr78OVGEl1F0uQyfMmUmSwfZ JUikKbuubqkEqtWBOqmeMciUuO8XLk1P8WDrKQoxDbCtlXav3UFtcmiQbm4Kiqm6jgBt p20Y5uvddKXPqTh9FzJi8VC1QjMdYUGYSdtMscm8siIH8gTUL2s23lwGJaYfDaQ0VsQp EI+38PstFg0Og1cVneil8rSslFIDnBSycpQcbZB1RBCILY1w6DH1XN3gsjJa5H4iviHn ZtCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380878; x=1756985678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n8ApJz7RXENElQplzIs6M0aQR9sbG/YlsiM6m/0WkJo=; b=e3+2DVapr0NUcfq8ztYPdiiWSQ4pEhD28FRnoCcIYYtcCac9FplNojlXsSJPwV64R/ OeO8SXz3RrUoS/HBKLg1leNZUyoCqibtAPuNQhVlXLr02eWKxiH1ONKrqyIP1GVJA/OO aLyoRDMDKUryRMTCy5GxyTXf8UDWPtSGwBqxaR1qQKIt/hTXZ208aIL2IpZu0wn8d29n 11Kl0QnhJUBgN9hImlQix0T+OYVHgYgAPy3pouYuFfDPW2B1MFG0tEikPzdOSyp5iXtk Slyb/x51pXrglOKamWt91f8qVLRpMAyed+CbmqHe3bH50aVIfLNp87M50SERVWVsG5J8 dAEA== X-Gm-Message-State: AOJu0Yz9V0bT58cUSEdlYL3XCgyEwUSeB6Dp/QTsJz0WHSKPcnwhDoUY izOHcciIH2XLdhuRl9rWIj16UmJiLyMB48W1c6aB2O/DKL4VQf87smeeiZ8umSUFrhW66W51kRi Uw3oV X-Gm-Gg: ASbGnctthEDiI52a+uatZo18463gtU6PcaqmzqzA50hwi/AcmN61nqJeVl72Hiwd34A OpS2oE4BeUhMkiJxIFqlp8qJv44/K2WU9JtbV0bIELhFCnEAZvPwnmWHs9xqzT6IDbFVqtLtIEO FD8CkiOTnL9htWJuEiuQa1+CPj9nzCT7IZIZe0pKvPDyXp0q6XOSoiwRYY7HDkf6w0lPubnB9QN mf7rrPW392PWW3kXKOh5TdrgTB2dfrXu9O4WLsSZllWDLREpJTitnJrgguA709aoWbbP3/Lkrf3 8EULULfuMapm4WcSwN5yVszD2+U2lxQTZNNoaWSYvxUs88SPjet9hVU5oO/d9+2v+YxsaBK3m+m 26me9zr4b/cO83HhDyh0InzQJk14d5W9zTwrwIIs= X-Google-Smtp-Source: AGHT+IEOz2p7rnKKTgIHjEvc3sga9Wg98UY8v4VDDUiHfF3vep+6TPdHf9CjifvbpmQ4b0v+Rg6BAQ== X-Received: by 2002:a05:6000:310e:b0:3cd:16b0:dbad with SMTP id ffacd0b85a97d-3cd16b0de9emr3866444f8f.15.1756380877736; Thu, 28 Aug 2025 04:34:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/32] target/arm: Implement FEAT_SCTLR2 and enable with -cpu max Date: Thu, 28 Aug 2025 12:34:01 +0100 Message-ID: <20250828113430.3214314-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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: 1756381003196124100 Content-Type: text/plain; charset="utf-8" From: Gustavo Romero Add FEAT_SCTLR2, which introduces the SCTLR2_EL1, SCTLR2_EL2, and SCTLR2_EL3 registers. These registers are extensions of the SCTLR_ELx ones. Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20250727074202.83141-4-richard.henderson@linaro.org Message-ID: <20250711140828.1714666-4-gustavo.romero@linaro.org> [rth: Remove FEAT_MEC code; handle SCR and HCRX enable bits.] Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell --- docs/system/arm/emulation.rst | 1 + target/arm/cpu-features.h | 5 ++ target/arm/cpu.h | 15 ++++++ target/arm/internals.h | 1 + target/arm/cpu.c | 3 ++ target/arm/helper.c | 97 ++++++++++++++++++++++++++++++++--- target/arm/tcg/cpu64.c | 5 +- 7 files changed, 119 insertions(+), 8 deletions(-) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 890dc6fee21..66043b0747a 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -121,6 +121,7 @@ the following architecture extensions: - FEAT_RPRES (Increased precision of FRECPE and FRSQRTE) - FEAT_S2FWB (Stage 2 forced Write-Back) - FEAT_SB (Speculation Barrier) +- FEAT_SCTLR2 (Extension to SCTLR_ELx) - FEAT_SEL2 (Secure EL2) - FEAT_SHA1 (SHA1 instructions) - FEAT_SHA256 (SHA256 instructions) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 5876162428a..e372543bf35 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -904,6 +904,11 @@ static inline bool isar_feature_aa64_nv2(const ARMISAR= egisters *id) return FIELD_EX64_IDREG(id, ID_AA64MMFR2, NV) >=3D 2; } =20 +static inline bool isar_feature_aa64_sctlr2(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64MMFR3, SCTLRX) !=3D 0; +} + static inline bool isar_feature_aa64_pmuv3p1(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64DFR0, PMUVER) >=3D 4 && diff --git a/target/arm/cpu.h b/target/arm/cpu.h index dc9b6dce4c9..08a29802e13 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -337,6 +337,7 @@ typedef struct CPUArchState { }; uint64_t sctlr_el[4]; }; + uint64_t sctlr2_el[4]; /* Extension to System control register. */ uint64_t vsctlr; /* Virtualization System control register. */ uint64_t cpacr_el1; /* Architectural feature access control regist= er */ uint64_t cptr_el[4]; /* ARMv8 feature trap registers */ @@ -1420,6 +1421,19 @@ void pmu_init(ARMCPU *cpu); #define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */ #define SCTLR_TIDCP (1ULL << 63) /* FEAT_TIDCP1 */ =20 +#define SCTLR2_EMEC (1ULL << 1) /* FEAT_MEC */ +#define SCTLR2_NMEA (1ULL << 2) /* FEAT_DoubleFault2 */ +#define SCTLR2_ENADERR (1ULL << 3) /* FEAT_ADERR */ +#define SCTLR2_ENANERR (1ULL << 4) /* FEAT_ANERR */ +#define SCTLR2_EASE (1ULL << 5) /* FEAT_DoubleFault2 */ +#define SCTLR2_ENIDCP128 (1ULL << 6) /* FEAT_SYSREG128 */ +#define SCTLR2_ENPACM (1ULL << 7) /* FEAT_PAuth_LR */ +#define SCTLR2_ENPACM0 (1ULL << 8) /* FEAT_PAuth_LR */ +#define SCTLR2_CPTA (1ULL << 9) /* FEAT_CPA2 */ +#define SCTLR2_CPTA0 (1ULL << 10) /* FEAT_CPA2 */ +#define SCTLR2_CPTM (1ULL << 11) /* FEAT_CPA2 */ +#define SCTLR2_CPTM0 (1ULL << 12) /* FEAT_CAP2 */ + #define CPSR_M (0x1fU) #define CPSR_T (1U << 5) #define CPSR_F (1U << 6) @@ -1712,6 +1726,7 @@ static inline void xpsr_write(CPUARMState *env, uint3= 2_t val, uint32_t mask) #define SCR_HXEN (1ULL << 38) #define SCR_TRNDR (1ULL << 40) #define SCR_ENTP2 (1ULL << 41) +#define SCR_SCTLR2EN (1ULL << 44) #define SCR_GPF (1ULL << 48) #define SCR_NSE (1ULL << 62) =20 diff --git a/target/arm/internals.h b/target/arm/internals.h index 3f86b070447..fb722362551 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -230,6 +230,7 @@ FIELD(VSTCR, SA, 30, 1) #define HCRX_CMOW (1ULL << 9) #define HCRX_MCE2 (1ULL << 10) #define HCRX_MSCEN (1ULL << 11) +#define HCRX_SCTLR2EN (1ULL << 15) =20 #define HPFAR_NS (1ULL << 63) =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index e2b2337399c..2ab04cb5f7c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -644,6 +644,9 @@ void arm_emulate_firmware_reset(CPUState *cpustate, int= target_el) if (cpu_isar_feature(aa64_fgt, cpu)) { env->cp15.scr_el3 |=3D SCR_FGTEN; } + if (cpu_isar_feature(aa64_sctlr2, cpu)) { + env->cp15.scr_el3 |=3D SCR_SCTLR2EN; + } } =20 if (target_el =3D=3D 2) { diff --git a/target/arm/helper.c b/target/arm/helper.c index 0c1299ff841..11ddeabb132 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -741,6 +741,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegI= nfo *ri, uint64_t value) if (cpu_isar_feature(aa64_ecv, cpu)) { valid_mask |=3D SCR_ECVEN; } + if (cpu_isar_feature(aa64_sctlr2, cpu)) { + valid_mask |=3D SCR_SCTLR2EN; + } } else { valid_mask &=3D ~(SCR_RW | SCR_ST); if (cpu_isar_feature(aa32_ras, cpu)) { @@ -3907,23 +3910,21 @@ static void hcrx_write(CPUARMState *env, const ARMC= PRegInfo *ri, ARMCPU *cpu =3D env_archcpu(env); uint64_t valid_mask =3D 0; =20 - /* FEAT_MOPS adds MSCEn and MCE2 */ if (cpu_isar_feature(aa64_mops, cpu)) { valid_mask |=3D HCRX_MSCEN | HCRX_MCE2; } - - /* FEAT_NMI adds TALLINT, VINMI and VFNMI */ if (cpu_isar_feature(aa64_nmi, cpu)) { valid_mask |=3D HCRX_TALLINT | HCRX_VINMI | HCRX_VFNMI; } - /* FEAT_CMOW adds CMOW */ if (cpu_isar_feature(aa64_cmow, cpu)) { valid_mask |=3D HCRX_CMOW; } - /* FEAT_XS adds FGTnXS, FnXS */ if (cpu_isar_feature(aa64_xs, cpu)) { valid_mask |=3D HCRX_FGTNXS | HCRX_FNXS; } + if (cpu_isar_feature(aa64_sctlr2, cpu)) { + valid_mask |=3D HCRX_SCTLR2EN; + } =20 /* Clear RES0 bits. */ env->cp15.hcrx_el2 =3D value & valid_mask; @@ -3981,11 +3982,16 @@ uint64_t arm_hcrx_el2_eff(CPUARMState *env) * This may need to be revisited for future bits. */ if (!arm_is_el2_enabled(env)) { + ARMCPU *cpu =3D env_archcpu(env); uint64_t hcrx =3D 0; - if (cpu_isar_feature(aa64_mops, env_archcpu(env))) { - /* MSCEn behaves as 1 if EL2 is not enabled */ + + /* Bits which whose effective value is 1 if el2 not enabled. */ + if (cpu_isar_feature(aa64_mops, cpu)) { hcrx |=3D HCRX_MSCEN; } + if (cpu_isar_feature(aa64_sctlr2, cpu)) { + hcrx |=3D HCRX_SCTLR2EN; + } return hcrx; } if (arm_feature(env, ARM_FEATURE_EL3) && !(env->cp15.scr_el3 & SCR_HXE= N)) { @@ -4513,6 +4519,8 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCP= U *cpu) static const struct E2HAlias aliases[] =3D { { K(3, 0, 1, 0, 0), K(3, 4, 1, 0, 0), K(3, 5, 1, 0, 0), "SCTLR", "SCTLR_EL2", "SCTLR_EL12" }, + { K(3, 0, 1, 0, 3), K(3, 4, 1, 0, 3), K(3, 5, 1, 0, 3), + "SCTLR2_EL1", "SCTLR2_EL2", "SCTLR2_EL12", isar_feature_aa64_sct= lr2 }, { K(3, 0, 1, 0, 2), K(3, 4, 1, 1, 2), K(3, 5, 1, 0, 2), "CPACR", "CPTR_EL2", "CPACR_EL12" }, { K(3, 0, 2, 0, 0), K(3, 4, 2, 0, 0), K(3, 5, 2, 0, 0), @@ -5994,6 +6002,77 @@ static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = =3D { .resetvalue =3D 0 }, }; =20 +static CPAccessResult sctlr2_el2_access(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_current_el(env) < 3 + && arm_feature(env, ARM_FEATURE_EL3) + && !(env->cp15.scr_el3 & SCR_SCTLR2EN)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + +static CPAccessResult sctlr2_el1_access(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + CPAccessResult ret =3D access_tvm_trvm(env, ri, isread); + if (ret !=3D CP_ACCESS_OK) { + return ret; + } + if (arm_current_el(env) < 2 && !(arm_hcrx_el2_eff(env) & HCRX_SCTLR2EN= )) { + return CP_ACCESS_TRAP_EL2; + } + return sctlr2_el2_access(env, ri, isread); +} + +static void sctlr2_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t valid_mask =3D 0; + + value &=3D valid_mask; + raw_write(env, ri, value); +} + +static void sctlr2_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t valid_mask =3D 0; + + value &=3D valid_mask; + raw_write(env, ri, value); +} + +static void sctlr2_el3_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t valid_mask =3D 0; + + value &=3D valid_mask; + raw_write(env, ri, value); +} + +static const ARMCPRegInfo sctlr2_reginfo[] =3D { + { .name =3D "SCTLR2_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .opc2 =3D 3, .crn =3D 1, .crm =3D 0, + .access =3D PL1_RW, .accessfn =3D sctlr2_el1_access, + .writefn =3D sctlr2_el1_write, .fgt =3D FGT_SCTLR_EL1, + .nv2_redirect_offset =3D 0x278 | NV2_REDIR_NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr2_el[1]) }, + { .name =3D "SCTLR2_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 3, .crn =3D 1, .crm =3D 0, + .access =3D PL2_RW, .accessfn =3D sctlr2_el2_access, + .writefn =3D sctlr2_el2_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr2_el[2]) }, + { .name =3D "SCTLR2_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .opc2 =3D 3, .crn =3D 1, .crm =3D 0, + .access =3D PL3_RW, .writefn =3D sctlr2_el3_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr2_el[3]) }, +}; + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -7223,6 +7302,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, nmi_reginfo); } =20 + if (cpu_isar_feature(aa64_sctlr2, cpu)) { + define_arm_cp_regs(cpu, sctlr2_reginfo); + } + if (cpu_isar_feature(any_predinv, cpu)) { define_arm_cp_regs(cpu, predinv_reginfo); } diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index 35cddbafa4c..f4efff03a59 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1247,7 +1247,10 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */ SET_IDREG(isar, ID_AA64MMFR2, t); =20 - FIELD_DP64_IDREG(isar, ID_AA64MMFR3, SPEC_FPACC, 1); /* FEAT_FPACC_SPE= C */ + t =3D GET_IDREG(isar, ID_AA64MMFR3); + t =3D FIELD_DP64(t, ID_AA64MMFR3, SCTLRX, 1); /* FEAT_SCTLR2 */ + t =3D FIELD_DP64(t, ID_AA64MMFR3, SPEC_FPACC, 1); /* FEAT_FPACC_SPEC */ + SET_IDREG(isar, ID_AA64MMFR3, t); =20 t =3D GET_IDREG(isar, ID_AA64ZFR0); t =3D FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 2); /* FEAT_SVE2p1 */ --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381382; cv=none; d=zohomail.com; s=zohoarc; b=g7nVPK1vNIa1Pyj2CBcsFLD3nj5O/bMrTyXlCmq2biidBoY4SUj50v4OcIveZym6LF08yOMysIpjuGaBsud/bygAChME8lWL51u5CNE5OzLrCi5P8tjtxMrq8pqpVkCNlcCWp9SoyeguQLmNRwK3sAk0lcp10U56MJuoYfSvTYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381382; h=Content-Transfer-Encoding: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:Cc; bh=rh690dxt7d9YAOfCnBE3P+AaRyL65K9p7Ens+Z41Pjc=; b=MQSlQvjKrj3e22rjPx5T2xNJPwSBln3hjBRDcV/LN9t9D0MAjU89qDpF3+UerN7IrrPn7aegr8OSrTRoWf8Bn6gLJy0JUi4AgNtboYMhwNLmIwKkSxxEcDxyKDkMrN7stfjpMjA33752A96pd4Ltw3hy4JVrCoFpO52LIPpqlNw= 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 1756381382601683.6620065744912; Thu, 28 Aug 2025 04:43:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau2-0003Jp-Ci; Thu, 28 Aug 2025 07:34:50 -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 1uratw-0003FG-GQ for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:45 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratt-0005di-Dm for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:43 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-45b618b7d33so6926415e9.1 for ; Thu, 28 Aug 2025 04:34:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380879; x=1756985679; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rh690dxt7d9YAOfCnBE3P+AaRyL65K9p7Ens+Z41Pjc=; b=uOGfye/mw9iHtH49OCMMvJA1kn7aNH55ZxX58MEBpVkjroFEeAr4wJAmVXRTjAnZlr +hwOcvSaS1lOFu1i8X92hEHK/yla17YRY5DXMpntNBr8m6jfDsyl8d5Jx4MjzxuroH/1 tGGcw19K+RVrQeh2BtjYHdyThcBdzXFO3ve/mZeG5kOiSEGC6Qiuf98W/h1I0pblxwsV 6VWVQKJjsdMxtZz8/6skVquVr6G4p58SyVXVRoPfewL2tAmK4FU8EYmH2M3jTHRmgCjJ PPS/Uj/lbOrTyUUj62gWk6oRjavfoljulLV9+ttnVSTB+q9TDf9g9wADBmejV8q/jwCM A0Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380879; x=1756985679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rh690dxt7d9YAOfCnBE3P+AaRyL65K9p7Ens+Z41Pjc=; b=AzQqrKwKiagcxBCzxt/nBR7wEry4W9IguWN43vcYDa4vUw9gvGGtCyM3gzqkruDM9j 1qDVI9koArb5u0Q2fPK3fpF+oByidEGrsvMuo2luh6IRPtpAvcJSmcWbzoypp+9//Gq6 tvjqYSfc2QGXEnwhLpsVVn5pMz52uDBVPt4RYkCN8Bda0fqFSeILyXHPD7BzQePej6vX 2SqoogMMg/4gcx8RD2Mh52ZwFXPupYFA3ZF8IfRkLasvydzvotMjBZZ//vEPoHq7DHX9 lbv1aES9zb7gaCrbecXSHYU0NdwAudnUwL1ihFUh+/41bQPqXJOFgd0Unrvjeknw87An /o4Q== X-Gm-Message-State: AOJu0YwA3Iu4zTQprO2COqY94aRdP6k6WuxCPzO8HyqzyHAbBKH1YeU0 h9ZbnRBOBWT06ClyyUrnhhMhHZMJ+oHyH2ZYF9Iv7zmYOlajYnW2Rxelj7lCVHr64NX9PTtyjGT QNFY0 X-Gm-Gg: ASbGncvvkG5WGlSCTJCY/220eOIV1gCD1Nbf0PJ6eOfpYlaQo4w+eAAyowgGbhrgXB2 ql6TSAkptK4FfNWMk0QBz5m2Mnv+aM4pc67sq3gSgfSU+xeuP4du9sW2dV9uPMoRKOHOTmB1KOp bRaupn61l6cHSe/ay1yCYVNKMdmMaQGO82dQAqPOMi5QoTI4k0QTiZZx10Kjait0M9NoeW/L5KL ngx1dYRImzcRfWnwdaoJHdDGLFUCtYb4Ws8BY1FmoQFnbXXocDZt+RPU7CoK9QgeGtzQEr0r4Zr z/u+/sfY60r5h0gGGbA1QLy5V7I6h9CkHx27v7OR1GPF4a/GSATfsErAyap1ruUrzUieIgbIZrX +o8j9DHdZC1UPq6z0S5+TxR0QlWFl1sZNWRFI3GQ= X-Google-Smtp-Source: AGHT+IGNgBysGFYSXBcnPRxZ4qw5fctSgFEyBlxLNinbrdUm4adieXv9faOCx9KN8xH0HXH1KSCGcA== X-Received: by 2002:a05:600c:5491:b0:456:1d4e:c127 with SMTP id 5b1f17b1804b1-45b5179cdf4mr211284145e9.8.1756380878939; Thu, 28 Aug 2025 04:34:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/32] target/arm: Implement FEAT_TCR2 and enable with -cpu max Date: Thu, 28 Aug 2025 12:34:02 +0100 Message-ID: <20250828113430.3214314-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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: 1756381385312116600 Content-Type: text/plain; charset="utf-8" From: Gustavo Romero Add FEAT_TCR2, which introduces the TCR2_EL1 and TCR2_EL2 registers. These registers are extensions of the TCR_ELx registers and provide top-level control of the EL10 and EL20 translation regimes. Signed-off-by: Gustavo Romero Signed-off-by: Richard Henderson Reviewed-by: Richard Henderson Message-id: 20250727074202.83141-5-richard.henderson@linaro.org Message-ID: <20250711140828.1714666-5-gustavo.romero@linaro.org> Reviewed-by: Richard Henderson [rth: Remove FEAT_MEC code; handle SCR and HCRX enable bits.] Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell --- docs/system/arm/emulation.rst | 1 + target/arm/cpu-features.h | 5 +++ target/arm/cpu.h | 2 + target/arm/internals.h | 19 ++++++++++ target/arm/cpu.c | 3 ++ target/arm/helper.c | 71 +++++++++++++++++++++++++++++++++++ target/arm/tcg/cpu64.c | 1 + 7 files changed, 102 insertions(+) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 66043b0747a..1c597d86738 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -149,6 +149,7 @@ the following architecture extensions: - FEAT_SPECRES (Speculation restriction instructions) - FEAT_SSBS (Speculative Store Bypass Safe) - FEAT_SSBS2 (MRS and MSR instructions for SSBS version 2) +- FEAT_TCR2 (Support for TCR2_ELx) - FEAT_TGran16K (Support for 16KB memory translation granule size at stage= 1) - FEAT_TGran4K (Support for 4KB memory translation granule size at stage 1) - FEAT_TGran64K (Support for 64KB memory translation granule size at stage= 1) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index e372543bf35..8ec8c3feb3d 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -904,6 +904,11 @@ static inline bool isar_feature_aa64_nv2(const ARMISAR= egisters *id) return FIELD_EX64_IDREG(id, ID_AA64MMFR2, NV) >=3D 2; } =20 +static inline bool isar_feature_aa64_tcr2(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64MMFR3, TCRX) !=3D 0; +} + static inline bool isar_feature_aa64_sctlr2(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64MMFR3, SCTLRX) !=3D 0; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 08a29802e13..c15d79a106b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -366,6 +366,7 @@ typedef struct CPUArchState { uint64_t vsttbr_el2; /* Secure Virtualization Translation Table. */ /* MMU translation table base control. */ uint64_t tcr_el[4]; + uint64_t tcr2_el[3]; uint64_t vtcr_el2; /* Virtualization Translation Control. */ uint64_t vstcr_el2; /* Secure Virtualization Translation Control. = */ uint32_t c2_data; /* MPU data cacheable bits. */ @@ -1726,6 +1727,7 @@ static inline void xpsr_write(CPUARMState *env, uint3= 2_t val, uint32_t mask) #define SCR_HXEN (1ULL << 38) #define SCR_TRNDR (1ULL << 40) #define SCR_ENTP2 (1ULL << 41) +#define SCR_TCR2EN (1ULL << 43) #define SCR_SCTLR2EN (1ULL << 44) #define SCR_GPF (1ULL << 48) #define SCR_NSE (1ULL << 62) diff --git a/target/arm/internals.h b/target/arm/internals.h index fb722362551..f5a1e75db37 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -196,6 +196,24 @@ FIELD(CPTR_EL3, TCPAC, 31, 1) #define TTBCR_SH1 (1U << 28) #define TTBCR_EAE (1U << 31) =20 +#define TCR2_PNCH (1ULL << 0) +#define TCR2_PIE (1ULL << 1) +#define TCR2_E0POE (1ULL << 2) +#define TCR2_POE (1ULL << 3) +#define TCR2_AIE (1ULL << 4) +#define TCR2_D128 (1ULL << 5) +#define TCR2_PTTWI (1ULL << 10) +#define TCR2_HAFT (1ULL << 11) +#define TCR2_AMEC0 (1ULL << 12) +#define TCR2_AMEC1 (1ULL << 13) +#define TCR2_DISCH0 (1ULL << 14) +#define TCR2_DISCH1 (1ULL << 15) +#define TCR2_A2 (1ULL << 16) +#define TCR2_FNG0 (1ULL << 17) +#define TCR2_FNG1 (1ULL << 18) +#define TCR2_FNGNA0 (1ULL << 20) +#define TCR2_FNGNA1 (1ULL << 21) + FIELD(VTCR, T0SZ, 0, 6) FIELD(VTCR, SL0, 6, 2) FIELD(VTCR, IRGN0, 8, 2) @@ -230,6 +248,7 @@ FIELD(VSTCR, SA, 30, 1) #define HCRX_CMOW (1ULL << 9) #define HCRX_MCE2 (1ULL << 10) #define HCRX_MSCEN (1ULL << 11) +#define HCRX_TCR2EN (1ULL << 14) #define HCRX_SCTLR2EN (1ULL << 15) =20 #define HPFAR_NS (1ULL << 63) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 2ab04cb5f7c..27a4610da59 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -644,6 +644,9 @@ void arm_emulate_firmware_reset(CPUState *cpustate, int= target_el) if (cpu_isar_feature(aa64_fgt, cpu)) { env->cp15.scr_el3 |=3D SCR_FGTEN; } + if (cpu_isar_feature(aa64_tcr2, cpu)) { + env->cp15.scr_el3 |=3D SCR_TCR2EN; + } if (cpu_isar_feature(aa64_sctlr2, cpu)) { env->cp15.scr_el3 |=3D SCR_SCTLR2EN; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 11ddeabb132..5a219703aed 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -741,6 +741,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegI= nfo *ri, uint64_t value) if (cpu_isar_feature(aa64_ecv, cpu)) { valid_mask |=3D SCR_ECVEN; } + if (cpu_isar_feature(aa64_tcr2, cpu)) { + valid_mask |=3D SCR_TCR2EN; + } if (cpu_isar_feature(aa64_sctlr2, cpu)) { valid_mask |=3D SCR_SCTLR2EN; } @@ -3922,6 +3925,9 @@ static void hcrx_write(CPUARMState *env, const ARMCPR= egInfo *ri, if (cpu_isar_feature(aa64_xs, cpu)) { valid_mask |=3D HCRX_FGTNXS | HCRX_FNXS; } + if (cpu_isar_feature(aa64_tcr2, cpu)) { + valid_mask |=3D HCRX_TCR2EN; + } if (cpu_isar_feature(aa64_sctlr2, cpu)) { valid_mask |=3D HCRX_SCTLR2EN; } @@ -3989,6 +3995,9 @@ uint64_t arm_hcrx_el2_eff(CPUARMState *env) if (cpu_isar_feature(aa64_mops, cpu)) { hcrx |=3D HCRX_MSCEN; } + if (cpu_isar_feature(aa64_tcr2, cpu)) { + hcrx |=3D HCRX_TCR2EN; + } if (cpu_isar_feature(aa64_sctlr2, cpu)) { hcrx |=3D HCRX_SCTLR2EN; } @@ -4529,6 +4538,8 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCP= U *cpu) "TTBR1_EL1", "TTBR1_EL2", "TTBR1_EL12" }, { K(3, 0, 2, 0, 2), K(3, 4, 2, 0, 2), K(3, 5, 2, 0, 2), "TCR_EL1", "TCR_EL2", "TCR_EL12" }, + { K(3, 0, 2, 0, 3), K(3, 4, 2, 0, 3), K(3, 5, 2, 0, 3), + "TCR2_EL1", "TCR2_EL2", "TCR2_EL12", isar_feature_aa64_tcr2 }, { K(3, 0, 4, 0, 0), K(3, 4, 4, 0, 0), K(3, 5, 4, 0, 0), "SPSR_EL1", "SPSR_EL2", "SPSR_EL12" }, { K(3, 0, 4, 0, 1), K(3, 4, 4, 0, 1), K(3, 5, 4, 0, 1), @@ -6073,6 +6084,62 @@ static const ARMCPRegInfo sctlr2_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr2_el[3]) }, }; =20 +static CPAccessResult tcr2_el2_access(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + if (arm_current_el(env) < 3 + && arm_feature(env, ARM_FEATURE_EL3) + && !(env->cp15.scr_el3 & SCR_TCR2EN)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + +static CPAccessResult tcr2_el1_access(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + CPAccessResult ret =3D access_tvm_trvm(env, ri, isread); + if (ret !=3D CP_ACCESS_OK) { + return ret; + } + if (arm_current_el(env) < 2 && !(arm_hcrx_el2_eff(env) & HCRX_TCR2EN))= { + return CP_ACCESS_TRAP_EL2; + } + return tcr2_el2_access(env, ri, isread); +} + +static void tcr2_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t valid_mask =3D 0; + + value &=3D valid_mask; + raw_write(env, ri, value); +} + +static void tcr2_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t valid_mask =3D 0; + + value &=3D valid_mask; + raw_write(env, ri, value); +} + +static const ARMCPRegInfo tcr2_reginfo[] =3D { + { .name =3D "TCR2_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .opc2 =3D 3, .crn =3D 2, .crm =3D 0, + .access =3D PL1_RW, .accessfn =3D tcr2_el1_access, + .writefn =3D tcr2_el1_write, .fgt =3D FGT_TCR_EL1, + .nv2_redirect_offset =3D 0x270 | NV2_REDIR_NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.tcr2_el[1]) }, + { .name =3D "TCR2_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 3, .crn =3D 2, .crm =3D 0, + .access =3D PL2_RW, .accessfn =3D tcr2_el2_access, + .writefn =3D tcr2_el2_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.tcr2_el[2]) }, +}; + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -7306,6 +7373,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, sctlr2_reginfo); } =20 + if (cpu_isar_feature(aa64_tcr2, cpu)) { + define_arm_cp_regs(cpu, tcr2_reginfo); + } + if (cpu_isar_feature(any_predinv, cpu)) { define_arm_cp_regs(cpu, predinv_reginfo); } diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index f4efff03a59..4eb51420ef6 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1248,6 +1248,7 @@ void aarch64_max_tcg_initfn(Object *obj) SET_IDREG(isar, ID_AA64MMFR2, t); =20 t =3D GET_IDREG(isar, ID_AA64MMFR3); + t =3D FIELD_DP64(t, ID_AA64MMFR3, TCRX, 1); /* FEAT_TCR2 */ t =3D FIELD_DP64(t, ID_AA64MMFR3, SCTLRX, 1); /* FEAT_SCTLR2 */ t =3D FIELD_DP64(t, ID_AA64MMFR3, SPEC_FPACC, 1); /* FEAT_FPACC_SPEC */ SET_IDREG(isar, ID_AA64MMFR3, t); --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381219; cv=none; d=zohomail.com; s=zohoarc; b=RQ9U+Dx7mZWpJG1GJEzsiSorkNg3PU58ttW02QzisSfIycJTHjIk0zzsieRrwotVw1EvbNkjFjs0l/u2Hl22dcVISSMnoIeRvqRITXPvt7e/xmPPAyiVtmRTO1CIXOFsBO+tI/h6JBPdiE4V+ux8w7GZ0fS4Umgn/xKiUi4iAr4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381219; h=Content-Transfer-Encoding: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:Cc; bh=xhFp3A0M7NqYmjAgeESERQoIMPKzgUxo8xQ4836NcD4=; b=O6Jyk0zXvTI3ENX6VDVhsQr60pk8PvOXwfmEadG45Hz30vlxp1xEXTZpJziX11lec8Z9k9yTKBODavo/3QXkQWkSJa70d2Sp56iPdVVSUPASsUfvfS6cFDnHMgQFPtyqjUePZhSejuNCmKvB67aI7nWdEORG8jun0Z5sDRsJBM8= 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 1756381219693981.0183394834406; Thu, 28 Aug 2025 04:40:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau6-0003NQ-PC; Thu, 28 Aug 2025 07:34:54 -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 1uratw-0003FH-Gm for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:45 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratt-0005eB-OR for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:43 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45b618e067eso13387775e9.1 for ; Thu, 28 Aug 2025 04:34:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380880; x=1756985680; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xhFp3A0M7NqYmjAgeESERQoIMPKzgUxo8xQ4836NcD4=; b=gyAAsLzbv485uv0C81jzbKs7t2PgQ4tWnmXFly1zw8PrYSePeG0d5PkuvI5B2tnBqd Th46gxFvxdkpT4kJiD5nJwROuYZNGLnwAWTfN1IekyfaYOoNdEtdK4coOh+Houmr/TNX sLTlKLGXFlzN7m8O5HXLYTQZB/iChlCem1v4lY/a/N0aVjpoiLuCtw+NHjCro9pxU8+L owosuKuPlQZA+D2hO405ebx79jfQPHzHl77ylNfW/0ipGptag6BDPpePjMDe+0EsJ72i oFRIqnyeEkFpmajDtnRPopp6tg2Q1lBaBVFXh9LyEuGxTzMwx2nSMQ/Ujhn3ThOT/rhW 1TdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380880; x=1756985680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xhFp3A0M7NqYmjAgeESERQoIMPKzgUxo8xQ4836NcD4=; b=i+Wd7njt5khvok25A/r9yLVwD7CFJA6nYiuX3vjp4DiNw2Fk+lfvTffNvzH4/Kg4ii JLCn8eMJ2J6OSmlieGItRJWGHW6Fzp3dmk8A2y+5ZU9wKEWbRoPcfmRvFRUqHv0/hMhW +hA45T4lvP6oT5A2FPSSl5tBrBIiKQnv21+ihaTyE7Ruj479jMALPsGXvoaScln1xaXG 2vXtfpDJT7y9C6PTIAQFBXPAUoepWzud7H0q0pI69kKw8S6AW2JEjdj+RqW0Uuav5HPF eXbTjrgGuDBmNWVGBMz8qDa5v8LZ9rQZ2B2fj2G0MHYatGQXQXo7RfSdRglUSGsGoaJ4 59xw== X-Gm-Message-State: AOJu0YzW9AG9rblVsnL320SH2mIHSuoselObJdC9m69NUhtiLivOKM7S OM9VdTUtZUw5bTfASlajB+fq71ek4sxigBOKtdi2kyRpwftLgvtQe77Tw3d7ZdQ8riQfjC0Ymnp EFNG4 X-Gm-Gg: ASbGncv+YT9ZzfIpx4poqjWunYCgKWkej1U7eyadh6Yp6vokyYx4cwnrsYgAcp8mQUu N6ELn3BspTHVooTsOlfCaOCERWXsx56LuFSk9n4rwDa9neVsw0m+XClucDcD8vPS0F9d9uUJLIR BKeEXzoufw9Tui0n6CeK8iGpgR7L1QW+wNmVIYrqy5KGtH+F/4GE6HaMapsHm48dVik/yQA437Z A9fImhJqmZxJyrzP9iIim0RWdIclQ9vBCYVx239eA3UX/XG5a9VqyDeFI+dj7Nr+MJ99DrMbxQI KKrx4RztQYvqjoK5OpcOO3RAibOGxZDqs4X3wJy9h5SBMxaXb69hKlAvBqVks0LTtRq4b3BVemr uApLucZRWVWRo1RveHqajU0cAZTBxuIxwzt3rleI= X-Google-Smtp-Source: AGHT+IE+zQAdDMlrczfTqIG+WvesPJLS53lGoFS0Z5fiV/FLP4ybheUC2LX7jKez0L80Vuf9VMiklA== X-Received: by 2002:a05:600d:114:b0:45b:7585:9f95 with SMTP id 5b1f17b1804b1-45b7585a756mr19207265e9.3.1756380880108; Thu, 28 Aug 2025 04:34:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/32] hw/intc/arm_gicv3_kvm: preserve pending interrupts during cpr Date: Thu, 28 Aug 2025 12:34:03 +0100 Message-ID: <20250828113430.3214314-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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: 1756381221900124100 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Close a race condition that causes cpr-transfer to lose VFIO interrupts on ARM. CPR stops VCPUs but does not disable VFIO interrupts, which may continue to arrive throughout the transition to new QEMU. CPR calls kvm_irqchip_remove_irqfd_notifier_gsi in old QEMU to force future interrupts to the producer eventfd, where they are preserved. Old QEMU then destroys the old KVM instance. However, interrupts may already be pending in KVM state. To preserve them, call ioctl KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES to flush them to guest RAM, where they will be picked up when the new KVM+VCPU instance is created. Cc: qemu-stable@nongnu.org Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Message-id: 1754936384-278328-1-git-send-email-steven.sistare@oracle.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/intc/arm_gicv3_common.h | 3 +++ hw/intc/arm_gicv3_kvm.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3= _common.h index c18503869f9..572d971d22c 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -27,6 +27,7 @@ #include "hw/sysbus.h" #include "hw/intc/arm_gic_common.h" #include "qom/object.h" +#include "qemu/notify.h" =20 /* * Maximum number of possible interrupts, determined by the GIC architectu= re. @@ -271,6 +272,8 @@ struct GICv3State { GICv3CPUState *cpu; /* List of all ITSes connected to this GIC */ GPtrArray *itslist; + + NotifierWithReturn cpr_notifier; }; =20 #define GICV3_BITMAP_ACCESSORS(BMP) \ diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 6166283cd1a..0cd14d78a75 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -31,6 +31,7 @@ #include "gicv3_internal.h" #include "vgic_common.h" #include "migration/blocker.h" +#include "migration/misc.h" #include "qom/object.h" #include "target/arm/cpregs.h" =20 @@ -776,6 +777,17 @@ static void vm_change_state_handler(void *opaque, bool= running, } } =20 +static int kvm_arm_gicv3_notifier(NotifierWithReturn *notifier, + MigrationEvent *e, Error **errp) +{ + if (e->type =3D=3D MIG_EVENT_PRECOPY_DONE) { + GICv3State *s =3D container_of(notifier, GICv3State, cpr_notifier); + return kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, + KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES, + NULL, true, errp); + } + return 0; +} =20 static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) { @@ -917,6 +929,9 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Err= or **errp) if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES)) { qemu_add_vm_change_state_handler(vm_change_state_handler, s); + migration_add_notifier_mode(&s->cpr_notifier, + kvm_arm_gicv3_notifier, + MIG_MODE_CPR_TRANSFER); } } =20 --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381382; cv=none; d=zohomail.com; s=zohoarc; b=WLuyYLygdScNHpoP1mqKK7zcLetOm3A1VGKLvmWqgEBdYd/GXJ0v/yIVbtLWXFLiVJKHaAZFHoh/rU9E5rrwcqNTVeODQhh36ra7MTC0e6MNgOiX9AgZuDxq6wJoSqHZZ0lUkk81sfSiy+Cy6asujDP79g+uiZH3mk1hs637kA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381382; h=Content-Transfer-Encoding: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:Cc; bh=M4pBND/JQTcCccX+raHz6psiQqmFDrMciZMnw68mDqI=; b=M1mGUHiltRqCOJ/9TXOI+oy24Rv5NHPYbK6Qha99WaHYpDyOPnJo4pZGUqeDETq6P6EWzcVuXOYrZEfIvCbNUtiKEOl/yINVjGjPq8B+C36noBBhrBteZe0hCRJ3+IcEXDwnGHZVxxhbIo8ZotLnmnJ7m6t3SwjmNx+Yo6fYmSI= 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 1756381382474670.6488706132087; Thu, 28 Aug 2025 04:43:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau2-0003Js-DK; Thu, 28 Aug 2025 07:34:50 -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 1uratz-0003Gr-Bg for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:47 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratv-0005fN-5Q for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:45 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-45b49f7aaf5so4645385e9.2 for ; Thu, 28 Aug 2025 04:34:42 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380881; x=1756985681; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=M4pBND/JQTcCccX+raHz6psiQqmFDrMciZMnw68mDqI=; b=REl/iDF2jMslMdCKJQ5WMkfd+7ZKztwRD82Y91Z1g8bj1JriTK3HmJQd8jMWyOZ7rB mxjUd1T1CxzZQIkx83zA0igVGVZ410tqLkjZ2ZHvIGBvqYE8H6105TnOEvL2q3Ksu6vm vBdcR9EWzfm9T3TUuKMQHapENYWTB8vVk5uPQ46aXXQ4i0qqORad9vS+eysfmo3Zx48A svmyiyNJUR5B0ieZq/jJ/cHjUb7X5EXCR7LRuy1dgKM0KFIJM4WN9QN2rHKcj78ROu+N iYWu+Zfda69CC9a4X6v9XDf5Aww8oWrTKEYjXkIWN5+LKiFD1l4uM0Z7QcQlmhSBGjyw 0qxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380881; x=1756985681; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M4pBND/JQTcCccX+raHz6psiQqmFDrMciZMnw68mDqI=; b=w370jZ0pe+xtqyHiPOBYowmXrMSVHXch+ciP5DNA/8vORo8UVQTstzUjCzF2HIRwHV ldzgCiZNpjyM0zyuderJ6V9wuTBsu1G0e5bdlq8YORG/CSIe1Kv1tDdULSsOH/MUUT4l dPOKl0YI++0PhoZ0/9Z+mkWtf4tXIkrGpxWp9oJx/kPYo4e7LqkPu2Cxw+0bDwRWBaD7 BctjJjYh0h70xnyjoUjH0Hu1YoP01z/CF4aW7dzGn8ylU9WGYUgWGcS4MMeBQv/4sEZh yqfeOUmwnX2DVtFJB1XfVPhh9CMomSQeeaC5ez9Q0d42d7S8bl3ddzgGIO6N/eU9xrM2 uOrg== X-Gm-Message-State: AOJu0YwAwr3iDtVwQURDmPzUDNtbGyFrxTtKPnmePW6zBkuK3sVWu3ck fQJCw71nuA8GbMqAaj6uzfD0+9yzipy3PqZyv+2xuY6RqLJFg5Ko5rsHSCbuUjIGysVZEP2DDLp WUiLW X-Gm-Gg: ASbGncvyaXmGPoy4ZzDaAOCV/kPntNhBSFcXFSPlOLbk3AZIxAn6Z55RMqGCPn3gLQV pA0eFUGiXzjcsKITU1c6a58LIz9TjXkufaYt21kYQeCXlfAO/7SdZyUV91M5eQfZnBLZXf5ul+T vp0Y5cCICt0dS0W+uEb3KGfWHmO8BckidtwxVs0pRRBh348SQrD0YZ2/9txA8SjtGrTEG9fGvYX 8RUuVYd6GpTT8184lpxSlm8+GfZP68Pf1hNLoQ85768Z6IInH5C+YAnAVJZ6yJbuwdTV1KaNN0a kWK7hNrROqjhpGR/adPz+xsRkwKPRZSBxQU0T1mR8DJwO1UF+fQ+ZDhLiDPw/Wu8Esb7OKDztYK 6V92SHH72bRL8AFpb+2ggir6IKX5UlrOTSRlokJM= X-Google-Smtp-Source: AGHT+IEdz0Exd+tkPMLH2LsoXlF4kG4ph21pBUUVCxtfqqVsAifWP67pZKynIer5qdJZhvL0+R5acQ== X-Received: by 2002:a05:600c:5247:b0:45b:7580:6f46 with SMTP id 5b1f17b1804b1-45b75807d2fmr31059455e9.20.1756380881316; Thu, 28 Aug 2025 04:34:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/32] target/arm: Trap PMCR when MDCR_EL2.TPMCR is set Date: Thu, 28 Aug 2025 12:34:04 +0100 Message-ID: <20250828113430.3214314-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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: 1756381384791124100 Content-Type: text/plain; charset="utf-8" From: Smail AIDER Trap PMCR_EL0 or PMCR accesses to EL2 when MDCR_EL2.TPMCR is set. Similar to MDCR_EL2.TPM, MDCR_EL2.TPMCR allows trapping EL0 and EL1 accesses to the PMCR register to EL2. Cc: qemu-stable@nongnu.org Signed-off-by: Smail AIDER Reviewed-by: Richard Henderson Message-id: 20250811112143.1577055-2-smail.aider@huawei.com Message-Id: <20250722131925.2119169-1-smail.aider@huawei.com> Signed-off-by: Peter Maydell --- target/arm/cpregs-pmu.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/target/arm/cpregs-pmu.c b/target/arm/cpregs-pmu.c index 9c4431c18ba..31c01eddc87 100644 --- a/target/arm/cpregs-pmu.c +++ b/target/arm/cpregs-pmu.c @@ -228,22 +228,27 @@ static bool event_supported(uint16_t number) return supported_event_map[number] !=3D UNSUPPORTED_EVENT; } =20 -static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *r= i, - bool isread) +static CPAccessResult do_pmreg_access(CPUARMState *env, bool is_pmcr) { /* * Performance monitor registers user accessibility is controlled - * by PMUSERENR. MDCR_EL2.TPM and MDCR_EL3.TPM allow configurable + * by PMUSERENR. MDCR_EL2.TPM/TPMCR and MDCR_EL3.TPM allow configurable * trapping to EL2 or EL3 for other accesses. */ int el =3D arm_current_el(env); - uint64_t mdcr_el2 =3D arm_mdcr_el2_eff(env); =20 if (el =3D=3D 0 && !(env->cp15.c9_pmuserenr & 1)) { return CP_ACCESS_TRAP_EL1; } - if (el < 2 && (mdcr_el2 & MDCR_TPM)) { - return CP_ACCESS_TRAP_EL2; + if (el < 2) { + uint64_t mdcr_el2 =3D arm_mdcr_el2_eff(env); + + if (mdcr_el2 & MDCR_TPM) { + return CP_ACCESS_TRAP_EL2; + } + if (is_pmcr && (mdcr_el2 & MDCR_TPMCR)) { + return CP_ACCESS_TRAP_EL2; + } } if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TPM)) { return CP_ACCESS_TRAP_EL3; @@ -252,6 +257,19 @@ static CPAccessResult pmreg_access(CPUARMState *env, c= onst ARMCPRegInfo *ri, return CP_ACCESS_OK; } =20 +static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *r= i, + bool isread) +{ + return do_pmreg_access(env, false); +} + +static CPAccessResult pmreg_access_pmcr(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + return do_pmreg_access(env, true); +} + static CPAccessResult pmreg_access_xevcntr(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) @@ -1187,14 +1205,14 @@ void define_pm_cpregs(ARMCPU *cpu) .fgt =3D FGT_PMCR_EL0, .type =3D ARM_CP_IO | ARM_CP_ALIAS, .fieldoffset =3D offsetoflow32(CPUARMState, cp15.c9_pmcr), - .accessfn =3D pmreg_access, + .accessfn =3D pmreg_access_pmcr, .readfn =3D pmcr_read, .raw_readfn =3D raw_read, .writefn =3D pmcr_write, .raw_writefn =3D raw_write, }; const ARMCPRegInfo pmcr64 =3D { .name =3D "PMCR_EL0", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 3, .crn =3D 9, .crm =3D 12, .opc2 =3D 0, - .access =3D PL0_RW, .accessfn =3D pmreg_access, + .access =3D PL0_RW, .accessfn =3D pmreg_access_pmcr, .fgt =3D FGT_PMCR_EL0, .type =3D ARM_CP_IO, .fieldoffset =3D offsetof(CPUARMState, cp15.c9_pmcr), --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381069; cv=none; d=zohomail.com; s=zohoarc; b=P8mO5MpMwH/9nHRCqkGkxLoLU5CQeaqC/QyXTFomAHsOblKGbgP3CfshMdvgBYSo5yi0V3JT+kBL0SYaqjSs08DPdQ3kb6aw7/uw9TXHTHRplK6A0HgS/rHg9IoV6T2Qc5bXLYpu/BT4EUpeTcAkI/z6Jw1RFDS2Q/7f34Tx9Ro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381069; h=Content-Transfer-Encoding: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:Cc; bh=xuy/HnGxlj+ennOmSNrgDfp/IdNzHUoZQxb6SbArPQ4=; b=Dlln/lsQjQJYDMwNgP3yQnCAmw/TTc1S+w1ZY+ZReOSgkcXvgAHLUXaxv0KnekWukfIXP8v6RnFwCrjrV4XieJo0rMHt2jWuYAnzKt5Qur/fTrJ3mZ7fXVW0vlIm5T1H0B3AaPa5mqzSQgys6aFjCDjec4IEeqXE1O+DKAtrsFA= 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 1756381069265686.4894502769183; Thu, 28 Aug 2025 04:37:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau1-0003Ic-Eo; Thu, 28 Aug 2025 07:34:49 -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 1uratz-0003Gn-B9 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:47 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratw-0005fp-2a for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:45 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-45b7c01a708so1555895e9.3 for ; Thu, 28 Aug 2025 04:34:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380882; x=1756985682; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xuy/HnGxlj+ennOmSNrgDfp/IdNzHUoZQxb6SbArPQ4=; b=lIliu+sprZ63H49zSKTiB6eR/r6yxOvG1lOvMsGtvUuoA2UT7wp2VpgakLqvsoFBEY UlnJwqcwDTZeRmBQfANYXeSOW3q8U3Wt6+zOBDIQhaU7KWjVdcXKe1fJ/UZD4PuT4u/O 0dXOEacu23yr+e7Eb3WM7N/zzrjiG5LVsC+EzGUjQWt7DftXH9XkTAmpXsxqlh2Z8mdr mNcDa4GgalP2IQkIPQOmxIY0fW/gVvkDjhJvx8JKWT4+LKqw5IFRXAcSM0m7TF3dE4/o JHBGjkUO01rkp6VP71jSaEVm0yXzI+2Bd7pHV+bPTLTYBptC5cjJweoRVV/CbrkRcCs9 WggA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380882; x=1756985682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xuy/HnGxlj+ennOmSNrgDfp/IdNzHUoZQxb6SbArPQ4=; b=u9wcCrpoy49Uo+GJV4HJxmAzkLH4NUZE0YOMc7EOoM5drTHCsJLw0rpdowcMEQtMaP 8RYl6mv7KEEAwH5RsAZCed61kO/hiix5N6mLSdaDLAncZ/wgOuhB+vElx6HZPrYg55eD SM6wDpAQgHoJoq5cBCLLFHIrYL2mQjykQ5aqG2qEA2hUcrQKInSkPZh02hw8Y6krvPn/ 6ctrrrwEOi+TtbBglvCVJ2AkBJNTzT2s0qhaAZ5RUGe6xbjDRzn/qDBdC2YjYjAQXgmN na5O/ULL7Blpm5YrJDV/YAJRVLx2X2opoKeXCGOVFjEw+J4+HbpgdTDLVbwc2YXtLugt KhVA== X-Gm-Message-State: AOJu0YxZ+OvA8eWGQR5R5mVjnkMERaeImOP93ooTlF4u/hzN69llKgvv 00LcjjM4qzrlh5nMQOx0d20xZofunGtwOSed9LMj8sg2U7NqNJkpMYuZpqouCUlRhBDKxc4gis/ /1ALb X-Gm-Gg: ASbGncvCmrT65XbaXH2q22H76COjaIaroxjAATXanEc/9kvqIgmQZgy5AH/Y4mP2N2m xCQ4siBx5+RxcDXhqWsIaa1EMuhATvE34CWBf7DeRCnZNGgnmKiglV17AIU54kv5nzsBEVJcTFN DrTpqwDVUp1D1mM6v4bIU25hf6j6X8iOiu4iS+qp0A+T6gmA9GWGpQKR/LMXFJraMRGBrGpLhE4 ZJprJHvw02j06eJpXq96OrxkOeYQHzVChj2gquEYnHhr9uObCsZXU2et2WMKZghPvidGcyNEGRk U9cdZHMAIXoYefZiqUkiRGHEUuS4hYQUpeZsJmDugfN4jD+m/e0m7rSu5goIHfv8LsNOCqEnntM Az+OW8tDfpbIJea4RgO4BXXr+GXzl X-Google-Smtp-Source: AGHT+IG3BunqCNMxuxLJOnSKpfKKFmxQHSX687x2mI50vc1GNqfJG1sZV4B+wFCoT3jnynIkc2ZshA== X-Received: by 2002:a05:600c:1911:b0:453:23fe:ca86 with SMTP id 5b1f17b1804b1-45b5178e8a9mr194268595e9.4.1756380882283; Thu, 28 Aug 2025 04:34:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/32] target/arm: Add feature predicate for FEAT_CSSC Date: Thu, 28 Aug 2025 12:34:05 +0100 Message-ID: <20250828113430.3214314-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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: 1756381071247116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250803014019.416797-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu-features.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 8ec8c3feb3d..41511d08350 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -604,6 +604,11 @@ static inline bool isar_feature_aa64_rpres(const ARMIS= ARegisters *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR2, RPRES); } =20 +static inline bool isar_feature_aa64_cssc(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64ISAR2, CSSC) !=3D 0; +} + static inline bool isar_feature_aa64_lut(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64ISAR2, LUT); --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381173; cv=none; d=zohomail.com; s=zohoarc; b=RB1OgWGRhOjetuO438n2cVhNzYPMnJYP/PrvUVquRcMtoSeE3wtP89O0xJR78VGp7mbmd6DZHInRKfH/6rqgHNoTcLiSJNEsTIG/EIAxCRqTiuwgOMG/dorwQf4HcZnTih86yMO0zDO9UhOQUFmPY51MEDUbhAClhrvzNOXc+mA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381173; h=Content-Transfer-Encoding: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:Cc; bh=9rv5evHq+vjKZvOo6i0wNloSfFYxnuEPBkxKdkW8gSk=; b=lWIOE9VTiQW8bztrHjAOSGVyvutStRkPKIVb/9QsHru7HDokHqixLkgWz4Ce/qgDOJyOY6vcoaXO2qnXIW3SHhT8P/HCSVfB/8c65EwxZu2RQ4ibXCz9eecLoBlR9d/DgeK2ULoOP6NoLdJzCs1/rIbkEoYcpDr9mv8seyj5WGg= 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 1756381173170248.4107270541184; Thu, 28 Aug 2025 04:39:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau3-0003LG-LW; Thu, 28 Aug 2025 07:34:51 -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 1uratz-0003Gs-BX for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:47 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratx-0005hO-5w for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:46 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-45b7d485204so1575245e9.0 for ; Thu, 28 Aug 2025 04:34:44 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380883; x=1756985683; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9rv5evHq+vjKZvOo6i0wNloSfFYxnuEPBkxKdkW8gSk=; b=BiI9Ryov44Zy82sONzBcKN54Ju7z8WfGuwV5STgfF/GX6SSxdMDOkG5tLhvNaQbfqF w/D+9htgdNrxDW3wig4RI7jAls9uhidRxet9MPzMvl+X7taThHQWslSgIRCSpX16Kngu bkjp+0DMdzt8BBrXkfHNpUD9HZQlLTSyjzJhg0WM4o+8yTx5W2hWOY4ndXECQU6PCylp IBLqEg91zu7sBVBkp7GH1arP67zol1ikMdSnSq1DuMUHDQU/6CQ3CQvYucMgP0kaKOCU sdAN3vGVQtbSACGeqSpVedfp0gdImMVYT78lmkoEY2URJQ48B51X7TBpUab5UaUSs9dJ bh6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380883; x=1756985683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9rv5evHq+vjKZvOo6i0wNloSfFYxnuEPBkxKdkW8gSk=; b=W/SZRQqj4w5SbZtO2mjzWjfLdlU89nHFjlPa8AYlA7YSpwyZSg11c4pOtPgV9wWDFe KFO23W76s3H/ucjKmnqdlodm3HYvq8raizw27X1k3qW8/oDaZF2JkG0ba/rDEL4Im14w 3aNBA46ZYkgfZISGW9HAILakM/vvUKLhg6ikYpqxiVFq2c0Knkq6YWF3vnSo3+lRCSrw qkWVBP30srtgWkN2bEdJSOhQBmCC55oRY8LPMCuHzLjgGDR1yxGUC6LJpkmvVQ9erjuZ VB0X7QOsP4zz1nVpRsB7kErODpqu6TTV6PP0omuAvI9BGaU686/3No6gNbha+mUGRhxu G3NQ== X-Gm-Message-State: AOJu0YxwGZGIj/6ukyUzQLw+4qVA8NFnussTqfWE10uXJtVcf23ie6VF 8ZM6LxnNBW2I8zwFQce0KLpOUvc4wG8v5mdHSx/3dwUEDw24w5X1NJe8a+pI+pscf9w+5aNpbEI 4xqUo X-Gm-Gg: ASbGncuwHq7cHNDW/vVHFNlnaLFMcwCt8L6VA6IS8rpKNP9uN6a03yy9IL3PaqhsRY7 rpIQ3BA19Pti7LE4DQxRZrRH1/OWoUYH5P8H106xiPxymjlfERDIaGbz13Jhc5n2fCrjvoZsTDo ZVHvl7LKvkGS7C4PBoTh9edNgkfts/dSPUfwD+xrAbx5xG25RaJgKQ1GtRHIvykMxTZWCEFsL4C 8vGrtIYh0/RtUpQkJaHeea3YyfV/vaYV+bO6VKDb+u2L8uKRyMzdPfY0XAof3Zam3TDygmiltb4 7MT5LQEG89Hx4jh+hsyfT2YKOZWewOESoSZtfHneaRaogXDs2R/3ZkYKyhvgV3GlDLdq8PmRr/c Z7cz1ooYY/9i98Kxeua3vqmRvJdrXCKq0BwhUh7DXLiZoeN0dmA== X-Google-Smtp-Source: AGHT+IGTdTRweGagzdZ13NT2qbQTj+E4X8+5zJWCCNScCnRWGNrlqPbhUh60EbBjdGSQwEaIKVuypQ== X-Received: by 2002:a05:600c:4ecf:b0:459:d3ce:2cea with SMTP id 5b1f17b1804b1-45b5179947cmr232275815e9.6.1756380883235; Thu, 28 Aug 2025 04:34:43 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/32] target/arm: Implement MIN/MAX (immediate) Date: Thu, 28 Aug 2025 12:34:06 +0100 Message-ID: <20250828113430.3214314-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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: 1756381175308124100 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250803014019.416797-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 10 ++++++++ target/arm/tcg/translate-a64.c | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 8c798cde2b4..c1811b02747 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -156,6 +156,16 @@ MOVZ . 10 100101 .. ................ ..... = @movw_32 MOVK . 11 100101 .. ................ ..... @movw_64 MOVK . 11 100101 .. ................ ..... @movw_32 =20 +# Min/Max (immediate) + +@minmaxi_s sf:1 .. ........... imm:s8 rn:5 rd:5 &rri_sf +@minmaxi_u sf:1 .. ........... imm:8 rn:5 rd:5 &rri_sf + +SMAX_i . 00 1000111 0000 ........ ..... ..... @minmaxi_s +SMIN_i . 00 1000111 0010 ........ ..... ..... @minmaxi_s +UMAX_i . 00 1000111 0001 ........ ..... ..... @minmaxi_u +UMIN_i . 00 1000111 0011 ........ ..... ..... @minmaxi_u + # Bitfield =20 &bitfield rd rn sf immr imms diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index dbf47595dbe..b70ae5befd2 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4552,6 +4552,50 @@ TRANS(SUB_i, gen_rri, a, 1, 1, tcg_gen_sub_i64) TRANS(ADDS_i, gen_rri, a, 0, 1, a->sf ? gen_add64_CC : gen_add32_CC) TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_CC : gen_sub32_CC) =20 +/* + * Min/Max (immediate) + */ + +static void gen_wrap3_i32(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, NeonGenTwoOp= Fn fn) +{ + TCGv_i32 t1 =3D tcg_temp_new_i32(); + TCGv_i32 t2 =3D tcg_temp_new_i32(); + + tcg_gen_extrl_i64_i32(t1, n); + tcg_gen_extrl_i64_i32(t2, m); + fn(t1, t1, t2); + tcg_gen_extu_i32_i64(d, t1); +} + +static void gen_smax32_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) +{ + gen_wrap3_i32(d, n, m, tcg_gen_smax_i32); +} + +static void gen_smin32_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) +{ + gen_wrap3_i32(d, n, m, tcg_gen_smin_i32); +} + +static void gen_umax32_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) +{ + gen_wrap3_i32(d, n, m, tcg_gen_umax_i32); +} + +static void gen_umin32_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) +{ + gen_wrap3_i32(d, n, m, tcg_gen_umin_i32); +} + +TRANS_FEAT(SMAX_i, aa64_cssc, gen_rri, a, 0, 0, + a->sf ? tcg_gen_smax_i64 : gen_smax32_i64) +TRANS_FEAT(SMIN_i, aa64_cssc, gen_rri, a, 0, 0, + a->sf ? tcg_gen_smin_i64 : gen_smin32_i64) +TRANS_FEAT(UMAX_i, aa64_cssc, gen_rri, a, 0, 0, + a->sf ? tcg_gen_umax_i64 : gen_umax32_i64) +TRANS_FEAT(UMIN_i, aa64_cssc, gen_rri, a, 0, 0, + a->sf ? tcg_gen_umin_i64 : gen_umin32_i64) + /* * Add/subtract (immediate, with tags) */ --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381206; cv=none; d=zohomail.com; s=zohoarc; b=lVLt/Cb9yH8y3O/WkHFeRYtPKrEVUMGkvjUAtfnnhivFLkH7nGuPZZaWafQ1ktA8xmJMYgHOwPrKIhAYbaRu8rzl7/lclwDKBV1dXthRD5vDFp0DG8B0lS1KbLtkcBCP1o8jl9r/O1m+Z1Yh+MUSbE+F3p+28GRSOSq9Kqr0cUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381206; h=Content-Transfer-Encoding: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:Cc; bh=Iow63uqXZAY75W+e/Yf2GGnz7y0LeqIPIqHaXt7y/f8=; b=bYGZcikvQjmAPr6pt83SBYUG4EyJSmwY4qlaLJ+h4dX+ew1/McHYj54wgGbnupLOi1WRM3uEaiOsjfmsZteTN/w8fXJ2c1AkLzzL+pXLedgZBM7HvUhGEfNzFtm5lu+AqJF1N1WV9HuN9s3N2sKE2Zh4PjFp7wcLqUY+c+cXzxQ= 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 1756381206112332.48981824140185; Thu, 28 Aug 2025 04:40:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau4-0003M2-UX; Thu, 28 Aug 2025 07:34: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 1urau0-0003IO-S3 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:49 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uraty-0005iW-U2 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:48 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-45b7d485173so1537055e9.0 for ; Thu, 28 Aug 2025 04:34:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380884; x=1756985684; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Iow63uqXZAY75W+e/Yf2GGnz7y0LeqIPIqHaXt7y/f8=; b=sMB1RiOAGgjsQhKq8S0HhANljkxiikxpjk9Pj/26RkHYY9k1Fs7cYDcspwgDb2eR+/ D1conL0geG5OEeOaQ+vnBJpkRIrQs1Wdve9TdXdxcC+iEL1HEcTwF5SrLqc6713oHPvv 8vEKxu+8/HBYVHLVfe888HDg5zT8a25UJsi2xEuV+RpjBBuzC9xdKOjgdzrNZo1SzUXC uG9R2HtneV7+D7OVc4m4a0sF+rVSZsMQMy7mUczikGKRthH5OC7CKCTr46MyibWqe+XE 3YWd4LQUjHuG1u4mc23JztGpHmRnAayPifYn2mHRzFv91yygbvrn9/WSfqIILewAvcv2 jQJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380884; x=1756985684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Iow63uqXZAY75W+e/Yf2GGnz7y0LeqIPIqHaXt7y/f8=; b=LoPw0F+boOvyoPixQtLG7yyQ7A0OVgCA6OGglarqnoCbHUUWkk+4WC3LhmIPBhEL6+ LbiVpy7LcL0F/tNMRcuCntr51Dze1De3O/YCBWaT/WBkz3Z8Ve42rFKxSebCyH3W9O6L 86bC6jDYSdZlMunScn0ejVc/i7vxnYMGWUx1NOH+MU4wBI8cdSw9Ymz9CgZM4jOO/Lmk n04SAsC6iH9I7ZNUeK8G4pqzrj7aVYzhZuiaWxNq9Hd1be4VDON5fSu6r/XZKGpp3WuH v+CSUWkhkKS7GVRil5De3OUA6Bycad6mMSkapTqq4qMIO5Dpr2n42ena3P1pXPmNxutQ hwNg== X-Gm-Message-State: AOJu0Yz/J7X5Y4RVWmivcOr3YvNxkItTiOq9YGKycGeeo1X21DU3gdS/ JHbfjISzx+wn0nDPmWKVGWTX9Goedtc1GeHD38cx1X+q/3bBaRxcPoatcgt5khRyI5pQUm9Sf5G euQeb X-Gm-Gg: ASbGncsd2ghG2rBEg6MyVkextTH6UUIfaumjuUGEnk8GZD8vplsl3PwUl/lImElLGij z7TGIQOUFARrGHtwMvrYsHEk6vmriD79BVmWjIF/bJ3j5iYuOsdob7L2aHbK3irZVNk7+n5UUFq jwDeD730VFzJf+Z2s7gGPJQmtQPEyeQlS61ZWcx2LaX8HjjczfjgZleUbBVk5DJods2vnCUfyqr qV0mv6aWM+7z7UYOnJrFLGl6Uw78jsmVD5rlru8vQlQ4+gxXDU8R/TgVtvDedvnlnvWpl4NNDBN P2j9AFGZmTB6jX0s72W5JU9ZvUmQlTUpn3b594IRey08BWRju199ClpenHDLGwxyJ+l9cFdKpG/ mMsuKJRGzksBVdsIV9DmMDRDkl4lBFJEUl7WgRnQ= X-Google-Smtp-Source: AGHT+IHPmfUm5QObhjtEbEQZoX9DiEHCdcRvsO9DP43+ZIbCRpvLW+BGLX70APma+P1sP1fAwiWJWQ== X-Received: by 2002:a05:600c:4695:b0:456:26a1:a0c1 with SMTP id 5b1f17b1804b1-45b517cb8e5mr240528395e9.17.1756380884176; Thu, 28 Aug 2025 04:34:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/32] target/arm: Implement MIN/MAX (register) Date: Thu, 28 Aug 2025 12:34:07 +0100 Message-ID: <20250828113430.3214314-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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: 1756381207735124100 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250803014019.416797-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 5 +++++ target/arm/tcg/translate-a64.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index c1811b02747..a886b3ba4c7 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -708,6 +708,11 @@ GMI 1 00 11010110 ..... 000101 ..... .....= @rrr =20 PACGA 1 00 11010110 ..... 001100 ..... ..... @rrr =20 +SMAX . 00 11010110 ..... 011000 ..... ..... @rrr_sf +SMIN . 00 11010110 ..... 011010 ..... ..... @rrr_sf +UMAX . 00 11010110 ..... 011001 ..... ..... @rrr_sf +UMIN . 00 11010110 ..... 011011 ..... ..... @rrr_sf + # Data Processing (1-source) =20 @rr . .......... ..... ...... rn:5 rd:5 &rr diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index b70ae5befd2..bb92bdc296a 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -8201,6 +8201,28 @@ static bool trans_PACGA(DisasContext *s, arg_rrr *a) return false; } =20 +static bool gen_rrr(DisasContext *s, arg_rrr_sf *a, ArithTwoOp fn) +{ + TCGv_i64 tcg_rm =3D cpu_reg(s, a->rm); + TCGv_i64 tcg_rn =3D cpu_reg(s, a->rn); + TCGv_i64 tcg_rd =3D cpu_reg(s, a->rd); + + fn(tcg_rd, tcg_rn, tcg_rm); + if (!a->sf) { + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); + } + return true; +} + +TRANS_FEAT(SMAX, aa64_cssc, gen_rrr, a, + a->sf ? tcg_gen_smax_i64 : gen_smax32_i64) +TRANS_FEAT(SMIN, aa64_cssc, gen_rrr, a, + a->sf ? tcg_gen_smin_i64 : gen_smin32_i64) +TRANS_FEAT(UMAX, aa64_cssc, gen_rrr, a, + a->sf ? tcg_gen_umax_i64 : gen_umax32_i64) +TRANS_FEAT(UMIN, aa64_cssc, gen_rrr, a, + a->sf ? tcg_gen_umin_i64 : gen_umin32_i64) + typedef void ArithOneOp(TCGv_i64, TCGv_i64); =20 static bool gen_rr(DisasContext *s, int rd, int rn, ArithOneOp fn) --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381157; cv=none; d=zohomail.com; s=zohoarc; b=QTfX0pZoXJzXm+9e7lVnEY+bpnWaPsc1hHwDOdgxPf6AweYCAKbZEoM8SMwOqHASdEmVnWyR6UMC+SzPKQ45ib9x1utpSuW7mqV08+HhH9ePYKyuuoPGm6oFfrC91IgllRd664Ea7kpiChsjVEQK8IFjslgaRTDknJlRCsYpcRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381157; h=Content-Transfer-Encoding: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:Cc; bh=we7y5/VDqLpIsOAURE4m8mL6SQ4y7Eow7HTKGCKn19g=; b=DwAD0EKqigl1ZAwzVLUng5Z6sIK+3y7MyehgLbnvcZNP1RW9gyI6dNj7zdL21AGBvm/JnGnWbwJiQ2dpA+XRYAey3tCAyGbB4L64N5O0e4JY7WS+n1R5uqgoSR0N+w9bFDFRNslVwJh2LDZJn2/4/ACWTRQyAILJTL0a8mz0QzQ= 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 1756381157356483.7375135877377; Thu, 28 Aug 2025 04:39:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau4-0003Ly-NC; Thu, 28 Aug 2025 07:34:52 -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 1urau1-0003IV-3n for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:49 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratz-0005jH-CT for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:48 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-45a1b00f23eso5273055e9.0 for ; Thu, 28 Aug 2025 04:34:46 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380885; x=1756985685; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=we7y5/VDqLpIsOAURE4m8mL6SQ4y7Eow7HTKGCKn19g=; b=WdTBDHchOWnXT/9jelkThKKUGim9hTmAPesmYaoakl/cH6z644EJsVaVwYe+vbtO3V lQLeoqIn//h+K3MsdHSuWHAGJaKUvsv6hwXVmvQSWev7PWsNFetckMXJdfsgLsS3+MXo kchqqEA9qoS7UDlSXrgIUoVEYLmC1aIfx2qf4Dc+LzxZnzQ6yyYHF9HxYVCPWNM3JG+l HsduzyfUAqRqoPeqts0hRHybElHUxKQSwztztk2Z1dKi1XcxbdvdUuRlKPT8PhniJOsR KsYLVzme7Zd0d6qbxBy//HQWR0n1DZ2IRirmFpc1d5xyd1uTsQ7SCr6duBpZgEO4S+l/ 9fmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380885; x=1756985685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=we7y5/VDqLpIsOAURE4m8mL6SQ4y7Eow7HTKGCKn19g=; b=jYaYzcoR9PTol9NXDQAUErPMB+LzlSw96RitQU5rFLBB8BQ+24AdYssz/vV1PoGBLX HEH082hAWW2ynrdlBzpIx5UW0X+VVfdLQq0dzGb323/Vk2A/S9aUtxhtb8QfCrjA6wjI DlKKq0qBf6gOYnFzCTFdBs2TXT7Y1NhbqTnP3RPcy4GHCGddyUfdXVO5oRUsL0MJbwlk YJhfojI/Y2tnAuA6TWwH0HyI53VcF4aGQFa4iKUxxgql0pXVxotx2GkF4zdqkvgf7TAi Ur5v9UX6eaK4xjph48kaqZij9ssCLS/J3ZiID7GW49my5rDiBl/if/fqH7bAr+GMPeUV OWCg== X-Gm-Message-State: AOJu0Yys69crx9gB9zNdKwJOOBrt+VDC05oFd/i+bsVdEPTRZCjZzsCo +03Lxi6HRJ/PafbfD0IBJRQ0If3jWjql0a67FL+4Gf+DdiZqF8pu9+DN9qt7Q5hFvBwvUs2o5aU siT7m X-Gm-Gg: ASbGncsDkdHgpr1xUcjtk0tTwR85LwMWEljz5RiWg5WwZRqc2K12MlbFVnOpnszptaN j4Pxp3+LwJkK2pAaSP6JqoUU/isD7iprKyXE3bHEbeVKjOMRq0sq3A8upXWrdv1KLZvoIZF6v1A VF+5I7ane0Fd2DAUMvbqsBIL4vLnxey0jTaMAHiXHYIOa697zh2GsOgrFYmtTgCW7KN68MY8qHm thfbpaKEVUd8+lomAF1kkoVPCUawLQCpWx38UdvMYEZnSPFf+BkapE/Eev12RPh8br/9vEa9wiQ I6HaYEiuIjhK046K4LNJ8iISPT4ng04HG+497ZV7mXIBsquHQxCZlrrlyC0PRhf51dGkefuY64J rw05E98foJ59qQcckI6KLLTlabk+S X-Google-Smtp-Source: AGHT+IH3UimZfMWvkNi3rlnHNjGxQu6JbaJnzOZB5o1B1tltyAI1wDez5GK4H2AcFyUnocVX1Rf1mA== X-Received: by 2002:a05:600c:c48f:b0:459:dfa8:b854 with SMTP id 5b1f17b1804b1-45b5fbee605mr125589405e9.5.1756380885212; Thu, 28 Aug 2025 04:34:45 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/32] target/arm: Split out gen_wrap2_i32 helper Date: Thu, 28 Aug 2025 12:34:08 +0100 Message-ID: <20250828113430.3214314-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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: 1756381158415116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Wrapper to extract the low 32 bits, perform an operation, and zero-extend back to 64 bits. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250803014019.416797-5-richard.henderson@linaro.org [PMM: fixed wrong output-reg argument in callsites; add comment] Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index bb92bdc296a..c0fa9a44e7a 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -8231,13 +8231,22 @@ static bool gen_rr(DisasContext *s, int rd, int rn,= ArithOneOp fn) return true; } =20 +/* + * Perform 32-bit operation fn on the low half of n; + * the high half of the output is zeroed. + */ +static void gen_wrap2_i32(TCGv_i64 d, TCGv_i64 n, NeonGenOneOpFn fn) +{ + TCGv_i32 t =3D tcg_temp_new_i32(); + + tcg_gen_extrl_i64_i32(t, n); + fn(t, t); + tcg_gen_extu_i32_i64(d, t); +} + static void gen_rbit32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) { - TCGv_i32 t32 =3D tcg_temp_new_i32(); - - tcg_gen_extrl_i64_i32(t32, tcg_rn); - gen_helper_rbit(t32, t32); - tcg_gen_extu_i32_i64(tcg_rd, t32); + gen_wrap2_i32(tcg_rd, tcg_rn, gen_helper_rbit); } =20 static void gen_rev16_xx(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn, TCGv_i64 mask) @@ -8293,11 +8302,7 @@ static void gen_clz64(TCGv_i64 tcg_rd, TCGv_i64 tcg_= rn) =20 static void gen_cls32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) { - TCGv_i32 t32 =3D tcg_temp_new_i32(); - - tcg_gen_extrl_i64_i32(t32, tcg_rn); - tcg_gen_clrsb_i32(t32, t32); - tcg_gen_extu_i32_i64(tcg_rd, t32); + gen_wrap2_i32(tcg_rd, tcg_rn, tcg_gen_clrsb_i32); } =20 TRANS(CLZ, gen_rr, a->rd, a->rn, a->sf ? gen_clz64 : gen_clz32) --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381034; cv=none; d=zohomail.com; s=zohoarc; b=aXBQfEPzoHGzqiPhxbWPUMkbObdSvtrt0c9Yvj1yhfZ5Ij46cEyd3F34uBLG/PKRi9YmQpEVPvBht3AKR9FV0+n2tXku9fq5iAHzHvPx3uetnM4Uq7U+zUARqyRzTKMMp2WzCoHusxNUz5ErYh4QZYanN+63yfqxb6cKwOJK1J4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381034; h=Content-Transfer-Encoding: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:Cc; bh=p4G7w0pai8M2Z8EIlVyV0BgZ+1hlYNheGkiwdpE2My4=; b=nONlX4pqwuwhnsuP7oHe0/NZAs9jiG/066n1eFw8yVDOA3fITdCSP+M6s5T+bgBaGCRpj9eBz+iM3SDeJBOEJNzcomCkCP2SmkwON5kFwGCZDFz24Cgo/rPcg8zGskofPk61Q121snq5vTVf3V5WQ1MFzzeaJKdeMFAn8/oPcPM= 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 1756381034438900.7930396031592; Thu, 28 Aug 2025 04:37:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau5-0003Mw-Hy; Thu, 28 Aug 2025 07:34: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 1urau2-0003K6-Dv for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:50 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uratz-0005jg-UP for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:50 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-45b49f7aaf5so4645845e9.2 for ; Thu, 28 Aug 2025 04:34:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380886; x=1756985686; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=p4G7w0pai8M2Z8EIlVyV0BgZ+1hlYNheGkiwdpE2My4=; b=uDDfad2kxXSEw3KSoF8QqoBKCuZ760lpGqa+3HU+isiza4h1y5LQas0Cvf1Z8MupcV 1vUcqiiyYFsWeiU0my1xzeIkLRTRjoSXWZjqINg8qYwjTDvuj9jEqA7liOt0JksI5MOH JkI3QmFNiZP4LA63LYErlH1RVvgEkJ0nI5Bsm8ukLQOL/ZSq07bOpj/OX2w1bnLy4gz3 lbzhzYIJ7lZlEGGlQz2FPx8sDZiBZCHHa7pCgilr8A1P1sFzUVL8pRXnWpRW8djeQ0Vn a4mRWTa1HnW3AFXOAInuiJ3GCDJN9a8idzWfW8CS5+7xMMYvxJLm37letR2lfceB4zbA i8Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380886; x=1756985686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p4G7w0pai8M2Z8EIlVyV0BgZ+1hlYNheGkiwdpE2My4=; b=XiWdA9Qp4wJYUzVxbPKYo+sSJTZI9EVGWcKMx0qlwThvxtaUs1qiitOJydqZ7UaDP5 7RtifSVia8xTSipLu1dZmVU4u0/OXbAb/htz27Dx26MAFydg8PmalO4zPBNT5heU4khn w3J7124h34CSL8yfneEsS/Y21EstqoZhrK64K9NB3JyNwf2PB6U4wKxaIISmSV6Vnsz2 tJtAYTvAFKaX2xU93WzcrQe2VMS6jv5O0HqwvY1/b2fXtq59LhKkr5GANvUTXT848uOZ sVWKnqWJOJQznUMyd85Db348L696PocmTMdf/2lc0FmO84WqIXwlhuHT5GAgdatTZkFU SmPA== X-Gm-Message-State: AOJu0Yww3a4ipDTfhP9/eTiC1015ciTawjY9kqMg17WdXMYaK2SwHsvb 8Mv9JdkDOX2AaSMXvDxkC8KZkyvm5EFVgMnlaGHY5EqcEnUDDu8G2owhq/G9/lqg2iaYLqF4PYQ 7VuYx X-Gm-Gg: ASbGncs3mTEG6ZFwINmugxT3uKzifQqjma7uszIub8uT09u/n2NNLhA5yYnfVrc5oTt kWsLxJB5xB9PkvCawl81pvoFts2x4qlQNnyU6hFYkb0isCcb0VbVKbw0f5V5oq30sdgSE8dD7rZ mSKRdeq1+xobWSYDwhctyVp9zEVbw81jkNft8BwL3A1ZxOEk6LZX1r1tcliFrlx7JZ3UkiygwOA M495Y1o1rfcs0niPylKJT5ZZ+rkxj+AcOKrhXHibQ9TqUqCtA7qfT3YghHWJ72/9t4+mzyfUKUM lVpxd3+VtBvHCtnxKcN1DtUw8or83LkuTJw60oeskwYNFZMGs2xGhVPweMhsZArpuXRLnFOrS08 8EmwcXDTQ3PeCR1PTI3BUWQzg+QPNom27gRezPvM= X-Google-Smtp-Source: AGHT+IE1j8YrFy8L91vbGxHq43Zd4SqAa4hxuY5RW2NGTw9zcdcfoMT+stdrrNSUsg//lpM+t+2iJA== X-Received: by 2002:a05:600c:1f12:b0:45b:71ac:b45a with SMTP id 5b1f17b1804b1-45b72e0ed54mr48972415e9.11.1756380886258; Thu, 28 Aug 2025 04:34:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/32] target/arm: Implement CTZ, CNT, ABS Date: Thu, 28 Aug 2025 12:34:09 +0100 Message-ID: <20250828113430.3214314-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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: 1756381035696124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250803014019.416797-6-richard.henderson@linaro.org [PMM: fix tcg_rd/tcg_rn mixup] Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 4 ++++ target/arm/tcg/translate-a64.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index a886b3ba4c7..766c610c019 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -726,6 +726,10 @@ REV64 1 10 11010110 00000 000011 ..... .....= @rr CLZ . 10 11010110 00000 000100 ..... ..... @rr_sf CLS . 10 11010110 00000 000101 ..... ..... @rr_sf =20 +CTZ . 10 11010110 00000 000110 ..... ..... @rr_sf +CNT . 10 11010110 00000 000111 ..... ..... @rr_sf +ABS . 10 11010110 00000 001000 ..... ..... @rr_sf + &pacaut rd rn z @pacaut . .. ........ ..... .. z:1 ... rn:5 rd:5 &pacaut =20 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index c0fa9a44e7a..259aa70a36d 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -8308,6 +8308,37 @@ static void gen_cls32(TCGv_i64 tcg_rd, TCGv_i64 tcg_= rn) TRANS(CLZ, gen_rr, a->rd, a->rn, a->sf ? gen_clz64 : gen_clz32) TRANS(CLS, gen_rr, a->rd, a->rn, a->sf ? tcg_gen_clrsb_i64 : gen_cls32) =20 +static void gen_ctz32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + TCGv_i32 t32 =3D tcg_temp_new_i32(); + + tcg_gen_extrl_i64_i32(t32, tcg_rn); + tcg_gen_ctzi_i32(t32, t32, 32); + tcg_gen_extu_i32_i64(tcg_rd, t32); +} + +static void gen_ctz64(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + tcg_gen_ctzi_i64(tcg_rd, tcg_rn, 64); +} + +static void gen_cnt32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + gen_wrap2_i32(tcg_rd, tcg_rn, tcg_gen_ctpop_i32); +} + +static void gen_abs32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + gen_wrap2_i32(tcg_rd, tcg_rn, tcg_gen_abs_i32); +} + +TRANS_FEAT(CTZ, aa64_cssc, gen_rr, a->rd, a->rn, + a->sf ? gen_ctz64 : gen_ctz32) +TRANS_FEAT(CNT, aa64_cssc, gen_rr, a->rd, a->rn, + a->sf ? tcg_gen_ctpop_i64 : gen_cnt32) +TRANS_FEAT(ABS, aa64_cssc, gen_rr, a->rd, a->rn, + a->sf ? tcg_gen_abs_i64 : gen_abs32) + static bool gen_pacaut(DisasContext *s, arg_pacaut *a, NeonGenTwo64OpEnvFn= fn) { TCGv_i64 tcg_rd, tcg_rn; --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381186; cv=none; d=zohomail.com; s=zohoarc; b=eMwDsX/8Nz7QuKX6l9A8UXplunb4BIGXIIfirbEo/JjjmSUeGzEaPqU3vW8bNCh89pVJ2nNPAK6PMv0Xuu0u0EXRgExMuvWvV+8vu12dwgzyMQ9Vq3ZKDFB2Yn8SscqjpeEIJtK4gBhrbmUHupnXPhPRwOaTOqqYff3dgD6WAjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381186; h=Content-Transfer-Encoding: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:Cc; bh=EnGGrcv97B1m9Yhyyzk0TCrzPdK4iabw1UUxjeGtLm0=; b=ndgR1PZJJj6/bHQKpD21M+XeU+wgJ+whfnZ3uQP8d4yOFT6Dh4tgR0D6XoV7oobYVZNZdeZPv0jTFOi6PCw21XG7TeaWLD9cYbgcQ/8SKCBeG2K+6WULFXnRU1QJ8tcntuikoikDH9h4GLDTZbmXuJ6njwpUwjp+QKxCN+QBDLI= 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 1756381186208125.73005142409; Thu, 28 Aug 2025 04:39:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau4-0003M5-TV; Thu, 28 Aug 2025 07:34:52 -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 1urau3-0003Ks-7q for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:51 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau1-0005kq-Cr for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:50 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3c7edd71bbfso591181f8f.0 for ; Thu, 28 Aug 2025 04:34:48 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380887; x=1756985687; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=EnGGrcv97B1m9Yhyyzk0TCrzPdK4iabw1UUxjeGtLm0=; b=EELQuHTRxwpjAy+S4mh+yNqrsogCTx7fxObZODrlQIkcvyI/FlA04Qci0xqzmBidih gE/0Z1cnFHcbEbmaz2Lkn6PtH2FgqbFvBCz7zps0HmR18epsw3KBkUhwtOxd28N3Y1iH LSEt0z5FLkgiloCAweBgANMqqpYMJ81xAuSbOLnNXeQX0BnQPONgRIYs5HzDcmg352I3 m19gaekeBiM8OdPNoCEITHU4BaD/ms1SxRyjlD5hSopw2LmdEY2/jV0sW/jhlbsbCMHh dX+mWrfnb21HCjqGHRNQMOlS/Pv5d/vkBCMsO0+CqPVv/wE0wu1Ky5Ukjg8H1EXCMpd+ Vc8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380887; x=1756985687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EnGGrcv97B1m9Yhyyzk0TCrzPdK4iabw1UUxjeGtLm0=; b=YZfYhMHNtgDSm4kfFGQXmDwgtEmKdTk5ZvbU2BknEZaPmVz5dNEHlxTiuEoo+CquQq F2dudaSLqFqGA3ehyeFi4DoKBcIMfnqj4+4pH3NUAQp5SmAkHOEZyk9tfLolpwfNiGEo HKQ6S6yLf6PSqmmbbmUdUcPERHBp7yQ3U0s6ssO1Lio9I+1prjidSFJEsyp1bwdkSY7Z wJb689dUIfWlmnaEgu/VmEEGtiTJ01mmQTTT64ppHOzK7n0B9CQuDR89hrWWWZJwsXu+ C7OnkOB4I1cRN9k7E3mFd6kNmMdd/CdJ8+ZYcC7G46DiZjIj6mavXDHpxibRYRTCdY1W De3A== X-Gm-Message-State: AOJu0Yz48LCcs0C08d243vtTwCHrSCi4iBeAJQfaibPw4gxtSmHRM6C7 wwf9GXFl3fstCTNsNxpN0mB87B6i34OEX046P3l14pmme+/J6bLXvggRwCBbwpXJSsgBIdKB33y 7acq9 X-Gm-Gg: ASbGncvObE+tnbkzGwXURsjyt2GVerZ0PJZKP/199OX0BPY+E0Ji4yB7MIFBGLdjV9v /N5Oj8VvolqDUMmb1dTu+bGWGZhB9zv73T3EUBaw/rpmlw22XKOKqG/TDGaj6lv5u6wAMV1ypcl sUDrt2+uXdb93nYae3rwg6LhJpdiDDqjDbo9/M8PQQKsnJixV/5IEZpu1V1dMWXSx6dDdEwo+b/ H89/nQlqFbz8aNS6l1WYOId0x5xja3a5JvAiofkSBahICNrM5OvscSVSO5jn8/JxrVMP2O+M6+d Z0aDYKp9lqxsLB/PqH4Y5+4Lv5qWXrbCGokh7F0fsnwWVd/dbnwsd3fDOhth7DFcALQTigDxmis hgU4TECRNwFN0YSK46/d+OIO8Hen4rodFOQPUfTA= X-Google-Smtp-Source: AGHT+IEK3Jn6RMpgrGSjsU4+RCTgzWAVF8xAIPG9vm94prJO6lX3c4c3qChjik9DnvFxvyxTCYOYaw== X-Received: by 2002:a5d:5d0c:0:b0:3cb:46fc:8ea8 with SMTP id ffacd0b85a97d-3cb46fc9040mr6613020f8f.3.1756380887507; Thu, 28 Aug 2025 04:34:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/32] target/arm: Enable FEAT_CSSC for -cpu max Date: Thu, 28 Aug 2025 12:34:10 +0100 Message-ID: <20250828113430.3214314-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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: 1756381186698116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250803014019.416797-7-richard.henderson@linaro.org [PMM: rebased to handle linux-user elfload.c refactor] Signed-off-by: Peter Maydell --- docs/system/arm/emulation.rst | 1 + linux-user/aarch64/elfload.c | 1 + target/arm/tcg/cpu64.c | 1 + 3 files changed, 3 insertions(+) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 1c597d86738..b12f013b4fc 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -30,6 +30,7 @@ the following architecture extensions: - FEAT_CMOW (Control for cache maintenance permission) - FEAT_CRC32 (CRC32 instructions) - FEAT_Crypto (Cryptographic Extension) +- FEAT_CSSC (Common Short Sequence Compression instructions) - FEAT_CSV2 (Cache speculation variant 2) - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) diff --git a/linux-user/aarch64/elfload.c b/linux-user/aarch64/elfload.c index 1030cb80947..482c0df2d7f 100644 --- a/linux-user/aarch64/elfload.c +++ b/linux-user/aarch64/elfload.c @@ -212,6 +212,7 @@ abi_ulong get_elf_hwcap2(CPUState *cs) GET_FEATURE_ID(aa64_sme_b16b16, ARM_HWCAP2_A64_SME_B16B16); GET_FEATURE_ID(aa64_sme_f16f16, ARM_HWCAP2_A64_SME_F16F16); GET_FEATURE_ID(aa64_sve_b16b16, ARM_HWCAP2_A64_SVE_B16B16); + GET_FEATURE_ID(aa64_cssc, ARM_HWCAP2_A64_CSSC); =20 return hwcaps; } diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index 4eb51420ef6..eaf8846a6a5 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1178,6 +1178,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64ISAR2, MOPS, 1); /* FEAT_MOPS */ t =3D FIELD_DP64(t, ID_AA64ISAR2, BC, 1); /* FEAT_HBC */ t =3D FIELD_DP64(t, ID_AA64ISAR2, WFXT, 2); /* FEAT_WFxT */ + t =3D FIELD_DP64(t, ID_AA64ISAR2, CSSC, 1); /* FEAT_CSSC */ SET_IDREG(isar, ID_AA64ISAR2, t); =20 t =3D GET_IDREG(isar, ID_AA64PFR0); --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380935; cv=none; d=zohomail.com; s=zohoarc; b=EBfFDsnLm63JjkDjTWcTWi1rXBeRKKpu/pnCOoy5DbOMo0ehHxKVN15WLja5Dr0hWuELMntdb2O5eZkbrrwl0B1jbbJThhtlO+8I2KUUdvpRmE1sj98QT0cWdxwztdLZsnYY11cUqnNimk58BT+Sj1+PPry4GOgFepqmkVUe9Rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380935; h=Content-Transfer-Encoding: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:Cc; bh=iam1hDuVEJ4IEWHLRQN0p7qFdPnVJgerGQJU7wZLLt8=; b=Jwgi/Y/AKD9YzgMCVU2RVME5HzLnQ3i8LL/noLvRtqi5MxG0E+L7/997E/rSZp0SfqSA0qmKLSW45eT5Z1bFrBR9doZT9UWBX0L6aCE/6xO+YgiTTg80/ECaFueueUDJ1BbtmKhX08mwr08PRp7mLLcrtz0XZVa6fDOOfrlSBEg= 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 1756380935574704.1324299913394; Thu, 28 Aug 2025 04:35:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau9-0003QV-UY; Thu, 28 Aug 2025 07:34: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 1urau4-0003Lz-Li for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:52 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau2-0005lX-R2 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:52 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3c6743a10e3so419586f8f.0 for ; Thu, 28 Aug 2025 04:34:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380889; x=1756985689; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=iam1hDuVEJ4IEWHLRQN0p7qFdPnVJgerGQJU7wZLLt8=; b=IIyJ8wGuotb0l+sdSf9Cj6iOlzc4rNsEMugoAwmP7QFiQFUFRujBq3ZOvR1+MH6iyC 9uN0Kj9rXku0aWQhxHAiHj+/Y49qUFxgU0eFmNOKWZ/e9CthTzLdzkio2q93DQYjGTX4 xuL4z50YihRialZ80mopWxkCkPGFb1TlIZP0B+CjEEQ973fwVanANMJy57qWk6sLqWqv 9IpwUIqLlp2PwiAQN9x1kn/ay+4SByWoOSGdlC/n0MeSkTRnDm3s35dfipP5nYME+TJT 00/rOZlwzSbEDW8YxSIODyyRBmNEa31RbsQAw/8wBUVBhrJDOUrylt9btjK2vquBtcek EWTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380889; x=1756985689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iam1hDuVEJ4IEWHLRQN0p7qFdPnVJgerGQJU7wZLLt8=; b=LD73U4QxblA7f2cdPOrpUdwezXQOrStvvrKpzl7a3YBl+lltQAKkYl5y304bI02T9O fREEXDri93FJXLtyzCJ1T83maeT9KeKxwom6T62osGWLvCKTUDkDYwtZf+F0jxmXWasB MrIT6PWDUDYMKJQo6smLdjZxQr1SAsIlfhcpQJcsbYWo29zPrgKU4gKmlSNkgbcvtKSC jjigPNwnmli6Wyl4CrrYDw109mo4gBvNaGQxmIm3AVMbhx5Wd1IyoDFHuNcVjn1S4pHr jL7HpNblTIb4yjlQmz9VJ0f9AyT05V08JU6G0dni14p8xkE9tCvZeCVWdsnsra8+aBkm shMg== X-Gm-Message-State: AOJu0YxQyXeOw+Nl4Mrp67CtHZaLqLLL6c80BGSqIEkGHVP7LH+xJub8 //U6HoUnC6wnj2qCuzvggsAnv7tdjO5UG9DQxkw7RVxu1383q1VpkhXvSMhv2Scrg3xDCkdHkcF /X92o X-Gm-Gg: ASbGncsp0cmGzbOv6OybOtlwtHf9LiiwlbpXul0KihHyFwWOJnRewaoQKgouKblGEKL oV4z+wS6pFfSJFVhrVF0omsFbLRr8xEN63Kb8O6bvUL8zy5MrbTS+UFW2tXGFS/O5PW6s6No8bf 6dCwYYFMK5gDtXkM9H9BpThmIQMz0OJfSgjTRDyjOaCt4f9/Sqz64chGOQLHiS1hifo7s7dWdGk anUUwyI7VTngpElDzV2GOMCQ1k/t1l7OfpYBJ7pX4yU5sElEV0wnJ19dyelykUWcAvAL7imFNzp FD+6QzQw3bWeIrNofqxixyY7SS7jNyJNJpxfmaaATa18vzLqBU5SWcrVePWhajJiw2wxGpEpCrT X6uiWIvzhjFguLggLIQVG4zcLKkYg X-Google-Smtp-Source: AGHT+IFss20RtRhdpwVp4fhbVZimEoadZXjKPdC6oLoKnl5A/duv7BW4/sKyi/MOKw20BMPXgMm0gA== X-Received: by 2002:a5d:64e7:0:b0:3ca:6584:be0b with SMTP id ffacd0b85a97d-3ca6584c142mr10246675f8f.20.1756380888653; Thu, 28 Aug 2025 04:34:48 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/32] hw/arm: add static NVDIMMs in device tree Date: Thu, 28 Aug 2025 12:34:11 +0100 Message-ID: <20250828113430.3214314-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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: 1756380937960116600 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis NVDIMM is used for fast rootfs with EROFS, for example by kata containers. To allow booting with static NVDIMM memory, add them to the device tree in arm virt machine. This allows users to boot directly with nvdimm memory devices without having to rely on ACPI and hotplug. Verified to work with command invocation: ./qemu-system-aarch64 \ -M virt,nvdimm=3Don \ -cpu cortex-a57 \ -m 4G,slots=3D2,maxmem=3D8G \ -object memory-backend-file,id=3Dmem1,share=3Don,mem-path=3D/tmp/nvdimm,s= ize=3D4G,readonly=3Doff \ -device nvdimm,id=3Dnvdimm1,memdev=3Dmem1,unarmed=3Doff \ -drive file=3D./debian-12-nocloud-arm64-commited.qcow2,format=3Dqcow2 \ -kernel ./vmlinuz-6.1.0-13-arm64 \ -append "root=3D/dev/vda1 console=3DttyAMA0,115200 acpi=3Doff" -initrd ./initrd.img-6.1.0-13-arm64 \ -nographic \ -serial mon:stdio Signed-off-by: Manos Pitsidianakis Message-id: 20250807-nvdimm_arm64_virt-v2-1-b8054578bea8@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/boot.c | 42 ++++++++++++++++++++++++++++++++++++++++++ hw/arm/virt.c | 8 +++++--- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index d391cd01bb1..1e57c4ab9ee 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -25,6 +25,7 @@ #include "hw/boards.h" #include "system/reset.h" #include "hw/loader.h" +#include "hw/mem/memory-device.h" #include "elf.h" #include "system/device_tree.h" #include "qemu/config-file.h" @@ -515,6 +516,29 @@ static void fdt_add_psci_node(void *fdt, ARMCPU *armcp= u) qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn); } =20 +static int fdt_add_pmem_node(void *fdt, uint32_t acells, uint32_t scells, + int64_t mem_base, int64_t size, int64_t node) +{ + int ret; + + g_autofree char *nodename =3D g_strdup_printf("/pmem@%" PRIx64, mem_ba= se); + + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "pmem-region"); + ret =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, + mem_base, scells, size); + if (ret) { + return ret; + } + + if (node >=3D 0) { + return qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", + node); + } + + return 0; +} + int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, hwaddr addr_limit, AddressSpace *as, MachineState *ms, ARMCPU *cpu) @@ -525,6 +549,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_inf= o *binfo, unsigned int i; hwaddr mem_base, mem_len; char **node_path; + g_autofree MemoryDeviceInfoList *md_list =3D NULL; Error *err =3D NULL; =20 if (binfo->dtb_filename) { @@ -628,6 +653,23 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_in= fo *binfo, } } =20 + md_list =3D qmp_memory_device_list(); + for (MemoryDeviceInfoList *m =3D md_list; m !=3D NULL; m =3D m->next) { + MemoryDeviceInfo *mi =3D m->value; + + if (mi->type =3D=3D MEMORY_DEVICE_INFO_KIND_NVDIMM) { + PCDIMMDeviceInfo *di =3D mi->u.nvdimm.data; + + rc =3D fdt_add_pmem_node(fdt, acells, scells, + di->addr, di->size, di->node); + if (rc < 0) { + fprintf(stderr, "couldn't add NVDIMM /pmem@%"PRIx64" node\= n", + di->addr); + goto fail; + } + } + } + rc =3D fdt_path_offset(fdt, "/chosen"); if (rc < 0) { qemu_fdt_add_subnode(fdt, "/chosen"); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9326cfc895f..1e63f40fbec 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2917,7 +2917,7 @@ static void virt_memory_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, const MachineState *ms =3D MACHINE(hotplug_dev); const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 - if (!vms->acpi_dev) { + if (!vms->acpi_dev && !(is_nvdimm && !dev->hotplugged)) { error_setg(errp, "memory hotplug is not enabled: missing acpi-ged device= "); return; @@ -2949,8 +2949,10 @@ static void virt_memory_plug(HotplugHandler *hotplug= _dev, nvdimm_plug(ms->nvdimms_state); } =20 - hotplug_handler_plug(HOTPLUG_HANDLER(vms->acpi_dev), - dev, &error_abort); + if (vms->acpi_dev) { + hotplug_handler_plug(HOTPLUG_HANDLER(vms->acpi_dev), + dev, &error_abort); + } } =20 static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381111; cv=none; d=zohomail.com; s=zohoarc; b=VSIFaV2OPIXbup89fiZ40OQANAGzSp79QReSa3vdev0qdSJi+scrIzjzeaZI4HZhIB5LP9OwT6GSRiU3IApillPYnc9V3vEimXMo88l8fJusLELYCuyFYog5rnqUnvasMIJRbvEMo/iF00Fa365q1fsXncUv4tBxi8k3wrDjvi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381111; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=S+zSf5gKYyiBX8RYazhXjiVCPsv19NY1x2MGbwfSWFo=; b=K7e08MpZZwFPQanPOincOZH22SI8GpcegIjB/mWUQfNUDvYkbR9ZlVznZxtNkQ6H1V7wK8WLIq1qej1eckQQShsZtn6friLuJjWRZ2knuwi14Xb5rXRQ05esGFsWKEu6EGMhttEsXT2R2s47RkCzINzQOzCpS+hgxJmSpG40vHU= 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 1756381111776661.0394633684313; Thu, 28 Aug 2025 04:38:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau6-0003Nb-SK; Thu, 28 Aug 2025 07:34:54 -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 1urau5-0003MX-72 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:53 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau3-0005lp-Fy for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:52 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-45a1b05a59fso6040515e9.1 for ; Thu, 28 Aug 2025 04:34:51 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380890; x=1756985690; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=S+zSf5gKYyiBX8RYazhXjiVCPsv19NY1x2MGbwfSWFo=; b=JOMn4hzZQoQ4k7845Pl0Vd7o316UBqfcBKCbxbFr3edNTkaFCNwI7Dnopk3VTDdwe4 kjVms/dq1RWjbOmJpb6Sc1PVNLc5kwAt2KV0eZodkZzM+Uy6nqPOU2U3UC7mOXP3id4X Ff0bIBkbjqZ7T6w6GzdYqi9k++YWNheatnfES6YZaYDhW9rsiTwQhBTpi7UZZsJdG7yX 6kBt9lNU59NnvJAQbGXKaVkf29nXalomYDvmGbkx8+CaNPCLOE1zPMK8LXJOvsMk6FPE j+FgbxgXWKs1ZVIOBikKP0NFF3AbqEr6xkIBPFlW5fxYOGr/aI6+0Rss6Nap5NZHl/KK mvBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380890; x=1756985690; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S+zSf5gKYyiBX8RYazhXjiVCPsv19NY1x2MGbwfSWFo=; b=XlPe0EbjyiNOZwp9WZm9n+TkPFEfHob/rytR5ul0DqOWOscXJBVqhVWwhTTLLru4p7 y14sKafKlTWPgQ5sHH0PFgJK/GWB66xIKRbukgJjMVb0hfTQZup0jNdOp2ptiYcXrq5N /aHdocqgo+gWQvIhwj254H7CIvUOVvdMcjgvNHUCgbSTSy4l8eTtS9xR1tN/ozuZsDN6 rFfxSXg76o34tQDB8uD7u3Qs77mSnQAoi0tBNA+aeZCZXDxfKP8e2h/lnEfMiZuo7eUV Kh0DU94ab+o6qsmgBsvhE6VEd3PBJLdg+mD2oBwqaptC0cgf61hgzcQwUrvzMxoYGNJY 1FCQ== X-Gm-Message-State: AOJu0Yy/oVFpV2Son6nsesXTGt8/YoIM8Nqj5HaxhCfLLM7ejb/xVB7m 8Q97xgM9npMCFXi8WoCkUy5EMK3FYU+SowJmHjCcst+l9KYiKvcoGcXG5ibyMZebhkdTounzli9 xhYtu X-Gm-Gg: ASbGncs6Jqha/LwaaViemzed8HU2xHFUhz++bY4bXOzbCYP65xvLIyq+sUFjVs8A35W MBuSKhbrKDP0yr9q96bOlya0w026lQo5mBrDYMS0UtQomnAZYUye0PGZDIgBkidH/GT+WO4a372 HWO9ISJ1TNjNTleGZ2noZUejXB7JIAfWZzrbHMfyn++B1K5T4VFI8CKknsgalDjHHWQI9Mbt/88 p8hlSL8a+9gX4q3962dOQrXd+G/eRagDWQ1eZ4AktD9Qk1YoILZ5yAZpJY9eNPSzbsCI4NzB58J Dfq7Yd8pYg/4/H/KtAeN7OvBODELUbk51LrMNgDQAzgv3fDbr2yztrHGR5T242QK3KC2KLkmaRR hQSbXRRdq6y2YA1YHjFoC2JWfwj1s9fQxeaovnvQ= X-Google-Smtp-Source: AGHT+IHCxIRmghgd5YWev+N653pMKjUbocl/9emiHYoEgLRyNtDVp7cYAdDQpRc6uhvAln0EUoz9vg== X-Received: by 2002:a05:600c:4fc8:b0:45b:7be1:be1f with SMTP id 5b1f17b1804b1-45b7be1bfcemr11182345e9.32.1756380889613; Thu, 28 Aug 2025 04:34:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/32] scripts/kernel-doc: Avoid new Perl precedence warning Date: Thu, 28 Aug 2025 12:34:12 +0100 Message-ID: <20250828113430.3214314-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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: 1756381114571124100 Newer versions of Perl (5.41.x and up) emit a warning for code in kernel-doc: Possible precedence problem between ! and pattern match (m//) at /scripts/= kernel-doc line 1597. This is because the code does: if (!$param =3D~ /\w\.\.\.$/) { In Perl, the ! operator has higher precedence than the =3D~ pattern-match binding, so the effect of this condition is to first logically-negate the string $param into a true-or-false value and then try to pattern match it against the regex, which in this case will always fail. This is almost certainly not what the author intended. In the new Python version of kernel-doc in the Linux kernel, the equivalent code is written: if KernRe(r'\w\.\.\.$').search(param): # For named variable parameters of the form `x...`, # remove the dots param =3D param[:-3] else: # Handles unnamed variable parameters param =3D "..." which is a more sensible way of writing the behaviour you would get if you put in brackets to make the regex match first and then negate the result. Take this as the intended behaviour, and update the Perl to match. For QEMU, this produces no change in output, presumably because we never used the "unnamed variable parameters" syntax. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Mauro Carvalho Chehab Message-id: 20250819115648.2125709-1-peter.maydell@linaro.org --- scripts/kernel-doc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index fec83f53eda..117ec8fcd1f 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1594,13 +1594,12 @@ sub push_parameter($$$$$) { =20 if ($type eq "" && $param =3D~ /\.\.\.$/) { - if (!$param =3D~ /\w\.\.\.$/) { - # handles unnamed variable parameters - $param =3D "..."; - } - elsif ($param =3D~ /\w\.\.\.$/) { + if ($param =3D~ /\w\.\.\.$/) { # for named variable parameters of the form `x...`, remove the dots $param =3D~ s/\.\.\.$//; + } else { + # handles unnamed variable parameters + $param =3D "..."; } if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq ""= ) { $parameterdescs{$param} =3D "variable arguments"; --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380963; cv=none; d=zohomail.com; s=zohoarc; b=fXe1N0etOoGyrZE1wYaNBXxlOUFMrKxJI3r5803udqI7etZ/yHvFvdvDMbmYXUmoSOnKcao1ggVkI26XVh81WBwn745amHhESSe9e7tx7zkhcyFgKLMKi7Z4j9QNxdN6LhP5DNrDUvUIpVRs0A8oCEtmStzvuMpdgdUOQh6fDgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380963; h=Content-Transfer-Encoding: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:Cc; bh=b8ajJViGCAPLZDLfex9Nz79/xy+FoUmGUxGAj6rowos=; b=PBKlbrjvHpM56n8i9DqhyEdZ7JYyR9FEjh7JylWYoIv9N4Z3iIDs8SYff10hWszfJJVDb6ySldvkhAnLTWzf1pRioOLtKLua0FdKIVODkDJPqZCIKy3PxOhvsSAgFkEAEolb7Jpywye34PKR++R4fhZOsaF9kXLhS1iBjMSu98c= 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 1756380963829752.6355884148345; Thu, 28 Aug 2025 04:36:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauA-0003Qw-61; Thu, 28 Aug 2025 07:34: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 1urau6-0003N4-8K for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:54 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau4-0005mH-Ft for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:54 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3c380aa1ad0so414695f8f.3 for ; Thu, 28 Aug 2025 04:34:52 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380891; x=1756985691; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=b8ajJViGCAPLZDLfex9Nz79/xy+FoUmGUxGAj6rowos=; b=P8RtFVvFWcHXayJ0YacnwLRc9+ZCGT55V+4Wii6kE1Zx2RF6sQCkEo1bOsaIFVrsVD 0lG1DQOx0K42o5LOFZri66S2sw4Kqv9RAvACtuz+4QY9NAQJJyy9KOTeReyYjBqWRGLh PgJ1NSaCKbVKKr/Zm0yERDSEg1uz9I972tGnI/uIKUxExnCmdHnJ1jJUK2WdMurbBCE6 2XD34IXft007lY2U33XJswcrXIL/1OgqEFx9AIFW2pXIKPJJaPpVuVuJgth+EPXLlxyU dsSba/pOjhozXofFqjxIgR5ahlXUt9anjXLXxFbUvalilR4ca1UD+b5dDhPYipDNwYj5 m9hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380891; x=1756985691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b8ajJViGCAPLZDLfex9Nz79/xy+FoUmGUxGAj6rowos=; b=JRz1EqtuXfKwvu/lxF/EyEB/e037Z1s5IAvXPWdF/q6XiHrweaqn6xsPUBitew7VaI ykGUC13SKCC4v+M/fN0WQCTXlN/9PCRB8FLI5ikSKi5ZxkDM1kUaZ3Z+hejzXV5uUsM5 1sPs2SEhGuF1qpSMiWEjFjzS8uq6TremvN4du6RufKR5M1BiNM5HYKJhG9s1kalcjayj 0G8XebDRQxF43E9z3BB0MJ9nyDBFAviVw6KzTm4BNQ/thN+PBVP3mpAv6bwc3vEvKgOr sniq+S71Bp5A7or+jqopLLZ1sH+mM/5KvASLnC/1Wab4+lIjAZaEPoBXZ3exBvG3DLcy MVvw== X-Gm-Message-State: AOJu0YyCjZyuH3dpCieud6vlMGnFoeV3fyA3rAPafApvmXQfHE7JvfYG HB5IYaDWvUoHvY+S8u59GKHzVsSAD7d+dAQpx/YZYmRRxAOaBcwY7j+2ejvwnRFPmCIQaYWgT5Q /UJXj X-Gm-Gg: ASbGncu8BJynG59h1+ob8iqB1pI6O83FTuWz/TVjZKlTJrOmm/83YBEtENf78jGhybx Y82KY1Ij27Zr5jqpUDTeZ6jDKCl554HwUXfh8myJK37CHB3UVAjc339u+78nybrRGqQPxn+rtCz l6mHtQZ0LX2HyPnZQ8WCl7lx0gbuayWpbFVz6JkpzDc5TDnH8U5VrxkhLh0idzLtukgzDHkycdJ 0xVz8nrjh0wNQE9VjJmqWRT1r/s5nCbYSBvslQ47VKZpftR5EDhlfyS2gm7/kgpXUB6TA/gs4NA rrG30ARZPAgh0Te8Nog6d01RZiLPvBJhYvv4tqNhnR5LCTCsYDoottzKxwtsM2bor+Zl4fV2L+P ZILi4LhzBrOBzV/+WvNYZgZX4aKHeAE9fK8xAieE= X-Google-Smtp-Source: AGHT+IFAeSI5GNTUXewe4bTR1E5szjXbERv4PTa6rRXhSrFnGH2FI00CNCfJ2GyeGsRxWrTr3gYvQw== X-Received: by 2002:a05:6000:2013:b0:3c8:152d:a707 with SMTP id ffacd0b85a97d-3c8152dad20mr13764707f8f.53.1756380890553; Thu, 28 Aug 2025 04:34:50 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/32] docs/sphinx/kerneldoc.py: Handle new LINENO syntax Date: Thu, 28 Aug 2025 12:34:13 +0100 Message-ID: <20250828113430.3214314-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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: 1756380966031116600 Content-Type: text/plain; charset="utf-8" The new upstream kernel-doc that we plan to update to uses a different syntax for the LINENO directives that the Sphinx extension parses: instead of #define LINENO 86 it has .. LINENO 86 Update the kerneldoc.py extension to handle both syntaxes, so that it will work with both the old and the new kernel-doc. Signed-off-by: Peter Maydell Reviewed-by: Paolo Bonzini Reviewed-by: Mauro Carvalho Chehab Message-id: 20250814171324.1614516-2-peter.maydell@linaro.org --- docs/sphinx/kerneldoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py index 3aa972f2e89..30bb3431983 100644 --- a/docs/sphinx/kerneldoc.py +++ b/docs/sphinx/kerneldoc.py @@ -127,7 +127,7 @@ def run(self): result =3D ViewList() =20 lineoffset =3D 0; - line_regex =3D re.compile("^#define LINENO ([0-9]+)$") + line_regex =3D re.compile(r"^(?:\.\.|#define) LINENO ([0-9]+)$= ") for line in lines: match =3D line_regex.search(line) if match: --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380910; cv=none; d=zohomail.com; s=zohoarc; b=Pqa3ZqSObfB/hheH+k4q9vcJLqfCBZBbffip+c025u3Y8/BhtkW/ogzYi+QntSED2PItg/hEmsdkXTIUpOWo1JV9Ree0ufndi337+wkw1BuHyRvdGP8osxDMHBoUENkR7ssl09rF52vW/VELwbTisH+dEEEJRjSqdwii7HTzU7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380910; h=Content-Transfer-Encoding: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:Cc; bh=PJHqiXggFgAiWZxXmkBYzyTnpBKCQII/0oqdzzevA9c=; b=K6iGvSCqhTotGoMHQN0TLICzbymhDp//lTw0PadbTEkJgnAg28uoEsKVWZoQFInQSYFDdlMcxIGSUydeANlv6rFYUIJohPdLFlqcPJB3oxjPF9yst1a52WV8S6XwOXhHXDU4GFv3QRzvgU3ugF5yifa/fJA8gXBR1n96yRrN2Ro= 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 1756380910883280.6742684900406; Thu, 28 Aug 2025 04:35:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urau9-0003Pn-4l; Thu, 28 Aug 2025 07:34:57 -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 1urau6-0003NS-PL for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:54 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau5-0005mZ-5Z for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:54 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-45a20c51c40so6758635e9.3 for ; Thu, 28 Aug 2025 04:34:52 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380891; x=1756985691; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PJHqiXggFgAiWZxXmkBYzyTnpBKCQII/0oqdzzevA9c=; b=rmo4zaZzEHlB9MQFJV+nlXzSoUQtBckp2aE3IuRm2nkDljgtl8qq4GHAKECNRNC+XX +eGjcI7jRpE9T4zKbZitFlYFqmkRUCSEW2kp/IeeVTfseaRwdcX9kVnqlq4sMZCdjBMN 03sM9rpZtG4Ue7WRwykgfxY1J/sKNK7EYC/Dov0PaJBwvVz6azA/9aL/RcZiRmTrhLtB RnvV0YDWPDpnfOXuwrx8lSy+W4UjbgZWKfi9hbN2ebxNkrbtATbs8LmjJAysF5TQkT+w VDCDYMkD0UEStGkWPv1NO0ZnKaYo2RvqSs3njxwqEXCA6bvCc5/iRv01oBWq4lZcvvcL KlQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380891; x=1756985691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PJHqiXggFgAiWZxXmkBYzyTnpBKCQII/0oqdzzevA9c=; b=O0UZRkQmzcUL1xbBfS3hzoPmTuuyTvWazA+sUealGxc89miJJyYP1iyKm3kOTb4Bcj JWWQHQUQEgLA1ddFhNq8TPU8hmS5Wa8xAlambksHVjIxuScvcfSrBG+MhGmIVylfenog RHNIW/nwmUWnyGFpxNobV5zy9Gv1rrV7nLU1XC/lOu8UPlkPUcBoYcNkk28Mvh8HNlI/ lhPzZIM40SNU5VLPOu4eyVQv589HIERMIgjw3ckabdNO5BW6BHgcQjmXMCivwMKvzLz+ UXqCR8yewB+wgEulT808SJlyLb6TU4ahBIktGoFEqRSSp0oZ3erX7AjoVG1FB2a747AZ c2Vw== X-Gm-Message-State: AOJu0Yy1iV2EDakxxgjtXHfmcuRBQ76RlojC3fuEV8W7X6EcLUAk8Q4o OcgemsGvEKr165q8sy6TcWaFXt8diNoKDjlEXdXVqM9n/f8v2r4CuGegTrXyukJHjXqqwYDDMlC vclia X-Gm-Gg: ASbGnctljjf4KMj62+J0Gdtcv3XwKMBLs/igLznoYPvx6jC+17HEits+zCw8rc6mjvX eyGshxjtiRh7jUMYow9jDlSTepSfUshD8mZ/0GltKRr5bfI31UymU32BohSSYhvr/ebG42hN+6g faM5v0GQofyFl+ZJhHHIt22KAPvJ0Gt24YRiWs+x7a+AGux4XbI9wWCNEYbmQoO6udUih2mEiPT nsR5cHg3YiNRz4+mJbt0g04gThm5v7vz3g3yg388yZo+ykjloMauLwkjoPx91R9G0SeDNn0QSGv 3/KeepDwWtli/bd2mNSTwFrab0poB+n/GMkLt01KQ+SXFC+nmqqqqcrWARARMKXyOnrtMZq91x3 NGn3qg+CUvPgND34L9Wsyd5AfEQ85cSVxvxI2430= X-Google-Smtp-Source: AGHT+IFB+sFJAUaChuPcDFX5JqYs4RCC4BdAfhhswTjcOhS3gLndld4L6BU/lhG7HhxGDNiZF6+PIw== X-Received: by 2002:a05:600c:4747:b0:45b:627a:60cf with SMTP id 5b1f17b1804b1-45b627a62cbmr132447825e9.24.1756380891492; Thu, 28 Aug 2025 04:34:51 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/32] tests/qtest/libqtest.h: Remove stray space from doc comment Date: Thu, 28 Aug 2025 12:34:14 +0100 Message-ID: <20250828113430.3214314-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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: 1756380911430116600 Content-Type: text/plain; charset="utf-8" The doc comment for qtest_cb_for_every_machine has a stray space at the start of its description, which makes kernel-doc think that this line is part of the documentation of the skip_old_versioned argument. The result is that the HTML doesn't have a "Description" section and the text is instead put in the wrong place. Remove the stray space. Signed-off-by: Peter Maydell Reviewed-by: Paolo Bonzini Reviewed-by: Mauro Carvalho Chehab Message-id: 20250814171324.1614516-3-peter.maydell@linaro.org --- tests/qtest/libqtest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index b3f2e7fbefd..fd27521a9c7 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -977,7 +977,7 @@ void qtest_qmp_fds_assert_success(QTestState *qts, int = *fds, size_t nfds, * @cb: Pointer to the callback function * @skip_old_versioned: true if versioned old machine types should be skip= ped * - * Call a callback function for every name of all available machines. + * Call a callback function for every name of all available machines. */ void qtest_cb_for_every_machine(void (*cb)(const char *machine), bool skip_old_versioned); --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381220; cv=none; d=zohomail.com; s=zohoarc; b=XSGrdAk+j98dV2Z8go/+v9XcI47dny6b116Uo+UShGiOgi9dM2RFGVTlAKK1jYMSOLU0J/8chi2SkyHNmgjA8SsDwA2uJn0qfKuOF9T4uirQas/MKleMHjT+w+6UlqwfenR6twNXTU2zITyNaH7H5gWV21s1AuCAwThPgZIGbP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381220; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=ML9Xq7399KsE/ai8FKHEWYvYcSHNH3BaqyKhr9/ikE4=; b=a1X98Urzhm/MDg3bOgXM47lFM+muw1EzzDV3e4RKyvuohuilJ3yrPdP7LgvciR62zAWlhp0kZ1pFN2ejFojKrOqDb/qf4AbeCwtMUSY8/dDq/LLkIyRt2rg70XrZzNG1z5mKv1G2UvKPjEiFRVA7iibfmY4I/Y5vzGeEyoW7CwU= 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 1756381220857953.5574964405147; Thu, 28 Aug 2025 04:40:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauG-0003Xe-HR; Thu, 28 Aug 2025 07:35:04 -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 1urauD-0003Te-3r for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:01 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau7-0005nt-Ug for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:00 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45b618b7d33so6928195e9.1 for ; Thu, 28 Aug 2025 04:34:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380894; x=1756985694; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ML9Xq7399KsE/ai8FKHEWYvYcSHNH3BaqyKhr9/ikE4=; b=RC2sWo1Y29d4jSi8bE9QRRKnF0KB0hGI831dcenLciGsY09V2jxP1tHPww+Dsuyi4T FsaKntOyt8d+TtbVSInin7yL4VMngLqHAhh6TeGNAfJXW7uTsY3FEp9CJrByLP3dlS91 BSqcG/oWOjt64+TUw9hmwHLbdQ+KIs2SgiNWeEql4OHnyKS5E0aBnF+dat0mJDI7IwAf 5rYXVTscC9y9fhmQP/Xsc/tDlzsQ0iBCYI1yfEgZh0v3aizGp/HRBtkHjHua/rCsQ4d3 j7BAO5Xjnz8xS0/IFc2CQCTdbMbBgoSJ28nxh4XdeGmqkBsgZs11FdKsIbI844C2kw7I SiFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380894; x=1756985694; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ML9Xq7399KsE/ai8FKHEWYvYcSHNH3BaqyKhr9/ikE4=; b=U4kbg+en6ztkeVoqtKJ6ZRxhm+AWV5w5nK+Pj1zvvstH5Ax2qyykt0bHyTAEdjMq9v uKS1kBT1m+CY6vug5GikYD7YUftGWCU7qkABpFojYPPFpZZqZtP8Ey//P51keWgOgu2s ViAPYPU5O/4/pqkMmN3zY2L9ugKUhs4y5MqZJXkSRISchELLFDoMb3F5Liwf3Iud6lEN onDrpVfpYoUELpsDJQn7k7ZYPbuFdPmSFguiVGdZ9TZ+N74ieaqyDwAuWO38Mxujgxea Ezm1a0P2KoJukavSCXO0WjaXBHpewJY/77PUuNCmlk70T1gkYwDB7ItoTVLDEuMNZTkk lG2g== X-Gm-Message-State: AOJu0Ywvk9mzcOl1SqlcN58a8KxM7plb1CzidndvYaeDg4OK7fkY1MLE M1Pw8fo87WNHURa7IN0OXxV1Sb3UGLZw9jcNNkDOisjJoAmwT2F2yCg/E1Iw7EIAY9fKIUOpu2Y 6BJWv X-Gm-Gg: ASbGncsTAioDS726Pm5xZshp96rz4IjQlVhOFsXp5JUOjGaRpSwirnfp6OFvxEVRjqi fS+6fA9DRtZCQJZNxEPQZ+YO7LjE6joepAzVdh3O82iwzfqAMqVBtT2FwsKTDZfXP8tODr40INK C8MinwQxZfTSuJgp+RgOz51PtgC10E8Pq8drrwlgLM6WNTfAuSMddYT1BGyrSszh3V6xzIgcDBH TnN2HAasLmHIf/nGWlEDO1UsoTnUleIovQpkgLJva1Q37lp4bJ7jeTTIZQ9HkaCk1lBAGYiTrAt vIeNSG/AKQ3/R4KMwx5o8ouXpJhEJqW3nlAPpgSdmV8fNxx6DpdkdIxgrFDbsIDBvXNNs27uVZ+ v5dSWvyGjisYTNPHG/0bHkcge00+X X-Google-Smtp-Source: AGHT+IGgNGwVXSmowtSDgqsxtYV3QfCC8R2yKLxqNQCEAHuxmmzJbqxjx2w9ykbNmhIeyMZrUcMsOA== X-Received: by 2002:a05:600c:1f95:b0:459:dc92:b95f with SMTP id 5b1f17b1804b1-45b5cb461f6mr140554375e9.5.1756380892761; Thu, 28 Aug 2025 04:34:52 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/32] scripts: Import Python kerneldoc from Linux kernel Date: Thu, 28 Aug 2025 12:34:15 +0100 Message-ID: <20250828113430.3214314-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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: 1756381222341124100 We last synced our copy of kerneldoc with Linux back in 2020. In the interim, upstream has entirely rewritten the script in Python, and the new Python version is split into a main script plus some libraries in the kernel's scripts/lib/kdoc. Import all these files. These are the versions as of kernel commit 0cc53520e68be, with no local changes. We use the same lib/kdoc/ directory as the kernel does here, so we can avoid having to edit the top-level script just to adjust a pathname, even though it is probably not the naming we would have picked if this was a purely QEMU script. The Sphinx conf.py still points at the Perl version of the script, so this Python code will not be invoked to build the docs yet. NB: checkpatch complains about many things in this commit, including the use of "GPL-2.0" rather than "GPL-2.0-only" in the SPDX tags, but since this is a third party import we can ignore this. Signed-off-by: Peter Maydell Reviewed-by: Paolo Bonzini Reviewed-by: Mauro Carvalho Chehab Message-id: 20250814171324.1614516-4-peter.maydell@linaro.org --- scripts/kernel-doc.py | 325 ++++++ scripts/lib/kdoc/kdoc_files.py | 291 ++++++ scripts/lib/kdoc/kdoc_item.py | 42 + scripts/lib/kdoc/kdoc_output.py | 749 ++++++++++++++ scripts/lib/kdoc/kdoc_parser.py | 1669 +++++++++++++++++++++++++++++++ scripts/lib/kdoc/kdoc_re.py | 270 +++++ 6 files changed, 3346 insertions(+) create mode 100755 scripts/kernel-doc.py create mode 100644 scripts/lib/kdoc/kdoc_files.py create mode 100644 scripts/lib/kdoc/kdoc_item.py create mode 100644 scripts/lib/kdoc/kdoc_output.py create mode 100644 scripts/lib/kdoc/kdoc_parser.py create mode 100644 scripts/lib/kdoc/kdoc_re.py diff --git a/scripts/kernel-doc.py b/scripts/kernel-doc.py new file mode 100755 index 00000000000..fc3d46ef519 --- /dev/null +++ b/scripts/kernel-doc.py @@ -0,0 +1,325 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# +# pylint: disable=3DC0103,R0915 +# +# Converted from the kernel-doc script originally written in Perl +# under GPLv2, copyrighted since 1998 by the following authors: +# +# Aditya Srivastava +# Akira Yokosawa +# Alexander A. Klimov +# Alexander Lobakin +# Andr=C3=A9 Almeida +# Andy Shevchenko +# Anna-Maria Behnsen +# Armin Kuster +# Bart Van Assche +# Ben Hutchings +# Borislav Petkov +# Chen-Yu Tsai +# Coco Li +# Conch=C3=BAr Navid +# Daniel Santos +# Danilo Cesar Lemes de Paula +# Dan Luedtke +# Donald Hunter +# Gabriel Krisman Bertazi +# Greg Kroah-Hartman +# Harvey Harrison +# Horia Geanta +# Ilya Dryomov +# Jakub Kicinski +# Jani Nikula +# Jason Baron +# Jason Gunthorpe +# J=C3=A9r=C3=A9my Bobbio +# Johannes Berg +# Johannes Weiner +# Jonathan Cameron +# Jonathan Corbet +# Jonathan Neusch=C3=A4fer +# Kamil Rytarowski +# Kees Cook +# Laurent Pinchart +# Levin, Alexander (Sasha Levin) +# Linus Torvalds +# Lucas De Marchi +# Mark Rutland +# Markus Heiser +# Martin Waitz +# Masahiro Yamada +# Matthew Wilcox +# Mauro Carvalho Chehab +# Michal Wajdeczko +# Michael Zucchi +# Mike Rapoport +# Niklas S=C3=B6derlund +# Nishanth Menon +# Paolo Bonzini +# Pavan Kumar Linga +# Pavel Pisa +# Peter Maydell +# Pierre-Louis Bossart +# Randy Dunlap +# Richard Kennedy +# Rich Walker +# Rolf Eike Beer +# Sakari Ailus +# Silvio Fricke +# Simon Huggins +# Tim Waugh +# Tomasz Warnie=C5=82=C5=82o +# Utkarsh Tripathi +# valdis.kletnieks@vt.edu +# Vegard Nossum +# Will Deacon +# Yacine Belkadi +# Yujie Liu + +""" +kernel_doc +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Print formatted kernel documentation to stdout + +Read C language source or header FILEs, extract embedded +documentation comments, and print formatted documentation +to standard output. + +The documentation comments are identified by the "/**" +opening comment mark. + +See Documentation/doc-guide/kernel-doc.rst for the +documentation comment syntax. +""" + +import argparse +import logging +import os +import sys + +# Import Python modules + +LIB_DIR =3D "lib/kdoc" +SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) + +sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) + +from kdoc_files import KernelFiles # pylint: disable= =3DC0413 +from kdoc_output import RestFormat, ManFormat # pylint: disable= =3DC0413 + +DESC =3D """ +Read C language source or header FILEs, extract embedded documentation com= ments, +and print formatted documentation to standard output. + +The documentation comments are identified by the "/**" opening comment mar= k. + +See Documentation/doc-guide/kernel-doc.rst for the documentation comment s= yntax. +""" + +EXPORT_FILE_DESC =3D """ +Specify an additional FILE in which to look for EXPORT_SYMBOL information. + +May be used multiple times. +""" + +EXPORT_DESC =3D """ +Only output documentation for the symbols that have been +exported using EXPORT_SYMBOL() and related macros in any input +FILE or -export-file FILE. +""" + +INTERNAL_DESC =3D """ +Only output documentation for the symbols that have NOT been +exported using EXPORT_SYMBOL() and related macros in any input +FILE or -export-file FILE. +""" + +FUNCTION_DESC =3D """ +Only output documentation for the given function or DOC: section +title. All other functions and DOC: sections are ignored. + +May be used multiple times. +""" + +NOSYMBOL_DESC =3D """ +Exclude the specified symbol from the output documentation. + +May be used multiple times. +""" + +FILES_DESC =3D """ +Header and C source files to be parsed. +""" + +WARN_CONTENTS_BEFORE_SECTIONS_DESC =3D """ +Warns if there are contents before sections (deprecated). + +This option is kept just for backward-compatibility, but it does nothing, +neither here nor at the original Perl script. +""" + + +class MsgFormatter(logging.Formatter): + """Helper class to format warnings on a similar way to kernel-doc.pl""" + + def format(self, record): + record.levelname =3D record.levelname.capitalize() + return logging.Formatter.format(self, record) + +def main(): + """Main program""" + + parser =3D argparse.ArgumentParser(formatter_class=3Dargparse.RawTextH= elpFormatter, + description=3DDESC) + + # Normal arguments + + parser.add_argument("-v", "-verbose", "--verbose", action=3D"store_tru= e", + help=3D"Verbose output, more warnings and other in= formation.") + + parser.add_argument("-d", "-debug", "--debug", action=3D"store_true", + help=3D"Enable debug messages") + + parser.add_argument("-M", "-modulename", "--modulename", + default=3D"Kernel API", + help=3D"Allow setting a module name at the output.= ") + + parser.add_argument("-l", "-enable-lineno", "--enable_lineno", + action=3D"store_true", + help=3D"Enable line number output (only in ReST mo= de)") + + # Arguments to control the warning behavior + + parser.add_argument("-Wreturn", "--wreturn", action=3D"store_true", + help=3D"Warns about the lack of a return markup on= functions.") + + parser.add_argument("-Wshort-desc", "-Wshort-description", "--wshort-d= esc", + action=3D"store_true", + help=3D"Warns if initial short description is miss= ing") + + parser.add_argument("-Wcontents-before-sections", + "--wcontents-before-sections", action=3D"store_tru= e", + help=3DWARN_CONTENTS_BEFORE_SECTIONS_DESC) + + parser.add_argument("-Wall", "--wall", action=3D"store_true", + help=3D"Enable all types of warnings") + + parser.add_argument("-Werror", "--werror", action=3D"store_true", + help=3D"Treat warnings as errors.") + + parser.add_argument("-export-file", "--export-file", action=3D'append', + help=3DEXPORT_FILE_DESC) + + # Output format mutually-exclusive group + + out_group =3D parser.add_argument_group("Output format selection (mutu= ally exclusive)") + + out_fmt =3D out_group.add_mutually_exclusive_group() + + out_fmt.add_argument("-m", "-man", "--man", action=3D"store_true", + help=3D"Output troff manual page format.") + out_fmt.add_argument("-r", "-rst", "--rst", action=3D"store_true", + help=3D"Output reStructuredText format (default).= ") + out_fmt.add_argument("-N", "-none", "--none", action=3D"store_true", + help=3D"Do not output documentation, only warning= s.") + + # Output selection mutually-exclusive group + + sel_group =3D parser.add_argument_group("Output selection (mutually ex= clusive)") + sel_mut =3D sel_group.add_mutually_exclusive_group() + + sel_mut.add_argument("-e", "-export", "--export", action=3D'store_true= ', + help=3DEXPORT_DESC) + + sel_mut.add_argument("-i", "-internal", "--internal", action=3D'store_= true', + help=3DINTERNAL_DESC) + + sel_mut.add_argument("-s", "-function", "--symbol", action=3D'append', + help=3DFUNCTION_DESC) + + # Those are valid for all 3 types of filter + parser.add_argument("-n", "-nosymbol", "--nosymbol", action=3D'append', + help=3DNOSYMBOL_DESC) + + parser.add_argument("-D", "-no-doc-sections", "--no-doc-sections", + action=3D'store_true', help=3D"Don't outputt DOC s= ections") + + parser.add_argument("files", metavar=3D"FILE", + nargs=3D"+", help=3DFILES_DESC) + + args =3D parser.parse_args() + + if args.wall: + args.wreturn =3D True + args.wshort_desc =3D True + args.wcontents_before_sections =3D True + + logger =3D logging.getLogger() + + if not args.debug: + logger.setLevel(logging.INFO) + else: + logger.setLevel(logging.DEBUG) + + formatter =3D MsgFormatter('%(levelname)s: %(message)s') + + handler =3D logging.StreamHandler() + handler.setFormatter(formatter) + + logger.addHandler(handler) + + python_ver =3D sys.version_info[:2] + if python_ver < (3,6): + logger.warning("Python 3.6 or later is required by kernel-doc") + + # Return 0 here to avoid breaking compilation + sys.exit(0) + + if python_ver < (3,7): + logger.warning("Python 3.7 or later is required for correct result= s") + + if args.man: + out_style =3D ManFormat(modulename=3Dargs.modulename) + elif args.none: + out_style =3D None + else: + out_style =3D RestFormat() + + kfiles =3D KernelFiles(verbose=3Dargs.verbose, + out_style=3Dout_style, werror=3Dargs.werror, + wreturn=3Dargs.wreturn, wshort_desc=3Dargs.wshort= _desc, + wcontents_before_sections=3Dargs.wcontents_before= _sections) + + kfiles.parse(args.files, export_file=3Dargs.export_file) + + for t in kfiles.msg(enable_lineno=3Dargs.enable_lineno, export=3Dargs.= export, + internal=3Dargs.internal, symbol=3Dargs.symbol, + nosymbol=3Dargs.nosymbol, export_file=3Dargs.expor= t_file, + no_doc_sections=3Dargs.no_doc_sections): + msg =3D t[1] + if msg: + print(msg) + + error_count =3D kfiles.errors + if not error_count: + sys.exit(0) + + if args.werror: + print(f"{error_count} warnings as errors") + sys.exit(error_count) + + if args.verbose: + print(f"{error_count} errors") + + if args.none: + sys.exit(0) + + sys.exit(error_count) + + +# Call main method +if __name__ =3D=3D "__main__": + main() diff --git a/scripts/lib/kdoc/kdoc_files.py b/scripts/lib/kdoc/kdoc_files.py new file mode 100644 index 00000000000..9e09b45b02f --- /dev/null +++ b/scripts/lib/kdoc/kdoc_files.py @@ -0,0 +1,291 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# +# pylint: disable=3DR0903,R0913,R0914,R0917 + +""" +Parse lernel-doc tags on multiple kernel source files. +""" + +import argparse +import logging +import os +import re + +from kdoc_parser import KernelDoc +from kdoc_output import OutputFormat + + +class GlobSourceFiles: + """ + Parse C source code file names and directories via an Interactor. + """ + + def __init__(self, srctree=3DNone, valid_extensions=3DNone): + """ + Initialize valid extensions with a tuple. + + If not defined, assume default C extensions (.c and .h) + + It would be possible to use python's glob function, but it is + very slow, and it is not interactive. So, it would wait to read all + directories before actually do something. + + So, let's use our own implementation. + """ + + if not valid_extensions: + self.extensions =3D (".c", ".h") + else: + self.extensions =3D valid_extensions + + self.srctree =3D srctree + + def _parse_dir(self, dirname): + """Internal function to parse files recursively""" + + with os.scandir(dirname) as obj: + for entry in obj: + name =3D os.path.join(dirname, entry.name) + + if entry.is_dir(): + yield from self._parse_dir(name) + + if not entry.is_file(): + continue + + basename =3D os.path.basename(name) + + if not basename.endswith(self.extensions): + continue + + yield name + + def parse_files(self, file_list, file_not_found_cb): + """ + Define an interator to parse all source files from file_list, + handling directories if any + """ + + if not file_list: + return + + for fname in file_list: + if self.srctree: + f =3D os.path.join(self.srctree, fname) + else: + f =3D fname + + if os.path.isdir(f): + yield from self._parse_dir(f) + elif os.path.isfile(f): + yield f + elif file_not_found_cb: + file_not_found_cb(fname) + + +class KernelFiles(): + """ + Parse kernel-doc tags on multiple kernel source files. + + There are two type of parsers defined here: + - self.parse_file(): parses both kernel-doc markups and + EXPORT_SYMBOL* macros; + - self.process_export_file(): parses only EXPORT_SYMBOL* macros. + """ + + def warning(self, msg): + """Ancillary routine to output a warning and increment error count= """ + + self.config.log.warning(msg) + self.errors +=3D 1 + + def error(self, msg): + """Ancillary routine to output an error and increment error count"= "" + + self.config.log.error(msg) + self.errors +=3D 1 + + def parse_file(self, fname): + """ + Parse a single Kernel source. + """ + + # Prevent parsing the same file twice if results are cached + if fname in self.files: + return + + doc =3D KernelDoc(self.config, fname) + export_table, entries =3D doc.parse_kdoc() + + self.export_table[fname] =3D export_table + + self.files.add(fname) + self.export_files.add(fname) # parse_kdoc() already check exp= orts + + self.results[fname] =3D entries + + def process_export_file(self, fname): + """ + Parses EXPORT_SYMBOL* macros from a single Kernel source file. + """ + + # Prevent parsing the same file twice if results are cached + if fname in self.export_files: + return + + doc =3D KernelDoc(self.config, fname) + export_table =3D doc.parse_export() + + if not export_table: + self.error(f"Error: Cannot check EXPORT_SYMBOL* on {fname}") + export_table =3D set() + + self.export_table[fname] =3D export_table + self.export_files.add(fname) + + def file_not_found_cb(self, fname): + """ + Callback to warn if a file was not found. + """ + + self.error(f"Cannot find file {fname}") + + def __init__(self, verbose=3DFalse, out_style=3DNone, + werror=3DFalse, wreturn=3DFalse, wshort_desc=3DFalse, + wcontents_before_sections=3DFalse, + logger=3DNone): + """ + Initialize startup variables and parse all files + """ + + if not verbose: + verbose =3D bool(os.environ.get("KBUILD_VERBOSE", 0)) + + if out_style is None: + out_style =3D OutputFormat() + + if not werror: + kcflags =3D os.environ.get("KCFLAGS", None) + if kcflags: + match =3D re.search(r"(\s|^)-Werror(\s|$)/", kcflags) + if match: + werror =3D True + + # reading this variable is for backwards compat just in case + # someone was calling it with the variable from outside the + # kernel's build system + kdoc_werror =3D os.environ.get("KDOC_WERROR", None) + if kdoc_werror: + werror =3D kdoc_werror + + # Some variables are global to the parser logic as a whole as they= are + # used to send control configuration to KernelDoc class. As such, + # those variables are read-only inside the KernelDoc. + self.config =3D argparse.Namespace + + self.config.verbose =3D verbose + self.config.werror =3D werror + self.config.wreturn =3D wreturn + self.config.wshort_desc =3D wshort_desc + self.config.wcontents_before_sections =3D wcontents_before_sections + + if not logger: + self.config.log =3D logging.getLogger("kernel-doc") + else: + self.config.log =3D logger + + self.config.warning =3D self.warning + + self.config.src_tree =3D os.environ.get("SRCTREE", None) + + # Initialize variables that are internal to KernelFiles + + self.out_style =3D out_style + + self.errors =3D 0 + self.results =3D {} + + self.files =3D set() + self.export_files =3D set() + self.export_table =3D {} + + def parse(self, file_list, export_file=3DNone): + """ + Parse all files + """ + + glob =3D GlobSourceFiles(srctree=3Dself.config.src_tree) + + for fname in glob.parse_files(file_list, self.file_not_found_cb): + self.parse_file(fname) + + for fname in glob.parse_files(export_file, self.file_not_found_cb): + self.process_export_file(fname) + + def out_msg(self, fname, name, arg): + """ + Return output messages from a file name using the output style + filtering. + + If output type was not handled by the syler, return None. + """ + + # NOTE: we can add rules here to filter out unwanted parts, + # although OutputFormat.msg already does that. + + return self.out_style.msg(fname, name, arg) + + def msg(self, enable_lineno=3DFalse, export=3DFalse, internal=3DFalse, + symbol=3DNone, nosymbol=3DNone, no_doc_sections=3DFalse, + filenames=3DNone, export_file=3DNone): + """ + Interacts over the kernel-doc results and output messages, + returning kernel-doc markups on each interaction + """ + + self.out_style.set_config(self.config) + + if not filenames: + filenames =3D sorted(self.results.keys()) + + glob =3D GlobSourceFiles(srctree=3Dself.config.src_tree) + + for fname in filenames: + function_table =3D set() + + if internal or export: + if not export_file: + export_file =3D [fname] + + for f in glob.parse_files(export_file, self.file_not_found= _cb): + function_table |=3D self.export_table[f] + + if symbol: + for s in symbol: + function_table.add(s) + + self.out_style.set_filter(export, internal, symbol, nosymbol, + function_table, enable_lineno, + no_doc_sections) + + msg =3D "" + if fname not in self.results: + self.config.log.warning("No kernel-doc for file %s", fname) + continue + + for arg in self.results[fname]: + m =3D self.out_msg(fname, arg.name, arg) + + if m is None: + ln =3D arg.get("ln", 0) + dtype =3D arg.get('type', "") + + self.config.log.warning("%s:%d Can't handle %s", + fname, ln, dtype) + else: + msg +=3D m + + if msg: + yield fname, msg diff --git a/scripts/lib/kdoc/kdoc_item.py b/scripts/lib/kdoc/kdoc_item.py new file mode 100644 index 00000000000..b3b22576455 --- /dev/null +++ b/scripts/lib/kdoc/kdoc_item.py @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# A class that will, eventually, encapsulate all of the parsed data that we +# then pass into the output modules. +# + +class KdocItem: + def __init__(self, name, type, start_line, **other_stuff): + self.name =3D name + self.type =3D type + self.declaration_start_line =3D start_line + self.sections =3D {} + self.sections_start_lines =3D {} + self.parameterlist =3D [] + self.parameterdesc_start_lines =3D [] + self.parameterdescs =3D {} + self.parametertypes =3D {} + # + # Just save everything else into our own dict so that the output + # side can grab it directly as before. As we move things into more + # structured data, this will, hopefully, fade away. + # + self.other_stuff =3D other_stuff + + def get(self, key, default =3D None): + return self.other_stuff.get(key, default) + + def __getitem__(self, key): + return self.get(key) + + # + # Tracking of section and parameter information. + # + def set_sections(self, sections, start_lines): + self.sections =3D sections + self.section_start_lines =3D start_lines + + def set_params(self, names, descs, types, starts): + self.parameterlist =3D names + self.parameterdescs =3D descs + self.parametertypes =3D types + self.parameterdesc_start_lines =3D starts diff --git a/scripts/lib/kdoc/kdoc_output.py b/scripts/lib/kdoc/kdoc_output= .py new file mode 100644 index 00000000000..ea8914537ba --- /dev/null +++ b/scripts/lib/kdoc/kdoc_output.py @@ -0,0 +1,749 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# +# pylint: disable=3DC0301,R0902,R0911,R0912,R0913,R0914,R0915,R0917 + +""" +Implement output filters to print kernel-doc documentation. + +The implementation uses a virtual base class (OutputFormat) which +contains a dispatches to virtual methods, and some code to filter +out output messages. + +The actual implementation is done on one separate class per each type +of output. Currently, there are output classes for ReST and man/troff. +""" + +import os +import re +from datetime import datetime + +from kdoc_parser import KernelDoc, type_param +from kdoc_re import KernRe + + +function_pointer =3D KernRe(r"([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)", cache=3DF= alse) + +# match expressions used to find embedded type information +type_constant =3D KernRe(r"\b``([^\`]+)``\b", cache=3DFalse) +type_constant2 =3D KernRe(r"\%([-_*\w]+)", cache=3DFalse) +type_func =3D KernRe(r"(\w+)\(\)", cache=3DFalse) +type_param_ref =3D KernRe(r"([\!~\*]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)",= cache=3DFalse) + +# Special RST handling for func ptr params +type_fp_param =3D KernRe(r"\@(\w+)\(\)", cache=3DFalse) + +# Special RST handling for structs with func ptr params +type_fp_param2 =3D KernRe(r"\@(\w+->\S+)\(\)", cache=3DFalse) + +type_env =3D KernRe(r"(\$\w+)", cache=3DFalse) +type_enum =3D KernRe(r"\&(enum\s*([_\w]+))", cache=3DFalse) +type_struct =3D KernRe(r"\&(struct\s*([_\w]+))", cache=3DFalse) +type_typedef =3D KernRe(r"\&(typedef\s*([_\w]+))", cache=3DFalse) +type_union =3D KernRe(r"\&(union\s*([_\w]+))", cache=3DFalse) +type_member =3D KernRe(r"\&([_\w]+)(\.|->)([_\w]+)", cache=3DFalse) +type_fallback =3D KernRe(r"\&([_\w]+)", cache=3DFalse) +type_member_func =3D type_member + KernRe(r"\(\)", cache=3DFalse) + + +class OutputFormat: + """ + Base class for OutputFormat. If used as-is, it means that only + warnings will be displayed. + """ + + # output mode. + OUTPUT_ALL =3D 0 # output all symbols and doc sections + OUTPUT_INCLUDE =3D 1 # output only specified symbols + OUTPUT_EXPORTED =3D 2 # output exported symbols + OUTPUT_INTERNAL =3D 3 # output non-exported symbols + + # Virtual member to be overriden at the inherited classes + highlights =3D [] + + def __init__(self): + """Declare internal vars and set mode to OUTPUT_ALL""" + + self.out_mode =3D self.OUTPUT_ALL + self.enable_lineno =3D None + self.nosymbol =3D {} + self.symbol =3D None + self.function_table =3D None + self.config =3D None + self.no_doc_sections =3D False + + self.data =3D "" + + def set_config(self, config): + """ + Setup global config variables used by both parser and output. + """ + + self.config =3D config + + def set_filter(self, export, internal, symbol, nosymbol, function_tabl= e, + enable_lineno, no_doc_sections): + """ + Initialize filter variables according with the requested mode. + + Only one choice is valid between export, internal and symbol. + + The nosymbol filter can be used on all modes. + """ + + self.enable_lineno =3D enable_lineno + self.no_doc_sections =3D no_doc_sections + self.function_table =3D function_table + + if symbol: + self.out_mode =3D self.OUTPUT_INCLUDE + elif export: + self.out_mode =3D self.OUTPUT_EXPORTED + elif internal: + self.out_mode =3D self.OUTPUT_INTERNAL + else: + self.out_mode =3D self.OUTPUT_ALL + + if nosymbol: + self.nosymbol =3D set(nosymbol) + + + def highlight_block(self, block): + """ + Apply the RST highlights to a sub-block of text. + """ + + for r, sub in self.highlights: + block =3D r.sub(sub, block) + + return block + + def out_warnings(self, args): + """ + Output warnings for identifiers that will be displayed. + """ + + for log_msg in args.warnings: + self.config.warning(log_msg) + + def check_doc(self, name, args): + """Check if DOC should be output""" + + if self.no_doc_sections: + return False + + if name in self.nosymbol: + return False + + if self.out_mode =3D=3D self.OUTPUT_ALL: + self.out_warnings(args) + return True + + if self.out_mode =3D=3D self.OUTPUT_INCLUDE: + if name in self.function_table: + self.out_warnings(args) + return True + + return False + + def check_declaration(self, dtype, name, args): + """ + Checks if a declaration should be output or not based on the + filtering criteria. + """ + + if name in self.nosymbol: + return False + + if self.out_mode =3D=3D self.OUTPUT_ALL: + self.out_warnings(args) + return True + + if self.out_mode in [self.OUTPUT_INCLUDE, self.OUTPUT_EXPORTED]: + if name in self.function_table: + return True + + if self.out_mode =3D=3D self.OUTPUT_INTERNAL: + if dtype !=3D "function": + self.out_warnings(args) + return True + + if name not in self.function_table: + self.out_warnings(args) + return True + + return False + + def msg(self, fname, name, args): + """ + Handles a single entry from kernel-doc parser + """ + + self.data =3D "" + + dtype =3D args.type + + if dtype =3D=3D "doc": + self.out_doc(fname, name, args) + return self.data + + if not self.check_declaration(dtype, name, args): + return self.data + + if dtype =3D=3D "function": + self.out_function(fname, name, args) + return self.data + + if dtype =3D=3D "enum": + self.out_enum(fname, name, args) + return self.data + + if dtype =3D=3D "typedef": + self.out_typedef(fname, name, args) + return self.data + + if dtype in ["struct", "union"]: + self.out_struct(fname, name, args) + return self.data + + # Warn if some type requires an output logic + self.config.log.warning("doesn't now how to output '%s' block", + dtype) + + return None + + # Virtual methods to be overridden by inherited classes + # At the base class, those do nothing. + def out_doc(self, fname, name, args): + """Outputs a DOC block""" + + def out_function(self, fname, name, args): + """Outputs a function""" + + def out_enum(self, fname, name, args): + """Outputs an enum""" + + def out_typedef(self, fname, name, args): + """Outputs a typedef""" + + def out_struct(self, fname, name, args): + """Outputs a struct""" + + +class RestFormat(OutputFormat): + """Consts and functions used by ReST output""" + + highlights =3D [ + (type_constant, r"``\1``"), + (type_constant2, r"``\1``"), + + # Note: need to escape () to avoid func matching later + (type_member_func, r":c:type:`\1\2\3\\(\\) <\1>`"), + (type_member, r":c:type:`\1\2\3 <\1>`"), + (type_fp_param, r"**\1\\(\\)**"), + (type_fp_param2, r"**\1\\(\\)**"), + (type_func, r"\1()"), + (type_enum, r":c:type:`\1 <\2>`"), + (type_struct, r":c:type:`\1 <\2>`"), + (type_typedef, r":c:type:`\1 <\2>`"), + (type_union, r":c:type:`\1 <\2>`"), + + # in rst this can refer to any type + (type_fallback, r":c:type:`\1`"), + (type_param_ref, r"**\1\2**") + ] + blankline =3D "\n" + + sphinx_literal =3D KernRe(r'^[^.].*::$', cache=3DFalse) + sphinx_cblock =3D KernRe(r'^\.\.\ +code-block::', cache=3DFalse) + + def __init__(self): + """ + Creates class variables. + + Not really mandatory, but it is a good coding style and makes + pylint happy. + """ + + super().__init__() + self.lineprefix =3D "" + + def print_lineno(self, ln): + """Outputs a line number""" + + if self.enable_lineno and ln is not None: + ln +=3D 1 + self.data +=3D f".. LINENO {ln}\n" + + def output_highlight(self, args): + """ + Outputs a C symbol that may require being converted to ReST using + the self.highlights variable + """ + + input_text =3D args + output =3D "" + in_literal =3D False + litprefix =3D "" + block =3D "" + + for line in input_text.strip("\n").split("\n"): + + # If we're in a literal block, see if we should drop out of it. + # Otherwise, pass the line straight through unmunged. + if in_literal: + if line.strip(): # If the line is not blank + # If this is the first non-blank line in a literal blo= ck, + # figure out the proper indent. + if not litprefix: + r =3D KernRe(r'^(\s*)') + if r.match(line): + litprefix =3D '^' + r.group(1) + else: + litprefix =3D "" + + output +=3D line + "\n" + elif not KernRe(litprefix).match(line): + in_literal =3D False + else: + output +=3D line + "\n" + else: + output +=3D line + "\n" + + # Not in a literal block (or just dropped out) + if not in_literal: + block +=3D line + "\n" + if self.sphinx_literal.match(line) or self.sphinx_cblock.m= atch(line): + in_literal =3D True + litprefix =3D "" + output +=3D self.highlight_block(block) + block =3D "" + + # Handle any remaining block + if block: + output +=3D self.highlight_block(block) + + # Print the output with the line prefix + for line in output.strip("\n").split("\n"): + self.data +=3D self.lineprefix + line + "\n" + + def out_section(self, args, out_docblock=3DFalse): + """ + Outputs a block section. + + This could use some work; it's used to output the DOC: sections, a= nd + starts by putting out the name of the doc section itself, but that + tends to duplicate a header already in the template file. + """ + for section, text in args.sections.items(): + # Skip sections that are in the nosymbol_table + if section in self.nosymbol: + continue + + if out_docblock: + if not self.out_mode =3D=3D self.OUTPUT_INCLUDE: + self.data +=3D f".. _{section}:\n\n" + self.data +=3D f'{self.lineprefix}**{section}**\n\n' + else: + self.data +=3D f'{self.lineprefix}**{section}**\n\n' + + self.print_lineno(args.section_start_lines.get(section, 0)) + self.output_highlight(text) + self.data +=3D "\n" + self.data +=3D "\n" + + def out_doc(self, fname, name, args): + if not self.check_doc(name, args): + return + self.out_section(args, out_docblock=3DTrue) + + def out_function(self, fname, name, args): + + oldprefix =3D self.lineprefix + signature =3D "" + + func_macro =3D args.get('func_macro', False) + if func_macro: + signature =3D name + else: + if args.get('functiontype'): + signature =3D args['functiontype'] + " " + signature +=3D name + " (" + + ln =3D args.declaration_start_line + count =3D 0 + for parameter in args.parameterlist: + if count !=3D 0: + signature +=3D ", " + count +=3D 1 + dtype =3D args.parametertypes.get(parameter, "") + + if function_pointer.search(dtype): + signature +=3D function_pointer.group(1) + parameter + fun= ction_pointer.group(3) + else: + signature +=3D dtype + + if not func_macro: + signature +=3D ")" + + self.print_lineno(ln) + if args.get('typedef') or not args.get('functiontype'): + self.data +=3D f".. c:macro:: {name}\n\n" + + if args.get('typedef'): + self.data +=3D " **Typedef**: " + self.lineprefix =3D "" + self.output_highlight(args.get('purpose', "")) + self.data +=3D "\n\n**Syntax**\n\n" + self.data +=3D f" ``{signature}``\n\n" + else: + self.data +=3D f"``{signature}``\n\n" + else: + self.data +=3D f".. c:function:: {signature}\n\n" + + if not args.get('typedef'): + self.print_lineno(ln) + self.lineprefix =3D " " + self.output_highlight(args.get('purpose', "")) + self.data +=3D "\n" + + # Put descriptive text into a container (HTML
) to help set + # function prototypes apart + self.lineprefix =3D " " + + if args.parameterlist: + self.data +=3D ".. container:: kernelindent\n\n" + self.data +=3D f"{self.lineprefix}**Parameters**\n\n" + + for parameter in args.parameterlist: + parameter_name =3D KernRe(r'\[.*').sub('', parameter) + dtype =3D args.parametertypes.get(parameter, "") + + if dtype: + self.data +=3D f"{self.lineprefix}``{dtype}``\n" + else: + self.data +=3D f"{self.lineprefix}``{parameter}``\n" + + self.print_lineno(args.parameterdesc_start_lines.get(parameter= _name, 0)) + + self.lineprefix =3D " " + if parameter_name in args.parameterdescs and \ + args.parameterdescs[parameter_name] !=3D KernelDoc.undescri= bed: + + self.output_highlight(args.parameterdescs[parameter_name]) + self.data +=3D "\n" + else: + self.data +=3D f"{self.lineprefix}*undescribed*\n\n" + self.lineprefix =3D " " + + self.out_section(args) + self.lineprefix =3D oldprefix + + def out_enum(self, fname, name, args): + + oldprefix =3D self.lineprefix + ln =3D args.declaration_start_line + + self.data +=3D f"\n\n.. c:enum:: {name}\n\n" + + self.print_lineno(ln) + self.lineprefix =3D " " + self.output_highlight(args.get('purpose', '')) + self.data +=3D "\n" + + self.data +=3D ".. container:: kernelindent\n\n" + outer =3D self.lineprefix + " " + self.lineprefix =3D outer + " " + self.data +=3D f"{outer}**Constants**\n\n" + + for parameter in args.parameterlist: + self.data +=3D f"{outer}``{parameter}``\n" + + if args.parameterdescs.get(parameter, '') !=3D KernelDoc.undes= cribed: + self.output_highlight(args.parameterdescs[parameter]) + else: + self.data +=3D f"{self.lineprefix}*undescribed*\n\n" + self.data +=3D "\n" + + self.lineprefix =3D oldprefix + self.out_section(args) + + def out_typedef(self, fname, name, args): + + oldprefix =3D self.lineprefix + ln =3D args.declaration_start_line + + self.data +=3D f"\n\n.. c:type:: {name}\n\n" + + self.print_lineno(ln) + self.lineprefix =3D " " + + self.output_highlight(args.get('purpose', '')) + + self.data +=3D "\n" + + self.lineprefix =3D oldprefix + self.out_section(args) + + def out_struct(self, fname, name, args): + + purpose =3D args.get('purpose', "") + declaration =3D args.get('definition', "") + dtype =3D args.type + ln =3D args.declaration_start_line + + self.data +=3D f"\n\n.. c:{dtype}:: {name}\n\n" + + self.print_lineno(ln) + + oldprefix =3D self.lineprefix + self.lineprefix +=3D " " + + self.output_highlight(purpose) + self.data +=3D "\n" + + self.data +=3D ".. container:: kernelindent\n\n" + self.data +=3D f"{self.lineprefix}**Definition**::\n\n" + + self.lineprefix =3D self.lineprefix + " " + + declaration =3D declaration.replace("\t", self.lineprefix) + + self.data +=3D f"{self.lineprefix}{dtype} {name}" + ' {' + "\n" + self.data +=3D f"{declaration}{self.lineprefix}" + "};\n\n" + + self.lineprefix =3D " " + self.data +=3D f"{self.lineprefix}**Members**\n\n" + for parameter in args.parameterlist: + if not parameter or parameter.startswith("#"): + continue + + parameter_name =3D parameter.split("[", maxsplit=3D1)[0] + + if args.parameterdescs.get(parameter_name) =3D=3D KernelDoc.un= described: + continue + + self.print_lineno(args.parameterdesc_start_lines.get(parameter= _name, 0)) + + self.data +=3D f"{self.lineprefix}``{parameter}``\n" + + self.lineprefix =3D " " + self.output_highlight(args.parameterdescs[parameter_name]) + self.lineprefix =3D " " + + self.data +=3D "\n" + + self.data +=3D "\n" + + self.lineprefix =3D oldprefix + self.out_section(args) + + +class ManFormat(OutputFormat): + """Consts and functions used by man pages output""" + + highlights =3D ( + (type_constant, r"\1"), + (type_constant2, r"\1"), + (type_func, r"\\fB\1\\fP"), + (type_enum, r"\\fI\1\\fP"), + (type_struct, r"\\fI\1\\fP"), + (type_typedef, r"\\fI\1\\fP"), + (type_union, r"\\fI\1\\fP"), + (type_param, r"\\fI\1\\fP"), + (type_param_ref, r"\\fI\1\2\\fP"), + (type_member, r"\\fI\1\2\3\\fP"), + (type_fallback, r"\\fI\1\\fP") + ) + blankline =3D "" + + date_formats =3D [ + "%a %b %d %H:%M:%S %Z %Y", + "%a %b %d %H:%M:%S %Y", + "%Y-%m-%d", + "%b %d %Y", + "%B %d %Y", + "%m %d %Y", + ] + + def __init__(self, modulename): + """ + Creates class variables. + + Not really mandatory, but it is a good coding style and makes + pylint happy. + """ + + super().__init__() + self.modulename =3D modulename + + dt =3D None + tstamp =3D os.environ.get("KBUILD_BUILD_TIMESTAMP") + if tstamp: + for fmt in self.date_formats: + try: + dt =3D datetime.strptime(tstamp, fmt) + break + except ValueError: + pass + + if not dt: + dt =3D datetime.now() + + self.man_date =3D dt.strftime("%B %Y") + + def output_highlight(self, block): + """ + Outputs a C symbol that may require being highlighted with + self.highlights variable using troff syntax + """ + + contents =3D self.highlight_block(block) + + if isinstance(contents, list): + contents =3D "\n".join(contents) + + for line in contents.strip("\n").split("\n"): + line =3D KernRe(r"^\s*").sub("", line) + if not line: + continue + + if line[0] =3D=3D ".": + self.data +=3D "\\&" + line + "\n" + else: + self.data +=3D line + "\n" + + def out_doc(self, fname, name, args): + if not self.check_doc(name, args): + return + + self.data +=3D f'.TH "{self.modulename}" 9 "{self.modulename}" "{s= elf.man_date}" "API Manual" LINUX' + "\n" + + for section, text in args.sections.items(): + self.data +=3D f'.SH "{section}"' + "\n" + self.output_highlight(text) + + def out_function(self, fname, name, args): + """output function in man""" + + self.data +=3D f'.TH "{name}" 9 "{name}" "{self.man_date}" "Kernel= Hacker\'s Manual" LINUX' + "\n" + + self.data +=3D ".SH NAME\n" + self.data +=3D f"{name} \\- {args['purpose']}\n" + + self.data +=3D ".SH SYNOPSIS\n" + if args.get('functiontype', ''): + self.data +=3D f'.B "{args["functiontype"]}" {name}' + "\n" + else: + self.data +=3D f'.B "{name}' + "\n" + + count =3D 0 + parenth =3D "(" + post =3D "," + + for parameter in args.parameterlist: + if count =3D=3D len(args.parameterlist) - 1: + post =3D ");" + + dtype =3D args.parametertypes.get(parameter, "") + if function_pointer.match(dtype): + # Pointer-to-function + self.data +=3D f'".BI "{parenth}{function_pointer.group(1)= }" " ") ({function_pointer.group(2)}){post}"' + "\n" + else: + dtype =3D KernRe(r'([^\*])$').sub(r'\1 ', dtype) + + self.data +=3D f'.BI "{parenth}{dtype}" "{post}"' + "\n" + count +=3D 1 + parenth =3D "" + + if args.parameterlist: + self.data +=3D ".SH ARGUMENTS\n" + + for parameter in args.parameterlist: + parameter_name =3D re.sub(r'\[.*', '', parameter) + + self.data +=3D f'.IP "{parameter}" 12' + "\n" + self.output_highlight(args.parameterdescs.get(parameter_name, = "")) + + for section, text in args.sections.items(): + self.data +=3D f'.SH "{section.upper()}"' + "\n" + self.output_highlight(text) + + def out_enum(self, fname, name, args): + self.data +=3D f'.TH "{self.modulename}" 9 "enum {name}" "{self.ma= n_date}" "API Manual" LINUX' + "\n" + + self.data +=3D ".SH NAME\n" + self.data +=3D f"enum {name} \\- {args['purpose']}\n" + + self.data +=3D ".SH SYNOPSIS\n" + self.data +=3D f"enum {name}" + " {\n" + + count =3D 0 + for parameter in args.parameterlist: + self.data +=3D f'.br\n.BI " {parameter}"' + "\n" + if count =3D=3D len(args.parameterlist) - 1: + self.data +=3D "\n};\n" + else: + self.data +=3D ", \n.br\n" + + count +=3D 1 + + self.data +=3D ".SH Constants\n" + + for parameter in args.parameterlist: + parameter_name =3D KernRe(r'\[.*').sub('', parameter) + self.data +=3D f'.IP "{parameter}" 12' + "\n" + self.output_highlight(args.parameterdescs.get(parameter_name, = "")) + + for section, text in args.sections.items(): + self.data +=3D f'.SH "{section}"' + "\n" + self.output_highlight(text) + + def out_typedef(self, fname, name, args): + module =3D self.modulename + purpose =3D args.get('purpose') + + self.data +=3D f'.TH "{module}" 9 "{name}" "{self.man_date}" "API = Manual" LINUX' + "\n" + + self.data +=3D ".SH NAME\n" + self.data +=3D f"typedef {name} \\- {purpose}\n" + + for section, text in args.sections.items(): + self.data +=3D f'.SH "{section}"' + "\n" + self.output_highlight(text) + + def out_struct(self, fname, name, args): + module =3D self.modulename + purpose =3D args.get('purpose') + definition =3D args.get('definition') + + self.data +=3D f'.TH "{module}" 9 "{args.type} {name}" "{self.man_= date}" "API Manual" LINUX' + "\n" + + self.data +=3D ".SH NAME\n" + self.data +=3D f"{args.type} {name} \\- {purpose}\n" + + # Replace tabs with two spaces and handle newlines + declaration =3D definition.replace("\t", " ") + declaration =3D KernRe(r"\n").sub('"\n.br\n.BI "', declaration) + + self.data +=3D ".SH SYNOPSIS\n" + self.data +=3D f"{args.type} {name} " + "{" + "\n.br\n" + self.data +=3D f'.BI "{declaration}\n' + "};\n.br\n\n" + + self.data +=3D ".SH Members\n" + for parameter in args.parameterlist: + if parameter.startswith("#"): + continue + + parameter_name =3D re.sub(r"\[.*", "", parameter) + + if args.parameterdescs.get(parameter_name) =3D=3D KernelDoc.un= described: + continue + + self.data +=3D f'.IP "{parameter}" 12' + "\n" + self.output_highlight(args.parameterdescs.get(parameter_name)) + + for section, text in args.sections.items(): + self.data +=3D f'.SH "{section}"' + "\n" + self.output_highlight(text) diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser= .py new file mode 100644 index 00000000000..fe730099eca --- /dev/null +++ b/scripts/lib/kdoc/kdoc_parser.py @@ -0,0 +1,1669 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# +# pylint: disable=3DC0301,C0302,R0904,R0912,R0913,R0914,R0915,R0917,R1702 + +""" +kdoc_parser +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Read a C language source or header FILE and extract embedded +documentation comments +""" + +import sys +import re +from pprint import pformat + +from kdoc_re import NestedMatch, KernRe +from kdoc_item import KdocItem + +# +# Regular expressions used to parse kernel-doc markups at KernelDoc class. +# +# Let's declare them in lowercase outside any class to make easier to +# convert from the python script. +# +# As those are evaluated at the beginning, no need to cache them +# + +# Allow whitespace at end of comment start. +doc_start =3D KernRe(r'^/\*\*\s*$', cache=3DFalse) + +doc_end =3D KernRe(r'\*/', cache=3DFalse) +doc_com =3D KernRe(r'\s*\*\s*', cache=3DFalse) +doc_com_body =3D KernRe(r'\s*\* ?', cache=3DFalse) +doc_decl =3D doc_com + KernRe(r'(\w+)', cache=3DFalse) + +# @params and a strictly limited set of supported section names +# Specifically: +# Match @word: +# @...: +# @{section-name}: +# while trying to not match literal block starts like "example::" +# +known_section_names =3D 'description|context|returns?|notes?|examples?' +known_sections =3D KernRe(known_section_names, flags =3D re.I) +doc_sect =3D doc_com + \ + KernRe(r'\s*(\@[.\w]+|\@\.\.\.|' + known_section_names + r')\s*:([^:].= *)?$', + flags=3Dre.I, cache=3DFalse) + +doc_content =3D doc_com_body + KernRe(r'(.*)', cache=3DFalse) +doc_inline_start =3D KernRe(r'^\s*/\*\*\s*$', cache=3DFalse) +doc_inline_sect =3D KernRe(r'\s*\*\s*(@\s*[\w][\w\.]*\s*):(.*)', cache=3DF= alse) +doc_inline_end =3D KernRe(r'^\s*\*/\s*$', cache=3DFalse) +doc_inline_oneline =3D KernRe(r'^\s*/\*\*\s*(@[\w\s]+):\s*(.*)\s*\*/\s*$',= cache=3DFalse) +attribute =3D KernRe(r"__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)", + flags=3Dre.I | re.S, cache=3DFalse) + +export_symbol =3D KernRe(r'^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*',= cache=3DFalse) +export_symbol_ns =3D KernRe(r'^\s*EXPORT_SYMBOL_NS(_GPL)?\s*\(\s*(\w+)\s*,= \s*"\S+"\)\s*', cache=3DFalse) + +type_param =3D KernRe(r"\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)", cache=3DFalse) + +# +# Tests for the beginning of a kerneldoc block in its various forms. +# +doc_block =3D doc_com + KernRe(r'DOC:\s*(.*)?', cache=3DFalse) +doc_begin_data =3D KernRe(r"^\s*\*?\s*(struct|union|enum|typedef)\b\s*(\w*= )", cache =3D False) +doc_begin_func =3D KernRe(str(doc_com) + # initial " * ' + r"(?:\w+\s*\*\s*)?" + # type (not captured) + r'(?:define\s+)?' + # possible "define" (not cap= tured) + r'(\w+)\s*(?:\(\w*\))?\s*' + # name and optional "= (...)" + r'(?:[-:].*)?$', # description (not captured) + cache =3D False) + +# +# A little helper to get rid of excess white space +# +multi_space =3D KernRe(r'\s\s+') +def trim_whitespace(s): + return multi_space.sub(' ', s.strip()) + +class state: + """ + State machine enums + """ + + # Parser states + NORMAL =3D 0 # normal code + NAME =3D 1 # looking for function name + DECLARATION =3D 2 # We have seen a declaration which might no= t be done + BODY =3D 3 # the body of the comment + SPECIAL_SECTION =3D 4 # doc section ending with a blank line + PROTO =3D 5 # scanning prototype + DOCBLOCK =3D 6 # documentation block + INLINE_NAME =3D 7 # gathering doc outside main block + INLINE_TEXT =3D 8 # reading the body of inline docs + + name =3D [ + "NORMAL", + "NAME", + "DECLARATION", + "BODY", + "SPECIAL_SECTION", + "PROTO", + "DOCBLOCK", + "INLINE_NAME", + "INLINE_TEXT", + ] + + +SECTION_DEFAULT =3D "Description" # default section + +class KernelEntry: + + def __init__(self, config, ln): + self.config =3D config + + self._contents =3D [] + self.prototype =3D "" + + self.warnings =3D [] + + self.parameterlist =3D [] + self.parameterdescs =3D {} + self.parametertypes =3D {} + self.parameterdesc_start_lines =3D {} + + self.section_start_lines =3D {} + self.sections =3D {} + + self.anon_struct_union =3D False + + self.leading_space =3D None + + # State flags + self.brcount =3D 0 + self.declaration_start_line =3D ln + 1 + + # + # Management of section contents + # + def add_text(self, text): + self._contents.append(text) + + def contents(self): + return '\n'.join(self._contents) + '\n' + + # TODO: rename to emit_message after removal of kernel-doc.pl + def emit_msg(self, log_msg, warning=3DTrue): + """Emit a message""" + + if not warning: + self.config.log.info(log_msg) + return + + # Delegate warning output to output logic, as this way it + # will report warnings/info only for symbols that are output + + self.warnings.append(log_msg) + return + + # + # Begin a new section. + # + def begin_section(self, line_no, title =3D SECTION_DEFAULT, dump =3D F= alse): + if dump: + self.dump_section(start_new =3D True) + self.section =3D title + self.new_start_line =3D line_no + + def dump_section(self, start_new=3DTrue): + """ + Dumps section contents to arrays/hashes intended for that purpose. + """ + # + # If we have accumulated no contents in the default ("description") + # section, don't bother. + # + if self.section =3D=3D SECTION_DEFAULT and not self._contents: + return + name =3D self.section + contents =3D self.contents() + + if type_param.match(name): + name =3D type_param.group(1) + + self.parameterdescs[name] =3D contents + self.parameterdesc_start_lines[name] =3D self.new_start_line + + self.new_start_line =3D 0 + + else: + if name in self.sections and self.sections[name] !=3D "": + # Only warn on user-specified duplicate section names + if name !=3D SECTION_DEFAULT: + self.emit_msg(self.new_start_line, + f"duplicate section name '{name}'\n") + # Treat as a new paragraph - add a blank line + self.sections[name] +=3D '\n' + contents + else: + self.sections[name] =3D contents + self.section_start_lines[name] =3D self.new_start_line + self.new_start_line =3D 0 + +# self.config.log.debug("Section: %s : %s", name, pformat(vars(self= ))) + + if start_new: + self.section =3D SECTION_DEFAULT + self._contents =3D [] + + +class KernelDoc: + """ + Read a C language source or header FILE and extract embedded + documentation comments. + """ + + # Section names + + section_context =3D "Context" + section_return =3D "Return" + + undescribed =3D "-- undescribed --" + + def __init__(self, config, fname): + """Initialize internal variables""" + + self.fname =3D fname + self.config =3D config + + # Initial state for the state machines + self.state =3D state.NORMAL + + # Store entry currently being processed + self.entry =3D None + + # Place all potential outputs into an array + self.entries =3D [] + + # + # We need Python 3.7 for its "dicts remember the insertion + # order" guarantee + # + if sys.version_info.major =3D=3D 3 and sys.version_info.minor < 7: + self.emit_msg(0, + 'Python 3.7 or later is required for correct res= ults') + + def emit_msg(self, ln, msg, warning=3DTrue): + """Emit a message""" + + log_msg =3D f"{self.fname}:{ln} {msg}" + + if self.entry: + self.entry.emit_msg(log_msg, warning) + return + + if warning: + self.config.log.warning(log_msg) + else: + self.config.log.info(log_msg) + + def dump_section(self, start_new=3DTrue): + """ + Dumps section contents to arrays/hashes intended for that purpose. + """ + + if self.entry: + self.entry.dump_section(start_new) + + # TODO: rename it to store_declaration after removal of kernel-doc.pl + def output_declaration(self, dtype, name, **args): + """ + Stores the entry into an entry array. + + The actual output and output filters will be handled elsewhere + """ + + item =3D KdocItem(name, dtype, self.entry.declaration_start_line, = **args) + item.warnings =3D self.entry.warnings + + # Drop empty sections + # TODO: improve empty sections logic to emit warnings + sections =3D self.entry.sections + for section in ["Description", "Return"]: + if section in sections and not sections[section].rstrip(): + del sections[section] + item.set_sections(sections, self.entry.section_start_lines) + item.set_params(self.entry.parameterlist, self.entry.parameterdesc= s, + self.entry.parametertypes, + self.entry.parameterdesc_start_lines) + self.entries.append(item) + + self.config.log.debug("Output: %s:%s =3D %s", dtype, name, pformat= (args)) + + def reset_state(self, ln): + """ + Ancillary routine to create a new entry. It initializes all + variables used by the state machine. + """ + + self.entry =3D KernelEntry(self.config, ln) + + # State flags + self.state =3D state.NORMAL + + def push_parameter(self, ln, decl_type, param, dtype, + org_arg, declaration_name): + """ + Store parameters and their descriptions at self.entry. + """ + + if self.entry.anon_struct_union and dtype =3D=3D "" and param =3D= =3D "}": + return # Ignore the ending }; from anonymous struct/union + + self.entry.anon_struct_union =3D False + + param =3D KernRe(r'[\[\)].*').sub('', param, count=3D1) + + if dtype =3D=3D "" and param.endswith("..."): + if KernRe(r'\w\.\.\.$').search(param): + # For named variable parameters of the form `x...`, + # remove the dots + param =3D param[:-3] + else: + # Handles unnamed variable parameters + param =3D "..." + + if param not in self.entry.parameterdescs or \ + not self.entry.parameterdescs[param]: + + self.entry.parameterdescs[param] =3D "variable arguments" + + elif dtype =3D=3D "" and (not param or param =3D=3D "void"): + param =3D "void" + self.entry.parameterdescs[param] =3D "no arguments" + + elif dtype =3D=3D "" and param in ["struct", "union"]: + # Handle unnamed (anonymous) union or struct + dtype =3D param + param =3D "{unnamed_" + param + "}" + self.entry.parameterdescs[param] =3D "anonymous\n" + self.entry.anon_struct_union =3D True + + # Handle cache group enforcing variables: they do not need + # to be described in header files + elif "__cacheline_group" in param: + # Ignore __cacheline_group_begin and __cacheline_group_end + return + + # Warn if parameter has no description + # (but ignore ones starting with # as these are not parameters + # but inline preprocessor statements) + if param not in self.entry.parameterdescs and not param.startswith= ("#"): + self.entry.parameterdescs[param] =3D self.undescribed + + if "." not in param: + if decl_type =3D=3D 'function': + dname =3D f"{decl_type} parameter" + else: + dname =3D f"{decl_type} member" + + self.emit_msg(ln, + f"{dname} '{param}' not described in '{decla= ration_name}'") + + # Strip spaces from param so that it is one continuous string on + # parameterlist. This fixes a problem where check_sections() + # cannot find a parameter like "addr[6 + 2]" because it actually + # appears as "addr[6", "+", "2]" on the parameter list. + # However, it's better to maintain the param string unchanged for + # output, so just weaken the string compare in check_sections() + # to ignore "[blah" in a parameter string. + + self.entry.parameterlist.append(param) + org_arg =3D KernRe(r'\s\s+').sub(' ', org_arg) + self.entry.parametertypes[param] =3D org_arg + + + def create_parameter_list(self, ln, decl_type, args, + splitter, declaration_name): + """ + Creates a list of parameters, storing them at self.entry. + """ + + # temporarily replace all commas inside function pointer definition + arg_expr =3D KernRe(r'(\([^\),]+),') + while arg_expr.search(args): + args =3D arg_expr.sub(r"\1#", args) + + for arg in args.split(splitter): + # Strip comments + arg =3D KernRe(r'\/\*.*\*\/').sub('', arg) + + # Ignore argument attributes + arg =3D KernRe(r'\sPOS0?\s').sub(' ', arg) + + # Strip leading/trailing spaces + arg =3D arg.strip() + arg =3D KernRe(r'\s+').sub(' ', arg, count=3D1) + + if arg.startswith('#'): + # Treat preprocessor directive as a typeless variable just= to fill + # corresponding data structures "correctly". Catch it late= r in + # output_* subs. + + # Treat preprocessor directive as a typeless variable + self.push_parameter(ln, decl_type, arg, "", + "", declaration_name) + + elif KernRe(r'\(.+\)\s*\(').search(arg): + # Pointer-to-function + + arg =3D arg.replace('#', ',') + + r =3D KernRe(r'[^\(]+\(\*?\s*([\w\[\]\.]*)\s*\)') + if r.match(arg): + param =3D r.group(1) + else: + self.emit_msg(ln, f"Invalid param: {arg}") + param =3D arg + + dtype =3D KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).s= ub(r'\1', arg) + self.push_parameter(ln, decl_type, param, dtype, + arg, declaration_name) + + elif KernRe(r'\(.+\)\s*\[').search(arg): + # Array-of-pointers + + arg =3D arg.replace('#', ',') + r =3D KernRe(r'[^\(]+\(\s*\*\s*([\w\[\]\.]*?)\s*(\s*\[\s*[= \w]+\s*\]\s*)*\)') + if r.match(arg): + param =3D r.group(1) + else: + self.emit_msg(ln, f"Invalid param: {arg}") + param =3D arg + + dtype =3D KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).s= ub(r'\1', arg) + + self.push_parameter(ln, decl_type, param, dtype, + arg, declaration_name) + + elif arg: + arg =3D KernRe(r'\s*:\s*').sub(":", arg) + arg =3D KernRe(r'\s*\[').sub('[', arg) + + args =3D KernRe(r'\s*,\s*').split(arg) + if args[0] and '*' in args[0]: + args[0] =3D re.sub(r'(\*+)\s*', r' \1', args[0]) + + first_arg =3D [] + r =3D KernRe(r'^(.*\s+)(.*?\[.*\].*)$') + if args[0] and r.match(args[0]): + args.pop(0) + first_arg.extend(r.group(1)) + first_arg.append(r.group(2)) + else: + first_arg =3D KernRe(r'\s+').split(args.pop(0)) + + args.insert(0, first_arg.pop()) + dtype =3D ' '.join(first_arg) + + for param in args: + if KernRe(r'^(\*+)\s*(.*)').match(param): + r =3D KernRe(r'^(\*+)\s*(.*)') + if not r.match(param): + self.emit_msg(ln, f"Invalid param: {param}") + continue + + param =3D r.group(1) + + self.push_parameter(ln, decl_type, r.group(2), + f"{dtype} {r.group(1)}", + arg, declaration_name) + + elif KernRe(r'(.*?):(\w+)').search(param): + r =3D KernRe(r'(.*?):(\w+)') + if not r.match(param): + self.emit_msg(ln, f"Invalid param: {param}") + continue + + if dtype !=3D "": # Skip unnamed bit-fields + self.push_parameter(ln, decl_type, r.group(1), + f"{dtype}:{r.group(2)}", + arg, declaration_name) + else: + self.push_parameter(ln, decl_type, param, dtype, + arg, declaration_name) + + def check_sections(self, ln, decl_name, decl_type): + """ + Check for errors inside sections, emitting warnings if not found + parameters are described. + """ + for section in self.entry.sections: + if section not in self.entry.parameterlist and \ + not known_sections.search(section): + if decl_type =3D=3D 'function': + dname =3D f"{decl_type} parameter" + else: + dname =3D f"{decl_type} member" + self.emit_msg(ln, + f"Excess {dname} '{section}' description in = '{decl_name}'") + + def check_return_section(self, ln, declaration_name, return_type): + """ + If the function doesn't return void, warns about the lack of a + return description. + """ + + if not self.config.wreturn: + return + + # Ignore an empty return type (It's a macro) + # Ignore functions with a "void" return type (but not "void *") + if not return_type or KernRe(r'void\s*\w*\s*$').search(return_type= ): + return + + if not self.entry.sections.get("Return", None): + self.emit_msg(ln, + f"No description found for return value of '{dec= laration_name}'") + + def dump_struct(self, ln, proto): + """ + Store an entry for an struct or union + """ + + type_pattern =3D r'(struct|union)' + + qualifiers =3D [ + "__attribute__", + "__packed", + "__aligned", + "____cacheline_aligned_in_smp", + "____cacheline_aligned", + ] + + definition_body =3D r'\{(.*)\}\s*' + "(?:" + '|'.join(qualifiers) = + ")?" + struct_members =3D KernRe(type_pattern + r'([^\{\};]+)(\{)([^\{\}]= *)(\})([^\{\}\;]*)(\;)') + + # Extract struct/union definition + members =3D None + declaration_name =3D None + decl_type =3D None + + r =3D KernRe(type_pattern + r'\s+(\w+)\s*' + definition_body) + if r.search(proto): + decl_type =3D r.group(1) + declaration_name =3D r.group(2) + members =3D r.group(3) + else: + r =3D KernRe(r'typedef\s+' + type_pattern + r'\s*' + definitio= n_body + r'\s*(\w+)\s*;') + + if r.search(proto): + decl_type =3D r.group(1) + declaration_name =3D r.group(3) + members =3D r.group(2) + + if not members: + self.emit_msg(ln, f"{proto} error: Cannot parse struct or unio= n!") + return + + if self.entry.identifier !=3D declaration_name: + self.emit_msg(ln, + f"expecting prototype for {decl_type} {self.entr= y.identifier}. Prototype was for {decl_type} {declaration_name} instead\n") + return + + args_pattern =3D r'([^,)]+)' + + sub_prefixes =3D [ + (KernRe(r'\/\*\s*private:.*?\/\*\s*public:.*?\*\/', re.S | re.= I), ''), + (KernRe(r'\/\*\s*private:.*', re.S | re.I), ''), + + # Strip comments + (KernRe(r'\/\*.*?\*\/', re.S), ''), + + # Strip attributes + (attribute, ' '), + (KernRe(r'\s*__aligned\s*\([^;]*\)', re.S), ' '), + (KernRe(r'\s*__counted_by\s*\([^;]*\)', re.S), ' '), + (KernRe(r'\s*__counted_by_(le|be)\s*\([^;]*\)', re.S), ' '), + (KernRe(r'\s*__packed\s*', re.S), ' '), + (KernRe(r'\s*CRYPTO_MINALIGN_ATTR', re.S), ' '), + (KernRe(r'\s*____cacheline_aligned_in_smp', re.S), ' '), + (KernRe(r'\s*____cacheline_aligned', re.S), ' '), + + # Unwrap struct_group macros based on this definition: + # __struct_group(TAG, NAME, ATTRS, MEMBERS...) + # which has variants like: struct_group(NAME, MEMBERS...) + # Only MEMBERS arguments require documentation. + # + # Parsing them happens on two steps: + # + # 1. drop struct group arguments that aren't at MEMBERS, + # storing them as STRUCT_GROUP(MEMBERS) + # + # 2. remove STRUCT_GROUP() ancillary macro. + # + # The original logic used to remove STRUCT_GROUP() using an + # advanced regex: + # + # \bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*; + # + # with two patterns that are incompatible with + # Python re module, as it has: + # + # - a recursive pattern: (?1) + # - an atomic grouping: (?>...) + # + # I tried a simpler version: but it didn't work either: + # \bSTRUCT_GROUP\(([^\)]+)\)[^;]*; + # + # As it doesn't properly match the end parenthesis on some cas= es. + # + # So, a better solution was crafted: there's now a NestedMatch + # class that ensures that delimiters after a search are proper= ly + # matched. So, the implementation to drop STRUCT_GROUP() will = be + # handled in separate. + + (KernRe(r'\bstruct_group\s*\(([^,]*,)', re.S), r'STRUCT_GROUP(= '), + (KernRe(r'\bstruct_group_attr\s*\(([^,]*,){2}', re.S), r'STRUC= T_GROUP('), + (KernRe(r'\bstruct_group_tagged\s*\(([^,]*),([^,]*),', re.S), = r'struct \1 \2; STRUCT_GROUP('), + (KernRe(r'\b__struct_group\s*\(([^,]*,){3}', re.S), r'STRUCT_G= ROUP('), + + # Replace macros + # + # TODO: use NestedMatch for FOO($1, $2, ...) matches + # + # it is better to also move those to the NestedMatch logic, + # to ensure that parenthesis will be properly matched. + + (KernRe(r'__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)', re= .S), r'DECLARE_BITMAP(\1, __ETHTOOL_LINK_MODE_MASK_NBITS)'), + (KernRe(r'DECLARE_PHY_INTERFACE_MASK\s*\(([^\)]+)\)', re.S), r= 'DECLARE_BITMAP(\1, PHY_INTERFACE_MODE_MAX)'), + (KernRe(r'DECLARE_BITMAP\s*\(' + args_pattern + r',\s*' + args= _pattern + r'\)', re.S), r'unsigned long \1[BITS_TO_LONGS(\2)]'), + (KernRe(r'DECLARE_HASHTABLE\s*\(' + args_pattern + r',\s*' + a= rgs_pattern + r'\)', re.S), r'unsigned long \1[1 << ((\2) - 1)]'), + (KernRe(r'DECLARE_KFIFO\s*\(' + args_pattern + r',\s*' + args_= pattern + r',\s*' + args_pattern + r'\)', re.S), r'\2 *\1'), + (KernRe(r'DECLARE_KFIFO_PTR\s*\(' + args_pattern + r',\s*' + a= rgs_pattern + r'\)', re.S), r'\2 *\1'), + (KernRe(r'(?:__)?DECLARE_FLEX_ARRAY\s*\(' + args_pattern + r',= \s*' + args_pattern + r'\)', re.S), r'\1 \2[]'), + (KernRe(r'DEFINE_DMA_UNMAP_ADDR\s*\(' + args_pattern + r'\)', = re.S), r'dma_addr_t \1'), + (KernRe(r'DEFINE_DMA_UNMAP_LEN\s*\(' + args_pattern + r'\)', r= e.S), r'__u32 \1'), + (KernRe(r'VIRTIO_DECLARE_FEATURES\s*\(' + args_pattern + r'\)'= , re.S), r'u64 \1; u64 \1_array[VIRTIO_FEATURES_DWORDS]'), + ] + + # Regexes here are guaranteed to have the end limiter matching + # the start delimiter. Yet, right now, only one replace group + # is allowed. + + sub_nested_prefixes =3D [ + (re.compile(r'\bSTRUCT_GROUP\('), r'\1'), + ] + + for search, sub in sub_prefixes: + members =3D search.sub(sub, members) + + nested =3D NestedMatch() + + for search, sub in sub_nested_prefixes: + members =3D nested.sub(search, sub, members) + + # Keeps the original declaration as-is + declaration =3D members + + # Split nested struct/union elements + # + # This loop was simpler at the original kernel-doc perl version, as + # while ($members =3D~ m/$struct_members/) { ... } + # reads 'members' string on each interaction. + # + # Python behavior is different: it parses 'members' only once, + # creating a list of tuples from the first interaction. + # + # On other words, this won't get nested structs. + # + # So, we need to have an extra loop on Python to override such + # re limitation. + + while True: + tuples =3D struct_members.findall(members) + if not tuples: + break + + for t in tuples: + newmember =3D "" + maintype =3D t[0] + s_ids =3D t[5] + content =3D t[3] + + oldmember =3D "".join(t) + + for s_id in s_ids.split(','): + s_id =3D s_id.strip() + + newmember +=3D f"{maintype} {s_id}; " + s_id =3D KernRe(r'[:\[].*').sub('', s_id) + s_id =3D KernRe(r'^\s*\**(\S+)\s*').sub(r'\1', s_id) + + for arg in content.split(';'): + arg =3D arg.strip() + + if not arg: + continue + + r =3D KernRe(r'^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)= ') + if r.match(arg): + # Pointer-to-function + dtype =3D r.group(1) + name =3D r.group(2) + extra =3D r.group(3) + + if not name: + continue + + if not s_id: + # Anonymous struct/union + newmember +=3D f"{dtype}{name}{extra}; " + else: + newmember +=3D f"{dtype}{s_id}.{name}{extr= a}; " + + else: + arg =3D arg.strip() + # Handle bitmaps + arg =3D KernRe(r':\s*\d+\s*').sub('', arg) + + # Handle arrays + arg =3D KernRe(r'\[.*\]').sub('', arg) + + # Handle multiple IDs + arg =3D KernRe(r'\s*,\s*').sub(',', arg) + + r =3D KernRe(r'(.*)\s+([\S+,]+)') + + if r.search(arg): + dtype =3D r.group(1) + names =3D r.group(2) + else: + newmember +=3D f"{arg}; " + continue + + for name in names.split(','): + name =3D KernRe(r'^\s*\**(\S+)\s*').sub(r'= \1', name).strip() + + if not name: + continue + + if not s_id: + # Anonymous struct/union + newmember +=3D f"{dtype} {name}; " + else: + newmember +=3D f"{dtype} {s_id}.{name}= ; " + + members =3D members.replace(oldmember, newmember) + + # Ignore other nested elements, like enums + members =3D re.sub(r'(\{[^\{\}]*\})', '', members) + + self.create_parameter_list(ln, decl_type, members, ';', + declaration_name) + self.check_sections(ln, declaration_name, decl_type) + + # Adjust declaration for better display + declaration =3D KernRe(r'([\{;])').sub(r'\1\n', declaration) + declaration =3D KernRe(r'\}\s+;').sub('};', declaration) + + # Better handle inlined enums + while True: + r =3D KernRe(r'(enum\s+\{[^\}]+),([^\n])') + if not r.search(declaration): + break + + declaration =3D r.sub(r'\1,\n\2', declaration) + + def_args =3D declaration.split('\n') + level =3D 1 + declaration =3D "" + for clause in def_args: + + clause =3D clause.strip() + clause =3D KernRe(r'\s+').sub(' ', clause, count=3D1) + + if not clause: + continue + + if '}' in clause and level > 1: + level -=3D 1 + + if not KernRe(r'^\s*#').match(clause): + declaration +=3D "\t" * level + + declaration +=3D "\t" + clause + "\n" + if "{" in clause and "}" not in clause: + level +=3D 1 + + self.output_declaration(decl_type, declaration_name, + definition=3Ddeclaration, + purpose=3Dself.entry.declaration_purpose) + + def dump_enum(self, ln, proto): + """ + Stores an enum inside self.entries array. + """ + + # Ignore members marked private + proto =3D KernRe(r'\/\*\s*private:.*?\/\*\s*public:.*?\*\/', flags= =3Dre.S).sub('', proto) + proto =3D KernRe(r'\/\*\s*private:.*}', flags=3Dre.S).sub('}', pro= to) + + # Strip comments + proto =3D KernRe(r'\/\*.*?\*\/', flags=3Dre.S).sub('', proto) + + # Strip #define macros inside enums + proto =3D KernRe(r'#\s*((define|ifdef|if)\s+|endif)[^;]*;', flags= =3Dre.S).sub('', proto) + + # + # Parse out the name and members of the enum. Typedef form first. + # + r =3D KernRe(r'typedef\s+enum\s*\{(.*)\}\s*(\w*)\s*;') + if r.search(proto): + declaration_name =3D r.group(2) + members =3D r.group(1).rstrip() + # + # Failing that, look for a straight enum + # + else: + r =3D KernRe(r'enum\s+(\w*)\s*\{(.*)\}') + if r.match(proto): + declaration_name =3D r.group(1) + members =3D r.group(2).rstrip() + # + # OK, this isn't going to work. + # + else: + self.emit_msg(ln, f"{proto}: error: Cannot parse enum!") + return + # + # Make sure we found what we were expecting. + # + if self.entry.identifier !=3D declaration_name: + if self.entry.identifier =3D=3D "": + self.emit_msg(ln, + f"{proto}: wrong kernel-doc identifier on pr= ototype") + else: + self.emit_msg(ln, + f"expecting prototype for enum {self.entry.i= dentifier}. " + f"Prototype was for enum {declaration_name} = instead") + return + + if not declaration_name: + declaration_name =3D "(anonymous)" + # + # Parse out the name of each enum member, and verify that we + # have a description for it. + # + member_set =3D set() + members =3D KernRe(r'\([^;)]*\)').sub('', members) + for arg in members.split(','): + if not arg: + continue + arg =3D KernRe(r'^\s*(\w+).*').sub(r'\1', arg) + self.entry.parameterlist.append(arg) + if arg not in self.entry.parameterdescs: + self.entry.parameterdescs[arg] =3D self.undescribed + self.emit_msg(ln, + f"Enum value '{arg}' not described in enum '= {declaration_name}'") + member_set.add(arg) + # + # Ensure that every described member actually exists in the enum. + # + for k in self.entry.parameterdescs: + if k not in member_set: + self.emit_msg(ln, + f"Excess enum value '%{k}' description in '{= declaration_name}'") + + self.output_declaration('enum', declaration_name, + purpose=3Dself.entry.declaration_purpose) + + def dump_declaration(self, ln, prototype): + """ + Stores a data declaration inside self.entries array. + """ + + if self.entry.decl_type =3D=3D "enum": + self.dump_enum(ln, prototype) + elif self.entry.decl_type =3D=3D "typedef": + self.dump_typedef(ln, prototype) + elif self.entry.decl_type in ["union", "struct"]: + self.dump_struct(ln, prototype) + else: + # This would be a bug + self.emit_message(ln, f'Unknown declaration type: {self.entry.= decl_type}') + + def dump_function(self, ln, prototype): + """ + Stores a function of function macro inside self.entries array. + """ + + func_macro =3D False + return_type =3D '' + decl_type =3D 'function' + + # Prefixes that would be removed + sub_prefixes =3D [ + (r"^static +", "", 0), + (r"^extern +", "", 0), + (r"^asmlinkage +", "", 0), + (r"^inline +", "", 0), + (r"^__inline__ +", "", 0), + (r"^__inline +", "", 0), + (r"^__always_inline +", "", 0), + (r"^noinline +", "", 0), + (r"^__FORTIFY_INLINE +", "", 0), + (r"__init +", "", 0), + (r"__init_or_module +", "", 0), + (r"__deprecated +", "", 0), + (r"__flatten +", "", 0), + (r"__meminit +", "", 0), + (r"__must_check +", "", 0), + (r"__weak +", "", 0), + (r"__sched +", "", 0), + (r"_noprof", "", 0), + (r"__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +", "", 0), + (r"__(?:re)?alloc_size\s*\(\s*\d+\s*(?:,\s*\d+\s*)?\) +", "", = 0), + (r"__diagnose_as\s*\(\s*\S+\s*(?:,\s*\d+\s*)*\) +", "", 0), + (r"DECL_BUCKET_PARAMS\s*\(\s*(\S+)\s*,\s*(\S+)\s*\)", r"\1, \2= ", 0), + (r"__attribute_const__ +", "", 0), + + # It seems that Python support for re.X is broken: + # At least for me (Python 3.13), this didn't work +# (r""" +# __attribute__\s*\(\( +# (?: +# [\w\s]+ # attribute name +# (?:\([^)]*\))? # attribute arguments +# \s*,? # optional comma at the end +# )+ +# \)\)\s+ +# """, "", re.X), + + # So, remove whitespaces and comments from it + (r"__attribute__\s*\(\((?:[\w\s]+(?:\([^)]*\))?\s*,?)+\)\)\s+"= , "", 0), + ] + + for search, sub, flags in sub_prefixes: + prototype =3D KernRe(search, flags).sub(sub, prototype) + + # Macros are a special case, as they change the prototype format + new_proto =3D KernRe(r"^#\s*define\s+").sub("", prototype) + if new_proto !=3D prototype: + is_define_proto =3D True + prototype =3D new_proto + else: + is_define_proto =3D False + + # Yes, this truly is vile. We are looking for: + # 1. Return type (may be nothing if we're looking at a macro) + # 2. Function name + # 3. Function parameters. + # + # All the while we have to watch out for function pointer paramete= rs + # (which IIRC is what the two sections are for), C types (these + # regexps don't even start to express all the possibilities), and + # so on. + # + # If you mess with these regexps, it's a good idea to check that + # the following functions' documentation still comes out right: + # - parport_register_device (function pointer parameters) + # - atomic_set (macro) + # - pci_match_device, __copy_to_user (long return type) + + name =3D r'[a-zA-Z0-9_~:]+' + prototype_end1 =3D r'[^\(]*' + prototype_end2 =3D r'[^\{]*' + prototype_end =3D fr'\(({prototype_end1}|{prototype_end2})\)' + + # Besides compiling, Perl qr{[\w\s]+} works as a non-capturing gro= up. + # So, this needs to be mapped in Python with (?:...)? or (?:...)+ + + type1 =3D r'(?:[\w\s]+)?' + type2 =3D r'(?:[\w\s]+\*+)+' + + found =3D False + + if is_define_proto: + r =3D KernRe(r'^()(' + name + r')\s+') + + if r.search(prototype): + return_type =3D '' + declaration_name =3D r.group(2) + func_macro =3D True + + found =3D True + + if not found: + patterns =3D [ + rf'^()({name})\s*{prototype_end}', + rf'^({type1})\s+({name})\s*{prototype_end}', + rf'^({type2})\s*({name})\s*{prototype_end}', + ] + + for p in patterns: + r =3D KernRe(p) + + if r.match(prototype): + + return_type =3D r.group(1) + declaration_name =3D r.group(2) + args =3D r.group(3) + + self.create_parameter_list(ln, decl_type, args, ',', + declaration_name) + + found =3D True + break + if not found: + self.emit_msg(ln, + f"cannot understand function prototype: '{protot= ype}'") + return + + if self.entry.identifier !=3D declaration_name: + self.emit_msg(ln, + f"expecting prototype for {self.entry.identifier= }(). Prototype was for {declaration_name}() instead") + return + + self.check_sections(ln, declaration_name, "function") + + self.check_return_section(ln, declaration_name, return_type) + + if 'typedef' in return_type: + self.output_declaration(decl_type, declaration_name, + typedef=3DTrue, + functiontype=3Dreturn_type, + purpose=3Dself.entry.declaration_purpo= se, + func_macro=3Dfunc_macro) + else: + self.output_declaration(decl_type, declaration_name, + typedef=3DFalse, + functiontype=3Dreturn_type, + purpose=3Dself.entry.declaration_purpo= se, + func_macro=3Dfunc_macro) + + def dump_typedef(self, ln, proto): + """ + Stores a typedef inside self.entries array. + """ + + typedef_type =3D r'((?:\s+[\w\*]+\b){0,7}\s+(?:\w+\b|\*+))\s*' + typedef_ident =3D r'\*?\s*(\w\S+)\s*' + typedef_args =3D r'\s*\((.*)\);' + + typedef1 =3D KernRe(r'typedef' + typedef_type + r'\(' + typedef_id= ent + r'\)' + typedef_args) + typedef2 =3D KernRe(r'typedef' + typedef_type + typedef_ident + ty= pedef_args) + + # Strip comments + proto =3D KernRe(r'/\*.*?\*/', flags=3Dre.S).sub('', proto) + + # Parse function typedef prototypes + for r in [typedef1, typedef2]: + if not r.match(proto): + continue + + return_type =3D r.group(1).strip() + declaration_name =3D r.group(2) + args =3D r.group(3) + + if self.entry.identifier !=3D declaration_name: + self.emit_msg(ln, + f"expecting prototype for typedef {self.entr= y.identifier}. Prototype was for typedef {declaration_name} instead\n") + return + + decl_type =3D 'function' + self.create_parameter_list(ln, decl_type, args, ',', declarati= on_name) + + self.output_declaration(decl_type, declaration_name, + typedef=3DTrue, + functiontype=3Dreturn_type, + purpose=3Dself.entry.declaration_purpo= se) + return + + # Handle nested parentheses or brackets + r =3D KernRe(r'(\(*.\)\s*|\[*.\]\s*);$') + while r.search(proto): + proto =3D r.sub('', proto) + + # Parse simple typedefs + r =3D KernRe(r'typedef.*\s+(\w+)\s*;') + if r.match(proto): + declaration_name =3D r.group(1) + + if self.entry.identifier !=3D declaration_name: + self.emit_msg(ln, + f"expecting prototype for typedef {self.entr= y.identifier}. Prototype was for typedef {declaration_name} instead\n") + return + + self.output_declaration('typedef', declaration_name, + purpose=3Dself.entry.declaration_purpo= se) + return + + self.emit_msg(ln, "error: Cannot parse typedef!") + + @staticmethod + def process_export(function_set, line): + """ + process EXPORT_SYMBOL* tags + + This method doesn't use any variable from the class, so declare it + with a staticmethod decorator. + """ + + # We support documenting some exported symbols with different + # names. A horrible hack. + suffixes =3D [ '_noprof' ] + + # Note: it accepts only one EXPORT_SYMBOL* per line, as having + # multiple export lines would violate Kernel coding style. + + if export_symbol.search(line): + symbol =3D export_symbol.group(2) + elif export_symbol_ns.search(line): + symbol =3D export_symbol_ns.group(2) + else: + return False + # + # Found an export, trim out any special suffixes + # + for suffix in suffixes: + # Be backward compatible with Python < 3.9 + if symbol.endswith(suffix): + symbol =3D symbol[:-len(suffix)] + function_set.add(symbol) + return True + + def process_normal(self, ln, line): + """ + STATE_NORMAL: looking for the /** to begin everything. + """ + + if not doc_start.match(line): + return + + # start a new entry + self.reset_state(ln) + + # next line is always the function name + self.state =3D state.NAME + + def process_name(self, ln, line): + """ + STATE_NAME: Looking for the "name - description" line + """ + # + # Check for a DOC: block and handle them specially. + # + if doc_block.search(line): + + if not doc_block.group(1): + self.entry.begin_section(ln, "Introduction") + else: + self.entry.begin_section(ln, doc_block.group(1)) + + self.entry.identifier =3D self.entry.section + self.state =3D state.DOCBLOCK + # + # Otherwise we're looking for a normal kerneldoc declaration line. + # + elif doc_decl.search(line): + self.entry.identifier =3D doc_decl.group(1) + + # Test for data declaration + if doc_begin_data.search(line): + self.entry.decl_type =3D doc_begin_data.group(1) + self.entry.identifier =3D doc_begin_data.group(2) + # + # Look for a function description + # + elif doc_begin_func.search(line): + self.entry.identifier =3D doc_begin_func.group(1) + self.entry.decl_type =3D "function" + # + # We struck out. + # + else: + self.emit_msg(ln, + f"This comment starts with '/**', but isn't = a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst\n{line}") + self.state =3D state.NORMAL + return + # + # OK, set up for a new kerneldoc entry. + # + self.state =3D state.BODY + self.entry.identifier =3D self.entry.identifier.strip(" ") + # if there's no @param blocks need to set up default section h= ere + self.entry.begin_section(ln + 1) + # + # Find the description portion, which *should* be there but + # isn't always. + # (We should be able to capture this from the previous parsing= - someday) + # + r =3D KernRe("[-:](.*)") + if r.search(line): + self.entry.declaration_purpose =3D trim_whitespace(r.group= (1)) + self.state =3D state.DECLARATION + else: + self.entry.declaration_purpose =3D "" + + if not self.entry.declaration_purpose and self.config.wshort_d= esc: + self.emit_msg(ln, + f"missing initial short description on line:= \n{line}") + + if not self.entry.identifier and self.entry.decl_type !=3D "en= um": + self.emit_msg(ln, + f"wrong kernel-doc identifier on line:\n{lin= e}") + self.state =3D state.NORMAL + + if self.config.verbose: + self.emit_msg(ln, + f"Scanning doc for {self.entry.decl_type} {s= elf.entry.identifier}", + warning=3DFalse) + # + # Failed to find an identifier. Emit a warning + # + else: + self.emit_msg(ln, f"Cannot find identifier on line:\n{line}") + + # + # Helper function to determine if a new section is being started. + # + def is_new_section(self, ln, line): + if doc_sect.search(line): + self.state =3D state.BODY + # + # Pick out the name of our new section, tweaking it if need be. + # + newsection =3D doc_sect.group(1) + if newsection.lower() =3D=3D 'description': + newsection =3D 'Description' + elif newsection.lower() =3D=3D 'context': + newsection =3D 'Context' + self.state =3D state.SPECIAL_SECTION + elif newsection.lower() in ["@return", "@returns", + "return", "returns"]: + newsection =3D "Return" + self.state =3D state.SPECIAL_SECTION + elif newsection[0] =3D=3D '@': + self.state =3D state.SPECIAL_SECTION + # + # Initialize the contents, and get the new section going. + # + newcontents =3D doc_sect.group(2) + if not newcontents: + newcontents =3D "" + self.dump_section() + self.entry.begin_section(ln, newsection) + self.entry.leading_space =3D None + + self.entry.add_text(newcontents.lstrip()) + return True + return False + + # + # Helper function to detect (and effect) the end of a kerneldoc commen= t. + # + def is_comment_end(self, ln, line): + if doc_end.search(line): + self.dump_section() + + # Look for doc_com + + doc_end: + r =3D KernRe(r'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') + if r.match(line): + self.emit_msg(ln, f"suspicious ending line: {line}") + + self.entry.prototype =3D "" + self.entry.new_start_line =3D ln + 1 + + self.state =3D state.PROTO + return True + return False + + + def process_decl(self, ln, line): + """ + STATE_DECLARATION: We've seen the beginning of a declaration + """ + if self.is_new_section(ln, line) or self.is_comment_end(ln, line): + return + # + # Look for anything with the " * " line beginning. + # + if doc_content.search(line): + cont =3D doc_content.group(1) + # + # A blank line means that we have moved out of the declaration + # part of the comment (without any "special section" parameter + # descriptions). + # + if cont =3D=3D "": + self.state =3D state.BODY + # + # Otherwise we have more of the declaration section to soak up. + # + else: + self.entry.declaration_purpose =3D \ + trim_whitespace(self.entry.declaration_purpose + ' ' += cont) + else: + # Unknown line, ignore + self.emit_msg(ln, f"bad line: {line}") + + + def process_special(self, ln, line): + """ + STATE_SPECIAL_SECTION: a section ending with a blank line + """ + # + # If we have hit a blank line (only the " * " marker), then this + # section is done. + # + if KernRe(r"\s*\*\s*$").match(line): + self.entry.begin_section(ln, dump =3D True) + self.state =3D state.BODY + return + # + # Not a blank line, look for the other ways to end the section. + # + if self.is_new_section(ln, line) or self.is_comment_end(ln, line): + return + # + # OK, we should have a continuation of the text for this section. + # + if doc_content.search(line): + cont =3D doc_content.group(1) + # + # If the lines of text after the first in a special section ha= ve + # leading white space, we need to trim it out or Sphinx will g= et + # confused. For the second line (the None case), see what we + # find there and remember it. + # + if self.entry.leading_space is None: + r =3D KernRe(r'^(\s+)') + if r.match(cont): + self.entry.leading_space =3D len(r.group(1)) + else: + self.entry.leading_space =3D 0 + # + # Otherwise, before trimming any leading chars, be *sure* + # that they are white space. We should maybe warn if this + # isn't the case. + # + for i in range(0, self.entry.leading_space): + if cont[i] !=3D " ": + self.entry.leading_space =3D i + break + # + # Add the trimmed result to the section and we're done. + # + self.entry.add_text(cont[self.entry.leading_space:]) + else: + # Unknown line, ignore + self.emit_msg(ln, f"bad line: {line}") + + def process_body(self, ln, line): + """ + STATE_BODY: the bulk of a kerneldoc comment. + """ + if self.is_new_section(ln, line) or self.is_comment_end(ln, line): + return + + if doc_content.search(line): + cont =3D doc_content.group(1) + self.entry.add_text(cont) + else: + # Unknown line, ignore + self.emit_msg(ln, f"bad line: {line}") + + def process_inline_name(self, ln, line): + """STATE_INLINE_NAME: beginning of docbook comments within a proto= type.""" + + if doc_inline_sect.search(line): + self.entry.begin_section(ln, doc_inline_sect.group(1)) + self.entry.add_text(doc_inline_sect.group(2).lstrip()) + self.state =3D state.INLINE_TEXT + elif doc_inline_end.search(line): + self.dump_section() + self.state =3D state.PROTO + elif doc_content.search(line): + self.emit_msg(ln, f"Incorrect use of kernel-doc format: {line}= ") + self.state =3D state.PROTO + # else ... ?? + + def process_inline_text(self, ln, line): + """STATE_INLINE_TEXT: docbook comments within a prototype.""" + + if doc_inline_end.search(line): + self.dump_section() + self.state =3D state.PROTO + elif doc_content.search(line): + self.entry.add_text(doc_content.group(1)) + # else ... ?? + + def syscall_munge(self, ln, proto): # pylint: disable=3DW0613 + """ + Handle syscall definitions + """ + + is_void =3D False + + # Strip newlines/CR's + proto =3D re.sub(r'[\r\n]+', ' ', proto) + + # Check if it's a SYSCALL_DEFINE0 + if 'SYSCALL_DEFINE0' in proto: + is_void =3D True + + # Replace SYSCALL_DEFINE with correct return type & function name + proto =3D KernRe(r'SYSCALL_DEFINE.*\(').sub('long sys_', proto) + + r =3D KernRe(r'long\s+(sys_.*?),') + if r.search(proto): + proto =3D KernRe(',').sub('(', proto, count=3D1) + elif is_void: + proto =3D KernRe(r'\)').sub('(void)', proto, count=3D1) + + # Now delete all of the odd-numbered commas in the proto + # so that argument types & names don't have a comma between them + count =3D 0 + length =3D len(proto) + + if is_void: + length =3D 0 # skip the loop if is_void + + for ix in range(length): + if proto[ix] =3D=3D ',': + count +=3D 1 + if count % 2 =3D=3D 1: + proto =3D proto[:ix] + ' ' + proto[ix + 1:] + + return proto + + def tracepoint_munge(self, ln, proto): + """ + Handle tracepoint definitions + """ + + tracepointname =3D None + tracepointargs =3D None + + # Match tracepoint name based on different patterns + r =3D KernRe(r'TRACE_EVENT\((.*?),') + if r.search(proto): + tracepointname =3D r.group(1) + + r =3D KernRe(r'DEFINE_SINGLE_EVENT\((.*?),') + if r.search(proto): + tracepointname =3D r.group(1) + + r =3D KernRe(r'DEFINE_EVENT\((.*?),(.*?),') + if r.search(proto): + tracepointname =3D r.group(2) + + if tracepointname: + tracepointname =3D tracepointname.lstrip() + + r =3D KernRe(r'TP_PROTO\((.*?)\)') + if r.search(proto): + tracepointargs =3D r.group(1) + + if not tracepointname or not tracepointargs: + self.emit_msg(ln, + f"Unrecognized tracepoint format:\n{proto}\n") + else: + proto =3D f"static inline void trace_{tracepointname}({tracepo= intargs})" + self.entry.identifier =3D f"trace_{self.entry.identifier}" + + return proto + + def process_proto_function(self, ln, line): + """Ancillary routine to process a function prototype""" + + # strip C99-style comments to end of line + line =3D KernRe(r"\/\/.*$", re.S).sub('', line) + # + # Soak up the line's worth of prototype text, stopping at { or ; i= f present. + # + if KernRe(r'\s*#\s*define').match(line): + self.entry.prototype =3D line + elif not line.startswith('#'): # skip other preprocessor stuff + r =3D KernRe(r'([^\{]*)') + if r.match(line): + self.entry.prototype +=3D r.group(1) + " " + # + # If we now have the whole prototype, clean it up and declare vict= ory. + # + if '{' in line or ';' in line or KernRe(r'\s*#\s*define').match(li= ne): + # strip comments and surrounding spaces + self.entry.prototype =3D KernRe(r'/\*.*\*/').sub('', self.entr= y.prototype).strip() + # + # Handle self.entry.prototypes for function pointers like: + # int (*pcs_config)(struct foo) + # by turning it into + # int pcs_config(struct foo) + # + r =3D KernRe(r'^(\S+\s+)\(\s*\*(\S+)\)') + self.entry.prototype =3D r.sub(r'\1\2', self.entry.prototype) + # + # Handle special declaration syntaxes + # + if 'SYSCALL_DEFINE' in self.entry.prototype: + self.entry.prototype =3D self.syscall_munge(ln, + self.entry.proto= type) + else: + r =3D KernRe(r'TRACE_EVENT|DEFINE_EVENT|DEFINE_SINGLE_EVEN= T') + if r.search(self.entry.prototype): + self.entry.prototype =3D self.tracepoint_munge(ln, + self.entr= y.prototype) + # + # ... and we're done + # + self.dump_function(ln, self.entry.prototype) + self.reset_state(ln) + + def process_proto_type(self, ln, line): + """Ancillary routine to process a type""" + + # Strip C99-style comments and surrounding whitespace + line =3D KernRe(r"//.*$", re.S).sub('', line).strip() + if not line: + return # nothing to see here + + # To distinguish preprocessor directive from regular declaration l= ater. + if line.startswith('#'): + line +=3D ";" + # + # Split the declaration on any of { } or ;, and accumulate pieces + # until we hit a semicolon while not inside {brackets} + # + r =3D KernRe(r'(.*?)([{};])') + for chunk in r.split(line): + if chunk: # Ignore empty matches + self.entry.prototype +=3D chunk + # + # This cries out for a match statement ... someday after w= e can + # drop Python 3.9 ... + # + if chunk =3D=3D '{': + self.entry.brcount +=3D 1 + elif chunk =3D=3D '}': + self.entry.brcount -=3D 1 + elif chunk =3D=3D ';' and self.entry.brcount <=3D 0: + self.dump_declaration(ln, self.entry.prototype) + self.reset_state(ln) + return + # + # We hit the end of the line while still in the declaration; put + # in a space to represent the newline. + # + self.entry.prototype +=3D ' ' + + def process_proto(self, ln, line): + """STATE_PROTO: reading a function/whatever prototype.""" + + if doc_inline_oneline.search(line): + self.entry.begin_section(ln, doc_inline_oneline.group(1)) + self.entry.add_text(doc_inline_oneline.group(2)) + self.dump_section() + + elif doc_inline_start.search(line): + self.state =3D state.INLINE_NAME + + elif self.entry.decl_type =3D=3D 'function': + self.process_proto_function(ln, line) + + else: + self.process_proto_type(ln, line) + + def process_docblock(self, ln, line): + """STATE_DOCBLOCK: within a DOC: block.""" + + if doc_end.search(line): + self.dump_section() + self.output_declaration("doc", self.entry.identifier) + self.reset_state(ln) + + elif doc_content.search(line): + self.entry.add_text(doc_content.group(1)) + + def parse_export(self): + """ + Parses EXPORT_SYMBOL* macros from a single Kernel source file. + """ + + export_table =3D set() + + try: + with open(self.fname, "r", encoding=3D"utf8", + errors=3D"backslashreplace") as fp: + + for line in fp: + self.process_export(export_table, line) + + except IOError: + return None + + return export_table + + # + # The state/action table telling us which function to invoke in + # each state. + # + state_actions =3D { + state.NORMAL: process_normal, + state.NAME: process_name, + state.BODY: process_body, + state.DECLARATION: process_decl, + state.SPECIAL_SECTION: process_special, + state.INLINE_NAME: process_inline_name, + state.INLINE_TEXT: process_inline_text, + state.PROTO: process_proto, + state.DOCBLOCK: process_docblock, + } + + def parse_kdoc(self): + """ + Open and process each line of a C source file. + The parsing is controlled via a state machine, and the line is pas= sed + to a different process function depending on the state. The process + function may update the state as needed. + + Besides parsing kernel-doc tags, it also parses export symbols. + """ + + prev =3D "" + prev_ln =3D None + export_table =3D set() + + try: + with open(self.fname, "r", encoding=3D"utf8", + errors=3D"backslashreplace") as fp: + for ln, line in enumerate(fp): + + line =3D line.expandtabs().strip("\n") + + # Group continuation lines on prototypes + if self.state =3D=3D state.PROTO: + if line.endswith("\\"): + prev +=3D line.rstrip("\\") + if not prev_ln: + prev_ln =3D ln + continue + + if prev: + ln =3D prev_ln + line =3D prev + line + prev =3D "" + prev_ln =3D None + + self.config.log.debug("%d %s: %s", + ln, state.name[self.state], + line) + + # This is an optimization over the original script. + # There, when export_file was used for the same file, + # it was read twice. Here, we use the already-existing + # loop to parse exported symbols as well. + # + if (self.state !=3D state.NORMAL) or \ + not self.process_export(export_table, line): + # Hand this line to the appropriate state handler + self.state_actions[self.state](self, ln, line) + + except OSError: + self.config.log.error(f"Error: Cannot open file {self.fname}") + + return export_table, self.entries diff --git a/scripts/lib/kdoc/kdoc_re.py b/scripts/lib/kdoc/kdoc_re.py new file mode 100644 index 00000000000..612223e1e72 --- /dev/null +++ b/scripts/lib/kdoc/kdoc_re.py @@ -0,0 +1,270 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2025: Mauro Carvalho Chehab . + +""" +Regular expression ancillary classes. + +Those help caching regular expressions and do matching for kernel-doc. +""" + +import re + +# Local cache for regular expressions +re_cache =3D {} + + +class KernRe: + """ + Helper class to simplify regex declaration and usage, + + It calls re.compile for a given pattern. It also allows adding + regular expressions and define sub at class init time. + + Regular expressions can be cached via an argument, helping to speedup + searches. + """ + + def _add_regex(self, string, flags): + """ + Adds a new regex or re-use it from the cache. + """ + self.regex =3D re_cache.get(string, None) + if not self.regex: + self.regex =3D re.compile(string, flags=3Dflags) + if self.cache: + re_cache[string] =3D self.regex + + def __init__(self, string, cache=3DTrue, flags=3D0): + """ + Compile a regular expression and initialize internal vars. + """ + + self.cache =3D cache + self.last_match =3D None + + self._add_regex(string, flags) + + def __str__(self): + """ + Return the regular expression pattern. + """ + return self.regex.pattern + + def __add__(self, other): + """ + Allows adding two regular expressions into one. + """ + + return KernRe(str(self) + str(other), cache=3Dself.cache or other.= cache, + flags=3Dself.regex.flags | other.regex.flags) + + def match(self, string): + """ + Handles a re.match storing its results + """ + + self.last_match =3D self.regex.match(string) + return self.last_match + + def search(self, string): + """ + Handles a re.search storing its results + """ + + self.last_match =3D self.regex.search(string) + return self.last_match + + def findall(self, string): + """ + Alias to re.findall + """ + + return self.regex.findall(string) + + def split(self, string): + """ + Alias to re.split + """ + + return self.regex.split(string) + + def sub(self, sub, string, count=3D0): + """ + Alias to re.sub + """ + + return self.regex.sub(sub, string, count=3Dcount) + + def group(self, num): + """ + Returns the group results of the last match + """ + + return self.last_match.group(num) + + +class NestedMatch: + """ + Finding nested delimiters is hard with regular expressions. It is + even harder on Python with its normal re module, as there are several + advanced regular expressions that are missing. + + This is the case of this pattern: + + '\\bSTRUCT_GROUP(\\(((?:(?>[^)(]+)|(?1))*)\\))[^;]*;' + + which is used to properly match open/close parenthesis of the + string search STRUCT_GROUP(), + + Add a class that counts pairs of delimiters, using it to match and + replace nested expressions. + + The original approach was suggested by: + https://stackoverflow.com/questions/5454322/python-how-to-match-ne= sted-parentheses-with-regex + + Although I re-implemented it to make it more generic and match 3 types + of delimiters. The logic checks if delimiters are paired. If not, it + will ignore the search string. + """ + + # TODO: make NestedMatch handle multiple match groups + # + # Right now, regular expressions to match it are defined only up to + # the start delimiter, e.g.: + # + # \bSTRUCT_GROUP\( + # + # is similar to: STRUCT_GROUP\((.*)\) + # except that the content inside the match group is delimiter's aligne= d. + # + # The content inside parenthesis are converted into a single replace + # group (e.g. r`\1'). + # + # It would be nice to change such definition to support multiple + # match groups, allowing a regex equivalent to. + # + # FOO\((.*), (.*), (.*)\) + # + # it is probably easier to define it not as a regular expression, but + # with some lexical definition like: + # + # FOO(arg1, arg2, arg3) + + DELIMITER_PAIRS =3D { + '{': '}', + '(': ')', + '[': ']', + } + + RE_DELIM =3D re.compile(r'[\{\}\[\]\(\)]') + + def _search(self, regex, line): + """ + Finds paired blocks for a regex that ends with a delimiter. + + The suggestion of using finditer to match pairs came from: + https://stackoverflow.com/questions/5454322/python-how-to-match-ne= sted-parentheses-with-regex + but I ended using a different implementation to align all three ty= pes + of delimiters and seek for an initial regular expression. + + The algorithm seeks for open/close paired delimiters and place them + into a stack, yielding a start/stop position of each match when t= he + stack is zeroed. + + The algorithm shoud work fine for properly paired lines, but will + silently ignore end delimiters that preceeds an start delimiter. + This should be OK for kernel-doc parser, as unaligned delimiters + would cause compilation errors. So, we don't need to rise exceptio= ns + to cover such issues. + """ + + stack =3D [] + + for match_re in regex.finditer(line): + start =3D match_re.start() + offset =3D match_re.end() + + d =3D line[offset - 1] + if d not in self.DELIMITER_PAIRS: + continue + + end =3D self.DELIMITER_PAIRS[d] + stack.append(end) + + for match in self.RE_DELIM.finditer(line[offset:]): + pos =3D match.start() + offset + + d =3D line[pos] + + if d in self.DELIMITER_PAIRS: + end =3D self.DELIMITER_PAIRS[d] + + stack.append(end) + continue + + # Does the end delimiter match what it is expected? + if stack and d =3D=3D stack[-1]: + stack.pop() + + if not stack: + yield start, offset, pos + 1 + break + + def search(self, regex, line): + """ + This is similar to re.search: + + It matches a regex that it is followed by a delimiter, + returning occurrences only if all delimiters are paired. + """ + + for t in self._search(regex, line): + + yield line[t[0]:t[2]] + + def sub(self, regex, sub, line, count=3D0): + """ + This is similar to re.sub: + + It matches a regex that it is followed by a delimiter, + replacing occurrences only if all delimiters are paired. + + if r'\1' is used, it works just like re: it places there the + matched paired data with the delimiter stripped. + + If count is different than zero, it will replace at most count + items. + """ + out =3D "" + + cur_pos =3D 0 + n =3D 0 + + for start, end, pos in self._search(regex, line): + out +=3D line[cur_pos:start] + + # Value, ignoring start/end delimiters + value =3D line[end:pos - 1] + + # replaces \1 at the sub string, if \1 is used there + new_sub =3D sub + new_sub =3D new_sub.replace(r'\1', value) + + out +=3D new_sub + + # Drop end ';' if any + if line[pos] =3D=3D ';': + pos +=3D 1 + + cur_pos =3D pos + n +=3D 1 + + if count and count >=3D n: + break + + # Append the remaining string + l =3D len(line) + out +=3D line[cur_pos:l] + + return out --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380934; cv=none; d=zohomail.com; s=zohoarc; b=EfeAgfyL5uJQ2ZTTmSQiSGzukAhQj28vGq3ShUVhCND7t+jI/9j7dthzqxCRPNb8YS3qBgC0jE0QjZ24ey608ZCX5RwLgzn/Jnm/vbn1P25APw84S4XTHTh7DlESCPfDcRTx/vszEAojCPb6clMYZuDZaHMlxDjaB2GWGcIeCr0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380934; h=Content-Transfer-Encoding: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:Cc; bh=L8ZNqyB7lsPlVBv6H+81X/cqv1r68vjQ/+0ChB/MUWw=; b=ALyuNyKwgTktxW9yMeJRLrDs8MfOXgEBi3lGW41zqSPeVlSRVlLIUBh9BQcq1Ivem0EzwOQqUxieoCjO9j4D/nwnJjLE5yabY9qRw6JSkijx/hY5AyLBvu8p/vU+am833bt5IkUwh8QLazxsXoIp67P2ZsMqjCLCF6ctcB8l/nQ= 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 1756380934346632.705511054455; Thu, 28 Aug 2025 04:35:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauB-0003RS-T9; Thu, 28 Aug 2025 07:35: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 1urau9-0003QH-Ih for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:57 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau7-0005nc-KN for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:57 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-45b7d497ab9so1635045e9.0 for ; Thu, 28 Aug 2025 04:34: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-45b79799c33sm28691015e9.5.2025.08.28.04.34.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380894; x=1756985694; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=L8ZNqyB7lsPlVBv6H+81X/cqv1r68vjQ/+0ChB/MUWw=; b=QtOqieXKFBOyrQTT4mE9MTxpQe1bC23Pzddz1J/w1MVAb/vt2AO39Ou7zvCZsgYHdK zwxXi6XgXKk+01zNn27GXVx5rIFxuBLTtZ3x3Rnu77Oo1JMQNp24JOcui67vpRfI+mEq Y3LTcXa1hCmOEKTwP4tW6UZppYbR7jm+M5nhcATUxzp3U5WLQnWtfEPqrJ7hwjVDV926 pl/DhZD/MY5xsAHrsc24g/gklE2kWqH6pFFEm2QFrrCgWq0QRXu7/1jjWRWybDgmSHV3 HCIzkZS58gQMKS7/f55STsajY6SX+JPvIcF1GgQ1NLwt1ZgWbg8Bfxwea24t1WwMUUU2 7azg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380894; x=1756985694; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L8ZNqyB7lsPlVBv6H+81X/cqv1r68vjQ/+0ChB/MUWw=; b=ZkaPxXghyMwUhpJrhuyjEwZAMrfJeoAlvw+r4pnGcZopaDsjQV8uDswKk5YU+llQKf 87tanL0+xywaLVd+gF80YDqKwNklb7cxvbcAIFu2DjrlkDqPk8U9ZyXdH/fTo5OAla1h v+iCR6AIvKPFpZ9m+8HC4tXhOq0NdNxR/azUr+baZjPv8V1g/KTgLGtYudS6i6a2peHX QKltBGBcXyLy/HKUcFL4fbCwTrWrqtL+JY5OXUe7MGfOIoJYl5sTVA0fTS7+kzLCv/yU XMZfejTMdprKihZR8B8M6Fli4EIAYS9Fto5mOmF+/RtZ3CF6MUKPIKMxAQ9jlQohHc3R lETQ== X-Gm-Message-State: AOJu0YzMM9b5rIlbjakdYbJAvw31ANFtHPQF3F5wCi6WChzcb6H16/rV U75pw82L/cVzu+Hy4atOPaaUjenZGI66pV//vhbo+vnacXFBXjX+ykJNJGQzxK1xs7k5ZbThDGe WT++u X-Gm-Gg: ASbGncsWztikqdEeq3xaSPzaUgVYd33Qp40Wdr7Z4nCpyqjUVu5oANODfAR+pJT8Go+ B7X8OASHXspWpbuFCuJv6Nrni/6PKex8Y9/PPBjLwStc/8peu/xQga8JosJ/Iwnv6a9nt5AVGew UVS7yyyTJMacpIdad1OebTgZfzQx2U90ukVfUZENySyM7UW4BNQTIgMwGfUYpPQV6p+R/+tXU2h keVTZ/XT4SkfSOeA6CqIyPeb5g42oHDXqfStvgckZZKz2ERZoRvpBrillrYxfYZflz3bm/ZyJCg U4yrxzbscRSuiW1iybehkQKH0FEu3bg1LDeaRFVuI8eosOqvNfeFc9rzXd5mlomiWEVlYj9kFZL HIWyeZoX7Z37aIJ8HlunbTkVflUuIk9BGQ09bAJI= X-Google-Smtp-Source: AGHT+IEr66z4VQ7ZP603hU4wwFW/8y3EYgOXvV5n6jhuOySDAlFj8leRA+7z21JWR0EyRbNKiJHkuQ== X-Received: by 2002:a05:600c:3b26:b0:456:1ac8:cac8 with SMTP id 5b1f17b1804b1-45b517ad6c8mr196830175e9.15.1756380893735; Thu, 28 Aug 2025 04:34:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/32] scripts/kernel-doc: strip QEMU_ from function definitions Date: Thu, 28 Aug 2025 12:34:16 +0100 Message-ID: <20250828113430.3214314-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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: 1756380936449124100 Content-Type: text/plain; charset="utf-8" This commit is the Python version of our older commit b30df2751e5 ("scripts/kernel-doc: strip QEMU_ from function definitions"). Some versions of Sphinx get confused if function attributes are left on the C code from kernel-doc; strip out any QEMU_* prefixes from function prototypes. Signed-off-by: Peter Maydell Reviewed-by: Paolo Bonzini Reviewed-by: Mauro Carvalho Chehab Message-id: 20250814171324.1614516-5-peter.maydell@linaro.org --- scripts/lib/kdoc/kdoc_parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser= .py index fe730099eca..32b43562929 100644 --- a/scripts/lib/kdoc/kdoc_parser.py +++ b/scripts/lib/kdoc/kdoc_parser.py @@ -907,6 +907,7 @@ def dump_function(self, ln, prototype): (r"^__always_inline +", "", 0), (r"^noinline +", "", 0), (r"^__FORTIFY_INLINE +", "", 0), + (r"QEMU_[A-Z_]+ +", "", 0), (r"__init +", "", 0), (r"__init_or_module +", "", 0), (r"__deprecated +", "", 0), --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380954; cv=none; d=zohomail.com; s=zohoarc; b=WJfqYbovk12hYMBwOzno1KFnOFsVFTRQ9OO+weAKWJtSpmQF21FYCoKAPv1rYExIXS8M7ru38QqU8KDNQLFKiijzRynSIxqyLTBfoK6UWavVWQ9QJN5mwWFJ469Z4sLu9AncKFHppXr6zvQXjndTHZTRJuhqsXErA371cXmJlO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380954; h=Content-Transfer-Encoding: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:Cc; bh=yXdNwBtixAVHyZNqVndinWYHb5cWF2hyLP2f+EbgbMU=; b=CgH9EKP+u1UUdE7IPvhi+xDLMFmqD3RWegW/DG7YjIdp+gTie5skudPyb4P5G6T6x5oVTzfwGcETmD0mzSSHnJZG880q4vSZVDa4doTdibcT7R1nfoedMPvEswlwh9i9yqhyS27A468hmBHgOisXq5nnaUt3ToCHI1L95CRaLC4= 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 1756380954281569.342472744129; Thu, 28 Aug 2025 04:35:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauF-0003Vs-4U; Thu, 28 Aug 2025 07:35:03 -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 1urauB-0003RP-57 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:59 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau8-0005o6-Bz for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:58 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-45a20c51c40so6759235e9.3 for ; Thu, 28 Aug 2025 04:34:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380895; x=1756985695; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=yXdNwBtixAVHyZNqVndinWYHb5cWF2hyLP2f+EbgbMU=; b=YJXxtGw5xp/woNUMj6MKT3jsssb2vFur0ZMmo4ZBri1/SRwf8elwZzWDC/EIrAQRL7 jazZPc30lrx8xyA5/b+bjLBcmvKVQCYRPRm0r/YbF5d+KdhvoKvG4tZSO9wSuRq3MeMb T21+b/RLg6v++tsyZ21j3kVvASvzpT95HjXKtEtZiOeZu1UvVHsGZoifQeHowf2gs6EY ymFvQ7J86LkjhSgTle597ST2E5rlW2nQdaSz7DJdPPyo+bqSd8DCpPqjuUEfQ/5yG28Y Df8pmUjf4mGtCs/bchj9TACvaQgCtoqUahxvuyTIOusxJloKeVIFBdL/ZwsbiezUENlt 1g3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380895; x=1756985695; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yXdNwBtixAVHyZNqVndinWYHb5cWF2hyLP2f+EbgbMU=; b=lKjHVo5oVEllD0RXuQ5k3I9HCrgJtsVl7J5ss35aizgHbJ36aFQRZmL3nsz7f/gV8V sD+ThYpZHx+qmCydAUEXZQOnK7jBaRKEXu7JwzFR0nR64TbpCNqPs21hqHx8YJi8kqfw ORwNhBYK+kDDi6o95hpQRj5jkn323p9jwd0bYUbp3XcyE85yJvGtpO26v0TLrJiZg+0w SyTudA0AhlYj6m0lxp3A4Qu1v2aCFNSI2zDqt9uIfI7hZi8t4h0kB/BWL0b+8kDCGElj Y+utTcrfxQFgDq96tMhP5AOM4FN72ke/7ycKAVko/tFfURLGJGs1npd8HI3r0Vhx5WyX EbCg== X-Gm-Message-State: AOJu0YyzUY9ipqX+WY4mif2dRVgL6yPnxHGQ1DVybBUhjW9Vo/apXC+/ hVsWnDy87fm2+Oyrdp85S5NGM+sbWkVu+GYOMJl5adxKq/PATn7s6GWPoANGE8OoW+0xbcfQBmr 0rihX X-Gm-Gg: ASbGncu0AMshO+UQ4u9Vw26cGobwYm4kOvlEOY29vpV6yyKV5MCRyRB8W/mNpmlv/Kp ESHllbHm25ob2UaKaPbPKzLEypProh/gE1QI8ykurCDSe+ZBysaU8P851JYVyp+1HbReoIWkA4y Aq8fGMkgb/p4wiTF8JpS1dozgyCdP8fwQ7yEw2zgpWOL/iBspq/FFa4/2E9PAgec5kXB//knmhc LL+53Z54OZOlFyZWgDIQtJid5U11Is50sFwFYVZcC17Z0dCnivJuLv+Om5hHnFOXBzBXhpnHANn mD52Y8Fu0w32KGFKp70dFW2DaW9YOaXAEhW83aBbk+jxcJcsxekcJR7GqIKxfYrfbDbbpJeD9Wp m2nVPJGfTrmzG4MDY3zwFvDKyqE7wPIAvb1CC1Wo= X-Google-Smtp-Source: AGHT+IF8isbF8xnM0P6C3I6yTTEMZbml1/3kGyqyXKCRpxEk+InxD4Xa+zj42jYc8hCDzTscUUkYMA== X-Received: by 2002:a05:600c:3b29:b0:45b:6269:d257 with SMTP id 5b1f17b1804b1-45b71f46f24mr47617505e9.35.1756380894843; Thu, 28 Aug 2025 04:34:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/32] scripts/kernel-doc: tweak for QEMU coding standards Date: Thu, 28 Aug 2025 12:34:17 +0100 Message-ID: <20250828113430.3214314-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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: 1756380957030124100 Content-Type: text/plain; charset="utf-8" This commit makes the equivalent changes to the Python script that we had for the old Perl script in commit 4cf41794411f ("docs: tweak kernel-doc for QEMU coding standards"). To repeat the rationale from that commit: Surprisingly, QEMU does have a pretty consistent doc comment style and it is not very different from the Linux kernel's. Of the documentation "sigils", only "#" separates the QEMU doc comment style from Linux's, and it has 200+ instances vs. 6 for the kernel's '&struct foo' (all in accel/tcg/translate-all.c), so it's clear that the two standards are different in this respect. In addition, our structs are typedefed and recognized by CamelCase names. Note that in 4cf41794411f we used '(?!)' as our type_fallback regex; this is strictly not quite a replacement for the upstream '\&([_\w]+)', because the latter includes a group that can later be matched with \1, and the former does not. The old perl script did not care about this, but the python version does, so we must include the extra set of brackets to ensure we have a group. This commit does not include all the same changes that 4cf41794411f did. Of the missing pieces, some had already gone in an earlier kernel-doc update; the parts we still had but do not include here are: @@ -2057,7 +2060,7 @@ } elsif (/$doc_decl/o) { $identifier =3D $1; - if (/\s*([\w\s]+?)(\(\))?\s*-/) { + if (/\s*([\w\s]+?)(\s*-|:)/) { $identifier =3D $1; } @@ -2067,7 +2070,7 @@ $contents =3D ""; $section =3D $section_default; $new_start_line =3D $. + 1; - if (/-(.*)/) { + if (/[-:](.*)/) { # strip leading/trailing/multiple spaces $descr=3D $1; $descr =3D~ s/^\s*//; The second of these is already in the upstream version: the line r =3D KernRe("[-:](.*)") in process_name() matches the regex we have. The first change has been refactored into the doc_begin_data and doc_begin_func changes. Since the output HTML for QEMU's documentation has no relevant changes with the new kerneldoc, we assume that this too has been handled upstream. Signed-off-by: Peter Maydell Reviewed-by: Paolo Bonzini Reviewed-by: Mauro Carvalho Chehab Message-id: 20250814171324.1614516-6-peter.maydell@linaro.org --- scripts/lib/kdoc/kdoc_output.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/lib/kdoc/kdoc_output.py b/scripts/lib/kdoc/kdoc_output= .py index ea8914537ba..39fa872dfca 100644 --- a/scripts/lib/kdoc/kdoc_output.py +++ b/scripts/lib/kdoc/kdoc_output.py @@ -38,12 +38,12 @@ type_fp_param2 =3D KernRe(r"\@(\w+->\S+)\(\)", cache=3DFalse) =20 type_env =3D KernRe(r"(\$\w+)", cache=3DFalse) -type_enum =3D KernRe(r"\&(enum\s*([_\w]+))", cache=3DFalse) -type_struct =3D KernRe(r"\&(struct\s*([_\w]+))", cache=3DFalse) -type_typedef =3D KernRe(r"\&(typedef\s*([_\w]+))", cache=3DFalse) -type_union =3D KernRe(r"\&(union\s*([_\w]+))", cache=3DFalse) -type_member =3D KernRe(r"\&([_\w]+)(\.|->)([_\w]+)", cache=3DFalse) -type_fallback =3D KernRe(r"\&([_\w]+)", cache=3DFalse) +type_enum =3D KernRe(r"#(enum\s*([_\w]+))", cache=3DFalse) +type_struct =3D KernRe(r"#(struct\s*([_\w]+))", cache=3DFalse) +type_typedef =3D KernRe(r"#(([A-Z][_\w]*))", cache=3DFalse) +type_union =3D KernRe(r"#(union\s*([_\w]+))", cache=3DFalse) +type_member =3D KernRe(r"#([_\w]+)(\.|->)([_\w]+)", cache=3DFalse) +type_fallback =3D KernRe(r"((?!))", cache=3DFalse) # this never matches type_member_func =3D type_member + KernRe(r"\(\)", cache=3DFalse) =20 =20 --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381177; cv=none; d=zohomail.com; s=zohoarc; b=XvtWY3XqAGCnFM8atXZ3h5HwmzU9PkBersG6JPCom1x3RDP5DfTKFNcH2YUrxdXX/zP+mOoXRoPvuO5eWHIL1lna8EYJUIT5Hvcsu+CTNHkk+uk18Wqww0nY9h+FIh4hT2ZBDgo943srShzDnftPxI2CqWf9gj9IHRKkuCdw0Ak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381177; h=Content-Transfer-Encoding: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:Cc; bh=tlYbhB8nOl5JrIUdyBD4JxZnpHrBbp0zUqXwmx5QSWY=; b=NLQsl5E5ZLGbsJvUgmqiOSp8SQ7O+MKtfEFrH3DCEU/i2rXp5dvZvwZJAE+Uuluc+51oUkWIGZcdUdQF0eG0yWxecItnmMbkQVUvey96IT8bSxqCYicUI5jOidZMAEgoJJnWhQPtqRfwztgdEdaH1ZB+wk5ZO3L63pT2ppP7PCA= 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 1756381177622800.3459077039282; Thu, 28 Aug 2025 04:39:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauH-0003Ye-8N; Thu, 28 Aug 2025 07:35:05 -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 1urauB-0003Ro-Uv for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:00 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urau9-0005oY-Ku for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:34:59 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-45b4d8921f2so7129035e9.2 for ; Thu, 28 Aug 2025 04:34:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380896; x=1756985696; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tlYbhB8nOl5JrIUdyBD4JxZnpHrBbp0zUqXwmx5QSWY=; b=hMA02QDoH5v24jm5vqGt5q7BDaIO4hJqC82VnzO9ULxRyrnLihVIZAuuvmxhn4Wxby d9ETzBgUEbZVNux6BQ6B2LX2fo0BMatQq6KdexpwiT2GkUclA6+j6VFnHIeEoePN6hzj LhPwy+zR7RpUFsQmMME85waEotBGAt8c7mFPXxlMnzqbmWSReKpEkBDodyfFVPFTsoHm bCgZ8YNC9/cX1JXYImxg6OKecN41GkM+R14I8Tlpin/Apc3XjmxPPPltyH/MtcfzTXIc Fzik+AgnoOeeCr6lMBqOTz7fRNeRfwMlynUSsQPQqfouu6P3fBx33xiv9dGNtFcLanWL 8Teg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380896; x=1756985696; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tlYbhB8nOl5JrIUdyBD4JxZnpHrBbp0zUqXwmx5QSWY=; b=nMdIQNzm4OUA/JBRHrub9Wg4YLcAlV0zUi5EaHovOLfsAiasCJFgBr+GWySvQzrI0M Po0/pnzpwyarc60Qlt1lX+zncqLFnf/qgl7zmQknMPaTjRXROJFhEEszyIJtne3WKo+N ifWJC2qTgXAThhCUlCLBXwxEtIMsImK7N/AOJVJoR6zjkm3Jzq40YbJS0K+o7+NdZMCW Ym30K8caTN5JepnSbLXscDs7/bHozG9/a0rc5tRcXcyGiTLsd4vmeFlG2KNsRAKcsVk7 DMpg5rh1XIOh2p+FMEjXs1jAzECo1X2MRReX034Cl/w1rxKDKm54ORvML3OXX/KzRb8e TGPA== X-Gm-Message-State: AOJu0YxRvhbE+o17zE2AuCyik7MHHYQA8rtbuUBFmSZBBjwzUAa9F27X 3VWb5LfX+fe6jTq9L8HyE267Ft3X187pQDn7FHuM8enz86DFN0InUVUwfs71dZQjr6cR4+W7kPH E1eqF X-Gm-Gg: ASbGncvMaGDIjG1ctu9I3XKAfZJHE7kmqoENR5WEG1stSZ1DDTKR+PoVdwjfln3vlai E2ywIyFEoDh0ZrY0zOcGrameJbLvBG7haeqEKfTgnp/LuLmPmw56/sGXpzZPTlLL7I315UswPfZ z4+i6Vt16/qJiJNBJK5vZFTnGY2qRMc4oaluvIZVTY4rUnTmUrE15nXSJuVC9dsZfur+KsxLxwv q5qYweuvI4TP08YA97jxO/FO9QlUD9NROlnrvlkuI+YnFqsnTLfuBk5knDJQvQWuJ5f6Odv4CWm NwTCrJ9Nj1DjWmIW9Op2Cc5xqE+GKTUVFUa+Y61YF+shm85svfw1C79xRB0rWaB22B8ZsA29jE8 /NzpFu9sqsoObk/oOgmUvL42QdHwLex66nncC0rg= X-Google-Smtp-Source: AGHT+IEhekCwFl8XcyS5kuEn7i/XrhEWqFauR65JKRCYM/uZ11wsK0bzisdeXxfyZAXN5MBiFJ1vDA== X-Received: by 2002:a05:600c:4f41:b0:459:d3ce:2cbd with SMTP id 5b1f17b1804b1-45b517ad602mr194774255e9.13.1756380895875; Thu, 28 Aug 2025 04:34:55 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/32] scripts/kerneldoc: Switch to the Python kernel-doc script Date: Thu, 28 Aug 2025 12:34:18 +0100 Message-ID: <20250828113430.3214314-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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: 1756381179498124100 Content-Type: text/plain; charset="utf-8" Change the Sphinx config to run the new Python kernel-doc script instead of the Perl one. The only difference between the two is that the new script does not handle the -sphinx-version option, instead assuming that Sphinx is always at least version 3: so we must delete the code that passes that option to avoid the Python script complaining about an unknown option. QEMU's minimum Sphinx version is already 3.4.3, so this doesn't change the set of versions we can handle. Signed-off-by: Peter Maydell Reviewed-by: Paolo Bonzini Reviewed-by: Mauro Carvalho Chehab Message-id: 20250814171324.1614516-7-peter.maydell@linaro.org --- docs/conf.py | 4 +++- docs/sphinx/kerneldoc.py | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f892a6e1da3..e09769e5f83 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -341,7 +341,9 @@ # We use paths starting from qemu_docdir here so that you can run # sphinx-build from anywhere and the kerneldoc extension can still # find everything. -kerneldoc_bin =3D ['perl', os.path.join(qemu_docdir, '../scripts/kernel-do= c')] +# Since kernel-doc is now a Python script, we should run it with whatever +# Python this sphinx is using (rather than letting it find one via env) +kerneldoc_bin =3D [sys.executable, os.path.join(qemu_docdir, '../scripts/k= ernel-doc.py')] kerneldoc_srctree =3D os.path.join(qemu_docdir, '..') hxtool_srctree =3D os.path.join(qemu_docdir, '..') qapidoc_srctree =3D os.path.join(qemu_docdir, '..') diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py index 30bb3431983..9721072e476 100644 --- a/docs/sphinx/kerneldoc.py +++ b/docs/sphinx/kerneldoc.py @@ -63,11 +63,6 @@ def run(self): env =3D self.state.document.settings.env cmd =3D env.config.kerneldoc_bin + ['-rst', '-enable-lineno'] =20 - # Pass the version string to kernel-doc, as it needs to use a diff= erent - # dialect, depending what the C domain supports for each specific - # Sphinx versions - cmd +=3D ['-sphinx-version', sphinx.__version__] - # Pass through the warnings-as-errors flag if env.config.kerneldoc_werror: cmd +=3D ['-Werror'] --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380986; cv=none; d=zohomail.com; s=zohoarc; b=le+prSx6qS0sDyEKAtp1DY93Ct1cW01UYX17Q6zTrVMiUfX2KfuJEzBpxjPz2t62UrjzAclWGUQ+rVggN/iiDlNNAt/GFUXa6qfc03bs0kGhLvSIqzNnN71VcyBJUHKYLl1lkEKYbx/1lPO8IrQ6isguPu0SDnuWkPcq6VROmiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380986; h=Content-Transfer-Encoding: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:Cc; bh=WeDGo2dpz1/Hku7kdli1YSDp3jvOb+KDY3M+EWGKOZs=; b=VxZCsfbdaT7AKN0KIHTlV4udZ32OkS1ApdHLjbkhBlNbfhvXzRNyAjRPre84Usa3lwn0svTNhYaTYEAaOBSQXjhMWJZjdAK2qJrC/ZscWFvW9rEh6mH2zD6ujJk1f9ytc3Y6FwV0qZy8v0k2p5rK4igtuPcemOP04th8uG0fkUY= 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 1756380986365264.38747603141155; Thu, 28 Aug 2025 04:36:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauR-0003hG-RT; Thu, 28 Aug 2025 07:35:15 -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 1urauH-0003Zz-Dh for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:05 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauB-0005pl-MW for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:05 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-45b629c8035so4899185e9.3 for ; Thu, 28 Aug 2025 04:34:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380898; x=1756985698; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WeDGo2dpz1/Hku7kdli1YSDp3jvOb+KDY3M+EWGKOZs=; b=yMt1AnPwn53C3W6D6Yb+ahguYEYRJa7LwnMMRQDy1uHbMAu4zRNCZw1OtpLf3vIfgJ 4AC4IcMV60g7Vsnr5BdJfpTAhdfSSi6/VIle6qlWsxCkXLSEssGAGvne4xxaipsyKgXG HGKHXE+Xhua91eK3uey6Xhum+bGF5WGPwfkg2v9ug+2plyNKRxaXh/aiaQfZQZKN1GXg BvyGRcj+pzSZxQVcm3Gmf7ZJ/+3jLLhaJ/Py44cYG9Rh/xAzRK8BE9LTnRgi8HjaepvE e+lc5VKwPqKJynvEThaWS7PqTVXZUlL9iqvTqOB+UCtSUdEfezdcI+Js/naEDzdCk1J5 WgaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380898; x=1756985698; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WeDGo2dpz1/Hku7kdli1YSDp3jvOb+KDY3M+EWGKOZs=; b=krBa4isN7UAbidawNlGIKVfFjR/28brGm5vvPGy2MUHcaYdUZkyETbzp8XhsuRLB8R SOfZPVwdAWx2G1M/ii+SF0T+QuLRCb7mg5ID+piaRFEqZR/E+iK7yZa8S82xAaom2N3f Ilvv90II49obGjnAw6AXysTFDA6BDq6lEmaDgTS70jFF3yH+KJSudJOaUtOqmLROkLts 4wt4TAJIDGIByeBY+gjt2oT+NLDPDAHI6AF2Y9+HkMnN8D+jlF4Bu9+sVzqLchh3Yksa rJeWn1FvnN9rcUMX1WNlDDFfbsY1AeQNMKLUzeR1cRpKSc0oy1Sls6K4C2Ib7i0DDtcI BwRw== X-Gm-Message-State: AOJu0YzzvaEqnMT0aE5nvIJCaEwDx4NHyRDfIqq2bhHXo8+iJdtTrkyo CpP1k8GS0LLDYNBQzuoBDpfFLaIcJsM2vOLvPR1g5WQj5YIn/qxHQ3deEmjdA5OWCNiNWg4IA5q 9NMB+ X-Gm-Gg: ASbGncvE4LOWAQ6vOyJ8DS13ci6Jr04vhqWyfPm7VMwULLZIw9zAPOpo/zavpgNIpv3 kSOtkWLMFRs+1K+NMKCF2AAxWZi9azFvL2TN4PBN7I4i7jJBMWMMZqrlLsTIx6Fm9Wk116czsxh ncSQGSYF2y4deBVlbMPkKMAYwtG8HDkP2eACp13Ny5oVXxL1vDzO/AKos19/7hfQ6tqjV6/fTlI CVrzDN9k3+1vx++ZQYBh+f0otgpXtE0hkqVg4sEnEm53PyXlgYK2vCqnhyg+S2VwqtuCvOM10kk 2tEE8+amTGwhMwgRccOurBYxHBBc0zzLfSDGsKBbDoGyb0NfQYhMded2q0j3bzpdRbFr6C/TKbD pQLL0W8k7uvsXZ+nIpZ3FBpJedi9s X-Google-Smtp-Source: AGHT+IH0i5suXB7lkdFIy+Zdl7yFTDMpa2fLjzwtZlw5Mjuh73M2ilaR9iyR71rxdK6TE0QLG6KNEA== X-Received: by 2002:a05:600c:a46:b0:456:19be:5e8 with SMTP id 5b1f17b1804b1-45b517d459dmr197752615e9.20.1756380897133; Thu, 28 Aug 2025 04:34:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/32] scripts/kernel-doc: Delete the old Perl kernel-doc script Date: Thu, 28 Aug 2025 12:34:19 +0100 Message-ID: <20250828113430.3214314-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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: 1756380988727116600 Content-Type: text/plain; charset="utf-8" We can now delete the old Perl kernel-doc script. For posterity, this is a complete diff of the local changes that we were carrying between the kernel's Perl script as of kernel commit 72b97d0b911872ba (the last time we synced it) and our local copy: Reviewed-by: Mauro Carvalho Chehab Reviewed-by: Paolo Bonzini --- /tmp/kdoc 2025-08-14 10:42:47.620331939 +0100 +++ scripts/kernel-doc 2025-02-17 10:44:34.528421457 +0000 @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: GPL-2.0-only use warnings; use strict; @@ -224,12 +224,12 @@ my $type_fp_param =3D '\@(\w+)\(\)'; # Special RST handling for func ptr = params my $type_fp_param2 =3D '\@(\w+->\S+)\(\)'; # Special RST handling for str= ucts with func ptr params my $type_env =3D '(\$\w+)'; -my $type_enum =3D '\&(enum\s*([_\w]+))'; -my $type_struct =3D '\&(struct\s*([_\w]+))'; -my $type_typedef =3D '\&(typedef\s*([_\w]+))'; -my $type_union =3D '\&(union\s*([_\w]+))'; -my $type_member =3D '\&([_\w]+)(\.|->)([_\w]+)'; -my $type_fallback =3D '\&([_\w]+)'; +my $type_enum =3D '#(enum\s*([_\w]+))'; +my $type_struct =3D '#(struct\s*([_\w]+))'; +my $type_typedef =3D '#(([A-Z][_\w]*))'; +my $type_union =3D '#(union\s*([_\w]+))'; +my $type_member =3D '#([_\w]+)(\.|->)([_\w]+)'; +my $type_fallback =3D '(?!)'; # this never matches my $type_member_func =3D $type_member . '\(\)'; # Output conversion substitutions. @@ -1745,6 +1745,9 @@ )+ \)\)\s+//x; + # Strip QEMU specific compiler annotations + $prototype =3D~ s/QEMU_[A-Z_]+ +//; + # Yes, this truly is vile. We are looking for: # 1. Return type (may be nothing if we're looking at a macro) # 2. Function name @@ -2057,7 +2060,7 @@ } elsif (/$doc_decl/o) { $identifier =3D $1; - if (/\s*([\w\s]+?)(\(\))?\s*-/) { + if (/\s*([\w\s]+?)(\s*-|:)/) { $identifier =3D $1; } @@ -2067,7 +2070,7 @@ $contents =3D ""; $section =3D $section_default; $new_start_line =3D $. + 1; - if (/-(.*)/) { + if (/[-:](.*)/) { # strip leading/trailing/multiple spaces $descr=3D $1; $descr =3D~ s/^\s*//; These changes correspond to: 06e2329636f license: Update deprecated SPDX tag GPL-2.0 to GPL-2.0-only (a bulk change which we won't bother to re-apply to this third-party script) b30df2751e5 scripts/kernel-doc: strip QEMU_ from function definitions 4cf41794411 docs: tweak kernel-doc for QEMU coding standards We have already applied the equivalent of these changes to the Python code in libs/kdoc/ in the preceding commits. Signed-off-by: Peter Maydell Reviewed-by: Mauro Carvalho Chehab Reviewed-by: Paolo Bonzini --- .editorconfig | 2 +- scripts/kernel-doc | 2441 -------------------------------------------- 2 files changed, 1 insertion(+), 2442 deletions(-) delete mode 100755 scripts/kernel-doc diff --git a/.editorconfig b/.editorconfig index a04cb9054cb..258d41ab485 100644 --- a/.editorconfig +++ b/.editorconfig @@ -55,7 +55,7 @@ indent_size =3D 4 emacs_mode =3D perl =20 # but user kernel "style" for imported scripts -[scripts/{kernel-doc,get_maintainer.pl,checkpatch.pl}] +[scripts/{get_maintainer.pl,checkpatch.pl}] indent_style =3D tab indent_size =3D 8 emacs_mode =3D perl diff --git a/scripts/kernel-doc b/scripts/kernel-doc deleted file mode 100755 index 117ec8fcd1f..00000000000 --- a/scripts/kernel-doc +++ /dev/null @@ -1,2441 +0,0 @@ -#!/usr/bin/env perl -# SPDX-License-Identifier: GPL-2.0-only - -use warnings; -use strict; - -## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## -## Copyright (C) 2000, 1 Tim Waugh ## -## Copyright (C) 2001 Simon Huggins ## -## Copyright (C) 2005-2012 Randy Dunlap ## -## Copyright (C) 2012 Dan Luedtke ## -## ## -## #define enhancements by Armin Kuster ## -## Copyright (c) 2000 MontaVista Software, Inc. ## -## ## -## This software falls under the GNU General Public License. ## -## Please read the COPYING file for more information ## - -# 18/01/2001 - Cleanups -# Functions prototyped as foo(void) same as foo() -# Stop eval'ing where we don't need to. -# -- huggie@earth.li - -# 27/06/2001 - Allowed whitespace after initial "/**" and -# allowed comments before function declarations. -# -- Christian Kreibich - -# Still to do: -# - add perldoc documentation -# - Look more closely at some of the scarier bits :) - -# 26/05/2001 - Support for separate source and object trees. -# Return error code. -# Keith Owens - -# 23/09/2001 - Added support for typedefs, structs, enums and unions -# Support for Context section; can be terminated using empty = line -# Small fixes (like spaces vs. \s in regex) -# -- Tim Jansen - -# 25/07/2012 - Added support for HTML5 -# -- Dan Luedtke - -sub usage { - my $message =3D <<"EOF"; -Usage: $0 [OPTION ...] FILE ... - -Read C language source or header FILEs, extract embedded documentation com= ments, -and print formatted documentation to standard output. - -The documentation comments are identified by "/**" opening comment mark. S= ee -Documentation/doc-guide/kernel-doc.rst for the documentation comment synta= x. - -Output format selection (mutually exclusive): - -man Output troff manual page format. This is the default. - -rst Output reStructuredText format. - -none Do not output documentation, only warnings. - -Output format selection modifier (affects only ReST output): - - -sphinx-version Use the ReST C domain dialect compatible with an - specific Sphinx Version. - If not specified, kernel-doc will auto-detect using - the sphinx-build version found on PATH. - -Output selection (mutually exclusive): - -export Only output documentation for symbols that have been - exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL() - in any input FILE or -export-file FILE. - -internal Only output documentation for symbols that have NOT been - exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL() - in any input FILE or -export-file FILE. - -function NAME Only output documentation for the given function(s) - or DOC: section title(s). All other functions and DOC: - sections are ignored. May be specified multiple times. - -nosymbol NAME Exclude the specified symbols from the output - documentation. May be specified multiple times. - -Output selection modifiers: - -no-doc-sections Do not output DOC: sections. - -enable-lineno Enable output of #define LINENO lines. Only works = with - reStructuredText format. - -export-file FILE Specify an additional FILE in which to look for - EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL(). To be use= d with - -export or -internal. May be specified multiple ti= mes. - -Other parameters: - -v Verbose output, more warnings and other information. - -h Print this help. - -Werror Treat warnings as errors. - -EOF - print $message; - exit 1; -} - -# -# format of comments. -# In the following table, (...)? signifies optional structure. -# (...)* signifies 0 or more structure elements -# /** -# * function_name(:)? (- short description)? -# (* @parameterx: (description of parameter x)?)* -# (* a blank line)? -# * (Description:)? (Description of function)? -# * (section header: (section description)? )* -# (*)?*/ -# -# So .. the trivial example would be: -# -# /** -# * my_function -# */ -# -# If the Description: header tag is omitted, then there must be a blank li= ne -# after the last parameter specification. -# e.g. -# /** -# * my_function - does my stuff -# * @my_arg: its mine damnit -# * -# * Does my stuff explained. -# */ -# -# or, could also use: -# /** -# * my_function - does my stuff -# * @my_arg: its mine damnit -# * Description: Does my stuff explained. -# */ -# etc. -# -# Besides functions you can also write documentation for structs, unions, -# enums and typedefs. Instead of the function name you must write the name -# of the declaration; the struct/union/enum/typedef must always precede -# the name. Nesting of declarations is not supported. -# Use the argument mechanism to document members or constants. -# e.g. -# /** -# * struct my_struct - short description -# * @a: first member -# * @b: second member -# * -# * Longer description -# */ -# struct my_struct { -# int a; -# int b; -# /* private: */ -# int c; -# }; -# -# All descriptions can be multiline, except the short function description. -# -# For really longs structs, you can also describe arguments inside the -# body of the struct. -# eg. -# /** -# * struct my_struct - short description -# * @a: first member -# * @b: second member -# * -# * Longer description -# */ -# struct my_struct { -# int a; -# int b; -# /** -# * @c: This is longer description of C -# * -# * You can use paragraphs to describe arguments -# * using this method. -# */ -# int c; -# }; -# -# This should be use only for struct/enum members. -# -# You can also add additional sections. When documenting kernel functions = you -# should document the "Context:" of the function, e.g. whether the functio= ns -# can be called form interrupts. Unlike other sections you can end it with= an -# empty line. -# A non-void function should have a "Return:" section describing the return -# value(s). -# Example-sections should contain the string EXAMPLE so that they are mark= ed -# appropriately in DocBook. -# -# Example: -# /** -# * user_function - function that can only be called in user context -# * @a: some argument -# * Context: !in_interrupt() -# * -# * Some description -# * Example: -# * user_function(22); -# */ -# ... -# -# -# All descriptive text is further processed, scanning for the following sp= ecial -# patterns, which are highlighted appropriately. -# -# 'funcname()' - function -# '$ENVVAR' - environmental variable -# '&struct_name' - name of a structure (up to two words including 'struct') -# '&struct_name.member' - name of a structure member -# '@parameter' - name of a parameter -# '%CONST' - name of a constant. -# '``LITERAL``' - literal string without any spaces on it. - -## init lots of data - -my $errors =3D 0; -my $warnings =3D 0; -my $anon_struct_union =3D 0; - -# match expressions used to find embedded type information -my $type_constant =3D '\b``([^\`]+)``\b'; -my $type_constant2 =3D '\%([-_\w]+)'; -my $type_func =3D '(\w+)\(\)'; -my $type_param =3D '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)'; -my $type_param_ref =3D '([\!]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)'; -my $type_fp_param =3D '\@(\w+)\(\)'; # Special RST handling for func ptr = params -my $type_fp_param2 =3D '\@(\w+->\S+)\(\)'; # Special RST handling for str= ucts with func ptr params -my $type_env =3D '(\$\w+)'; -my $type_enum =3D '#(enum\s*([_\w]+))'; -my $type_struct =3D '#(struct\s*([_\w]+))'; -my $type_typedef =3D '#(([A-Z][_\w]*))'; -my $type_union =3D '#(union\s*([_\w]+))'; -my $type_member =3D '#([_\w]+)(\.|->)([_\w]+)'; -my $type_fallback =3D '(?!)'; # this never matches -my $type_member_func =3D $type_member . '\(\)'; - -# Output conversion substitutions. -# One for each output format - -# these are pretty rough -my @highlights_man =3D ( - [$type_constant, "\$1"], - [$type_constant2, "\$1"], - [$type_func, "\\\\fB\$1\\\\fP"], - [$type_enum, "\\\\fI\$1\\\\fP"], - [$type_struct, "\\\\fI\$1\\\\fP"], - [$type_typedef, "\\\\fI\$1\\\\fP"], - [$type_union, "\\\\fI\$1\\\\fP"], - [$type_param, "\\\\fI\$1\\\\fP"], - [$type_param_ref, "\\\\fI\$1\$2\\\\fP"], - [$type_member, "\\\\fI\$1\$2\$3\\\\fP"], - [$type_fallback, "\\\\fI\$1\\\\fP"] - ); -my $blankline_man =3D ""; - -# rst-mode -my @highlights_rst =3D ( - [$type_constant, "``\$1``"], - [$type_constant2, "``\$1``"], - # Note: need to escape () to avoid func matching la= ter - [$type_member_func, "\\:c\\:type\\:`\$1\$2\$3\\\\(\= \\\) <\$1>`"], - [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"], - [$type_fp_param, "**\$1\\\\(\\\\)**"], - [$type_fp_param2, "**\$1\\\\(\\\\)**"], - [$type_func, "\$1()"], - [$type_enum, "\\:c\\:type\\:`\$1 <\$2>`"], - [$type_struct, "\\:c\\:type\\:`\$1 <\$2>`"], - [$type_typedef, "\\:c\\:type\\:`\$1 <\$2>`"], - [$type_union, "\\:c\\:type\\:`\$1 <\$2>`"], - # in rst this can refer to any type - [$type_fallback, "\\:c\\:type\\:`\$1`"], - [$type_param_ref, "**\$1\$2**"] - ); -my $blankline_rst =3D "\n"; - -# read arguments -if ($#ARGV =3D=3D -1) { - usage(); -} - -my $kernelversion; -my ($sphinx_major, $sphinx_minor, $sphinx_patch); - -my $dohighlight =3D ""; - -my $verbose =3D 0; -my $Werror =3D 0; -my $output_mode =3D "rst"; -my $output_preformatted =3D 0; -my $no_doc_sections =3D 0; -my $enable_lineno =3D 0; -my @highlights =3D @highlights_rst; -my $blankline =3D $blankline_rst; -my $modulename =3D "Kernel API"; - -use constant { - OUTPUT_ALL =3D> 0, # output all symbols and doc sections - OUTPUT_INCLUDE =3D> 1, # output only specified symbols - OUTPUT_EXPORTED =3D> 2, # output exported symbols - OUTPUT_INTERNAL =3D> 3, # output non-exported symbols -}; -my $output_selection =3D OUTPUT_ALL; -my $show_not_found =3D 0; # No longer used - -my @export_file_list; - -my @build_time; -if (defined($ENV{'KBUILD_BUILD_TIMESTAMP'}) && - (my $seconds =3D `date -d"${ENV{'KBUILD_BUILD_TIMESTAMP'}}" +%s`) ne '= ') { - @build_time =3D gmtime($seconds); -} else { - @build_time =3D localtime; -} - -my $man_date =3D ('January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', - 'November', 'December')[$build_time[4]] . - " " . ($build_time[5]+1900); - -# Essentially these are globals. -# They probably want to be tidied up, made more localised or something. -# CAVEAT EMPTOR! Some of the others I localised may not want to be, which -# could cause "use of undefined value" or other bugs. -my ($function, %function_table, %parametertypes, $declaration_purpose); -my %nosymbol_table =3D (); -my $declaration_start_line; -my ($type, $declaration_name, $return_type); -my ($newsection, $newcontents, $prototype, $brcount, %source_map); - -if (defined($ENV{'KBUILD_VERBOSE'})) { - $verbose =3D "$ENV{'KBUILD_VERBOSE'}"; -} - -if (defined($ENV{'KDOC_WERROR'})) { - $Werror =3D "$ENV{'KDOC_WERROR'}"; -} - -if (defined($ENV{'KCFLAGS'})) { - my $kcflags =3D "$ENV{'KCFLAGS'}"; - - if ($kcflags =3D~ /Werror/) { - $Werror =3D 1; - } -} - -# Generated docbook code is inserted in a template at a point where -# docbook v3.1 requires a non-zero sequence of RefEntry's; see: -# https://www.oasis-open.org/docbook/documentation/reference/html/refentry= .html -# We keep track of number of generated entries and generate a dummy -# if needs be to ensure the expanded template can be postprocessed -# into html. -my $section_counter =3D 0; - -my $lineprefix=3D""; - -# Parser states -use constant { - STATE_NORMAL =3D> 0, # normal code - STATE_NAME =3D> 1, # looking for function name - STATE_BODY_MAYBE =3D> 2, # body - or maybe more description - STATE_BODY =3D> 3, # the body of the comment - STATE_BODY_WITH_BLANK_LINE =3D> 4, # the body, which has a blank line - STATE_PROTO =3D> 5, # scanning prototype - STATE_DOCBLOCK =3D> 6, # documentation block - STATE_INLINE =3D> 7, # gathering doc outside main block -}; -my $state; -my $in_doc_sect; -my $leading_space; - -# Inline documentation state -use constant { - STATE_INLINE_NA =3D> 0, # not applicable ($state !=3D STATE_INLINE) - STATE_INLINE_NAME =3D> 1, # looking for member name (@foo:) - STATE_INLINE_TEXT =3D> 2, # looking for member documentation - STATE_INLINE_END =3D> 3, # done - STATE_INLINE_ERROR =3D> 4, # error - Comment without header was found. - # Spit a warning as it's not - # proper kernel-doc and ignore the rest. -}; -my $inline_doc_state; - -#declaration types: can be -# 'function', 'struct', 'union', 'enum', 'typedef' -my $decl_type; - -my $doc_start =3D '^/\*\*\s*$'; # Allow whitespace at end of comment start. -my $doc_end =3D '\*/'; -my $doc_com =3D '\s*\*\s*'; -my $doc_com_body =3D '\s*\* ?'; -my $doc_decl =3D $doc_com . '(\w+)'; -# @params and a strictly limited set of supported section names -my $doc_sect =3D $doc_com . - '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\= s*:(.*)'; -my $doc_content =3D $doc_com_body . '(.*)'; -my $doc_block =3D $doc_com . 'DOC:\s*(.*)?'; -my $doc_inline_start =3D '^\s*/\*\*\s*$'; -my $doc_inline_sect =3D '\s*\*\s*(@\s*[\w][\w\.]*\s*):(.*)'; -my $doc_inline_end =3D '^\s*\*/\s*$'; -my $doc_inline_oneline =3D '^\s*/\*\*\s*(@[\w\s]+):\s*(.*)\s*\*/\s*$'; -my $export_symbol =3D '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;'; - -my %parameterdescs; -my %parameterdesc_start_lines; -my @parameterlist; -my %sections; -my @sectionlist; -my %section_start_lines; -my $sectcheck; -my $struct_actual; - -my $contents =3D ""; -my $new_start_line =3D 0; - -# the canonical section names. see also $doc_sect above. -my $section_default =3D "Description"; # default section -my $section_intro =3D "Introduction"; -my $section =3D $section_default; -my $section_context =3D "Context"; -my $section_return =3D "Return"; - -my $undescribed =3D "-- undescribed --"; - -reset_state(); - -while ($ARGV[0] =3D~ m/^--?(.*)/) { - my $cmd =3D $1; - shift @ARGV; - if ($cmd eq "man") { - $output_mode =3D "man"; - @highlights =3D @highlights_man; - $blankline =3D $blankline_man; - } elsif ($cmd eq "rst") { - $output_mode =3D "rst"; - @highlights =3D @highlights_rst; - $blankline =3D $blankline_rst; - } elsif ($cmd eq "none") { - $output_mode =3D "none"; - } elsif ($cmd eq "module") { # not needed for XML, inherits from calli= ng document - $modulename =3D shift @ARGV; - } elsif ($cmd eq "function") { # to only output specific functions - $output_selection =3D OUTPUT_INCLUDE; - $function =3D shift @ARGV; - $function_table{$function} =3D 1; - } elsif ($cmd eq "nosymbol") { # Exclude specific symbols - my $symbol =3D shift @ARGV; - $nosymbol_table{$symbol} =3D 1; - } elsif ($cmd eq "export") { # only exported symbols - $output_selection =3D OUTPUT_EXPORTED; - %function_table =3D (); - } elsif ($cmd eq "internal") { # only non-exported symbols - $output_selection =3D OUTPUT_INTERNAL; - %function_table =3D (); - } elsif ($cmd eq "export-file") { - my $file =3D shift @ARGV; - push(@export_file_list, $file); - } elsif ($cmd eq "v") { - $verbose =3D 1; - } elsif ($cmd eq "Werror") { - $Werror =3D 1; - } elsif (($cmd eq "h") || ($cmd eq "help")) { - usage(); - } elsif ($cmd eq 'no-doc-sections') { - $no_doc_sections =3D 1; - } elsif ($cmd eq 'enable-lineno') { - $enable_lineno =3D 1; - } elsif ($cmd eq 'show-not-found') { - $show_not_found =3D 1; # A no-op but don't fail - } elsif ($cmd eq "sphinx-version") { - my $ver_string =3D shift @ARGV; - if ($ver_string =3D~ m/^(\d+)(\.\d+)?(\.\d+)?/) { - $sphinx_major =3D $1; - if (defined($2)) { - $sphinx_minor =3D substr($2,1); - } else { - $sphinx_minor =3D 0; - } - if (defined($3)) { - $sphinx_patch =3D substr($3,1) - } else { - $sphinx_patch =3D 0; - } - } else { - die "Sphinx version should either major.minor or major.minor.patch fo= rmat\n"; - } - } else { - # Unknown argument - usage(); - } -} - -# continue execution near EOF; - -# The C domain dialect changed on Sphinx 3. So, we need to check the -# version in order to produce the right tags. -sub findprog($) -{ - foreach(split(/:/, $ENV{PATH})) { - return "$_/$_[0]" if(-x "$_/$_[0]"); - } -} - -sub get_sphinx_version() -{ - my $ver; - - my $cmd =3D "sphinx-build"; - if (!findprog($cmd)) { - my $cmd =3D "sphinx-build3"; - if (!findprog($cmd)) { - $sphinx_major =3D 1; - $sphinx_minor =3D 2; - $sphinx_patch =3D 0; - printf STDERR "Warning: Sphinx version not found. Using default (Sphinx= version %d.%d.%d)\n", - $sphinx_major, $sphinx_minor, $sphinx_patch; - return; - } - } - - open IN, "$cmd --version 2>&1 |"; - while () { - if (m/^\s*sphinx-build\s+([\d]+)\.([\d\.]+)(\+\/[\da-f]+)?$/) { - $sphinx_major =3D $1; - $sphinx_minor =3D $2; - $sphinx_patch =3D $3; - last; - } - # Sphinx 1.2.x uses a different format - if (m/^\s*Sphinx.*\s+([\d]+)\.([\d\.]+)$/) { - $sphinx_major =3D $1; - $sphinx_minor =3D $2; - $sphinx_patch =3D $3; - last; - } - } - close IN; -} - -# get kernel version from env -sub get_kernel_version() { - my $version =3D 'unknown kernel version'; - - if (defined($ENV{'KERNELVERSION'})) { - $version =3D $ENV{'KERNELVERSION'}; - } - return $version; -} - -# -sub print_lineno { - my $lineno =3D shift; - if ($enable_lineno && defined($lineno)) { - print "#define LINENO " . $lineno . "\n"; - } -} -## -# dumps section contents to arrays/hashes intended for that purpose. -# -sub dump_section { - my $file =3D shift; - my $name =3D shift; - my $contents =3D join "\n", @_; - - if ($name =3D~ m/$type_param/) { - $name =3D $1; - $parameterdescs{$name} =3D $contents; - $sectcheck =3D $sectcheck . $name . " "; - $parameterdesc_start_lines{$name} =3D $new_start_line; - $new_start_line =3D 0; - } elsif ($name eq "@\.\.\.") { - $name =3D "..."; - $parameterdescs{$name} =3D $contents; - $sectcheck =3D $sectcheck . $name . " "; - $parameterdesc_start_lines{$name} =3D $new_start_line; - $new_start_line =3D 0; - } else { - if (defined($sections{$name}) && ($sections{$name} ne "")) { - # Only warn on user specified duplicate section names. - if ($name ne $section_default) { - print STDERR "${file}:$.: warning: duplicate section name '$name'\n"; - ++$warnings; - } - $sections{$name} .=3D $contents; - } else { - $sections{$name} =3D $contents; - push @sectionlist, $name; - $section_start_lines{$name} =3D $new_start_line; - $new_start_line =3D 0; - } - } -} - -## -# dump DOC: section after checking that it should go out -# -sub dump_doc_section { - my $file =3D shift; - my $name =3D shift; - my $contents =3D join "\n", @_; - - if ($no_doc_sections) { - return; - } - - return if (defined($nosymbol_table{$name})); - - if (($output_selection =3D=3D OUTPUT_ALL) || - (($output_selection =3D=3D OUTPUT_INCLUDE) && - defined($function_table{$name}))) - { - dump_section($file, $name, $contents); - output_blockhead({'sectionlist' =3D> \@sectionlist, - 'sections' =3D> \%sections, - 'module' =3D> $modulename, - 'content-only' =3D> ($output_selection !=3D OUTPUT_ALL), }); - } -} - -## -# output function -# -# parameterdescs, a hash. -# function =3D> "function name" -# parameterlist =3D> @list of parameters -# parameterdescs =3D> %parameter descriptions -# sectionlist =3D> @list of sections -# sections =3D> %section descriptions -# - -sub output_highlight { - my $contents =3D join "\n",@_; - my $line; - -# DEBUG -# if (!defined $contents) { -# use Carp; -# confess "output_highlight got called with no args?\n"; -# } - -# print STDERR "contents b4:$contents\n"; - eval $dohighlight; - die $@ if $@; -# print STDERR "contents af:$contents\n"; - - foreach $line (split "\n", $contents) { - if (! $output_preformatted) { - $line =3D~ s/^\s*//; - } - if ($line eq ""){ - if (! $output_preformatted) { - print $lineprefix, $blankline; - } - } else { - if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { - print "\\&$line"; - } else { - print $lineprefix, $line; - } - } - print "\n"; - } -} - -## -# output function in man -sub output_function_man(%) { - my %args =3D %{$_[0]}; - my ($parameter, $section); - my $count; - - print ".TH \"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\"= \"Kernel Hacker's Manual\" LINUX\n"; - - print ".SH NAME\n"; - print $args{'function'} . " \\- " . $args{'purpose'} . "\n"; - - print ".SH SYNOPSIS\n"; - if ($args{'functiontype'} ne "") { - print ".B \"" . $args{'functiontype'} . "\" " . $args{'function'} . "\n"; - } else { - print ".B \"" . $args{'function'} . "\n"; - } - $count =3D 0; - my $parenth =3D "("; - my $post =3D ","; - foreach my $parameter (@{$args{'parameterlist'}}) { - if ($count =3D=3D $#{$args{'parameterlist'}}) { - $post =3D ");"; - } - $type =3D $args{'parametertypes'}{$parameter}; - if ($type =3D~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { - # pointer-to-function - print ".BI \"" . $parenth . $1 . "\" " . " \") (" . $2 . ")" . $post = . "\"\n"; - } else { - $type =3D~ s/([^\*])$/$1 /; - print ".BI \"" . $parenth . $type . "\" " . " \"" . $post . "\"\n"; - } - $count++; - $parenth =3D ""; - } - - print ".SH ARGUMENTS\n"; - foreach $parameter (@{$args{'parameterlist'}}) { - my $parameter_name =3D $parameter; - $parameter_name =3D~ s/\[.*//; - - print ".IP \"" . $parameter . "\" 12\n"; - output_highlight($args{'parameterdescs'}{$parameter_name}); - } - foreach $section (@{$args{'sectionlist'}}) { - print ".SH \"", uc $section, "\"\n"; - output_highlight($args{'sections'}{$section}); - } -} - -## -# output enum in man -sub output_enum_man(%) { - my %args =3D %{$_[0]}; - my ($parameter, $section); - my $count; - - print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" = \"API Manual\" LINUX\n"; - - print ".SH NAME\n"; - print "enum " . $args{'enum'} . " \\- " . $args{'purpose'} . "\n"; - - print ".SH SYNOPSIS\n"; - print "enum " . $args{'enum'} . " {\n"; - $count =3D 0; - foreach my $parameter (@{$args{'parameterlist'}}) { - print ".br\n.BI \" $parameter\"\n"; - if ($count =3D=3D $#{$args{'parameterlist'}}) { - print "\n};\n"; - last; - } - else { - print ", \n.br\n"; - } - $count++; - } - - print ".SH Constants\n"; - foreach $parameter (@{$args{'parameterlist'}}) { - my $parameter_name =3D $parameter; - $parameter_name =3D~ s/\[.*//; - - print ".IP \"" . $parameter . "\" 12\n"; - output_highlight($args{'parameterdescs'}{$parameter_name}); - } - foreach $section (@{$args{'sectionlist'}}) { - print ".SH \"$section\"\n"; - output_highlight($args{'sections'}{$section}); - } -} - -## -# output struct in man -sub output_struct_man(%) { - my %args =3D %{$_[0]}; - my ($parameter, $section); - - print ".TH \"$args{'module'}\" 9 \"" . $args{'type'} . " " . $args{'st= ruct'} . "\" \"$man_date\" \"API Manual\" LINUX\n"; - - print ".SH NAME\n"; - print $args{'type'} . " " . $args{'struct'} . " \\- " . $args{'purpose= '} . "\n"; - - my $declaration =3D $args{'definition'}; - $declaration =3D~ s/\t/ /g; - $declaration =3D~ s/\n/"\n.br\n.BI \"/g; - print ".SH SYNOPSIS\n"; - print $args{'type'} . " " . $args{'struct'} . " {\n.br\n"; - print ".BI \"$declaration\n};\n.br\n\n"; - - print ".SH Members\n"; - foreach $parameter (@{$args{'parameterlist'}}) { - ($parameter =3D~ /^#/) && next; - - my $parameter_name =3D $parameter; - $parameter_name =3D~ s/\[.*//; - - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; - print ".IP \"" . $parameter . "\" 12\n"; - output_highlight($args{'parameterdescs'}{$parameter_name}); - } - foreach $section (@{$args{'sectionlist'}}) { - print ".SH \"$section\"\n"; - output_highlight($args{'sections'}{$section}); - } -} - -## -# output typedef in man -sub output_typedef_man(%) { - my %args =3D %{$_[0]}; - my ($parameter, $section); - - print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"= API Manual\" LINUX\n"; - - print ".SH NAME\n"; - print "typedef " . $args{'typedef'} . " \\- " . $args{'purpose'} . "\n= "; - - foreach $section (@{$args{'sectionlist'}}) { - print ".SH \"$section\"\n"; - output_highlight($args{'sections'}{$section}); - } -} - -sub output_blockhead_man(%) { - my %args =3D %{$_[0]}; - my ($parameter, $section); - my $count; - - print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"A= PI Manual\" LINUX\n"; - - foreach $section (@{$args{'sectionlist'}}) { - print ".SH \"$section\"\n"; - output_highlight($args{'sections'}{$section}); - } -} - -## -# output in restructured text -# - -# -# This could use some work; it's used to output the DOC: sections, and -# starts by putting out the name of the doc section itself, but that tends -# to duplicate a header already in the template file. -# -sub output_blockhead_rst(%) { - my %args =3D %{$_[0]}; - my ($parameter, $section); - - foreach $section (@{$args{'sectionlist'}}) { - next if (defined($nosymbol_table{$section})); - - if ($output_selection !=3D OUTPUT_INCLUDE) { - print "**$section**\n\n"; - } - print_lineno($section_start_lines{$section}); - output_highlight_rst($args{'sections'}{$section}); - print "\n"; - } -} - -# -# Apply the RST highlights to a sub-block of text. -# -sub highlight_block($) { - # The dohighlight kludge requires the text be called $contents - my $contents =3D shift; - eval $dohighlight; - die $@ if $@; - return $contents; -} - -# -# Regexes used only here. -# -my $sphinx_literal =3D '^[^.].*::$'; -my $sphinx_cblock =3D '^\.\.\ +code-block::'; - -sub output_highlight_rst { - my $input =3D join "\n",@_; - my $output =3D ""; - my $line; - my $in_literal =3D 0; - my $litprefix; - my $block =3D ""; - - foreach $line (split "\n",$input) { - # - # If we're in a literal block, see if we should drop out - # of it. Otherwise pass the line straight through unmunged. - # - if ($in_literal) { - if (! ($line =3D~ /^\s*$/)) { - # - # If this is the first non-blank line in a literal - # block we need to figure out what the proper indent is. - # - if ($litprefix eq "") { - $line =3D~ /^(\s*)/; - $litprefix =3D '^' . $1; - $output .=3D $line . "\n"; - } elsif (! ($line =3D~ /$litprefix/)) { - $in_literal =3D 0; - } else { - $output .=3D $line . "\n"; - } - } else { - $output .=3D $line . "\n"; - } - } - # - # Not in a literal block (or just dropped out) - # - if (! $in_literal) { - $block .=3D $line . "\n"; - if (($line =3D~ /$sphinx_literal/) || ($line =3D~ /$sphinx_cblock/)) { - $in_literal =3D 1; - $litprefix =3D ""; - $output .=3D highlight_block($block); - $block =3D "" - } - } - } - - if ($block) { - $output .=3D highlight_block($block); - } - foreach $line (split "\n", $output) { - print $lineprefix . $line . "\n"; - } -} - -sub output_function_rst(%) { - my %args =3D %{$_[0]}; - my ($parameter, $section); - my $oldprefix =3D $lineprefix; - my $start =3D ""; - my $is_macro =3D 0; - - if ($sphinx_major < 3) { - if ($args{'typedef'}) { - print ".. c:type:: ". $args{'function'} . "\n\n"; - print_lineno($declaration_start_line); - print " **Typedef**: "; - $lineprefix =3D ""; - output_highlight_rst($args{'purpose'}); - $start =3D "\n\n**Syntax**\n\n ``"; - $is_macro =3D 1; - } else { - print ".. c:function:: "; - } - } else { - if ($args{'typedef'} || $args{'functiontype'} eq "") { - $is_macro =3D 1; - print ".. c:macro:: ". $args{'function'} . "\n\n"; - } else { - print ".. c:function:: "; - } - - if ($args{'typedef'}) { - print_lineno($declaration_start_line); - print " **Typedef**: "; - $lineprefix =3D ""; - output_highlight_rst($args{'purpose'}); - $start =3D "\n\n**Syntax**\n\n ``"; - } else { - print "``" if ($is_macro); - } - } - if ($args{'functiontype'} ne "") { - $start .=3D $args{'functiontype'} . " " . $args{'function'} . " ("; - } else { - $start .=3D $args{'function'} . " ("; - } - print $start; - - my $count =3D 0; - foreach my $parameter (@{$args{'parameterlist'}}) { - if ($count ne 0) { - print ", "; - } - $count++; - $type =3D $args{'parametertypes'}{$parameter}; - - if ($type =3D~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { - # pointer-to-function - print $1 . $parameter . ") (" . $2 . ")"; - } else { - print $type; - } - } - if ($is_macro) { - print ")``\n\n"; - } else { - print ")\n\n"; - } - if (!$args{'typedef'}) { - print_lineno($declaration_start_line); - $lineprefix =3D " "; - output_highlight_rst($args{'purpose'}); - print "\n"; - } - - print "**Parameters**\n\n"; - $lineprefix =3D " "; - foreach $parameter (@{$args{'parameterlist'}}) { - my $parameter_name =3D $parameter; - $parameter_name =3D~ s/\[.*//; - $type =3D $args{'parametertypes'}{$parameter}; - - if ($type ne "") { - print "``$type``\n"; - } else { - print "``$parameter``\n"; - } - - print_lineno($parameterdesc_start_lines{$parameter_name}); - - if (defined($args{'parameterdescs'}{$parameter_name}) && - $args{'parameterdescs'}{$parameter_name} ne $undescribed) { - output_highlight_rst($args{'parameterdescs'}{$parameter_name}); - } else { - print " *undescribed*\n"; - } - print "\n"; - } - - $lineprefix =3D $oldprefix; - output_section_rst(@_); -} - -sub output_section_rst(%) { - my %args =3D %{$_[0]}; - my $section; - my $oldprefix =3D $lineprefix; - $lineprefix =3D ""; - - foreach $section (@{$args{'sectionlist'}}) { - print "**$section**\n\n"; - print_lineno($section_start_lines{$section}); - output_highlight_rst($args{'sections'}{$section}); - print "\n"; - } - print "\n"; - $lineprefix =3D $oldprefix; -} - -sub output_enum_rst(%) { - my %args =3D %{$_[0]}; - my ($parameter); - my $oldprefix =3D $lineprefix; - my $count; - - if ($sphinx_major < 3) { - my $name =3D "enum " . $args{'enum'}; - print "\n\n.. c:type:: " . $name . "\n\n"; - } else { - my $name =3D $args{'enum'}; - print "\n\n.. c:enum:: " . $name . "\n\n"; - } - print_lineno($declaration_start_line); - $lineprefix =3D " "; - output_highlight_rst($args{'purpose'}); - print "\n"; - - print "**Constants**\n\n"; - $lineprefix =3D " "; - foreach $parameter (@{$args{'parameterlist'}}) { - print "``$parameter``\n"; - if ($args{'parameterdescs'}{$parameter} ne $undescribed) { - output_highlight_rst($args{'parameterdescs'}{$parameter}); - } else { - print " *undescribed*\n"; - } - print "\n"; - } - - $lineprefix =3D $oldprefix; - output_section_rst(@_); -} - -sub output_typedef_rst(%) { - my %args =3D %{$_[0]}; - my ($parameter); - my $oldprefix =3D $lineprefix; - my $name; - - if ($sphinx_major < 3) { - $name =3D "typedef " . $args{'typedef'}; - } else { - $name =3D $args{'typedef'}; - } - print "\n\n.. c:type:: " . $name . "\n\n"; - print_lineno($declaration_start_line); - $lineprefix =3D " "; - output_highlight_rst($args{'purpose'}); - print "\n"; - - $lineprefix =3D $oldprefix; - output_section_rst(@_); -} - -sub output_struct_rst(%) { - my %args =3D %{$_[0]}; - my ($parameter); - my $oldprefix =3D $lineprefix; - - if ($sphinx_major < 3) { - my $name =3D $args{'type'} . " " . $args{'struct'}; - print "\n\n.. c:type:: " . $name . "\n\n"; - } else { - my $name =3D $args{'struct'}; - if ($args{'type'} eq 'union') { - print "\n\n.. c:union:: " . $name . "\n\n"; - } else { - print "\n\n.. c:struct:: " . $name . "\n\n"; - } - } - print_lineno($declaration_start_line); - $lineprefix =3D " "; - output_highlight_rst($args{'purpose'}); - print "\n"; - - print "**Definition**\n\n"; - print "::\n\n"; - my $declaration =3D $args{'definition'}; - $declaration =3D~ s/\t/ /g; - print " " . $args{'type'} . " " . $args{'struct'} . " {\n$declaration= };\n\n"; - - print "**Members**\n\n"; - $lineprefix =3D " "; - foreach $parameter (@{$args{'parameterlist'}}) { - ($parameter =3D~ /^#/) && next; - - my $parameter_name =3D $parameter; - $parameter_name =3D~ s/\[.*//; - - ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; - $type =3D $args{'parametertypes'}{$parameter}; - print_lineno($parameterdesc_start_lines{$parameter_name}); - print "``" . $parameter . "``\n"; - output_highlight_rst($args{'parameterdescs'}{$parameter_name}); - print "\n"; - } - print "\n"; - - $lineprefix =3D $oldprefix; - output_section_rst(@_); -} - -## none mode output functions - -sub output_function_none(%) { -} - -sub output_enum_none(%) { -} - -sub output_typedef_none(%) { -} - -sub output_struct_none(%) { -} - -sub output_blockhead_none(%) { -} - -## -# generic output function for all types (function, struct/union, typedef, = enum); -# calls the generated, variable output_ function name based on -# functype and output_mode -sub output_declaration { - no strict 'refs'; - my $name =3D shift; - my $functype =3D shift; - my $func =3D "output_${functype}_$output_mode"; - - return if (defined($nosymbol_table{$name})); - - if (($output_selection =3D=3D OUTPUT_ALL) || - (($output_selection =3D=3D OUTPUT_INCLUDE || - $output_selection =3D=3D OUTPUT_EXPORTED) && - defined($function_table{$name})) || - ($output_selection =3D=3D OUTPUT_INTERNAL && - !($functype eq "function" && defined($function_table{$name})))) - { - &$func(@_); - $section_counter++; - } -} - -## -# generic output function - calls the right one based on current output mo= de. -sub output_blockhead { - no strict 'refs'; - my $func =3D "output_blockhead_" . $output_mode; - &$func(@_); - $section_counter++; -} - -## -# takes a declaration (struct, union, enum, typedef) and -# invokes the right handler. NOT called for functions. -sub dump_declaration($$) { - no strict 'refs'; - my ($prototype, $file) =3D @_; - my $func =3D "dump_" . $decl_type; - &$func(@_); -} - -sub dump_union($$) { - dump_struct(@_); -} - -sub dump_struct($$) { - my $x =3D shift; - my $file =3D shift; - - if ($x =3D~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|= ____cacheline_aligned_in_smp|____cacheline_aligned|__attribute__\s*\(\([a-z= 0-9,_\s\(\)]*\)\)))*/) { - my $decl_type =3D $1; - $declaration_name =3D $2; - my $members =3D $3; - - # ignore members marked private: - $members =3D~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gosi; - $members =3D~ s/\/\*\s*private:.*//gosi; - # strip comments: - $members =3D~ s/\/\*.*?\*\///gos; - # strip attributes - $members =3D~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)/ /gi; - $members =3D~ s/\s*__aligned\s*\([^;]*\)/ /gos; - $members =3D~ s/\s*__packed\s*/ /gos; - $members =3D~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos; - $members =3D~ s/\s*____cacheline_aligned_in_smp/ /gos; - $members =3D~ s/\s*____cacheline_aligned/ /gos; - - # replace DECLARE_BITMAP - $members =3D~ s/__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)/DECLARE_B= ITMAP($1, __ETHTOOL_LINK_MODE_MASK_NBITS)/gos; - $members =3D~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $= 1\[BITS_TO_LONGS($2)\]/gos; - # replace DECLARE_HASHTABLE - $members =3D~ s/DECLARE_HASHTABLE\s*\(([^,)]+),\s*([^,)]+)\)/unsigned lon= g $1\[1 << (($2) - 1)\]/gos; - # replace DECLARE_KFIFO - $members =3D~ s/DECLARE_KFIFO\s*\(([^,)]+),\s*([^,)]+),\s*([^,)]+)\)/$2 \= *$1/gos; - # replace DECLARE_KFIFO_PTR - $members =3D~ s/DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos; - - my $declaration =3D $members; - - # Split nested struct/union elements as newer ones - while ($members =3D~ m/(struct|union)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*= )\;/) { - my $newmember; - my $maintype =3D $1; - my $ids =3D $4; - my $content =3D $3; - foreach my $id(split /,/, $ids) { - $newmember .=3D "$maintype $id; "; - - $id =3D~ s/[:\[].*//; - $id =3D~ s/^\s*\**(\S+)\s*/$1/; - foreach my $arg (split /;/, $content) { - next if ($arg =3D~ m/^\s*$/); - if ($arg =3D~ m/^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)/) { - # pointer-to-function - my $type =3D $1; - my $name =3D $2; - my $extra =3D $3; - next if (!$name); - if ($id =3D~ m/^\s*$/) { - # anonymous struct/union - $newmember .=3D "$type$name$extra; "; - } else { - $newmember .=3D "$type$id.$name$extra; "; - } - } else { - my $type; - my $names; - $arg =3D~ s/^\s+//; - $arg =3D~ s/\s+$//; - # Handle bitmaps - $arg =3D~ s/:\s*\d+\s*//g; - # Handle arrays - $arg =3D~ s/\[.*\]//g; - # The type may have multiple words, - # and multiple IDs can be defined, like: - # const struct foo, *bar, foobar - # So, we remove spaces when parsing the - # names, in order to match just names - # and commas for the names - $arg =3D~ s/\s*,\s*/,/g; - if ($arg =3D~ m/(.*)\s+([\S+,]+)/) { - $type =3D $1; - $names =3D $2; - } else { - $newmember .=3D "$arg; "; - next; - } - foreach my $name (split /,/, $names) { - $name =3D~ s/^\s*\**(\S+)\s*/$1/; - next if (($name =3D~ m/^\s*$/)); - if ($id =3D~ m/^\s*$/) { - # anonymous struct/union - $newmember .=3D "$type $name; "; - } else { - $newmember .=3D "$type $id.$name; "; - } - } - } - } - } - $members =3D~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*)\;/$n= ewmember/; - } - - # Ignore other nested elements, like enums - $members =3D~ s/(\{[^\{\}]*\})//g; - - create_parameterlist($members, ';', $file, $declaration_name); - check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_= actual); - - # Adjust declaration for better display - $declaration =3D~ s/([\{;])/$1\n/g; - $declaration =3D~ s/\}\s+;/};/g; - # Better handle inlined enums - do {} while ($declaration =3D~ s/(enum\s+\{[^\}]+),([^\n])/$1,\n$2/); - - my @def_args =3D split /\n/, $declaration; - my $level =3D 1; - $declaration =3D ""; - foreach my $clause (@def_args) { - $clause =3D~ s/^\s+//; - $clause =3D~ s/\s+$//; - $clause =3D~ s/\s+/ /; - next if (!$clause); - $level-- if ($clause =3D~ m/(\})/ && $level > 1); - if (!($clause =3D~ m/^\s*#/)) { - $declaration .=3D "\t" x $level; - } - $declaration .=3D "\t" . $clause . "\n"; - $level++ if ($clause =3D~ m/(\{)/ && !($clause =3D~m/\}/)); - } - output_declaration($declaration_name, - 'struct', - {'struct' =3D> $declaration_name, - 'module' =3D> $modulename, - 'definition' =3D> $declaration, - 'parameterlist' =3D> \@parameterlist, - 'parameterdescs' =3D> \%parameterdescs, - 'parametertypes' =3D> \%parametertypes, - 'sectionlist' =3D> \@sectionlist, - 'sections' =3D> \%sections, - 'purpose' =3D> $declaration_purpose, - 'type' =3D> $decl_type - }); - } - else { - print STDERR "${file}:$.: error: Cannot parse struct or union!\n"; - ++$errors; - } -} - - -sub show_warnings($$) { - my $functype =3D shift; - my $name =3D shift; - - return 0 if (defined($nosymbol_table{$name})); - - return 1 if ($output_selection =3D=3D OUTPUT_ALL); - - if ($output_selection =3D=3D OUTPUT_EXPORTED) { - if (defined($function_table{$name})) { - return 1; - } else { - return 0; - } - } - if ($output_selection =3D=3D OUTPUT_INTERNAL) { - if (!($functype eq "function" && defined($function_table{$name}))) { - return 1; - } else { - return 0; - } - } - if ($output_selection =3D=3D OUTPUT_INCLUDE) { - if (defined($function_table{$name})) { - return 1; - } else { - return 0; - } - } - die("Please add the new output type at show_warnings()"); -} - -sub dump_enum($$) { - my $x =3D shift; - my $file =3D shift; - my $members; - - - $x =3D~ s@/\*.*?\*/@@gos; # strip comments. - # strip #define macros inside enums - $x =3D~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos; - - if ($x =3D~ /typedef\s+enum\s*\{(.*)\}\s*(\w*)\s*;/) { - $declaration_name =3D $2; - $members =3D $1; - } elsif ($x =3D~ /enum\s+(\w*)\s*\{(.*)\}/) { - $declaration_name =3D $1; - $members =3D $2; - } - - if ($declaration_name) { - my %_members; - - $members =3D~ s/\s+$//; - - foreach my $arg (split ',', $members) { - $arg =3D~ s/^\s*(\w+).*/$1/; - push @parameterlist, $arg; - if (!$parameterdescs{$arg}) { - $parameterdescs{$arg} =3D $undescribed; - if (show_warnings("enum", $declaration_name)) { - print STDERR "${file}:$.: warning: Enum value '$arg' not described in e= num '$declaration_name'\n"; - } - } - $_members{$arg} =3D 1; - } - - while (my ($k, $v) =3D each %parameterdescs) { - if (!exists($_members{$k})) { - if (show_warnings("enum", $declaration_name)) { - print STDERR "${file}:$.: warning: Excess enum value '$k' descripti= on in '$declaration_name'\n"; - } - } - } - - output_declaration($declaration_name, - 'enum', - {'enum' =3D> $declaration_name, - 'module' =3D> $modulename, - 'parameterlist' =3D> \@parameterlist, - 'parameterdescs' =3D> \%parameterdescs, - 'sectionlist' =3D> \@sectionlist, - 'sections' =3D> \%sections, - 'purpose' =3D> $declaration_purpose - }); - } else { - print STDERR "${file}:$.: error: Cannot parse enum!\n"; - ++$errors; - } -} - -my $typedef_type =3D qr { ((?:\s+[\w\*]+){1,8})\s* }x; -my $typedef_ident =3D qr { \*?\s*(\w\S+)\s* }x; -my $typedef_args =3D qr { \s*\((.*)\); }x; - -my $typedef1 =3D qr { typedef$typedef_type\($typedef_ident\)$typedef_args = }x; -my $typedef2 =3D qr { typedef$typedef_type$typedef_ident$typedef_args }x; - -sub dump_typedef($$) { - my $x =3D shift; - my $file =3D shift; - - $x =3D~ s@/\*.*?\*/@@gos; # strip comments. - - # Parse function typedef prototypes - if ($x =3D~ $typedef1 || $x =3D~ $typedef2) { - $return_type =3D $1; - $declaration_name =3D $2; - my $args =3D $3; - $return_type =3D~ s/^\s+//; - - create_parameterlist($args, ',', $file, $declaration_name); - - output_declaration($declaration_name, - 'function', - {'function' =3D> $declaration_name, - 'typedef' =3D> 1, - 'module' =3D> $modulename, - 'functiontype' =3D> $return_type, - 'parameterlist' =3D> \@parameterlist, - 'parameterdescs' =3D> \%parameterdescs, - 'parametertypes' =3D> \%parametertypes, - 'sectionlist' =3D> \@sectionlist, - 'sections' =3D> \%sections, - 'purpose' =3D> $declaration_purpose - }); - return; - } - - while (($x =3D~ /\(*.\)\s*;$/) || ($x =3D~ /\[*.\]\s*;$/)) { - $x =3D~ s/\(*.\)\s*;$/;/; - $x =3D~ s/\[*.\]\s*;$/;/; - } - - if ($x =3D~ /typedef.*\s+(\w+)\s*;/) { - $declaration_name =3D $1; - - output_declaration($declaration_name, - 'typedef', - {'typedef' =3D> $declaration_name, - 'module' =3D> $modulename, - 'sectionlist' =3D> \@sectionlist, - 'sections' =3D> \%sections, - 'purpose' =3D> $declaration_purpose - }); - } - else { - print STDERR "${file}:$.: error: Cannot parse typedef!\n"; - ++$errors; - } -} - -sub save_struct_actual($) { - my $actual =3D shift; - - # strip all spaces from the actual param so that it looks like one str= ing item - $actual =3D~ s/\s*//g; - $struct_actual =3D $struct_actual . $actual . " "; -} - -sub create_parameterlist($$$$) { - my $args =3D shift; - my $splitter =3D shift; - my $file =3D shift; - my $declaration_name =3D shift; - my $type; - my $param; - - # temporarily replace commas inside function pointer definition - while ($args =3D~ /(\([^\),]+),/) { - $args =3D~ s/(\([^\),]+),/$1#/g; - } - - foreach my $arg (split($splitter, $args)) { - # strip comments - $arg =3D~ s/\/\*.*\*\///; - # strip leading/trailing spaces - $arg =3D~ s/^\s*//; - $arg =3D~ s/\s*$//; - $arg =3D~ s/\s+/ /; - - if ($arg =3D~ /^#/) { - # Treat preprocessor directive as a typeless variable just to fill - # corresponding data structures "correctly". Catch it later in - # output_* subs. - push_parameter($arg, "", "", $file); - } elsif ($arg =3D~ m/\(.+\)\s*\(/) { - # pointer-to-function - $arg =3D~ tr/#/,/; - $arg =3D~ m/[^\(]+\(\*?\s*([\w\.]*)\s*\)/; - $param =3D $1; - $type =3D $arg; - $type =3D~ s/([^\(]+\(\*?)\s*$param/$1/; - save_struct_actual($param); - push_parameter($param, $type, $arg, $file, $declaration_name); - } elsif ($arg) { - $arg =3D~ s/\s*:\s*/:/g; - $arg =3D~ s/\s*\[/\[/g; - - my @args =3D split('\s*,\s*', $arg); - if ($args[0] =3D~ m/\*/) { - $args[0] =3D~ s/(\*+)\s*/ $1/; - } - - my @first_arg; - if ($args[0] =3D~ /^(.*\s+)(.*?\[.*\].*)$/) { - shift @args; - push(@first_arg, split('\s+', $1)); - push(@first_arg, $2); - } else { - @first_arg =3D split('\s+', shift @args); - } - - unshift(@args, pop @first_arg); - $type =3D join " ", @first_arg; - - foreach $param (@args) { - if ($param =3D~ m/^(\*+)\s*(.*)/) { - save_struct_actual($2); - - push_parameter($2, "$type $1", $arg, $file, $declaration_name); - } - elsif ($param =3D~ m/(.*?):(\d+)/) { - if ($type ne "") { # skip unnamed bit-fields - save_struct_actual($1); - push_parameter($1, "$type:$2", $arg, $file, $declaration_name) - } - } - else { - save_struct_actual($param); - push_parameter($param, $type, $arg, $file, $declaration_name); - } - } - } - } -} - -sub push_parameter($$$$$) { - my $param =3D shift; - my $type =3D shift; - my $org_arg =3D shift; - my $file =3D shift; - my $declaration_name =3D shift; - - if (($anon_struct_union =3D=3D 1) && ($type eq "") && - ($param eq "}")) { - return; # ignore the ending }; from anon. struct/union - } - - $anon_struct_union =3D 0; - $param =3D~ s/[\[\)].*//; - - if ($type eq "" && $param =3D~ /\.\.\.$/) - { - if ($param =3D~ /\w\.\.\.$/) { - # for named variable parameters of the form `x...`, remove the dots - $param =3D~ s/\.\.\.$//; - } else { - # handles unnamed variable parameters - $param =3D "..."; - } - if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq ""= ) { - $parameterdescs{$param} =3D "variable arguments"; - } - } - elsif ($type eq "" && ($param eq "" or $param eq "void")) - { - $param=3D"void"; - $parameterdescs{void} =3D "no arguments"; - } - elsif ($type eq "" && ($param eq "struct" or $param eq "union")) - # handle unnamed (anonymous) union or struct: - { - $type =3D $param; - $param =3D "{unnamed_" . $param . "}"; - $parameterdescs{$param} =3D "anonymous\n"; - $anon_struct_union =3D 1; - } - - # warn if parameter has no description - # (but ignore ones starting with # as these are not parameters - # but inline preprocessor statements); - # Note: It will also ignore void params and unnamed structs/unions - if (!defined $parameterdescs{$param} && $param !~ /^#/) { - $parameterdescs{$param} =3D $undescribed; - - if (show_warnings($type, $declaration_name) && $param !~ /\./) { - print STDERR - "${file}:$.: warning: Function parameter or member '$param' not d= escribed in '$declaration_name'\n"; - ++$warnings; - } - } - - # strip spaces from $param so that it is one continuous string - # on @parameterlist; - # this fixes a problem where check_sections() cannot find - # a parameter like "addr[6 + 2]" because it actually appears - # as "addr[6", "+", "2]" on the parameter list; - # but it's better to maintain the param string unchanged for output, - # so just weaken the string compare in check_sections() to ignore - # "[blah" in a parameter string; - ###$param =3D~ s/\s*//g; - push @parameterlist, $param; - $org_arg =3D~ s/\s\s+/ /g; - $parametertypes{$param} =3D $org_arg; -} - -sub check_sections($$$$$) { - my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck) =3D @_; - my @sects =3D split ' ', $sectcheck; - my @prms =3D split ' ', $prmscheck; - my $err; - my ($px, $sx); - my $prm_clean; # strip trailing "[array size]" and/or beginning "*" - - foreach $sx (0 .. $#sects) { - $err =3D 1; - foreach $px (0 .. $#prms) { - $prm_clean =3D $prms[$px]; - $prm_clean =3D~ s/\[.*\]//; - $prm_clean =3D~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i; - # ignore array size in a parameter string; - # however, the original param string may contain - # spaces, e.g.: addr[6 + 2] - # and this appears in @prms as "addr[6" since the - # parameter list is split at spaces; - # hence just ignore "[..." for the sections check; - $prm_clean =3D~ s/\[.*//; - - ##$prm_clean =3D~ s/^\**//; - if ($prm_clean eq $sects[$sx]) { - $err =3D 0; - last; - } - } - if ($err) { - if ($decl_type eq "function") { - print STDERR "${file}:$.: warning: " . - "Excess function parameter " . - "'$sects[$sx]' " . - "description in '$decl_name'\n"; - ++$warnings; - } - } - } -} - -## -# Checks the section describing the return value of a function. -sub check_return_section { - my $file =3D shift; - my $declaration_name =3D shift; - my $return_type =3D shift; - - # Ignore an empty return type (It's a macro) - # Ignore functions with a "void" return type. (But don't ignore "v= oid *") - if (($return_type eq "") || ($return_type =3D~ /void\s*\w*\s*$/)) { - return; - } - - if (!defined($sections{$section_return}) || - $sections{$section_return} eq "") { - print STDERR "${file}:$.: warning: " . - "No description found for return value of " . - "'$declaration_name'\n"; - ++$warnings; - } -} - -## -# takes a function prototype and the name of the current file being -# processed and spits out all the details stored in the global -# arrays/hashes. -sub dump_function($$) { - my $prototype =3D shift; - my $file =3D shift; - my $noret =3D 0; - - print_lineno($new_start_line); - - $prototype =3D~ s/^static +//; - $prototype =3D~ s/^extern +//; - $prototype =3D~ s/^asmlinkage +//; - $prototype =3D~ s/^inline +//; - $prototype =3D~ s/^__inline__ +//; - $prototype =3D~ s/^__inline +//; - $prototype =3D~ s/^__always_inline +//; - $prototype =3D~ s/^noinline +//; - $prototype =3D~ s/__init +//; - $prototype =3D~ s/__init_or_module +//; - $prototype =3D~ s/__meminit +//; - $prototype =3D~ s/__must_check +//; - $prototype =3D~ s/__weak +//; - $prototype =3D~ s/__sched +//; - $prototype =3D~ s/__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +//; - my $define =3D $prototype =3D~ s/^#\s*define\s+//; #ak added - $prototype =3D~ s/__attribute__\s*\(\( - (?: - [\w\s]++ # attribute name - (?:\([^)]*+\))? # attribute arguments - \s*+,? # optional comma at the end - )+ - \)\)\s+//x; - - # Strip QEMU specific compiler annotations - $prototype =3D~ s/QEMU_[A-Z_]+ +//; - - # Yes, this truly is vile. We are looking for: - # 1. Return type (may be nothing if we're looking at a macro) - # 2. Function name - # 3. Function parameters. - # - # All the while we have to watch out for function pointer parameters - # (which IIRC is what the two sections are for), C types (these - # regexps don't even start to express all the possibilities), and - # so on. - # - # If you mess with these regexps, it's a good idea to check that - # the following functions' documentation still comes out right: - # - parport_register_device (function pointer parameters) - # - atomic_set (macro) - # - pci_match_device, __copy_to_user (long return type) - - if ($define && $prototype =3D~ m/^()([a-zA-Z0-9_~:]+)\s+/) { - # This is an object-like macro, it has no return type and no param= eter - # list. - # Function-like macros are not allowed to have spaces between - # declaration_name and opening parenthesis (notice the \s+). - $return_type =3D $1; - $declaration_name =3D $2; - $noret =3D 1; - } elsif ($prototype =3D~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || - $prototype =3D~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || - $prototype =3D~ m/^(\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || - $prototype =3D~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || - $prototype =3D~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ = || - $prototype =3D~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ = || - $prototype =3D~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]= *)\)/ || - $prototype =3D~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || - $prototype =3D~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || - $prototype =3D~ m/^(\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || - $prototype =3D~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || - $prototype =3D~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ = || - $prototype =3D~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ = || - $prototype =3D~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]= *)\)/ || - $prototype =3D~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]= *)\)/ || - $prototype =3D~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(= ([^\{]*)\)/ || - $prototype =3D~ m/^(\w+\s+\w+\s*\*+\s*\w+\s*\*+\s*)\s*([a-zA-Z0-9_~:]+)\s= *\(([^\{]*)\)/) { - $return_type =3D $1; - $declaration_name =3D $2; - my $args =3D $3; - - create_parameterlist($args, ',', $file, $declaration_name); - } else { - print STDERR "${file}:$.: warning: cannot understand function prototype: = '$prototype'\n"; - return; - } - - my $prms =3D join " ", @parameterlist; - check_sections($file, $declaration_name, "function", $sectcheck, $prms= ); - - # This check emits a lot of warnings at the moment, because many - # functions don't have a 'Return' doc section. So until the number - # of warnings goes sufficiently down, the check is only performed in - # verbose mode. - # TODO: always perform the check. - if ($verbose && !$noret) { - check_return_section($file, $declaration_name, $return_type); - } - - # The function parser can be called with a typedef parameter. - # Handle it. - if ($return_type =3D~ /typedef/) { - output_declaration($declaration_name, - 'function', - {'function' =3D> $declaration_name, - 'typedef' =3D> 1, - 'module' =3D> $modulename, - 'functiontype' =3D> $return_type, - 'parameterlist' =3D> \@parameterlist, - 'parameterdescs' =3D> \%parameterdescs, - 'parametertypes' =3D> \%parametertypes, - 'sectionlist' =3D> \@sectionlist, - 'sections' =3D> \%sections, - 'purpose' =3D> $declaration_purpose - }); - } else { - output_declaration($declaration_name, - 'function', - {'function' =3D> $declaration_name, - 'module' =3D> $modulename, - 'functiontype' =3D> $return_type, - 'parameterlist' =3D> \@parameterlist, - 'parameterdescs' =3D> \%parameterdescs, - 'parametertypes' =3D> \%parametertypes, - 'sectionlist' =3D> \@sectionlist, - 'sections' =3D> \%sections, - 'purpose' =3D> $declaration_purpose - }); - } -} - -sub reset_state { - $function =3D ""; - %parameterdescs =3D (); - %parametertypes =3D (); - @parameterlist =3D (); - %sections =3D (); - @sectionlist =3D (); - $sectcheck =3D ""; - $struct_actual =3D ""; - $prototype =3D ""; - - $state =3D STATE_NORMAL; - $inline_doc_state =3D STATE_INLINE_NA; -} - -sub tracepoint_munge($) { - my $file =3D shift; - my $tracepointname =3D 0; - my $tracepointargs =3D 0; - - if ($prototype =3D~ m/TRACE_EVENT\((.*?),/) { - $tracepointname =3D $1; - } - if ($prototype =3D~ m/DEFINE_SINGLE_EVENT\((.*?),/) { - $tracepointname =3D $1; - } - if ($prototype =3D~ m/DEFINE_EVENT\((.*?),(.*?),/) { - $tracepointname =3D $2; - } - $tracepointname =3D~ s/^\s+//; #strip leading whitespace - if ($prototype =3D~ m/TP_PROTO\((.*?)\)/) { - $tracepointargs =3D $1; - } - if (($tracepointname eq 0) || ($tracepointargs eq 0)) { - print STDERR "${file}:$.: warning: Unrecognized tracepoint format: \n". - "$prototype\n"; - } else { - $prototype =3D "static inline void trace_$tracepointname($tracepointargs= )"; - } -} - -sub syscall_munge() { - my $void =3D 0; - - $prototype =3D~ s@[\r\n]+@ @gos; # strip newlines/CR's -## if ($prototype =3D~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) { - if ($prototype =3D~ m/SYSCALL_DEFINE0/) { - $void =3D 1; -## $prototype =3D "long sys_$1(void)"; - } - - $prototype =3D~ s/SYSCALL_DEFINE.*\(/long sys_/; # fix return type & func= name - if ($prototype =3D~ m/long (sys_.*?),/) { - $prototype =3D~ s/,/\(/; - } elsif ($void) { - $prototype =3D~ s/\)/\(void\)/; - } - - # now delete all of the odd-number commas in $prototype - # so that arg types & arg names don't have a comma between them - my $count =3D 0; - my $len =3D length($prototype); - if ($void) { - $len =3D 0; # skip the for-loop - } - for (my $ix =3D 0; $ix < $len; $ix++) { - if (substr($prototype, $ix, 1) eq ',') { - $count++; - if ($count % 2 =3D=3D 1) { - substr($prototype, $ix, 1) =3D ' '; - } - } - } -} - -sub process_proto_function($$) { - my $x =3D shift; - my $file =3D shift; - - $x =3D~ s@\/\/.*$@@gos; # strip C99-style comments to end of line - - if ($x =3D~ m#\s*/\*\s+MACDOC\s*#io || ($x =3D~ /^#/ && $x !~ /^#\s*de= fine/)) { - # do nothing - } - elsif ($x =3D~ /([^\{]*)/) { - $prototype .=3D $1; - } - - if (($x =3D~ /\{/) || ($x =3D~ /\#\s*define/) || ($x =3D~ /;/)) { - $prototype =3D~ s@/\*.*?\*/@@gos; # strip comments. - $prototype =3D~ s@[\r\n]+@ @gos; # strip newlines/cr's. - $prototype =3D~ s@^\s+@@gos; # strip leading spaces - - # Handle prototypes for function pointers like: - # int (*pcs_config)(struct foo) - $prototype =3D~ s@^(\S+\s+)\(\s*\*(\S+)\)@$1$2@gos; - - if ($prototype =3D~ /SYSCALL_DEFINE/) { - syscall_munge(); - } - if ($prototype =3D~ /TRACE_EVENT/ || $prototype =3D~ /DEFINE_EVENT/ || - $prototype =3D~ /DEFINE_SINGLE_EVENT/) - { - tracepoint_munge($file); - } - dump_function($prototype, $file); - reset_state(); - } -} - -sub process_proto_type($$) { - my $x =3D shift; - my $file =3D shift; - - $x =3D~ s@[\r\n]+@ @gos; # strip newlines/cr's. - $x =3D~ s@^\s+@@gos; # strip leading spaces - $x =3D~ s@\s+$@@gos; # strip trailing spaces - $x =3D~ s@\/\/.*$@@gos; # strip C99-style comments to end of line - - if ($x =3D~ /^#/) { - # To distinguish preprocessor directive from regular declaration later. - $x .=3D ";"; - } - - while (1) { - if ( $x =3D~ /([^\{\};]*)([\{\};])(.*)/ ) { - if( length $prototype ) { - $prototype .=3D " " - } - $prototype .=3D $1 . $2; - ($2 eq '{') && $brcount++; - ($2 eq '}') && $brcount--; - if (($2 eq ';') && ($brcount =3D=3D 0)) { - dump_declaration($prototype, $file); - reset_state(); - last; - } - $x =3D $3; - } else { - $prototype .=3D $x; - last; - } - } -} - - -sub map_filename($) { - my $file; - my ($orig_file) =3D @_; - - if (defined($ENV{'SRCTREE'})) { - $file =3D "$ENV{'SRCTREE'}" . "/" . $orig_file; - } else { - $file =3D $orig_file; - } - - if (defined($source_map{$file})) { - $file =3D $source_map{$file}; - } - - return $file; -} - -sub process_export_file($) { - my ($orig_file) =3D @_; - my $file =3D map_filename($orig_file); - - if (!open(IN,"<$file")) { - print STDERR "Error: Cannot open file $file\n"; - ++$errors; - return; - } - - while () { - if (/$export_symbol/) { - next if (defined($nosymbol_table{$2})); - $function_table{$2} =3D 1; - } - } - - close(IN); -} - -# -# Parsers for the various processing states. -# -# STATE_NORMAL: looking for the /** to begin everything. -# -sub process_normal() { - if (/$doc_start/o) { - $state =3D STATE_NAME; # next line is always the function name - $in_doc_sect =3D 0; - $declaration_start_line =3D $. + 1; - } -} - -# -# STATE_NAME: Looking for the "name - description" line -# -sub process_name($$) { - my $file =3D shift; - my $identifier; - my $descr; - - if (/$doc_block/o) { - $state =3D STATE_DOCBLOCK; - $contents =3D ""; - $new_start_line =3D $.; - - if ( $1 eq "" ) { - $section =3D $section_intro; - } else { - $section =3D $1; - } - } - elsif (/$doc_decl/o) { - $identifier =3D $1; - if (/\s*([\w\s]+?)(\s*-|:)/) { - $identifier =3D $1; - } - - $state =3D STATE_BODY; - # if there's no @param blocks need to set up default section - # here - $contents =3D ""; - $section =3D $section_default; - $new_start_line =3D $. + 1; - if (/[-:](.*)/) { - # strip leading/trailing/multiple spaces - $descr=3D $1; - $descr =3D~ s/^\s*//; - $descr =3D~ s/\s*$//; - $descr =3D~ s/\s+/ /g; - $declaration_purpose =3D $descr; - $state =3D STATE_BODY_MAYBE; - } else { - $declaration_purpose =3D ""; - } - - if (($declaration_purpose eq "") && $verbose) { - print STDERR "${file}:$.: warning: missing initial short description = on line:\n"; - print STDERR $_; - ++$warnings; - } - - if ($identifier =3D~ m/^struct\b/) { - $decl_type =3D 'struct'; - } elsif ($identifier =3D~ m/^union\b/) { - $decl_type =3D 'union'; - } elsif ($identifier =3D~ m/^enum\b/) { - $decl_type =3D 'enum'; - } elsif ($identifier =3D~ m/^typedef\b/) { - $decl_type =3D 'typedef'; - } else { - $decl_type =3D 'function'; - } - - if ($verbose) { - print STDERR "${file}:$.: info: Scanning doc for $identifier\n"; - } - } else { - print STDERR "${file}:$.: warning: Cannot understand $_ on line $.", - " - I thought it was a doc line\n"; - ++$warnings; - $state =3D STATE_NORMAL; - } -} - - -# -# STATE_BODY and STATE_BODY_MAYBE: the bulk of a kerneldoc comment. -# -sub process_body($$) { - my $file =3D shift; - - # Until all named variable macro parameters are - # documented using the bare name (`x`) rather than with - # dots (`x...`), strip the dots: - if ($section =3D~ /\w\.\.\.$/) { - $section =3D~ s/\.\.\.$//; - - if ($verbose) { - print STDERR "${file}:$.: warning: Variable macro arguments should be= documented without dots\n"; - ++$warnings; - } - } - - if ($state =3D=3D STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) { - dump_section($file, $section, $contents); - $section =3D $section_default; - $new_start_line =3D $.; - $contents =3D ""; - } - - if (/$doc_sect/i) { # case insensitive for supported section names - $newsection =3D $1; - $newcontents =3D $2; - - # map the supported section names to the canonical names - if ($newsection =3D~ m/^description$/i) { - $newsection =3D $section_default; - } elsif ($newsection =3D~ m/^context$/i) { - $newsection =3D $section_context; - } elsif ($newsection =3D~ m/^returns?$/i) { - $newsection =3D $section_return; - } elsif ($newsection =3D~ m/^\@return$/) { - # special: @return is a section, not a param description - $newsection =3D $section_return; - } - - if (($contents ne "") && ($contents ne "\n")) { - if (!$in_doc_sect && $verbose) { - print STDERR "${file}:$.: warning: contents before sections\n"; - ++$warnings; - } - dump_section($file, $section, $contents); - $section =3D $section_default; - } - - $in_doc_sect =3D 1; - $state =3D STATE_BODY; - $contents =3D $newcontents; - $new_start_line =3D $.; - while (substr($contents, 0, 1) eq " ") { - $contents =3D substr($contents, 1); - } - if ($contents ne "") { - $contents .=3D "\n"; - } - $section =3D $newsection; - $leading_space =3D undef; - } elsif (/$doc_end/) { - if (($contents ne "") && ($contents ne "\n")) { - dump_section($file, $section, $contents); - $section =3D $section_default; - $contents =3D ""; - } - # look for doc_com + + doc_end: - if ($_ =3D~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') { - print STDERR "${file}:$.: warning: suspicious ending line: $_"; - ++$warnings; - } - - $prototype =3D ""; - $state =3D STATE_PROTO; - $brcount =3D 0; - $new_start_line =3D $. + 1; - } elsif (/$doc_content/) { - if ($1 eq "") { - if ($section eq $section_context) { - dump_section($file, $section, $contents); - $section =3D $section_default; - $contents =3D ""; - $new_start_line =3D $.; - $state =3D STATE_BODY; - } else { - if ($section ne $section_default) { - $state =3D STATE_BODY_WITH_BLANK_LINE; - } else { - $state =3D STATE_BODY; - } - $contents .=3D "\n"; - } - } elsif ($state =3D=3D STATE_BODY_MAYBE) { - # Continued declaration purpose - chomp($declaration_purpose); - $declaration_purpose .=3D " " . $1; - $declaration_purpose =3D~ s/\s+/ /g; - } else { - my $cont =3D $1; - if ($section =3D~ m/^@/ || $section eq $section_context) { - if (!defined $leading_space) { - if ($cont =3D~ m/^(\s+)/) { - $leading_space =3D $1; - } else { - $leading_space =3D ""; - } - } - $cont =3D~ s/^$leading_space//; - } - $contents .=3D $cont . "\n"; - } - } else { - # i dont know - bad line? ignore. - print STDERR "${file}:$.: warning: bad line: $_"; - ++$warnings; - } -} - - -# -# STATE_PROTO: reading a function/whatever prototype. -# -sub process_proto($$) { - my $file =3D shift; - - if (/$doc_inline_oneline/) { - $section =3D $1; - $contents =3D $2; - if ($contents ne "") { - $contents .=3D "\n"; - dump_section($file, $section, $contents); - $section =3D $section_default; - $contents =3D ""; - } - } elsif (/$doc_inline_start/) { - $state =3D STATE_INLINE; - $inline_doc_state =3D STATE_INLINE_NAME; - } elsif ($decl_type eq 'function') { - process_proto_function($_, $file); - } else { - process_proto_type($_, $file); - } -} - -# -# STATE_DOCBLOCK: within a DOC: block. -# -sub process_docblock($$) { - my $file =3D shift; - - if (/$doc_end/) { - dump_doc_section($file, $section, $contents); - $section =3D $section_default; - $contents =3D ""; - $function =3D ""; - %parameterdescs =3D (); - %parametertypes =3D (); - @parameterlist =3D (); - %sections =3D (); - @sectionlist =3D (); - $prototype =3D ""; - $state =3D STATE_NORMAL; - } elsif (/$doc_content/) { - if ( $1 eq "" ) { - $contents .=3D $blankline; - } else { - $contents .=3D $1 . "\n"; - } - } -} - -# -# STATE_INLINE: docbook comments within a prototype. -# -sub process_inline($$) { - my $file =3D shift; - - # First line (state 1) needs to be a @parameter - if ($inline_doc_state =3D=3D STATE_INLINE_NAME && /$doc_inline_sect/o)= { - $section =3D $1; - $contents =3D $2; - $new_start_line =3D $.; - if ($contents ne "") { - while (substr($contents, 0, 1) eq " ") { - $contents =3D substr($contents, 1); - } - $contents .=3D "\n"; - } - $inline_doc_state =3D STATE_INLINE_TEXT; - # Documentation block end */ - } elsif (/$doc_inline_end/) { - if (($contents ne "") && ($contents ne "\n")) { - dump_section($file, $section, $contents); - $section =3D $section_default; - $contents =3D ""; - } - $state =3D STATE_PROTO; - $inline_doc_state =3D STATE_INLINE_NA; - # Regular text - } elsif (/$doc_content/) { - if ($inline_doc_state =3D=3D STATE_INLINE_TEXT) { - $contents .=3D $1 . "\n"; - # nuke leading blank lines - if ($contents =3D~ /^\s*$/) { - $contents =3D ""; - } - } elsif ($inline_doc_state =3D=3D STATE_INLINE_NAME) { - $inline_doc_state =3D STATE_INLINE_ERROR; - print STDERR "${file}:$.: warning: "; - print STDERR "Incorrect use of kernel-doc format: $_"; - ++$warnings; - } - } -} - - -sub process_file($) { - my $file; - my $initial_section_counter =3D $section_counter; - my ($orig_file) =3D @_; - - $file =3D map_filename($orig_file); - - if (!open(IN_FILE,"<$file")) { - print STDERR "Error: Cannot open file $file\n"; - ++$errors; - return; - } - - $. =3D 1; - - $section_counter =3D 0; - while () { - while (s/\\\s*$//) { - $_ .=3D ; - } - # Replace tabs by spaces - while ($_ =3D~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; - # Hand this line to the appropriate state handler - if ($state =3D=3D STATE_NORMAL) { - process_normal(); - } elsif ($state =3D=3D STATE_NAME) { - process_name($file, $_); - } elsif ($state =3D=3D STATE_BODY || $state =3D=3D STATE_BODY_MAYBE || - $state =3D=3D STATE_BODY_WITH_BLANK_LINE) { - process_body($file, $_); - } elsif ($state =3D=3D STATE_INLINE) { # scanning for inline parameters - process_inline($file, $_); - } elsif ($state =3D=3D STATE_PROTO) { - process_proto($file, $_); - } elsif ($state =3D=3D STATE_DOCBLOCK) { - process_docblock($file, $_); - } - } - - # Make sure we got something interesting. - if ($initial_section_counter =3D=3D $section_counter && $ - output_mode ne "none") { - if ($output_selection =3D=3D OUTPUT_INCLUDE) { - print STDERR "${file}:1: warning: '$_' not found\n" - for keys %function_table; - } - else { - print STDERR "${file}:1: warning: no structured comments found\n"; - } - } - close IN_FILE; -} - - -if ($output_mode eq "rst") { - get_sphinx_version() if (!$sphinx_major); -} - -$kernelversion =3D get_kernel_version(); - -# generate a sequence of code that will splice in highlighting information -# using the s// operator. -for (my $k =3D 0; $k < @highlights; $k++) { - my $pattern =3D $highlights[$k][0]; - my $result =3D $highlights[$k][1]; -# print STDERR "scanning pattern:$pattern, highlight:($result)\n"; - $dohighlight .=3D "\$contents =3D~ s:$pattern:$result:gs;\n"; -} - -# Read the file that maps relative names to absolute names for -# separate source and object directories and for shadow trees. -if (open(SOURCE_MAP, "<.tmp_filelist.txt")) { - my ($relname, $absname); - while() { - chop(); - ($relname, $absname) =3D (split())[0..1]; - $relname =3D~ s:^/+::; - $source_map{$relname} =3D $absname; - } - close(SOURCE_MAP); -} - -if ($output_selection =3D=3D OUTPUT_EXPORTED || - $output_selection =3D=3D OUTPUT_INTERNAL) { - - push(@export_file_list, @ARGV); - - foreach (@export_file_list) { - chomp; - process_export_file($_); - } -} - -foreach (@ARGV) { - chomp; - process_file($_); -} -if ($verbose && $errors) { - print STDERR "$errors errors\n"; -} -if ($verbose && $warnings) { - print STDERR "$warnings warnings\n"; -} - -if ($Werror && $warnings) { - print STDERR "$warnings warnings as Errors\n"; - exit($warnings); -} else { - exit($output_mode eq "none" ? 0 : $errors) -} --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381160; cv=none; d=zohomail.com; s=zohoarc; b=MY+do+uxggdiZmmmZiTS80qt9kYQIKaszu8QotV1FK5DngW7QtBR1WL4U9+Nv+9BGjl8xKRS1pvA2AwRxdINTqBod/eKOz0CdwZ7/F/7T0fMSGuXkCqlZa//izh0uaZX/GAxCj8GAbFJsv+mPmCA/Sq3DyvoHT4LozgZvI97eXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381160; h=Content-Transfer-Encoding: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:Cc; bh=aFlNi84zHV+DQWq3I7X+awnNfmQLP9zzDTB0j2InexA=; b=Q1dR5b9vLXcelNQ1A/BlsR+/XQ5Cb55BLGcqQNyQV8kAjuJ4FoLgFE6SAxjw9HihoecMKFIR4eJIhOWTtfN99FHl+u4/atcqTXzHcIbkmVMqZw60/Bo8BIyNrpLLnzIdeA/HhzWQTA7CrzG8y2p9ITau4fsIhtdXOEhBXcYGOMA= 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 1756381160342907.155364084348; Thu, 28 Aug 2025 04:39:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauH-0003Yp-AI; Thu, 28 Aug 2025 07:35:05 -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 1urauD-0003UL-UG for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:02 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauB-0005pr-V0 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:01 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3ceb830dd58so66531f8f.0 for ; Thu, 28 Aug 2025 04:34:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380898; x=1756985698; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=aFlNi84zHV+DQWq3I7X+awnNfmQLP9zzDTB0j2InexA=; b=VftZQsTz8arM7vHrrrACvbYJgWh/JIt2KIsIlLsZYUsfRsXNfEbLmH6pS6mXmfc/TP Xgr/n5oj9H5U+oNtab+pAPaD9RTH+KynbEUoobYuMYekPog3yYJyQ7iIZxRvtycxL0tB yXEGVnO+Nm1OAAJ6njS4rrR3XqnhrNJrXLdssC8oP/oAgHsxnXOmIXaV1ppn5GPVvHGO OahwWirZquxHZD/CjnHTqKOQCjBOPs92mThlNSSkgr3p3k934K1tYzQrOzpPr6LLqeq5 3VQJ8o/d89NlZGzNKJmOQDi/DUM0p7a460oueUr9zn53z0yFKxQW4SUhkjdDoPuOn/zt 3zyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380898; x=1756985698; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aFlNi84zHV+DQWq3I7X+awnNfmQLP9zzDTB0j2InexA=; b=trxaAwstsq7hq6N2tAwQeVnB/1EtMG+Nlk28ipIDHN4ZB/No+D/Mpa2CWPkM4XnHrv s09OC9+rIz7ReK2YJWboBio8pzVhywqzYOrSGmzfNuRtcFN25oMaKbqzxZ7Sqmof55a5 s0chU+0rzFm1ijXlw7iFHZE4nrm+aUyRP+ekSMvEhPkVqaYXuTnUF/dLJqBvKiiFpAoY 5cw9ctkDZ/VhX/crH3hoZ/IrR0hfQzysR2D6Pgidn4AdJX6C48nUYOEmyFJ8A4DIUHGZ qL3HzcRXHrEVvyETj14rkBqM1j0rX/k5qykGVAy/VxlvFZ888IUe+z2SsEPid4M7Z1xH zmfg== X-Gm-Message-State: AOJu0Yz866gdU2hHUfY6FIeKMrzalCQiz5fWPA739ky454HaCU7TlP6s d1RkGyv5s6ToEg6EfU1VoYaxL8b9KPG87BxhtnNaciLhR4wZOYgmPnepCXFNApWCcGRNGQJ6cES muAoU X-Gm-Gg: ASbGnctbX2M7SbQxBlPJ9DtO2bsq4KsvyYfOPsm1NZ2tNe/lGRBRd6jSDHusq4mleWg A9fhtc63LQ5nTDSH7rRX4p4BXEX4228ytBdalFvAYk7ItxHvj2SLvG8KhV/5MF2V2LOip6ciYh3 yZb0Bm+vO9bax6ysMkJqqyHKWFGcGyb6fMgPd/QAGbXj4IXDtGcZyWB9TpbO2ytHVOk1XKTKrP2 zuKELt2bN81zK3tzFLrdUXKKsLnOWlEAEHoqK54vZ/fbhnZ7WODI61ZgVzX/f4Yl1/VMgpkPvVm 5FjZz0gZKvXYQFJC/PAyI2YnjRPDUs5WaxNElqWy2vDis3Ikm+EUXw+nTetihz5DyI23ZCjwXFv O7Ea8/ZFGk5gu1zYsC8srnCaIGrbxieiSWDCSysY= X-Google-Smtp-Source: AGHT+IEfmyEPNcbFz4decERQggBDX/a08LH19W9Gp5h0QPxhqPxrZUdQZc/myLWPbE7i8nB79UuUVg== X-Received: by 2002:a05:6000:26cc:b0:3c9:83f3:bdb7 with SMTP id ffacd0b85a97d-3cbb15c9df6mr7802537f8f.30.1756380898230; Thu, 28 Aug 2025 04:34:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/32] MAINTAINERS: Put kernel-doc under the "docs build machinery" section Date: Thu, 28 Aug 2025 12:34:20 +0100 Message-ID: <20250828113430.3214314-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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: 1756381163177124100 Content-Type: text/plain; charset="utf-8" We never had a MAINTAINERS entry for the old kernel-doc script; add the files for the new Python kernel-doc under "Sphinx documentation configuration and build machinery", as the most appropriate subsection. Mauro has kindly volunteered to help with maintenance/review of this area of the codebase, so add him as a maintainer. Signed-off-by: Peter Maydell Reviewed-by: Paolo Bonzini Reviewed-by: Mauro Carvalho Chehab Message-id: 20250814171324.1614516-9-peter.maydell@linaro.org --- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8f074e43712..8147fff3523 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4441,6 +4441,7 @@ F: po/*.po Sphinx documentation configuration and build machinery M: John Snow M: Peter Maydell +M: Mauro Carvalho Chehab S: Maintained F: docs/conf.py F: docs/*/conf.py @@ -4449,6 +4450,8 @@ F: docs/sphinx/ F: docs/_templates/ F: docs/devel/docs.rst F: docs/devel/qapi-domain.rst +F: scripts/kernel-doc +F: scripts/lib/kdoc/ =20 Rust build system integration M: Manos Pitsidianakis --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381032; cv=none; d=zohomail.com; s=zohoarc; b=TshUvLDa/ZlIjxW/u5AKwJ9LbhQVSM6Zh560Sbjd+rgGy2Omwg4EZq2pviiO+US41jQPX+Amj+RiidRh7ISUaDY1K/8uA6J0rfz4udcZ+8vdIFFjCCFK+x44W+83hOHZg6Li13kjxT7tkDYenyZcnFna069SChsUQIYhpwryNDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381032; h=Content-Transfer-Encoding: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:Cc; bh=jYyNxAEYuDq5SIsEhCR5IeKunK9WAoYLVLlbeucS6+w=; b=BIqc9amMPbf6lXjdpp4pwrfBJ0KxnZ06rwM64gZqAuuZ9ksFFrGz3xyS9lSCChc3SA/tQJOCFreLy5nZgEicNkRLM+1VmgaAa1zJfHAfuL7BUYZy1FFQTyJMV43Xmeoiwb2XZZenCkK+44Q8gNOlmgHZIyQIrH31MlAmnm1PF8Y= 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 1756381032484495.401496478185; Thu, 28 Aug 2025 04:37:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauJ-0003cw-DL; Thu, 28 Aug 2025 07:35:07 -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 1urauF-0003Vr-2G for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:03 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauD-0005r5-5m for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:02 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-45b7d497ab9so1635915e9.0 for ; Thu, 28 Aug 2025 04:35: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-45b79799c33sm28691015e9.5.2025.08.28.04.34.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380899; x=1756985699; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jYyNxAEYuDq5SIsEhCR5IeKunK9WAoYLVLlbeucS6+w=; b=KE57gZxbR6q6V4WK+4z7Pr1YzD8gNf7eGPrfnwmhNSvk5MyafIzhZM6F/FSwL+2CZi zlquqjTumOk41rzHbr2AW0ze6vLyhbpNPe34sbQHCSPvh+00nynRgTtXBmCUcmt9EO9A keRM+hxRxPH47dyztNpUT0j3pJLqHx7aCfMo2RNVgOS8Mt9/63hb15/g0bysOOBr94Hl BPA0lfgDBE1394b4bu2Hc6AhjubGFaEFN0e7OMIfHTAJHjiZfr+t2i3yi25J68/roesB CbS1HOGU+t80UwCSqN2P0fWxC5KmKtJZ3lfZ3n3T0otQaHvwkNGxTOdtjQc9uU/kk22Q hCYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380899; x=1756985699; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jYyNxAEYuDq5SIsEhCR5IeKunK9WAoYLVLlbeucS6+w=; b=ZjTmrLeUxlZ1wiLFHl9sgQaifAjmBR8GCDSoYbEqTQ4NT5yM5Eb6nfuqzuRtnEQex/ TOPiFc4zPO0A0jE41/Q2X/uoCm6IlRKqXGPGKkf+WSg31zB1CzwSr+8q7IJSEJ7ygXgf RYUOipBKsP2qu+xBWhNZ1JYdoV7y9V7itedKM6EgLck8XOWx186Q8kcz61SprO+v+l8m BTvo6BAWCXRKIN1jwmXTbZVQI+lDQEjL1LTn7gZva0LjRDgeCjvQEKEqcWSo5RS9Es4e P4Mv6IcvfVUWtWwTya6Dy/LXy1ZO+GS2bHyBqIzMTiImWSIj2Qk8toYzLCRGEMMs9dOM pAaA== X-Gm-Message-State: AOJu0Ywnj30rUUqJzEQ6xMR3DXMnTip0Pr1ZKS6KgukWch1/LovpkrxR o9lQX5UIFt4Q6vSgl65ZTEECTMHmw24ElwjQNQMkiV8nQl5I48Rwm1Bf2etLIfwLWQgZHOEZiF8 3+R4K X-Gm-Gg: ASbGnctlxwAD6n2HbJal+aoJ+PTn/Z71rMsrRehh+gZSxPL9V7ybt1n1opVcjC3LMrN V04fRv/78u+dhr0r/0kbW57z4caakjnpDq9GO8lmWmhzNaw94ZQjDM0N1S1uv73DuwpL7vgm+Ju wEoPb20vAwQ9AsdkQUwJkpOxlOkZDT9iimawDCwKSLx4YTEomYzrvxukVzQE86AMyNGNuc3TM2S oNYhgBLMTaaonAcSS9WTzDdryUQK4itxYYML5WKId1AR0wJ+7e87N6yd5UmFkUAhByKYJZ0zy4d l/QLKBRk0FYrlzNnXlkPKiiJ2x3pQlloJ8E4N0E6g5t0TeimO0O8F402+JDB0QSdwYqXdMhV4Bn vYPwbNPcIG2nl4PKKIq3AcMDn4yIAJ+GZMJ9ahQQ= X-Google-Smtp-Source: AGHT+IHyoLvA+DFB0hWaLwNqkE4u1309DYmCa8J5R1JQswG9t/tmTVn7k4fKeimLpfJXWjXtLk2+eQ== X-Received: by 2002:a05:600c:3b26:b0:456:1ac8:cac8 with SMTP id 5b1f17b1804b1-45b517ad6c8mr196832655e9.15.1756380899179; Thu, 28 Aug 2025 04:34:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/32] target/arm: Correct condition of aa64_atomics feature function Date: Thu, 28 Aug 2025 12:34:21 +0100 Message-ID: <20250828113430.3214314-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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: 1756381033711124100 Content-Type: text/plain; charset="utf-8" The ARMv8.1-Atomics feature (renamed FEAT_LSE in more modern versions of the Arm ARM) has always ben indicated by ID_AA64ISAR0.ATOMIC being 0b0010 or greater; 0b0001 is a reserved unused value. We were incorrectly checking for !=3D 0; this had no harmful effects because all the CPUs set their value for this field to either 0 (for not having the feature) or 2 (if they do have it), but it's better to match what the architecture specifies here. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20250819145659.2165160-1-peter.maydell@linaro.org --- target/arm/cpu-features.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 41511d08350..d48754bcf27 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -408,7 +408,7 @@ static inline bool isar_feature_aa64_crc32(const ARMISA= Registers *id) =20 static inline bool isar_feature_aa64_atomics(const ARMISARegisters *id) { - return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) !=3D 0; + return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) >=3D 2; } =20 static inline bool isar_feature_aa64_rdm(const ARMISARegisters *id) --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381049; cv=none; d=zohomail.com; s=zohoarc; b=h0f69fpKDZ9ntUsMPF8Qe9kL/ZenlJHfPqdVOrdR3HuljftKvkbT3mdIjwE3WJR01tZNkhFt5D2ZJjVsirQo2SU/KA5t6kTjTsxu0+Y0mW/VeEZUi/iA9w75RxR1t3zLjFTu2uFxM9XmyWdHGO61WZBqBlArpAIQpoF9QrsbLoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381049; h=Content-Transfer-Encoding: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:Cc; bh=xf/g1rBN/QzXId5vJeGSeSFs029NiEx5BSVc/H9VkHA=; b=nyi7KRz5pruw9eVqNMj9m78azuneoESow3ZPKX3hHzgbVPhuWNZQIrtWwnntKtN8VtL28Afvhs4KWD3MSz4+9HADLQAHlf2lIotv5luJXjGE1gKxzsrpPk6rQmyrEtMFMuHYs0DgBMoxg2OE4srQxQ9ud5EcnGglq4iN08owIEo= 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 1756381049368154.72401262190056; Thu, 28 Aug 2025 04:37:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauM-0003ep-9n; Thu, 28 Aug 2025 07:35:14 -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 1urauG-0003XP-5W for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:04 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauE-0005s8-74 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:03 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-45b7d497abaso1453885e9.0 for ; Thu, 28 Aug 2025 04:35:01 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.34.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380900; x=1756985700; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xf/g1rBN/QzXId5vJeGSeSFs029NiEx5BSVc/H9VkHA=; b=KV2WuOlK1x4bUYrzyxqTgG9ZaZrqO/UCMqyCJxJhoP7F0jfL/Q8VAQqkVb6Xa/hxas Uers9joO0VZpOhctIXwDxxUHlMvxbLPLYLrV25f1VXzfUpNTIUACfcBMCjjko3Zru1LE 4ioKfqwbxt00lHB8xDCPUCwBZIsw1X/qr33qjOvfi1ivgsiCS5a8N2b1h4E9lKq4nXR1 +/gWnPLkaqGPSgeGDyBYwwWfYNddCsozmFZ1T80Joq9jzk7p19tnUsdl5jDjkax3zCZS wYGfOafkMnbO96+8NdXlIP7be7k0JP6kboOheWUgsPslh9T7lx9+aXMc9Mj4AmxayGms ZXWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380900; x=1756985700; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xf/g1rBN/QzXId5vJeGSeSFs029NiEx5BSVc/H9VkHA=; b=YP/vk0S5cMDDe7F3RQia8GGor6hObPG2nFp77iSHWsvChqK959xvvowha1aD/JeCwW 2MezVDYTq/pAQKzVQBpdr2gCwMF2mr/GbOOAXDmWUpIdMGKXy9UwXuSuCGe+5m+ieIZM OA5hUYyTn3yROxzZIqn3tenDcHQC4oao/28UDWd3IJGhzqiKcwxGc5V7BhCpBz7hU+EV JpBLtpIXqaxxgWtMS8tA4OypliqcoTaUWCYNSt2boqWmMt2jC+4TeZnITGQjYpkofsmZ PbV2snVVVU3+dzZeJo9WqUbTUeNhWdEGFkV3UiVd6FM4zKG/C1drOpLvxMb+mWrP+pMS 5iFQ== X-Gm-Message-State: AOJu0YzoEPthYmQWW5n+4/7t9gVPN4cyN0mCFoVuaM1g844cv/3JyvZA bE3iGzGruBVb8jDqDO0XT3A+68uoLOEj8EaIZjhSPHzf3RCyQR5bnniy5atq/wdEpFkKKgJK5wT sUtmR X-Gm-Gg: ASbGncu6xpl6slg5VJKaH+cwFB5C1BK83zFr1sw6k8SxBLnH575wJUi0VAuOnkAhTOY CK4mAT4nhchqWwGyR+hroXnF8FUCOxHFLD2irbLiuXVPigndZ+Cz8JGUlvkfvhKRfWIHlVBGlL3 CMtc4vp1KviNZmOiyxUzbyA9WSdbVfeupuYOHENoa9jZrfxzcWIKfsmNpt+sM2qKDTlsK2/18cS b1OjRmTpLrfMczjFjv9U44y+vV/W5dBMxYwLm7nPAgs7hf8GAcQ4IzWlhY3AbyFgrDy141UHFzS Qudq6Dd384uDkHn9exK4p52MZx5Zw4+oI98FW768QQ0MpqdV+bBt9rC05U7OCnWLl4o1ev65b62 LG1pO7iLtvwh6CufPMp0kvCkeS+wMccAgG5u/f7Q= X-Google-Smtp-Source: AGHT+IEg4fTcjln/+5puH6w3F2/Rt0XGxKp9UAwam34hO0g+e7MxHfxh1/plgF/1xed9MM2oUex8ww== X-Received: by 2002:a05:600c:1d23:b0:45a:236a:23ba with SMTP id 5b1f17b1804b1-45b648f7ddcmr92092915e9.22.1756380900129; Thu, 28 Aug 2025 04:35:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/32] qemu/atomic: Finish renaming atomic128-cas.h headers Date: Thu, 28 Aug 2025 12:34:22 +0100 Message-ID: <20250828113430.3214314-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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: 1756381051086116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The aarch64 header was not renamed with the others, meaning it was skipped in favor of the generic version. Cc: qemu-stable@nongnu.org Fixes: 15606965400b ("qemu/atomic: Rename atomic128-cas.h headers using .h.= inc suffix") Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250815122653.701782-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- .../include/aarch64/host/{atomic128-cas.h =3D> atomic128-cas.h.inc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename host/include/aarch64/host/{atomic128-cas.h =3D> atomic128-cas.h.inc= } (100%) diff --git a/host/include/aarch64/host/atomic128-cas.h b/host/include/aarch= 64/host/atomic128-cas.h.inc similarity index 100% rename from host/include/aarch64/host/atomic128-cas.h rename to host/include/aarch64/host/atomic128-cas.h.inc --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381077; cv=none; d=zohomail.com; s=zohoarc; b=dvWmIaH4DDo+437vRtLa4Wm5a0Vj34+xgIbK7KjAXRxMQfM5G8R4wTUBKEkNtrRsOKhAB0gNJKAj34j1bzi+8uQkn9EhpHpWHUKmozR049phTOEm0pZo/B7IpiNRW4Bg7AqYJ2ANGGO/StrcXY9/thzYzV+l4zfKfSh7LhqpXQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381077; h=Content-Transfer-Encoding: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:Cc; bh=q260xObDFBnDUN8dnnYug1vSW1AKbW6lpt6JSmCuOfk=; b=lIM2QCYoNwZjSF8KaejW5W7BtsazMjIPSNcScFt6o6/YWxMyfma1zKAwMyt331ZVW8t16jKpaoHQdTIRRUcYlnEqf9kSqVdU0YSjvlZkoWE0atET+9yZfDwQmid4MKyu4u5pCc+NPbfvtdYU1laxUA2UVmq7QfEY7+jU2jskRlo= 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 175638107737268.2501428592467; Thu, 28 Aug 2025 04:37:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauJ-0003cz-Cg; Thu, 28 Aug 2025 07:35:07 -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 1urauH-0003Z9-87 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:05 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauE-0005ss-U4 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:04 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3c7ba0f6983so570362f8f.0 for ; Thu, 28 Aug 2025 04:35:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.35.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380901; x=1756985701; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=q260xObDFBnDUN8dnnYug1vSW1AKbW6lpt6JSmCuOfk=; b=YFYpGVdB95Xr8/WcTyOaBAmK5iZb5PwelBPLlEhgjpt7FWJKxvunyJOFJ008iJ0QPZ Waf7m3pWs5p0U5uO+tj1BP6RcEZ6bXGXt41b3kncakEYrhLzc+aMczB+GiTh8T0pHoFD S6pg2HGQUMNviOKIhrQyOl2scwzdsItGlZEUvPPBpkUgHbpbm13CXico+ICok6Xn4/DE SDCXSBA/5jq86SwL+AVbyF3yh3Zb9xv4NRRMm3auDGv/0ppCtAQgF3PYELEfcHxKTdPg G31/2dKnPTQHSdz46BOhGJXYAY1MJ1mwd3XA/OXsC5wv11Si9kXhCqDRP2GqxPGukXKb tx3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380901; x=1756985701; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q260xObDFBnDUN8dnnYug1vSW1AKbW6lpt6JSmCuOfk=; b=jIQ0SVwduUKkGIaxyh7lRdO9Rq7t4XKXYY4AWKDBUTz3Ft3AIg/i0PqRkXlId2CtiC 2lVUHli3MlOuF4ggTLBpV/iabEL7lvITP515fvlwLGuoivRx5T40R7BnO8mcgMej1kWb IJessi7C5vV/iSE5Gwx6Z5RWJ6TKyOpgYdut8aTcl+Cc/BNyeXUX3YKIhsSQb1IIBqLS 9SVYJvG8X9kNp7VGULmAroe98O3CsenUFXaC9pRlUz9A6Oz2xQWT/QD5xoCZTR2YCHXJ lvNu9GDkVA+mGdeCoCd8zv7sjgXIakv+mCLmZ4ikPFzpxTpLeVUg5lfjN4t8y2K8/ms/ /0sQ== X-Gm-Message-State: AOJu0YziCQZNro/2Lz6dzdi6EMAHd/mG86DH9dlPW7fgRcHf+WjfQT+Q mxJ9qqe1HdD4DZAeonk6G53O/gaLIusZ8Ck3/H+ZDVenVArwDdZMtddwoHIUUgK/uySs9439U8p FVaA1 X-Gm-Gg: ASbGncv/De4xHrZ0YQGOXS5P/d5G7nVKSmxHPU13WgJGfXkP4p+oHYAdvVFryDB36g3 4l1U5P5AJ/hay0J1e3LTlPHEU3j0e5MPt3XgCEJBdf2I1HOnJHgeSPt/zrv5qymhtuKUGtYGaZw TVH0ZZBwPzntoGgvqMxw5n7CM0Noeaasp3X0vpB/mZbSuBPaTINHYj+ddqaURQsel6pnMaOfgVN TaXvHGS6UPGDt7pb+DRr7gGUsykcaYWQrGWk1pu6IQm3hewFrA1BVf626/b7wYJZIPQdu7B+FLS 3XYLH4bDnx/bUtyYr2gvwK9ogJaC9JQxcLm0MDgHlgZbfl2XM9crTHrXWJ3mAnjnF1skITTp9Uv ZBKggioYMbKpHkEp8fcVaod51pqaCAthuh6K2x3o= X-Google-Smtp-Source: AGHT+IFunqEnqpff7N+h/SgbjIf5DnVfZQhMk5axTZH9ij2WYv3AYaQ+ev/pIa1h4Vi6SB5k56KQ9w== X-Received: by 2002:a05:6000:4007:b0:3ce:47a3:4675 with SMTP id ffacd0b85a97d-3ce47a34700mr1250989f8f.18.1756380901264; Thu, 28 Aug 2025 04:35:01 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/32] qemu/atomic: Add atomic16 primitives for xchg, fetch_and, fetch_or Date: Thu, 28 Aug 2025 12:34:23 +0100 Message-ID: <20250828113430.3214314-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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: 1756381081277124100 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250815122653.701782-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- host/include/aarch64/host/atomic128-cas.h.inc | 57 +++++++++++ host/include/generic/host/atomic128-cas.h.inc | 96 +++++++++++++++++++ 2 files changed, 153 insertions(+) diff --git a/host/include/aarch64/host/atomic128-cas.h.inc b/host/include/a= arch64/host/atomic128-cas.h.inc index 991da4ef543..aec27df1820 100644 --- a/host/include/aarch64/host/atomic128-cas.h.inc +++ b/host/include/aarch64/host/atomic128-cas.h.inc @@ -38,6 +38,63 @@ static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int12= 8 cmp, Int128 new) return int128_make128(oldl, oldh); } =20 +static inline Int128 atomic16_xchg(Int128 *ptr, Int128 new) +{ + uint64_t newl =3D int128_getlo(new), newh =3D int128_gethi(new); + uint64_t oldl, oldh; + uint32_t tmp; + + asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t" + "stlxp %w[tmp], %[newl], %[newh], %[mem]\n\t" + "cbnz %w[tmp], 0b" + : [mem] "+m"(*ptr), [tmp] "=3D&r"(tmp), + [oldl] "=3D&r"(oldl), [oldh] "=3D&r"(oldh) + : [newl] "r"(newl), [newh] "r"(newh) + : "memory"); + + return int128_make128(oldl, oldh); +} + +static inline Int128 atomic16_fetch_and(Int128 *ptr, Int128 new) +{ + uint64_t newl =3D int128_getlo(new), newh =3D int128_gethi(new); + uint64_t oldl, oldh, tmpl, tmph; + uint32_t tmp; + + asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t" + "and %[tmpl], %[oldl], %[newl]\n\t" + "and %[tmph], %[oldh], %[newh]\n\t" + "stlxp %w[tmp], %[tmpl], %[tmph], %[mem]\n\t" + "cbnz %w[tmp], 0b" + : [mem] "+m"(*ptr), [tmp] "=3D&r"(tmp), + [oldl] "=3D&r"(oldl), [oldh] "=3D&r"(oldh) + : [newl] "r"(newl), [newh] "r"(newh), + [tmpl] "r"(tmpl), [tmph] "r"(tmph) + : "memory"); + + return int128_make128(oldl, oldh); +} + +static inline Int128 atomic16_fetch_or(Int128 *ptr, Int128 new) +{ + uint64_t newl =3D int128_getlo(new), newh =3D int128_gethi(new); + uint64_t oldl, oldh, tmpl, tmph; + uint32_t tmp; + + asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t" + "orr %[tmpl], %[oldl], %[newl]\n\t" + "orr %[tmph], %[oldh], %[newh]\n\t" + "stlxp %w[tmp], %[tmpl], %[tmph], %[mem]\n\t" + "cbnz %w[tmp], 0b" + : [mem] "+m"(*ptr), [tmp] "=3D&r"(tmp), + [oldl] "=3D&r"(oldl), [oldh] "=3D&r"(oldh) + : [newl] "r"(newl), [newh] "r"(newh), + [tmpl] "r"(tmpl), [tmph] "r"(tmph) + : "memory"); + + return int128_make128(oldl, oldh); +} + # define CONFIG_CMPXCHG128 1 # define HAVE_CMPXCHG128 1 #endif diff --git a/host/include/generic/host/atomic128-cas.h.inc b/host/include/g= eneric/host/atomic128-cas.h.inc index 6b40cc22710..990162c56fe 100644 --- a/host/include/generic/host/atomic128-cas.h.inc +++ b/host/include/generic/host/atomic128-cas.h.inc @@ -23,6 +23,51 @@ atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) r.i =3D qatomic_cmpxchg__nocheck(ptr_align, c.i, n.i); return r.s; } + +/* + * Since we're looping anyway, use weak compare and swap. + * If the host supports weak, this will eliminate a second loop hidden + * within the atomic operation itself; otherwise the weak parameter is + * ignored. + */ +static inline Int128 ATTRIBUTE_ATOMIC128_OPT +atomic16_xchg(Int128 *ptr, Int128 new) +{ + __int128_t *ptr_align =3D __builtin_assume_aligned(ptr, 16); + Int128 old =3D *ptr_align; + + while (!__atomic_compare_exchange_n(ptr_align, &old, new, true, + __ATOMIC_SEQ_CST, 0)) { + continue; + } + return old; +} + +static inline Int128 ATTRIBUTE_ATOMIC128_OPT +atomic16_fetch_and(Int128 *ptr, Int128 val) +{ + __int128_t *ptr_align =3D __builtin_assume_aligned(ptr, 16); + Int128 old =3D *ptr_align; + + while (!__atomic_compare_exchange_n(ptr_align, &old, old & val, true, + __ATOMIC_SEQ_CST, 0)) { + continue; + } + return old; +} + +static inline Int128 ATTRIBUTE_ATOMIC128_OPT +atomic16_fetch_or(Int128 *ptr, Int128 val) +{ + __int128_t *ptr_align =3D __builtin_assume_aligned(ptr, 16); + Int128 old =3D *ptr_align; + + while (!__atomic_compare_exchange_n(ptr_align, &old, old | val, true, + __ATOMIC_SEQ_CST, 0)) { + continue; + } + return old; +} # define HAVE_CMPXCHG128 1 #elif defined(CONFIG_CMPXCHG128) static inline Int128 ATTRIBUTE_ATOMIC128_OPT @@ -36,6 +81,57 @@ atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) r.i =3D __sync_val_compare_and_swap_16(ptr_align, c.i, n.i); return r.s; } + +static inline Int128 ATTRIBUTE_ATOMIC128_OPT +atomic16_xchg(Int128 *ptr, Int128 new) +{ + Int128Aligned *ptr_align =3D __builtin_assume_aligned(ptr, 16); + Int128Alias o, n; + + n.s =3D new; + o.s =3D *ptr_align; + while (1) { + __int128 c =3D __sync_val_compare_and_swap_16(ptr_align, o.i, n.i); + if (c =3D=3D o.i) { + return o.s; + } + o.i =3D c; + } +} + +static inline Int128 ATTRIBUTE_ATOMIC128_OPT +atomic16_fetch_and(Int128 *ptr, Int128 val) +{ + Int128Aligned *ptr_align =3D __builtin_assume_aligned(ptr, 16); + Int128Alias o, v; + + v.s =3D val; + o.s =3D *ptr_align; + while (1) { + __int128 c =3D __sync_val_compare_and_swap_16(ptr_align, o.i, o.i = & v.i); + if (c =3D=3D o.i) { + return o.s; + } + o.i =3D c; + } +} + +static inline Int128 ATTRIBUTE_ATOMIC128_OPT +atomic16_fetch_or(Int128 *ptr, Int128 val) +{ + Int128Aligned *ptr_align =3D __builtin_assume_aligned(ptr, 16); + Int128Alias o, v; + + v.s =3D val; + o.s =3D *ptr_align; + while (1) { + __int128 c =3D __sync_val_compare_and_swap_16(ptr_align, o.i, o.i = | v.i); + if (c =3D=3D o.i) { + return o.s; + } + o.i =3D c; + } +} # define HAVE_CMPXCHG128 1 #else /* Fallback definition that must be optimized away, or error. */ --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380960; cv=none; d=zohomail.com; s=zohoarc; b=Ur2KcbbMnf+TmzoDLpuPTVwadZDaHt6Tkp/JRWAB3jk/GMp8bYhQSTiYcHHfbGNpab/NoZ+v6M4BWxxG0Uw8SgVi5UhFS1BDzFxIXw8bKu5GF8ZvXHwMmrpaHi1VALAWdfRxOdsIOxF/VKsSTXEmzijDEoN6f+jL2sLDNB8pULU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380960; h=Content-Transfer-Encoding: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:Cc; bh=reoWPBYk3yQmUnLtz/TOxOWd9zM5TyHFM2hf1Ap4HwM=; b=BF32RalPu0fRlCqgZFY4ai9rtB7vwpY7ssIbMOgCj/fmu2cz1J45MrcgbwjExXpUYrW31SnbE54uifIqpmBRAQpWs3SCILEA8hHb7m2HdrWEDvklcX4eO4b3DMHzSvJJXF0x1Sq6LueEPy+TtuHPF4i9vsqp+HKyJqhhDvppnW4= 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 1756380960837106.59590129031062; Thu, 28 Aug 2025 04:36:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uraud-0003z2-7t; Thu, 28 Aug 2025 07:35:27 -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 1urauI-0003bM-7g for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:06 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauF-0005tH-Tg for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:05 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-45a1b066b5eso4395145e9.1 for ; Thu, 28 Aug 2025 04:35:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.35.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380902; x=1756985702; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=reoWPBYk3yQmUnLtz/TOxOWd9zM5TyHFM2hf1Ap4HwM=; b=Db785Euk1GnhVayisNKq63497/j8bNtkM5whvnAtfk1+eMCkFIQebX64tKc62IlOIt GYUkXSZc+VBqh2RIxUmaI50QZC96dMNi6rlHJUID+l1piMqdbkL89xRLX8W5ILyHdKQw IacQI+oVw79q0vmzyXtJydIp3vuIOAgcoNQjxwceatZiF7ImrP5lCi8u216AACs3GODW kCywj7yKtDt4AEkFEMUY3ypWcDPHz9iT4hxGsbavTlgqjgJhNhYnLzH/oGtqCfv5PCRm t4mEwF2L+HxSx+XJZuRfdXUkai9fvufReDmIjcUwyHOeLjLnmpRFedN/0Xuj3ue6R/jQ FULw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380902; x=1756985702; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=reoWPBYk3yQmUnLtz/TOxOWd9zM5TyHFM2hf1Ap4HwM=; b=DCLZ8mb1KfBlNK0bCdiTYgdbRdhxgf4Z7jrl8UAp7PNW3gncJU7z1WcnB+6nCSdawQ wiU7RVbvxGoHYh9jQDYdcqchGAiJKfHO9RABgWzQScjMFUzBwzAEswONHO22/QBXABAx JzmNyIvKHDlent9gLOsAsp17psWy7J5BLTAVzpIMlPwet0EYbNv153wsrSiylcJdo4VN gTGkeNUa8k8ZJyw7q7IWN0mPgMKtk+BjMkPKtgSknULtd7kpAeFbKnjWhjWUFwNQ6Crk MYIhNitlvJ7Gf9wvEcd7pcOOcileoLQpsKqBfflqAd+2OegGopbfaOOVJSlC5q9X5kbB SCfQ== X-Gm-Message-State: AOJu0YxzrtqcILFID3Ko4OkaH1ah56C3cMyZNFeDjr2lC7di4T1AoDOg ewQAT3diJZ5ffKgksr+hwM4OltCmE4LjavsuOWbBkWni1jfXSP0pEM5EOxhOAPBvr3fRaQ+mr4q ui9/t X-Gm-Gg: ASbGncur4QQ2qvR0ImAqAX76qBi3CwhlTQ7k2klinU8ri8FFFEifjk+CJ+C4NNl1Vw7 0dsQhfV39YDMLjC2Pw5itqMNO29KsLY835y60SFK3kFbhNwZ7G1Xz4Fk8sGycSrjs+CD7+zazbI J1ggEs3k5ToCxsX/P9Os5KWraAS32X0oAMMTay23Y5lGq6yO+AvgOqio0FradU24aDFZC6lqGrt ONb62OlhH0Mnov8GBSBOSxlRdEAK0ypob78DloKGh7CjWm0MD1R2tPYE/OBtLICzNWMSrUMbU1n D/Fs5UyAzJe4xvufZOWVoMJzo7s9/2rV9+0TkojozYR5/vgXqdVYkKifdnV+Ms3UEb70mFqhzja LkKBL4gQsOzlb9wU1ii3Ujlb2+SMr+thxednaR88= X-Google-Smtp-Source: AGHT+IHwiQ5e25nEi2TGkP+n1taHfTWcppGZcybeRALka+QJraJUDyuNvr5MT162/NgapmRgo2M9qg== X-Received: by 2002:a05:600c:b96:b0:45b:725e:6acc with SMTP id 5b1f17b1804b1-45b74359d7dmr44635055e9.31.1756380902214; Thu, 28 Aug 2025 04:35:02 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/32] accel/tcg: Add cpu_atomic_*_mmu for 16-byte xchg, fetch_and, fetch_or Date: Thu, 28 Aug 2025 12:34:24 +0100 Message-ID: <20250828113430.3214314-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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: 1756380962754124100 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250815122653.701782-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- accel/tcg/atomic_template.h | 80 +++++++++++++++++++++++++++-- include/accel/tcg/cpu-ldst-common.h | 13 +++-- 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 08a475c10ca..ae5203b4390 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -100,7 +100,6 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, vaddr = addr, return ret; } =20 -#if DATA_SIZE < 16 ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, vaddr addr, ABI_TYPE val, MemOpIdx oi, uintptr_t retaddr) { @@ -108,7 +107,11 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, vaddr ad= dr, ABI_TYPE val, DATA_SIZE, retaddr); DATA_TYPE ret; =20 +#if DATA_SIZE =3D=3D 16 + ret =3D atomic16_xchg(haddr, val); +#else ret =3D qatomic_xchg__nocheck(haddr, val); +#endif ATOMIC_MMU_CLEANUP; atomic_trace_rmw_post(env, addr, VALUE_LOW(ret), @@ -119,6 +122,39 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, vaddr ad= dr, ABI_TYPE val, return ret; } =20 +#if DATA_SIZE =3D=3D 16 +ABI_TYPE ATOMIC_NAME(fetch_and)(CPUArchState *env, vaddr addr, ABI_TYPE va= l, + MemOpIdx oi, uintptr_t retaddr) +{ + DATA_TYPE *haddr =3D atomic_mmu_lookup(env_cpu(env), addr, oi, + DATA_SIZE, retaddr); + DATA_TYPE ret =3D atomic16_fetch_and(haddr, val); + ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(val), + VALUE_HIGH(val), + oi); + return ret; +} + +ABI_TYPE ATOMIC_NAME(fetch_or)(CPUArchState *env, vaddr addr, ABI_TYPE val, + MemOpIdx oi, uintptr_t retaddr) +{ + DATA_TYPE *haddr =3D atomic_mmu_lookup(env_cpu(env), addr, oi, + DATA_SIZE, retaddr); + DATA_TYPE ret =3D atomic16_fetch_or(haddr, val); + ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(val), + VALUE_HIGH(val), + oi); + return ret; +} +#else #define GEN_ATOMIC_HELPER(X) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, vaddr addr, \ ABI_TYPE val, MemOpIdx oi, uintptr_t retaddr) \ @@ -188,7 +224,7 @@ GEN_ATOMIC_HELPER_FN(smax_fetch, MAX, SDATA_TYPE, new) GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new) =20 #undef GEN_ATOMIC_HELPER_FN -#endif /* DATA SIZE < 16 */ +#endif /* DATA SIZE =3D=3D 16 */ =20 #undef END =20 @@ -225,7 +261,6 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, vaddr = addr, return BSWAP(ret); } =20 -#if DATA_SIZE < 16 ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, vaddr addr, ABI_TYPE val, MemOpIdx oi, uintptr_t retaddr) { @@ -233,7 +268,11 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, vaddr ad= dr, ABI_TYPE val, DATA_SIZE, retaddr); ABI_TYPE ret; =20 +#if DATA_SIZE =3D=3D 16 + ret =3D atomic16_xchg(haddr, BSWAP(val)); +#else ret =3D qatomic_xchg__nocheck(haddr, BSWAP(val)); +#endif ATOMIC_MMU_CLEANUP; atomic_trace_rmw_post(env, addr, VALUE_LOW(ret), @@ -244,6 +283,39 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, vaddr ad= dr, ABI_TYPE val, return BSWAP(ret); } =20 +#if DATA_SIZE =3D=3D 16 +ABI_TYPE ATOMIC_NAME(fetch_and)(CPUArchState *env, vaddr addr, ABI_TYPE va= l, + MemOpIdx oi, uintptr_t retaddr) +{ + DATA_TYPE *haddr =3D atomic_mmu_lookup(env_cpu(env), addr, oi, + DATA_SIZE, retaddr); + DATA_TYPE ret =3D atomic16_fetch_and(haddr, BSWAP(val)); + ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(val), + VALUE_HIGH(val), + oi); + return BSWAP(ret); +} + +ABI_TYPE ATOMIC_NAME(fetch_or)(CPUArchState *env, vaddr addr, ABI_TYPE val, + MemOpIdx oi, uintptr_t retaddr) +{ + DATA_TYPE *haddr =3D atomic_mmu_lookup(env_cpu(env), addr, oi, + DATA_SIZE, retaddr); + DATA_TYPE ret =3D atomic16_fetch_or(haddr, BSWAP(val)); + ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(val), + VALUE_HIGH(val), + oi); + return BSWAP(ret); +} +#else #define GEN_ATOMIC_HELPER(X) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, vaddr addr, \ ABI_TYPE val, MemOpIdx oi, uintptr_t retaddr) \ @@ -317,7 +389,7 @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new) #undef ADD =20 #undef GEN_ATOMIC_HELPER_FN -#endif /* DATA_SIZE < 16 */ +#endif /* DATA_SIZE =3D=3D 16 */ =20 #undef END #endif /* DATA_SIZE > 1 */ diff --git a/include/accel/tcg/cpu-ldst-common.h b/include/accel/tcg/cpu-ld= st-common.h index 8bf17c2fab0..17a3250deda 100644 --- a/include/accel/tcg/cpu-ldst-common.h +++ b/include/accel/tcg/cpu-ldst-common.h @@ -100,9 +100,6 @@ GEN_ATOMIC_HELPER_ALL(umax_fetch) =20 GEN_ATOMIC_HELPER_ALL(xchg) =20 -#undef GEN_ATOMIC_HELPER_ALL -#undef GEN_ATOMIC_HELPER - Int128 cpu_atomic_cmpxchgo_le_mmu(CPUArchState *env, vaddr addr, Int128 cmpv, Int128 newv, MemOpIdx oi, uintptr_t retaddr); @@ -110,6 +107,16 @@ Int128 cpu_atomic_cmpxchgo_be_mmu(CPUArchState *env, v= addr addr, Int128 cmpv, Int128 newv, MemOpIdx oi, uintptr_t retaddr); =20 +GEN_ATOMIC_HELPER(xchg, Int128, o_le) +GEN_ATOMIC_HELPER(xchg, Int128, o_be) +GEN_ATOMIC_HELPER(fetch_and, Int128, o_le) +GEN_ATOMIC_HELPER(fetch_and, Int128, o_be) +GEN_ATOMIC_HELPER(fetch_or, Int128, o_le) +GEN_ATOMIC_HELPER(fetch_or, Int128, o_be) + +#undef GEN_ATOMIC_HELPER_ALL +#undef GEN_ATOMIC_HELPER + uint8_t cpu_ldb_code_mmu(CPUArchState *env, vaddr addr, MemOpIdx oi, uintptr_t ra); uint16_t cpu_ldw_code_mmu(CPUArchState *env, vaddr addr, --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380961; cv=none; d=zohomail.com; s=zohoarc; b=jpGpWNXPHNeInyR5JIGhwUzHImNgE1ufjkS9O9xh+NdqsIqNQCoFjhc9ihMr4MHnKf5Nn3iT4+1ZLQICLVrprDdltvl9MpUlr9QHtOD/rCLl5jMv52XZPqVi45b1LWXfAZRhOvyGqK8BsX/lkFklmd1h/IIZ2oU0yZjGaUwjIpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380961; h=Content-Transfer-Encoding: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:Cc; bh=NDrWJvA3EAPGzXVi7xR+GWIA5VWSXLCvDTDuqmFRPTY=; b=ZZaCsSmdBsbwUd7JqDB6VoNASr9f8LfKJF5ALlp92ZUGN4c6uXrZN8Y4IPFX0fEdHObS/hN6LxP5AMfhrXUVOE+9FX7HsVjJN2Q9afOIBR82KwRHGh+YD0hDpW49ARy0WzOOZ2mAu0Um0uks5cV4pWUBL/MyxOcxOYdETEzhM1M= 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 1756380961811811.5255814403723; Thu, 28 Aug 2025 04:36:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uraud-0003ys-8u; Thu, 28 Aug 2025 07:35:27 -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 1urauJ-0003eC-Ld for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:07 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauH-00060a-14 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:07 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-45b7d497abaso1454275e9.0 for ; Thu, 28 Aug 2025 04:35: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-45b79799c33sm28691015e9.5.2025.08.28.04.35.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380903; x=1756985703; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=NDrWJvA3EAPGzXVi7xR+GWIA5VWSXLCvDTDuqmFRPTY=; b=iUCypIxg2Lw10HAyz1wOSK5Eh+dWZKuhX6woR/KOzWY4oX92Ux7L0d5HG5wdYQdCqB uEQry88UwH9HkXUmLDrollabNIj0l5xAjeKafEQBqwHJOcESeAY5/K35AlrrYjnWU+kp cTJ5tmP/UPqo40umvcj7r9ryH5Qhl2O4gzDQA/f6DBt14gkuBSbMC6nuSWinlgjTHBnq SXuXs0aLXjyXYaqpUAcIzRx/SbRS/gtC9UAIhf/MkPXNXCoAfwFUP6X5rhIvwvLmkZ4j 0KlMGjVUPUsYfeEtzM7HV/FiP3SPUkMGMhwPAqbpMSHYf4mdWWNs2JanMkPcQIs8N0dh M92Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380903; x=1756985703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NDrWJvA3EAPGzXVi7xR+GWIA5VWSXLCvDTDuqmFRPTY=; b=I19O2DNfAACpNAmjYsKKq+BeGeN/knxD3BT3zzhQtln2TbGpXb1FxUyHZBR7A/07MJ h4oxmHxN9gG9cCPXQJ+gfJuKNUexrnsgktuhBEWrV5o4gw/KIuEvHyQCFlNJ8gyGYbmJ 1/53emeznzRUpNK4vvHOdI47lsesMPbPQI1IsU2whiDmpqkSDAEpRNLz2jK6dytT826j nx4+am0Wj1SJMn/9hikcn2sgAHyiam8AQRjnqF7qzArMGIdTx6nCaqRb34LBudFkbmSn PqQ7sZjNM+RBM3OWwft2XY4MnlgTikcCde7+HfZwjq0LDXbv79mcMYsepEN665nOYGlC Fgwg== X-Gm-Message-State: AOJu0Yzn1k/6wEKj3PdHXVWRY9CWjINZQfp2MR7txGByF4DJ6Iiser84 e0AiLTnr8JxIWp5q2UWfrP503/hi16sVMfhy1jx0W9+MgZvtr4YiqOxZxD6uRhx+3WrEaRoGPrL RHPPa X-Gm-Gg: ASbGncvf05hKn4fPEK5M9shU6bPDmQtQrv9oH3shYjtyDcHmMpMZ6MRuXCSZVnu+YVn kwaWElVuVGtZJzpr957CAK4RjI1EP2JHHy9XBqLHckrRpH/6GUxCt9KWoa6NxOoNGbTxy6EaVWO mIF4RQy+2C/cXMROvJs9pHlbld3N2Jl8f10BFLQ0kBi3FYs69H1sA0E0jOElAI0baON9IecwNyT ZTvF5ajVITKcWnUY2HkQMTK3adwdUbIjzfbzHX88KhFDPnAayHn+K3Z6vXlyNcv/DJa93/n4Eob h8chH85YQrIQj6hC3YxSQmhMIBYyoiciInttbHACITvuJlbqT4TDQ0VIIIzymYlZ1I8NxN8ZC7P DLGdjZav7vn1loP9TtRKGTkIH4NzNagwcmXIyJrw= X-Google-Smtp-Source: AGHT+IHgDUzdg4CzTC1ePEopt0QAwabmmV1/SOMuhhuUa/ZY150/Ltkjw5CTDLED6o22eP/5DsXckQ== X-Received: by 2002:a05:600c:1c0c:b0:458:bda4:43df with SMTP id 5b1f17b1804b1-45b727a2c43mr50191875e9.17.1756380903208; Thu, 28 Aug 2025 04:35:03 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 28/32] tcg: Add tcg_gen_atomic_{xchg,fetch_and,fetch_or}_i128 Date: Thu, 28 Aug 2025 12:34:25 +0100 Message-ID: <20250828113430.3214314-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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: 1756380964231116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250815122653.701782-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- accel/tcg/tcg-runtime.h | 12 +++++ include/tcg/tcg-op-common.h | 7 +++ include/tcg/tcg-op.h | 3 ++ tcg/tcg-op-ldst.c | 97 +++++++++++++++++++++++++++++++++-- accel/tcg/atomic_common.c.inc | 9 ++++ 5 files changed, 125 insertions(+), 3 deletions(-) diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index c23b5e66c46..8436599b9f1 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -63,6 +63,18 @@ DEF_HELPER_FLAGS_5(atomic_cmpxchgo_be, TCG_CALL_NO_WG, i128, env, i64, i128, i128, i32) DEF_HELPER_FLAGS_5(atomic_cmpxchgo_le, TCG_CALL_NO_WG, i128, env, i64, i128, i128, i32) +DEF_HELPER_FLAGS_4(atomic_xchgo_be, TCG_CALL_NO_WG, + i128, env, i64, i128, i32) +DEF_HELPER_FLAGS_4(atomic_xchgo_le, TCG_CALL_NO_WG, + i128, env, i64, i128, i32) +DEF_HELPER_FLAGS_4(atomic_fetch_ando_be, TCG_CALL_NO_WG, + i128, env, i64, i128, i32) +DEF_HELPER_FLAGS_4(atomic_fetch_ando_le, TCG_CALL_NO_WG, + i128, env, i64, i128, i32) +DEF_HELPER_FLAGS_4(atomic_fetch_oro_be, TCG_CALL_NO_WG, + i128, env, i64, i128, i32) +DEF_HELPER_FLAGS_4(atomic_fetch_oro_le, TCG_CALL_NO_WG, + i128, env, i64, i128, i32) #endif =20 DEF_HELPER_FLAGS_5(nonatomic_cmpxchgo, TCG_CALL_NO_WG, diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index e1071adebf2..f752ef440b2 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -344,6 +344,8 @@ void tcg_gen_atomic_xchg_i32_chk(TCGv_i32, TCGTemp *, T= CGv_i32, TCGArg, MemOp, TCGType); void tcg_gen_atomic_xchg_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, TCGArg, MemOp, TCGType); +void tcg_gen_atomic_xchg_i128_chk(TCGv_i128, TCGTemp *, TCGv_i128, + TCGArg, MemOp, TCGType); =20 void tcg_gen_atomic_fetch_add_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, TCGArg, MemOp, TCGType); @@ -411,6 +413,11 @@ void tcg_gen_atomic_umax_fetch_i32_chk(TCGv_i32, TCGTe= mp *, TCGv_i32, void tcg_gen_atomic_umax_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, TCGArg, MemOp, TCGType); =20 +void tcg_gen_atomic_fetch_and_i128_chk(TCGv_i128, TCGTemp *, TCGv_i128, + TCGArg, MemOp, TCGType); +void tcg_gen_atomic_fetch_or_i128_chk(TCGv_i128, TCGTemp *, TCGv_i128, + TCGArg, MemOp, TCGType); + /* Vector ops */ =20 void tcg_gen_mov_vec(TCGv_vec, TCGv_vec); diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index c912578fdd2..232733cb718 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -134,13 +134,16 @@ DEF_ATOMIC3(tcg_gen_nonatomic_cmpxchg, i128) =20 DEF_ATOMIC2(tcg_gen_atomic_xchg, i32) DEF_ATOMIC2(tcg_gen_atomic_xchg, i64) +DEF_ATOMIC2(tcg_gen_atomic_xchg, i128) =20 DEF_ATOMIC2(tcg_gen_atomic_fetch_add, i32) DEF_ATOMIC2(tcg_gen_atomic_fetch_add, i64) DEF_ATOMIC2(tcg_gen_atomic_fetch_and, i32) DEF_ATOMIC2(tcg_gen_atomic_fetch_and, i64) +DEF_ATOMIC2(tcg_gen_atomic_fetch_and, i128) DEF_ATOMIC2(tcg_gen_atomic_fetch_or, i32) DEF_ATOMIC2(tcg_gen_atomic_fetch_or, i64) +DEF_ATOMIC2(tcg_gen_atomic_fetch_or, i128) DEF_ATOMIC2(tcg_gen_atomic_fetch_xor, i32) DEF_ATOMIC2(tcg_gen_atomic_fetch_xor, i64) DEF_ATOMIC2(tcg_gen_atomic_fetch_smin, i32) diff --git a/tcg/tcg-op-ldst.c b/tcg/tcg-op-ldst.c index 548496002d7..67c15fd4d0d 100644 --- a/tcg/tcg-op-ldst.c +++ b/tcg/tcg-op-ldst.c @@ -801,6 +801,8 @@ typedef void (*gen_atomic_op_i32)(TCGv_i32, TCGv_env, T= CGv_i64, TCGv_i32, TCGv_i32); typedef void (*gen_atomic_op_i64)(TCGv_i64, TCGv_env, TCGv_i64, TCGv_i64, TCGv_i32); +typedef void (*gen_atomic_op_i128)(TCGv_i128, TCGv_env, TCGv_i64, + TCGv_i128, TCGv_i32); =20 #ifdef CONFIG_ATOMIC64 # define WITH_ATOMIC64(X) X, @@ -1201,6 +1203,94 @@ static void do_atomic_op_i64(TCGv_i64 ret, TCGTemp *= addr, TCGv_i64 val, } } =20 +static void do_nonatomic_op_i128(TCGv_i128 ret, TCGTemp *addr, TCGv_i128 v= al, + TCGArg idx, MemOp memop, bool new_val, + void (*gen)(TCGv_i64, TCGv_i64, TCGv_i64)) +{ + TCGv_i128 t =3D tcg_temp_ebb_new_i128(); + TCGv_i128 r =3D tcg_temp_ebb_new_i128(); + + tcg_gen_qemu_ld_i128_int(r, addr, idx, memop); + gen(TCGV128_LOW(t), TCGV128_LOW(r), TCGV128_LOW(val)); + gen(TCGV128_HIGH(t), TCGV128_HIGH(r), TCGV128_HIGH(val)); + tcg_gen_qemu_st_i128_int(t, addr, idx, memop); + + tcg_gen_mov_i128(ret, r); + tcg_temp_free_i128(t); + tcg_temp_free_i128(r); +} + +static void do_atomic_op_i128(TCGv_i128 ret, TCGTemp *addr, TCGv_i128 val, + TCGArg idx, MemOp memop, void * const table[= ]) +{ + gen_atomic_op_i128 gen =3D table[memop & (MO_SIZE | MO_BSWAP)]; + + if (gen) { + MemOpIdx oi =3D make_memop_idx(memop & ~MO_SIGN, idx); + TCGv_i64 a64 =3D maybe_extend_addr64(addr); + gen(ret, tcg_env, a64, val, tcg_constant_i32(oi)); + maybe_free_addr64(a64); + return; + } + + gen_helper_exit_atomic(tcg_env); + /* Produce a result */ + tcg_gen_movi_i64(TCGV128_LOW(ret), 0); + tcg_gen_movi_i64(TCGV128_HIGH(ret), 0); +} + +#define GEN_ATOMIC_HELPER128(NAME, OP, NEW) \ +static void * const table_##NAME[(MO_SIZE | MO_BSWAP) + 1] =3D { \ + [MO_8] =3D gen_helper_atomic_##NAME##b, \ + [MO_16 | MO_LE] =3D gen_helper_atomic_##NAME##w_le, \ + [MO_16 | MO_BE] =3D gen_helper_atomic_##NAME##w_be, \ + [MO_32 | MO_LE] =3D gen_helper_atomic_##NAME##l_le, \ + [MO_32 | MO_BE] =3D gen_helper_atomic_##NAME##l_be, \ + WITH_ATOMIC64([MO_64 | MO_LE] =3D gen_helper_atomic_##NAME##q_le) \ + WITH_ATOMIC64([MO_64 | MO_BE] =3D gen_helper_atomic_##NAME##q_be) \ + WITH_ATOMIC128([MO_128 | MO_LE] =3D gen_helper_atomic_##NAME##o_le) \ + WITH_ATOMIC128([MO_128 | MO_BE] =3D gen_helper_atomic_##NAME##o_be) \ +}; \ +void tcg_gen_atomic_##NAME##_i32_chk(TCGv_i32 ret, TCGTemp *addr, \ + TCGv_i32 val, TCGArg idx, \ + MemOp memop, TCGType addr_type) \ +{ \ + tcg_debug_assert(addr_type =3D=3D tcg_ctx->addr_type); = \ + tcg_debug_assert((memop & MO_SIZE) <=3D MO_32); \ + if (tcg_ctx->gen_tb->cflags & CF_PARALLEL) { \ + do_atomic_op_i32(ret, addr, val, idx, memop, table_##NAME); \ + } else { \ + do_nonatomic_op_i32(ret, addr, val, idx, memop, NEW, \ + tcg_gen_##OP##_i32); \ + } \ +} \ +void tcg_gen_atomic_##NAME##_i64_chk(TCGv_i64 ret, TCGTemp *addr, \ + TCGv_i64 val, TCGArg idx, \ + MemOp memop, TCGType addr_type) \ +{ \ + tcg_debug_assert(addr_type =3D=3D tcg_ctx->addr_type); = \ + tcg_debug_assert((memop & MO_SIZE) <=3D MO_64); \ + if (tcg_ctx->gen_tb->cflags & CF_PARALLEL) { \ + do_atomic_op_i64(ret, addr, val, idx, memop, table_##NAME); \ + } else { \ + do_nonatomic_op_i64(ret, addr, val, idx, memop, NEW, \ + tcg_gen_##OP##_i64); \ + } \ +} \ +void tcg_gen_atomic_##NAME##_i128_chk(TCGv_i128 ret, TCGTemp *addr, \ + TCGv_i128 val, TCGArg idx, \ + MemOp memop, TCGType addr_type) \ +{ \ + tcg_debug_assert(addr_type =3D=3D tcg_ctx->addr_type); = \ + tcg_debug_assert((memop & MO_SIZE) =3D=3D MO_128); = \ + if (tcg_ctx->gen_tb->cflags & CF_PARALLEL) { \ + do_atomic_op_i128(ret, addr, val, idx, memop, table_##NAME); \ + } else { \ + do_nonatomic_op_i128(ret, addr, val, idx, memop, NEW, \ + tcg_gen_##OP##_i64); \ + } \ +} + #define GEN_ATOMIC_HELPER(NAME, OP, NEW) \ static void * const table_##NAME[(MO_SIZE | MO_BSWAP) + 1] =3D { \ [MO_8] =3D gen_helper_atomic_##NAME##b, \ @@ -1239,8 +1329,8 @@ void tcg_gen_atomic_##NAME##_i64_chk(TCGv_i64 ret, TC= GTemp *addr, \ } =20 GEN_ATOMIC_HELPER(fetch_add, add, 0) -GEN_ATOMIC_HELPER(fetch_and, and, 0) -GEN_ATOMIC_HELPER(fetch_or, or, 0) +GEN_ATOMIC_HELPER128(fetch_and, and, 0) +GEN_ATOMIC_HELPER128(fetch_or, or, 0) GEN_ATOMIC_HELPER(fetch_xor, xor, 0) GEN_ATOMIC_HELPER(fetch_smin, smin, 0) GEN_ATOMIC_HELPER(fetch_umin, umin, 0) @@ -1266,6 +1356,7 @@ static void tcg_gen_mov2_i64(TCGv_i64 r, TCGv_i64 a, = TCGv_i64 b) tcg_gen_mov_i64(r, b); } =20 -GEN_ATOMIC_HELPER(xchg, mov2, 0) +GEN_ATOMIC_HELPER128(xchg, mov2, 0) =20 #undef GEN_ATOMIC_HELPER +#undef GEN_ATOMIC_HELPER128 diff --git a/accel/tcg/atomic_common.c.inc b/accel/tcg/atomic_common.c.inc index 6056598c23d..bca93a0ac49 100644 --- a/accel/tcg/atomic_common.c.inc +++ b/accel/tcg/atomic_common.c.inc @@ -122,5 +122,14 @@ GEN_ATOMIC_HELPERS(umax_fetch) =20 GEN_ATOMIC_HELPERS(xchg) =20 +#if HAVE_CMPXCHG128 +ATOMIC_HELPER(xchgo_be, Int128) +ATOMIC_HELPER(xchgo_le, Int128) +ATOMIC_HELPER(fetch_ando_be, Int128) +ATOMIC_HELPER(fetch_ando_le, Int128) +ATOMIC_HELPER(fetch_oro_be, Int128) +ATOMIC_HELPER(fetch_oro_le, Int128) +#endif + #undef ATOMIC_HELPER #undef GEN_ATOMIC_HELPERS --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380963; cv=none; d=zohomail.com; s=zohoarc; b=DXFtaSqeFbh/WXuYVho83mHbVVeRM88iqW5VfxHXh7qVRe+/p3YEoE1ATUV6RxnWLnAYOcl39fwYyLl28BUG4VVHzIlC2ZKkl+zegswSx7c3N+XYo7nzgZyB8k4VByBv9PShDC136JOfHWjemUi7dvLZL1B6hZXowFqWU2mqfvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380963; h=Content-Transfer-Encoding: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:Cc; bh=tiT8sfxtJED9cTlqO78ECD4NGjv4tcXWJ2sLdQU3sWk=; b=IaD2v3GlVMfhPdn92CiofevB/oAz1F68YpHIW+psPmd80bVqpnXih6UC4E9E/foKMlwr+JYndwTRAdHnw9UKQbNkjYea89foSUhZS2byoBx+eocQ7Rf4/bF9ohJnBAx4kXdGBqmx067BBR/EtEZdqrP6sXmdcTl+//4lRc8cV2g= 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 1756380963427631.8541227966072; Thu, 28 Aug 2025 04:36:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uraue-00047f-Ti; Thu, 28 Aug 2025 07:35:29 -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 1urauK-0003f4-PM for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:10 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauI-00065U-LQ for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:08 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-45b4d89217aso5033665e9.2 for ; Thu, 28 Aug 2025 04:35:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.35.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380905; x=1756985705; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tiT8sfxtJED9cTlqO78ECD4NGjv4tcXWJ2sLdQU3sWk=; b=M1TZY0g2mag97MRNDlBFmC/zt/44D2vnqJpWaBrXCbCuuqL5c13HJqf9m753cZEXeo 2UMrmFb4wASrtbvkulbFUIJe+7r5+MGy+x22H1LIL3thKeMrfJYuMf16TKdXZetKcbPA xwk1BaJeUeT8BYW+ArW5sEHrsjujvtRDAum1MCkxkSeVGafLu2AVzZ0t0rC6PbHutRCI tXFeIIW/7ENR9a7CMLNyPnQg20k3J5IQ8iRHNkF1Ca+QOpupdFMsr8g+DhC4V0NvX7uU wcaHZb4gtC8ZS5p1/hJqcaqrHy5KEvR8q2cu5lQKg2eItVf+sodmcGqnCJD6WBqWg7GD heZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380905; x=1756985705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tiT8sfxtJED9cTlqO78ECD4NGjv4tcXWJ2sLdQU3sWk=; b=mWPhipmWI6fsASwB5X7CsSho2zHNDhSKdGRZ3LLv8MaDTYNMeZ+BO3QJq2ZOY9yZUH p9mKZe2Caou4ipPcR+7DQyX3Vg5h9B/5QXb1Sj95FaqeBIRbBzpC4LVbxxWQVZe98fcg eC8ai697y1dGByC4J9Rws9r5/m+3g+58QHWhqxpW0mM2vx2B9K2UkeB1Mqk2PNg9z5T5 Vu6bkYOiVUqViriN0HBJv2ErMvpv4Vbibwtvm6Dn4wY+x3nw4p2nz3KtGGCKMA2z50AK MNkb/Xib2ZWTVmftsKvT7BzGK90Aj6mRgAlsucRsNjWfNuFtZSS9ZQ4JcPiyNbpO8tAK YquQ== X-Gm-Message-State: AOJu0YxsHI8WyRpRtpNZgW2bl2kaFZ0lX2LfVzY6TsX57bqgOli2P9H9 QOpokPc6XIC1LPuI9NtLV8tpKkjgScgtSoESXjwX4oXnmXEfizEvDQtivlBe5kc0lKcGOtNd6rJ rgWwY X-Gm-Gg: ASbGncuAdOXaQ9ui4i1Z7VwycN8uO+dozLiiZMclqmm/f62gFxgBUBAtgcKQbcZJSBT EoRJemzUmIxHN/+P0cgc+6CgNWrCL+/iwj/gF0xy0HyiwkYEUn6Z1RXhLXGvxejqLo+0UtDL/z0 DN+Aq8ArrqBnovy7Vh/lfcGdeESKqo6AEZtzFuhBYdlpdhMsk3lhHONInNyMCscN/FKAv7kfDaU vnakoBzJVV6MypMURKplcaGtZnXvAzY+GPgcMfHZQHvqUeEAYCMFE2EXpavYnfXLRSrS8zU5OqR PpgpY+V376mmyXYG/7A5skdujo4EFbiKRENlwFyfXOFRWAzZbvD3yVCLncKT8W/vDNS6vEU+4di 6P8HyTje4nE/5yhUQwkQEZbSFlVS48Q+mxt2C3HU= X-Google-Smtp-Source: AGHT+IEsacV+FU5y7uwiod9ThU1ZmO+ISmEy1goZptPbNcODJojaSBvMWq8Wvnik7HqxebJpCnbJJg== X-Received: by 2002:a05:600c:a49:b0:453:66f:b96e with SMTP id 5b1f17b1804b1-45b517ad6b4mr196731645e9.11.1756380904833; Thu, 28 Aug 2025 04:35:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 29/32] target/arm: Rename isar_feature_aa64_atomics Date: Thu, 28 Aug 2025 12:34:26 +0100 Message-ID: <20250828113430.3214314-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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: 1756380964736124100 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This is FEAT_LSE -- rename the predicate to match. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250815122653.701782-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu-features.h | 2 +- linux-user/aarch64/elfload.c | 2 +- target/arm/tcg/translate-a64.c | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index d48754bcf27..451b37b5b39 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -406,7 +406,7 @@ static inline bool isar_feature_aa64_crc32(const ARMISA= Registers *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR0, CRC32) !=3D 0; } =20 -static inline bool isar_feature_aa64_atomics(const ARMISARegisters *id) +static inline bool isar_feature_aa64_lse(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) >=3D 2; } diff --git a/linux-user/aarch64/elfload.c b/linux-user/aarch64/elfload.c index 482c0df2d7f..0bec43d8c38 100644 --- a/linux-user/aarch64/elfload.c +++ b/linux-user/aarch64/elfload.c @@ -151,7 +151,7 @@ abi_ulong get_elf_hwcap(CPUState *cs) GET_FEATURE_ID(aa64_sm3, ARM_HWCAP_A64_SM3); GET_FEATURE_ID(aa64_sm4, ARM_HWCAP_A64_SM4); GET_FEATURE_ID(aa64_fp16, ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); - GET_FEATURE_ID(aa64_atomics, ARM_HWCAP_A64_ATOMICS); + GET_FEATURE_ID(aa64_lse, ARM_HWCAP_A64_ATOMICS); GET_FEATURE_ID(aa64_lse2, ARM_HWCAP_A64_USCAT); GET_FEATURE_ID(aa64_rdm, ARM_HWCAP_A64_ASIMDRDM); GET_FEATURE_ID(aa64_dp, ARM_HWCAP_A64_ASIMDDP); diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 259aa70a36d..0ba537268cd 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -3237,7 +3237,7 @@ static bool trans_LDXP(DisasContext *s, arg_stxr *a) =20 static bool trans_CASP(DisasContext *s, arg_CASP *a) { - if (!dc_isar_feature(aa64_atomics, s)) { + if (!dc_isar_feature(aa64_lse, s)) { return false; } if (((a->rt | a->rs) & 1) !=3D 0) { @@ -3250,7 +3250,7 @@ static bool trans_CASP(DisasContext *s, arg_CASP *a) =20 static bool trans_CAS(DisasContext *s, arg_CAS *a) { - if (!dc_isar_feature(aa64_atomics, s)) { + if (!dc_isar_feature(aa64_lse, s)) { return false; } gen_compare_and_swap(s, a->rs, a->rt, a->rn, a->sz); @@ -3743,15 +3743,15 @@ static bool do_atomic_ld(DisasContext *s, arg_atomi= c *a, AtomicThreeOpFn *fn, return true; } =20 -TRANS_FEAT(LDADD, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_add_= i64, 0, false) -TRANS_FEAT(LDCLR, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_and_= i64, 0, true) -TRANS_FEAT(LDEOR, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_xor_= i64, 0, false) -TRANS_FEAT(LDSET, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_or_i= 64, 0, false) -TRANS_FEAT(LDSMAX, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_sma= x_i64, MO_SIGN, false) -TRANS_FEAT(LDSMIN, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_smi= n_i64, MO_SIGN, false) -TRANS_FEAT(LDUMAX, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_uma= x_i64, 0, false) -TRANS_FEAT(LDUMIN, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_umi= n_i64, 0, false) -TRANS_FEAT(SWP, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_xchg_i64, 0,= false) +TRANS_FEAT(LDADD, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_add_i64,= 0, false) +TRANS_FEAT(LDCLR, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_and_i64,= 0, true) +TRANS_FEAT(LDEOR, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_xor_i64,= 0, false) +TRANS_FEAT(LDSET, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_or_i64, = 0, false) +TRANS_FEAT(LDSMAX, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_smax_i6= 4, MO_SIGN, false) +TRANS_FEAT(LDSMIN, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_smin_i6= 4, MO_SIGN, false) +TRANS_FEAT(LDUMAX, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_umax_i6= 4, 0, false) +TRANS_FEAT(LDUMIN, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_umin_i6= 4, 0, false) +TRANS_FEAT(SWP, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_xchg_i64, 0, fal= se) =20 static bool trans_LDAPR(DisasContext *s, arg_LDAPR *a) { @@ -3759,7 +3759,7 @@ static bool trans_LDAPR(DisasContext *s, arg_LDAPR *a) TCGv_i64 clean_addr; MemOp mop; =20 - if (!dc_isar_feature(aa64_atomics, s) || + if (!dc_isar_feature(aa64_lse, s) || !dc_isar_feature(aa64_rcpc_8_3, s)) { return false; } --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380989; cv=none; d=zohomail.com; s=zohoarc; b=UKy0Hi3vjczKsUbPrtVAjM1FweV85GxaoeBr7hhX4tfTaEHYpG4ajiqebAaEttBZjkkJiTQUHJ7gNzXqG4y09JoK8G0E0BwCSAZBiuXA6T/2mMCZonDbDXMbfFdrCmLCyJqMH0g/QXdDIPHROgDmtIiwAceSb5R35in9E4mba4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380989; h=Content-Transfer-Encoding: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:Cc; bh=ZQrm7QYldVzvYXlm3oou4nEhjLJT00tZjC2U4TRau+Y=; b=MCFFsdxyJr3FqKh+oAfbeStMN0m2JDEC/ISXDZxLubWBOdiNpi7DyVEyulEuAsyDZyHbnGhOf74E1aiJdSUgykjspOTCwDoXKItKPgT94hA63z9QmFLyEja0o73ISxousWvBzEOxCKVrK/fHqsPzYo9wq1PnsBxh15UE1DFa+Pg= 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 1756380989261379.7358479712718; Thu, 28 Aug 2025 04:36:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uraug-0004JK-Tg; Thu, 28 Aug 2025 07:35:30 -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 1urauM-0003hI-E1 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:14 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauK-00065y-5B for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:09 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3c6743a10e3so419766f8f.0 for ; Thu, 28 Aug 2025 04:35:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.35.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380906; x=1756985706; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ZQrm7QYldVzvYXlm3oou4nEhjLJT00tZjC2U4TRau+Y=; b=I1ftlSUJoh4cF1/lbx/+xlt/FG4MsQzDK7pJwqqC0cn3xseWNObpoI/NUmwHuYjNsG qjS4HYiTf9j+h7QsX4QuzD50V1jhDm0oc3Y6rVNpEGDZ3VsOsVAHId2FMtDuKR3ER421 lWVwH2qm5qYupkpQ4UOGE8dFmh4tURjJHAXegfRqQuVcjzEPn49GIREEWb6/u01OELnC VKYZBp9nnqj4dn86sUMq7vll5MywNcT1CriMaoMHj+t5UuJe8QckJPJrJBczSi2f6Vub TR99vxDSjCWMzvnSdicAo0Lz90imVj9j20AD2TLkXjqiRbfUUQnMk89NMKudUcZyKqna rLXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380906; x=1756985706; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZQrm7QYldVzvYXlm3oou4nEhjLJT00tZjC2U4TRau+Y=; b=hS7Ww7b1ipsX1ds/cP0a4zcM8XFVWAk57YpIG8bl7gPmX22rMCStpEE8+0CtaibhUX nLeRUvPbjGl7CRlx2RYit+Z2KoHjtBGAO00EA3+dEc6YKZSPtqp1AAfEV5xOmpQULBhf 5DFvaw6xp5gWLmdD+fVPDWI2aPhuvd0mgXAfDSHV0skYYJfVY+inYbq2nF5l7T1I2GLG MiuHshQfWUAIU+tMbEmGW3Z5vPqKvrg2WnZpxkXNdxD4ZXKyjFOeQwJxgVi8bNn++uKe kFtaQcQncQD9wjrZhAHAjw4zZGf/+lLs7wRF3iReMFdIRsYZtlU4Mcp09OXQMwjIMDMv KjbA== X-Gm-Message-State: AOJu0YwUYiZadXe//3W3gXYnUA7az2IEp8v1Xv9xNVQI7psmPiWCyPiH LSYniyTc6Hr3P++pl0kjvIfI8f9iDpGRsplL7jAbRslCUxWiQGS5G+8JqaYHd+REIWUAiwR4ItX QzeDW X-Gm-Gg: ASbGnctoFSz+H8R94TW3jmazloIoG0k1PzGSV3P4UX+y5aZQkUtxh2T8P0c/GqDdVMe ASHctUfn02KyEsg/1NvG4su6+CX6/Yf1r0Nmj38vMOA2fpnlirTXcQiXgjKHAYnVtLBIn2ZNMAu BFZ09RfklsU94mbsP1w/NcuWS+QYpiIds2i/wFcrpq46lJ9SINa+vdi8mhwiMGa0stl0bHioTue 3iCRB/EMhX3lARvyyNKMIvJKOzXIxJuCmsw9SrBK1tusp18Bc8Hw6wUaUDx7mE1cktpKo2v37j0 /KbGGLImXtq7ydMQzjWSrV6BKdHinnqbUwJQlld1BLMeBIZm7yz11Y3LdxRMHeeiliXWuVard91 ruiZm+N1BfTKaap8RTyXrLmx22jOhiloPDdGCAqcJMx5Vo9Oe6Q== X-Google-Smtp-Source: AGHT+IF3SUjYvhzkWMCFiaLv4kCOZT9jDQxvu7JjXvT6ZDtd0zTnX5W4f1WnItvYpZBphCKkzCk63Q== X-Received: by 2002:a05:6000:40dd:b0:3b7:dd87:d730 with SMTP id ffacd0b85a97d-3c5dcd03eecmr16610257f8f.52.1756380906081; Thu, 28 Aug 2025 04:35:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 30/32] target/arm: Implement FEAT_LSE128 Date: Thu, 28 Aug 2025 12:34:27 +0100 Message-ID: <20250828113430.3214314-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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: 1756380990578116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This feature contains the LDCLRP, LDSETP, and SWPP instructions. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250815122653.701782-7-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu-features.h | 5 ++++ target/arm/tcg/a64.decode | 7 +++++ target/arm/tcg/translate-a64.c | 49 ++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 451b37b5b39..e49e0ae3af0 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -411,6 +411,11 @@ static inline bool isar_feature_aa64_lse(const ARMISAR= egisters *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) >=3D 2; } =20 +static inline bool isar_feature_aa64_lse128(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) >=3D 3; +} + static inline bool isar_feature_aa64_rdm(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64ISAR0, RDM) !=3D 0; diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 766c610c019..55ff6c504f1 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -546,6 +546,13 @@ SWP .. 111 0 00 . . 1 ..... 1000 00 ..... = ..... @atomic =20 LDAPR sz:2 111 0 00 1 0 1 11111 1100 00 rn:5 rt:5 =20 +# Atomic 128-bit memory operations +&atomic128 rn rt rt2 a r +@atomic128 ........ a:1 r:1 . rt2:5 ...... rn:5 rt:5 &atomic128 +LDCLRP 00011001 . . 1 ..... 000100 ..... ..... @atomic128 +LDSETP 00011001 . . 1 ..... 001100 ..... ..... @atomic128 +SWPP 00011001 . . 1 ..... 100000 ..... ..... @atomic128 + # Load/store register (pointer authentication) =20 # LDRA immediate is 10 bits signed and scaled, but the bits aren't all con= tiguous diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 0ba537268cd..37bedc3780b 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -3753,6 +3753,55 @@ TRANS_FEAT(LDUMAX, aa64_lse, do_atomic_ld, a, tcg_ge= n_atomic_fetch_umax_i64, 0, TRANS_FEAT(LDUMIN, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_fetch_umin_i6= 4, 0, false) TRANS_FEAT(SWP, aa64_lse, do_atomic_ld, a, tcg_gen_atomic_xchg_i64, 0, fal= se) =20 +typedef void Atomic128ThreeOpFn(TCGv_i128, TCGv_i64, TCGv_i128, TCGArg, Me= mOp); + +static bool do_atomic128_ld(DisasContext *s, arg_atomic128 *a, + Atomic128ThreeOpFn *fn, bool invert) +{ + MemOp mop; + int rlo, rhi; + TCGv_i64 clean_addr, tlo, thi; + TCGv_i128 t16; + + if (a->rt =3D=3D 31 || a->rt2 =3D=3D 31 || a->rt =3D=3D a->rt2) { + return false; + } + if (a->rn =3D=3D 31) { + gen_check_sp_alignment(s); + } + mop =3D check_atomic_align(s, a->rn, MO_128); + clean_addr =3D gen_mte_check1(s, cpu_reg_sp(s, a->rn), false, + a->rn !=3D 31, mop); + + rlo =3D (s->be_data =3D=3D MO_LE ? a->rt : a->rt2); + rhi =3D (s->be_data =3D=3D MO_LE ? a->rt2 : a->rt); + + tlo =3D read_cpu_reg(s, rlo, true); + thi =3D read_cpu_reg(s, rhi, true); + if (invert) { + tcg_gen_not_i64(tlo, tlo); + tcg_gen_not_i64(thi, thi); + } + /* + * The tcg atomic primitives are all full barriers. Therefore we + * can ignore the Acquire and Release bits of this instruction. + */ + t16 =3D tcg_temp_new_i128(); + tcg_gen_concat_i64_i128(t16, tlo, thi); + + fn(t16, clean_addr, t16, get_mem_index(s), mop); + + tcg_gen_extr_i128_i64(cpu_reg(s, rlo), cpu_reg(s, rhi), t16); + return true; +} + +TRANS_FEAT(LDCLRP, aa64_lse128, do_atomic128_ld, + a, tcg_gen_atomic_fetch_and_i128, true) +TRANS_FEAT(LDSETP, aa64_lse128, do_atomic128_ld, + a, tcg_gen_atomic_fetch_or_i128, false) +TRANS_FEAT(SWPP, aa64_lse128, do_atomic128_ld, + a, tcg_gen_atomic_xchg_i128, false) + static bool trans_LDAPR(DisasContext *s, arg_LDAPR *a) { bool iss_sf =3D ldst_iss_sf(a->sz, false, false); --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756380971; cv=none; d=zohomail.com; s=zohoarc; b=fJbJEhG48dZ49bhGr6//y0iqC+Z48LephZ49S3KD4K9pDKSKJbfkuObyq5zcb03fB7mGVf6c/GCDsiIBON+rWM0PayTMrCY+BdObfAr21sOnVqQ6SMiGv8kURTsaF1EWmMVw6i/zCchGX7F9zUgSiCYhJbRuCC2avp6mLUEsEO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756380971; h=Content-Transfer-Encoding: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:Cc; bh=+iibDeZh9Q26h4uiIWhGZyfyeeD8dI+3eoknboruTG8=; b=jBhiPS0aLuKz8kcoOYHg0X8jYPLeW7WKORVzOkYB4lMcfHuipxySs7Tppz1YDe7H8WeOG2go+mbi0jdh+SxRBtj60YC9dyodLRSRuF7LuY2qqnAa3W99EjE4QfQE7H/osaBDn9NMZZ94N98SynO2miuPQhJsOoeT+hYkKIgAQiU= 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 1756380971638338.19329911656644; Thu, 28 Aug 2025 04:36:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urauj-0004Sm-2Q; Thu, 28 Aug 2025 07:35: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 1urauM-0003hO-Sa for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:14 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauK-00066U-UX for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:10 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-45a1b065d59so5403325e9.1 for ; Thu, 28 Aug 2025 04:35:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.35.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380907; x=1756985707; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+iibDeZh9Q26h4uiIWhGZyfyeeD8dI+3eoknboruTG8=; b=eUZ4Oixo6oDLCqWSPmFgC1YvrjS2hgzD6EwMs7vziDuRZaDp9Tsavh32LATWFFQb2c 5j/wPNghLkdacszuN27gJTqw5rLheQnZ2WaHmse6WJJXPJC/TKiKP4G2BnLkHG4B/bdC rtHZM+r24CHzeCv4/1Bg4YrOBI18YULdy9xv7s+Mhxlld3Wqow/CfpVrURX7OQQ6o97J acV30r2j3EwqLJuIMcxqar0pLqkv8GaCLMJCdrrIVRbdZHa0Upv5MFp2XqtiXsKkMRxn +7so59No/EYy34sdcy1fvxUO+TYcjR15D1OFpn0JhNc5jtYpMHRV0Z5tX7U0M1YVYFek yLdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380907; x=1756985707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+iibDeZh9Q26h4uiIWhGZyfyeeD8dI+3eoknboruTG8=; b=Lr7Znoj7DRIYu+8kkHyQN/l5r+32X8A6yMV7/WFmFop4OZCKl6nAwoxLAhZ9Fa7X8S LsBOejp8uymgF2RK/GwOh0hRY2+GR4gGDyN8fEgdXYlFKM0zVHMJA2z3P264EHh+RpSf RKyb1X9nzqYlmisIwNDrH6k6qw2z+iQHJeu63QSJCHigrAAmNOiYw0NQI2iM04EtRJuY lQJYXzHEk6Qj2aFX67gPoGl7Wcx7xd8brc96wJJkuPB5BnQa9KNC7/7Oj5b1eho0TOKK qNNBU8LNUz3PgFQ7PxHDqBLANW3Hoqtd6ksofDiBcAaHnv8ZcyVAhBusqxts1ToOBHO7 qgQw== X-Gm-Message-State: AOJu0Yyj4TrH9ZOXx5A3aXcELJCkIzRvuDwJg7PNmqhDB/BESSjSaS06 a0NgYYgpgk28aHOorb9Jg+ycXydxsiakGXJpKFb4e/lksefbXNerlDwJy98xestcCKgL1m/SHDG jvMsH X-Gm-Gg: ASbGncv1DlaP8SCmzNLdoCcwMM0ZtAOO5FbA9TK9gDmggEjUR6V6OHoAJkBw8Ohx63l CTWbYwANZN9OkxVBrHyt4HeDxY281EOG98rO5djOzhkQS+GTmm+0wWVWO+Kr9t5CThPuS/BtsXl nlNU3Fd611DD+15TDZev9gxvzSSJHr6lInfeBIjl/pF0kDAM1exPTJ94JwOh8dmYNrVuxIqvyI+ Wg/r6ywI3pU8P+TeKuYd11wSrkgdikzanhY25XwkLX+nSflSGI1rS9k9Gd4g6QI1TMEEJ1GWkHR 4b/RBVrE09Qeco56WBRaBpI+jYyzScwe19iQSnxocmB56uaF3jVhLpv/4hWTULw29+prmpBS7MR YXmSlxSeYiS+O0FZtZl2Q7EH67pKk X-Google-Smtp-Source: AGHT+IFtlg2qqPip0bUM+8An8mFv53/fw63gMNjBi80oUK+1V4poFQx4/JLLYDg/vI1meZCoByeQow== X-Received: by 2002:a05:600c:1c0f:b0:45b:6365:7957 with SMTP id 5b1f17b1804b1-45b68bc7a0bmr74390865e9.33.1756380906995; Thu, 28 Aug 2025 04:35:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 31/32] target/arm: Enable FEAT_LSE128 for -cpu max Date: Thu, 28 Aug 2025 12:34:28 +0100 Message-ID: <20250828113430.3214314-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-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::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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: 1756380972246116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20250815122653.701782-8-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- docs/system/arm/emulation.rst | 1 + linux-user/aarch64/elfload.c | 1 + target/arm/tcg/cpu64.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index b12f013b4fc..4e8aca8b5d5 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -89,6 +89,7 @@ the following architecture extensions: - FEAT_LRCPC2 (Load-acquire RCpc instructions v2) - FEAT_LSE (Large System Extensions) - FEAT_LSE2 (Large System Extensions v2) +- FEAT_LSE128 (128-bit Atomics) - FEAT_LVA (Large Virtual Address space) - FEAT_MixedEnd (Mixed-endian support) - FEAT_MixedEndEL0 (Mixed-endian support at EL0) diff --git a/linux-user/aarch64/elfload.c b/linux-user/aarch64/elfload.c index 0bec43d8c38..ec81363c920 100644 --- a/linux-user/aarch64/elfload.c +++ b/linux-user/aarch64/elfload.c @@ -213,6 +213,7 @@ abi_ulong get_elf_hwcap2(CPUState *cs) GET_FEATURE_ID(aa64_sme_f16f16, ARM_HWCAP2_A64_SME_F16F16); GET_FEATURE_ID(aa64_sve_b16b16, ARM_HWCAP2_A64_SVE_B16B16); GET_FEATURE_ID(aa64_cssc, ARM_HWCAP2_A64_CSSC); + GET_FEATURE_ID(aa64_lse128, ARM_HWCAP2_A64_LSE128); =20 return hwcaps; } diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index eaf8846a6a5..b8b1981e702 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1145,7 +1145,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ t =3D FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); /* FEAT_CRC32 */ - t =3D FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */ + t =3D FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 3); /* FEAT_LSE, FEAT_LSE1= 28 */ t =3D FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */ t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */ t =3D FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); /* FEAT_SM3 */ --=20 2.43.0 From nobody Sun Sep 28 16:28:05 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=1756381217; cv=none; d=zohomail.com; s=zohoarc; b=Ch8J0f9znZ62fO71H10w8dLoZZxyoT/nnmYKF/NF+QeQBte32OFh1dpWU7ghf/hkTy5n99kW0uoFYIjiD2aKsKUDE4YeHOjQCVEQxDTY5F2II0OSCICLIekO2snYq4e0SMg3wLm6udc/BlI3bnuyy3jx5rFY+fRE70n6C0Ym9N4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756381217; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=+JXna42BUY+PHZn26MLXt9OfmKpXLIHJyS7UYzTkIbI=; b=RSrWLaBTG8F8zIwYkg+m0834QBpUa/CTPjj5G0lPCwBamQSrXXsU72VW1WgS2sC4RKAyLVyNZFS+2C61ujBtx/zGkfIl+YI69P+txkQ2vxETiWMrTZ+DRJ43PvjE9Ns496M0FQxAwPPvShDqFtwDFSdF3PmRMWQWSvaRnPmaNpc= 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 17563812174561020.3118410068519; Thu, 28 Aug 2025 04:40:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uraug-0004Fu-5u; Thu, 28 Aug 2025 07:35:30 -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 1urauO-0003hf-FJ for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:15 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urauL-00066u-K8 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 07:35:11 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-45b7d497ab9so1637455e9.0 for ; Thu, 28 Aug 2025 04:35:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b79799c33sm28691015e9.5.2025.08.28.04.35.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 04:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756380908; x=1756985708; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+JXna42BUY+PHZn26MLXt9OfmKpXLIHJyS7UYzTkIbI=; b=t3v5Zqw5hvBWjYgHt2RidzfjlnEpV69wNX6UGIhJ9wEU5NQjTAgxAwUEnINf/vR1Oc gWSBgph8YSImu5wvQwEoYM8xqg1wD06fuuaXpFyH4BD5FZ37IAX1/led1ANa8Oi8TzJ2 uGaAMEmw9deQ5lXm7KmeZs82DQH3WSKVsI2ChK2E4sk+ZVkhGEgeLnIjaSxUkCbXHJId hKvzpSGDTAzzDqwyOFpbwiFRitw0fhdshL88DofOf5eXaPjUYCHl2Ozniz7d1qeptGfi bj1MzvzMTC0bWQnQT/Glf0vjcfQLHS6S1z/tJAqTlmVDd+vTrIyX0YfxyQ8BAEweF5M1 YOfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756380908; x=1756985708; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+JXna42BUY+PHZn26MLXt9OfmKpXLIHJyS7UYzTkIbI=; b=F/Vb3GBubKgJ1rqr+5frKW3lEe2HlPTvXVlepM7EU0WRwBpjb8dqrN6ekKLj474x2P HyFw3Y6yhoIqADwotcaRm/dLVsjg+lwi11aIYFtCyxpTZ4WYiXBRr4WdN6rozcr0RdQr dzrU7Nrlv2R5Szq9MsqRDPNGmIjbxA6z3vu7YuigDQo6ek17kCAp5fEhtZSrmIBgNSvk ddSYjaU6hHakv3ul4PkuGIYAtjWL1wlUuLEMAaYMoUgUPZYSsqcHA05c6Nq5N9ZJLWJb xDkIMnnBum9F03hIuavwbmyc8gnwpZDYpLP+9HjjJ1UHYG76Kv2ITDIN58561ER5dg0M ENfQ== X-Gm-Message-State: AOJu0YxpxtKJyVM1iCZcAmKB7AI4bAWYxk6mkzT/XreIHKgVKx8fEk53 mTNUFJVfwjF6oiQ5u/buYaIzESPlbBFexxZg3pAzOx34v/tKU0BXxfYH1ZK/ToEsO1QX2Gh0e5f Eon8g X-Gm-Gg: ASbGnctK2I07qssCC3YHMcDBlxdTwJ4CEUYWPZ4nnsMJ5LXVpPnwhObimKHl+sR3W92 E34BXwpZGYa4UucLqMQ20CGx3EsMLg25e3asw01FB0b03I5IoJI1tLbLVKlmuhb/nHC0iTufS6Z DbLJ7GXw2/2w0z2frBwYBy81enB80CZMLNFi61ZKSBOpSII2qaXVudVCZzcYbjdeBFMxrypZHEN FJz71XVj+J/3ygj01rZz7TbKjC3Ek3WgbjpV1WvnstMR/Zzo71e31gNF+v8NC6p5l93NDZvoCrb wNDjo1PIojMYch86iUQCdYwMz1RCCJPUmOleafWlCl7+RqHkWeKFQsTLq5hegGn4/L9im+zzwrM FgeyUQda2lSxVYgYJmcJ8uIV2BMtG X-Google-Smtp-Source: AGHT+IH+Mt5HgjNrIiJ9CXJsxcGEiHIWTrDKtn2bd2Vqhof5yQFUZg8RujOe61lbb4msO4OBgnLZTQ== X-Received: by 2002:a05:600c:a46:b0:456:1bca:7faf with SMTP id 5b1f17b1804b1-45b517ad840mr273802455e9.16.1756380907941; Thu, 28 Aug 2025 04:35:07 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 32/32] hw/arm/stm32f205_soc: Don't leak TYPE_OR_IRQ objects Date: Thu, 28 Aug 2025 12:34:29 +0100 Message-ID: <20250828113430.3214314-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828113430.3214314-1-peter.maydell@linaro.org> References: <20250828113430.3214314-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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: 1756381219928124100 In stm32f250_soc_initfn() we mostly use the standard pattern for child objects of calling object_initialize_child(). However for s->adc_irqs we call object_new() and then later qdev_realize(), and we never unref the object on deinit. This causes a leak, detected by ASAN on the device-introspect-test: Indirect leak of 10 byte(s) in 1 object(s) allocated from: #0 0x5b9fc4789de3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu= /build/arm-asan/qemu-system-arm+0x21f1de3) (BuildId: 267a2619a026ed91c78a07= b1eb2ef15381538efe) #1 0x740de3f28b09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0= x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75) #2 0x740de3f3e4d8 in g_strdup (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0= x784d8) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75) #3 0x5b9fc70159e1 in g_strdup_inline /usr/include/glib-2.0/glib/gstrfun= cs.h:321:10 #4 0x5b9fc70159e1 in object_property_try_add /mnt/nvmedisk/linaro/qemu-= from-laptop/qemu/build/arm-asan/../../qom/object.c:1276:18 #5 0x5b9fc7015f94 in object_property_add /mnt/nvmedisk/linaro/qemu-from= -laptop/qemu/build/arm-asan/../../qom/object.c:1294:12 #6 0x5b9fc701b900 in object_add_link_prop /mnt/nvmedisk/linaro/qemu-fro= m-laptop/qemu/build/arm-asan/../../qom/object.c:2021:10 #7 0x5b9fc701b3fc in object_property_add_link /mnt/nvmedisk/linaro/qemu= -from-laptop/qemu/build/arm-asan/../../qom/object.c:2037:12 #8 0x5b9fc4c299fb in qdev_init_gpio_out_named /mnt/nvmedisk/linaro/qemu= -from-laptop/qemu/build/arm-asan/../../hw/core/gpio.c:90:9 #9 0x5b9fc4c29b26 in qdev_init_gpio_out /mnt/nvmedisk/linaro/qemu-from-= laptop/qemu/build/arm-asan/../../hw/core/gpio.c:101:5 #10 0x5b9fc4c0f77a in or_irq_init /mnt/nvmedisk/linaro/qemu-from-laptop= /qemu/build/arm-asan/../../hw/core/or-irq.c:70:5 #11 0x5b9fc70257e1 in object_init_with_type /mnt/nvmedisk/linaro/qemu-f= rom-laptop/qemu/build/arm-asan/../../qom/object.c:428:9 #12 0x5b9fc700cd4b in object_initialize_with_type /mnt/nvmedisk/linaro/= qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:570:5 #13 0x5b9fc700e66d in object_new_with_type /mnt/nvmedisk/linaro/qemu-fr= om-laptop/qemu/build/arm-asan/../../qom/object.c:774:5 #14 0x5b9fc700e750 in object_new /mnt/nvmedisk/linaro/qemu-from-laptop/= qemu/build/arm-asan/../../qom/object.c:789:12 #15 0x5b9fc68b2162 in stm32f205_soc_initfn /mnt/nvmedisk/linaro/qemu-fr= om-laptop/qemu/build/arm-asan/../../hw/arm/stm32f205_soc.c:69:26 Switch to using object_initialize_child() like all our other child objects for this SoC object. Cc: qemu-stable@nongnu.org Fixes: b63041c8f6b ("STM32F205: Connect the ADC devices") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20250821154229.2417453-1-peter.maydell@linaro.org --- include/hw/arm/stm32f205_soc.h | 2 +- hw/arm/stm32f205_soc.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h index 4f4c8bbebc1..46eda3403a9 100644 --- a/include/hw/arm/stm32f205_soc.h +++ b/include/hw/arm/stm32f205_soc.h @@ -59,7 +59,7 @@ struct STM32F205State { STM32F2XXADCState adc[STM_NUM_ADCS]; STM32F2XXSPIState spi[STM_NUM_SPIS]; =20 - OrIRQState *adc_irqs; + OrIRQState adc_irqs; =20 MemoryRegion sram; MemoryRegion flash; diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c index 229af7fb108..e3c7203c6e7 100644 --- a/hw/arm/stm32f205_soc.c +++ b/hw/arm/stm32f205_soc.c @@ -66,7 +66,7 @@ static void stm32f205_soc_initfn(Object *obj) TYPE_STM32F2XX_TIMER); } =20 - s->adc_irqs =3D OR_IRQ(object_new(TYPE_OR_IRQ)); + object_initialize_child(obj, "adc-irq-orgate", &s->adc_irqs, TYPE_OR_I= RQ); =20 for (i =3D 0; i < STM_NUM_ADCS; i++) { object_initialize_child(obj, "adc[*]", &s->adc[i], TYPE_STM32F2XX_= ADC); @@ -171,12 +171,12 @@ static void stm32f205_soc_realize(DeviceState *dev_so= c, Error **errp) } =20 /* ADC 1 to 3 */ - object_property_set_int(OBJECT(s->adc_irqs), "num-lines", STM_NUM_ADCS, + object_property_set_int(OBJECT(&s->adc_irqs), "num-lines", STM_NUM_ADC= S, &error_abort); - if (!qdev_realize(DEVICE(s->adc_irqs), NULL, errp)) { + if (!qdev_realize(DEVICE(&s->adc_irqs), NULL, errp)) { return; } - qdev_connect_gpio_out(DEVICE(s->adc_irqs), 0, + qdev_connect_gpio_out(DEVICE(&s->adc_irqs), 0, qdev_get_gpio_in(armv7m, ADC_IRQ)); =20 for (i =3D 0; i < STM_NUM_ADCS; i++) { @@ -187,7 +187,7 @@ static void stm32f205_soc_realize(DeviceState *dev_soc,= Error **errp) busdev =3D SYS_BUS_DEVICE(dev); sysbus_mmio_map(busdev, 0, adc_addr[i]); sysbus_connect_irq(busdev, 0, - qdev_get_gpio_in(DEVICE(s->adc_irqs), i)); + qdev_get_gpio_in(DEVICE(&s->adc_irqs), i)); } =20 /* SPI 1 and 2 */ --=20 2.43.0