Skip to contentSkip to conversation

target/i386: HAX: Enable ROM/ROM device memory region support

PATCH In review [email protected] 3 participants 4 messages Mar 30, 2020 – Apr 28, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/i386: HAX: Enable ROM/ROM device memory region support

From: Hang Yuan <[email protected]>

Add ROM and ROM device memory region support in HAX. Their memory region is read only and write access will generate EPT violation. The violation will be handled in the HAX kernel with the following patch.

https://github.com/intel/haxm/commit/33ceea09a1655fca12c47f1e112b1d269357ff28

v2: fix coding style problems

---
 target/i386/hax-mem.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
target/i386/hax-mem.c +4 -7
index 6bb5a24917..a8bfd37977 100644
@@ -175,13 +175,10 @@ static void hax_process_section(MemoryRegionSection *section, uint8_t flags)
     uint64_t host_va;
     uint32_t max_mapping_size;
 
-    /* We only care about RAM and ROM regions */
-    if (!memory_region_is_ram(mr)) {
-        if (memory_region_is_romd(mr)) {
-            /* HAXM kernel module does not support ROMD yet  */
-            warn_report("Ignoring ROMD region 0x%016" PRIx64 "->0x%016" PRIx64,
-                        start_pa, start_pa + size);
-        }
+    /* We only care about RAM/ROM regions and ROM device */
+    if (memory_region_is_rom(mr) || (memory_region_is_romd(mr))) {
+        flags |= HAX_RAM_INFO_ROM;
+    } else if (!memory_region_is_ram(mr)) {
         return;
     }
 
Signature · 1 line
2.21.0
Reviewed-by on v2 1/1
#1 lore raw

Looks good to me.

Quoted 37 lines · On 2020-03-30 11:25, [email protected] wrote:

From: Hang Yuan <[email protected]>

Add ROM and ROM device memory region support in HAX. Their memory region is read only and write access will generate EPT violation. The violation will be handled in the HAX kernel with the following patch.

https://github.com/intel/haxm/commit/33ceea09a1655fca12c47f1e112b1d269357ff28

v2: fix coding style problems

---
  target/i386/hax-mem.c | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)
target/i386/hax-mem.c +4 -7
index 6bb5a24917..a8bfd37977 100644
@@ -175,13 +175,10 @@ static void hax_process_section(MemoryRegionSection *section, uint8_t flags)
      uint64_t host_va;
      uint32_t max_mapping_size;
 
-    /* We only care about RAM and ROM regions */
-    if (!memory_region_is_ram(mr)) {
-        if (memory_region_is_romd(mr)) {
-            /* HAXM kernel module does not support ROMD yet  */
-            warn_report("Ignoring ROMD region 0x%016" PRIx64 "->0x%016" PRIx64,
-                        start_pa, start_pa + size);
-        }
+    /* We only care about RAM/ROM regions and ROM device */
+    if (memory_region_is_rom(mr) || (memory_region_is_romd(mr))) {
+        flags |= HAX_RAM_INFO_ROM;
+    } else if (!memory_region_is_ram(mr)) {
          return;
      }
 
Signature · 2 lines
Best Regards,
Colin Xu
#2 lore raw

Hi Paolo,

Would you please queue this one?
--
Best Regards,
Colin Xu

Quoted 49 lines · Colin Xu

Looks good to me.

Quoted 37 lines · On 2020-03-30 11:25, [email protected] wrote:

From: Hang Yuan <[email protected]>

Add ROM and ROM device memory region support in HAX. Their memory region is read only and write access will generate EPT violation. The violation will be handled in the HAX kernel with the following patch.

https://github.com/intel/haxm/commit/33ceea09a1655fca12c47f1e112b1d269357ff28

v2: fix coding style problems

---
  target/i386/hax-mem.c | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)
target/i386/hax-mem.c +4 -7
index 6bb5a24917..a8bfd37977 100644
@@ -175,13 +175,10 @@ static void hax_process_section(MemoryRegionSection *section, uint8_t flags)
      uint64_t host_va;
      uint32_t max_mapping_size;
 
-    /* We only care about RAM and ROM regions */
-    if (!memory_region_is_ram(mr)) {
-        if (memory_region_is_romd(mr)) {
-            /* HAXM kernel module does not support ROMD yet  */
-            warn_report("Ignoring ROMD region 0x%016" PRIx64 "->0x%016" PRIx64,
-                        start_pa, start_pa + size);
-        }
+    /* We only care about RAM/ROM regions and ROM device */
+    if (memory_region_is_rom(mr) || (memory_region_is_romd(mr))) {
+        flags |= HAX_RAM_INFO_ROM;
+    } else if (!memory_region_is_ram(mr)) {
          return;
      }
 
Signature · 2 lines
Best Regards,
Colin Xu
#3 lore raw
Quoted 20 lines · Colin Xu

Hi Paolo,

Would you please queue this one?

Signature · 2 lines
Best Regards,
Colin Xu
Quoted 10 lines · Colin Xu

Looks good to me.

Quoted 5 lines · On 2020-03-30 11:25, [email protected] wrote:

From: Hang Yuan <[email protected]>

Add ROM and ROM device memory region support in HAX. Their memory region is read only and write access will generate EPT violation. The violation will be handled in the HAX kernel with the following patch.

"will be"? This patch is 10 months old.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

https://github.com/intel/haxm/commit/33ceea09a1655fca12c47f1e112b1d269357ff28

v2: fix coding style problems

^ This line goes ...

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

---

... here after the '---'.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

  target/i386/hax-mem.c | 11 ++++-------

  1 file changed, 4 insertions(+), 7 deletions(-)
target/i386/hax-mem.c +0 -0
index 6bb5a24917..a8bfd37977 100644
@@ -175,13 +175,10 @@ static void 
 hax_process_section(MemoryRegionSection *section, uint8_t flags)
       uint64_t host_va;
       uint32_t max_mapping_size;
 
Quoted 7 lines
Quoted 7 lines

target/i386/hax-mem.c static void hax_process_section(MemoryRegionSection *section, uint8_t flags) · line 183

Quoted 7 lines
target/i386/hax-mem.c +0 -6
-    /* We only care about RAM and ROM regions */
-    if (!memory_region_is_ram(mr)) {
-        if (memory_region_is_romd(mr)) {
-            /* HAXM kernel module does not support ROMD yet  */
-            warn_report("Ignoring ROMD region 0x%016" PRIx64 
 "->0x%016" PRIx64,
-                        start_pa, start_pa + size);

Don't you need to check for some kmod version before removing this check?

Quoted 3 lines
Quoted 3 lines

target/i386/hax-mem.c static void hax_process_section(MemoryRegionSection *section, uint8_t flags) · line 179

Quoted 3 lines
target/i386/hax-mem.c +2 -1
-        }
+    /* We only care about RAM/ROM regions and ROM device */
+    if (memory_region_is_rom(mr) || (memory_region_is_romd(mr))) {

Redundant parenthesis.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
target/i386/hax-mem.c +2 -0
+        flags |= HAX_RAM_INFO_ROM;
+    } else if (!memory_region_is_ram(mr)) {
           return;

      }

If you move the 'if (RAM) return' first, the code becomes easier to review.

Quoted 9 lines
Quoted 8 lines
Quoted 1 line
Signature · 2 lines
Best Regards,
Colin Xu