-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start adding infrastructure for accelerating guest AES. Begin with a SubBytes + ShiftRows + AddRoundKey primitive. Acked-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* No host specific aes acceleration. | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
|
||
#ifndef GENERIC_HOST_CRYPTO_AES_ROUND_H | ||
#define GENERIC_HOST_CRYPTO_AES_ROUND_H | ||
|
||
#define HAVE_AES_ACCEL false | ||
#define ATTR_AES_ACCEL | ||
|
||
void aesenc_SB_SR_AK_accel(AESState *, const AESState *, | ||
const AESState *, bool) | ||
QEMU_ERROR("unsupported accel"); | ||
|
||
#endif /* GENERIC_HOST_CRYPTO_AES_ROUND_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* AES round fragments, generic version | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
* | ||
* Copyright (C) 2023 Linaro, Ltd. | ||
*/ | ||
|
||
#ifndef CRYPTO_AES_ROUND_H | ||
#define CRYPTO_AES_ROUND_H | ||
|
||
/* Hosts with acceleration will usually need a 16-byte vector type. */ | ||
typedef uint8_t AESStateVec __attribute__((vector_size(16))); | ||
|
||
typedef union { | ||
uint8_t b[16]; | ||
uint32_t w[4]; | ||
uint64_t d[2]; | ||
AESStateVec v; | ||
} AESState; | ||
|
||
#include "host/crypto/aes-round.h" | ||
|
||
/* | ||
* Perform SubBytes + ShiftRows + AddRoundKey. | ||
*/ | ||
|
||
void aesenc_SB_SR_AK_gen(AESState *ret, const AESState *st, | ||
const AESState *rk); | ||
void aesenc_SB_SR_AK_genrev(AESState *ret, const AESState *st, | ||
const AESState *rk); | ||
|
||
static inline void aesenc_SB_SR_AK(AESState *r, const AESState *st, | ||
const AESState *rk, bool be) | ||
{ | ||
if (HAVE_AES_ACCEL) { | ||
aesenc_SB_SR_AK_accel(r, st, rk, be); | ||
} else if (HOST_BIG_ENDIAN == be) { | ||
aesenc_SB_SR_AK_gen(r, st, rk); | ||
} else { | ||
aesenc_SB_SR_AK_genrev(r, st, rk); | ||
} | ||
} | ||
|
||
#endif /* CRYPTO_AES_ROUND_H */ |