Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp333956pxk; Thu, 24 Sep 2020 06:50:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2DeTrNWYZPDXbGNyPk+VJK4zVBfWu3wl3ypJ/CZMCSgxB/+SlIGccYiT4a0RNr2DqX1Kx X-Received: by 2002:a17:906:1186:: with SMTP id n6mr1085993eja.331.1600955424793; Thu, 24 Sep 2020 06:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600955424; cv=none; d=google.com; s=arc-20160816; b=XZp3r1I/pUy/gXo2nMCGsliITJud/TcVo6H97hEVCMfrGTJj44GhrvppgWbAvbbfC9 tTvtU0s0Ounz7r2gFdD7Nx7fgYPS69aH9+Rz9aEmwDU53szZ3GIDvd0sR1/RYMk+GzYK TUsx1LrNbQD0OqmF5JWt0mIBPXiAkgFcDnfX9HAClujXHW7x9p4VUmxobc3hrcjOuM+t EVAjJchrWPLmckQ5gauFbNR+JyYjpSod0zOedOQnQFQwcJPhdG2HnLcXUMGyIwb5wf94 k7o30UtYPtKM6EX/ffWTVdHD3i4di9VZMUhFMm5o/Sf6V69lXpu93V9kLF6iaFZgGBEP MBQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=gtTRlWPdYZcnssWKg3oiOcBLqD9nzOVFgOvLy/nvr40=; b=LUhgJUoWr4fIMt3E9evpOrJF1aQdz6UoNio3T2w9RkkQzZHWaNskhJLfPL3TrJKBlq Z6XS7CQhU2BkXUtBlPKR0bwH3tDJKrCZSw/o8WHnkjcZwiDuZftYrtZ4fZMaC2/wIHH/ nNzI8UpPos43lAhdoT+Rb68bJ8wNI2a70KfEN0N0nwlefcbodWXJy67f8jv3HP/oj65M jQlybVj6dgGwKwpKpvjQlRu7Bwn50BAx6n3ZbOem8gp0lJSx547JQJqMD0pwxSfZl1QH 0AXCaV8L1GMQQ5OUtgCw1H3Ep40+emuc4kuZHeajQ+RXViqDF1db6++FxJu424Uh0FpF znsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si2161652edq.113.2020.09.24.06.50.01; Thu, 24 Sep 2020 06:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728065AbgIXNr7 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 24 Sep 2020 09:47:59 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:31480 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727970AbgIXNr7 (ORCPT ); Thu, 24 Sep 2020 09:47:59 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-275-AmPfbs06OlSmLB8NwMzbeQ-1; Thu, 24 Sep 2020 14:47:55 +0100 X-MC-Unique: AmPfbs06OlSmLB8NwMzbeQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 24 Sep 2020 14:47:54 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 24 Sep 2020 14:47:54 +0100 From: David Laight To: 'YiFei Zhu' , "containers@lists.linux-foundation.org" CC: YiFei Zhu , "bpf@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Aleksa Sarai , "Andrea Arcangeli" , Andy Lutomirski , Dimitrios Skarlatos , Giuseppe Scrivano , Hubertus Franke , Jack Chen , Jann Horn , Josep Torrellas , Kees Cook , Tianyin Xu , Tobin Feldman-Fitzthum , Tycho Andersen , Valentin Rothberg , Will Drewry Subject: RE: [PATCH v2 seccomp 2/6] asm/syscall.h: Add syscall_arches[] array Thread-Topic: [PATCH v2 seccomp 2/6] asm/syscall.h: Add syscall_arches[] array Thread-Index: AQHWknD17ZW/yCPmvkCTJZb3HlQhMal3ymow Date: Thu, 24 Sep 2020 13:47:54 +0000 Message-ID: <7042ba3307b34ce3b95e5fede823514e@AcuMS.aculab.com> References: <20bbc8ed4b9f2c83d0f67f37955eb2d789268525.1600951211.git.yifeifz2@illinois.edu> In-Reply-To: <20bbc8ed4b9f2c83d0f67f37955eb2d789268525.1600951211.git.yifeifz2@illinois.edu> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: YiFei Zhu > Sent: 24 September 2020 13:44 > > Seccomp cache emulator needs to know all the architecture numbers > that syscall_get_arch() could return for the kernel build in order > to generate a cache for all of them. > > The array is declared in header as static __maybe_unused const > to maximize compiler optimiation opportunities such as loop > unrolling. I doubt the compiler will do what you want. Looking at it, in most cases there are one or two entries. I think only MIPS has three. So a static inline function that contains a list of conditionals will generate better code that any kind of array lookup. For x86-64 you end up with something like: #ifdef CONFIG_IA32_EMULATION if (sd->arch == AUDIT_ARCH_I386) return xxx; #endif return yyy; Probably saves you having multiple arrays that need to be kept carefully in step. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)