All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/2] xen queue
@ 2022-07-05 13:45 Anthony PERARD via
  2022-07-05 13:45 ` [PULL 1/2] xen/pass-through: merge emulated bits correctly Anthony PERARD via
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Anthony PERARD via @ 2022-07-05 13:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony PERARD

The following changes since commit 19361471b59441cd6f2aa22d4fbee7a6e9e76586:

  Merge tag 'pull-la-20220705' of https://gitlab.com/rth7680/qemu into staging (2022-07-05 16:30:52 +0530)

are available in the Git repository at:

  https://xenbits.xen.org/git-http/people/aperard/qemu-dm.git tags/pull-xen-20220705

for you to fetch changes up to c0e86b7624cb9d6db03e0d48cf82659e5b89a6a6:

  xen/pass-through: don't create needless register group (2022-07-05 14:19:48 +0100)

----------------------------------------------------------------
Xen patches

- Xen PCI passthrough fixes

----------------------------------------------------------------
Chuck Zmudzinski (2):
      xen/pass-through: merge emulated bits correctly
      xen/pass-through: don't create needless register group

 hw/xen/xen_pt_config_init.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PULL 1/2] xen/pass-through: merge emulated bits correctly
  2022-07-05 13:45 [PULL 0/2] xen queue Anthony PERARD via
@ 2022-07-05 13:45 ` Anthony PERARD via
  2022-07-05 13:45 ` [PULL 2/2] xen/pass-through: don't create needless register group Anthony PERARD via
  2022-07-06  1:48 ` [PULL 0/2] xen queue Richard Henderson
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony PERARD via @ 2022-07-05 13:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Chuck Zmudzinski, Anthony PERARD

From: Chuck Zmudzinski <brchuckz@aol.com>

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 ("xen/pt: Sync up the dev.config and data values")
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 <brchuckz@aol.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Message-Id: <e4392535d8e5266063dc5461d0f1d301e3dd5951.1656522217.git.brchuckz@aol.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 hw/xen/xen_pt_config_init.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index c5c4e943a8..bff0962795 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -1965,11 +1965,12 @@ 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. */
-- 
Anthony PERARD



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PULL 2/2] xen/pass-through: don't create needless register group
  2022-07-05 13:45 [PULL 0/2] xen queue Anthony PERARD via
  2022-07-05 13:45 ` [PULL 1/2] xen/pass-through: merge emulated bits correctly Anthony PERARD via
@ 2022-07-05 13:45 ` Anthony PERARD via
  2022-07-06  1:48 ` [PULL 0/2] xen queue Richard Henderson
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony PERARD via @ 2022-07-05 13:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Chuck Zmudzinski, Anthony PERARD

From: Chuck Zmudzinski <brchuckz@aol.com>

Currently we are creating a register group for the Intel IGD OpRegion
for every device we pass through, but the XEN_PCI_INTEL_OPREGION
register group is only valid for an Intel IGD. Add a check to make
sure the device is an Intel IGD and a check that the administrator has
enabled gfx_passthru in the xl domain configuration. Require both checks
to be true before creating the register group. Use the existing
is_igd_vga_passthrough() function to check for a graphics device from
any vendor and that the administrator enabled gfx_passthru in the xl
domain configuration, but further require that the vendor be Intel,
because only Intel IGD devices have an Intel OpRegion. These are the
same checks hvmloader and libxl do to determine if the Intel OpRegion
needs to be mapped into the guest's memory. Also, move the comment
about trapping 0xfc for the Intel OpRegion where it belongs after
applying this patch.

Signed-off-by: Chuck Zmudzinski <brchuckz@aol.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Message-Id: <c76dff6369ccf2256bd9eed5141da1db767293d2.1656480662.git.brchuckz@aol.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 hw/xen/xen_pt_config_init.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index bff0962795..4758514ddf 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -2032,12 +2032,16 @@ void xen_pt_config_init(XenPCIPassthroughState *s, Error **errp)
             }
         }
 
-        /*
-         * By default we will trap up to 0x40 in the cfg space.
-         * If an intel device is pass through we need to trap 0xfc,
-         * therefore the size should be 0xff.
-         */
         if (xen_pt_emu_reg_grps[i].grp_id == XEN_PCI_INTEL_OPREGION) {
+            if (!is_igd_vga_passthrough(&s->real_device) ||
+                s->real_device.vendor_id != PCI_VENDOR_ID_INTEL) {
+                continue;
+            }
+            /*
+             * By default we will trap up to 0x40 in the cfg space.
+             * If an intel device is pass through we need to trap 0xfc,
+             * therefore the size should be 0xff.
+             */
             reg_grp_offset = XEN_PCI_INTEL_OPREGION;
         }
 
-- 
Anthony PERARD



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PULL 0/2] xen queue
  2022-07-05 13:45 [PULL 0/2] xen queue Anthony PERARD via
  2022-07-05 13:45 ` [PULL 1/2] xen/pass-through: merge emulated bits correctly Anthony PERARD via
  2022-07-05 13:45 ` [PULL 2/2] xen/pass-through: don't create needless register group Anthony PERARD via
@ 2022-07-06  1:48 ` Richard Henderson
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2022-07-06  1:48 UTC (permalink / raw)
  To: Anthony PERARD, qemu-devel

On 7/5/22 19:15, Anthony PERARD via wrote:
> The following changes since commit 19361471b59441cd6f2aa22d4fbee7a6e9e76586:
> 
>    Merge tag 'pull-la-20220705' of https://gitlab.com/rth7680/qemu into staging (2022-07-05 16:30:52 +0530)
> 
> are available in the Git repository at:
> 
>    https://xenbits.xen.org/git-http/people/aperard/qemu-dm.git tags/pull-xen-20220705
> 
> for you to fetch changes up to c0e86b7624cb9d6db03e0d48cf82659e5b89a6a6:
> 
>    xen/pass-through: don't create needless register group (2022-07-05 14:19:48 +0100)
> 
> ----------------------------------------------------------------
> Xen patches
> 
> - Xen PCI passthrough fixes

Applied, thanks.  Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.


r~


> 
> ----------------------------------------------------------------
> Chuck Zmudzinski (2):
>        xen/pass-through: merge emulated bits correctly
>        xen/pass-through: don't create needless register group
> 
>   hw/xen/xen_pt_config_init.c | 25 +++++++++++++++----------
>   1 file changed, 15 insertions(+), 10 deletions(-)
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-06  1:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-05 13:45 [PULL 0/2] xen queue Anthony PERARD via
2022-07-05 13:45 ` [PULL 1/2] xen/pass-through: merge emulated bits correctly Anthony PERARD via
2022-07-05 13:45 ` [PULL 2/2] xen/pass-through: don't create needless register group Anthony PERARD via
2022-07-06  1:48 ` [PULL 0/2] xen queue Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.