Path: blob/master/arch/riscv/crypto/ghash-riscv64-zvkg.S
26451 views
/* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause */1//2// This file is dual-licensed, meaning that you can use it under your3// choice of either of the following two licenses:4//5// Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.6//7// Licensed under the Apache License 2.0 (the "License"). You can obtain8// a copy in the file LICENSE in the source distribution or at9// https://www.openssl.org/source/license.html10//11// or12//13// Copyright (c) 2023, Christoph Müllner <christoph.muellner@vrull.eu>14// Copyright (c) 2023, Jerry Shih <jerry.shih@sifive.com>15// Copyright 2024 Google LLC16// All rights reserved.17//18// Redistribution and use in source and binary forms, with or without19// modification, are permitted provided that the following conditions20// are met:21// 1. Redistributions of source code must retain the above copyright22// notice, this list of conditions and the following disclaimer.23// 2. Redistributions in binary form must reproduce the above copyright24// notice, this list of conditions and the following disclaimer in the25// documentation and/or other materials provided with the distribution.26//27// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS28// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT29// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR30// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT31// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,32// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT33// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,34// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY35// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT36// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE37// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.3839// The generated code of this file depends on the following RISC-V extensions:40// - RV64I41// - RISC-V Vector ('V') with VLEN >= 12842// - RISC-V Vector GCM/GMAC extension ('Zvkg')4344#include <linux/linkage.h>4546.text47.option arch, +zvkg4849#define ACCUMULATOR a050#define KEY a151#define DATA a252#define LEN a35354// void ghash_zvkg(be128 *accumulator, const be128 *key, const u8 *data,55// size_t len);56//57// |len| must be nonzero and a multiple of 16 (GHASH_BLOCK_SIZE).58SYM_FUNC_START(ghash_zvkg)59vsetivli zero, 4, e32, m1, ta, ma60vle32.v v1, (ACCUMULATOR)61vle32.v v2, (KEY)62.Lnext_block:63vle32.v v3, (DATA)64vghsh.vv v1, v2, v365addi DATA, DATA, 1666addi LEN, LEN, -1667bnez LEN, .Lnext_block6869vse32.v v1, (ACCUMULATOR)70ret71SYM_FUNC_END(ghash_zvkg)727374