get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/808354/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 808354,
    "url": "http://patchwork.ozlabs.org/api/patches/808354/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-imx/patch/1504198860-12951-19-git-send-email-Dave.Martin@arm.com/",
    "project": {
        "id": 19,
        "url": "http://patchwork.ozlabs.org/api/projects/19/?format=api",
        "name": "Linux IMX development",
        "link_name": "linux-imx",
        "list_id": "linux-imx-kernel.lists.patchwork.ozlabs.org",
        "list_email": "linux-imx-kernel@lists.patchwork.ozlabs.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1504198860-12951-19-git-send-email-Dave.Martin@arm.com>",
    "list_archive_url": null,
    "date": "2017-08-31T17:00:50",
    "name": "[v2,18/28] arm64/sve: Preserve SVE registers around EFI runtime service calls",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7c133b3476b737def643f24a737ca23e3ba2eba0",
    "submitter": {
        "id": 26612,
        "url": "http://patchwork.ozlabs.org/api/people/26612/?format=api",
        "name": "Dave Martin",
        "email": "Dave.Martin@arm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-imx/patch/1504198860-12951-19-git-send-email-Dave.Martin@arm.com/mbox/",
    "series": [
        {
            "id": 883,
            "url": "http://patchwork.ozlabs.org/api/series/883/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-imx/list/?series=883",
            "date": "2017-08-31T17:00:33",
            "name": "ARM Scalable Vector Extension (SVE)",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/883/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/808354/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/808354/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>",
        "X-Original-To": "incoming-imx@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming-imx@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"sBU5ZXZP\"; dkim-atps=neutral"
        ],
        "Received": [
            "from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjpkR5m80z9sD5\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 03:09:03 +1000 (AEST)",
            "from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnSxf-0005UF-Mg; Thu, 31 Aug 2017 17:08:59 +0000",
            "from foss.arm.com ([217.140.101.70])\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnSrD-0007an-NE for linux-arm-kernel@lists.infradead.org;\n\tThu, 31 Aug 2017 17:02:42 +0000",
            "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249])\n\tby usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9D77E1A09;\n\tThu, 31 Aug 2017 10:01:50 -0700 (PDT)",
            "from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com\n\t[10.72.51.249])\n\tby usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id\n\tF12673F58F; Thu, 31 Aug 2017 10:01:48 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=1VWcXSiTnUzuWb0OjHmb5hcaV00feyXuBy3oWfWltu0=;\n\tb=sBU5ZXZPPZOqMl\n\tkZ2enG0U/vw3LeqQ51LfRkFX5SwxPi35H2FCayn6DTUjAEuusaDzolkcYfICn4U60I7CSorHRuxmr\n\tmacOmdCg2lg4L9nM4MzaZjNB9PeVbYudYTVaENXevWBU6pflHhAlZa/fWBo/hMPioiM3dtpGOBf07\n\t1nZqlkq7haDxAftsW+1pqs5cGU7FfKsmuDReL4EBR9kqjJyi+JvkO2nZ7GEmddVt0dMb6BaBjozRU\n\tI5vht+rHIVr7+0Eh7SagQ+AUdpzlHcUYhWo9dgRg4TDV08sOtXlrlikWkD3nUVhErHrNEmx013YFI\n\tEQUZgiSgAjKBjJpymVDw==;",
        "From": "Dave Martin <Dave.Martin@arm.com>",
        "To": "linux-arm-kernel@lists.infradead.org",
        "Subject": "[PATCH v2 18/28] arm64/sve: Preserve SVE registers around EFI\n\truntime service calls",
        "Date": "Thu, 31 Aug 2017 18:00:50 +0100",
        "Message-Id": "<1504198860-12951-19-git-send-email-Dave.Martin@arm.com>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": "<1504198860-12951-1-git-send-email-Dave.Martin@arm.com>",
        "References": "<1504198860-12951-1-git-send-email-Dave.Martin@arm.com>",
        "MIME-Version": "1.0",
        "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ",
        "X-CRM114-CacheID": "sfid-20170831_100220_301183_A0DA5670 ",
        "X-CRM114-Status": "GOOD (  14.38  )",
        "X-Spam-Score": "-6.9 (------)",
        "X-Spam-Report": "SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-6.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/,\n\thigh trust [217.140.101.70 listed in list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]",
        "X-BeenThere": "linux-arm-kernel@lists.infradead.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.infradead.org/pipermail/linux-arm-kernel/>",
        "List-Post": "<mailto:linux-arm-kernel@lists.infradead.org>",
        "List-Help": "<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>",
        "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>",
        "Cc": "linux-arch@vger.kernel.org, libc-alpha@sourceware.org, Ard Biesheuvel\n\t<ard.biesheuvel@linaro.org>,  Szabolcs Nagy <szabolcs.nagy@arm.com>,\n\tCatalin Marinas\n\t<catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com>, Richard\n\tSandiford <richard.sandiford@arm.com>, =?utf-8?q?Alex_Benn=C3=A9e?=\n\t<alex.bennee@linaro.org>,  kvmarm@lists.cs.columbia.edu",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Sender": "\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>",
        "Errors-To": "linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org",
        "List-Id": "linux-imx-kernel.lists.patchwork.ozlabs.org"
    },
    "content": "The EFI runtime services ABI allows EFI to make free use of the\nFPSIMD registers during EFI runtime service calls, subject to the\ncallee-save requirements of the AArch64 procedure call standard.\n\nHowever, the SVE architecture allows upper bits of the SVE vector\nregisters to be zeroed as a side-effect of FPSIMD V-register\nwrites.  This means that the SVE vector registers must be saved in\ntheir entirety in order to avoid data loss: non-SVE-aware EFI\nimplementations cannot restore them correctly.\n\nThe non-IRQ case is already handled gracefully by\nkernel_neon_begin().  For the IRQ case, this patch allocates a\nsuitable per-CPU stash buffer for the full SVE register state and\nuses it to preserve the affected registers around EFI calls.  It is\ncurrently unclear how the EFI runtime services ABI will be\nclarified with respect to SVE, so it safest to assume that the\npredicate registers and FFR must be saved and restored too.\n\nNo attempt is made to restore the restore the vector length after\na call, for now.  It is deemed rather insane for EFI to change it,\nand contemporary EFI implementations certainly won't.\n\nSigned-off-by: Dave Martin <Dave.Martin@arm.com>\nCc: Ard Biesheuvel <ard.biesheuvel@linaro.org>\n\n---\n\nChanges since v1\n----------------\n\nRequested by Ard Biesheuvel:\n\n* Fix unbalanced ifelse bracing to conform to the kernel coding style.\n\n* Make efi_sve_state_used static.\n\nChanges related to Alex Bennée's comments:\n\n* Migrate away from magic numbers for SVE_VQ_BYTES.\n\nOther:\n\n* Rename sve_kernel_mode_neon_setup() to sve_efi_setup().\nThe EFI FPSIMD code is something semi-independent from kernel-mode NEON\nnow, so the \"neon\" in the names no longer really makes sense.\n\n* Make the EFI FPSIMD setup code dependent on CONFIG_EFI (it's not\nsupposed to work with CONFIG_EFI=n anyway).\n---\n arch/arm64/kernel/fpsimd.c | 60 +++++++++++++++++++++++++++++++++++++++++-----\n 1 file changed, 54 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c\nindex dd89acf..fff9fcf 100644\n--- a/arch/arm64/kernel/fpsimd.c\n+++ b/arch/arm64/kernel/fpsimd.c\n@@ -118,11 +118,13 @@ static int sve_default_vl = -1;\n int __ro_after_init sve_max_vl = -1;\n /* Set of available vector lengths, as vq_to_bit(vq): */\n static __ro_after_init DECLARE_BITMAP(sve_vq_map, SVE_VQ_MAX);\n+static void __percpu *efi_sve_state;\n \n #else /* ! CONFIG_ARM64_SVE */\n \n /* Dummy declaration for code that will be optimised out: */\n extern __ro_after_init DECLARE_BITMAP(sve_vq_map, SVE_VQ_MAX);\n+extern void __percpu *efi_sve_state;\n \n #endif /* ! CONFIG_ARM64_SVE */\n \n@@ -447,6 +449,23 @@ int sve_verify_vq_map(void)\n \treturn ret;\n }\n \n+static void __init sve_efi_setup(void)\n+{\n+\tif (!IS_ENABLED(CONFIG_EFI))\n+\t\treturn;\n+\n+\t/*\n+\t * alloc_percpu() warns and prints a backtrace if this goes wrong.\n+\t * This is evidence of a crippled system and we are returning void,\n+\t * so no attempt is made to handle this situation here.\n+\t */\n+\tBUG_ON(!sve_vl_valid(sve_max_vl));\n+\tefi_sve_state = __alloc_percpu(\n+\t\tSVE_SIG_REGS_SIZE(sve_vq_from_vl(sve_max_vl)), SVE_VQ_BYTES);\n+\tif (!efi_sve_state)\n+\t\tpanic(\"Cannot allocate percpu memory for EFI SVE save/restore\");\n+}\n+\n void __init sve_setup(void)\n {\n \tu64 zcr;\n@@ -482,6 +501,8 @@ void __init sve_setup(void)\n \t\tsve_max_vl);\n \tpr_info(\"SVE: default vector length %u bytes per vector\\n\",\n \t\tsve_default_vl);\n+\n+\tsve_efi_setup();\n }\n \n void fpsimd_release_thread(struct task_struct *dead_task)\n@@ -783,6 +804,7 @@ EXPORT_SYMBOL(kernel_neon_end);\n \n static DEFINE_PER_CPU(struct fpsimd_state, efi_fpsimd_state);\n static DEFINE_PER_CPU(bool, efi_fpsimd_state_used);\n+static DEFINE_PER_CPU(bool, efi_sve_state_used);\n \n /*\n  * EFI runtime services support functions\n@@ -808,10 +830,24 @@ void __efi_fpsimd_begin(void)\n \n \tWARN_ON(preemptible());\n \n-\tif (may_use_simd())\n+\tif (may_use_simd()) {\n \t\tkernel_neon_begin();\n-\telse {\n-\t\tfpsimd_save_state(this_cpu_ptr(&efi_fpsimd_state));\n+\t} else {\n+\t\t/*\n+\t\t * If !efi_sve_state, SVE can't be in use yet and doesn't need\n+\t\t * preserving:\n+\t\t */\n+\t\tif (system_supports_sve() && likely(efi_sve_state)) {\n+\t\t\tchar *sve_state = this_cpu_ptr(efi_sve_state);\n+\n+\t\t\t__this_cpu_write(efi_sve_state_used, true);\n+\n+\t\t\tsve_save_state(sve_state + sve_ffr_offset(sve_max_vl),\n+\t\t\t\t       &this_cpu_ptr(&efi_fpsimd_state)->fpsr);\n+\t\t} else {\n+\t\t\tfpsimd_save_state(this_cpu_ptr(&efi_fpsimd_state));\n+\t\t}\n+\n \t\t__this_cpu_write(efi_fpsimd_state_used, true);\n \t}\n }\n@@ -824,10 +860,22 @@ void __efi_fpsimd_end(void)\n \tif (!system_supports_fpsimd())\n \t\treturn;\n \n-\tif (__this_cpu_xchg(efi_fpsimd_state_used, false))\n-\t\tfpsimd_load_state(this_cpu_ptr(&efi_fpsimd_state));\n-\telse\n+\tif (!__this_cpu_xchg(efi_fpsimd_state_used, false)) {\n \t\tkernel_neon_end();\n+\t} else {\n+\t\tif (system_supports_sve() &&\n+\t\t    likely(__this_cpu_read(efi_sve_state_used))) {\n+\t\t\tchar const *sve_state = this_cpu_ptr(efi_sve_state);\n+\n+\t\t\tsve_load_state(sve_state + sve_ffr_offset(sve_max_vl),\n+\t\t\t\t       &this_cpu_ptr(&efi_fpsimd_state)->fpsr,\n+\t\t\t\t       sve_vq_from_vl(sve_get_vl()) - 1);\n+\n+\t\t\t__this_cpu_write(efi_sve_state_used, false);\n+\t\t} else {\n+\t\t\tfpsimd_load_state(this_cpu_ptr(&efi_fpsimd_state));\n+\t\t}\n+\t}\n }\n \n #endif /* CONFIG_KERNEL_MODE_NEON */\n",
    "prefixes": [
        "v2",
        "18/28"
    ]
}