Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3403478ybd; Tue, 25 Jun 2019 01:53:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfj9m2zxx5IXk0YFVdnRRrSGDShZtOgAg9t6RbY0Kd1ibgLBMIDbi8W1+/cDH78JxgtZVX X-Received: by 2002:a17:90a:b30a:: with SMTP id d10mr30860233pjr.8.1561452793943; Tue, 25 Jun 2019 01:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561452793; cv=none; d=google.com; s=arc-20160816; b=FRj36tdf7thc0dbvRzfJvzkBdJ2R/CtHISeeZ6rxnnXVgFAEjHGfTIHlT6g0ISxhSr aVjUAG95iME8j2eB2v5OVtnDiZDNnMeu2dzZuu3h5mPYLX3oWrKH6qM3wEnaL6Z4jaHx T3YRFk+L7MT+Lrwqq+7n9d8RtfCbbazncEcS4w3yt6dLZRcWwwPhGkJaoXp1VpJTDB0J ZHHxXWP/PWVptvU7pVyktePrL0JrNXLxpEJBlAtZXrJ0nN59q57qavVskwoeLw9i3wtS +a+7MYj61Wtx0pPDqM8rtsu/qhIYQ96QKA8KZStczb7M5SKH6ug2h82aN9HB7YKzigFK rLXg== 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=BBA1NG64/5TLBLCMBIsPT7OuaVblZH5y/WjnLqDq5V4=; b=tsRfIX1r1Fq/fMAi6ZZJ/b7a+GvbFYLGPig2xJ7Bo9vUpSSW3LQkkBTbKQF9GZ0jU4 MQB3PzuWiDzyEaA5jbmEmcGAaIHiotwcINWK4I4o/KBhRUFX8Pv0+3x0qtai4JuyaMPW bkQp2CNXecwVAw1d4uVvbOUHyVosVJXE50zj46TYdKqVO9qMo1mMAOWP2JGPGQaf75v9 K80iw3eWzLrM7k0n0GRzEGB2lkMOqpT+0JADTUa+4pR9F/mST9SM4PIBGtY2yVVaRzXc DW31m6qJOoe3yxoSUm7IbF8bCYL6TIPO4J2jw5qaQuZkEWKznZ4S6IoqqslT1dvcFrm/ Rtww== 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 v9si12256044plp.4.2019.06.25.01.52.58; Tue, 25 Jun 2019 01:53:13 -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 S1731029AbfFYIwA (ORCPT + 99 others); Tue, 25 Jun 2019 04:52:00 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35232 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727770AbfFYIwA (ORCPT ); Tue, 25 Jun 2019 04:52:00 -0400 Received: by mail-wr1-f67.google.com with SMTP id f15so6993285wrp.2 for ; Tue, 25 Jun 2019 01:51:58 -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=BBA1NG64/5TLBLCMBIsPT7OuaVblZH5y/WjnLqDq5V4=; b=lXno8TwCwsjyvbsT6Vvy0dlGk0bsX8fzu1FTFBe1XZ+te38LIk5YDcG1EsZChFFTAp QHKs3wnJZkPdLZsfMRwhD213SWzyYhVit8KGv+Rpz0zV04LIVtZaKStOMA7cd2yyd0pi IuNVcZRFHEQl+L8HBCv18AdXVKmwvtMUPcHI9zBYR5dPxQbBZTrSiJ9/E8r0qRzT+Kn8 NHQjC0bxZxAHX1p71qmPIymky9av/QPaNrdb4vP1nv4tcRNkVi8RSpOPx0uK3E0wq1gr 0/wLSwhK2YUWH+QpBUSNdpKuakH1jMqML3c4VVMDTLmh9ie9cm0SnO+ZL0uXBa1BdaEB 1wmA== X-Gm-Message-State: APjAAAWc3Zfpc+v1+dy2s4lE5g/3EONiKsa1JgrZLg3PL7TsUcmcoT81 mzq/UbsZoa4qPC44XFlGXZDNRyqYqKI= X-Received: by 2002:adf:afde:: with SMTP id y30mr52581369wrd.197.1561452718089; Tue, 25 Jun 2019 01:51:58 -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 y19sm2392289wmc.21.2019.06.25.01.51.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 01:51:57 -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> Date: Tue, 25 Jun 2019 10:51:56 +0200 Message-ID: <87lfxqdp3n.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 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. If you still dislike nested_enlightened_vmentry() having the side effect of fetching evmcs_ptr I can get rid of it by splitting the function into two, however, it will be less efficient for nested_vmx_handle_enlightened_vmptrld(). Or we can just leave things as they are there and use the newly introduced function in handle_vmclear() only. -- Vitaly