From patchwork Thu Mar 3 13:38:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 8492711 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 02D439F8A8 for ; Thu, 3 Mar 2016 13:42:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2CD0A20122 for ; Thu, 3 Mar 2016 13:42:13 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 523592008F for ; Thu, 3 Mar 2016 13:42:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1abTT5-0001Qx-PS; Thu, 03 Mar 2016 13:39:03 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1abTT4-0001Qr-QZ for xen-devel@lists.xen.org; Thu, 03 Mar 2016 13:39:02 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id B7/D0-28898-67E38D65; Thu, 03 Mar 2016 13:39:02 +0000 X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1457012341!26620353!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=1.7 required=7.0 tests=BIZ_TLD X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26271 invoked from network); 3 Mar 2016 13:39:01 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-4.tower-206.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 3 Mar 2016 13:39:01 -0000 Received: (qmail 21773 invoked from network); 3 Mar 2016 15:39:00 +0200 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.bbu.dsd.mx.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 3 Mar 2016 15:39:00 +0200 Received: from smtp02.buh.bitdefender.net (unknown [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 5CA487FBFD for ; Thu, 3 Mar 2016 15:39:00 +0200 (EET) Received: (qmail 14904 invoked from network); 3 Mar 2016 15:39:00 +0200 Received: from xen.dsd.ro (HELO xen.dsd.bitdefender.biz) (rcojocaru@bitdefender.com@10.10.14.109) by smtp02.buh.bitdefender.net with AES128-SHA256 encrypted SMTP; 3 Mar 2016 15:39:00 +0200 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Thu, 3 Mar 2016 15:38:40 +0200 Message-Id: <1457012320-7876-1-git-send-email-rcojocaru@bitdefender.com> X-Mailer: git-send-email 1.9.1 X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.4 on smtp02.buh.bitdefender.net, sigver: 7.64710 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.743, Dats: 416124, Stamp: 3], Multi: [Enabled, t: (0.000011, 0.001560)], BW: [Enabled, t: (0.000011,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.001917), Flags: BDD9BED7; NN_NO_CONTENT_TYPE; NN_ADULT_16_SLT; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.009088)], URL: [Enabled, t: (0.000024)], RTDA: [Enabled, t: (0.035636), Hit: No, Details: v2.3.3; Id: 2m1ghak.1aclq2ef7.1t2pa], total: 0(775) X-BitDefender-CF-Stamp: none Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, Razvan Cojocaru , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH V2] libxc: Have xc_translate_foreign_address() set errno properly X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fixes https://jira.bitdefender.biz/browse/HEIMDALL-71 Roughly based on Don Slutz' patch: http://lists.xen.org/archives/html/xen-devel/2014-03/msg03720.html Signed-off-by: Razvan Cojocaru --- Changes since V1: - Turns out that the only case that has occured in my tests where errno is not set is the "if (!(pte & 1))" case. Removed all other errno checks. --- tools/libxc/xc_pagetab.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/libxc/xc_pagetab.c b/tools/libxc/xc_pagetab.c index ec97890..92eebd6 100644 --- a/tools/libxc/xc_pagetab.c +++ b/tools/libxc/xc_pagetab.c @@ -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 */