Received: by 10.192.165.148 with SMTP id m20csp3644225imm; Mon, 23 Apr 2018 09:53:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx49QwLZpB0SeLl/NioBtR/dwhG46vcjH7yy7nWPg/5e3Yw7DUjfl26jzPdNl8EdsXC4hr4/e X-Received: by 2002:a17:902:a50f:: with SMTP id s15-v6mr22118767plq.175.1524502405730; Mon, 23 Apr 2018 09:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524502405; cv=none; d=google.com; s=arc-20160816; b=h5qAyEkx9qHWuWk/IZAp2rzb/8WTs1X/qd6noHpIDfs6kJ0ifrKdBCiZ/SMr+vEujw It1nZA7ZjLtj8UI0uJtNUwYzz+t07MV2lNE0rMP2qtfvc4JxVlmdix9++ebZxGDu5V2D 5VBzpQ3My0qFZuF5JvfIYhzbJPPdva9ouZOQDAaM0l+hIDGxwrL3imhaHLDOnEjMiTsH BmQ563+C0zoJWBOxsUWg9exiD0k3WfYOu8ulY9KNOog3OlemyqqW6JdtugdIylgHlCXB JxmzytuIWyOeZ/CHoxkeou8UtJus6oaeVA8TDkpSwi1fZMetd2Sx9tcAqqYsgcqiqpkW A3IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature :arc-authentication-results; bh=5WPTWvK9B6hlLbLFuYD3EQpRcSoNbVUTuVY36rOmRIY=; b=utZloKkNi5A5ZFqaevoPfyW0peRJHB9BKG2URQONgFCvJJM1S14k5y2YlPIw9gTWPE uHKRQ1X90I/lpS8sSEbOAWdBj7XMUYDn1XCUpmho24tjx4qDfhbM78Cauf2FPDARo1EF geWs8m1FMjF1tRoSaIuAFHHQj4BT0FTTlUrDkNMPGQzS3A5XLhtsax0Vrajsy7sPwWgh iYKBeXV0oaIZhbhfjMJ0i03TZJyIQcJ71tLdnNRe8XWHiIlylAHBdExFTYGUZTDqQjDm rBbwrCIy7UKc4tPKS4LdWS2pKRdGqb9O3Sc7wekqMgEFZjbUKKFuBWd+RtIjL0od8R/W Jobw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=FMtwcOdG; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=daUya24g; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 85si11750877pfh.176.2018.04.23.09.53.10; Mon, 23 Apr 2018 09:53:25 -0700 (PDT) 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=@fb.com header.s=facebook header.b=FMtwcOdG; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=daUya24g; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755648AbeDWQv4 (ORCPT + 99 others); Mon, 23 Apr 2018 12:51:56 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:55094 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755486AbeDWQvy (ORCPT ); Mon, 23 Apr 2018 12:51:54 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3NGm99u011181; Mon, 23 Apr 2018 09:51:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=facebook; bh=5WPTWvK9B6hlLbLFuYD3EQpRcSoNbVUTuVY36rOmRIY=; b=FMtwcOdG1E1enzMBH210Ti8YqGVKOvJWftAHieH6v9oKvSIqYT/UGU8juGTY1QxvHyzi 2Vz7EH/c9YGvIukCKtGm8hqC0cYBjqtYgGrB7jp89wIvNENOA7dmAwQl88Hz7IwvVCLl xzJoHkZYKqQj5c8EfQhqwQMT8JgX5XYGQ0o= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2hhjmwr5td-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 23 Apr 2018 09:51:13 -0700 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.17) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 23 Apr 2018 09:51:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5WPTWvK9B6hlLbLFuYD3EQpRcSoNbVUTuVY36rOmRIY=; b=daUya24gGXI2zU9vESqtfH7LxjK3PuZI+jGxj0ffSYVJYIEa6XsZCamigQVNGVVlOK65BmhP6ikjXNljhactN5+sGE8J1gyMHWMU2/jT9LjC6A+t2314LwDshguaV0zfPW+/c/nxR4t9o6DDP+5r0SFTowpGM/T9fnl2I+dUt2M= Received: from macbook-pro-52.dhcp.thefacebook.com (2620:10d:c090:200::7:d824) by CY1PR15MB0078.namprd15.prod.outlook.com (2a01:111:e400:5849::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Mon, 23 Apr 2018 16:51:08 +0000 Subject: Re: [PATCH v2] x86/cpufeature: guard asm_volatile_goto usage with NO_BPF_WORKAROUND To: Peter Zijlstra CC: , , , , , References: <20180415042738.1788215-1-yhs@fb.com> <20180420081936.GD4064@hirez.programming.kicks-ass.net> <20180423105209.GX4064@hirez.programming.kicks-ass.net> From: Yonghong Song Message-ID: <3a6e6348-fb23-c2f9-5bd8-928b056b4722@fb.com> Date: Mon, 23 Apr 2018 09:50:59 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180423105209.GX4064@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [2620:10d:c090:200::7:d824] X-ClientProxiedBy: DM5PR21CA0031.namprd21.prod.outlook.com (2603:10b6:3:ed::17) To CY1PR15MB0078.namprd15.prod.outlook.com (2a01:111:e400:5849::28) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(2017052603328)(7153060)(7193020);SRVR:CY1PR15MB0078; X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0078;3:LrC/YjODTGytalcgCl6bplHT7or8j/SUXz7j9tdFLM0lyX1LJiKuTketw8owhlIReyvvB04MTbXEutcskPzTVo6+0cbvutSfMpvcGXDnyNpVVak2kjwhG/XIElr3yTQQxl3b98kuOKJJgW1BsSAYI3WOLPkH6jkDpRAplJ4zEzDSYtLiPmS7amBPERIBDD/G5iw8LdP06egX+34UQwlb3bHrG0zo1wwZ8p0K0rTKOfV464PrN+QwSleNGQRnZH+r;25:Bx8zAQlC1xUDEmrYqAYXczcVtsg2CyXTBT31qgUUYv2lwXIjS3tg1wI+LEsS44S+DtgEiLl2YC0kOtBVD8+8dPInrDosh+jJd9Nr+hVcSCqqarbHqPg9nZuD1P/5qlJEB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Q55g1FPmSDk3ssTIh5LZiqDJHwsSY4Hpn4jMrqwAVHebfFGCDv/3Rmokly4WCA9KQ2RKnF76sNhJvNVWj4fXnv7JDQgWSe6v7e89qzzi28nSXC88cGSp6BsbE1jtU/G9ts38o9LvfoqoGENdirKuSJWi/9T+F55NXE2hj7K4syFwMs46dWDhqNqN4XoeUQhyh3RKpaihn60JXd0RQpFMBuczHFZyPodEiPJpQFWzZ5yJw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231232)(11241501184)(944501410)(52105095)(3002001)(93006095)(93001095)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:CY1PR15MB0078;BCL:0;PCL:0;RULEID:;SRVR:CY1PR15MB0078; X-Forefront-PRVS: 06515DA04B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(366004)(376002)(346002)(39860400002)(39380400002)(8936002)(6916009)(93886005)(6512007)(65826007)(6246003)(478600001)(230700001)(6506007)(386003)(2486003)(53546011)(23676004)(52146003)(31686004)(316002)(52396003)(81166006)(86362001)(305945005)(8676002)(4326008)(7736002)(6666003)(53936002)(47776003)(67846002)(50466002)(6486002)(46003)(31696002)(16526019)(229853002)(36756003)(2616005)(446003)(11346002)(476003)(2906002)(5660300001)(6116002)(52116002)(76176011)(25786009)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR15MB0078;H:macbook-pro-52.dhcp.thefacebook.com;FPR:;SPF:None;LANG:en;MLV:sfv; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjE1TUIwMDc4OzIzOldYa0Jyc3pxbWJmSUZoQnFndGdta3l5UmJh?= =?utf-8?B?R0tEVmMyT2hUMm81Nkcwakl2ZHVrdG1rbG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k1k8YXt8zg8l5loQpTCmihmavz+IUcM0+tvFuFYJlSe+SzIBC8LbtLOk9bf0zG5Hi7/p/vWjYlWZ6Z+gwMrsn4mFIfG7i53V/j/jZphG1/GTJs= X-MS-Office365-Filtering-Correlation-Id: 38e0562a-6fc6-4654-fdc4-08d5a93a69ce X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2018 16:51:08.2569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38e0562a-6fc6-4654-fdc4-08d5a93a69ce X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR15MB0078 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-23_06:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Peter, Please see comments below. On 4/23/18 3:52 AM, Peter Zijlstra wrote: > On Fri, Apr 20, 2018 at 11:06:03AM -0700, Yonghong Song wrote: >> On 4/20/18 1:19 AM, Peter Zijlstra wrote: > >>> Hurm, so adding __BPF__ for BPF compiles isn't an option? It seems to me >>> having a CPP flag to identify BPF compile context might be useful in >>> general. >> >> With "clang -target bpf", we already have __BPF__ defined. >> For tracing, esp. ptrace.h is included, "clang -target " where >> "-target " can be omitted, is typically used. > >> The reason is the native architecture header files typically >> include a lot of various asm related stuff where "-target bpf" cannot >> really handle. We relay on native clang to flush out all these >> asm constructs and only bpf program needed stuff survives >> reach to backend compiler. > > So because 'clang -target bpf' is 'broken', you do a work-around using 'clang -target bpf' is 'broken' in this case because the x86 arch has a lot of inline asm's in the header file where bpf target cannot handle. For most networking related bpf programs where `asm` is rarely involved, `clang -target bpf` works fine most of time. > 'clang -target '. But because that doesn't set __BPF__ you `clang -target ` should work, regardless of whether __BPF__ macro is setup or not. The reason it doesn't work now is due to its lacking asm-goto support. So to use `clang -target ` is not really a workaround for `target bpf`. It by itself should work. > want to add NO_BPF_WORKAROUND to the kernel instead of adding __BPF__ to > your build rules to better mimick -target bpf, which you should be > using. > > How is that sane? Why not use 'clang -target -D__BPF__' To workaround the asm-goto issue, the suggested macro __BPF__ can be added to user space and kernel. But note that `clang -target ` will not define the macro __BPF__, so this requires user space change. Also, to make sure people understand that this is a WORKAROUND for asm-goto issue and is not a lasting thing we want to support. I have the following change for cpufeature.h: diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index b27da9602a6d..c832118defa1 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -140,6 +140,7 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit); #define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit) +#ifndef __BPF_WORKAROUND__ /* * Static testing of CPU features. Used the same as boot_cpu_has(). * These will statically patch the target code for additional @@ -195,6 +196,9 @@ static __always_inline __pure bool _static_cpu_has(u16 bit) boot_cpu_has(bit) : \ _static_cpu_has(bit) \ ) +#else +#define static_cpu_has(bit) boot_cpu_has(bit) +#endif #define cpu_has_bug(c, bit) cpu_has(c, (bit)) #define set_cpu_bug(c, bit) set_cpu_cap(c, (bit)) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 4d6a6edd4bf6..b229e5090e4a 100644 As mentioned above, user space needs to add this new macro definition. Specifically for kernel/samples/bpf: diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 4d6a6edd4bf6..b229e5090e4a 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -255,7 +255,7 @@ $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h $(obj)/%.o: $(src)/%.c $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \ -I$(srctree)/tools/testing/selftests/bpf/ \ - -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \ + -D__KERNEL__ -D__BPF_WORKAROUND__ -Wno-unused-value -Wno-pointer-sign \ -D__TARGET_ARCH_$(ARCH) -Wno-compare-distinct-pointer-types \ -Wno-gnu-variable-sized-type-not-at-end \ -Wno-address-of-packed-member -Wno-tautological-compare \ Please let me know whether this approach is okay to you or not, whether the name __BPF_WORKAROUND__ is better than __BPF__ or not, or we could use the earlier approach which does not require user space change. Thanks!