From patchwork Thu Oct 17 06:27:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 3058841 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A3A1BBF924 for ; Thu, 17 Oct 2013 06:28:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CBF8E2039F for ; Thu, 17 Oct 2013 06:28:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C609F201BF for ; Thu, 17 Oct 2013 06:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751311Ab3JQG14 (ORCPT ); Thu, 17 Oct 2013 02:27:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65040 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099Ab3JQG1z (ORCPT ); Thu, 17 Oct 2013 02:27:55 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9H6RrBi023611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Oct 2013 02:27:53 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-4-228.tlv.redhat.com [10.35.4.228]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9H6Rqhm027473; Thu, 17 Oct 2013 02:27:53 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id DA0AE18D477; Thu, 17 Oct 2013 09:27:51 +0300 (IDT) Date: Thu, 17 Oct 2013 09:27:51 +0300 From: Gleb Natapov To: "Michael S. Tsirkin" Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, pbonzini@redhat.com Subject: Re: [PATCH] kvm-unittest: fix build with gcc 4.3.X and older Message-ID: <20131017062751.GK15657@redhat.com> References: <20131016194653.GA10517@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20131016194653.GA10517@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_FRT_BELOW2, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Oct 16, 2013 at 10:46:53PM +0300, Michael S. Tsirkin wrote: > Old GCC didn't let you reference variable by > number if it is listed with a specific register > constraint, on the assumption you can just > use the register name explicitly. > > Build fails with errors like this: > a.c:6: error: invalid 'asm': invalid operand code 'd' > Is it worth to support such ancient compiler? Nobody complained till now. BTW with your patch I still cannot compile with 4.2: x86/s3.c: In function 'main': x86/s3.c:145: error: inconsistent operand constraints in an 'asm' > To fix, let's just use %eax %al etc. > Only %d0 does not work and dropping "d" fixes it since compiler can figure out correct register from variable size. The patch bellow fixes compilation for 4.2. Reviewed-by: Paolo Bonzini --- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/lib/x86/pci.c b/lib/x86/pci.c index f95cd88..231668a 100644 --- a/lib/x86/pci.c +++ b/lib/x86/pci.c @@ -3,13 +3,13 @@ static void outl(unsigned short port, unsigned val) { - asm volatile("outl %d0, %w1" : : "a"(val), "Nd"(port)); + asm volatile("outl %0, %w1" : : "a"(val), "Nd"(port)); } static unsigned inl(unsigned short port) { unsigned data; - asm volatile("inl %w1, %d0" : "=a"(data) : "Nd"(port)); + asm volatile("inl %w1, %0" : "=a"(data) : "Nd"(port)); return data; } static uint32_t pci_config_read(pcidevaddr_t dev, uint8_t reg) diff --git a/x86/s3.c b/x86/s3.c index 71d3ff9..d568aa7 100644 --- a/x86/s3.c +++ b/x86/s3.c @@ -143,14 +143,14 @@ static inline int rtc_in(u8 reg) { u8 x = reg; asm volatile("outb %b1, $0x70; inb $0x71, %b0" - : "+a"(x) : "0"(x)); + : "=a"(x) : "0"(x)); return x; } static inline void rtc_out(u8 reg, u8 val) { asm volatile("outb %b1, $0x70; mov %b2, %b1; outb %b1, $0x71" - : "+a"(reg) : "0"(reg), "ri"(val)); + : "=a"(reg) : "0"(reg), "ri"(val)); } extern char resume_start, resume_end; diff --git a/x86/vmexit.c b/x86/vmexit.c index 3b945de..7e9af15 100644 --- a/x86/vmexit.c +++ b/x86/vmexit.c @@ -26,7 +26,7 @@ static void outw(unsigned short port, unsigned val) static void outl(unsigned short port, unsigned val) { - asm volatile("outl %d0, %w1" : : "a"(val), "Nd"(port)); + asm volatile("outl %0, %w1" : : "a"(val), "Nd"(port)); } static unsigned int inb(unsigned short port)