Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp2061805rwj; Sun, 30 Oct 2022 10:34:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74zHfSAcuXeU0lQI/lOKWCFrkU4ovIqE9BzgxGonQf+pNgj/GejCgrl7+kYVCBg2D+x0H9 X-Received: by 2002:a05:6402:1cc5:b0:453:ed3f:6a38 with SMTP id ds5-20020a0564021cc500b00453ed3f6a38mr9851065edb.346.1667151278434; Sun, 30 Oct 2022 10:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667151278; cv=none; d=google.com; s=arc-20160816; b=xg3DM2/VkZ54SDZ+8EO/xI9RUHqnp0SUUIh0E2yUGU4i7WFo/ROan1YZSYzl/Ckkej 4DWezYt8ivzwwyjATHefAh4QvcNaEJwR2JK79ZMeyR5p7GTvJYR9k3RDRoVFF8geb8I+ k+trdmNEVnpXDp/5thp7YWXncRg31mK7QWPjUzAVU+9AnkdrAJmjsyVtoRIeg33albti a1k9NWkkvhFLnsTUbVpTohuByU9KOy1mw/FnrGESNPczjDaw19Gz8kjfrbaBPNVpihMW X7zP/HTJ45tvXozRBmQHZl0IrcQlgvTr0sf2OWeBOxJ4AikBhh3/m5KNPnq2F9vMl4Pe cA4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BB1ePUNM1BbC8WRzI6/WKi8TDgsMIa4rj1HirQWEQTY=; b=SWPS3oI+jbxy6hDGIkgcTxVAJxh30Oqa7dqUV5LPJmHMG/+pEXqR64ZNZ+m9UtY2oi FN1e4tB5gHoCppNsPdH6UN0ESejFseeNUgnBAtkaFE3EdHec8NSXP4fTQJ8qmlfn643I g/UTnnXEbrQokwWsQ9ompRIlH1nEMr9OGNaq6FGzoof66nib/iBrFIlPMP2gmYc7jgQM 3+lW5CrzihEVVjyQNaT8j9piqJ5LYJwMfuBeLswZIWiuovBBR5VsMvHIFiY3R7iIs8OA V11JJ3jNZqpcUTv1+QM1kauw9+MP8sIh1aJcT0/EUftHSAlk3/CXPcj4auxFfG/XqZgK V5tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Ew756vwm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho18-20020a1709070e9200b00741a0720a2bsi6270471ejc.814.2022.10.30.10.34.10; Sun, 30 Oct 2022 10:34:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Ew756vwm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbiJ3QjY (ORCPT + 99 others); Sun, 30 Oct 2022 12:39:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiJ3QjW (ORCPT ); Sun, 30 Oct 2022 12:39:22 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F113BF1A for ; Sun, 30 Oct 2022 09:39:20 -0700 (PDT) Received: from zn.tnic (p200300ea9733e745329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e745:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4603A1EC054E; Sun, 30 Oct 2022 17:39:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1667147959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=BB1ePUNM1BbC8WRzI6/WKi8TDgsMIa4rj1HirQWEQTY=; b=Ew756vwmyB1MD/KsS+mMBW0bBwaqmgNVsa6rgfkOwxWKtbmqQonScJVZcwXO48L9czGySu mlhYKFLNkEhQeKmHLU3HJ6iElzkev9I2lImcrnKjBCO+sCkzUFoa51k4s7YmWSNSBlX7B1 uSRjQiV0PcJtz1rA4CBbgwZLtXkAbiA= Date: Sun, 30 Oct 2022 17:39:14 +0100 From: Borislav Petkov To: Juergen Gross Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Dave Hansen , "H. Peter Anvin" Subject: Re: [PATCH v4 16/16] x86/mtrr: simplify mtrr_ops initialization Message-ID: References: <20221004081023.32402-1-jgross@suse.com> <20221004081023.32402-17-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 30, 2022 at 04:05:29PM +0100, Juergen Gross wrote: > As the specific ops variables are available for X86_32 only, this > would require to add an "#ifdef CONFIG_X86_32" around the code block > doing the assignments. Otherwise the build would fail. Well, it looks like my compiler is smart enough and eliminates all that dead code, see diff below. I've added the asm markers "#begin" and "#end" and the resulting asm looks like this: # arch/x86/kernel/cpu/mtrr/mtrr.c:666: asm volatile("#begin"); call __sanitizer_cov_trace_pc # #APP # 666 "arch/x86/kernel/cpu/mtrr/mtrr.c" 1 #begin # 0 "" 2 # arch/x86/kernel/cpu/mtrr/mtrr.c:693: asm volatile("#end"); # 693 "arch/x86/kernel/cpu/mtrr/mtrr.c" 1 #end # 0 "" 2 # arch/x86/kernel/cpu/mtrr/mtrr.c:630: phys_addr = 32; #NO_APP which basically says that all between line 666 and 693 has been eliminated. I have the suspicion, though, that clang might not be that smart. Lemme test it a bit. --- diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index 7ba68356c0ff..d499c83b2ad7 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -663,25 +663,26 @@ void __init mtrr_bp_init(void) phys_addr = 32; } } else { + asm volatile("#begin"); switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_AMD: if (cpu_feature_enabled(X86_FEATURE_K6_MTRR)) { /* Pre-Athlon (K6) AMD CPU MTRRs */ - mtrr_if = vendor_mtrr_ops(amd_mtrr_ops); + mtrr_if = &amd_mtrr_ops; size_or_mask = SIZE_OR_MASK_BITS(32); size_and_mask = 0; } break; case X86_VENDOR_CENTAUR: if (cpu_feature_enabled(X86_FEATURE_CENTAUR_MCR)) { - mtrr_if = vendor_mtrr_ops(centaur_mtrr_ops); + mtrr_if = ¢aur_mtrr_ops; size_or_mask = SIZE_OR_MASK_BITS(32); size_and_mask = 0; } break; case X86_VENDOR_CYRIX: if (cpu_feature_enabled(X86_FEATURE_CYRIX_ARR)) { - mtrr_if = vendor_mtrr_ops(cyrix_mtrr_ops); + mtrr_if = &cyrix_mtrr_ops; size_or_mask = SIZE_OR_MASK_BITS(32); size_and_mask = 0; } @@ -689,6 +690,7 @@ void __init mtrr_bp_init(void) default: break; } + asm volatile("#end"); } if (mtrr_if) { diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h index 7a7387356192..02eb5871492d 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h @@ -68,11 +68,6 @@ void mtrr_wrmsr(unsigned, unsigned, unsigned); extern const struct mtrr_ops amd_mtrr_ops; extern const struct mtrr_ops cyrix_mtrr_ops; extern const struct mtrr_ops centaur_mtrr_ops; -#ifdef CONFIG_X86_64 -#define vendor_mtrr_ops(x) NULL -#else -#define vendor_mtrr_ops(x) &(x) -#endif extern int changed_by_mtrr_cleanup; extern int mtrr_cleanup(unsigned address_bits); -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette