Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1500237ybf; Thu, 27 Feb 2020 12:11:30 -0800 (PST) X-Google-Smtp-Source: APXvYqwAfkjvdGG4jQ+PcI5+DIR5efehz2qoJtbWlVq30EwqctALXqOTSwcRrXkUHaCxx6UDlmHZ X-Received: by 2002:a05:6808:b15:: with SMTP id s21mr526829oij.123.1582834290477; Thu, 27 Feb 2020 12:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582834290; cv=none; d=google.com; s=arc-20160816; b=FW9TEMkSAUTn4VVcTwdkn1RsQYlzILvz+xPl8pj9dEWv6wgok/euS5tyFsbDdLZDpF VP2PlFrgcHLmLtlUB72LtMdVE5Td1F4P4dJOjvK+HqyRCENVycvNWKuOIWa13D1kvKdz 3YBA9zBQO9ZlQmbZhHXXH7OIna++/5tXvmGOqundYblWurJfEw6Pe5bIkdBKh6HfLwMQ sv/RixXuOupU16wHdU7xXNo29SxWSdnOyD62/7b5yvlA9vX1OfPao5nSOpb0rysW3B+n ixsoz3zVp9GHpTkUo+XdP8tfAlzsmlhF8xujAWv/lSji/WJzFFYTRY2h3/fqsPVp+hy0 kRWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=vTI3356UXLO6daiFtQpiwleqiIyVF/OpFewn1CjzkJE=; b=ghgkro+mKmGwmWmvp6ZiNye3oAaGhlEA60a0EA8x/uEYe8Sn/zjnFACLgVb23nnU27 4KX/3NeCJXgfXJrzdy8tDnh+eXwVIt5vrHgkFr4pYhdbv9yAhxhBoB/KjdyYubKUfAIY eF8ojAVu8PrbzCpGQoyYzIESIVYnrluNVKm+dDx/Oe2V6rzoIByT5KXB8N+2eC4ydLKl Wv/WWyrtU49Y81HoOUbv4f/SteqscS7qRv0QJ3Vj53mEdoAHw4kdP2uwItz0XrNt3gcK JcCS1MGn190DEpnrufNpomfeEjNukyM7C546A/WMkmoBD7/UL6HYu06HU0T007VUK3Fi y9zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=YkAA0quW; 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 b2si498305oic.205.2020.02.27.12.11.16; Thu, 27 Feb 2020 12:11:30 -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=@oracle.com header.s=corp-2020-01-29 header.b=YkAA0quW; 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 S1729816AbgB0UKw (ORCPT + 99 others); Thu, 27 Feb 2020 15:10:52 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:48066 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729737AbgB0UKw (ORCPT ); Thu, 27 Feb 2020 15:10:52 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01RJqje2016502; Thu, 27 Feb 2020 20:08:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=vTI3356UXLO6daiFtQpiwleqiIyVF/OpFewn1CjzkJE=; b=YkAA0quWcullrhDKmChBzEZLwyf6280JvYe130sYSu1xX5sWFUprxvm9hkIgAzF09Pqb ZrLJX5xxk3P2qlCMb6YxxN2n7u8SbiMv1M86QvB94OPJithlYzHfnYX+N7JKfl0GCuFr zv/myyCtNEkz44gGfcDaNSAap/stuo8QV1CNiSHKiUaINp0Ua/6eJVeXEzdvzfijhccO OptP/eLH1fVyvZawvLDz48Nq1cF0k508ni2XiuZA8gIU/ypWsW3wvACKJhjTHRJMHwRt 7W4adaStZfqyEM9y2r2kGYp/vHgYNQOfH6g6HGQwR0PbmF1Iwm2CY2H7cwhPQWy4AO8t 8g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2ydct3dcse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Feb 2020 20:08:59 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01RJm9SZ059733; Thu, 27 Feb 2020 20:08:59 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2ydj4ngmvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Feb 2020 20:08:59 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01RK8vNL021906; Thu, 27 Feb 2020 20:08:57 GMT Received: from localhost.localdomain (/10.159.246.46) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 27 Feb 2020 12:08:57 -0800 Subject: Re: [PATCH] KVM: nVMX: Consult only the "basic" exit reason when routing nested exit To: Sean Christopherson , Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li References: <20200227174430.26371-1-sean.j.christopherson@intel.com> From: Krish Sadhukhan Message-ID: Date: Thu, 27 Feb 2020 12:08:55 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20200227174430.26371-1-sean.j.christopherson@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9544 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002270137 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9544 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 spamscore=0 priorityscore=1501 malwarescore=0 adultscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002270137 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/27/20 9:44 AM, Sean Christopherson wrote: > Consult only the basic exit reason, i.e. bits 15:0 of vmcs.EXIT_REASON, > when determining whether a nested VM-Exit should be reflected into L1 or > handled by KVM in L0. > > For better or worse, the switch statement in nested_vmx_exit_reflected() > currently defaults to "true", i.e. reflects any nested VM-Exit without > dedicated logic. Because the case statements only contain the basic > exit reason, any VM-Exit with modifier bits set will be reflected to L1, > even if KVM intended to handle it in L0. > > Practically speaking, this only affects EXIT_REASON_MCE_DURING_VMENTRY, > i.e. a #MC that occurs on nested VM-Enter would be incorrectly routed to > L1, as "failed VM-Entry" is the only modifier that KVM can currently > encounter. The SMM modifiers will never be generated as KVM doesn't > support/employ a SMI Transfer Monitor. Ditto for "exit from enclave", > as KVM doesn't yet support virtualizing SGX, i.e. it's impossible to > enter an enclave in a KVM guest (L1 or L2). It seems nested_vmx_exit_reflected() deals only with the basic exit reason. If it doesn't need anything beyond bits 15:0, may be vmx_handle_exit() can pass just the base exit reason ? > > Fixes: 644d711aa0e1 ("KVM: nVMX: Deciding if L0 or L1 should handle an L2 exit") > Cc: Jim Mattson > Cc: Xiaoyao Li > Cc: stable@vger.kernel.org > Signed-off-by: Sean Christopherson > --- > 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 0946122a8d3b..127065bbde2c 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -5554,7 +5554,7 @@ bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason) > vmcs_read32(VM_EXIT_INTR_ERROR_CODE), > KVM_ISA_VMX); > > - switch (exit_reason) { > + switch ((u16)exit_reason) { > case EXIT_REASON_EXCEPTION_NMI: > if (is_nmi(intr_info)) > return false; Reviewed-by: Krish Sadhukhan