[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] x86/setup: Correct register clobbers for the asm statement when resyncing the stack



>>> On 20.10.14 at 19:30, <andrew.cooper3@xxxxxxxxxx> wrote:
> When resyncing the stack, the asm statement does not identify %rsi, %rdi and
> %rcx as clobbered by the 'rep movsq'.
> 
> Luckily, there are no functional problems in the generated code.  GCC 
> decides
> not to save any of them before calling boostrap_map(), which clobbers them.
> 
> Correct the clobbers, by listing them as earlyclobber discarded outputs.
> 
> Reported-by: Daniel Kiper <daniel.kiper@xxxxxxxxxx>
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> CC: Keir Fraser <keir@xxxxxxx>
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> 
> ---
> 
> I have done an audit of the other uses of `rep $STRINGOP` and this is the 
> only
> asm statement with incorrect clobbers.
> ---
>  xen/arch/x86/setup.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 8c8b91f..f470c4a 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -836,6 +836,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>              l2_pgentry_t *pl2e;
>              uint64_t load_start;
>              int i, j, k;
> +            long _discard;

I can't see why you couldn't use i, j, or k for the discarding purposes.

> @@ -902,11 +903,13 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>                  "movq %%cr4,%%rsi ; "
>                  "andb $0x7f,%%sil ; "
>                  "movq %%rsi,%%cr4 ; " /* CR4.PGE == 0 */
> -                "movq %0,%%cr3    ; " /* CR3 == new pagetables */
> +                "movq %6,%%cr3    ; " /* CR3 == new pagetables */
>                  "orb $0x80,%%sil  ; "
>                  "movq %%rsi,%%cr4   " /* CR4.PGE == 1 */
> -                : : "r" (__pa(idle_pg_table)), "S" (cpu0_stack),
> -                "D" (__va(__pa(cpu0_stack))), "c" (STACK_SIZE / 8) : 
> "memory" );
> +                : "=&S"(_discard), "=&D"(_discard), "=&c"(_discard)
> +                : "0"(cpu0_stack), "1"(__va(__pa(cpu0_stack))),
> +                  "2"(STACK_SIZE / 8), "r"(__pa(idle_pg_table))
> +                : "memory" );

Among the inputs, please put the one actively used by number first,
or convert to labeled operands. Also please don't corrupt the
formatting - there ought to be a blank between the closing constraint
quote and the opening parenthesis in all operands.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.