return false;
}
+static int hash_prepare_direct_iov(AspeedHACEState *s, struct iovec *iov)
+{
+ uint32_t src;
+ void *haddr;
+ hwaddr plen;
+ int iov_idx;
+
+ plen = s->regs[R_HASH_SRC_LEN];
+ src = s->regs[R_HASH_SRC];
+ haddr = address_space_map(&s->dram_as, src, &plen, false,
+ MEMTXATTRS_UNSPECIFIED);
+ if (haddr == NULL) {
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "%s: Unable to map address, addr=0x%x, "
+ "plen=0x%" HWADDR_PRIx "\n",
+ __func__, src, plen);
+ return -1;
+ }
+
+ iov[0].iov_base = haddr;
+ iov[0].iov_len = plen;
+ iov_idx = 1;
+
+ return iov_idx;
+}
static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
bool acc_mode)
{
}
}
+ /* Prepares the iov for hashing operations based on the selected mode */
if (sg_mode) {
for (iov_idx = 0; !(len & SG_LIST_LEN_LAST); iov_idx++) {
if (iov_idx == ASPEED_HACE_MAX_SG) {
}
}
} else {
- plen = s->regs[R_HASH_SRC_LEN];
+ iov_idx = hash_prepare_direct_iov(s, iov);
+ }
- haddr = address_space_map(&s->dram_as, s->regs[R_HASH_SRC],
- &plen, false, MEMTXATTRS_UNSPECIFIED);
- if (haddr == NULL) {
- qemu_log_mask(LOG_GUEST_ERROR, "%s: qcrypto failed\n", __func__);
- return;
- }
- iov[0].iov_base = haddr;
- iov[0].iov_len = plen;
- iov_idx = 1;
+ if (iov_idx <= 0) {
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "%s: Failed to prepare iov\n", __func__);
+ return;
}
if (acc_mode) {