Re: [PATCH v1 2/8] x86/xen: simplify xen_oldmem_pfn_is_ram()

From
David Hildenbrand <hidden>
Date
2021-09-29 08:45:51
Also in
kexec, linux-fsdevel, lkml, virtualization, xen-devel
Reply to
Boris Ostrovsky, 2021-09-29
How about

     return a.mem_type != HVMMEM_mmio_dm;
Ha, how could I have missed that :)
Result should be promoted to int and this has added benefit of not requiring changes in patch 4.
Can we go one step further and do

@@ -20,24 +20,11 @@ static int xen_oldmem_pfn_is_ram(unsigned long pfn)
        struct xen_hvm_get_mem_type a = {
                .domid = DOMID_SELF,
                .pfn = pfn,
+               .mem_type = HVMMEM_ram_rw,
        };
-       int ram;
 
-       if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a))
-               return -ENXIO;
-
-       switch (a.mem_type) {
-       case HVMMEM_mmio_dm:
-               ram = 0;
-               break;
-       case HVMMEM_ram_rw:
-       case HVMMEM_ram_ro:
-       default:
-               ram = 1;
-               break;
-       }
-
-       return ram;
+       HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a);
+       return a.mem_type != HVMMEM_mmio_dm;
 }
 #endif

Assuming that if HYPERVISOR_hvm_op() fails that
.mem_type is not set to HVMMEM_mmio_dm.

-- 
Thanks,

David / dhildenb

Thread (16 messages) 16 messages, 2 authors, last reply 2021-09-29
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help