1178476Sjb/* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause */ 2178476Sjb// 3178476Sjb// This file is dual-licensed, meaning that you can use it under your 4178476Sjb// choice of either of the following two licenses: 5178476Sjb// 6178476Sjb// Copyright 2023 The OpenSSL Project Authors. All Rights Reserved. 7178476Sjb// 8178476Sjb// Licensed under the Apache License 2.0 (the "License"). You can obtain 9178476Sjb// a copy in the file LICENSE in the source distribution or at 10178476Sjb// https://www.openssl.org/source/license.html 11178476Sjb// 12178476Sjb// or 13178476Sjb// 14178476Sjb// Copyright (c) 2023, Christoph M��llner <christoph.muellner@vrull.eu> 15178476Sjb// Copyright (c) 2023, Jerry Shih <jerry.shih@sifive.com> 16178476Sjb// Copyright 2024 Google LLC 17178476Sjb// All rights reserved. 18178476Sjb// 19178476Sjb// Redistribution and use in source and binary forms, with or without 20178476Sjb// modification, are permitted provided that the following conditions 21178476Sjb// are met: 22178476Sjb// 1. Redistributions of source code must retain the above copyright 23178476Sjb// notice, this list of conditions and the following disclaimer. 24178476Sjb// 2. Redistributions in binary form must reproduce the above copyright 25178476Sjb// notice, this list of conditions and the following disclaimer in the 26178476Sjb// documentation and/or other materials provided with the distribution. 27178476Sjb// 28178476Sjb// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29178476Sjb// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30178476Sjb// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31178476Sjb// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32178476Sjb// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33178476Sjb// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34178476Sjb// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35178476Sjb// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36178476Sjb// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37178476Sjb// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38178476Sjb// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39178476Sjb 40178476Sjb// The generated code of this file depends on the following RISC-V extensions: 41178476Sjb// - RV64I 42178476Sjb// - RISC-V Vector ('V') with VLEN >= 128 43178476Sjb// - RISC-V Vector GCM/GMAC extension ('Zvkg') 44178476Sjb 45178476Sjb#include <linux/linkage.h> 46178476Sjb 47178476Sjb.text 48178476Sjb.option arch, +zvkg 49178476Sjb 50178476Sjb#define ACCUMULATOR a0 51178476Sjb#define KEY a1 52178476Sjb#define DATA a2 53178476Sjb#define LEN a3 54178476Sjb 55178476Sjb// void ghash_zvkg(be128 *accumulator, const be128 *key, const u8 *data, 56178476Sjb// size_t len); 57178476Sjb// 58178476Sjb// |len| must be nonzero and a multiple of 16 (GHASH_BLOCK_SIZE). 59178476SjbSYM_FUNC_START(ghash_zvkg) 60178476Sjb vsetivli zero, 4, e32, m1, ta, ma 61178476Sjb vle32.v v1, (ACCUMULATOR) 62178476Sjb vle32.v v2, (KEY) 63178476Sjb.Lnext_block: 64178476Sjb vle32.v v3, (DATA) 65178476Sjb vghsh.vv v1, v2, v3 66178476Sjb addi DATA, DATA, 16 67 addi LEN, LEN, -16 68 bnez LEN, .Lnext_block 69 70 vse32.v v1, (ACCUMULATOR) 71 ret 72SYM_FUNC_END(ghash_zvkg) 73