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
Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
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 */