Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6372646rdb; Mon, 1 Jan 2024 22:17:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpa6DKidMXj3PkzYh4qfW1V0qMrE2n+AWOKOGu/7NffDQfsPiH1/V2OHoNtkOC1b51uS4e X-Received: by 2002:ad4:5b8e:0:b0:67c:cfba:5098 with SMTP id 14-20020ad45b8e000000b0067ccfba5098mr28316213qvp.43.1704176235398; Mon, 01 Jan 2024 22:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704176235; cv=none; d=google.com; s=arc-20160816; b=CIx5vOdVCz13QvHhovn9GOi3yzDls4tP6J2uY6n/8MkgStvQtUnO5vo5VPfoIh5SnK u9rid1vPuZOKhAVx/k96W1+zlK0gpspGDE5rkpgsq4z658ydkJqhQJUDjQ4qoIQ3+NUC f8/AaYlIx2BXIIp0EL0FvA2jiX94Q4xKX3cOJIPKVVbU5wMpNlXp4nEcmvy0DJhAELOD yVci+OgZZb+uiXI8gpMAAMj974ep9Uujj0IjA7gkHqTwra04s+oqzmF0AuDk87Up95wb U3x5WhorBXP3VeQCHHc47/+afsgAeR+9qXRctlVtocuoNrPaoUW+KBBWKXOqt6OY2Wmw O4ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=YpIRPyFf90I4Z3IJEoDmkRte1e+hElppoVNgHQl0hWA=; fh=SppvFXHx7G5ziY3I5z/Y2LgtAdv4ksb+OiP6jkmi1VI=; b=FseHrS8yt9TtYyVNhATOwks7uuODY9TzIZbk8XzNJrKywX81jh2kFSMZjdprxnyD0Q I6SLPA10niTvpPTTftzIuaiUS9pjRPuAojI+VC15y5brnkzwzRoctb+oYb3DqTf6I4rt t9LH+/Vp8j6MlNMRkEOPJYs/6aTHpKAIV3SJqqfWCQJqy2MqAYKBw099Dgpu0EESMd31 NFET8B9Y0St1tPr3oUtAjXH1MWMOIiMmh5NSRqL4dhDoDDkjrlrkMq/xJ2Ukjz7L1svM 70AoWzoekmouoX5xqrMa8mRy6unFI3FPLWt5BCcS/n5ks9IdVpMBEfm776FEbeeyXYlP 47JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=sO0SmGJI; spf=pass (google.com: domain of linux-kernel+bounces-14079-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14079-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c25-20020a05620a269900b00781b4f3d5aesi5484571qkp.25.2024.01.01.22.17.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 22:17:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14079-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=sO0SmGJI; spf=pass (google.com: domain of linux-kernel+bounces-14079-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14079-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D3E581C2137B for ; Tue, 2 Jan 2024 06:17:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5981468C; Tue, 2 Jan 2024 06:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="sO0SmGJI" X-Original-To: linux-kernel@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 506182583; Tue, 2 Jan 2024 06:17:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=YpIRPyFf90I4Z3IJEoDmkRte1e+hElppoVNgHQl0hWA=; b=sO0SmGJIunwG0I7STeC1KWrsQn hyWznpREMw2uAcfZi44vGzWDRwznblH9ldUnCCXRZKpDKEK0hIdUAfzkGMsOGuHl/sS3h2ipnegKP dR4JCxF62Bk9J9tOjsqtz9JtkDFk7tpV83+EIx8u9fEg1wuyUCC/naInDcKuemnYmVYBc2I0eywSJ ZOxonysIIV4+WlqM3WIOLeB49zs/DFPhMih7gaMY38+GTzCvXWGPuHrinx6qY5STHKHr5qEFMNCdI U4MHZOe835i3yvO1Sqh0LckyhKGGkCH3D1htKtT89Qa9YXOeWVXQHm/7IDH/yCxyLMfym4svbxbi0 Gm8HLM4Q==; Received: from [50.53.46.231] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKY5F-007ALs-1T; Tue, 02 Jan 2024 06:17:01 +0000 From: Randy Dunlap To: linux-kernel@vger.kernel.org Cc: Randy Dunlap , Thomas Gleixner , x86@kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org Subject: [RFC PATCH] kernel-doc: handle X86 DEFINE_IDTENTRY() variants Date: Mon, 1 Jan 2024 22:17:00 -0800 Message-ID: <20240102061700.3807-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Teach scripts/kernel-doc to handle the various DEFINE_IDTENTRY*() flavors. This corrects 2 kernel-doc warnings: arch/x86/entry/common.c:211: warning: expecting prototype for int80_emulation(). Prototype was for DEFINE_IDTENTRY_RAW() instead arch/x86/kernel/apic/apic.c:2170: warning: expecting prototype for spurious_interrupt(). Prototype was for DEFINE_IDTENTRY_IRQ() instead The script uses 'uname -m' to determine if it is running on i386 or x86_64 or something else. It also uses "ARCH=" in the environment variables to allow for overriding the processed ARCH. Alternatively, we could remove the "/**" kernel-doc markers from those 2 functions. There are 60 uses of DEFINE_IDTENTRY*() that I see and only 2 of them have kernel-doc comments. Signed-off-by: Randy Dunlap Cc: Thomas Gleixner Cc: x86@kernel.org Cc: Jonathan Corbet Cc: linux-doc@vger.kernel.org --- scripts/kernel-doc | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff -- a/scripts/kernel-doc b/scripts/kernel-doc --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -128,6 +128,7 @@ if ($#ARGV == -1) { my $kernelversion; my ($sphinx_major, $sphinx_minor, $sphinx_patch); +my ($arch, $arch_is_x86, $arch_x86_64); my $dohighlight = ""; @@ -439,6 +440,31 @@ sub get_kernel_version() { return $version; } +# get the environment ARCH and x86 flavor +sub get_arch() { + + my $uname = `uname -m`; + chomp($uname); + $uname =~ s/i.86/i386/; + if ($uname eq "x86") { + $uname = "x86_64"; + } + + # allow ENV ARCH to override uname -m + if (defined($ENV{'ARCH'})) { + $arch = $ENV{'ARCH'}; + if ($arch eq "i386" || $arch eq "x86_64") { + # use that + } else { + $arch = $uname; + } + } else { + $arch = $uname; + } + $arch_is_x86 = ($arch eq "i386") || ($arch eq "x86_64"); + $arch_x86_64 = $arch eq "x86_64"; +} + # sub print_lineno { my $lineno = shift; @@ -1867,6 +1893,62 @@ sub tracepoint_munge($) { } } +# idtentry_munge() is only for x86 and can be different for i386 vs. x86_64. +sub idtentry_munge($) { + my $file = shift; + my $idtentryname = ""; + my $idtentryargs = "void"; + $prototype =~ s/^\s+|\s+$//g; # remove both leading and trailing whitespace + + if ($prototype =~ m/DEFINE_IDTENTRY\((.*?)\)/) { + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_ERRORCODE\((.*?)\)/) { + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs, unsigned long error_code"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_RAW\((.*?)\)/) { + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_RAW_ERRORCODE\((.*?)\)/) { + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs, unsigned long error_code"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_IRQ\((.*?)\)/) { + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs, u32 vector"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_SYSVEC\((.*?)\)/) { + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_SYSVEC_SIMPLE\((.*?)\)/) { + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_IST\((.*?)\)/) { # same as _RAW + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_NOIST\((.*?)\)/) { # same as _RAW + $idtentryname = "noist_" . $1; + $idtentryargs = "struct pt_regs *regs"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_DF\((.*?)\)/) { # same as _RAW_ERRORCODE + $idtentryname = $1; + $idtentryargs = $arch_x86_64 ? "struct pt_regs *regs, unsigned long error_code" + : "struct pt_regs *regs, unsigned long error_code, unsigned long address"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_VC_KERNEL\((.*?)\)/) { # same as _RAW_ERRORCODE + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs, unsigned long error_code"; + } elsif ($prototype =~ m/DEFINE_IDTENTRY_VC_USER\((.*?)\)/) { # same as _RAW_ERRORCODE + $idtentryname = $1; + $idtentryargs = "struct pt_regs *regs, unsigned long error_code"; + } + + $idtentryname =~ s/^\s+//; #strip leading whitespace + if ($idtentryname eq "") { + emit_warning("${file}:$.", "Unrecognized IDTENTRY macro: \n". + "$prototype\n"); + } else { + $prototype = "void $idtentryname($idtentryargs)"; + $identifier = "$idtentryname"; + } +} + sub syscall_munge() { my $void = 0; @@ -1931,6 +2013,9 @@ sub process_proto_function($$) { { tracepoint_munge($file); } + if ($arch_is_x86 && $prototype =~ /DEFINE_IDTENTRY/) { + idtentry_munge($file); + } dump_function($prototype, $file); reset_state(); } @@ -2374,6 +2459,8 @@ if ($output_mode eq "rst") { $kernelversion = get_kernel_version(); +get_arch(); + # generate a sequence of code that will splice in highlighting information # using the s// operator. for (my $k = 0; $k < @highlights; $k++) {