[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Use Aff1 with mpidr

From: Pavel Fedin
Subject: Re: [Qemu-devel] [PATCH] Use Aff1 with mpidr
Date: Fri, 29 May 2015 11:53:38 +0300


> > +    /*
> > +     * When KVM is in use, psci is emulated in-kernel and not by qemu.
> > +     * In order for it to work correctly we should use correct MPIDR 
> > values,
> > +     * which appear to be inherited from the host.
> why it must be inherited from host?
> Could you point out to KVM code that depends on it?

 It is PSCI, i have tested this and experienced this problem. In KVM guest PSCI 
is handled
by "hvc" call and is done entirely in kernel, no qemu code is involved. If i 
supply wrong
IDs the processors will simply not power up.
 I have checked how kvmtool (found here: git://linux-arm.org/linux-ap.git, 
handles this. Related parts are:
tools/kvm/arm/fdt.c - generate_cpu_nodes() - "reg" property assignment:
--- cut ---
static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
        int cpu;

        _FDT(fdt_begin_node(fdt, "cpus"));
        _FDT(fdt_property_cell(fdt, "#address-cells", 0x1));
        _FDT(fdt_property_cell(fdt, "#size-cells", 0x0));

        for (cpu = 0; cpu < kvm->nrcpus; ++cpu) {
                char cpu_name[CPU_NAME_MAX_LEN];
                struct kvm_cpu *vcpu = kvm->cpus[cpu];
                unsigned long mpidr = kvm_cpu__get_vcpu_mpidr(vcpu);

                mpidr &= ARM_MPIDR_HWID_BITMASK;
                snprintf(cpu_name, CPU_NAME_MAX_LEN, "address@hidden", mpidr);

                _FDT(fdt_begin_node(fdt, cpu_name));
                _FDT(fdt_property_string(fdt, "device_type", "cpu"));
                _FDT(fdt_property_string(fdt, "compatible", 

                if (kvm->nrcpus > 1)
                        _FDT(fdt_property_string(fdt, "enable-method", "psci"));

                _FDT(fdt_property_cell(fdt, "reg", mpidr));

--- cut ---
 tools/kvm/arm/aarch64/kvm-cpu.c - kvm_cpu__get_vcpu_mpidr() - obtains CPU ID 
from the
--- cut ---
unsigned long kvm_cpu__get_vcpu_mpidr(struct kvm_cpu *vcpu)
        struct kvm_one_reg reg;
        u64 mpidr;

        reg.id = ARM64_SYS_REG(ARM_CPU_ID, ARM_CPU_ID_MPIDR);
        reg.addr = (u64)&mpidr;
        if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
                die("KVM_GET_ONE_REG failed (get_mpidr vcpu%ld", vcpu->cpu_id);

        return mpidr;
--- cut ---

 So i just decided to do the same thing in KVM. However, to tell the truth, i 
actually do
not know whether it is possible to do it in reverse and assign MPIDR to VCPUs 
KVM_SET_ONE_REG ioctl instead. I can try it if you think it's more appropriate.
Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

reply via email to

[Prev in Thread] Current Thread [Next in Thread]