Skip to content

Commit

Permalink
gcm.c tried to nest kfpu calls
Browse files Browse the repository at this point in the history
Which will fail on Windows, due to variable allocations

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
  • Loading branch information
lundman committed Nov 23, 2024
1 parent 65ae459 commit 773833e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/os/windows/spl/sys/simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ extern uint32_t kfpu_state;
XSTATE_SAVE SaveState; \
saveStatus = KeSaveExtendedProcessorState(kfpu_state, &SaveState);

#define kfpu_begin_cont() \
saveStatus = KeSaveExtendedProcessorState(kfpu_state, &SaveState);

#define kfpu_end() \
if (NT_SUCCESS(saveStatus)) \
KeRestoreExtendedProcessorState(&SaveState);
Expand Down
9 changes: 7 additions & 2 deletions module/icp/algs/modes/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ static int gcm_init_avx(gcm_ctx_t *, const uint8_t *, size_t, const uint8_t *,
size_t, size_t);
#endif /* ifdef CAN_USE_GCM_ASM */

/* Windows defines variables, so can't be nested */
#ifndef kfpu_begin_cont
#define kfpu_begin_cont kfpu_begin
#endif

/*
* Encrypt multiple blocks of data in GCM mode. Decrypt for GCM mode
* is done in another function.
Expand Down Expand Up @@ -1478,7 +1483,7 @@ gcm_init_avx(gcm_ctx_t *ctx, const uint8_t *iv, size_t iv_len,
kfpu_end();
gcm_format_initial_blocks(iv, iv_len, ctx, block_size,
aes_copy_block, aes_xor_block);
kfpu_begin();
kfpu_begin_cont();
}

/* Openssl post increments the counter, adjust for that. */
Expand All @@ -1490,7 +1495,7 @@ gcm_init_avx(gcm_ctx_t *ctx, const uint8_t *iv, size_t iv_len,
datap += chunk_size;
clear_fpu_regs();
kfpu_end();
kfpu_begin();
kfpu_begin_cont();
}
/* Ghash the remainder and handle possible incomplete GCM block. */
if (bleft > 0) {
Expand Down

0 comments on commit 773833e

Please sign in to comment.