Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp77036ybl; Tue, 7 Jan 2020 14:30:14 -0800 (PST) X-Google-Smtp-Source: APXvYqwwCYwmG1MeYdkLDP1Mj4pUJBo8tI3sZNAQmzkCtQiR5cZRsobtK0nv/0Joa6R0jNwMjFQc X-Received: by 2002:a05:6830:10d7:: with SMTP id z23mr1901943oto.114.1578436214051; Tue, 07 Jan 2020 14:30:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578436214; cv=none; d=google.com; s=arc-20160816; b=xqpkAAtGdrhx6V0Nk5Hb22HD8kp4tRfeXE5zxm05POkPRY38+lHHxwBnjEFftK70tj 6HQ+ghP+Vjfnxx+eY1SVtgbgyMDrdNAIgpIJMqElK6H7lZ1EE+oGBoPjSVCH8u1jGsyL mZe0dIbs7jpDw822bhfeIl1aZI7BJY+yA0lbaHzOPqoyk1x2eXOQoDR5dUpPbzujK+ZB 1b3eHgkUgpuYm+4p1JNfEqN154mGqYF+lEqH5dzK52kR9NkGJYaSS/XSv3eR2tLERGqY MpZ+rNY13j441rb2bPF4bpUgxX8hSacSyk+5OOSjRW0sVLaYXEqfhKE9HGNnrKItW4yi 0G3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+pUUQkJWAkCBt8iZr6TKJoEKTX28vtvR4CQrBqVCvR8=; b=NF0H6VcTSGRuScZ3XgyH5Da09/WDrBfbUs/4pg8RM8n5KwdZrLQl58CqLTi3gGGmqp gCmjmbaw16ar22oI8a++kU0GZfvTvtiO/CHhZIZaC4hvjJoMpu4tlgacWLhkkpKUmLoB NL5PBnFjJUpVAuAtjX5XA4PEd19HPaoi3fZ/fDenEceSUA98JFQBwTriW+Lt0gZ/tE3k kDdzFFJITwF2t8FrojgcjynC+PQxu6R2g/pW3moXgnquDoaYXu4+V3FrFVtD2Qz79uGd HM4ovH/4Gl67Knt5CDvdkNfu9LkGAU0AQZ8RkJusbfzGcqXexY025eKI4OtrNN/cANdB ZAwQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si562024otq.322.2020.01.07.14.30.02; Tue, 07 Jan 2020 14:30:14 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727299AbgAGW2P (ORCPT + 99 others); Tue, 7 Jan 2020 17:28:15 -0500 Received: from mga17.intel.com ([192.55.52.151]:42133 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgAGW2P (ORCPT ); Tue, 7 Jan 2020 17:28:15 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2020 14:28:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,407,1571727600"; d="scan'208";a="211328975" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by orsmga007.jf.intel.com with ESMTP; 07 Jan 2020 14:28:14 -0800 Date: Tue, 7 Jan 2020 14:28:14 -0800 From: Sean Christopherson To: Tom Lendacky Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Brijesh Singh Subject: Re: [PATCH v2] KVM: SVM: Override default MMIO mask if memory encryption is enabled Message-ID: <20200107222813.GB16987@linux.intel.com> References: <20200106224931.GB12879@linux.intel.com> <20200106233846.GC12879@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 07, 2020 at 02:16:37PM -0600, Tom Lendacky wrote: > On 1/6/20 5:38 PM, Sean Christopherson wrote: > > On Mon, Jan 06, 2020 at 05:14:04PM -0600, Tom Lendacky wrote: > >> On 1/6/20 4:49 PM, Sean Christopherson wrote: > >>> This doesn't handle the case where x86_phys_bits _isn't_ reduced by SME/SEV > >>> on a future processor, i.e. x86_phys_bits==52. > >> > >> Not sure I follow. If MSR_K8_SYSCFG_MEM_ENCRYPT is set then there will > >> always be a reduction in physical addressing (so I'm told). > > > > Hmm, I'm going off APM Vol 2, which states, or at least strongly implies, > > that reducing the PA space is optional. Section 7.10.2 is especially > > clear on this: > > > > In implementations where the physical address size of the processor is > > reduced when memory encryption features are enabled, software must > > ensure it is executing from addresses where these upper physical address > > bits are 0 prior to setting SYSCFG[MemEncryptionModEn]. > > It's probably not likely, but given what is stated, I can modify my patch > to check for a x86_phys_bits == 52 and skip the call to set the mask, eg: > > if (msr & MSR_K8_SYSCFG_MEM_ENCRYPT && > boot_cpu_data.x86_phys_bits < 52) { > > > > > But, hopefully the other approach I have in mind actually works, as it's > > significantly less special-case code and would naturally handle either > > case, i.e. make this a moot point. > > I'll hold off on the above and wait for your patch. Sorry for the delay, this is a bigger mess than originally thought. Or I'm completely misunderstanding the issue, which is also a distinct possibility :-) Due to KVM activating its L1TF mitigation irrespective of whether the CPU is whitelisted as not being vulnerable to L1TF, simply using 86_phys_bits to avoid colliding with the C-bit isn't sufficient as the L1TF mitigation uses those first five reserved PA bits to store the MMIO GFN. Setting BIT(x86_phys_bits) for all MMIO sptes would cause it to be interpreted as a GFN bit when the L1TF mitigation is active and lead to bogus MMIO. The only sane approach I can think of is to activate the L1TF mitigation based on whether the CPU is vulnerable to L1TF, as opposed to activating the mitigation purely based on the max PA of the CPU. Since all CPUs that support SME/SEV are whitelisted as NO_L1TF, the L1TF mitigation and C-bit should never be active at the same time. Patch should be incoming soon...