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: 1642453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aol.com header.i=@aol.com header.a=rsa-sha256 header.s=a2048 header.b=rj3EKPf8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4LL3Zx69s4z9sFk for ; Sun, 12 Jun 2022 02:44:40 +1000 (AEST) Received: from localhost ([::1]:38232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o04E0-0005lz-Tb for incoming@patchwork.ozlabs.org; Sat, 11 Jun 2022 12:44:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o04DF-0005ld-2c for qemu-devel@nongnu.org; Sat, 11 Jun 2022 12:43:49 -0400 Received: from sonic304-24.consmr.mail.gq1.yahoo.com ([98.137.68.205]:36267) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o04DC-0004Ro-EK for qemu-devel@nongnu.org; Sat, 11 Jun 2022 12:43:48 -0400 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/jJxrdlGr8bqBgCzQNIrPpFgBbBa0FeR6zw70JHBltxqIK456RVBnfzLiirbWqrVZ5g1o/WzUAMJZAjyNQ3j4RznkY6q+lQdBoLHxlreUvVUNDhuXrPNaXLQl+Q0WvPi9MbEwjlrUOE0znssLT30pA30ING4RpFSjPZH/metJt5Izr5cYJ7zCaWQyhLlTMZumaoFKeMtG+D0knK5vWFg== X-YMail-OSG: AWXn12oVM1k3G32cr49lu1hpWFcCdIsYTwluI2HkZElXlWe7QdEhcypMisJ6FQS AdSXl0fE6Sfs9J4xbP7_82mUhW6okyP9SUwtYPp64ltydNqMLcCKBV1s899BZdNW6R3V5sN6U3.1 2bRRsK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ic-MF: 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) 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: Received-SPF: pass client-ip=98.137.68.205; envelope-from=brchuckz@aim.com; helo=sonic304-24.consmr.mail.gq1.yahoo.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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. */