From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gRy13-00070U-VN for mharc-grub-devel@gnu.org; Wed, 28 Nov 2018 06:28:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRy11-0006zn-GC for grub-devel@gnu.org; Wed, 28 Nov 2018 06:28:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRy0y-0007iX-Qt for grub-devel@gnu.org; Wed, 28 Nov 2018 06:28:23 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:37018) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRy0y-0007hh-4M for grub-devel@gnu.org; Wed, 28 Nov 2018 06:28:20 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wASBIvIh179600; Wed, 28 Nov 2018 11:28:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=ZEvxBeX4uthBlVImFZ9QYbR2JPeR50x6qPngbO17s2I=; b=HkLsaothjbJRR11XSyIlfHhD3K7eEp+IEfqbFTzwTryOAbO+nZ/tI88JIJBYTBNgre5Q gk1vvfSALwu/By5wBVQELWesnmcQZboN0vmXx/fecNI4jc4Z7KWeYl31Bq6ywjdM1kZ0 Zo4hlyA6M6aZwYqvSd/jOP3SY71/yRZalsUuj++V1ewOaLQGlEnNm+zPHeTDQ6vDUjpt aH8jd6YDK55yo092hAHTz0s+NZMDNx+NIFipK8M3CcXvgI65neBuwI1U5zcDpZY3zCvy 3bFY9DMdthuIIqK6jkOzHM3sb9uyv17Ktha9HqbxKFN0LvIpKlQ8dEp4rzwyDdRI+Oi7 wQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2nxx2u9n3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Nov 2018 11:28:16 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wASBSFfW031360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Nov 2018 11:28:15 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wASBSCD9023511; Wed, 28 Nov 2018 11:28:12 GMT Received: from tomti.i.net-space.pl (/10.175.222.155) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Nov 2018 03:28:12 -0800 Date: Wed, 28 Nov 2018 12:28:08 +0100 From: Daniel Kiper To: Juergen Gross Cc: grub-devel@gnu.org, xen-devel@lists.xen.org, phcoder@gmail.com, roger.pau@citrix.com, hans@knorrie.org Subject: Re: [PATCH v5 11/20] xen: setup hypercall page for PVH Message-ID: <20181128112808.uikn75y2rmcoqma6@tomti.i.net-space.pl> References: <20181121142855.13537-1-jgross@suse.com> <20181121142855.13537-12-jgross@suse.com> <20181127203110.bcti52xm2jnqux5k@tomti.i.net-space.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181127203110.bcti52xm2jnqux5k@tomti.i.net-space.pl> User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9090 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=827 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811280103 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Nov 2018 11:28:24 -0000 On Tue, Nov 27, 2018 at 09:31:10PM +0100, Daniel Kiper wrote: > On Wed, Nov 21, 2018 at 03:28:46PM +0100, Juergen Gross wrote: > > Add the needed code to setup the hypercall page for calling into the > > Xen hypervisor. > > > > Import the XEN_HVM_DEBUGCONS_IOPORT define from Xen unstable into > > include/xen/arch-x86/xen.h > > > > Signed-off-by: Juergen Gross [...] > > +int > > +grub_xen_hypercall (grub_uint32_t callno, grub_uint32_t a0, > > + grub_uint32_t a1, grub_uint32_t a2, > > + grub_uint32_t a3, grub_uint32_t a4, > > + grub_uint32_t a5 __attribute__ ((unused))) > > +{ > > + grub_uint32_t __res, dummy; > > + > > + asm volatile ("call *%[callno]" > > + : "=a" (__res), "=b" (dummy), "=c" (dummy), "=d" (dummy), > > + "=S" (dummy), "=D" (dummy) > > + : "1" (a0), "2" (a1), "3" (a2), "4" (a3), "5" (a4), > > + [callno] "a" (&hypercall_page[callno * 32]) > > + : "memory"); > > Have you tried "+b", "+c", ... instead of "=b", "=c", ...? I have done some experiments. Your code: grub_uint32_t __res, dummy; asm volatile ("call *%[callno]" : "=a" (__res), "=b" (dummy), "=c" (dummy), "=d" (dummy), "=S" (dummy), "=D" (dummy) : "1" (a0), "2" (a1), "3" (a2), "4" (a3), "5" (a4), [callno] "a" (&hypercall_page[callno * 32]) : "memory"); ... generates this assembly: 0000048e : 48e: 55 push %ebp 48f: 89 e5 mov %esp,%ebp 491: 57 push %edi 492: 56 push %esi 493: 53 push %ebx 494: c1 e0 05 shl $0x5,%eax 497: 05 00 10 00 00 add $0x1000,%eax 49c: 89 d3 mov %edx,%ebx 49e: 8b 55 08 mov 0x8(%ebp),%edx 4a1: 8b 75 0c mov 0xc(%ebp),%esi 4a4: 8b 7d 10 mov 0x10(%ebp),%edi 4a7: ff d0 call *%eax 4a9: 5b pop %ebx 4aa: 5e pop %esi 4ab: 5f pop %edi 4ac: 5d pop %ebp 4ad: c2 10 00 ret $0x10 Mine code: grub_uint32_t __res; asm volatile ("call *%[callno]" : "=a" (__res), "+b" (a0), "+c" (a1), "+d" (a2), "+S" (a3), "+D" (a4) : [callno] "rm" (&hypercall_page[callno * 32]) : "memory"); ... generates this assembly: 0000048e : 48e: 55 push %ebp 48f: 89 e5 mov %esp,%ebp 491: 57 push %edi 492: 56 push %esi 493: 53 push %ebx 494: c1 e0 05 shl $0x5,%eax 497: 05 00 10 00 00 add $0x1000,%eax 49c: 89 d3 mov %edx,%ebx 49e: 8b 55 08 mov 0x8(%ebp),%edx 4a1: 8b 75 0c mov 0xc(%ebp),%esi 4a4: 8b 7d 10 mov 0x10(%ebp),%edi 4a7: ff d0 call *%eax 4a9: 5b pop %ebx 4aa: 5e pop %esi 4ab: 5f pop %edi 4ac: 5d pop %ebp 4ad: c2 10 00 ret $0x10 So, both are equal but mine seems a bit simpler. And I think that you can drop "__" from __res variable. Daniel