From patchwork Mon Mar 11 18:02:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 10847977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C9E4139A for ; Mon, 11 Mar 2019 18:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78E5A1FEBD for ; Mon, 11 Mar 2019 18:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CFBB284F1; Mon, 11 Mar 2019 18:14:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E3E01FEBD for ; Mon, 11 Mar 2019 18:14:19 +0000 (UTC) Received: from localhost ([127.0.0.1]:38094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PRK-0002QZ-BW for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Mar 2019 14:14:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PGu-00030K-Fc for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3PGi-0002Ld-2l for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:25 -0400 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]:38776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3PGd-0002Dw-Ky for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:16 -0400 Received: by mail-qt1-x842.google.com with SMTP id s1so6129039qte.5 for ; Mon, 11 Mar 2019 11:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7rPHfXiOcpHxYxSc/kHk9IvcnpOOtggDU1BVuwjtYDw=; b=LPp24KpeeF6mJTHmQszt5a2qnTt+97MBjZy0XCSAhbKF20kOt9gCGdk4RS+MFWhdYp OxL/N/NWG+y/XIdiBWUDfY9QN45SGVSfzwm/7/5SkyD2P8RI+Vn1xF+LFS2xEPFmYnr4 F3tWDWWfSUENkfwOaU4MXirAcI1PKmeXLlE5jwgzE/yYO/DWRKrrqi1/cg4Ddr/KM5f6 pDrlahfwxHIh8xPnmiOSiDn2n7JczWbo427z8zNJ7Z8IsSJ3GqIkw5Mn913JinzUMeHZ kckVwuNh0dHwTONI+bKDehy1RAwlc8yM+PjGGuCcyssWEgxbU88Rv/8wK/4SMElD9ZKY IZzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7rPHfXiOcpHxYxSc/kHk9IvcnpOOtggDU1BVuwjtYDw=; b=GuBnFS3UE/QQNSVpz9zUfDUTfRmhBUC8X9s9Y/Np7KZst+qCedqPO4eAaPBgTnHaY0 afC97THb3VNTjWUJMw90izG46O7P67QDzQ1l5Lj7ZD2JNqVbdGjNTEU0AI7UCE2p3yXS dX8dlAoQPE8v58LZgIRKwp1rDgr7e8tZ63CMmqe4VLB1F/JWir9r0iNmWHyyc1gTX/Uy rqgq5I8jSsuEWgPvgZSG4Xn2/8gIyxyz4asBP6opSTQvIDSPiB6QtvHdVPKJJeAp/tF4 RjrDkfj4wV3WMKDFIyR5rwwu4s6OaxDJwURuhkDksK1++sTsHb2rp1653YVUdjIQj+jp dy0A== X-Gm-Message-State: APjAAAXhBTC19t+KCmCiZqBfyA3p14nEujPsBF2PaP8KrbS/di0TdHWX BZZMU2U9+a7UiZ14Aw+q6pWpFsZMD4U= X-Google-Smtp-Source: APXvYqziJ9SafszTJaceW7nKEsCc4sKaRZ/0ePJvnRe8bbPsxG6kwE88yyj9ya6JQIswTv4fyECJoQ== X-Received: by 2002:a0c:d0c9:: with SMTP id b9mr26552089qvh.95.1552327393689; Mon, 11 Mar 2019 11:03:13 -0700 (PDT) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:ba27:ebff:fee8:ce27]) by smtp.gmail.com with ESMTPSA id f126sm4687637qka.14.2019.03.11.11.03.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 11:03:12 -0700 (PDT) From: Jason Andryuk To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2019 14:02:11 -0400 Message-Id: <20190311180216.18811-2-jandryuk@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311180216.18811-1-jandryuk@gmail.com> References: <20190311180216.18811-1-jandryuk@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::842 Subject: [Qemu-devel] [PATCH 1/6] xen: Introduce -xen-stubdom option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Jason Andryuk , marmarek@invisiblethingslab.com, Paul Durrant , Paolo Bonzini , Anthony Perard , xen-devel@lists.xenproject.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP With Xen, QEMU can run isolated in a dedicated service VM - a stubdom. There are a few differences when running in a stubdom compared to dom0. Add the -xen-stubdom option to select this mode at runtime. The default is off. Signed-off-by: Jason Andryuk --- include/hw/xen/xen.h | 6 ++++++ qemu-options.hx | 7 +++++++ vl.c | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index ba039c146d..fed3611623 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -21,6 +21,7 @@ enum xen_mode { extern uint32_t xen_domid; extern enum xen_mode xen_mode; extern bool xen_domid_restrict; +extern bool xen_stubdom; extern bool xen_allowed; @@ -29,6 +30,11 @@ static inline bool xen_enabled(void) return xen_allowed; } +static inline bool xen_stubdom_enabled(void) +{ + return xen_stubdom; +} + int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num); void xen_piix3_set_irq(void *opaque, int irq_num, int level); void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len); diff --git a/qemu-options.hx b/qemu-options.hx index 1cf9aac1fe..ba56c3dd9a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3386,6 +3386,10 @@ DEF("xen-domid-restrict", 0, QEMU_OPTION_xen_domid_restrict, " to specified domain id. (Does not affect\n" " xenpv machine type).\n", QEMU_ARCH_ALL) +DEF("xen-stubdom", 0, QEMU_OPTION_xen_stubdom, + "-xen-stubdom specify QEMU is running in a stubdom, so certain\n" + " behavior changes. (Does not affect xenpv machine type).\n", + QEMU_ARCH_ALL) STEXI @item -xen-domid @var{id} @findex -xen-domid @@ -3396,6 +3400,9 @@ Attach to existing xen domain. libxl will use this when starting QEMU (XEN only). @findex -xen-domid-restrict Restrict set of available xen operations to specified domain id (XEN only). +@findex -xen-stubdom +@item -xen-stubdom +Run qemu in stubdom-mode (XEN only). ETEXI DEF("no-reboot", 0, QEMU_OPTION_no_reboot, \ diff --git a/vl.c b/vl.c index 4a350de5cd..0d04319d9b 100644 --- a/vl.c +++ b/vl.c @@ -206,6 +206,7 @@ bool xen_allowed; uint32_t xen_domid; enum xen_mode xen_mode = XEN_EMULATE; bool xen_domid_restrict; +bool xen_stubdom; static int has_defaults = 1; static int default_serial = 1; @@ -3796,6 +3797,13 @@ int main(int argc, char **argv, char **envp) } xen_domid_restrict = true; break; + case QEMU_OPTION_xen_stubdom: + if (!(xen_available())) { + error_report("Option not supported for this target"); + exit(1); + } + xen_stubdom = true; + break; case QEMU_OPTION_trace: g_free(trace_file); trace_file = trace_opt_parse(optarg); From patchwork Mon Mar 11 18:02:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 10847981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09495139A for ; Mon, 11 Mar 2019 18:17:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB5D328BA7 for ; Mon, 11 Mar 2019 18:17:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFA7628BDF; Mon, 11 Mar 2019 18:17:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8E79A28BDC for ; Mon, 11 Mar 2019 18:17:07 +0000 (UTC) Received: from localhost ([127.0.0.1]:38144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PU2-0004kx-Pc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Mar 2019 14:17:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PHA-0003Af-40 for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3PH8-0002gd-12 for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:47 -0400 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]:42651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3PH2-0002KB-PH for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:42 -0400 Received: by mail-qt1-x842.google.com with SMTP id u7so6108842qtg.9 for ; Mon, 11 Mar 2019 11:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rwip1nuAVYbjkkViy3FgTxhBpY/j8I1NfaRBBQVabgs=; b=VwCwJeIafO4nAvcQKFfc2AzaA5wwqab8jH4zLZlSuZdvNXg/F1CxhR01R8lnFNI4A3 GnAEowAlzUcy2JYbNIS+yLeZBX/bbANcu9hw/bok8PKXA9PLtFw+XgCYg77okGCxVqdI QqcOP08N82pV2A6bKWZJh7lqRmfk7uUQzBPMaD3nJlnqnwV+oEW27IMF0cidjg1M4TV2 WyyxRN1eLXQpOjtjT0kZupvESrGIci5dDAz86v+T90jHlGoh8qGp8nxQkqQlmSfzDkgq Fvv9SvagTFkWFUC1MMV4mF3addz0y+2DuNxTcMVBR4myKCnQrVm/5ct2d9mth6I1DUBT fIOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rwip1nuAVYbjkkViy3FgTxhBpY/j8I1NfaRBBQVabgs=; b=s8oXZIVBV5VMS+HSCHD8JcY+9VV1i1WUstVvXN+ABMLabYWUPnYwGpdhHV552Fa9Gc UI/5zRRWxWQ24JJm+bA4elODAYLS6DX/lWSrxzagBUHLm6Vhpr7+Jh9Pxr8f9nMHwoqr ZP9CmHEtmssH/OSxmkmiteP7YllOwUs5eP5U8Gjbx7Wwz63YAinW7/Yabb6MtBi5ltdq rlwZI1U41ZVglFsqSojeMOBf1Y4DQNI9ZEGlcCuHjvJpPKRj2UiBR9pBIFJRBBX4z1Pa J6jalx2O/qCk0MaUnMNW+gunxzID1AoOwii7JBfZEb/Bko8Pf2/HR7xLasTbXTeW5cJ7 mXyQ== X-Gm-Message-State: APjAAAXSKYVypfT/o3CljG+vsRc/Vb4ubGPKAP9Nd9kfw0qfklvD5jRt ceqB6cilggwhrtzgLZN8NsK7SnR/Wg0= X-Google-Smtp-Source: APXvYqwrKt3z08h5bHbW1bhIc50/qVY3twfcUHF1yZBGMlFTbzS7/FCoaDkmdIsPVgLw8K7vwo88wA== X-Received: by 2002:a0c:987a:: with SMTP id e55mr27336202qvd.21.1552327398103; Mon, 11 Mar 2019 11:03:18 -0700 (PDT) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:ba27:ebff:fee8:ce27]) by smtp.gmail.com with ESMTPSA id f126sm4687637qka.14.2019.03.11.11.03.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 11:03:17 -0700 (PDT) From: Jason Andryuk To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2019 14:02:12 -0400 Message-Id: <20190311180216.18811-3-jandryuk@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311180216.18811-1-jandryuk@gmail.com> References: <20190311180216.18811-1-jandryuk@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::842 Subject: [Qemu-devel] [PATCH 2/6] xen: Move xenstore initialization to common location X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Eduardo Habkost , Jason Andryuk , "Michael S. Tsirkin" , marmarek@invisiblethingslab.com, Paul Durrant , Paolo Bonzini , Anthony Perard , xen-devel@lists.xenproject.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP For the xen stubdom case, we'll want xenstore initialized, but we'll want to skip the rest of xen_be_init. Move the initialization to xen_hvm_init so we can conditionalize calling xen_be_init. xs_domain_open() is deprecated for xs_open(0), so make the replacement as well. Signed-off-by: Jason Andryuk --- hw/i386/xen/xen-hvm.c | 8 ++++++++ hw/xen/xen-legacy-backend.c | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 2939122e7c..c20c4b27f6 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -1487,6 +1487,14 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) xen_bus_init(); + xenstore = xs_open(0); + if (!xenstore) { + error_report("Can't connect to xenstored"); + goto err; + } + + qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL); + /* Initialize backend core & drivers */ if (xen_be_init() != 0) { error_report("xen backend core setup failed"); diff --git a/hw/xen/xen-legacy-backend.c b/hw/xen/xen-legacy-backend.c index 36fd1e9b09..bdf2fa917f 100644 --- a/hw/xen/xen-legacy-backend.c +++ b/hw/xen/xen-legacy-backend.c @@ -683,14 +683,6 @@ int xen_be_init(void) { xengnttab_handle *gnttabdev; - xenstore = xs_daemon_open(); - if (!xenstore) { - xen_pv_printf(NULL, 0, "can't connect to xenstored\n"); - return -1; - } - - qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL); - if (xen_xc == NULL || xen_fmem == NULL) { /* Check if xen_init() have been called */ goto err; From patchwork Mon Mar 11 18:02:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 10847975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA65C6C2 for ; Mon, 11 Mar 2019 18:13:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C82EE29221 for ; Mon, 11 Mar 2019 18:13:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC0A72922D; Mon, 11 Mar 2019 18:13:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6C14D2901B for ; Mon, 11 Mar 2019 18:13:10 +0000 (UTC) Received: from localhost ([127.0.0.1]:38084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PQD-0001eL-KR for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Mar 2019 14:13:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PH6-00037x-5I for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3PH1-0002e5-5u for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:42 -0400 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:42652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3PGy-0002Oc-GN for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:37 -0400 Received: by mail-qt1-x843.google.com with SMTP id u7so6109064qtg.9 for ; Mon, 11 Mar 2019 11:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zcglz1eNxE2q7OWiP9FjJNKkviuZSiRm7EMY+ZmdRmw=; b=sl0TsJ5569h7iMxH7Oec97j8DcO6DaOnOQY5wQ/GHuflUmVBB800b0rk8xw16vZhO6 k+ov6WjMTq71viKTILfF48eZkhY6nv87nd8YXeNPgmK9vkuSoNSf1Wv17iI9YlCpbFWJ YTaPafUu4091/TMhZdMvUWq74Sz9eHysxIZSMfmbhNdadbXSoEzDV8IjcP0mjHuC75PZ hfSJRoncWaeXQn30RoSLKCJ4xfrJbW7Xg9kpj+tWVktgeW5uc0L0pm1YsB/CHbuumUwq PxoOV3vPhBidhbPLSQ1Vf8Uegb1F10hPsYvEDWyTGqGCCroOOQkyVPVUI6gxvfAoRNMF d/Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zcglz1eNxE2q7OWiP9FjJNKkviuZSiRm7EMY+ZmdRmw=; b=YDKYHaSw4QwDeLJn9EttRBb4SWIx8vh1iZl89KSR+Onzn1u12wtz26rprLMcy8RpFg 0ZRK1m2CvgErrfjG3w1hiaLw/xcqwmD99mbpf6Nxhcq30oN7tCzLUg6YyXmtU3CVp4/t iC2zIYD3TmlRE7KQNBOYXsiSrIFxhC4IThlGcfes0K34hiwOd6BgAX5/klSYiMU1/OBA 9HdIB6f7iGL/i5GdkBeVuSzJ/PykYecWcv9nZJ/56LnaZ5tVlK9DqFU+rH9hXNqsw2GP /2q2pxnJLb7CSnE/Ef8tt25RZtwJ9h5ICi8UiCTJt03L/Fw2YelkPt241yUSn4zgVeTT bsig== X-Gm-Message-State: APjAAAUFewyct99PDL4QPw2GVD60BXpKI6IpQ57Sv1c0bsuwXyJm5q/K 1LbRvKSlPC6ESbHFxjaPWbrjCXdT/bI= X-Google-Smtp-Source: APXvYqxkC50vIl8odwljXBngFsqQe8eDJncRXBUFGzEKwlLGQSGSbiXNBnMxjIdb6xTVul96sBgdSg== X-Received: by 2002:ac8:2ad9:: with SMTP id c25mr26385794qta.250.1552327401631; Mon, 11 Mar 2019 11:03:21 -0700 (PDT) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:ba27:ebff:fee8:ce27]) by smtp.gmail.com with ESMTPSA id f126sm4687637qka.14.2019.03.11.11.03.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 11:03:20 -0700 (PDT) From: Jason Andryuk To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2019 14:02:13 -0400 Message-Id: <20190311180216.18811-4-jandryuk@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311180216.18811-1-jandryuk@gmail.com> References: <20190311180216.18811-1-jandryuk@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::843 Subject: [Qemu-devel] [PATCH 3/6] xen: Skip backend initialization for stubdom X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Eduardo Habkost , Jason Andryuk , "Michael S. Tsirkin" , marmarek@invisiblethingslab.com, Paul Durrant , Paolo Bonzini , Anthony Perard , xen-devel@lists.xenproject.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When QEMU is running in a stubdom, it does not provide any Paravirtualized backends. Those still run in dom0 or another driver domain. Therefore we skip backend initialization (xen_bus_init and xen_be_init) for the stubdom case. Original patch by Anthony PERARD Signed-off-by: Jason Andryuk Reviewed-by: Paul Durrant --- hw/i386/xen/xen-hvm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index c20c4b27f6..4b62f070cb 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -1485,8 +1485,6 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) QLIST_INIT(&state->dev_list); device_listener_register(&state->device_listener); - xen_bus_init(); - xenstore = xs_open(0); if (!xenstore) { error_report("Can't connect to xenstored"); @@ -1495,12 +1493,16 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL); - /* Initialize backend core & drivers */ - if (xen_be_init() != 0) { - error_report("xen backend core setup failed"); - goto err; + if (!xen_stubdom_enabled()) { + xen_bus_init(); + + /* Initialize backend core & drivers */ + if (xen_be_init() != 0) { + error_report("xen backend core setup failed"); + goto err; + } + xen_be_register_common(); } - xen_be_register_common(); QLIST_INIT(&xen_physmap); xen_read_physmap(state); From patchwork Mon Mar 11 18:02:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 10847983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 943A91874 for ; Mon, 11 Mar 2019 18:19:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F77928BA7 for ; Mon, 11 Mar 2019 18:19:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D60028FFC; Mon, 11 Mar 2019 18:19:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 00E7B28BA7 for ; Mon, 11 Mar 2019 18:19:57 +0000 (UTC) Received: from localhost ([127.0.0.1]:38164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PWn-0006ci-9M for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Mar 2019 14:19:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PHA-0003Ag-4Z for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3PH8-0002h7-6S for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:47 -0400 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]:35270) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3PH6-0002RB-3Z for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:46 -0400 Received: by mail-qk1-x743.google.com with SMTP id z13so3276184qki.2 for ; Mon, 11 Mar 2019 11:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wCjs9cwkqED/q+uvu13DGjKTcQtyMpKWJlEv6QgrmoY=; b=ZohQrGvmhUl5FnJveSZi0STUWx/I4HEcSIE+a2pnEe2Mv55VgLetoFivfJBMOJPPGV SInQxdNUHK2niCZ+VzsGbaO9BCd5EwB74Yt8JZdphFnmw17Pw/J/ZNzSeJtYs3X9PCwO mW1NRq2kfq6Ct2o36XZbnM8oVzTyPFWAnw5y7es4PEAo9Kuy9LM32a8frY99EQxVk2CG C9ebXCbe5Tww2GO4MUtCHx7FaewIojAUy2tEduCEnSQ9dOhgP2wuK1BQ9cCGqLwZ1Yy4 CyOeE1en8pn6HUNLOqJxwwnDkxeBG8oeB45EhPeAJ6rodvCTzul9XJXiMeVvSVvSKy2g HBJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wCjs9cwkqED/q+uvu13DGjKTcQtyMpKWJlEv6QgrmoY=; b=NCuoMJSy5ehziPE0fAimIpoGsWWSmDxEOkyW8llHmxDOjUSNy1wxypiMx5IdZu9ysV HYrkkkF3yQ+HJerCURV1DRdQlLP1mO4x0fy6dQvB7z4uax+DeYIj1QVt9XZgiMMeL+mF ArjSRg0j10sb2qtMABaRxWgLgmZKn0V2i38qfIaVVpX/2hniAj7wMaT1OdQX+KbyDDGi UUH9zSWL84YIU6fDfReKpycMsSQJ2yk3WeUt/5j5xVgJMc/EbGLNbSCG1XccJ0q+S9hk EKEEaWzVD2KFHYjQENJXDahpILyhVZh/go9Enuk5WC53HbvTJW/Xnl7y6ahMss1xQRQi fCgQ== X-Gm-Message-State: APjAAAX/QPSjlGIX2ZgDnsoEcvgSZ8oTaaKGQZTrm0BfUm/826DfLINh mtE0fVn19hnewHA3/lx2sP6dXEuv3Pw= X-Google-Smtp-Source: APXvYqyDYKLNbABEzEgzTq2vtZbunx/1mGs9Ru9MHYt21yiT7iWrWdj123HD5QtTbLC1GupMEREW8g== X-Received: by 2002:a37:3541:: with SMTP id c62mr24767936qka.240.1552327404235; Mon, 11 Mar 2019 11:03:24 -0700 (PDT) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:ba27:ebff:fee8:ce27]) by smtp.gmail.com with ESMTPSA id f126sm4687637qka.14.2019.03.11.11.03.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 11:03:23 -0700 (PDT) From: Jason Andryuk To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2019 14:02:14 -0400 Message-Id: <20190311180216.18811-5-jandryuk@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311180216.18811-1-jandryuk@gmail.com> References: <20190311180216.18811-1-jandryuk@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::743 Subject: [Qemu-devel] [PATCH 4/6] xen: Set HVM_PARAM_DM_DOMAIN for stubdom on older Xen X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Jason Andryuk , marmarek@invisiblethingslab.com, Paul Durrant , Anthony Perard , xen-devel@lists.xenproject.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When running in a stubdom, we have to inform the hypervisor that the stubdom and not dom0 is handling the device model. Explicitly created ioreq servers are fine, but a call to HVM_PARAM_DM_DOMAIN is needed for the default ioreq server. Xen 4.12 removes the default ioreq server. With that, Xen started returning an error when setting HVM_PARAM_DM_DOMAIN. Put the HVM_PARAM_DM_DOMAIN call in the version compatibility header. When we fallback to the default ioreq server, issue the call and don't bother to check the return value. Original patch by Anthony PERARD Signed-off-by: Jason Andryuk --- include/hw/xen/xen_common.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 9a8155e172..f59f841a43 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -616,6 +616,11 @@ static inline void xen_create_ioreq_server(domid_t dom, *ioservid = 0; use_default_ioreq_server = true; + + if (xen_stubdom_enabled()) { + xc_hvm_param_set(xen_xc, xen_domid, HVM_PARAM_DM_DOMAIN, DOMID_SELF); + } + trace_xen_default_ioreq_server(); } From patchwork Mon Mar 11 18:02:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 10847979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16EAD139A for ; Mon, 11 Mar 2019 18:15:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03EB328BA7 for ; Mon, 11 Mar 2019 18:15:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E969828BDF; Mon, 11 Mar 2019 18:14:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8879E28BA7 for ; Mon, 11 Mar 2019 18:14:59 +0000 (UTC) Received: from localhost ([127.0.0.1]:38097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PRy-00036E-T1 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Mar 2019 14:14:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PHB-0003Ai-EX for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3PHA-0002id-Ge for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:49 -0400 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:35005) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3PHA-0002Ue-AG for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:48 -0400 Received: by mail-qt1-x843.google.com with SMTP id b16so5030812qtt.2 for ; Mon, 11 Mar 2019 11:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WeVoF9PrMuQFqq85MC3JztPLLMKfH/BmcSYZTIUdjfM=; b=aMQTJuzAGXXzds92Thgctd89R4sNn01ppbvDKulySBG65eCL4prmBfdz3pE5b7dhQp 4vdOjNLUjYxWvswdZwciSS6WwOF838u2YLttHIa4fJWdtvl2MqhbbiUI2D3ek6BMY7pM vxoV9phuViTXu9bTAEfkn2WNV4nEBp7L8+M7k3DUj+r0na31kcrpi1T1zipgSVVs6pE+ Ei8X3dHnxogrGPV4hew6HfsXwfos+hVMHHZKEHD+cqg1aNkY/OF4QXn4ivTw1hg1uhGw l6GeR/5Z7AxDf6ECAgVflBQjSG/V+zgC/IynDNxESR9R0daH1Q4njbgRqMDtoymzCWOF ZCmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WeVoF9PrMuQFqq85MC3JztPLLMKfH/BmcSYZTIUdjfM=; b=ab0CBOZLvPodm6r7s1h6oPown19Bh6hOTvMrokydX2aA/FyhYY0d6M9Qmt4IuxlvuC G+3SNWwDfeJy+7nmoKFGvRDsjT+8oRdPgh2AOHtovOSAd6Wci+1VvO9ian+BddDMuMPq g5RfSrSO4vomPw2w8AEtOJD2bzqcjwHDFbxs1mKJBfP9EQT1OXzEOhpZlxL7i8YVd+uG FZ6EVBJPRL26dF193i3r9NRjdAxlNpGMBHLnf+lUhSQEpd9zNo7SqW1B0mVSc/cqu1SX NKGIy+37KPeIgbTDdPiwxJNX9k05ipK+HC6zGFyrWiUj+Wan/gkQt9YA7bmNR0lNtaEq ggPw== X-Gm-Message-State: APjAAAUCMA1jYDnegNP6q0pX5B4/tIbipFxkGVZvbrHlHRCie+Skdof1 avDHLnKC0K31Yk1SC58aHGSl6B8sok0= X-Google-Smtp-Source: APXvYqzLD3q9ahjdG6tj7XkIoyztEZUzB1FUs0jJTqvqBpH+ZMZiDc1wFgrEl3W5ZeQHVaomln7tBA== X-Received: by 2002:ac8:3554:: with SMTP id z20mr591129qtb.150.1552327407902; Mon, 11 Mar 2019 11:03:27 -0700 (PDT) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:ba27:ebff:fee8:ce27]) by smtp.gmail.com with ESMTPSA id f126sm4687637qka.14.2019.03.11.11.03.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 11:03:27 -0700 (PDT) From: Jason Andryuk To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2019 14:02:15 -0400 Message-Id: <20190311180216.18811-6-jandryuk@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311180216.18811-1-jandryuk@gmail.com> References: <20190311180216.18811-1-jandryuk@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::843 Subject: [Qemu-devel] [PATCH 5/6] xen-pt: Hide MSI-X from xen stubdoms X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James McKenzie , Stefano Stabellini , Jason Andryuk , marmarek@invisiblethingslab.com, Paul Durrant , Anthony Perard , xen-devel@lists.xenproject.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP MSI-X is not supported in Xen stubdoms, so it must be disabled. Use the existing xen_pt_hide_dev_cap to hide when running under -xen-stubdom. A compile-time patch was originally written by James McKenzie Signed-off-by: Jason Andryuk --- hw/xen/xen_pt_config_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c index 31ec5add1d..b827a493ea 100644 --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -54,6 +54,9 @@ static int xen_pt_hide_dev_cap(const XenHostPCIDevice *d, uint8_t grp_id) return 1; } break; + case PCI_CAP_ID_MSIX: + /* stubdoms don't support MSI-X so skip it. */ + return xen_stubdom_enabled(); } return 0; } From patchwork Mon Mar 11 18:02:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 10847969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16C496C2 for ; Mon, 11 Mar 2019 18:07:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02FA7292B1 for ; Mon, 11 Mar 2019 18:07:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB630292C5; Mon, 11 Mar 2019 18:07:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 917B3292B1 for ; Mon, 11 Mar 2019 18:07:45 +0000 (UTC) Received: from localhost ([127.0.0.1]:37998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PKy-0006Es-Oo for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Mar 2019 14:07:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3PHA-0003Ah-Vy for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3PH9-0002hq-W6 for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:48 -0400 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]:34643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3PH6-0002Wv-4x for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:03:46 -0400 Received: by mail-qk1-x744.google.com with SMTP id n6so3279391qkf.1 for ; Mon, 11 Mar 2019 11:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2pZYwQaJACSsOGn4WGDZJwf1nT2bs3mpeMm63NmR5yo=; b=DzklfA1n+P0B8jvdOePPjPzyO2hOpiUNBaaHiUUL1cpJ37o3DJUr4Eh6T9IeJt5xiz G1F3o6ivdYOpfZ6cpLD0nma64RB5G/FwLLJryzbGg3oNMGZF8MWjhUrMkDqoYcT1Rh4u rbmXe9AoNxhZZT9KzjJdRXzIYZcCz2EF9llEarlokejiP3Fekez3z2hi7JZhfU10LGQS A/y6MqBioiTVS1qxC3QbFUZX+kPWkGzrFKtshHjwFpjQdGYoAmty8sIMFC/duJfJ4kg7 TIpoFgnfTk++x+6p3eu6LFCue9cPXvoeGwjXqFZd4iAJGAiGPbEsv6W4Q9grWeqtdTbV qKyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2pZYwQaJACSsOGn4WGDZJwf1nT2bs3mpeMm63NmR5yo=; b=eibgyW9j4V+TEH5Ph6QiGia3/5psZ6RqATnMvdxqgsiy/wxUZKR7xwvUdzmN/EGI6W 5H8j4dNLXRKl3pOJbIJiv85XeJaO7mqHzd88HERsZN0lfnoNGTDVc1o/BHIzBOyyLjOx 97qMdPpXjd2ufXoo06I0HFTxK61d3/btT2CxRBWupP+YGWkvUXK7viWWGGTV0qAx8s8B WVN7IMc+j6vPTBEkTTLV3WZ+Xf/QMrLwD0d7iXbCdThcMoP7uGM6j6Ayhh4kbobW+bpH MG/RJkS+ZvVrWKw9Lw1KD5TPszyefNh6hEEcAx7C2uD/rzM4wrHDn1rhaeMCmJhax4XD 47Xw== X-Gm-Message-State: APjAAAX6VkrwYqGviV8tjYqqTkwKoGPb/P/Px50wm5BHA605zuP9MHTL fY2nzUDZ8RaUNVnv6qK49tkzufkqar4= X-Google-Smtp-Source: APXvYqyPE+SDB8Bko5uGxRwWOq/nef328TC8LKIE58vmCwuBBmxmlx4b3IYIAEyZiIgH8YA8TkfiPQ== X-Received: by 2002:a37:4a84:: with SMTP id x126mr25189066qka.326.1552327410658; Mon, 11 Mar 2019 11:03:30 -0700 (PDT) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:ba27:ebff:fee8:ce27]) by smtp.gmail.com with ESMTPSA id f126sm4687637qka.14.2019.03.11.11.03.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 11:03:29 -0700 (PDT) From: Jason Andryuk To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2019 14:02:16 -0400 Message-Id: <20190311180216.18811-7-jandryuk@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311180216.18811-1-jandryuk@gmail.com> References: <20190311180216.18811-1-jandryuk@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::744 Subject: [Qemu-devel] [PATCH 6/6] xen-pt: Round pci regions sizes to XEN_PAGE_SIZE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Jason Andryuk , marmarek@invisiblethingslab.com, Simon Gaiser , Paul Durrant , Anthony Perard , xen-devel@lists.xenproject.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Simon Gaiser If a pci memory region has a size < XEN_PAGE_SIZE it can get located at an address which is not page aligned. This breaks the memory mapping via xc_domain_memory_mapping since this function is page based and the "offset" is therefore lost. Without this patch you will see error like this in the stubdom log: [00:05.0] xen_pt_bar_read: Error: Should not read BAR through QEMU. @0x0000000000000004 QubesOS/qubes-issues#2849 Signed-off-by: Simon Gaiser Signed-off-by: Jason Andryuk --- hw/xen/xen_pt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 5539d56c3a..7f680442ee 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -449,9 +449,10 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s, uint16_t *cmd) /* Register PIO/MMIO BARs */ for (i = 0; i < PCI_ROM_SLOT; i++) { XenHostPCIIORegion *r = &d->io_regions[i]; + pcibus_t r_size = r->size; uint8_t type; - if (r->base_addr == 0 || r->size == 0) { + if (r->base_addr == 0 || r_size == 0) { continue; } @@ -469,15 +470,18 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s, uint16_t *cmd) type |= PCI_BASE_ADDRESS_MEM_TYPE_64; } *cmd |= PCI_COMMAND_MEMORY; + + /* Round up to a full page for the hypercall. */ + r_size = (r_size + XC_PAGE_SIZE - 1) & XC_PAGE_MASK; } memory_region_init_io(&s->bar[i], OBJECT(s), &ops, &s->dev, - "xen-pci-pt-bar", r->size); + "xen-pci-pt-bar", r_size); pci_register_bar(&s->dev, i, type, &s->bar[i]); XEN_PT_LOG(&s->dev, "IO region %i registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64" type: %#x)\n", - i, r->size, r->base_addr, type); + i, r_size, r->base_addr, type); } /* Register expansion ROM address */