From nobody Thu May 16 04:14:18 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1705484252; cv=none; d=zohomail.com; s=zohoarc; b=OKRi82e9Ttbx3O4GsGCPbzdUG5xEBta8oSKVVfzojgGZx5wVukm+OK9WCOkCBSzrS96Abt3/5h22iJE+1j5b+0WntyNKEKi7hyb0GSOhzIYLu2O6I9yeyABZiW97jSc7ZKV+1Ku0UVrYoM8n8ThAyQBqVY7ZG/sHhQxvs58MI20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705484252; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fFqWW5VsBqyLXFmEo7/4sxcjiyzuJkj0f+lb546UJ40=; b=XXOImLfCszHO7s5cVOphcNojiBQ1F4GSuHPnMXtm8zbnGmZgBSYr0miVIEx+QO1oMT7xnOLnw7hjr4mKYYDbwiU1A9D5qM5L08dNceHBhq4IFuZFPMkI+irm5WZcU2xTB/gZQv5ay1Kd456vlwqJsb0RhdoXT5hpI5rdypqrf14= ARC-Authentication-Results: i=1; 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; 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 1705484252726534.0123149797322; Wed, 17 Jan 2024 01:37:32 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.668322.1040413 (Exim 4.92) (envelope-from ) id 1rQ2M6-0004yR-94; Wed, 17 Jan 2024 09:37:06 +0000 Received: by outflank-mailman (output) from mailman id 668322.1040413; Wed, 17 Jan 2024 09:37:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rQ2M6-0004yK-6T; Wed, 17 Jan 2024 09:37:06 +0000 Received: by outflank-mailman (input) for mailman id 668322; Wed, 17 Jan 2024 09:37:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rQ2M4-0004wC-I1 for xen-devel@lists.xenproject.org; Wed, 17 Jan 2024 09:37:04 +0000 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [2a00:1450:4864:20::32d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f825b2f6-b51b-11ee-9b0f-b553b5be7939; Wed, 17 Jan 2024 10:37:02 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40e72a567eeso32556055e9.0 for ; Wed, 17 Jan 2024 01:37:02 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id b16-20020adfe650000000b00337a81a0a89sm1207581wrn.114.2024.01.17.01.37.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jan 2024 01:37:02 -0800 (PST) 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: f825b2f6-b51b-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1705484222; x=1706089022; darn=lists.xenproject.org; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=fFqWW5VsBqyLXFmEo7/4sxcjiyzuJkj0f+lb546UJ40=; b=cmAULrSxsu7/InZOz6U4EORF+C1dWk0LC207WcRKGXTZ8sOX6IbCGMbA5yXOLO3FPk xW9qbUq/Qlg75D1afSTI4hcRX8XztXyqCYh9TxSdJLXj3FrAE44kxB0avw1j53jJd+m6 7j8sbbnqEXVqNdeIjcrxBsQWaKJt9dZzNmi21kTS/1B84MRBM87p8F97v4JDRjNMJ2yX 2LKhE5JYzSNgDDneGqQU6QX8HDtwUnxzJo5gBsU9nPF2wmF4d3w1Wnui8uvEVAN24Xgs b8/mKQetsHJCaZauDzX7I+J2IneDntfRd1dQiVP4QgvRd16QQE5iB0NDR7TrfgVYNvQH H/WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705484222; x=1706089022; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fFqWW5VsBqyLXFmEo7/4sxcjiyzuJkj0f+lb546UJ40=; b=wq2nJs8Y7mCCyFbOxuNjAwsrRZn1ahxzAGpm0lsNxBFM4lmH3Jcn9SdaJlr6G3dtl7 SFdKnJDXTYTN+4oaT3qWWY8EVnRtnQ/XYEfKGrliu5J97fqlNep6cZGOLbiVD1XO4J9a 2s3pEMlmk6/J8+mxJXZmYaTopOV/GBIEEP6KnZUIXLSCfSiinG+eaY+/WHhAtXqjN7Fv 02OK/p10lhEJnefS3RhYRsS7PSKNtp8jPrIoJwEzlxGKdcuze7jS2riFyBHj3ucunDlb f/BJQviMT4OvpsUMpS8+SkwPSLktWe0B+slUVaVD/uYlCEuLY/4OoCZ7aW0uFGuhy58E VFGw== X-Gm-Message-State: AOJu0YzFw6T9COTMzjZYVkkog8xQ5X9qTHjUx9wbyk8UGf5jxNmn5+b/ denYe09fcv0gK+MoWgY+LxqqX2KB38uqoZybklVMyiYtzg== X-Google-Smtp-Source: AGHT+IHgyd8afn6XbClzUUL+fC+1zLdh2cUL+Iq7vApGCsszqBVEKKypKkSyFySw7QbV1uXIg58CFA== X-Received: by 2002:a05:600c:1f86:b0:40b:5f03:b3b1 with SMTP id je6-20020a05600c1f8600b0040b5f03b3b1mr2784312wmb.211.1705484222341; Wed, 17 Jan 2024 01:37:02 -0800 (PST) Message-ID: <28b46611-ff98-45cd-a2b0-ffe36b8f0ccf@suse.com> Date: Wed, 17 Jan 2024 10:37:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= From: Jan Beulich Subject: [PATCH v2] x86/PV: avoid indirect call for I/O emulation quirk hook Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv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KdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1705484254683100001 Content-Type: text/plain; charset="utf-8" This way ioemul_handle_proliant_quirk() won't need ENDBR anymore. While touching this code, also - arrange for it to not be built at all when !PV, - add "const" to the last function parameter and bring the definition in sync with the declaration (for Misra). Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- Obviously the file may want moving to pv/ then. I wasn't sure whether to also fold doing so right into here. Of course things could also be done the other way around: Have ioemul_handle_quirk as function name and ioemul_handle_proliant_quirk be the boolean. --- v2: Don't use alternative_call(); drop indirect call altogether. --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -45,7 +45,7 @@ obj-$(CONFIG_LIVEPATCH) +=3D alternative.o obj-y +=3D msi.o obj-y +=3D msr.o obj-$(CONFIG_INDIRECT_THUNK) +=3D indirect-thunk.o -obj-y +=3D ioport_emulate.o +obj-$(CONFIG_PV) +=3D ioport_emulate.o obj-y +=3D irq.o obj-$(CONFIG_KEXEC) +=3D machine_kexec.o obj-y +=3D mm.o x86_64/mm.o --- a/xen/arch/x86/include/asm/io.h +++ b/xen/arch/x86/include/asm/io.h @@ -47,10 +47,14 @@ __OUT(b,"b",char) __OUT(w,"w",short) __OUT(l,,int) =20 -/* Function pointer used to handle platform specific I/O port emulation. */ +/* + * Boolean indicator and function used to handle platform specific I/O port + * emulation. + */ #define IOEMUL_QUIRK_STUB_BYTES 9 +extern bool ioemul_handle_quirk; struct cpu_user_regs; -extern unsigned int (*ioemul_handle_quirk)( - uint8_t opcode, char *io_emul_stub, struct cpu_user_regs *regs); +unsigned int ioemul_handle_proliant_quirk( + uint8_t opcode, char *io_emul_stub, const struct cpu_user_regs *regs); =20 #endif --- a/xen/arch/x86/ioport_emulate.c +++ b/xen/arch/x86/ioport_emulate.c @@ -8,11 +8,10 @@ #include #include =20 -unsigned int (*__read_mostly ioemul_handle_quirk)( - uint8_t opcode, char *io_emul_stub, struct cpu_user_regs *regs); +bool __ro_after_init ioemul_handle_quirk; =20 -static unsigned int cf_check ioemul_handle_proliant_quirk( - u8 opcode, char *io_emul_stub, struct cpu_user_regs *regs) +unsigned int ioemul_handle_proliant_quirk( + uint8_t opcode, char *io_emul_stub, const struct cpu_user_regs *regs) { static const char stub[] =3D { 0x9c, /* pushf */ @@ -95,7 +94,7 @@ static const struct dmi_system_id __init static int __init cf_check ioport_quirks_init(void) { if ( dmi_check_system(ioport_quirks_tbl) ) - ioemul_handle_quirk =3D ioemul_handle_proliant_quirk; + ioemul_handle_quirk =3D true; =20 return 0; } --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -112,7 +112,7 @@ static io_emul_stub_t *io_emul_stub_setu /* Some platforms might need to quirk the stub for specific inputs. */ if ( unlikely(ioemul_handle_quirk) ) { - quirk_bytes =3D ioemul_handle_quirk(opcode, p, ctxt->ctxt.regs); + quirk_bytes =3D ioemul_handle_proliant_quirk(opcode, p, ctxt->ctxt= .regs); p +=3D quirk_bytes; }