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

Ping: [PATCH v2] x86: correct asm() constraints when dealing with immediate selector values


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 23 Jun 2022 14:03:14 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i+TaXK5q8EwNOsaof0Oa83Zj9OAG55ERnCGvpk7KNHU=; b=f5d0uYWmtw25KpZsSTxiVQsqtXcpSfakP66ybDCfpvIAmYusSc9vknJkvKbtMDTKFjwCu/qV85U3OBM4kaZ54LTBpIpoquSJM/dZA4cy+HUc94ONw3TY7ckxi86+HG5Hgbh/IAU5r8anI3yWkYDR5tsiZY1f3qrcZL0t1Ck7PQ1120cUEWmM1cKHApns6828zCfVtVwnSYfPeupwF7maY3o6EE2/k2BVCqJQtAPSvCMI6pPNN1RZ4tvzedv3eeo8TYe315CKw3vVyTcUwyJHmO8Lp4c4v8Huzq7EfqARVmjoR2WHR1mAMw1VQVO1HDl5UXM/CHM7MQGZTkXJegtUdA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xgk3Bei9Q0Yno9495l2e5ZtbQ/1N3BzXvQUR7QX1MJjFSYGyxWI+qVKUpzCpNJ02xkG8QS2F6YVnDbcLwjKg8uFdRvbmlh1ULDrXZl4INxxQTSsiofvnymlXTQ9q8m5vNpsEAPxC156XOA76GzJUQudxuGZ2iZtOAC8MEQu7PG/gOzu/8LktKWQxmNajQlsjVnaYbDgyaW92QxfXtj+zNXoGOgQHNh0+6m3DEmn+zEWlQRou+57AV/GVuvTnBaglD/EKVec4QfDiCgGSR6XsFI4BtOQIkLcSWnq/cV/BJbMkv9entjkTwENvcq7i4jEhOfdTIYJIXhvQxq7eN8GcFA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 23 Jun 2022 12:03:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13.09.2021 08:26, Jan Beulich wrote:
> asm() constraints need to fit both the intended insn(s) which the
> respective operands are going to be used with as well as the actual kind
> of value specified. "m" (alone) together with a constant, however, leads
> to gcc saying
> 
> error: memory input <N> is not directly addressable
> 
> while clang complains
> 
> error: invalid lvalue in asm input for constraint 'm'
> 
> And rightly so - in order to access a memory operand, an address needs
> to be specified to the insn. In some cases it might be possible for a
> compiler to synthesize a memory operand holding the requested constant,
> but I think any solution there would have sharp edges.
> 
> If "m" alone doesn't work with constants, it is at best pointless (and
> perhaps misleading or even risky - the compiler might decide to actually
> pick "m" and not try very hard to find a suitable register) to specify
> it alongside "r". And indeed clang does, oddly enough despite its
> objection to "m" alone. Which means there the change also improves the
> generated code.
> 
> While there also switch the two operand case to using named operands.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> v2: Use named operands in do_double_fault().

This has been pending for over 9 months. May I ask for feedback?

Thanks, Jan

> --- a/xen/arch/x86/cpu/amd.c
> +++ b/xen/arch/x86/cpu/amd.c
> @@ -736,7 +736,7 @@ void __init detect_zen2_null_seg_behavio
>       uint64_t base;
>  
>       wrmsrl(MSR_FS_BASE, 1);
> -     asm volatile ( "mov %0, %%fs" :: "rm" (0) );
> +     asm volatile ( "mov %0, %%fs" :: "r" (0) );
>       rdmsrl(MSR_FS_BASE, base);
>  
>       if (base == 0)
> --- a/xen/arch/x86/x86_64/traps.c
> +++ b/xen/arch/x86/x86_64/traps.c
> @@ -248,7 +248,8 @@ void do_double_fault(struct cpu_user_reg
>  
>      console_force_unlock();
>  
> -    asm ( "lsll %1, %0" : "=r" (cpu) : "rm" (PER_CPU_SELECTOR) );
> +    asm ( "lsll %[sel], %[limit]" : [limit] "=r" (cpu)
> +                                  : [sel] "r" (PER_CPU_SELECTOR) );
>  
>      /* Find information saved during fault and dump it to the console. */
>      printk("*** DOUBLE FAULT ***\n");




 


Rackspace

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