[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 7/8] hvf: Add Apple Silicon support
From: |
Peter Maydell |
Subject: |
Re: [PATCH v2 7/8] hvf: Add Apple Silicon support |
Date: |
Mon, 30 Nov 2020 09:52:40 +0000 |
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
- [PATCH v2 0/8] hvf: Implement Apple Silicon Support, Alexander Graf, 2020/11/29
- [PATCH v2 3/8] hvf: Actually set SIG_IPI mask, Alexander Graf, 2020/11/29
- [PATCH v2 1/8] hvf: Add hypervisor entitlement to output binaries, Alexander Graf, 2020/11/29
- [PATCH v2 5/8] arm: Set PSCI to 0.2 for HVF, Alexander Graf, 2020/11/29
- [PATCH v2 6/8] hvf: arm: Mark CPU as dirty on reset, Alexander Graf, 2020/11/29
- [PATCH v2 4/8] hvf: Introduce hvf vcpu struct, Alexander Graf, 2020/11/29
- [PATCH v2 2/8] hvf: Move common code out, Alexander Graf, 2020/11/29
- [PATCH v2 8/8] arm: Add Hypervisor.framework build target, Alexander Graf, 2020/11/29
- [PATCH v2 7/8] hvf: Add Apple Silicon support, Alexander Graf, 2020/11/29
- Re: [PATCH v2 7/8] hvf: Add Apple Silicon support,
Peter Maydell <=
- Re: [PATCH v2 0/8] hvf: Implement Apple Silicon Support, no-reply, 2020/11/29