Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1978274pxk; Sat, 19 Sep 2020 08:22:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSxqXgn+0KmeDotV/Odw6HCzk7eaiaDQWfQoqOuiAcm1P66RAJmZux+jnDICOMU5pEthAn X-Received: by 2002:a05:6402:7d2:: with SMTP id u18mr44530992edy.69.1600528945632; Sat, 19 Sep 2020 08:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600528945; cv=none; d=google.com; s=arc-20160816; b=BzQSS2T0mh2sK9HpD+PNqrbwJBYzNi7hBsOITQYt0ZTlq4LfldFrYMffNz8JaDnC0F a3gxE6vE+/Nu6NzDuwLMtZhghP9AmmXrl+L4npOCExW8w9MQWLl5qhOFagpvqjaQSWG9 sHoO7GHf20Nb+6gVAnh4LvZ5TJIleTEDbCbeWDDC+lmcN4Ehs3WQERcdWv5MfiV5k7aV IS6xRpXBvgF3ZqP8Wr8QPcDSIcu/TiWBo/QU/kA0hzizKYoFl0Axgiy6yqbjl0xVQbmC XsvceDUVp8AQT76TkklGjPKDerxfOZbK6UeuRiOYPwWQshKtVc9dcbrI0ZeskjFzzRiV UoLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=UbPVb1SNMbV2AieY6+SVa7sK76f4nIZ2S6J0MZz1m7s=; b=ji1lKwJwtVspOZrBNHM6MSqc//4nowFSELSWV4b/75+9nzxrjzIYWSnk0YDRVyqVnQ wh4DKokSg0n+J9YAifA3FfNUDzRfXspy79wpAZfgTLPx/Nk9Cdn/P7ssVxYNTp+x+QS8 JVv21xNauLUEYIHZTjnqOT/kPtlsSXB68NrSkTG0XxpDuYjHF7BRMarGL58S6y8dwiJU OZo2dxhbd+jLcltmEYKBlqb5ci/ATgDV/RN0tzL8UeQQ/RvGuE+aW5NpXR4lbs88cuPv 5zBvZnUI96gRKnbhHVl0meihIP4a+Emg6Z5e1wGf074AnxXB0gfZMwIVk/Ym98QN5CvE YOWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UlpxXjvG; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay1si4513945edb.440.2020.09.19.08.22.02; Sat, 19 Sep 2020 08:22: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=@redhat.com header.s=mimecast20190719 header.b=UlpxXjvG; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbgISPTF (ORCPT + 99 others); Sat, 19 Sep 2020 11:19:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55832 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbgISPTF (ORCPT ); Sat, 19 Sep 2020 11:19:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600528743; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UbPVb1SNMbV2AieY6+SVa7sK76f4nIZ2S6J0MZz1m7s=; b=UlpxXjvGWJUV13PYeWhApTYf9SWLDU9qIvQOjR1kdga5l9BDVHXoOFWVa11ZBEssp8uWaD 4hzW1Yqmo4BYSrbxKWSW+RhhEZpyYo2JY4kL1UtkQAKyzySv+VgnUoAi/qN2kX0z4YzL09 /BuknwYtx74lLPy6KQrSMco3ZO2m3N4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-GHJ8CIQ_MWyBFnIIsn8yCA-1; Sat, 19 Sep 2020 11:19:02 -0400 X-MC-Unique: GHJ8CIQ_MWyBFnIIsn8yCA-1 Received: by mail-wr1-f72.google.com with SMTP id r16so3534318wrm.18 for ; Sat, 19 Sep 2020 08:19:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UbPVb1SNMbV2AieY6+SVa7sK76f4nIZ2S6J0MZz1m7s=; b=qNwtSenxo5WpbEGb4AjCu+2BVhwDXRZlR1/vC3p3R8DUCrS5FZhdeKMPYLwV1nrHdG bPqQ+L+4PD7nrDysd9IMoBYui2Vtk5RIKRm8URz8h3g5+kzelzMAhIsJLJHqpixsKgqs KXwn5nRlcPjY8RBX/QFveZCT8AysqNU8tGd0hRmq2l6KBH4eU89TM2RVEtdG5efqeUNN ZcCKs/xkDS35fSWGt5BxoLk5F+V1HaI2TkmNJbhIdoMbXo4jN/LDYjy4MgikrymJTuSx tdnAi+G8hwghTujN2BTM2LoOdukSqVTi7swqIesQX8iblkHjNrHCU22tTVeFl5Utv/Ve Xd9Q== X-Gm-Message-State: AOAM533llEN4Fw9/NsrKqj9LYG3FM0RRDAZPRfNywQR/887XnGYrpNb8 xpgT8PvEG6HK5zZrQ9tHIBWBIE06+/YG5Pm6gbKq2OqnSH5GC4sA5b8zK2C58ZSprhP4zT1RUzp 73j4CLCl00jJ6NB9JgTqtnV2y X-Received: by 2002:a05:6000:100c:: with SMTP id a12mr46271719wrx.115.1600528740889; Sat, 19 Sep 2020 08:19:00 -0700 (PDT) X-Received: by 2002:a05:6000:100c:: with SMTP id a12mr46271696wrx.115.1600528740649; Sat, 19 Sep 2020 08:19:00 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:b20a:b600:521c:512d? ([2001:b07:6468:f312:b20a:b600:521c:512d]) by smtp.gmail.com with ESMTPSA id c16sm12719465wrx.31.2020.09.19.08.18.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 19 Sep 2020 08:18:59 -0700 (PDT) Subject: Re: [PATCH 3/3 v4] KVM: SVM: Don't flush cache if hardware enforces cache coherency across encryption domains To: Borislav Petkov , Krish Sadhukhan Cc: kvm@vger.kernel.org, jmattson@google.com, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, joro@8bytes.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, hpa@zytor.com References: <20200917212038.5090-1-krish.sadhukhan@oracle.com> <20200917212038.5090-4-krish.sadhukhan@oracle.com> <20200918075651.GC6585@zn.tnic> From: Paolo Bonzini Message-ID: Date: Sat, 19 Sep 2020 17:18:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200918075651.GC6585@zn.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/09/20 09:56, Borislav Petkov wrote: > On Thu, Sep 17, 2020 at 09:20:38PM +0000, Krish Sadhukhan wrote: >> In some hardware implementations, coherency between the encrypted and >> unencrypted mappings of the same physical page in a VM is enforced. In such a >> system, it is not required for software to flush the VM's page from all CPU >> caches in the system prior to changing the value of the C-bit for the page. >> >> Signed-off-by: Krish Sadhukhan >> --- >> arch/x86/kvm/svm/sev.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c >> index 7bf7bf734979..3c9a45efdd4d 100644 >> --- a/arch/x86/kvm/svm/sev.c >> +++ b/arch/x86/kvm/svm/sev.c >> @@ -384,7 +384,8 @@ static void sev_clflush_pages(struct page *pages[], unsigned long npages) >> uint8_t *page_virtual; >> unsigned long i; >> >> - if (npages == 0 || pages == NULL) >> + if (this_cpu_has(X86_FEATURE_SME_COHERENT) || npages == 0 || >> + pages == NULL) >> return; >> >> for (i = 0; i < npages; i++) { >> -- > > Took the first two, Paolo lemme know if I should route this one through > tip too. > > Thx. > Yeah, it's innocuous enough as far as conflicts are concerned. Acked-by: Paolo Bonzini Paolo