Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp487873pxb; Tue, 14 Sep 2021 02:04:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSApJdmwkh5mYf5NfaXTzInVFOrh+nliFDP0P2fxIKAujFoPMqlb79OlO7rqm6hk2Rxu+l X-Received: by 2002:a5d:9319:: with SMTP id l25mr6373404ion.208.1631610284104; Tue, 14 Sep 2021 02:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631610284; cv=none; d=google.com; s=arc-20160816; b=RG9Njpd20W5rQ4Ck8wj0Oj/dA/dYnvc3sFW2zerm7iFAktZGVdZrfXRQYlZ7UoFozp TbImOH/cogm4Xdn2czXadUUhTMg3jP4XOtECUmKGXlCrW5cyJYoPv5ISplsXi5GPaY9N c9+NTgMFAD4FQDmKlB/DnO63AKgC7+r7TpoxYT4acWJ8KUhJavni3TnoPHkbeX6bLvt3 6OFy6C1eGwE5lOFWr6vWLXZtd0vFpAfBPV561x3K/2Dv8skVEozE5UDNRgQdJsMQnGLE D7EiEzpK9VDygQ8SLlHD/0klyG7NZoDk9R4wvU0oVmg4VrF5Mnb6zfbET9VHqVYiquEz gMzg== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=d9zHzAE5JRRNzn4tPguLuhYSUPQr1fd/jH5EtFVUE3c=; b=eDBPhiExf7Qrh1aAlznGE60Kt8mN3OPMNqcaFBFY7xdFnf08fGg5y1f+VlsdDHCnPm FDyFH18QHjCqviisESQanwwuy1m8vp2eCIwHOu1f/EtK9U+jojJKqST7lDvgdb8F6tlJ LtzMJCtf8YTdVThI28atyuHlZB4I2JIS00Vqh1K3NjJe6CC9umg2g3ADev3W1rNd4KB0 Hf36B1pt1cCb/QNiiXZGTmGeZGh1If/SAE4ay/useZZqHQR0FLY1JnbHTguJ6uWHh0RD TKc0i9IettvmOWvoYQrxM9vqHsX3q4wk/1wRpNIsYCukM/u6CiB71y2/raTzUuAhtlu5 ic2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QAbt76ZB; 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 j8si2067898jat.1.2021.09.14.02.04.30; Tue, 14 Sep 2021 02:04:44 -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=QAbt76ZB; 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 S230116AbhINJDz (ORCPT + 99 others); Tue, 14 Sep 2021 05:03:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33926 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbhINJDy (ORCPT ); Tue, 14 Sep 2021 05:03:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631610157; 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=d9zHzAE5JRRNzn4tPguLuhYSUPQr1fd/jH5EtFVUE3c=; b=QAbt76ZBn3ZTIsTesDpADF+Lf4xTewBwxcV/pBc137OsigI6iBWuRXA+MEOJc7S643TMm4 Ky5P4jJ4w5OlrLzklw9Yo/GmyZ0EP8956iVCscAv7fdve4ofZwa6pH4LRFy4ONDpazzA2k QYbs4UvLGFM9ZAZEvjWNWAPVSBlKWLE= 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-511-6ZFRKCtGND6AYxhtycmzbw-1; Tue, 14 Sep 2021 05:02:36 -0400 X-MC-Unique: 6ZFRKCtGND6AYxhtycmzbw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF157800FF4; Tue, 14 Sep 2021 09:02:32 +0000 (UTC) Received: from starship (unknown [10.35.206.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 668835D9DC; Tue, 14 Sep 2021 09:02:29 +0000 (UTC) Message-ID: <9585f1387b2581d30b74cd163a9aac2adbd37a93.camel@redhat.com> Subject: Re: [RFC PATCH 3/3] nSVM: use svm->nested.save to load vmcb12 registers and avoid TOC/TOU races From: Maxim Levitsky To: Emanuele Giuseppe Esposito , kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Date: Tue, 14 Sep 2021 12:02:28 +0300 In-Reply-To: <73b5a5bb-48f2-3a08-c76b-a82b5b69c406@redhat.com> References: <20210903102039.55422-1-eesposit@redhat.com> <20210903102039.55422-4-eesposit@redhat.com> <21d2bf8c4e3eb3fc5d297fd13300557ec686b625.camel@redhat.com> <73b5a5bb-48f2-3a08-c76b-a82b5b69c406@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-09-14 at 10:20 +0200, Emanuele Giuseppe Esposito wrote: > > On 12/09/2021 12:42, Maxim Levitsky wrote: > > > > > > - if (!nested_vmcb_valid_sregs(vcpu, &vmcb12->save) || > > > + if (!nested_vmcb_valid_sregs(vcpu, &svm->nested.save) || > > > !nested_vmcb_check_controls(vcpu, &svm->nested.ctl)) { > > If you use a different struct for the copied fields, then it makes > > sense IMHO to drop the 'control' parameter from nested_vmcb_check_controls, > > and just use the svm->nested.save there directly. > > > > Ok, what you say in patch 2 makes sense to me. I can create a new struct > vmcb_save_area_cached, but I need to keep nested.ctl because 1) it is > used also elsewhere, and different fields from the one checked here are > read/set and 2) using another structure (or the same Yes, keep nested.ctl, since vast majority of the fields are copied I think. Best regards, Maxim Levitsky > vmcb_save_area_cached) in its place would just duplicate the same fields > of nested.ctl, creating even more confusion and possible inconsistency. > > Let me know if you disagree. > > Thank you, > Emanuele >