Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp587453pxk; Wed, 23 Sep 2020 10:36:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNndTAgTf82DvAmlzB7umjsaQGhZ7TZzFCwmJQl0k5fYhYFKAIxom9HpIO+Fx15F3kktHB X-Received: by 2002:a50:ec12:: with SMTP id g18mr399726edr.309.1600882564753; Wed, 23 Sep 2020 10:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600882564; cv=none; d=google.com; s=arc-20160816; b=jUMQP1ZdwDw14V3m4Otz3PhRobnGBoIURB7oAox/+Jt+XzBkQAfAOr/2C6bIdJ9fQ3 7Ju5RDz6z/FbY5Mk8GP1x97fhtoIAU18lkLqpNBzJ20JggJjQPGe4Gr53EEtyySd4HEJ vc8zDwMabETTeQ7WxEyowBEODBBFCgu88qlS/YPJf2nHpUrYFAyfSqYEFFHuwHMfjWDK d+e0Cw1JGfoN8tSyS5sEZR3aCCvuJqJ+L2/0Ax1oBvOai8Xc4t19FMhhM3Y+QYWi40Nm K0+2OikaZd2ayjLKXgBy1CP66fzpCWleNTAvDAcAR8TfjyIeffKeDNf2my4SbHFnejuJ EEWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ldfka2JU/8jYBcA7GSDSVnVY22PnP+CZq+UK9hEXQUs=; b=lAhHEZyM9MoJk4a6l/qTAelZWnmJuS9SON/6bHA9yZQHP1lF50qlDBfnNf3NFut8lE y2v9V9jgnsssVeD9BKZSsAJDZLF8fhWQHo9VVylGOUNP3PV+sYg0Bx3pjixzAO6uQUuw YPgMuhVrtXfmjIcYAV1DeKXNwQmi1xudWO57JzyBKPLcaxxSgOKdNZTPPh8kHFwt5Cvx MNsDCZIfYYDHUSSw977UNK/xlf3bvv7/arkYHsHToVU6phK6KdrJSnwhalzEMTubFTyU LNZpxcw3LqqKBoMS50EKkaNVXLfPA5hF4KMdkdzJIiiLbkO5H5nnmfS+EWx3F1lGID2p rIVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KCQzpGw5; 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 a13si414258edf.9.2020.09.23.10.35.41; Wed, 23 Sep 2020 10:36:04 -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=KCQzpGw5; 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 S1726744AbgIWReK (ORCPT + 99 others); Wed, 23 Sep 2020 13:34:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50720 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbgIWReK (ORCPT ); Wed, 23 Sep 2020 13:34:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600882449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ldfka2JU/8jYBcA7GSDSVnVY22PnP+CZq+UK9hEXQUs=; b=KCQzpGw5adQNbKumoJ6jjRN6GmNxwsD4aesMTi0lz+ZIfWH0U64SrOQ+1iGzc/KnUct4mE x3jWMCT98BwdpZfHuQoz2Ss1Zl499plWkVSZ+HguuK1JRDTF7PrAiWyn0rh6rGtjyLmEP1 qrOek8Z2c6rVHbxf/7XUnbVPVxHnSPw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-406--llZzXH6MFadSR-JdG7y4w-1; Wed, 23 Sep 2020 13:34:04 -0400 X-MC-Unique: -llZzXH6MFadSR-JdG7y4w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BCDE1800D42; Wed, 23 Sep 2020 17:34:03 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D24D5C230; Wed, 23 Sep 2020 17:34:02 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson Subject: [PATCH] KVM: SEV: shorten comments around sev_clflush_pages Date: Wed, 23 Sep 2020 13:34:01 -0400 Message-Id: <20200923173401.1632172-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Very similar content is present in four comments in sev.c. Unfortunately there are small differences that make it harder to place the comment in sev_clflush_pages itself, but at least we can make it more concise. Suggested-by: Sean Christopherson Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/sev.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index bb0e89c79a04..65e15c22bd3c 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -446,10 +446,8 @@ static int sev_launch_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp) } /* - * The LAUNCH_UPDATE command will perform in-place encryption of the - * memory content (i.e it will write the same memory region with C=1). - * It's possible that the cache may contain the data with C=0, i.e., - * unencrypted so invalidate it first. + * Flush (on non-coherent CPUs) before LAUNCH_UPDATE encrypts pages in + * place; the cache may contain the data that was written unencrypted. */ sev_clflush_pages(inpages, npages); @@ -805,10 +803,9 @@ static int sev_dbg_crypt(struct kvm *kvm, struct kvm_sev_cmd *argp, bool dec) } /* - * The DBG_{DE,EN}CRYPT commands will perform {dec,en}cryption of the - * memory content (i.e it will write the same memory region with C=1). - * It's possible that the cache may contain the data with C=0, i.e., - * unencrypted so invalidate it first. + * Flush (on non-coherent CPUs) before DBG_{DE,EN}CRYPT read or modify + * the pages; flush the destination too so that future accesses do not + * see stale data. */ sev_clflush_pages(src_p, 1); sev_clflush_pages(dst_p, 1); @@ -870,10 +867,8 @@ static int sev_launch_secret(struct kvm *kvm, struct kvm_sev_cmd *argp) return PTR_ERR(pages); /* - * The LAUNCH_SECRET command will perform in-place encryption of the - * memory content (i.e it will write the same memory region with C=1). - * It's possible that the cache may contain the data with C=0, i.e., - * unencrypted so invalidate it first. + * Flush (on non-coherent CPUs) before LAUNCH_SECRET encrypts pages in + * place; the cache may contain the data that was written unencrypted. */ sev_clflush_pages(pages, n); -- 2.26.2