Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3621995ybd; Tue, 25 Jun 2019 05:54:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwA0XOe35n24YJ/8Y8D7zMAXhg67fpkZgHOsj98yCDiPmYH+75OV6MZ57mEteKKh0En+v0k X-Received: by 2002:a17:902:1566:: with SMTP id b35mr158294196plh.147.1561467259223; Tue, 25 Jun 2019 05:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561467259; cv=none; d=google.com; s=arc-20160816; b=j5qhkIiBO3w9qFIyI5zqGLvoaYEYcDY8xtWzQVj2ynfifJtaRSFIB4h50mp5mIoGF+ W3PFYNn24jK5VT+TxYU7pG1LJukW4XcBDa6+mb7zgOZ9TPbxAa9zKuCqDDMQC9b+4WSL 8vOgp++7qlT/5xKCNOyRPRt/ZPV03J248XTzVSHUBJxrZVu1v8xQ/Ox48cVXedZX1Wy5 T+YZNSvSXRf5lzWNgr3DF2KJYJwH5vyylPh2Og0UbcqR8zymT06RjtUmFYZ1YjNO3J7V X7LOjw6O0ZHVgvmuN49o3962GdLXXxuJyxfu049GlOyLmh/rFH50FgPVwv8dgk1U4B/3 0Vsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=B2zsKIoRAShW+y2NyCEXOSxGQYTAtwaazZmMjEodyZ8=; b=eRFDbWBcnEgkg0yEggXmh6aebCkiLNguHMNgqqoFwMAGeP5n948/jIY4QWfivJ0kNV ulyam6ftrhSj17QR9AsajnnWijJ5x5BzpQf6GWZ3T2aTiOcIrCZKEj+WT/JUoED7NYrH UM+Y3QjmGLy941IdvJuL6wSJT2rFldWTU6/t5owLevg4FGlAnadw0mpdarH+VfuSE58i wXOPjcR82LWNWSNxz1knQyqSZ0adpI2N7HLm+Qswo3gIvHUQozZouR8OOc71i6RpFWZB 67A+X+PXrXvggEm7mEwsA6AfPvtsllpymh7R0D6RbyXAmAdHFCp/jh7mpv34nYClyM9l aj4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=OCpLaY2I; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si285254pls.146.2019.06.25.05.54.03; Tue, 25 Jun 2019 05:54:19 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=OCpLaY2I; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729745AbfFYLCY (ORCPT + 99 others); Tue, 25 Jun 2019 07:02:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55968 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbfFYLCY (ORCPT ); Tue, 25 Jun 2019 07:02:24 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5PAxxMr177500; Tue, 25 Jun 2019 11:01:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2018-07-02; bh=B2zsKIoRAShW+y2NyCEXOSxGQYTAtwaazZmMjEodyZ8=; b=OCpLaY2IF7JosIlxBkL5z+C6J6pDZgAGpE5VAHMrOK0QoZyfAVntL3gJ0wbBqeALTtrV liu8QqcPTFm+zofwM6Km6G9TeVdiU4xkFKiGZfMwMqDracIOztM3/iN5Az6gDzv2Cd0N 0FwzYq4B/mKONmqBkrJf700Qx8OpQOQ/7jNy+L9SM2UX5dHjejKczUKTe1lTOncA84Em VZUab5EIESL2HXo2WHneToCz2fPIIcG2BLjsBxDGC/7azL1AcNRlajwo0U2t5ukBEX0E 7EMg729E4UuLtnWmfSamjWb4/tFLjrF8F5po4yea+VFPO2oj6/SbzlYjRrVXEpDgU7MV Fg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2t9brt3pd1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2019 11:01:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5PB030j010029; Tue, 25 Jun 2019 11:01:40 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2t99f3tbn0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2019 11:01:40 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5PB1drN020837; Tue, 25 Jun 2019 11:01:39 GMT Received: from [192.168.14.112] (/109.64.216.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 25 Jun 2019 04:01:39 -0700 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) Subject: Re: [PATCH] x86/kvm/nVMCS: fix VMCLEAR when Enlightened VMCS is in use From: Liran Alon In-Reply-To: <87lfxqdp3n.fsf@vitty.brq.redhat.com> Date: Tue, 25 Jun 2019 14:01:36 +0300 Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , =?utf-8?B?UmFkaW0gS3LEjW3DocWZ?= Content-Transfer-Encoding: quoted-printable Message-Id: References: <20190624133028.3710-1-vkuznets@redhat.com> <87lfxqdp3n.fsf@vitty.brq.redhat.com> To: Vitaly Kuznetsov X-Mailer: Apple Mail (2.3445.4.7) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9298 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906250089 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9298 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906250089 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 25 Jun 2019, at 11:51, Vitaly Kuznetsov = wrote: >=20 > Liran Alon writes: >=20 >>> On 24 Jun 2019, at 16:30, Vitaly Kuznetsov = wrote: >>>=20 >>>=20 >>> +bool nested_enlightened_vmentry(struct kvm_vcpu *vcpu, u64 *evmptr) >>=20 >> I prefer to rename evmptr to evmcs_ptr. I think it=E2=80=99s more = readable and sufficiently short. >> In addition, I think you should return either -1ull or = assist_page.current_nested_vmcs. >> i.e. Don=E2=80=99t return evmcs_ptr by pointer but instead as a = return-value >> and get rid of the bool. >=20 > 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=E2=80=99m 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. i.e. I thought about having this version of the method: +u64 nested_enlightened_vmentry(struct kvm_vcpu *vcpu) +{ + struct hv_vp_assist_page assist_page; + + if (unlikely(!kvm_hv_get_assist_page(vcpu, &assist_page))) + return -1ull; + + if (unlikely(!assist_page.enlighten_vmentry)) + return -1ull; + + return assist_page.current_nested_vmcs; +} + -Liran >=20 > 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. >=20 > --=20 > Vitaly