Path: blob/master/lib/crypto/riscv/ghash-riscv64-zvkg.S
170891 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 NBLOCKS a35354// void ghash_zvkg(u8 accumulator[GHASH_BLOCK_SIZE],55// const u8 key[GHASH_BLOCK_SIZE],56// const u8 *data, size_t nblocks);57//58// |nblocks| must be nonzero.59SYM_FUNC_START(ghash_zvkg)60vsetivli zero, 4, e32, m1, ta, ma61vle32.v v1, (ACCUMULATOR)62vle32.v v2, (KEY)63.Lnext_block:64vle32.v v3, (DATA)65vghsh.vv v1, v2, v366addi DATA, DATA, 1667addi NBLOCKS, NBLOCKS, -168bnez NBLOCKS, .Lnext_block6970vse32.v v1, (ACCUMULATOR)71ret72SYM_FUNC_END(ghash_zvkg)737475