Re: git: 2eb2079554f4 - main - bhyve: keep physical and virtual COMMAND reg in sync

From: John Baldwin <>
Date: Tue, 23 Nov 2021 16:23:16 UTC
On 11/23/21 1:33 AM, Corvin Köhne wrote:
> Hi John,
> sry, I didn't see your patch. Seems like your patch is very similar to
> mine. However, your patch goes a bit further. It initializes the
> virtual cmd register with it's physical value and always enables
> bus mastering. Are you still interested in working on your patch?
> Otherwise, I'm going to proceed your work.

Would you be able to test if that change works in your environment?  I was
never able to confirm that it fixed the bug I was trying to address, but I
do think it is more correct.  The busmastering thing is to work around Linux
clearing that flag on shutdown of a guest, and I wanted to preserve other
bits in the command register that weren't related to BARs, etc.

> Best regards
> Corvin
> Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
> Registered office: Verl, Germany | Register court: Guetersloh HRA 7075
> -----Original Message-----
> From: <> On Behalf Of John Baldwin
> Sent: Monday, November 22, 2021 5:39 PM
> To: Emmanuel Vadot <>;;;
> Subject: Re: git: 2eb2079554f4 - main - bhyve: keep physical and virtual COMMAND reg in sync
> CAUTION: External Email!!
> On 11/22/21 7:30 AM, Emmanuel Vadot wrote:
>> The branch main has been updated by manu:
>> URL:
>> commit 2eb2079554f4d54c4283410b4ee1aca549b29616
>> Author:     Corvin Köhne <>
>> AuthorDate: 2021-11-22 15:26:03 +0000
>> Commit:     Emmanuel Vadot <>
>> CommitDate: 2021-11-22 15:26:03 +0000
>>       bhyve: keep physical and virtual COMMAND reg in sync
>>       On startup all virtual BARs are registered.
>>       Additionally, the encoding bit in the virtual cmd register is set.
>>       After that, the passthru emulation overwrites the virtual cmd register with
>>       the physical one.
>>       This could lead to a mismatch between registered BARs and the encoding
>>       bits in the cmd register.
>>       Instead of writing the physical to the virtual cmd register,
>>       write the virtual to the physical cmd register to solve this issue.
>>       Reviewed by:      markj
>>       Differential Revision:
>>       Sponsored by:   Beckhoff Automation GmbH & Co. KG
> Humm, I wonder if my older patch that tries to handle the command register
> more deterministically might have handled this.  The patch tried to fix an
> open bug where you can't use a XHCI controller via passthru after you have
> rebooted a Linux guest.  It makes this write here conditional:
> --
> John Baldwin

John Baldwin