Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2181733ybi; Thu, 20 Jun 2019 10:24:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV2S5kQGrERq04qMvqjb1ivHunYm5aDCbAROX7d0RuzYwAj+kBGrv9CbAGJi9HzoLKuew0 X-Received: by 2002:a63:1b26:: with SMTP id b38mr14106111pgb.257.1561051473863; Thu, 20 Jun 2019 10:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561051473; cv=none; d=google.com; s=arc-20160816; b=tpJOt9Tbb4cxOUFJbZpGtOEeao6h7sBJCnOq2fkISRhX0H/WOpwttIlTaIGxcY/xgn jCKDg5AmBb8F5Gh/j2nT/xpTJ9BDu7NDSRLtvhJiY7L54qh51ca3F8ONI99lnz22ufpE ePmRa/0FeaVBFm0zYNqrYKLSj/eoFkoqhOODlEkGErAxUCN+C78VSbx7WQkYENcXxRkh 0PfU5fn5DORBYTig1lAqpaYMS1LdV4tf2j8vSD66ITT6F6pnV+2RkmhqJ3Q745GdlQ6H jQMb8d0RrhtaYjXWZhFPRVlSVxbIw5s+wJOrK0PFQTGgTMbOobCzKGFCRlOURC1yqIAM wXMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iCSzZqLsrl4SZGgGSimNBkQcdOEuLjaMwS/hhvVK5Fk=; b=JxV7Bsl/tZjdZTGfDAH8XIpm3If+SkDEWXyDiRUuFqf+o+7BLzT7K7pQ6+wMxKQNoH DRkvY4sYClUmCTao0k+DiKY4xDzPciUD1lyYxbFQ8xTnPVqplc2aL9b4T1Go6CyI4enJ pssIGO8H+mQNIFQSwb6bAnWQZF/gmKR6sFQsw3VTqsoRSwfK2FTU29agM0UWSqG7xve0 EKycWilqFnTrf+qUOtbeWP/GJLAfdWge8dDLB05GlpSBV59cFOvjXFNY0RsxQjTGQKCn dy0fybvOu8XjOS/SBu5IxLGb94Emq4o/cNW6DbnbtFPlt6w4GNbgKVkoHP6gq0ykd0vC llfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EPsioJ5w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si320434pjl.60.2019.06.20.10.24.18; Thu, 20 Jun 2019 10:24:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EPsioJ5w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732305AbfFTRXu (ORCPT + 99 others); Thu, 20 Jun 2019 13:23:50 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52640 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732192AbfFTRXU (ORCPT ); Thu, 20 Jun 2019 13:23:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=iCSzZqLsrl4SZGgGSimNBkQcdOEuLjaMwS/hhvVK5Fk=; b=EPsioJ5wGUTTkgGp6YkE8sMWez ogV3xkkjy8zucX2C06wc6WfyPApPn5Cbu7jEnmlE13J9iAD8VTPZlzVO82T0ZGqgO0GQWBZlp8OO6 AyZlUDT98rMURZOxDDhC/D6cLVeOgiL/C3l7XWM25289OESB1GsO55Fl1j6aEL6BEXWlbK4OQqkXB bpHmRA1/Xb1GzcZ/jzRjmWQi76omRZ4yi9xlha9JR7GlurcioUHaOzqQJiQNmSZ5RtaHrZNcCZJze KH7EkSWUzpSH+YIULKpCFX8Pm0jfrCGDdAhLgctmUvWGC1FUqHLvv3F9XIk3tLQ+zU77dPjzmYmEv GDRfFZSQ==; Received: from [177.97.20.138] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1he0mM-0008S4-Ar; Thu, 20 Jun 2019 17:23:18 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1he0mK-0000Dx-1S; Thu, 20 Jun 2019 14:23:16 -0300 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Greg Kroah-Hartman , Alexey Budankov , "Darrick J. Wong" , Changbin Du Subject: [PATCH v2 20/22] docs: admin-guide, x86: add a features list Date: Thu, 20 Jun 2019 14:23:12 -0300 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a feature list matrix at the admin-guide and a x86-specific feature list to the respective Kernel books. Signed-off-by: Mauro Carvalho Chehab --- Documentation/admin-guide/features.rst | 3 + Documentation/admin-guide/index.rst | 1 + Documentation/conf.py | 2 +- Documentation/sphinx/kernel_feat.py | 169 +++++++++++++++++++++++++ Documentation/x86/features.rst | 3 + Documentation/x86/index.rst | 1 + 6 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/features.rst create mode 100644 Documentation/sphinx/kernel_feat.py create mode 100644 Documentation/x86/features.rst diff --git a/Documentation/admin-guide/features.rst b/Documentation/admin-guide/features.rst new file mode 100644 index 000000000000..8c167082a84f --- /dev/null +++ b/Documentation/admin-guide/features.rst @@ -0,0 +1,3 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. kernel-feat:: $srctree/Documentation/features diff --git a/Documentation/admin-guide/index.rst b/Documentation/admin-guide/index.rst index 20c3020fd73c..14c8464f6ca9 100644 --- a/Documentation/admin-guide/index.rst +++ b/Documentation/admin-guide/index.rst @@ -17,6 +17,7 @@ etc. kernel-parameters devices abi + features This section describes CPU vulnerabilities and their mitigations. diff --git a/Documentation/conf.py b/Documentation/conf.py index 598256fb5c98..a0ef76ce5615 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -34,7 +34,7 @@ needs_sphinx = '1.3' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain', 'kfigure', 'sphinx.ext.ifconfig', 'kernel_abi'] +extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain', 'kfigure', 'sphinx.ext.ifconfig', 'kernel_abi', 'kernel_feat'] # The name of the math extension changed on Sphinx 1.4 if (major == 1 and minor > 3) or (major > 1): diff --git a/Documentation/sphinx/kernel_feat.py b/Documentation/sphinx/kernel_feat.py new file mode 100644 index 000000000000..2fee04f1dedd --- /dev/null +++ b/Documentation/sphinx/kernel_feat.py @@ -0,0 +1,169 @@ +# coding=utf-8 +# SPDX-License-Identifier: GPL-2.0 +# +u""" + kernel-feat + ~~~~~~~~~~~ + + Implementation of the ``kernel-feat`` reST-directive. + + :copyright: Copyright (C) 2016 Markus Heiser + :copyright: Copyright (C) 2016-2019 Mauro Carvalho Chehab + :maintained-by: Mauro Carvalho Chehab + :license: GPL Version 2, June 1991 see Linux/COPYING for details. + + The ``kernel-feat`` (:py:class:`KernelFeat`) directive calls the + scripts/get_feat.pl script to parse the Kernel ABI files. + + Overview of directive's argument and options. + + .. code-block:: rst + + .. kernel-feat:: + :debug: + + The argument ```` is required. It contains the + location of the ABI files to be parsed. + + ``debug`` + Inserts a code-block with the *raw* reST. Sometimes it is helpful to see + what reST is generated. + +""" + +import codecs +import os +import subprocess +import sys + +from os import path + +from docutils import nodes, statemachine +from docutils.statemachine import ViewList +from docutils.parsers.rst import directives, Directive +from docutils.utils.error_reporting import ErrorString + +# +# AutodocReporter is only good up to Sphinx 1.7 +# +import sphinx + +Use_SSI = sphinx.__version__[:3] >= '1.7' +if Use_SSI: + from sphinx.util.docutils import switch_source_input +else: + from sphinx.ext.autodoc import AutodocReporter + +__version__ = '1.0' + +def setup(app): + + app.add_directive("kernel-feat", KernelFeat) + return dict( + version = __version__ + , parallel_read_safe = True + , parallel_write_safe = True + ) + +class KernelFeat(Directive): + + u"""KernelFeat (``kernel-feat``) directive""" + + required_arguments = 1 + optional_arguments = 2 + has_content = False + final_argument_whitespace = True + + option_spec = { + "debug" : directives.flag + } + + def warn(self, message, **replace): + replace["fname"] = self.state.document.current_source + replace["line_no"] = replace.get("line_no", self.lineno) + message = ("%(fname)s:%(line_no)s: [kernel-feat WARN] : " + message) % replace + self.state.document.settings.env.app.warn(message, prefix="") + + def run(self): + + doc = self.state.document + if not doc.settings.file_insertion_enabled: + raise self.warning("docutils: file insertion disabled") + + env = doc.settings.env + cwd = path.dirname(doc.current_source) + cmd = "get_feat.pl rest --dir " + cmd += self.arguments[0] + + if len(self.arguments) > 1: + cmd += " --arch " + self.arguments[1] + + srctree = path.abspath(os.environ["srctree"]) + + fname = cmd + + # extend PATH with $(srctree)/scripts + path_env = os.pathsep.join([ + srctree + os.sep + "scripts", + os.environ["PATH"] + ]) + shell_env = os.environ.copy() + shell_env["PATH"] = path_env + shell_env["srctree"] = srctree + + lines = self.runCmd(cmd, shell=True, cwd=cwd, env=shell_env) + nodeList = self.nestedParse(lines, fname) + return nodeList + + def runCmd(self, cmd, **kwargs): + u"""Run command ``cmd`` and return it's stdout as unicode.""" + + try: + proc = subprocess.Popen( + cmd + , stdout = subprocess.PIPE + , stderr = subprocess.PIPE + , **kwargs + ) + out, err = proc.communicate() + + out, err = codecs.decode(out, 'utf-8'), codecs.decode(err, 'utf-8') + + if proc.returncode != 0: + raise self.severe( + u"command '%s' failed with return code %d" + % (cmd, proc.returncode) + ) + except OSError as exc: + raise self.severe(u"problems with '%s' directive: %s." + % (self.name, ErrorString(exc))) + return out + + def nestedParse(self, lines, fname): + content = ViewList() + node = nodes.section() + + if "debug" in self.options: + code_block = "\n\n.. code-block:: rst\n :linenos:\n" + for l in lines.split("\n"): + code_block += "\n " + l + lines = code_block + "\n\n" + + for c, l in enumerate(lines.split("\n")): + content.append(l, fname, c) + + buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter + + if Use_SSI: + with switch_source_input(self.state, content): + self.state.nested_parse(content, 0, node, match_titles=1) + else: + self.state.memo.title_styles = [] + self.state.memo.section_level = 0 + self.state.memo.reporter = AutodocReporter(content, self.state.memo.reporter) + try: + self.state.nested_parse(content, 0, node, match_titles=1) + finally: + self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf + + return node.children diff --git a/Documentation/x86/features.rst b/Documentation/x86/features.rst new file mode 100644 index 000000000000..b663f15053ce --- /dev/null +++ b/Documentation/x86/features.rst @@ -0,0 +1,3 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. kernel-feat:: $srctree/Documentation/features x86 diff --git a/Documentation/x86/index.rst b/Documentation/x86/index.rst index ae36fc5fc649..ed42c8c9154d 100644 --- a/Documentation/x86/index.rst +++ b/Documentation/x86/index.rst @@ -29,3 +29,4 @@ x86-specific Documentation usb-legacy-support i386/index x86_64/index + features -- 2.21.0