From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225CkI7fRfx7HUb1G3CCSGZnrMfPM3uS58ljMtm3JV3m4BkB4PllePTop8colW7VdFsu9DyI ARC-Seal: i=1; a=rsa-sha256; t=1516874478; cv=none; d=google.com; s=arc-20160816; b=SaB4oNP8cHVsxcx94h2Zahhlh8b01sLIJvqKP8J4b4s2ZxRAhLXSqO7eqY2gDsGmlx LX4eqZDv6VlIMD/HQC15CFojqQloBsD0/Edb40H7FHEMWymsNKDl3zIArM0Newv1jqP2 FnYS4xZapa6X4JYHS/OsLZIc40RuViTu56p+tSwyOn7Dq39vD+VWKKWMqxkNa5uXmYu9 Nwd6uW+N8Rqs0EhSOve2lEQOH43YbS4NeQa5qOtyv0p+E8Ju7oSaX0AsegArVdQ0WMXg ZGzYA0EhAjNcPTttcNLDVZxQNWffaw13QdPXaT9XbuNb5My2cuRRGn5gaiUagYyHC0dI /HqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:arc-authentication-results; bh=VvMEO9nPo9ShwkDXm1Z7vlLHuXZ1Gn/TP/dB1hScK5E=; b=PbYAcaMqUfjJFE4nbVffqVxaTF4MnMpErae6DPpQSsd6y4dWJJ3RA/zxFawU6iOvQe w7tz2ftYrggbFx+1gurQ5de6/BXMutsSmxK1gimOghOSsGy1FxTW1SlvV7wQi09zQ/qj WrmC/grtGoPExOZXbR7UbmToKvX0bZl5H6tjJ+k/MLVmpIf675MAZFYtc0v7PJKgDpxL eqNUnR0DkFrxOeQqBXfr0hq7huXEdS5bnk8+E3xovXZCcIsBGr9Nan+akEhILc8WkzYS 7zQZ6lAI5UYckmpY24upMWMNssYiWiXFQ7KC6+RVNw6k6aBkgqi7MnRnWsw6OsnrFNVt au8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tglx@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=tglx@linutronix.de Date: Thu, 25 Jan 2018 11:01:00 +0100 (CET) From: Thomas Gleixner To: David Woodhouse cc: Peter Zijlstra , arjan@linux.intel.com, karahmed@amazon.de, x86@kernel.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, bp@alien8.de, pbonzini@redhat.com, ak@linux.intel.com, torvalds@linux-foundation.org, gregkh@linux-foundation.org, dave.hansen@intel.com, gnomes@lxorguk.ukuu.org.uk, ashok.raj@intel.com, mingo@kernel.org Subject: Re: [PATCH v4 5/7] x86/pti: Do not enable PTI on processors which are not vulnerable to Meltdown In-Reply-To: <1516874209.30244.38.camel@infradead.org> Message-ID: References: <1516872189-16577-1-git-send-email-dwmw@amazon.co.uk> <1516872189-16577-6-git-send-email-dwmw@amazon.co.uk> <20180125094258.GZ2228@hirez.programming.kicks-ass.net> <1516874209.30244.38.camel@infradead.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-850804649-1516874461=:2020" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590555846213033818?= X-GMAIL-MSGID: =?utf-8?q?1590558172479485469?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-850804649-1516874461=:2020 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Thu, 25 Jan 2018, David Woodhouse wrote: > On Thu, 2018-01-25 at 10:42 +0100, Peter Zijlstra wrote: > > On Thu, Jan 25, 2018 at 09:23:07AM +0000, David Woodhouse wrote: > > > +static bool __init early_cpu_vulnerable_meltdown(struct cpuinfo_x86 *c) > > > +{ > > > +     u64 ia32_cap = 0; > > > + > > > +     if (x86_match_cpu(cpu_no_meltdown)) > > > +                return false; > > > + > > > +     if (cpu_has(c, X86_FEATURE_ARCH_CAPABILITIES)) > > > +             rdmsrl(MSR_IA32_ARCH_CAPABILITIES, ia32_cap); > > > > I think it was suggested a while back to write this like: > > > >         if (cpu_has(c, X86_FEATURE_ARCH_CAPABILITIES) && > >             !rdmsrl_safe(MSR_IA32_ARCH_CAPABILITIES, ia32_cap)) > > > > to deal with funny virt scenarios where they accidentally advertise the > > CPUID bit but don't in fact provide the MSR. > > It was indeed suggested, but I was a bit confused by that. Because the > CPUID bit exists *purely* to advertise the existence of that MSR; > nothing more. > > If it doesn't exist we'll end up with zero in ia32_cap anyway, which > will mean we *won't* see the RDCL_NO bit, and won't disable the > Meltdown flag. And using rdmsrl() has the benefit of running into the ex_handler_rdmsr_unsafe() exception handler, which emits a warning. The value returned in ia32_cap is 0. Thanks, tglx --8323329-850804649-1516874461=:2020--