From: Stefan Berger <stefanb@linux.ibm.com>
To: Joelle van Dyne <j@getutm.app>
Cc: qemu-devel@nongnu.org, Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: Re: [PATCH v2 11/11] tpm_crb: support restoring older vmstate
Date: Fri, 14 Jul 2023 15:12:27 -0400 [thread overview]
Message-ID: <78cee616-94fa-baba-8dad-1dbcbbbbc45a@linux.ibm.com> (raw)
In-Reply-To: <CA+E+eSC_Hg5zxepaeCZTNiYS8oq6hNUqO8Pijft45O7vhD2q6Q@mail.gmail.com>
On 7/14/23 14:49, Joelle van Dyne wrote:
> On Fri, Jul 14, 2023 at 11:41 AM Stefan Berger <stefanb@linux.ibm.com> wrote:
>>
>>
>>
>> On 7/14/23 14:22, Stefan Berger wrote:
>>> On 7/14/23 13:04, Joelle van Dyne wrote:
>>>> On Fri, Jul 14, 2023 at 7:51 AM Stefan Berger <stefanb@linux.ibm.com> wrote:
>>>>>
>>>>>
>>>>>
>>>>> On 7/14/23 10:05, Stefan Berger wrote:
>>>>>>
>>>>>>
>>>>>> On 7/14/23 03:09, Joelle van Dyne wrote:
>>>>>>> When we moved to a single mapping and modified TPM CRB's VMState, it
>>>>>>> broke restoring of VMs that were saved on an older version. This
>>>>>>> change allows those VMs to gracefully migrate to the new memory
>>>>>>> mapping.
>>>>>>
>>>>>> Thanks. This has to be in 4/11 though.
>>>>>>
>>>>>
>>>>> After applying the whole series and trying to resume state taken with current git
>>>>> master I cannot restore it but it leads to this error here. I would just leave it
>>>>> completely untouched in 4/11.
>>>>>
>>>>> 2023-07-14T14:46:34.547550Z qemu-system-x86_64: Unknown ramblock "tpm-crb-cmd", cannot accept migration
>>>>> 2023-07-14T14:46:34.547799Z qemu-system-x86_64: error while loading state for instance 0x0 of device 'ram'
>>>>> 2023-07-14T14:46:34.547835Z qemu-system-x86_64: load of migration failed: Invalid argument
>>>>>
>>>>> Stefan
>>>>
>>>> To be clear, you are asking to back out of 4/11? That patch changes
>>>> how the registers are mapped so it's impossible to support the old
>>>> style register mapping. This patch attempts to fix that with a
>>>
>>> Why can we not keep the old style register mapping as 'secondary mapping'?
>>
>> I think the first goal should be for existing TPM CRB device not to change anything, they
>> keep their .read and .write behaivor as it.
>>
>> If you need different .read behavior for the sysbus device due to AARCH64 then it may want to use its own MemoryRegionOps.
>>
>> I am fairly sure that you could refactor the core of the existing tpm_crb_mmio_write() and have it work on s->regs and mmio regs.
>> The former would be used by existing code, the latter for CRB sysbus calling into this new function from a wrapper.
>>
>> Stefan
>
> I agree that new QEMU should be able to read old QEMU state but vice
> versa is not always true. There's been many changes in the past that
> incremented the vmstate's version_id to indicate that the state format
> has changed. Also, we are not changing the .read behavior because in
Unfortunately the CRB device is being used by x86 on some distros
and the expectation is that this existing device can also downgrade
to a previous version of QEMU I would say. I have read people migrating
from RHEL 9.x even to RHEL 8.x and the expectation is that this works.
Now you are introducing a new device and I think you can leave
the existing device with its s->regs alone and have the new device
with its mmio regs work a little different just to preserve the QEMU
downgrade for x86.
> the old code, the only field that gets a dynamic update is
> tpmEstablished which we found is never changed. So effectively, .read
Correct and that's why you don't need a .read in the new device.
> is just doing a memcpy of the `regs` state. This makes it possible to
> map the page as memory while retaining the same behavior as before.
> (We are changing the code but not the behavior).
>
> The issue with Windows's buggy tpm.sys driver is that fundamentally it
> cannot work with MemoryRegionOps. The way MMIO is implemented is that
At least not with the .read part as it seems and you have to have the
.write part to be able to react to cmd transfers etc.
> a hole is left in the guest memory space so when the device registers
> are accessed, the hypervisor traps it and sends it over to QEMU to
> handle. QEMU looks up the address, sees its a valid MMIO mapping, and
> calls into the MemoryRegionOps implementation. When tpm.sys does a LDP
> instruction access to the hole, the information for QEMU to determine
> if it's a valid access is not provided. Other hypervisors like Apple's
> VZ.framework and VMware will read the guest PC, manually decode the
> AArch64 instruction, determine the type of access, read the guest Rn
> registers, does a TLB lookup to determine the physical address, then
> emulate the MMIO. None of this capability currently exists in QEMU's
> ARM64 backend. That's why we decided the easier path is to tell QEMU
> that this mapping is RAM for read purposes and MMIO only for write
> purposes (thankfully Windows does not do a STP or we'd be hosed).
Thanks, this confirms what I thought.
Stefan
next prev parent reply other threads:[~2023-07-14 19:13 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 7:09 [PATCH v2 00/11] tpm: introduce TPM CRB SysBus device Joelle van Dyne
2023-07-14 7:09 ` [PATCH v2 01/11] tpm_crb: refactor common code Joelle van Dyne
2023-07-14 7:09 ` [PATCH v2 02/11] tpm_crb: CTRL_RSP_ADDR is 64-bits wide Joelle van Dyne
2023-07-14 7:09 ` [PATCH v2 03/11] tpm_ppi: refactor memory space initialization Joelle van Dyne
2023-07-14 7:09 ` [PATCH v2 04/11] tpm_crb: use a single read-as-mem/write-as-mmio mapping Joelle van Dyne
2023-07-14 12:03 ` Stefan Berger
2023-07-14 7:09 ` [PATCH v2 05/11] tpm_crb: use the ISA bus Joelle van Dyne
2023-07-17 13:46 ` Igor Mammedov
2023-07-18 14:16 ` Stefan Berger
2023-08-01 1:46 ` Joelle van Dyne
2023-10-17 14:24 ` Alexander Graf
2023-07-14 7:09 ` [PATCH v2 06/11] tpm_crb: move ACPI table building to device interface Joelle van Dyne
2023-07-14 17:21 ` Stefan Berger
2023-07-17 13:42 ` Igor Mammedov
2023-08-01 3:02 ` Joelle van Dyne
2023-08-01 19:38 ` Stefan Berger
2023-08-07 10:20 ` Igor Mammedov
2023-07-14 7:09 ` [PATCH v2 07/11] hw/arm/virt: add plug handler for TPM on SysBus Joelle van Dyne
2023-07-14 12:11 ` Stefan Berger
2023-07-14 17:09 ` Joelle van Dyne
2023-07-17 14:00 ` Igor Mammedov
2023-07-14 7:09 ` [PATCH v2 08/11] hw/loongarch/virt: " Joelle van Dyne
2023-07-20 17:57 ` Stefan Berger
2023-08-03 11:35 ` Stefan Berger
2023-07-14 7:09 ` [PATCH v2 09/11] tpm_tis_sysbus: move DSDT AML generation to device Joelle van Dyne
2023-07-14 16:19 ` Stefan Berger
2023-07-14 17:29 ` Joelle van Dyne
2023-07-14 17:37 ` Stefan Berger
2023-07-14 17:39 ` Joelle van Dyne
2023-07-14 17:43 ` Stefan Berger
2023-07-14 17:46 ` Joelle van Dyne
2023-07-14 18:01 ` Stefan Berger
2023-07-14 18:15 ` Joelle van Dyne
2023-07-17 14:06 ` Igor Mammedov
2023-07-14 7:09 ` [PATCH v2 10/11] tpm_crb_sysbus: introduce TPM CRB SysBus device Joelle van Dyne
2023-07-14 14:27 ` Stefan Berger
2023-07-14 17:20 ` Joelle van Dyne
2023-07-14 17:52 ` Stefan Berger
2023-07-17 14:23 ` Igor Mammedov
2023-10-29 2:21 ` Joelle van Dyne
2023-07-14 7:09 ` [PATCH v2 11/11] tpm_crb: support restoring older vmstate Joelle van Dyne
2023-07-14 14:05 ` Stefan Berger
2023-07-14 14:51 ` Stefan Berger
2023-07-14 17:04 ` Joelle van Dyne
2023-07-14 18:22 ` Stefan Berger
2023-07-14 18:41 ` Stefan Berger
2023-07-14 18:49 ` Joelle van Dyne
2023-07-14 19:12 ` Stefan Berger [this message]
2023-07-14 19:44 ` Joelle van Dyne
2023-07-14 19:56 ` Stefan Berger
2023-07-17 14:40 ` Peter Maydell
2023-07-17 14:33 ` Igor Mammedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=78cee616-94fa-baba-8dad-1dbcbbbbc45a@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=j@getutm.app \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).