Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp458392ybl; Thu, 23 Jan 2020 01:46:37 -0800 (PST) X-Google-Smtp-Source: APXvYqzkfMF/AZJ6UsLwcO1myuoB59ursSTh8/hPWkQAl57yPi2Vss+Ii6g0PhXODp8QyheX/72G X-Received: by 2002:a9d:67ce:: with SMTP id c14mr10455168otn.106.1579772797752; Thu, 23 Jan 2020 01:46:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579772797; cv=none; d=google.com; s=arc-20160816; b=LOGUhN0Bo1Q1ayORDvUDL1iNZ86EL541SB8nrk0h5cpfKrtdm+ECKhbMAQoBMRdXLN KhORdTiDoSXWgvD2S6Ru6L+J2Xsb1fu6XbeAxAIRWj5+fub6Bt/qxgwaIKhTIa0aN0Fx XtWH0rtJKamU9cphdNdJIKLIS7MZ0uMoWp64XO4vF5Wykzs0+wcJyIwx4pXFoDgaD3PO PSk89D1qEXnJuX0pwH7mcihWPP/+OKItrGHdgSxdkuX4o/GyBe/ycSnc4ePUWmi1U7pd BmHlWSUglqiS9h8TPVzqOs9awxwYWUeLGZBlKPC6zaKh34c0RVomssGPfEgQE5Rq4ZK8 ECOQ== 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=MzX6+vB1Xsw4thPSPKllXzkIMMw9yMJ4EsBg/hWVsio=; b=uUsovQxBFsOPwUhgIX4AMH9TgCrPDvC97ex1jhpLc2vr8K1wWe/hX5gmyfDt1XmerO ViX16my6e7dnneSl8st3RPaWmCsQJ7McxhOA+gpqiryFmS0Er5tV2FvY3udejWhgm0d4 5r70DzQyc2Ohnx8pYIe4FWKiyo1PRqYEmIWV4bjDqDkmgfXRsnWGyUMDq8jvp6FJ9toD 0bM0riCHq9oYdw4rAaWRM8XCptYX17yMCofqNGkSw4IBwPj99pFGge+VveANOOIDGaBP zJ47mHk8SXUi499F3PCy9f5VSKv5tlytVHbIMbFih6kx2vCkx+7UN5CKndhghrF/MWFF HXsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X8hXKyjT; 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 a7si890774oti.135.2020.01.23.01.46.26; Thu, 23 Jan 2020 01:46: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=X8hXKyjT; 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 S1727264AbgAWJpV (ORCPT + 99 others); Thu, 23 Jan 2020 04:45:21 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:27436 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726885AbgAWJpU (ORCPT ); Thu, 23 Jan 2020 04:45:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579772719; 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=MzX6+vB1Xsw4thPSPKllXzkIMMw9yMJ4EsBg/hWVsio=; b=X8hXKyjTGFLdB1iJnyxrPFusY5mrxMi4MITekeLD3qPVEHXx1k5zVJyN/rs12eZB1+0Up+ m3JD20SOjXCQAx/mbHuUWXGK6QeRdu6KzFyBcycZPJMWHYMpNU/n0/8Gqg+Bn2j7VCitI+ /M9h4voDSe/k9T/lYyeTiz8m79804HE= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-85-1H301O7MOj25qqFp8h-iTg-1; Thu, 23 Jan 2020 04:45:16 -0500 X-MC-Unique: 1H301O7MOj25qqFp8h-iTg-1 Received: by mail-wr1-f71.google.com with SMTP id j4so1455161wrs.13 for ; Thu, 23 Jan 2020 01:45:16 -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=MzX6+vB1Xsw4thPSPKllXzkIMMw9yMJ4EsBg/hWVsio=; b=Ei+FZwipoVAl7V5pZblp9FYDUuh3Rs+yhZA7ZY5IubAloAUAYKVwJeMG0P2fDgn19G zMdCZLs3tC/cipDAVwIdqhkVeb/2iua8iSOUIN1bH0novaWcbx7Sr0wKqLbSSkQTJjtl XotM6IK7kCI556vEAs/Ly+2yiMhcfnS9TT3l0nbAVMeObOkGdVYmSdgASfvzrO5OiOP9 Ti6uK4W0vDrmmOmKwVMNpgyXLdpijyAuphlC5YgQSbuqdsPIgAXwP7YYTcMTbdthP13d NAWXn+NWtbsXNhsesnM5KageAW58tlyYsUgyvaTH2dWX6b4pV1OvCmXc1FJfxXWrDYLK uVzA== X-Gm-Message-State: APjAAAXNYTwkFGAQeUDQaHJv5roAEXABEIINikvnBx7HhcfQECY2OHYN pOTvmWvdCEuAKX9IrBrCI1xSnHiM6pIqqQoAc3yFr097V6aSeydx9kMOkpIXttEi2uMUfLJ2O5s hWl4nceK9YowmGa4BfwvPlq0E X-Received: by 2002:a1c:4144:: with SMTP id o65mr3109661wma.81.1579772715480; Thu, 23 Jan 2020 01:45:15 -0800 (PST) X-Received: by 2002:a1c:4144:: with SMTP id o65mr3109641wma.81.1579772715295; Thu, 23 Jan 2020 01:45:15 -0800 (PST) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id o15sm2251300wra.83.2020.01.23.01.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 01:45:14 -0800 (PST) From: Vitaly Kuznetsov To: Paolo Bonzini , linmiaohe Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, 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: <1a083ac8-3b01-fd2d-d867-2b3956cdef6d@redhat.com> References: <1579749241-712-1-git-send-email-linmiaohe@huawei.com> <8736c6sga7.fsf@vitty.brq.redhat.com> <1a083ac8-3b01-fd2d-d867-2b3956cdef6d@redhat.com> Date: Thu, 23 Jan 2020 10:45:13 +0100 Message-ID: <87wo9iqzfa.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 Paolo Bonzini writes: > On 23/01/20 09:55, Vitaly Kuznetsov wrote: >>> 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? > > Yes, both INVEPT and INVVPID catch this earlier. > > For INVEPT: > > types = (vmx->nested.msrs.ept_caps >> VMX_EPT_EXTENT_SHIFT) & 6; > > if (type >= 32 || !(types & (1 << type))) > return nested_vmx_failValid(vcpu, > VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); > > > > For INVVPID: > > types = (vmx->nested.msrs.vpid_caps & > VMX_VPID_EXTENT_SUPPORTED_MASK) >> 8; > > if (type >= 32 || !(types & (1 << type))) > return nested_vmx_failValid(vcpu, > VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); > Ah, true, thanks for checking! > So I'm leaning towards not applying Miaohe's patch. Well, we may at least want to converge on BUG_ON() for both handle_invvpid()/handle_invept(), there's no need for them to differ. -- Vitaly