qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Zhuojia Shen <chaosdefinition@hotmail.com>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Beata Michalska <beata.michalska@linaro.org>,
	qemu-arm@nongnu.org
Subject: Re: [PATCH v2] target/arm: allow DC CVA[D]P in user mode emulation
Date: Wed, 17 May 2023 12:51:40 -0700	[thread overview]
Message-ID: <6051fefc-a5b0-0c45-b1a9-ebdf2717caa7@linaro.org> (raw)
In-Reply-To: <DS7PR12MB6309A0F097FA4FB9D7CACB5BAC7E9@DS7PR12MB6309.namprd12.prod.outlook.com>

On 5/17/23 10:31, Zhuojia Shen wrote:
> DC CVAP and DC CVADP instructions can be executed in EL0 on Linux,
> either directly when SCTLR_EL1.UCI == 1 or emulated by the kernel (see
> user_cache_maint_handler() in arch/arm64/kernel/traps.c).
> 
> This patch enables execution of the two instructions in user mode
> emulation.
> 
> Signed-off-by: Zhuojia Shen <chaosdefinition@hotmail.com>
> ---
>   target/arm/helper.c               |  6 ++--
>   tests/tcg/aarch64/Makefile.target | 11 ++++++++
>   tests/tcg/aarch64/dcpodp-1.c      | 47 +++++++++++++++++++++++++++++++
>   tests/tcg/aarch64/dcpodp-2.c      | 47 +++++++++++++++++++++++++++++++
>   tests/tcg/aarch64/dcpop-1.c       | 47 +++++++++++++++++++++++++++++++
>   tests/tcg/aarch64/dcpop-2.c       | 47 +++++++++++++++++++++++++++++++
>   6 files changed, 201 insertions(+), 4 deletions(-)
>   create mode 100644 tests/tcg/aarch64/dcpodp-1.c
>   create mode 100644 tests/tcg/aarch64/dcpodp-2.c
>   create mode 100644 tests/tcg/aarch64/dcpop-1.c
>   create mode 100644 tests/tcg/aarch64/dcpop-2.c

I recommend splitting the tests to a second patch.

  +++ b/tests/tcg/aarch64/dcpodp-1.c
> @@ -0,0 +1,47 @@
> +/* Test execution of DC CVADP instruction */
> +
> +#include <asm/hwcap.h>
> +#include <sys/auxv.h>
> +
> +#include <signal.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#ifndef HWCAP2_DCPODP
> +#define HWCAP2_DCPODP (1 << 0)
> +#endif
> +
> +static void signal_handler(int sig)
> +{
> +    exit(EXIT_FAILURE);
> +}
> +
> +static int do_dc_cvadp(void)
> +{
> +    struct sigaction sa = {
> +        .sa_handler = signal_handler,
> +    };
> +
> +    if (sigaction(SIGILL, &sa, NULL) < 0) {
> +        perror("sigaction");
> +        return EXIT_FAILURE;
> +    }
> +    if (sigaction(SIGSEGV, &sa, NULL) < 0) {
> +        perror("sigaction");
> +        return EXIT_FAILURE;
> +    }
> +
> +    asm volatile("dc cvadp, %0\n\t" :: "r"(&sa));
> +
> +    return EXIT_SUCCESS;
> +}

...

> diff --git a/tests/tcg/aarch64/dcpodp-2.c b/tests/tcg/aarch64/dcpodp-2.c
> new file mode 100644
> index 0000000000..3245d7883d
> --- /dev/null
> +++ b/tests/tcg/aarch64/dcpodp-2.c
> @@ -0,0 +1,47 @@
> +/* Test execution of DC CVADP instruction on unmapped address */
> +
> +#include <asm/hwcap.h>
> +#include <sys/auxv.h>
> +
> +#include <signal.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#ifndef HWCAP2_DCPODP
> +#define HWCAP2_DCPODP (1 << 0)
> +#endif
> +
> +static void signal_handler(int sig)
> +{
> +    exit(EXIT_SUCCESS);
> +}
> +
> +static int do_dc_cvadp(void)
> +{
> +    struct sigaction sa = {
> +        .sa_handler = signal_handler,
> +    };
> +
> +    if (sigaction(SIGILL, &sa, NULL) < 0) {
> +        perror("sigaction");
> +        return EXIT_FAILURE;
> +    }

This isn't: if SIGILL, exit with success.

You don't actually need to register anything for SIGILL, in either test, because SIGILL is 
a fine exit for failure.  So is SIGSEGV for test 1.

Also, you could merge all 4 tests and save some CI time.


r~



  parent reply	other threads:[~2023-05-17 19:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 17:31 [PATCH v2] target/arm: allow DC CVA[D]P in user mode emulation Zhuojia Shen
2023-05-17 18:11 ` Zhuojia Shen
2023-05-17 19:51 ` Richard Henderson [this message]
2023-05-18 19:34   ` Zhuojia Shen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6051fefc-a5b0-0c45-b1a9-ebdf2717caa7@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=beata.michalska@linaro.org \
    --cc=chaosdefinition@hotmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).