All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Fedin <p.fedin@samsung.com>
To: 'Igor Mammedov' <imammedo@redhat.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org,
	'Ashok Kumar' <ashoks@broadcom.com>,
	'Shlomo Pongratz' <shlomo.pongratz@huawei.com>
Subject: Re: [Qemu-devel] [PATCH] Use Aff1 with mpidr
Date: Fri, 29 May 2015 11:53:38 +0300	[thread overview]
Message-ID: <011d01d099ec$f4f5b7a0$dee126e0$@samsung.com> (raw)
In-Reply-To: <20150529103652.30d30a3d@nial.brq.redhat.com>

 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, &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

  reply	other threads:[~2015-05-29  8:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 10:32 [Qemu-devel] [PATCH] Use Aff1 with mpidr Pavel Fedin
2015-05-28 14:57 ` Shlomo Pongratz
2015-05-29  6:45   ` Pavel Fedin
2015-05-31 11:03     ` Shlomo Pongratz
2015-06-01  6:34       ` Pavel Fedin
2015-06-01  9:03       ` Pavel Fedin
2015-06-01 14:26         ` Shlomo Pongratz
2015-06-02  6:29           ` Pavel Fedin
2015-06-02 15:37       ` Igor Mammedov
2015-05-29  8:36 ` Igor Mammedov
2015-05-29  8:53   ` Pavel Fedin [this message]
2015-05-29  9:18     ` Igor Mammedov
2015-05-29 12:26       ` Pavel Fedin
2015-05-29 13:03         ` Igor Mammedov
2015-05-29 13:41           ` Pavel Fedin
2015-06-02 15:32             ` Igor Mammedov
2015-06-02 15:42               ` Peter Maydell
2015-06-02 15:54                 ` Igor Mammedov
2015-05-29 17:37           ` Pavel Fedin
2015-05-30  2:30             ` Shannon Zhao

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='011d01d099ec$f4f5b7a0$dee126e0$@samsung.com' \
    --to=p.fedin@samsung.com \
    --cc=ashoks@broadcom.com \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shlomo.pongratz@huawei.com \
    /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.