Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2795456ybk; Tue, 12 May 2020 08:19:26 -0700 (PDT) X-Google-Smtp-Source: APiQypK/848zEinEj3Dd5SRWoZOjEK9JxrEH3VR/fgxBV/iUPyfmeI6G907yg9hYN7RHeHWLmr3G X-Received: by 2002:a50:9e2c:: with SMTP id z41mr10529959ede.193.1589296766296; Tue, 12 May 2020 08:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589296766; cv=none; d=google.com; s=arc-20160816; b=wWGILrY5dvnmtO/U5a68HA1rD9/M8ne183vEsGkD97JiGUWr9/SatVPj8LUOZ9xqJs Qj0gRjhNJZrWw2nt+8xeDmGw/v8lulb4ax84vEeh6tcUnzDE9JSL8CRish35uPzlj0H8 pkz7UHa7mrzM/tfr68W/FuQaAXtomzreTIKmfSYPwEzEpDQdjJZAVtGKX4XcDvp/weZp 0sBQuzhzBIUlHqzEskFc7targ2V4u7ufTmAOYY2qz786cxVJh6ea5vRv4tDLzzu0ue6w Yj+/XkBEYgWp8lf6a2qB13vK+0HyudDeAqAObCLK07cWIP8pINfxdjVitzJJ7r/eSQjs t9jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bPeAtc/ouqJ2VEXlhLFvfKjqV47RCLeXOikuieDXBWA=; b=MKNhES9LfNorLyDIdQFBkVcasCvJj36ytYDi1HluDa9/GdJB5gsL4MBcJ3pYOw2bsf ms0XfEnOn7SqXcYgOFXCXtSvhbxXb47I2pg7UGffMBFBQ8YFYjcXe/j1mCpKfbmzXCbf 7YUbVludQ9ig10UDPKlIbbZytgkN2uUvu9pFQxLImHgL4oCBwrVPvJkKlX3T7yFv8k5u u4A47Pf3rhiC7ztmj8p08V627vfK1KJM9x8l0KBP5GQXKcukr+UnKMp8vQxNO0NuIPku N0q8bNzY4TZ2d3Ept/U5AkkwRD8ldXAKa8J0nYqGz3UiXk5oKZ8Y/YsxVw/oDHjT4XAG shNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="Z8UG5e/b"; 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 b13si6153566ejg.10.2020.05.12.08.19.02; Tue, 12 May 2020 08:19:26 -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="Z8UG5e/b"; 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 S1727903AbgELPPb (ORCPT + 99 others); Tue, 12 May 2020 11:15:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726891AbgELPPa (ORCPT ); Tue, 12 May 2020 11:15:30 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4431EC061A0C for ; Tue, 12 May 2020 08:15:30 -0700 (PDT) Received: from zn.tnic (p200300EC2F0A9D0059BB7FCAE11E2EA0.dip0.t-ipconnect.de [IPv6:2003:ec:2f0a:9d00:59bb:7fca:e11e:2ea0]) (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 C563C1EC0114; Tue, 12 May 2020 17:15:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1589296526; 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=bPeAtc/ouqJ2VEXlhLFvfKjqV47RCLeXOikuieDXBWA=; b=Z8UG5e/bHeGvTITOd8GxXo0hvpM0PRuSa0dwMrUivg+DvSc0DCTHw2JC6Y8CE5I+T5MKC9 gZcrlQ6qnMcj9R+8L5FgBBtL44Eh/fpQgkMteRIgkSkWz4Vcxgxfqspk07o+TqggSWoJwK kMepWsQGFmHDoZkJUk64qGn+BD53s60= Date: Tue, 12 May 2020 17:15:22 +0200 From: Borislav Petkov To: Uros Bizjak Cc: LKML , linux-tip-commits@vger.kernel.org, "H. Peter Anvin (Intel)" , "Peter Zijlstra (Intel)" , x86 Subject: Re: [tip: x86/cpu] x86/cpu: Use INVPCID mnemonic in invpcid.h Message-ID: <20200512151522.GB6859@zn.tnic> References: <20200508092247.132147-1-ubizjak@gmail.com> <158929264101.390.18239205970315804831.tip-bot2@tip-bot2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2020 at 04:26:37PM +0200, Uros Bizjak wrote: > Actually, the order was correct for AT&T syntax in the original patch. > > The insn template for AT&T syntax goes: > > insn arg2, arg1, arg0 > > where rightmost arguments are output operands. > > The operands in asm template go > > asm ("insn template" : output0, output1 : input0, input1 : clobbers) > > so, in effect: > > asm ("insn template" : arg0, arg1 : arg2, arg3: clobbers) > > As you can see, the operand order in insn tempate is reversed for AT&T > syntax. I didn't notice the reversal of operands in your improvement. Your version had: + asm volatile ("invpcid %1, %0" + : : "r" (type), "m" (desc) : "memory"); with "type" being the 0th operand and "desc" being the 1st operand in the input operands list. The order of the operands after the "invpcid" mnemonic are the other way around though: you first have %1 which is "desc" and then %0 which is the type. I simply swapped the arguments order in the input operands list, after the second ':' + asm volatile("invpcid %[desc], %[type]" + :: [desc] "m" (desc), [type] "r" (type) : "memory"); so that "desc" comes first and "type" second when reading from left-to-right in both 1. *after* the "invpcid" mnemonic and 2. in the input operands list, after the second ':'. And since I'm using the symbolic operand names, then the order just works because looking at a before-and-after thing doesn't show any opcode differences: $ diff -suprN /tmp/before /tmp/after Files /tmp/before and /tmp/after are identical $ cat /tmp/before ffffffff81058392: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8105c542: 66 44 0f 38 82 04 24 invpcid (%rsp),%r8 ffffffff8105c5b4: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8105ccd2: 66 44 0f 38 82 14 24 invpcid (%rsp),%r10 ffffffff8105d6cf: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8105d7ef: 66 0f 38 82 1c 24 invpcid (%rsp),%rbx ffffffff8105e4db: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8106067b: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8169547d: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff82406698 : ffffffff824066a3: 75 27 jne ffffffff824066cc ffffffff824066b4: 73 16 jae ffffffff824066cc ffffffff824124db: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff82412e34: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff82415158: 66 0f 38 82 44 24 10 invpcid 0x10(%rsp),%rax $ cat /tmp/after ffffffff81058392: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8105c542: 66 44 0f 38 82 04 24 invpcid (%rsp),%r8 ffffffff8105c5b4: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8105ccd2: 66 44 0f 38 82 14 24 invpcid (%rsp),%r10 ffffffff8105d6cf: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8105d7ef: 66 0f 38 82 1c 24 invpcid (%rsp),%rbx ffffffff8105e4db: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8106067b: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff8169547d: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff82406698 : ffffffff824066a3: 75 27 jne ffffffff824066cc ffffffff824066b4: 73 16 jae ffffffff824066cc ffffffff824124db: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff82412e34: 66 0f 38 82 04 24 invpcid (%rsp),%rax ffffffff82415158: 66 0f 38 82 44 24 10 invpcid 0x10(%rsp),%rax Makes sense? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette