From nobody Thu Nov 28 18:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=suse.com); dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=2; a=rsa-sha256; t=1660631627; cv=pass; d=zohomail.com; s=zohoarc; b=eBKIxPRaBWVGseeJ4vPsdalE/saJCscSFOk6x0+OhbBxgpbWyW5SYQOdv2XfKJfvaVIX3Uni3nTqAjko6QiHEM5nx31D+GFMR8qiLog3RduhVdhxV+6zRpm5/inXIw9ZwKGqA0gOzF883fxcicaVD/mCvD2DII7Hrk4ogqtNN6Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660631627; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ccQ6u66wE4z1aGcyRkbwjalqIrT4SRm5yCI2P5XJOYI=; b=lRbB14ne5eeNMEH838bOe0dvkH2TodF0RwQb9tdKnOFtRxGYUhhYwXA1HWVFW9ytrr7QVINyPxSPI1ZZrRN6wSBI/T8NO19zx3lkt6kx57KeLmoJ2+GcqyHY6EWVwNSnyn/5UI15I12M1RkdShHXFSUOs/0sgh+kXto63GZitrA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=suse.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 166063162779342.00944684336571; Mon, 15 Aug 2022 23:33:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.387960.624448 (Exim 4.92) (envelope-from ) id 1oNq8R-0004ls-EK; Tue, 16 Aug 2022 06:33:07 +0000 Received: by outflank-mailman (output) from mailman id 387960.624448; Tue, 16 Aug 2022 06:33:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oNq8R-0004ll-A4; Tue, 16 Aug 2022 06:33:07 +0000 Received: by outflank-mailman (input) for mailman id 387960; Tue, 16 Aug 2022 06:33:06 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oNq8Q-0004lf-02 for xen-devel@lists.xenproject.org; Tue, 16 Aug 2022 06:33:06 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130043.outbound.protection.outlook.com [40.107.13.43]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 47fcff95-1d2d-11ed-bd2e-47488cf2e6aa; Tue, 16 Aug 2022 08:33:04 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PAXPR04MB8112.eurprd04.prod.outlook.com (2603:10a6:102:1cd::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Tue, 16 Aug 2022 06:33:02 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2d5d:bae0:430f:70ad]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2d5d:bae0:430f:70ad%4]) with mapi id 15.20.5525.010; Tue, 16 Aug 2022 06:33:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 47fcff95-1d2d-11ed-bd2e-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TJ9H2cb2Qx0y+kfHOPE6HOGs2gjiCscOzH1TLo2eEQISFMcazaA/xAajbQGD62mjiKyk8CWqp3DC1zA3uKGx1GQdotvLqdGXa2Kltq1Ds55XefbVKo5sATgHmZ1ZhWaM2ejrLNNULIj2pzIjGXDv4rpX5p9/aRf0Kk6eFEwjTCU5OOChgFoEXxxHVohrjIwSBjt2UPdX3nC5mHls1qDZG9TDFg6j7p5Qivap1CI4xcOqu1dQE6NLDX3NC7hQQoMy+cnRJCq0Iot3FxCqRo6LtFDrqlSFjKbuKnfHZHyq+qrNQmA3rLsqyr5xxrMkIWlQlTBVTZqyBTUdLugFRUdCkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ccQ6u66wE4z1aGcyRkbwjalqIrT4SRm5yCI2P5XJOYI=; b=R84eAtnvgSvo/UOPt/cs6LAc4U97H70tPa4qLucKBCJUxHc2MLBeFjKMU0wAoSeJsTLIMVoSQCE3NhCPU7dCTFph6ptcWy2oL/VAPWav+cw0Jlv65EJI7HcKoO/9Z3P5CPcgbTXyRYv/dPTYpAhtkH5a68/A4qgYW5txpKULsjJuUXdY4lLj3q5f+u7mKwooDTbIuu/o2mbb+Zv5CLlTxKpOCaoSN9dDoY1Dbp2hWk6x5DGGljA2Dto9BOuWkp88BNJxL3jQ8IFwDnMxR799vNd+vTmD3vciaumTEViWx5j/Jrw9dYRF7tW7Os2IOJTvxsf8erPxjgOALXwg4Vw54g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ccQ6u66wE4z1aGcyRkbwjalqIrT4SRm5yCI2P5XJOYI=; b=zLgQNhZeQjVEJtC1WhPYcTKsQQh0SqC5EvvnCaGkzqxvvFLdQqWLF2BDk5OW/v8ARRaxpsnSCuDgg3ZbKS9ctgFRdzx9ce17Bx6BL3nZ2kFDPYgof3FoJxfGVFWD7U6aOyk8sLsjlHa3pTH2lpcOELKD/kqiz3/U9d30gXl5Qbd9y7nKkfHw8PNJyTW0/sR/KneU1cesFt3L5Fv/cKLMxyBkwLbs4zY9Fe7Sgsj8wAgh4lsHNQNCAmW64M9jATKvJ6LFKUqv8iD5p2k2klrBxS3QlqeGyCGtETWEJmKp9LF+wa7UB7d4u+BYcHJirn5IRCEhQklCWZ06liDSV46VNw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <6f5f7adb-d34d-e753-0880-92eccccfb75a@suse.com> Date: Tue, 16 Aug 2022 08:32:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 From: Jan Beulich Subject: [PATCH v2] x86: rework hypercall argument count table instantiation & use To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Juergen Gross Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6PR01CA0040.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::17) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec758cd7-3d08-4adb-0ed1-08da7f512b08 X-MS-TrafficTypeDiagnostic: PAXPR04MB8112:EE_ X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k9uy28MeLK7SS+dB2XL81cnJDpUdVm7L21bXd1PXaHwZeKQ0SVGZH8PBGyIgNItzmZBipJBiXdQ1YGVBrm0qIzKYWO1cJqSu8TZfR7GYQ1oZmC8A19jNRCtG1cvsPEhCSsgS/NRRL+jwnGIC2yrrDMD2X/GpD93JjAmW6xBpPxJRK2TxhMN3fcVpvBVphCjXI9EY5ReUNcKs+Ijwhm9fRGNJtZFl2KBgU42DJeAzwobUF8gh5aaAIig0Z2YQQRKh6Dc0DuAx7Tq+JjLxt3o63q2X8udlBvxU1xKtZBWc4xFQP4I1yPZM6vLQEWFdG9znG7fzBaCKG3izZrgpXSHp4x0wh/0j5UHsGmOATTRafku200yuBt6R2TXFf7195TCeNOxUjoR+lgtsSaOBwfd+oOvgQS2SM1g2OGZ+yA8tQe2E401i3unbQXx1b3rIkX7pjn3qmS1/bSjcOQ3CRiKRk257ITC8tCgOtdDtuIGMKW8/FTLj4NIi0Likolxu65PCa3HcK+y122jdZWX3QcLlFTdZ0HzQuNtG7YPZGkGWeVOt0R6iYq/wcp2V1Xef6valMgrlauzPAuprrDlBgqM7E++rEPrUv6k01DGV4i0Q3C6zCKSPEWy35cRcwsCIPBa/b1quT4L8SFPmol0CDWCeTKEgGIAzzTpN5thkK431WMFtaBCKm9bQ38v9IkM44kcIhbJhIM3CqJU8mc4RNyfToXNgSgX2VEVSebEy9527+FhgsbJsFIfWJOJ3PyiAFBfvm49wrMfuOnL3yKhtgUUq8qfriPB93psZ5+BXC58t5HStASKHkunWFoec+oNg9XYCrrZg0gzKkt4CTIwD6q57XQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(396003)(136003)(346002)(39860400002)(376002)(366004)(186003)(38100700002)(36756003)(26005)(31686004)(86362001)(107886003)(6506007)(31696002)(2616005)(6512007)(6916009)(83380400001)(41300700001)(478600001)(6486002)(54906003)(5660300002)(66946007)(316002)(2906002)(66556008)(66476007)(8676002)(8936002)(4326008)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RFJqZmQzZWN1UWcyYXJvK0VJSHYyc0FmbzFpd3NReEJHMGJOdlJ1bldsWnBw?= =?utf-8?B?ellpT25tMEU0a2FaZnN3Q2JFaTVlQ2czVUplK3ZNV1ovajZkdkh5OUZST1c2?= =?utf-8?B?RXZCZUFYQnBwTW05MmNqa2VEMkE0aW96ekU3K0ZHTU1GQXdJWHBQU2FtVExu?= =?utf-8?B?eXg1amtYWWtkdFlPbkZaQXVsb1ZrZ0tKRmZkMkQ3REFLeDFZR1J0OGpYS0ZL?= =?utf-8?B?NmM1UDVVUkxZQTRtNmN4MGt2NmdOUEp3azZTS0YyWmx6RThWNzVuTHR4UldP?= =?utf-8?B?UXJFdEdOb0JkV29VMGNyaDQyQlRlazBEL1JQdXM2YUlBM0doSU15UFZYaE16?= =?utf-8?B?YWljUU9jYklpM05RMHVPR3lWOXo5dzVTWGdyZDk2RWhINHFmTUZPS2dvbkIr?= =?utf-8?B?dXF4ZWlCaWludVF0WEU2NFJ1ZUVYVkxFRkJtUUFneUlNL2lYQlFBQ3dibi9l?= =?utf-8?B?NXQ0UUpNcmdmdXVvMUNjT0JNR2x3eno3ZzdTRDV1aDhZTkdKWGhNeXpDd2d6?= =?utf-8?B?VTJTen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ir?= =?utf-8?B?WnJoSVNYbHUvRFpuSFlzOFkvbUovbGtzQm9WTGVmQlFZQzZiR2R4UHMwa25Z?= =?utf-8?B?TncwSkJSRFV3QXI0R25vWHNSZ1NaMmVxcE1WY3JUcFdDbkFCV2VwcE1qbnpu?= =?utf-8?B?VWpVQlVHV09scnJQSFVNUURYc1JFeVkweEFBaXAzd0RrZGtObWhQdnRSRFUr?= =?utf-8?B?U2Y4QzFiK3l5bFVOcWIvb29sUUNSRTg0c3dKRm9BdTVxSFNFRTdxY25wL1Bk?= =?utf-8?B?M0Y2SS9kWnhJd3Y2bm11cmdyaStoV3RUYVV0emhJdHBIYVcwWWJKRDcwczZ6?= =?utf-8?B?VmtycTdDeGcvZ2NRZktWekVtZ012UU52bloyc3pHeWlpOGlsb01Hdjk3cWRH?= =?utf-8?B?QnFOSVVHQmFoKzRIcnRBV3J2ZStVU25KY3ljNGdISW9vcEd1RXZLdTNPWkND?= =?utf-8?B?ZVdEVHpvVXJhOU5TTnhDUnJ5ZmoxMDAxSzBtUU9uTVc5aTBaQWpYbmVzRWxD?= =?utf-8?B?bVNHVEZPWUZ4dXg4dGVXN0EvWVNWQjJJTGZXWCtoL2JkeFdBWHZnQk5ucUlG?= =?utf-8?B?dXFkRmd4Wi9ueWtWd0Q3M010QXdjL3BhWE5FdW5yOXNUTUxISEx4VWVSUUd6?= =?utf-8?B?Ym9YbUtzUEhvekFYQklsNmpOb0lBZ1JqSGtKWXBXT1VaR1FmSkZoQWd5bHo1?= =?utf-8?Q?DLLgy8O7rm2ikxkzn/su+12Pv?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec758cd7-3d08-4adb-0ed1-08da7f512b08 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 06:33:01.8779 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: O3wPj+UlqqHVY59iXcdap79cNB8nBmB67VAXo+cYsufQol1snYwW9YPWOj9FXM+YzHLW3Wt6YUf9GXCBm3zp5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8112 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1660631630392100001 Content-Type: text/plain; charset="utf-8" The initial observation were duplicate symbols that our checking warns about. Instead of merely renaming one or both pair(s) of symbols, reduce #ifdef-ary at the same time by moving the instantiation of the arrays into a macro. While doing the conversion also stop open-coding array_access_nospec(). Signed-off-by: Jan Beulich Reviewed-by: Juergen Gross --- v2: Use single-macro approach. --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -111,11 +111,6 @@ long hvm_physdev_op(int cmd, XEN_GUEST_H return compat_physdev_op(cmd, arg); } =20 -#ifndef NDEBUG -static const unsigned char hypercall_args_64[] =3D hypercall_args_hvm64; -static const unsigned char hypercall_args_32[] =3D hypercall_args_hvm32; -#endif - int hvm_hypercall(struct cpu_user_regs *regs) { struct vcpu *curr =3D current; @@ -177,7 +172,7 @@ int hvm_hypercall(struct cpu_user_regs * regs->r10, regs->r8); =20 if ( !curr->hcall_preempted && regs->rax !=3D -ENOSYS ) - clobber_regs(regs, get_nargs(hypercall_args_64, eax)); + clobber_regs(regs, eax, hvm, 64); } else { @@ -190,7 +185,7 @@ int hvm_hypercall(struct cpu_user_regs * curr->hcall_compat =3D false; =20 if ( !curr->hcall_preempted && regs->eax !=3D -ENOSYS ) - clobber_regs32(regs, get_nargs(hypercall_args_32, eax)); + clobber_regs(regs, eax, hvm, 32); } =20 hvmemul_cache_restore(curr, token); --- a/xen/arch/x86/include/asm/hypercall.h +++ b/xen/arch/x86/include/asm/hypercall.h @@ -43,18 +43,8 @@ compat_common_vcpu_op( =20 #endif /* CONFIG_COMPAT */ =20 -#ifndef NDEBUG -static inline unsigned int _get_nargs(const unsigned char *tbl, unsigned i= nt c) -{ - return tbl[c]; -} -#define get_nargs(t, c) _get_nargs(t, array_index_nospec(c, ARRAY_SIZE(t))) -#else -#define get_nargs(tbl, c) 0 -#endif - -static inline void clobber_regs(struct cpu_user_regs *regs, - unsigned int nargs) +static inline void clobber_regs64(struct cpu_user_regs *regs, + unsigned int nargs) { #ifndef NDEBUG /* Deliberately corrupt used parameter regs. */ @@ -85,4 +75,9 @@ static inline void clobber_regs32(struct #endif } =20 +#define clobber_regs(r, n, t, b) ({ \ + static const unsigned char t ## b[] =3D hypercall_args_ ## t ## b; \ + clobber_regs ## b(r, array_access_nospec(t ## b, n)); \ +}) + #endif /* __ASM_X86_HYPERCALL_H__ */ --- a/xen/arch/x86/pv/hypercall.c +++ b/xen/arch/x86/pv/hypercall.c @@ -27,13 +27,6 @@ #include #include =20 -#ifndef NDEBUG -static const unsigned char hypercall_args_64[] =3D hypercall_args_pv64; -#ifdef CONFIG_PV32 -static const unsigned char hypercall_args_32[] =3D hypercall_args_pv32; -#endif -#endif - /* Forced inline to cause 'compat' to be evaluated at compile time. */ static void always_inline _pv_hypercall(struct cpu_user_regs *regs, bool compat) @@ -65,7 +58,7 @@ _pv_hypercall(struct cpu_user_regs *regs call_handlers_pv64(eax, regs->rax, rdi, rsi, rdx, r10, r8); =20 if ( !curr->hcall_preempted && regs->rax !=3D -ENOSYS ) - clobber_regs(regs, get_nargs(hypercall_args_64, eax)); + clobber_regs(regs, eax, pv, 64); } #ifdef CONFIG_PV32 else @@ -90,7 +83,7 @@ _pv_hypercall(struct cpu_user_regs *regs curr->hcall_compat =3D false; =20 if ( !curr->hcall_preempted && regs->eax !=3D -ENOSYS ) - clobber_regs32(regs, get_nargs(hypercall_args_32, eax)); + clobber_regs(regs, eax, pv, 32); } #endif /* CONFIG_PV32 */