Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp421993ybl; Thu, 23 Jan 2020 00:57:37 -0800 (PST) X-Google-Smtp-Source: APXvYqx4uqTV9zfdwp/kasSZDNQ6ihUNVFkGufjEJZ9jhCdQfnXhcdU/oNc82OnC4softjoMs7z1 X-Received: by 2002:aca:1111:: with SMTP id 17mr9354026oir.37.1579769857215; Thu, 23 Jan 2020 00:57:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579769857; cv=none; d=google.com; s=arc-20160816; b=yvFOSeBGptZSAFYz3IeRLz0BQgXP0qbD084TV3h15G+IveW3EijuoAjwOsxaFPOZDY 0u/b4M+oJykQ2+oaPPkBRuT8xStjpGwcxdX8sDYpyIyujjvrxhoKQyByUnYtFvxvLwaM OQT5XfuP7w3Wj7dG19DgIELVRIu9FdYe9IA12V9iOtYzg3jyA3np+2eAfzYGfLg2n5cn IIMLMxrV1uBn0xO4fIEch/ffb2beVO1+bINrn4fB5FIIVrn3ajkpj8YLOKMDtnUuXpQ+ Z65HL/zUHtFyo5gxQS5bDxX4Ub7cJGoybVdqw7Z2J6/XRBAKv1SLfxdOXvskZvAFz0/D HnOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=Zk983o09Ptf4EhRmMF4WXJnJTt4L7VbNZwtev+QYBaI=; b=MO/svmG4Hy/TErLaHJXaX5+kGBc2tWhYRA9G+60JUCaqFG/QAcsH5w4AVxcu+fz8F5 Qpo3/pnzjHtsMNl1F7RVDrzvSYZt+BvZDXfgT6Xg8SFEEI9NikBd1nx+Oa1+jl182sQh XuRd06V0qvqTrooL0Ud4PiTTc/sHVXpMcpYx5/unS8BFu2jvWzt1PpleNKHcXSt+RNXE 4+uVF6lexFSkt9TmgVuaMdQABuvmTh3NGhlf1PYS/ZJEHiwV+YaPfETjkonCR6tou2XQ BddHRUmDnTSJcyioxY7GgcejfWBLyNlkFQ5gISsIERB/B5ks2nsgtWB9rsWJ8ex94ymB MMdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M1nx35rY; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t185si581669oib.39.2020.01.23.00.57.24; Thu, 23 Jan 2020 00:57:37 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=M1nx35rY; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728665AbgAWIzv (ORCPT + 99 others); Thu, 23 Jan 2020 03:55:51 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54867 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725785AbgAWIzu (ORCPT ); Thu, 23 Jan 2020 03:55:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579769749; 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: in-reply-to:in-reply-to:references:references; bh=Zk983o09Ptf4EhRmMF4WXJnJTt4L7VbNZwtev+QYBaI=; b=M1nx35rYQNnIzzYOvPGXUPgwYUXfz+WS4bh7uYbMxVDlAmshsldwJwH5OcNF3J9KlK0FrS QLC4+mOdurhC5YhR9pRajs6VfFMeFFbHBF5eNNOgPK90TZzKPlQxNdExUiC49Sz58VEtlP Ermqxn1VJQu2tjE13cXy+2ubOnsTFwU= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303-5X-cez6MPMS_tqKhQd6eSw-1; Thu, 23 Jan 2020 03:55:48 -0500 X-MC-Unique: 5X-cez6MPMS_tqKhQd6eSw-1 Received: by mail-wr1-f69.google.com with SMTP id z10so1382136wrt.21 for ; Thu, 23 Jan 2020 00:55:47 -0800 (PST) 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; bh=Zk983o09Ptf4EhRmMF4WXJnJTt4L7VbNZwtev+QYBaI=; b=kOc3uFFdKsLa2x5y0ovyEHHBhG1y1b8PBhuIbyTq/ZgpLG6DyCEeICNBqbnlMb8CtP 5KYsOz+n+oaslcY3DuwCyhW281M2PAXAnZNN4CVfkwMm/QzLTFvXnApAMOB7FFZ9MwKA 8iXuUi4TBGEbJ9hCVq9EcpjUNyI2dnEc7rGjMQ3YbrC8mvuZKSn0wtCOJLy5xGiL+p3c Riza+WNfo05UXZ81C+EJ7C2bU/BAyx3mzw5Aq/l/5Y9MZBtU7R1nzesu8nizpqJoCAuM f1uZcSeGF5d+gYMDCBfRBpfIf3XuZoFiIy24KOJE5jTUvbjaXmVeSlfkJBivh0AZEYTv 71DA== X-Gm-Message-State: APjAAAXwxdM8qgwn3vb8jjOLm05F+rfBrLM2rROq0wkeXNFtubtqu+7g w1P3mws8owqjZI0wvyIJqF9ZExpRpohQTuh806I6X8WPXpHKh7Wj06+U/nXynTxJGLZBoJTbv5G /R5MBfYXlA0uHP5Fd5te7+0hJ X-Received: by 2002:adf:ef4e:: with SMTP id c14mr16424022wrp.142.1579769747114; Thu, 23 Jan 2020 00:55:47 -0800 (PST) X-Received: by 2002:adf:ef4e:: with SMTP id c14mr16423996wrp.142.1579769746853; Thu, 23 Jan 2020 00:55:46 -0800 (PST) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id o2sm1258790wmh.46.2020.01.23.00.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 00:55:46 -0800 (PST) From: Vitaly Kuznetsov To: linmiaohe Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com Subject: Re: [PATCH] KVM: nVMX: set rflags to specify success in handle_invvpid() default case In-Reply-To: <1579749241-712-1-git-send-email-linmiaohe@huawei.com> References: <1579749241-712-1-git-send-email-linmiaohe@huawei.com> Date: Thu, 23 Jan 2020 09:55:44 +0100 Message-ID: <8736c6sga7.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org linmiaohe writes: > From: Miaohe Lin > > In handle_invvpid() default case, we just skip emulated instruction and > forget to set rflags to specify success. This would result in indefinite > rflags value and thus indeterminate return value for guest. > > Signed-off-by: Miaohe Lin > --- > Chinese New Year is coming. Happy Spring Festival! ^_^ Happy Spring Festival! > --- > arch/x86/kvm/vmx/nested.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index 7608924ee8c1..985d3307ec56 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -5165,7 +5165,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu) > break; > default: > WARN_ON_ONCE(1); > - return kvm_skip_emulated_instruction(vcpu); > + break; > } > > return nested_vmx_succeed(vcpu); Your patch seems to do the right thing, however, I started wondering if WARN_ON_ONCE() is the right thing to do. SDM says that "If an unsupported INVVPID type is specified, the instruction fails." and this is similar to INVEPT and I decided to check what handle_invept() does. Well, it does BUG_ON(). Are we doing the right thing in any of these cases? -- Vitaly