From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74747C433DF for ; Wed, 3 Jun 2020 17:10:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4092920674 for ; Wed, 3 Jun 2020 17:10:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LV2TlVep" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4092920674 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgWuF-0004Bu-Ex for qemu-devel@archiver.kernel.org; Wed, 03 Jun 2020 13:10:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgWsz-0003EA-AT for qemu-devel@nongnu.org; Wed, 03 Jun 2020 13:09:05 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:48882 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jgWsx-0006nQ-Ey for qemu-devel@nongnu.org; Wed, 03 Jun 2020 13:09:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591204141; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rS446/KGlPZUtACxgdHjhWpFjUqIoulxEPtmo1bYVf0=; b=LV2TlVepKVhRgjhhvrCN0MQJLNkqhPkwZuxF3sboUFe38et6/6ypDe1pAlw7E1Ct/C0F2S BylCHJ1Xpc2nnGaOzYpJ+/gbLd4gl8LPhRAOlgQYW++NxFWvHwsE+/iNanC/ypg7zPu+la NqNPXF6m72QVY021lGGhUT8um6D76X8= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-7-m9Ewy3sgNJa5xoPzScr-oQ-1; Wed, 03 Jun 2020 13:09:00 -0400 X-MC-Unique: m9Ewy3sgNJa5xoPzScr-oQ-1 Received: by mail-wr1-f70.google.com with SMTP id e7so1332031wrp.14 for ; Wed, 03 Jun 2020 10:08:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rS446/KGlPZUtACxgdHjhWpFjUqIoulxEPtmo1bYVf0=; b=GGqAa68AqZyZtYFRi+q7WVtmODUS53ZDYtyd6BTfDm3XjsTiUCAVV1i8MpcPQCaamF t3ip20Pmr8IPiu2wnz5o0nuRYtkDt82WavffQXU9ll5EE3eq6+V2bpG2SahPeLvIfrQO OZzwdxOFcHqVQ4JMVdUF/VoXauIM0DWArLlH/jh1f8wLj55dDHpiEBnBtbmSJ00CBawO j4/GfHJ9EyBnhUsejs/VT4RLqSEGhOgQ3qaeNK7HKPcP1ZrEyRuyZV2Hh051Yz/OuRUU KKV7SeOEFySmP+rXfEcaYOpzKMQ6Fer4VsFfCKs3rYujwDYPF5eItkEc+TcwQHGAGU68 Lz8Q== X-Gm-Message-State: AOAM532JmZJJGD/WGT26Xt2wJBlWq5w7gMzx2F4ffpM/SDxAKs2E0Y0R rQsRysfojxPNfaM7OaeBWSHFmjPq3CZ2SFXVHqnYCLLPN2qua4GRYXrOQOAnZ16lJErysrjOaxk 8Xm2n5tAUYGoj7Dc= X-Received: by 2002:a1c:a74f:: with SMTP id q76mr154437wme.65.1591204138900; Wed, 03 Jun 2020 10:08:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwkCPAEMXCpG0Na33VwxpLRawCgnRsNwVIi22brbtvYEWZ1vj1f5fkIdqzSEPamlLCfBJurw== X-Received: by 2002:a1c:a74f:: with SMTP id q76mr154409wme.65.1591204138545; Wed, 03 Jun 2020 10:08:58 -0700 (PDT) Received: from [192.168.178.58] ([151.20.243.176]) by smtp.gmail.com with ESMTPSA id j5sm4281911wrm.57.2020.06.03.10.08.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jun 2020 10:08:57 -0700 (PDT) Subject: Re: [PATCH v3] xen: fix build without pci passthrough To: Anthony PERARD , qemu-devel@nongnu.org References: <20200603160442.3151170-1-anthony.perard@citrix.com> From: Paolo Bonzini Message-ID: <8bf5371c-713a-c9f4-fffb-4a2ddc50dd1b@redhat.com> Date: Wed, 3 Jun 2020 19:08:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200603160442.3151170-1-anthony.perard@citrix.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 01:12:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Eduardo Habkost , "Michael S. Tsirkin" , Paul Durrant , xen-devel@lists.xenproject.org, Roger Pau Monne , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 03/06/20 18:04, Anthony PERARD wrote: > From: Roger Pau Monne > > Xen PCI passthrough support may not be available and thus the global > variable "has_igd_gfx_passthru" might be compiled out. Common code > should not access it in that case. > > Unfortunately, we can't use CONFIG_XEN_PCI_PASSTHROUGH directly in > xen-common.c so this patch instead move access to the > has_igd_gfx_passthru variable via function and those functions are > also implemented as stubs. The stubs will be used when QEMU is built > without passthrough support. > > Now, when one will want to enable igd-passthru via the -machine > property, they will get an error message if QEMU is built without > passthrough support. > > Fixes: 46472d82322d0 ('xen: convert "-machine igd-passthru" to an accelerator property') > Reported-by: Roger Pau Monné > Signed-off-by: Anthony PERARD > --- > > Notes: > Changes in v3: > - reworked to use stubs instead of #ifdef CONFIG_XEN_PCI_PASSTHROUGH > CONFIG_XEN_PCI_PASSTHROUGH isn't available in xen-common.c > > moving CONFIG_XEN_PCI_PASSTHROUGH to be in config_host_mak isn't > really possible, or at least I didn't managed to make that work. > > hw/i386/pc_piix.c | 2 +- > hw/xen/xen-common.c | 4 ++-- > hw/xen/xen_pt.c | 12 +++++++++++- > hw/xen/xen_pt.h | 6 ++++-- > stubs/Makefile.objs | 1 + > stubs/xen-pt.c | 22 ++++++++++++++++++++++ > 6 files changed, 41 insertions(+), 6 deletions(-) > create mode 100644 stubs/xen-pt.c > > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c > index f66e1d73ce0b..347fb8c6c807 100644 > --- a/hw/i386/pc_piix.c > +++ b/hw/i386/pc_piix.c > @@ -375,7 +375,7 @@ static void pc_init_isa(MachineState *machine) > #ifdef CONFIG_XEN > static void pc_xen_hvm_init_pci(MachineState *machine) > { > - const char *pci_type = has_igd_gfx_passthru ? > + const char *pci_type = xen_igd_gfx_pt_enabled() ? > TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE; > > pc_init1(machine, > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c > index 70564cc952d5..dd2c22cc4c0b 100644 > --- a/hw/xen/xen-common.c > +++ b/hw/xen/xen-common.c > @@ -129,12 +129,12 @@ static void xen_change_state_handler(void *opaque, int running, > > static bool xen_get_igd_gfx_passthru(Object *obj, Error **errp) > { > - return has_igd_gfx_passthru; > + return xen_igd_gfx_pt_enabled(); > } > > static void xen_set_igd_gfx_passthru(Object *obj, bool value, Error **errp) > { > - has_igd_gfx_passthru = value; > + xen_igd_gfx_pt_set(value, errp); > } > > static void xen_setup_post(MachineState *ms, AccelState *accel) > diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c > index 81d5ad8da7f0..ab84443d5ec8 100644 > --- a/hw/xen/xen_pt.c > +++ b/hw/xen/xen_pt.c > @@ -65,7 +65,17 @@ > #include "qemu/range.h" > #include "exec/address-spaces.h" > > -bool has_igd_gfx_passthru; > +static bool has_igd_gfx_passthru; > + > +bool xen_igd_gfx_pt_enabled(void) > +{ > + return has_igd_gfx_passthru; > +} > + > +void xen_igd_gfx_pt_set(bool value, Error **errp) > +{ > + has_igd_gfx_passthru = value; > +} > > #define XEN_PT_NR_IRQS (256) > static uint8_t xen_pt_mapped_machine_irq[XEN_PT_NR_IRQS] = {0}; > diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h > index 179775db7b22..6e9cec95f3b7 100644 > --- a/hw/xen/xen_pt.h > +++ b/hw/xen/xen_pt.h > @@ -5,6 +5,9 @@ > #include "hw/pci/pci.h" > #include "xen-host-pci-device.h" > > +bool xen_igd_gfx_pt_enabled(void); > +void xen_igd_gfx_pt_set(bool value, Error **errp); > + > void xen_pt_log(const PCIDevice *d, const char *f, ...) GCC_FMT_ATTR(2, 3); > > #define XEN_PT_ERR(d, _f, _a...) xen_pt_log(d, "%s: Error: "_f, __func__, ##_a) > @@ -322,10 +325,9 @@ extern void *pci_assign_dev_load_option_rom(PCIDevice *dev, > unsigned int domain, > unsigned int bus, unsigned int slot, > unsigned int function); > -extern bool has_igd_gfx_passthru; > static inline bool is_igd_vga_passthrough(XenHostPCIDevice *dev) > { > - return (has_igd_gfx_passthru > + return (xen_igd_gfx_pt_enabled() > && ((dev->class_code >> 0x8) == PCI_CLASS_DISPLAY_VGA)); > } > int xen_pt_register_vga_regions(XenHostPCIDevice *dev); > diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs > index 6a9e3135e8f9..564527e00997 100644 > --- a/stubs/Makefile.objs > +++ b/stubs/Makefile.objs > @@ -40,6 +40,7 @@ stub-obj-y += target-get-monitor-def.o > stub-obj-y += vmgenid.o > stub-obj-y += xen-common.o > stub-obj-y += xen-hvm.o > +stub-obj-y += xen-pt.o > stub-obj-y += pci-host-piix.o > stub-obj-y += ram-block.o > stub-obj-y += ramfb.o > diff --git a/stubs/xen-pt.c b/stubs/xen-pt.c > new file mode 100644 > index 000000000000..2d8cac8d54b9 > --- /dev/null > +++ b/stubs/xen-pt.c > @@ -0,0 +1,22 @@ > +/* > + * Copyright (C) 2020 Citrix Systems UK Ltd. > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + */ > + > +#include "qemu/osdep.h" > +#include "hw/xen/xen_pt.h" > +#include "qapi/error.h" > + > +bool xen_igd_gfx_pt_enabled(void) > +{ > + return false; > +} > + > +void xen_igd_gfx_pt_set(bool value, Error **errp) > +{ > + if (value) { > + error_setg(errp, "Xen PCI passthrough support not built in"); > + } > +} > Queued, thanks (I have other conflicting patches in the queue). Paolo