Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp104832pxb; Mon, 2 Nov 2020 15:27:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2npeeabTGA60TParsVWtR7MKdHse0BX82vEXg4DUjgz4ld01SjwBnJrr2hfUGGtOj7vJV X-Received: by 2002:a17:906:f98e:: with SMTP id li14mr2786361ejb.75.1604359637156; Mon, 02 Nov 2020 15:27:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604359637; cv=none; d=google.com; s=arc-20160816; b=pRDUqDTsLZhExbeDsyQmqG7CVCTCbCwDYOlG5wgcgyuQvkblBUNhgL+x10zcOFHzva Jc1tcuIphaaQghsj50dRyr0Lh/hBI9B6nuXipHMqPa8JSyRz9VZojfXPdY8qdIZJfz9J NmrcwupDjYoIdGOgukZ66v5Xg4qTqkXmUFwY9yGJ7nY1FaAySc21gdOD440EyYk4QWAM 4ZJWr0sEQ6QEMLcyAKC0Z/yOkDpph+VUVUXkD9zyWArvrlI8Fq+5WV7YmG8f+FwdRqD4 eOyg/Z0wkOq2vaEYniDGVCXcI3y0MntOhe9lE+ZkYDkLnUDYl8JQjcKhR5/hCh2G69Ka W1bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=mwApFPwB4lWk9XKSxrSJ0Gd96owZblR+uYbt6WIIp/U=; b=EqxCKpzbG7N5n3faNt93dQHacFj051ZhSjI5xvihEIYuubq9vOeGVW9AhlC+stMXYI eQlyoNEK4OavWn+dYN/gtitjp1ttSo42/9vmrgWZQgKvZA3mhzQevA8Nvg/801fJwdBr qwmdvBMmPjFQgFUUm4Du1q88yBrJMQGaUZQyJ/U1iLOoZhBstNIam4rWXanMvLBXIBge CYPl7uQsalYXrm1sAR9ygJXS4sye/3P0cBxokn/exBryl6AjrtUvJE52aHQoY7hXfXYb OlIb7Dvcfbb6LI9/QZXtLQEvo44fdpXRYnAEmPXTEBwkiBcVMN7+9TguCNTEcq5R5Tfz y/Gw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si10749852ejb.494.2020.11.02.15.26.55; Mon, 02 Nov 2020 15:27:17 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727138AbgKBXYn (ORCPT + 99 others); Mon, 2 Nov 2020 18:24:43 -0500 Received: from gate.crashing.org ([63.228.1.57]:45052 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727122AbgKBXYm (ORCPT ); Mon, 2 Nov 2020 18:24:42 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 0A2NICji019700; Mon, 2 Nov 2020 17:18:12 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 0A2NI9MI019691; Mon, 2 Nov 2020 17:18:09 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 2 Nov 2020 17:18:09 -0600 From: Segher Boessenkool To: Borislav Petkov Cc: shuo.a.liu@intel.com, linux-kernel@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , Sean Christopherson , Yu Wang , Reinette Chatre , Yakui Zhao , Dave Hansen , Dan Williams , Fengwei Yin , Zhi Wang , Zhenyu Wang , Arvind Sankar , Peter Zijlstra , Nick Desaulniers Subject: Re: [PATCH v5 04/17] x86/acrn: Introduce hypercall interfaces Message-ID: <20201102231809.GC2672@gate.crashing.org> References: <20201019061803.13298-1-shuo.a.liu@intel.com> <20201019061803.13298-5-shuo.a.liu@intel.com> <20201102145657.GD15392@zn.tnic> <20201102160901.GU2672@gate.crashing.org> <20201102171950.GF15392@zn.tnic> <20201102181000.GX2672@gate.crashing.org> <20201102183430.GG15392@zn.tnic> <20201102200113.GY2672@gate.crashing.org> <20201102225439.GI15392@zn.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201102225439.GI15392@zn.tnic> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 02, 2020 at 11:54:39PM +0100, Borislav Petkov wrote: > On Mon, Nov 02, 2020 at 02:01:13PM -0600, Segher Boessenkool wrote: > > It just asks the general_operand function, which (for registers) accepts > > the hard registers that are accessible. This does include the float and > > vector etc. registers, normally. > > > > But you usually have a pseudo-register there (which is always allowed > > here), unless you used some register asm variable. > > You mean like this: > > --- > int main(void) > { > register float foo asm ("xmm0") = 0.99f; > > asm volatile("movl %0, %%r8d\n\t" > "vmcall\n\t" > :: "g" (foo)); > > return 0; > } > --- > > That works ok AFAICT: > > --- > > 0000000000000000
: > 0: 55 push %rbp > 1: 48 89 e5 mov %rsp,%rbp > 4: f3 0f 10 05 00 00 00 movss 0x0(%rip),%xmm0 # c > b: 00 > c: 66 0f 7e c0 movd %xmm0,%eax > 10: 41 89 c0 mov %eax,%r8d > 13: 0f 01 c1 vmcall > 16: b8 00 00 00 00 mov $0x0,%eax > 1b: 5d pop %rbp > 1c: c3 retq > > --- That is invalid actually: local register asm as input to an inline asm should use *that* register! This is all correct until LRA ("reload"). Not that "movl %xmm0,$eax" works, but at least it screams its head off, as it should. And then LRA puts it in %eax, a different register than asked for. > gcc smartypants shuffles it through a GPR before sticking it into %r8. > > It works too If I use a float immediate: > > --- > int main(void) > { > asm volatile("movl %0, %%r8d\n\t" > "vmcall\n\t" > :: "g" (0.99f)); > > return 0; > } > --- > > --- > 0000000000000000
: > 0: 55 push %rbp > 1: 48 89 e5 mov %rsp,%rbp > 4: 41 b8 a4 70 7d 3f mov $0x3f7d70a4,%r8d > a: 0f 01 c1 vmcall > d: b8 00 00 00 00 mov $0x0,%eax > 12: 5d pop %rbp > 13: c3 retq > --- (this one is correct code) > or maybe I'm missing some freaky way to specify the input operand so > that I can make it take a float register. But even if I could, it would > error out when generating the asm, I presume, due to invalid insn or > whatnot. Yes. But GCC doing what you should have said instead of doing what you said, is not good. > > And pseudos usually are allocated a simple integer register during > > register allocation, in an asm that is. > > Interesting. > > > > Might even make people copying from bad examples > > > to go look at the docs first... > > > > Optimism is cool :-) > > In my experience so far, documenting stuff better might not always bring > the expected results but sometimes it does move people in the most > unexpected way and miracles happen. > > :-))) Now if only we had time to document what we wrote! We *do* write docs to go with new code (maybe not enough always), but no one spends a lot of time on documenting the existing compiler, or with a larger view than just a single aspect of the compiler. Alas. Segher