Skip to contentSkip to conversation

mem_access: Fix npfec.kind propagation

PATCH In review George Dunlap 5 participants 6 messages Sep 27, 2018 – Oct 17, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mem_access: Fix npfec.kind propagation

The name of the "with_gla" flag is confusing; it has nothing to do with the existence or lack thereof of a faulting GLA, but rather where the fault originated. The npfec.kind value is always valid, and should thus be propagated, regardless of whether gla_valid is set or not.

In particular, gla_valid will never be set on AMD systems; but npfec.kind will still be valid and should still be propagated.

---
Changes since RFC:
- Use switch() rather than a series of if's
- Adjust spacing

CC Andrew Cooper <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Tamas K Lengyel <[email protected]>
CC Razvan Cojocaru <[email protected]>
---
 xen/arch/x86/mm/mem_access.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
xen/arch/x86/mm/mem_access.c +12 -4
index d9e64fcbb9..99232045a9 100644
@@ -228,16 +228,24 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
         req->reason = VM_EVENT_REASON_MEM_ACCESS;
         req->u.mem_access.gfn = gfn_x(gfn);
         req->u.mem_access.offset = gpa & ((1 << PAGE_SHIFT) - 1);
+
         if ( npfec.gla_valid )
         {
             req->u.mem_access.flags |= MEM_ACCESS_GLA_VALID;
             req->u.mem_access.gla = gla;
+        }
 
-            if ( npfec.kind == npfec_kind_with_gla )
-                req->u.mem_access.flags |= MEM_ACCESS_FAULT_WITH_GLA;
-            else if ( npfec.kind == npfec_kind_in_gpt )
-                req->u.mem_access.flags |= MEM_ACCESS_FAULT_IN_GPT;
+        switch ( npfec.kind )
+        {
+        case npfec_kind_with_gla:
+            req->u.mem_access.flags |= MEM_ACCESS_FAULT_WITH_GLA;
+            break;
+        case npfec_kind_in_gpt:
+            req->u.mem_access.flags |= MEM_ACCESS_FAULT_IN_GPT;
+        default:
+            break;
         }
+
         req->u.mem_access.flags |= npfec.read_access    ? MEM_ACCESS_R : 0;
         req->u.mem_access.flags |= npfec.write_access   ? MEM_ACCESS_W : 0;
         req->u.mem_access.flags |= npfec.insn_fetch     ? MEM_ACCESS_X : 0;
Signature · 7 lines
2.19.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · George Dunlap

The name of the "with_gla" flag is confusing; it has nothing to do with the existence or lack thereof of a faulting GLA, but rather where the fault originated. The npfec.kind value is always valid, and should thus be propagated, regardless of whether gla_valid is set or not.

In particular, gla_valid will never be set on AMD systems; but npfec.kind will still be valid and should still be propagated.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to George Dunlap
Quoted 7 lines · George Dunlap

The name of the "with_gla" flag is confusing; it has nothing to do with the existence or lack thereof of a faulting GLA, but rather where
the fault originated. The npfec.kind value is always valid, and should thus be propagated, regardless of whether gla_valid is set or not.

Quoted 5 lines

In particular, gla_valid will never be set on AMD systems; but npfec.kind will still be valid and should still be propagated.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/1
#3 lore raw
In reply to George Dunlap
Quoted 11 lines · George Dunlap

The name of the "with_gla" flag is confusing; it has nothing to do with the existence or lack thereof of a faulting GLA, but rather where the fault originated. The npfec.kind value is always valid, and should thus be propagated, regardless of whether gla_valid is set or not.

In particular, gla_valid will never be set on AMD systems; but npfec.kind will still be valid and should still be propagated.

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 7 lines · Razvan Cojocaru
Quoted 6 lines · George Dunlap

The name of the "with_gla" flag is confusing; it has nothing to do with the existence or lack thereof of a faulting GLA, but rather where the fault originated. The npfec.kind value is always valid, and should thus be propagated, regardless of whether gla_valid is set or not.

Quoted 7 lines
Quoted 5 lines

In particular, gla_valid will never be set on AMD systems; but npfec.kind will still be valid and should still be propagated.

Does this also need Tamas' ack to go in?

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by Tamas K Lengyel
#5 lore raw
Quoted 12 lines · Razvan Cojocaru
Quoted 10 lines · Razvan Cojocaru
Quoted 9 lines · George Dunlap

The name of the "with_gla" flag is confusing; it has nothing to do with the existence or lack thereof of a faulting GLA, but rather where the fault originated. The npfec.kind value is always valid, and should thus be propagated, regardless of whether gla_valid is set or not.

In particular, gla_valid will never be set on AMD systems; but npfec.kind will still be valid and should still be propagated.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Does this also need Tamas' ack to go in?

Hm, I recall acking this patch before. In any case:

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel