From patchwork Tue Apr 4 12:14:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 9661525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 10DCA60352 for ; Tue, 4 Apr 2017 12:17:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0482426E69 for ; Tue, 4 Apr 2017 12:17:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECECA2846C; Tue, 4 Apr 2017 12:17:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id C1CB428418 for ; Tue, 4 Apr 2017 12:17:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvNMq-0000MF-HO; Tue, 04 Apr 2017 12:15:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvNMp-0000M2-Ip for xen-devel@lists.xen.org; Tue, 04 Apr 2017 12:15:23 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 21/4D-20914-A5E83E85; Tue, 04 Apr 2017 12:15:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsUSfTxjoW5U3+M Ig++TZCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oznH/azFNzhqNh54ihzA+MTti5GTg4hATeJ syeXsXQxcgHZaxglZkyfzQjhXGOUmNy4hBmiyl3i97I3UIl9jBLrL10AS7AJGEqs3tgCNkpEQ Fri2ufLjCA2s8AERolPN41BbGEBK4mu/xvYQWwWAVWJrvMrwXp5BTwkNh87AhaXEJCTOHlsMi uEnSPRcf8jkM0BZEtJ/G9VAtkrIdDLIrH35W5GiBoZiUcTb7JNYBRYwMiwilGjOLWoLLVI18h cL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMjMLTqGRgYdzC27PU7xCjJwaQkynvY 83GEEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQnetF6gnGBRanpqRVpmDjDIYdISHDxKIrwzQNK8x QWJucWZ6RCpU4y6HHNm737DJMSSl5+XKiXOawZSJABSlFGaBzcCFnGXGGWlhHkZGRgYhHgKUo tyM0tQ5V8xinMwKgnzJoJM4cnMK4Hb9AroCCagI57ceQhyREkiQkqqgVH89he3sKrGgDfq13M /Z9a9j1K78qbxguWt+EkBV5O9HtU1C0Qylh3Kit0pxVKWP4+b/XZJe8+09Jscm4oiQ38lxXA/ jpvk/Oa6oMca4eg19kucH7Xs3ldcm5HyNpnXeKr48rqN27N9DFs9vH7fC21r47WISv9U8Lib4 /CKyCk/pins3D7VXYmlOCPRUIu5qDgRAPl26KqzAgAA X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1491308122!38562334!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39183 invoked from network); 4 Apr 2017 12:15:22 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-9.tower-31.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 4 Apr 2017 12:15:22 -0000 Received: (qmail 4965 invoked from network); 4 Apr 2017 15:15:21 +0300 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; 4 Apr 2017 15:15:21 +0300 Received: from smtp02.buh.bitdefender.net (smtp.bitdefender.biz [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 778FE7FC40 for ; Tue, 4 Apr 2017 15:15:21 +0300 (EEST) Received: (qmail 21590 invoked from network); 4 Apr 2017 15:15:21 +0300 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; 4 Apr 2017 15:15:21 +0300 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Tue, 4 Apr 2017 15:14:59 +0300 Message-Id: <1491308099-4751-1-git-send-email-rcojocaru@bitdefender.com> X-Mailer: git-send-email 1.9.1 X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp02.buh.bitdefender.net, sigver: 7.70607 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.8.1074, Dats: 445222, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.003712)], BW: [Enabled, t: (0.000007)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002141), Flags: 85D2ED72; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.009004,0.000061)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.142460), Hit: No, Details: v2.4.5; Id: 11.5eujg9.1bcs8kdqs.1o6g], total: 0(775) X-BitDefender-CF-Stamp: none Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, Razvan Cojocaru , Cristian-Bogdan Sirb Subject: [Xen-devel] [PATCH] Libxc: fix xc_translate_foreign_address() 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-Virus-Scanned: ClamAV using ClamSMTP Currently xc_translate_foreign_address only checks for PSE bit only on level 2 entries (that's 2 MB pages on x64 and 32-bit with PAE, and 4 MB pages on 32-bit). But linux kernel sometimes uses 1 GB pages. This patch fixes that, and checks the PSE bit on level 3 entries if the guest has 4 translation levels (that means 64-bit guests only). Signed-off-by: Cristian-Bogdan Sirb --- tools/libxc/xc_pagetab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libxc/xc_pagetab.c b/tools/libxc/xc_pagetab.c index 92eebd6..db25c20 100644 --- a/tools/libxc/xc_pagetab.c +++ b/tools/libxc/xc_pagetab.c @@ -93,7 +93,7 @@ unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom, return 0; } paddr = pte & 0x000ffffffffff000ull; - if (level == 2 && (pte & PTE_PSE)) { + if ((level == 2 || (level == 3 && pt_levels == 4)) && (pte & PTE_PSE)) { mask = ((mask ^ ~-mask) >> 1); /* All bits below first set bit */ return ((paddr & ~mask) | (virt & mask)) >> PAGE_SHIFT; }