All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Alexander Graf <agraf@csgraf.de>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Cameron Esfahani <dirty@apple.com>,
	Roman Bolshakov <r.bolshakov@yadro.com>,
	qemu-arm <qemu-arm@nongnu.org>, Frank Yang <lfy@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2 7/8] hvf: Add Apple Silicon support
Date: Mon, 30 Nov 2020 09:52:40 +0000	[thread overview]
Message-ID: <CAFEAcA8utMuT55R5TzV_3N1Emdu-AjSE7CJ1Oqhs0Vsc4OzEYQ@mail.gmail.com> (raw)
In-Reply-To: <20201130030723.78326-8-agraf@csgraf.de>

On Mon, 30 Nov 2020 at 03:07, Alexander Graf <agraf@csgraf.de> wrote:
>
> With Apple Silicon available to the masses, it's a good time to add support
> for driving its virtualization extensions from QEMU.
>
> This patch adds all necessary architecture specific code to get basic VMs
> working. It's still pretty raw, but definitely functional.
>
> Known limitations:
>
>   - Vtimer acknowledgement is hacky
>   - Should implement more sysregs and fault on invalid ones then
>   - WFI handling is missing, need to marry it with vtimer
>
> Signed-off-by: Alexander Graf <agraf@csgraf.de>

> +static const struct hvf_reg_match hvf_sreg_match[] = {
> +    { HV_SYS_REG_DBGBVR0_EL1, offsetof(CPUARMState, cp15.dbgbvr[0]) },
> +    { HV_SYS_REG_DBGBCR0_EL1, offsetof(CPUARMState, cp15.dbgbcr[0]) },
> +    { HV_SYS_REG_DBGWVR0_EL1, offsetof(CPUARMState, cp15.dbgwvr[0]) },

> +};
> +
> +int hvf_get_registers(CPUState *cpu)
> +{
> +    ARMCPU *arm_cpu = ARM_CPU(cpu);
> +    CPUARMState *env = &arm_cpu->env;
> +    hv_return_t ret;
> +    uint64_t val;
> +    int i;
> +
> +    for (i = 0; i < ARRAY_SIZE(hvf_reg_match); i++) {
> +        ret = hv_vcpu_get_reg(cpu->hvf->fd, hvf_reg_match[i].reg, &val);
> +        *(uint64_t *)((void *)env + hvf_reg_match[i].offset) = val;
> +        assert_hvf_ok(ret);
> +    }

Please don't just blat straight into the CPU struct like this.
Compare KVM's handling of the cpreg list (data structure set up
in kvm_arm_init_cpreg_list() and the various write_*_to_* functions
that use it), where we look up the cpreg by its encoding and then
that gives us the field offset if necessary and also various flags
including ones that say "don't sync this". You'll need to set up
the cpreg list for migration anyway.

thanks
-- PMM


  reply	other threads:[~2020-11-30  9:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30  3:07 [PATCH v2 0/8] hvf: Implement Apple Silicon Support Alexander Graf
2020-11-30  3:07 ` [PATCH v2 1/8] hvf: Add hypervisor entitlement to output binaries Alexander Graf
2020-11-30  3:07 ` [PATCH v2 2/8] hvf: Move common code out Alexander Graf
2020-11-30  3:07 ` [PATCH v2 3/8] hvf: Actually set SIG_IPI mask Alexander Graf
2020-11-30  3:07 ` [PATCH v2 4/8] hvf: Introduce hvf vcpu struct Alexander Graf
2020-11-30  3:07 ` [PATCH v2 5/8] arm: Set PSCI to 0.2 for HVF Alexander Graf
2020-11-30  3:07 ` [PATCH v2 6/8] hvf: arm: Mark CPU as dirty on reset Alexander Graf
2020-11-30  3:07 ` [PATCH v2 7/8] hvf: Add Apple Silicon support Alexander Graf
2020-11-30  9:52   ` Peter Maydell [this message]
2020-11-30  3:07 ` [PATCH v2 8/8] arm: Add Hypervisor.framework build target Alexander Graf
2020-11-30  3:21 ` [PATCH v2 0/8] hvf: Implement Apple Silicon Support no-reply

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=CAFEAcA8utMuT55R5TzV_3N1Emdu-AjSE7CJ1Oqhs0Vsc4OzEYQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=dirty@apple.com \
    --cc=ehabkost@redhat.com \
    --cc=lfy@google.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=r.bolshakov@yadro.com \
    --cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.