1/*
2 * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230)
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <autoconf.h>
8
9/* Writes the current value in xmm0 to the stack, then reads it back.
10 * This function should cause a general protection fault if the stack
11 * is not correctly aligned. */
12.global movaps_test
13movaps_test:
14    /* Align the stack to 16 bytes assuming:
15     * - 16 byte stack alignment before this function was called
16     * - the register-sized return address has been pushed by the
17     *   call and nothing else
18     */
19    #define STACK_OFFSET_BYTES $(16 - (CONFIG_WORD_SIZE / 8))
20    sub STACK_OFFSET_BYTES, %esp
21
22    /* Push and pop the %xmm0 */
23    sub $16, %esp
24    movdqa %xmm0, (%esp)
25    movdqa (%esp), %xmm0
26    add $16, %esp
27
28    /* Compensate for stack alignment */
29    add STACK_OFFSET_BYTES, %esp
30
31    ret
32