Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ea07a15 authored by Glauber de Oliveira Costa's avatar Glauber de Oliveira Costa Committed by Rusty Russell
Browse files

lguest: make write() operation smp aware



This patch makes the write() file operation smp aware. Which means, receiving
the vcpu_id value through the offset parameter, and being well aware to which
vcpu we're talking to.

Signed-off-by: default avatarGlauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent d0953d42
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -227,14 +227,21 @@ static ssize_t write(struct file *file, const char __user *in,
	struct lguest *lg = file->private_data;
	struct lguest *lg = file->private_data;
	const unsigned long __user *input = (const unsigned long __user *)in;
	const unsigned long __user *input = (const unsigned long __user *)in;
	unsigned long req;
	unsigned long req;
	struct lg_cpu *cpu;
	unsigned int cpu_id = *off;


	if (get_user(req, input) != 0)
	if (get_user(req, input) != 0)
		return -EFAULT;
		return -EFAULT;
	input++;
	input++;


	/* If you haven't initialized, you must do that first. */
	/* If you haven't initialized, you must do that first. */
	if (req != LHREQ_INITIALIZE && !lg)
	if (req != LHREQ_INITIALIZE) {
		if (!lg || (cpu_id >= lg->nr_cpus))
			return -EINVAL;
		cpu = &lg->cpus[cpu_id];
		if (!cpu)
			return -EINVAL;
			return -EINVAL;
	}


	/* Once the Guest is dead, all you can do is read() why it died. */
	/* Once the Guest is dead, all you can do is read() why it died. */
	if (lg && lg->dead)
	if (lg && lg->dead)