All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Claudio Fontana" <cfontana@suse.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Stefan Berger" <stefanb@linux.ibm.com>
Subject: Re: [PATCH v3 1/4] tpm: mark correct memory region range dirty when clearing RAM
Date: Mon, 26 Jul 2021 12:57:43 -0400	[thread overview]
Message-ID: <YP7ph0a9kI9p4zhs@t490s> (raw)
In-Reply-To: <20210726160346.109915-2-david@redhat.com>

On Mon, Jul 26, 2021 at 06:03:43PM +0200, David Hildenbrand wrote:
> We might not start at the beginning of the memory region. Let's
> calculate the offset into the memory region via the difference in the
> host addresses.
> 
> Acked-by: Stefan Berger <stefanb@linux.ibm.com>
> Fixes: ffab1be70692 ("tpm: clear RAM when "memory overwrite" requested")
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Claudio Fontana <cfontana@suse.de>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: "Alex Bennée" <alex.bennee@linaro.org>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  hw/tpm/tpm_ppi.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
> index 362edcc5c9..f243d9d0f6 100644
> --- a/hw/tpm/tpm_ppi.c
> +++ b/hw/tpm/tpm_ppi.c
> @@ -30,11 +30,14 @@ 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) {
> +            hwaddr mr_offs = (uint8_t *)memory_region_get_ram_ptr(block->mr) -
> +                             block->host_addr;

Didn't look closely previous - should it be reversed instead?

  block->host_addr - memory_region_get_ram_ptr(block->mr)

Thanks,

> +
>              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, mr_offs,
>                                      block->target_end - block->target_start);
>          }
>          guest_phys_blocks_free(&guest_phys_blocks);
> -- 
> 2.31.1
> 

-- 
Peter Xu



  reply	other threads:[~2021-07-26 16:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 16:03 [PATCH v3 0/4] softmmu/memory_mapping: optimize dump/tpm for virtio-mem David Hildenbrand
2021-07-26 16:03 ` [PATCH v3 1/4] tpm: mark correct memory region range dirty when clearing RAM David Hildenbrand
2021-07-26 16:57   ` Peter Xu [this message]
2021-07-26 16:58     ` David Hildenbrand
2021-07-26 16:03 ` [PATCH v3 2/4] softmmu/memory_mapping: never merge ranges accross memory regions David Hildenbrand
2021-07-26 16:03 ` [PATCH v3 3/4] softmmu/memory_mapping: factor out adding physical memory ranges David Hildenbrand
2021-07-26 16:03 ` [PATCH v3 4/4] softmmu/memory_mapping: optimize for RamDiscardManager sections David Hildenbrand
  -- strict thread matches above, loose matches on Subject: below --
2021-07-21  8:38 [PATCH v3 0/4] softmmu/memory_mapping: optimize dump/tpm for virtio-mem David Hildenbrand
2021-07-21  8:38 ` [PATCH v3 1/4] tpm: mark correct memory region range dirty when clearing RAM David Hildenbrand

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=YP7ph0a9kI9p4zhs@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.