Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp418574ybt; Fri, 19 Jun 2020 05:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxpHCQdURP34Ma7xAQFbB5tzl4qWLQqYhCPIrb+3needJg293PXU5UsSrpnpY8wcuB18Tu X-Received: by 2002:a17:906:6686:: with SMTP id z6mr3233034ejo.258.1592568565658; Fri, 19 Jun 2020 05:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592568565; cv=none; d=google.com; s=arc-20160816; b=yT0lQw2CzUVr1R6abn5OtLKgHlzWLI8SzuZrUnBN62sVTiwkEUPlsLDMxOH5DtFr2o 5JM6DRwqCh61cBb6HZWoOgDJSarknXcMjZEiBoBlrXttyuSOVooQ2v/mh2/TpYHHaC3c Mv9jijWelXU3E2zRsGdwQOD9EIM7k8t5rElmabE+UjbY4+nzaj+lHFlam1H4TpeONhVD 815BfeTgHLuZMmhFfgRGbr6qennPGxeGgXa66Bc1mKdz2Bwf5sP7/uHN/WAe8SS2OLAz /0hiyaCjhT7dXawfXdVcOM2Kft3VfN4/YLCdUi1JvYFGYBKEVW9/yvRzuShWjIM+CnqJ ljxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=IritHY2wnRSz18h7p7bbLCpGe2Z1I4B1arbap5AVn8U=; b=sir10kUEt8z4H4vmm/Fq469fnEWKD0xWFcPZ0YfiFYFS2lTFuM/ZXBVf5Us3RTONuT NLSKl9ok4gR2GulUt6k4RsBP2Ym3+Ed7AfusPgsI9G4UGPh7h65YFuep2VXNTF3OY5Ra i/KpUpNGBdUN737I7xZHHrN7zE6o0zZXSwCmtAM50aGvYTukIm5YZJ5Nmmvmpw4iP+4H D6ZQXNoq1yguy9WgpoB0xkgsblxp5wdp8N3XYi8Zn7cVjIxdYyGqXaPWqsvE9rD7M/5q 6pBbfIfkgWw6+K0XcwexPub56WEe7htABvbgmx2UxS3PdEGDy4WKeNrfFX3syooy4wls MLGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=pfKzaMfC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r4si3936834edb.585.2020.06.19.05.08.57; Fri, 19 Jun 2020 05:09:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=pfKzaMfC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730792AbgFSHlE (ORCPT + 99 others); Fri, 19 Jun 2020 03:41:04 -0400 Received: from mail.skyhub.de ([5.9.137.197]:58794 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729548AbgFSHlC (ORCPT ); Fri, 19 Jun 2020 03:41:02 -0400 Received: from zn.tnic (p200300ec2f0bac00fd80253c6a150deb.dip0.t-ipconnect.de [IPv6:2003:ec:2f0b:ac00:fd80:253c:6a15:deb]) (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 91A071EC0298; Fri, 19 Jun 2020 09:41:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1592552460; 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=IritHY2wnRSz18h7p7bbLCpGe2Z1I4B1arbap5AVn8U=; b=pfKzaMfCiuoUSuFoMXI39QqAHedsWRO5ccukKB+JVpbofnbCm9q3yJ2rMIQEiejKNoIfk4 68ICEortCSIaTz5Tvoh++8jrauFM9kTb1+iEWFnDGDqhXXg8q4ThaCxlBlAA79FG+NAC/1 T3AOGMju1KbkkYX0VQwf1xzP9DwK4CY= Date: Fri, 19 Jun 2020 09:40:53 +0200 From: Borislav Petkov To: Daniel Gutson Cc: Dave Hansen , Thomas Gleixner , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , Arnd Bergmann , Greg Kroah-Hartman , Peter Zijlstra , "David S. Miller" , Rob Herring , Tony Luck , Rahul Tanwar , Xiaoyao Li , Sean Christopherson , Dave Hansen , linux-kernel@vger.kernel.org, Richard Hughes Subject: Re: [PATCH] Ability to read the MKTME status from userspace Message-ID: <20200619074053.GA32683@zn.tnic> References: <20200618210215.23602-1-daniel.gutson@eclypsium.com> <589c89ae-620e-36f8-2be5-4afc727c2911@intel.com> <20200618220139.GH27951@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 18, 2020 at 07:34:21PM -0300, Daniel Gutson wrote: > Besides being a CPU capability, it has to be enabled by the BIOS, which is > what the flag represents. ... yes, and if it is disabled in the BIOS, you clear the CPU cap flag. Something like this untested diff: --- diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index c25a67a34bd3..59d8342f6a64 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -525,6 +525,7 @@ static void detect_tme(struct cpuinfo_x86 *c) if (!TME_ACTIVATE_LOCKED(tme_activate) || !TME_ACTIVATE_ENABLED(tme_activate)) { pr_info_once("x86/tme: not enabled by BIOS\n"); mktme_status = MKTME_DISABLED; + clear_cpu_cap(c, X86_FEATURE_TME); return; } @@ -553,10 +554,11 @@ static void detect_tme(struct cpuinfo_x86 *c) pr_info_once("x86/mktme: disabled by BIOS\n"); } - if (mktme_status == MKTME_UNINITIALIZED) { - /* MKTME is usable */ + /* MKTME is usable */ + if (mktme_status == MKTME_UNINITIALIZED) mktme_status = MKTME_ENABLED; - } + else if (mktme_status == MKTME_DISABLED) + clear_cpu_cap(c, X86_FEATURE_TME); /* * KeyID bits effectively lower the number of physical address -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette