Skip to contentSkip to conversation

tools/libxc/xc_cpuid_x86.c:cpuid()'s inline asm

DISCUSSION Jan Beulich 3 participants 7 messages Dec 2, 2011

lore
Share & tools
lore
#0 lore raw

Keir,

do you recall what it was that 20976:f8692cc67d67 was supposed to fix? The code is clearly wrong now on x86-64 - inline asm that uses push/pop (or other stack pointer manipulation instructions) and memory accesses that may reference the stack (even if not through %rsp) can't be expected to work without -mno-red-zone.

The question is whether to use that command line option, or whether to correct the inline assembly (besides the purpose of your change, I also wonder why this isn't coded the obvious way, with rBX and rDX explicitly named in the constraints - on 32-bit this may be to reduce register pressure, but on 64-bit it's entirely unclear).

Thanks, Jan

#1 lore raw
Quoted 7 lines · Jan Beulich

Keir,

do you recall what it was that 20976:f8692cc67d67 was supposed to fix? The code is clearly wrong now on x86-64 - inline asm that uses push/pop (or other stack pointer manipulation instructions) and memory accesses that may reference the stack (even if not through %rsp) can't be expected to work without -mno-red-zone.

I totally missed the red-zone constraint. :-(

Quoted 5 lines

The question is whether to use that command line option, or whether to correct the inline assembly (besides the purpose of your change, I also wonder why this isn't coded the obvious way, with rBX and rDX explicitly named in the constraints - on 32-bit this may be to reduce register pressure, but on 64-bit it's entirely unclear).

I think reg constraint failures had only been reported on 32-bit. So how about the attached patch?

-- Keir

Quoted 2 lines

Thanks, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 2 lines · Keir Fraser

I think reg constraint failures had only been reported on 32-bit. So how about the attached patch?

+ : "0" (input[0]), "1" (count), "S" (_regs)

_regs is undeclared in 32bit, I think it should be regs.

Olaf

#3 lore raw
Quoted 8 lines · Olaf Hering
Quoted 2 lines · Keir Fraser

I think reg constraint failures had only been reported on 32-bit. So how about the attached patch?

+ : "0" (input[0]), "1" (count), "S" (_regs)

_regs is undeclared in 32bit, I think it should be regs.

Oops! Fixed!

Thanks,
Keir

Quoted 1 line

Olaf

#4 lore raw
In reply to Keir Fraser
Quoted 2 lines · Keir Fraser

I think reg constraint failures had only been reported on 32-bit. So how about the attached patch?

So finally I was able to test this change, and it fixes the reported segfault. Thanks!

Olaf

#5 lore raw
Quoted 7 lines · Olaf Hering
Quoted 2 lines · Keir Fraser

I think reg constraint failures had only been reported on 32-bit. So how about the attached patch?

So finally I was able to test this change, and it fixes the reported segfault. Thanks!

I will sweep this through into 4.0/4.1 as part of a general backport sweep next week.

-- Keir

Quoted 1 line

Olaf

author Acked-by
#6 lore raw
In reply to Keir Fraser
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 5 lines · Jan Beulich

The question is whether to use that command line option, or whether to correct the inline assembly (besides the purpose of your change, I also wonder why this isn't coded the obvious way, with rBX and rDX explicitly named in the constraints - on 32-bit this may be to reduce register pressure, but on 64-bit it's entirely unclear).

I think reg constraint failures had only been reported on 32-bit. So how about the attached patch?

Looks good.

While we only got problems with this on 4.1.2, I would suggest to also put this back into 4.0-testing.

Thanks, Jan

E-mail confidentiality notice. This message is intended for the addressees only. It may be private, confidential and may be covered by legal professional privilege or other confidentiality requirements. If you are not one of the intended recipients, please notify the sender immediately on +44 0 20-8215-3000 and delete the message from all locations in your computer network. Do not copy this email or use it for any purpose or disclose its contents to any person:to do so maybe unlawful.