Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3626818ybd; Tue, 25 Jun 2019 05:59:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZ+iqpcwyKxeCJ8P5YcoVIDn0TRzBvBbQ6OZItIj717hSEamfJied8ctyXWHoMUXRoIpCV X-Received: by 2002:a63:a367:: with SMTP id v39mr28942279pgn.131.1561467576046; Tue, 25 Jun 2019 05:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561467576; cv=none; d=google.com; s=arc-20160816; b=foxj2VSTlr9gadOcpCwTtePlakkxETJIgmbX7jqQkFTbWOJjjIr9RoNcWtWjZ6D4mt eZnYAnihJMgYsfUer8RJnUOQOc9U5wH71lr+MAPERKKhEm/Jyh01lwQ2ElCVNKnTKbLk kV0kE+jEUh3KQDxgpWUL5NVk7CJN8nFW+3umVGqPUUk+c3kfv8t7n5DjufRZIGhyUeUD 9Jm4nlNWEdYz4L/yux/CWkaGtk6Xmv+PsE20cEdFNd1B4L2crhjwNu9lswhiuam0fIBt zZu/b8tY6sPzPlZst7WYmKAzNuiaLbo/uKcecUR2Gy1S3Tt5nhCpcYtxAdY3YtAssNU/ 1SRw== 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:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from; bh=pXjNCSKO+A8itxoJob/5aeE7uqcr9aKUUDE+2xRnOkY=; b=taZzlz0Kl5CQrOsjrm0jJwVcURzOk1+BZm+5KUY9Hqvhudb7FuzGAqLG5OVKDlYkz/ Dlpm7ZgF5hIjP4/4IpTSL7eNvhMO/nvacz7qjrlTAMHAhYDaU+ejgLZMqbEPzWZtRuIG Gk+51YtL3hngS+pT1lw7s642Cv8+V6ck67PnG9zAffRIshJ5V9o1Z+FGh5vUJpot4J85 bw8Hkj//oXSWd2I0U9tvHqXD76XhU30/aed5PULQ9+4HKP7k/mAAnBqbu5FdKj73WLNm iek9qqYycvejRuzhlfP1Q5jWgHeorC3UJtNl3VhnBtaE3/pRDPUzvcs64BLjumVDuJu7 o3Eg== 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 y6si13313438pga.501.2019.06.25.05.59.20; Tue, 25 Jun 2019 05:59:36 -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 S1728232AbfFYLPL (ORCPT + 99 others); Tue, 25 Jun 2019 07:15:11 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36250 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727527AbfFYLPL (ORCPT ); Tue, 25 Jun 2019 07:15:11 -0400 Received: by mail-wm1-f65.google.com with SMTP id u8so2559913wmm.1 for ; Tue, 25 Jun 2019 04:15:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=pXjNCSKO+A8itxoJob/5aeE7uqcr9aKUUDE+2xRnOkY=; b=k11s8DVJNaAw4WmkTVVXIAh6NRoaBBq9PgkuPl0Ec7KXvFXwz6/IJc5wG32uoInJB2 NLf7g6mU8WHR2NzlDSLr08FqEnDhF/SSUGbAHyUhbF4/N8WRofzZZ2YydyGWF/euhSEx SOxwhFwYD099LSjhos4RPFCwzOTkEWnC29rqDooWKxoW48NLdk7/TlLm/hQy2WLr74mq IxsinZeuYzXqKofdvacdTQWbOFesr5Q+TbGLLFPypSAseobubegEwHImClNcyUo+MqdY EhY0wtR5KIgYkZphUbL/jKfnRIoo+oJoLR9TvkzNSbAZXyOikCvMkredNTMf3pogDj4F 3ekA== X-Gm-Message-State: APjAAAVbL0Tkdqaoc/8lSQnUq1HuHp/xrGOHGhcVi54w7QhroleOdxUj 6jxyL2k3uFgI9IOLPI8bQQzj/w== X-Received: by 2002:a05:600c:291:: with SMTP id 17mr18954242wmk.32.1561461309066; Tue, 25 Jun 2019 04:15:09 -0700 (PDT) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id d1sm12697836wru.41.2019.06.25.04.15.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 04:15:08 -0700 (PDT) From: Vitaly Kuznetsov To: Liran Alon Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] x86/kvm/nVMCS: fix VMCLEAR when Enlightened VMCS is in use In-Reply-To: References: <20190624133028.3710-1-vkuznets@redhat.com> <87lfxqdp3n.fsf@vitty.brq.redhat.com> Date: Tue, 25 Jun 2019 13:15:07 +0200 Message-ID: <87ftnxex1g.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Liran Alon writes: >> On 25 Jun 2019, at 11:51, Vitaly Kuznetsov wrote: >> >> Liran Alon writes: >> >>>> On 24 Jun 2019, at 16:30, Vitaly Kuznetsov wrote: >>>> >>>> >>>> +bool nested_enlightened_vmentry(struct kvm_vcpu *vcpu, u64 *evmptr) >>> >>> I prefer to rename evmptr to evmcs_ptr. I think it’s more readable and sufficiently short. >>> In addition, I think you should return either -1ull or assist_page.current_nested_vmcs. >>> i.e. Don’t return evmcs_ptr by pointer but instead as a return-value >>> and get rid of the bool. >> >> Actually no, sorry, I'm having second thoughts here: in handle_vmclear() >> we don't care about the value of evmcs_ptr, we only want to check that >> enlightened vmentry bit is enabled in assist page. If we switch to >> checking evmcs_ptr against '-1', for example, we will make '-1' a magic >> value which is not in the TLFS. Windows may decide to use it for >> something else - and we will get a hard-to-debug bug again. > > I’m not sure I understand. > You are worried that when guest have setup a valid assist-page and set > enlighten_vmentry to true, > that assist_page.current_nested_vmcs can be -1ull and still be considered a valid eVMCS? > I don't think that's reasonable. No, -1ull is not a valid eVMCS - but this shouldn't change VMCLEAR semantics as VMCLEAR has it's own argument. It's perfectly valid to try to put a eVMCS which was previously used on a different vCPU (and thus which is 'active') to non-active state. The fact that we don't have an active eVMCS on the vCPU doing VMCLEAR shouldn't matter at all. -- Vitaly