Re: [Xen-devel] [PATCH] PVH: vcpu info placement, loadselectors, and remove debug printk.

From: Jan Beulich
Date: Wed Jun 05 2013 - 03:03:27 EST


>>> On 04.06.13 at 23:53, Mukesh Rathor <mukesh.rathor@xxxxxxxxxx> wrote:
> Following OK? :
>
> if (xen_feature(XENFEAT_auto_translated_physmap)) {
> switch_to_new_gdt(0);
>
> asm volatile (
> "pushq %%rax\n"
> "leaq 1f(%%rip),%%rax\n"
> "pushq %%rax\n"
> "lretq\n"
> "1:\n"
> : : "a" (__KERNEL_CS) : "memory");
>
> return;
> }

While generally the choice of using %%rax instead of %0 here is
a matter of taste to some degree, I still don't see why you can't
use "r" as the constraint here in the first place.

Furthermore, assuming this sits in a function guaranteed to not be
inlined, this has a latent bug (and if the assumption isn't right, the
bug is real) in that the asm() modifies %rax without telling the
compiler.

This is how I would have done it:

unsigned long dummy;

asm volatile ("pushq %0\n"
"leaq 1f(%%rip),%0\n"
"pushq %0\n"
"lretq\n"
"1:\n"
: "=&r" (dummy) : "0" (__KERNEL_CS));

(also dropping the memory clobber, as I don't see what you
need this for).

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/