Skip to contentSkip to conversation

libxc: Have xc_translate_foreign_address() set errno properly

PATCH Applied Razvan Cojocaru 2 participants 4 messages Mar 3, 2016 – Mar 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 libxc: Have xc_translate_foreign_address() set errno properly

Currently it's possible for xc_translate_foreign_address() to fail and errno still be set to success. This patch fixes the issue. Based on the first half of Don Slutz' patch:
http://lists.xen.org/archives/html/xen-devel/2014-03/msg03720.html

---
Changes since V2:
- Fixed description text.
- Added Wei Liu's ack.

---
 tools/libxc/xc_pagetab.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxc/xc_pagetab.c +3 -1
index ec97890..92eebd6 100644
@@ -88,8 +88,10 @@ unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom,
             return 0;
         memcpy(&pte, map + (paddr & (PAGE_SIZE - 1)), size);
         munmap(map, PAGE_SIZE);
-        if (!(pte & 1)) 
+        if (!(pte & 1)) {
+            errno = EADDRNOTAVAIL;
             return 0;
+        }
         paddr = pte & 0x000ffffffffff000ull;
         if (level == 2 && (pte & PTE_PSE)) {
             mask = ((mask ^ ~-mask) >> 1); /* All bits below first set bit */
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw
Quoted 23 lines · Razvan Cojocaru

Currently it's possible for xc_translate_foreign_address() to fail and errno still be set to success. This patch fixes the issue. Based on the first half of Don Slutz' patch:
http://lists.xen.org/archives/html/xen-devel/2014-03/msg03720.html

---
Changes since V2:
- Fixed description text.
- Added Wei Liu's ack.

---
 tools/libxc/xc_pagetab.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxc/xc_pagetab.c +0 -0
index ec97890..92eebd6 100644
@@ -88,8 +88,10 @@ unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom,
             return 0;

tools/libxc/xc_pagetab.c unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom, · line 97

Quoted 10 lines
tools/libxc/xc_pagetab.c +3 -1
         memcpy(&pte, map + (paddr & (PAGE_SIZE - 1)), size);
         munmap(map, PAGE_SIZE);
-        if (!(pte & 1)) 
+        if (!(pte & 1)) {
+            errno = EADDRNOTAVAIL;
             return 0;
+        }
         paddr = pte & 0x000ffffffffff000ull;
         if (level == 2 && (pte & PTE_PSE)) {
             mask = ((mask ^ ~-mask) >> 1); /* All bits below first set bit */

Should I change something in this patch? It's been roughly two weeks since the previous message with no commit to staging and no additional comments, could I have missed a review?

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 30 lines · Razvan Cojocaru
Quoted 29 lines · Razvan Cojocaru

Currently it's possible for xc_translate_foreign_address() to fail and errno still be set to success. This patch fixes the issue. Based on the first half of Don Slutz' patch:
http://lists.xen.org/archives/html/xen-devel/2014-03/msg03720.html

---
Changes since V2:
- Fixed description text.
- Added Wei Liu's ack.

---
 tools/libxc/xc_pagetab.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxc/xc_pagetab.c +3 -1
index ec97890..92eebd6 100644
@@ -88,8 +88,10 @@ unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom,
             return 0;
         memcpy(&pte, map + (paddr & (PAGE_SIZE - 1)), size);
         munmap(map, PAGE_SIZE);
-        if (!(pte & 1)) 
+        if (!(pte & 1)) {
+            errno = EADDRNOTAVAIL;
             return 0;
+        }
Quoted 8 lines

tools/libxc/xc_pagetab.c unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom, · line 97

Quoted 4 lines
tools/libxc/xc_pagetab.c +0 -0
         paddr = pte & 0x000ffffffffff000ull;
         if (level == 2 && (pte & PTE_PSE)) {
             mask = ((mask ^ ~-mask) >> 1); /* All bits below first set bit */

Should I change something in this patch? It's been roughly two weeks since the previous message with no commit to staging and no additional comments, could I have missed a review?

Applied.

Quoted 9 lines

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 40 lines · Konrad Rzeszutek Wilk
Quoted 30 lines · Razvan Cojocaru
Quoted 29 lines · Razvan Cojocaru

Currently it's possible for xc_translate_foreign_address() to fail and errno still be set to success. This patch fixes the issue. Based on the first half of Don Slutz' patch:
http://lists.xen.org/archives/html/xen-devel/2014-03/msg03720.html

---
Changes since V2:
- Fixed description text.
- Added Wei Liu's ack.

---
 tools/libxc/xc_pagetab.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxc/xc_pagetab.c +3 -1
index ec97890..92eebd6 100644
@@ -88,8 +88,10 @@ unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom,
             return 0;
         memcpy(&pte, map + (paddr & (PAGE_SIZE - 1)), size);
         munmap(map, PAGE_SIZE);
-        if (!(pte & 1)) 
+        if (!(pte & 1)) {
+            errno = EADDRNOTAVAIL;
             return 0;
+        }
Quoted 8 lines

tools/libxc/xc_pagetab.c unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom, · line 97

Quoted 4 lines
tools/libxc/xc_pagetab.c +0 -0
         paddr = pte & 0x000ffffffffff000ull;
         if (level == 2 && (pte & PTE_PSE)) {
             mask = ((mask ^ ~-mask) >> 1); /* All bits below first set bit */

Should I change something in this patch? It's been roughly two weeks since the previous message with no commit to staging and no additional comments, could I have missed a review?

Quoted 1 line

Applied.

Thank you!

Cheers,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel