From patchwork Mon Mar 6 12:31:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9605951 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 55E32604DD for ; Mon, 6 Mar 2017 12:34:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50D2828305 for ; Mon, 6 Mar 2017 12:34:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45AE728391; Mon, 6 Mar 2017 12:34:46 +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 D2CDC28394 for ; Mon, 6 Mar 2017 12:34:45 +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 1ckro9-0002yC-2d; Mon, 06 Mar 2017 12:32:09 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckro8-0002xp-2m for xen-devel@lists.xenproject.org; Mon, 06 Mar 2017 12:32:08 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 19/CE-12861-7C65DB85; Mon, 06 Mar 2017 12:32:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXitHRDpO6xsL0 RBlPe61t83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkTF11lKbgnWDHz9kW2BsbXfF2MnBwSAv4S P3c+YAKx2QR0JC7O3cnWxcjBISKgInF7rwFImFkgROLq1P1sILawgLfErUuvWUBKWIBKFjXZg YR5BSwl5m1YxAwxUU9i15HfrCA2p4CVROv0vWBxIaCad6u/MEHUC0qcnPmEBWK8pkTr9t/sEL a8RPPW2VD1ihL98x6wTWDkm4WkZRaSlllIWhYwMq9iVC9OLSpLLdI10ksqykzPKMlNzMzRNTQ w1stNLS5OTE/NSUwq1kvOz93ECAyzegYGxh2Mp5qdDzFKcjApifIumLYzQogvKT+lMiOxOCO+ qDQntfgQowwHh5IEb+ESoJxgUWp6akVaZg4w4GHSEhw8SiK8/SBp3uKCxNzizHSI1ClGXY45s 3e/YRJiycvPS5US500CKRIAKcoozYMbAYu+S4yyUsK8jAwMDEI8BalFuZklqPKvGMU5GJWEeR eBTOHJzCuB2/QK6AgmoCP8ZMCOKElESEk1MKY/3LTK5gzrv5T1ku4/GHbaqptqHA64aFKpySa xY7mQz+SLp/7Y9K5ecN5Pvrh/y44Yr5bMJ+8eF2+vvrK/i4N5Bi8Lm0/DVRm5dys/eoS1p7It nDnZja3icubiP6v1l+Z8OXnQeI+B17xrkbufhBmrLcqff4HFjOErn9fWh9uPf1/xVdbmVY4SS 3FGoqEWc1FxIgAYOb0OuQIAAA== X-Env-Sender: prvs=23199f632=roger.pau@citrix.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1488803523!30702766!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62329 invoked from network); 6 Mar 2017 12:32:06 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-4.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 6 Mar 2017 12:32:06 -0000 X-IronPort-AV: E=Sophos;i="5.35,253,1484006400"; d="scan'208";a="411736081" From: Roger Pau Monne To: Date: Mon, 6 Mar 2017 12:31:50 +0000 Message-ID: <20170306123150.99386-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170306123150.99386-1-roger.pau@citrix.com> References: <20170306123150.99386-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Daniel De Graaf , Roger Pau Monne Subject: [Xen-devel] [PATCH 2/2] build/clang: fix XSM dummy policy when using clang 4.0 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP There seems to be some weird bug in clang 4.0 that prevents xsm_pmu_op from working as expected, and vpmu.o ends up with a reference to __xsm_action_mismatch_detected which makes the build fail: [...] ld -melf_x86_64_fbsd -T xen.lds -N prelink.o \ xen/common/symbols-dummy.o -o xen/.xen-syms.0 prelink.o: In function `xsm_default_action': xen/include/xsm/dummy.h:80: undefined reference to `__xsm_action_mismatch_detected' xen/xen/include/xsm/dummy.h:80: relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__xsm_action_mismatch_detected' ld: xen/xen/.xen-syms.0: hidden symbol `__xsm_action_mismatch_detected' isn't defined Then doing a search in the objects files: # find xen/ -type f -name '*.o' -print0 | xargs -0 bash -c \ 'for filename; do nm "$filename" | \ grep -q __xsm_action_mismatch_detected && echo "$filename"; done' bash xen/arch/x86/prelink.o xen/arch/x86/cpu/vpmu.o xen/arch/x86/cpu/built_in.o xen/arch/x86/built_in.o The current patch is the only way I've found to fix this so far, by simply moving the XSM_PRIV check into the default case in xsm_pmu_op. This also fixes the behavior of do_xenpmu_op, which will now return -EINVAL for unknown XENPMU_* operations, instead of -EPERM when called by a privileged domain. Signed-off-by: Roger Pau Monné Acked-by: Daniel De Graaf --- Cc: Daniel De Graaf --- xen/include/xsm/dummy.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 4b27ae7..ff73039 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -682,18 +682,13 @@ static XSM_INLINE int xsm_pmu_op (XSM_DEFAULT_ARG struct domain *d, unsigned int XSM_ASSERT_ACTION(XSM_OTHER); switch ( op ) { - case XENPMU_mode_set: - case XENPMU_mode_get: - case XENPMU_feature_set: - case XENPMU_feature_get: - return xsm_default_action(XSM_PRIV, d, current->domain); case XENPMU_init: case XENPMU_finish: case XENPMU_lvtpc_set: case XENPMU_flush: return xsm_default_action(XSM_HOOK, d, current->domain); default: - return -EPERM; + return xsm_default_action(XSM_PRIV, d, current->domain); } }