From: Peter Xu <peterx@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: "Laurent Vivier" <lvivier@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-devel@nongnu.org,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Claudio Fontana" <cfontana@suse.de>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Igor Mammedov" <imammedo@redhat.com>,
"Stefan Berger" <stefanb@linux.ibm.com>
Subject: Re: [PATCH resend v2 1/5] tpm: mark correct memory region range dirty when clearing RAM
Date: Fri, 23 Jul 2021 18:35:06 -0400 [thread overview]
Message-ID: <YPtEGpcLd4bT/5sD@t490s> (raw)
In-Reply-To: <c4bc5d98-7a34-6a9c-3c07-10e5b52cd06a@redhat.com>
On Fri, Jul 23, 2021 at 09:15:43PM +0200, David Hildenbrand wrote:
> On 23.07.21 16:52, Peter Xu wrote:
> > On Tue, Jul 20, 2021 at 03:03:00PM +0200, David Hildenbrand wrote:
> > > @@ -30,11 +30,13 @@ void tpm_ppi_reset(TPMPPI *tpmppi)
> > > guest_phys_blocks_init(&guest_phys_blocks);
> > > guest_phys_blocks_append(&guest_phys_blocks);
> > > QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
> > > + ram_addr_t mr_start = memory_region_get_ram_addr(block->mr);
> > > +
> > > trace_tpm_ppi_memset(block->host_addr,
> > > block->target_end - block->target_start);
> > > memset(block->host_addr, 0,
> > > block->target_end - block->target_start);
> > > - memory_region_set_dirty(block->mr, 0,
> > > + memory_region_set_dirty(block->mr, block->target_start - mr_start,
> > > block->target_end - block->target_start);
> >
> > target_start should falls in gpa range, while mr_start is ram_addr_t. I am not
> > sure whether this is right..
>
> When I wrote that code I was under the impression that
> memory_region_get_ram_addr() would give the GPA where the memory region
> starts, but ... that's not correct as you point out. "offset" confusion :)
>
> >
> > Neither do I know how to get correct mr offset with the existing info we've got
> > from GuestPhysBlock. Maybe we need to teach guest_phys_blocks_region_add() to
> > also record section->offset_within_region?
>
> We might actually want offset_within_address_space + offset_within_region,
> so we can calculate the GPA difference to see where inside the ramblock we
> end up.
I still think offset_within_region is exactly what we want to fill in here, but
you can do a double check.
>
> I'll have a look next week, thanks for noticing!
Sure!
--
Peter Xu
next prev parent reply other threads:[~2021-07-23 22:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-20 13:02 [PATCH resend v2 0/5] softmmu/memory_mapping: optimize dump/tpm for virtio-mem David Hildenbrand
2021-07-20 13:03 ` [PATCH resend v2 1/5] tpm: mark correct memory region range dirty when clearing RAM David Hildenbrand
2021-07-23 14:52 ` Peter Xu
2021-07-23 19:15 ` David Hildenbrand
2021-07-23 22:35 ` Peter Xu [this message]
2021-07-26 8:08 ` David Hildenbrand
2021-07-26 14:21 ` Peter Xu
2021-07-20 13:03 ` [PATCH resend v2 2/5] softmmu/memory_mapping: reuse qemu_get_guest_simple_memory_mapping() David Hildenbrand
2021-07-20 13:37 ` Stefan Berger
2021-07-20 13:45 ` David Hildenbrand
2021-07-20 13:03 ` [PATCH resend v2 3/5] softmmu/memory_mapping: never merge ranges accross memory regions David Hildenbrand
2021-07-20 13:26 ` Stefan Berger
2021-07-23 15:09 ` Peter Xu
2021-07-20 13:03 ` [PATCH resend v2 4/5] softmmu/memory_mapping: factor out adding physical memory ranges David Hildenbrand
2021-07-20 13:25 ` Stefan Berger
2021-07-23 15:09 ` Peter Xu
2021-07-20 13:03 ` [PATCH resend v2 5/5] softmmu/memory_mapping: optimize for RamDiscardManager sections David Hildenbrand
2021-07-23 15:28 ` Peter Xu
2021-07-23 18:56 ` David Hildenbrand
2021-07-23 22:33 ` Peter Xu
2021-07-26 7:51 ` David Hildenbrand
2021-07-26 15:24 ` Peter Xu
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=YPtEGpcLd4bT/5sD@t490s \
--to=peterx@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=cfontana@suse.de \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.ibm.com \
--cc=stefanb@linux.vnet.ibm.com \
--cc=thuth@redhat.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 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.