Received: by 10.223.164.202 with SMTP id h10csp1272041wrb; Wed, 8 Nov 2017 01:27:10 -0800 (PST) X-Google-Smtp-Source: ABhQp+RRtYZ4AgHob6/F0omFf4jhrEUdXsvNbIYoYKMXYBLm3VQK691mhaq945qmNihPFAd1aCrj X-Received: by 10.84.168.5 with SMTP id e5mr1692260plb.150.1510133229961; Wed, 08 Nov 2017 01:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510133229; cv=none; d=google.com; s=arc-20160816; b=S+h4nt4bU7B6FQ/ayKUtAGsmCPOPmJHqHjRX/gXXW12JATV4c0w/fBQP8wfu/hdJ82 UQmvSMhvAvq9xGIY9HCF8sLWF+SNTiChO7rYzXX1HL6vw4POvuXb1mcXpNHqUj9cKMOY irPW+pdI1/RXtlU5FZH23yII4bwozhv6bG7KX6jqc3xLZE2oE0+5PzsLVmk1mbHeISyH jb5pWkbCPuY+5qotBYYTkVjuwjgDORMK0geKZFsTegYR2cvM9YcK6kudJp9wO/Yg8nYt E2MHCnM+znwklOw1bTGO5wAhP+3Q6vpXKB5mxtoteuwZJOpfgwYRmMNQT6zvntx8IyCA EPkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=F4XS+zUvSUp++ZDqmgIoOrjyGy3T8jc2umd4q8pyeSQ=; b=cuzuv11kiK/PZvJIj92LCmBOUQtDschCYtIaePRYfVJpy5jelMWggbV8VMzuev3H6C BygVBibqveQNztIOjSIv41BOXyRnrbPzu0mKUmcxemeFzaRk/p1862ey4LwZrtUBg9hK cMoz9tICRmZApfFEWaZsRQ1OT2YisgCSIOvoS82AVIDIBw2jxQ2yQBD7hDD5g0GIqAFS 88F2biHfgoY7pmxRj3mVJ7w8QeTAhZhTEHm6CnJjpAH4iNNd+UE00WDeWrgXsCbjIGq8 L2pfM9WzFEOeVu+y697MCirS0gtkSligw4v2umBjUaMuRbHvjs9Gz9q+Su2vBTUdxAaM MLqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=HObKQr0u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g19si3698628pfd.61.2017.11.08.01.26.56; Wed, 08 Nov 2017 01:27:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=HObKQr0u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751417AbdKHJ0S (ORCPT + 91 others); Wed, 8 Nov 2017 04:26:18 -0500 Received: from mail-cys01nam02on0045.outbound.protection.outlook.com ([104.47.37.45]:36865 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750752AbdKHJ0N (ORCPT ); Wed, 8 Nov 2017 04:26:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=F4XS+zUvSUp++ZDqmgIoOrjyGy3T8jc2umd4q8pyeSQ=; b=HObKQr0uuKBSHJ7F8eSfRqLDkFX8fo6n5+UXN9m/DWQq3RN5n4Kh6KlfpVvc9lo280hICuZy61fxvVlg5/hkBb+xxajqaNirLbymoYyuxOVtrYuFFsA+MiWh87wyGYXs/OTljAYXWagk3UizoHXZKrFmCh9/qEt/0BAhHyHBZmw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (50.233.148.156) by MWHPR0701MB3835.namprd07.prod.outlook.com (2603:10b6:301:7f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12; Wed, 8 Nov 2017 09:26:09 +0000 Date: Wed, 8 Nov 2017 12:25:55 +0300 From: Yury Norov To: Sami Tolvanen Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Greg Hackmann , Kees Cook , Matthias Kaehlcke , Nick Desaulniers , Andi Kleen , Maxim Kuvyrkov , Alex Matveev , Yury Norov Subject: Re: [PATCH 13/15] arm64: fix mrs_s/msr_s macros for clang LTO Message-ID: <20171108092555.ta4mkqolunyw6mdr@yury-thinkpad> References: <20171103171203.107569-1-samitolvanen@google.com> <20171103171203.107569-18-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171103171203.107569-18-samitolvanen@google.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: AM5PR0102CA0001.eurprd01.prod.exchangelabs.com (2603:10a6:206::14) To MWHPR0701MB3835.namprd07.prod.outlook.com (2603:10b6:301:7f::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78bdb0ad-de0a-4f71-b793-08d5268abfe0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603249);SRVR:MWHPR0701MB3835; X-Microsoft-Exchange-Diagnostics: 1;MWHPR0701MB3835;3:dOXGMneUgX7Ke3NdHTBFvZ+fCXHZXiERenDMK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oZ0Zv15+Ps3jeIHspLRfrxdKjDmYaa6wsmIDvy5OpnXJriJFNJPmL3v3FtPoeVSgf4nU3AbfpsJufVRYln47+8qZp2s3Q/JeVFT18vCUEsdzwF1F2uM2s0YSeOBB5qARyIHyCVZPboWmmoaizUxWlev9H2NX/NctsBsGbLRtTrZeAfmLFKeAqvl/jULaMtvKVoKhXYfGjytNAvsEmvYZLhxsij9iMpE1B/39vXs5Dl0QrhQHBgJcSdkfzVgjdBTKIUKNKIguNUj/NXnMKpRo5ZpXwSfcPAx5H/KeiYdGHg/aZgWsjRe/MbkGChlVsFHW+4BUplFglyJTjdUcabQFVwwO6fB1BRqYx2VCO/ilU8sxZqws6b++zpdgkNtLgfUi19i8b62XmcB+roCVcsBnFPJy5WItnwMvTY= X-Exchange-Antispam-Report-Test: UriScan:(166708455590820)(262104967686372); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231021)(93006095)(100000703101)(100105400095)(6041248)(20161123555025)(20161123564025)(20161123558100)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR0701MB3835;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR0701MB3835; X-Microsoft-Exchange-Diagnostics: 1;MWHPR0701MB3835;4:C16yhsVXQnYc1pI5hoxXWyKoZ6RSc8gM7ppPjnLeViasMp9pB3B1Yj2d14kuw8Dbv39VJ99QB/fNf+nhX5s5ILS8X9j1Jpfj4mTLiTC3GirAw1CiVcPI2z67zdCBCT2/aEMzEkDOoD2fDVR5pGjUaq+EgjsVT3wro2sXfqLrRlYW3eTXzyKThAgRuUAIHEMXcWIc+vvBfbGnDwaiLqDaN6pIwGwrs5uN2mRyOORWyMDg404zkI1Sj3qm27VDWeydmKhlVY3suB9lRgju7CtEkaPVsbmfDtJI1N475948qo9AOG/JIUUjpgDORGE8BgBNAL1YQ68vP2UZNC8bhUdneggvyySCm6SbE85kA4cb7zI= X-Forefront-PRVS: 0485417665 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(7916004)(376002)(346002)(11905935001)(189002)(24454002)(199003)(54906003)(83506002)(6916009)(53936002)(1076002)(42882006)(16586007)(6666003)(316002)(58126008)(2950100002)(229853002)(101416001)(50986999)(9686003)(33646002)(6306002)(107886003)(6496005)(575784001)(8936002)(6246003)(39060400002)(105586002)(106356001)(5660300001)(6116002)(3846002)(33716001)(50466002)(97736004)(7416002)(189998001)(76506005)(305945005)(4326008)(23726003)(2906002)(478600001)(7736002)(72206003)(47776003)(66066001)(25786009)(81156014)(966005)(53546010)(76176999)(81166006)(54356999)(16526018)(68736007)(6486002)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR0701MB3835;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR0701MB3835;23:heT0Lxa0wY7IWT2ssYgdPKJRSjMZsmOY8pJKOSs?= =?us-ascii?Q?MSndn2lAundicBfiBJilq3skxTHNq49LRGeY8n9zfydjNQbYg1JimGzNu3rx?= =?us-ascii?Q?WnYq1wvr6cUvP96pY8heJxT+8i5UvvAz5M7z1GbmOoxhJG+VT0yIA3O5Wrgb?= =?us-ascii?Q?klvxvKwzQpf88ALS51ng06eRfMokxSQyKX6V1WlCxdJbXPNsFpYsq22KvTuw?= =?us-ascii?Q?sXCxP/wZ1eaibjSTFJv34jQlTWvYi7liC0ZfFW+ee8wRTKMsb2dvPu1ByBQn?= =?us-ascii?Q?O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FeNfZEFHj+2kYJ65il458?= =?us-ascii?Q?jRIYIcANbnY3hyVcz6BUkJ6wTt5pOMLYwUWi7qRGTOMTu5QIRyigR9IxW1/U?= =?us-ascii?Q?BjiUXIzFyW+REW+EjimUaS3OB6C2t72J1psMoKBCUIjDQAXUD3NmuVnPs/nM?= =?us-ascii?Q?EgC7axgZHzPVv20m1FkWLJXujzOGmZO11l4dK0VOz6BUK4iNNdtJWRkSNGlA?= =?us-ascii?Q?miax+yUzWyVHbMUmMRTsUcH5u1DXNApKB1k2gPR+92XnnUCKry93f7S5siQ6?= =?us-ascii?Q?6OQdO4Jfua8fQ3TDx0daARaOvSI15dNk=3D?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR0701MB3835;6:bUTHwNRHp3wcYQ/s38yPerWHkYLzlMikPYMLBzPiW8+QJ+dhoE3m2Z9mkUFaI2PS1tK+zKcDP2RqiUlntzwG0w8rbnssObYjTij7FayswvK87q+kOa7s1+/+msJlqFjuCCdQD+GzK582rHmUIgLliOTl6TcJlqjQIrOY40b/l6QOuGb2RBuwCVqkX1A8myGvAofAXAOco4qHeObkjPkuRv6yQyjSgS6C716c1yyHiPOdFwdDTTd/V0AJ7wZlYmfTL0TPvt8iiUOpKZWO/DMcrzpqOyx5egjprvK41Aq0A9zTW3vA0CuKq5neTrDsVGfVUPzsTEF2LDkX+W93gqf/LXvdTDKqaumpZKyuRypGveQ=;5:zEMHcyuaXFEv2gPbANQcMvkGIrYGTZLLokzACb0w+c8dZj8mqR12wMgIpJcWSX9Oq7r7wm7grxVywgblX63FCBSFTUVkgAbVEwGug0QKlDh0yN6oo3fQidOaU0A6W9j/asDG/bKA3m7C3VyuqLm2OFrho/CEN2/ESHfzbvXo21I=;24:K3GtBjAVErj+nsgxUUyYZTaJShf83Wlef7+18dxvvz05KwEqs17aTAIhOzTt4jVzfere4U/VN/EucdAdiv752SBYXgRlZ14hn0YPjR6W3hs=;7:NjpXrnDNKZROdZNxLrM/SW42OccJCjLRFqd+4W/j3xHZGnR/pefFrsq03eal9sMm9K6GzZdiI6TY7VN/zKg85SkTk/QFjLtGMtlRUeSOPGuOtFHoZrNjmkzjsj5dcDNNPNGsg1zFYcRZhwkekKLbuHbenAVBRuotP92y5D6KCDz+WM0E06Hpq/tYG4VtMNcBCynaebBLwjzsVQlvN6DJ+CNhrUEsR6XK/XYYAPafJPpoXY1fxpKXe3iwDMoJGj7g SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2017 09:26:09.5873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78bdb0ad-de0a-4f71-b793-08d5268abfe0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0701MB3835 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sami, (CC Andi Kleen, Alex Matveev, Maxim Kuvyrkov) On Fri, Nov 03, 2017 at 10:12:01AM -0700, Sami Tolvanen wrote: > Clang's integrated assembler does not allow assembly macros defined > in one inline asm block using the .macro directive to be used across > separate asm blocks. LLVM developers consider this a feature and not a > bug, recommending code refactoring: > > https://bugs.llvm.org/show_bug.cgi?id=19749 > > As binutils doesn't allow macros to be redefined, this change adds C > preprocessor macros that define the assembly macros globally for binutils > and locally for clang's integrated assembler. This macros are also the problem for gcc and ld.bfd if we try to enable LTO. The patch below uses trick with undefining mrs_s/msr_s immediately after use to solve the problem. It works for both gcc and clang. There's the series from Andi Kleen that enables LTO for Linux on x86: https://lwn.net/Articles/512548/ https://github.com/andikleen/linux-misc/tree/lto-411-1 It has solved many problems you also try to solve, and some patches are looking very similar. At now we have different patchsets for gcc and clang, and it would be better to have them together. One thing I'm worried is that you introduce CONFIG_CLANG_LTO and use it for all cases, including that where more generic CONFIG_LTO should be used. I think we'd also discuss it here. ________ >From c939344c726e8ae6b28012ad2807c63b54175e40 Mon Sep 17 00:00:00 2001 From: Alex Matveev Date: Tue, 7 Nov 2017 01:06:33 +0000 Subject: [PATCH] arm64: make mrs_s and msr_s macros work with LTO Use UNDEFINE_MRS_S and UNDEFINE_MSR_S to define corresponding macros in-place and workaround gcc and clang limitations on redefining macros across different assembler blocks. Signed-off-by: Alex Matveev Signed-off-by: Yury Norov --- arch/arm64/include/asm/kvm_hyp.h | 8 ++++-- arch/arm64/include/asm/sysreg.h | 55 +++++++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h index 4572a9b560fa..20bfb8e676e0 100644 --- a/arch/arm64/include/asm/kvm_hyp.h +++ b/arch/arm64/include/asm/kvm_hyp.h @@ -29,7 +29,9 @@ ({ \ u64 reg; \ asm volatile(ALTERNATIVE("mrs %0, " __stringify(r##nvh),\ - "mrs_s %0, " __stringify(r##vh),\ + DEFINE_MRS_S \ + "mrs_s %0, " __stringify(r##vh) "\n"\ + UNDEFINE_MRS_S, \ ARM64_HAS_VIRT_HOST_EXTN) \ : "=r" (reg)); \ reg; \ @@ -39,7 +41,9 @@ do { \ u64 __val = (u64)(v); \ asm volatile(ALTERNATIVE("msr " __stringify(r##nvh) ", %x0",\ - "msr_s " __stringify(r##vh) ", %x0",\ + DEFINE_MSR_S \ + "msr_s " __stringify(r##vh) ", %x0\n"\ + UNDEFINE_MSR_S, \ ARM64_HAS_VIRT_HOST_EXTN) \ : : "rZ" (__val)); \ } while (0) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index f707fed5886f..a69b0ca9a3b4 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -463,20 +463,39 @@ #include -asm( -" .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n" -" .equ .L__reg_num_x\\num, \\num\n" -" .endr\n" +#define __DEFINE_MRS_MSR_S_REGNUM \ +" .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n" \ +" .equ .L__reg_num_x\\num, \\num\n" \ +" .endr\n" \ " .equ .L__reg_num_xzr, 31\n" -"\n" -" .macro mrs_s, rt, sreg\n" - __emit_inst(0xd5200000|(\\sreg)|(.L__reg_num_\\rt)) + +#define DEFINE_MRS_S \ + __DEFINE_MRS_MSR_S_REGNUM \ +" .macro mrs_s, rt, sreg\n" \ + __emit_inst(0xd5200000|(\\sreg)|(.L__reg_num_\\rt)) \ " .endm\n" -"\n" -" .macro msr_s, sreg, rt\n" - __emit_inst(0xd5000000|(\\sreg)|(.L__reg_num_\\rt)) + +#define DEFINE_MSR_S \ + __DEFINE_MRS_MSR_S_REGNUM \ +" .macro msr_s, sreg, rt\n" \ + __emit_inst(0xd5000000|(\\sreg)|(.L__reg_num_\\rt)) \ " .endm\n" -); + +#define UNDEFINE_MRS_S \ +" .purgem mrs_s\n" + +#define UNDEFINE_MSR_S \ +" .purgem msr_s\n" + +#define __mrs_s(r, v) \ + DEFINE_MRS_S \ +" mrs_s %0, " __stringify(r) "\n" \ + UNDEFINE_MRS_S : "=r" (v) + +#define __msr_s(r, v) \ + DEFINE_MSR_S \ +" msr_s " __stringify(r) ", %x0\n" \ + UNDEFINE_MSR_S : : "rZ" (v) /* * Unlike read_cpuid, calls to read_sysreg are never expected to be @@ -502,15 +521,15 @@ asm( * For registers without architectural names, or simply unsupported by * GAS. */ -#define read_sysreg_s(r) ({ \ - u64 __val; \ - asm volatile("mrs_s %0, " __stringify(r) : "=r" (__val)); \ - __val; \ +#define read_sysreg_s(r) ({ \ + u64 __val; \ + asm volatile(__mrs_s(r, __val)); \ + __val; \ }) -#define write_sysreg_s(v, r) do { \ - u64 __val = (u64)(v); \ - asm volatile("msr_s " __stringify(r) ", %x0" : : "rZ" (__val)); \ +#define write_sysreg_s(v, r) do { \ + u64 __val = (u64)(v); \ + asm volatile(__msr_s(r, __val)); \ } while (0) static inline void config_sctlr_el1(u32 clear, u32 set) -- 2.11.0 From 1583071245489036889@xxx Fri Nov 03 18:39:47 +0000 2017 X-GM-THRID: 1583065954961523588 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread