* [PATCH 0/2] tpm: fix PPI RAM migration
@ 2020-01-02 21:01 Marc-André Lureau
2020-01-02 21:01 ` [PATCH 1/2] RFC: savevm: check RAM is page_size aligned Marc-André Lureau
2020-01-02 21:01 ` [PATCH 2/2] tpm-ppi: page-align PPI RAM Marc-André Lureau
0 siblings, 2 replies; 6+ messages in thread
From: Marc-André Lureau @ 2020-01-02 21:01 UTC (permalink / raw)
To: qemu-devel
Cc: Marc-André Lureau, Stefan Berger, Dr. David Alan Gilbert,
Juan Quintela
Hi,
The following series fixes a migration issue with the TPM PPI code due
to unaligned host RAM pointer.
Marc-André Lureau (2):
RFC: savevm: check RAM is page_size aligned
tpm-ppi: page-align PPI RAM
hw/tpm/tpm_ppi.c | 3 ++-
migration/savevm.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
--
2.24.0.308.g228f53135a
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] RFC: savevm: check RAM is page_size aligned
2020-01-02 21:01 [PATCH 0/2] tpm: fix PPI RAM migration Marc-André Lureau
@ 2020-01-02 21:01 ` Marc-André Lureau
2020-01-03 5:06 ` Philippe Mathieu-Daudé
2020-01-02 21:01 ` [PATCH 2/2] tpm-ppi: page-align PPI RAM Marc-André Lureau
1 sibling, 1 reply; 6+ messages in thread
From: Marc-André Lureau @ 2020-01-02 21:01 UTC (permalink / raw)
To: qemu-devel
Cc: Marc-André Lureau, Stefan Berger, Dr. David Alan Gilbert,
Juan Quintela
Check the host pointer is correctly aligned, otherwise we may fail
during migration in ram_block_discard_range().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
migration/savevm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/migration/savevm.c b/migration/savevm.c
index a71b930b91..ab6e02011f 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2910,6 +2910,11 @@ err_drain:
void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
{
+ RAMBlock *rb = mr->ram_block;
+ uintptr_t hostaddr = (uintptr_t)qemu_ram_get_host_addr(rb);
+
+ assert((hostaddr & (qemu_ram_pagesize(rb) - 1)) == 0);
+
qemu_ram_set_idstr(mr->ram_block,
memory_region_name(mr), dev);
qemu_ram_set_migratable(mr->ram_block);
--
2.24.0.308.g228f53135a
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] tpm-ppi: page-align PPI RAM
2020-01-02 21:01 [PATCH 0/2] tpm: fix PPI RAM migration Marc-André Lureau
2020-01-02 21:01 ` [PATCH 1/2] RFC: savevm: check RAM is page_size aligned Marc-André Lureau
@ 2020-01-02 21:01 ` Marc-André Lureau
2020-01-03 5:15 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 6+ messages in thread
From: Marc-André Lureau @ 2020-01-02 21:01 UTC (permalink / raw)
To: qemu-devel
Cc: Marc-André Lureau, qemu-stable, Stefan Berger,
Dr. David Alan Gilbert, Juan Quintela
post-copy migration fails on destination with error such as:
2019-12-26T10:22:44.714644Z qemu-kvm: ram_block_discard_range:
Unaligned start address: 0x559d2afae9a0
Use qemu_memalign() to constrain the PPI RAM memory alignment.
Cc: qemu-stable@nongnu.org
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/tpm/tpm_ppi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
index ff314592b4..6d9c1a3e40 100644
--- a/hw/tpm/tpm_ppi.c
+++ b/hw/tpm/tpm_ppi.c
@@ -43,7 +43,8 @@ void tpm_ppi_reset(TPMPPI *tpmppi)
void tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
hwaddr addr, Object *obj)
{
- tpmppi->buf = g_malloc0(HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
+ tpmppi->buf = qemu_memalign(qemu_real_host_page_size,
+ HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi",
TPM_PPI_ADDR_SIZE, tpmppi->buf);
vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
--
2.24.0.308.g228f53135a
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] RFC: savevm: check RAM is page_size aligned
2020-01-02 21:01 ` [PATCH 1/2] RFC: savevm: check RAM is page_size aligned Marc-André Lureau
@ 2020-01-03 5:06 ` Philippe Mathieu-Daudé
2020-01-03 6:39 ` Marc-André Lureau
0 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-03 5:06 UTC (permalink / raw)
To: Marc-André Lureau, qemu-devel
Cc: Juan Quintela, Dr. David Alan Gilbert, Stefan Berger
Hi Marc-André,
On 1/2/20 10:01 PM, Marc-André Lureau wrote:
> Check the host pointer is correctly aligned, otherwise we may fail
> during migration in ram_block_discard_range().
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> migration/savevm.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index a71b930b91..ab6e02011f 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2910,6 +2910,11 @@ err_drain:
>
> void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
> {
> + RAMBlock *rb = mr->ram_block;
> + uintptr_t hostaddr = (uintptr_t)qemu_ram_get_host_addr(rb);
> +
> + assert((hostaddr & (qemu_ram_pagesize(rb) - 1)) == 0);
Can we use the QEMU_PTR_IS_ALIGNED() macro instead?
assert(QEMU_PTR_IS_ALIGNED(qemu_ram_get_host_addr(rb),
qemu_ram_pagesize(rb)));
> qemu_ram_set_idstr(mr->ram_block,
> memory_region_name(mr), dev);
> qemu_ram_set_migratable(mr->ram_block);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] tpm-ppi: page-align PPI RAM
2020-01-02 21:01 ` [PATCH 2/2] tpm-ppi: page-align PPI RAM Marc-André Lureau
@ 2020-01-03 5:15 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-03 5:15 UTC (permalink / raw)
To: Marc-André Lureau, qemu-devel
Cc: Juan Quintela, qemu-stable, Dr. David Alan Gilbert, Stefan Berger
On 1/2/20 10:01 PM, Marc-André Lureau wrote:
> post-copy migration fails on destination with error such as:
> 2019-12-26T10:22:44.714644Z qemu-kvm: ram_block_discard_range:
> Unaligned start address: 0x559d2afae9a0
>
> Use qemu_memalign() to constrain the PPI RAM memory alignment.
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/tpm/tpm_ppi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
> index ff314592b4..6d9c1a3e40 100644
> --- a/hw/tpm/tpm_ppi.c
> +++ b/hw/tpm/tpm_ppi.c
> @@ -43,7 +43,8 @@ void tpm_ppi_reset(TPMPPI *tpmppi)
> void tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
> hwaddr addr, Object *obj)
> {
> - tpmppi->buf = g_malloc0(HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
> + tpmppi->buf = qemu_memalign(qemu_real_host_page_size,
> + HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
> memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi",
> TPM_PPI_ADDR_SIZE, tpmppi->buf);
> vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] RFC: savevm: check RAM is page_size aligned
2020-01-03 5:06 ` Philippe Mathieu-Daudé
@ 2020-01-03 6:39 ` Marc-André Lureau
0 siblings, 0 replies; 6+ messages in thread
From: Marc-André Lureau @ 2020-01-03 6:39 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Juan Quintela, qemu-devel, Dr. David Alan Gilbert, Stefan Berger
Hi
On Fri, Jan 3, 2020 at 9:06 AM Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Hi Marc-André,
>
> On 1/2/20 10:01 PM, Marc-André Lureau wrote:
> > Check the host pointer is correctly aligned, otherwise we may fail
> > during migration in ram_block_discard_range().
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > migration/savevm.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/migration/savevm.c b/migration/savevm.c
> > index a71b930b91..ab6e02011f 100644
> > --- a/migration/savevm.c
> > +++ b/migration/savevm.c
> > @@ -2910,6 +2910,11 @@ err_drain:
> >
> > void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
> > {
> > + RAMBlock *rb = mr->ram_block;
> > + uintptr_t hostaddr = (uintptr_t)qemu_ram_get_host_addr(rb);
> > +
> > + assert((hostaddr & (qemu_ram_pagesize(rb) - 1)) == 0);
>
> Can we use the QEMU_PTR_IS_ALIGNED() macro instead?
>
> assert(QEMU_PTR_IS_ALIGNED(qemu_ram_get_host_addr(rb),
> qemu_ram_pagesize(rb)));
>
nice, good idea
> > qemu_ram_set_idstr(mr->ram_block,
> > memory_region_name(mr), dev);
> > qemu_ram_set_migratable(mr->ram_block);
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-01-03 6:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-02 21:01 [PATCH 0/2] tpm: fix PPI RAM migration Marc-André Lureau
2020-01-02 21:01 ` [PATCH 1/2] RFC: savevm: check RAM is page_size aligned Marc-André Lureau
2020-01-03 5:06 ` Philippe Mathieu-Daudé
2020-01-03 6:39 ` Marc-André Lureau
2020-01-02 21:01 ` [PATCH 2/2] tpm-ppi: page-align PPI RAM Marc-André Lureau
2020-01-03 5:15 ` Philippe Mathieu-Daudé
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).