From patchwork Sat Jun 11 16:43:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Zmudzinski X-Patchwork-Id: 12878583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06525C43334 for ; Sat, 11 Jun 2022 16:44:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.347300.573567 (Exim 4.92) (envelope-from ) id 1o04DG-0004eU-F6; Sat, 11 Jun 2022 16:43:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 347300.573567; Sat, 11 Jun 2022 16:43:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o04DG-0004eN-CL; Sat, 11 Jun 2022 16:43:50 +0000 Received: by outflank-mailman (input) for mailman id 347300; Sat, 11 Jun 2022 16:43:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o04DE-0004eH-Kt for xen-devel@lists.xenproject.org; Sat, 11 Jun 2022 16:43:49 +0000 Received: from sonic304-24.consmr.mail.gq1.yahoo.com (sonic304-24.consmr.mail.gq1.yahoo.com [98.137.68.205]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a8656465-e9a5-11ec-bd2c-47488cf2e6aa; Sat, 11 Jun 2022 18:43:46 +0200 (CEST) Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.gq1.yahoo.com with HTTP; Sat, 11 Jun 2022 16:43:43 +0000 Received: by hermes--canary-production-bf1-856dbf94db-ld7kl (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 10a8310a1deef4c241e871970cd315d5; Sat, 11 Jun 2022 16:43:39 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a8656465-e9a5-11ec-bd2c-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1654965823; bh=uKipQ9GESCapGnwnZNCK+G59mD+JZ/aP2507Xtz69BU=; h=From:To:Cc:Subject:Date:References:From:Subject:Reply-To; b=rj3EKPf8cHONK1o3O/aL8eLuOd7jPEM5O7se7HquQi0H1Ar0Udg9WyciIQJ630X+hgudHPynMV+haJAl3umomxdUtOiCumbxuNY3Bi5C6fjMB7pOuTuHgZ+hKgIBK2i4JYcWNpSdDknwcxKOMqYgwq56hw/VSgyEr0+9e9xIxJGkkE4uuWcFzwgMDmIlc8dufD26cLbr0lCaD0HS81aOPQ33uAvjtmSuijLPNlcShceo8zntuboRhXfBMsOzF7LQPi88i+zT78NiEJdronIuh58zqeWXK4JDcR3Bp69UbkS1AZ9uRs5REvjtrNBBUZTcsXPIyC92gmeLN9bj3O7vyg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1654965823; bh=DA2vKnKf+zEJ+BS8cQu11up+Ie3P63di7K7wlyd/Bal=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Fbgz+GJjm1oytjNO04YnchJYs1BpSV9dnHS5hE5XKg1rCbrfwBqU/GS+WJZFDDW6hHMhENR5VkyWZE6/uz/JOvLHUTC+kYzho3uhGov8Dshvz2sXwHjE6DzUkBDINbUT7l/jJxrdlGr8bqBgCzQNIrPpFgBbBa0FeR6zw70JHBltxqIK456RVBnfzLiirbWqrV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QZrmY70BmJDr5cA3yx0JUssXePar4qj988aWn9GGWnftZd 51uTNgKeNjVLb0CMrYyFSv4xJLOgwkBq4CxjQ_LOrert9sKtRRRVKD1YZyPVDQmSCo3JJKTJ6LCh uXAvH16Ou5_C0Rfs7Uqn.GXNfsR04_JPmjze4wQzbXxKlPjtyaTPZdcHi1PFepiUfCDs5f33toD1 EQKbQ7OwlF.Ib6uiTpHBh4JJvJzFsri84545KQDcaj.lDRUZkSfWtaRKq3GPj_V4DNY7lFGD2gKl 2nnkz8aiL8JNRIlQ- X-Sonic-MF: From: Chuck Zmudzinski To: qemu-devel@nongnu.org Cc: xen-devel@lists.xenproject.org, qemu-trivial@nongnu.org, Stefano Stabellini , Anthony Perard , Paul Durrant Subject: [PATCH v2] xen/pass-through: merge emulated bits correctly Date: Sat, 11 Jun 2022 12:43:29 -0400 Message-Id: X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 References: In xen_pt_config_reg_init(), there is an error in the merging of the emulated data with the host value. With the current Qemu, instead of merging the emulated bits with the host bits as defined by emu_mask, the emulated bits are merged with the host bits as defined by the inverse of emu_mask. In some cases, depending on the data in the registers on the host, the way the registers are setup, and the initial values of the emulated bits, the end result will be that the register is initialized with the wrong value. To correct this error, use the XEN_PT_MERGE_VALUE macro to help ensure the merge is done correctly. This correction is needed to resolve Qemu project issue #1061, which describes the failure of Xen HVM Linux guests to boot in certain configurations with passed through PCI devices, that is, when this error disables instead of enables the PCI_STATUS_CAP_LIST bit of the PCI_STATUS register of a passed through PCI device, which in turn disables the MSI-X capability of the device in Linux guests with the end result being that the Linux guest never completes the boot process. Fixes: 2e87512eccf3 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1061 Buglink: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988333 Signed-off-by: Chuck Zmudzinski Reviewed-by: Anthony PERARD --- v2: Edit the commit message to more accurately describe the cause of the error. hw/xen/xen_pt_config_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c index ffd915654c..bc0383f7fb 100644 --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -1966,10 +1966,10 @@ static void xen_pt_config_reg_init(XenPCIPassthroughState *s, if ((data & host_mask) != (val & host_mask)) { uint32_t new_val; - /* Mask out host (including past size). */ - new_val = val & host_mask; - /* Merge emulated ones (excluding the non-emulated ones). */ - new_val |= data & host_mask; + /* Merge the emulated bits (data) with the host bits (val) + * and mask out the bits past size to enable restoration + * of the proper value for logging below. */ + new_val = XEN_PT_MERGE_VALUE(val, data, host_mask) & size_mask; /* Leave intact host and emulated values past the size - even though * we do not care as we write per reg->size granularity, but for the * logging below lets have the proper value. */