Received: from eggs.gnu.org ([2001:4830:134:3::10]:52549)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from
) id 1YyG30-00007P-Gx
for qemu-devel@nongnu.org; Fri, 29 May 2015 04:53:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1YyG2w-0006nr-ET
for qemu-devel@nongnu.org; Fri, 29 May 2015 04:53:46 -0400
Received: from mailout3.w1.samsung.com ([210.118.77.13]:47942)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1YyG2w-0006nj-8z
for qemu-devel@nongnu.org; Fri, 29 May 2015 04:53:42 -0400
Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244])
by mailout3.w1.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTP id <0NP30020YSPFR530@mailout3.w1.samsung.com> for
qemu-devel@nongnu.org; Fri, 29 May 2015 09:53:39 +0100 (BST)
From: Pavel Fedin
References: <011801d0947a$a9e1e8a0$fda5b9e0$@samsung.com>
<20150529103652.30d30a3d@nial.brq.redhat.com>
In-reply-to: <20150529103652.30d30a3d@nial.brq.redhat.com>
Date: Fri, 29 May 2015 11:53:38 +0300
Message-id: <011d01d099ec$f4f5b7a0$dee126e0$@samsung.com>
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7bit
Content-language: ru
Subject: Re: [Qemu-devel] [PATCH] Use Aff1 with mpidr
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: 'Igor Mammedov'
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, 'Ashok Kumar' , 'Shlomo Pongratz'
Hello!
> > + /*
> > + * 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, tools/kvm)
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, "cpu@%lx", mpidr);
_FDT(fdt_begin_node(fdt, cpu_name));
_FDT(fdt_property_string(fdt, "device_type", "cpu"));
_FDT(fdt_property_string(fdt, "compatible", vcpu->cpu_compatible));
if (kvm->nrcpus > 1)
_FDT(fdt_property_string(fdt, "enable-method", "psci"));
_FDT(fdt_property_cell(fdt, "reg", mpidr));
_FDT(fdt_end_node(fdt));
}
_FDT(fdt_end_node(fdt));
}
--- cut ---
tools/kvm/arm/aarch64/kvm-cpu.c - kvm_cpu__get_vcpu_mpidr() - obtains CPU ID from the
kernel:
--- 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, ®) < 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 using
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