From nobody Thu May 9 12:44:46 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=1705394489; cv=none; d=zohomail.com; s=zohoarc; b=JBC7ltSR2F3I8h+N89p0SVlGX6c+kVqlp5l1EsQTJKJKT4q6gR036HAHQmvP5T3zaJKNVMbYeDBxN7hJAz4J4nZova2oE3Q1Ba8ZSRtxTH7WPNlccblioFwBzWvT7E25tCuK95v0DUqTeK25wvL3HRrEO9ZEtwVIFPN9ALTdXQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705394489; 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=IUIR6jhBeaCWm4WLuVInZHdrkJh9OVonMA+8LwOnY14=; b=c7LBsLqFRIomCS9YSTpU4SLcUbCDWMbSI1Pnn8DKjzWcBJKlR5wOFCJ2GTxqoEnWjAKQ5tlhG3LIYvXp3+2w9ltNMap7lcutC5LdPK/yTaLLrvPUStNGJIebnjdGqKow8FZBKvJnZ+WkzUNUFNX3WubPF9AZqDSub6rIlG3THmQ= 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 1705394489171978.3093736373967; Tue, 16 Jan 2024 00:41:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.667663.1039142 (Exim 4.92) (envelope-from ) id 1rPf0Q-0000TV-Cc; Tue, 16 Jan 2024 08:41:10 +0000 Received: by outflank-mailman (output) from mailman id 667663.1039142; Tue, 16 Jan 2024 08:41:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rPf0Q-0000TO-9a; Tue, 16 Jan 2024 08:41:10 +0000 Received: by outflank-mailman (input) for mailman id 667663; Tue, 16 Jan 2024 08:41:09 +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 1rPf0P-0000TI-Hv for xen-devel@lists.xenproject.org; Tue, 16 Jan 2024 08:41:09 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fe349fe3-b44a-11ee-98f1-6d05b1d4d9a1; Tue, 16 Jan 2024 09:41:08 +0100 (CET) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40e7065b7bdso24736935e9.3 for ; Tue, 16 Jan 2024 00:41:08 -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 l22-20020a05600c4f1600b0040d6b91efd9sm22293931wmq.44.2024.01.16.00.41.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jan 2024 00:41:07 -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: fe349fe3-b44a-11ee-98f1-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1705394467; x=1705999267; 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=IUIR6jhBeaCWm4WLuVInZHdrkJh9OVonMA+8LwOnY14=; b=fywtD0L4joAXfGIs0FVQxVCdyqDinW8x8MGrnPj/V5aEu9OAk9vVdATkb4j2ZKl3Or mNkXoY0Zj1ecS3PRthvCIxuPyPPmzW0q0LDnlzfpsRueeYkS6+XrIF1GOsFofiQ9lb1S 6twr/RpIGKwZsS2NRkNiHWpEhLSbyEtnEwr+wL8U1hMzZXLBe+xrkECjWccit3tXxB7D ZX8DtYnBug1FxXvPA1xP6WC7Pb1Jt89oITKvy8O0WQriEiUIySkXPEG8Hj7XjSgOyOME tZ8vlo+PnwPYsf489Sqrk1uk5vpN9wjSW+xPm+pUQmRH0GiLZxDNuSsdFzM5BnvbXquh 7B4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705394467; x=1705999267; 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=IUIR6jhBeaCWm4WLuVInZHdrkJh9OVonMA+8LwOnY14=; b=EhNkG4G3pt6ComOaFee73zec6ruLPs0EY/LO0KnByf5Jk98+WsExpCf6Cp9TLh1wJ4 sFuCD2WoHkJmDyCR2e+e5tL2IyNzwOwHHb4JxtCcwQrK1aYVYGGgDGPU4ArMFq4qzkJj F70BwW9iImkuCd7cWrz7+Qb7SopWb36YKRQix7wOPPIEpNQctgEXCzObIRMGnxoacEUP KxM0PHgfrxUkSNMWo8P8HQRk466o+r+V2Od7VsYNbKvonUCjHLwYBifDu7QpffadNoAV clWejWeNsJNV9UmNthB/X+EHOvF+xnOCmOFQN5epob9ElYkAX2OZ/z+DS/Ivh92AzMb9 AW8A== X-Gm-Message-State: AOJu0YwML1WGUb36PNfk9plW1Okdfe1R917yv5jpsylBkP49zMYAWx5o f/67coMbiRSaNUHw058GvrYKXgoMLiwj+UcBG+yfGaed3w== X-Google-Smtp-Source: AGHT+IFaVq5SrdEEPnIWWlpGPantLyRt238Hl6kcFOvKpCOKrBRO6HRWnBT1oYa2GSA2suBh0W5MlQ== X-Received: by 2002:a05:600c:5101:b0:40e:76b5:1973 with SMTP id o1-20020a05600c510100b0040e76b51973mr1085046wms.48.1705394467714; Tue, 16 Jan 2024 00:41:07 -0800 (PST) Message-ID: Date: Tue, 16 Jan 2024 09:41:06 +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] x86/CPU: convert vendor hook invocations to altcall Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZG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Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1705394491811100001 Content-Type: text/plain; charset="utf-8" While not performance critical, these hook invocations still want converting: This way all pre-filled struct cpu_dev instances can become __initconst_cf_clobber, thus allowing to eliminate further 8 ENDBR during the 2nd phase of alternatives patching (besides moving previously resident data to .init.*). Since all use sites need touching anyway, take the opportunity and also address a Misra C:2012 Rule 5.5 violation: Rename the this_cpu static variable. Signed-off-by: Jan Beulich --- With LTO it might end up necessary to tag as __used more than just "default_cpu". --- a/xen/arch/x86/cpu/amd.c +++ b/xen/arch/x86/cpu/amd.c @@ -1302,7 +1302,7 @@ static void cf_check init_amd(struct cpu amd_log_freq(c); } =20 -const struct cpu_dev amd_cpu_dev =3D { +const struct cpu_dev __initconst_cf_clobber amd_cpu_dev =3D { .c_early_init =3D early_init_amd, .c_init =3D init_amd, }; --- a/xen/arch/x86/cpu/centaur.c +++ b/xen/arch/x86/cpu/centaur.c @@ -54,6 +54,6 @@ static void cf_check init_centaur(struct init_c3(c); } =20 -const struct cpu_dev centaur_cpu_dev =3D { +const struct cpu_dev __initconst_cf_clobber centaur_cpu_dev =3D { .c_init =3D init_centaur, }; --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -113,10 +113,10 @@ static void cf_check default_init(struct __clear_bit(X86_FEATURE_SEP, c->x86_capability); } =20 -static const struct cpu_dev default_cpu =3D { +static const struct cpu_dev __initconst_cf_clobber default_cpu =3D { .c_init =3D default_init, }; -static const struct cpu_dev *this_cpu =3D &default_cpu; +static struct cpu_dev __ro_after_init actual_cpu; =20 static DEFINE_PER_CPU(uint64_t, msr_misc_features); void (* __read_mostly ctxt_switch_masking)(const struct vcpu *next); @@ -336,12 +336,13 @@ void __init early_cpu_init(bool verbose) =20 c->x86_vendor =3D x86_cpuid_lookup_vendor(ebx, ecx, edx); switch (c->x86_vendor) { - case X86_VENDOR_INTEL: this_cpu =3D &intel_cpu_dev; break; - case X86_VENDOR_AMD: this_cpu =3D &amd_cpu_dev; break; - case X86_VENDOR_CENTAUR: this_cpu =3D ¢aur_cpu_dev; break; - case X86_VENDOR_SHANGHAI: this_cpu =3D &shanghai_cpu_dev; break; - case X86_VENDOR_HYGON: this_cpu =3D &hygon_cpu_dev; break; + case X86_VENDOR_INTEL: actual_cpu =3D intel_cpu_dev; break; + case X86_VENDOR_AMD: actual_cpu =3D amd_cpu_dev; break; + case X86_VENDOR_CENTAUR: actual_cpu =3D centaur_cpu_dev; break; + case X86_VENDOR_SHANGHAI: actual_cpu =3D shanghai_cpu_dev; break; + case X86_VENDOR_HYGON: actual_cpu =3D hygon_cpu_dev; break; default: + actual_cpu =3D default_cpu; if (!verbose) break; printk(XENLOG_ERR @@ -448,8 +449,8 @@ static void generic_identify(struct cpui if (c->extended_cpuid_level >=3D 0x80000021) c->x86_capability[FEATURESET_e21a] =3D cpuid_eax(0x80000021); =20 - if (this_cpu->c_early_init) - this_cpu->c_early_init(c); + if (actual_cpu.c_early_init) + alternative_vcall(actual_cpu.c_early_init, c); =20 /* c_early_init() may have adjusted cpuid levels/features. Reread. */ c->cpuid_level =3D cpuid_eax(0); @@ -546,9 +547,8 @@ void identify_cpu(struct cpuinfo_x86 *c) * At the end of this section, c->x86_capability better * indicate the features this CPU genuinely supports! */ - if (this_cpu->c_init) - this_cpu->c_init(c); - + if (actual_cpu.c_init) + alternative_vcall(actual_cpu.c_init, c); =20 /* * The vendor-specific functions might have changed features. Now --- a/xen/arch/x86/cpu/hygon.c +++ b/xen/arch/x86/cpu/hygon.c @@ -87,7 +87,7 @@ static void cf_check init_hygon(struct c amd_log_freq(c); } =20 -const struct cpu_dev hygon_cpu_dev =3D { +const struct cpu_dev __initconst_cf_clobber hygon_cpu_dev =3D { .c_early_init =3D early_init_amd, .c_init =3D init_hygon, }; --- a/xen/arch/x86/cpu/intel.c +++ b/xen/arch/x86/cpu/intel.c @@ -577,7 +577,7 @@ static void cf_check init_intel(struct c setup_clear_cpu_cap(X86_FEATURE_CLWB); } =20 -const struct cpu_dev intel_cpu_dev =3D { +const struct cpu_dev __initconst_cf_clobber intel_cpu_dev =3D { .c_early_init =3D early_init_intel, .c_init =3D init_intel, }; --- a/xen/arch/x86/cpu/shanghai.c +++ b/xen/arch/x86/cpu/shanghai.c @@ -15,6 +15,6 @@ static void cf_check init_shanghai(struc init_intel_cacheinfo(c); } =20 -const struct cpu_dev shanghai_cpu_dev =3D { +const struct cpu_dev __initconst_cf_clobber shanghai_cpu_dev =3D { .c_init =3D init_shanghai, };