Received: by 10.213.65.68 with SMTP id h4csp359019imn; Fri, 16 Mar 2018 05:30:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELvzKracY+OU2fgDcLS6mbz1rj54p9XwAzQGolXVK5yDScOIzF491XUAYVWb5WDHQSgjlhcw X-Received: by 2002:a17:902:7787:: with SMTP id o7-v6mr1979308pll.75.1521203426252; Fri, 16 Mar 2018 05:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521203426; cv=none; d=google.com; s=arc-20160816; b=Ba9R42ObuHROidOfL9gWwppB7rbGqEBuCv9OJ6UCRLjOl5Kw8tmNoFKlDFTdAOk0Jd EChT7e+DBO4FF5mAP3q+WQ+lfQh9CpxvZnNSI/Jh47F783NsyxtOXUG8Rt8tqgn+2KdD J9nyGQwQ24LJx2j1INHT4j2Vb+5w2PmFQ/zfd2P8gwHQhuu75ZeVqVtj6fagEoAKC9EQ oX+WzfBSiWIJaWhN0g6nrbbAQKaRs8KaoACYXF2NsmUFL024k0zjnryFMsqJOaw0Saqw 6BXEf3Dqxa9hSrwptOG3tTTUQpCq/dvywQwFhEr2UAI0axSt7wHL6S8L4rhBXehfmMhe DSOg== 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:references:cc:to:subject:arc-authentication-results; bh=CwbrNHd5Clhr12oQUx3mkiFSgcjxw3SdrGfaOF0nL8s=; b=0OkiQBkY+DZWjzD5Cd8Gi5dYi2QJav9hpaJf1PtG9izJU6J+w/BF6gz146TYjhpPZf Jom3vLXQ94zzXVQuNYMa8I8BXRIj6vXJda6n7tsk5Xd35K7BLK8xcXPGdB9wcdy5cavh p5b2xFg3qwde6zgWUW/o2KsyMAktJQ2s3I2EhHr/0x1yIeI+VlvRkOnaMr83hr78+9vJ kTyU2165/vaZnJMhjMwMZd6cL+XmAJtluCvqdBPubItzSxXLts53py0Z86pcwFw/Kq8L B68fvkDuJ2Krm7jHHzggDS3fXk+bQgFjmy3nPN9ZrGHJnPrSuEkcjOILU4rvTS/3vC8w 4fjA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i61-v6si6179938plb.560.2018.03.16.05.30.09; Fri, 16 Mar 2018 05:30:26 -0700 (PDT) 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751796AbeCPM3O (ORCPT + 99 others); Fri, 16 Mar 2018 08:29:14 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59690 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751546AbeCPM3L (ORCPT ); Fri, 16 Mar 2018 08:29:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFF517C6CC; Fri, 16 Mar 2018 12:29:10 +0000 (UTC) Received: from [10.36.116.50] (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AD842166BB2; Fri, 16 Mar 2018 12:29:08 +0000 (UTC) Subject: Re: [PATCH] KVM: x86: Fix device passthrough when SME is active To: Tom Lendacky , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Brijesh Singh , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Joerg Roedel , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Thomas Gleixner References: <20180308231731.27881.84826.stgit@tlendack-t1.amdoffice.net> From: Paolo Bonzini Message-ID: <505b4128-2336-7d81-791a-6e95acdd2a62@redhat.com> Date: Fri, 16 Mar 2018 13:29:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180308231731.27881.84826.stgit@tlendack-t1.amdoffice.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Mar 2018 12:29:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Mar 2018 12:29:10 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/03/2018 00:17, Tom Lendacky wrote: > When using device passthrough with SME active, the MMIO range that is > mapped for the device should not be mapped encrypted. Add a check in > set_spte() to insure that a page is not mapped encrypted if that page > is a device MMIO page as indicated by kvm_is_mmio_pfn(). > > Cc: # 4.14.x- > Signed-off-by: Tom Lendacky > --- > arch/x86/kvm/mmu.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index f551962..763bb3b 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -2770,8 +2770,10 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, > else > pte_access &= ~ACC_WRITE_MASK; > > + if (!kvm_is_mmio_pfn(pfn)) > + spte |= shadow_me_mask; > + > spte |= (u64)pfn << PAGE_SHIFT; > - spte |= shadow_me_mask; > > if (pte_access & ACC_WRITE_MASK) { > > No, I'm applying it. Paolo