Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp192272pxk; Thu, 24 Sep 2020 03:16:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL5cB+e4bnViL45L68j3FfjdzZpJAbC/HwMbhqT3S8kwN/0p43SPT7yDVl+Q2nX9G7Sfu4 X-Received: by 2002:aa7:c1c3:: with SMTP id d3mr238853edp.228.1600942598012; Thu, 24 Sep 2020 03:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600942598; cv=none; d=google.com; s=arc-20160816; b=li/l8Dv7SSWT+DZ9jKwBNpvLm5eG0XZqV+rYsQ2ocM3m1wEzwg/N1tyFMqlMrAmjcM Zj2FEUbVF85FBYYADmFGFJWKvdEeDjLy+2CzVdpmx0qQ66GMLAK4awL2KIJamP7B716t C71m0H3GUFJRhltzE/9qmhsQHOzOBu/uUeN6Cl93y810GO79S2PCY1gay2EmsdW1wg5y 6dKaUdPRZEfeQvIgYQK9vsXN6XnUHzWUbah+cYDdZTloKYgu6Al06eLjzM4Htnnj06Ar BD2+bZD2OkCxsJFq5d9IjsZqkEXoghRzbCDrNY2pgh7RxaBkaJQoWQ1467PwhoNAQFJ4 fhFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DXqVO7HVeWlePM1INcUriyOsdG0miN23CY4cZLheeeg=; b=p2X86VFqHwabZcQWmrZLHgPXtpDzq9jV5HmgrqNSwT3+NllNkjZ+nCscAyPOLVzsUK D2lM8msUoQ1arhAmcS/7HJ7zA7KQRXGvb/g6l8R+b93foJLxnufCQUhQ7wGwSgq+uWCS R/hNu18cPU/fbjMtlc3VjSr4RGibr2dEwagB2gqpXKBkJ8pmGArFjK3dFKen0hY2tU5K V2aAhpG1wsgh5ExwX8NZZ9o2dq3moCtGOhfBcSilE2p9RYU1zQVgoo8RV4Wk39/wbz0D MT582qpvWn+4SDp8/9YcoLwckjeIsShoEQItZVyIirza7c0zLuwN+RQ64EQRYXrcSRiY Vz1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=KLFUru5k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si1349946edf.103.2020.09.24.03.16.14; Thu, 24 Sep 2020 03:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=KLFUru5k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727368AbgIXKPQ (ORCPT + 99 others); Thu, 24 Sep 2020 06:15:16 -0400 Received: from mail.skyhub.de ([5.9.137.197]:38782 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbgIXKPQ (ORCPT ); Thu, 24 Sep 2020 06:15:16 -0400 X-Greylist: delayed 84794 seconds by postgrey-1.27 at vger.kernel.org; Thu, 24 Sep 2020 06:15:15 EDT Received: from zn.tnic (p200300ec2f0c9500b3077ed5fae90a35.dip0.t-ipconnect.de [IPv6:2003:ec:2f0c:9500:b307:7ed5:fae9:a35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 8A1761EC037C; Thu, 24 Sep 2020 12:15:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1600942514; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=DXqVO7HVeWlePM1INcUriyOsdG0miN23CY4cZLheeeg=; b=KLFUru5ki6EGsGyFSv3QT0IYhdw7z/OYlteFatkBLrGnDNe6F6WF3twRfEA1EtpE+gm531 f4hC0oKjbJPqsfaMf7V70KmUeZpcOg2gc8bust2Svl4t5R3WtAHPatNeOTk6wKQ25QsXKp sEAXxZV//Bz7wTTj468292AzHM6RVRY= Date: Thu, 24 Sep 2020 12:15:06 +0200 From: Borislav Petkov To: David Laight , Michael Matz Cc: 'Dave Jiang' , "vkoul@kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "dan.j.williams@intel.com" , "tony.luck@intel.com" , "jing.lin@intel.com" , "ashok.raj@intel.com" , "sanjay.k.kumar@intel.com" , "fenghua.yu@intel.com" , "kevin.tian@intel.com" , "dmaengine@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 1/5] x86/asm: Carve out a generic movdir64b() helper for general usage Message-ID: <20200924101506.GD5030@zn.tnic> References: <160090233730.44288.4446779116422752486.stgit@djiang5-desk3.ch.intel.com> <160090264332.44288.7575027054245105525.stgit@djiang5-desk3.ch.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2020 at 08:24:46AM +0000, David Laight wrote: > static inline void movdir64b(void *dst, const void *src) > { > /* > * 64 bytes from dst are marked as modified for completeness. > * Since the writes bypass the cache later reads may return > * old data anyway. > */ > /* MOVDIR64B [rdx], rax */ > asm volatile (".byte 0x66, 0x0f, 0x38, 0xf8, 0x02" > : "=m" ((struct { char _[64];} *)dst), > : "m" ((struct { char _[64];} *)src), "d" (src), "a" (dst)); Now since you're so generous with your advice on random threads, please explain what you're advising here? The destination operand - in this case in %rax - is "destination memory address specified as offset to ES segment in the register operand." So what is the difference between: ...(void *dst, ... ) volatile struct { char _[64]; } *__dst = dst; ... : "=m" (__dst) : "a" (__dst) and ...(void *dst, ... ) ... : "=m" ((struct { char _[64];} *)dst) : "a" (__dst) and why? Point me to the gcc documentation where this is explained. To cut to the chase, I don't think you need to do that, otherwise clwb() would be broken too but perhaps you know something I don't. Looking at clwb(), I believe the proper specification should be: volatile struct { char _[64]; } *__dst = dst; ... : "+m" (__dst) : "a" (__dst) And if anything, the source specification should be something like that: volatile struct { char x[64]; } *__src = src; ... "d" (__src) because this tells gcc that the source operand would read 64 bytes through the pointer in the %rdx reg. So this ends up close to what you're saying but it is using local variables to make the asm actually readable. Lemme add Micha to Cc for sanity-checking: Micha, the instruction is: MOVDIR64B %(rdx), rax "Move 64-bytes as direct-store with guaranteed 64-byte write atomicity from the source memory operand address to destination memory address specified as offset to ES segment in the register operand." Do I need to tell gcc that both operands are referencing 64 bytes, source operand is a memory reference, destination operand is an address specified in a register? What we have currently is: volatile struct { char _[64]; } *dst = __dst; /* MOVDIR64B [rdx], rax */ asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02" : "=m" (dst) : "d" (from), "a" (dst)); Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette