All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions
@ 2018-10-03 11:44 Marc-André Lureau
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 1/3] memory: learn about non-volatile memory region Marc-André Lureau
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Marc-André Lureau @ 2018-10-03 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Igor Mammedov, Dr. David Alan Gilbert,
	Xiao Guangrong, Juan Quintela, Michael S. Tsirkin,
	Marc-André Lureau

Hi,

As discussed in the "[PATCH v10 6/6] tpm: add ACPI memory clear
interface" thread, and proposed in the "[PATCH] RFC: mark non-volatile
memory region", here is a small series to mark non-volvatile memory
regions and skip them on dump. Upcoming TCG "Platform Reset Attack
Mitigation" will also use this information to eventually skip
non-volatile memory.

Thanks

Marc-André Lureau (3):
  memory: learn about non-volatile memory region
  nvdimm: set non-volatile on the memory region
  memory-mapping: skip non-volatile memory regions in GuestPhysBlockList

 include/exec/memory.h    | 25 ++++++++++++++++++++++
 hw/mem/nvdimm.c          |  1 +
 memory.c                 | 45 +++++++++++++++++++++++++++++++---------
 memory_mapping.c         |  3 ++-
 docs/devel/migration.rst |  1 +
 5 files changed, 64 insertions(+), 11 deletions(-)

-- 
2.19.0.271.gfe8321ec05

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1/3] memory: learn about non-volatile memory region
  2018-10-03 11:44 [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions Marc-André Lureau
@ 2018-10-03 11:44 ` Marc-André Lureau
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 2/3] nvdimm: set non-volatile on the " Marc-André Lureau
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Marc-André Lureau @ 2018-10-03 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Igor Mammedov, Dr. David Alan Gilbert,
	Xiao Guangrong, Juan Quintela, Michael S. Tsirkin,
	Marc-André Lureau, guangrong.xiao

Add a new flag to mark memory region that are used as non-volatile, by
NVDIMM for example. That bit is propagated down to the flat view, and
reflected in HMP info mtree with a "nv-" prefix on the memory type.

This way, guest_phys_blocks_region_add() can skip the NV memory
regions for dumps and TCG memory clear in a following patch.

Cc: dgilbert@redhat.com
Cc: imammedo@redhat.com
Cc: pbonzini@redhat.com
Cc: guangrong.xiao@linux.intel.com
Cc: mst@redhat.com
Cc: xiaoguangrong.eric@gmail.com
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/exec/memory.h    | 25 ++++++++++++++++++++++
 memory.c                 | 45 +++++++++++++++++++++++++++++++---------
 docs/devel/migration.rst |  1 +
 3 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 3a427aacf1..43ffa7fc15 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -355,6 +355,7 @@ struct MemoryRegion {
     bool ram;
     bool subpage;
     bool readonly; /* For RAM regions */
+    bool nonvolatile;
     bool rom_device;
     bool flush_coalesced_mmio;
     bool global_locking;
@@ -480,6 +481,7 @@ static inline FlatView *address_space_to_flatview(AddressSpace *as)
  * @offset_within_address_space: the address of the first byte of the section
  *     relative to the region's address space
  * @readonly: writes to this section are ignored
+ * @nonvolatile: this section is non-volatile
  */
 struct MemoryRegionSection {
     MemoryRegion *mr;
@@ -488,6 +490,7 @@ struct MemoryRegionSection {
     Int128 size;
     hwaddr offset_within_address_space;
     bool readonly;
+    bool nonvolatile;
 };
 
 /**
@@ -1170,6 +1173,17 @@ static inline bool memory_region_is_rom(MemoryRegion *mr)
     return mr->ram && mr->readonly;
 }
 
+/**
+ * memory_region_is_nonvolatile: check whether a memory region is non-volatile
+ *
+ * Returns %true is a memory region is non-volatile memory.
+ *
+ * @mr: the memory region being queried
+ */
+static inline bool memory_region_is_nonvolatile(MemoryRegion *mr)
+{
+    return mr->nonvolatile;
+}
 
 /**
  * memory_region_get_fd: Get a file descriptor backing a RAM memory region.
@@ -1341,6 +1355,17 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,
  */
 void memory_region_set_readonly(MemoryRegion *mr, bool readonly);
 
+/**
+ * memory_region_set_nonvolatile: Turn a memory region non-volatile
+ *
+ * Allows a memory region to be marked as non-volatile.
+ * only useful on RAM regions.
+ *
+ * @mr: the region being updated.
+ * @nonvolatile: whether rhe region is to be non-volatile.
+ */
+void memory_region_set_nonvolatile(MemoryRegion *mr, bool nonvolatile);
+
 /**
  * memory_region_rom_device_set_romd: enable/disable ROMD mode
  *
diff --git a/memory.c b/memory.c
index d852f1143d..9ff5bb6b7e 100644
--- a/memory.c
+++ b/memory.c
@@ -216,6 +216,7 @@ struct FlatRange {
     uint8_t dirty_log_mask;
     bool romd_mode;
     bool readonly;
+    bool nonvolatile;
 };
 
 #define FOR_EACH_FLAT_RANGE(var, view)          \
@@ -231,6 +232,7 @@ section_from_flat_range(FlatRange *fr, FlatView *fv)
         .size = fr->addr.size,
         .offset_within_address_space = int128_get64(fr->addr.start),
         .readonly = fr->readonly,
+        .nonvolatile = fr->nonvolatile,
     };
 }
 
@@ -240,7 +242,8 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b)
         && addrrange_equal(a->addr, b->addr)
         && a->offset_in_region == b->offset_in_region
         && a->romd_mode == b->romd_mode
-        && a->readonly == b->readonly;
+        && a->readonly == b->readonly
+        && a->nonvolatile == b->nonvolatile;
 }
 
 static FlatView *flatview_new(MemoryRegion *mr_root)
@@ -312,7 +315,8 @@ static bool can_merge(FlatRange *r1, FlatRange *r2)
                      int128_make64(r2->offset_in_region))
         && r1->dirty_log_mask == r2->dirty_log_mask
         && r1->romd_mode == r2->romd_mode
-        && r1->readonly == r2->readonly;
+        && r1->readonly == r2->readonly
+        && r1->nonvolatile == r2->nonvolatile;
 }
 
 /* Attempt to simplify a view by merging adjacent ranges */
@@ -592,7 +596,8 @@ static void render_memory_region(FlatView *view,
                                  MemoryRegion *mr,
                                  Int128 base,
                                  AddrRange clip,
-                                 bool readonly)
+                                 bool readonly,
+                                 bool nonvolatile)
 {
     MemoryRegion *subregion;
     unsigned i;
@@ -608,6 +613,7 @@ static void render_memory_region(FlatView *view,
 
     int128_addto(&base, int128_make64(mr->addr));
     readonly |= mr->readonly;
+    nonvolatile |= mr->nonvolatile;
 
     tmp = addrrange_make(base, mr->size);
 
@@ -620,13 +626,15 @@ static void render_memory_region(FlatView *view,
     if (mr->alias) {
         int128_subfrom(&base, int128_make64(mr->alias->addr));
         int128_subfrom(&base, int128_make64(mr->alias_offset));
-        render_memory_region(view, mr->alias, base, clip, readonly);
+        render_memory_region(view, mr->alias, base, clip,
+                             readonly, nonvolatile);
         return;
     }
 
     /* Render subregions in priority order. */
     QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) {
-        render_memory_region(view, subregion, base, clip, readonly);
+        render_memory_region(view, subregion, base, clip,
+                             readonly, nonvolatile);
     }
 
     if (!mr->terminates) {
@@ -641,6 +649,7 @@ static void render_memory_region(FlatView *view,
     fr.dirty_log_mask = memory_region_get_dirty_log_mask(mr);
     fr.romd_mode = mr->romd_mode;
     fr.readonly = readonly;
+    fr.nonvolatile = nonvolatile;
 
     /* Render the region itself into any gaps left by the current view. */
     for (i = 0; i < view->nr && int128_nz(remain); ++i) {
@@ -726,7 +735,8 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)
 
     if (mr) {
         render_memory_region(view, mr, int128_zero(),
-                             addrrange_make(int128_zero(), int128_2_64()), false);
+                             addrrange_make(int128_zero(), int128_2_64()),
+                             false, false);
     }
     flatview_simplify(view);
 
@@ -2039,6 +2049,16 @@ void memory_region_set_readonly(MemoryRegion *mr, bool readonly)
     }
 }
 
+void memory_region_set_nonvolatile(MemoryRegion *mr, bool nonvolatile)
+{
+    if (mr->nonvolatile != nonvolatile) {
+        memory_region_transaction_begin();
+        mr->nonvolatile = nonvolatile;
+        memory_region_update_pending |= mr->enabled;
+        memory_region_transaction_commit();
+    }
+}
+
 void memory_region_rom_device_set_romd(MemoryRegion *mr, bool romd_mode)
 {
     if (mr->romd_mode != romd_mode) {
@@ -2489,6 +2509,7 @@ static MemoryRegionSection memory_region_find_rcu(MemoryRegion *mr,
     ret.size = range.size;
     ret.offset_within_address_space = int128_get64(range.start);
     ret.readonly = fr->readonly;
+    ret.nonvolatile = fr->nonvolatile;
     return ret;
 }
 
@@ -2839,10 +2860,11 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
             QTAILQ_INSERT_TAIL(alias_print_queue, ml, mrqueue);
         }
         mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx
-                   " (prio %d, %s): alias %s @%s " TARGET_FMT_plx
+                   " (prio %d, %s%s): alias %s @%s " TARGET_FMT_plx
                    "-" TARGET_FMT_plx "%s",
                    cur_start, cur_end,
                    mr->priority,
+                   mr->nonvolatile ? "nv-" : "",
                    memory_region_type((MemoryRegion *)mr),
                    memory_region_name(mr),
                    memory_region_name(mr->alias),
@@ -2854,9 +2876,10 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
         }
     } else {
         mon_printf(f,
-                   TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s",
+                   TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s%s): %s%s",
                    cur_start, cur_end,
                    mr->priority,
+                   mr->nonvolatile ? "nv-" : "",
                    memory_region_type((MemoryRegion *)mr),
                    memory_region_name(mr),
                    mr->enabled ? "" : " [disabled]");
@@ -2941,19 +2964,21 @@ static void mtree_print_flatview(gpointer key, gpointer value,
         mr = range->mr;
         if (range->offset_in_region) {
             p(f, MTREE_INDENT TARGET_FMT_plx "-"
-              TARGET_FMT_plx " (prio %d, %s): %s @" TARGET_FMT_plx,
+              TARGET_FMT_plx " (prio %d, %s%s): %s @" TARGET_FMT_plx,
               int128_get64(range->addr.start),
               int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
               mr->priority,
+              range->nonvolatile ? "nv-" : "",
               range->readonly ? "rom" : memory_region_type(mr),
               memory_region_name(mr),
               range->offset_in_region);
         } else {
             p(f, MTREE_INDENT TARGET_FMT_plx "-"
-              TARGET_FMT_plx " (prio %d, %s): %s",
+              TARGET_FMT_plx " (prio %d, %s%s): %s",
               int128_get64(range->addr.start),
               int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
               mr->priority,
+              range->nonvolatile ? "nv-" : "",
               range->readonly ? "rom" : memory_region_type(mr),
               memory_region_name(mr));
         }
diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst
index 687570754d..e7658ab050 100644
--- a/docs/devel/migration.rst
+++ b/docs/devel/migration.rst
@@ -435,6 +435,7 @@ Examples of such memory API functions are:
   - memory_region_add_subregion()
   - memory_region_del_subregion()
   - memory_region_set_readonly()
+  - memory_region_set_nonvolatile()
   - memory_region_set_enabled()
   - memory_region_set_address()
   - memory_region_set_alias_offset()
-- 
2.19.0.271.gfe8321ec05

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 2/3] nvdimm: set non-volatile on the memory region
  2018-10-03 11:44 [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions Marc-André Lureau
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 1/3] memory: learn about non-volatile memory region Marc-André Lureau
@ 2018-10-03 11:44 ` Marc-André Lureau
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList Marc-André Lureau
  2018-10-29  9:03 ` [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions Marc-André Lureau
  3 siblings, 0 replies; 10+ messages in thread
From: Marc-André Lureau @ 2018-10-03 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Igor Mammedov, Dr. David Alan Gilbert,
	Xiao Guangrong, Juan Quintela, Michael S. Tsirkin,
	Marc-André Lureau

qemu-system-x86_64 -machine pc,nvdimm -m 2G,slots=4,maxmem=16G -enable-kvm -monitor stdio -object memory-backend-file,id=mem1,share=on,mem-path=/tmp/foo,size=1G -device nvdimm,id=nvdimm1,memdev=mem1

HMP info mtree command reflects the flag with "nv-" prefix on memory type:

(qemu) info mtree
0000000100000000-000000013fffffff (prio 0, nv-i/o): alias nvdimm-memory @/objects/mem1 0000000000000000-000000003fffffff

(qemu) info mtree -f
0000000100000000-000000013fffffff (prio 0, nv-ram): /objects/mem1

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/mem/nvdimm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index 1c6674c4ed..0b1eeb677b 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -115,6 +115,7 @@ static void nvdimm_prepare_memory_region(NVDIMMDevice *nvdimm, Error **errp)
     nvdimm->nvdimm_mr = g_new(MemoryRegion, 1);
     memory_region_init_alias(nvdimm->nvdimm_mr, OBJECT(dimm),
                              "nvdimm-memory", mr, 0, pmem_size);
+    memory_region_set_nonvolatile(nvdimm->nvdimm_mr, true);
     nvdimm->nvdimm_mr->align = align;
 }
 
-- 
2.19.0.271.gfe8321ec05

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList
  2018-10-03 11:44 [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions Marc-André Lureau
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 1/3] memory: learn about non-volatile memory region Marc-André Lureau
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 2/3] nvdimm: set non-volatile on the " Marc-André Lureau
@ 2018-10-03 11:44 ` Marc-André Lureau
  2018-10-03 13:54   ` Laszlo Ersek
  2018-10-29  9:50   ` Paolo Bonzini
  2018-10-29  9:03 ` [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions Marc-André Lureau
  3 siblings, 2 replies; 10+ messages in thread
From: Marc-André Lureau @ 2018-10-03 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Igor Mammedov, Dr. David Alan Gilbert,
	Xiao Guangrong, Juan Quintela, Michael S. Tsirkin,
	Marc-André Lureau, lersek

GuestPhysBlockList is currently used to produce dumps. Given the size
and the typical usage of NVDIMM for storage, they are not a good idea
to have in the dumps. We may want to have an extra dump option to
include them. For now, skip non-volatile regions.

The TCG memory clear function is going to use the GuestPhysBlockList
as well, and will thus skip NVDIMM for similar reasons.

Cc: lersek@redhat.com
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 memory_mapping.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/memory_mapping.c b/memory_mapping.c
index 775466f3a8..724dd0b417 100644
--- a/memory_mapping.c
+++ b/memory_mapping.c
@@ -206,7 +206,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
 
     /* we only care about RAM */
     if (!memory_region_is_ram(section->mr) ||
-        memory_region_is_ram_device(section->mr)) {
+        memory_region_is_ram_device(section->mr) ||
+        memory_region_is_nonvolatile(section->mr)) {
         return;
     }
 
-- 
2.19.0.271.gfe8321ec05

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList Marc-André Lureau
@ 2018-10-03 13:54   ` Laszlo Ersek
  2018-10-10  9:44     ` Dr. David Alan Gilbert
  2018-10-29  9:50   ` Paolo Bonzini
  1 sibling, 1 reply; 10+ messages in thread
From: Laszlo Ersek @ 2018-10-03 13:54 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Paolo Bonzini, Igor Mammedov, Dr. David Alan Gilbert,
	Xiao Guangrong, Juan Quintela, Michael S. Tsirkin

On 10/03/18 13:44, Marc-André Lureau wrote:
> GuestPhysBlockList is currently used to produce dumps. Given the size
> and the typical usage of NVDIMM for storage, they are not a good idea
> to have in the dumps. We may want to have an extra dump option to
> include them. For now, skip non-volatile regions.
> 
> The TCG memory clear function is going to use the GuestPhysBlockList
> as well, and will thus skip NVDIMM for similar reasons.
> 
> Cc: lersek@redhat.com
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  memory_mapping.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/memory_mapping.c b/memory_mapping.c
> index 775466f3a8..724dd0b417 100644
> --- a/memory_mapping.c
> +++ b/memory_mapping.c
> @@ -206,7 +206,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
>  
>      /* we only care about RAM */
>      if (!memory_region_is_ram(section->mr) ||
> -        memory_region_is_ram_device(section->mr)) {
> +        memory_region_is_ram_device(section->mr) ||
> +        memory_region_is_nonvolatile(section->mr)) {
>          return;
>      }
>  
> 

I've peeked at the first two patches as well. Seems OK to me. (Famous
last words?)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList
  2018-10-03 13:54   ` Laszlo Ersek
@ 2018-10-10  9:44     ` Dr. David Alan Gilbert
  2018-10-10  9:49       ` David Hildenbrand
  0 siblings, 1 reply; 10+ messages in thread
From: Dr. David Alan Gilbert @ 2018-10-10  9:44 UTC (permalink / raw)
  To: Laszlo Ersek, david
  Cc: Marc-André Lureau, qemu-devel, Paolo Bonzini, Igor Mammedov,
	Xiao Guangrong, Juan Quintela, Michael S. Tsirkin

* Laszlo Ersek (lersek@redhat.com) wrote:
> On 10/03/18 13:44, Marc-André Lureau wrote:
> > GuestPhysBlockList is currently used to produce dumps. Given the size
> > and the typical usage of NVDIMM for storage, they are not a good idea
> > to have in the dumps. We may want to have an extra dump option to
> > include them. For now, skip non-volatile regions.
> > 
> > The TCG memory clear function is going to use the GuestPhysBlockList
> > as well, and will thus skip NVDIMM for similar reasons.
> > 
> > Cc: lersek@redhat.com
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  memory_mapping.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/memory_mapping.c b/memory_mapping.c
> > index 775466f3a8..724dd0b417 100644
> > --- a/memory_mapping.c
> > +++ b/memory_mapping.c
> > @@ -206,7 +206,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
> >  
> >      /* we only care about RAM */
> >      if (!memory_region_is_ram(section->mr) ||
> > -        memory_region_is_ram_device(section->mr)) {
> > +        memory_region_is_ram_device(section->mr) ||
> > +        memory_region_is_nonvolatile(section->mr)) {
> >          return;
> >      }
> >  
> > 
> 
> I've peeked at the first two patches as well. Seems OK to me. (Famous
> last words?)
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>

This also looks good to me; just cc'ing in David H as well though.

Dave

--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList
  2018-10-10  9:44     ` Dr. David Alan Gilbert
@ 2018-10-10  9:49       ` David Hildenbrand
  0 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2018-10-10  9:49 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Laszlo Ersek
  Cc: Marc-André Lureau, qemu-devel, Paolo Bonzini, Igor Mammedov,
	Xiao Guangrong, Juan Quintela, Michael S. Tsirkin

On 10/10/2018 11:44, Dr. David Alan Gilbert wrote:
> * Laszlo Ersek (lersek@redhat.com) wrote:
>> On 10/03/18 13:44, Marc-André Lureau wrote:
>>> GuestPhysBlockList is currently used to produce dumps. Given the size
>>> and the typical usage of NVDIMM for storage, they are not a good idea
>>> to have in the dumps. We may want to have an extra dump option to
>>> include them. For now, skip non-volatile regions.
>>>
>>> The TCG memory clear function is going to use the GuestPhysBlockList
>>> as well, and will thus skip NVDIMM for similar reasons.
>>>
>>> Cc: lersek@redhat.com
>>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>> ---
>>>  memory_mapping.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/memory_mapping.c b/memory_mapping.c
>>> index 775466f3a8..724dd0b417 100644
>>> --- a/memory_mapping.c
>>> +++ b/memory_mapping.c
>>> @@ -206,7 +206,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
>>>  
>>>      /* we only care about RAM */
>>>      if (!memory_region_is_ram(section->mr) ||
>>> -        memory_region_is_ram_device(section->mr)) {
>>> +        memory_region_is_ram_device(section->mr) ||
>>> +        memory_region_is_nonvolatile(section->mr)) {
>>>          return;
>>>      }
>>>  
>>>
>>
>> I've peeked at the first two patches as well. Seems OK to me. (Famous
>> last words?)
>>
>> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> 
> This also looks good to me; just cc'ing in David H as well though.
> 

Thanks Dave. Yes, just like the guest will exclude NVDIMMs from dumps,
so should we. (if somebody ever want to have this e.g. because the
NVDIMM is based on RAM in the host, we can introduce what you describe -
extra dump option).

Reviewed-by: David Hildenbrand <david@redhat.com>


-- 

Thanks,

David / dhildenb

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions
  2018-10-03 11:44 [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions Marc-André Lureau
                   ` (2 preceding siblings ...)
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList Marc-André Lureau
@ 2018-10-29  9:03 ` Marc-André Lureau
  3 siblings, 0 replies; 10+ messages in thread
From: Marc-André Lureau @ 2018-10-29  9:03 UTC (permalink / raw)
  To: QEMU
  Cc: Guangrong Xiao, Michael S. Tsirkin, Juan Quintela,
	Dr. David Alan Gilbert, Igor Mammedov, Paolo Bonzini

Hi

On Wed, Oct 3, 2018 at 3:46 PM Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> Hi,
>
> As discussed in the "[PATCH v10 6/6] tpm: add ACPI memory clear
> interface" thread, and proposed in the "[PATCH] RFC: mark non-volatile
> memory region", here is a small series to mark non-volvatile memory
> regions and skip them on dump. Upcoming TCG "Platform Reset Attack
> Mitigation" will also use this information to eventually skip
> non-volatile memory.
>
> Thanks
>
> Marc-André Lureau (3):
>   memory: learn about non-volatile memory region
>   nvdimm: set non-volatile on the memory region
>   memory-mapping: skip non-volatile memory regions in GuestPhysBlockList

Only last patch got reviews, but that means the first are probably ok as well.
Is anybody reviewing & picking the series?

thanks

>
>  include/exec/memory.h    | 25 ++++++++++++++++++++++
>  hw/mem/nvdimm.c          |  1 +
>  memory.c                 | 45 +++++++++++++++++++++++++++++++---------
>  memory_mapping.c         |  3 ++-
>  docs/devel/migration.rst |  1 +
>  5 files changed, 64 insertions(+), 11 deletions(-)
>
> --
> 2.19.0.271.gfe8321ec05
>
>


-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList
  2018-10-03 11:44 ` [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList Marc-André Lureau
  2018-10-03 13:54   ` Laszlo Ersek
@ 2018-10-29  9:50   ` Paolo Bonzini
  2018-11-05 15:17     ` Laszlo Ersek
  1 sibling, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2018-10-29  9:50 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Igor Mammedov, Dr. David Alan Gilbert, Xiao Guangrong,
	Juan Quintela, Michael S. Tsirkin, lersek

On 03/10/2018 13:44, Marc-André Lureau wrote:
> diff --git a/memory_mapping.c b/memory_mapping.c
> index 775466f3a8..724dd0b417 100644
> --- a/memory_mapping.c
> +++ b/memory_mapping.c
> @@ -206,7 +206,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
>  
>      /* we only care about RAM */
>      if (!memory_region_is_ram(section->mr) ||
> -        memory_region_is_ram_device(section->mr)) {
> +        memory_region_is_ram_device(section->mr) ||
> +        memory_region_is_nonvolatile(section->mr)) {
>          return;
>      }
>  

We should also have

diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
index 5a857cebcf..dd180b531c 100644
--- a/scripts/dump-guest-memory.py
+++ b/scripts/dump-guest-memory.py
@@ -417,7 +417,9 @@ def get_guest_phys_blocks():
         memory_region = flat_range["mr"].dereference()

         # we only care about RAM
-        if not memory_region["ram"]:
+        if not memory_region["ram"] \
+           or memory_region["ram_device"] \
+           or memory_region["nonvolatile"]:
             continue

         section_size = int128_get64(flat_range["addr"]["size"])

here.  I queued the patches and will post this soon as a separate patch.

Paolo

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList
  2018-10-29  9:50   ` Paolo Bonzini
@ 2018-11-05 15:17     ` Laszlo Ersek
  0 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2018-11-05 15:17 UTC (permalink / raw)
  To: Paolo Bonzini, Marc-André Lureau, qemu-devel
  Cc: Igor Mammedov, Dr. David Alan Gilbert, Xiao Guangrong,
	Juan Quintela, Michael S. Tsirkin

On 10/29/18 10:50, Paolo Bonzini wrote:
> On 03/10/2018 13:44, Marc-André Lureau wrote:
>> diff --git a/memory_mapping.c b/memory_mapping.c
>> index 775466f3a8..724dd0b417 100644
>> --- a/memory_mapping.c
>> +++ b/memory_mapping.c
>> @@ -206,7 +206,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
>>  
>>      /* we only care about RAM */
>>      if (!memory_region_is_ram(section->mr) ||
>> -        memory_region_is_ram_device(section->mr)) {
>> +        memory_region_is_ram_device(section->mr) ||
>> +        memory_region_is_nonvolatile(section->mr)) {
>>          return;
>>      }
>>  
> 
> We should also have
> 
> diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
> index 5a857cebcf..dd180b531c 100644
> --- a/scripts/dump-guest-memory.py
> +++ b/scripts/dump-guest-memory.py
> @@ -417,7 +417,9 @@ def get_guest_phys_blocks():
>          memory_region = flat_range["mr"].dereference()
> 
>          # we only care about RAM
> -        if not memory_region["ram"]:
> +        if not memory_region["ram"] \
> +           or memory_region["ram_device"] \
> +           or memory_region["nonvolatile"]:
>              continue
> 
>          section_size = int128_get64(flat_range["addr"]["size"])
> 
> here.  I queued the patches and will post this soon as a separate patch.

Thanks. I keep forgetting that this logic is duplicated.

Laszlo

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-11-05 15:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 11:44 [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions Marc-André Lureau
2018-10-03 11:44 ` [Qemu-devel] [PATCH 1/3] memory: learn about non-volatile memory region Marc-André Lureau
2018-10-03 11:44 ` [Qemu-devel] [PATCH 2/3] nvdimm: set non-volatile on the " Marc-André Lureau
2018-10-03 11:44 ` [Qemu-devel] [PATCH 3/3] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList Marc-André Lureau
2018-10-03 13:54   ` Laszlo Ersek
2018-10-10  9:44     ` Dr. David Alan Gilbert
2018-10-10  9:49       ` David Hildenbrand
2018-10-29  9:50   ` Paolo Bonzini
2018-11-05 15:17     ` Laszlo Ersek
2018-10-29  9:03 ` [Qemu-devel] [PATCH 0/3] Mark non-volatile memory regions Marc-André Lureau

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.