Received: by 10.223.176.5 with SMTP id f5csp3900669wra; Mon, 29 Jan 2018 22:14:36 -0800 (PST) X-Google-Smtp-Source: AH8x225hkOvfWiWzf1S8rdgZ7FGeS5X68Ai4bRzohMDXdXZYhT2OSEHCHHfv5LYqLAmDAXmUryOT X-Received: by 2002:a17:902:6c41:: with SMTP id h1-v6mr24157405pln.25.1517292876558; Mon, 29 Jan 2018 22:14:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517292876; cv=none; d=google.com; s=arc-20160816; b=P5N5ek1iN2M94L69oQSKYmYKhcdDSGs3aS3KcwgcWuIKAyJI3R1HhKalkL0Kjn2YIi FAA9CmFjIMlDzorJ0r3crtwwzrt6PnF9LwNpVlOL5mBl6iG1GbigVPvnIWZswyleVWyj d3LmMNtMQxZbLLyOOF4eEfPTGrlNEkCfGzLkHT0DMRSXVaYryeqdQauEXf9FxZAUnCmx ePu14IISi6PQKrjIOmqLgzIcljIoeRVktmvW7Kfx6h98wPb9INUDetJluIPwlU/Qgr6t rGjyDpXRfIg3Z5wYR7Wr1+mmRIDbgLPx0gbddKNnQL5oQYcyUroE2SsXR+9ppDb/IPgt Lq6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject:arc-authentication-results; bh=923s6XmAsYDm991dtUlv8rCfb8xYMWgeYuiCU01BAnA=; b=xC0+qQ7IZMU/2JOkA7j/CzyFkDWzLRwTj4P3BdV9CkPZ7hdCdWe5NLtexrc4bpV7jF EzKp0xA4aWFVT4NoBO46JFBlMtgGkSGuSZgAn6R9xksbH1X++BtK2U00ahTEWx0Y9En4 UUMCyJShl9BwVGM1xLXyYORnwERKD7qnqHJLamArarYu8PU+ZPBYZcFgzjsuLTjVTuXJ XKyMeUWRg8eMixiRUepbXKC2A1mS7jIt4en3VO4OZ3YKD7EO89OqwSsQe52+JTgsBvAm TrpOWUS5quX17J1Bia8BcfdlywQcUgB/jZnFCTyEQ7YPGF4P8C7wbNjrHMVMM5qdb2To AUpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t70si3975291pgd.13.2018.01.29.22.14.21; Mon, 29 Jan 2018 22:14:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752741AbeA3GNz (ORCPT + 99 others); Tue, 30 Jan 2018 01:13:55 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:49699 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752325AbeA3GNy (ORCPT ); Tue, 30 Jan 2018 01:13:54 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="36308432" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Jan 2018 14:13:53 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 8ED7A48AEA1E; Tue, 30 Jan 2018 14:13:53 +0800 (CST) Received: from localhost.localdomain (10.167.226.106) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 30 Jan 2018 14:13:51 +0800 Subject: Re: Question about dmesg/sysfs output when retpoline config is disabled To: "Misono, Tomohiro" , References: <00bcb291-2b99-1122-9eb3-13c191fa3a5b@jp.fujitsu.com> CC: , , , , , , , "x86@kernel.org" , From: Dou Liyang Message-ID: Date: Tue, 30 Jan 2018 14:13:50 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <00bcb291-2b99-1122-9eb3-13c191fa3a5b@jp.fujitsu.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 8ED7A48AEA1E.AEE24 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Misono-san, At 01/30/2018 12:52 PM, Misono, Tomohiro wrote: > Hello, > > I think dmesg/sysfs output messages are not suitable if retpoline config is off: > > I intentionally compiled the kernel 4.15.0 with CONFIG_RETPOLINE=n for test and > boot it with the following kernel command line option to check dmesg/sysfs: > > (a) no command line option or "spectre_v2=on" or "spectre_v2=auto" > $ dmesg | grep -i spectre > [ 0.017714] Spectre V2 mitigation: Vulnerable: Minimal generic ASM retpoline > $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 > Minimal generic ASM retpoline > > (b) "spectre_v2=off" > $ dmesg | grep -i spectre > [ 0.017002] Spectre V2 mitigation: disabled on command line. > $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 > Vulnerable > > (c) "spectre_v2=retpoline" > $ dmesg | grep -i spectre > [ 0.018002] Spectre V2 mitigation: kernel not compiled with retpoline; no mitigation available! > $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 > Vulnerable > > I think the output of (c) is correct for this case, or are these outputs actually right? > > Also, the output of (a) is the same with following condition: > (1) CONFIG_RETPOLINE=n, and > (2) CONFIG_RETPOLINE=y but the compiler did not support retpoline > These cannot be distinguished unless option of (c) is explicitly used. > +Cc maintainers and x86 mail list... first. IMO, Selecting 'on' or 'auto' to "spectre_v2=" should also consider the setting of the CONFIG_RETPOLINE configuration option. So, check if CONFIG_RETPOLINE is y before setup CPU capability. Thanks, dou. --------------8<----------------------------- diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 390b3dc3d438..10188f856099 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -193,8 +193,9 @@ static void __init spectre_v2_select_mitigation(void) case SPECTRE_V2_CMD_FORCE: /* FALLTRHU */ case SPECTRE_V2_CMD_AUTO: - goto retpoline_auto; - + if (IS_ENABLED(CONFIG_RETPOLINE)) + goto retpoline_auto; + break; case SPECTRE_V2_CMD_RETPOLINE_AMD: if (IS_ENABLED(CONFIG_RETPOLINE)) goto retpoline_amd; > Regards, > Tomohiro Misono > > > >